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