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