]> git.saurik.com Git - wxWidgets.git/blob - samples/widgets/textctrl.cpp
Put a wxRegion test into the erase sample.
[wxWidgets.git] / samples / widgets / textctrl.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Program: wxWindows Widgets Sample
3 // Name: textctrl.cpp
4 // Purpose: part of the widgets sample showing wxTextCtrl
5 // Author: Vadim Zeitlin
6 // Created: 27.03.01
7 // Id: $Id$
8 // Copyright: (c) 2001 Vadim Zeitlin
9 // License: wxWindows license
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 #include "wx/timer.h"
31
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 "widgets.h"
43
44 #include "icons/text.xpm"
45
46 // ----------------------------------------------------------------------------
47 // constants
48 // ----------------------------------------------------------------------------
49
50 // control ids
51 enum
52 {
53 TextPage_Reset = 100,
54
55 TextPage_Set,
56 TextPage_Add,
57 TextPage_Insert,
58 TextPage_Clear,
59 TextPage_Load,
60
61 TextPage_Password,
62 TextPage_WrapLines,
63 TextPage_Textctrl
64 };
65
66 // textctrl line number radiobox values
67 enum TextLines
68 {
69 TextLines_Single,
70 TextLines_Multi
71 };
72
73 #ifdef __WXMSW__
74
75 // textctrl kind values
76 enum TextKind
77 {
78 TextKind_Plain,
79 TextKind_Rich,
80 TextKind_Rich2
81 };
82
83 #endif // __WXMSW__
84
85 // default values for the controls
86 static const struct ControlValues
87 {
88 TextLines textLines;
89 bool password;
90 bool wraplines;
91 bool readonly;
92 #ifdef __WXMSW__
93 TextKind textKind;
94 #endif // __WXMSW__
95 } DEFAULTS =
96 {
97 TextLines_Multi, // multiline
98 FALSE, // not password
99 TRUE, // do wrap lines
100 FALSE, // not readonly
101 #ifdef __WXMSW__
102 TextKind_Plain // plain EDIT control
103 #endif // __WXMSW__
104 };
105
106 // ----------------------------------------------------------------------------
107 // TextWidgetsPage
108 // ----------------------------------------------------------------------------
109
110 // Define a new frame type: this is going to be our main frame
111 class TextWidgetsPage : public WidgetsPage
112 {
113 public:
114 // ctor(s) and dtor
115 TextWidgetsPage(wxNotebook *notebook, wxImageList *imaglist);
116 virtual ~TextWidgetsPage();
117
118 protected:
119 // create an info text contorl
120 wxTextCtrl *CreateInfoText();
121
122 // create a horz sizer holding a static text and this text control
123 wxSizer *CreateTextWithLabelSizer(const wxString& label,
124 wxTextCtrl *text,
125 const wxString& label2 = wxEmptyString,
126 wxTextCtrl *text2 = NULL);
127
128 // event handlers
129 void OnButtonReset(wxCommandEvent& event);
130 void OnButtonClearLog(wxCommandEvent& event);
131
132 void OnButtonSet(wxCommandEvent& event);
133 void OnButtonAdd(wxCommandEvent& event);
134 void OnButtonInsert(wxCommandEvent& event);
135 void OnButtonClear(wxCommandEvent& event);
136 void OnButtonLoad(wxCommandEvent& event);
137
138 void OnButtonQuit(wxCommandEvent& event);
139
140 void OnText(wxCommandEvent& event);
141 void OnTextEnter(wxCommandEvent& event);
142
143 void OnCheckOrRadioBox(wxCommandEvent& event);
144
145 void OnUpdateUIClearButton(wxUpdateUIEvent& event);
146
147 void OnUpdateUIPasswordCheckbox(wxUpdateUIEvent& event);
148 void OnUpdateUIWrapLinesCheckbox(wxUpdateUIEvent& event);
149
150 void OnUpdateUIResetButton(wxUpdateUIEvent& event);
151
152 void OnIdle(wxIdleEvent& event);
153
154 // reset the textctrl parameters
155 void Reset();
156
157 // (re)create the textctrl
158 void CreateText();
159
160 // is the control currently single line?
161 bool IsSingleLine() const
162 {
163 return m_radioTextLines->GetSelection() == TextLines_Single;
164 }
165
166 // the controls
167 // ------------
168
169 // the radiobox to choose between single and multi line
170 wxRadioBox *m_radioTextLines;
171
172 // the checkboxes controlling text ctrl styles
173 wxCheckBox *m_chkPassword,
174 *m_chkWrapLines,
175 *m_chkReadonly;
176
177 // under MSW we test rich edit controls as well here
178 #ifdef __WXMSW__
179 wxRadioBox *m_radioKind;
180 #endif // __WXMSW__
181
182 // the textctrl itself and the sizer it is in
183 wxTextCtrl *m_text;
184 wxSizer *m_sizerText;
185
186 // the information text zones
187 wxTextCtrl *m_textPosCur,
188 *m_textRowCur,
189 *m_textColCur,
190 *m_textPosLast,
191 *m_textLineLast,
192 *m_textSelFrom,
193 *m_textSelTo,
194 *m_textRange;
195
196 // and the data to show in them
197 long m_posCur,
198 m_posLast,
199 m_selFrom,
200 m_selTo;
201
202 private:
203 // any class wishing to process wxWindows events must use this macro
204 DECLARE_EVENT_TABLE()
205 DECLARE_WIDGETS_PAGE(TextWidgetsPage)
206 };
207
208 // ----------------------------------------------------------------------------
209 // event tables
210 // ----------------------------------------------------------------------------
211
212 BEGIN_EVENT_TABLE(TextWidgetsPage, WidgetsPage)
213 EVT_IDLE(TextWidgetsPage::OnIdle)
214
215 EVT_BUTTON(TextPage_Reset, TextWidgetsPage::OnButtonReset)
216
217 EVT_BUTTON(TextPage_Clear, TextWidgetsPage::OnButtonClear)
218 EVT_BUTTON(TextPage_Set, TextWidgetsPage::OnButtonSet)
219 EVT_BUTTON(TextPage_Add, TextWidgetsPage::OnButtonAdd)
220 EVT_BUTTON(TextPage_Insert, TextWidgetsPage::OnButtonInsert)
221 EVT_BUTTON(TextPage_Load, TextWidgetsPage::OnButtonLoad)
222
223 EVT_UPDATE_UI(TextPage_Clear, TextWidgetsPage::OnUpdateUIClearButton)
224
225 EVT_UPDATE_UI(TextPage_Password, TextWidgetsPage::OnUpdateUIPasswordCheckbox)
226 EVT_UPDATE_UI(TextPage_WrapLines, TextWidgetsPage::OnUpdateUIWrapLinesCheckbox)
227
228 EVT_UPDATE_UI(TextPage_Reset, TextWidgetsPage::OnUpdateUIResetButton)
229
230 EVT_TEXT(TextPage_Textctrl, TextWidgetsPage::OnText)
231 EVT_TEXT_ENTER(TextPage_Textctrl, TextWidgetsPage::OnTextEnter)
232
233 EVT_CHECKBOX(-1, TextWidgetsPage::OnCheckOrRadioBox)
234 EVT_RADIOBOX(-1, TextWidgetsPage::OnCheckOrRadioBox)
235 END_EVENT_TABLE()
236
237 // ============================================================================
238 // implementation
239 // ============================================================================
240
241 IMPLEMENT_WIDGETS_PAGE(TextWidgetsPage, _T("Text"));
242
243 // ----------------------------------------------------------------------------
244 // TextWidgetsPage creation
245 // ----------------------------------------------------------------------------
246
247 TextWidgetsPage::TextWidgetsPage(wxNotebook *notebook, wxImageList *imaglist)
248 : WidgetsPage(notebook)
249 {
250 imaglist->Add(wxBitmap(text_xpm));
251
252 // init everything
253 #ifdef __WXMSW__
254 m_radioKind =
255 #endif // __WXMSW__
256 m_radioTextLines = (wxRadioBox *)NULL;
257
258 m_chkPassword =
259 m_chkWrapLines =
260 m_chkReadonly = (wxCheckBox *)NULL;
261
262 m_text =
263 m_textPosCur =
264 m_textRowCur =
265 m_textColCur =
266 m_textPosLast =
267 m_textLineLast =
268 m_textSelFrom =
269 m_textSelTo =
270 m_textRange = (wxTextCtrl *)NULL;
271
272 m_sizerText = (wxSizer *)NULL;
273
274 m_posCur =
275 m_posLast =
276 m_selFrom =
277 m_selTo = -2; // not -1 which means "no selection"
278
279 // left pane
280 static const wxString modes[] =
281 {
282 _T("single line"),
283 _T("multi line"),
284 };
285
286 wxStaticBox *box = new wxStaticBox(this, -1, _T("&Set textctrl parameters"));
287 m_radioTextLines = new wxRadioBox(this, -1, _T("&Number of lines:"),
288 wxDefaultPosition, wxDefaultSize,
289 WXSIZEOF(modes), modes,
290 1, wxRA_SPECIFY_COLS);
291
292 wxSizer *sizerLeft = new wxStaticBoxSizer(box, wxVERTICAL);
293
294 sizerLeft->Add(m_radioTextLines, 0, wxGROW | wxALL, 5);
295 sizerLeft->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer
296
297 m_chkPassword = CreateCheckBoxAndAddToSizer(
298 sizerLeft, _T("&Password control"), TextPage_Password
299 );
300 m_chkWrapLines = CreateCheckBoxAndAddToSizer(
301 sizerLeft, _T("Line &wrap"), TextPage_WrapLines
302 );
303 m_chkReadonly = CreateCheckBoxAndAddToSizer(
304 sizerLeft, _T("&Read-only mode")
305 );
306
307 #ifdef __WXMSW__
308 static const wxString kinds[] =
309 {
310 _T("plain edit"),
311 _T("rich edit"),
312 _T("rich edit 2.0"),
313 };
314
315 m_radioKind = new wxRadioBox(this, -1, _T("Control &kind"),
316 wxDefaultPosition, wxDefaultSize,
317 WXSIZEOF(kinds), kinds,
318 1, wxRA_SPECIFY_COLS);
319
320 sizerLeft->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer
321 sizerLeft->Add(m_radioKind, 0, wxGROW | wxALL, 5);
322 #endif // __WXMSW__
323
324 wxButton *btn = new wxButton(this, TextPage_Reset, _T("&Reset"));
325 sizerLeft->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer
326 sizerLeft->Add(btn, 0, wxALIGN_CENTRE_HORIZONTAL | wxALL, 15);
327
328 // middle pane
329 wxStaticBox *box2 = new wxStaticBox(this, -1, _T("&Change contents:"));
330 wxSizer *sizerMiddleUp = new wxStaticBoxSizer(box2, wxVERTICAL);
331
332 btn = new wxButton(this, TextPage_Set, _T("&Set text value"));
333 sizerMiddleUp->Add(btn, 0, wxALL | wxGROW, 5);
334
335 btn = new wxButton(this, TextPage_Add, _T("&Append text"));
336 sizerMiddleUp->Add(btn, 0, wxALL | wxGROW, 5);
337
338 btn = new wxButton(this, TextPage_Insert, _T("&Insert text"));
339 sizerMiddleUp->Add(btn, 0, wxALL | wxGROW, 5);
340
341 btn = new wxButton(this, TextPage_Load, _T("&Load file"));
342 sizerMiddleUp->Add(btn, 0, wxALL | wxGROW, 5);
343
344 btn = new wxButton(this, TextPage_Clear, _T("&Clear"));
345 sizerMiddleUp->Add(btn, 0, wxALL | wxGROW, 5);
346
347 wxStaticBox *box4 = new wxStaticBox(this, -1, _T("&Info:"));
348 wxSizer *sizerMiddleDown = new wxStaticBoxSizer(box4, wxVERTICAL);
349
350 m_textPosCur = CreateInfoText();
351 m_textRowCur = CreateInfoText();
352 m_textColCur = CreateInfoText();
353
354 wxSizer *sizerRow = new wxBoxSizer(wxHORIZONTAL);
355 sizerRow->Add(CreateTextWithLabelSizer
356 (
357 _T("Current pos:"),
358 m_textPosCur
359 ),
360 0, wxRIGHT, 5);
361 sizerRow->Add(CreateTextWithLabelSizer
362 (
363 _T("Col:"),
364 m_textColCur
365 ),
366 0, wxLEFT | wxRIGHT, 5);
367 sizerRow->Add(CreateTextWithLabelSizer
368 (
369 _T("Row:"),
370 m_textRowCur
371 ),
372 0, wxLEFT, 5);
373 sizerMiddleDown->Add(sizerRow, 0, wxALL, 5);
374
375 m_textLineLast = CreateInfoText();
376 m_textPosLast = CreateInfoText();
377 sizerMiddleDown->Add
378 (
379 CreateTextWithLabelSizer
380 (
381 _T("Number of lines:"),
382 m_textLineLast,
383 _T("Last position:"),
384 m_textPosLast
385 ),
386 0, wxALL, 5
387 );
388
389 m_textSelFrom = CreateInfoText();
390 m_textSelTo = CreateInfoText();
391 sizerMiddleDown->Add
392 (
393 CreateTextWithLabelSizer
394 (
395 _T("Selection: from"),
396 m_textSelFrom,
397 _T("to"),
398 m_textSelTo
399 ),
400 0, wxALL, 5
401 );
402
403 m_textRange = new wxTextCtrl(this, -1, _T(""),
404 wxDefaultPosition, wxDefaultSize,
405 wxTE_READONLY);
406 sizerMiddleDown->Add
407 (
408 CreateTextWithLabelSizer
409 (
410 _T("Range 10..20:"),
411 m_textRange
412 ),
413 0, wxALL, 5
414 );
415
416 wxSizer *sizerMiddle = new wxBoxSizer(wxVERTICAL);
417 sizerMiddle->Add(sizerMiddleUp, 0, wxGROW);
418 sizerMiddle->Add(sizerMiddleDown, 1, wxGROW | wxTOP, 5);
419
420 // right pane
421 wxStaticBox *box3 = new wxStaticBox(this, -1, _T("&Text:"));
422 m_sizerText = new wxStaticBoxSizer(box3, wxHORIZONTAL);
423 Reset();
424 CreateText();
425 m_sizerText->SetMinSize(250, 0);
426
427 // the 3 panes panes compose the upper part of the window
428 wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
429 sizerTop->Add(sizerLeft, 0, wxGROW | (wxALL & ~wxLEFT), 10);
430 sizerTop->Add(sizerMiddle, 0, wxGROW | wxALL, 10);
431 sizerTop->Add(m_sizerText, 1, wxGROW | (wxALL & ~wxRIGHT), 10);
432
433 SetAutoLayout(TRUE);
434 SetSizer(sizerTop);
435
436 sizerTop->Fit(this);
437 }
438
439 TextWidgetsPage::~TextWidgetsPage()
440 {
441 }
442
443 // ----------------------------------------------------------------------------
444 // creation helpers
445 // ----------------------------------------------------------------------------
446
447 wxTextCtrl *TextWidgetsPage::CreateInfoText()
448 {
449 static int s_maxWidth = 0;
450 if ( !s_maxWidth )
451 {
452 // calc it once only
453 GetTextExtent(_T("9999999"), &s_maxWidth, NULL);
454 }
455
456 wxTextCtrl *text = new wxTextCtrl(this, -1, _T(""),
457 wxDefaultPosition,
458 wxSize(s_maxWidth, -1),
459 wxTE_READONLY);
460 return text;
461 }
462
463 wxSizer *TextWidgetsPage::CreateTextWithLabelSizer(const wxString& label,
464 wxTextCtrl *text,
465 const wxString& label2,
466 wxTextCtrl *text2)
467 {
468 wxSizer *sizerRow = new wxBoxSizer(wxHORIZONTAL);
469 sizerRow->Add(new wxStaticText(this, -1, label), 0,
470 wxALIGN_CENTRE_VERTICAL | wxRIGHT, 5);
471 sizerRow->Add(text, 0, wxALIGN_CENTRE_VERTICAL);
472 if ( text2 )
473 {
474 sizerRow->Add(new wxStaticText(this, -1, label2), 0,
475 wxALIGN_CENTRE_VERTICAL | wxLEFT | wxRIGHT, 5);
476 sizerRow->Add(text2, 0, wxALIGN_CENTRE_VERTICAL);
477 }
478
479 return sizerRow;
480 }
481
482 // ----------------------------------------------------------------------------
483 // operations
484 // ----------------------------------------------------------------------------
485
486 void TextWidgetsPage::Reset()
487 {
488 m_radioTextLines->SetSelection(DEFAULTS.textLines);
489 m_chkPassword->SetValue(DEFAULTS.password);
490 m_chkWrapLines->SetValue(DEFAULTS.wraplines);
491 m_chkReadonly->SetValue(DEFAULTS.readonly);
492 #ifdef __WXMSW__
493 m_radioKind->SetSelection(DEFAULTS.textKind);
494 #endif // __WXMSW__
495 }
496
497 void TextWidgetsPage::CreateText()
498 {
499 int flags = 0;
500 switch ( m_radioTextLines->GetSelection() )
501 {
502 default:
503 wxFAIL_MSG( _T("unexpected lines radio box selection") );
504
505 case TextLines_Single:
506 break;
507
508 case TextLines_Multi:
509 flags |= wxTE_MULTILINE;
510 m_chkPassword->SetValue(FALSE);
511 break;
512 }
513
514 if ( m_chkPassword->GetValue() )
515 flags |= wxTE_PASSWORD;
516 if ( m_chkReadonly->GetValue() )
517 flags |= wxTE_READONLY;
518 if ( !m_chkWrapLines->GetValue() )
519 flags |= wxHSCROLL;
520
521 #ifdef __WXMSW__
522 switch ( m_radioKind->GetSelection() )
523 {
524 default:
525 wxFAIL_MSG( _T("unexpected kind radio box selection") );
526
527 case TextKind_Plain:
528 break;
529
530 case TextKind_Rich:
531 flags |= wxTE_RICH;
532 break;
533
534 case TextKind_Rich2:
535 flags |= wxTE_RICH2;
536 break;
537 }
538 #endif // __WXMSW__
539
540 wxString valueOld;
541 if ( m_text )
542 {
543 valueOld = m_text->GetValue();
544
545 m_sizerText->Remove(m_text);
546 delete m_text;
547 }
548 else
549 {
550 valueOld = _T("Hello, Universe!");
551 }
552
553 m_text = new wxTextCtrl(this, TextPage_Textctrl,
554 valueOld,
555 wxDefaultPosition, wxDefaultSize,
556 flags);
557 m_sizerText->Add(m_text, 1, wxALL |
558 (flags & wxTE_MULTILINE ? wxGROW
559 : wxALIGN_TOP), 5);
560 m_sizerText->Layout();
561 }
562
563 // ----------------------------------------------------------------------------
564 // event handlers
565 // ----------------------------------------------------------------------------
566
567 void TextWidgetsPage::OnIdle(wxIdleEvent& WXUNUSED(event))
568 {
569 // update all info texts
570
571 if ( m_textPosCur )
572 {
573 long posCur = m_text->GetInsertionPoint();
574 if ( posCur != m_posCur )
575 {
576 m_textPosCur->Clear();
577 m_textRowCur->Clear();
578 m_textColCur->Clear();
579
580 long col, row;
581 m_text->PositionToXY(posCur, &col, &row);
582
583 *m_textPosCur << posCur;
584 *m_textRowCur << row;
585 *m_textColCur << col;
586
587 m_posCur = posCur;
588 }
589 }
590
591 if ( m_textPosLast )
592 {
593 long posLast = m_text->GetLastPosition();
594 if ( posLast != m_posLast )
595 {
596 m_textPosLast->Clear();
597 *m_textPosLast << posLast;
598
599 m_posLast = posLast;
600 }
601 }
602
603 if ( m_textLineLast )
604 {
605 m_textLineLast->SetValue(
606 wxString::Format(_T("%ld"), m_text->GetNumberOfLines()));
607 }
608
609 if ( m_textSelFrom && m_textSelTo )
610 {
611 long selFrom, selTo;
612 m_text->GetSelection(&selFrom, &selTo);
613 if ( selFrom != m_selFrom )
614 {
615 m_textSelFrom->Clear();
616 *m_textSelFrom << selFrom;
617
618 m_selFrom = selFrom;
619 }
620
621 if ( selTo != m_selTo )
622 {
623 m_textSelTo->Clear();
624 *m_textSelTo << selTo;
625
626 m_selTo = selTo;
627 }
628 }
629
630 if ( m_textRange )
631 {
632 m_textRange->SetValue(m_text->GetRange(10, 20));
633 }
634 }
635
636 void TextWidgetsPage::OnButtonReset(wxCommandEvent& WXUNUSED(event))
637 {
638 Reset();
639
640 CreateText();
641 }
642
643 void TextWidgetsPage::OnButtonSet(wxCommandEvent& WXUNUSED(event))
644 {
645 m_text->SetValue(m_text->GetWindowStyle() & wxTE_MULTILINE
646 ? _T("Here,\nthere and\neverywhere")
647 : _T("Yellow submarine"));
648
649 m_text->SetFocus();
650 }
651
652 void TextWidgetsPage::OnButtonAdd(wxCommandEvent& WXUNUSED(event))
653 {
654 if ( m_text->GetWindowStyle() & wxTE_MULTILINE )
655 {
656 m_text->AppendText(_T("We all live in a\n"));
657 }
658
659 m_text->AppendText(_T("Yellow submarine"));
660 }
661
662 void TextWidgetsPage::OnButtonInsert(wxCommandEvent& WXUNUSED(event))
663 {
664 m_text->WriteText(_T("Is there anybody going to listen to my story"));
665 if ( m_text->GetWindowStyle() & wxTE_MULTILINE )
666 {
667 m_text->WriteText(_T("\nall about the girl who came to stay"));
668 }
669 }
670
671 void TextWidgetsPage::OnButtonClear(wxCommandEvent& WXUNUSED(event))
672 {
673 m_text->Clear();
674 m_text->SetFocus();
675 }
676
677 void TextWidgetsPage::OnButtonLoad(wxCommandEvent& WXUNUSED(event))
678 {
679 // search for the file in several dirs where it's likely to be
680 wxPathList pathlist;
681 pathlist.Add(_T("."));
682 pathlist.Add(_T(".."));
683 pathlist.Add(_T("../../../samples/widgets"));
684
685 wxString filename = pathlist.FindValidPath(_T("textctrl.cpp"));
686 if ( !filename )
687 {
688 wxLogError(_T("File textctrl.cpp not found."));
689 }
690 else // load it
691 {
692 wxStopWatch sw;
693 if ( !m_text->LoadFile(filename) )
694 {
695 // this is not supposed to happen ...
696 wxLogError(_T("Error loading file."));
697 }
698 else
699 {
700 long elapsed = sw.Time();
701 wxLogMessage(_T("Loaded file '%s' in %u.%us"),
702 filename.c_str(), elapsed / 1000, elapsed % 1000);
703 }
704 }
705 }
706
707 void TextWidgetsPage::OnUpdateUIClearButton(wxUpdateUIEvent& event)
708 {
709 event.Enable(!m_text->GetValue().empty());
710 }
711
712 void TextWidgetsPage::OnUpdateUIWrapLinesCheckbox(wxUpdateUIEvent& event)
713 {
714 event.Enable( !IsSingleLine() );
715 }
716
717 void TextWidgetsPage::OnUpdateUIPasswordCheckbox(wxUpdateUIEvent& event)
718 {
719 // can't put multiline control in password mode
720 event.Enable( IsSingleLine() );
721 }
722
723 void TextWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
724 {
725 event.Enable( (m_radioTextLines->GetSelection() != DEFAULTS.textLines) ||
726 #ifdef __WXMSW__
727 (m_radioKind->GetSelection() != DEFAULTS.textKind) ||
728 #endif // __WXMSW__
729 (m_chkReadonly->GetValue() != DEFAULTS.readonly) ||
730 (m_chkPassword->GetValue() != DEFAULTS.password) ||
731 (m_chkWrapLines->GetValue() != DEFAULTS.wraplines) );
732 }
733
734 void TextWidgetsPage::OnText(wxCommandEvent& event)
735 {
736 // small hack to suppress the very first message: by then the logging is
737 // not yet redirected and so initial setting of the text value results in
738 // an annoying message box
739 static bool s_firstTime = TRUE;
740 if ( s_firstTime )
741 {
742 s_firstTime = FALSE;
743 return;
744 }
745
746 wxLogMessage(_T("Text ctrl value changed"));
747 }
748
749 void TextWidgetsPage::OnTextEnter(wxCommandEvent& event)
750 {
751 wxLogMessage(_T("Text entered: '%s'"), event.GetString().c_str());
752 }
753
754 void TextWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& event)
755 {
756 CreateText();
757 }
758