]> git.saurik.com Git - wxWidgets.git/blame - docs/doxygen/overviews/windowsizing.h
wxMessageBox off the main thread lost result code.
[wxWidgets.git] / docs / doxygen / overviews / windowsizing.h
CommitLineData
15b6757b 1/////////////////////////////////////////////////////////////////////////////
3863c5eb 2// Name: windowsizing.h
15b6757b
FM
3// Purpose: topic overview
4// Author: wxWidgets team
526954c5 5// Licence: wxWindows licence
15b6757b
FM
6/////////////////////////////////////////////////////////////////////////////
7
880efa2a 8/**
36c9828f 9
cded6aa1 10@page overview_windowsizing Window Sizing Overview
3863c5eb 11
831e1028
BP
12@tableofcontents
13
3863c5eb
BP
14It can sometimes be confusing to keep track of the various size-related
15attributes of a wxWindow, how they relate to each other, and how they interact
16with sizers. This document will attempt to clear the fog a little, and give
17some simple explanations of things.
18
edbcb094
FM
19
20
21@section overview_windowsizing_glossary Glossary
cded6aa1 22
386279c3
VZ
23@li @b "Size": this is the current size of the window and it can be explicitly
24 set or fetched with the wxWindow::SetSize() or wxWindow::GetSize() methods.
25 This size value is the size that the widget is currently using on screen and is
26 the way to change the size of something that is not being managed by a sizer.
27
28@li @b "Client Size": the client size represents the widget's area inside of any
29 borders belonging to the widget and is the area that can be drawn upon in a
30 @c EVT_PAINT event. For wxFrame, the client size also excludes the frame
31 menu, tool and status bars, if any. If a window doesn't have any border
32 (and is not a wxFrame with some bars) then its client size is the same as
33 its size.
34
cded6aa1
FM
35@li @b "Best Size": the best size of a widget depends on what kind of widget it is,
36 and usually also on the contents of the widget. For example a wxListBox's best
37 size will be calculated based on how many items it has, up to a certain limit,
38 or a wxButton's best size will be calculated based on its label size, but
39 normally won't be smaller than the platform default button size (unless a style
40 flag overrides that).
41 There is a special virtual method in the C++ window classes called
386279c3
VZ
42 wxWindow::DoGetBestSize() that a class can override if it wants to calculate
43 its own best size based on its content, however notice that usually it is
44 more convenient to override DoGetBestClientSize(), see below.
45
46@li @b "Best Client Size": this is simply the client size corresponding to the
47 best window size. When the fitting size for the given contents is computed,
48 it will usually be the client size and the size of the borders needs to be
49 added to obtain the full best size. For this reason, it's preferable to
50 override DoGetBestClientSize() and let DoGetBestSize() compute the full
51 best size.
cded6aa1 52
d9ced90b
FM
53@li @b "Minimal Size": the minimal size of a widget is a size that is normally explicitly
54 set by the programmer either with the wxWindow::SetMinSize() method or with the
cded6aa1 55 wxWindow::SetSizeHints() method.
d9ced90b 56 Most controls will also set the minimal size to the size given in the control's
cded6aa1
FM
57 constructor if a non-default value is passed.
58 Top-level windows such as wxFrame will not allow the user to resize the frame below
59 the minimal size.
60
d9ced90b 61@li @b "Maximum Size": just like for the minimal size, the maximum size is normally
4c51a665 62 explicitly set by the programmer with the wxWindow::SetMaxSize() method or
d9ced90b
FM
63 with wxWindow::SetSizeHints().
64 Top-level windows such as wxFrame will not allow the user to resize the frame above
65 the maximum size.
66
cded6aa1
FM
67@li @b "Initial Size": the initial size of a widget is the size given to the
68 constructor of the widget, if any.
69 As mentioned above most controls will also set this size value as the control's
70 minimal size. If the size passed to the constructor is the default ::wxDefaultSize,
71 or if the size is not fully specified (such as wxSize(150,-1)) then most controls
72 will fill in the missing size components using the best size and will set the
73 initial size of the control to the resulting size.
74
d9ced90b
FM
75@li @b "Virtual Size": the virtual size is the size of the potentially viewable
76 area of the widget.
77 The virtual size of a widget may be larger than its actual size and in this
78 case scrollbars will appear to the let the user 'explore' the full contents
79 of the widget.
80 See wxScrolled for more info.
81
cded6aa1 82
edbcb094 83@section overview_windowsizing_func Functions related to sizing
cded6aa1
FM
84
85@li wxWindow::GetEffectiveMinSize(): returns a blending of the widget's minimal size
86 and best size, giving precedence to the minimal size.
87 For example, if a widget's min size is set to (150, -1) and the best size is
88 (80, 22) then the best fitting size is (150, 22). If the min size is (50, 20)
89 then the best fitting size is (50, 20). This method is what is called by the
90 sizers when determining what the requirements of each item in the sizer is,
91 and is used for calculating the overall minimum needs of the sizer.
92
93@li wxWindow::SetInitialSize(): this is a little different than the typical size
94 setters. Rather than just setting an "initial size" attribute it actually sets
95 the minimal size to the value passed in, blends that value with the best size,
96 and then sets the size of the widget to be the result.
97 So you can consider this method to be a "Smart SetSize". This method is what is
98 called by the constructor of most controls to set the minimal size and the initial
99 size of the control.
100
101@li wxWindow::Fit(): this method sets the size of a window to fit around its children.
102 If it has no children then nothing is done, if it does have children then the size
103 of the window is set to the window's best size.
104
105@li wxSizer::Fit(): this sets the size of the window to be large enough to
106 accommodate the minimum size needed by the sizer, (along with a few other
107 constraints...). If the sizer is the one that is assigned to the window then
108 this should be equivalent to wxWindow::Fit().
109
110@li wxSizer::Layout(): recalculates the minimum space needed by each item in the
111 sizer, and then lays out the items within the space currently allotted to the sizer.
112
113@li wxWindow::Layout(): if the window has a sizer then it sets the space given to
114 the sizer to the current size of the window, which results in a call to
115 wxSizer::Layout(). If the window has layout constraints instead of a sizer then
116 the constraints algorithm is run. The @c Layout() method is what is called by
117 the default @c EVT_SIZE handler for container windows.
3863c5eb
BP
118
119*/