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