]> git.saurik.com Git - wxWidgets.git/blame - docs/doxygen/overviews/dialog.h
Move wx/msw/gccpriv.h inclusion back to wx/platform.h from wx/compiler.h.
[wxWidgets.git] / docs / doxygen / overviews / dialog.h
CommitLineData
15b6757b 1/////////////////////////////////////////////////////////////////////////////
d54cf7ff 2// Name: dialog.h
15b6757b
FM
3// Purpose: topic overview
4// Author: wxWidgets team
5// RCS-ID: $Id$
526954c5 6// Licence: wxWindows licence
15b6757b
FM
7/////////////////////////////////////////////////////////////////////////////
8
880efa2a 9/**
36c9828f 10
928f1a07 11@page overview_dialog wxDialog Overview
36c9828f 12
ce154616
BP
13@tableofcontents
14
928f1a07 15Classes: wxDialog, wxDialogLayoutAdapter
d54cf7ff 16
ce154616
BP
17A dialog box is similar to a panel, in that it is a window which can be used
18for placing controls, with the following exceptions:
36c9828f 19
928f1a07 20@li A surrounding frame is implicitly created.
ce154616
BP
21@li Extra functionality is automatically given to the dialog box, such as
22 tabbing between items (currently Windows only).
23@li If the dialog box is @e modal, the calling program is blocked until the
24 dialog box is dismissed.
36c9828f 25
928f1a07 26For a set of dialog convenience functions, including file selection, see
409e6ce4 27@ref group_funcmacro_dialog.
d54cf7ff 28
ce154616
BP
29See also wxTopLevelWindow and wxWindow for inherited member functions.
30Validation of data in controls is covered in @ref overview_validator.
30738aae
FM
31
32
30738aae 33
ce154616 34@section overview_dialog_autoscrolling Automatic Scrolled Dialogs
36c9828f 35
928f1a07 36As an ever greater variety of mobile hardware comes to market, it becomes more
ce154616
BP
37imperative for wxWidgets applications to adapt to these platforms without
38putting too much burden on the programmer. One area where wxWidgets can help is
39in adapting dialogs for the lower resolution screens that inevitably accompany
40a smaller form factor. wxDialog therefore supplies a global
41wxDialogLayoutAdapter class that implements automatic scrolling adaptation for
42most sizer-based custom dialogs.
43
44Many applications should therefore be able to adapt to small displays with
45little or no work, as far as dialogs are concerned. By default this adaptation
46is off. To switch scrolling adaptation on globally in your application, call
47the static function wxDialog::EnableLayoutAdaptation passing @true. You can
48also adjust adaptation on a per-dialog basis by calling
49wxDialog::SetLayoutAdaptationMode with one of
50@c wxDIALOG_ADAPTATION_MODE_DEFAULT (use the global setting),
51@c wxDIALOG_ADAPTATION_MODE_ENABLED or @c wxDIALOG_ADAPTATION_MODE_DISABLED.
52
53The last two modes override the global adaptation setting. With adaptation
54enabled, if the display size is too small for the dialog, wxWidgets (or rather
55the standard adapter class wxStandardDialogLayoutAdapter) will make part of the
56dialog scrolling, leaving standard buttons in a non-scrolling part at the
57bottom of the dialog. This is done as follows, in
58wxDialogLayoutAdapter::DoLayoutAdaptation called from within wxDialog::Show or
59wxDialog::ShowModal:
d54cf7ff 60
928f1a07
FM
61@li If wxDialog::GetContentWindow returns a window derived from wxBookCtrlBase,
62 the pages are made scrollable and no other adaptation is done.
ce154616
BP
63@li wxWidgets looks for a wxStdDialogButtonSizer and uses it for the
64 non-scrolling part.
65@li If that search failed, wxWidgets looks for a horizontal wxBoxSizer with one
66 or more standard buttons, with identifiers such as @c wxID_OK and
67 @c wxID_CANCEL.
68@li If that search failed too, wxWidgets finds 'loose' standard buttons (in any
69 kind of sizer) and adds them to a wxStdDialogButtonSizer. If no standard
70 buttons were found, the whole dialog content will scroll.
71@li All the children apart from standard buttons are reparented onto a new
72 ::wxScrolledWindow object, using the old top-level sizer for the scrolled
73 window and creating a new top-level sizer to lay out the scrolled window
74 and standard button sizer.
d54cf7ff
FM
75
76
ce154616 77@subsection overview_dialog_autoscrolling_custom Customising Scrolling Adaptation
d54cf7ff 78
ce154616
BP
79In addition to switching adaptation on and off globally and per dialog, you can
80choose how aggressively wxWidgets will search for standard buttons by setting
81wxDialog::SetLayoutAdaptationLevel. By default, all the steps described above
82will be performed but by setting the level to 1, for example, you can choose to
83only look for wxStdDialogButtonSizer.
d54cf7ff 84
ce154616
BP
85You can use wxDialog::AddMainButtonId to add identifiers for buttons that
86should also be treated as standard buttons for the non-scrolling area.
d54cf7ff 87
ce154616
BP
88You can derive your own class from wxDialogLayoutAdapter or
89wxStandardDialogLayoutAdapter and call wxDialog::SetLayoutAdapter, deleting the
90old object that this function returns. Override the functions
91CanDoLayoutAdaptation and DoLayoutAdaptation to test for adaptation
92applicability and perform the adaptation.
d54cf7ff 93
ce154616
BP
94You can also override wxDialog::CanDoLayoutAdaptation and
95wxDialog::DoLayoutAdaptation in a class derived from wxDialog.
d54cf7ff 96
36c9828f 97
ce154616 98@subsection overview_dialog_autoscrolling_fail Where Scrolling Adaptation May Fail
36c9828f 99
ce154616
BP
100Because adaptation rearranges your sizer and window hierarchy, it is not
101fool-proof, and may fail in the following situations:
36c9828f 102
928f1a07
FM
103@li The dialog doesn't use sizers.
104@li The dialog implementation makes assumptions about the window hierarchy,
105 for example getting the parent of a control and casting to the dialog class.
106@li The dialog does custom painting and/or event handling not handled by the scrolled window.
107 If this problem can be solved globally, you can derive a new adapter class from
108 wxStandardDialogLayoutAdapter and override its CreateScrolledWindow function to return
109 an instance of your own class.
110@li The dialog has unusual layout, for example a vertical sizer containing a mixture of
111 standard buttons and other controls.
112@li The dialog makes assumptions about the sizer hierarchy, for example to show or hide
113 children of the top-level sizer. However, the original sizer hierarchy will still hold
114 until Show or ShowModal is called.
36c9828f 115
ce154616
BP
116You can help make sure that your dialogs will continue to function after
117adaptation by:
36c9828f 118
928f1a07
FM
119@li avoiding the above situations and assumptions;
120@li using wxStdDialogButtonSizer;
121@li only making assumptions about hierarchy immediately after the dialog is created;
122@li using an intermediate sizer under the main sizer, a @false top-level sizer that
123 can be relied on to exist for the purposes of manipulating child sizers and windows;
124@li overriding wxDialog::GetContentWindow to return a book control if your dialog implements
125 pages: wxWidgets will then only make the pages scrollable.
36c9828f 126
36c9828f 127
928f1a07 128@subsection overview_dialog_propertysheet wxPropertySheetDialog and wxWizard
36c9828f 129
928f1a07 130Adaptation for wxPropertySheetDialog is always done by simply making the pages
ce154616
BP
131scrollable, since wxDialog::GetContentWindow returns the dialog's book control
132and this is handled by the standard layout adapter.
36c9828f 133
ce154616
BP
134wxWizard uses its own CanDoLayoutAdaptation and DoLayoutAdaptation functions
135rather than the global adapter: again, only the wizard pages are made
136scrollable.
36c9828f 137
d54cf7ff 138*/