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