1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Layout sample
4 // Author: Julian Smart
5 // Modified by: Robin Dunn, Vadim Zeitlin
8 // Copyright: (c) 1998 Julian Smart
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
13 // ----------------------------------------------------------------------------
15 // ----------------------------------------------------------------------------
17 // For compilers that support precompilation, includes "wx/wx.h".
18 #include "wx/wxprec.h"
29 #include "wx/gbsizer.h"
30 #include "wx/statline.h"
31 #include "wx/notebook.h"
32 #include "wx/spinctrl.h"
36 // ----------------------------------------------------------------------------
38 // ----------------------------------------------------------------------------
44 // Create the main frame window
45 MyFrame
*frame
= new MyFrame
;
52 // ----------------------------------------------------------------------------
54 // ----------------------------------------------------------------------------
56 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
57 EVT_MENU(LAYOUT_ABOUT
, MyFrame::OnAbout
)
58 EVT_MENU(LAYOUT_QUIT
, MyFrame::OnQuit
)
60 EVT_MENU(LAYOUT_TEST_PROPORTIONS
, MyFrame::TestProportions
)
61 EVT_MENU(LAYOUT_TEST_SIZER
, MyFrame::TestFlexSizers
)
62 EVT_MENU(LAYOUT_TEST_NB_SIZER
, MyFrame::TestNotebookSizers
)
63 EVT_MENU(LAYOUT_TEST_GB_SIZER
, MyFrame::TestGridBagSizer
)
64 EVT_MENU(LAYOUT_TEST_SET_MINIMAL
, MyFrame::TestSetMinimal
)
67 // Define my frame constructor
69 : wxFrame(NULL
, wxID_ANY
, _T("wxWidgets Layout Demo"),
70 wxDefaultPosition
, wxDefaultSize
,
71 wxDEFAULT_FRAME_STYLE
| wxNO_FULL_REPAINT_ON_RESIZE
)
74 wxMenu
*file_menu
= new wxMenu
;
76 file_menu
->Append(LAYOUT_TEST_PROPORTIONS
, _T("&Proportions demo...\tF1"));
77 file_menu
->Append(LAYOUT_TEST_SIZER
, _T("Test wx&FlexSizer...\tF2"));
78 file_menu
->Append(LAYOUT_TEST_NB_SIZER
, _T("Test ¬ebook sizers...\tF3"));
79 file_menu
->Append(LAYOUT_TEST_GB_SIZER
, _T("Test &gridbag sizer...\tF4"));
80 file_menu
->Append(LAYOUT_TEST_SET_MINIMAL
, _T("Test Set&ItemMinSize...\tF5"));
82 file_menu
->AppendSeparator();
83 file_menu
->Append(LAYOUT_QUIT
, _T("E&xit"), _T("Quit program"));
85 wxMenu
*help_menu
= new wxMenu
;
86 help_menu
->Append(LAYOUT_ABOUT
, _T("&About"), _T("About layout demo..."));
88 wxMenuBar
*menu_bar
= new wxMenuBar
;
90 menu_bar
->Append(file_menu
, _T("&File"));
91 menu_bar
->Append(help_menu
, _T("&Help"));
93 // Associate the menu bar with the frame
98 SetStatusText(_T("wxWidgets layout demo"));
99 #endif // wxUSE_STATUSBAR
101 wxPanel
* p
= new wxPanel(this, wxID_ANY
);
103 // we want to get a dialog that is stretchable because it
104 // has a text ctrl in the middle. at the bottom, we have
105 // two buttons which.
107 wxBoxSizer
*topsizer
= new wxBoxSizer( wxVERTICAL
);
109 // 1) top: create wxStaticText with minimum size equal to its default size
111 new wxStaticText( p
, wxID_ANY
, _T("An explanation (wxALIGN_RIGHT).") ),
112 wxSizerFlags().Align(wxALIGN_RIGHT
).Border(wxALL
& ~wxBOTTOM
, 5));
114 // 2) top: create wxTextCtrl with minimum size (100x60)
116 new wxTextCtrl( p
, wxID_ANY
, _T("My text (wxEXPAND)."), wxDefaultPosition
, wxSize(100,60), wxTE_MULTILINE
),
117 wxSizerFlags(1).Expand().Border(wxALL
, 5));
119 // 2.5) Gratuitous test of wxStaticBoxSizers
120 wxBoxSizer
*statsizer
= new wxStaticBoxSizer(
121 new wxStaticBox(p
, wxID_ANY
, _T("A wxStaticBoxSizer")), wxVERTICAL
);
123 new wxStaticText(p
, wxID_ANY
, _T("And some TEXT inside it")),
124 wxSizerFlags().Center().Border(wxALL
, 30));
127 wxSizerFlags(1).Expand().Border(wxALL
, 10));
129 // 2.7) And a test of wxGridSizer
130 wxGridSizer
*gridsizer
= new wxGridSizer(2, 5, 5);
131 gridsizer
->Add(new wxStaticText(p
, wxID_ANY
, _T("Label")),
132 wxSizerFlags().Align(wxALIGN_RIGHT
| wxALIGN_CENTER_VERTICAL
));
133 gridsizer
->Add(new wxTextCtrl(p
, wxID_ANY
, _T("Grid sizer demo")),
134 wxSizerFlags(1).Align(wxGROW
| wxALIGN_CENTER_VERTICAL
));
135 gridsizer
->Add(new wxStaticText(p
, wxID_ANY
, _T("Another label")),
136 wxSizerFlags().Align(wxALIGN_RIGHT
| wxALIGN_CENTER_VERTICAL
));
137 gridsizer
->Add(new wxTextCtrl(p
, wxID_ANY
, _T("More text")),
138 wxSizerFlags(1).Align(wxGROW
| wxALIGN_CENTER_VERTICAL
));
139 gridsizer
->Add(new wxStaticText(p
, wxID_ANY
, _T("Final label")),
140 wxSizerFlags().Align(wxALIGN_RIGHT
| wxALIGN_CENTER_VERTICAL
));
141 gridsizer
->Add(new wxTextCtrl(p
, wxID_ANY
, _T("And yet more text")),
142 wxSizerFlags().Align(wxGROW
| wxALIGN_CENTER_VERTICAL
));
145 wxSizerFlags().Proportion(1).Expand().Border(wxALL
, 10));
149 // 3) middle: create wxStaticLine with minimum size (3x3)
151 new wxStaticLine( p
, wxID_ANY
, wxDefaultPosition
, wxSize(3,3), wxHORIZONTAL
),
152 wxSizerFlags().Expand());
153 #endif // wxUSE_STATLINE
156 // 4) bottom: create two centred wxButtons
157 wxBoxSizer
*button_box
= new wxBoxSizer( wxHORIZONTAL
);
159 new wxButton( p
, wxID_ANY
, _T("Two buttons in a box") ),
160 wxSizerFlags().Border(wxALL
, 7));
162 new wxButton( p
, wxID_ANY
, _T("(wxCENTER)") ),
163 wxSizerFlags().Border(wxALL
, 7));
165 topsizer
->Add(button_box
, wxSizerFlags().Center());
167 p
->SetSizer( topsizer
);
169 // don't allow frame to get smaller than what the sizers tell it and also set
170 // the initial size as calculated by the sizers
171 topsizer
->SetSizeHints( this );
174 void MyFrame::OnQuit(wxCommandEvent
& WXUNUSED(event
))
179 void MyFrame::TestProportions(wxCommandEvent
& WXUNUSED(event
))
181 (new MyProportionsFrame(this))->Show();
184 void MyFrame::TestFlexSizers(wxCommandEvent
& WXUNUSED(event
) )
186 MyFlexSizerFrame
*newFrame
= new MyFlexSizerFrame(_T("Flex Sizer Test Frame"), 50, 50);
187 newFrame
->Show(true);
190 void MyFrame::TestNotebookSizers(wxCommandEvent
& WXUNUSED(event
) )
192 MySizerDialog
dialog( this, _T("Notebook Sizer Test Dialog") );
197 void MyFrame::TestSetMinimal(wxCommandEvent
& WXUNUSED(event
) )
199 MySimpleSizerFrame
*newFrame
= new MySimpleSizerFrame(_T("Simple Sizer Test Frame"), 50, 50);
200 newFrame
->Show(true);
204 void MyFrame::OnAbout(wxCommandEvent
& WXUNUSED(event
) )
206 (void)wxMessageBox(_T("wxWidgets GUI library layout demo\n"),
207 _T("About Layout Demo"), wxOK
|wxICON_INFORMATION
);
210 void MyFrame::TestGridBagSizer(wxCommandEvent
& WXUNUSED(event
) )
212 MyGridBagSizerFrame
*newFrame
= new
213 MyGridBagSizerFrame(_T("wxGridBagSizer Test Frame"), 50, 50);
214 newFrame
->Show(true);
217 // ----------------------------------------------------------------------------
218 // MyProportionsFrame
219 // ----------------------------------------------------------------------------
221 MyProportionsFrame::MyProportionsFrame(wxFrame
*parent
)
222 : wxFrame(parent
, wxID_ANY
, _T("Box Sizer Proportions Demo"))
226 // create the controls
227 wxPanel
*panel
= new wxPanel(this, wxID_ANY
);
228 for ( n
= 0; n
< WXSIZEOF(m_spins
); n
++ )
230 m_spins
[n
] = new wxSpinCtrl(panel
);
231 m_spins
[n
]->SetValue(n
);
235 m_sizer
= new wxStaticBoxSizer(wxHORIZONTAL
, panel
,
236 _T("Try changing elements proportions and resizing the window"));
237 for ( n
= 0; n
< WXSIZEOF(m_spins
); n
++ )
238 m_sizer
->Add(m_spins
[n
], wxSizerFlags().Border());
240 // put everything together
241 panel
->SetSizer(m_sizer
);
242 wxSizer
*sizerTop
= new wxBoxSizer(wxVERTICAL
);
243 sizerTop
->Add(panel
, wxSizerFlags(1).Expand().Border());
245 SetSizerAndFit(sizerTop
);
247 // and connect the events
248 Connect(wxEVT_COMMAND_TEXT_UPDATED
,
249 wxCommandEventHandler(MyProportionsFrame::OnProportionUpdated
));
250 Connect(wxEVT_COMMAND_SPINCTRL_UPDATED
,
251 wxSpinEventHandler(MyProportionsFrame::OnProportionChanged
));
254 void MyProportionsFrame::UpdateProportions()
256 for ( size_t n
= 0; n
< WXSIZEOF(m_spins
); n
++ )
258 m_sizer
->GetItem(n
)->SetProportion(m_spins
[n
]->GetValue());
264 void MyProportionsFrame::OnProportionUpdated(wxCommandEvent
& WXUNUSED(event
))
269 void MyProportionsFrame::OnProportionChanged(wxSpinEvent
& WXUNUSED(event
))
274 // ----------------------------------------------------------------------------
276 // ----------------------------------------------------------------------------
278 void MyFlexSizerFrame::InitFlexSizer(wxFlexGridSizer
*sizer
, wxWindow
* parent
)
280 for ( int i
= 0; i
< 3; i
++ )
282 for ( int j
= 0; j
< 3; j
++ )
284 sizer
->Add(new wxStaticText
288 wxString::Format(_T("(%d, %d)"), i
+ 1, j
+ 1),
293 0, wxEXPAND
| wxALIGN_CENTER_VERTICAL
| wxALL
, 3);
298 MyFlexSizerFrame::MyFlexSizerFrame(const wxChar
*title
, int x
, int y
)
299 : wxFrame(NULL
, wxID_ANY
, title
, wxPoint(x
, y
) )
301 wxFlexGridSizer
*sizerFlex
;
302 wxPanel
* p
= new wxPanel(this, wxID_ANY
);
304 // consttuct the first column
305 wxSizer
*sizerCol1
= new wxBoxSizer(wxVERTICAL
);
306 sizerCol1
->Add(new wxStaticText(p
, wxID_ANY
, _T("Ungrowable:")), 0, wxCENTER
| wxTOP
, 20);
307 sizerFlex
= new wxFlexGridSizer(3, 3);
308 InitFlexSizer(sizerFlex
, p
);
309 sizerCol1
->Add(sizerFlex
, 1, wxALL
| wxEXPAND
, 10);
311 sizerCol1
->Add(new wxStaticText(p
, wxID_ANY
, _T("Growable middle column:")), 0, wxCENTER
| wxTOP
, 20);
312 sizerFlex
= new wxFlexGridSizer(3, 3);
313 InitFlexSizer(sizerFlex
, p
);
314 sizerFlex
->AddGrowableCol(1);
315 sizerCol1
->Add(sizerFlex
, 1, wxALL
| wxEXPAND
, 10);
317 sizerCol1
->Add(new wxStaticText(p
, wxID_ANY
, _T("Growable middle row:")), 0, wxCENTER
| wxTOP
, 20);
318 sizerFlex
= new wxFlexGridSizer(3, 3);
319 InitFlexSizer(sizerFlex
, p
);
320 sizerFlex
->AddGrowableRow(1);
321 sizerCol1
->Add(sizerFlex
, 1, wxALL
| wxEXPAND
, 10);
323 sizerCol1
->Add(new wxStaticText(p
, wxID_ANY
, _T("All growable columns:")), 0, wxCENTER
| wxTOP
, 20);
324 sizerFlex
= new wxFlexGridSizer(3, 3);
325 InitFlexSizer(sizerFlex
, p
);
326 sizerFlex
->AddGrowableCol(0, 1);
327 sizerFlex
->AddGrowableCol(1, 2);
328 sizerFlex
->AddGrowableCol(2, 3);
329 sizerCol1
->Add(sizerFlex
, 1, wxALL
| wxEXPAND
, 10);
332 wxSizer
*sizerCol2
= new wxBoxSizer(wxVERTICAL
);
333 sizerCol2
->Add(new wxStaticText(p
, wxID_ANY
, _T("Growable middle row and column:")), 0, wxCENTER
| wxTOP
, 20);
334 sizerFlex
= new wxFlexGridSizer(3, 3);
335 InitFlexSizer(sizerFlex
, p
);
336 sizerFlex
->AddGrowableCol(1);
337 sizerFlex
->AddGrowableRow(1);
338 sizerCol2
->Add(sizerFlex
, 1, wxALL
| wxEXPAND
, 10);
340 sizerCol2
->Add(new wxStaticText(p
, wxID_ANY
, _T("Same with horz flex direction")), 0, wxCENTER
| wxTOP
, 20);
341 sizerFlex
= new wxFlexGridSizer(3, 3);
342 InitFlexSizer(sizerFlex
, p
);
343 sizerFlex
->AddGrowableCol(1);
344 sizerFlex
->AddGrowableRow(1);
345 sizerFlex
->SetFlexibleDirection(wxHORIZONTAL
);
346 sizerCol2
->Add(sizerFlex
, 1, wxALL
| wxEXPAND
, 10);
348 sizerCol2
->Add(new wxStaticText(p
, wxID_ANY
, _T("Same with grow mode == \"none\"")), 0, wxCENTER
| wxTOP
, 20);
349 sizerFlex
= new wxFlexGridSizer(3, 3);
350 InitFlexSizer(sizerFlex
, p
);
351 sizerFlex
->AddGrowableCol(1);
352 sizerFlex
->AddGrowableRow(1);
353 sizerFlex
->SetFlexibleDirection(wxHORIZONTAL
);
354 sizerFlex
->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_NONE
);
355 sizerCol2
->Add(sizerFlex
, 1, wxALL
| wxEXPAND
, 10);
357 sizerCol2
->Add(new wxStaticText(p
, wxID_ANY
, _T("Same with grow mode == \"all\"")), 0, wxCENTER
| wxTOP
, 20);
358 sizerFlex
= new wxFlexGridSizer(3, 3);
359 InitFlexSizer(sizerFlex
, p
);
360 sizerFlex
->AddGrowableCol(1);
361 sizerFlex
->AddGrowableRow(1);
362 sizerFlex
->SetFlexibleDirection(wxHORIZONTAL
);
363 sizerFlex
->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_ALL
);
364 sizerCol2
->Add(sizerFlex
, 1, wxALL
| wxEXPAND
, 10);
366 // add both columns to grid sizer
367 wxGridSizer
*sizerTop
= new wxGridSizer(2, 0, 20);
368 sizerTop
->Add(sizerCol1
, 1, wxEXPAND
);
369 sizerTop
->Add(sizerCol2
, 1, wxEXPAND
);
371 p
->SetSizer(sizerTop
);
372 sizerTop
->SetSizeHints(this);
375 // ----------------------------------------------------------------------------
377 // ----------------------------------------------------------------------------
379 MySizerDialog::MySizerDialog(wxWindow
*parent
, const wxChar
*title
)
380 : wxDialog(parent
, wxID_ANY
, wxString(title
))
382 // Begin with first hierarchy: a notebook at the top and
383 // and OK button at the bottom.
385 wxBoxSizer
*topsizer
= new wxBoxSizer( wxVERTICAL
);
387 wxNotebook
*notebook
= new wxNotebook( this, wxID_ANY
);
388 topsizer
->Add( notebook
, 1, wxGROW
);
390 wxButton
*button
= new wxButton( this, wxID_OK
, _T("OK") );
391 topsizer
->Add( button
, 0, wxALIGN_RIGHT
| wxALL
, 10 );
393 // First page: one big text ctrl
394 wxTextCtrl
*multi
= new wxTextCtrl( notebook
, wxID_ANY
, _T("TextCtrl."), wxDefaultPosition
, wxDefaultSize
, wxTE_MULTILINE
);
395 notebook
->AddPage( multi
, _T("Page One") );
397 // Second page: a text ctrl and a button
398 wxPanel
*panel
= new wxPanel( notebook
, wxID_ANY
);
399 notebook
->AddPage( panel
, _T("Page Two") );
401 wxSizer
*panelsizer
= new wxBoxSizer( wxVERTICAL
);
403 wxTextCtrl
*text
= new wxTextCtrl( panel
, wxID_ANY
, _T("TextLine 1."), wxDefaultPosition
, wxSize(250,wxDefaultCoord
) );
404 panelsizer
->Add( text
, 0, wxGROW
|wxALL
, 30 );
405 text
= new wxTextCtrl( panel
, wxID_ANY
, _T("TextLine 2."), wxDefaultPosition
, wxSize(250,wxDefaultCoord
) );
406 panelsizer
->Add( text
, 0, wxGROW
|wxALL
, 30 );
407 wxButton
*button2
= new wxButton( panel
, wxID_ANY
, _T("Hallo") );
408 panelsizer
->Add( button2
, 0, wxALIGN_RIGHT
| wxLEFT
|wxRIGHT
|wxBOTTOM
, 30 );
410 panel
->SetAutoLayout( true );
411 panel
->SetSizer( panelsizer
);
413 // Tell dialog to use sizer
414 SetSizer( topsizer
);
415 topsizer
->SetSizeHints( this );
418 // ----------------------------------------------------------------------------
419 // MyGridBagSizerFrame
420 // ----------------------------------------------------------------------------
422 // some simple macros to help make the sample code below more clear
423 #define TEXTCTRL(text) new wxTextCtrl(p, wxID_ANY, _T(text))
424 #define MLTEXTCTRL(text) new wxTextCtrl(p, wxID_ANY, _T(text), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE)
425 #define POS(r, c) wxGBPosition(r,c)
426 #define SPAN(r, c) wxGBSpan(r,c)
428 const wxChar gbsDescription
[] =_T("\
429 The wxGridBagSizer is similar to the wxFlexGridSizer except the items are explicitly positioned\n\
430 in a virtual cell of the layout grid, and column or row spanning is allowed. For example, this\n\
431 static text is positioned at (0,0) and it spans 7 columns.");
445 BEGIN_EVENT_TABLE(MyGridBagSizerFrame
, wxFrame
)
446 EVT_BUTTON( GBS_HIDE_BTN
, MyGridBagSizerFrame::OnHideBtn
)
447 EVT_BUTTON( GBS_SHOW_BTN
, MyGridBagSizerFrame::OnShowBtn
)
448 EVT_BUTTON( GBS_MOVE_BTN1
, MyGridBagSizerFrame::OnMoveBtn
)
449 EVT_BUTTON( GBS_MOVE_BTN2
, MyGridBagSizerFrame::OnMoveBtn
)
453 MyGridBagSizerFrame::MyGridBagSizerFrame(const wxChar
*title
, int x
, int y
)
454 : wxFrame( NULL
, wxID_ANY
, title
, wxPoint(x
, y
) )
456 wxPanel
* p
= new wxPanel(this, wxID_ANY
);
458 m_gbs
= new wxGridBagSizer();
461 m_gbs
->Add( new wxStaticText(p
, wxID_ANY
, gbsDescription
),
462 POS(0,0), SPAN(1, 7),
463 wxALIGN_CENTER
| wxALL
, 5);
465 m_gbs
->Add( TEXTCTRL("pos(1,0)"), POS(1,0) );
466 m_gbs
->Add( TEXTCTRL("pos(1,1)"), POS(1,1) );
467 m_gbs
->Add( TEXTCTRL("pos(2,0)"), POS(2,0) );
468 m_gbs
->Add( TEXTCTRL("pos(2,1)"), POS(2,1) );
469 m_gbs
->Add( MLTEXTCTRL("pos(3,2), span(1,2)\nthis row and col are growable"),
470 POS(3,2), SPAN(1,2), wxEXPAND
);
471 m_gbs
->Add( MLTEXTCTRL("pos(4,3)\nspan(3,1)"),
472 POS(4,3), SPAN(3,1), wxEXPAND
);
473 m_gbs
->Add( TEXTCTRL("pos(5,4)"), POS(5,4), wxDefaultSpan
, wxEXPAND
);
474 m_gbs
->Add( TEXTCTRL("pos(6,5)"), POS(6,5), wxDefaultSpan
, wxEXPAND
);
475 m_gbs
->Add( TEXTCTRL("pos(7,6)"), POS(7,6) );
477 //m_gbs->Add( TEXTCTRL("bad position"), POS(4,3) ); // Test for assert
478 //m_gbs->Add( TEXTCTRL("bad position"), POS(5,3) ); // Test for assert
481 m_moveBtn1
= new wxButton(p
, GBS_MOVE_BTN1
, _T("Move this to (3,6)"));
482 m_moveBtn2
= new wxButton(p
, GBS_MOVE_BTN2
, _T("Move this to (3,6)"));
483 m_gbs
->Add( m_moveBtn1
, POS(10,2) );
484 m_gbs
->Add( m_moveBtn2
, POS(10,3) );
486 m_hideBtn
= new wxButton(p
, GBS_HIDE_BTN
, _T("Hide this item -->"));
487 m_gbs
->Add(m_hideBtn
, POS(12, 3));
489 m_hideTxt
= new wxTextCtrl(p
, wxID_ANY
, _T("pos(12,4), size(150, wxDefaultCoord)"),
490 wxDefaultPosition
, wxSize(150,wxDefaultCoord
));
491 m_gbs
->Add( m_hideTxt
, POS(12,4) );
493 m_showBtn
= new wxButton(p
, GBS_SHOW_BTN
, _T("<-- Show it again"));
494 m_gbs
->Add(m_showBtn
, POS(12, 5));
495 m_showBtn
->Disable();
497 m_gbs
->Add(10,10, POS(14,0));
499 m_gbs
->AddGrowableRow(3);
500 m_gbs
->AddGrowableCol(2);
502 p
->SetSizerAndFit(m_gbs
);
503 SetClientSize(p
->GetSize());
507 void MyGridBagSizerFrame::OnHideBtn(wxCommandEvent
&)
509 m_gbs
->Hide(m_hideTxt
);
510 m_hideBtn
->Disable();
515 void MyGridBagSizerFrame::OnShowBtn(wxCommandEvent
&)
517 m_gbs
->Show(m_hideTxt
);
519 m_showBtn
->Disable();
524 void MyGridBagSizerFrame::OnMoveBtn(wxCommandEvent
& event
)
526 wxButton
* btn
= (wxButton
*)event
.GetEventObject();
527 wxGBPosition curPos
= m_gbs
->GetItemPosition(btn
);
529 // if it's already at the "other" spot then move it back
530 if (curPos
== wxGBPosition(3,6))
532 m_gbs
->SetItemPosition(btn
, m_lastPos
);
533 btn
->SetLabel(_T("Move this to (3,6)"));
537 if ( m_gbs
->CheckForIntersection(wxGBPosition(3,6), wxGBSpan(1,1)) )
539 _T("wxGridBagSizer will not allow items to be in the same cell as\n\
540 another item, so this operation will fail. You will also get an assert\n\
541 when compiled in debug mode."), _T("Warning"), wxOK
| wxICON_INFORMATION
);
543 if ( m_gbs
->SetItemPosition(btn
, wxGBPosition(3,6)) )
546 btn
->SetLabel(_T("Move it back"));
552 // ----------------------------------------------------------------------------
553 // MySimpleSizerFrame
554 // ----------------------------------------------------------------------------
562 BEGIN_EVENT_TABLE(MySimpleSizerFrame
, wxFrame
)
563 EVT_MENU( ID_SET_SMALL
, MySimpleSizerFrame::OnSetSmallSize
)
564 EVT_MENU( ID_SET_BIG
, MySimpleSizerFrame::OnSetBigSize
)
567 MySimpleSizerFrame::MySimpleSizerFrame(const wxChar
*title
, int x
, int y
)
568 : wxFrame( NULL
, wxID_ANY
, title
, wxPoint(x
, y
) )
570 wxMenu
*menu
= new wxMenu
;
572 menu
->Append(ID_SET_SMALL
, _T("Make text control small\tF4"));
573 menu
->Append(ID_SET_BIG
, _T("Make text control big\tF5"));
575 wxMenuBar
*menu_bar
= new wxMenuBar
;
576 menu_bar
->Append(menu
, _T("&File"));
578 SetMenuBar( menu_bar
);
580 wxBoxSizer
*main_sizer
= new wxBoxSizer( wxHORIZONTAL
);
582 m_target
= new wxTextCtrl( this, wxID_ANY
, wxEmptyString
, wxDefaultPosition
, wxSize( 80, wxDefaultCoord
) );
583 main_sizer
->Add( m_target
, 1, wxALL
, 5 );
585 main_sizer
->Add( new wxStaticText( this, wxID_ANY
, wxT("Set alternating sizes using F4 and F5") ), 0, wxALL
, 5 );
587 SetSizer( main_sizer
);
590 GetSizer()->Fit( this );
593 void MySimpleSizerFrame::OnSetSmallSize( wxCommandEvent
& WXUNUSED(event
))
595 GetSizer()->SetItemMinSize( m_target
, 40, -1 );
597 GetSizer()->Fit( this );
600 void MySimpleSizerFrame::OnSetBigSize( wxCommandEvent
& WXUNUSED(event
))
602 GetSizer()->SetItemMinSize( m_target
, 140, -1 );
604 GetSizer()->Fit( this );