]> git.saurik.com Git - wxWidgets.git/blame - include/wx/sizer.h
Increase interoperability between wxPoint and wxRealPoint introducing constructors...
[wxWidgets.git] / include / wx / sizer.h
CommitLineData
5279a24d 1/////////////////////////////////////////////////////////////////////////////
ce7208d4 2// Name: wx/sizer.h
a4ab8ed5 3// Purpose: provide wxSizer class for layout
5279a24d 4// Author: Robert Roebling and Robin Dunn
5f813ad6 5// Modified by: Ron Lee, Vadim Zeitlin (wxSizerFlags)
0c0d686f 6// Created:
5279a24d 7// RCS-ID: $Id$
a4ab8ed5 8// Copyright: (c) Robin Dunn, Robert Roebling
65571936 9// Licence: wxWindows licence
5279a24d
RR
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef __WXSIZER_H__
13#define __WXSIZER_H__
14
5279a24d
RR
15#include "wx/defs.h"
16
17#include "wx/window.h"
5279a24d
RR
18
19//---------------------------------------------------------------------------
20// classes
21//---------------------------------------------------------------------------
22
b5dbe15d
VS
23class WXDLLIMPEXP_FWD_CORE wxButton;
24class WXDLLIMPEXP_FWD_CORE wxBoxSizer;
25class WXDLLIMPEXP_FWD_CORE wxSizerItem;
26class WXDLLIMPEXP_FWD_CORE wxSizer;
5f813ad6 27
97ebfd54
VZ
28#ifndef wxUSE_BORDER_BY_DEFAULT
29 #ifdef __SMARTPHONE__
30 // no borders by default on limited size screen
31 #define wxUSE_BORDER_BY_DEFAULT 0
32 #else
33 #define wxUSE_BORDER_BY_DEFAULT 1
34 #endif
35#endif
36
5f813ad6
VZ
37// ----------------------------------------------------------------------------
38// wxSizerFlags: flags used for an item in the sizer
39// ----------------------------------------------------------------------------
40
53a2db12 41class WXDLLIMPEXP_CORE wxSizerFlags
5f813ad6
VZ
42{
43public:
44 // construct the flags object initialized with the given proportion (0 by
45 // default)
46 wxSizerFlags(int proportion = 0) : m_proportion(proportion)
47 {
48 m_flags = 0;
49 m_borderInPixels = 0;
50 }
51
52 // setters for all sizer flags, they all return the object itself so that
53 // calls to them can be chained
54
55 wxSizerFlags& Proportion(int proportion)
56 {
57 m_proportion = proportion;
58 return *this;
59 }
60
30a56ea8 61 wxSizerFlags& Expand()
5f813ad6 62 {
30a56ea8 63 m_flags |= wxEXPAND;
5f813ad6
VZ
64 return *this;
65 }
66
30a56ea8
VZ
67 // notice that Align() replaces the current alignment flags, use specific
68 // methods below such as Top(), Left() &c if you want to set just the
69 // vertical or horizontal alignment
70 wxSizerFlags& Align(int alignment) // combination of wxAlignment values
00dc67b8 71 {
30a56ea8
VZ
72 m_flags &= ~wxALIGN_MASK;
73 m_flags |= alignment;
74
00dc67b8
VZ
75 return *this;
76 }
77
5f813ad6 78 // some shortcuts for Align()
89064717 79 wxSizerFlags& Centre() { return Align(wxALIGN_CENTRE); }
5f813ad6 80 wxSizerFlags& Center() { return Centre(); }
30a56ea8 81
2f39b5a3
VZ
82 wxSizerFlags& Top()
83 {
84 m_flags &= ~(wxALIGN_BOTTOM | wxALIGN_CENTRE_VERTICAL);
85 return *this;
30a56ea8
VZ
86 }
87
2f39b5a3
VZ
88 wxSizerFlags& Left()
89 {
90 m_flags &= ~(wxALIGN_RIGHT | wxALIGN_CENTRE_HORIZONTAL);
91 return *this;
30a56ea8
VZ
92 }
93
2f39b5a3
VZ
94 wxSizerFlags& Right()
95 {
96 m_flags = (m_flags & ~wxALIGN_CENTRE_HORIZONTAL) | wxALIGN_RIGHT;
97 return *this;
30a56ea8
VZ
98 }
99
2f39b5a3
VZ
100 wxSizerFlags& Bottom()
101 {
102 m_flags = (m_flags & ~wxALIGN_CENTRE_VERTICAL) | wxALIGN_BOTTOM;
103 return *this;
30a56ea8
VZ
104 }
105
5f813ad6 106
2be7beda
VZ
107 // default border size used by Border() below
108 static int GetDefaultBorder()
109 {
97ebfd54 110#if wxUSE_BORDER_BY_DEFAULT
43c5fff8
VS
111 #ifdef __WXGTK20__
112 // GNOME HIG says to use 6px as the base unit:
113 // http://library.gnome.org/devel/hig-book/stable/design-window.html.en
114 return 6;
115 #else
2be7beda
VZ
116 // FIXME: default border size shouldn't be hardcoded and at the very
117 // least they should depend on the current font size
118 return 5;
43c5fff8 119 #endif
97ebfd54
VZ
120#else
121 return 0;
122#endif
2be7beda
VZ
123 }
124
5f813ad6
VZ
125
126 wxSizerFlags& Border(int direction, int borderInPixels)
127 {
128 m_flags &= ~wxALL;
129 m_flags |= direction;
130
131 m_borderInPixels = borderInPixels;
132
133 return *this;
134 }
135
136 wxSizerFlags& Border(int direction = wxALL)
137 {
97ebfd54
VZ
138#if wxUSE_BORDER_BY_DEFAULT
139 return Border(direction, GetDefaultBorder());
140#else
92b0cd9e
VZ
141 // no borders by default on limited size screen
142 wxUnusedVar(direction);
143
144 return *this;
97ebfd54
VZ
145#endif
146 }
147
148 wxSizerFlags& DoubleBorder(int direction = wxALL)
149 {
150#if wxUSE_BORDER_BY_DEFAULT
151 return Border(direction, 2*GetDefaultBorder());
92b0cd9e 152#else
97ebfd54
VZ
153 wxUnusedVar(direction);
154
155 return *this;
92b0cd9e 156#endif
5f813ad6
VZ
157 }
158
97ebfd54
VZ
159 wxSizerFlags& TripleBorder(int direction = wxALL)
160 {
161#if wxUSE_BORDER_BY_DEFAULT
162 return Border(direction, 3*GetDefaultBorder());
163#else
164 wxUnusedVar(direction);
165
166 return *this;
167#endif
168 }
169
170 wxSizerFlags& HorzBorder()
171 {
172#if wxUSE_BORDER_BY_DEFAULT
173 return Border(wxLEFT | wxRIGHT, GetDefaultBorder());
174#else
175 return *this;
176#endif
177 }
178
179 wxSizerFlags& DoubleHorzBorder()
180 {
181#if wxUSE_BORDER_BY_DEFAULT
182 return Border(wxLEFT | wxRIGHT, 2*GetDefaultBorder());
183#else
184 return *this;
185#endif
186 }
5f813ad6 187
d95527de
VZ
188 // setters for the others flags
189 wxSizerFlags& Shaped()
190 {
191 m_flags |= wxSHAPED;
192
193 return *this;
194 }
195
196 wxSizerFlags& FixedMinSize()
197 {
198 m_flags |= wxFIXED_MINSIZE;
199
200 return *this;
201 }
d95527de 202
0ba6faae
VS
203 // makes the item ignore window's visibility status
204 wxSizerFlags& ReserveSpaceEvenIfHidden()
205 {
206 m_flags |= wxRESERVE_SPACE_EVEN_IF_HIDDEN;
207 return *this;
208 }
209
5f813ad6
VZ
210 // accessors for wxSizer only
211 int GetProportion() const { return m_proportion; }
212 int GetFlags() const { return m_flags; }
213 int GetBorderInPixels() const { return m_borderInPixels; }
214
215private:
216 int m_proportion;
217 int m_flags;
218 int m_borderInPixels;
219};
220
221
50c06297
VZ
222// ----------------------------------------------------------------------------
223// wxSizerSpacer: used by wxSizerItem to represent a spacer
224// ----------------------------------------------------------------------------
5279a24d 225
53a2db12 226class WXDLLIMPEXP_CORE wxSizerSpacer
5279a24d
RR
227{
228public:
50c06297 229 wxSizerSpacer(const wxSize& size) : m_size(size), m_isShown(true) { }
5f813ad6 230
50c06297
VZ
231 void SetSize(const wxSize& size) { m_size = size; }
232 const wxSize& GetSize() const { return m_size; }
5f813ad6 233
50c06297
VZ
234 void Show(bool show) { m_isShown = show; }
235 bool IsShown() const { return m_isShown; }
5f813ad6 236
50c06297
VZ
237private:
238 // the size, in pixel
239 wxSize m_size;
df5ddbca 240
50c06297
VZ
241 // is the spacer currently shown?
242 bool m_isShown;
243};
244
245// ----------------------------------------------------------------------------
246// wxSizerItem
247// ----------------------------------------------------------------------------
248
53a2db12 249class WXDLLIMPEXP_CORE wxSizerItem : public wxObject
50c06297
VZ
250{
251public:
df5ddbca 252 // window
12a3f227
RL
253 wxSizerItem( wxWindow *window,
254 int proportion,
255 int flag,
256 int border,
257 wxObject* userData );
df5ddbca 258
50c06297
VZ
259 // window with flags
260 wxSizerItem(wxWindow *window, const wxSizerFlags& flags)
261 {
262 Init(flags);
263
4dd10327 264 DoSetWindow(window);
50c06297
VZ
265 }
266
df5ddbca 267 // subsizer
12a3f227
RL
268 wxSizerItem( wxSizer *sizer,
269 int proportion,
270 int flag,
271 int border,
272 wxObject* userData );
df5ddbca 273
50c06297
VZ
274 // sizer with flags
275 wxSizerItem(wxSizer *sizer, const wxSizerFlags& flags)
276 {
277 Init(flags);
278
4dd10327 279 DoSetSizer(sizer);
50c06297
VZ
280 }
281
5f813ad6
VZ
282 // spacer
283 wxSizerItem( int width,
284 int height,
285 int proportion,
286 int flag,
287 int border,
288 wxObject* userData);
289
50c06297
VZ
290 // spacer with flags
291 wxSizerItem(int width, int height, const wxSizerFlags& flags)
292 {
293 Init(flags);
294
4dd10327 295 DoSetSpacer(wxSize(width, height));
50c06297
VZ
296 }
297
20b35a69
RD
298 wxSizerItem();
299 virtual ~wxSizerItem();
dc259b79 300
84f7908b 301 virtual void DeleteWindows();
df5ddbca 302
96fdbb60 303 // Enable deleting the SizerItem without destroying the contained sizer.
50c06297 304 void DetachSizer() { m_sizer = NULL; }
96fdbb60 305
9cbee2ce 306 virtual wxSize GetSize() const;
df5ddbca 307 virtual wxSize CalcMin();
fbfb8bcc 308 virtual void SetDimension( const wxPoint& pos, const wxSize& size );
df5ddbca 309
9cbee2ce 310 wxSize GetMinSize() const
df5ddbca 311 { return m_minSize; }
ba763a45
RD
312 wxSize GetMinSizeWithBorder() const;
313
1eba2193 314 void SetMinSize(const wxSize& size)
50c06297
VZ
315 {
316 if ( IsWindow() )
317 m_window->SetMinSize(size);
318 m_minSize = size;
319 }
1eba2193 320 void SetMinSize( int x, int y )
8b2bac62 321 { SetMinSize(wxSize(x, y)); }
12a3f227 322 void SetInitSize( int x, int y )
1eba2193 323 { SetMinSize(wxSize(x, y)); }
df5ddbca 324
50c06297
VZ
325 // if either of dimensions is zero, ratio is assumed to be 1
326 // to avoid "divide by zero" errors
327 void SetRatio(int width, int height)
df5ddbca 328 { m_ratio = (width && height) ? ((float) width / (float) height) : 1; }
50c06297
VZ
329 void SetRatio(const wxSize& size)
330 { SetRatio(size.x, size.y); }
331 void SetRatio(float ratio)
df5ddbca 332 { m_ratio = ratio; }
2aab8f16 333 float GetRatio() const
df5ddbca
RR
334 { return m_ratio; }
335
50c06297 336 virtual wxRect GetRect() { return m_rect; }
56eee37f 337
86909f4c
VZ
338 // set a sizer item id (different from a window id, all sizer items,
339 // including spacers, can have an associated id)
340 void SetId(int id) { m_id = id; }
341 int GetId() const { return m_id; }
342
50c06297
VZ
343 bool IsWindow() const { return m_kind == Item_Window; }
344 bool IsSizer() const { return m_kind == Item_Sizer; }
345 bool IsSpacer() const { return m_kind == Item_Spacer; }
2aab8f16 346
6a9e54bd 347#if WXWIN_COMPATIBILITY_2_6
12a3f227
RL
348 // Deprecated in 2.6, use {G,S}etProportion instead.
349 wxDEPRECATED( void SetOption( int option ) );
350 wxDEPRECATED( int GetOption() const );
6a9e54bd 351#endif // WXWIN_COMPATIBILITY_2_6
12a3f227
RL
352
353 void SetProportion( int proportion )
354 { m_proportion = proportion; }
355 int GetProportion() const
356 { return m_proportion; }
df5ddbca
RR
357 void SetFlag( int flag )
358 { m_flag = flag; }
12a3f227
RL
359 int GetFlag() const
360 { return m_flag; }
df5ddbca
RR
361 void SetBorder( int border )
362 { m_border = border; }
12a3f227
RL
363 int GetBorder() const
364 { return m_border; }
df5ddbca
RR
365
366 wxWindow *GetWindow() const
50c06297 367 { return m_kind == Item_Window ? m_window : NULL; }
df5ddbca 368 wxSizer *GetSizer() const
50c06297
VZ
369 { return m_kind == Item_Sizer ? m_sizer : NULL; }
370 wxSize GetSpacer() const;
12a3f227 371
0ba6faae 372 // This function behaves obviously for the windows and spacers but for the
c86fd3a7 373 // sizers it returns true if any sizer element is shown and only returns
0ba6faae
VS
374 // false if all of them are hidden. Also, it always returns true if
375 // wxRESERVE_SPACE_EVEN_IF_HIDDEN flag was used.
c86fd3a7 376 bool IsShown() const;
0ba6faae 377
50c06297 378 void Show(bool show);
12a3f227 379
e8c1be04 380 void SetUserData(wxObject* userData)
1737dac2 381 { delete m_userData; m_userData = userData; }
9cbee2ce 382 wxObject* GetUserData() const
df5ddbca 383 { return m_userData; }
9cbee2ce 384 wxPoint GetPosition() const
df5ddbca 385 { return m_pos; }
0c0d686f 386
2f39b5a3
VZ
387 // Called once the first component of an item has been decided. This is
388 // used in algorithms that depend on knowing the size in one direction
389 // before the min size in the other direction can be known.
15f7c305
RR
390 // Returns true if it made use of the information (and min size was changed).
391 bool InformFirstDirection( int direction, int size, int availableOtherDir=-1 );
392
4dd10327
VZ
393 // these functions delete the current contents of the item if it's a sizer
394 // or a spacer but not if it is a window
395 void AssignWindow(wxWindow *window)
396 {
397 Free();
398 DoSetWindow(window);
399 }
400
401 void AssignSizer(wxSizer *sizer)
402 {
403 Free();
404 DoSetSizer(sizer);
405 }
406
407 void AssignSpacer(const wxSize& size)
408 {
409 Free();
410 DoSetSpacer(size);
411 }
412
413 void AssignSpacer(int w, int h) { AssignSpacer(wxSize(w, h)); }
50c06297 414
4dd10327
VZ
415#if WXWIN_COMPATIBILITY_2_8
416 // these functions do not free the old sizer/spacer and so can easily
417 // provoke the memory leaks and so shouldn't be used, use Assign() instead
418 wxDEPRECATED( void SetWindow(wxWindow *window) );
419 wxDEPRECATED( void SetSizer(wxSizer *sizer) );
420 wxDEPRECATED( void SetSpacer(const wxSize& size) );
421 wxDEPRECATED( void SetSpacer(int width, int height) );
422#endif // WXWIN_COMPATIBILITY_2_8
50c06297 423
c62ac5b6 424protected:
5f813ad6 425 // common part of several ctors
4dd10327 426 void Init() { m_userData = NULL; m_kind = Item_None; }
5f813ad6
VZ
427
428 // common part of ctors taking wxSizerFlags
429 void Init(const wxSizerFlags& flags);
430
4dd10327
VZ
431 // free current contents
432 void Free();
433
434 // common parts of Set/AssignXXX()
435 void DoSetWindow(wxWindow *window);
436 void DoSetSizer(wxSizer *sizer);
437 void DoSetSpacer(const wxSize& size);
f303d69f
VZ
438
439 // discriminated union: depending on m_kind one of the fields is valid
50c06297
VZ
440 enum
441 {
442 Item_None,
443 Item_Window,
444 Item_Sizer,
445 Item_Spacer,
446 Item_Max
447 } m_kind;
448 union
449 {
450 wxWindow *m_window;
451 wxSizer *m_sizer;
452 wxSizerSpacer *m_spacer;
453 };
5f813ad6 454
df5ddbca
RR
455 wxPoint m_pos;
456 wxSize m_minSize;
12a3f227 457 int m_proportion;
df5ddbca
RR
458 int m_border;
459 int m_flag;
86909f4c 460 int m_id;
2b5f62a0 461
50c06297
VZ
462 // on screen rectangle of this item (not including borders)
463 wxRect m_rect;
12a3f227
RL
464
465 // Aspect ratio can always be calculated from m_size,
466 // but this would cause precision loss when the window
467 // is shrunk. It is safer to preserve the initial value.
df5ddbca 468 float m_ratio;
2b5f62a0 469
df5ddbca 470 wxObject *m_userData;
2aab8f16 471
9cbee2ce 472private:
4393b50c 473 DECLARE_CLASS(wxSizerItem)
c0c133e1 474 wxDECLARE_NO_COPY_CLASS(wxSizerItem);
c62ac5b6 475};
5279a24d 476
12a3f227
RL
477WX_DECLARE_EXPORTED_LIST( wxSizerItem, wxSizerItemList );
478
5f813ad6 479
5279a24d 480//---------------------------------------------------------------------------
3417c2cd 481// wxSizer
5279a24d
RR
482//---------------------------------------------------------------------------
483
53a2db12 484class WXDLLIMPEXP_CORE wxSizer: public wxObject, public wxClientDataContainer
5279a24d
RR
485{
486public:
e8cfff87 487 wxSizer() { m_containingWindow = NULL; }
d3c7fc99 488 virtual ~wxSizer();
f6bcfd97 489
436ae7cf
VZ
490 // methods for adding elements to the sizer: there are Add/Insert/Prepend
491 // overloads for each of window/sizer/spacer/wxSizerItem
ca8d899f
VZ
492 wxSizerItem* Add(wxWindow *window,
493 int proportion = 0,
494 int flag = 0,
495 int border = 0,
496 wxObject* userData = NULL);
497 wxSizerItem* Add(wxSizer *sizer,
498 int proportion = 0,
499 int flag = 0,
500 int border = 0,
501 wxObject* userData = NULL);
502 wxSizerItem* Add(int width,
503 int height,
504 int proportion = 0,
505 int flag = 0,
506 int border = 0,
507 wxObject* userData = NULL);
508 wxSizerItem* Add( wxWindow *window, const wxSizerFlags& flags);
509 wxSizerItem* Add( wxSizer *sizer, const wxSizerFlags& flags);
b701f995 510 wxSizerItem* Add( int width, int height, const wxSizerFlags& flags);
ca8d899f
VZ
511 wxSizerItem* Add( wxSizerItem *item);
512
1a2df6a7 513 virtual wxSizerItem *AddSpacer(int size);
ca8d899f
VZ
514 wxSizerItem* AddStretchSpacer(int prop = 1);
515
516 wxSizerItem* Insert(size_t index,
517 wxWindow *window,
518 int proportion = 0,
519 int flag = 0,
520 int border = 0,
521 wxObject* userData = NULL);
522 wxSizerItem* Insert(size_t index,
523 wxSizer *sizer,
524 int proportion = 0,
525 int flag = 0,
526 int border = 0,
527 wxObject* userData = NULL);
528 wxSizerItem* Insert(size_t index,
529 int width,
530 int height,
531 int proportion = 0,
532 int flag = 0,
533 int border = 0,
534 wxObject* userData = NULL);
535 wxSizerItem* Insert(size_t index,
536 wxWindow *window,
537 const wxSizerFlags& flags);
538 wxSizerItem* Insert(size_t index,
539 wxSizer *sizer,
540 const wxSizerFlags& flags);
b701f995
VZ
541 wxSizerItem* Insert(size_t index,
542 int width,
543 int height,
2f39b5a3 544 const wxSizerFlags& flags);
e556b612
VZ
545
546 // NB: do _not_ override this function in the derived classes, this one is
547 // virtual for compatibility reasons only to allow old code overriding
548 // it to continue to work, override DoInsert() instead in the new code
549 virtual wxSizerItem* Insert(size_t index, wxSizerItem *item);
ca8d899f
VZ
550
551 wxSizerItem* InsertSpacer(size_t index, int size);
552 wxSizerItem* InsertStretchSpacer(size_t index, int prop = 1);
553
554 wxSizerItem* Prepend(wxWindow *window,
555 int proportion = 0,
556 int flag = 0,
557 int border = 0,
558 wxObject* userData = NULL);
559 wxSizerItem* Prepend(wxSizer *sizer,
560 int proportion = 0,
561 int flag = 0,
562 int border = 0,
563 wxObject* userData = NULL);
564 wxSizerItem* Prepend(int width,
565 int height,
566 int proportion = 0,
567 int flag = 0,
568 int border = 0,
569 wxObject* userData = NULL);
570 wxSizerItem* Prepend(wxWindow *window, const wxSizerFlags& flags);
571 wxSizerItem* Prepend(wxSizer *sizer, const wxSizerFlags& flags);
b701f995 572 wxSizerItem* Prepend(int width, int height, const wxSizerFlags& flags);
ca8d899f
VZ
573 wxSizerItem* Prepend(wxSizerItem *item);
574
575 wxSizerItem* PrependSpacer(int size);
576 wxSizerItem* PrependStretchSpacer(int prop = 1);
8e32ea1c 577
e8cfff87 578 // set (or possibly unset if window is NULL) or get the window this sizer
ce7208d4 579 // is used in
e8cfff87
VZ
580 void SetContainingWindow(wxWindow *window);
581 wxWindow *GetContainingWindow() const { return m_containingWindow; }
749bb9f1 582
6a9e54bd 583#if WXWIN_COMPATIBILITY_2_6
12a3f227
RL
584 // Deprecated in 2.6 since historically it does not delete the window,
585 // use Detach instead.
586 wxDEPRECATED( virtual bool Remove( wxWindow *window ) );
6a9e54bd
WS
587#endif // WXWIN_COMPATIBILITY_2_6
588
f6bcfd97 589 virtual bool Remove( wxSizer *sizer );
e0d8fb45 590 virtual bool Remove( int index );
00976fe5 591
12a3f227 592 virtual bool Detach( wxWindow *window );
00976fe5 593 virtual bool Detach( wxSizer *sizer );
e0d8fb45 594 virtual bool Detach( int index );
00976fe5 595
ce7208d4
WS
596 virtual bool Replace( wxWindow *oldwin, wxWindow *newwin, bool recursive = false );
597 virtual bool Replace( wxSizer *oldsz, wxSizer *newsz, bool recursive = false );
598 virtual bool Replace( size_t index, wxSizerItem *newitem );
eae0338f 599
e0d8fb45 600 virtual void Clear( bool delete_windows = false );
84f7908b 601 virtual void DeleteWindows();
f6bcfd97 602
15f7c305
RR
603 // Inform sizer about the first direction that has been decided (by parent item)
604 // Returns true if it made use of the informtion (and recalculated min size)
605 virtual bool InformFirstDirection( int WXUNUSED(direction), int WXUNUSED(size), int WXUNUSED(availableOtherDir) )
606 { return false; }
2f39b5a3 607
f6bcfd97
BP
608 void SetMinSize( int width, int height )
609 { DoSetMinSize( width, height ); }
fbfb8bcc 610 void SetMinSize( const wxSize& size )
f6bcfd97 611 { DoSetMinSize( size.x, size.y ); }
1e6feb95 612
50c06297 613 // Searches recursively
f6bcfd97
BP
614 bool SetItemMinSize( wxWindow *window, int width, int height )
615 { return DoSetItemMinSize( window, width, height ); }
fbfb8bcc 616 bool SetItemMinSize( wxWindow *window, const wxSize& size )
f6bcfd97 617 { return DoSetItemMinSize( window, size.x, size.y ); }
1e6feb95 618
50c06297 619 // Searches recursively
f6bcfd97
BP
620 bool SetItemMinSize( wxSizer *sizer, int width, int height )
621 { return DoSetItemMinSize( sizer, width, height ); }
fbfb8bcc 622 bool SetItemMinSize( wxSizer *sizer, const wxSize& size )
f6bcfd97 623 { return DoSetItemMinSize( sizer, size.x, size.y ); }
1e6feb95 624
12a3f227
RL
625 bool SetItemMinSize( size_t index, int width, int height )
626 { return DoSetItemMinSize( index, width, height ); }
fbfb8bcc 627 bool SetItemMinSize( size_t index, const wxSize& size )
12a3f227 628 { return DoSetItemMinSize( index, size.x, size.y ); }
1e6feb95 629
9cbee2ce 630 wxSize GetSize() const
f6bcfd97 631 { return m_size; }
9cbee2ce 632 wxPoint GetPosition() const
f6bcfd97 633 { return m_position; }
1e6feb95 634
50c06297 635 // Calculate the minimal size or return m_minSize if bigger.
f6bcfd97
BP
636 wxSize GetMinSize();
637
89064717
VZ
638 // These virtual functions are used by the layout algorithm: first
639 // CalcMin() is called to calculate the minimal size of the sizer and
640 // prepare for laying it out and then RecalcSizes() is called to really
641 // update all the sizer items
f6bcfd97 642 virtual wxSize CalcMin() = 0;
89064717 643 virtual void RecalcSizes() = 0;
f6bcfd97
BP
644
645 virtual void Layout();
646
32013b47
VS
647 wxSize ComputeFittingClientSize(wxWindow *window);
648 wxSize ComputeFittingWindowSize(wxWindow *window);
649
e5251d4f 650 wxSize Fit( wxWindow *window );
566d84a7 651 void FitInside( wxWindow *window );
f6bcfd97 652 void SetSizeHints( wxWindow *window );
f944aec0
VS
653#if WXWIN_COMPATIBILITY_2_8
654 // This only calls FitInside() since 2.9
655 wxDEPRECATED( void SetVirtualSizeHints( wxWindow *window ) );
656#endif
f6bcfd97 657
12a3f227 658 wxSizerItemList& GetChildren()
f6bcfd97 659 { return m_children; }
f9b5691a
VZ
660 const wxSizerItemList& GetChildren() const
661 { return m_children; }
f6bcfd97 662
49dcc246
VZ
663 void SetDimension(const wxPoint& pos, const wxSize& size)
664 {
665 m_position = pos;
666 m_size = size;
667 Layout();
668 }
669 void SetDimension(int x, int y, int width, int height)
670 { SetDimension(wxPoint(x, y), wxSize(width, height)); }
0c0d686f 671
2f39b5a3 672 size_t GetItemCount() const { return m_children.GetCount(); }
6e1f851b 673 bool IsEmpty() const { return m_children.IsEmpty(); }
6b527e15 674
9f13661f
WS
675 wxSizerItem* GetItem( wxWindow *window, bool recursive = false );
676 wxSizerItem* GetItem( wxSizer *sizer, bool recursive = false );
677 wxSizerItem* GetItem( size_t index );
86909f4c 678 wxSizerItem* GetItemById( int id, bool recursive = false );
9f13661f 679
12a3f227 680 // Manage whether individual scene items are considered
2b5f62a0 681 // in the layout calculations or not.
8b2bac62
WS
682 bool Show( wxWindow *window, bool show = true, bool recursive = false );
683 bool Show( wxSizer *sizer, bool show = true, bool recursive = false );
684 bool Show( size_t index, bool show = true );
12a3f227 685
8b2bac62
WS
686 bool Hide( wxSizer *sizer, bool recursive = false )
687 { return Show( sizer, false, recursive ); }
688 bool Hide( wxWindow *window, bool recursive = false )
689 { return Show( window, false, recursive ); }
690 bool Hide( size_t index )
691 { return Show( index, false ); }
2b5f62a0 692
9cbee2ce
RL
693 bool IsShown( wxWindow *window ) const;
694 bool IsShown( wxSizer *sizer ) const;
695 bool IsShown( size_t index ) const;
dc259b79 696
2b5f62a0 697 // Recursively call wxWindow::Show () on all sizer items.
eb2a7883 698 virtual void ShowItems (bool show);
2b5f62a0 699
f303d69f 700 void Show(bool show) { ShowItems(show); }
50c06297 701
f6bcfd97 702protected:
12a3f227
RL
703 wxSize m_size;
704 wxSize m_minSize;
705 wxPoint m_position;
706 wxSizerItemList m_children;
f6bcfd97 707
e8cfff87
VZ
708 // the window this sizer is used in, can be NULL
709 wxWindow *m_containingWindow;
710
9cbee2ce 711 wxSize GetMaxClientSize( wxWindow *window ) const;
566d84a7 712 wxSize GetMinClientSize( wxWindow *window );
566d84a7 713 wxSize VirtualFitSize( wxWindow *window );
65ba4113 714
f6bcfd97
BP
715 virtual void DoSetMinSize( int width, int height );
716 virtual bool DoSetItemMinSize( wxWindow *window, int width, int height );
717 virtual bool DoSetItemMinSize( wxSizer *sizer, int width, int height );
12a3f227 718 virtual bool DoSetItemMinSize( size_t index, int width, int height );
1e6feb95 719
e556b612
VZ
720 // insert a new item into m_children at given index and return the item
721 // itself
722 virtual wxSizerItem* DoInsert(size_t index, wxSizerItem *item);
723
9cbee2ce 724private:
4393b50c 725 DECLARE_CLASS(wxSizer)
f6bcfd97 726};
c62ac5b6 727
f6bcfd97
BP
728//---------------------------------------------------------------------------
729// wxGridSizer
730//---------------------------------------------------------------------------
0c0d686f 731
53a2db12 732class WXDLLIMPEXP_CORE wxGridSizer: public wxSizer
f6bcfd97
BP
733{
734public:
7e6edd27
VZ
735 // ctors specifying the number of columns only: number of rows will be
736 // deduced automatically depending on the number of sizer elements
737 wxGridSizer( int cols, int vgap, int hgap );
738 wxGridSizer( int cols, const wxSize& gap = wxSize(0, 0) );
739
740 // ctors specifying the number of rows and columns
f6bcfd97 741 wxGridSizer( int rows, int cols, int vgap, int hgap );
4a00e77c 742 wxGridSizer( int rows, int cols, const wxSize& gap );
1e6feb95 743
5d76f462
VZ
744 virtual void RecalcSizes();
745 virtual wxSize CalcMin();
f6bcfd97 746
4f671eeb
VZ
747 void SetCols( int cols )
748 {
0be3080a 749 wxASSERT_MSG( cols >= 0, "Number of columns must be non-negative");
4f671eeb
VZ
750 m_cols = cols;
751 }
752
753 void SetRows( int rows )
754 {
0be3080a 755 wxASSERT_MSG( rows >= 0, "Number of rows must be non-negative");
4f671eeb
VZ
756 m_rows = rows;
757 }
758
f6bcfd97
BP
759 void SetVGap( int gap ) { m_vgap = gap; }
760 void SetHGap( int gap ) { m_hgap = gap; }
9cbee2ce
RL
761 int GetCols() const { return m_cols; }
762 int GetRows() const { return m_rows; }
763 int GetVGap() const { return m_vgap; }
764 int GetHGap() const { return m_hgap; }
1e6feb95 765
0274a797
VZ
766 int GetEffectiveColsCount() const { return m_cols ? m_cols : CalcCols(); }
767 int GetEffectiveRowsCount() const { return m_rows ? m_rows : CalcRows(); }
768
afc0db8c
VS
769 // return the number of total items and the number of columns and rows
770 // (for internal use only)
771 int CalcRowsCols(int& rows, int& cols) const;
772
f6bcfd97 773protected:
0274a797
VZ
774 // the number of rows/columns in the sizer, if 0 then it is determined
775 // dynamically depending on the total number of items
f6bcfd97
BP
776 int m_rows;
777 int m_cols;
0274a797
VZ
778
779 // gaps between rows and columns
f6bcfd97
BP
780 int m_vgap;
781 int m_hgap;
1e6feb95 782
e556b612
VZ
783 virtual wxSizerItem *DoInsert(size_t index, wxSizerItem *item);
784
f6bcfd97 785 void SetItemBounds( wxSizerItem *item, int x, int y, int w, int h );
1e6feb95 786
0274a797
VZ
787 // returns the number of columns/rows needed for the current total number
788 // of children (and the fixed number of rows/columns)
789 int CalcCols() const
790 {
791 wxCHECK_MSG
792 (
793 m_rows, 0,
794 "Can't calculate number of cols if number of rows is not specified"
795 );
796
797 return (m_children.GetCount() + m_rows - 1) / m_rows;
798 }
799
800 int CalcRows() const
801 {
802 wxCHECK_MSG
803 (
804 m_cols, 0,
805 "Can't calculate number of cols if number of rows is not specified"
806 );
807
808 return (m_children.GetCount() + m_cols - 1) / m_cols;
809 }
810
9cbee2ce 811private:
4393b50c 812 DECLARE_CLASS(wxGridSizer)
f6bcfd97 813};
5279a24d 814
f6bcfd97
BP
815//---------------------------------------------------------------------------
816// wxFlexGridSizer
817//---------------------------------------------------------------------------
0c0d686f 818
52ceb90e
FM
819// values which define the behaviour for resizing wxFlexGridSizer cells in the
820// "non-flexible" direction
5d76f462
VZ
821enum wxFlexSizerGrowMode
822{
823 // don't resize the cells in non-flexible direction at all
824 wxFLEX_GROWMODE_NONE,
825
826 // uniformly resize only the specified ones (default)
827 wxFLEX_GROWMODE_SPECIFIED,
828
829 // uniformly resize all cells
830 wxFLEX_GROWMODE_ALL
831};
832
53a2db12 833class WXDLLIMPEXP_CORE wxFlexGridSizer: public wxGridSizer
f6bcfd97
BP
834{
835public:
4a00e77c
VZ
836 // ctors specifying the number of columns only: number of rows will be
837 // deduced automatically depending on the number of sizer elements
d7bb2926 838 wxFlexGridSizer( int cols, int vgap, int hgap );
4a00e77c
VZ
839 wxFlexGridSizer( int cols, const wxSize& gap = wxSize(0, 0) );
840
841 // ctors specifying the number of rows and columns
f6bcfd97 842 wxFlexGridSizer( int rows, int cols, int vgap, int hgap );
4a00e77c 843 wxFlexGridSizer( int rows, int cols, const wxSize& gap );
1e6feb95 844
4a00e77c
VZ
845 // dtor
846 virtual ~wxFlexGridSizer();
1e6feb95 847
5d76f462
VZ
848 // set the rows/columns which will grow (the others will remain of the
849 // constant initial size)
e8800dcf 850 void AddGrowableRow( size_t idx, int proportion = 0 );
f6bcfd97 851 void RemoveGrowableRow( size_t idx );
e8800dcf 852 void AddGrowableCol( size_t idx, int proportion = 0 );
f6bcfd97 853 void RemoveGrowableCol( size_t idx );
0c0d686f 854
67ef83eb
VZ
855 bool IsRowGrowable( size_t idx );
856 bool IsColGrowable( size_t idx );
1e6feb95 857
5d76f462
VZ
858 // the sizer cells may grow in both directions, not grow at all or only
859 // grow in one direction but not the other
860
861 // the direction may be wxVERTICAL, wxHORIZONTAL or wxBOTH (default)
862 void SetFlexibleDirection(int direction) { m_flexDirection = direction; }
863 int GetFlexibleDirection() const { return m_flexDirection; }
864
865 // note that the grow mode only applies to the direction which is not
866 // flexible
867 void SetNonFlexibleGrowMode(wxFlexSizerGrowMode mode) { m_growMode = mode; }
868 wxFlexSizerGrowMode GetNonFlexibleGrowMode() const { return m_growMode; }
869
fc1fcd0e
RD
870 // Read-only access to the row heights and col widths arrays
871 const wxArrayInt& GetRowHeights() const { return m_rowHeights; }
872 const wxArrayInt& GetColWidths() const { return m_colWidths; }
8b2bac62 873
5d76f462
VZ
874 // implementation
875 virtual void RecalcSizes();
876 virtual wxSize CalcMin();
877
878protected:
20b35a69 879 void AdjustForFlexDirection();
97800f66 880 void AdjustForGrowables(const wxSize& sz);
15f7c305 881 void FindWidthsAndHeights(int nrows, int ncols);
8b2bac62 882
5d76f462
VZ
883 // the heights/widths of all rows/columns
884 wxArrayInt m_rowHeights,
885 m_colWidths;
886
887 // indices of the growable columns and rows
888 wxArrayInt m_growableRows,
889 m_growableCols;
890
e8800dcf
VZ
891 // proportion values of the corresponding growable rows and columns
892 wxArrayInt m_growableRowsProportions,
893 m_growableColsProportions;
894
5d76f462
VZ
895 // parameters describing whether the growable cells should be resized in
896 // both directions or only one
897 int m_flexDirection;
898 wxFlexSizerGrowMode m_growMode;
1e6feb95 899
ba763a45
RD
900 // saves CalcMin result to optimize RecalcSizes
901 wxSize m_calculatedMinSize;
902
9cbee2ce 903private:
4393b50c 904 DECLARE_CLASS(wxFlexGridSizer)
c0c133e1 905 wxDECLARE_NO_COPY_CLASS(wxFlexGridSizer);
c62ac5b6
RR
906};
907
908//---------------------------------------------------------------------------
92afa2b1 909// wxBoxSizer
c62ac5b6
RR
910//---------------------------------------------------------------------------
911
53a2db12 912class WXDLLIMPEXP_CORE wxBoxSizer: public wxSizer
61d514bb
RR
913{
914public:
89064717
VZ
915 wxBoxSizer(int orient)
916 {
917 m_orient = orient;
2a818b7a 918 m_totalProportion = 0;
89064717
VZ
919
920 wxASSERT_MSG( m_orient == wxHORIZONTAL || m_orient == wxVERTICAL,
9a83f860 921 wxT("invalid value for wxBoxSizer orientation") );
89064717
VZ
922 }
923
1a2df6a7
VZ
924 virtual wxSizerItem *AddSpacer(int size);
925
89064717 926 int GetOrientation() const { return m_orient; }
0c0d686f 927
89064717 928 bool IsVertical() const { return m_orient == wxVERTICAL; }
0c0d686f 929
89064717 930 void SetOrientation(int orient) { m_orient = orient; }
0c0d686f 931
89064717
VZ
932 // implementation of our resizing logic
933 virtual wxSize CalcMin();
934 virtual void RecalcSizes();
b657b4c9 935
61d514bb 936protected:
89064717
VZ
937 // helpers for our code: this returns the component of the given wxSize in
938 // the direction of the sizer and in the other direction, respectively
3d2085a4 939 int GetSizeInMajorDir(const wxSize& sz) const
89064717
VZ
940 {
941 return m_orient == wxHORIZONTAL ? sz.x : sz.y;
942 }
943
944 int& SizeInMajorDir(wxSize& sz)
945 {
946 return m_orient == wxHORIZONTAL ? sz.x : sz.y;
947 }
948
949 int& PosInMajorDir(wxPoint& pt)
950 {
951 return m_orient == wxHORIZONTAL ? pt.x : pt.y;
952 }
953
3d2085a4 954 int GetSizeInMinorDir(const wxSize& sz) const
89064717
VZ
955 {
956 return m_orient == wxHORIZONTAL ? sz.y : sz.x;
957 }
958
959 int& SizeInMinorDir(wxSize& sz)
960 {
961 return m_orient == wxHORIZONTAL ? sz.y : sz.x;
962 }
963
964 int& PosInMinorDir(wxPoint& pt)
965 {
966 return m_orient == wxHORIZONTAL ? pt.y : pt.x;
967 }
968
969 // another helper: creates wxSize from major and minor components
970 wxSize SizeFromMajorMinor(int major, int minor) const
971 {
972 if ( m_orient == wxHORIZONTAL )
973 {
974 return wxSize(major, minor);
975 }
976 else // wxVERTICAL
977 {
978 return wxSize(minor, major);
979 }
980 }
981
982
983 // either wxHORIZONTAL or wxVERTICAL
61d514bb 984 int m_orient;
89064717
VZ
985
986 // the sum of proportion of all of our elements
987 int m_totalProportion;
988
989 // the minimal size needed for this sizer as calculated by the last call to
990 // our CalcMin()
991 wxSize m_minSize;
1e6feb95 992
9cbee2ce 993private:
4393b50c 994 DECLARE_CLASS(wxBoxSizer)
61d514bb 995};
0c0d686f 996
27ea1d8a
RR
997//---------------------------------------------------------------------------
998// wxStaticBoxSizer
999//---------------------------------------------------------------------------
1000
1e6feb95
VZ
1001#if wxUSE_STATBOX
1002
b5dbe15d 1003class WXDLLIMPEXP_FWD_CORE wxStaticBox;
1e6feb95 1004
53a2db12 1005class WXDLLIMPEXP_CORE wxStaticBoxSizer: public wxBoxSizer
27ea1d8a
RR
1006{
1007public:
6c1635b5 1008 wxStaticBoxSizer(wxStaticBox *box, int orient);
450a1593 1009 wxStaticBoxSizer(int orient, wxWindow *win, const wxString& label = wxEmptyString);
649cfca1 1010 virtual ~wxStaticBoxSizer();
0c0d686f 1011
f6bcfd97
BP
1012 void RecalcSizes();
1013 wxSize CalcMin();
0c0d686f 1014
9cbee2ce 1015 wxStaticBox *GetStaticBox() const
f6bcfd97 1016 { return m_staticBox; }
0c0d686f 1017
eb2a7883
VZ
1018 // override to hide/show the static box as well
1019 virtual void ShowItems (bool show);
7e2b7860 1020
e978011a 1021 virtual bool Detach( wxWindow *window );
7e2b7860
VZ
1022 virtual bool Detach( wxSizer *sizer ) { return wxBoxSizer::Detach(sizer); }
1023 virtual bool Detach( int index ) { return wxBoxSizer::Detach(index); }
eb2a7883 1024
27ea1d8a 1025protected:
f6bcfd97 1026 wxStaticBox *m_staticBox;
1e6feb95 1027
9cbee2ce 1028private:
4393b50c 1029 DECLARE_CLASS(wxStaticBoxSizer)
c0c133e1 1030 wxDECLARE_NO_COPY_CLASS(wxStaticBoxSizer);
27ea1d8a
RR
1031};
1032
1e6feb95
VZ
1033#endif // wxUSE_STATBOX
1034
9b494057
FM
1035//---------------------------------------------------------------------------
1036// wxStdDialogButtonSizer
1037//---------------------------------------------------------------------------
1038
974c2a59
WS
1039#if wxUSE_BUTTON
1040
53a2db12 1041class WXDLLIMPEXP_CORE wxStdDialogButtonSizer: public wxBoxSizer
acf2ac37
RR
1042{
1043public:
acf2ac37
RR
1044 // Constructor just creates a new wxBoxSizer, not much else.
1045 // Box sizer orientation is automatically determined here:
1046 // vertical for PDAs, horizontal for everything else?
b181a505 1047 wxStdDialogButtonSizer();
acf2ac37 1048
acf2ac37 1049 // Checks button ID against system IDs and sets one of the pointers below
b181a505
RR
1050 // to this button. Does not do any sizer-related things here.
1051 void AddButton(wxButton *button);
acf2ac37 1052
b181a505
RR
1053 // Use these if no standard ID can/should be used
1054 void SetAffirmativeButton( wxButton *button );
1055 void SetNegativeButton( wxButton *button );
1056 void SetCancelButton( wxButton *button );
acf2ac37 1057
acf2ac37
RR
1058 // All platform-specific code here, checks which buttons exist and add
1059 // them to the sizer accordingly.
1060 // Note - one potential hack on Mac we could use here,
1061 // if m_buttonAffirmative is wxID_SAVE then ensure wxID_SAVE
1062 // is set to _("Save") and m_buttonNegative is set to _("Don't Save")
1063 // I wouldn't add any other hacks like that into here,
1064 // but this one I can see being useful.
718903fe 1065 void Realize();
974c2a59 1066
acf2ac37
RR
1067 wxButton *GetAffirmativeButton() const { return m_buttonAffirmative; }
1068 wxButton *GetApplyButton() const { return m_buttonApply; }
1069 wxButton *GetNegativeButton() const { return m_buttonNegative; }
1070 wxButton *GetCancelButton() const { return m_buttonCancel; }
1071 wxButton *GetHelpButton() const { return m_buttonHelp; }
1072
1073protected:
b181a505 1074 wxButton *m_buttonAffirmative; // wxID_OK, wxID_YES, wxID_SAVE go here
57d7f988 1075 wxButton *m_buttonApply; // wxID_APPLY
b181a505 1076 wxButton *m_buttonNegative; // wxID_NO
57d7f988
VZ
1077 wxButton *m_buttonCancel; // wxID_CANCEL, wxID_CLOSE
1078 wxButton *m_buttonHelp; // wxID_HELP, wxID_CONTEXT_HELP
974c2a59 1079
acf2ac37
RR
1080private:
1081 DECLARE_CLASS(wxStdDialogButtonSizer)
c0c133e1 1082 wxDECLARE_NO_COPY_CLASS(wxStdDialogButtonSizer);
acf2ac37 1083};
adbf2d73 1084
6b5c4761 1085#endif // wxUSE_BUTTON
974c2a59 1086
adbf2d73 1087
8e32ea1c
VZ
1088// ----------------------------------------------------------------------------
1089// inline functions implementation
1090// ----------------------------------------------------------------------------
1091
4dd10327
VZ
1092#if WXWIN_COMPATIBILITY_2_8
1093
1094inline void wxSizerItem::SetWindow(wxWindow *window)
1095{
1096 DoSetWindow(window);
1097}
1098
1099inline void wxSizerItem::SetSizer(wxSizer *sizer)
1100{
1101 DoSetSizer(sizer);
1102}
1103
1104inline void wxSizerItem::SetSpacer(const wxSize& size)
1105{
1106 DoSetSpacer(size);
1107}
1108
1109inline void wxSizerItem::SetSpacer(int width, int height)
2f39b5a3
VZ
1110{
1111 DoSetSpacer(wxSize(width, height));
1112}
4dd10327
VZ
1113
1114#endif // WXWIN_COMPATIBILITY_2_8
1115
54d61068
VZ
1116inline wxSizerItem*
1117wxSizer::Insert(size_t index, wxSizerItem *item)
1118{
1119 return DoInsert(index, item);
1120}
1121
4dd10327 1122
50961a35
PC
1123inline wxSizerItem*
1124wxSizer::Add( wxSizerItem *item )
1125{
1126 return Insert( m_children.GetCount(), item );
1127}
1128
56eee37f 1129inline wxSizerItem*
8e32ea1c
VZ
1130wxSizer::Add( wxWindow *window, int proportion, int flag, int border, wxObject* userData )
1131{
56eee37f 1132 return Add( new wxSizerItem( window, proportion, flag, border, userData ) );
8e32ea1c
VZ
1133}
1134
56eee37f 1135inline wxSizerItem*
8e32ea1c
VZ
1136wxSizer::Add( wxSizer *sizer, int proportion, int flag, int border, wxObject* userData )
1137{
56eee37f 1138 return Add( new wxSizerItem( sizer, proportion, flag, border, userData ) );
8e32ea1c
VZ
1139}
1140
56eee37f 1141inline wxSizerItem*
8e32ea1c
VZ
1142wxSizer::Add( int width, int height, int proportion, int flag, int border, wxObject* userData )
1143{
56eee37f 1144 return Add( new wxSizerItem( width, height, proportion, flag, border, userData ) );
8e32ea1c
VZ
1145}
1146
56eee37f 1147inline wxSizerItem*
5f813ad6
VZ
1148wxSizer::Add( wxWindow *window, const wxSizerFlags& flags )
1149{
56eee37f 1150 return Add( new wxSizerItem(window, flags) );
5f813ad6
VZ
1151}
1152
56eee37f 1153inline wxSizerItem*
5f813ad6
VZ
1154wxSizer::Add( wxSizer *sizer, const wxSizerFlags& flags )
1155{
56eee37f 1156 return Add( new wxSizerItem(sizer, flags) );
5f813ad6
VZ
1157}
1158
b701f995
VZ
1159inline wxSizerItem*
1160wxSizer::Add( int width, int height, const wxSizerFlags& flags )
1161{
1162 return Add( new wxSizerItem(width, height, flags) );
1163}
1164
56eee37f 1165inline wxSizerItem*
8e32ea1c
VZ
1166wxSizer::AddSpacer(int size)
1167{
56eee37f 1168 return Add(size, size);
8e32ea1c
VZ
1169}
1170
56eee37f 1171inline wxSizerItem*
8e32ea1c
VZ
1172wxSizer::AddStretchSpacer(int prop)
1173{
56eee37f 1174 return Add(0, 0, prop);
8e32ea1c
VZ
1175}
1176
50961a35
PC
1177inline wxSizerItem*
1178wxSizer::Prepend( wxSizerItem *item )
1179{
1180 return Insert( 0, item );
1181}
1182
56eee37f 1183inline wxSizerItem*
8e32ea1c
VZ
1184wxSizer::Prepend( wxWindow *window, int proportion, int flag, int border, wxObject* userData )
1185{
56eee37f 1186 return Prepend( new wxSizerItem( window, proportion, flag, border, userData ) );
8e32ea1c
VZ
1187}
1188
56eee37f 1189inline wxSizerItem*
8e32ea1c
VZ
1190wxSizer::Prepend( wxSizer *sizer, int proportion, int flag, int border, wxObject* userData )
1191{
56eee37f 1192 return Prepend( new wxSizerItem( sizer, proportion, flag, border, userData ) );
8e32ea1c
VZ
1193}
1194
56eee37f 1195inline wxSizerItem*
8e32ea1c
VZ
1196wxSizer::Prepend( int width, int height, int proportion, int flag, int border, wxObject* userData )
1197{
56eee37f 1198 return Prepend( new wxSizerItem( width, height, proportion, flag, border, userData ) );
8e32ea1c
VZ
1199}
1200
56eee37f 1201inline wxSizerItem*
8e32ea1c
VZ
1202wxSizer::PrependSpacer(int size)
1203{
56eee37f 1204 return Prepend(size, size);
8e32ea1c
VZ
1205}
1206
56eee37f 1207inline wxSizerItem*
8e32ea1c
VZ
1208wxSizer::PrependStretchSpacer(int prop)
1209{
56eee37f 1210 return Prepend(0, 0, prop);
8e32ea1c
VZ
1211}
1212
56eee37f 1213inline wxSizerItem*
5f813ad6
VZ
1214wxSizer::Prepend( wxWindow *window, const wxSizerFlags& flags )
1215{
56eee37f 1216 return Prepend( new wxSizerItem(window, flags) );
5f813ad6
VZ
1217}
1218
56eee37f 1219inline wxSizerItem*
5f813ad6
VZ
1220wxSizer::Prepend( wxSizer *sizer, const wxSizerFlags& flags )
1221{
56eee37f 1222 return Prepend( new wxSizerItem(sizer, flags) );
5f813ad6
VZ
1223}
1224
b701f995
VZ
1225inline wxSizerItem*
1226wxSizer::Prepend( int width, int height, const wxSizerFlags& flags )
1227{
1228 return Prepend( new wxSizerItem(width, height, flags) );
1229}
1230
56eee37f 1231inline wxSizerItem*
8e32ea1c 1232wxSizer::Insert( size_t index,
5f813ad6
VZ
1233 wxWindow *window,
1234 int proportion,
1235 int flag,
1236 int border,
1237 wxObject* userData )
8e32ea1c 1238{
56eee37f 1239 return Insert( index, new wxSizerItem( window, proportion, flag, border, userData ) );
8e32ea1c
VZ
1240}
1241
56eee37f 1242inline wxSizerItem*
8e32ea1c 1243wxSizer::Insert( size_t index,
5f813ad6
VZ
1244 wxSizer *sizer,
1245 int proportion,
1246 int flag,
1247 int border,
1248 wxObject* userData )
8e32ea1c 1249{
56eee37f 1250 return Insert( index, new wxSizerItem( sizer, proportion, flag, border, userData ) );
8e32ea1c
VZ
1251}
1252
56eee37f 1253inline wxSizerItem*
8e32ea1c 1254wxSizer::Insert( size_t index,
5f813ad6
VZ
1255 int width,
1256 int height,
1257 int proportion,
1258 int flag,
1259 int border,
1260 wxObject* userData )
8e32ea1c 1261{
56eee37f 1262 return Insert( index, new wxSizerItem( width, height, proportion, flag, border, userData ) );
8e32ea1c
VZ
1263}
1264
56eee37f 1265inline wxSizerItem*
5f813ad6
VZ
1266wxSizer::Insert( size_t index, wxWindow *window, const wxSizerFlags& flags )
1267{
56eee37f 1268 return Insert( index, new wxSizerItem(window, flags) );
5f813ad6
VZ
1269}
1270
56eee37f 1271inline wxSizerItem*
5f813ad6
VZ
1272wxSizer::Insert( size_t index, wxSizer *sizer, const wxSizerFlags& flags )
1273{
56eee37f 1274 return Insert( index, new wxSizerItem(sizer, flags) );
5f813ad6
VZ
1275}
1276
b701f995
VZ
1277inline wxSizerItem*
1278wxSizer::Insert( size_t index, int width, int height, const wxSizerFlags& flags )
1279{
1280 return Insert( index, new wxSizerItem(width, height, flags) );
1281}
1282
56eee37f 1283inline wxSizerItem*
8e32ea1c
VZ
1284wxSizer::InsertSpacer(size_t index, int size)
1285{
56eee37f 1286 return Insert(index, size, size);
8e32ea1c
VZ
1287}
1288
56eee37f 1289inline wxSizerItem*
8e32ea1c
VZ
1290wxSizer::InsertStretchSpacer(size_t index, int prop)
1291{
56eee37f 1292 return Insert(index, 0, 0, prop);
8e32ea1c
VZ
1293}
1294
ade4eb65 1295#endif // __WXSIZER_H__