]> git.saurik.com Git - wxWidgets.git/blob - samples/text/text.cpp
Added dialup to filelist.txt and wxUniv.dsp
[wxWidgets.git] / samples / text / text.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: text.cpp
3 // Purpose: TextCtrl wxWindows sample
4 // Author: Robert Roebling
5 // Modified by:
6 // RCS-ID: $Id$
7 // Copyright: (c) Robert Roebling, Julian Smart, Vadim Zeitlin
8 // Licence: wxWindows license
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifdef __GNUG__
12 #pragma implementation "text.cpp"
13 #endif
14
15 // For compilers that support precompilation, includes "wx/wx.h".
16 #include "wx/wxprec.h"
17
18 #ifdef __BORLANDC__
19 #pragma hdrstop
20 #endif
21
22 #ifndef WX_PRECOMP
23 #include "wx/wx.h"
24 #endif
25
26 #if wxUSE_CLIPBOARD
27 #include "wx/dataobj.h"
28 #include "wx/clipbrd.h"
29 #endif
30
31 #if wxUSE_FILE
32 #include "wx/file.h"
33 #endif
34
35 #if wxUSE_TOOLTIPS
36 #include "wx/tooltip.h"
37 #endif
38
39 #include "wx/progdlg.h"
40
41 // We test for wxUSE_DRAG_AND_DROP also, because data objects may not be
42 // implemented for compilers that can't cope with the OLE parts in
43 // wxUSE_DRAG_AND_DROP.
44 #if !wxUSE_DRAG_AND_DROP
45 #undef wxUSE_CLIPBOARD
46 #define wxUSE_CLIPBOARD 0
47 #endif
48
49 //----------------------------------------------------------------------
50 // class definitions
51 //----------------------------------------------------------------------
52
53 class MyApp: public wxApp
54 {
55 public:
56 bool OnInit();
57 };
58
59 // a text ctrl which allows to call different wxTextCtrl functions
60 // interactively by pressing function keys in it
61 class MyTextCtrl : public wxTextCtrl
62 {
63 public:
64 MyTextCtrl(wxWindow *parent, wxWindowID id, const wxString &value,
65 const wxPoint &pos, const wxSize &size, int style = 0)
66 : wxTextCtrl(parent, id, value, pos, size, style)
67 {
68 m_hasCapture = FALSE;
69 }
70
71 void OnKeyDown(wxKeyEvent& event);
72 void OnKeyUp(wxKeyEvent& event);
73 void OnChar(wxKeyEvent& event);
74
75 void OnText(wxCommandEvent& event);
76 void OnTextURL(wxTextUrlEvent& event);
77 void OnTextMaxLen(wxCommandEvent& event);
78
79 void OnMouseEvent(wxMouseEvent& event);
80
81 void OnSetFocus(wxFocusEvent& event);
82 void OnKillFocus(wxFocusEvent& event);
83
84 static bool ms_logKey;
85 static bool ms_logChar;
86 static bool ms_logMouse;
87 static bool ms_logText;
88 static bool ms_logFocus;
89
90 private:
91 static inline wxChar GetChar(bool on, wxChar c) { return on ? c : _T('-'); }
92 void LogKeyEvent(const wxChar *name, wxKeyEvent& event) const;
93
94 bool m_hasCapture;
95
96 DECLARE_EVENT_TABLE()
97 };
98
99 class MyPanel: public wxPanel
100 {
101 public:
102 MyPanel(wxFrame *frame, int x, int y, int w, int h);
103 virtual ~MyPanel() { delete wxLog::SetActiveTarget(m_logOld); }
104
105 #if wxUSE_CLIPBOARD
106 void DoPasteFromClipboard();
107 void DoCopyToClipboard();
108 #endif // wxUSE_CLIPBOARD
109
110 void DoRemoveText();
111 void DoMoveToEndOfText();
112 void DoMoveToEndOfEntry();
113
114 void OnSize( wxSizeEvent &event );
115
116 MyTextCtrl *m_text;
117 MyTextCtrl *m_password;
118 MyTextCtrl *m_enter;
119 MyTextCtrl *m_tab;
120 MyTextCtrl *m_readonly;
121 MyTextCtrl *m_limited;
122
123 MyTextCtrl *m_multitext;
124 MyTextCtrl *m_horizontal;
125
126 MyTextCtrl *m_textrich;
127
128 wxTextCtrl *m_log;
129
130 wxLog *m_logOld;
131
132 private:
133 // get the currently focused text control or return the default one is no
134 // text ctrl has focus
135 wxTextCtrl *GetFocusedText(wxTextCtrl *textDef);
136
137 DECLARE_EVENT_TABLE()
138 };
139
140 class MyFrame: public wxFrame
141 {
142 public:
143 MyFrame(wxFrame *frame, const wxChar *title, int x, int y, int w, int h);
144
145 void OnQuit(wxCommandEvent& event);
146 void OnAbout(wxCommandEvent& event);
147 #if wxUSE_TOOLTIPS
148 void OnSetTooltipDelay(wxCommandEvent& event);
149 void OnToggleTooltips(wxCommandEvent& event);
150 #endif // wxUSE_TOOLTIPS
151
152 #if wxUSE_CLIPBOARD
153 void OnPasteFromClipboard( wxCommandEvent &event )
154 { m_panel->DoPasteFromClipboard(); }
155 void OnCopyToClipboard( wxCommandEvent &event )
156 { m_panel->DoCopyToClipboard(); }
157 #endif // wxUSE_CLIPBOARD
158
159 void OnAddTextFreeze( wxCommandEvent& event )
160 { DoAddText(true); }
161 void OnAddText( wxCommandEvent& event )
162 { DoAddText(false); }
163 void OnRemoveText( wxCommandEvent& event )
164 { m_panel->DoRemoveText(); }
165
166 void OnMoveToEndOfText( wxCommandEvent &event )
167 { m_panel->DoMoveToEndOfText(); }
168 void OnMoveToEndOfEntry( wxCommandEvent &event )
169 { m_panel->DoMoveToEndOfEntry(); }
170
171 void OnScrollLineDown(wxCommandEvent& event)
172 {
173 if ( !m_panel->m_textrich->LineDown() )
174 wxLogMessage(_T("Already at the bottom"));
175 }
176
177 void OnScrollLineUp(wxCommandEvent& event)
178 {
179 if ( !m_panel->m_textrich->LineUp() )
180 wxLogMessage(_T("Already at the top"));
181 }
182
183 void OnScrollPageDown(wxCommandEvent& event)
184 {
185 if ( !m_panel->m_textrich->PageDown() )
186 wxLogMessage(_T("Already at the bottom"));
187 }
188
189 void OnScrollPageUp(wxCommandEvent& event)
190 {
191 if ( !m_panel->m_textrich->PageUp() )
192 wxLogMessage(_T("Already at the top"));
193 }
194
195 void OnLogClear(wxCommandEvent& event);
196 void OnFileSave(wxCommandEvent& event);
197 void OnFileLoad(wxCommandEvent& event);
198
199 void OnSetEditable(wxCommandEvent& event);
200 void OnSetEnabled(wxCommandEvent& event);
201
202 void OnLogKey(wxCommandEvent& event)
203 {
204 MyTextCtrl::ms_logKey = event.IsChecked();
205 }
206
207 void OnLogChar(wxCommandEvent& event)
208 {
209 MyTextCtrl::ms_logChar = event.IsChecked();
210 }
211
212 void OnLogMouse(wxCommandEvent& event)
213 {
214 MyTextCtrl::ms_logMouse = event.IsChecked();
215 }
216
217 void OnLogText(wxCommandEvent& event)
218 {
219 MyTextCtrl::ms_logText = event.IsChecked();
220 }
221
222 void OnLogFocus(wxCommandEvent& event)
223 {
224 MyTextCtrl::ms_logFocus = event.IsChecked();
225 }
226
227 void OnSetText(wxCommandEvent& event)
228 {
229 m_panel->m_text->SetValue(_T("Hello, world (what else did you expect)?"));
230 }
231
232 void OnIdle( wxIdleEvent& event );
233
234 private:
235 void DoAddText(bool freeze)
236 {
237 wxTextCtrl *text = m_panel->m_textrich;
238 if ( freeze )
239 text->Freeze();
240
241 text->Clear();
242
243 wxProgressDialog dlg(_T("Wait..."), _T("Updating"), 100, this);
244 for ( int i = 0; i < 100; i++ )
245 {
246 dlg.Update(i);
247 text->AppendText(wxString::Format(wxT("Line %i\n"), i));
248 }
249
250 text->SetInsertionPoint(0);
251
252 if ( freeze )
253 text->Thaw();
254 }
255
256 MyPanel *m_panel;
257
258 DECLARE_EVENT_TABLE()
259 };
260
261 //----------------------------------------------------------------------
262 // main()
263 //----------------------------------------------------------------------
264
265 IMPLEMENT_APP(MyApp)
266
267 //----------------------------------------------------------------------
268 // MyApp
269 //----------------------------------------------------------------------
270
271 enum
272 {
273 TEXT_QUIT = 100,
274 TEXT_ABOUT,
275 TEXT_LOAD,
276 TEXT_SAVE,
277 TEXT_CLEAR,
278
279 // clipboard menu
280 TEXT_CLIPBOARD_COPY = 200,
281 TEXT_CLIPBOARD_PASTE,
282
283 // tooltip menu
284 TEXT_TOOLTIPS_SETDELAY = 300,
285 TEXT_TOOLTIPS_ENABLE,
286
287 // text menu
288 TEXT_ADD_SOME = 400,
289 TEXT_ADD_FREEZE,
290 TEXT_MOVE_ENDTEXT,
291 TEXT_MOVE_ENDENTRY,
292 TEXT_SET_EDITABLE,
293 TEXT_SET_ENABLED,
294 TEXT_LINE_DOWN,
295 TEXT_LINE_UP,
296 TEXT_PAGE_DOWN,
297 TEXT_PAGE_UP,
298 TEXT_REMOVE,
299 TEXT_SET,
300
301 // log menu
302 TEXT_LOG_KEY,
303 TEXT_LOG_CHAR,
304 TEXT_LOG_MOUSE,
305 TEXT_LOG_TEXT,
306 TEXT_LOG_FOCUS,
307
308 TEXT_END
309 };
310
311 bool MyApp::OnInit()
312 {
313 // Create the main frame window
314 MyFrame *frame = new MyFrame((wxFrame *) NULL,
315 _T("Text wxWindows sample"), 50, 50, 700, 420);
316 frame->SetSizeHints( 500, 400 );
317
318 wxMenu *file_menu = new wxMenu;
319 file_menu->Append(TEXT_SAVE, _T("&Save file\tCtrl-S"),
320 _T("Save the text control contents to file"));
321 file_menu->Append(TEXT_LOAD, _T("&Load file\tCtrl-O"),
322 _T("Load the sample file into text control"));
323 file_menu->AppendSeparator();
324 file_menu->Append(TEXT_ABOUT, _T("&About\tAlt-A"));
325 file_menu->AppendSeparator();
326 file_menu->Append(TEXT_QUIT, _T("E&xit\tAlt-X"), _T("Quit this sample"));
327
328 wxMenuBar *menu_bar = new wxMenuBar( wxMB_DOCKABLE );
329 menu_bar->Append(file_menu, _T("&File"));
330
331 #if wxUSE_TOOLTIPS
332 wxMenu *tooltip_menu = new wxMenu;
333 tooltip_menu->Append(TEXT_TOOLTIPS_SETDELAY, _T("Set &delay\tCtrl-D"));
334 tooltip_menu->AppendSeparator();
335 tooltip_menu->Append(TEXT_TOOLTIPS_ENABLE, _T("&Toggle tooltips\tCtrl-T"),
336 _T("enable/disable tooltips"), TRUE);
337 tooltip_menu->Check(TEXT_TOOLTIPS_ENABLE, TRUE);
338 menu_bar->Append(tooltip_menu, _T("&Tooltips"));
339 #endif // wxUSE_TOOLTIPS
340
341 #if wxUSE_CLIPBOARD
342 wxMenu *menuClipboard = new wxMenu;
343 menuClipboard->Append(TEXT_CLIPBOARD_COPY, _T("&Copy\tCtrl-C"),
344 _T("Copy the first line to the clipboard"));
345 menuClipboard->Append(TEXT_CLIPBOARD_PASTE, _T("&Paste\tCtrl-V"),
346 _T("Paste from clipboard to the text control"));
347 menu_bar->Append(menuClipboard, _T("&Clipboard"));
348 #endif // wxUSE_CLIPBOARD
349
350 wxMenu *menuText = new wxMenu;
351 menuText->Append(TEXT_ADD_SOME, _T("&Append some text\tCtrl-A"));
352 menuText->Append(TEXT_ADD_FREEZE, _T("&Append text with freeze/thaw\tShift-Ctrl-A"));
353 menuText->Append(TEXT_REMOVE, _T("&Remove first 10 characters\tCtrl-X"));
354 menuText->Append(TEXT_SET, _T("&Set the first text zone value\tCtrl-E"));
355 menuText->AppendSeparator();
356 menuText->Append(TEXT_MOVE_ENDTEXT, _T("Move cursor to the end of &text"));
357 menuText->Append(TEXT_MOVE_ENDENTRY, _T("Move cursor to the end of &entry"));
358 menuText->Append(TEXT_SET_EDITABLE, _T("Toggle &editable state"), _T(""), TRUE);
359 menuText->Append(TEXT_SET_ENABLED, _T("Toggle e&nabled state"), _T(""), TRUE);
360 menuText->Check(TEXT_SET_EDITABLE, TRUE);
361 menuText->Check(TEXT_SET_ENABLED, TRUE);
362 menuText->AppendSeparator();
363 menuText->Append(TEXT_LINE_DOWN, _T("Scroll text one line down"));
364 menuText->Append(TEXT_LINE_UP, _T("Scroll text one line up"));
365 menuText->Append(TEXT_PAGE_DOWN, _T("Scroll text one page down"));
366 menuText->Append(TEXT_PAGE_DOWN, _T("Scroll text one page up"));
367 menu_bar->Append(menuText, _T("Te&xt"));
368
369 wxMenu *menuLog = new wxMenu;
370 menuLog->Append(TEXT_LOG_KEY, _T("Log &key events"), _T(""), TRUE);
371 menuLog->Append(TEXT_LOG_CHAR, _T("Log &char events"), _T(""), TRUE);
372 menuLog->Append(TEXT_LOG_MOUSE, _T("Log &mouse events"), _T(""), TRUE);
373 menuLog->Append(TEXT_LOG_TEXT, _T("Log &text events"), _T(""), TRUE);
374 menuLog->Append(TEXT_LOG_FOCUS, _T("Log &focus events"), _T(""), TRUE);
375 menuLog->AppendSeparator();
376 menuLog->Append(TEXT_CLEAR, _T("&Clear the log\tCtrl-C"),
377 _T("Clear the log window contents"));
378
379 // select only the interesting events by default
380 menuLog->Check(TEXT_LOG_KEY, TRUE);
381 menuLog->Check(TEXT_LOG_CHAR, TRUE);
382 menuLog->Check(TEXT_LOG_TEXT, TRUE);
383
384 MyTextCtrl::ms_logKey =
385 MyTextCtrl::ms_logChar =
386 MyTextCtrl::ms_logText = TRUE;
387 menu_bar->Append(menuLog, _T("&Log"));
388
389 frame->SetMenuBar(menu_bar);
390
391 frame->Show(TRUE);
392
393 SetTopWindow(frame);
394
395 // report success
396 return TRUE;
397 }
398
399 //----------------------------------------------------------------------
400 // MyTextCtrl
401 //----------------------------------------------------------------------
402
403 BEGIN_EVENT_TABLE(MyTextCtrl, wxTextCtrl)
404 EVT_KEY_DOWN(MyTextCtrl::OnKeyDown)
405 EVT_KEY_UP(MyTextCtrl::OnKeyUp)
406 EVT_CHAR(MyTextCtrl::OnChar)
407
408 EVT_TEXT(-1, MyTextCtrl::OnText)
409 EVT_TEXT_URL(-1, MyTextCtrl::OnTextURL)
410 EVT_TEXT_MAXLEN(-1, MyTextCtrl::OnTextMaxLen)
411
412 EVT_MOUSE_EVENTS(MyTextCtrl::OnMouseEvent)
413
414 EVT_SET_FOCUS(MyTextCtrl::OnSetFocus)
415 EVT_KILL_FOCUS(MyTextCtrl::OnKillFocus)
416 END_EVENT_TABLE()
417
418 bool MyTextCtrl::ms_logKey = FALSE;
419 bool MyTextCtrl::ms_logChar = FALSE;
420 bool MyTextCtrl::ms_logMouse = FALSE;
421 bool MyTextCtrl::ms_logText = FALSE;
422 bool MyTextCtrl::ms_logFocus = FALSE;
423
424 void MyTextCtrl::LogKeyEvent(const wxChar *name, wxKeyEvent& event) const
425 {
426 wxString key;
427 long keycode = event.KeyCode();
428 {
429 switch ( keycode )
430 {
431 case WXK_BACK: key = _T("BACK"); break;
432 case WXK_TAB: key = _T("TAB"); break;
433 case WXK_RETURN: key = _T("RETURN"); break;
434 case WXK_ESCAPE: key = _T("ESCAPE"); break;
435 case WXK_SPACE: key = _T("SPACE"); break;
436 case WXK_DELETE: key = _T("DELETE"); break;
437 case WXK_START: key = _T("START"); break;
438 case WXK_LBUTTON: key = _T("LBUTTON"); break;
439 case WXK_RBUTTON: key = _T("RBUTTON"); break;
440 case WXK_CANCEL: key = _T("CANCEL"); break;
441 case WXK_MBUTTON: key = _T("MBUTTON"); break;
442 case WXK_CLEAR: key = _T("CLEAR"); break;
443 case WXK_SHIFT: key = _T("SHIFT"); break;
444 case WXK_ALT: key = _T("ALT"); break;
445 case WXK_CONTROL: key = _T("CONTROL"); break;
446 case WXK_MENU: key = _T("MENU"); break;
447 case WXK_PAUSE: key = _T("PAUSE"); break;
448 case WXK_CAPITAL: key = _T("CAPITAL"); break;
449 case WXK_PRIOR: key = _T("PRIOR"); break;
450 case WXK_NEXT: key = _T("NEXT"); break;
451 case WXK_END: key = _T("END"); break;
452 case WXK_HOME: key = _T("HOME"); break;
453 case WXK_LEFT: key = _T("LEFT"); break;
454 case WXK_UP: key = _T("UP"); break;
455 case WXK_RIGHT: key = _T("RIGHT"); break;
456 case WXK_DOWN: key = _T("DOWN"); break;
457 case WXK_SELECT: key = _T("SELECT"); break;
458 case WXK_PRINT: key = _T("PRINT"); break;
459 case WXK_EXECUTE: key = _T("EXECUTE"); break;
460 case WXK_SNAPSHOT: key = _T("SNAPSHOT"); break;
461 case WXK_INSERT: key = _T("INSERT"); break;
462 case WXK_HELP: key = _T("HELP"); break;
463 case WXK_NUMPAD0: key = _T("NUMPAD0"); break;
464 case WXK_NUMPAD1: key = _T("NUMPAD1"); break;
465 case WXK_NUMPAD2: key = _T("NUMPAD2"); break;
466 case WXK_NUMPAD3: key = _T("NUMPAD3"); break;
467 case WXK_NUMPAD4: key = _T("NUMPAD4"); break;
468 case WXK_NUMPAD5: key = _T("NUMPAD5"); break;
469 case WXK_NUMPAD6: key = _T("NUMPAD6"); break;
470 case WXK_NUMPAD7: key = _T("NUMPAD7"); break;
471 case WXK_NUMPAD8: key = _T("NUMPAD8"); break;
472 case WXK_NUMPAD9: key = _T("NUMPAD9"); break;
473 case WXK_MULTIPLY: key = _T("MULTIPLY"); break;
474 case WXK_ADD: key = _T("ADD"); break;
475 case WXK_SEPARATOR: key = _T("SEPARATOR"); break;
476 case WXK_SUBTRACT: key = _T("SUBTRACT"); break;
477 case WXK_DECIMAL: key = _T("DECIMAL"); break;
478 case WXK_DIVIDE: key = _T("DIVIDE"); break;
479 case WXK_F1: key = _T("F1"); break;
480 case WXK_F2: key = _T("F2"); break;
481 case WXK_F3: key = _T("F3"); break;
482 case WXK_F4: key = _T("F4"); break;
483 case WXK_F5: key = _T("F5"); break;
484 case WXK_F6: key = _T("F6"); break;
485 case WXK_F7: key = _T("F7"); break;
486 case WXK_F8: key = _T("F8"); break;
487 case WXK_F9: key = _T("F9"); break;
488 case WXK_F10: key = _T("F10"); break;
489 case WXK_F11: key = _T("F11"); break;
490 case WXK_F12: key = _T("F12"); break;
491 case WXK_F13: key = _T("F13"); break;
492 case WXK_F14: key = _T("F14"); break;
493 case WXK_F15: key = _T("F15"); break;
494 case WXK_F16: key = _T("F16"); break;
495 case WXK_F17: key = _T("F17"); break;
496 case WXK_F18: key = _T("F18"); break;
497 case WXK_F19: key = _T("F19"); break;
498 case WXK_F20: key = _T("F20"); break;
499 case WXK_F21: key = _T("F21"); break;
500 case WXK_F22: key = _T("F22"); break;
501 case WXK_F23: key = _T("F23"); break;
502 case WXK_F24: key = _T("F24"); break;
503 case WXK_NUMLOCK: key = _T("NUMLOCK"); break;
504 case WXK_SCROLL: key = _T("SCROLL"); break;
505 case WXK_PAGEUP: key = _T("PAGEUP"); break;
506 case WXK_PAGEDOWN: key = _T("PAGEDOWN"); break;
507 case WXK_NUMPAD_SPACE: key = _T("NUMPAD_SPACE"); break;
508 case WXK_NUMPAD_TAB: key = _T("NUMPAD_TAB"); break;
509 case WXK_NUMPAD_ENTER: key = _T("NUMPAD_ENTER"); break;
510 case WXK_NUMPAD_F1: key = _T("NUMPAD_F1"); break;
511 case WXK_NUMPAD_F2: key = _T("NUMPAD_F2"); break;
512 case WXK_NUMPAD_F3: key = _T("NUMPAD_F3"); break;
513 case WXK_NUMPAD_F4: key = _T("NUMPAD_F4"); break;
514 case WXK_NUMPAD_HOME: key = _T("NUMPAD_HOME"); break;
515 case WXK_NUMPAD_LEFT: key = _T("NUMPAD_LEFT"); break;
516 case WXK_NUMPAD_UP: key = _T("NUMPAD_UP"); break;
517 case WXK_NUMPAD_RIGHT: key = _T("NUMPAD_RIGHT"); break;
518 case WXK_NUMPAD_DOWN: key = _T("NUMPAD_DOWN"); break;
519 case WXK_NUMPAD_PRIOR: key = _T("NUMPAD_PRIOR"); break;
520 case WXK_NUMPAD_PAGEUP: key = _T("NUMPAD_PAGEUP"); break;
521 case WXK_NUMPAD_PAGEDOWN: key = _T("NUMPAD_PAGEDOWN"); break;
522 case WXK_NUMPAD_END: key = _T("NUMPAD_END"); break;
523 case WXK_NUMPAD_BEGIN: key = _T("NUMPAD_BEGIN"); break;
524 case WXK_NUMPAD_INSERT: key = _T("NUMPAD_INSERT"); break;
525 case WXK_NUMPAD_DELETE: key = _T("NUMPAD_DELETE"); break;
526 case WXK_NUMPAD_EQUAL: key = _T("NUMPAD_EQUAL"); break;
527 case WXK_NUMPAD_MULTIPLY: key = _T("NUMPAD_MULTIPLY"); break;
528 case WXK_NUMPAD_ADD: key = _T("NUMPAD_ADD"); break;
529 case WXK_NUMPAD_SEPARATOR: key = _T("NUMPAD_SEPARATOR"); break;
530 case WXK_NUMPAD_SUBTRACT: key = _T("NUMPAD_SUBTRACT"); break;
531 case WXK_NUMPAD_DECIMAL: key = _T("NUMPAD_DECIMAL"); break;
532
533 default:
534 {
535 if ( wxIsprint((int)keycode) )
536 key.Printf(_T("'%c'"), (char)keycode);
537 else if ( keycode > 0 && keycode < 27 )
538 key.Printf(_("Ctrl-%c"), _T('A') + keycode - 1);
539 else
540 key.Printf(_T("unknown (%ld)"), keycode);
541 }
542 }
543 }
544
545 wxLogMessage( _T("%s event: %s (flags = %c%c%c%c)"),
546 name,
547 key.c_str(),
548 GetChar( event.ControlDown(), _T('C') ),
549 GetChar( event.AltDown(), _T('A') ),
550 GetChar( event.ShiftDown(), _T('S') ),
551 GetChar( event.MetaDown(), _T('M') ) );
552 }
553
554 static wxString GetMouseEventDesc(const wxMouseEvent& ev)
555 {
556 // click event
557 wxString button;
558 bool dbl, up;
559 if ( ev.LeftDown() || ev.LeftUp() || ev.LeftDClick() )
560 {
561 button = _T("Left");
562 dbl = ev.LeftDClick();
563 up = ev.LeftUp();
564 }
565 else if ( ev.MiddleDown() || ev.MiddleUp() || ev.MiddleDClick() )
566 {
567 button = _T("Middle");
568 dbl = ev.MiddleDClick();
569 up = ev.MiddleUp();
570 }
571 else if ( ev.RightDown() || ev.RightUp() || ev.RightDClick() )
572 {
573 button = _T("Right");
574 dbl = ev.RightDClick();
575 up = ev.RightUp();
576 }
577 else
578 {
579 return _T("Unknown mouse event");
580 }
581
582 return wxString::Format(_T("%s mouse button %s"),
583 button.c_str(),
584 dbl ? _T("double clicked")
585 : up ? _T("released") : _T("clicked"));
586 }
587
588 void MyTextCtrl::OnMouseEvent(wxMouseEvent& ev)
589 {
590 ev.Skip();
591
592 if ( !ms_logMouse )
593 return;
594
595 if ( !ev.Moving() )
596 {
597 wxString msg;
598 if ( ev.Entering() )
599 {
600 msg = _T("Mouse entered the window");
601 }
602 else if ( ev.Leaving() )
603 {
604 msg = _T("Mouse left the window");
605 }
606 else
607 {
608 msg = GetMouseEventDesc(ev);
609 }
610
611 msg << _T(" at (") << ev.GetX() << _T(", ") << ev.GetY() << _T(") ")
612 << _T("Flags: ")
613 << GetChar( ev.LeftIsDown(), _T('1') )
614 << GetChar( ev.MiddleIsDown(), _T('2') )
615 << GetChar( ev.RightIsDown(), _T('3') )
616 << GetChar( ev.ControlDown(), _T('C') )
617 << GetChar( ev.AltDown(), _T('A') )
618 << GetChar( ev.ShiftDown(), _T('S') )
619 << GetChar( ev.MetaDown(), _T('M') );
620
621 wxLogMessage(msg);
622 }
623 //else: we're not interested in mouse move events
624 }
625
626 void MyTextCtrl::OnSetFocus(wxFocusEvent& event)
627 {
628 if ( ms_logFocus )
629 wxLogMessage( wxT("%p got focus."), this);
630
631 event.Skip();
632 }
633
634 void MyTextCtrl::OnKillFocus(wxFocusEvent& event)
635 {
636 if ( ms_logFocus )
637 wxLogMessage( wxT("%p lost focus"), this);
638
639 event.Skip();
640 }
641
642 void MyTextCtrl::OnText(wxCommandEvent& event)
643 {
644 if ( !ms_logText )
645 return;
646
647 MyTextCtrl *win = (MyTextCtrl *)event.GetEventObject();
648 const wxChar *data = (const wxChar *)(win->GetClientData());
649 if ( data )
650 {
651 wxLogMessage(_T("Text changed in control '%s'"), data);
652 }
653 else
654 {
655 // wxLogMessage( event.GetString() );
656 wxLogMessage(_T("Text changed in some control"));
657 }
658 }
659
660 void MyTextCtrl::OnTextMaxLen(wxCommandEvent& event)
661 {
662 wxLogMessage(_T("You can't enter more characters into this control."));
663 }
664
665 void MyTextCtrl::OnTextURL(wxTextUrlEvent& event)
666 {
667 const wxMouseEvent& ev = event.GetMouseEvent();
668
669 // filter out mouse moves, too many of them
670 if ( ev.Moving() )
671 return;
672
673 long start = event.GetURLStart(),
674 end = event.GetURLEnd();
675
676 wxLogMessage(_T("Mouse event over URL '%s': %s"),
677 GetValue().Mid(start, end - start).c_str(),
678 GetMouseEventDesc(ev).c_str());
679 }
680
681 void MyTextCtrl::OnChar(wxKeyEvent& event)
682 {
683 if ( ms_logChar )
684 LogKeyEvent( _T("Char"), event);
685
686 event.Skip();
687 }
688
689 void MyTextCtrl::OnKeyUp(wxKeyEvent& event)
690 {
691 if ( ms_logKey )
692 LogKeyEvent( _T("Key up"), event);
693
694 event.Skip();
695 }
696
697 void MyTextCtrl::OnKeyDown(wxKeyEvent& event)
698 {
699 switch ( event.KeyCode() )
700 {
701 case WXK_F1:
702 // show current position and text length
703 {
704 long line, column, pos = GetInsertionPoint();
705 PositionToXY(pos, &column, &line);
706
707 wxLogMessage(_T("Current position: %ld\nCurrent line, column: (%ld, %ld)\nNumber of lines: %ld\nCurrent line length: %ld\nTotal text length: %u (%ld)"),
708 pos,
709 line, column,
710 (long) GetNumberOfLines(),
711 (long) GetLineLength(line),
712 GetValue().length(),
713 GetLastPosition());
714
715 long from, to;
716 GetSelection(&from, &to);
717
718 wxString sel = GetStringSelection();
719
720 wxLogMessage(_T("Selection: from %ld to %ld."), from, to);
721 wxLogMessage(_T("Selection = '%s' (len = %u)"),
722 sel.c_str(), sel.length());
723 }
724 break;
725
726 case WXK_F2:
727 // go to the end
728 SetInsertionPointEnd();
729 break;
730
731 case WXK_F3:
732 // go to position 10
733 SetInsertionPoint(10);
734 break;
735
736 case WXK_F4:
737 if (!m_hasCapture)
738 {
739 wxLogDebug( wxT("Now capturing mouse and events.") );
740 m_hasCapture = TRUE;
741 CaptureMouse();
742 }
743 else
744 {
745 wxLogDebug( wxT("Stopped capturing mouse and events.") );
746 m_hasCapture = FALSE;
747 ReleaseMouse();
748 }
749 break;
750
751 case WXK_F5:
752 // insert a blank line
753 WriteText(_T("\n"));
754 break;
755
756 case WXK_F6:
757 wxLogMessage(_T("IsModified() before SetValue(): %d"),
758 IsModified());
759 SetValue(_T("SetValue() has been called"));
760 wxLogMessage(_T("IsModified() after SetValue(): %d"),
761 IsModified());
762 break;
763
764 case WXK_F7:
765 wxLogMessage(_T("Position 10 should be now visible."));
766 ShowPosition(10);
767 break;
768
769 case WXK_F8:
770 wxLogMessage(_T("Control has been cleared"));
771 Clear();
772 break;
773
774 case WXK_F9:
775 WriteText(_T("WriteText() has been called"));
776 break;
777
778 case WXK_F10:
779 AppendText(_T("AppendText() has been called"));
780 break;
781 }
782
783 if ( ms_logKey )
784 LogKeyEvent( wxT("Key down"), event);
785
786 event.Skip();
787 }
788
789 //----------------------------------------------------------------------
790 // MyPanel
791 //----------------------------------------------------------------------
792
793 BEGIN_EVENT_TABLE(MyPanel, wxPanel)
794 EVT_SIZE(MyPanel::OnSize)
795 END_EVENT_TABLE()
796
797 MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
798 : wxPanel( frame, -1, wxPoint(x, y), wxSize(w, h) )
799 {
800 m_log = new wxTextCtrl( this, -1, _T("This is the log window.\n"),
801 wxPoint(5,260), wxSize(630,100),
802 wxTE_MULTILINE | wxTE_READONLY /* | wxTE_RICH */);
803
804 m_logOld = wxLog::SetActiveTarget( new wxLogTextCtrl( m_log ) );
805
806 // single line text controls
807
808 m_text = new MyTextCtrl( this, -1, _T("Single line."),
809 wxPoint(10,10), wxSize(140,-1),
810 wxTE_PROCESS_ENTER);
811 m_text->SetForegroundColour(*wxBLUE);
812 m_text->SetBackgroundColour(*wxLIGHT_GREY);
813 (*m_text) << _T(" Appended.");
814 m_text->SetInsertionPoint(0);
815 m_text->WriteText( _T("Prepended. ") );
816
817 m_password = new MyTextCtrl( this, -1, _T(""),
818 wxPoint(10,50), wxSize(140,-1), wxTE_PASSWORD );
819
820 m_readonly = new MyTextCtrl( this, -1, _T("Read only"),
821 wxPoint(10,90), wxSize(140,-1), wxTE_READONLY );
822
823 m_limited = new MyTextCtrl(this, -1, _T("Max 8 ch"),
824 wxPoint(10, 130), wxSize(140, -1));
825 m_limited->SetMaxLength(8);
826
827 // multi line text controls
828
829 m_horizontal = new MyTextCtrl( this, -1, _T("Multiline text control with a horizontal scrollbar."),
830 wxPoint(10,170), wxSize(140,70), wxTE_MULTILINE | wxHSCROLL );
831
832 // a little hack to use the command line argument for encoding testing
833 if ( wxTheApp->argc == 2 )
834 {
835 switch ( wxTheApp->argv[1][0] )
836 {
837 case '2':
838 m_horizontal->SetFont(wxFont(18, wxSWISS, wxNORMAL, wxNORMAL,
839 FALSE, _T(""),
840 wxFONTENCODING_ISO8859_2));
841 m_horizontal->SetValue(_T("®lu»ouèký kùò zbìsile èe¹tina «»"));
842 break;
843
844 case '1':
845 m_horizontal->SetFont(wxFont(18, wxSWISS, wxNORMAL, wxNORMAL,
846 FALSE, _T(""),
847 wxFONTENCODING_CP1251));
848 m_horizontal->SetValue(_T("Ïðèâåò!"));
849 break;
850
851 case '8':
852 m_horizontal->SetFont(wxFont(18, wxSWISS, wxNORMAL, wxNORMAL,
853 FALSE, _T(""),
854 wxFONTENCODING_CP1251));
855 #if wxUSE_UNICODE
856 m_horizontal->SetValue(L"\x0412\x0430\x0434\x0438\x043c \x0426");
857 #else
858 m_horizontal->SetValue("ËÁÖÅÔÓÑ ÕÄÁÞÎÙÍ");
859 #endif
860 }
861 }
862 else
863 {
864 m_horizontal->SetValue(_T("Text in default encoding"));
865 }
866
867 m_multitext = new MyTextCtrl( this, -1, _T("Multi line."),
868 wxPoint(180,10), wxSize(240,70), wxTE_MULTILINE );
869 m_multitext->SetFont(*wxITALIC_FONT);
870 (*m_multitext) << _T(" Appended.");
871 m_multitext->SetInsertionPoint(0);
872 m_multitext->WriteText( _T("Prepended. ") );
873 m_multitext->SetForegroundColour(*wxRED);
874 m_multitext->SetBackgroundColour(*wxLIGHT_GREY);
875
876 #if wxUSE_TOOLTIPS
877 m_multitext->SetToolTip(_T("Press Fn function keys here"));
878 #endif
879
880 m_tab = new MyTextCtrl( this, 100, _T("Multiline, allow <TAB> processing."),
881 wxPoint(180,90), wxSize(240,70), wxTE_MULTILINE | wxTE_PROCESS_TAB );
882 m_tab->SetClientData((void *)_T("tab"));
883
884 m_enter = new MyTextCtrl( this, 100, _T("Multiline, allow <ENTER> processing."),
885 wxPoint(180,170), wxSize(240,70), wxTE_MULTILINE);
886 m_enter->SetClientData((void *)_T("enter"));
887
888 m_textrich = new MyTextCtrl(this, -1, _T("Allows more than 30Kb of text\n")
889 _T("(even under broken Win9x)\n")
890 _T("and a very very very very very ")
891 _T("very very very long line to test ")
892 _T("wxHSCROLL style"),
893 wxPoint(450, 10), wxSize(230, 230),
894 wxTE_RICH |
895 wxTE_MULTILINE |
896 // wxTE_AUTO_URL |
897 wxHSCROLL);
898
899 m_textrich->SetStyle(0, 10, *wxRED);
900 m_textrich->SetStyle(10, 20, *wxBLUE);
901 m_textrich->SetStyle(30, 40,
902 wxTextAttr(*wxGREEN, wxNullColour, *wxITALIC_FONT));
903 m_textrich->SetDefaultStyle(wxTextAttr());
904 m_textrich->AppendText(_T("\n\nFirst 10 characters should be in red\n"));
905 m_textrich->AppendText(_T("Next 10 characters should be in blue\n"));
906 m_textrich->AppendText(_T("Next 10 characters should be normal\n"));
907 m_textrich->AppendText(_T("And the next 10 characters should be green and italic\n"));
908 m_textrich->SetDefaultStyle(wxTextAttr(*wxCYAN, *wxBLUE));
909 m_textrich->AppendText(_T("This text should be cyan on blue\n"));
910 m_textrich->SetDefaultStyle(wxTextAttr(*wxBLUE, *wxWHITE));
911 m_textrich->AppendText(_T("And this should be in blue and the text you ")
912 _T("type should be in blue as well"));
913 }
914
915 void MyPanel::OnSize( wxSizeEvent &event )
916 {
917 wxSize client_area( GetClientSize() );
918 m_log->SetSize( 0, 260, client_area.x, client_area.y - 260 );
919 event.Skip();
920 }
921
922 wxTextCtrl *MyPanel::GetFocusedText(wxTextCtrl *textDef)
923 {
924 wxWindow *win = FindFocus();
925
926 wxTextCtrl *text = win ? wxDynamicCast(win, wxTextCtrl) : NULL;
927 return text ? text : textDef;
928 }
929
930 #if wxUSE_CLIPBOARD
931 void MyPanel::DoPasteFromClipboard()
932 {
933 // On X11, we want to get the data from the primary selection instead
934 // of the normal clipboard (which isn't normal under X11 at all). This
935 // call has no effect under MSW.
936 wxTheClipboard->UsePrimarySelection();
937
938 if (!wxTheClipboard->Open())
939 {
940 *m_log << _T("Error opening the clipboard.\n");
941 return;
942 }
943 else
944 {
945 *m_log << _T("Successfully opened the clipboard.\n");
946 }
947
948 wxTextDataObject data;
949
950 if (wxTheClipboard->IsSupported( data.GetFormat() ))
951 {
952 *m_log << _T("Clipboard supports requested format.\n");
953
954 if (wxTheClipboard->GetData( data ))
955 {
956 *m_log << _T("Successfully retrieved data from the clipboard.\n");
957 *m_multitext << data.GetText() << _T("\n");
958 }
959 else
960 {
961 *m_log << _T("Error getting data from the clipboard.\n");
962 }
963 }
964 else
965 {
966 *m_log << _T("Clipboard doesn't support requested format.\n");
967 }
968
969 wxTheClipboard->Close();
970
971 *m_log << _T("Closed the clipboard.\n");
972 }
973
974 void MyPanel::DoCopyToClipboard()
975 {
976 // On X11, we want to get the data from the primary selection instead
977 // of the normal clipboard (which isn't normal under X11 at all). This
978 // call has no effect under MSW.
979 wxTheClipboard->UsePrimarySelection();
980
981 wxString text( m_multitext->GetLineText(0) );
982
983 if (text.IsEmpty())
984 {
985 *m_log << _T("No text to copy.\n");
986
987 return;
988 }
989
990 if (!wxTheClipboard->Open())
991 {
992 *m_log << _T("Error opening the clipboard.\n");
993
994 return;
995 }
996 else
997 {
998 *m_log << _T("Successfully opened the clipboard.\n");
999 }
1000
1001 wxTextDataObject *data = new wxTextDataObject( text );
1002
1003 if (!wxTheClipboard->SetData( data ))
1004 {
1005 *m_log << _T("Error while copying to the clipboard.\n");
1006 }
1007 else
1008 {
1009 *m_log << _T("Successfully copied data to the clipboard.\n");
1010 }
1011
1012 wxTheClipboard->Close();
1013
1014 *m_log << _T("Closed the clipboard.\n");
1015 }
1016
1017 #endif // wxUSE_CLIPBOARD
1018
1019 void MyPanel::DoMoveToEndOfText()
1020 {
1021 m_multitext->SetInsertionPointEnd();
1022 m_multitext->SetFocus();
1023 }
1024
1025 void MyPanel::DoMoveToEndOfEntry()
1026 {
1027 m_text->SetInsertionPointEnd();
1028 m_text->SetFocus();
1029 }
1030
1031 void MyPanel::DoRemoveText()
1032 {
1033 GetFocusedText(m_multitext)->Remove(0, 10);
1034 }
1035
1036 //----------------------------------------------------------------------
1037 // MyFrame
1038 //----------------------------------------------------------------------
1039
1040 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
1041 EVT_MENU(TEXT_QUIT, MyFrame::OnQuit)
1042 EVT_MENU(TEXT_ABOUT, MyFrame::OnAbout)
1043 EVT_MENU(TEXT_SAVE, MyFrame::OnFileSave)
1044 EVT_MENU(TEXT_LOAD, MyFrame::OnFileLoad)
1045
1046 EVT_MENU(TEXT_LOG_KEY, MyFrame::OnLogKey)
1047 EVT_MENU(TEXT_LOG_CHAR, MyFrame::OnLogChar)
1048 EVT_MENU(TEXT_LOG_MOUSE,MyFrame::OnLogMouse)
1049 EVT_MENU(TEXT_LOG_TEXT, MyFrame::OnLogText)
1050 EVT_MENU(TEXT_LOG_FOCUS,MyFrame::OnLogFocus)
1051 EVT_MENU(TEXT_CLEAR, MyFrame::OnLogClear)
1052
1053 #if wxUSE_TOOLTIPS
1054 EVT_MENU(TEXT_TOOLTIPS_SETDELAY, MyFrame::OnSetTooltipDelay)
1055 EVT_MENU(TEXT_TOOLTIPS_ENABLE, MyFrame::OnToggleTooltips)
1056 #endif // wxUSE_TOOLTIPS
1057
1058 #if wxUSE_CLIPBOARD
1059 EVT_MENU(TEXT_CLIPBOARD_PASTE, MyFrame::OnPasteFromClipboard)
1060 EVT_MENU(TEXT_CLIPBOARD_COPY, MyFrame::OnCopyToClipboard)
1061 #endif // wxUSE_CLIPBOARD
1062
1063 EVT_MENU(TEXT_REMOVE, MyFrame::OnRemoveText)
1064 EVT_MENU(TEXT_ADD_SOME, MyFrame::OnAddText)
1065 EVT_MENU(TEXT_ADD_FREEZE, MyFrame::OnAddTextFreeze)
1066 EVT_MENU(TEXT_MOVE_ENDTEXT, MyFrame::OnMoveToEndOfText)
1067 EVT_MENU(TEXT_MOVE_ENDENTRY, MyFrame::OnMoveToEndOfEntry)
1068
1069 EVT_MENU(TEXT_SET_EDITABLE, MyFrame::OnSetEditable)
1070 EVT_MENU(TEXT_SET_ENABLED, MyFrame::OnSetEnabled)
1071
1072 EVT_MENU(TEXT_LINE_DOWN, MyFrame::OnScrollLineDown)
1073 EVT_MENU(TEXT_LINE_UP, MyFrame::OnScrollLineUp)
1074 EVT_MENU(TEXT_PAGE_DOWN, MyFrame::OnScrollPageDown)
1075 EVT_MENU(TEXT_PAGE_UP, MyFrame::OnScrollPageUp)
1076
1077 EVT_MENU(TEXT_SET, MyFrame::OnSetText)
1078
1079 EVT_IDLE(MyFrame::OnIdle)
1080 END_EVENT_TABLE()
1081
1082 MyFrame::MyFrame(wxFrame *frame, const wxChar *title, int x, int y, int w, int h)
1083 : wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h) )
1084 {
1085 CreateStatusBar(2);
1086
1087 m_panel = new MyPanel( this, 10, 10, 300, 100 );
1088 }
1089
1090 void MyFrame::OnQuit (wxCommandEvent& WXUNUSED(event) )
1091 {
1092 Close(TRUE);
1093 }
1094
1095 void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) )
1096 {
1097 wxBeginBusyCursor();
1098
1099 wxMessageDialog dialog(this,
1100 _T("This is a text control sample. It demonstrates the many different\n")
1101 _T("text control styles, the use of the clipboard, setting and handling\n")
1102 _T("tooltips and intercepting key and char events.\n")
1103 _T("\n")
1104 _T("Copyright (c) 1999, Robert Roebling, Julian Smart, Vadim Zeitlin"),
1105 _T("About wxTextCtrl Sample"),
1106 wxOK | wxICON_INFORMATION);
1107
1108 dialog.ShowModal();
1109
1110 wxEndBusyCursor();
1111 }
1112
1113 #if wxUSE_TOOLTIPS
1114 void MyFrame::OnSetTooltipDelay(wxCommandEvent& event)
1115 {
1116 static long s_delay = 5000;
1117
1118 wxString delay;
1119 delay.Printf( _T("%ld"), s_delay);
1120
1121 delay = wxGetTextFromUser(_T("Enter delay (in milliseconds)"),
1122 _T("Set tooltip delay"),
1123 delay,
1124 this);
1125 if ( !delay )
1126 return; // cancelled
1127
1128 wxSscanf(delay, _T("%ld"), &s_delay);
1129
1130 wxToolTip::SetDelay(s_delay);
1131
1132 wxLogStatus(this, _T("Tooltip delay set to %ld milliseconds"), s_delay);
1133 }
1134
1135 void MyFrame::OnToggleTooltips(wxCommandEvent& event)
1136 {
1137 static bool s_enabled = TRUE;
1138
1139 s_enabled = !s_enabled;
1140
1141 wxToolTip::Enable(s_enabled);
1142
1143 wxLogStatus(this, _T("Tooltips %sabled"), s_enabled ? _T("en") : _T("dis") );
1144 }
1145 #endif // tooltips
1146
1147 void MyFrame::OnLogClear(wxCommandEvent& WXUNUSED(event))
1148 {
1149 m_panel->m_log->Clear();
1150 }
1151
1152 void MyFrame::OnSetEditable(wxCommandEvent& WXUNUSED(event))
1153 {
1154 static bool s_editable = TRUE;
1155
1156 s_editable = !s_editable;
1157 m_panel->m_text->SetEditable(s_editable);
1158 m_panel->m_password->SetEditable(s_editable);
1159 m_panel->m_multitext->SetEditable(s_editable);
1160 m_panel->m_textrich->SetEditable(s_editable);
1161 }
1162
1163 void MyFrame::OnSetEnabled(wxCommandEvent& WXUNUSED(event))
1164 {
1165 bool enabled = m_panel->m_text->IsEnabled();
1166 enabled = !enabled;
1167
1168 m_panel->m_text->Enable(enabled);
1169 m_panel->m_password->Enable(enabled);
1170 m_panel->m_multitext->Enable(enabled);
1171 m_panel->m_readonly->Enable(enabled);
1172 m_panel->m_limited->Enable(enabled);
1173 m_panel->m_textrich->Enable(enabled);
1174 }
1175
1176 void MyFrame::OnFileSave(wxCommandEvent& event)
1177 {
1178 if ( m_panel->m_textrich->SaveFile(_T("dummy.txt")) )
1179 {
1180 #if wxUSE_FILE
1181 // verify that the fil length is correct (it wasn't under Win95)
1182 wxFile file(wxT("dummy.txt"));
1183 wxLogStatus(this,
1184 _T("Successfully saved file (text len = %lu, file size = %ld)"),
1185 (unsigned long)m_panel->m_textrich->GetValue().length(),
1186 (long) file.Length());
1187 #endif
1188 }
1189 else
1190 wxLogStatus(this, _T("Couldn't save the file"));
1191 }
1192
1193 void MyFrame::OnFileLoad(wxCommandEvent& event)
1194 {
1195 if ( m_panel->m_textrich->LoadFile(_T("dummy.txt")) )
1196 wxLogStatus(this, _T("Successfully loaded file"));
1197 else
1198 wxLogStatus(this, _T("Couldn't load the file"));
1199 }
1200
1201 void MyFrame::OnIdle( wxIdleEvent& event )
1202 {
1203 // track the window which has the focus in the status bar
1204 static wxWindow *s_windowFocus = (wxWindow *)NULL;
1205 wxWindow *focus = wxWindow::FindFocus();
1206 if ( focus && (focus != s_windowFocus) )
1207 {
1208 s_windowFocus = focus;
1209
1210 wxString msg;
1211 msg.Printf(
1212 #ifdef __WXMSW__
1213 _T("Focus: wxWindow = %p, HWND = %08x"),
1214 #else
1215 _T("Focus: wxWindow = %p"),
1216 #endif
1217 s_windowFocus
1218 #ifdef __WXMSW__
1219 , (unsigned int) s_windowFocus->GetHWND()
1220 #endif
1221 );
1222
1223 SetStatusText(msg);
1224 }
1225 event.Skip();
1226 }