]> git.saurik.com Git - wxWidgets.git/blame - include/wx/sizer.h
Use wmain() if supported by the compiler/CRT instead of main().
[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 253 wxSizerItem( wxWindow *window,
5eb16fe2
RD
254 int proportion=0,
255 int flag=0,
256 int border=0,
257 wxObject* userData=NULL );
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 268 wxSizerItem( wxSizer *sizer,
5eb16fe2
RD
269 int proportion=0,
270 int flag=0,
271 int border=0,
272 wxObject* userData=NULL );
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,
5eb16fe2
RD
285 int proportion=0,
286 int flag=0,
287 int border=0,
288 wxObject* userData=NULL);
5f813ad6 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
93b87dd9
VZ
314 wxSize GetMaxSize() const
315 { return IsWindow() ? m_window->GetMaxSize() : wxDefaultSize; }
316 wxSize GetMaxSizeWithBorder() const;
317
1eba2193 318 void SetMinSize(const wxSize& size)
50c06297
VZ
319 {
320 if ( IsWindow() )
321 m_window->SetMinSize(size);
322 m_minSize = size;
323 }
1eba2193 324 void SetMinSize( int x, int y )
8b2bac62 325 { SetMinSize(wxSize(x, y)); }
12a3f227 326 void SetInitSize( int x, int y )
1eba2193 327 { SetMinSize(wxSize(x, y)); }
df5ddbca 328
50c06297
VZ
329 // if either of dimensions is zero, ratio is assumed to be 1
330 // to avoid "divide by zero" errors
331 void SetRatio(int width, int height)
df5ddbca 332 { m_ratio = (width && height) ? ((float) width / (float) height) : 1; }
50c06297
VZ
333 void SetRatio(const wxSize& size)
334 { SetRatio(size.x, size.y); }
335 void SetRatio(float ratio)
df5ddbca 336 { m_ratio = ratio; }
2aab8f16 337 float GetRatio() const
df5ddbca
RR
338 { return m_ratio; }
339
50c06297 340 virtual wxRect GetRect() { return m_rect; }
56eee37f 341
86909f4c
VZ
342 // set a sizer item id (different from a window id, all sizer items,
343 // including spacers, can have an associated id)
344 void SetId(int id) { m_id = id; }
345 int GetId() const { return m_id; }
346
50c06297
VZ
347 bool IsWindow() const { return m_kind == Item_Window; }
348 bool IsSizer() const { return m_kind == Item_Sizer; }
349 bool IsSpacer() const { return m_kind == Item_Spacer; }
2aab8f16 350
6a9e54bd 351#if WXWIN_COMPATIBILITY_2_6
12a3f227
RL
352 // Deprecated in 2.6, use {G,S}etProportion instead.
353 wxDEPRECATED( void SetOption( int option ) );
354 wxDEPRECATED( int GetOption() const );
6a9e54bd 355#endif // WXWIN_COMPATIBILITY_2_6
12a3f227
RL
356
357 void SetProportion( int proportion )
358 { m_proportion = proportion; }
359 int GetProportion() const
360 { return m_proportion; }
df5ddbca
RR
361 void SetFlag( int flag )
362 { m_flag = flag; }
12a3f227
RL
363 int GetFlag() const
364 { return m_flag; }
df5ddbca
RR
365 void SetBorder( int border )
366 { m_border = border; }
12a3f227
RL
367 int GetBorder() const
368 { return m_border; }
df5ddbca
RR
369
370 wxWindow *GetWindow() const
50c06297 371 { return m_kind == Item_Window ? m_window : NULL; }
df5ddbca 372 wxSizer *GetSizer() const
50c06297
VZ
373 { return m_kind == Item_Sizer ? m_sizer : NULL; }
374 wxSize GetSpacer() const;
12a3f227 375
0ba6faae 376 // This function behaves obviously for the windows and spacers but for the
c86fd3a7 377 // sizers it returns true if any sizer element is shown and only returns
0ba6faae
VS
378 // false if all of them are hidden. Also, it always returns true if
379 // wxRESERVE_SPACE_EVEN_IF_HIDDEN flag was used.
c86fd3a7 380 bool IsShown() const;
0ba6faae 381
50c06297 382 void Show(bool show);
12a3f227 383
e8c1be04 384 void SetUserData(wxObject* userData)
1737dac2 385 { delete m_userData; m_userData = userData; }
9cbee2ce 386 wxObject* GetUserData() const
df5ddbca 387 { return m_userData; }
9cbee2ce 388 wxPoint GetPosition() const
df5ddbca 389 { return m_pos; }
0c0d686f 390
2f39b5a3
VZ
391 // Called once the first component of an item has been decided. This is
392 // used in algorithms that depend on knowing the size in one direction
393 // before the min size in the other direction can be known.
15f7c305
RR
394 // Returns true if it made use of the information (and min size was changed).
395 bool InformFirstDirection( int direction, int size, int availableOtherDir=-1 );
396
4dd10327
VZ
397 // these functions delete the current contents of the item if it's a sizer
398 // or a spacer but not if it is a window
399 void AssignWindow(wxWindow *window)
400 {
401 Free();
402 DoSetWindow(window);
403 }
404
405 void AssignSizer(wxSizer *sizer)
406 {
407 Free();
408 DoSetSizer(sizer);
409 }
410
411 void AssignSpacer(const wxSize& size)
412 {
413 Free();
414 DoSetSpacer(size);
415 }
416
417 void AssignSpacer(int w, int h) { AssignSpacer(wxSize(w, h)); }
50c06297 418
4dd10327
VZ
419#if WXWIN_COMPATIBILITY_2_8
420 // these functions do not free the old sizer/spacer and so can easily
421 // provoke the memory leaks and so shouldn't be used, use Assign() instead
422 wxDEPRECATED( void SetWindow(wxWindow *window) );
423 wxDEPRECATED( void SetSizer(wxSizer *sizer) );
424 wxDEPRECATED( void SetSpacer(const wxSize& size) );
425 wxDEPRECATED( void SetSpacer(int width, int height) );
426#endif // WXWIN_COMPATIBILITY_2_8
50c06297 427
c62ac5b6 428protected:
5f813ad6 429 // common part of several ctors
4dd10327 430 void Init() { m_userData = NULL; m_kind = Item_None; }
5f813ad6
VZ
431
432 // common part of ctors taking wxSizerFlags
433 void Init(const wxSizerFlags& flags);
434
4dd10327
VZ
435 // free current contents
436 void Free();
437
438 // common parts of Set/AssignXXX()
439 void DoSetWindow(wxWindow *window);
440 void DoSetSizer(wxSizer *sizer);
441 void DoSetSpacer(const wxSize& size);
f303d69f 442
465de0be
VZ
443 // Add the border specified for this item to the given size
444 // if it's != wxDefaultSize, just return wxDefaultSize otherwise.
445 wxSize AddBorderToSize(const wxSize& size) const;
446
f303d69f 447 // discriminated union: depending on m_kind one of the fields is valid
50c06297
VZ
448 enum
449 {
450 Item_None,
451 Item_Window,
452 Item_Sizer,
453 Item_Spacer,
454 Item_Max
455 } m_kind;
456 union
457 {
458 wxWindow *m_window;
459 wxSizer *m_sizer;
460 wxSizerSpacer *m_spacer;
461 };
5f813ad6 462
df5ddbca
RR
463 wxPoint m_pos;
464 wxSize m_minSize;
12a3f227 465 int m_proportion;
df5ddbca
RR
466 int m_border;
467 int m_flag;
86909f4c 468 int m_id;
2b5f62a0 469
50c06297
VZ
470 // on screen rectangle of this item (not including borders)
471 wxRect m_rect;
12a3f227
RL
472
473 // Aspect ratio can always be calculated from m_size,
474 // but this would cause precision loss when the window
475 // is shrunk. It is safer to preserve the initial value.
df5ddbca 476 float m_ratio;
2b5f62a0 477
df5ddbca 478 wxObject *m_userData;
2aab8f16 479
9cbee2ce 480private:
4393b50c 481 DECLARE_CLASS(wxSizerItem)
c0c133e1 482 wxDECLARE_NO_COPY_CLASS(wxSizerItem);
c62ac5b6 483};
5279a24d 484
12a3f227
RL
485WX_DECLARE_EXPORTED_LIST( wxSizerItem, wxSizerItemList );
486
5f813ad6 487
5279a24d 488//---------------------------------------------------------------------------
3417c2cd 489// wxSizer
5279a24d
RR
490//---------------------------------------------------------------------------
491
53a2db12 492class WXDLLIMPEXP_CORE wxSizer: public wxObject, public wxClientDataContainer
5279a24d
RR
493{
494public:
e8cfff87 495 wxSizer() { m_containingWindow = NULL; }
d3c7fc99 496 virtual ~wxSizer();
f6bcfd97 497
436ae7cf
VZ
498 // methods for adding elements to the sizer: there are Add/Insert/Prepend
499 // overloads for each of window/sizer/spacer/wxSizerItem
ca8d899f
VZ
500 wxSizerItem* Add(wxWindow *window,
501 int proportion = 0,
502 int flag = 0,
503 int border = 0,
504 wxObject* userData = NULL);
505 wxSizerItem* Add(wxSizer *sizer,
506 int proportion = 0,
507 int flag = 0,
508 int border = 0,
509 wxObject* userData = NULL);
510 wxSizerItem* Add(int width,
511 int height,
512 int proportion = 0,
513 int flag = 0,
514 int border = 0,
515 wxObject* userData = NULL);
516 wxSizerItem* Add( wxWindow *window, const wxSizerFlags& flags);
517 wxSizerItem* Add( wxSizer *sizer, const wxSizerFlags& flags);
b701f995 518 wxSizerItem* Add( int width, int height, const wxSizerFlags& flags);
ca8d899f
VZ
519 wxSizerItem* Add( wxSizerItem *item);
520
1a2df6a7 521 virtual wxSizerItem *AddSpacer(int size);
ca8d899f
VZ
522 wxSizerItem* AddStretchSpacer(int prop = 1);
523
524 wxSizerItem* Insert(size_t index,
525 wxWindow *window,
526 int proportion = 0,
527 int flag = 0,
528 int border = 0,
529 wxObject* userData = NULL);
530 wxSizerItem* Insert(size_t index,
531 wxSizer *sizer,
532 int proportion = 0,
533 int flag = 0,
534 int border = 0,
535 wxObject* userData = NULL);
536 wxSizerItem* Insert(size_t index,
537 int width,
538 int height,
539 int proportion = 0,
540 int flag = 0,
541 int border = 0,
542 wxObject* userData = NULL);
543 wxSizerItem* Insert(size_t index,
544 wxWindow *window,
545 const wxSizerFlags& flags);
546 wxSizerItem* Insert(size_t index,
547 wxSizer *sizer,
548 const wxSizerFlags& flags);
b701f995
VZ
549 wxSizerItem* Insert(size_t index,
550 int width,
551 int height,
2f39b5a3 552 const wxSizerFlags& flags);
e556b612
VZ
553
554 // NB: do _not_ override this function in the derived classes, this one is
555 // virtual for compatibility reasons only to allow old code overriding
556 // it to continue to work, override DoInsert() instead in the new code
557 virtual wxSizerItem* Insert(size_t index, wxSizerItem *item);
ca8d899f
VZ
558
559 wxSizerItem* InsertSpacer(size_t index, int size);
560 wxSizerItem* InsertStretchSpacer(size_t index, int prop = 1);
561
562 wxSizerItem* Prepend(wxWindow *window,
563 int proportion = 0,
564 int flag = 0,
565 int border = 0,
566 wxObject* userData = NULL);
567 wxSizerItem* Prepend(wxSizer *sizer,
568 int proportion = 0,
569 int flag = 0,
570 int border = 0,
571 wxObject* userData = NULL);
572 wxSizerItem* Prepend(int width,
573 int height,
574 int proportion = 0,
575 int flag = 0,
576 int border = 0,
577 wxObject* userData = NULL);
578 wxSizerItem* Prepend(wxWindow *window, const wxSizerFlags& flags);
579 wxSizerItem* Prepend(wxSizer *sizer, const wxSizerFlags& flags);
b701f995 580 wxSizerItem* Prepend(int width, int height, const wxSizerFlags& flags);
ca8d899f
VZ
581 wxSizerItem* Prepend(wxSizerItem *item);
582
583 wxSizerItem* PrependSpacer(int size);
584 wxSizerItem* PrependStretchSpacer(int prop = 1);
8e32ea1c 585
e8cfff87 586 // set (or possibly unset if window is NULL) or get the window this sizer
ce7208d4 587 // is used in
e8cfff87
VZ
588 void SetContainingWindow(wxWindow *window);
589 wxWindow *GetContainingWindow() const { return m_containingWindow; }
749bb9f1 590
6a9e54bd 591#if WXWIN_COMPATIBILITY_2_6
12a3f227
RL
592 // Deprecated in 2.6 since historically it does not delete the window,
593 // use Detach instead.
594 wxDEPRECATED( virtual bool Remove( wxWindow *window ) );
6a9e54bd
WS
595#endif // WXWIN_COMPATIBILITY_2_6
596
f6bcfd97 597 virtual bool Remove( wxSizer *sizer );
e0d8fb45 598 virtual bool Remove( int index );
00976fe5 599
12a3f227 600 virtual bool Detach( wxWindow *window );
00976fe5 601 virtual bool Detach( wxSizer *sizer );
e0d8fb45 602 virtual bool Detach( int index );
00976fe5 603
ce7208d4
WS
604 virtual bool Replace( wxWindow *oldwin, wxWindow *newwin, bool recursive = false );
605 virtual bool Replace( wxSizer *oldsz, wxSizer *newsz, bool recursive = false );
606 virtual bool Replace( size_t index, wxSizerItem *newitem );
eae0338f 607
e0d8fb45 608 virtual void Clear( bool delete_windows = false );
84f7908b 609 virtual void DeleteWindows();
f6bcfd97 610
15f7c305 611 // Inform sizer about the first direction that has been decided (by parent item)
1582a1db 612 // Returns true if it made use of the information (and recalculated min size)
15f7c305
RR
613 virtual bool InformFirstDirection( int WXUNUSED(direction), int WXUNUSED(size), int WXUNUSED(availableOtherDir) )
614 { return false; }
2f39b5a3 615
f6bcfd97
BP
616 void SetMinSize( int width, int height )
617 { DoSetMinSize( width, height ); }
fbfb8bcc 618 void SetMinSize( const wxSize& size )
f6bcfd97 619 { DoSetMinSize( size.x, size.y ); }
1e6feb95 620
50c06297 621 // Searches recursively
f6bcfd97
BP
622 bool SetItemMinSize( wxWindow *window, int width, int height )
623 { return DoSetItemMinSize( window, width, height ); }
fbfb8bcc 624 bool SetItemMinSize( wxWindow *window, const wxSize& size )
f6bcfd97 625 { return DoSetItemMinSize( window, size.x, size.y ); }
1e6feb95 626
50c06297 627 // Searches recursively
f6bcfd97
BP
628 bool SetItemMinSize( wxSizer *sizer, int width, int height )
629 { return DoSetItemMinSize( sizer, width, height ); }
fbfb8bcc 630 bool SetItemMinSize( wxSizer *sizer, const wxSize& size )
f6bcfd97 631 { return DoSetItemMinSize( sizer, size.x, size.y ); }
1e6feb95 632
12a3f227
RL
633 bool SetItemMinSize( size_t index, int width, int height )
634 { return DoSetItemMinSize( index, width, height ); }
fbfb8bcc 635 bool SetItemMinSize( size_t index, const wxSize& size )
12a3f227 636 { return DoSetItemMinSize( index, size.x, size.y ); }
1e6feb95 637
9cbee2ce 638 wxSize GetSize() const
f6bcfd97 639 { return m_size; }
9cbee2ce 640 wxPoint GetPosition() const
f6bcfd97 641 { return m_position; }
1e6feb95 642
50c06297 643 // Calculate the minimal size or return m_minSize if bigger.
f6bcfd97
BP
644 wxSize GetMinSize();
645
89064717
VZ
646 // These virtual functions are used by the layout algorithm: first
647 // CalcMin() is called to calculate the minimal size of the sizer and
648 // prepare for laying it out and then RecalcSizes() is called to really
649 // update all the sizer items
f6bcfd97 650 virtual wxSize CalcMin() = 0;
89064717 651 virtual void RecalcSizes() = 0;
f6bcfd97
BP
652
653 virtual void Layout();
654
32013b47
VS
655 wxSize ComputeFittingClientSize(wxWindow *window);
656 wxSize ComputeFittingWindowSize(wxWindow *window);
657
e5251d4f 658 wxSize Fit( wxWindow *window );
566d84a7 659 void FitInside( wxWindow *window );
f6bcfd97 660 void SetSizeHints( wxWindow *window );
f944aec0
VS
661#if WXWIN_COMPATIBILITY_2_8
662 // This only calls FitInside() since 2.9
663 wxDEPRECATED( void SetVirtualSizeHints( wxWindow *window ) );
664#endif
f6bcfd97 665
12a3f227 666 wxSizerItemList& GetChildren()
f6bcfd97 667 { return m_children; }
f9b5691a
VZ
668 const wxSizerItemList& GetChildren() const
669 { return m_children; }
f6bcfd97 670
49dcc246
VZ
671 void SetDimension(const wxPoint& pos, const wxSize& size)
672 {
673 m_position = pos;
674 m_size = size;
675 Layout();
e4c903b2
VZ
676
677 // This call is required for wxWrapSizer to be able to calculate its
678 // minimal size correctly.
679 InformFirstDirection(wxHORIZONTAL, size.x, size.y);
49dcc246
VZ
680 }
681 void SetDimension(int x, int y, int width, int height)
682 { SetDimension(wxPoint(x, y), wxSize(width, height)); }
0c0d686f 683
2f39b5a3 684 size_t GetItemCount() const { return m_children.GetCount(); }
6e1f851b 685 bool IsEmpty() const { return m_children.IsEmpty(); }
6b527e15 686
9f13661f
WS
687 wxSizerItem* GetItem( wxWindow *window, bool recursive = false );
688 wxSizerItem* GetItem( wxSizer *sizer, bool recursive = false );
689 wxSizerItem* GetItem( size_t index );
86909f4c 690 wxSizerItem* GetItemById( int id, bool recursive = false );
9f13661f 691
12a3f227 692 // Manage whether individual scene items are considered
2b5f62a0 693 // in the layout calculations or not.
8b2bac62
WS
694 bool Show( wxWindow *window, bool show = true, bool recursive = false );
695 bool Show( wxSizer *sizer, bool show = true, bool recursive = false );
696 bool Show( size_t index, bool show = true );
12a3f227 697
8b2bac62
WS
698 bool Hide( wxSizer *sizer, bool recursive = false )
699 { return Show( sizer, false, recursive ); }
700 bool Hide( wxWindow *window, bool recursive = false )
701 { return Show( window, false, recursive ); }
702 bool Hide( size_t index )
703 { return Show( index, false ); }
2b5f62a0 704
9cbee2ce
RL
705 bool IsShown( wxWindow *window ) const;
706 bool IsShown( wxSizer *sizer ) const;
707 bool IsShown( size_t index ) const;
dc259b79 708
2b5f62a0 709 // Recursively call wxWindow::Show () on all sizer items.
eb2a7883 710 virtual void ShowItems (bool show);
2b5f62a0 711
f303d69f 712 void Show(bool show) { ShowItems(show); }
50c06297 713
f6bcfd97 714protected:
12a3f227
RL
715 wxSize m_size;
716 wxSize m_minSize;
717 wxPoint m_position;
718 wxSizerItemList m_children;
f6bcfd97 719
e8cfff87
VZ
720 // the window this sizer is used in, can be NULL
721 wxWindow *m_containingWindow;
722
9cbee2ce 723 wxSize GetMaxClientSize( wxWindow *window ) const;
566d84a7 724 wxSize GetMinClientSize( wxWindow *window );
566d84a7 725 wxSize VirtualFitSize( wxWindow *window );
65ba4113 726
f6bcfd97
BP
727 virtual void DoSetMinSize( int width, int height );
728 virtual bool DoSetItemMinSize( wxWindow *window, int width, int height );
729 virtual bool DoSetItemMinSize( wxSizer *sizer, int width, int height );
12a3f227 730 virtual bool DoSetItemMinSize( size_t index, int width, int height );
1e6feb95 731
e556b612
VZ
732 // insert a new item into m_children at given index and return the item
733 // itself
734 virtual wxSizerItem* DoInsert(size_t index, wxSizerItem *item);
735
9cbee2ce 736private:
4393b50c 737 DECLARE_CLASS(wxSizer)
f6bcfd97 738};
c62ac5b6 739
f6bcfd97
BP
740//---------------------------------------------------------------------------
741// wxGridSizer
742//---------------------------------------------------------------------------
0c0d686f 743
53a2db12 744class WXDLLIMPEXP_CORE wxGridSizer: public wxSizer
f6bcfd97
BP
745{
746public:
7e6edd27
VZ
747 // ctors specifying the number of columns only: number of rows will be
748 // deduced automatically depending on the number of sizer elements
749 wxGridSizer( int cols, int vgap, int hgap );
750 wxGridSizer( int cols, const wxSize& gap = wxSize(0, 0) );
751
752 // ctors specifying the number of rows and columns
f6bcfd97 753 wxGridSizer( int rows, int cols, int vgap, int hgap );
4a00e77c 754 wxGridSizer( int rows, int cols, const wxSize& gap );
1e6feb95 755
5d76f462
VZ
756 virtual void RecalcSizes();
757 virtual wxSize CalcMin();
f6bcfd97 758
4f671eeb
VZ
759 void SetCols( int cols )
760 {
0be3080a 761 wxASSERT_MSG( cols >= 0, "Number of columns must be non-negative");
4f671eeb
VZ
762 m_cols = cols;
763 }
764
765 void SetRows( int rows )
766 {
0be3080a 767 wxASSERT_MSG( rows >= 0, "Number of rows must be non-negative");
4f671eeb
VZ
768 m_rows = rows;
769 }
770
f6bcfd97
BP
771 void SetVGap( int gap ) { m_vgap = gap; }
772 void SetHGap( int gap ) { m_hgap = gap; }
9cbee2ce
RL
773 int GetCols() const { return m_cols; }
774 int GetRows() const { return m_rows; }
775 int GetVGap() const { return m_vgap; }
776 int GetHGap() const { return m_hgap; }
1e6feb95 777
0274a797
VZ
778 int GetEffectiveColsCount() const { return m_cols ? m_cols : CalcCols(); }
779 int GetEffectiveRowsCount() const { return m_rows ? m_rows : CalcRows(); }
780
afc0db8c
VS
781 // return the number of total items and the number of columns and rows
782 // (for internal use only)
783 int CalcRowsCols(int& rows, int& cols) const;
784
f6bcfd97 785protected:
0274a797
VZ
786 // the number of rows/columns in the sizer, if 0 then it is determined
787 // dynamically depending on the total number of items
f6bcfd97
BP
788 int m_rows;
789 int m_cols;
0274a797
VZ
790
791 // gaps between rows and columns
f6bcfd97
BP
792 int m_vgap;
793 int m_hgap;
1e6feb95 794
e556b612
VZ
795 virtual wxSizerItem *DoInsert(size_t index, wxSizerItem *item);
796
f6bcfd97 797 void SetItemBounds( wxSizerItem *item, int x, int y, int w, int h );
1e6feb95 798
0274a797
VZ
799 // returns the number of columns/rows needed for the current total number
800 // of children (and the fixed number of rows/columns)
801 int CalcCols() const
802 {
803 wxCHECK_MSG
804 (
805 m_rows, 0,
806 "Can't calculate number of cols if number of rows is not specified"
807 );
808
809 return (m_children.GetCount() + m_rows - 1) / m_rows;
810 }
811
812 int CalcRows() const
813 {
814 wxCHECK_MSG
815 (
816 m_cols, 0,
817 "Can't calculate number of cols if number of rows is not specified"
818 );
819
820 return (m_children.GetCount() + m_cols - 1) / m_cols;
821 }
822
9cbee2ce 823private:
4393b50c 824 DECLARE_CLASS(wxGridSizer)
f6bcfd97 825};
5279a24d 826
f6bcfd97
BP
827//---------------------------------------------------------------------------
828// wxFlexGridSizer
829//---------------------------------------------------------------------------
0c0d686f 830
52ceb90e
FM
831// values which define the behaviour for resizing wxFlexGridSizer cells in the
832// "non-flexible" direction
5d76f462
VZ
833enum wxFlexSizerGrowMode
834{
835 // don't resize the cells in non-flexible direction at all
836 wxFLEX_GROWMODE_NONE,
837
838 // uniformly resize only the specified ones (default)
839 wxFLEX_GROWMODE_SPECIFIED,
840
841 // uniformly resize all cells
842 wxFLEX_GROWMODE_ALL
843};
844
53a2db12 845class WXDLLIMPEXP_CORE wxFlexGridSizer: public wxGridSizer
f6bcfd97
BP
846{
847public:
4a00e77c
VZ
848 // ctors specifying the number of columns only: number of rows will be
849 // deduced automatically depending on the number of sizer elements
d7bb2926 850 wxFlexGridSizer( int cols, int vgap, int hgap );
4a00e77c
VZ
851 wxFlexGridSizer( int cols, const wxSize& gap = wxSize(0, 0) );
852
853 // ctors specifying the number of rows and columns
f6bcfd97 854 wxFlexGridSizer( int rows, int cols, int vgap, int hgap );
4a00e77c 855 wxFlexGridSizer( int rows, int cols, const wxSize& gap );
1e6feb95 856
4a00e77c
VZ
857 // dtor
858 virtual ~wxFlexGridSizer();
1e6feb95 859
5d76f462
VZ
860 // set the rows/columns which will grow (the others will remain of the
861 // constant initial size)
e8800dcf 862 void AddGrowableRow( size_t idx, int proportion = 0 );
f6bcfd97 863 void RemoveGrowableRow( size_t idx );
e8800dcf 864 void AddGrowableCol( size_t idx, int proportion = 0 );
f6bcfd97 865 void RemoveGrowableCol( size_t idx );
0c0d686f 866
67ef83eb
VZ
867 bool IsRowGrowable( size_t idx );
868 bool IsColGrowable( size_t idx );
1e6feb95 869
5d76f462
VZ
870 // the sizer cells may grow in both directions, not grow at all or only
871 // grow in one direction but not the other
872
873 // the direction may be wxVERTICAL, wxHORIZONTAL or wxBOTH (default)
874 void SetFlexibleDirection(int direction) { m_flexDirection = direction; }
875 int GetFlexibleDirection() const { return m_flexDirection; }
876
877 // note that the grow mode only applies to the direction which is not
878 // flexible
879 void SetNonFlexibleGrowMode(wxFlexSizerGrowMode mode) { m_growMode = mode; }
880 wxFlexSizerGrowMode GetNonFlexibleGrowMode() const { return m_growMode; }
881
fc1fcd0e
RD
882 // Read-only access to the row heights and col widths arrays
883 const wxArrayInt& GetRowHeights() const { return m_rowHeights; }
884 const wxArrayInt& GetColWidths() const { return m_colWidths; }
8b2bac62 885
5d76f462
VZ
886 // implementation
887 virtual void RecalcSizes();
888 virtual wxSize CalcMin();
889
890protected:
20b35a69 891 void AdjustForFlexDirection();
97800f66 892 void AdjustForGrowables(const wxSize& sz);
15f7c305 893 void FindWidthsAndHeights(int nrows, int ncols);
8b2bac62 894
5d76f462
VZ
895 // the heights/widths of all rows/columns
896 wxArrayInt m_rowHeights,
897 m_colWidths;
898
899 // indices of the growable columns and rows
900 wxArrayInt m_growableRows,
901 m_growableCols;
902
e8800dcf
VZ
903 // proportion values of the corresponding growable rows and columns
904 wxArrayInt m_growableRowsProportions,
905 m_growableColsProportions;
906
5d76f462
VZ
907 // parameters describing whether the growable cells should be resized in
908 // both directions or only one
909 int m_flexDirection;
910 wxFlexSizerGrowMode m_growMode;
1e6feb95 911
ba763a45
RD
912 // saves CalcMin result to optimize RecalcSizes
913 wxSize m_calculatedMinSize;
914
9cbee2ce 915private:
4393b50c 916 DECLARE_CLASS(wxFlexGridSizer)
c0c133e1 917 wxDECLARE_NO_COPY_CLASS(wxFlexGridSizer);
c62ac5b6
RR
918};
919
920//---------------------------------------------------------------------------
92afa2b1 921// wxBoxSizer
c62ac5b6
RR
922//---------------------------------------------------------------------------
923
53a2db12 924class WXDLLIMPEXP_CORE wxBoxSizer: public wxSizer
61d514bb
RR
925{
926public:
89064717
VZ
927 wxBoxSizer(int orient)
928 {
929 m_orient = orient;
2a818b7a 930 m_totalProportion = 0;
89064717
VZ
931
932 wxASSERT_MSG( m_orient == wxHORIZONTAL || m_orient == wxVERTICAL,
9a83f860 933 wxT("invalid value for wxBoxSizer orientation") );
89064717
VZ
934 }
935
1a2df6a7
VZ
936 virtual wxSizerItem *AddSpacer(int size);
937
89064717 938 int GetOrientation() const { return m_orient; }
0c0d686f 939
89064717 940 bool IsVertical() const { return m_orient == wxVERTICAL; }
0c0d686f 941
89064717 942 void SetOrientation(int orient) { m_orient = orient; }
0c0d686f 943
89064717
VZ
944 // implementation of our resizing logic
945 virtual wxSize CalcMin();
946 virtual void RecalcSizes();
b657b4c9 947
61d514bb 948protected:
89064717
VZ
949 // helpers for our code: this returns the component of the given wxSize in
950 // the direction of the sizer and in the other direction, respectively
3d2085a4 951 int GetSizeInMajorDir(const wxSize& sz) const
89064717
VZ
952 {
953 return m_orient == wxHORIZONTAL ? sz.x : sz.y;
954 }
955
956 int& SizeInMajorDir(wxSize& sz)
957 {
958 return m_orient == wxHORIZONTAL ? sz.x : sz.y;
959 }
960
961 int& PosInMajorDir(wxPoint& pt)
962 {
963 return m_orient == wxHORIZONTAL ? pt.x : pt.y;
964 }
965
3d2085a4 966 int GetSizeInMinorDir(const wxSize& sz) const
89064717
VZ
967 {
968 return m_orient == wxHORIZONTAL ? sz.y : sz.x;
969 }
970
971 int& SizeInMinorDir(wxSize& sz)
972 {
973 return m_orient == wxHORIZONTAL ? sz.y : sz.x;
974 }
975
976 int& PosInMinorDir(wxPoint& pt)
977 {
978 return m_orient == wxHORIZONTAL ? pt.y : pt.x;
979 }
980
981 // another helper: creates wxSize from major and minor components
982 wxSize SizeFromMajorMinor(int major, int minor) const
983 {
984 if ( m_orient == wxHORIZONTAL )
985 {
986 return wxSize(major, minor);
987 }
988 else // wxVERTICAL
989 {
990 return wxSize(minor, major);
991 }
992 }
993
994
995 // either wxHORIZONTAL or wxVERTICAL
61d514bb 996 int m_orient;
89064717
VZ
997
998 // the sum of proportion of all of our elements
999 int m_totalProportion;
1000
1001 // the minimal size needed for this sizer as calculated by the last call to
1002 // our CalcMin()
1003 wxSize m_minSize;
1e6feb95 1004
9cbee2ce 1005private:
4393b50c 1006 DECLARE_CLASS(wxBoxSizer)
61d514bb 1007};
0c0d686f 1008
27ea1d8a
RR
1009//---------------------------------------------------------------------------
1010// wxStaticBoxSizer
1011//---------------------------------------------------------------------------
1012
1e6feb95
VZ
1013#if wxUSE_STATBOX
1014
b5dbe15d 1015class WXDLLIMPEXP_FWD_CORE wxStaticBox;
1e6feb95 1016
53a2db12 1017class WXDLLIMPEXP_CORE wxStaticBoxSizer: public wxBoxSizer
27ea1d8a
RR
1018{
1019public:
6c1635b5 1020 wxStaticBoxSizer(wxStaticBox *box, int orient);
450a1593 1021 wxStaticBoxSizer(int orient, wxWindow *win, const wxString& label = wxEmptyString);
649cfca1 1022 virtual ~wxStaticBoxSizer();
0c0d686f 1023
f6bcfd97
BP
1024 void RecalcSizes();
1025 wxSize CalcMin();
0c0d686f 1026
9cbee2ce 1027 wxStaticBox *GetStaticBox() const
f6bcfd97 1028 { return m_staticBox; }
0c0d686f 1029
eb2a7883
VZ
1030 // override to hide/show the static box as well
1031 virtual void ShowItems (bool show);
7e2b7860 1032
e978011a 1033 virtual bool Detach( wxWindow *window );
7e2b7860
VZ
1034 virtual bool Detach( wxSizer *sizer ) { return wxBoxSizer::Detach(sizer); }
1035 virtual bool Detach( int index ) { return wxBoxSizer::Detach(index); }
eb2a7883 1036
27ea1d8a 1037protected:
f6bcfd97 1038 wxStaticBox *m_staticBox;
1e6feb95 1039
9cbee2ce 1040private:
4393b50c 1041 DECLARE_CLASS(wxStaticBoxSizer)
c0c133e1 1042 wxDECLARE_NO_COPY_CLASS(wxStaticBoxSizer);
27ea1d8a
RR
1043};
1044
1e6feb95
VZ
1045#endif // wxUSE_STATBOX
1046
9b494057
FM
1047//---------------------------------------------------------------------------
1048// wxStdDialogButtonSizer
1049//---------------------------------------------------------------------------
1050
974c2a59
WS
1051#if wxUSE_BUTTON
1052
53a2db12 1053class WXDLLIMPEXP_CORE wxStdDialogButtonSizer: public wxBoxSizer
acf2ac37
RR
1054{
1055public:
acf2ac37
RR
1056 // Constructor just creates a new wxBoxSizer, not much else.
1057 // Box sizer orientation is automatically determined here:
1058 // vertical for PDAs, horizontal for everything else?
b181a505 1059 wxStdDialogButtonSizer();
acf2ac37 1060
acf2ac37 1061 // Checks button ID against system IDs and sets one of the pointers below
b181a505
RR
1062 // to this button. Does not do any sizer-related things here.
1063 void AddButton(wxButton *button);
acf2ac37 1064
b181a505
RR
1065 // Use these if no standard ID can/should be used
1066 void SetAffirmativeButton( wxButton *button );
1067 void SetNegativeButton( wxButton *button );
1068 void SetCancelButton( wxButton *button );
acf2ac37 1069
acf2ac37
RR
1070 // All platform-specific code here, checks which buttons exist and add
1071 // them to the sizer accordingly.
1072 // Note - one potential hack on Mac we could use here,
1073 // if m_buttonAffirmative is wxID_SAVE then ensure wxID_SAVE
1074 // is set to _("Save") and m_buttonNegative is set to _("Don't Save")
1075 // I wouldn't add any other hacks like that into here,
1076 // but this one I can see being useful.
718903fe 1077 void Realize();
974c2a59 1078
acf2ac37
RR
1079 wxButton *GetAffirmativeButton() const { return m_buttonAffirmative; }
1080 wxButton *GetApplyButton() const { return m_buttonApply; }
1081 wxButton *GetNegativeButton() const { return m_buttonNegative; }
1082 wxButton *GetCancelButton() const { return m_buttonCancel; }
1083 wxButton *GetHelpButton() const { return m_buttonHelp; }
1084
1085protected:
b181a505 1086 wxButton *m_buttonAffirmative; // wxID_OK, wxID_YES, wxID_SAVE go here
57d7f988 1087 wxButton *m_buttonApply; // wxID_APPLY
b181a505 1088 wxButton *m_buttonNegative; // wxID_NO
57d7f988
VZ
1089 wxButton *m_buttonCancel; // wxID_CANCEL, wxID_CLOSE
1090 wxButton *m_buttonHelp; // wxID_HELP, wxID_CONTEXT_HELP
974c2a59 1091
acf2ac37
RR
1092private:
1093 DECLARE_CLASS(wxStdDialogButtonSizer)
c0c133e1 1094 wxDECLARE_NO_COPY_CLASS(wxStdDialogButtonSizer);
acf2ac37 1095};
adbf2d73 1096
6b5c4761 1097#endif // wxUSE_BUTTON
974c2a59 1098
adbf2d73 1099
8e32ea1c
VZ
1100// ----------------------------------------------------------------------------
1101// inline functions implementation
1102// ----------------------------------------------------------------------------
1103
4dd10327
VZ
1104#if WXWIN_COMPATIBILITY_2_8
1105
1106inline void wxSizerItem::SetWindow(wxWindow *window)
1107{
1108 DoSetWindow(window);
1109}
1110
1111inline void wxSizerItem::SetSizer(wxSizer *sizer)
1112{
1113 DoSetSizer(sizer);
1114}
1115
1116inline void wxSizerItem::SetSpacer(const wxSize& size)
1117{
1118 DoSetSpacer(size);
1119}
1120
1121inline void wxSizerItem::SetSpacer(int width, int height)
2f39b5a3
VZ
1122{
1123 DoSetSpacer(wxSize(width, height));
1124}
4dd10327
VZ
1125
1126#endif // WXWIN_COMPATIBILITY_2_8
1127
54d61068
VZ
1128inline wxSizerItem*
1129wxSizer::Insert(size_t index, wxSizerItem *item)
1130{
1131 return DoInsert(index, item);
1132}
1133
4dd10327 1134
50961a35
PC
1135inline wxSizerItem*
1136wxSizer::Add( wxSizerItem *item )
1137{
1138 return Insert( m_children.GetCount(), item );
1139}
1140
56eee37f 1141inline wxSizerItem*
8e32ea1c
VZ
1142wxSizer::Add( wxWindow *window, int proportion, int flag, int border, wxObject* userData )
1143{
56eee37f 1144 return Add( new wxSizerItem( window, proportion, flag, border, userData ) );
8e32ea1c
VZ
1145}
1146
56eee37f 1147inline wxSizerItem*
8e32ea1c
VZ
1148wxSizer::Add( wxSizer *sizer, int proportion, int flag, int border, wxObject* userData )
1149{
56eee37f 1150 return Add( new wxSizerItem( sizer, proportion, flag, border, userData ) );
8e32ea1c
VZ
1151}
1152
56eee37f 1153inline wxSizerItem*
8e32ea1c
VZ
1154wxSizer::Add( int width, int height, int proportion, int flag, int border, wxObject* userData )
1155{
56eee37f 1156 return Add( new wxSizerItem( width, height, proportion, flag, border, userData ) );
8e32ea1c
VZ
1157}
1158
56eee37f 1159inline wxSizerItem*
5f813ad6
VZ
1160wxSizer::Add( wxWindow *window, const wxSizerFlags& flags )
1161{
56eee37f 1162 return Add( new wxSizerItem(window, flags) );
5f813ad6
VZ
1163}
1164
56eee37f 1165inline wxSizerItem*
5f813ad6
VZ
1166wxSizer::Add( wxSizer *sizer, const wxSizerFlags& flags )
1167{
56eee37f 1168 return Add( new wxSizerItem(sizer, flags) );
5f813ad6
VZ
1169}
1170
b701f995
VZ
1171inline wxSizerItem*
1172wxSizer::Add( int width, int height, const wxSizerFlags& flags )
1173{
1174 return Add( new wxSizerItem(width, height, flags) );
1175}
1176
56eee37f 1177inline wxSizerItem*
8e32ea1c
VZ
1178wxSizer::AddSpacer(int size)
1179{
56eee37f 1180 return Add(size, size);
8e32ea1c
VZ
1181}
1182
56eee37f 1183inline wxSizerItem*
8e32ea1c
VZ
1184wxSizer::AddStretchSpacer(int prop)
1185{
56eee37f 1186 return Add(0, 0, prop);
8e32ea1c
VZ
1187}
1188
50961a35
PC
1189inline wxSizerItem*
1190wxSizer::Prepend( wxSizerItem *item )
1191{
1192 return Insert( 0, item );
1193}
1194
56eee37f 1195inline wxSizerItem*
8e32ea1c
VZ
1196wxSizer::Prepend( wxWindow *window, int proportion, int flag, int border, wxObject* userData )
1197{
56eee37f 1198 return Prepend( new wxSizerItem( window, proportion, flag, border, userData ) );
8e32ea1c
VZ
1199}
1200
56eee37f 1201inline wxSizerItem*
8e32ea1c
VZ
1202wxSizer::Prepend( wxSizer *sizer, int proportion, int flag, int border, wxObject* userData )
1203{
56eee37f 1204 return Prepend( new wxSizerItem( sizer, proportion, flag, border, userData ) );
8e32ea1c
VZ
1205}
1206
56eee37f 1207inline wxSizerItem*
8e32ea1c
VZ
1208wxSizer::Prepend( int width, int height, int proportion, int flag, int border, wxObject* userData )
1209{
56eee37f 1210 return Prepend( new wxSizerItem( width, height, proportion, flag, border, userData ) );
8e32ea1c
VZ
1211}
1212
56eee37f 1213inline wxSizerItem*
8e32ea1c
VZ
1214wxSizer::PrependSpacer(int size)
1215{
56eee37f 1216 return Prepend(size, size);
8e32ea1c
VZ
1217}
1218
56eee37f 1219inline wxSizerItem*
8e32ea1c
VZ
1220wxSizer::PrependStretchSpacer(int prop)
1221{
56eee37f 1222 return Prepend(0, 0, prop);
8e32ea1c
VZ
1223}
1224
56eee37f 1225inline wxSizerItem*
5f813ad6
VZ
1226wxSizer::Prepend( wxWindow *window, const wxSizerFlags& flags )
1227{
56eee37f 1228 return Prepend( new wxSizerItem(window, flags) );
5f813ad6
VZ
1229}
1230
56eee37f 1231inline wxSizerItem*
5f813ad6
VZ
1232wxSizer::Prepend( wxSizer *sizer, const wxSizerFlags& flags )
1233{
56eee37f 1234 return Prepend( new wxSizerItem(sizer, flags) );
5f813ad6
VZ
1235}
1236
b701f995
VZ
1237inline wxSizerItem*
1238wxSizer::Prepend( int width, int height, const wxSizerFlags& flags )
1239{
1240 return Prepend( new wxSizerItem(width, height, flags) );
1241}
1242
56eee37f 1243inline wxSizerItem*
8e32ea1c 1244wxSizer::Insert( size_t index,
5f813ad6
VZ
1245 wxWindow *window,
1246 int proportion,
1247 int flag,
1248 int border,
1249 wxObject* userData )
8e32ea1c 1250{
56eee37f 1251 return Insert( index, new wxSizerItem( window, proportion, flag, border, userData ) );
8e32ea1c
VZ
1252}
1253
56eee37f 1254inline wxSizerItem*
8e32ea1c 1255wxSizer::Insert( size_t index,
5f813ad6
VZ
1256 wxSizer *sizer,
1257 int proportion,
1258 int flag,
1259 int border,
1260 wxObject* userData )
8e32ea1c 1261{
56eee37f 1262 return Insert( index, new wxSizerItem( sizer, proportion, flag, border, userData ) );
8e32ea1c
VZ
1263}
1264
56eee37f 1265inline wxSizerItem*
8e32ea1c 1266wxSizer::Insert( size_t index,
5f813ad6
VZ
1267 int width,
1268 int height,
1269 int proportion,
1270 int flag,
1271 int border,
1272 wxObject* userData )
8e32ea1c 1273{
56eee37f 1274 return Insert( index, new wxSizerItem( width, height, proportion, flag, border, userData ) );
8e32ea1c
VZ
1275}
1276
56eee37f 1277inline wxSizerItem*
5f813ad6
VZ
1278wxSizer::Insert( size_t index, wxWindow *window, const wxSizerFlags& flags )
1279{
56eee37f 1280 return Insert( index, new wxSizerItem(window, flags) );
5f813ad6
VZ
1281}
1282
56eee37f 1283inline wxSizerItem*
5f813ad6
VZ
1284wxSizer::Insert( size_t index, wxSizer *sizer, const wxSizerFlags& flags )
1285{
56eee37f 1286 return Insert( index, new wxSizerItem(sizer, flags) );
5f813ad6
VZ
1287}
1288
b701f995
VZ
1289inline wxSizerItem*
1290wxSizer::Insert( size_t index, int width, int height, const wxSizerFlags& flags )
1291{
1292 return Insert( index, new wxSizerItem(width, height, flags) );
1293}
1294
56eee37f 1295inline wxSizerItem*
8e32ea1c
VZ
1296wxSizer::InsertSpacer(size_t index, int size)
1297{
56eee37f 1298 return Insert(index, size, size);
8e32ea1c
VZ
1299}
1300
56eee37f 1301inline wxSizerItem*
8e32ea1c
VZ
1302wxSizer::InsertStretchSpacer(size_t index, int prop)
1303{
56eee37f 1304 return Insert(index, 0, 0, prop);
8e32ea1c
VZ
1305}
1306
ade4eb65 1307#endif // __WXSIZER_H__