]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/wincmn.cpp
install wxUniv headers in make install and include wxUniv sources in make dist
[wxWidgets.git] / src / common / wincmn.cpp
index 5b677218c737d03085d7b7e740f5ea5ab5b2f998..24158367eb3f7d855ae30313308643cc53985b3d 100644 (file)
@@ -124,14 +124,14 @@ void wxWindowBase::InitBase()
 #endif // wxUSE_VALIDATORS
 
     // use the system default colours
-    m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_BTNFACE);
-    m_foregroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOWTEXT);
+    m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE);
+    m_foregroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
 
     // don't set the font here for wxMSW as we don't call WM_SETFONT here and
     // so the font is *not* really set - but calls to SetFont() later won't do
     // anything because m_font appears to be already set!
 #ifndef __WXMSW__
-    m_font = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT);
+    m_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
 #endif // __WXMSW__
 
     // the colours/fonts are default for now
@@ -214,6 +214,8 @@ bool wxWindowBase::CreateBase(wxWindowBase *parent,
 // common clean up
 wxWindowBase::~wxWindowBase()
 {
+    wxASSERT_MSG( GetCapture() != this, wxT("attempt to destroy window with mouse capture") );
+
     // FIXME if these 2 cases result from programming errors in the user code
     //       we should probably assert here instead of silently fixing them
 
@@ -631,6 +633,41 @@ wxEvtHandler *wxWindowBase::PopEventHandler(bool deleteHandler)
     return handlerA;
 }
 
+bool wxWindowBase::RemoveEventHandler(wxEvtHandler *handler)
+{
+    wxCHECK_MSG( handler, FALSE, _T("RemoveEventHandler(NULL) called") );
+
+    wxEvtHandler *handlerPrev = NULL,
+                 *handlerCur = GetEventHandler();
+    while ( handlerCur )
+    {
+        wxEvtHandler *handlerNext = handlerCur->GetNextHandler();
+
+        if ( handlerCur == handler )
+        {
+            if ( handlerPrev )
+            {
+                handlerPrev->SetNextHandler(handlerNext);
+            }
+            else
+            {
+                SetEventHandler(handlerNext);
+            }
+
+            handler->SetNextHandler(NULL);
+
+            return TRUE;
+        }
+
+        handlerPrev = handlerCur;
+        handlerCur = handlerNext;
+    }
+
+    wxFAIL_MSG( _T("where has the event handler gone?") );
+
+    return FALSE;
+}
+
 // ----------------------------------------------------------------------------
 // cursors, fonts &c
 // ----------------------------------------------------------------------------
@@ -1612,3 +1649,54 @@ wxHitTest wxWindowBase::DoHitTest(wxCoord x, wxCoord y) const
     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 )
+    {
+        // 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 )
+    {
+        ms_winCaptureNext->win->CaptureMouse();
+
+        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());
+}
+