sizer.h 63 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: sizer.h
  3. // Purpose: interface of wxStdDialogButtonSizer
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. /**
  8. @class wxSizer
  9. wxSizer is the abstract base class used for laying out subwindows in a window.
  10. You cannot use wxSizer directly; instead, you will have to use one of the sizer
  11. classes derived from it. Currently there are wxBoxSizer, wxStaticBoxSizer,
  12. wxGridSizer, wxFlexGridSizer, wxWrapSizer and wxGridBagSizer.
  13. The layout algorithm used by sizers in wxWidgets is closely related to layout
  14. in other GUI toolkits, such as Java's AWT, the GTK toolkit or the Qt toolkit.
  15. It is based upon the idea of the individual subwindows reporting their minimal
  16. required size and their ability to get stretched if the size of the parent window
  17. has changed.
  18. This will most often mean that the programmer does not set the original size of
  19. a dialog in the beginning, rather the dialog will be assigned a sizer and this
  20. sizer will be queried about the recommended size. The sizer in turn will query
  21. its children, which can be normal windows, empty space or other sizers, so that
  22. a hierarchy of sizers can be constructed. Note that wxSizer does not derive
  23. from wxWindow and thus does not interfere with tab ordering and requires very little
  24. resources compared to a real window on screen.
  25. What makes sizers so well fitted for use in wxWidgets is the fact that every
  26. control reports its own minimal size and the algorithm can handle differences in
  27. font sizes or different window (dialog item) sizes on different platforms without
  28. problems. If e.g. the standard font as well as the overall design of Motif widgets
  29. requires more space than on Windows, the initial dialog size will automatically
  30. be bigger on Motif than on Windows.
  31. Sizers may also be used to control the layout of custom drawn items on the
  32. window. The wxSizer::Add(), wxSizer::Insert(), and wxSizer::Prepend() functions
  33. return a pointer to the newly added wxSizerItem.
  34. Just add empty space of the desired size and attributes, and then use the
  35. wxSizerItem::GetRect() method to determine where the drawing operations
  36. should take place.
  37. Please notice that sizers, like child windows, are owned by the library and
  38. will be deleted by it which implies that they must be allocated on the heap.
  39. However if you create a sizer and do not add it to another sizer or
  40. window, the library wouldn't be able to delete such an orphan sizer and in
  41. this, and only this, case it should be deleted explicitly.
  42. @section wxsizer_flags wxSizer flags
  43. The "flag" argument accepted by wxSizeItem constructors and other
  44. functions, e.g. wxSizer::Add(), is OR-combination of the following flags.
  45. Two main behaviours are defined using these flags. One is the border around
  46. a window: the border parameter determines the border width whereas the
  47. flags given here determine which side(s) of the item that the border will
  48. be added. The other flags determine how the sizer item behaves when the
  49. space allotted to the sizer changes, and is somewhat dependent on the
  50. specific kind of sizer used.
  51. @beginDefList
  52. @itemdef{wxTOP<br>
  53. wxBOTTOM<br>
  54. wxLEFT<br>
  55. wxRIGHT<br>
  56. wxALL,
  57. These flags are used to specify which side(s) of the sizer item
  58. the border width will apply to.}
  59. @itemdef{wxEXPAND,
  60. The item will be expanded to fill the space assigned to the item.}
  61. @itemdef{wxSHAPED,
  62. The item will be expanded as much as possible while also
  63. maintaining its aspect ratio.}
  64. @itemdef{wxFIXED_MINSIZE,
  65. Normally wxSizers will use GetAdjustedBestSize() to determine what
  66. the minimal size of window items should be, and will use that size
  67. to calculate the layout. This allows layouts to adjust when an
  68. item changes and its best size becomes different. If you would
  69. rather have a window item stay the size it started with then use
  70. @c wxFIXED_MINSIZE.}
  71. @itemdef{wxRESERVE_SPACE_EVEN_IF_HIDDEN,
  72. Normally wxSizers don't allocate space for hidden windows or other
  73. items. This flag overrides this behaviour so that sufficient space
  74. is allocated for the window even if it isn't visible. This makes
  75. it possible to dynamically show and hide controls without resizing
  76. parent dialog, for example. (Available since 2.8.8.)}
  77. @itemdef{wxALIGN_CENTER<br>
  78. wxALIGN_CENTRE<br>
  79. wxALIGN_LEFT<br>
  80. wxALIGN_RIGHT<br>
  81. wxALIGN_TOP<br>
  82. wxALIGN_BOTTOM<br>
  83. wxALIGN_CENTER_VERTICAL<br>
  84. wxALIGN_CENTRE_VERTICAL<br>
  85. wxALIGN_CENTER_HORIZONTAL<br>
  86. wxALIGN_CENTRE_HORIZONTAL,
  87. The @c wxALIGN_* flags allow you to specify the alignment of the item
  88. within the space allotted to it by the sizer, adjusted for the
  89. border if any.}
  90. @endDefList
  91. @library{wxcore}
  92. @category{winlayout}
  93. @see @ref overview_sizer
  94. */
  95. class wxSizer : public wxObject
  96. {
  97. public:
  98. /**
  99. The constructor.
  100. Note that wxSizer is an abstract base class and may not be instantiated.
  101. */
  102. wxSizer();
  103. /**
  104. The destructor.
  105. */
  106. virtual ~wxSizer();
  107. /**
  108. Appends a child to the sizer.
  109. wxSizer itself is an abstract class, but the parameters are equivalent
  110. in the derived classes that you will instantiate to use it so they are
  111. described here:
  112. @param window
  113. The window to be added to the sizer. Its initial size (either set
  114. explicitly by the user or calculated internally when using
  115. wxDefaultSize) is interpreted as the minimal and in many cases also
  116. the initial size.
  117. @param flags
  118. A wxSizerFlags object that enables you to specify most of the above
  119. parameters more conveniently.
  120. */
  121. wxSizerItem* Add(wxWindow* window, const wxSizerFlags& flags);
  122. /**
  123. Appends a child to the sizer.
  124. wxSizer itself is an abstract class, but the parameters are equivalent
  125. in the derived classes that you will instantiate to use it so they are
  126. described here:
  127. @param window
  128. The window to be added to the sizer. Its initial size (either set
  129. explicitly by the user or calculated internally when using
  130. wxDefaultSize) is interpreted as the minimal and in many cases also
  131. the initial size.
  132. @param proportion
  133. Although the meaning of this parameter is undefined in wxSizer, it
  134. is used in wxBoxSizer to indicate if a child of a sizer can change
  135. its size in the main orientation of the wxBoxSizer - where 0 stands
  136. for not changeable and a value of more than zero is interpreted
  137. relative to the value of other children of the same wxBoxSizer. For
  138. example, you might have a horizontal wxBoxSizer with three
  139. children, two of which are supposed to change their size with the
  140. sizer. Then the two stretchable windows would get a value of 1 each
  141. to make them grow and shrink equally with the sizer's horizontal
  142. dimension.
  143. @param flag
  144. OR-combination of flags affecting sizer's behaviour. See
  145. @ref wxsizer_flags "wxSizer flags list" for details.
  146. @param border
  147. Determines the border width, if the flag parameter is set to
  148. include any border flag.
  149. @param userData
  150. Allows an extra object to be attached to the sizer item, for use in
  151. derived classes when sizing information is more complex than the
  152. proportion and flag will allow for.
  153. */
  154. wxSizerItem* Add(wxWindow* window,
  155. int proportion = 0,
  156. int flag = 0,
  157. int border = 0,
  158. wxObject* userData = NULL);
  159. /**
  160. Appends a child to the sizer.
  161. wxSizer itself is an abstract class, but the parameters are equivalent
  162. in the derived classes that you will instantiate to use it so they are
  163. described here:
  164. @param sizer
  165. The (child-)sizer to be added to the sizer. This allows placing a
  166. child sizer in a sizer and thus to create hierarchies of sizers
  167. (typically a vertical box as the top sizer and several horizontal
  168. boxes on the level beneath).
  169. @param flags
  170. A wxSizerFlags object that enables you to specify most of the above
  171. parameters more conveniently.
  172. */
  173. wxSizerItem* Add(wxSizer* sizer, const wxSizerFlags& flags);
  174. /**
  175. Appends a child to the sizer.
  176. wxSizer itself is an abstract class, but the parameters are equivalent
  177. in the derived classes that you will instantiate to use it so they are
  178. described here:
  179. @param sizer
  180. The (child-)sizer to be added to the sizer. This allows placing a
  181. child sizer in a sizer and thus to create hierarchies of sizers
  182. (typically a vertical box as the top sizer and several horizontal
  183. boxes on the level beneath).
  184. @param proportion
  185. Although the meaning of this parameter is undefined in wxSizer, it
  186. is used in wxBoxSizer to indicate if a child of a sizer can change
  187. its size in the main orientation of the wxBoxSizer - where 0 stands
  188. for not changeable and a value of more than zero is interpreted
  189. relative to the value of other children of the same wxBoxSizer. For
  190. example, you might have a horizontal wxBoxSizer with three
  191. children, two of which are supposed to change their size with the
  192. sizer. Then the two stretchable windows would get a value of 1 each
  193. to make them grow and shrink equally with the sizer's horizontal
  194. dimension.
  195. @param flag
  196. OR-combination of flags affecting sizer's behaviour. See
  197. @ref wxsizer_flags "wxSizer flags list" for details.
  198. @param border
  199. Determines the border width, if the flag parameter is set to
  200. include any border flag.
  201. @param userData
  202. Allows an extra object to be attached to the sizer item, for use in
  203. derived classes when sizing information is more complex than the
  204. proportion and flag will allow for.
  205. */
  206. wxSizerItem* Add(wxSizer* sizer,
  207. int proportion = 0,
  208. int flag = 0,
  209. int border = 0,
  210. wxObject* userData = NULL);
  211. /**
  212. Appends a spacer child to the sizer.
  213. wxSizer itself is an abstract class, but the parameters are equivalent
  214. in the derived classes that you will instantiate to use it so they are
  215. described here.
  216. @a width and @a height specify the dimension of a spacer to be added to
  217. the sizer. Adding spacers to sizers gives more flexibility in the
  218. design of dialogs; imagine for example a horizontal box with two
  219. buttons at the bottom of a dialog: you might want to insert a space
  220. between the two buttons and make that space stretchable using the
  221. proportion flag and the result will be that the left button will be
  222. aligned with the left side of the dialog and the right button with the
  223. right side - the space in between will shrink and grow with the dialog.
  224. @param width
  225. Width of the spacer.
  226. @param height
  227. Height of the spacer.
  228. @param proportion
  229. Although the meaning of this parameter is undefined in wxSizer, it
  230. is used in wxBoxSizer to indicate if a child of a sizer can change
  231. its size in the main orientation of the wxBoxSizer - where 0 stands
  232. for not changeable and a value of more than zero is interpreted
  233. relative to the value of other children of the same wxBoxSizer. For
  234. example, you might have a horizontal wxBoxSizer with three
  235. children, two of which are supposed to change their size with the
  236. sizer. Then the two stretchable windows would get a value of 1 each
  237. to make them grow and shrink equally with the sizer's horizontal
  238. dimension.
  239. @param flag
  240. OR-combination of flags affecting sizer's behaviour. See
  241. @ref wxsizer_flags "wxSizer flags list" for details.
  242. @param border
  243. Determines the border width, if the flag parameter is set to
  244. include any border flag.
  245. @param userData
  246. Allows an extra object to be attached to the sizer item, for use in
  247. derived classes when sizing information is more complex than the
  248. proportion and flag will allow for.
  249. */
  250. wxSizerItem* Add(int width, int height,
  251. int proportion = 0,
  252. int flag = 0,
  253. int border = 0,
  254. wxObject* userData = NULL);
  255. /**
  256. Appends a spacer child to the sizer.
  257. @param width
  258. Width of the spacer.
  259. @param height
  260. Height of the spacer.
  261. @param flags
  262. A wxSizerFlags object that enables you to specify most of the other
  263. parameters more conveniently.
  264. */
  265. wxSizerItem* Add( int width, int height, const wxSizerFlags& flags);
  266. wxSizerItem* Add(wxSizerItem* item);
  267. /**
  268. This base function adds non-stretchable space to both the horizontal
  269. and vertical orientation of the sizer.
  270. More readable way of calling:
  271. @code
  272. wxSizer::Add(size, size, 0).
  273. @endcode
  274. @see wxBoxSizer::AddSpacer()
  275. */
  276. virtual wxSizerItem *AddSpacer(int size);
  277. /**
  278. Adds stretchable space to the sizer.
  279. More readable way of calling:
  280. @code
  281. wxSizer::Add(0, 0, prop).
  282. @endcode
  283. */
  284. wxSizerItem* AddStretchSpacer(int prop = 1);
  285. /**
  286. This method is abstract and has to be overwritten by any derived class.
  287. Here, the sizer will do the actual calculation of its children's minimal sizes.
  288. */
  289. virtual wxSize CalcMin() = 0;
  290. /**
  291. Detaches all children from the sizer.
  292. If @a delete_windows is @true then child windows will also be deleted.
  293. Notice that child sizers are always deleted, as a general consequence
  294. of the principle that sizers own their sizer children, but don't own
  295. their window children (because they are already owned by their parent
  296. windows).
  297. */
  298. virtual void Clear(bool delete_windows = false);
  299. /**
  300. Computes client area size for @a window so that it matches the sizer's
  301. minimal size. Unlike GetMinSize(), this method accounts for other
  302. constraints imposed on @e window, namely display's size (returned size
  303. will never be too large for the display) and maximum window size if
  304. previously set by wxWindow::SetMaxSize().
  305. The returned value is suitable for passing to wxWindow::SetClientSize() or
  306. wxWindow::SetMinClientSize().
  307. @since 2.8.8
  308. @see ComputeFittingWindowSize(), Fit()
  309. */
  310. wxSize ComputeFittingClientSize(wxWindow* window);
  311. /**
  312. Like ComputeFittingClientSize(), but converts the result into window
  313. size. The returned value is suitable for passing to wxWindow::SetSize()
  314. or wxWindow::SetMinSize().
  315. @since 2.8.8
  316. @see ComputeFittingClientSize(), Fit()
  317. */
  318. wxSize ComputeFittingWindowSize(wxWindow* window);
  319. /**
  320. Detach the child @a window from the sizer without destroying it.
  321. This method does not cause any layout or resizing to take place, call Layout()
  322. to update the layout "on screen" after detaching a child from the sizer.
  323. Returns @true if the child item was found and detached, @false otherwise.
  324. @see Remove()
  325. */
  326. virtual bool Detach(wxWindow* window);
  327. /**
  328. Detach the child @a sizer from the sizer without destroying it.
  329. This method does not cause any layout or resizing to take place, call Layout()
  330. to update the layout "on screen" after detaching a child from the sizer.
  331. Returns @true if the child item was found and detached, @false otherwise.
  332. @see Remove()
  333. */
  334. virtual bool Detach(wxSizer* sizer);
  335. /**
  336. Detach a item at position @a index from the sizer without destroying it.
  337. This method does not cause any layout or resizing to take place, call Layout()
  338. to update the layout "on screen" after detaching a child from the sizer.
  339. Returns @true if the child item was found and detached, @false otherwise.
  340. @see Remove()
  341. */
  342. virtual bool Detach(int index);
  343. /**
  344. Tell the sizer to resize the @a window so that its client area matches the
  345. sizer's minimal size (ComputeFittingClientSize() is called to determine it).
  346. This is commonly done in the constructor of the window itself, see sample
  347. in the description of wxBoxSizer.
  348. @return The new window size.
  349. @see ComputeFittingClientSize(), ComputeFittingWindowSize()
  350. */
  351. wxSize Fit(wxWindow* window);
  352. /**
  353. Tell the sizer to resize the virtual size of the @a window to match the sizer's
  354. minimal size. This will not alter the on screen size of the window, but may
  355. cause the addition/removal/alteration of scrollbars required to view the virtual
  356. area in windows which manage it.
  357. @see wxScrolled::SetScrollbars(), SetVirtualSizeHints()
  358. */
  359. void FitInside(wxWindow* window);
  360. /**
  361. Inform sizer about the first direction that has been decided (by
  362. parent item). Returns true if it made use of the information (and
  363. recalculated min size).
  364. */
  365. virtual bool InformFirstDirection(int direction, int size, int availableOtherDir);
  366. //@{
  367. /**
  368. Returns the list of the items in this sizer.
  369. The elements of type-safe wxList @c wxSizerItemList are pointers to
  370. objects of type wxSizerItem.
  371. */
  372. wxSizerItemList& GetChildren();
  373. const wxSizerItemList& GetChildren() const;
  374. //@}
  375. /**
  376. Returns the window this sizer is used in or @NULL if none.
  377. */
  378. wxWindow* GetContainingWindow() const;
  379. /**
  380. Set the window this sizer is used in.
  381. */
  382. void SetContainingWindow(wxWindow *window);
  383. /**
  384. Returns the number of items in the sizer.
  385. If you just need to test whether the sizer is empty or not you can also
  386. use IsEmpty() function.
  387. */
  388. size_t GetItemCount() const;
  389. /**
  390. Finds wxSizerItem which holds the given @a window.
  391. Use parameter @a recursive to search in subsizers too.
  392. Returns pointer to item or @NULL.
  393. */
  394. wxSizerItem* GetItem(wxWindow* window, bool recursive = false);
  395. /**
  396. Finds wxSizerItem which holds the given @a sizer.
  397. Use parameter @a recursive to search in subsizers too.
  398. Returns pointer to item or @NULL.
  399. */
  400. wxSizerItem* GetItem(wxSizer* sizer, bool recursive = false);
  401. /**
  402. Finds wxSizerItem which is located in the sizer at position @a index.
  403. Use parameter @a recursive to search in subsizers too.
  404. Returns pointer to item or @NULL.
  405. */
  406. wxSizerItem* GetItem(size_t index);
  407. /**
  408. Finds item of the sizer which has the given @e id.
  409. This @a id is not the window id but the id of the wxSizerItem itself.
  410. This is mainly useful for retrieving the sizers created from XRC resources.
  411. Use parameter @a recursive to search in subsizers too.
  412. Returns pointer to item or @NULL.
  413. */
  414. wxSizerItem* GetItemById(int id, bool recursive = false);
  415. /**
  416. Returns the minimal size of the sizer.
  417. This is either the combined minimal size of all the children and their
  418. borders or the minimal size set by SetMinSize(), depending on which is bigger.
  419. Note that the returned value is client size, not window size.
  420. In particular, if you use the value to set toplevel window's minimal or
  421. actual size, use wxWindow::SetMinClientSize() or wxWindow::SetClientSize(),
  422. not wxWindow::SetMinSize() or wxWindow::SetSize().
  423. */
  424. wxSize GetMinSize();
  425. /**
  426. Returns the current position of the sizer.
  427. */
  428. wxPoint GetPosition() const;
  429. /**
  430. Returns the current size of the sizer.
  431. */
  432. wxSize GetSize() const;
  433. /**
  434. Hides the child @a window.
  435. To make a sizer item disappear, use Hide() followed by Layout().
  436. Use parameter @a recursive to hide elements found in subsizers.
  437. Returns @true if the child item was found, @false otherwise.
  438. @see IsShown(), Show()
  439. */
  440. bool Hide(wxWindow* window, bool recursive = false);
  441. /**
  442. Hides the child @a sizer.
  443. To make a sizer item disappear, use Hide() followed by Layout().
  444. Use parameter @a recursive to hide elements found in subsizers.
  445. Returns @true if the child item was found, @false otherwise.
  446. @see IsShown(), Show()
  447. */
  448. bool Hide(wxSizer* sizer, bool recursive = false);
  449. /**
  450. Hides the item at position @a index.
  451. To make a sizer item disappear, use Hide() followed by Layout().
  452. Use parameter @a recursive to hide elements found in subsizers.
  453. Returns @true if the child item was found, @false otherwise.
  454. @see IsShown(), Show()
  455. */
  456. bool Hide(size_t index);
  457. /**
  458. Insert a child into the sizer before any existing item at @a index.
  459. See Add() for the meaning of the other parameters.
  460. */
  461. wxSizerItem* Insert(size_t index, wxWindow* window,
  462. const wxSizerFlags& flags);
  463. /**
  464. Insert a child into the sizer before any existing item at @a index.
  465. See Add() for the meaning of the other parameters.
  466. */
  467. wxSizerItem* Insert(size_t index, wxWindow* window,
  468. int proportion = 0,
  469. int flag = 0,
  470. int border = 0,
  471. wxObject* userData = NULL);
  472. /**
  473. Insert a child into the sizer before any existing item at @a index.
  474. See Add() for the meaning of the other parameters.
  475. */
  476. wxSizerItem* Insert(size_t index, wxSizer* sizer,
  477. const wxSizerFlags& flags);
  478. /**
  479. Insert a child into the sizer before any existing item at @a index.
  480. See Add() for the meaning of the other parameters.
  481. */
  482. wxSizerItem* Insert(size_t index, wxSizer* sizer,
  483. int proportion = 0,
  484. int flag = 0,
  485. int border = 0,
  486. wxObject* userData = NULL);
  487. /**
  488. Insert a child into the sizer before any existing item at @a index.
  489. See Add() for the meaning of the other parameters.
  490. */
  491. wxSizerItem* Insert(size_t index, int width, int height,
  492. int proportion = 0,
  493. int flag = 0,
  494. int border = 0,
  495. wxObject* userData = NULL);
  496. /**
  497. Insert a child into the sizer before any existing item at @a index.
  498. See Add() for the meaning of the other parameters.
  499. */
  500. wxSizerItem* Insert(size_t index,
  501. int width,
  502. int height,
  503. const wxSizerFlags& flags);
  504. wxSizerItem* Insert(size_t index, wxSizerItem* item);
  505. /**
  506. Inserts non-stretchable space to the sizer.
  507. More readable way of calling wxSizer::Insert(index, size, size).
  508. */
  509. wxSizerItem* InsertSpacer(size_t index, int size);
  510. /**
  511. Inserts stretchable space to the sizer.
  512. More readable way of calling wxSizer::Insert(0, 0, prop).
  513. */
  514. wxSizerItem* InsertStretchSpacer(size_t index, int prop = 1);
  515. /**
  516. Return @true if the sizer has no elements.
  517. @see GetItemCount()
  518. */
  519. bool IsEmpty() const;
  520. /**
  521. Returns @true if the @a window is shown.
  522. @see Hide(), Show(), wxSizerItem::IsShown()
  523. */
  524. bool IsShown(wxWindow* window) const;
  525. /**
  526. Returns @true if the @a sizer is shown.
  527. @see Hide(), Show(), wxSizerItem::IsShown()
  528. */
  529. bool IsShown(wxSizer* sizer) const;
  530. /**
  531. Returns @true if the item at @a index is shown.
  532. @see Hide(), Show(), wxSizerItem::IsShown()
  533. */
  534. bool IsShown(size_t index) const;
  535. /**
  536. Call this to force layout of the children anew, e.g.\ after having added a child
  537. to or removed a child (window, other sizer or space) from the sizer while
  538. keeping the current dimension.
  539. */
  540. virtual void Layout();
  541. /**
  542. Same as Add(), but prepends the items to the beginning of the
  543. list of items (windows, subsizers or spaces) owned by this sizer.
  544. */
  545. wxSizerItem* Prepend(wxWindow* window, const wxSizerFlags& flags);
  546. /**
  547. Same as Add(), but prepends the items to the beginning of the
  548. list of items (windows, subsizers or spaces) owned by this sizer.
  549. */
  550. wxSizerItem* Prepend(wxWindow* window, int proportion = 0,
  551. int flag = 0,
  552. int border = 0,
  553. wxObject* userData = NULL);
  554. /**
  555. Same as Add(), but prepends the items to the beginning of the
  556. list of items (windows, subsizers or spaces) owned by this sizer.
  557. */
  558. wxSizerItem* Prepend(wxSizer* sizer,
  559. const wxSizerFlags& flags);
  560. /**
  561. Same as Add(), but prepends the items to the beginning of the
  562. list of items (windows, subsizers or spaces) owned by this sizer.
  563. */
  564. wxSizerItem* Prepend(wxSizer* sizer, int proportion = 0,
  565. int flag = 0,
  566. int border = 0,
  567. wxObject* userData = NULL);
  568. /**
  569. Same as Add(), but prepends the items to the beginning of the
  570. list of items (windows, subsizers or spaces) owned by this sizer.
  571. */
  572. wxSizerItem* Prepend(int width, int height,
  573. int proportion = 0,
  574. int flag = 0,
  575. int border = 0,
  576. wxObject* userData = NULL);
  577. /**
  578. Same as Add(), but prepends the items to the beginning of the
  579. list of items (windows, subsizers or spaces) owned by this sizer.
  580. */
  581. wxSizerItem* Prepend(int width, int height, const wxSizerFlags& flags);
  582. wxSizerItem* Prepend(wxSizerItem* item);
  583. /**
  584. Prepends non-stretchable space to the sizer.
  585. More readable way of calling wxSizer::Prepend(size, size, 0).
  586. */
  587. wxSizerItem* PrependSpacer(int size);
  588. /**
  589. Prepends stretchable space to the sizer.
  590. More readable way of calling wxSizer::Prepend(0, 0, prop).
  591. */
  592. wxSizerItem* PrependStretchSpacer(int prop = 1);
  593. /**
  594. This method is abstract and has to be overwritten by any derived class.
  595. Here, the sizer will do the actual calculation of its children's
  596. positions and sizes.
  597. */
  598. virtual void RecalcSizes() = 0;
  599. /**
  600. Removes a child window from the sizer, but does @b not destroy it
  601. (because windows are owned by their parent window, not the sizer).
  602. @deprecated
  603. The overload of this method taking a wxWindow* parameter
  604. is deprecated as it does not destroy the window as would usually be
  605. expected from Remove(). You should use Detach() in new code instead.
  606. There is currently no wxSizer method that will both detach and destroy
  607. a wxWindow item.
  608. @note This method does not cause any layout or resizing to take
  609. place, call Layout() to update the layout "on screen" after
  610. removing a child from the sizer.
  611. @return @true if the child item was found and removed, @false otherwise.
  612. */
  613. virtual bool Remove(wxWindow* window);
  614. /**
  615. Removes a sizer child from the sizer and destroys it.
  616. @note This method does not cause any layout or resizing to take
  617. place, call Layout() to update the layout "on screen" after
  618. removing a child from the sizer.
  619. @param sizer The wxSizer to be removed.
  620. @return @true if the child item was found and removed, @false otherwise.
  621. */
  622. virtual bool Remove(wxSizer* sizer);
  623. /**
  624. Removes a child from the sizer and destroys it if it is a sizer or a
  625. spacer, but not if it is a window (because windows are owned by their
  626. parent window, not the sizer).
  627. @note This method does not cause any layout or resizing to take
  628. place, call Layout() to update the layout "on screen" after
  629. removing a child from the sizer.
  630. @param index
  631. The position of the child in the sizer, e.g. 0 for the first item.
  632. @return @true if the child item was found and removed, @false otherwise.
  633. */
  634. virtual bool Remove(int index);
  635. /**
  636. Detaches the given @a oldwin from the sizer and replaces it with the
  637. given @a newwin. The detached child window is @b not deleted (because
  638. windows are owned by their parent window, not the sizer).
  639. Use parameter @a recursive to search the given element recursively in subsizers.
  640. This method does not cause any layout or resizing to take place,
  641. call Layout() to update the layout "on screen" after replacing a
  642. child from the sizer.
  643. Returns @true if the child item was found and removed, @false otherwise.
  644. */
  645. virtual bool Replace(wxWindow* oldwin, wxWindow* newwin,
  646. bool recursive = false);
  647. /**
  648. Detaches the given @a oldsz from the sizer and replaces it with the
  649. given @a newsz. The detached child sizer is deleted.
  650. Use parameter @a recursive to search the given element recursively in subsizers.
  651. This method does not cause any layout or resizing to take place,
  652. call Layout() to update the layout "on screen" after replacing a
  653. child from the sizer.
  654. Returns @true if the child item was found and removed, @false otherwise.
  655. */
  656. virtual bool Replace(wxSizer* oldsz, wxSizer* newsz,
  657. bool recursive = false);
  658. /**
  659. Detaches the given item at position @a index from the sizer and
  660. replaces it with the given wxSizerItem @a newitem.
  661. The detached child is deleted @b only if it is a sizer or a spacer
  662. (but not if it is a wxWindow because windows are owned by their
  663. parent window, not the sizer).
  664. This method does not cause any layout or resizing to take place,
  665. call Layout() to update the layout "on screen" after replacing a
  666. child from the sizer.
  667. Returns @true if the child item was found and removed, @false otherwise.
  668. */
  669. virtual bool Replace(size_t index, wxSizerItem* newitem);
  670. /**
  671. Call this to force the sizer to take the given dimension and thus force
  672. the items owned by the sizer to resize themselves according to the
  673. rules defined by the parameter in the Add() and Prepend() methods.
  674. */
  675. void SetDimension(int x, int y, int width, int height);
  676. /**
  677. @overload
  678. */
  679. void SetDimension(const wxPoint& pos, const wxSize& size);
  680. /**
  681. Set an item's minimum size by window, sizer, or position.
  682. This function enables an application to set the size of an item after
  683. initial creation.
  684. The @a window or @a sizer will be found recursively in the sizer's
  685. descendants.
  686. @see wxSizerItem::SetMinSize()
  687. @return
  688. @true if the minimal size was successfully set or @false if the
  689. item was not found.
  690. */
  691. //@{
  692. bool SetItemMinSize(wxWindow* window, int width, int height);
  693. bool SetItemMinSize(wxWindow* window, const wxSize& size);
  694. bool SetItemMinSize(wxSizer* sizer, int width, int height);
  695. bool SetItemMinSize(wxSizer* sizer, const wxSize& size);
  696. bool SetItemMinSize(size_t index, int width, int height);
  697. bool SetItemMinSize(size_t index, const wxSize& size);
  698. //@}
  699. /**
  700. Call this to give the sizer a minimal size.
  701. Normally, the sizer will calculate its minimal size based purely on how
  702. much space its children need. After calling this method GetMinSize()
  703. will return either the minimal size as requested by its children or the
  704. minimal size set here, depending on which is bigger.
  705. */
  706. void SetMinSize(const wxSize& size);
  707. /**
  708. @overload
  709. */
  710. void SetMinSize(int width, int height);
  711. /**
  712. This method first calls Fit() and then wxTopLevelWindow::SetSizeHints()
  713. on the @a window passed to it.
  714. This only makes sense when @a window is actually a wxTopLevelWindow such
  715. as a wxFrame or a wxDialog, since SetSizeHints only has any effect in these classes.
  716. It does nothing in normal windows or controls.
  717. This method is implicitly used by wxWindow::SetSizerAndFit() which is
  718. commonly invoked in the constructor of a toplevel window itself (see
  719. the sample in the description of wxBoxSizer) if the toplevel window is
  720. resizable.
  721. */
  722. void SetSizeHints(wxWindow* window);
  723. /**
  724. Tell the sizer to set the minimal size of the @a window virtual area to match
  725. the sizer's minimal size. For windows with managed scrollbars this will set them
  726. appropriately.
  727. @deprecated This is exactly the same as FitInside() in wxWidgets 2.9
  728. and later, please replace calls to it with FitInside().
  729. @see wxScrolled::SetScrollbars()
  730. */
  731. void SetVirtualSizeHints(wxWindow* window);
  732. /**
  733. Shows or hides the @a window.
  734. To make a sizer item disappear or reappear, use Show() followed by Layout().
  735. Use parameter @a recursive to show or hide elements found in subsizers.
  736. Returns @true if the child item was found, @false otherwise.
  737. @see Hide(), IsShown()
  738. */
  739. bool Show(wxWindow* window, bool show = true,
  740. bool recursive = false);
  741. /**
  742. Shows or hides @a sizer.
  743. To make a sizer item disappear or reappear, use Show() followed by Layout().
  744. Use parameter @a recursive to show or hide elements found in subsizers.
  745. Returns @true if the child item was found, @false otherwise.
  746. @see Hide(), IsShown()
  747. */
  748. bool Show(wxSizer* sizer, bool show = true,
  749. bool recursive = false);
  750. /**
  751. Shows the item at @a index.
  752. To make a sizer item disappear or reappear, use Show() followed by Layout().
  753. Returns @true if the child item was found, @false otherwise.
  754. @see Hide(), IsShown()
  755. */
  756. bool Show(size_t index, bool show = true);
  757. /**
  758. Show or hide all items managed by the sizer.
  759. */
  760. virtual void ShowItems(bool show);
  761. };
  762. /**
  763. @class wxStdDialogButtonSizer
  764. This class creates button layouts which conform to the standard button spacing
  765. and ordering defined by the platform or toolkit's user interface guidelines
  766. (if such things exist). By using this class, you can ensure that all your
  767. standard dialogs look correct on all major platforms. Currently it conforms to
  768. the Windows, GTK+ and Mac OS X human interface guidelines.
  769. When there aren't interface guidelines defined for a particular platform or
  770. toolkit, wxStdDialogButtonSizer reverts to the Windows implementation.
  771. To use this class, first add buttons to the sizer by calling
  772. wxStdDialogButtonSizer::AddButton (or wxStdDialogButtonSizer::SetAffirmativeButton,
  773. wxStdDialogButtonSizer::SetNegativeButton or wxStdDialogButtonSizer::SetCancelButton)
  774. and then call Realize in order to create the actual button layout used.
  775. Other than these special operations, this sizer works like any other sizer.
  776. If you add a button with wxID_SAVE, on Mac OS X the button will be renamed to
  777. "Save" and the wxID_NO button will be renamed to "Don't Save" in accordance
  778. with the Mac OS X Human Interface Guidelines.
  779. @library{wxcore}
  780. @category{winlayout}
  781. @see wxSizer, @ref overview_sizer, wxDialog::CreateButtonSizer
  782. */
  783. class wxStdDialogButtonSizer : public wxBoxSizer
  784. {
  785. public:
  786. /**
  787. Constructor for a wxStdDialogButtonSizer.
  788. */
  789. wxStdDialogButtonSizer();
  790. /**
  791. Adds a button to the wxStdDialogButtonSizer. The @a button must have
  792. one of the following identifiers:
  793. - wxID_OK
  794. - wxID_YES
  795. - wxID_SAVE
  796. - wxID_APPLY
  797. - wxID_CLOSE
  798. - wxID_NO
  799. - wxID_CANCEL
  800. - wxID_HELP
  801. - wxID_CONTEXT_HELP
  802. */
  803. void AddButton(wxButton* button);
  804. /**
  805. Rearranges the buttons and applies proper spacing between buttons to make
  806. them match the platform or toolkit's interface guidelines.
  807. */
  808. void Realize();
  809. /**
  810. Sets the affirmative button for the sizer.
  811. This allows you to use identifiers other than the standard identifiers
  812. outlined above.
  813. */
  814. void SetAffirmativeButton(wxButton* button);
  815. /**
  816. Sets the cancel button for the sizer.
  817. This allows you to use identifiers other than the standard identifiers
  818. outlined above.
  819. */
  820. void SetCancelButton(wxButton* button);
  821. /**
  822. Sets the negative button for the sizer.
  823. This allows you to use identifiers other than the standard identifiers
  824. outlined above.
  825. */
  826. void SetNegativeButton(wxButton* button);
  827. virtual void RecalcSizes();
  828. virtual wxSize CalcMin();
  829. };
  830. /**
  831. @class wxSizerItem
  832. The wxSizerItem class is used to track the position, size and other
  833. attributes of each item managed by a wxSizer.
  834. It is not usually necessary to use this class because the sizer elements can
  835. also be identified by their positions or window or sizer pointers but sometimes
  836. it may be more convenient to use it directly.
  837. @library{wxcore}
  838. @category{winlayout}
  839. */
  840. class wxSizerItem : public wxObject
  841. {
  842. public:
  843. /**
  844. Construct a sizer item for tracking a spacer.
  845. */
  846. wxSizerItem(int width, int height, int proportion=0, int flag=0,
  847. int border=0, wxObject* userData=NULL);
  848. //@{
  849. /**
  850. Construct a sizer item for tracking a window.
  851. */
  852. wxSizerItem(wxWindow* window, const wxSizerFlags& flags);
  853. wxSizerItem(wxWindow* window, int proportion=0, int flag=0,
  854. int border=0,
  855. wxObject* userData=NULL);
  856. //@}
  857. //@{
  858. /**
  859. Construct a sizer item for tracking a subsizer.
  860. */
  861. wxSizerItem(wxSizer* sizer, const wxSizerFlags& flags);
  862. wxSizerItem(wxSizer* sizer, int proportion=0, int flag=0,
  863. int border=0,
  864. wxObject* userData=NULL);
  865. //@}
  866. /**
  867. Deletes the user data and subsizer, if any.
  868. */
  869. virtual ~wxSizerItem();
  870. /**
  871. Set the window to be tracked by this item.
  872. The old window isn't deleted as it is now owned by the sizer item.
  873. */
  874. void AssignWindow(wxWindow *window);
  875. /**
  876. Set the sizer tracked by this item.
  877. Old sizer, if any, is deleted.
  878. */
  879. void AssignSizer(wxSizer *sizer);
  880. //@{
  881. /**
  882. Set the size of the spacer tracked by this item.
  883. Old spacer, if any, is deleted.
  884. */
  885. void AssignSpacer(const wxSize& size);
  886. void AssignSpacer(int w, int h);
  887. //@}
  888. /**
  889. Calculates the minimum desired size for the item, including any space
  890. needed by borders.
  891. */
  892. virtual wxSize CalcMin();
  893. /**
  894. Destroy the window or the windows in a subsizer, depending on the type
  895. of item.
  896. */
  897. virtual void DeleteWindows();
  898. /**
  899. Enable deleting the SizerItem without destroying the contained sizer.
  900. */
  901. void DetachSizer();
  902. /**
  903. Return the border attribute.
  904. */
  905. int GetBorder() const;
  906. /**
  907. Return the flags attribute.
  908. See @ref wxsizer_flags "wxSizer flags list" for details.
  909. */
  910. int GetFlag() const;
  911. /**
  912. Return the numeric id of wxSizerItem, or @c wxID_NONE if the id has
  913. not been set.
  914. */
  915. int GetId() const;
  916. /**
  917. Get the minimum size needed for the item.
  918. */
  919. wxSize GetMinSize() const;
  920. /**
  921. Sets the minimum size to be allocated for this item.
  922. If this item is a window, the @a size is also passed to
  923. wxWindow::SetMinSize().
  924. */
  925. void SetMinSize(const wxSize& size);
  926. /**
  927. @overload
  928. */
  929. void SetMinSize(int x, int y);
  930. /**
  931. What is the current position of the item, as set in the last Layout.
  932. */
  933. wxPoint GetPosition() const;
  934. /**
  935. Get the proportion item attribute.
  936. */
  937. int GetProportion() const;
  938. /**
  939. Get the ration item attribute.
  940. */
  941. float GetRatio() const;
  942. /**
  943. Get the rectangle of the item on the parent window, excluding borders.
  944. */
  945. virtual wxRect GetRect();
  946. /**
  947. Get the current size of the item, as set in the last Layout.
  948. */
  949. virtual wxSize GetSize() const;
  950. /**
  951. If this item is tracking a sizer, return it. @NULL otherwise.
  952. */
  953. wxSizer* GetSizer() const;
  954. /**
  955. If this item is tracking a spacer, return its size.
  956. */
  957. wxSize GetSpacer() const;
  958. /**
  959. Get the userData item attribute.
  960. */
  961. wxObject* GetUserData() const;
  962. /**
  963. If this item is tracking a window then return it. @NULL otherwise.
  964. */
  965. wxWindow* GetWindow() const;
  966. /**
  967. Returns @true if this item is a window or a spacer and it is shown or
  968. if this item is a sizer and not all of its elements are hidden.
  969. In other words, for sizer items, all of the child elements must be
  970. hidden for the sizer itself to be considered hidden.
  971. As an exception, if the @c wxRESERVE_SPACE_EVEN_IF_HIDDEN flag was
  972. used for this sizer item, then IsShown() always returns @true for it
  973. (see wxSizerFlags::ReserveSpaceEvenIfHidden()).
  974. */
  975. bool IsShown() const;
  976. /**
  977. Is this item a sizer?
  978. */
  979. bool IsSizer() const;
  980. /**
  981. Is this item a spacer?
  982. */
  983. bool IsSpacer() const;
  984. /**
  985. Is this item a window?
  986. */
  987. bool IsWindow() const;
  988. /**
  989. Set the border item attribute.
  990. */
  991. void SetBorder(int border);
  992. /**
  993. Set the position and size of the space allocated to the sizer, and
  994. adjust the position and size of the item to be within that space
  995. taking alignment and borders into account.
  996. */
  997. virtual void SetDimension(const wxPoint& pos, const wxSize& size);
  998. /**
  999. Set the flag item attribute.
  1000. */
  1001. void SetFlag(int flag);
  1002. /**
  1003. Sets the numeric id of the wxSizerItem to @e id.
  1004. */
  1005. void SetId(int id);
  1006. /**
  1007. @todo docme.
  1008. */
  1009. void SetInitSize(int x, int y);
  1010. /**
  1011. Set the proportion item attribute.
  1012. */
  1013. void SetProportion(int proportion);
  1014. //@{
  1015. /**
  1016. Set the ratio item attribute.
  1017. */
  1018. void SetRatio(int width, int height);
  1019. void SetRatio(wxSize size);
  1020. void SetRatio(float ratio);
  1021. //@}
  1022. /**
  1023. Set the sizer tracked by this item.
  1024. @deprecated This function does not free the old sizer which may result
  1025. in memory leaks, use AssignSizer() which does free it instead.
  1026. */
  1027. void SetSizer(wxSizer* sizer);
  1028. /**
  1029. Set the size of the spacer tracked by this item.
  1030. @deprecated This function does not free the old spacer which may result
  1031. in memory leaks, use AssignSpacer() which does free it instead.
  1032. */
  1033. void SetSpacer(const wxSize& size);
  1034. void SetUserData(wxObject* userData);
  1035. /**
  1036. Set the window to be tracked by this item.
  1037. @deprecated @todo provide deprecation description
  1038. */
  1039. void SetWindow(wxWindow* window);
  1040. /**
  1041. Set the show item attribute, which sizers use to determine if the item
  1042. is to be made part of the layout or not. If the item is tracking a
  1043. window then it is shown or hidden as needed.
  1044. */
  1045. void Show(bool show);
  1046. };
  1047. /**
  1048. @class wxSizerFlags
  1049. Container for sizer items flags providing readable names for them.
  1050. Normally, when you add an item to a sizer via wxSizer::Add, you have to
  1051. specify a lot of flags and parameters which can be unwieldy. This is where
  1052. wxSizerFlags comes in: it allows you to specify all parameters using the
  1053. named methods instead. For example, instead of
  1054. @code
  1055. sizer->Add(ctrl, 0, wxEXPAND | wxALL, 10);
  1056. @endcode
  1057. you can now write
  1058. @code
  1059. sizer->Add(ctrl, wxSizerFlags().Expand().Border(wxALL, 10));
  1060. @endcode
  1061. This is more readable and also allows you to create wxSizerFlags objects which
  1062. can be reused for several sizer items.
  1063. @code
  1064. wxSizerFlags flagsExpand(1);
  1065. flagsExpand.Expand().Border(wxALL, 10);
  1066. sizer->Add(ctrl1, flagsExpand);
  1067. sizer->Add(ctrl2, flagsExpand);
  1068. @endcode
  1069. Note that by specification, all methods of wxSizerFlags return the wxSizerFlags
  1070. object itself to allowing chaining multiple methods calls like in the examples
  1071. above.
  1072. @library{wxcore}
  1073. @category{winlayout}
  1074. @see wxSizer
  1075. */
  1076. class wxSizerFlags
  1077. {
  1078. public:
  1079. /**
  1080. Creates the wxSizer with the proportion specified by @a proportion.
  1081. */
  1082. wxSizerFlags(int proportion = 0);
  1083. /**
  1084. Sets the alignment of this wxSizerFlags to @a align.
  1085. This method replaces the previously set alignment with the specified one.
  1086. @param alignment
  1087. Combination of @c wxALIGN_XXX bit masks.
  1088. @see Top(), Left(), Right(), Bottom(), Centre()
  1089. */
  1090. wxSizerFlags& Align(int alignment);
  1091. /**
  1092. Sets the wxSizerFlags to have a border of a number of pixels specified
  1093. by @a borderinpixels with the directions specified by @a direction.
  1094. */
  1095. wxSizerFlags& Border(int direction, int borderinpixels);
  1096. /**
  1097. Sets the wxSizerFlags to have a border with size as returned by
  1098. GetDefaultBorder().
  1099. @param direction
  1100. Direction(s) to apply the border in.
  1101. */
  1102. wxSizerFlags& Border(int direction = wxALL);
  1103. /**
  1104. Aligns the object to the bottom, similar for @c Align(wxALIGN_BOTTOM).
  1105. Unlike Align(), this method doesn't change the horizontal alignment of
  1106. the item.
  1107. */
  1108. wxSizerFlags& Bottom();
  1109. /**
  1110. Sets the object of the wxSizerFlags to center itself in the area it is
  1111. given.
  1112. */
  1113. wxSizerFlags& Center();
  1114. /**
  1115. Center() for people with the other dialect of English.
  1116. */
  1117. wxSizerFlags& Centre();
  1118. /**
  1119. Sets the border in the given @a direction having twice the default
  1120. border size.
  1121. */
  1122. wxSizerFlags& DoubleBorder(int direction = wxALL);
  1123. /**
  1124. Sets the border in left and right directions having twice the default
  1125. border size.
  1126. */
  1127. wxSizerFlags& DoubleHorzBorder();
  1128. /**
  1129. Sets the object of the wxSizerFlags to expand to fill as much area as
  1130. it can.
  1131. */
  1132. wxSizerFlags& Expand();
  1133. /**
  1134. Set the @c wxFIXED_MINSIZE flag which indicates that the initial size
  1135. of the window should be also set as its minimal size.
  1136. */
  1137. wxSizerFlags& FixedMinSize();
  1138. /**
  1139. Set the @c wxRESERVE_SPACE_EVEN_IF_HIDDEN flag. Normally wxSizers
  1140. don't allocate space for hidden windows or other items. This flag
  1141. overrides this behaviour so that sufficient space is allocated for the
  1142. window even if it isn't visible. This makes it possible to dynamically
  1143. show and hide controls without resizing parent dialog, for example.
  1144. @since 2.8.8
  1145. */
  1146. wxSizerFlags& ReserveSpaceEvenIfHidden();
  1147. /**
  1148. Returns the border used by default in Border() method.
  1149. */
  1150. static int GetDefaultBorder();
  1151. /**
  1152. Aligns the object to the left, similar for @c Align(wxALIGN_LEFT).
  1153. Unlike Align(), this method doesn't change the vertical alignment of
  1154. the item.
  1155. */
  1156. wxSizerFlags& Left();
  1157. /**
  1158. Sets the proportion of this wxSizerFlags to @e proportion
  1159. */
  1160. wxSizerFlags& Proportion(int proportion);
  1161. /**
  1162. Aligns the object to the right, similar for @c Align(wxALIGN_RIGHT).
  1163. Unlike Align(), this method doesn't change the vertical alignment of
  1164. the item.
  1165. */
  1166. wxSizerFlags& Right();
  1167. /**
  1168. Set the @c wx_SHAPED flag which indicates that the elements should
  1169. always keep the fixed width to height ratio equal to its original value.
  1170. */
  1171. wxSizerFlags& Shaped();
  1172. /**
  1173. Aligns the object to the top, similar for @c Align(wxALIGN_TOP).
  1174. Unlike Align(), this method doesn't change the horizontal alignment of
  1175. the item.
  1176. */
  1177. wxSizerFlags& Top();
  1178. /**
  1179. Sets the border in the given @a direction having thrice the default
  1180. border size.
  1181. */
  1182. wxSizerFlags& TripleBorder(int direction = wxALL);
  1183. };
  1184. /**
  1185. Values which define the behaviour for resizing wxFlexGridSizer cells in the
  1186. "non-flexible" direction.
  1187. */
  1188. enum wxFlexSizerGrowMode
  1189. {
  1190. /// Don't resize the cells in non-flexible direction at all.
  1191. wxFLEX_GROWMODE_NONE,
  1192. /// Uniformly resize only the specified ones (default).
  1193. wxFLEX_GROWMODE_SPECIFIED,
  1194. /// Uniformly resize all cells.
  1195. wxFLEX_GROWMODE_ALL
  1196. };
  1197. /**
  1198. @class wxFlexGridSizer
  1199. A flex grid sizer is a sizer which lays out its children in a two-dimensional
  1200. table with all table fields in one row having the same height and all fields
  1201. in one column having the same width, but all rows or all columns are not
  1202. necessarily the same height or width as in the wxGridSizer.
  1203. Since wxWidgets 2.5.0, wxFlexGridSizer can also size items equally in one
  1204. direction but unequally ("flexibly") in the other. If the sizer is only
  1205. flexible in one direction (this can be changed using wxFlexGridSizer::SetFlexibleDirection),
  1206. it needs to be decided how the sizer should grow in the other ("non-flexible")
  1207. direction in order to fill the available space.
  1208. The wxFlexGridSizer::SetNonFlexibleGrowMode() method serves this purpose.
  1209. @library{wxcore}
  1210. @category{winlayout}
  1211. @see wxSizer, @ref overview_sizer
  1212. */
  1213. class wxFlexGridSizer : public wxGridSizer
  1214. {
  1215. public:
  1216. //@{
  1217. /**
  1218. wxFlexGridSizer constructors.
  1219. Please see wxGridSizer::wxGridSizer documentation.
  1220. @since 2.9.1 (except for the four argument overload)
  1221. */
  1222. wxFlexGridSizer( int cols, int vgap, int hgap );
  1223. wxFlexGridSizer( int cols, const wxSize& gap = wxSize(0, 0) );
  1224. wxFlexGridSizer( int rows, int cols, int vgap, int hgap );
  1225. wxFlexGridSizer( int rows, int cols, const wxSize& gap );
  1226. //@}
  1227. /**
  1228. Specifies that column @a idx (starting from zero) should be grown if
  1229. there is extra space available to the sizer.
  1230. The @a proportion parameter has the same meaning as the stretch factor
  1231. for the sizers (see wxBoxSizer) except that if all proportions are 0,
  1232. then all columns are resized equally (instead of not being resized at all).
  1233. Notice that the column must not be already growable, if you need to change
  1234. the proportion you must call RemoveGrowableCol() first and then make it
  1235. growable (with a different proportion) again. You can use IsColGrowable()
  1236. to check whether a column is already growable.
  1237. */
  1238. void AddGrowableCol(size_t idx, int proportion = 0);
  1239. /**
  1240. Specifies that row idx (starting from zero) should be grown if there
  1241. is extra space available to the sizer.
  1242. This is identical to AddGrowableCol() except that it works with rows
  1243. and not columns.
  1244. */
  1245. void AddGrowableRow(size_t idx, int proportion = 0);
  1246. /**
  1247. Returns a ::wxOrientation value that specifies whether the sizer flexibly
  1248. resizes its columns, rows, or both (default).
  1249. @return
  1250. One of the following values:
  1251. - wxVERTICAL: Rows are flexibly sized.
  1252. - wxHORIZONTAL: Columns are flexibly sized.
  1253. - wxBOTH: Both rows and columns are flexibly sized (this is the default value).
  1254. @see SetFlexibleDirection()
  1255. */
  1256. int GetFlexibleDirection() const;
  1257. /**
  1258. Returns the value that specifies how the sizer grows in the "non-flexible"
  1259. direction if there is one.
  1260. The behaviour of the elements in the flexible direction (i.e. both rows
  1261. and columns by default, or rows only if GetFlexibleDirection() is
  1262. @c wxVERTICAL or columns only if it is @c wxHORIZONTAL) is always governed
  1263. by their proportion as specified in the call to AddGrowableRow() or
  1264. AddGrowableCol(). What happens in the other direction depends on the
  1265. value of returned by this function as described below.
  1266. @return
  1267. One of the following values:
  1268. - wxFLEX_GROWMODE_NONE: Sizer doesn't grow its elements at all in
  1269. the non-flexible direction.
  1270. - wxFLEX_GROWMODE_SPECIFIED: Sizer honors growable columns/rows set
  1271. with AddGrowableCol() and AddGrowableRow() in the non-flexible
  1272. direction as well. In this case equal sizing applies to minimum
  1273. sizes of columns or rows (this is the default value).
  1274. - wxFLEX_GROWMODE_ALL: Sizer equally stretches all columns or rows in
  1275. the non-flexible direction, independently of the proportions
  1276. applied in the flexible direction.
  1277. @see SetFlexibleDirection(), SetNonFlexibleGrowMode()
  1278. */
  1279. wxFlexSizerGrowMode GetNonFlexibleGrowMode() const;
  1280. /**
  1281. Returns @true if column @a idx is growable.
  1282. @since 2.9.0
  1283. */
  1284. bool IsColGrowable(size_t idx);
  1285. /**
  1286. Returns @true if row @a idx is growable.
  1287. @since 2.9.0
  1288. */
  1289. bool IsRowGrowable(size_t idx);
  1290. /**
  1291. Specifies that the @a idx column index is no longer growable.
  1292. */
  1293. void RemoveGrowableCol(size_t idx);
  1294. /**
  1295. Specifies that the @a idx row index is no longer growable.
  1296. */
  1297. void RemoveGrowableRow(size_t idx);
  1298. /**
  1299. Specifies whether the sizer should flexibly resize its columns, rows, or both.
  1300. Argument @a direction can be @c wxVERTICAL, @c wxHORIZONTAL or @c wxBOTH
  1301. (which is the default value). Any other value is ignored.
  1302. See GetFlexibleDirection() for the explanation of these values.
  1303. Note that this method does not trigger relayout.
  1304. */
  1305. void SetFlexibleDirection(int direction);
  1306. /**
  1307. Specifies how the sizer should grow in the non-flexible direction if
  1308. there is one (so SetFlexibleDirection() must have been called previously).
  1309. Argument @a mode can be one of those documented in GetNonFlexibleGrowMode(),
  1310. please see there for their explanation.
  1311. Note that this method does not trigger relayout.
  1312. */
  1313. void SetNonFlexibleGrowMode(wxFlexSizerGrowMode mode);
  1314. /**
  1315. Returns a read-only array containing the heights of the rows in the sizer.
  1316. */
  1317. const wxArrayInt& GetRowHeights() const;
  1318. /**
  1319. Returns a read-only array containing the widths of the columns in the sizer.
  1320. */
  1321. const wxArrayInt& GetColWidths() const;
  1322. virtual void RecalcSizes();
  1323. virtual wxSize CalcMin();
  1324. };
  1325. /**
  1326. @class wxGridSizer
  1327. A grid sizer is a sizer which lays out its children in a two-dimensional
  1328. table with all table fields having the same size, i.e. the width of each
  1329. field is the width of the widest child, the height of each field is the
  1330. height of the tallest child.
  1331. @library{wxcore}
  1332. @category{winlayout}
  1333. @see wxSizer, @ref overview_sizer
  1334. */
  1335. class wxGridSizer : public wxSizer
  1336. {
  1337. public:
  1338. //@{
  1339. /**
  1340. wxGridSizer constructors.
  1341. Usually only the number of columns in the flex grid sizer needs to be
  1342. specified using @a cols argument. The number of rows will be deduced
  1343. automatically depending on the number of the elements added to the
  1344. sizer.
  1345. If a constructor form with @a rows parameter is used (and the value of
  1346. @a rows argument is not zero, meaning "unspecified") the sizer will
  1347. check that no more than @c cols*rows elements are added to it, i.e.
  1348. that no more than the given number of @a rows is used. Adding less than
  1349. maximally allowed number of items is not an error however.
  1350. Finally, it is also possible to specify the number of rows and use 0
  1351. for @a cols. In this case, the sizer will use the given fixed number of
  1352. rows and as many columns as necessary.
  1353. The @a gap (or @a vgap and @a hgap, which correspond to the height and
  1354. width of the wxSize object) argument defines the size of the padding
  1355. between the rows (its vertical component, or @a vgap) and columns
  1356. (its horizontal component, or @a hgap), in pixels.
  1357. @since 2.9.1 (except for the four argument overload)
  1358. */
  1359. wxGridSizer( int cols, int vgap, int hgap );
  1360. wxGridSizer( int cols, const wxSize& gap = wxSize(0, 0) );
  1361. wxGridSizer( int rows, int cols, int vgap, int hgap );
  1362. wxGridSizer( int rows, int cols, const wxSize& gap );
  1363. //@}
  1364. /**
  1365. Returns the number of columns that has been specified for the
  1366. sizer.
  1367. Returns zero if the sizer is automatically adjusting the number of
  1368. columns depending on number of its children. To get the effective
  1369. number of columns or rows being currently used, see GetEffectiveColsCount()
  1370. */
  1371. int GetCols() const;
  1372. /**
  1373. Returns the number of rows that has been specified for the
  1374. sizer.
  1375. Returns zero if the sizer is automatically adjusting the number of
  1376. rows depending on number of its children. To get the effective
  1377. number of columns or rows being currently used, see GetEffectiveRowsCount().
  1378. */
  1379. int GetRows() const;
  1380. /**
  1381. Returns the number of columns currently used by the sizer.
  1382. This will depend on the number of children the sizer has if
  1383. the sizer is automatically adjusting the number of columns/rows.
  1384. @since 2.9.1
  1385. */
  1386. int GetEffectiveColsCount() const;
  1387. /**
  1388. Returns the number of rows currently used by the sizer.
  1389. This will depend on the number of children the sizer has if
  1390. the sizer is automatically adjusting the number of columns/rows.
  1391. @since 2.9.1
  1392. */
  1393. int GetEffectiveRowsCount() const;
  1394. /**
  1395. Returns the horizontal gap (in pixels) between cells in the sizer.
  1396. */
  1397. int GetHGap() const;
  1398. /**
  1399. Returns the vertical gap (in pixels) between the cells in the sizer.
  1400. */
  1401. int GetVGap() const;
  1402. /**
  1403. Sets the number of columns in the sizer.
  1404. */
  1405. void SetCols(int cols);
  1406. /**
  1407. Sets the horizontal gap (in pixels) between cells in the sizer.
  1408. */
  1409. void SetHGap(int gap);
  1410. /**
  1411. Sets the number of rows in the sizer.
  1412. */
  1413. void SetRows(int rows);
  1414. /**
  1415. Sets the vertical gap (in pixels) between the cells in the sizer.
  1416. */
  1417. void SetVGap(int gap);
  1418. virtual wxSize CalcMin();
  1419. virtual void RecalcSizes();
  1420. };
  1421. /**
  1422. @class wxStaticBoxSizer
  1423. wxStaticBoxSizer is a sizer derived from wxBoxSizer but adds a static box around
  1424. the sizer.
  1425. The static box may be either created independently or the sizer may create it
  1426. itself as a convenience. In any case, the sizer owns the wxStaticBox control
  1427. and will delete it in the wxStaticBoxSizer destructor.
  1428. Note that since wxWidgets 2.9.1 you are encouraged to create the windows
  1429. which are added to wxStaticBoxSizer as children of wxStaticBox itself, see
  1430. this class documentation for more details.
  1431. Example of use of this class:
  1432. @code
  1433. void MyFrame::CreateControls()
  1434. {
  1435. wxPanel *panel = new wxPanel(this);
  1436. ...
  1437. wxStaticBoxSizer *sz = new wxStaticBoxSizer(wxVERTICAL, panel, "Box");
  1438. sz->Add(new wxStaticText(sz->GetStaticBox(), wxID_ANY,
  1439. "This window is a child of the staticbox"));
  1440. ...
  1441. }
  1442. @endcode
  1443. @library{wxcore}
  1444. @category{winlayout}
  1445. @see wxSizer, wxStaticBox, wxBoxSizer, @ref overview_sizer
  1446. */
  1447. class wxStaticBoxSizer : public wxBoxSizer
  1448. {
  1449. public:
  1450. /**
  1451. This constructor uses an already existing static box.
  1452. @param box
  1453. The static box to associate with the sizer (which will take its
  1454. ownership).
  1455. @param orient
  1456. Can be either @c wxVERTICAL or @c wxHORIZONTAL.
  1457. */
  1458. wxStaticBoxSizer(wxStaticBox* box, int orient);
  1459. /**
  1460. This constructor creates a new static box with the given label and parent window.
  1461. */
  1462. wxStaticBoxSizer(int orient, wxWindow *parent,
  1463. const wxString& label = wxEmptyString);
  1464. /**
  1465. Returns the static box associated with the sizer.
  1466. */
  1467. wxStaticBox* GetStaticBox() const;
  1468. virtual wxSize CalcMin();
  1469. virtual void RecalcSizes();
  1470. };
  1471. /**
  1472. @class wxBoxSizer
  1473. The basic idea behind a box sizer is that windows will most often be laid out
  1474. in rather simple basic geometry, typically in a row or a column or several
  1475. hierarchies of either.
  1476. For more information, please see @ref overview_sizer_box.
  1477. @library{wxcore}
  1478. @category{winlayout}
  1479. @see wxSizer, @ref overview_sizer
  1480. */
  1481. class wxBoxSizer : public wxSizer
  1482. {
  1483. public:
  1484. /**
  1485. Constructor for a wxBoxSizer. @a orient may be either of wxVERTICAL
  1486. or wxHORIZONTAL for creating either a column sizer or a row sizer.
  1487. */
  1488. wxBoxSizer(int orient);
  1489. /**
  1490. Adds non-stretchable space to the main orientation of the sizer only.
  1491. More readable way of calling:
  1492. @code
  1493. if ( wxBoxSizer::IsVertical() )
  1494. {
  1495. wxBoxSizer::Add(0, size, 0).
  1496. }
  1497. else
  1498. {
  1499. wxBoxSizer::Add(size, 0, 0).
  1500. }
  1501. @endcode
  1502. */
  1503. virtual wxSizerItem *AddSpacer(int size);
  1504. /**
  1505. Implements the calculation of a box sizer's minimal.
  1506. It is used internally only and must not be called by the user.
  1507. Documented for information.
  1508. */
  1509. virtual wxSize CalcMin();
  1510. /**
  1511. Returns the orientation of the box sizer, either wxVERTICAL
  1512. or wxHORIZONTAL.
  1513. */
  1514. int GetOrientation() const;
  1515. /**
  1516. Sets the orientation of the box sizer, either wxVERTICAL
  1517. or wxHORIZONTAL.
  1518. */
  1519. void SetOrientation(int orient);
  1520. /**
  1521. Implements the calculation of a box sizer's dimensions and then sets
  1522. the size of its children (calling wxWindow::SetSize if the child is a window).
  1523. It is used internally only and must not be called by the user
  1524. (call Layout() if you want to resize). Documented for information.
  1525. */
  1526. virtual void RecalcSizes();
  1527. };