sashwin.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: sashwin.h
  3. // Purpose: interface of wxSashWindow
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. /**
  8. wxSashWindow flags
  9. */
  10. #define wxSW_NOBORDER 0x0000
  11. #define wxSW_BORDER 0x0020
  12. #define wxSW_3DSASH 0x0040
  13. #define wxSW_3DBORDER 0x0080
  14. #define wxSW_3D (wxSW_3DSASH | wxSW_3DBORDER)
  15. /**
  16. See wxSashWindow.
  17. */
  18. enum wxSashEdgePosition
  19. {
  20. wxSASH_TOP = 0,
  21. wxSASH_RIGHT,
  22. wxSASH_BOTTOM,
  23. wxSASH_LEFT,
  24. wxSASH_NONE = 100
  25. };
  26. /**
  27. See wxSashEvent.
  28. */
  29. enum wxSashDragStatus
  30. {
  31. wxSASH_STATUS_OK,
  32. wxSASH_STATUS_OUT_OF_RANGE
  33. };
  34. /**
  35. @class wxSashWindow
  36. wxSashWindow allows any of its edges to have a sash which can be dragged
  37. to resize the window. The actual content window will be created by the
  38. application as a child of wxSashWindow.
  39. The window (or an ancestor) will be notified of a drag via a
  40. wxSashEvent notification.
  41. @beginStyleTable
  42. @style{wxSW_3D}
  43. Draws a 3D effect sash and border.
  44. @style{wxSW_3DSASH}
  45. Draws a 3D effect sash.
  46. @style{wxSW_3DBORDER}
  47. Draws a 3D effect border.
  48. @style{wxSW_BORDER}
  49. Draws a thin black border.
  50. @endStyleTable
  51. @beginEventEmissionTable{wxSashEvent}
  52. @event{EVT_SASH_DRAGGED(id, func)}
  53. Process a @c wxEVT_SASH_DRAGGED event, when the user has finished
  54. dragging a sash.
  55. @event{EVT_SASH_DRAGGED_RANGE(id1, id2, func)}
  56. Process a @c wxEVT_SASH_DRAGGED_RANGE event, when the user has
  57. finished dragging a sash. The event handler is called when windows
  58. with ids in the given range have their sashes dragged.
  59. @endEventTable
  60. @library{wxadv}
  61. @category{miscwnd}
  62. @see wxSashEvent, wxSashLayoutWindow, @ref overview_events
  63. */
  64. class wxSashWindow : public wxWindow
  65. {
  66. public:
  67. /**
  68. Default ctor.
  69. */
  70. wxSashWindow();
  71. /**
  72. Constructs a sash window, which can be a child of a frame, dialog or any other
  73. non-control window.
  74. @param parent
  75. Pointer to a parent window.
  76. @param id
  77. Window identifier. If -1, will automatically create an identifier.
  78. @param pos
  79. Window position. wxDefaultPosition is (-1, -1) which indicates that
  80. wxSashWindows should generate a default position for the window.
  81. If using the wxSashWindow class directly, supply an actual position.
  82. @param size
  83. Window size. wxDefaultSize is (-1, -1) which indicates that wxSashWindows
  84. should generate a default size for the window.
  85. @param style
  86. Window style. For window styles, please see wxSashWindow.
  87. @param name
  88. Window name.
  89. */
  90. wxSashWindow(wxWindow* parent, wxWindowID id,
  91. const wxPoint& pos = wxDefaultPosition,
  92. const wxSize& size = wxDefaultSize,
  93. long style = wxCLIP_CHILDREN | wxSW_3D,
  94. const wxString& name = "sashWindow");
  95. /**
  96. Destructor.
  97. */
  98. virtual ~wxSashWindow();
  99. /**
  100. Gets the maximum window size in the x direction.
  101. */
  102. virtual int GetMaximumSizeX() const;
  103. /**
  104. Gets the maximum window size in the y direction.
  105. */
  106. virtual int GetMaximumSizeY() const;
  107. /**
  108. Gets the minimum window size in the x direction.
  109. */
  110. virtual int GetMinimumSizeX() const;
  111. /**
  112. Gets the minimum window size in the y direction.
  113. */
  114. virtual int GetMinimumSizeY() const;
  115. /**
  116. Returns @true if a sash is visible on the given edge, @false otherwise.
  117. @param edge
  118. Edge. One of wxSASH_TOP, wxSASH_RIGHT, wxSASH_BOTTOM, wxSASH_LEFT.
  119. @see SetSashVisible()
  120. */
  121. bool GetSashVisible(wxSashEdgePosition edge) const;
  122. /**
  123. Sets the maximum window size in the x direction.
  124. */
  125. virtual void SetMaximumSizeX(int min);
  126. /**
  127. Sets the maximum window size in the y direction.
  128. */
  129. virtual void SetMaximumSizeY(int min);
  130. /**
  131. Sets the minimum window size in the x direction.
  132. */
  133. virtual void SetMinimumSizeX(int min);
  134. /**
  135. Sets the minimum window size in the y direction.
  136. */
  137. virtual void SetMinimumSizeY(int min);
  138. /**
  139. Call this function to make a sash visible or invisible on a particular edge.
  140. @param edge
  141. Edge to change. One of wxSASH_TOP, wxSASH_RIGHT, wxSASH_BOTTOM, wxSASH_LEFT.
  142. @param visible
  143. @true to make the sash visible, @false to make it invisible.
  144. @see GetSashVisible()
  145. */
  146. void SetSashVisible(wxSashEdgePosition edge, bool visible);
  147. /**
  148. Get border size
  149. */
  150. int GetEdgeMargin(wxSashEdgePosition edge) const;
  151. /**
  152. Sets the default sash border size
  153. */
  154. void SetDefaultBorderSize(int width);
  155. /**
  156. Gets the default sash border size
  157. */
  158. int GetDefaultBorderSize() const;
  159. /**
  160. Sets the additional border size between child and sash window
  161. */
  162. void SetExtraBorderSize(int width);
  163. /**
  164. Gets the addition border size between child and sash window
  165. */
  166. int GetExtraBorderSize() const;
  167. /**
  168. Tests for x, y over sash
  169. */
  170. wxSashEdgePosition SashHitTest(int x, int y, int tolerance = 2);
  171. /**
  172. Resizes subwindows
  173. */
  174. void SizeWindows();
  175. };
  176. /**
  177. @class wxSashEvent
  178. A sash event is sent when the sash of a wxSashWindow has been
  179. dragged by the user.
  180. @remarks
  181. When a sash belonging to a sash window is dragged by the user, and then released,
  182. this event is sent to the window, where it may be processed by an event table
  183. entry in a derived class, a plug-in event handler or an ancestor class.
  184. Note that the wxSashWindow doesn't change the window's size itself.
  185. It relies on the application's event handler to do that.
  186. This is because the application may have to handle other consequences of the resize,
  187. or it may wish to veto it altogether. The event handler should look at the drag
  188. rectangle: see wxSashEvent::GetDragRect to see what the new size of the window
  189. would be if the resize were to be applied.
  190. It should also call wxSashEvent::GetDragStatus to see whether the drag was
  191. OK or out of the current allowed range.
  192. @beginEventTable{wxSashEvent}
  193. @event{EVT_SASH_DRAGGED(id, func)}
  194. Process a @c wxEVT_SASH_DRAGGED event, when the user has finished dragging a sash.
  195. @event{EVT_SASH_DRAGGED_RANGE(id1, id2, func)}
  196. Process a @c wxEVT_SASH_DRAGGED_RANGE event, when the user has finished
  197. dragging a sash. The event handler is called when windows with ids in
  198. the given range have their sashes dragged.
  199. @endEventTable
  200. @library{wxadv}
  201. @category{events}
  202. @see wxSashWindow, @ref overview_events
  203. */
  204. class wxSashEvent : public wxCommandEvent
  205. {
  206. public:
  207. /**
  208. Constructor.
  209. */
  210. wxSashEvent(int id = 0, wxSashEdgePosition edge = wxSASH_NONE);
  211. /**
  212. Returns the rectangle representing the new size the window would be if the
  213. resize was applied. It is up to the application to set the window size if required.
  214. */
  215. wxRect GetDragRect() const;
  216. /**
  217. Returns the status of the sash: one of wxSASH_STATUS_OK, wxSASH_STATUS_OUT_OF_RANGE.
  218. If the drag caused the notional bounding box of the window to flip over, for
  219. example, the drag will be out of rage.
  220. */
  221. wxSashDragStatus GetDragStatus() const;
  222. /**
  223. Returns the dragged edge.
  224. The return value is one of wxSASH_TOP, wxSASH_RIGHT, wxSASH_BOTTOM, wxSASH_LEFT.
  225. */
  226. wxSashEdgePosition GetEdge() const;
  227. void SetEdge(wxSashEdgePosition edge);
  228. void SetDragRect(const wxRect& rect);
  229. void SetDragStatus(wxSashDragStatus status);
  230. };
  231. wxEventType wxEVT_SASH_DRAGGED;