]> git.saurik.com Git - wxWidgets.git/blob - src/common/wincmn.cpp
Added new dynamic loading classes. (which handle proper
[wxWidgets.git] / src / common / wincmn.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: common/window.cpp
3 // Purpose: common (to all ports) wxWindow functions
4 // Author: Julian Smart, Vadim Zeitlin
5 // Modified by:
6 // Created: 13/07/98
7 // RCS-ID: $Id$
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #ifdef __GNUG__
21 #pragma implementation "windowbase.h"
22 #endif
23
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
26
27 #ifdef __BORLANDC__
28 #pragma hdrstop
29 #endif
30
31 #ifndef WX_PRECOMP
32 #include "wx/string.h"
33 #include "wx/log.h"
34 #include "wx/intl.h"
35 #include "wx/frame.h"
36 #include "wx/defs.h"
37 #include "wx/window.h"
38 #include "wx/control.h"
39 #include "wx/checkbox.h"
40 #include "wx/radiobut.h"
41 #include "wx/textctrl.h"
42 #include "wx/settings.h"
43 #include "wx/dialog.h"
44 #include "wx/msgdlg.h"
45 #include "wx/statusbr.h"
46 #endif //WX_PRECOMP
47
48 #if wxUSE_CONSTRAINTS
49 #include "wx/layout.h"
50 #include "wx/sizer.h"
51 #endif // wxUSE_CONSTRAINTS
52
53 #if wxUSE_DRAG_AND_DROP
54 #include "wx/dnd.h"
55 #endif // wxUSE_DRAG_AND_DROP
56
57 #if wxUSE_HELP
58 #include "wx/cshelp.h"
59 #endif // wxUSE_HELP
60
61 #if wxUSE_TOOLTIPS
62 #include "wx/tooltip.h"
63 #endif // wxUSE_TOOLTIPS
64
65 #if wxUSE_CARET
66 #include "wx/caret.h"
67 #endif // wxUSE_CARET
68
69 // ----------------------------------------------------------------------------
70 // static data
71 // ----------------------------------------------------------------------------
72
73 int wxWindowBase::ms_lastControlId = -200;
74
75 IMPLEMENT_ABSTRACT_CLASS(wxWindowBase, wxEvtHandler)
76
77 // ----------------------------------------------------------------------------
78 // event table
79 // ----------------------------------------------------------------------------
80
81 BEGIN_EVENT_TABLE(wxWindowBase, wxEvtHandler)
82 EVT_SYS_COLOUR_CHANGED(wxWindowBase::OnSysColourChanged)
83 EVT_INIT_DIALOG(wxWindowBase::OnInitDialog)
84 EVT_MIDDLE_DOWN(wxWindowBase::OnMiddleClick)
85
86 #if wxUSE_HELP
87 EVT_HELP(-1, wxWindowBase::OnHelp)
88 #endif // wxUSE_HELP
89
90 END_EVENT_TABLE()
91
92 // ============================================================================
93 // implementation of the common functionality of the wxWindow class
94 // ============================================================================
95
96 // ----------------------------------------------------------------------------
97 // initialization
98 // ----------------------------------------------------------------------------
99
100 // the default initialization
101 void wxWindowBase::InitBase()
102 {
103 // no window yet, no parent nor children
104 m_parent = (wxWindow *)NULL;
105 m_windowId = -1;
106 m_children.DeleteContents( FALSE ); // don't auto delete node data
107
108 // no constraints on the minimal window size
109 m_minWidth =
110 m_minHeight =
111 m_maxWidth =
112 m_maxHeight = -1;
113
114 // window is created enabled but it's not visible yet
115 m_isShown = FALSE;
116 m_isEnabled = TRUE;
117
118 // the default event handler is just this window
119 m_eventHandler = this;
120
121 #if wxUSE_VALIDATORS
122 // no validator
123 m_windowValidator = (wxValidator *) NULL;
124 #endif // wxUSE_VALIDATORS
125
126 // use the system default colours
127 m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_BTNFACE);
128 m_foregroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOWTEXT);
129
130 // don't set the font here for wxMSW as we don't call WM_SETFONT here and
131 // so the font is *not* really set - but calls to SetFont() later won't do
132 // anything because m_font appears to be already set!
133 #ifndef __WXMSW__
134 m_font = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT);
135 #endif // __WXMSW__
136
137 // the colours/fonts are default for now
138 m_hasBgCol =
139 m_hasFgCol =
140 m_hasFont = FALSE;
141
142 // no style bits
143 m_exStyle =
144 m_windowStyle = 0;
145
146 // an optimization for the event processing: checking this flag is much
147 // faster than using IsKindOf(CLASSINFO(wxWindow))
148 m_isWindow = TRUE;
149
150 #if wxUSE_CONSTRAINTS
151 // no constraints whatsoever
152 m_constraints = (wxLayoutConstraints *) NULL;
153 m_constraintsInvolvedIn = (wxWindowList *) NULL;
154 m_windowSizer = (wxSizer *) NULL;
155 m_autoLayout = FALSE;
156 #endif // wxUSE_CONSTRAINTS
157
158 #if wxUSE_DRAG_AND_DROP
159 m_dropTarget = (wxDropTarget *)NULL;
160 #endif // wxUSE_DRAG_AND_DROP
161
162 #if wxUSE_TOOLTIPS
163 m_tooltip = (wxToolTip *)NULL;
164 #endif // wxUSE_TOOLTIPS
165
166 #if wxUSE_CARET
167 m_caret = (wxCaret *)NULL;
168 #endif // wxUSE_CARET
169
170 // Whether we're using the current theme for this window (wxGTK only for now)
171 m_themeEnabled = FALSE;
172 }
173
174 // common part of window creation process
175 bool wxWindowBase::CreateBase(wxWindowBase *parent,
176 wxWindowID id,
177 const wxPoint& WXUNUSED(pos),
178 const wxSize& WXUNUSED(size),
179 long style,
180 const wxValidator& validator,
181 const wxString& name)
182 {
183 // m_isWindow is set to TRUE in wxWindowBase::Init() as well as many other
184 // member variables - check that it has been called (will catch the case
185 // when a new ctor is added which doesn't call InitWindow)
186 wxASSERT_MSG( m_isWindow, wxT("Init() must have been called before!") );
187
188 // generate a new id if the user doesn't care about it
189 m_windowId = id == -1 ? NewControlId() : id;
190
191 SetName(name);
192 SetWindowStyleFlag(style);
193 SetParent(parent);
194
195 #if wxUSE_VALIDATORS
196 SetValidator(validator);
197 #endif // wxUSE_VALIDATORS
198
199 // if the parent window has wxWS_EX_VALIDATE_RECURSIVELY set, we want to
200 // have it too - like this it's possible to set it only in the top level
201 // dialog/frame and all children will inherit it by defult
202 if ( parent && (parent->GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY) )
203 {
204 SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY);
205 }
206
207 return TRUE;
208 }
209
210 // ----------------------------------------------------------------------------
211 // destruction
212 // ----------------------------------------------------------------------------
213
214 // common clean up
215 wxWindowBase::~wxWindowBase()
216 {
217 // FIXME if these 2 cases result from programming errors in the user code
218 // we should probably assert here instead of silently fixing them
219
220 // Just in case the window has been Closed, but we're then deleting
221 // immediately: don't leave dangling pointers.
222 wxPendingDelete.DeleteObject(this);
223
224 // Just in case we've loaded a top-level window via LoadNativeDialog but
225 // we weren't a dialog class
226 wxTopLevelWindows.DeleteObject(this);
227
228 wxASSERT_MSG( GetChildren().GetCount() == 0, wxT("children not destroyed") );
229
230 #if wxUSE_CARET
231 if ( m_caret )
232 delete m_caret;
233 #endif // wxUSE_CARET
234
235 #if wxUSE_VALIDATORS
236 if ( m_windowValidator )
237 delete m_windowValidator;
238 #endif // wxUSE_VALIDATORS
239
240 #if wxUSE_CONSTRAINTS
241 // Have to delete constraints/sizer FIRST otherwise sizers may try to look
242 // at deleted windows as they delete themselves.
243 DeleteRelatedConstraints();
244
245 if ( m_constraints )
246 {
247 // This removes any dangling pointers to this window in other windows'
248 // constraintsInvolvedIn lists.
249 UnsetConstraints(m_constraints);
250 delete m_constraints;
251 m_constraints = NULL;
252 }
253
254 if ( m_windowSizer )
255 delete m_windowSizer;
256
257 #endif // wxUSE_CONSTRAINTS
258
259 #if wxUSE_DRAG_AND_DROP
260 if ( m_dropTarget )
261 delete m_dropTarget;
262 #endif // wxUSE_DRAG_AND_DROP
263
264 #if wxUSE_TOOLTIPS
265 if ( m_tooltip )
266 delete m_tooltip;
267 #endif // wxUSE_TOOLTIPS
268
269 // reset the dangling pointer our parent window may keep to us
270 if ( m_parent && m_parent->GetDefaultItem() == this )
271 {
272 m_parent->SetDefaultItem(NULL);
273 }
274 }
275
276 bool wxWindowBase::Destroy()
277 {
278 delete this;
279
280 return TRUE;
281 }
282
283 bool wxWindowBase::Close(bool force)
284 {
285 wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId);
286 event.SetEventObject(this);
287 #if WXWIN_COMPATIBILITY
288 event.SetForce(force);
289 #endif // WXWIN_COMPATIBILITY
290 event.SetCanVeto(!force);
291
292 // return FALSE if window wasn't closed because the application vetoed the
293 // close event
294 return GetEventHandler()->ProcessEvent(event) && !event.GetVeto();
295 }
296
297 bool wxWindowBase::DestroyChildren()
298 {
299 wxWindowList::Node *node;
300 for ( ;; )
301 {
302 // we iterate until the list becomes empty
303 node = GetChildren().GetFirst();
304 if ( !node )
305 break;
306
307 wxWindow *child = node->GetData();
308
309 wxASSERT_MSG( child, wxT("children list contains empty nodes") );
310
311 child->Show(FALSE);
312 delete child;
313
314 wxASSERT_MSG( !GetChildren().Find(child),
315 wxT("child didn't remove itself using RemoveChild()") );
316 }
317
318 return TRUE;
319 }
320
321 // ----------------------------------------------------------------------------
322 // size/position related methods
323 // ----------------------------------------------------------------------------
324
325 // centre the window with respect to its parent in either (or both) directions
326 void wxWindowBase::Centre(int direction)
327 {
328 // the position/size of the parent window or of the entire screen
329 wxPoint posParent;
330 int widthParent, heightParent;
331
332 wxWindow *parent = NULL;
333
334 if ( !(direction & wxCENTRE_ON_SCREEN) )
335 {
336 // find the parent to centre this window on: it should be the
337 // immediate parent for the controls but the top level parent for the
338 // top level windows (like dialogs)
339 parent = GetParent();
340 if ( IsTopLevel() )
341 {
342 while ( parent && !parent->IsTopLevel() )
343 {
344 parent = parent->GetParent();
345 }
346 }
347
348 // did we find the parent?
349 if ( !parent )
350 {
351 // no other choice
352 direction |= wxCENTRE_ON_SCREEN;
353 }
354 }
355
356 if ( direction & wxCENTRE_ON_SCREEN )
357 {
358 // centre with respect to the whole screen
359 wxDisplaySize(&widthParent, &heightParent);
360 }
361 else
362 {
363 if ( IsTopLevel() )
364 {
365 // centre on the parent
366 parent->GetSize(&widthParent, &heightParent);
367
368 // adjust to the parents position
369 posParent = parent->GetPosition();
370 }
371 else
372 {
373 // centre inside the parents client rectangle
374 parent->GetClientSize(&widthParent, &heightParent);
375 }
376 }
377
378 int width, height;
379 GetSize(&width, &height);
380
381 int xNew = -1,
382 yNew = -1;
383
384 if ( direction & wxHORIZONTAL )
385 xNew = (widthParent - width)/2;
386
387 if ( direction & wxVERTICAL )
388 yNew = (heightParent - height)/2;
389
390 xNew += posParent.x;
391 yNew += posParent.y;
392
393 // Base size of the visible dimensions of the display
394 // to take into account the taskbar
395 wxRect rect = wxGetClientDisplayRect();
396 wxSize size (rect.width,rect.height);
397
398 if (posParent.x >= 0) // if parent is on the main display
399 {
400 if (xNew < 0)
401 xNew = 0;
402 else if (xNew+width > size.x)
403 xNew = size.x-width-1;
404 }
405 if (posParent.y >= 0) // if parent is on the main display
406 {
407 if (yNew+height > size.y)
408 yNew = size.y-height-1;
409
410 // Make certain that the title bar is initially visible
411 // always, even if this would push the bottom of the
412 // dialog of the visible area of the display
413 if (yNew < 0)
414 yNew = 0;
415 }
416
417 // move the window to this position (keeping the old size but using
418 // SetSize() and not Move() to allow xNew and/or yNew to be -1)
419 SetSize(xNew, yNew, width, height, wxSIZE_ALLOW_MINUS_ONE);
420 }
421
422 // fits the window around the children
423 void wxWindowBase::Fit()
424 {
425 if ( GetChildren().GetCount() > 0 )
426 {
427 wxSize size = DoGetBestSize();
428
429 // for compatibility with the old versions and because it really looks
430 // slightly more pretty like this, add a pad
431 size.x += 7;
432 size.y += 14;
433
434 SetClientSize(size);
435 }
436 //else: do nothing if we have no children
437 }
438
439 // return the size best suited for the current window
440 wxSize wxWindowBase::DoGetBestSize() const
441 {
442 if ( GetChildren().GetCount() > 0 )
443 {
444 // our minimal acceptable size is such that all our windows fit inside
445 int maxX = 0,
446 maxY = 0;
447
448 for ( wxWindowList::Node *node = GetChildren().GetFirst();
449 node;
450 node = node->GetNext() )
451 {
452 wxWindow *win = node->GetData();
453 if ( win->IsTopLevel()
454 #if wxUSE_STATUSBAR
455 || wxDynamicCast(win, wxStatusBar)
456 #endif // wxUSE_STATUSBAR
457 )
458 {
459 // dialogs and frames lie in different top level windows -
460 // don't deal with them here; as for the status bars, they
461 // don't lie in the client area at all
462 continue;
463 }
464
465 int wx, wy, ww, wh;
466 win->GetPosition(&wx, &wy);
467
468 // if the window hadn't been positioned yet, assume that it is in
469 // the origin
470 if ( wx == -1 )
471 wx = 0;
472 if ( wy == -1 )
473 wy = 0;
474
475 win->GetSize(&ww, &wh);
476 if ( wx + ww > maxX )
477 maxX = wx + ww;
478 if ( wy + wh > maxY )
479 maxY = wy + wh;
480 }
481
482 return wxSize(maxX, maxY);
483 }
484 else
485 {
486 // for a generic window there is no natural best size - just use the
487 // current one
488 return GetSize();
489 }
490 }
491
492 // by default the origin is not shifted
493 wxPoint wxWindowBase::GetClientAreaOrigin() const
494 {
495 return wxPoint(0, 0);
496 }
497
498 // set the min/max size of the window
499 void wxWindowBase::SetSizeHints(int minW, int minH,
500 int maxW, int maxH,
501 int WXUNUSED(incW), int WXUNUSED(incH))
502 {
503 m_minWidth = minW;
504 m_maxWidth = maxW;
505 m_minHeight = minH;
506 m_maxHeight = maxH;
507 }
508
509 // ----------------------------------------------------------------------------
510 // show/hide/enable/disable the window
511 // ----------------------------------------------------------------------------
512
513 bool wxWindowBase::Show(bool show)
514 {
515 if ( show != m_isShown )
516 {
517 m_isShown = show;
518
519 return TRUE;
520 }
521 else
522 {
523 return FALSE;
524 }
525 }
526
527 bool wxWindowBase::Enable(bool enable)
528 {
529 if ( enable != m_isEnabled )
530 {
531 m_isEnabled = enable;
532
533 return TRUE;
534 }
535 else
536 {
537 return FALSE;
538 }
539 }
540 // ----------------------------------------------------------------------------
541 // RTTI
542 // ----------------------------------------------------------------------------
543
544 bool wxWindowBase::IsTopLevel() const
545 {
546 return FALSE;
547 }
548
549 // ----------------------------------------------------------------------------
550 // reparenting the window
551 // ----------------------------------------------------------------------------
552
553 void wxWindowBase::AddChild(wxWindowBase *child)
554 {
555 wxCHECK_RET( child, wxT("can't add a NULL child") );
556
557 // this should never happen and it will lead to a crash later if it does
558 // because RemoveChild() will remove only one node from the children list
559 // and the other(s) one(s) will be left with dangling pointers in them
560 wxASSERT_MSG( !GetChildren().Find(child), _T("AddChild() called twice") );
561
562 GetChildren().Append(child);
563 child->SetParent(this);
564 }
565
566 void wxWindowBase::RemoveChild(wxWindowBase *child)
567 {
568 wxCHECK_RET( child, wxT("can't remove a NULL child") );
569
570 GetChildren().DeleteObject(child);
571 child->SetParent((wxWindow *)NULL);
572 }
573
574 bool wxWindowBase::Reparent(wxWindowBase *newParent)
575 {
576 wxWindow *oldParent = GetParent();
577 if ( newParent == oldParent )
578 {
579 // nothing done
580 return FALSE;
581 }
582
583 // unlink this window from the existing parent.
584 if ( oldParent )
585 {
586 oldParent->RemoveChild(this);
587 }
588 else
589 {
590 wxTopLevelWindows.DeleteObject(this);
591 }
592
593 // add it to the new one
594 if ( newParent )
595 {
596 newParent->AddChild(this);
597 }
598 else
599 {
600 wxTopLevelWindows.Append(this);
601 }
602
603 return TRUE;
604 }
605
606 // ----------------------------------------------------------------------------
607 // event handler stuff
608 // ----------------------------------------------------------------------------
609
610 void wxWindowBase::PushEventHandler(wxEvtHandler *handler)
611 {
612 handler->SetNextHandler(GetEventHandler());
613 SetEventHandler(handler);
614 }
615
616 wxEvtHandler *wxWindowBase::PopEventHandler(bool deleteHandler)
617 {
618 wxEvtHandler *handlerA = GetEventHandler();
619 if ( handlerA )
620 {
621 wxEvtHandler *handlerB = handlerA->GetNextHandler();
622 handlerA->SetNextHandler((wxEvtHandler *)NULL);
623 SetEventHandler(handlerB);
624 if ( deleteHandler )
625 {
626 delete handlerA;
627 handlerA = (wxEvtHandler *)NULL;
628 }
629 }
630
631 return handlerA;
632 }
633
634 // ----------------------------------------------------------------------------
635 // cursors, fonts &c
636 // ----------------------------------------------------------------------------
637
638 bool wxWindowBase::SetBackgroundColour( const wxColour &colour )
639 {
640 if ( !colour.Ok() || (colour == m_backgroundColour) )
641 return FALSE;
642
643 m_backgroundColour = colour;
644
645 m_hasBgCol = TRUE;
646
647 return TRUE;
648 }
649
650 bool wxWindowBase::SetForegroundColour( const wxColour &colour )
651 {
652 if ( !colour.Ok() || (colour == m_foregroundColour) )
653 return FALSE;
654
655 m_foregroundColour = colour;
656
657 m_hasFgCol = TRUE;
658
659 return TRUE;
660 }
661
662 bool wxWindowBase::SetCursor(const wxCursor& cursor)
663 {
664 // setting an invalid cursor is ok, it means that we don't have any special
665 // cursor
666 if ( m_cursor == cursor )
667 {
668 // no change
669 return FALSE;
670 }
671
672 m_cursor = cursor;
673
674 return TRUE;
675 }
676
677 bool wxWindowBase::SetFont(const wxFont& font)
678 {
679 // don't try to set invalid font, always fall back to the default
680 const wxFont& fontOk = font.Ok() ? font : *wxSWISS_FONT;
681
682 if ( fontOk == m_font )
683 {
684 // no change
685 return FALSE;
686 }
687
688 m_font = fontOk;
689
690 m_hasFont = TRUE;
691
692 return TRUE;
693 }
694
695 #if wxUSE_CARET
696 void wxWindowBase::SetCaret(wxCaret *caret)
697 {
698 if ( m_caret )
699 {
700 delete m_caret;
701 }
702
703 m_caret = caret;
704
705 if ( m_caret )
706 {
707 wxASSERT_MSG( m_caret->GetWindow() == this,
708 wxT("caret should be created associated to this window") );
709 }
710 }
711 #endif // wxUSE_CARET
712
713 #if wxUSE_VALIDATORS
714 // ----------------------------------------------------------------------------
715 // validators
716 // ----------------------------------------------------------------------------
717
718 void wxWindowBase::SetValidator(const wxValidator& validator)
719 {
720 if ( m_windowValidator )
721 delete m_windowValidator;
722
723 m_windowValidator = (wxValidator *)validator.Clone();
724
725 if ( m_windowValidator )
726 m_windowValidator->SetWindow(this) ;
727 }
728 #endif // wxUSE_VALIDATORS
729
730 // ----------------------------------------------------------------------------
731 // update region stuff
732 // ----------------------------------------------------------------------------
733
734 wxRect wxWindowBase::GetUpdateClientRect() const
735 {
736 wxRegion rgnUpdate = GetUpdateRegion();
737 rgnUpdate.Intersect(GetClientRect());
738 wxRect rectUpdate = rgnUpdate.GetBox();
739 wxPoint ptOrigin = GetClientAreaOrigin();
740 rectUpdate.x -= ptOrigin.x;
741 rectUpdate.y -= ptOrigin.y;
742
743 return rectUpdate;
744 }
745
746 bool wxWindowBase::IsExposed(int x, int y) const
747 {
748 return m_updateRegion.Contains(x, y) != wxOutRegion;
749 }
750
751 bool wxWindowBase::IsExposed(int x, int y, int w, int h) const
752 {
753 return m_updateRegion.Contains(x, y, w, h) != wxOutRegion;
754 }
755
756 // ----------------------------------------------------------------------------
757 // find window by id or name
758 // ----------------------------------------------------------------------------
759
760 wxWindow *wxWindowBase::FindWindow( long id )
761 {
762 if ( id == m_windowId )
763 return (wxWindow *)this;
764
765 wxWindowBase *res = (wxWindow *)NULL;
766 wxWindowList::Node *node;
767 for ( node = m_children.GetFirst(); node && !res; node = node->GetNext() )
768 {
769 wxWindowBase *child = node->GetData();
770 res = child->FindWindow( id );
771 }
772
773 return (wxWindow *)res;
774 }
775
776 wxWindow *wxWindowBase::FindWindow( const wxString& name )
777 {
778 if ( name == m_windowName )
779 return (wxWindow *)this;
780
781 wxWindowBase *res = (wxWindow *)NULL;
782 wxWindowList::Node *node;
783 for ( node = m_children.GetFirst(); node && !res; node = node->GetNext() )
784 {
785 wxWindow *child = node->GetData();
786 res = child->FindWindow(name);
787 }
788
789 return (wxWindow *)res;
790 }
791
792 // ----------------------------------------------------------------------------
793 // dialog oriented functions
794 // ----------------------------------------------------------------------------
795
796 void wxWindowBase::MakeModal(bool modal)
797 {
798 // Disable all other windows
799 if ( IsTopLevel() )
800 {
801 wxWindowList::Node *node = wxTopLevelWindows.GetFirst();
802 while (node)
803 {
804 wxWindow *win = node->GetData();
805 if (win != this)
806 win->Enable(!modal);
807
808 node = node->GetNext();
809 }
810 }
811 }
812
813 bool wxWindowBase::Validate()
814 {
815 #if wxUSE_VALIDATORS
816 bool recurse = (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY) != 0;
817
818 wxWindowList::Node *node;
819 for ( node = m_children.GetFirst(); node; node = node->GetNext() )
820 {
821 wxWindowBase *child = node->GetData();
822 wxValidator *validator = child->GetValidator();
823 if ( validator && !validator->Validate((wxWindow *)this) )
824 {
825 return FALSE;
826 }
827
828 if ( recurse && !child->Validate() )
829 {
830 return FALSE;
831 }
832 }
833 #endif // wxUSE_VALIDATORS
834
835 return TRUE;
836 }
837
838 bool wxWindowBase::TransferDataToWindow()
839 {
840 #if wxUSE_VALIDATORS
841 bool recurse = (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY) != 0;
842
843 wxWindowList::Node *node;
844 for ( node = m_children.GetFirst(); node; node = node->GetNext() )
845 {
846 wxWindowBase *child = node->GetData();
847 wxValidator *validator = child->GetValidator();
848 if ( validator && !validator->TransferToWindow() )
849 {
850 wxLogWarning(_("Could not transfer data to window"));
851 wxLog::FlushActive();
852
853 return FALSE;
854 }
855
856 if ( recurse )
857 {
858 if ( !child->TransferDataToWindow() )
859 {
860 // warning already given
861 return FALSE;
862 }
863 }
864 }
865 #endif // wxUSE_VALIDATORS
866
867 return TRUE;
868 }
869
870 bool wxWindowBase::TransferDataFromWindow()
871 {
872 #if wxUSE_VALIDATORS
873 bool recurse = (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY) != 0;
874
875 wxWindowList::Node *node;
876 for ( node = m_children.GetFirst(); node; node = node->GetNext() )
877 {
878 wxWindow *child = node->GetData();
879 wxValidator *validator = child->GetValidator();
880 if ( validator && !validator->TransferFromWindow() )
881 {
882 // nop warning here because the application is supposed to give
883 // one itself - we don't know here what might have gone wrongly
884
885 return FALSE;
886 }
887
888 if ( recurse )
889 {
890 if ( !child->TransferDataFromWindow() )
891 {
892 // warning already given
893 return FALSE;
894 }
895 }
896 }
897 #endif // wxUSE_VALIDATORS
898
899 return TRUE;
900 }
901
902 void wxWindowBase::InitDialog()
903 {
904 wxInitDialogEvent event(GetId());
905 event.SetEventObject( this );
906 GetEventHandler()->ProcessEvent(event);
907 }
908
909 // ----------------------------------------------------------------------------
910 // context-sensitive help support
911 // ----------------------------------------------------------------------------
912
913 #if wxUSE_HELP
914
915 // associate this help text with this window
916 void wxWindowBase::SetHelpText(const wxString& text)
917 {
918 wxHelpProvider *helpProvider = wxHelpProvider::Get();
919 if ( helpProvider )
920 {
921 helpProvider->AddHelp(this, text);
922 }
923 }
924
925 // associate this help text with all windows with the same id as this
926 // one
927 void wxWindowBase::SetHelpTextForId(const wxString& text)
928 {
929 wxHelpProvider *helpProvider = wxHelpProvider::Get();
930 if ( helpProvider )
931 {
932 helpProvider->AddHelp(GetId(), text);
933 }
934 }
935
936 // get the help string associated with this window (may be empty)
937 wxString wxWindowBase::GetHelpText() const
938 {
939 wxString text;
940 wxHelpProvider *helpProvider = wxHelpProvider::Get();
941 if ( helpProvider )
942 {
943 text = helpProvider->GetHelp(this);
944 }
945
946 return text;
947 }
948
949 // show help for this window
950 void wxWindowBase::OnHelp(wxHelpEvent& event)
951 {
952 wxHelpProvider *helpProvider = wxHelpProvider::Get();
953 if ( helpProvider )
954 {
955 if ( helpProvider->ShowHelp(this) )
956 {
957 // skip the event.Skip() below
958 return;
959 }
960 }
961
962 event.Skip();
963 }
964
965 #endif // wxUSE_HELP
966
967 // ----------------------------------------------------------------------------
968 // tooltips
969 // ----------------------------------------------------------------------------
970
971 #if wxUSE_TOOLTIPS
972
973 void wxWindowBase::SetToolTip( const wxString &tip )
974 {
975 // don't create the new tooltip if we already have one
976 if ( m_tooltip )
977 {
978 m_tooltip->SetTip( tip );
979 }
980 else
981 {
982 SetToolTip( new wxToolTip( tip ) );
983 }
984
985 // setting empty tooltip text does not remove the tooltip any more - use
986 // SetToolTip((wxToolTip *)NULL) for this
987 }
988
989 void wxWindowBase::DoSetToolTip(wxToolTip *tooltip)
990 {
991 if ( m_tooltip )
992 delete m_tooltip;
993
994 m_tooltip = tooltip;
995 }
996
997 #endif // wxUSE_TOOLTIPS
998
999 // ----------------------------------------------------------------------------
1000 // constraints and sizers
1001 // ----------------------------------------------------------------------------
1002
1003 #if wxUSE_CONSTRAINTS
1004
1005 void wxWindowBase::SetConstraints( wxLayoutConstraints *constraints )
1006 {
1007 if ( m_constraints )
1008 {
1009 UnsetConstraints(m_constraints);
1010 delete m_constraints;
1011 }
1012 m_constraints = constraints;
1013 if ( m_constraints )
1014 {
1015 // Make sure other windows know they're part of a 'meaningful relationship'
1016 if ( m_constraints->left.GetOtherWindow() && (m_constraints->left.GetOtherWindow() != this) )
1017 m_constraints->left.GetOtherWindow()->AddConstraintReference(this);
1018 if ( m_constraints->top.GetOtherWindow() && (m_constraints->top.GetOtherWindow() != this) )
1019 m_constraints->top.GetOtherWindow()->AddConstraintReference(this);
1020 if ( m_constraints->right.GetOtherWindow() && (m_constraints->right.GetOtherWindow() != this) )
1021 m_constraints->right.GetOtherWindow()->AddConstraintReference(this);
1022 if ( m_constraints->bottom.GetOtherWindow() && (m_constraints->bottom.GetOtherWindow() != this) )
1023 m_constraints->bottom.GetOtherWindow()->AddConstraintReference(this);
1024 if ( m_constraints->width.GetOtherWindow() && (m_constraints->width.GetOtherWindow() != this) )
1025 m_constraints->width.GetOtherWindow()->AddConstraintReference(this);
1026 if ( m_constraints->height.GetOtherWindow() && (m_constraints->height.GetOtherWindow() != this) )
1027 m_constraints->height.GetOtherWindow()->AddConstraintReference(this);
1028 if ( m_constraints->centreX.GetOtherWindow() && (m_constraints->centreX.GetOtherWindow() != this) )
1029 m_constraints->centreX.GetOtherWindow()->AddConstraintReference(this);
1030 if ( m_constraints->centreY.GetOtherWindow() && (m_constraints->centreY.GetOtherWindow() != this) )
1031 m_constraints->centreY.GetOtherWindow()->AddConstraintReference(this);
1032 }
1033 }
1034
1035 // This removes any dangling pointers to this window in other windows'
1036 // constraintsInvolvedIn lists.
1037 void wxWindowBase::UnsetConstraints(wxLayoutConstraints *c)
1038 {
1039 if ( c )
1040 {
1041 if ( c->left.GetOtherWindow() && (c->top.GetOtherWindow() != this) )
1042 c->left.GetOtherWindow()->RemoveConstraintReference(this);
1043 if ( c->top.GetOtherWindow() && (c->top.GetOtherWindow() != this) )
1044 c->top.GetOtherWindow()->RemoveConstraintReference(this);
1045 if ( c->right.GetOtherWindow() && (c->right.GetOtherWindow() != this) )
1046 c->right.GetOtherWindow()->RemoveConstraintReference(this);
1047 if ( c->bottom.GetOtherWindow() && (c->bottom.GetOtherWindow() != this) )
1048 c->bottom.GetOtherWindow()->RemoveConstraintReference(this);
1049 if ( c->width.GetOtherWindow() && (c->width.GetOtherWindow() != this) )
1050 c->width.GetOtherWindow()->RemoveConstraintReference(this);
1051 if ( c->height.GetOtherWindow() && (c->height.GetOtherWindow() != this) )
1052 c->height.GetOtherWindow()->RemoveConstraintReference(this);
1053 if ( c->centreX.GetOtherWindow() && (c->centreX.GetOtherWindow() != this) )
1054 c->centreX.GetOtherWindow()->RemoveConstraintReference(this);
1055 if ( c->centreY.GetOtherWindow() && (c->centreY.GetOtherWindow() != this) )
1056 c->centreY.GetOtherWindow()->RemoveConstraintReference(this);
1057 }
1058 }
1059
1060 // Back-pointer to other windows we're involved with, so if we delete this
1061 // window, we must delete any constraints we're involved with.
1062 void wxWindowBase::AddConstraintReference(wxWindowBase *otherWin)
1063 {
1064 if ( !m_constraintsInvolvedIn )
1065 m_constraintsInvolvedIn = new wxWindowList;
1066 if ( !m_constraintsInvolvedIn->Find(otherWin) )
1067 m_constraintsInvolvedIn->Append(otherWin);
1068 }
1069
1070 // REMOVE back-pointer to other windows we're involved with.
1071 void wxWindowBase::RemoveConstraintReference(wxWindowBase *otherWin)
1072 {
1073 if ( m_constraintsInvolvedIn )
1074 m_constraintsInvolvedIn->DeleteObject(otherWin);
1075 }
1076
1077 // Reset any constraints that mention this window
1078 void wxWindowBase::DeleteRelatedConstraints()
1079 {
1080 if ( m_constraintsInvolvedIn )
1081 {
1082 wxWindowList::Node *node = m_constraintsInvolvedIn->GetFirst();
1083 while (node)
1084 {
1085 wxWindow *win = node->GetData();
1086 wxLayoutConstraints *constr = win->GetConstraints();
1087
1088 // Reset any constraints involving this window
1089 if ( constr )
1090 {
1091 constr->left.ResetIfWin(this);
1092 constr->top.ResetIfWin(this);
1093 constr->right.ResetIfWin(this);
1094 constr->bottom.ResetIfWin(this);
1095 constr->width.ResetIfWin(this);
1096 constr->height.ResetIfWin(this);
1097 constr->centreX.ResetIfWin(this);
1098 constr->centreY.ResetIfWin(this);
1099 }
1100
1101 wxWindowList::Node *next = node->GetNext();
1102 delete node;
1103 node = next;
1104 }
1105
1106 delete m_constraintsInvolvedIn;
1107 m_constraintsInvolvedIn = (wxWindowList *) NULL;
1108 }
1109 }
1110
1111 void wxWindowBase::SetSizer(wxSizer *sizer)
1112 {
1113 if (m_windowSizer) delete m_windowSizer;
1114
1115 m_windowSizer = sizer;
1116 }
1117
1118 bool wxWindowBase::Layout()
1119 {
1120 // If there is a sizer, use it instead of the constraints
1121 if ( GetSizer() )
1122 {
1123 int w, h;
1124 GetClientSize(&w, &h);
1125
1126 GetSizer()->SetDimension( 0, 0, w, h );
1127 }
1128 else
1129 {
1130 wxLayoutConstraints *constr = GetConstraints();
1131 bool wasOk = constr && constr->AreSatisfied();
1132
1133 ResetConstraints(); // Mark all constraints as unevaluated
1134
1135 // if we're a top level panel (i.e. our parent is frame/dialog), our
1136 // own constraints will never be satisfied any more unless we do it
1137 // here
1138 if ( wasOk )
1139 {
1140 int noChanges = 1;
1141 while ( noChanges > 0 )
1142 {
1143 constr->SatisfyConstraints(this, &noChanges);
1144 }
1145 }
1146
1147 DoPhase(1); // Layout children
1148 DoPhase(2); // Layout grand children
1149 SetConstraintSizes(); // Recursively set the real window sizes
1150 }
1151
1152 return TRUE;
1153 }
1154
1155
1156 // Do a phase of evaluating constraints: the default behaviour. wxSizers may
1157 // do a similar thing, but also impose their own 'constraints' and order the
1158 // evaluation differently.
1159 bool wxWindowBase::LayoutPhase1(int *noChanges)
1160 {
1161 wxLayoutConstraints *constr = GetConstraints();
1162 if ( constr )
1163 {
1164 return constr->SatisfyConstraints(this, noChanges);
1165 }
1166 else
1167 return TRUE;
1168 }
1169
1170 bool wxWindowBase::LayoutPhase2(int *noChanges)
1171 {
1172 *noChanges = 0;
1173
1174 // Layout children
1175 DoPhase(1);
1176 DoPhase(2);
1177 return TRUE;
1178 }
1179
1180 // Do a phase of evaluating child constraints
1181 bool wxWindowBase::DoPhase(int phase)
1182 {
1183 int noIterations = 0;
1184 int maxIterations = 500;
1185 int noChanges = 1;
1186 int noFailures = 0;
1187 wxWindowList succeeded;
1188 while ((noChanges > 0) && (noIterations < maxIterations))
1189 {
1190 noChanges = 0;
1191 noFailures = 0;
1192 wxWindowList::Node *node = GetChildren().GetFirst();
1193 while (node)
1194 {
1195 wxWindow *child = node->GetData();
1196 if ( !child->IsTopLevel() )
1197 {
1198 wxLayoutConstraints *constr = child->GetConstraints();
1199 if ( constr )
1200 {
1201 if ( !succeeded.Find(child) )
1202 {
1203 int tempNoChanges = 0;
1204 bool success = ( (phase == 1) ? child->LayoutPhase1(&tempNoChanges) : child->LayoutPhase2(&tempNoChanges) ) ;
1205 noChanges += tempNoChanges;
1206 if ( success )
1207 {
1208 succeeded.Append(child);
1209 }
1210 }
1211 }
1212 }
1213 node = node->GetNext();
1214 }
1215
1216 noIterations++;
1217 }
1218
1219 return TRUE;
1220 }
1221
1222 void wxWindowBase::ResetConstraints()
1223 {
1224 wxLayoutConstraints *constr = GetConstraints();
1225 if ( constr )
1226 {
1227 constr->left.SetDone(FALSE);
1228 constr->top.SetDone(FALSE);
1229 constr->right.SetDone(FALSE);
1230 constr->bottom.SetDone(FALSE);
1231 constr->width.SetDone(FALSE);
1232 constr->height.SetDone(FALSE);
1233 constr->centreX.SetDone(FALSE);
1234 constr->centreY.SetDone(FALSE);
1235 }
1236
1237 wxWindowList::Node *node = GetChildren().GetFirst();
1238 while (node)
1239 {
1240 wxWindow *win = node->GetData();
1241 if ( !win->IsTopLevel() )
1242 win->ResetConstraints();
1243 node = node->GetNext();
1244 }
1245 }
1246
1247 // Need to distinguish between setting the 'fake' size for windows and sizers,
1248 // and setting the real values.
1249 void wxWindowBase::SetConstraintSizes(bool recurse)
1250 {
1251 wxLayoutConstraints *constr = GetConstraints();
1252 if ( constr && constr->AreSatisfied() )
1253 {
1254 int x = constr->left.GetValue();
1255 int y = constr->top.GetValue();
1256 int w = constr->width.GetValue();
1257 int h = constr->height.GetValue();
1258
1259 if ( (constr->width.GetRelationship() != wxAsIs ) ||
1260 (constr->height.GetRelationship() != wxAsIs) )
1261 {
1262 SetSize(x, y, w, h);
1263 }
1264 else
1265 {
1266 // If we don't want to resize this window, just move it...
1267 Move(x, y);
1268 }
1269 }
1270 else if ( constr )
1271 {
1272 wxLogDebug(wxT("Constraints not satisfied for %s named '%s'."),
1273 GetClassInfo()->GetClassName(),
1274 GetName().c_str());
1275 }
1276
1277 if ( recurse )
1278 {
1279 wxWindowList::Node *node = GetChildren().GetFirst();
1280 while (node)
1281 {
1282 wxWindow *win = node->GetData();
1283 if ( !win->IsTopLevel() && win->GetConstraints() )
1284 win->SetConstraintSizes();
1285 node = node->GetNext();
1286 }
1287 }
1288 }
1289
1290 // Only set the size/position of the constraint (if any)
1291 void wxWindowBase::SetSizeConstraint(int x, int y, int w, int h)
1292 {
1293 wxLayoutConstraints *constr = GetConstraints();
1294 if ( constr )
1295 {
1296 if ( x != -1 )
1297 {
1298 constr->left.SetValue(x);
1299 constr->left.SetDone(TRUE);
1300 }
1301 if ( y != -1 )
1302 {
1303 constr->top.SetValue(y);
1304 constr->top.SetDone(TRUE);
1305 }
1306 if ( w != -1 )
1307 {
1308 constr->width.SetValue(w);
1309 constr->width.SetDone(TRUE);
1310 }
1311 if ( h != -1 )
1312 {
1313 constr->height.SetValue(h);
1314 constr->height.SetDone(TRUE);
1315 }
1316 }
1317 }
1318
1319 void wxWindowBase::MoveConstraint(int x, int y)
1320 {
1321 wxLayoutConstraints *constr = GetConstraints();
1322 if ( constr )
1323 {
1324 if ( x != -1 )
1325 {
1326 constr->left.SetValue(x);
1327 constr->left.SetDone(TRUE);
1328 }
1329 if ( y != -1 )
1330 {
1331 constr->top.SetValue(y);
1332 constr->top.SetDone(TRUE);
1333 }
1334 }
1335 }
1336
1337 void wxWindowBase::GetSizeConstraint(int *w, int *h) const
1338 {
1339 wxLayoutConstraints *constr = GetConstraints();
1340 if ( constr )
1341 {
1342 *w = constr->width.GetValue();
1343 *h = constr->height.GetValue();
1344 }
1345 else
1346 GetSize(w, h);
1347 }
1348
1349 void wxWindowBase::GetClientSizeConstraint(int *w, int *h) const
1350 {
1351 wxLayoutConstraints *constr = GetConstraints();
1352 if ( constr )
1353 {
1354 *w = constr->width.GetValue();
1355 *h = constr->height.GetValue();
1356 }
1357 else
1358 GetClientSize(w, h);
1359 }
1360
1361 void wxWindowBase::AdjustForParentClientOrigin(int& x, int& y, int sizeFlags)
1362 {
1363 // don't do it for the dialogs/frames - they float independently of their
1364 // parent
1365 if ( !IsTopLevel() )
1366 {
1367 wxWindow *parent = GetParent();
1368 if ( !(sizeFlags & wxSIZE_NO_ADJUSTMENTS) && parent )
1369 {
1370 wxPoint pt(parent->GetClientAreaOrigin());
1371 x += pt.x;
1372 y += pt.y;
1373 }
1374 }
1375 }
1376
1377
1378 void wxWindowBase::GetPositionConstraint(int *x, int *y) const
1379 {
1380 wxLayoutConstraints *constr = GetConstraints();
1381 if ( constr )
1382 {
1383 *x = constr->left.GetValue();
1384 *y = constr->top.GetValue();
1385 }
1386 else
1387 GetPosition(x, y);
1388 }
1389
1390 #endif // wxUSE_CONSTRAINTS
1391
1392 // ----------------------------------------------------------------------------
1393 // do Update UI processing for child controls
1394 // ----------------------------------------------------------------------------
1395
1396 // TODO: should this be implemented for the child window rather
1397 // than the parent? Then you can override it e.g. for wxCheckBox
1398 // to do the Right Thing rather than having to assume a fixed number
1399 // of control classes.
1400 void wxWindowBase::UpdateWindowUI()
1401 {
1402 #if wxUSE_CONTROLS
1403 wxUpdateUIEvent event(GetId());
1404 event.m_eventObject = this;
1405
1406 if ( GetEventHandler()->ProcessEvent(event) )
1407 {
1408 if ( event.GetSetEnabled() )
1409 Enable(event.GetEnabled());
1410
1411 if ( event.GetSetText() )
1412 {
1413 wxControl *control = wxDynamicCastThis(wxControl);
1414 if ( control )
1415 {
1416 #if wxUSE_TEXTCTRL
1417 wxTextCtrl *text = wxDynamicCast(control, wxTextCtrl);
1418 if ( text )
1419 text->SetValue(event.GetText());
1420 else
1421 #endif // wxUSE_TEXTCTRL
1422 control->SetLabel(event.GetText());
1423 }
1424 }
1425
1426 #if wxUSE_CHECKBOX
1427 wxCheckBox *checkbox = wxDynamicCastThis(wxCheckBox);
1428 if ( checkbox )
1429 {
1430 if ( event.GetSetChecked() )
1431 checkbox->SetValue(event.GetChecked());
1432 }
1433 #endif // wxUSE_CHECKBOX
1434
1435 #if wxUSE_RADIOBTN
1436 wxRadioButton *radiobtn = wxDynamicCastThis(wxRadioButton);
1437 if ( radiobtn )
1438 {
1439 if ( event.GetSetChecked() )
1440 radiobtn->SetValue(event.GetChecked());
1441 }
1442 #endif // wxUSE_RADIOBTN
1443 }
1444 #endif // wxUSE_CONTROLS
1445 }
1446
1447 // ----------------------------------------------------------------------------
1448 // dialog units translations
1449 // ----------------------------------------------------------------------------
1450
1451 wxPoint wxWindowBase::ConvertPixelsToDialog(const wxPoint& pt)
1452 {
1453 int charWidth = GetCharWidth();
1454 int charHeight = GetCharHeight();
1455 wxPoint pt2(-1, -1);
1456 if (pt.x != -1)
1457 pt2.x = (int) ((pt.x * 4) / charWidth) ;
1458 if (pt.y != -1)
1459 pt2.y = (int) ((pt.y * 8) / charHeight) ;
1460
1461 return pt2;
1462 }
1463
1464 wxPoint wxWindowBase::ConvertDialogToPixels(const wxPoint& pt)
1465 {
1466 int charWidth = GetCharWidth();
1467 int charHeight = GetCharHeight();
1468 wxPoint pt2(-1, -1);
1469 if (pt.x != -1)
1470 pt2.x = (int) ((pt.x * charWidth) / 4) ;
1471 if (pt.y != -1)
1472 pt2.y = (int) ((pt.y * charHeight) / 8) ;
1473
1474 return pt2;
1475 }
1476
1477 // ----------------------------------------------------------------------------
1478 // event handlers
1479 // ----------------------------------------------------------------------------
1480
1481 // propagate the colour change event to the subwindows
1482 void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent& event)
1483 {
1484 wxWindowList::Node *node = GetChildren().GetFirst();
1485 while ( node )
1486 {
1487 // Only propagate to non-top-level windows
1488 wxWindow *win = node->GetData();
1489 if ( !win->IsTopLevel() )
1490 {
1491 wxSysColourChangedEvent event2;
1492 event.m_eventObject = win;
1493 win->GetEventHandler()->ProcessEvent(event2);
1494 }
1495
1496 node = node->GetNext();
1497 }
1498 }
1499
1500 // the default action is to populate dialog with data when it's created
1501 void wxWindowBase::OnInitDialog( wxInitDialogEvent &WXUNUSED(event) )
1502 {
1503 TransferDataToWindow();
1504 }
1505
1506 // process Ctrl-Alt-mclick
1507 void wxWindowBase::OnMiddleClick( wxMouseEvent& event )
1508 {
1509 #if wxUSE_MSGDLG
1510 if ( event.ControlDown() && event.AltDown() )
1511 {
1512 // don't translate these strings
1513 wxString port;
1514 switch ( wxGetOsVersion() )
1515 {
1516 case wxMOTIF_X: port = _T("Motif"); break;
1517 case wxMAC:
1518 case wxMAC_DARWIN: port = _T("Mac"); break;
1519 case wxBEOS: port = _T("BeOS"); break;
1520 case wxGTK:
1521 case wxGTK_WIN32:
1522 case wxGTK_OS2:
1523 case wxGTK_BEOS: port = _T("GTK"); break;
1524 case wxWINDOWS:
1525 case wxPENWINDOWS:
1526 case wxWINDOWS_NT:
1527 case wxWIN32S:
1528 case wxWIN95:
1529 case wxWIN386: port = _T("MS Windows"); break;
1530 case wxMGL_UNIX:
1531 case wxMGL_X:
1532 case wxMGL_WIN32:
1533 case wxMGL_OS2: port = _T("MGL"); break;
1534 case wxWINDOWS_OS2:
1535 case wxOS2_PM: port = _T("OS/2"); break;
1536 default: port = _T("unknown"); break;
1537 }
1538
1539 wxMessageBox(wxString::Format(
1540 _T(
1541 " wxWindows Library (%s port)\nVersion %u.%u.%u%s, compiled at %s %s\n Copyright (c) 1995-2001 wxWindows team"
1542 ),
1543 port.c_str(),
1544 wxMAJOR_VERSION,
1545 wxMINOR_VERSION,
1546 wxRELEASE_NUMBER,
1547 #if wxUSE_UNICODE
1548 L" (Unicode)",
1549 #else
1550 "",
1551 #endif
1552 __TDATE__,
1553 __TTIME__
1554 ),
1555 _T("wxWindows information"),
1556 wxICON_INFORMATION | wxOK,
1557 (wxWindow *)this);
1558 }
1559 else
1560 #endif // wxUSE_MSGDLG
1561 {
1562 event.Skip();
1563 }
1564 }
1565
1566 // ----------------------------------------------------------------------------
1567 // list classes implementation
1568 // ----------------------------------------------------------------------------
1569
1570 void wxWindowListNode::DeleteData()
1571 {
1572 delete (wxWindow *)GetData();
1573 }
1574
1575 // ----------------------------------------------------------------------------
1576 // borders
1577 // ----------------------------------------------------------------------------
1578
1579 wxBorder wxWindowBase::GetBorder() const
1580 {
1581 wxBorder border = (wxBorder)(m_windowStyle & wxBORDER_MASK);
1582 if ( border == wxBORDER_DEFAULT )
1583 {
1584 border = GetDefaultBorder();
1585 }
1586
1587 return border;
1588 }
1589
1590 wxBorder wxWindowBase::GetDefaultBorder() const
1591 {
1592 return wxBORDER_NONE;
1593 }
1594
1595 // ----------------------------------------------------------------------------
1596 // hit testing
1597 // ----------------------------------------------------------------------------
1598
1599 wxHitTest wxWindowBase::DoHitTest(wxCoord x, wxCoord y) const
1600 {
1601 // here we just check if the point is inside the window or not
1602
1603 // check the top and left border first
1604 bool outside = x < 0 || y < 0;
1605 if ( !outside )
1606 {
1607 // check the right and bottom borders too
1608 wxSize size = GetSize();
1609 outside = x >= size.x || y >= size.y;
1610 }
1611
1612 return outside ? wxHT_WINDOW_OUTSIDE : wxHT_WINDOW_INSIDE;
1613 }
1614