]>
Commit | Line | Data |
---|---|---|
15b6757b | 1 | ///////////////////////////////////////////////////////////////////////////// |
d54cf7ff | 2 | // Name: dialog.h |
15b6757b FM |
3 | // Purpose: topic overview |
4 | // Author: wxWidgets team | |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
880efa2a | 9 | /** |
36c9828f | 10 | |
928f1a07 | 11 | @page overview_dialog wxDialog Overview |
36c9828f | 12 | |
928f1a07 | 13 | Classes: wxDialog, wxDialogLayoutAdapter |
d54cf7ff | 14 | |
928f1a07 FM |
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: | |
36c9828f | 17 | |
928f1a07 FM |
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. | |
36c9828f | 23 | |
928f1a07 | 24 | For a set of dialog convenience functions, including file selection, see |
409e6ce4 | 25 | @ref group_funcmacro_dialog. |
d54cf7ff | 26 | |
928f1a07 FM |
27 | See also wxTopLevelWindow and wxWindow for inherited |
28 | member functions. Validation of data in controls is covered in @ref overview_validator. | |
d54cf7ff FM |
29 | |
30 | ||
928f1a07 | 31 | @li @ref overview_dialog_autoscrolling |
30738aae FM |
32 | |
33 | ||
928f1a07 | 34 | <hr> |
30738aae FM |
35 | |
36 | ||
36c9828f | 37 | |
928f1a07 | 38 | @section overview_dialog_autoscrolling Automatic scrolling dialogs |
36c9828f | 39 | |
928f1a07 FM |
40 | As an ever greater variety of mobile hardware comes to market, it becomes more |
41 | imperative for wxWidgets applications to adapt to these platforms without putting | |
42 | too much burden on the programmer. One area where wxWidgets can help is in adapting | |
43 | dialogs for the lower resolution screens that inevitably accompany a smaller form factor. | |
44 | wxDialog therefore supplies a global wxDialogLayoutAdapter class that implements | |
45 | automatic scrolling adaptation for most sizer-based custom dialogs. | |
d54cf7ff | 46 | |
928f1a07 FM |
47 | Many applications should therefore be able to adapt to small displays with little |
48 | or no work, as far as dialogs are concerned. | |
49 | By default this adaptation is off. To switch scrolling adaptation on globally in | |
50 | your application, call the static function wxDialog::EnableLayoutAdaptation passing @true. | |
51 | You can also adjust adaptation on a per-dialog basis by calling | |
52 | wxDialog::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. | |
36c9828f | 54 | |
928f1a07 FM |
55 | The last two modes override the global adaptation setting. |
56 | With adaptation enabled, if the display size is too small for the dialog, wxWidgets (or rather the | |
57 | standard adapter class wxStandardDialogLayoutAdapter) will make part of the dialog scrolling, | |
58 | leaving standard buttons in a non-scrolling part at the bottom of the dialog. | |
59 | This is done as follows, in wxDialogLayoutAdapter::DoLayoutAdaptation called from | |
60 | within wxDialog::Show or wxDialog::ShowModal: | |
d54cf7ff | 61 | |
928f1a07 FM |
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. | |
f09b5681 | 70 | @li All the children apart from standard buttons are reparented onto a new ::wxScrolledWindow |
928f1a07 FM |
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. | |
d54cf7ff FM |
73 | |
74 | ||
928f1a07 | 75 | @subsection overview_dialog_autoscrolling_custom Customising scrolling adaptation |
d54cf7ff | 76 | |
928f1a07 FM |
77 | In addition to switching adaptation on and off globally and per dialog, |
78 | you can choose how aggressively wxWidgets will search for standard buttons by setting | |
79 | wxDialog::SetLayoutAdaptationLevel. By default, all the steps described above will be | |
80 | performed but by setting the level to 1, for example, you can choose to only look for | |
81 | wxStdDialogButtonSizer. | |
d54cf7ff | 82 | |
928f1a07 FM |
83 | You can use wxDialog::AddMainButtonId to add identifiers for buttons that should also be |
84 | treated as standard buttons for the non-scrolling area. | |
d54cf7ff | 85 | |
928f1a07 FM |
86 | You can derive your own class from wxDialogLayoutAdapter or wxStandardDialogLayoutAdapter and call |
87 | wxDialog::SetLayoutAdapter, deleting the old object that this function returns. Override | |
88 | the functions CanDoLayoutAdaptation and DoLayoutAdaptation to test for adaptation applicability | |
89 | and perform the adaptation. | |
d54cf7ff | 90 | |
928f1a07 FM |
91 | You can also override wxDialog::CanDoLayoutAdaptation and wxDialog::DoLayoutAdaptation |
92 | in a class derived from wxDialog. | |
d54cf7ff | 93 | |
36c9828f | 94 | |
928f1a07 | 95 | @subsection overview_dialog_autoscrolling_fail Situations where automatic scrolling adaptation may fail |
36c9828f | 96 | |
928f1a07 FM |
97 | Because adaptation rearranges your sizer and window hierarchy, it is not fool-proof, |
98 | and may fail in the following situations: | |
36c9828f | 99 | |
928f1a07 FM |
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. | |
36c9828f | 112 | |
928f1a07 | 113 | You can help make sure that your dialogs will continue to function after adaptation by: |
36c9828f | 114 | |
928f1a07 FM |
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. | |
36c9828f | 122 | |
36c9828f | 123 | |
928f1a07 | 124 | @subsection overview_dialog_propertysheet wxPropertySheetDialog and wxWizard |
36c9828f | 125 | |
928f1a07 FM |
126 | Adaptation for wxPropertySheetDialog is always done by simply making the pages |
127 | scrollable, since wxDialog::GetContentWindow returns the dialog's book control and | |
128 | this is handled by the standard layout adapter. | |
36c9828f | 129 | |
928f1a07 FM |
130 | wxWizard uses its own CanDoLayoutAdaptation and DoLayoutAdaptation functions rather |
131 | than the global adapter: again, only the wizard pages are made scrollable. | |
36c9828f | 132 | |
d54cf7ff | 133 | */ |
36c9828f | 134 |