1998-05-22 15:57:05 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: dialogs.h
|
|
|
|
// Purpose: Common dialogs demo
|
|
|
|
// Author: Julian Smart
|
2004-06-11 16:43:45 -04:00
|
|
|
// Modified by: ABX (2004) - adjustementd for conditional building
|
1998-05-22 15:57:05 -04:00
|
|
|
// Created: 04/01/98
|
|
|
|
// RCS-ID: $Id$
|
2003-03-17 06:55:54 -05:00
|
|
|
// Copyright: (c) Julian Smart
|
1999-07-22 19:39:47 -04:00
|
|
|
// Licence: wxWindows license
|
1998-05-22 15:57:05 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2004-09-16 14:35:43 -04:00
|
|
|
/*
|
2004-09-22 07:56:48 -04:00
|
|
|
This sample shows how to use the common dialogs available from wxWidgets.
|
2004-09-16 14:35:43 -04: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 07:56:48 -04: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 14:35:43 -04:00
|
|
|
of MSW, MAC and OS2
|
|
|
|
*/
|
|
|
|
|
1998-05-22 15:57:05 -04:00
|
|
|
#ifndef __DIALOGSH__
|
|
|
|
#define __DIALOGSH__
|
|
|
|
|
2004-06-23 05:39:42 -04:00
|
|
|
#ifdef __WXUNIVERSAL__
|
|
|
|
#define USE_WXUNIVERSAL 1
|
|
|
|
#else
|
|
|
|
#define USE_WXUNIVERSAL 0
|
|
|
|
#endif
|
|
|
|
|
2004-08-31 07:39:25 -04:00
|
|
|
#ifdef WXUSINGDLL
|
|
|
|
#define USE_DLL 1
|
|
|
|
#else
|
|
|
|
#define USE_DLL 0
|
|
|
|
#endif
|
|
|
|
|
2004-06-24 02:54:55 -04:00
|
|
|
#if defined(__WXMSW__) && !defined(__WXWINCE__)
|
2004-06-23 05:39:42 -04:00
|
|
|
#define USE_WXMSW 1
|
|
|
|
#else
|
|
|
|
#define USE_WXMSW 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
#define USE_WXMAC 1
|
|
|
|
#else
|
|
|
|
#define USE_WXMAC 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#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 06:49:36 -04:00
|
|
|
#define USE_GENERIC_DIALOGS (!USE_WXUNIVERSAL && !USE_DLL)
|
2004-06-11 16:43:45 -04:00
|
|
|
|
2004-09-08 06:49:36 -04: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 \
|
|
|
|
((USE_WXMSW || USE_WXPM) && USE_GENERIC_DIALOGS && wxUSE_FONTDLG)
|
2004-06-11 16:43:45 -04:00
|
|
|
|
2004-09-16 14:35:43 -04:00
|
|
|
|
2004-09-22 07:56:48 -04: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)
|
|
|
|
#if defined(__SMARTPHONE__)
|
|
|
|
#define USE_MODAL_PRESENTATION 0
|
|
|
|
#else
|
|
|
|
#define USE_MODAL_PRESENTATION 1
|
|
|
|
#endif
|
2004-09-16 14:35:43 -04:00
|
|
|
|
2004-06-11 16:43:45 -04:00
|
|
|
|
1998-05-22 15:57:05 -04:00
|
|
|
// Define a new application type
|
|
|
|
class MyApp: public wxApp
|
1999-07-22 19:39:47 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool OnInit();
|
1998-05-22 15:57:05 -04:00
|
|
|
|
|
|
|
wxFont m_canvasFont;
|
|
|
|
wxColour m_canvasTextColour;
|
|
|
|
};
|
|
|
|
|
2004-06-21 06:31:39 -04:00
|
|
|
#if USE_MODAL_PRESENTATION
|
|
|
|
|
2000-07-15 15:51:35 -04:00
|
|
|
// A custom modeless dialog
|
2000-01-29 20:33:02 -05:00
|
|
|
class MyModelessDialog : public wxDialog
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MyModelessDialog(wxWindow *parent);
|
2000-02-24 21:20:44 -05:00
|
|
|
|
2001-08-20 19:01:17 -04:00
|
|
|
void OnButton(wxCommandEvent& event);
|
2000-02-24 21:20:44 -05:00
|
|
|
void OnClose(wxCloseEvent& event);
|
|
|
|
|
|
|
|
private:
|
|
|
|
DECLARE_EVENT_TABLE()
|
2000-01-29 20:33:02 -05:00
|
|
|
};
|
|
|
|
|
2000-07-15 15:51:35 -04:00
|
|
|
// A custom modal dialog
|
|
|
|
class MyModalDialog : public wxDialog
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MyModalDialog(wxWindow *parent);
|
|
|
|
|
|
|
|
void OnButton(wxCommandEvent& event);
|
|
|
|
|
|
|
|
private:
|
2003-02-25 07:33:35 -05:00
|
|
|
wxButton *m_btnModal,
|
|
|
|
*m_btnModeless,
|
|
|
|
*m_btnDelete;
|
2000-07-15 15:51:35 -04:00
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
};
|
|
|
|
|
2004-06-21 06:31:39 -04:00
|
|
|
#endif // USE_MODAL_PRESENTATION
|
|
|
|
|
1998-05-22 15:57:05 -04:00
|
|
|
// Define a new frame type
|
|
|
|
class MyFrame: public wxFrame
|
1999-07-22 19:39:47 -04:00
|
|
|
{
|
|
|
|
public:
|
2004-06-11 16:43:45 -04:00
|
|
|
MyFrame(wxWindow *parent, const wxString& title);
|
|
|
|
|
|
|
|
void MessageBox(wxCommandEvent& event);
|
1998-05-22 15:57:05 -04:00
|
|
|
|
2004-06-11 16:43:45 -04:00
|
|
|
#if wxUSE_COLOURDLG
|
1999-07-03 12:40:54 -04:00
|
|
|
void ChooseColour(wxCommandEvent& event);
|
2004-06-11 16:43:45 -04:00
|
|
|
#endif // wxUSE_COLOURDLG
|
|
|
|
|
|
|
|
#if wxUSE_FONTDLG
|
1999-07-03 12:40:54 -04:00
|
|
|
void ChooseFont(wxCommandEvent& event);
|
2004-06-11 16:43:45 -04:00
|
|
|
#endif // wxUSE_FONTDLG
|
|
|
|
|
|
|
|
#if wxUSE_LOG_DIALOG
|
2000-01-20 21:31:49 -05:00
|
|
|
void LogDialog(wxCommandEvent& event);
|
2004-06-11 16:43:45 -04:00
|
|
|
#endif // wxUSE_LOG_DIALOG
|
|
|
|
|
|
|
|
#if wxUSE_CHOICEDLG
|
1998-05-22 15:57:05 -04:00
|
|
|
void SingleChoice(wxCommandEvent& event);
|
2000-11-03 15:52:17 -05:00
|
|
|
void MultiChoice(wxCommandEvent& event);
|
2004-06-11 16:43:45 -04:00
|
|
|
#endif // wxUSE_CHOICEDLG
|
|
|
|
|
|
|
|
#if wxUSE_TEXTDLG
|
1998-05-22 15:57:05 -04:00
|
|
|
void TextEntry(wxCommandEvent& event);
|
2000-01-24 13:26:54 -05:00
|
|
|
void PasswordEntry(wxCommandEvent& event);
|
2004-06-11 16:43:45 -04:00
|
|
|
#endif // wxUSE_TEXTDLG
|
|
|
|
|
|
|
|
#if wxUSE_NUMBERDLG
|
1999-07-22 19:39:47 -04:00
|
|
|
void NumericEntry(wxCommandEvent& event);
|
2004-06-11 16:43:45 -04:00
|
|
|
#endif // wxUSE_NUMBERDLG
|
|
|
|
|
|
|
|
#if wxUSE_FILEDLG
|
1998-05-22 15:57:05 -04:00
|
|
|
void FileOpen(wxCommandEvent& event);
|
2000-08-23 18:47:33 -04:00
|
|
|
void FileOpen2(wxCommandEvent& event);
|
1999-12-06 19:48:45 -05:00
|
|
|
void FilesOpen(wxCommandEvent& event);
|
1998-05-22 15:57:05 -04:00
|
|
|
void FileSave(wxCommandEvent& event);
|
2004-06-11 16:43:45 -04:00
|
|
|
#endif // wxUSE_FILEDLG
|
|
|
|
|
2004-06-16 11:03:44 -04:00
|
|
|
#if USE_FILEDLG_GENERIC
|
|
|
|
void FileOpenGeneric(wxCommandEvent& event);
|
|
|
|
void FilesOpenGeneric(wxCommandEvent& event);
|
|
|
|
void FileSaveGeneric(wxCommandEvent& event);
|
|
|
|
#endif // USE_FILEDLG_GENERIC
|
|
|
|
|
2004-06-11 16:43:45 -04:00
|
|
|
#if wxUSE_DIRDLG
|
1998-05-22 15:57:05 -04:00
|
|
|
void DirChoose(wxCommandEvent& event);
|
2003-02-01 17:51:07 -05:00
|
|
|
void DirChooseNew(wxCommandEvent& event);
|
2004-06-11 16:43:45 -04:00
|
|
|
#endif // wxUSE_DIRDLG
|
|
|
|
|
|
|
|
#if USE_DIRDLG_GENERIC
|
2000-07-23 15:10:27 -04:00
|
|
|
void GenericDirChoose(wxCommandEvent& event);
|
2004-06-11 16:43:45 -04:00
|
|
|
#endif // USE_DIRDLG_GENERIC
|
|
|
|
|
|
|
|
#if wxUSE_STARTUP_TIPS
|
1999-06-28 17:39:49 -04:00
|
|
|
void ShowTip(wxCommandEvent& event);
|
2004-06-11 16:43:45 -04:00
|
|
|
#endif // wxUSE_STARTUP_TIPS
|
|
|
|
|
|
|
|
#if USE_MODAL_PRESENTATION
|
2000-07-15 15:51:35 -04:00
|
|
|
void ModalDlg(wxCommandEvent& event);
|
2000-01-29 20:33:02 -05:00
|
|
|
void ModelessDlg(wxCommandEvent& event);
|
2004-06-11 16:43:45 -04:00
|
|
|
#endif // USE_MODAL_PRESENTATION
|
|
|
|
|
2001-07-31 22:29:35 -04:00
|
|
|
#if wxUSE_PROGRESSDLG
|
2000-02-24 21:20:44 -05:00
|
|
|
void ShowProgress(wxCommandEvent& event);
|
2001-07-31 22:29:35 -04:00
|
|
|
#endif // wxUSE_PROGRESSDLG
|
2004-06-11 16:43:45 -04:00
|
|
|
|
2001-10-29 08:21:29 -05:00
|
|
|
#if wxUSE_BUSYINFO
|
|
|
|
void ShowBusyInfo(wxCommandEvent& event);
|
|
|
|
#endif // wxUSE_BUSYINFO
|
2004-06-11 16:43:45 -04:00
|
|
|
|
2001-07-31 22:29:35 -04:00
|
|
|
#if wxUSE_FINDREPLDLG
|
|
|
|
void ShowFindDialog(wxCommandEvent& event);
|
|
|
|
void ShowReplaceDialog(wxCommandEvent& event);
|
|
|
|
void OnFindDialog(wxFindDialogEvent& event);
|
|
|
|
#endif // wxUSE_FINDREPLDLG
|
1998-05-22 15:57:05 -04:00
|
|
|
|
2004-06-11 16:43:45 -04:00
|
|
|
#if USE_COLOURDLG_GENERIC
|
1999-07-03 12:40:54 -04:00
|
|
|
void ChooseColourGeneric(wxCommandEvent& event);
|
2004-06-11 16:43:45 -04:00
|
|
|
#endif // USE_COLOURDLG_GENERIC
|
|
|
|
|
|
|
|
#if USE_FONTDLG_GENERIC
|
1999-07-03 12:40:54 -04:00
|
|
|
void ChooseFontGeneric(wxCommandEvent& event);
|
2004-06-11 16:43:45 -04:00
|
|
|
#endif // USE_FONTDLG_GENERIC
|
1999-07-22 19:39:47 -04:00
|
|
|
|
2004-09-08 06:49:36 -04:00
|
|
|
void OnRequestUserAttention(wxCommandEvent& event);
|
1999-07-03 12:40:54 -04:00
|
|
|
void OnExit(wxCommandEvent& event);
|
1999-07-22 19:39:47 -04:00
|
|
|
|
2000-01-29 20:33:02 -05:00
|
|
|
private:
|
2004-06-11 16:43:45 -04:00
|
|
|
#if wxUSE_DIRDLG
|
2003-02-01 17:51:07 -05:00
|
|
|
void DoDirChoose(int style);
|
2004-06-11 16:43:45 -04:00
|
|
|
#endif // wxUSE_DIRDLG
|
2003-02-01 17:51:07 -05:00
|
|
|
|
2004-06-11 16:43:45 -04:00
|
|
|
#if USE_MODAL_PRESENTATION
|
2000-01-29 20:33:02 -05:00
|
|
|
MyModelessDialog *m_dialog;
|
2004-06-11 16:43:45 -04:00
|
|
|
#endif // USE_MODAL_PRESENTATION
|
2000-01-29 20:33:02 -05:00
|
|
|
|
2001-07-31 22:29:35 -04:00
|
|
|
#if wxUSE_FINDREPLDLG
|
|
|
|
wxFindReplaceData m_findData;
|
2001-11-18 18:06:43 -05:00
|
|
|
|
|
|
|
wxFindReplaceDialog *m_dlgFind,
|
|
|
|
*m_dlgReplace;
|
2001-07-31 22:29:35 -04:00
|
|
|
#endif // wxUSE_FINDREPLDLG
|
|
|
|
|
2004-06-04 11:57:12 -04:00
|
|
|
wxColourData m_clrData;
|
|
|
|
|
2000-01-29 20:33:02 -05:00
|
|
|
DECLARE_EVENT_TABLE()
|
1998-05-22 15:57:05 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
class MyCanvas: public wxScrolledWindow
|
|
|
|
{
|
1999-07-22 19:39:47 -04:00
|
|
|
public:
|
2004-09-22 07:56:48 -04:00
|
|
|
MyCanvas(wxWindow *parent) :
|
2004-06-11 16:43:45 -04:00
|
|
|
wxScrolledWindow(parent,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxNO_FULL_REPAINT_ON_RESIZE) { }
|
1999-07-22 19:39:47 -04:00
|
|
|
|
|
|
|
void OnPaint(wxPaintEvent& event);
|
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
1998-05-22 15:57:05 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Menu IDs
|
2000-01-24 13:26:54 -05:00
|
|
|
enum
|
|
|
|
{
|
2004-06-11 16:43:45 -04:00
|
|
|
DIALOGS_CHOOSE_COLOUR = wxID_HIGHEST,
|
2000-01-24 13:26:54 -05:00
|
|
|
DIALOGS_CHOOSE_COLOUR_GENERIC,
|
|
|
|
DIALOGS_CHOOSE_FONT,
|
|
|
|
DIALOGS_CHOOSE_FONT_GENERIC,
|
|
|
|
DIALOGS_MESSAGE_BOX,
|
|
|
|
DIALOGS_SINGLE_CHOICE,
|
2000-11-03 15:52:17 -05:00
|
|
|
DIALOGS_MULTI_CHOICE,
|
2000-01-24 13:26:54 -05:00
|
|
|
DIALOGS_TEXT_ENTRY,
|
|
|
|
DIALOGS_PASSWORD_ENTRY,
|
|
|
|
DIALOGS_FILE_OPEN,
|
2000-08-23 18:47:33 -04:00
|
|
|
DIALOGS_FILE_OPEN2,
|
2000-01-24 13:26:54 -05:00
|
|
|
DIALOGS_FILES_OPEN,
|
|
|
|
DIALOGS_FILE_SAVE,
|
2004-06-16 11:03:44 -04:00
|
|
|
DIALOGS_FILE_OPEN_GENERIC,
|
|
|
|
DIALOGS_FILES_OPEN_GENERIC,
|
|
|
|
DIALOGS_FILE_SAVE_GENERIC,
|
2000-01-24 13:26:54 -05:00
|
|
|
DIALOGS_DIR_CHOOSE,
|
2003-02-01 17:51:07 -05:00
|
|
|
DIALOGS_DIRNEW_CHOOSE,
|
2000-07-23 15:10:27 -04:00
|
|
|
DIALOGS_GENERIC_DIR_CHOOSE,
|
2000-01-24 13:26:54 -05:00
|
|
|
DIALOGS_TIP,
|
|
|
|
DIALOGS_NUM_ENTRY,
|
2000-01-29 20:33:02 -05:00
|
|
|
DIALOGS_LOG_DIALOG,
|
2000-07-15 15:51:35 -04:00
|
|
|
DIALOGS_MODAL,
|
2000-01-29 20:33:02 -05:00
|
|
|
DIALOGS_MODELESS,
|
2000-02-24 21:20:44 -05:00
|
|
|
DIALOGS_MODELESS_BTN,
|
2001-07-31 22:29:35 -04:00
|
|
|
DIALOGS_PROGRESS,
|
2001-10-29 08:21:29 -05:00
|
|
|
DIALOGS_BUSYINFO,
|
2001-07-31 22:29:35 -04:00
|
|
|
DIALOGS_FIND,
|
2004-09-08 06:49:36 -04:00
|
|
|
DIALOGS_REPLACE,
|
|
|
|
DIALOGS_REQUEST
|
2000-01-24 13:26:54 -05:00
|
|
|
};
|
1998-05-22 15:57:05 -04:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|