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