]> git.saurik.com Git - wxWidgets.git/blob - docs/doxygen/overviews/windowsizing.h
Added margin to event handler function prototypes for IE6 and IE7 which were renderin...
[wxWidgets.git] / docs / doxygen / overviews / windowsizing.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: windowsizing.h
3 // Purpose: topic overview
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10
11 @page overview_windowsizing Window Sizing Overview
12
13 It can sometimes be confusing to keep track of the various size-related
14 attributes of a wxWindow, how they relate to each other, and how they interact
15 with sizers. This document will attempt to clear the fog a little, and give
16 some simple explanations of things.
17
18 Glossary:
19
20 @li @b "Best Size": the best size of a widget depends on what kind of widget it is,
21 and usually also on the contents of the widget. For example a wxListBox's best
22 size will be calculated based on how many items it has, up to a certain limit,
23 or a wxButton's best size will be calculated based on its label size, but
24 normally won't be smaller than the platform default button size (unless a style
25 flag overrides that).
26 There is a special virtual method in the C++ window classes called
27 wxWindow::DoGetBestSize() that a class needs to override if it wants to calculate
28 its own best size based on its content.
29
30 @li @b "Min Size": the minimal size of a widget is a size that is normally explicitly set
31 by the programmer either with the wxWindow::SetMinSize() method or with the
32 wxWindow::SetSizeHints() method.
33 Most controls will also set the min size to the size given in the control's
34 constructor if a non-default value is passed.
35 Top-level windows such as wxFrame will not allow the user to resize the frame below
36 the minimal size.
37
38 @li @b "Size": the size of a widget can be explicitly set or fetched with the
39 wxWindow::SetSize() or wxWindow::GetSize() methods.
40 This size value is the size that the widget is currently using on screen and is
41 the way to change the size of something that is not being managed by a sizer.
42
43 @li @b "Client Size": the client size represents the widget's area inside of any
44 borders belonging to the widget and is the area that can be drawn upon in a
45 @c EVT_PAINT event. If a widget doesn't have a border then its client size is
46 the same as its size.
47
48 @li @b "Initial Size": the initial size of a widget is the size given to the
49 constructor of the widget, if any.
50 As mentioned above most controls will also set this size value as the control's
51 minimal size. If the size passed to the constructor is the default ::wxDefaultSize,
52 or if the size is not fully specified (such as wxSize(150,-1)) then most controls
53 will fill in the missing size components using the best size and will set the
54 initial size of the control to the resulting size.
55
56
57 Functions related to sizing:
58
59 @li wxWindow::GetEffectiveMinSize(): returns a blending of the widget's minimal size
60 and best size, giving precedence to the minimal size.
61 For example, if a widget's min size is set to (150, -1) and the best size is
62 (80, 22) then the best fitting size is (150, 22). If the min size is (50, 20)
63 then the best fitting size is (50, 20). This method is what is called by the
64 sizers when determining what the requirements of each item in the sizer is,
65 and is used for calculating the overall minimum needs of the sizer.
66
67 @li wxWindow::SetInitialSize(): this is a little different than the typical size
68 setters. Rather than just setting an "initial size" attribute it actually sets
69 the minimal size to the value passed in, blends that value with the best size,
70 and then sets the size of the widget to be the result.
71 So you can consider this method to be a "Smart SetSize". This method is what is
72 called by the constructor of most controls to set the minimal size and the initial
73 size of the control.
74
75 @li wxWindow::Fit(): this method sets the size of a window to fit around its children.
76 If it has no children then nothing is done, if it does have children then the size
77 of the window is set to the window's best size.
78
79 @li wxSizer::Fit(): this sets the size of the window to be large enough to
80 accommodate the minimum size needed by the sizer, (along with a few other
81 constraints...). If the sizer is the one that is assigned to the window then
82 this should be equivalent to wxWindow::Fit().
83
84 @li wxSizer::Layout(): recalculates the minimum space needed by each item in the
85 sizer, and then lays out the items within the space currently allotted to the sizer.
86
87 @li wxWindow::Layout(): if the window has a sizer then it sets the space given to
88 the sizer to the current size of the window, which results in a call to
89 wxSizer::Layout(). If the window has layout constraints instead of a sizer then
90 the constraints algorithm is run. The @c Layout() method is what is called by
91 the default @c EVT_SIZE handler for container windows.
92
93 */
94