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