]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/dialog.h
Add wxDataViewCtrl::GetCurrentColumn().
[wxWidgets.git] / interface / wx / dialog.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: dialog.h
e54c96f1 3// Purpose: interface of wxDialog
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
526954c5 6// Licence: wxWindows licence
23324ae1
FM
7/////////////////////////////////////////////////////////////////////////////
8
1db8f1dc
BP
9/**
10 Modes used for wxDialog::SetLayoutAdaptationMode().
11*/
12enum wxDialogLayoutAdaptationMode
13{
14 wxDIALOG_ADAPTATION_MODE_DEFAULT = 0, ///< Use global adaptation enabled status.
15 wxDIALOG_ADAPTATION_MODE_ENABLED = 1, ///< Enable this dialog overriding global status.
16 wxDIALOG_ADAPTATION_MODE_DISABLED = 2 ///< Disable this dialog overriding global status.
17};
18
ea8fa3c4
RD
19#define wxDEFAULT_DIALOG_STYLE (wxCAPTION | wxSYSTEM_MENU | wxCLOSE_BOX)
20
23324ae1
FM
21/**
22 @class wxDialog
7c913512 23
1db8f1dc
BP
24 A dialog box is a window with a title bar and sometimes a system menu,
25 which can be moved around the screen. It can contain controls and other
26 windows and is often used to allow the user to make some choice or to
27 answer a question.
28
29 Dialogs can be made scrollable, automatically, for computers with low
30 resolution screens: please see @ref overview_dialog_autoscrolling for
31 further details.
32
33 Dialogs usually contains either a single button allowing to close the
34 dialog or two buttons, one accepting the changes and the other one
35 discarding them (such button, if present, is automatically activated if the
36 user presses the "Esc" key). By default, buttons with the standard wxID_OK
37 and wxID_CANCEL identifiers behave as expected. Starting with wxWidgets 2.7
38 it is also possible to use a button with a different identifier instead,
39 see SetAffirmativeId() and SetEscapeId().
40
41 Also notice that the CreateButtonSizer() should be used to create the
42 buttons appropriate for the current platform and positioned correctly
43 (including their order which is platform-dependent).
44
45 @section dialog_modal Modal and Modeless
46
47 There are two kinds of dialog, modal and modeless. A modal dialog blocks
48 program flow and user input on other windows until it is dismissed, whereas
49 a modeless dialog behaves more like a frame in that program flow continues,
50 and input in other windows is still possible. To show a modal dialog you
51 should use the ShowModal() method while to show a dialog modelessly you
52 simply use Show(), just as with frames.
53
54 Note that the modal dialog is one of the very few examples of
55 wxWindow-derived objects which may be created on the stack and not on the
56 heap. In other words, while most windows would be created like this:
57
58 @code
59 void AskUser()
60 {
61 MyAskDialog *dlg = new MyAskDialog(...);
62 if ( dlg->ShowModal() == wxID_OK )
63 // ...
64 //else: dialog was cancelled or some another button pressed
65
66 dlg->Destroy();
67 }
68 @endcode
69
70 You can achieve the same result with dialogs by using simpler code:
71
72 @code
73 void AskUser()
74 {
75 MyAskDialog dlg(...);
76 if ( dlg.ShowModal() == wxID_OK )
77 // ...
78
79 // no need to call Destroy() here
80 }
81 @endcode
82
83 An application can define a wxCloseEvent handler for the dialog to respond
84 to system close events.
7c913512 85
23324ae1 86 @beginStyleTable
8c6791e4 87 @style{wxCAPTION}
23324ae1 88 Puts a caption on the dialog box.
8c6791e4 89 @style{wxDEFAULT_DIALOG_STYLE}
23324ae1 90 Equivalent to a combination of wxCAPTION, wxCLOSE_BOX and
1db8f1dc 91 wxSYSTEM_MENU (the last one is not used under Unix).
8c6791e4 92 @style{wxRESIZE_BORDER}
d13b34d3 93 Display a resizable frame around the window.
8c6791e4 94 @style{wxSYSTEM_MENU}
23324ae1 95 Display a system menu.
8c6791e4 96 @style{wxCLOSE_BOX}
23324ae1 97 Displays a close box on the frame.
8c6791e4 98 @style{wxMAXIMIZE_BOX}
23324ae1 99 Displays a maximize box on the dialog.
8c6791e4 100 @style{wxMINIMIZE_BOX}
23324ae1 101 Displays a minimize box on the dialog.
8c6791e4 102 @style{wxTHICK_FRAME}
23324ae1 103 Display a thick frame around the window.
8c6791e4 104 @style{wxSTAY_ON_TOP}
23324ae1 105 The dialog stays on top of all other windows.
8c6791e4 106 @style{wxNO_3D}
23324ae1
FM
107 Under Windows, specifies that the child controls should not have 3D
108 borders unless specified in the control.
8c6791e4 109 @style{wxDIALOG_NO_PARENT}
23324ae1 110 By default, a dialog created with a @NULL parent window will be
1db8f1dc
BP
111 given the @ref wxApp::GetTopWindow() "application's top level window"
112 as parent. Use this style to prevent this from happening and create
113 an orphan dialog. This is not recommended for modal dialogs.
8c6791e4 114 @style{wxDIALOG_EX_CONTEXTHELP}
23324ae1
FM
115 Under Windows, puts a query button on the caption. When pressed,
116 Windows will go into a context-sensitive help mode and wxWidgets
3a194bda 117 will send a @c wxEVT_HELP event if the user clicked on an application
23324ae1 118 window. Note that this is an extended style and must be set by
1db8f1dc 119 calling SetExtraStyle() before Create is called (two-step
23324ae1 120 construction).
8c6791e4 121 @style{wxDIALOG_EX_METAL}
23324ae1
FM
122 On Mac OS X, frames with this style will be shown with a metallic
123 look. This is an extra style.
124 @endStyleTable
7c913512 125
1db8f1dc
BP
126 Under Unix or Linux, MWM (the Motif Window Manager) or other window
127 managers recognizing the MHM hints should be running for any of these
128 styles to have an effect.
129
9d157d59 130
3051a44a 131 @beginEventEmissionTable{wxCloseEvent}
9d157d59
FM
132 @event{EVT_CLOSE(func)}
133 The dialog is being closed by the user or programmatically (see wxWindow::Close).
134 The user may generate this event clicking the close button
135 (typically the 'X' on the top-right of the title bar) if it's present
136 (see the @c wxCLOSE_BOX style) or by clicking a button with the
137 @c wxID_CANCEL or @c wxID_OK ids.
3051a44a
FM
138 @event{EVT_INIT_DIALOG(func)}
139 Process a @c wxEVT_INIT_DIALOG event. See wxInitDialogEvent.
9d157d59
FM
140 @endEventTable
141
23324ae1
FM
142 @library{wxcore}
143 @category{cmndlg}
7c913512 144
1db8f1dc 145 @see @ref overview_dialog, wxFrame, @ref overview_validator
23324ae1
FM
146*/
147class wxDialog : public wxTopLevelWindow
148{
149public:
1db8f1dc
BP
150 /**
151 Default constructor.
152 */
153 wxDialog();
23324ae1
FM
154 /**
155 Constructor.
3c4f71cc 156
7c913512 157 @param parent
4cc4bfaf 158 Can be @NULL, a frame or another dialog box.
7c913512 159 @param id
1db8f1dc
BP
160 An identifier for the dialog. A value of -1 is taken to mean a
161 default.
7c913512 162 @param title
4cc4bfaf 163 The title of the dialog.
7c913512 164 @param pos
1db8f1dc
BP
165 The dialog position. The value wxDefaultPosition indicates a
166 default position, chosen by either the windowing system or
167 wxWidgets, depending on platform.
7c913512 168 @param size
1db8f1dc
BP
169 The dialog size. The value wxDefaultSize indicates a default size,
170 chosen by either the windowing system or wxWidgets, depending on
171 platform.
7c913512 172 @param style
1db8f1dc 173 The window style.
7c913512 174 @param name
1db8f1dc
BP
175 Used to associate a name with the window, allowing the application
176 user to set Motif resource values for individual dialog boxes.
3c4f71cc 177
4cc4bfaf 178 @see Create()
23324ae1 179 */
1db8f1dc 180 wxDialog(wxWindow* parent, wxWindowID id, const wxString& title,
7c913512
FM
181 const wxPoint& pos = wxDefaultPosition,
182 const wxSize& size = wxDefaultSize,
183 long style = wxDEFAULT_DIALOG_STYLE,
408776d0 184 const wxString& name = wxDialogNameStr);
23324ae1
FM
185
186 /**
2e4f32d7
FM
187 Destructor.
188
189 Deletes any child windows before deleting the physical window.
190
191 See @ref overview_windowdeletion for more info.
23324ae1 192 */
adaaa686 193 virtual ~wxDialog();
23324ae1
FM
194
195 /**
1db8f1dc
BP
196 Adds an identifier to be regarded as a main button for the
197 non-scrolling area of a dialog.
198
199 @see @ref overview_dialog_autoscrolling (for more on layout adaptation)
23324ae1
FM
200 */
201 void AddMainButtonId(wxWindowID id);
202
203 /**
1db8f1dc
BP
204 Returns @true if this dialog can and should perform layout adaptation
205 using DoLayoutAdaptation(), usually if the dialog is too large to fit
206 on the display.
207
208 @see @ref overview_dialog_autoscrolling (for more on layout adaptation)
23324ae1 209 */
4ccf0566 210 virtual bool CanDoLayoutAdaptation();
23324ae1
FM
211
212 /**
213 Centres the dialog box on the display.
3c4f71cc 214
7c913512 215 @param direction
4cc4bfaf 216 May be wxHORIZONTAL, wxVERTICAL or wxBOTH.
23324ae1
FM
217 */
218 void Centre(int direction = wxBOTH);
219
220 /**
1db8f1dc
BP
221 Used for two-step dialog box construction.
222
223 @see wxDialog()
23324ae1 224 */
1db8f1dc 225 bool Create(wxWindow* parent, wxWindowID id, const wxString& title,
23324ae1 226 const wxPoint& pos = wxDefaultPosition,
408776d0
FM
227 const wxSize& size = wxDefaultSize,
228 long style = wxDEFAULT_DIALOG_STYLE,
b91c4601 229 const wxString& name = wxDialogNameStr);
23324ae1
FM
230
231 /**
1db8f1dc
BP
232 Creates a sizer with standard buttons. @a flags is a bit list of the
233 following flags: wxOK, wxCANCEL, wxYES, wxNO, wxAPPLY, wxCLOSE, wxHELP,
234 wxNO_DEFAULT.
235
23324ae1 236 The sizer lays out the buttons in a manner appropriate to the platform.
1db8f1dc
BP
237
238 This function uses CreateStdDialogButtonSizer() internally for most
239 platforms but doesn't create the sizer at all for the platforms with
240 hardware buttons (such as smartphones) for which it sets up the
241 hardware buttons appropriately and returns @NULL, so don't forget to
242 test that the return value is valid before using it.
23324ae1
FM
243 */
244 wxSizer* CreateButtonSizer(long flags);
245
246 /**
1db8f1dc
BP
247 Creates a sizer with standard buttons using CreateButtonSizer()
248 separated from the rest of the dialog contents by a horizontal
249 wxStaticLine.
250
251 @note Just like CreateButtonSizer(), this function may return @NULL if
252 no buttons were created.
b14cca2a
VZ
253
254 This is a combination of CreateButtonSizer() and
255 CreateSeparatedSizer().
23324ae1
FM
256 */
257 wxSizer* CreateSeparatedButtonSizer(long flags);
258
b14cca2a
VZ
259 /**
260 Returns the sizer containing the given one with a separating
261 wxStaticLine if necessarily.
262
263 This function is useful for creating the sizer containing footer-like
264 contents in dialog boxes. It will add a separating static line only if
265 it conforms to the current platform convention (currently it is not
266 added under Mac where the use of static lines for grouping is
267 discouraged and is added elsewhere).
268
269 @since 2.9.2
270
271 @param sizer The sizer to wrap, must be non-@NULL.
272 @return The sizer wrapping the input one or possibly the input sizer
273 itself if no wrapping is necessary.
274 */
275 wxSizer *CreateSeparatedSizer(wxSizer *sizer);
276
23324ae1 277 /**
1db8f1dc
BP
278 Creates a wxStdDialogButtonSizer with standard buttons. @a flags is a
279 bit list of the following flags: wxOK, wxCANCEL, wxYES, wxNO, wxAPPLY,
280 wxCLOSE, wxHELP, wxNO_DEFAULT.
281
23324ae1
FM
282 The sizer lays out the buttons in a manner appropriate to the platform.
283 */
284 wxStdDialogButtonSizer* CreateStdDialogButtonSizer(long flags);
285
286 /**
1db8f1dc
BP
287 Performs layout adaptation, usually if the dialog is too large to fit
288 on the display.
289
290 @see @ref overview_dialog_autoscrolling (for more on layout adaptation)
23324ae1 291 */
4ccf0566 292 virtual bool DoLayoutAdaptation();
23324ae1
FM
293
294 /**
1db8f1dc
BP
295 This function is called when the titlebar OK button is pressed
296 (PocketPC only). A command event for the identifier returned by
297 GetAffirmativeId() is sent by default. You can override this function.
298 If the function returns @false, wxWidgets will call Close() for the
299 dialog.
4ccf0566
FM
300
301 @onlyfor{wxmsw}
23324ae1 302 */
4cc4bfaf 303 virtual bool DoOK();
23324ae1
FM
304
305 /**
1db8f1dc
BP
306 A static function enabling or disabling layout adaptation for all
307 dialogs.
308
309 @see @ref overview_dialog_autoscrolling (for more on layout adaptation)
23324ae1
FM
310 */
311 static void EnableLayoutAdaptation(bool enable);
312
313 /**
1db8f1dc
BP
314 Ends a modal dialog, passing a value to be returned from the
315 ShowModal() invocation.
3c4f71cc 316
7c913512 317 @param retCode
4cc4bfaf 318 The value that should be returned by ShowModal.
3c4f71cc 319
4cc4bfaf 320 @see ShowModal(), GetReturnCode(), SetReturnCode()
23324ae1 321 */
adaaa686 322 virtual void EndModal(int retCode);
23324ae1
FM
323
324 /**
1db8f1dc
BP
325 Gets the identifier of the button which works like standard OK button
326 in this dialog.
3c4f71cc 327
4cc4bfaf 328 @see SetAffirmativeId()
23324ae1 329 */
328f5751 330 int GetAffirmativeId() const;
23324ae1
FM
331
332 /**
1db8f1dc
BP
333 Override this to return a window containing the main content of the
334 dialog. This is particularly useful when the dialog implements pages,
335 such as wxPropertySheetDialog, and allows the
336 @ref overview_dialog "layout adaptation code" to know that only the
337 pages need to be made scrollable.
23324ae1 338 */
adaaa686 339 virtual wxWindow* GetContentWindow() const;
23324ae1
FM
340
341 /**
1db8f1dc 342 Gets the identifier of the button to map presses of @c ESC button to.
3c4f71cc 343
4cc4bfaf 344 @see SetEscapeId()
23324ae1 345 */
328f5751 346 int GetEscapeId() const;
23324ae1
FM
347
348 /**
1db8f1dc
BP
349 Returns @true if the dialog has been adapted, usually by making it
350 scrollable to work with a small display.
351
352 @see @ref overview_dialog_autoscrolling (for more on layout adaptation)
23324ae1 353 */
328f5751 354 bool GetLayoutAdaptationDone() const;
23324ae1
FM
355
356 /**
1db8f1dc
BP
357 Gets a value representing the aggressiveness of search for buttons and
358 sizers to be in the non-scrolling part of a layout-adapted dialog. Zero
359 switches off adaptation, and 3 allows search for standard buttons
360 anywhere in the dialog.
361
362 @see @ref overview_dialog_autoscrolling (for more on layout adaptation)
23324ae1 363 */
adaaa686 364 int GetLayoutAdaptationLevel() const;
23324ae1
FM
365
366 /**
367 Gets the adaptation mode, overriding the global adaptation flag.
1db8f1dc
BP
368
369 @see @ref overview_dialog_autoscrolling (for more on layout adaptation)
23324ae1 370 */
328f5751 371 wxDialogLayoutAdaptationMode GetLayoutAdaptationMode() const;
23324ae1
FM
372
373 /**
374 A static function getting the current layout adapter object.
1db8f1dc
BP
375
376 @see @ref overview_dialog_autoscrolling (for more on layout adaptation)
23324ae1
FM
377 */
378 static wxDialogLayoutAdapter* GetLayoutAdapter();
379
380 /**
1db8f1dc
BP
381 Returns an array of identifiers to be regarded as the main buttons for
382 the non-scrolling area of a dialog.
383
384 @see @ref overview_dialog_autoscrolling (for more on layout adaptation)
23324ae1 385 */
b91c4601 386 wxArrayInt& GetMainButtonIds();
23324ae1
FM
387
388 /**
389 Gets the return code for this window.
3c4f71cc 390
1db8f1dc
BP
391 @remarks A return code is normally associated with a modal dialog,
392 where ShowModal() returns a code to the application.
3c4f71cc 393
4cc4bfaf 394 @see SetReturnCode(), ShowModal(), EndModal()
23324ae1 395 */
adaaa686 396 int GetReturnCode() const;
23324ae1
FM
397
398 /**
399 On PocketPC, a dialog is automatically provided with an empty toolbar.
1db8f1dc
BP
400 This function allows you to access the toolbar and add tools to it.
401 Removing tools and adding arbitrary controls are not currently
402 supported.
403
23324ae1 404 This function is not available on any other platform.
4ccf0566
FM
405
406 @onlyfor{wxmsw}
23324ae1 407 */
328f5751 408 wxToolBar* GetToolBar() const;
23324ae1
FM
409
410 /**
411 Iconizes or restores the dialog. Windows only.
3c4f71cc 412
7c913512 413 @param iconize
4cc4bfaf 414 If @true, iconizes the dialog box; if @false, shows and restores it.
3c4f71cc 415
23324ae1 416 @remarks Note that in Windows, iconization has no effect since dialog
1db8f1dc
BP
417 boxes cannot be iconized. However, applications may need to
418 explicitly restore dialog boxes under Motif which have
419 user-iconizable frames, and under Windows calling
420 Iconize(@false) will bring the window to the front, as does
421 Show(@true).
23324ae1 422 */
43c48e1e 423 virtual void Iconize(bool iconize = true);
23324ae1
FM
424
425 /**
426 Returns @true if the dialog box is iconized. Windows only.
3c4f71cc 427
23324ae1 428 @remarks Always returns @false under Windows since dialogs cannot be
4cc4bfaf 429 iconized.
23324ae1 430 */
0004982c 431 virtual bool IsIconized() const;
23324ae1
FM
432
433 /**
1db8f1dc
BP
434 A static function returning @true if layout adaptation is enabled for
435 all dialogs.
436
437 @see @ref overview_dialog_autoscrolling (for more on layout adaptation)
23324ae1
FM
438 */
439 static bool IsLayoutAdaptationEnabled();
440
441 /**
1db8f1dc
BP
442 Returns @true if @a id is in the array of identifiers to be regarded as
443 the main buttons for the non-scrolling area of a dialog.
444
4ccf0566
FM
445 @onlyfor{wxmsw}
446
1db8f1dc 447 @see @ref overview_dialog_autoscrolling (for more on layout adaptation)
23324ae1 448 */
4ccf0566 449 bool IsMainButtonId(wxWindowID id) const;
23324ae1
FM
450
451 /**
452 Returns @true if the dialog box is modal, @false otherwise.
453 */
adaaa686 454 virtual bool IsModal() const;
23324ae1
FM
455
456 /**
3a194bda 457 The default handler for @c wxEVT_SYS_COLOUR_CHANGED.
3c4f71cc 458
7c913512 459 @param event
4cc4bfaf 460 The colour change event.
3c4f71cc 461
23324ae1 462 @remarks Changes the dialog's colour to conform to the current settings
1db8f1dc
BP
463 (Windows only). Add an event table entry for your dialog class
464 if you wish the behaviour to be different (such as keeping a
465 user-defined background colour). If you do override this
466 function, call wxEvent::Skip() to propagate the notification
467 to child windows and controls.
3c4f71cc 468
4cc4bfaf 469 @see wxSysColourChangedEvent
23324ae1
FM
470 */
471 void OnSysColourChanged(wxSysColourChangedEvent& event);
472
473 /**
474 Sets the identifier to be used as OK button. When the button with this
1db8f1dc
BP
475 identifier is pressed, the dialog calls wxWindow::Validate() and
476 wxWindow::TransferDataFromWindow() and, if they both return @true,
814bfbb9 477 closes the dialog with the affirmative id return code.
1db8f1dc
BP
478
479 Also, when the user presses a hardware OK button on the devices having
480 one or the special OK button in the PocketPC title bar, an event with
481 this id is generated.
482
23324ae1 483 By default, the affirmative id is wxID_OK.
3c4f71cc 484
4cc4bfaf 485 @see GetAffirmativeId(), SetEscapeId()
23324ae1
FM
486 */
487 void SetAffirmativeId(int id);
488
489 /**
7c913512 490 Sets the identifier of the button which should work like the standard
1db8f1dc
BP
491 "Cancel" button in this dialog. When the button with this id is
492 clicked, the dialog is closed. Also, when the user presses @c ESC key
493 in the dialog or closes the dialog using the close button in the title
494 bar, this is mapped to the click of the button with the specified id.
495
496 By default, the escape id is the special value wxID_ANY meaning that
497 wxID_CANCEL button is used if it's present in the dialog and otherwise
498 the button with GetAffirmativeId() is used. Another special value for
499 @a id is wxID_NONE meaning that @c ESC presses should be ignored. If
500 any other value is given, it is interpreted as the id of the button to
501 map the escape key to.
23324ae1
FM
502 */
503 void SetEscapeId(int id);
504
505 /**
506 Sets the icon for this dialog.
3c4f71cc 507
7c913512 508 @param icon
4cc4bfaf 509 The icon to associate with this dialog.
1db8f1dc
BP
510
511 @see wxIcon
23324ae1
FM
512 */
513 void SetIcon(const wxIcon& icon);
514
515 /**
516 Sets the icons for this dialog.
3c4f71cc 517
7c913512 518 @param icons
4cc4bfaf 519 The icons to associate with this dialog.
1db8f1dc
BP
520
521 @see wxIconBundle
23324ae1
FM
522 */
523 void SetIcons(const wxIconBundle& icons);
524
525 /**
1db8f1dc
BP
526 Marks the dialog as having been adapted, usually by making it
527 scrollable to work with a small display.
528
529 @see @ref overview_dialog_autoscrolling (for more on layout adaptation)
23324ae1
FM
530 */
531 void SetLayoutAdaptationDone(bool done);
532
533 /**
534 Sets the aggressiveness of search for buttons and sizers to be in the
1db8f1dc
BP
535 non-scrolling part of a layout-adapted dialog. Zero switches off
536 adaptation, and 3 allows search for standard buttons anywhere in the
537 dialog.
538
539 @see @ref overview_dialog_autoscrolling (for more on layout adaptation)
23324ae1
FM
540 */
541 void SetLayoutAdaptationLevel(int level);
542
543 /**
1db8f1dc 544 Sets the adaptation mode, overriding the global adaptation flag.
3c4f71cc 545
1db8f1dc
BP
546 @see wxDialogLayoutAdaptationMode, @ref overview_dialog_autoscrolling
547 (for more on layout adaptation)
23324ae1
FM
548 */
549 void SetLayoutAdaptationMode(wxDialogLayoutAdaptationMode mode);
550
551 /**
1db8f1dc
BP
552 A static function for setting the current layout adapter object,
553 returning the old adapter. If you call this, you should delete the old
554 adapter object.
555
556 @see wxDialogLayoutAdapter, @ref overview_dialog_autoscrolling
23324ae1
FM
557 */
558 static wxDialogLayoutAdapter* SetLayoutAdapter(wxDialogLayoutAdapter* adapter);
559
560 /**
1db8f1dc
BP
561 @deprecated This function doesn't work for all ports, just use
562 ShowModal() to show a modal dialog instead.
563
564 Allows the programmer to specify whether the dialog box is modal
565 (Show() blocks control until the dialog is hidden) or modeless (control
566 returns immediately).
3c4f71cc 567
7c913512 568 @param flag
4cc4bfaf 569 If @true, the dialog will be modal, otherwise it will be modeless.
23324ae1
FM
570 */
571 void SetModal(bool flag);
572
573 /**
574 Sets the return code for this window.
3c4f71cc 575
1db8f1dc
BP
576 A return code is normally associated with a modal dialog, where
577 ShowModal() returns a code to the application. The function EndModal()
578 calls SetReturnCode().
579
7c913512 580 @param retCode
4cc4bfaf 581 The integer return code, usually a control identifier.
3c4f71cc 582
4cc4bfaf 583 @see GetReturnCode(), ShowModal(), EndModal()
23324ae1
FM
584 */
585 void SetReturnCode(int retCode);
586
587 /**
1db8f1dc
BP
588 Hides or shows the dialog. The preferred way of dismissing a modal
589 dialog is to use EndModal().
3c4f71cc 590
7c913512 591 @param show
1db8f1dc
BP
592 If @true, the dialog box is shown and brought to the front,
593 otherwise the box is hidden. If @false and the dialog is modal,
594 control is returned to the calling program.
23324ae1 595 */
b91c4601 596 virtual bool Show(bool show = 1);
23324ae1
FM
597
598 /**
c088756c 599 Shows an application-modal dialog.
dc28b856
VZ
600
601 Program flow does not return until the dialog has been dismissed with
602 EndModal().
603
604 Notice that it is possible to call ShowModal() for a dialog which had
605 been previously shown with Show(), this allows to make an existing
606 modeless dialog modal. However ShowModal() can't be called twice
607 without intervening EndModal() calls.
1db8f1dc 608
e10539a9
FM
609 Note that this function creates a temporary event loop which takes
610 precedence over the application's main event loop (see wxEventLoopBase)
611 and which is destroyed when the dialog is dismissed.
8f139810 612 This also results in a call to wxApp::ProcessPendingEvents().
e10539a9 613
d29a9a8a 614 @return The value set with SetReturnCode().
3c4f71cc 615
c088756c 616 @see ShowWindowModal(), EndModal(), GetReturnCode(), SetReturnCode()
23324ae1 617 */
adaaa686 618 virtual int ShowModal();
c088756c
VZ
619
620 /**
621 Shows a dialog modal to the parent top level window only.
622
623 Unlike ShowModal(), dialogs shown with this function only prevent the
624 user from interacting with their parent frame only but not with the
625 rest of the application. They also don't block the program execution
626 but instead return immediately, as Show(), and generate a
627 wxEVT_WINDOW_MODAL_DIALOG_CLOSED event later when the dialog is closed.
628
629 Currently this function is only fully implemented in wxOSX ports, under
630 the other platforms it behaves like ShowModal() (but also sends the
631 above mentioned event).
632
633 @since 2.9.0
634 */
635 void ShowWindowModal();
23324ae1
FM
636};
637
638
e54c96f1 639
23324ae1
FM
640/**
641 @class wxDialogLayoutAdapter
7c913512 642
d13b34d3 643 This abstract class is the base for classes that help wxWidgets perform
1db8f1dc
BP
644 run-time layout adaptation of dialogs. Principally, this is to cater for
645 small displays by making part of the dialog scroll, but the application
646 developer may find other uses for layout adaption.
7c913512 647
1db8f1dc
BP
648 By default, there is one instance of wxStandardDialogLayoutAdapter which
649 can perform adaptation for most custom dialogs and dialogs with book
650 controls such as wxPropertySheetDialog.
7c913512 651
23324ae1 652 @library{wxcore}
1db8f1dc 653 @category{winlayout}
7c913512 654
1db8f1dc 655 @see @ref overview_dialog_autoscrolling
23324ae1 656*/
7c913512 657class wxDialogLayoutAdapter
23324ae1
FM
658{
659public:
660 /**
661 Default constructor.
662 */
663 wxDialogLayoutAdapter();
664
665 /**
666 Override this to returns @true if adaptation can and should be done.
667 */
b91c4601 668 virtual bool CanDoLayoutAdaptation(wxDialog* dialog) = 0;
23324ae1
FM
669
670 /**
1db8f1dc
BP
671 Override this to perform layout adaptation, such as making parts of the
672 dialog scroll and resizing the dialog to fit the display. Normally this
673 function will be called just before the dialog is shown.
23324ae1 674 */
b91c4601 675 virtual bool DoLayoutAdaptation(wxDialog* dialog) = 0;
23324ae1 676};
e54c96f1 677
6e350141
RD
678
679class wxWindowModalDialogEvent : public wxCommandEvent
680{
681public:
682 wxWindowModalDialogEvent (wxEventType commandType = wxEVT_NULL, int id = 0);
683
684 wxDialog *GetDialog() const;
685 int GetReturnCode() const;
686 virtual wxEvent *Clone() const;
687};