]> git.saurik.com Git - wxWidgets.git/blob - samples/widgets/textctrl.cpp
updated project files and compilation options
[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/bitmap.h"
33 #include "wx/button.h"
34 #include "wx/checkbox.h"
35 #include "wx/radiobox.h"
36 #include "wx/statbox.h"
37 #include "wx/stattext.h"
38 #include "wx/textctrl.h"
39 #endif
40
41 #include "wx/sizer.h"
42
43 #include "widgets.h"
44
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->Detach( 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
559 // cast to int needed to silence gcc warning about different enums
560 m_sizerText->Add(m_text, 1, wxALL |
561 (flags & wxTE_MULTILINE ? (int)wxGROW
562 : wxALIGN_TOP), 5);
563 m_sizerText->Layout();
564 }
565
566 // ----------------------------------------------------------------------------
567 // event handlers
568 // ----------------------------------------------------------------------------
569
570 void TextWidgetsPage::OnIdle(wxIdleEvent& WXUNUSED(event))
571 {
572 // update all info texts
573
574 if ( m_textPosCur )
575 {
576 long posCur = m_text->GetInsertionPoint();
577 if ( posCur != m_posCur )
578 {
579 m_textPosCur->Clear();
580 m_textRowCur->Clear();
581 m_textColCur->Clear();
582
583 long col, row;
584 m_text->PositionToXY(posCur, &col, &row);
585
586 *m_textPosCur << posCur;
587 *m_textRowCur << row;
588 *m_textColCur << col;
589
590 m_posCur = posCur;
591 }
592 }
593
594 if ( m_textPosLast )
595 {
596 long posLast = m_text->GetLastPosition();
597 if ( posLast != m_posLast )
598 {
599 m_textPosLast->Clear();
600 *m_textPosLast << posLast;
601
602 m_posLast = posLast;
603 }
604 }
605
606 if ( m_textLineLast )
607 {
608 m_textLineLast->SetValue(
609 wxString::Format(_T("%d"), m_text->GetNumberOfLines()) );
610 }
611
612 if ( m_textSelFrom && m_textSelTo )
613 {
614 long selFrom, selTo;
615 m_text->GetSelection(&selFrom, &selTo);
616 if ( selFrom != m_selFrom )
617 {
618 m_textSelFrom->Clear();
619 *m_textSelFrom << selFrom;
620
621 m_selFrom = selFrom;
622 }
623
624 if ( selTo != m_selTo )
625 {
626 m_textSelTo->Clear();
627 *m_textSelTo << selTo;
628
629 m_selTo = selTo;
630 }
631 }
632
633 if ( m_textRange )
634 {
635 m_textRange->SetValue(m_text->GetRange(10, 20));
636 }
637 }
638
639 void TextWidgetsPage::OnButtonReset(wxCommandEvent& WXUNUSED(event))
640 {
641 Reset();
642
643 CreateText();
644 }
645
646 void TextWidgetsPage::OnButtonSet(wxCommandEvent& WXUNUSED(event))
647 {
648 m_text->SetValue(m_text->GetWindowStyle() & wxTE_MULTILINE
649 ? _T("Here,\nthere and\neverywhere")
650 : _T("Yellow submarine"));
651
652 m_text->SetFocus();
653 }
654
655 void TextWidgetsPage::OnButtonAdd(wxCommandEvent& WXUNUSED(event))
656 {
657 if ( m_text->GetWindowStyle() & wxTE_MULTILINE )
658 {
659 m_text->AppendText(_T("We all live in a\n"));
660 }
661
662 m_text->AppendText(_T("Yellow submarine"));
663 }
664
665 void TextWidgetsPage::OnButtonInsert(wxCommandEvent& WXUNUSED(event))
666 {
667 m_text->WriteText(_T("Is there anybody going to listen to my story"));
668 if ( m_text->GetWindowStyle() & wxTE_MULTILINE )
669 {
670 m_text->WriteText(_T("\nall about the girl who came to stay"));
671 }
672 }
673
674 void TextWidgetsPage::OnButtonClear(wxCommandEvent& WXUNUSED(event))
675 {
676 m_text->Clear();
677 m_text->SetFocus();
678 }
679
680 void TextWidgetsPage::OnButtonLoad(wxCommandEvent& WXUNUSED(event))
681 {
682 // search for the file in several dirs where it's likely to be
683 wxPathList pathlist;
684 pathlist.Add(_T("."));
685 pathlist.Add(_T(".."));
686 pathlist.Add(_T("../../../samples/widgets"));
687
688 wxString filename = pathlist.FindValidPath(_T("textctrl.cpp"));
689 if ( !filename )
690 {
691 wxLogError(_T("File textctrl.cpp not found."));
692 }
693 else // load it
694 {
695 wxStopWatch sw;
696 if ( !m_text->LoadFile(filename) )
697 {
698 // this is not supposed to happen ...
699 wxLogError(_T("Error loading file."));
700 }
701 else
702 {
703 long elapsed = sw.Time();
704 wxLogMessage(_T("Loaded file '%s' in %lu.%us"),
705 filename.c_str(), elapsed / 1000,
706 (unsigned int) elapsed % 1000);
707 }
708 }
709 }
710
711 void TextWidgetsPage::OnUpdateUIClearButton(wxUpdateUIEvent& event)
712 {
713 event.Enable(!m_text->GetValue().empty());
714 }
715
716 void TextWidgetsPage::OnUpdateUIWrapLinesCheckbox(wxUpdateUIEvent& event)
717 {
718 event.Enable( !IsSingleLine() );
719 }
720
721 void TextWidgetsPage::OnUpdateUIPasswordCheckbox(wxUpdateUIEvent& event)
722 {
723 // can't put multiline control in password mode
724 event.Enable( IsSingleLine() );
725 }
726
727 void TextWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
728 {
729 event.Enable( (m_radioTextLines->GetSelection() != DEFAULTS.textLines) ||
730 #ifdef __WXMSW__
731 (m_radioKind->GetSelection() != DEFAULTS.textKind) ||
732 #endif // __WXMSW__
733 (m_chkReadonly->GetValue() != DEFAULTS.readonly) ||
734 (m_chkPassword->GetValue() != DEFAULTS.password) ||
735 (m_chkWrapLines->GetValue() != DEFAULTS.wraplines) );
736 }
737
738 void TextWidgetsPage::OnText(wxCommandEvent& WXUNUSED(event))
739 {
740 // small hack to suppress the very first message: by then the logging is
741 // not yet redirected and so initial setting of the text value results in
742 // an annoying message box
743 static bool s_firstTime = TRUE;
744 if ( s_firstTime )
745 {
746 s_firstTime = FALSE;
747 return;
748 }
749
750 wxLogMessage(_T("Text ctrl value changed"));
751 }
752
753 void TextWidgetsPage::OnTextEnter(wxCommandEvent& event)
754 {
755 wxLogMessage(_T("Text entered: '%s'"), event.GetString().c_str());
756 }
757
758 void TextWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
759 {
760 CreateText();
761 }
762