]> git.saurik.com Git - wxWidgets.git/blame - samples/dialogs/dialogs.h
added alpha support to wxImage::Paste() (patch 1883497, bug 1831612)
[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
684883e3
WS
37#if defined(__WXWINCE__)
38 #define USE_WXWINCE 1
39#else
40 #define USE_WXWINCE 0
41#endif
42
43#if defined(__WXMSW__) && !USE_WXWINCE
da7a8602
WS
44 #define USE_WXMSW 1
45#else
46 #define USE_WXMSW 0
47#endif
48
49#ifdef __WXMAC__
50 #define USE_WXMAC 1
51#else
52 #define USE_WXMAC 0
53#endif
54
cea9c5b1 55#if defined(__WXMAC_OSX__) && ( MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_2) && USE_NATIVE_FONT_DIALOG_FOR_MACOSX
71622a68
RN
56 #define USE_WXMACFONTDLG 1
57#else
58 #define USE_WXMACFONTDLG 0
59#endif
60
da7a8602
WS
61#ifdef __WXGTK__
62 #define USE_WXGTK 1
63#else
64 #define USE_WXGTK 0
65#endif
66
67#ifdef __WXPM__
68 #define USE_WXPM 1
69#else
70 #define USE_WXPM 0
71#endif
72
29e3d1f9 73#define USE_GENERIC_DIALOGS (!USE_WXUNIVERSAL && !USE_DLL)
13188def 74
29e3d1f9
VZ
75#define USE_COLOURDLG_GENERIC \
76 ((USE_WXMSW || USE_WXMAC) && USE_GENERIC_DIALOGS && wxUSE_COLOURDLG)
77#define USE_DIRDLG_GENERIC \
78 ((USE_WXMSW || USE_WXMAC) && USE_GENERIC_DIALOGS && wxUSE_DIRDLG)
79#define USE_FILEDLG_GENERIC \
684883e3 80 ((((USE_WXMSW || USE_WXMAC || USE_WXPM) && USE_GENERIC_DIALOGS) || USE_WXWINCE) && wxUSE_FILEDLG)
29e3d1f9 81#define USE_FONTDLG_GENERIC \
684883e3 82 ((USE_WXMSW || USE_WXMACFONTDLG || USE_WXPM) && USE_GENERIC_DIALOGS && wxUSE_FONTDLG)
4c8fc4d6 83
08375332
WS
84// Turn USE_MODAL_PRESENTATION to 0 if there is any reason for not presenting difference
85// between modal and modeless dialogs (ie. not implemented it in your port yet)
532d575b 86#if defined(__SMARTPHONE__) || !wxUSE_BOOKCTRL
08375332
WS
87 #define USE_MODAL_PRESENTATION 0
88#else
89 #define USE_MODAL_PRESENTATION 1
90#endif
4c8fc4d6 91
13188def 92
532d575b
WS
93// Turn USE_SETTINGS_DIALOG to 0 if supported
94#if wxUSE_BOOKCTRL
95 #define USE_SETTINGS_DIALOG 1
96#else
97 #define USE_SETTINGS_DIALOG 0
98#endif
99
100
457814b5
JS
101// Define a new application type
102class MyApp: public wxApp
c49245f8
VZ
103{
104public:
105 bool OnInit();
457814b5
JS
106
107 wxFont m_canvasFont;
108 wxColour m_canvasTextColour;
109};
110
b4954d19
WS
111#if USE_MODAL_PRESENTATION
112
f6bcfd97 113// A custom modeless dialog
4c45f240
VZ
114class MyModelessDialog : public wxDialog
115{
116public:
117 MyModelessDialog(wxWindow *parent);
abceee76 118
5d987909 119 void OnButton(wxCommandEvent& event);
abceee76
VZ
120 void OnClose(wxCloseEvent& event);
121
122private:
123 DECLARE_EVENT_TABLE()
4c45f240
VZ
124};
125
f6bcfd97
BP
126// A custom modal dialog
127class MyModalDialog : public wxDialog
128{
129public:
130 MyModalDialog(wxWindow *parent);
131
132 void OnButton(wxCommandEvent& event);
133
134private:
5315ebfa
VZ
135 wxButton *m_btnModal,
136 *m_btnModeless,
137 *m_btnDelete;
f6bcfd97
BP
138
139 DECLARE_EVENT_TABLE()
140};
141
b4954d19
WS
142#endif // USE_MODAL_PRESENTATION
143
8e1dac82
VZ
144class StdButtonSizerDialog : public wxDialog
145{
146public:
147 StdButtonSizerDialog(wxWindow *parent);
148
149 void OnEvent(wxCommandEvent& event);
150
151private:
152 void EnableDisableControls();
153
154 wxCheckBox *m_chkboxAffirmativeButton;
155 wxRadioButton *m_radiobtnOk,
156 *m_radiobtnYes;
157
158 wxCheckBox *m_chkboxDismissButton;
159 wxRadioButton *m_radiobtnClose,
160 *m_radiobtnCancel;
161
162 wxCheckBox *m_chkboxApply,
163 *m_chkboxNo,
164 *m_chkboxHelp,
165 *m_chkboxNoDefault;
166
167 wxSizer *m_buttonsSizer;
168
169 DECLARE_EVENT_TABLE()
170};
171
a625c5b6
RR
172class TestDefaultActionDialog: public wxDialog
173{
174public:
175 TestDefaultActionDialog( wxWindow *parent );
176
177 void OnListBoxDClick(wxCommandEvent& event);
178 void OnCatchListBoxDClick(wxCommandEvent& event);
179
180private:
181 bool m_catchListBoxDClick;
182
183private:
184 DECLARE_EVENT_TABLE()
185};
186
187
532d575b 188#if USE_SETTINGS_DIALOG
0f5d8ecf
JS
189// Property sheet dialog
190class SettingsDialog: public wxPropertySheetDialog
191{
192DECLARE_CLASS(SettingsDialog)
193public:
64d3ed17 194 SettingsDialog(wxWindow* parent, int dialogType);
cc8bc5aa 195 ~SettingsDialog();
0f5d8ecf
JS
196
197 wxPanel* CreateGeneralSettingsPage(wxWindow* parent);
198 wxPanel* CreateAestheticSettingsPage(wxWindow* parent);
199
200protected:
201
202 enum {
203 ID_SHOW_TOOLTIPS = 100,
204 ID_AUTO_SAVE,
205 ID_AUTO_SAVE_MINS,
206 ID_LOAD_LAST_PROJECT,
207
208 ID_APPLY_SETTINGS_TO,
209 ID_BACKGROUND_STYLE,
210 ID_FONT_SIZE
211 };
212
cc8bc5aa
JS
213 wxImageList* m_imageList;
214
0f5d8ecf
JS
215DECLARE_EVENT_TABLE()
216};
217
532d575b
WS
218#endif // USE_SETTINGS_DIALOG
219
457814b5
JS
220// Define a new frame type
221class MyFrame: public wxFrame
c49245f8
VZ
222{
223public:
13188def 224 MyFrame(wxWindow *parent, const wxString& title);
e36a1739 225 virtual ~MyFrame();
13188def 226
8cf304f8 227#if wxUSE_MSGDLG
13188def 228 void MessageBox(wxCommandEvent& event);
8cf304f8
VZ
229 void MessageBoxInfo(wxCommandEvent& event);
230#endif // wxUSE_MSGDLG
457814b5 231
13188def 232#if wxUSE_COLOURDLG
329e86bf 233 void ChooseColour(wxCommandEvent& event);
e6ef9ea4 234 void GetColour(wxCommandEvent& event);
13188def
WS
235#endif // wxUSE_COLOURDLG
236
237#if wxUSE_FONTDLG
329e86bf 238 void ChooseFont(wxCommandEvent& event);
13188def
WS
239#endif // wxUSE_FONTDLG
240
241#if wxUSE_LOG_DIALOG
d93c719a 242 void LogDialog(wxCommandEvent& event);
13188def
WS
243#endif // wxUSE_LOG_DIALOG
244
245#if wxUSE_CHOICEDLG
457814b5 246 void SingleChoice(wxCommandEvent& event);
d6c9c1b7 247 void MultiChoice(wxCommandEvent& event);
13188def
WS
248#endif // wxUSE_CHOICEDLG
249
250#if wxUSE_TEXTDLG
457814b5 251 void TextEntry(wxCommandEvent& event);
a294c6d5 252 void PasswordEntry(wxCommandEvent& event);
13188def
WS
253#endif // wxUSE_TEXTDLG
254
255#if wxUSE_NUMBERDLG
c49245f8 256 void NumericEntry(wxCommandEvent& event);
13188def
WS
257#endif // wxUSE_NUMBERDLG
258
259#if wxUSE_FILEDLG
457814b5 260 void FileOpen(wxCommandEvent& event);
35b45b33 261 void FileOpen2(wxCommandEvent& event);
c61f4f6d 262 void FilesOpen(wxCommandEvent& event);
457814b5 263 void FileSave(wxCommandEvent& event);
13188def
WS
264#endif // wxUSE_FILEDLG
265
695fe764
WS
266#if USE_FILEDLG_GENERIC
267 void FileOpenGeneric(wxCommandEvent& event);
268 void FilesOpenGeneric(wxCommandEvent& event);
269 void FileSaveGeneric(wxCommandEvent& event);
270#endif // USE_FILEDLG_GENERIC
271
13188def 272#if wxUSE_DIRDLG
457814b5 273 void DirChoose(wxCommandEvent& event);
f09c8393 274 void DirChooseNew(wxCommandEvent& event);
13188def
WS
275#endif // wxUSE_DIRDLG
276
277#if USE_DIRDLG_GENERIC
51a58d8b 278 void GenericDirChoose(wxCommandEvent& event);
13188def
WS
279#endif // USE_DIRDLG_GENERIC
280
281#if wxUSE_STARTUP_TIPS
c50f1fb9 282 void ShowTip(wxCommandEvent& event);
13188def
WS
283#endif // wxUSE_STARTUP_TIPS
284
285#if USE_MODAL_PRESENTATION
f6bcfd97 286 void ModalDlg(wxCommandEvent& event);
1baa0a9d 287#endif // USE_MODAL_PRESENTATION
4c45f240 288 void ModelessDlg(wxCommandEvent& event);
cae50e6b
VZ
289 void DlgCenteredScreen(wxCommandEvent& event);
290 void DlgCenteredParent(wxCommandEvent& event);
1baa0a9d 291 void MiniFrame(wxCommandEvent& event);
8e5dbcdd 292 void DlgOnTop(wxCommandEvent& event);
13188def 293
761989ff 294#if wxUSE_PROGRESSDLG
abceee76 295 void ShowProgress(wxCommandEvent& event);
761989ff 296#endif // wxUSE_PROGRESSDLG
13188def 297
ca7adbf8
VZ
298#if wxUSE_ABOUTDLG
299 void ShowSimpleAboutDialog(wxCommandEvent& event);
300 void ShowFancyAboutDialog(wxCommandEvent& event);
453c9e3b
VZ
301 void ShowFullAboutDialog(wxCommandEvent& event);
302 void ShowCustomAboutDialog(wxCommandEvent& event);
ca7adbf8
VZ
303#endif // wxUSE_ABOUTDLG
304
a62b0bcc
VZ
305#if wxUSE_BUSYINFO
306 void ShowBusyInfo(wxCommandEvent& event);
307#endif // wxUSE_BUSYINFO
13188def 308
761989ff
VZ
309#if wxUSE_FINDREPLDLG
310 void ShowFindDialog(wxCommandEvent& event);
311 void ShowReplaceDialog(wxCommandEvent& event);
761989ff
VZ
312 void OnFindDialog(wxFindDialogEvent& event);
313#endif // wxUSE_FINDREPLDLG
457814b5 314
13188def 315#if USE_COLOURDLG_GENERIC
329e86bf 316 void ChooseColourGeneric(wxCommandEvent& event);
13188def
WS
317#endif // USE_COLOURDLG_GENERIC
318
319#if USE_FONTDLG_GENERIC
329e86bf 320 void ChooseFontGeneric(wxCommandEvent& event);
13188def 321#endif // USE_FONTDLG_GENERIC
c49245f8 322
0f5d8ecf 323 void OnPropertySheet(wxCommandEvent& event);
e36a1739 324
29e3d1f9 325 void OnRequestUserAttention(wxCommandEvent& event);
e36a1739
VZ
326#if wxUSE_NOTIFICATION_MESSAGE
327 void OnNotifMsgAuto(wxCommandEvent& event);
328 void OnNotifMsgShow(wxCommandEvent& event);
329 void OnNotifMsgHide(wxCommandEvent& event);
330#endif // wxUSE_NOTIFICATION_MESSAGE
331
8e1dac82 332 void OnStandardButtonsSizerDialog(wxCommandEvent& event);
a625c5b6
RR
333
334 void OnTestDefaultActionDialog(wxCommandEvent& event);
335
329e86bf 336 void OnExit(wxCommandEvent& event);
c49245f8 337
4c45f240 338private:
13188def 339#if wxUSE_DIRDLG
f09c8393 340 void DoDirChoose(int style);
13188def 341#endif // wxUSE_DIRDLG
f09c8393 342
13188def 343#if USE_MODAL_PRESENTATION
4c45f240 344 MyModelessDialog *m_dialog;
13188def 345#endif // USE_MODAL_PRESENTATION
4c45f240 346
761989ff
VZ
347#if wxUSE_FINDREPLDLG
348 wxFindReplaceData m_findData;
14fca738
VZ
349
350 wxFindReplaceDialog *m_dlgFind,
351 *m_dlgReplace;
761989ff
VZ
352#endif // wxUSE_FINDREPLDLG
353
e36a1739
VZ
354#if wxUSE_NOTIFICATION_MESSAGE
355 wxNotificationMessage *m_notifMsg;
356#endif // wxUSE_NOTIFICATION_MESSAGE
357
d33dd9ef
VS
358 wxColourData m_clrData;
359
4c45f240 360 DECLARE_EVENT_TABLE()
457814b5
JS
361};
362
363class MyCanvas: public wxScrolledWindow
364{
c49245f8 365public:
08375332 366 MyCanvas(wxWindow *parent) :
13188def 367 wxScrolledWindow(parent,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxNO_FULL_REPAINT_ON_RESIZE) { }
c49245f8
VZ
368
369 void OnPaint(wxPaintEvent& event);
370
371 DECLARE_EVENT_TABLE()
457814b5
JS
372};
373
374
375// Menu IDs
a294c6d5
VZ
376enum
377{
13188def 378 DIALOGS_CHOOSE_COLOUR = wxID_HIGHEST,
e6ef9ea4 379 DIALOGS_GET_COLOUR,
a294c6d5
VZ
380 DIALOGS_CHOOSE_COLOUR_GENERIC,
381 DIALOGS_CHOOSE_FONT,
382 DIALOGS_CHOOSE_FONT_GENERIC,
383 DIALOGS_MESSAGE_BOX,
8cf304f8 384 DIALOGS_MESSAGE_BOX_WXINFO,
a294c6d5 385 DIALOGS_SINGLE_CHOICE,
d6c9c1b7 386 DIALOGS_MULTI_CHOICE,
a294c6d5
VZ
387 DIALOGS_TEXT_ENTRY,
388 DIALOGS_PASSWORD_ENTRY,
389 DIALOGS_FILE_OPEN,
35b45b33 390 DIALOGS_FILE_OPEN2,
a294c6d5
VZ
391 DIALOGS_FILES_OPEN,
392 DIALOGS_FILE_SAVE,
695fe764
WS
393 DIALOGS_FILE_OPEN_GENERIC,
394 DIALOGS_FILES_OPEN_GENERIC,
395 DIALOGS_FILE_SAVE_GENERIC,
a294c6d5 396 DIALOGS_DIR_CHOOSE,
f09c8393 397 DIALOGS_DIRNEW_CHOOSE,
51a58d8b 398 DIALOGS_GENERIC_DIR_CHOOSE,
a294c6d5
VZ
399 DIALOGS_TIP,
400 DIALOGS_NUM_ENTRY,
4c45f240 401 DIALOGS_LOG_DIALOG,
f6bcfd97 402 DIALOGS_MODAL,
4c45f240 403 DIALOGS_MODELESS,
cae50e6b
VZ
404 DIALOGS_CENTRE_SCREEN,
405 DIALOGS_CENTRE_PARENT,
1baa0a9d 406 DIALOGS_MINIFRAME,
8e5dbcdd 407 DIALOGS_ONTOP,
abceee76 408 DIALOGS_MODELESS_BTN,
761989ff 409 DIALOGS_PROGRESS,
ca7adbf8
VZ
410 DIALOGS_ABOUTDLG_SIMPLE,
411 DIALOGS_ABOUTDLG_FANCY,
453c9e3b
VZ
412 DIALOGS_ABOUTDLG_FULL,
413 DIALOGS_ABOUTDLG_CUSTOM,
a62b0bcc 414 DIALOGS_BUSYINFO,
761989ff 415 DIALOGS_FIND,
29e3d1f9 416 DIALOGS_REPLACE,
0f5d8ecf 417 DIALOGS_REQUEST,
e36a1739
VZ
418 DIALOGS_NOTIFY_AUTO,
419 DIALOGS_NOTIFY_SHOW,
420 DIALOGS_NOTIFY_HIDE,
cc8bc5aa 421 DIALOGS_PROPERTY_SHEET,
64d3ed17 422 DIALOGS_PROPERTY_SHEET_TOOLBOOK,
8e1dac82 423 DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK,
a625c5b6
RR
424 DIALOGS_STANDARD_BUTTON_SIZER_DIALOG,
425 DIALOGS_TEST_DEFAULT_ACTION
a294c6d5 426};
457814b5
JS
427
428#endif
429