PageRenderTime 69ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/wxPython-src-2.8.12.0/docs/html/wx/wx_wxlayoutalgorithm.html

#
HTML | 164 lines | 146 code | 18 blank | 0 comment | 0 complexity | 4eefa8c4bdc1e49ccc6d2c33becd00c0 MD5 | raw file
Possible License(s): BSD-2-Clause, GPL-2.0, LGPL-2.0, LGPL-3.0, AGPL-3.0, CC-BY-SA-3.0, BSD-3-Clause
  1. <HTML>
  2. <head><link rel=stylesheet type="text/css" href="wx.css"><title>wxLayoutAlgorithm</title></head>
  3. <BODY BGCOLOR=#FFFFFF>
  4. <A NAME="wxlayoutalgorithm"></A><CENTER>
  5. <A HREF="wx_contents.html"><img align=center src="contents.gif" BORDER=0 ALT="Contents"></A> <A HREF="wx_classref.html#classref"><img align=center src="up.gif" BORDER=0 ALT="Up"></A> <A HREF="wx_wxkeyevent.html#wxkeyevent"><img align=center src="back.gif" BORDER=0 ALT="Previous"></A> <A HREF="wx_wxlayoutconstraints.html#wxlayoutconstraints"><img align=center src="forward.gif" BORDER=0 ALT="Next"></A> </CENTER><HR>
  6. <H2>wxLayoutAlgorithm</H2>
  7. <P>
  8. wxLayoutAlgorithm implements layout of subwindows in MDI or SDI frames.
  9. It sends a wxCalculateLayoutEvent event
  10. to children of the frame, asking them for information about
  11. their size. For MDI parent frames, the algorithm allocates
  12. the remaining space to the MDI client window (which contains the MDI child frames).
  13. For SDI (normal) frames, a 'main' window is specified as taking up the
  14. remaining space.<P>
  15. Because the event system is used, this technique can be applied to any windows,
  16. which are not necessarily 'aware' of the layout classes (no virtual functions
  17. in wxWindow refer to wxLayoutAlgorithm or its events). However, you
  18. may wish to use <A HREF="wx_wxsashlayoutwindow.html#wxsashlayoutwindow">wxSashLayoutWindow</A> for your subwindows
  19. since this class provides handlers for the required events, and accessors
  20. to specify the desired size of the window. The sash behaviour in the base class
  21. can be used, optionally, to make the windows user-resizable.<P>
  22. wxLayoutAlgorithm is typically used in IDE (integrated development environment) applications,
  23. where there are several resizable windows in addition to the MDI client window, or
  24. other primary editing window. Resizable windows might include toolbars, a project
  25. window, and a window for displaying error and warning messages.<P>
  26. When a window receives an OnCalculateLayout event, it should call SetRect in
  27. the given event object, to be the old supplied rectangle minus whatever space the
  28. window takes up. It should also set its own size accordingly.
  29. wxSashLayoutWindow::OnCalculateLayout generates an OnQueryLayoutInfo event
  30. which it sends to itself to determine the orientation, alignment and size of the window,
  31. which it gets from internal member variables set by the application.<P>
  32. The algorithm works by starting off with a rectangle equal to the whole frame client area.
  33. It iterates through the frame children, generating OnCalculateLayout events which subtract
  34. the window size and return the remaining rectangle for the next window to process. It
  35. is assumed (by wxSashLayoutWindow::OnCalculateLayout) that a window stretches the full dimension
  36. of the frame client, according to the orientation it specifies. For example, a horizontal window
  37. will stretch the full width of the remaining portion of the frame client area.
  38. In the other orientation, the window will be fixed to whatever size was specified by
  39. OnQueryLayoutInfo. An alignment setting will make the window 'stick' to the left, top, right or
  40. bottom of the remaining client area. This scheme implies that order of window creation is important.
  41. Say you wish to have an extra toolbar at the top of the frame, a project window to the left of
  42. the MDI client window, and an output window above the status bar. You should therefore create
  43. the windows in this order: toolbar, output window, project window. This ensures that the toolbar and
  44. output window take up space at the top and bottom, and then the remaining height in-between is used for
  45. the project window.<P>
  46. wxLayoutAlgorithm is quite independent of the way in which
  47. OnCalculateLayout chooses to interpret a window's size and alignment. Therefore you
  48. could implement a different window class with a new OnCalculateLayout event handler,
  49. that has a more sophisticated way of laying out the windows. It might allow
  50. specification of whether stretching occurs in the specified orientation, for example,
  51. rather than always assuming stretching. (This could, and probably should, be added to the existing
  52. implementation).<P>
  53. <I>Note:</I> wxLayoutAlgorithm has nothing to do with wxLayoutConstraints. It is an alternative
  54. way of specifying layouts for which the normal constraint system is unsuitable.<P>
  55. <B><FONT COLOR="#FF0000">Derived from</FONT></B><P>
  56. <A HREF="wx_wxobject.html#wxobject">wxObject</A><P>
  57. <B><FONT COLOR="#FF0000">Include files</FONT></B><P>
  58. &lt;wx/laywin.h&gt;<P>
  59. <B><FONT COLOR="#FF0000">Event handling</FONT></B><P>
  60. The algorithm object does not respond to events, but itself generates the
  61. following events in order to calculate window sizes.<P>
  62. <TABLE>
  63. <TR><TD VALIGN=TOP WIDTH=277>
  64. <B>EVT_QUERY_LAYOUT_INFO(func)</B>
  65. </FONT></TD>
  66. <TD VALIGN=TOP>
  67. Process a wxEVT_QUERY_LAYOUT_INFO event,
  68. to get size, orientation and alignment from a window. See <A HREF="wx_wxquerylayoutinfoevent.html#wxquerylayoutinfoevent">wxQueryLayoutInfoEvent</A>.
  69. </FONT></TD></TR>
  70. <TR><TD VALIGN=TOP WIDTH=277>
  71. <B>EVT_CALCULATE_LAYOUT(func)</B>
  72. </FONT></TD>
  73. <TD VALIGN=TOP>
  74. Process a wxEVT_CALCULATE_LAYOUT event,
  75. which asks the window to take a 'bite' out of a rectangle provided by the algorithm.
  76. See <A HREF="wx_wxcalculatelayoutevent.html#wxcalculatelayoutevent">wxCalculateLayoutEvent</A>.
  77. </FONT></TD></TR>
  78. </TABLE>
  79. <P>
  80. <B><FONT COLOR="#FF0000">Data types</FONT></B><P>
  81. <FONT SIZE=2>
  82. <PRE>
  83. enum wxLayoutOrientation {
  84. wxLAYOUT_HORIZONTAL,
  85. wxLAYOUT_VERTICAL
  86. };
  87. enum wxLayoutAlignment {
  88. wxLAYOUT_NONE,
  89. wxLAYOUT_TOP,
  90. wxLAYOUT_LEFT,
  91. wxLAYOUT_RIGHT,
  92. wxLAYOUT_BOTTOM,
  93. };
  94. </PRE>
  95. </FONT><P>
  96. <B><FONT COLOR="#FF0000">See also</FONT></B><P>
  97. <A HREF="wx_wxsashevent.html#wxsashevent">wxSashEvent</A>, <A HREF="wx_wxsashlayoutwindow.html#wxsashlayoutwindow">wxSashLayoutWindow</A>, <A HREF="wx_eventhandlingoverview.html#eventhandlingoverview">Event handling overview</A><P>
  98. <A HREF="wx_wxcalculatelayoutevent.html#wxcalculatelayoutevent">wxCalculateLayoutEvent</A>,
  99. <A HREF="wx_wxquerylayoutinfoevent.html#wxquerylayoutinfoevent">wxQueryLayoutInfoEvent</A>,
  100. <A HREF="wx_wxsashlayoutwindow.html#wxsashlayoutwindow">wxSashLayoutWindow</A>,
  101. <A HREF="wx_wxsashwindow.html#wxsashwindow">wxSashWindow</A><P>
  102. <B><FONT COLOR="#FF0000">Members</FONT></B><P>
  103. <A HREF="#wxlayoutalgorithmctor">wxLayoutAlgorithm::wxLayoutAlgorithm</A><BR>
  104. <A HREF="#wxlayoutalgorithmdtor">wxLayoutAlgorithm::~wxLayoutAlgorithm</A><BR>
  105. <A HREF="#wxlayoutalgorithmlayoutframe">wxLayoutAlgorithm::LayoutFrame</A><BR>
  106. <A HREF="#wxlayoutalgorithmlayoutmdiframe">wxLayoutAlgorithm::LayoutMDIFrame</A><BR>
  107. <A HREF="#wxlayoutalgorithmlayoutwindow">wxLayoutAlgorithm::LayoutWindow</A><BR>
  108. <P>
  109. <HR>
  110. <A NAME="wxlayoutalgorithmctor"></A>
  111. <H3>wxLayoutAlgorithm::wxLayoutAlgorithm</H3>
  112. <P>
  113. <B></B> <B>wxLayoutAlgorithm</B>()<P>
  114. Default constructor.<P>
  115. <HR>
  116. <A NAME="wxlayoutalgorithmdtor"></A>
  117. <H3>wxLayoutAlgorithm::~wxLayoutAlgorithm</H3>
  118. <P>
  119. <B></B> <B>~wxLayoutAlgorithm</B>()<P>
  120. Destructor.<P>
  121. <HR>
  122. <A NAME="wxlayoutalgorithmlayoutframe"></A>
  123. <H3>wxLayoutAlgorithm::LayoutFrame</H3>
  124. <P>
  125. <B>bool</B> <B>LayoutFrame</B>(<B><A HREF="wx_wxframe.html#wxframe">wxFrame</A>* </B></B><I>frame</I>, <B><A HREF="wx_wxwindow.html#wxwindow">wxWindow</A>*</B></B><I> mainWindow = NULL</I>) <B>const</B><P>
  126. Lays out the children of a normal frame. <I>mainWindow</I> is set to occupy the remaining space.<P>
  127. This function simply calls <A HREF="wx_wxlayoutalgorithm.html#wxlayoutalgorithmlayoutwindow">wxLayoutAlgorithm::LayoutWindow</A>.<P>
  128. <HR>
  129. <A NAME="wxlayoutalgorithmlayoutmdiframe"></A>
  130. <H3>wxLayoutAlgorithm::LayoutMDIFrame</H3>
  131. <P>
  132. <B>bool</B> <B>LayoutMDIFrame</B>(<B><A HREF="wx_wxmdiparentframe.html#wxmdiparentframe">wxMDIParentFrame</A>* </B></B><I>frame</I>, <B><A HREF="wx_wxrect.html#wxrect">wxRect</A>*</B></B><I> rect = NULL</I>) <B>const</B><P>
  133. Lays out the children of an MDI parent frame. If <I>rect</I> is non-NULL, the
  134. given rectangle will be used as a starting point instead of the frame's client area.<P>
  135. The MDI client window is set to occupy the remaining space.<P>
  136. <HR>
  137. <A NAME="wxlayoutalgorithmlayoutwindow"></A>
  138. <H3>wxLayoutAlgorithm::LayoutWindow</H3>
  139. <P>
  140. <B>bool</B> <B>LayoutWindow</B>(<B><A HREF="wx_wxwindow.html#wxwindow">wxWindow</A>* </B></B><I>parent</I>, <B><A HREF="wx_wxwindow.html#wxwindow">wxWindow</A>*</B></B><I> mainWindow = NULL</I>) <B>const</B><P>
  141. Lays out the children of a normal frame or other window.<P>
  142. <I>mainWindow</I> is set to occupy the remaining space. If this is not specified, then
  143. the last window that responds to a calculate layout event in query mode will get the remaining space
  144. (that is, a non-query OnCalculateLayout event will not be sent to this window and the window will be set
  145. to the remaining size).<P>
  146. </FONT></BODY></HTML>