⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 twinsizes.tex

📁 很牛的GUI源码wxWidgets-2.8.0.zip 可在多种平台下运行.
💻 TEX
字号:
\section{Window Sizing Overview}\label{windowsizingoverview}It can sometimes be confusing to keep track of the varioussize-related attributes of a \helpref{wxWindow}{wxwindow}, how theyrelate to each other, and how they interact with sizers. This documentwill attempt to clear the fog a little, and give some simpleexplanations of things.{\bf BestSize}: The best size of a widget depends on what kind of widget itis, and usually also on the contents of the widget. For example a\helpref{wxListBox}{wxlistbox}'s best size will be calculated based onhow many items it has, up to a certain limit, or a\helpref{wxButton}{wxbutton}'s best size will be calculated based onits label size, but normally won't be smaller than the platformdefault button size (unless a style flag overrides that). Get thepicture? There is a special virtual method in the C++ window classescalled \texttt{DoGetBestSize()} that a class needs to override if itwants to calculate its own best size based on its content. The default\texttt{DoGetBestSize()} is designed for use in container windows,such as \helpref{wxPanel}{wxpanel}, and works something like this:\begin{enumerate}  \item{If the window has a sizer then it is used to calculate the best size.}  \item{Otherwise if the window has layout constraints then that is used to calculate the best size.}  \item{Otherwise if the window has children then the best size is set to be large enough to show all the children.}  \item{Otherwise if there are no children then the window's min size will be used for the best size.}  \item{Otherwise if there is no min size set, then the current size is used for the best size.}\end{enumerate}{\bf MinSize}: The min size of a widget is a size that is normallyexplicitly set by the programmer either with the \texttt{SetMinSize()}method or the \texttt{SetSizeHints()} method. Most controls will alsoset the min size to the size given in the control's constructor if anon-default value is passed. Top-level windows such as\helpref{wxFrame}{wxframe} will not allow the user to resize the framebelow the min size.{\bf Size}: The size of a widget can be explicitly set or fetched withthe \texttt{SetSize()} or \texttt{GetSize()} methods. This size valueis the size that the widget is currently using on screen and is theway to change the size of something that is not being managed by asizer.{\bf ClientSize}: The client size represents the widget's area insideof any borders belonging to the widget and is the area that can bedrawn upon in a \texttt{EVT\_PAINT} event. If a widget doesn't have aborder then its client size is the same as its size.{\bf InitialSize}: The initial size of a widget is the size given tothe constructor of the widget, if any.  As mentioned above mostcontrols will also set this size value as the control's min size. Ifthe size passed to the constructor is the default\texttt{wxDefaultSize}, or if the size is not fully specified (such as\texttt{wxSize(150,-1)}) then most controls will fill in the missingsize components using the best size and will set the initial size ofthe control to the resulting size.{\bf GetEffectiveMinSize()}: (formerly \texttt{GetBestFittingSize}) Ablending of the widget's min size and best size, giving precedence tothe min 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 whatthe requirements of each item in the sizer is, and is used forcalculating the overall minimum needs of the sizer.{\bf SetInitialSize(size)}: (formerly \texttt{SetBestFittingSize})This is a little different than the typical size setters. Rather thanjust setting an "initial size" attribute it actually sets the minsizeto the value passed in, blends that value with the best size, and thensets the size of the widget to be the result. So you can consider thismethod to be a "Smart SetSize". This method is what is called by theconstructor of most controls to set the minsize and initial size ofthe control.{\bf window.Fit()}: The \texttt{Fit()} method sets the size of awindow to fit around its children. If it has no children then nothingis done, if it does have children then the size of the window is setto the window's best size.{\bf sizer.Fit(window)}: This sets the size of the window to be largeenough to accommodate the minimum size needed by the sizer, (along witha few other constraints...) If the sizer is the one that is assignedto the window then this should be equivalent to \texttt{window.Fit()}.{\bf sizer.Layout()}: Recalculates the minimum space needed by eachitem in the sizer, and then lays out the items within the spacecurrently allotted to the sizer.{\bf window.Layout()}: If the window has a sizer then it sets thespace given to the sizer to the current size of the window, whichresults in a call to \texttt{sizer.Layout()}. If the window has layoutconstraints instead of a sizer then the constraints algorithm isrun. The \texttt{Layout()} method is what is called by the default\texttt{EVT\_SIZE} handler for container windows.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -