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

📄 layalgor.tex

📁 很牛的GUI源码wxWidgets-2.8.0.zip 可在多种平台下运行.
💻 TEX
字号:
\section{\class{wxLayoutAlgorithm}}\label{wxlayoutalgorithm}wxLayoutAlgorithm implements layout of subwindows in MDI or SDI frames.It sends a wxCalculateLayoutEvent eventto children of the frame, asking them for information abouttheir size. For MDI parent frames, the algorithm allocatesthe remaining space to the MDI client window (which contains the MDI child frames).For SDI (normal) frames, a 'main' window is specified as taking up theremaining space.Because the event system is used, this technique can be applied to any windows,which are not necessarily 'aware' of the layout classes (no virtual functionsin wxWindow refer to wxLayoutAlgorithm or its events). However, youmay wish to use \helpref{wxSashLayoutWindow}{wxsashlayoutwindow} for your subwindowssince this class provides handlers for the required events, and accessorsto specify the desired size of the window. The sash behaviour in the base classcan be used, optionally, to make the windows user-resizable.wxLayoutAlgorithm is typically used in IDE (integrated development environment) applications,where there are several resizable windows in addition to the MDI client window, orother primary editing window. Resizable windows might include toolbars, a projectwindow, and a window for displaying error and warning messages.When a window receives an OnCalculateLayout event, it should call SetRect inthe given event object, to be the old supplied rectangle minus whatever space thewindow takes up. It should also set its own size accordingly.wxSashLayoutWindow::OnCalculateLayout generates an OnQueryLayoutInfo eventwhich it sends to itself to determine the orientation, alignment and size of the window,which it gets from internal member variables set by the application.The algorithm works by starting off with a rectangle equal to the whole frame client area.It iterates through the frame children, generating OnCalculateLayout events which subtractthe window size and return the remaining rectangle for the next window to process. Itis assumed (by wxSashLayoutWindow::OnCalculateLayout) that a window stretches the full dimensionof the frame client, according to the orientation it specifies. For example, a horizontal windowwill stretch the full width of the remaining portion of the frame client area.In the other orientation, the window will be fixed to whatever size was specified byOnQueryLayoutInfo. An alignment setting will make the window 'stick' to the left, top, right orbottom of the remaining client area. This scheme implies that order of window creation is important.Say you wish to have an extra toolbar at the top of the frame, a project window to the left ofthe MDI client window, and an output window above the status bar. You should therefore createthe windows in this order: toolbar, output window, project window. This ensures that the toolbar andoutput window take up space at the top and bottom, and then the remaining height in-between is used forthe project window.wxLayoutAlgorithm is quite independent of the way in whichOnCalculateLayout chooses to interpret a window's size and alignment. Therefore youcould implement a different window class with a new OnCalculateLayout event handler,that has a more sophisticated way of laying out the windows. It might allowspecification of whether stretching occurs in the specified orientation, for example,rather than always assuming stretching. (This could, and probably should, be added to the existingimplementation).{\it Note:} wxLayoutAlgorithm has nothing to do with wxLayoutConstraints. It is an alternativeway of specifying layouts for which the normal constraint system is unsuitable.\wxheading{Derived from}\helpref{wxObject}{wxobject}\wxheading{Include files}<wx/laywin.h>\wxheading{Event handling}The algorithm object does not respond to events, but itself generates thefollowing events in order to calculate window sizes.\twocolwidtha{7cm}%\begin{twocollist}\itemsep=0pt\twocolitem{{\bf EVT\_QUERY\_LAYOUT\_INFO(func)}}{Process a wxEVT\_QUERY\_LAYOUT\_INFO event,to get size, orientation and alignment from a window. See \helpref{wxQueryLayoutInfoEvent}{wxquerylayoutinfoevent}.}\twocolitem{{\bf EVT\_CALCULATE\_LAYOUT(func)}}{Process a wxEVT\_CALCULATE\_LAYOUT event,which asks the window to take a 'bite' out of a rectangle provided by the algorithm.See \helpref{wxCalculateLayoutEvent}{wxcalculatelayoutevent}.}\end{twocollist}\wxheading{Data types}{\small\begin{verbatim}enum wxLayoutOrientation {    wxLAYOUT_HORIZONTAL,    wxLAYOUT_VERTICAL};enum wxLayoutAlignment {    wxLAYOUT_NONE,    wxLAYOUT_TOP,    wxLAYOUT_LEFT,    wxLAYOUT_RIGHT,    wxLAYOUT_BOTTOM,};\end{verbatim}}\wxheading{See also}\helpref{wxSashEvent}{wxsashevent}, \helpref{wxSashLayoutWindow}{wxsashlayoutwindow}, \helpref{Event handling overview}{eventhandlingoverview}\helpref{wxCalculateLayoutEvent}{wxcalculatelayoutevent},\rtfsp\helpref{wxQueryLayoutInfoEvent}{wxquerylayoutinfoevent},\rtfsp\helpref{wxSashLayoutWindow}{wxsashlayoutwindow},\rtfsp\helpref{wxSashWindow}{wxsashwindow}\latexignore{\rtfignore{\wxheading{Members}}}\membersection{wxLayoutAlgorithm::wxLayoutAlgorithm}\label{wxlayoutalgorithmctor}\func{}{wxLayoutAlgorithm}{\void}Default constructor.\membersection{wxLayoutAlgorithm::\destruct{wxLayoutAlgorithm}}\label{wxlayoutalgorithmdtor}\func{}{\destruct{wxLayoutAlgorithm}}{\void}Destructor.\membersection{wxLayoutAlgorithm::LayoutFrame}\label{wxlayoutalgorithmlayoutframe}\constfunc{bool}{LayoutFrame}{\param{wxFrame* }{frame}, \param{wxWindow*}{ mainWindow = NULL}}Lays out the children of a normal frame. {\it mainWindow} is set to occupy the remaining space.This function simply calls \helpref{wxLayoutAlgorithm::LayoutWindow}{wxlayoutalgorithmlayoutwindow}.\membersection{wxLayoutAlgorithm::LayoutMDIFrame}\label{wxlayoutalgorithmlayoutmdiframe}\constfunc{bool}{LayoutMDIFrame}{\param{wxMDIParentFrame* }{frame}, \param{wxRect*}{ rect = NULL}}Lays out the children of an MDI parent frame. If {\it rect} is non-NULL, thegiven rectangle will be used as a starting point instead of the frame's client area.The MDI client window is set to occupy the remaining space.\membersection{wxLayoutAlgorithm::LayoutWindow}\label{wxlayoutalgorithmlayoutwindow}\constfunc{bool}{LayoutWindow}{\param{wxWindow* }{parent}, \param{wxWindow*}{ mainWindow = NULL}}Lays out the children of a normal frame or other window.{\it mainWindow} is set to occupy the remaining space. If this is not specified, thenthe last window that responds to a calculate layout event in query mode will get the remaining space(that is, a non-query OnCalculateLayout event will not be sent to this window and the window will be setto the remaining size).

⌨️ 快捷键说明

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