]> git.saurik.com Git - wxWidgets.git/blame - samples/widgets/static.cpp
wxMessageBox off the main thread lost result code.
[wxWidgets.git] / samples / widgets / static.cpp
CommitLineData
32b8ec41 1/////////////////////////////////////////////////////////////////////////////
be5a51fb 2// Program: wxWidgets Widgets Sample
32b8ec41
VZ
3// Name: static.cpp
4// Purpose: Part of the widgets sample showing various static controls
5// Author: Vadim Zeitlin
6// Created: 11.04.01
32b8ec41 7// Copyright: (c) 2001 Vadim Zeitlin
526954c5 8// Licence: wxWindows licence
32b8ec41
VZ
9/////////////////////////////////////////////////////////////////////////////
10
11// ============================================================================
12// declarations
13// ============================================================================
14
15// ----------------------------------------------------------------------------
16// headers
17// ----------------------------------------------------------------------------
18
19// for compilers that support precompilation, includes "wx/wx.h".
20#include "wx/wxprec.h"
21
22#ifdef __BORLANDC__
23 #pragma hdrstop
24#endif
25
26// for all others, include the necessary headers
27#ifndef WX_PRECOMP
28 #include "wx/log.h"
29
3bb70c40 30 #include "wx/bitmap.h"
32b8ec41
VZ
31 #include "wx/button.h"
32 #include "wx/checkbox.h"
33 #include "wx/radiobox.h"
34 #include "wx/statbox.h"
35 #include "wx/stattext.h"
36 #include "wx/textctrl.h"
37#endif
38
39#include "wx/sizer.h"
40
41#include "wx/statline.h"
916eabe6 42#include "wx/generic/stattextg.h"
c052f780 43#include "wx/wupdlock.h"
32b8ec41
VZ
44
45#include "widgets.h"
32b8ec41
VZ
46#include "icons/statbox.xpm"
47
48// ----------------------------------------------------------------------------
49// constants
50// ----------------------------------------------------------------------------
51
52// control ids
53enum
54{
f0fa4312 55 StaticPage_Reset = wxID_HIGHEST,
32b8ec41 56 StaticPage_BoxText,
39bc0347
VZ
57 StaticPage_LabelText,
58 StaticPage_LabelTextWithMarkup
32b8ec41
VZ
59};
60
61// alignment radiobox values
62enum
63{
64 StaticHAlign_Left,
65 StaticHAlign_Centre,
66 StaticHAlign_Right,
67 StaticHAlign_Max
68};
69
70enum
71{
72 StaticVAlign_Top,
73 StaticVAlign_Centre,
74 StaticVAlign_Bottom,
75 StaticVAlign_Max
76};
77
39bc0347
VZ
78enum
79{
80 StaticEllipsize_Start,
81 StaticEllipsize_Middle,
82 StaticEllipsize_End
83};
84
a9d171bd 85
32b8ec41
VZ
86// ----------------------------------------------------------------------------
87// StaticWidgetsPage
88// ----------------------------------------------------------------------------
89
90class StaticWidgetsPage : public WidgetsPage
91{
92public:
f2fdc4d5 93 StaticWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist);
8f6eaec9 94 virtual ~StaticWidgetsPage(){};
32b8ec41 95
195df7a7 96 virtual wxControl *GetWidget() const { return m_statText; }
2af006eb
VZ
97 virtual Widgets GetWidgets() const
98 {
99 Widgets widgets;
100 widgets.push_back(m_sizerStatBox->GetStaticBox());
101 widgets.push_back(m_statText);
f5bdfc69 102#if wxUSE_MARKUP
2af006eb 103 widgets.push_back(m_statMarkup);
f5bdfc69 104#endif // wxUSE_MARKUP
2af006eb
VZ
105#if wxUSE_STATLINE
106 widgets.push_back(m_statLine);
107#endif // wxUSE_STATLINE
108
109 return widgets;
110 }
1301e228 111 virtual void RecreateWidget() { CreateStatic(); }
195df7a7 112
453535a7
WS
113 // lazy creation of the content
114 virtual void CreateContent();
115
32b8ec41
VZ
116protected:
117 // event handlers
118 void OnCheckOrRadioBox(wxCommandEvent& event);
119
120 void OnButtonReset(wxCommandEvent& event);
121 void OnButtonBoxText(wxCommandEvent& event);
122 void OnButtonLabelText(wxCommandEvent& event);
f5bdfc69 123#if wxUSE_MARKUP
39bc0347 124 void OnButtonLabelWithMarkupText(wxCommandEvent& event);
f5bdfc69 125#endif // wxUSE_MARKUP
916eabe6 126 void OnMouseEvent(wxMouseEvent& event);
32b8ec41
VZ
127
128 // reset all parameters
129 void Reset();
130
131 // (re)create all controls
132 void CreateStatic();
133
134 // the controls
135 // ------------
136
137 // the check/radio boxes for styles
138 wxCheckBox *m_chkVert,
916eabe6 139 *m_chkGeneric,
39bc0347 140 *m_chkAutoResize,
f5bdfc69
VZ
141 *m_chkEllipsize;
142
143#if wxUSE_MARKUP
144 wxCheckBox *m_chkMarkup,
916eabe6 145 *m_chkGreen;
f5bdfc69 146#endif // wxUSE_MARKUP
32b8ec41
VZ
147
148 wxRadioBox *m_radioHAlign,
39bc0347
VZ
149 *m_radioVAlign,
150 *m_radioEllipsize;
32b8ec41
VZ
151
152 // the controls and the sizer containing them
153 wxStaticBoxSizer *m_sizerStatBox;
f5bdfc69
VZ
154 wxStaticTextBase *m_statText;
155
156#if wxUSE_MARKUP
157 wxStaticTextBase *m_statMarkup;
158#endif // wxUSE_MARKUP
159
a56938e4 160#if wxUSE_STATLINE
32b8ec41 161 wxStaticLine *m_statLine;
a56938e4 162#endif // wxUSE_STATLINE
32b8ec41
VZ
163 wxSizer *m_sizerStatic;
164
165 // the text entries for command parameters
166 wxTextCtrl *m_textBox,
f5bdfc69
VZ
167 *m_textLabel;
168
169#if wxUSE_MARKUP
170 wxTextCtrl *m_textLabelWithMarkup;
171#endif // wxUSE_MARKUP
32b8ec41
VZ
172
173private:
5e173f35
GD
174 DECLARE_EVENT_TABLE()
175 DECLARE_WIDGETS_PAGE(StaticWidgetsPage)
32b8ec41
VZ
176};
177
178// ----------------------------------------------------------------------------
179// event tables
180// ----------------------------------------------------------------------------
181
182BEGIN_EVENT_TABLE(StaticWidgetsPage, WidgetsPage)
183 EVT_BUTTON(StaticPage_Reset, StaticWidgetsPage::OnButtonReset)
184 EVT_BUTTON(StaticPage_LabelText, StaticWidgetsPage::OnButtonLabelText)
f5bdfc69 185#if wxUSE_MARKUP
39bc0347 186 EVT_BUTTON(StaticPage_LabelTextWithMarkup, StaticWidgetsPage::OnButtonLabelWithMarkupText)
f5bdfc69 187#endif // wxUSE_MARKUP
32b8ec41
VZ
188 EVT_BUTTON(StaticPage_BoxText, StaticWidgetsPage::OnButtonBoxText)
189
206d3a16
JS
190 EVT_CHECKBOX(wxID_ANY, StaticWidgetsPage::OnCheckOrRadioBox)
191 EVT_RADIOBOX(wxID_ANY, StaticWidgetsPage::OnCheckOrRadioBox)
32b8ec41
VZ
192END_EVENT_TABLE()
193
194// ============================================================================
195// implementation
196// ============================================================================
197
9a83f860 198IMPLEMENT_WIDGETS_PAGE(StaticWidgetsPage, wxT("Static"),
cc65c5f9 199 (int)wxPlatform(GENERIC_CTRLS).If(wxOS_WINDOWS,NATIVE_CTRLS)
f2fdc4d5 200 );
32b8ec41 201
f2fdc4d5 202StaticWidgetsPage::StaticWidgetsPage(WidgetsBookCtrl *book,
61c083e7 203 wxImageList *imaglist)
261357eb 204 : WidgetsPage(book, imaglist, statbox_xpm)
32b8ec41 205{
32b8ec41
VZ
206 // init everything
207 m_chkVert =
f5bdfc69
VZ
208 m_chkAutoResize =
209 m_chkGeneric =
210#if wxUSE_MARKUP
211 m_chkGreen =
212#endif // wxUSE_MARKUP
213 NULL;
32b8ec41
VZ
214
215 m_radioHAlign =
216 m_radioVAlign = (wxRadioBox *)NULL;
217
a56938e4 218#if wxUSE_STATLINE
32b8ec41 219 m_statLine = (wxStaticLine *)NULL;
a56938e4 220#endif // wxUSE_STATLINE
f5bdfc69 221#if wxUSE_MARKUP
916eabe6 222 m_statText = m_statMarkup = NULL;
f5bdfc69 223#endif // wxUSE_MARKUP
32b8ec41
VZ
224
225 m_sizerStatBox = (wxStaticBoxSizer *)NULL;
226 m_sizerStatic = (wxSizer *)NULL;
39bc0347 227
f5bdfc69
VZ
228 m_textBox =
229 m_textLabel =
230#if wxUSE_MARKUP
231 m_textLabelWithMarkup =
232#endif // wxUSE_MARKUP
233 NULL;
453535a7 234}
32b8ec41 235
453535a7
WS
236void StaticWidgetsPage::CreateContent()
237{
32b8ec41
VZ
238 wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
239
240 // left pane
916eabe6 241 wxSizer *sizerLeft = new wxStaticBoxSizer(wxVERTICAL, this, "&Set style");
32b8ec41 242
916eabe6
VZ
243 m_chkGeneric = CreateCheckBoxAndAddToSizer(sizerLeft,
244 "&Generic wxStaticText");
916eabe6
VZ
245 m_chkVert = CreateCheckBoxAndAddToSizer(sizerLeft, "&Vertical line");
246 m_chkAutoResize = CreateCheckBoxAndAddToSizer(sizerLeft, "&Fit to text");
32b8ec41
VZ
247 sizerLeft->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer
248
249 static const wxString halign[] =
250 {
9a83f860
VZ
251 wxT("left"),
252 wxT("centre"),
253 wxT("right"),
32b8ec41
VZ
254 };
255
256 static const wxString valign[] =
257 {
9a83f860
VZ
258 wxT("top"),
259 wxT("centre"),
260 wxT("bottom"),
32b8ec41
VZ
261 };
262
9a83f860 263 m_radioHAlign = new wxRadioBox(this, wxID_ANY, wxT("&Horz alignment"),
32b8ec41 264 wxDefaultPosition, wxDefaultSize,
916eabe6 265 WXSIZEOF(halign), halign, 3);
9a83f860 266 m_radioVAlign = new wxRadioBox(this, wxID_ANY, wxT("&Vert alignment"),
32b8ec41 267 wxDefaultPosition, wxDefaultSize,
916eabe6 268 WXSIZEOF(valign), valign, 3);
32b8ec41
VZ
269
270 sizerLeft->Add(m_radioHAlign, 0, wxGROW | wxALL, 5);
271 sizerLeft->Add(m_radioVAlign, 0, wxGROW | wxALL, 5);
272
39bc0347
VZ
273
274 sizerLeft->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer
275
9a83f860 276 m_chkEllipsize = CreateCheckBoxAndAddToSizer(sizerLeft, wxT("&Ellipsize"));
39bc0347
VZ
277
278 static const wxString ellipsizeMode[] =
279 {
9a83f860
VZ
280 wxT("&start"),
281 wxT("&middle"),
282 wxT("&end"),
39bc0347
VZ
283 };
284
9a83f860 285 m_radioEllipsize = new wxRadioBox(this, wxID_ANY, wxT("&Ellipsize mode"),
39bc0347 286 wxDefaultPosition, wxDefaultSize,
916eabe6
VZ
287 WXSIZEOF(ellipsizeMode), ellipsizeMode,
288 3);
39bc0347
VZ
289
290 sizerLeft->Add(m_radioEllipsize, 0, wxGROW | wxALL, 5);
291
9a83f860 292 wxButton *btn = new wxButton(this, StaticPage_Reset, wxT("&Reset"));
32b8ec41
VZ
293 sizerLeft->Add(btn, 0, wxALIGN_CENTRE_HORIZONTAL | wxALL, 15);
294
295 // middle pane
916eabe6
VZ
296 wxSizer *sizerMiddle = new wxStaticBoxSizer(wxVERTICAL, this,
297 "&Change labels");
298
299 m_textBox = new wxTextCtrl(this, wxID_ANY, wxEmptyString);
300 wxButton *b1 = new wxButton(this, wxID_ANY, "Change &box label");
ce7fe42e 301 b1->Connect(wxEVT_BUTTON,
916eabe6
VZ
302 wxCommandEventHandler(StaticWidgetsPage::OnButtonBoxText),
303 NULL, this);
304 sizerMiddle->Add(m_textBox, 0, wxEXPAND|wxALL, 5);
305 sizerMiddle->Add(b1, 0, wxLEFT|wxBOTTOM, 5);
306
307 m_textLabel = new wxTextCtrl(this, wxID_ANY, wxEmptyString,
308 wxDefaultPosition, wxDefaultSize,
309 wxTE_MULTILINE|wxHSCROLL);
310 wxButton *b2 = new wxButton(this, wxID_ANY, "Change &text label");
ce7fe42e 311 b2->Connect(wxEVT_BUTTON,
916eabe6
VZ
312 wxCommandEventHandler(StaticWidgetsPage::OnButtonLabelText),
313 NULL, this);
314 sizerMiddle->Add(m_textLabel, 0, wxEXPAND|wxALL, 5);
315 sizerMiddle->Add(b2, 0, wxLEFT|wxBOTTOM, 5);
316
f5bdfc69 317#if wxUSE_MARKUP
916eabe6
VZ
318 m_textLabelWithMarkup = new wxTextCtrl(this, wxID_ANY, wxEmptyString,
319 wxDefaultPosition, wxDefaultSize,
320 wxTE_MULTILINE|wxHSCROLL);
321
322 wxButton *b3 = new wxButton(this, wxID_ANY, "Change decorated text label");
ce7fe42e 323 b3->Connect(wxEVT_BUTTON,
916eabe6
VZ
324 wxCommandEventHandler(StaticWidgetsPage::OnButtonLabelWithMarkupText),
325 NULL, this);
326 sizerMiddle->Add(m_textLabelWithMarkup, 0, wxEXPAND|wxALL, 5);
327 sizerMiddle->Add(b3, 0, wxLEFT|wxBOTTOM, 5);
328
3a6b6a98 329 m_chkGreen = CreateCheckBoxAndAddToSizer(sizerMiddle,
916eabe6 330 "Decorated label on g&reen");
f5bdfc69 331#endif // wxUSE_MARKUP
39bc0347
VZ
332
333 // final initializations
334 // NB: must be done _before_ calling CreateStatic()
335 Reset();
336
b4607e89 337 m_textBox->SetValue(wxT("This is a &box"));
9a83f860
VZ
338 m_textLabel->SetValue(wxT("And this is a\n\tlabel inside the box with a &mnemonic.\n")
339 wxT("Only this text is affected by the ellipsize settings."));
f5bdfc69 340#if wxUSE_MARKUP
9a83f860
VZ
341 m_textLabelWithMarkup->SetValue(wxT("Another label, this time <b>decorated</b> ")
342 wxT("with <u>markup</u>; here you need entities ")
343 wxT("for the symbols: &lt; &gt; &amp; &apos; &quot; ")
344 wxT(" but you can still place &mnemonics..."));
f5bdfc69 345#endif // wxUSE_MARKUP
32b8ec41
VZ
346
347 // right pane
348 wxSizer *sizerRight = new wxBoxSizer(wxHORIZONTAL);
7b127900 349 sizerRight->SetMinSize(150, 0);
32b8ec41
VZ
350 m_sizerStatic = sizerRight;
351
352 CreateStatic();
353
354 // the 3 panes panes compose the window
355 sizerTop->Add(sizerLeft, 0, wxGROW | (wxALL & ~wxLEFT), 10);
7b127900 356 sizerTop->Add(sizerMiddle, 0, wxGROW | wxALL, 10);
32b8ec41
VZ
357 sizerTop->Add(sizerRight, 1, wxGROW | (wxALL & ~wxRIGHT), 10);
358
32b8ec41 359 SetSizer(sizerTop);
32b8ec41
VZ
360}
361
32b8ec41
VZ
362// ----------------------------------------------------------------------------
363// operations
364// ----------------------------------------------------------------------------
365
366void StaticWidgetsPage::Reset()
367{
916eabe6 368 m_chkGeneric->SetValue(false);
206d3a16
JS
369 m_chkVert->SetValue(false);
370 m_chkAutoResize->SetValue(true);
39bc0347 371 m_chkEllipsize->SetValue(true);
32b8ec41
VZ
372
373 m_radioHAlign->SetSelection(StaticHAlign_Left);
374 m_radioVAlign->SetSelection(StaticVAlign_Top);
375}
376
377void StaticWidgetsPage::CreateStatic()
378{
c052f780
VZ
379 wxWindowUpdateLocker lock(this);
380
32b8ec41
VZ
381 bool isVert = m_chkVert->GetValue();
382
383 if ( m_sizerStatBox )
384 {
32b8ec41 385 // delete m_sizerStatBox; -- deleted by Remove()
168954a1 386 m_sizerStatic->Remove(m_sizerStatBox);
32b8ec41 387 delete m_statText;
f5bdfc69 388#if wxUSE_MARKUP
916eabe6 389 delete m_statMarkup;
f5bdfc69 390#endif // wxUSE_MARKUP
a56938e4 391#if wxUSE_STATLINE
32b8ec41 392 delete m_statLine;
a56938e4 393#endif // wxUSE_STATLINE
32b8ec41
VZ
394 }
395
396 int flagsBox = 0,
39bc0347
VZ
397 flagsText = ms_defaultFlags,
398 flagsDummyText = ms_defaultFlags;
32b8ec41
VZ
399
400 if ( !m_chkAutoResize->GetValue() )
401 {
402 flagsText |= wxST_NO_AUTORESIZE;
39bc0347
VZ
403 flagsDummyText |= wxST_NO_AUTORESIZE;
404 }
405
32b8ec41
VZ
406 int align = 0;
407 switch ( m_radioHAlign->GetSelection() )
408 {
409 default:
9a83f860 410 wxFAIL_MSG(wxT("unexpected radiobox selection"));
32b8ec41
VZ
411 // fall through
412
413 case StaticHAlign_Left:
414 align |= wxALIGN_LEFT;
415 break;
416
417 case StaticHAlign_Centre:
418 align |= wxALIGN_CENTRE_HORIZONTAL;
419 break;
420
421 case StaticHAlign_Right:
422 align |= wxALIGN_RIGHT;
423 break;
424 }
425
426 switch ( m_radioVAlign->GetSelection() )
427 {
428 default:
9a83f860 429 wxFAIL_MSG(wxT("unexpected radiobox selection"));
32b8ec41
VZ
430 // fall through
431
432 case StaticVAlign_Top:
433 align |= wxALIGN_TOP;
434 break;
435
436 case StaticVAlign_Centre:
437 align |= wxALIGN_CENTRE_VERTICAL;
438 break;
439
440 case StaticVAlign_Bottom:
441 align |= wxALIGN_BOTTOM;
442 break;
443 }
444
39bc0347
VZ
445 if ( m_chkEllipsize->GetValue() )
446 {
447 switch ( m_radioEllipsize->GetSelection() )
448 {
449 default:
9a83f860 450 wxFAIL_MSG(wxT("unexpected radiobox selection"));
39bc0347
VZ
451 // fall through
452
453 case StaticEllipsize_Start:
454 flagsDummyText |= wxST_ELLIPSIZE_START;
455 break;
456
457 case StaticEllipsize_Middle:
458 flagsDummyText |= wxST_ELLIPSIZE_MIDDLE;
459 break;
460
461 case StaticEllipsize_End:
462 flagsDummyText |= wxST_ELLIPSIZE_END;
463 break;
464 }
465 }
466
467 flagsDummyText |= align;
32b8ec41
VZ
468 flagsText |= align;
469 flagsBox |= align;
470
916eabe6
VZ
471 wxStaticBox *staticBox = new wxStaticBox(this, wxID_ANY,
472 m_textBox->GetValue(),
473 wxDefaultPosition, wxDefaultSize,
474 flagsBox);
475 m_sizerStatBox = new wxStaticBoxSizer(staticBox, isVert ? wxHORIZONTAL
476 : wxVERTICAL);
32b8ec41 477
916eabe6
VZ
478 if ( m_chkGeneric->GetValue() )
479 {
f1c49882 480 m_statText = new wxGenericStaticText(staticBox, wxID_ANY,
916eabe6
VZ
481 m_textLabel->GetValue(),
482 wxDefaultPosition, wxDefaultSize,
483 flagsDummyText);
f5bdfc69 484#if wxUSE_MARKUP
f1c49882 485 m_statMarkup = new wxGenericStaticText(staticBox, wxID_ANY,
3da9cffc 486 wxString(),
916eabe6
VZ
487 wxDefaultPosition, wxDefaultSize,
488 flagsText);
f5bdfc69 489#endif // wxUSE_MARKUP
916eabe6
VZ
490 }
491 else // use native versions
492 {
f1c49882 493 m_statText = new wxStaticText(staticBox, wxID_ANY,
916eabe6
VZ
494 m_textLabel->GetValue(),
495 wxDefaultPosition, wxDefaultSize,
496 flagsDummyText);
f5bdfc69 497#if wxUSE_MARKUP
f1c49882 498 m_statMarkup = new wxStaticText(staticBox, wxID_ANY,
3da9cffc 499 wxString(),
916eabe6
VZ
500 wxDefaultPosition, wxDefaultSize,
501 flagsText);
f5bdfc69 502#endif // wxUSE_MARKUP
916eabe6 503 }
3da9cffc 504
f1c49882
VZ
505 m_statText->SetToolTip("Tooltip for a label inside the box");
506
f5bdfc69 507#if wxUSE_MARKUP
3da9cffc
VZ
508 m_statMarkup->SetLabelMarkup(m_textLabelWithMarkup->GetValue());
509
916eabe6
VZ
510 if ( m_chkGreen->GetValue() )
511 m_statMarkup->SetBackgroundColour(*wxGREEN);
f5bdfc69
VZ
512#endif // wxUSE_MARKUP
513
a56938e4 514#if wxUSE_STATLINE
f1c49882 515 m_statLine = new wxStaticLine(staticBox, wxID_ANY,
32b8ec41
VZ
516 wxDefaultPosition, wxDefaultSize,
517 isVert ? wxLI_VERTICAL : wxLI_HORIZONTAL);
a56938e4 518#endif // wxUSE_STATLINE
32b8ec41 519
f1c49882 520 m_sizerStatBox->Add(m_statText, 0, wxGROW | wxALL, 5);
a56938e4 521#if wxUSE_STATLINE
32b8ec41 522 m_sizerStatBox->Add(m_statLine, 0, wxGROW | wxALL, 5);
a56938e4 523#endif // wxUSE_STATLINE
f5bdfc69 524#if wxUSE_MARKUP
f1c49882 525 m_sizerStatBox->Add(m_statMarkup, 0, wxALL, 5);
f5bdfc69 526#endif // wxUSE_MARKUP
32b8ec41 527
f1c49882 528 m_sizerStatic->Add(m_sizerStatBox, 0, wxGROW);
32b8ec41
VZ
529
530 m_sizerStatic->Layout();
916eabe6
VZ
531
532 m_statText->Connect(wxEVT_LEFT_UP,
533 wxMouseEventHandler(StaticWidgetsPage::OnMouseEvent),
534 NULL, this);
535 staticBox->Connect(wxEVT_LEFT_UP,
536 wxMouseEventHandler(StaticWidgetsPage::OnMouseEvent),
537 NULL, this);
32b8ec41
VZ
538}
539
540// ----------------------------------------------------------------------------
541// event handlers
542// ----------------------------------------------------------------------------
543
544void StaticWidgetsPage::OnButtonReset(wxCommandEvent& WXUNUSED(event))
545{
546 Reset();
547
548 CreateStatic();
549}
550
39bc0347 551void StaticWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& event)
32b8ec41 552{
81d3348a 553 if (event.GetEventObject() == static_cast<wxObject*>(m_chkEllipsize))
39bc0347
VZ
554 {
555 m_radioEllipsize->Enable(event.IsChecked());
556 }
557
32b8ec41
VZ
558 CreateStatic();
559}
560
c02e5a31 561void StaticWidgetsPage::OnButtonBoxText(wxCommandEvent& WXUNUSED(event))
32b8ec41
VZ
562{
563 m_sizerStatBox->GetStaticBox()->SetLabel(m_textBox->GetValue());
564}
565
916eabe6 566void StaticWidgetsPage::OnButtonLabelText(wxCommandEvent& WXUNUSED(event))
39bc0347 567{
916eabe6 568 m_statText->SetLabel(m_textLabel->GetValue());
39bc0347
VZ
569
570 // test GetLabel() and GetLabelText(); the first should return the
571 // label as it is written in the relative text control; the second should
572 // return the label as it's shown in the wxStaticText
573 wxLogMessage(wxT("The original label should be '%s'"),
916eabe6 574 m_statText->GetLabel());
39bc0347 575 wxLogMessage(wxT("The label text is '%s'"),
916eabe6 576 m_statText->GetLabelText());
39bc0347
VZ
577}
578
f5bdfc69 579#if wxUSE_MARKUP
916eabe6 580void StaticWidgetsPage::OnButtonLabelWithMarkupText(wxCommandEvent& WXUNUSED(event))
32b8ec41 581{
3da9cffc 582 m_statMarkup->SetLabelMarkup(m_textLabelWithMarkup->GetValue());
39bc0347
VZ
583
584 // test GetLabel() and GetLabelText(); the first should return the
585 // label as it is written in the relative text control; the second should
586 // return the label as it's shown in the wxStaticText
587 wxLogMessage(wxT("The original label should be '%s'"),
916eabe6 588 m_statMarkup->GetLabel());
39bc0347 589 wxLogMessage(wxT("The label text is '%s'"),
916eabe6
VZ
590 m_statMarkup->GetLabelText());
591}
f5bdfc69 592#endif // wxUSE_MARKUP
916eabe6
VZ
593
594void StaticWidgetsPage::OnMouseEvent(wxMouseEvent& event)
595{
596 if ( event.GetEventObject() == m_statText )
43b2d5e7 597 {
916eabe6 598 wxLogMessage("Clicked on static text");
43b2d5e7 599 }
916eabe6 600 else
43b2d5e7 601 {
916eabe6 602 wxLogMessage("Clicked on static box");
43b2d5e7 603 }
32b8ec41
VZ
604}
605