1 /////////////////////////////////////////////////////////////////////////////
2 // Name: common/window.cpp
3 // Purpose: common (to all ports) wxWindow functions
4 // Author: Julian Smart, Vadim Zeitlin
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "windowbase.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
32 #include "wx/string.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"
49 #include "wx/layout.h"
50 #endif // wxUSE_CONSTRAINTS
54 #if wxUSE_DRAG_AND_DROP
56 #endif // wxUSE_DRAG_AND_DROP
59 #include "wx/cshelp.h"
63 #include "wx/tooltip.h"
64 #endif // wxUSE_TOOLTIPS
70 // ----------------------------------------------------------------------------
72 // ----------------------------------------------------------------------------
74 int wxWindowBase::ms_lastControlId
= -200;
76 IMPLEMENT_ABSTRACT_CLASS(wxWindowBase
, wxEvtHandler
)
78 // ----------------------------------------------------------------------------
80 // ----------------------------------------------------------------------------
82 BEGIN_EVENT_TABLE(wxWindowBase
, wxEvtHandler
)
83 EVT_SYS_COLOUR_CHANGED(wxWindowBase::OnSysColourChanged
)
84 EVT_INIT_DIALOG(wxWindowBase::OnInitDialog
)
85 EVT_MIDDLE_DOWN(wxWindowBase::OnMiddleClick
)
88 EVT_HELP(-1, wxWindowBase::OnHelp
)
93 // ============================================================================
94 // implementation of the common functionality of the wxWindow class
95 // ============================================================================
97 // ----------------------------------------------------------------------------
99 // ----------------------------------------------------------------------------
101 // the default initialization
102 void wxWindowBase::InitBase()
104 // no window yet, no parent nor children
105 m_parent
= (wxWindow
*)NULL
;
107 m_children
.DeleteContents( FALSE
); // don't auto delete node data
109 // no constraints on the minimal window size
115 // window is created enabled but it's not visible yet
119 // the default event handler is just this window
120 m_eventHandler
= this;
124 m_windowValidator
= (wxValidator
*) NULL
;
125 #endif // wxUSE_VALIDATORS
127 // use the system default colours
128 m_backgroundColour
= wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE
);
129 m_foregroundColour
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
);
131 // don't set the font here for wxMSW as we don't call WM_SETFONT here and
132 // so the font is *not* really set - but calls to SetFont() later won't do
133 // anything because m_font appears to be already set!
135 m_font
= wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
);
138 // the colours/fonts are default for now
147 // an optimization for the event processing: checking this flag is much
148 // faster than using IsKindOf(CLASSINFO(wxWindow))
151 #if wxUSE_CONSTRAINTS
152 // no constraints whatsoever
153 m_constraints
= (wxLayoutConstraints
*) NULL
;
154 m_constraintsInvolvedIn
= (wxWindowList
*) NULL
;
155 #endif // wxUSE_CONSTRAINTS
157 m_windowSizer
= (wxSizer
*) NULL
;
158 m_containingSizer
= (wxSizer
*) NULL
;
159 m_autoLayout
= FALSE
;
161 #if wxUSE_DRAG_AND_DROP
162 m_dropTarget
= (wxDropTarget
*)NULL
;
163 #endif // wxUSE_DRAG_AND_DROP
166 m_tooltip
= (wxToolTip
*)NULL
;
167 #endif // wxUSE_TOOLTIPS
170 m_caret
= (wxCaret
*)NULL
;
171 #endif // wxUSE_CARET
174 m_hasCustomPalette
= FALSE
;
175 #endif // wxUSE_PALETTE
177 m_virtualSize
= wxDefaultSize
;
182 m_maxVirtualHeight
= -1;
184 // Whether we're using the current theme for this window (wxGTK only for now)
185 m_themeEnabled
= FALSE
;
188 // common part of window creation process
189 bool wxWindowBase::CreateBase(wxWindowBase
*parent
,
191 const wxPoint
& WXUNUSED(pos
),
192 const wxSize
& WXUNUSED(size
),
194 const wxValidator
& validator
,
195 const wxString
& name
)
197 // m_isWindow is set to TRUE in wxWindowBase::Init() as well as many other
198 // member variables - check that it has been called (will catch the case
199 // when a new ctor is added which doesn't call InitWindow)
200 wxASSERT_MSG( m_isWindow
, wxT("Init() must have been called before!") );
202 // generate a new id if the user doesn't care about it
203 m_windowId
= id
== -1 ? NewControlId() : id
;
206 SetWindowStyleFlag(style
);
210 SetValidator(validator
);
211 #endif // wxUSE_VALIDATORS
213 // if the parent window has wxWS_EX_VALIDATE_RECURSIVELY set, we want to
214 // have it too - like this it's possible to set it only in the top level
215 // dialog/frame and all children will inherit it by defult
216 if ( parent
&& (parent
->GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) )
218 SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY
);
224 // ----------------------------------------------------------------------------
226 // ----------------------------------------------------------------------------
229 wxWindowBase::~wxWindowBase()
231 wxASSERT_MSG( GetCapture() != this, wxT("attempt to destroy window with mouse capture") );
233 // FIXME if these 2 cases result from programming errors in the user code
234 // we should probably assert here instead of silently fixing them
236 // Just in case the window has been Closed, but we're then deleting
237 // immediately: don't leave dangling pointers.
238 wxPendingDelete
.DeleteObject(this);
240 // Just in case we've loaded a top-level window via LoadNativeDialog but
241 // we weren't a dialog class
242 wxTopLevelWindows
.DeleteObject(this);
244 wxASSERT_MSG( GetChildren().GetCount() == 0, wxT("children not destroyed") );
249 #endif // wxUSE_CARET
252 if ( m_windowValidator
)
253 delete m_windowValidator
;
254 #endif // wxUSE_VALIDATORS
256 #if wxUSE_CONSTRAINTS
257 // Have to delete constraints/sizer FIRST otherwise sizers may try to look
258 // at deleted windows as they delete themselves.
259 DeleteRelatedConstraints();
263 // This removes any dangling pointers to this window in other windows'
264 // constraintsInvolvedIn lists.
265 UnsetConstraints(m_constraints
);
266 delete m_constraints
;
267 m_constraints
= NULL
;
270 #endif // wxUSE_CONSTRAINTS
272 if ( m_containingSizer
)
273 m_containingSizer
->Remove((wxWindow
*)this);
276 delete m_windowSizer
;
278 #if wxUSE_DRAG_AND_DROP
281 #endif // wxUSE_DRAG_AND_DROP
286 #endif // wxUSE_TOOLTIPS
288 // reset the dangling pointer our parent window may keep to us
289 if ( m_parent
&& m_parent
->GetDefaultItem() == this )
291 m_parent
->SetDefaultItem(NULL
);
295 bool wxWindowBase::Destroy()
302 bool wxWindowBase::Close(bool force
)
304 wxCloseEvent
event(wxEVT_CLOSE_WINDOW
, m_windowId
);
305 event
.SetEventObject(this);
306 #if WXWIN_COMPATIBILITY
307 event
.SetForce(force
);
308 #endif // WXWIN_COMPATIBILITY
309 event
.SetCanVeto(!force
);
311 // return FALSE if window wasn't closed because the application vetoed the
313 return GetEventHandler()->ProcessEvent(event
) && !event
.GetVeto();
316 bool wxWindowBase::DestroyChildren()
318 wxWindowList::Node
*node
;
321 // we iterate until the list becomes empty
322 node
= GetChildren().GetFirst();
326 wxWindow
*child
= node
->GetData();
328 wxASSERT_MSG( child
, wxT("children list contains empty nodes") );
333 wxASSERT_MSG( !GetChildren().Find(child
),
334 wxT("child didn't remove itself using RemoveChild()") );
340 // ----------------------------------------------------------------------------
341 // size/position related methods
342 // ----------------------------------------------------------------------------
344 // centre the window with respect to its parent in either (or both) directions
345 void wxWindowBase::Centre(int direction
)
347 // the position/size of the parent window or of the entire screen
349 int widthParent
, heightParent
;
351 wxWindow
*parent
= NULL
;
353 if ( !(direction
& wxCENTRE_ON_SCREEN
) )
355 // find the parent to centre this window on: it should be the
356 // immediate parent for the controls but the top level parent for the
357 // top level windows (like dialogs)
358 parent
= GetParent();
361 while ( parent
&& !parent
->IsTopLevel() )
363 parent
= parent
->GetParent();
367 // we shouldn't center the dialog on the iconized window: under
368 // Windows, for example, this places it completely off the screen
371 wxTopLevelWindow
*winTop
= wxDynamicCast(parent
, wxTopLevelWindow
);
372 if ( winTop
&& winTop
->IsIconized() )
378 // did we find the parent?
382 direction
|= wxCENTRE_ON_SCREEN
;
386 if ( direction
& wxCENTRE_ON_SCREEN
)
388 // centre with respect to the whole screen
389 wxDisplaySize(&widthParent
, &heightParent
);
395 // centre on the parent
396 parent
->GetSize(&widthParent
, &heightParent
);
398 // adjust to the parents position
399 posParent
= parent
->GetPosition();
403 // centre inside the parents client rectangle
404 parent
->GetClientSize(&widthParent
, &heightParent
);
409 GetSize(&width
, &height
);
414 if ( direction
& wxHORIZONTAL
)
415 xNew
= (widthParent
- width
)/2;
417 if ( direction
& wxVERTICAL
)
418 yNew
= (heightParent
- height
)/2;
423 // Base size of the visible dimensions of the display
424 // to take into account the taskbar
425 wxRect rect
= wxGetClientDisplayRect();
426 wxSize
size (rect
.width
,rect
.height
);
428 // NB: in wxMSW, negative position may not neccessary mean "out of screen",
429 // but it may mean that the window is placed on other than the main
430 // display. Therefore we only make sure centered window is on the main display
431 // if the parent is at least partially present here.
432 if (posParent
.x
+ widthParent
>= 0) // if parent is (partially) on the main display
436 else if (xNew
+width
> size
.x
)
437 xNew
= size
.x
-width
-1;
439 if (posParent
.y
+ heightParent
>= 0) // if parent is (partially) on the main display
441 if (yNew
+height
> size
.y
)
442 yNew
= size
.y
-height
-1;
444 // Make certain that the title bar is initially visible
445 // always, even if this would push the bottom of the
446 // dialog of the visible area of the display
451 // move the window to this position (keeping the old size but using
452 // SetSize() and not Move() to allow xNew and/or yNew to be -1)
453 SetSize(xNew
, yNew
, width
, height
, wxSIZE_ALLOW_MINUS_ONE
);
456 // fits the window around the children
457 void wxWindowBase::Fit()
459 if ( GetChildren().GetCount() > 0 )
461 SetClientSize(DoGetBestSize());
463 //else: do nothing if we have no children
466 // return the size best suited for the current window
467 wxSize
wxWindowBase::DoGetBestSize() const
471 return m_windowSizer
->GetMinSize();
473 #if wxUSE_CONSTRAINTS
474 else if ( m_constraints
)
476 wxConstCast(this, wxWindowBase
)->SatisfyConstraints();
478 // our minimal acceptable size is such that all our windows fit inside
482 for ( wxWindowList::Node
*node
= GetChildren().GetFirst();
484 node
= node
->GetNext() )
486 wxLayoutConstraints
*c
= node
->GetData()->GetConstraints();
489 // it's not normal that we have an unconstrained child, but
490 // what can we do about it?
494 int x
= c
->right
.GetValue(),
495 y
= c
->bottom
.GetValue();
503 // TODO: we must calculate the overlaps somehow, otherwise we
504 // will never return a size bigger than the current one :-(
507 return wxSize(maxX
, maxY
);
509 #endif // wxUSE_CONSTRAINTS
510 else if ( GetChildren().GetCount() > 0 )
512 // our minimal acceptable size is such that all our windows fit inside
516 for ( wxWindowList::Node
*node
= GetChildren().GetFirst();
518 node
= node
->GetNext() )
520 wxWindow
*win
= node
->GetData();
521 if ( win
->IsTopLevel()
523 || wxDynamicCast(win
, wxStatusBar
)
524 #endif // wxUSE_STATUSBAR
527 // dialogs and frames lie in different top level windows -
528 // don't deal with them here; as for the status bars, they
529 // don't lie in the client area at all
534 win
->GetPosition(&wx
, &wy
);
536 // if the window hadn't been positioned yet, assume that it is in
543 win
->GetSize(&ww
, &wh
);
544 if ( wx
+ ww
> maxX
)
546 if ( wy
+ wh
> maxY
)
550 // for compatibility with the old versions and because it really looks
551 // slightly more pretty like this, add a pad
555 return wxSize(maxX
, maxY
);
559 // for a generic window there is no natural best size - just use the
565 // by default the origin is not shifted
566 wxPoint
wxWindowBase::GetClientAreaOrigin() const
568 return wxPoint(0, 0);
571 // set the min/max size of the window
572 void wxWindowBase::SetSizeHints(int minW
, int minH
,
574 int WXUNUSED(incW
), int WXUNUSED(incH
))
582 void wxWindowBase::SetVirtualSizeHints( int minW
, int minH
,
585 m_minVirtualWidth
= minW
;
586 m_maxVirtualWidth
= maxW
;
587 m_minVirtualHeight
= minH
;
588 m_maxVirtualHeight
= maxH
;
590 SetVirtualSize( GetClientSize() );
593 void wxWindowBase::DoSetVirtualSize( int x
, int y
)
595 if ( m_minVirtualWidth
!= -1 && m_minVirtualWidth
> x
)
596 x
= m_minVirtualWidth
;
597 if ( m_maxVirtualWidth
!= -1 && m_maxVirtualWidth
< x
)
598 x
= m_maxVirtualWidth
;
599 if ( m_minVirtualHeight
!= -1 && m_minVirtualHeight
> y
)
600 y
= m_minVirtualHeight
;
601 if ( m_maxVirtualHeight
!= -1 && m_maxVirtualHeight
< y
)
602 y
= m_maxVirtualHeight
;
604 m_virtualSize
= wxSize(x
, y
);
607 wxSize
wxWindowBase::DoGetVirtualSize() const
609 wxSize
s( GetClientSize() );
611 if( m_virtualSize
.GetWidth() != -1 )
612 s
.SetWidth( m_virtualSize
.GetWidth() );
613 if( m_virtualSize
.GetHeight() != -1 )
614 s
.SetHeight( m_virtualSize
.GetHeight() );
619 // ----------------------------------------------------------------------------
620 // show/hide/enable/disable the window
621 // ----------------------------------------------------------------------------
623 bool wxWindowBase::Show(bool show
)
625 if ( show
!= m_isShown
)
637 bool wxWindowBase::Enable(bool enable
)
639 if ( enable
!= m_isEnabled
)
641 m_isEnabled
= enable
;
650 // ----------------------------------------------------------------------------
652 // ----------------------------------------------------------------------------
654 bool wxWindowBase::IsTopLevel() const
659 // ----------------------------------------------------------------------------
660 // reparenting the window
661 // ----------------------------------------------------------------------------
663 void wxWindowBase::AddChild(wxWindowBase
*child
)
665 wxCHECK_RET( child
, wxT("can't add a NULL child") );
667 // this should never happen and it will lead to a crash later if it does
668 // because RemoveChild() will remove only one node from the children list
669 // and the other(s) one(s) will be left with dangling pointers in them
670 wxASSERT_MSG( !GetChildren().Find(child
), _T("AddChild() called twice") );
672 GetChildren().Append(child
);
673 child
->SetParent(this);
676 void wxWindowBase::RemoveChild(wxWindowBase
*child
)
678 wxCHECK_RET( child
, wxT("can't remove a NULL child") );
680 GetChildren().DeleteObject(child
);
681 child
->SetParent((wxWindow
*)NULL
);
684 bool wxWindowBase::Reparent(wxWindowBase
*newParent
)
686 wxWindow
*oldParent
= GetParent();
687 if ( newParent
== oldParent
)
693 // unlink this window from the existing parent.
696 oldParent
->RemoveChild(this);
700 wxTopLevelWindows
.DeleteObject(this);
703 // add it to the new one
706 newParent
->AddChild(this);
710 wxTopLevelWindows
.Append(this);
716 // ----------------------------------------------------------------------------
717 // event handler stuff
718 // ----------------------------------------------------------------------------
720 void wxWindowBase::PushEventHandler(wxEvtHandler
*handler
)
722 handler
->SetNextHandler(GetEventHandler());
723 SetEventHandler(handler
);
726 wxEvtHandler
*wxWindowBase::PopEventHandler(bool deleteHandler
)
728 wxEvtHandler
*handlerA
= GetEventHandler();
731 wxEvtHandler
*handlerB
= handlerA
->GetNextHandler();
732 handlerA
->SetNextHandler((wxEvtHandler
*)NULL
);
733 SetEventHandler(handlerB
);
737 handlerA
= (wxEvtHandler
*)NULL
;
744 bool wxWindowBase::RemoveEventHandler(wxEvtHandler
*handler
)
746 wxCHECK_MSG( handler
, FALSE
, _T("RemoveEventHandler(NULL) called") );
748 wxEvtHandler
*handlerPrev
= NULL
,
749 *handlerCur
= GetEventHandler();
752 wxEvtHandler
*handlerNext
= handlerCur
->GetNextHandler();
754 if ( handlerCur
== handler
)
758 handlerPrev
->SetNextHandler(handlerNext
);
762 SetEventHandler(handlerNext
);
765 handler
->SetNextHandler(NULL
);
770 handlerPrev
= handlerCur
;
771 handlerCur
= handlerNext
;
774 wxFAIL_MSG( _T("where has the event handler gone?") );
779 // ----------------------------------------------------------------------------
781 // ----------------------------------------------------------------------------
783 bool wxWindowBase::SetBackgroundColour( const wxColour
&colour
)
785 if ( !colour
.Ok() || (colour
== m_backgroundColour
) )
788 m_backgroundColour
= colour
;
795 bool wxWindowBase::SetForegroundColour( const wxColour
&colour
)
797 if ( !colour
.Ok() || (colour
== m_foregroundColour
) )
800 m_foregroundColour
= colour
;
807 bool wxWindowBase::SetCursor(const wxCursor
& cursor
)
809 // setting an invalid cursor is ok, it means that we don't have any special
811 if ( m_cursor
== cursor
)
822 bool wxWindowBase::SetFont(const wxFont
& font
)
824 // don't try to set invalid font, always fall back to the default
825 const wxFont
& fontOk
= font
.Ok() ? font
: *wxSWISS_FONT
;
827 if ( fontOk
== m_font
)
842 void wxWindowBase::SetPalette(const wxPalette
& pal
)
844 m_hasCustomPalette
= TRUE
;
847 // VZ: can anyone explain me what do we do here?
848 wxWindowDC
d((wxWindow
*) this);
852 wxWindow
*wxWindowBase::GetAncestorWithCustomPalette() const
854 wxWindow
*win
= (wxWindow
*)this;
855 while ( win
&& !win
->HasCustomPalette() )
857 win
= win
->GetParent();
863 #endif // wxUSE_PALETTE
866 void wxWindowBase::SetCaret(wxCaret
*caret
)
877 wxASSERT_MSG( m_caret
->GetWindow() == this,
878 wxT("caret should be created associated to this window") );
881 #endif // wxUSE_CARET
884 // ----------------------------------------------------------------------------
886 // ----------------------------------------------------------------------------
888 void wxWindowBase::SetValidator(const wxValidator
& validator
)
890 if ( m_windowValidator
)
891 delete m_windowValidator
;
893 m_windowValidator
= (wxValidator
*)validator
.Clone();
895 if ( m_windowValidator
)
896 m_windowValidator
->SetWindow(this) ;
898 #endif // wxUSE_VALIDATORS
900 // ----------------------------------------------------------------------------
901 // update region stuff
902 // ----------------------------------------------------------------------------
904 wxRect
wxWindowBase::GetUpdateClientRect() const
906 wxRegion rgnUpdate
= GetUpdateRegion();
907 rgnUpdate
.Intersect(GetClientRect());
908 wxRect rectUpdate
= rgnUpdate
.GetBox();
909 wxPoint ptOrigin
= GetClientAreaOrigin();
910 rectUpdate
.x
-= ptOrigin
.x
;
911 rectUpdate
.y
-= ptOrigin
.y
;
916 bool wxWindowBase::IsExposed(int x
, int y
) const
918 return m_updateRegion
.Contains(x
, y
) != wxOutRegion
;
921 bool wxWindowBase::IsExposed(int x
, int y
, int w
, int h
) const
923 return m_updateRegion
.Contains(x
, y
, w
, h
) != wxOutRegion
;
926 // ----------------------------------------------------------------------------
927 // find child window by id or name
928 // ----------------------------------------------------------------------------
930 wxWindow
*wxWindowBase::FindWindow( long id
)
932 if ( id
== m_windowId
)
933 return (wxWindow
*)this;
935 wxWindowBase
*res
= (wxWindow
*)NULL
;
936 wxWindowList::Node
*node
;
937 for ( node
= m_children
.GetFirst(); node
&& !res
; node
= node
->GetNext() )
939 wxWindowBase
*child
= node
->GetData();
940 res
= child
->FindWindow( id
);
943 return (wxWindow
*)res
;
946 wxWindow
*wxWindowBase::FindWindow( const wxString
& name
)
948 if ( name
== m_windowName
)
949 return (wxWindow
*)this;
951 wxWindowBase
*res
= (wxWindow
*)NULL
;
952 wxWindowList::Node
*node
;
953 for ( node
= m_children
.GetFirst(); node
&& !res
; node
= node
->GetNext() )
955 wxWindow
*child
= node
->GetData();
956 res
= child
->FindWindow(name
);
959 return (wxWindow
*)res
;
963 // find any window by id or name or label: If parent is non-NULL, look through
964 // children for a label or title matching the specified string. If NULL, look
965 // through all top-level windows.
967 // to avoid duplicating code we reuse the same helper function but with
968 // different comparators
970 typedef bool (*wxFindWindowCmp
)(const wxWindow
*win
,
971 const wxString
& label
, long id
);
974 bool wxFindWindowCmpLabels(const wxWindow
*win
, const wxString
& label
,
977 return win
->GetLabel() == label
;
981 bool wxFindWindowCmpNames(const wxWindow
*win
, const wxString
& label
,
984 return win
->GetName() == label
;
988 bool wxFindWindowCmpIds(const wxWindow
*win
, const wxString
& WXUNUSED(label
),
991 return win
->GetId() == id
;
994 // recursive helper for the FindWindowByXXX() functions
996 wxWindow
*wxFindWindowRecursively(const wxWindow
*parent
,
997 const wxString
& label
,
1003 // see if this is the one we're looking for
1004 if ( (*cmp
)(parent
, label
, id
) )
1005 return (wxWindow
*)parent
;
1007 // It wasn't, so check all its children
1008 for ( wxWindowList::Node
* node
= parent
->GetChildren().GetFirst();
1010 node
= node
->GetNext() )
1012 // recursively check each child
1013 wxWindow
*win
= (wxWindow
*)node
->GetData();
1014 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1024 // helper for FindWindowByXXX()
1026 wxWindow
*wxFindWindowHelper(const wxWindow
*parent
,
1027 const wxString
& label
,
1029 wxFindWindowCmp cmp
)
1033 // just check parent and all its children
1034 return wxFindWindowRecursively(parent
, label
, id
, cmp
);
1037 // start at very top of wx's windows
1038 for ( wxWindowList::Node
* node
= wxTopLevelWindows
.GetFirst();
1040 node
= node
->GetNext() )
1042 // recursively check each window & its children
1043 wxWindow
*win
= node
->GetData();
1044 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1054 wxWindowBase::FindWindowByLabel(const wxString
& title
, const wxWindow
*parent
)
1056 return wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpLabels
);
1061 wxWindowBase::FindWindowByName(const wxString
& title
, const wxWindow
*parent
)
1063 wxWindow
*win
= wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpNames
);
1067 // fall back to the label
1068 win
= FindWindowByLabel(title
, parent
);
1076 wxWindowBase::FindWindowById( long id
, const wxWindow
* parent
)
1078 return wxFindWindowHelper(parent
, _T(""), id
, wxFindWindowCmpIds
);
1081 // ----------------------------------------------------------------------------
1082 // dialog oriented functions
1083 // ----------------------------------------------------------------------------
1085 void wxWindowBase::MakeModal(bool modal
)
1087 // Disable all other windows
1090 wxWindowList::Node
*node
= wxTopLevelWindows
.GetFirst();
1093 wxWindow
*win
= node
->GetData();
1095 win
->Enable(!modal
);
1097 node
= node
->GetNext();
1102 bool wxWindowBase::Validate()
1104 #if wxUSE_VALIDATORS
1105 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1107 wxWindowList::Node
*node
;
1108 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1110 wxWindowBase
*child
= node
->GetData();
1111 wxValidator
*validator
= child
->GetValidator();
1112 if ( validator
&& !validator
->Validate((wxWindow
*)this) )
1117 if ( recurse
&& !child
->Validate() )
1122 #endif // wxUSE_VALIDATORS
1127 bool wxWindowBase::TransferDataToWindow()
1129 #if wxUSE_VALIDATORS
1130 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1132 wxWindowList::Node
*node
;
1133 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1135 wxWindowBase
*child
= node
->GetData();
1136 wxValidator
*validator
= child
->GetValidator();
1137 if ( validator
&& !validator
->TransferToWindow() )
1139 wxLogWarning(_("Could not transfer data to window"));
1140 wxLog::FlushActive();
1147 if ( !child
->TransferDataToWindow() )
1149 // warning already given
1154 #endif // wxUSE_VALIDATORS
1159 bool wxWindowBase::TransferDataFromWindow()
1161 #if wxUSE_VALIDATORS
1162 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1164 wxWindowList::Node
*node
;
1165 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1167 wxWindow
*child
= node
->GetData();
1168 wxValidator
*validator
= child
->GetValidator();
1169 if ( validator
&& !validator
->TransferFromWindow() )
1171 // nop warning here because the application is supposed to give
1172 // one itself - we don't know here what might have gone wrongly
1179 if ( !child
->TransferDataFromWindow() )
1181 // warning already given
1186 #endif // wxUSE_VALIDATORS
1191 void wxWindowBase::InitDialog()
1193 wxInitDialogEvent
event(GetId());
1194 event
.SetEventObject( this );
1195 GetEventHandler()->ProcessEvent(event
);
1198 // ----------------------------------------------------------------------------
1199 // context-sensitive help support
1200 // ----------------------------------------------------------------------------
1204 // associate this help text with this window
1205 void wxWindowBase::SetHelpText(const wxString
& text
)
1207 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1210 helpProvider
->AddHelp(this, text
);
1214 // associate this help text with all windows with the same id as this
1216 void wxWindowBase::SetHelpTextForId(const wxString
& text
)
1218 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1221 helpProvider
->AddHelp(GetId(), text
);
1225 // get the help string associated with this window (may be empty)
1226 wxString
wxWindowBase::GetHelpText() const
1229 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1232 text
= helpProvider
->GetHelp(this);
1238 // show help for this window
1239 void wxWindowBase::OnHelp(wxHelpEvent
& event
)
1241 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1244 if ( helpProvider
->ShowHelp(this) )
1246 // skip the event.Skip() below
1254 #endif // wxUSE_HELP
1256 // ----------------------------------------------------------------------------
1257 // tooltipsroot.Replace("\\", "/");
1258 // ----------------------------------------------------------------------------
1262 void wxWindowBase::SetToolTip( const wxString
&tip
)
1264 // don't create the new tooltip if we already have one
1267 m_tooltip
->SetTip( tip
);
1271 SetToolTip( new wxToolTip( tip
) );
1274 // setting empty tooltip text does not remove the tooltip any more - use
1275 // SetToolTip((wxToolTip *)NULL) for this
1278 void wxWindowBase::DoSetToolTip(wxToolTip
*tooltip
)
1283 m_tooltip
= tooltip
;
1286 #endif // wxUSE_TOOLTIPS
1288 // ----------------------------------------------------------------------------
1289 // constraints and sizers
1290 // ----------------------------------------------------------------------------
1292 #if wxUSE_CONSTRAINTS
1294 void wxWindowBase::SetConstraints( wxLayoutConstraints
*constraints
)
1296 if ( m_constraints
)
1298 UnsetConstraints(m_constraints
);
1299 delete m_constraints
;
1301 m_constraints
= constraints
;
1302 if ( m_constraints
)
1304 // Make sure other windows know they're part of a 'meaningful relationship'
1305 if ( m_constraints
->left
.GetOtherWindow() && (m_constraints
->left
.GetOtherWindow() != this) )
1306 m_constraints
->left
.GetOtherWindow()->AddConstraintReference(this);
1307 if ( m_constraints
->top
.GetOtherWindow() && (m_constraints
->top
.GetOtherWindow() != this) )
1308 m_constraints
->top
.GetOtherWindow()->AddConstraintReference(this);
1309 if ( m_constraints
->right
.GetOtherWindow() && (m_constraints
->right
.GetOtherWindow() != this) )
1310 m_constraints
->right
.GetOtherWindow()->AddConstraintReference(this);
1311 if ( m_constraints
->bottom
.GetOtherWindow() && (m_constraints
->bottom
.GetOtherWindow() != this) )
1312 m_constraints
->bottom
.GetOtherWindow()->AddConstraintReference(this);
1313 if ( m_constraints
->width
.GetOtherWindow() && (m_constraints
->width
.GetOtherWindow() != this) )
1314 m_constraints
->width
.GetOtherWindow()->AddConstraintReference(this);
1315 if ( m_constraints
->height
.GetOtherWindow() && (m_constraints
->height
.GetOtherWindow() != this) )
1316 m_constraints
->height
.GetOtherWindow()->AddConstraintReference(this);
1317 if ( m_constraints
->centreX
.GetOtherWindow() && (m_constraints
->centreX
.GetOtherWindow() != this) )
1318 m_constraints
->centreX
.GetOtherWindow()->AddConstraintReference(this);
1319 if ( m_constraints
->centreY
.GetOtherWindow() && (m_constraints
->centreY
.GetOtherWindow() != this) )
1320 m_constraints
->centreY
.GetOtherWindow()->AddConstraintReference(this);
1324 // This removes any dangling pointers to this window in other windows'
1325 // constraintsInvolvedIn lists.
1326 void wxWindowBase::UnsetConstraints(wxLayoutConstraints
*c
)
1330 if ( c
->left
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
1331 c
->left
.GetOtherWindow()->RemoveConstraintReference(this);
1332 if ( c
->top
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
1333 c
->top
.GetOtherWindow()->RemoveConstraintReference(this);
1334 if ( c
->right
.GetOtherWindow() && (c
->right
.GetOtherWindow() != this) )
1335 c
->right
.GetOtherWindow()->RemoveConstraintReference(this);
1336 if ( c
->bottom
.GetOtherWindow() && (c
->bottom
.GetOtherWindow() != this) )
1337 c
->bottom
.GetOtherWindow()->RemoveConstraintReference(this);
1338 if ( c
->width
.GetOtherWindow() && (c
->width
.GetOtherWindow() != this) )
1339 c
->width
.GetOtherWindow()->RemoveConstraintReference(this);
1340 if ( c
->height
.GetOtherWindow() && (c
->height
.GetOtherWindow() != this) )
1341 c
->height
.GetOtherWindow()->RemoveConstraintReference(this);
1342 if ( c
->centreX
.GetOtherWindow() && (c
->centreX
.GetOtherWindow() != this) )
1343 c
->centreX
.GetOtherWindow()->RemoveConstraintReference(this);
1344 if ( c
->centreY
.GetOtherWindow() && (c
->centreY
.GetOtherWindow() != this) )
1345 c
->centreY
.GetOtherWindow()->RemoveConstraintReference(this);
1349 // Back-pointer to other windows we're involved with, so if we delete this
1350 // window, we must delete any constraints we're involved with.
1351 void wxWindowBase::AddConstraintReference(wxWindowBase
*otherWin
)
1353 if ( !m_constraintsInvolvedIn
)
1354 m_constraintsInvolvedIn
= new wxWindowList
;
1355 if ( !m_constraintsInvolvedIn
->Find(otherWin
) )
1356 m_constraintsInvolvedIn
->Append(otherWin
);
1359 // REMOVE back-pointer to other windows we're involved with.
1360 void wxWindowBase::RemoveConstraintReference(wxWindowBase
*otherWin
)
1362 if ( m_constraintsInvolvedIn
)
1363 m_constraintsInvolvedIn
->DeleteObject(otherWin
);
1366 // Reset any constraints that mention this window
1367 void wxWindowBase::DeleteRelatedConstraints()
1369 if ( m_constraintsInvolvedIn
)
1371 wxWindowList::Node
*node
= m_constraintsInvolvedIn
->GetFirst();
1374 wxWindow
*win
= node
->GetData();
1375 wxLayoutConstraints
*constr
= win
->GetConstraints();
1377 // Reset any constraints involving this window
1380 constr
->left
.ResetIfWin(this);
1381 constr
->top
.ResetIfWin(this);
1382 constr
->right
.ResetIfWin(this);
1383 constr
->bottom
.ResetIfWin(this);
1384 constr
->width
.ResetIfWin(this);
1385 constr
->height
.ResetIfWin(this);
1386 constr
->centreX
.ResetIfWin(this);
1387 constr
->centreY
.ResetIfWin(this);
1390 wxWindowList::Node
*next
= node
->GetNext();
1395 delete m_constraintsInvolvedIn
;
1396 m_constraintsInvolvedIn
= (wxWindowList
*) NULL
;
1400 #endif // wxUSE_CONSTRAINTS
1402 void wxWindowBase::SetSizer(wxSizer
*sizer
, bool deleteOld
)
1405 delete m_windowSizer
;
1407 m_windowSizer
= sizer
;
1409 SetAutoLayout( sizer
!= NULL
);
1412 void wxWindowBase::SetSizerAndFit(wxSizer
*sizer
, bool deleteOld
)
1414 SetSizer( sizer
, deleteOld
);
1415 sizer
->SetSizeHints( (wxWindow
*) this );
1418 #if wxUSE_CONSTRAINTS
1420 void wxWindowBase::SatisfyConstraints()
1422 wxLayoutConstraints
*constr
= GetConstraints();
1423 bool wasOk
= constr
&& constr
->AreSatisfied();
1425 ResetConstraints(); // Mark all constraints as unevaluated
1429 // if we're a top level panel (i.e. our parent is frame/dialog), our
1430 // own constraints will never be satisfied any more unless we do it
1434 while ( noChanges
> 0 )
1436 LayoutPhase1(&noChanges
);
1440 LayoutPhase2(&noChanges
);
1443 #endif // wxUSE_CONSTRAINTS
1445 bool wxWindowBase::Layout()
1447 // If there is a sizer, use it instead of the constraints
1451 GetVirtualSize(&w
, &h
);
1452 GetSizer()->SetDimension( 0, 0, w
, h
);
1454 #if wxUSE_CONSTRAINTS
1457 SatisfyConstraints(); // Find the right constraints values
1458 SetConstraintSizes(); // Recursively set the real window sizes
1465 #if wxUSE_CONSTRAINTS
1467 // first phase of the constraints evaluation: set our own constraints
1468 bool wxWindowBase::LayoutPhase1(int *noChanges
)
1470 wxLayoutConstraints
*constr
= GetConstraints();
1472 return !constr
|| constr
->SatisfyConstraints(this, noChanges
);
1475 // second phase: set the constraints for our children
1476 bool wxWindowBase::LayoutPhase2(int *noChanges
)
1483 // Layout grand children
1489 // Do a phase of evaluating child constraints
1490 bool wxWindowBase::DoPhase(int phase
)
1492 // the list containing the children for which the constraints are already
1494 wxWindowList succeeded
;
1496 // the max number of iterations we loop before concluding that we can't set
1498 static const int maxIterations
= 500;
1500 for ( int noIterations
= 0; noIterations
< maxIterations
; noIterations
++ )
1504 // loop over all children setting their constraints
1505 for ( wxWindowList::Node
*node
= GetChildren().GetFirst();
1507 node
= node
->GetNext() )
1509 wxWindow
*child
= node
->GetData();
1510 if ( child
->IsTopLevel() )
1512 // top level children are not inside our client area
1516 if ( !child
->GetConstraints() || succeeded
.Find(child
) )
1518 // this one is either already ok or nothing we can do about it
1522 int tempNoChanges
= 0;
1523 bool success
= phase
== 1 ? child
->LayoutPhase1(&tempNoChanges
)
1524 : child
->LayoutPhase2(&tempNoChanges
);
1525 noChanges
+= tempNoChanges
;
1529 succeeded
.Append(child
);
1535 // constraints are set
1543 void wxWindowBase::ResetConstraints()
1545 wxLayoutConstraints
*constr
= GetConstraints();
1548 constr
->left
.SetDone(FALSE
);
1549 constr
->top
.SetDone(FALSE
);
1550 constr
->right
.SetDone(FALSE
);
1551 constr
->bottom
.SetDone(FALSE
);
1552 constr
->width
.SetDone(FALSE
);
1553 constr
->height
.SetDone(FALSE
);
1554 constr
->centreX
.SetDone(FALSE
);
1555 constr
->centreY
.SetDone(FALSE
);
1558 wxWindowList::Node
*node
= GetChildren().GetFirst();
1561 wxWindow
*win
= node
->GetData();
1562 if ( !win
->IsTopLevel() )
1563 win
->ResetConstraints();
1564 node
= node
->GetNext();
1568 // Need to distinguish between setting the 'fake' size for windows and sizers,
1569 // and setting the real values.
1570 void wxWindowBase::SetConstraintSizes(bool recurse
)
1572 wxLayoutConstraints
*constr
= GetConstraints();
1573 if ( constr
&& constr
->AreSatisfied() )
1575 int x
= constr
->left
.GetValue();
1576 int y
= constr
->top
.GetValue();
1577 int w
= constr
->width
.GetValue();
1578 int h
= constr
->height
.GetValue();
1580 if ( (constr
->width
.GetRelationship() != wxAsIs
) ||
1581 (constr
->height
.GetRelationship() != wxAsIs
) )
1583 SetSize(x
, y
, w
, h
);
1587 // If we don't want to resize this window, just move it...
1593 wxLogDebug(wxT("Constraints not satisfied for %s named '%s'."),
1594 GetClassInfo()->GetClassName(),
1600 wxWindowList::Node
*node
= GetChildren().GetFirst();
1603 wxWindow
*win
= node
->GetData();
1604 if ( !win
->IsTopLevel() && win
->GetConstraints() )
1605 win
->SetConstraintSizes();
1606 node
= node
->GetNext();
1611 // Only set the size/position of the constraint (if any)
1612 void wxWindowBase::SetSizeConstraint(int x
, int y
, int w
, int h
)
1614 wxLayoutConstraints
*constr
= GetConstraints();
1619 constr
->left
.SetValue(x
);
1620 constr
->left
.SetDone(TRUE
);
1624 constr
->top
.SetValue(y
);
1625 constr
->top
.SetDone(TRUE
);
1629 constr
->width
.SetValue(w
);
1630 constr
->width
.SetDone(TRUE
);
1634 constr
->height
.SetValue(h
);
1635 constr
->height
.SetDone(TRUE
);
1640 void wxWindowBase::MoveConstraint(int x
, int y
)
1642 wxLayoutConstraints
*constr
= GetConstraints();
1647 constr
->left
.SetValue(x
);
1648 constr
->left
.SetDone(TRUE
);
1652 constr
->top
.SetValue(y
);
1653 constr
->top
.SetDone(TRUE
);
1658 void wxWindowBase::GetSizeConstraint(int *w
, int *h
) const
1660 wxLayoutConstraints
*constr
= GetConstraints();
1663 *w
= constr
->width
.GetValue();
1664 *h
= constr
->height
.GetValue();
1670 void wxWindowBase::GetClientSizeConstraint(int *w
, int *h
) const
1672 wxLayoutConstraints
*constr
= GetConstraints();
1675 *w
= constr
->width
.GetValue();
1676 *h
= constr
->height
.GetValue();
1679 GetClientSize(w
, h
);
1682 void wxWindowBase::GetPositionConstraint(int *x
, int *y
) const
1684 wxLayoutConstraints
*constr
= GetConstraints();
1687 *x
= constr
->left
.GetValue();
1688 *y
= constr
->top
.GetValue();
1694 #endif // wxUSE_CONSTRAINTS
1696 void wxWindowBase::AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
) const
1698 // don't do it for the dialogs/frames - they float independently of their
1700 if ( !IsTopLevel() )
1702 wxWindow
*parent
= GetParent();
1703 if ( !(sizeFlags
& wxSIZE_NO_ADJUSTMENTS
) && parent
)
1705 wxPoint
pt(parent
->GetClientAreaOrigin());
1712 // ----------------------------------------------------------------------------
1713 // do Update UI processing for child controls
1714 // ----------------------------------------------------------------------------
1716 // TODO: should this be implemented for the child window rather
1717 // than the parent? Then you can override it e.g. for wxCheckBox
1718 // to do the Right Thing rather than having to assume a fixed number
1719 // of control classes.
1720 void wxWindowBase::UpdateWindowUI()
1723 wxUpdateUIEvent
event(GetId());
1724 event
.m_eventObject
= this;
1726 if ( GetEventHandler()->ProcessEvent(event
) )
1728 if ( event
.GetSetEnabled() )
1729 Enable(event
.GetEnabled());
1731 if ( event
.GetSetText() )
1733 wxControl
*control
= wxDynamicCastThis(wxControl
);
1737 wxTextCtrl
*text
= wxDynamicCast(control
, wxTextCtrl
);
1739 text
->SetValue(event
.GetText());
1741 #endif // wxUSE_TEXTCTRL
1742 control
->SetLabel(event
.GetText());
1747 wxCheckBox
*checkbox
= wxDynamicCastThis(wxCheckBox
);
1750 if ( event
.GetSetChecked() )
1751 checkbox
->SetValue(event
.GetChecked());
1753 #endif // wxUSE_CHECKBOX
1756 wxRadioButton
*radiobtn
= wxDynamicCastThis(wxRadioButton
);
1759 if ( event
.GetSetChecked() )
1760 radiobtn
->SetValue(event
.GetChecked());
1762 #endif // wxUSE_RADIOBTN
1764 #endif // wxUSE_CONTROLS
1767 // ----------------------------------------------------------------------------
1768 // dialog units translations
1769 // ----------------------------------------------------------------------------
1771 wxPoint
wxWindowBase::ConvertPixelsToDialog(const wxPoint
& pt
)
1773 int charWidth
= GetCharWidth();
1774 int charHeight
= GetCharHeight();
1775 wxPoint
pt2(-1, -1);
1777 pt2
.x
= (int) ((pt
.x
* 4) / charWidth
) ;
1779 pt2
.y
= (int) ((pt
.y
* 8) / charHeight
) ;
1784 wxPoint
wxWindowBase::ConvertDialogToPixels(const wxPoint
& pt
)
1786 int charWidth
= GetCharWidth();
1787 int charHeight
= GetCharHeight();
1788 wxPoint
pt2(-1, -1);
1790 pt2
.x
= (int) ((pt
.x
* charWidth
) / 4) ;
1792 pt2
.y
= (int) ((pt
.y
* charHeight
) / 8) ;
1797 // ----------------------------------------------------------------------------
1799 // ----------------------------------------------------------------------------
1801 // propagate the colour change event to the subwindows
1802 void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent
& event
)
1804 wxWindowList::Node
*node
= GetChildren().GetFirst();
1807 // Only propagate to non-top-level windows
1808 wxWindow
*win
= node
->GetData();
1809 if ( !win
->IsTopLevel() )
1811 wxSysColourChangedEvent event2
;
1812 event
.m_eventObject
= win
;
1813 win
->GetEventHandler()->ProcessEvent(event2
);
1816 node
= node
->GetNext();
1820 // the default action is to populate dialog with data when it's created
1821 void wxWindowBase::OnInitDialog( wxInitDialogEvent
&WXUNUSED(event
) )
1823 TransferDataToWindow();
1826 // process Ctrl-Alt-mclick
1827 void wxWindowBase::OnMiddleClick( wxMouseEvent
& event
)
1830 if ( event
.ControlDown() && event
.AltDown() )
1832 // don't translate these strings
1835 #ifdef __WXUNIVERSAL__
1837 #endif // __WXUNIVERSAL__
1839 switch ( wxGetOsVersion() )
1841 case wxMOTIF_X
: port
= _T("Motif"); break;
1843 case wxMAC_DARWIN
: port
= _T("Mac"); break;
1844 case wxBEOS
: port
= _T("BeOS"); break;
1848 case wxGTK_BEOS
: port
= _T("GTK"); break;
1854 case wxWIN386
: port
= _T("MS Windows"); break;
1858 case wxMGL_OS2
: port
= _T("MGL"); break;
1860 case wxOS2_PM
: port
= _T("OS/2"); break;
1861 default: port
= _T("unknown"); break;
1864 wxMessageBox(wxString::Format(
1866 " wxWindows Library (%s port)\nVersion %u.%u.%u%s, compiled at %s %s\n Copyright (c) 1995-2002 wxWindows team"
1880 _T("wxWindows information"),
1881 wxICON_INFORMATION
| wxOK
,
1885 #endif // wxUSE_MSGDLG
1891 // ----------------------------------------------------------------------------
1892 // list classes implementation
1893 // ----------------------------------------------------------------------------
1895 void wxWindowListNode::DeleteData()
1897 delete (wxWindow
*)GetData();
1900 // ----------------------------------------------------------------------------
1902 // ----------------------------------------------------------------------------
1904 wxBorder
wxWindowBase::GetBorder() const
1906 wxBorder border
= (wxBorder
)(m_windowStyle
& wxBORDER_MASK
);
1907 if ( border
== wxBORDER_DEFAULT
)
1909 border
= GetDefaultBorder();
1915 wxBorder
wxWindowBase::GetDefaultBorder() const
1917 return wxBORDER_NONE
;
1920 // ----------------------------------------------------------------------------
1922 // ----------------------------------------------------------------------------
1924 wxHitTest
wxWindowBase::DoHitTest(wxCoord x
, wxCoord y
) const
1926 // here we just check if the point is inside the window or not
1928 // check the top and left border first
1929 bool outside
= x
< 0 || y
< 0;
1932 // check the right and bottom borders too
1933 wxSize size
= GetSize();
1934 outside
= x
>= size
.x
|| y
>= size
.y
;
1937 return outside
? wxHT_WINDOW_OUTSIDE
: wxHT_WINDOW_INSIDE
;
1940 // ----------------------------------------------------------------------------
1942 // ----------------------------------------------------------------------------
1944 struct WXDLLEXPORT wxWindowNext
1948 } *wxWindowBase::ms_winCaptureNext
= NULL
;
1950 void wxWindowBase::CaptureMouse()
1952 wxLogTrace(_T("mousecapture"), _T("CaptureMouse(0x%08x)"), this);
1954 wxWindow
*winOld
= GetCapture();
1957 ((wxWindowBase
*) winOld
)->DoReleaseMouse();
1960 wxWindowNext
*item
= new wxWindowNext
;
1962 item
->next
= ms_winCaptureNext
;
1963 ms_winCaptureNext
= item
;
1965 //else: no mouse capture to save
1970 void wxWindowBase::ReleaseMouse()
1972 wxLogTrace(_T("mousecapture"), _T("ReleaseMouse(0x%08x)"), this);
1974 wxASSERT_MSG( GetCapture() == this, wxT("attempt to release mouse, but this window hasn't captured it") );
1978 if ( ms_winCaptureNext
)
1980 ((wxWindowBase
*)ms_winCaptureNext
->win
)->DoCaptureMouse();
1982 wxWindowNext
*item
= ms_winCaptureNext
;
1983 ms_winCaptureNext
= item
->next
;
1986 //else: stack is empty, no previous capture
1988 wxLogTrace(_T("mousecapture"),
1989 _T("After ReleaseMouse() mouse is captured by 0x%08x"),
1993 // ----------------------------------------------------------------------------
1995 // ----------------------------------------------------------------------------
1997 wxWindow
* wxGetTopLevelParent(wxWindow
*win
)
1999 while ( win
&& !win
->IsTopLevel() )
2000 win
= win
->GetParent();