+// ----------------------------------------------------------------------------
+// borders
+// ----------------------------------------------------------------------------
+
+wxBorder wxWindowBase::GetBorder() const
+{
+ wxBorder border = (wxBorder)(m_windowStyle & wxBORDER_MASK);
+ if ( border == wxBORDER_DEFAULT )
+ {
+ border = GetDefaultBorder();
+ }
+
+ return border;
+}
+
+wxBorder wxWindowBase::GetDefaultBorder() const
+{
+ return wxBORDER_NONE;
+}
+
+// ----------------------------------------------------------------------------
+// hit testing
+// ----------------------------------------------------------------------------
+
+wxHitTest wxWindowBase::DoHitTest(wxCoord x, wxCoord y) const
+{
+ // here we just check if the point is inside the window or not
+
+ // check the top and left border first
+ bool outside = x < 0 || y < 0;
+ if ( !outside )
+ {
+ // check the right and bottom borders too
+ wxSize size = GetSize();
+ outside = x >= size.x || y >= size.y;
+ }
+
+ return outside ? wxHT_WINDOW_OUTSIDE : wxHT_WINDOW_INSIDE;
+}
+
+// ----------------------------------------------------------------------------
+// mouse capture
+// ----------------------------------------------------------------------------
+
+struct WXDLLEXPORT wxWindowNext
+{
+ wxWindow *win;
+ wxWindowNext *next;
+} *wxWindowBase::ms_winCaptureNext = NULL;
+
+void wxWindowBase::CaptureMouse()
+{
+ wxLogTrace(_T("mousecapture"), _T("CaptureMouse(0x%08x)"), this);
+
+ wxWindow *winOld = GetCapture();
+ if ( winOld )
+ {
+ ((wxWindowBase*) winOld)->DoReleaseMouse();
+
+ // save it on stack
+ wxWindowNext *item = new wxWindowNext;
+ item->win = winOld;
+ item->next = ms_winCaptureNext;
+ ms_winCaptureNext = item;
+ }
+ //else: no mouse capture to save
+
+ DoCaptureMouse();
+}
+
+void wxWindowBase::ReleaseMouse()
+{
+ wxLogTrace(_T("mousecapture"), _T("ReleaseMouse(0x%08x)"), this);
+
+ wxASSERT_MSG( GetCapture() == this, wxT("attempt to release mouse, but this window hasn't captured it") )
+
+ DoReleaseMouse();
+
+ if ( ms_winCaptureNext )
+ {
+ ((wxWindowBase*)ms_winCaptureNext->win)->DoCaptureMouse();
+
+ wxWindowNext *item = ms_winCaptureNext;
+ ms_winCaptureNext = item->next;
+ delete item;
+ }
+ //else: stack is empty, no previous capture
+
+ wxLogTrace(_T("mousecapture"),
+ _T("After ReleaseMouse() mouse is captured by 0x%08x"),
+ GetCapture());
+}
+
+// ----------------------------------------------------------------------------
+// global functions
+// ----------------------------------------------------------------------------
+
+wxWindow* wxGetTopLevelParent(wxWindow *win)
+{
+ while ( win && !win->IsTopLevel() )
+ win = win->GetParent();
+
+ return win;
+}
+