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