1998-05-22 19:57:05 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: dialogs.h
|
|
|
|
// Purpose: Common dialogs demo
|
|
|
|
// Author: Julian Smart
|
2004-06-11 20:43:45 +00:00
|
|
|
// Modified by: ABX (2004) - adjustementd for conditional building
|
1998-05-22 19:57:05 +00:00
|
|
|
// Created: 04/01/98
|
|
|
|
// RCS-ID: $Id$
|
2003-03-17 11:55:54 +00:00
|
|
|
// Copyright: (c) Julian Smart
|
1999-07-22 23:39:47 +00:00
|
|
|
// Licence: wxWindows license
|
1998-05-22 19:57:05 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2004-09-16 18:35:43 +00:00
|
|
|
/*
|
2004-09-22 11:56:48 +00:00
|
|
|
This sample shows how to use the common dialogs available from wxWidgets.
|
2004-09-16 18:35:43 +00:00
|
|
|
It also shows that generic implementations of common dialogs can be exchanged
|
|
|
|
with native dialogs and can coexist in one application. The need for generic
|
|
|
|
dialogs addition is recognized thanks to setup of below USE_*** setting. Their
|
2004-09-22 11:56:48 +00:00
|
|
|
combinations reflects conditions of makefiles and project files to avoid unresolved
|
|
|
|
references during linking. For now some generic dialogs are added in static builds
|
2004-09-16 18:35:43 +00:00
|
|
|
of MSW, MAC and OS2
|
|
|
|
*/
|
|
|
|
|
1998-05-22 19:57:05 +00:00
|
|
|
#ifndef __DIALOGSH__
|
|
|
|
#define __DIALOGSH__
|
|
|
|
|
2004-06-23 09:39:42 +00:00
|
|
|
#ifdef __WXUNIVERSAL__
|
|
|
|
#define USE_WXUNIVERSAL 1
|
|
|
|
#else
|
|
|
|
#define USE_WXUNIVERSAL 0
|
|
|
|
#endif
|
|
|
|
|
2004-08-31 11:39:25 +00:00
|
|
|
#ifdef WXUSINGDLL
|
|
|
|
#define USE_DLL 1
|
|
|
|
#else
|
|
|
|
#define USE_DLL 0
|
|
|
|
#endif
|
|
|
|
|
2004-06-24 06:54:55 +00:00
|
|
|
#if defined(__WXMSW__) && !defined(__WXWINCE__)
|
2004-06-23 09:39:42 +00:00
|
|
|
#define USE_WXMSW 1
|
|
|
|
#else
|
|
|
|
#define USE_WXMSW 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
#define USE_WXMAC 1
|
|
|
|
#else
|
|
|
|
#define USE_WXMAC 0
|
|
|
|
#endif
|
|
|
|
|
2004-10-01 01:57:31 +00:00
|
|
|
#if defined(__WXMAC_OSX__) && ( MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_2) && USE_NATIVE_FONT_DIALOG_FOR_MACOSX
|
2004-09-27 13:14:22 +00:00
|
|
|
#define USE_WXMACFONTDLG 1
|
|
|
|
#else
|
|
|
|
#define USE_WXMACFONTDLG 0
|
|
|
|
#endif
|
|
|
|
|
2004-06-23 09:39:42 +00:00
|
|
|
#ifdef __WXGTK__
|
|
|
|
#define USE_WXGTK 1
|
|
|
|
#else
|
|
|
|
#define USE_WXGTK 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __WXPM__
|
|
|
|
#define USE_WXPM 1
|
|
|
|
#else
|
|
|
|
#define USE_WXPM 0
|
|
|
|
#endif
|
|
|
|
|
2004-09-08 10:49:36 +00:00
|
|
|
#define USE_GENERIC_DIALOGS (!USE_WXUNIVERSAL && !USE_DLL)
|
2004-06-11 20:43:45 +00:00
|
|
|
|
2004-09-08 10:49:36 +00:00
|
|
|
#define USE_COLOURDLG_GENERIC \
|
|
|
|
((USE_WXMSW || USE_WXMAC) && USE_GENERIC_DIALOGS && wxUSE_COLOURDLG)
|
|
|
|
#define USE_DIRDLG_GENERIC \
|
|
|
|
((USE_WXMSW || USE_WXMAC) && USE_GENERIC_DIALOGS && wxUSE_DIRDLG)
|
|
|
|
#define USE_FILEDLG_GENERIC \
|
|
|
|
((USE_WXMSW || USE_WXMAC || USE_WXPM) && USE_GENERIC_DIALOGS && wxUSE_FILEDLG)
|
|
|
|
#define USE_FONTDLG_GENERIC \
|
2004-09-27 13:14:22 +00:00
|
|
|
((USE_WXMSW || USE_WXMACFONTDLG ||USE_WXPM) && USE_GENERIC_DIALOGS && wxUSE_FONTDLG)
|
2004-06-11 20:43:45 +00:00
|
|
|
|
2004-09-16 18:35:43 +00:00
|
|
|
|
2004-09-22 11:56:48 +00:00
|
|
|
// Turn USE_MODAL_PRESENTATION to 0 if there is any reason for not presenting difference
|
|
|
|
// between modal and modeless dialogs (ie. not implemented it in your port yet)
|
2005-06-10 17:53:19 +00:00
|
|
|
#if defined(__SMARTPHONE__) || !wxUSE_BOOKCTRL
|
2004-09-22 11:56:48 +00:00
|
|
|
#define USE_MODAL_PRESENTATION 0
|
|
|
|
#else
|
|
|
|
#define USE_MODAL_PRESENTATION 1
|
|
|
|
#endif
|
2004-09-16 18:35:43 +00:00
|
|
|
|
2004-06-11 20:43:45 +00:00
|
|
|
|
2005-06-10 17:53:19 +00:00
|
|
|
// Turn USE_SETTINGS_DIALOG to 0 if supported
|
|
|
|
#if wxUSE_BOOKCTRL
|
|
|
|
#define USE_SETTINGS_DIALOG 1
|
|
|
|
#else
|
|
|
|
#define USE_SETTINGS_DIALOG 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
1998-05-22 19:57:05 +00:00
|
|
|
// Define a new application type
|
|
|
|
class MyApp: public wxApp
|
1999-07-22 23:39:47 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool OnInit();
|
1998-05-22 19:57:05 +00:00
|
|
|
|
|
|
|
wxFont m_canvasFont;
|
|
|
|
wxColour m_canvasTextColour;
|
|
|
|
};
|
|
|
|
|
2004-06-21 10:31:39 +00:00
|
|
|
#if USE_MODAL_PRESENTATION
|
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
// A custom modeless dialog
|
2000-01-30 01:33:02 +00:00
|
|
|
class MyModelessDialog : public wxDialog
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MyModelessDialog(wxWindow *parent);
|
2000-02-25 02:20:44 +00:00
|
|
|
|
2001-08-20 23:01:17 +00:00
|
|
|
void OnButton(wxCommandEvent& event);
|
2000-02-25 02:20:44 +00:00
|
|
|
void OnClose(wxCloseEvent& event);
|
|
|
|
|
|
|
|
private:
|
|
|
|
DECLARE_EVENT_TABLE()
|
2000-01-30 01:33:02 +00:00
|
|
|
};
|
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
// A custom modal dialog
|
|
|
|
class MyModalDialog : public wxDialog
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MyModalDialog(wxWindow *parent);
|
|
|
|
|
|
|
|
void OnButton(wxCommandEvent& event);
|
|
|
|
|
|
|
|
private:
|
2003-02-25 12:33:35 +00:00
|
|
|
wxButton *m_btnModal,
|
|
|
|
*m_btnModeless,
|
|
|
|
*m_btnDelete;
|
2000-07-15 19:51:35 +00:00
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
};
|
|
|
|
|
2004-06-21 10:31:39 +00:00
|
|
|
#endif // USE_MODAL_PRESENTATION
|
|
|
|
|
2005-06-10 17:53:19 +00:00
|
|
|
#if USE_SETTINGS_DIALOG
|
2005-04-01 14:27:55 +00:00
|
|
|
// Property sheet dialog
|
|
|
|
class SettingsDialog: public wxPropertySheetDialog
|
|
|
|
{
|
|
|
|
DECLARE_CLASS(SettingsDialog)
|
|
|
|
public:
|
2006-01-31 13:54:17 +00:00
|
|
|
SettingsDialog(wxWindow* parent, bool useToolBook = false);
|
|
|
|
~SettingsDialog();
|
2005-04-01 14:27:55 +00:00
|
|
|
|
|
|
|
wxPanel* CreateGeneralSettingsPage(wxWindow* parent);
|
|
|
|
wxPanel* CreateAestheticSettingsPage(wxWindow* parent);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
enum {
|
|
|
|
ID_SHOW_TOOLTIPS = 100,
|
|
|
|
ID_AUTO_SAVE,
|
|
|
|
ID_AUTO_SAVE_MINS,
|
|
|
|
ID_LOAD_LAST_PROJECT,
|
|
|
|
|
|
|
|
ID_APPLY_SETTINGS_TO,
|
|
|
|
ID_BACKGROUND_STYLE,
|
|
|
|
ID_FONT_SIZE
|
|
|
|
};
|
|
|
|
|
2006-01-31 13:54:17 +00:00
|
|
|
wxImageList* m_imageList;
|
|
|
|
|
2005-04-01 14:27:55 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
};
|
|
|
|
|
2005-06-10 17:53:19 +00:00
|
|
|
#endif // USE_SETTINGS_DIALOG
|
|
|
|
|
1998-05-22 19:57:05 +00:00
|
|
|
// Define a new frame type
|
|
|
|
class MyFrame: public wxFrame
|
1999-07-22 23:39:47 +00:00
|
|
|
{
|
|
|
|
public:
|
2004-06-11 20:43:45 +00:00
|
|
|
MyFrame(wxWindow *parent, const wxString& title);
|
|
|
|
|
|
|
|
void MessageBox(wxCommandEvent& event);
|
1998-05-22 19:57:05 +00:00
|
|
|
|
2004-06-11 20:43:45 +00:00
|
|
|
#if wxUSE_COLOURDLG
|
1999-07-03 16:40:54 +00:00
|
|
|
void ChooseColour(wxCommandEvent& event);
|
2004-06-11 20:43:45 +00:00
|
|
|
#endif // wxUSE_COLOURDLG
|
|
|
|
|
|
|
|
#if wxUSE_FONTDLG
|
1999-07-03 16:40:54 +00:00
|
|
|
void ChooseFont(wxCommandEvent& event);
|
2004-06-11 20:43:45 +00:00
|
|
|
#endif // wxUSE_FONTDLG
|
|
|
|
|
|
|
|
#if wxUSE_LOG_DIALOG
|
2000-01-21 02:31:49 +00:00
|
|
|
void LogDialog(wxCommandEvent& event);
|
2004-06-11 20:43:45 +00:00
|
|
|
#endif // wxUSE_LOG_DIALOG
|
|
|
|
|
|
|
|
#if wxUSE_CHOICEDLG
|
1998-05-22 19:57:05 +00:00
|
|
|
void SingleChoice(wxCommandEvent& event);
|
2000-11-03 20:52:17 +00:00
|
|
|
void MultiChoice(wxCommandEvent& event);
|
2004-06-11 20:43:45 +00:00
|
|
|
#endif // wxUSE_CHOICEDLG
|
|
|
|
|
|
|
|
#if wxUSE_TEXTDLG
|
1998-05-22 19:57:05 +00:00
|
|
|
void TextEntry(wxCommandEvent& event);
|
2000-01-24 18:26:54 +00:00
|
|
|
void PasswordEntry(wxCommandEvent& event);
|
2004-06-11 20:43:45 +00:00
|
|
|
#endif // wxUSE_TEXTDLG
|
|
|
|
|
|
|
|
#if wxUSE_NUMBERDLG
|
1999-07-22 23:39:47 +00:00
|
|
|
void NumericEntry(wxCommandEvent& event);
|
2004-06-11 20:43:45 +00:00
|
|
|
#endif // wxUSE_NUMBERDLG
|
|
|
|
|
|
|
|
#if wxUSE_FILEDLG
|
1998-05-22 19:57:05 +00:00
|
|
|
void FileOpen(wxCommandEvent& event);
|
2000-08-23 22:47:33 +00:00
|
|
|
void FileOpen2(wxCommandEvent& event);
|
1999-12-07 00:48:45 +00:00
|
|
|
void FilesOpen(wxCommandEvent& event);
|
1998-05-22 19:57:05 +00:00
|
|
|
void FileSave(wxCommandEvent& event);
|
2004-06-11 20:43:45 +00:00
|
|
|
#endif // wxUSE_FILEDLG
|
|
|
|
|
2004-06-16 15:03:44 +00:00
|
|
|
#if USE_FILEDLG_GENERIC
|
|
|
|
void FileOpenGeneric(wxCommandEvent& event);
|
|
|
|
void FilesOpenGeneric(wxCommandEvent& event);
|
|
|
|
void FileSaveGeneric(wxCommandEvent& event);
|
|
|
|
#endif // USE_FILEDLG_GENERIC
|
|
|
|
|
2004-06-11 20:43:45 +00:00
|
|
|
#if wxUSE_DIRDLG
|
1998-05-22 19:57:05 +00:00
|
|
|
void DirChoose(wxCommandEvent& event);
|
2003-02-01 22:51:07 +00:00
|
|
|
void DirChooseNew(wxCommandEvent& event);
|
2004-06-11 20:43:45 +00:00
|
|
|
#endif // wxUSE_DIRDLG
|
|
|
|
|
|
|
|
#if USE_DIRDLG_GENERIC
|
2000-07-23 19:10:27 +00:00
|
|
|
void GenericDirChoose(wxCommandEvent& event);
|
2004-06-11 20:43:45 +00:00
|
|
|
#endif // USE_DIRDLG_GENERIC
|
|
|
|
|
|
|
|
#if wxUSE_STARTUP_TIPS
|
1999-06-28 21:39:49 +00:00
|
|
|
void ShowTip(wxCommandEvent& event);
|
2004-06-11 20:43:45 +00:00
|
|
|
#endif // wxUSE_STARTUP_TIPS
|
|
|
|
|
|
|
|
#if USE_MODAL_PRESENTATION
|
2000-07-15 19:51:35 +00:00
|
|
|
void ModalDlg(wxCommandEvent& event);
|
2000-01-30 01:33:02 +00:00
|
|
|
void ModelessDlg(wxCommandEvent& event);
|
2004-06-11 20:43:45 +00:00
|
|
|
#endif // USE_MODAL_PRESENTATION
|
|
|
|
|
2001-08-01 02:29:35 +00:00
|
|
|
#if wxUSE_PROGRESSDLG
|
2000-02-25 02:20:44 +00:00
|
|
|
void ShowProgress(wxCommandEvent& event);
|
2001-08-01 02:29:35 +00:00
|
|
|
#endif // wxUSE_PROGRESSDLG
|
2004-06-11 20:43:45 +00:00
|
|
|
|
2001-10-29 13:21:29 +00:00
|
|
|
#if wxUSE_BUSYINFO
|
|
|
|
void ShowBusyInfo(wxCommandEvent& event);
|
|
|
|
#endif // wxUSE_BUSYINFO
|
2004-06-11 20:43:45 +00:00
|
|
|
|
2001-08-01 02:29:35 +00:00
|
|
|
#if wxUSE_FINDREPLDLG
|
|
|
|
void ShowFindDialog(wxCommandEvent& event);
|
|
|
|
void ShowReplaceDialog(wxCommandEvent& event);
|
|
|
|
void OnFindDialog(wxFindDialogEvent& event);
|
|
|
|
#endif // wxUSE_FINDREPLDLG
|
1998-05-22 19:57:05 +00:00
|
|
|
|
2004-06-11 20:43:45 +00:00
|
|
|
#if USE_COLOURDLG_GENERIC
|
1999-07-03 16:40:54 +00:00
|
|
|
void ChooseColourGeneric(wxCommandEvent& event);
|
2004-06-11 20:43:45 +00:00
|
|
|
#endif // USE_COLOURDLG_GENERIC
|
|
|
|
|
|
|
|
#if USE_FONTDLG_GENERIC
|
1999-07-03 16:40:54 +00:00
|
|
|
void ChooseFontGeneric(wxCommandEvent& event);
|
2004-06-11 20:43:45 +00:00
|
|
|
#endif // USE_FONTDLG_GENERIC
|
1999-07-22 23:39:47 +00:00
|
|
|
|
2005-04-01 14:27:55 +00:00
|
|
|
void OnPropertySheet(wxCommandEvent& event);
|
2006-01-31 13:54:17 +00:00
|
|
|
void OnPropertySheetToolBook(wxCommandEvent& event);
|
2004-09-08 10:49:36 +00:00
|
|
|
void OnRequestUserAttention(wxCommandEvent& event);
|
1999-07-03 16:40:54 +00:00
|
|
|
void OnExit(wxCommandEvent& event);
|
1999-07-22 23:39:47 +00:00
|
|
|
|
2000-01-30 01:33:02 +00:00
|
|
|
private:
|
2004-06-11 20:43:45 +00:00
|
|
|
#if wxUSE_DIRDLG
|
2003-02-01 22:51:07 +00:00
|
|
|
void DoDirChoose(int style);
|
2004-06-11 20:43:45 +00:00
|
|
|
#endif // wxUSE_DIRDLG
|
2003-02-01 22:51:07 +00:00
|
|
|
|
2004-06-11 20:43:45 +00:00
|
|
|
#if USE_MODAL_PRESENTATION
|
2000-01-30 01:33:02 +00:00
|
|
|
MyModelessDialog *m_dialog;
|
2004-06-11 20:43:45 +00:00
|
|
|
#endif // USE_MODAL_PRESENTATION
|
2000-01-30 01:33:02 +00:00
|
|
|
|
2001-08-01 02:29:35 +00:00
|
|
|
#if wxUSE_FINDREPLDLG
|
|
|
|
wxFindReplaceData m_findData;
|
2001-11-18 23:06:43 +00:00
|
|
|
|
|
|
|
wxFindReplaceDialog *m_dlgFind,
|
|
|
|
*m_dlgReplace;
|
2001-08-01 02:29:35 +00:00
|
|
|
#endif // wxUSE_FINDREPLDLG
|
|
|
|
|
2004-06-04 15:57:12 +00:00
|
|
|
wxColourData m_clrData;
|
|
|
|
|
2000-01-30 01:33:02 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
1998-05-22 19:57:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class MyCanvas: public wxScrolledWindow
|
|
|
|
{
|
1999-07-22 23:39:47 +00:00
|
|
|
public:
|
2004-09-22 11:56:48 +00:00
|
|
|
MyCanvas(wxWindow *parent) :
|
2004-06-11 20:43:45 +00:00
|
|
|
wxScrolledWindow(parent,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxNO_FULL_REPAINT_ON_RESIZE) { }
|
1999-07-22 23:39:47 +00:00
|
|
|
|
|
|
|
void OnPaint(wxPaintEvent& event);
|
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
1998-05-22 19:57:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Menu IDs
|
2000-01-24 18:26:54 +00:00
|
|
|
enum
|
|
|
|
{
|
2004-06-11 20:43:45 +00:00
|
|
|
DIALOGS_CHOOSE_COLOUR = wxID_HIGHEST,
|
2000-01-24 18:26:54 +00:00
|
|
|
DIALOGS_CHOOSE_COLOUR_GENERIC,
|
|
|
|
DIALOGS_CHOOSE_FONT,
|
|
|
|
DIALOGS_CHOOSE_FONT_GENERIC,
|
|
|
|
DIALOGS_MESSAGE_BOX,
|
|
|
|
DIALOGS_SINGLE_CHOICE,
|
2000-11-03 20:52:17 +00:00
|
|
|
DIALOGS_MULTI_CHOICE,
|
2000-01-24 18:26:54 +00:00
|
|
|
DIALOGS_TEXT_ENTRY,
|
|
|
|
DIALOGS_PASSWORD_ENTRY,
|
|
|
|
DIALOGS_FILE_OPEN,
|
2000-08-23 22:47:33 +00:00
|
|
|
DIALOGS_FILE_OPEN2,
|
2000-01-24 18:26:54 +00:00
|
|
|
DIALOGS_FILES_OPEN,
|
|
|
|
DIALOGS_FILE_SAVE,
|
2004-06-16 15:03:44 +00:00
|
|
|
DIALOGS_FILE_OPEN_GENERIC,
|
|
|
|
DIALOGS_FILES_OPEN_GENERIC,
|
|
|
|
DIALOGS_FILE_SAVE_GENERIC,
|
2000-01-24 18:26:54 +00:00
|
|
|
DIALOGS_DIR_CHOOSE,
|
2003-02-01 22:51:07 +00:00
|
|
|
DIALOGS_DIRNEW_CHOOSE,
|
2000-07-23 19:10:27 +00:00
|
|
|
DIALOGS_GENERIC_DIR_CHOOSE,
|
2000-01-24 18:26:54 +00:00
|
|
|
DIALOGS_TIP,
|
|
|
|
DIALOGS_NUM_ENTRY,
|
2000-01-30 01:33:02 +00:00
|
|
|
DIALOGS_LOG_DIALOG,
|
2000-07-15 19:51:35 +00:00
|
|
|
DIALOGS_MODAL,
|
2000-01-30 01:33:02 +00:00
|
|
|
DIALOGS_MODELESS,
|
2000-02-25 02:20:44 +00:00
|
|
|
DIALOGS_MODELESS_BTN,
|
2001-08-01 02:29:35 +00:00
|
|
|
DIALOGS_PROGRESS,
|
2001-10-29 13:21:29 +00:00
|
|
|
DIALOGS_BUSYINFO,
|
2001-08-01 02:29:35 +00:00
|
|
|
DIALOGS_FIND,
|
2004-09-08 10:49:36 +00:00
|
|
|
DIALOGS_REPLACE,
|
2005-04-01 14:27:55 +00:00
|
|
|
DIALOGS_REQUEST,
|
2006-01-31 13:54:17 +00:00
|
|
|
DIALOGS_PROPERTY_SHEET,
|
|
|
|
DIALOGS_PROPERTY_SHEET_TOOLBOOK
|
2000-01-24 18:26:54 +00:00
|
|
|
};
|
1998-05-22 19:57:05 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|