1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>wxWidgets: Window Sizing Overview</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="extra_stylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="page_container">
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0" style="width: 100%;">
<tbody>
<tr>
<td id="projectlogo">
<a href="http://www.wxwidgets.org/" target="_new">
<img alt="wxWidgets" src="logo.png"/>
</a>
</td>
<td style="padding-left: 0.5em; text-align: right;">
<span id="projectnumber">Version: 3.0.2</span>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Generated by Doxygen 1.8.2 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li class="current"><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="modules.html"><span>Categories</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="index.html">Documentation</a></li><li class="navelem"><a class="el" href="page_topics.html">Programming Guides</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">Window Sizing Overview </div> </div>
</div><!--header-->
<div class="contents">
<div class="toc"><h3>Table of Contents</h3>
<ul><li class="level1"><a href="#overview_windowsizing_glossary">Glossary</a></li>
<li class="level1"><a href="#overview_windowsizing_func">Functions related to sizing</a></li>
</ul>
</div>
<div class="textblock"><p>It can sometimes be confusing to keep track of the various size-related attributes of a <a class="el" href="classwx_window.html" title="wxWindow is the base class for all windows and represents any visible object on screen.">wxWindow</a>, how they relate to each other, and how they interact with sizers.</p>
<p>This document will attempt to clear the fog a little, and give some simple explanations of things.</p>
<h1><a class="anchor" id="overview_windowsizing_glossary"></a>
Glossary</h1>
<ul>
<li><b>"Size"</b>: this is the current size of the window and it can be explicitly set or fetched with the <a class="el" href="classwx_window.html#a180312d5ad4a4a5ad805b8d52d67a74e" title="Sets the size of the window in pixels.">wxWindow::SetSize()</a> or <a class="el" href="classwx_window.html#a124c12cff1e7b6e96a5e1fd3e48dca34" title="Returns the size of the entire window in pixels, including title bar, border, scrollbars, etc.">wxWindow::GetSize()</a> methods. This size value is the size that the widget is currently using on screen and is the way to change the size of something that is not being managed by a sizer.</li>
</ul>
<ul>
<li><b>"Client Size"</b>: the client size represents the widget's area inside of any borders belonging to the widget and is the area that can be drawn upon in a <code>EVT_PAINT</code> event. For <a class="el" href="classwx_frame.html" title="A frame is a window whose size and position can (usually) be changed by the user.">wxFrame</a>, the client size also excludes the frame menu, tool and status bars, if any. If a window doesn't have any border (and is not a <a class="el" href="classwx_frame.html" title="A frame is a window whose size and position can (usually) be changed by the user.">wxFrame</a> with some bars) then its client size is the same as its size.</li>
</ul>
<ul>
<li><b>"Best Size"</b>: the best size of a widget depends on what kind of widget it is, and usually also on the contents of the widget. For example a <a class="el" href="classwx_list_box.html" title="A listbox is used to select one or more of a list of strings.">wxListBox</a>'s best size will be calculated based on how many items it has, up to a certain limit, or a <a class="el" href="classwx_button.html" title="A button is a control that contains a text string, and is one of the most common elements of a GUI...">wxButton</a>'s best size will be calculated based on its label size, but normally won't be smaller than the platform default button size (unless a style flag overrides that). There is a special virtual method in the C++ window classes called <a class="el" href="classwx_window.html#a01e7604ab0f0b2b1a8e322a630a4669e" title="Implementation of GetBestSize() that can be overridden.">wxWindow::DoGetBestSize()</a> that a class can override if it wants to calculate its own best size based on its content, however notice that usually it is more convenient to override DoGetBestClientSize(), see below.</li>
</ul>
<ul>
<li><b>"Best Client Size"</b>: this is simply the client size corresponding to the best window size. When the fitting size for the given contents is computed, it will usually be the client size and the size of the borders needs to be added to obtain the full best size. For this reason, it's preferable to override DoGetBestClientSize() and let DoGetBestSize() compute the full best size.</li>
</ul>
<ul>
<li><b>"Minimal Size"</b>: the minimal size of a widget is a size that is normally explicitly set by the programmer either with the <a class="el" href="classwx_window.html#a3fc066f4d8083319f004ac43811d545d" title="Sets the minimum size of the window, to indicate to the sizer layout mechanism that this is the minim...">wxWindow::SetMinSize()</a> method or with the <a class="el" href="classwx_window.html#a307329dc3b10f5584aeb2cbce9293ffd" title="Use of this function for windows which are not toplevel windows (such as wxDialog or wxFrame) is disc...">wxWindow::SetSizeHints()</a> method. Most controls will also set the minimal size to the size given in the control's constructor if a non-default value is passed. Top-level windows such as <a class="el" href="classwx_frame.html" title="A frame is a window whose size and position can (usually) be changed by the user.">wxFrame</a> will not allow the user to resize the frame below the minimal size.</li>
</ul>
<ul>
<li><b>"Maximum Size"</b>: just like for the minimal size, the maximum size is normally explicitly set by the programmer with the <a class="el" href="classwx_window.html#a38b496214d728a3212afadee5ed51606" title="Sets the maximum size of the window, to indicate to the sizer layout mechanism that this is the maxim...">wxWindow::SetMaxSize()</a> method or with <a class="el" href="classwx_window.html#a307329dc3b10f5584aeb2cbce9293ffd" title="Use of this function for windows which are not toplevel windows (such as wxDialog or wxFrame) is disc...">wxWindow::SetSizeHints()</a>. Top-level windows such as <a class="el" href="classwx_frame.html" title="A frame is a window whose size and position can (usually) be changed by the user.">wxFrame</a> will not allow the user to resize the frame above the maximum size.</li>
</ul>
<ul>
<li><b>"Initial Size"</b>: the initial size of a widget is the size given to the constructor of the widget, if any. As mentioned above most controls will also set this size value as the control's minimal size. If the size passed to the constructor is the default <a class="el" href="gdicmn_8h.html#a33a012cdb075e9f78c93f63bec2dc27b" title="Global instance of a wxSize object initialized to (-1,-1).">wxDefaultSize</a>, or if the size is not fully specified (such as <a class="el" href="classwx_size.html" title="A wxSize is a useful data structure for graphics operations.">wxSize</a>(150,-1)) then most controls will fill in the missing size components using the best size and will set the initial size of the control to the resulting size.</li>
</ul>
<ul>
<li><b>"Virtual Size"</b>: the virtual size is the size of the potentially viewable area of the widget. The virtual size of a widget may be larger than its actual size and in this case scrollbars will appear to the let the user 'explore' the full contents of the widget. See <a class="el" href="classwx_scrolled.html" title="The wxScrolled class manages scrolling for its client area, transforming the coordinates according to...">wxScrolled</a> for more info.</li>
</ul>
<h1><a class="anchor" id="overview_windowsizing_func"></a>
Functions related to sizing</h1>
<ul>
<li><a class="el" href="classwx_window.html#a1a54fcda8d52986482e030bd54739e9f" title="Merges the window's best size into the min size and returns the result.">wxWindow::GetEffectiveMinSize()</a>: returns a blending of the widget's minimal size and best size, giving precedence to the minimal size. For example, if a widget's min size is set to (150, -1) and the best size is (80, 22) then the best fitting size is (150, 22). If the min size is (50, 20) then the best fitting size is (50, 20). This method is what is called by the sizers when determining what the requirements of each item in the sizer is, and is used for calculating the overall minimum needs of the sizer.</li>
</ul>
<ul>
<li><a class="el" href="classwx_window.html#a1b309ca50ba87e34f968c83b79af1397" title="A smart SetSize that will fill in default size components with the window's best size values...">wxWindow::SetInitialSize()</a>: this is a little different than the typical size setters. Rather than just setting an "initial size" attribute it actually sets the minimal size to the value passed in, blends that value with the best size, and then sets the size of the widget to be the result. So you can consider this method to be a "Smart SetSize". This method is what is called by the constructor of most controls to set the minimal size and the initial size of the control.</li>
</ul>
<ul>
<li><a class="el" href="classwx_window.html#a2bf38a6cbd1f82fb46f274396f482994" title="Sizes the window so that it fits around its subwindows.">wxWindow::Fit()</a>: this method sets the size of a window to fit around its children. If it has no children then nothing is done, if it does have children then the size of the window is set to the window's best size.</li>
</ul>
<ul>
<li><a class="el" href="classwx_sizer.html#abad9cedc0cbe9ade2c799da23462d17e" title="Tell the sizer to resize the window so that its client area matches the sizer's minimal size (Compute...">wxSizer::Fit()</a>: this sets the size of the window to be large enough to accommodate the minimum size needed by the sizer, (along with a few other constraints...). If the sizer is the one that is assigned to the window then this should be equivalent to <a class="el" href="classwx_window.html#a2bf38a6cbd1f82fb46f274396f482994" title="Sizes the window so that it fits around its subwindows.">wxWindow::Fit()</a>.</li>
</ul>
<ul>
<li><a class="el" href="classwx_sizer.html#a1ea8589882944f8ac78b6ff8abde1554" title="Call this to force layout of the children anew, e.g. after having added a child to or removed a child...">wxSizer::Layout()</a>: recalculates the minimum space needed by each item in the sizer, and then lays out the items within the space currently allotted to the sizer.</li>
</ul>
<ul>
<li><a class="el" href="classwx_window.html#a1b143c3e72bd0af533b76db4830a6113" title="Invokes the constraint-based layout algorithm or the sizer-based algorithm for this window...">wxWindow::Layout()</a>: if the window has a sizer then it sets the space given to the sizer to the current size of the window, which results in a call to <a class="el" href="classwx_sizer.html#a1ea8589882944f8ac78b6ff8abde1554" title="Call this to force layout of the children anew, e.g. after having added a child to or removed a child...">wxSizer::Layout()</a>. If the window has layout constraints instead of a sizer then the constraints algorithm is run. The <code>Layout()</code> method is what is called by the default <code>EVT_SIZE</code> handler for container windows. </li>
</ul>
</div></div><!-- contents -->
<address class="footer">
<small>
Generated on Thu Nov 27 2014 13:46:42 for wxWidgets by <a href="http://www.doxygen.org/index.html" target="_new">Doxygen</a> 1.8.2
</small>
</address>
<script src="wxwidgets.js" type="text/javascript"></script>
</div><!-- #page_container -->
</body>
</html>
|