]> git.saurik.com Git - wxWidgets.git/blame - samples/dialogs/dialogs.h
IOKit framework now req. under darwin
[wxWidgets.git] / samples / dialogs / dialogs.h
CommitLineData
457814b5
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: dialogs.h
3// Purpose: Common dialogs demo
4// Author: Julian Smart
13188def 5// Modified by: ABX (2004) - adjustementd for conditional building
457814b5
JS
6// Created: 04/01/98
7// RCS-ID: $Id$
6aa89a22 8// Copyright: (c) Julian Smart
c49245f8 9// Licence: wxWindows license
457814b5
JS
10/////////////////////////////////////////////////////////////////////////////
11
4c8fc4d6 12/*
08375332 13This sample shows how to use the common dialogs available from wxWidgets.
4c8fc4d6
WS
14It also shows that generic implementations of common dialogs can be exchanged
15with native dialogs and can coexist in one application. The need for generic
16dialogs addition is recognized thanks to setup of below USE_*** setting. Their
08375332
WS
17combinations reflects conditions of makefiles and project files to avoid unresolved
18references during linking. For now some generic dialogs are added in static builds
4c8fc4d6
WS
19of MSW, MAC and OS2
20*/
21
457814b5
JS
22#ifndef __DIALOGSH__
23#define __DIALOGSH__
24
da7a8602
WS
25#ifdef __WXUNIVERSAL__
26 #define USE_WXUNIVERSAL 1
27#else
28 #define USE_WXUNIVERSAL 0
29#endif
30
f50ff87b
WS
31#ifdef WXUSINGDLL
32 #define USE_DLL 1
33#else
34 #define USE_DLL 0
35#endif
36
b6352c09 37#if defined(__WXMSW__) && !defined(__WXWINCE__)
da7a8602
WS
38 #define USE_WXMSW 1
39#else
40 #define USE_WXMSW 0
41#endif
42
43#ifdef __WXMAC__
44 #define USE_WXMAC 1
45#else
46 #define USE_WXMAC 0
47#endif
48
49#ifdef __WXGTK__
50 #define USE_WXGTK 1
51#else
52 #define USE_WXGTK 0
53#endif
54
55#ifdef __WXPM__
56 #define USE_WXPM 1
57#else
58 #define USE_WXPM 0
59#endif
60
29e3d1f9 61#define USE_GENERIC_DIALOGS (!USE_WXUNIVERSAL && !USE_DLL)
13188def 62
29e3d1f9
VZ
63#define USE_COLOURDLG_GENERIC \
64 ((USE_WXMSW || USE_WXMAC) && USE_GENERIC_DIALOGS && wxUSE_COLOURDLG)
65#define USE_DIRDLG_GENERIC \
66 ((USE_WXMSW || USE_WXMAC) && USE_GENERIC_DIALOGS && wxUSE_DIRDLG)
67#define USE_FILEDLG_GENERIC \
68 ((USE_WXMSW || USE_WXMAC || USE_WXPM) && USE_GENERIC_DIALOGS && wxUSE_FILEDLG)
69#define USE_FONTDLG_GENERIC \
70 ((USE_WXMSW || USE_WXPM) && USE_GENERIC_DIALOGS && wxUSE_FONTDLG)
13188def 71
4c8fc4d6 72
08375332
WS
73// Turn USE_MODAL_PRESENTATION to 0 if there is any reason for not presenting difference
74// between modal and modeless dialogs (ie. not implemented it in your port yet)
75#if defined(__SMARTPHONE__)
76 #define USE_MODAL_PRESENTATION 0
77#else
78 #define USE_MODAL_PRESENTATION 1
79#endif
4c8fc4d6 80
13188def 81
457814b5
JS
82// Define a new application type
83class MyApp: public wxApp
c49245f8
VZ
84{
85public:
86 bool OnInit();
457814b5
JS
87
88 wxFont m_canvasFont;
89 wxColour m_canvasTextColour;
90};
91
b4954d19
WS
92#if USE_MODAL_PRESENTATION
93
f6bcfd97 94// A custom modeless dialog
4c45f240
VZ
95class MyModelessDialog : public wxDialog
96{
97public:
98 MyModelessDialog(wxWindow *parent);
abceee76 99
5d987909 100 void OnButton(wxCommandEvent& event);
abceee76
VZ
101 void OnClose(wxCloseEvent& event);
102
103private:
104 DECLARE_EVENT_TABLE()
4c45f240
VZ
105};
106
f6bcfd97
BP
107// A custom modal dialog
108class MyModalDialog : public wxDialog
109{
110public:
111 MyModalDialog(wxWindow *parent);
112
113 void OnButton(wxCommandEvent& event);
114
115private:
5315ebfa
VZ
116 wxButton *m_btnModal,
117 *m_btnModeless,
118 *m_btnDelete;
f6bcfd97
BP
119
120 DECLARE_EVENT_TABLE()
121};
122
b4954d19
WS
123#endif // USE_MODAL_PRESENTATION
124
457814b5
JS
125// Define a new frame type
126class MyFrame: public wxFrame
c49245f8
VZ
127{
128public:
13188def
WS
129 MyFrame(wxWindow *parent, const wxString& title);
130
131 void MessageBox(wxCommandEvent& event);
457814b5 132
13188def 133#if wxUSE_COLOURDLG
329e86bf 134 void ChooseColour(wxCommandEvent& event);
13188def
WS
135#endif // wxUSE_COLOURDLG
136
137#if wxUSE_FONTDLG
329e86bf 138 void ChooseFont(wxCommandEvent& event);
13188def
WS
139#endif // wxUSE_FONTDLG
140
141#if wxUSE_LOG_DIALOG
d93c719a 142 void LogDialog(wxCommandEvent& event);
13188def
WS
143#endif // wxUSE_LOG_DIALOG
144
145#if wxUSE_CHOICEDLG
457814b5 146 void SingleChoice(wxCommandEvent& event);
d6c9c1b7 147 void MultiChoice(wxCommandEvent& event);
13188def
WS
148#endif // wxUSE_CHOICEDLG
149
150#if wxUSE_TEXTDLG
457814b5 151 void TextEntry(wxCommandEvent& event);
a294c6d5 152 void PasswordEntry(wxCommandEvent& event);
13188def
WS
153#endif // wxUSE_TEXTDLG
154
155#if wxUSE_NUMBERDLG
c49245f8 156 void NumericEntry(wxCommandEvent& event);
13188def
WS
157#endif // wxUSE_NUMBERDLG
158
159#if wxUSE_FILEDLG
457814b5 160 void FileOpen(wxCommandEvent& event);
35b45b33 161 void FileOpen2(wxCommandEvent& event);
c61f4f6d 162 void FilesOpen(wxCommandEvent& event);
457814b5 163 void FileSave(wxCommandEvent& event);
13188def
WS
164#endif // wxUSE_FILEDLG
165
695fe764
WS
166#if USE_FILEDLG_GENERIC
167 void FileOpenGeneric(wxCommandEvent& event);
168 void FilesOpenGeneric(wxCommandEvent& event);
169 void FileSaveGeneric(wxCommandEvent& event);
170#endif // USE_FILEDLG_GENERIC
171
13188def 172#if wxUSE_DIRDLG
457814b5 173 void DirChoose(wxCommandEvent& event);
f09c8393 174 void DirChooseNew(wxCommandEvent& event);
13188def
WS
175#endif // wxUSE_DIRDLG
176
177#if USE_DIRDLG_GENERIC
51a58d8b 178 void GenericDirChoose(wxCommandEvent& event);
13188def
WS
179#endif // USE_DIRDLG_GENERIC
180
181#if wxUSE_STARTUP_TIPS
c50f1fb9 182 void ShowTip(wxCommandEvent& event);
13188def
WS
183#endif // wxUSE_STARTUP_TIPS
184
185#if USE_MODAL_PRESENTATION
f6bcfd97 186 void ModalDlg(wxCommandEvent& event);
4c45f240 187 void ModelessDlg(wxCommandEvent& event);
13188def
WS
188#endif // USE_MODAL_PRESENTATION
189
761989ff 190#if wxUSE_PROGRESSDLG
abceee76 191 void ShowProgress(wxCommandEvent& event);
761989ff 192#endif // wxUSE_PROGRESSDLG
13188def 193
a62b0bcc
VZ
194#if wxUSE_BUSYINFO
195 void ShowBusyInfo(wxCommandEvent& event);
196#endif // wxUSE_BUSYINFO
13188def 197
761989ff
VZ
198#if wxUSE_FINDREPLDLG
199 void ShowFindDialog(wxCommandEvent& event);
200 void ShowReplaceDialog(wxCommandEvent& event);
761989ff
VZ
201 void OnFindDialog(wxFindDialogEvent& event);
202#endif // wxUSE_FINDREPLDLG
457814b5 203
13188def 204#if USE_COLOURDLG_GENERIC
329e86bf 205 void ChooseColourGeneric(wxCommandEvent& event);
13188def
WS
206#endif // USE_COLOURDLG_GENERIC
207
208#if USE_FONTDLG_GENERIC
329e86bf 209 void ChooseFontGeneric(wxCommandEvent& event);
13188def 210#endif // USE_FONTDLG_GENERIC
c49245f8 211
29e3d1f9 212 void OnRequestUserAttention(wxCommandEvent& event);
329e86bf 213 void OnExit(wxCommandEvent& event);
c49245f8 214
4c45f240 215private:
13188def 216#if wxUSE_DIRDLG
f09c8393 217 void DoDirChoose(int style);
13188def 218#endif // wxUSE_DIRDLG
f09c8393 219
13188def 220#if USE_MODAL_PRESENTATION
4c45f240 221 MyModelessDialog *m_dialog;
13188def 222#endif // USE_MODAL_PRESENTATION
4c45f240 223
761989ff
VZ
224#if wxUSE_FINDREPLDLG
225 wxFindReplaceData m_findData;
14fca738
VZ
226
227 wxFindReplaceDialog *m_dlgFind,
228 *m_dlgReplace;
761989ff
VZ
229#endif // wxUSE_FINDREPLDLG
230
d33dd9ef
VS
231 wxColourData m_clrData;
232
4c45f240 233 DECLARE_EVENT_TABLE()
457814b5
JS
234};
235
236class MyCanvas: public wxScrolledWindow
237{
c49245f8 238public:
08375332 239 MyCanvas(wxWindow *parent) :
13188def 240 wxScrolledWindow(parent,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxNO_FULL_REPAINT_ON_RESIZE) { }
c49245f8
VZ
241
242 void OnPaint(wxPaintEvent& event);
243
244 DECLARE_EVENT_TABLE()
457814b5
JS
245};
246
247
248// Menu IDs
a294c6d5
VZ
249enum
250{
13188def 251 DIALOGS_CHOOSE_COLOUR = wxID_HIGHEST,
a294c6d5
VZ
252 DIALOGS_CHOOSE_COLOUR_GENERIC,
253 DIALOGS_CHOOSE_FONT,
254 DIALOGS_CHOOSE_FONT_GENERIC,
255 DIALOGS_MESSAGE_BOX,
256 DIALOGS_SINGLE_CHOICE,
d6c9c1b7 257 DIALOGS_MULTI_CHOICE,
a294c6d5
VZ
258 DIALOGS_TEXT_ENTRY,
259 DIALOGS_PASSWORD_ENTRY,
260 DIALOGS_FILE_OPEN,
35b45b33 261 DIALOGS_FILE_OPEN2,
a294c6d5
VZ
262 DIALOGS_FILES_OPEN,
263 DIALOGS_FILE_SAVE,
695fe764
WS
264 DIALOGS_FILE_OPEN_GENERIC,
265 DIALOGS_FILES_OPEN_GENERIC,
266 DIALOGS_FILE_SAVE_GENERIC,
a294c6d5 267 DIALOGS_DIR_CHOOSE,
f09c8393 268 DIALOGS_DIRNEW_CHOOSE,
51a58d8b 269 DIALOGS_GENERIC_DIR_CHOOSE,
a294c6d5
VZ
270 DIALOGS_TIP,
271 DIALOGS_NUM_ENTRY,
4c45f240 272 DIALOGS_LOG_DIALOG,
f6bcfd97 273 DIALOGS_MODAL,
4c45f240 274 DIALOGS_MODELESS,
abceee76 275 DIALOGS_MODELESS_BTN,
761989ff 276 DIALOGS_PROGRESS,
a62b0bcc 277 DIALOGS_BUSYINFO,
761989ff 278 DIALOGS_FIND,
29e3d1f9
VZ
279 DIALOGS_REPLACE,
280 DIALOGS_REQUEST
a294c6d5 281};
457814b5
JS
282
283#endif
284