]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/wincmn.cpp
Updates for Y positioning
[wxWidgets.git] / src / common / wincmn.cpp
index bd4ec6de1e3897b3def2d833a25709603bbdb86b..26cdbc173e44b7d8ec5c09053fb60becf48f6270 100644 (file)
@@ -167,6 +167,10 @@ void wxWindowBase::InitBase()
     m_caret = (wxCaret *)NULL;
 #endif // wxUSE_CARET
 
     m_caret = (wxCaret *)NULL;
 #endif // wxUSE_CARET
 
+#if wxUSE_PALETTE
+    m_hasCustomPalette = FALSE;
+#endif // wxUSE_PALETTE
+
     // Whether we're using the current theme for this window (wxGTK only for now)
     m_themeEnabled = FALSE;
 }
     // Whether we're using the current theme for this window (wxGTK only for now)
     m_themeEnabled = FALSE;
 }
@@ -214,6 +218,8 @@ bool wxWindowBase::CreateBase(wxWindowBase *parent,
 // common clean up
 wxWindowBase::~wxWindowBase()
 {
 // 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
 
     // FIXME if these 2 cases result from programming errors in the user code
     //       we should probably assert here instead of silently fixing them
 
@@ -395,14 +401,18 @@ void wxWindowBase::Centre(int direction)
     wxRect rect = wxGetClientDisplayRect();
     wxSize size (rect.width,rect.height);
 
     wxRect rect = wxGetClientDisplayRect();
     wxSize size (rect.width,rect.height);
 
+#ifndef __WXMGL__ // FIXME - temporary dirty hack!!
     if (posParent.x >= 0)  // if parent is on the main display
     if (posParent.x >= 0)  // if parent is on the main display
+#endif
     {
         if (xNew < 0)
             xNew = 0;
         else if (xNew+width > size.x)
             xNew = size.x-width-1;
     }
     {
         if (xNew < 0)
             xNew = 0;
         else if (xNew+width > size.x)
             xNew = size.x-width-1;
     }
+#ifndef __WXMGL__ // FIXME - temporary dirty hack!!
     if (posParent.y >= 0)  // if parent is on the main display
     if (posParent.y >= 0)  // if parent is on the main display
+#endif
     {
         if (yNew+height > size.y)
             yNew = size.y-height-1;
     {
         if (yNew+height > size.y)
             yNew = size.y-height-1;
@@ -631,6 +641,41 @@ wxEvtHandler *wxWindowBase::PopEventHandler(bool deleteHandler)
     return handlerA;
 }
 
     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
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // cursors, fonts &c
 // ----------------------------------------------------------------------------
@@ -692,6 +737,31 @@ bool wxWindowBase::SetFont(const wxFont& font)
     return TRUE;
 }
 
     return TRUE;
 }
 
+#if wxUSE_PALETTE
+
+void wxWindowBase::SetPalette(const wxPalette& pal)
+{
+    m_hasCustomPalette = TRUE;
+    m_palette = pal;
+
+    // VZ: can anyone explain me what do we do here?
+    wxWindowDC d((wxWindow *) this);
+    d.SetPalette(pal);
+}
+
+wxWindow *wxWindowBase::GetAncestorWithCustomPalette() const
+{
+    wxWindow *win = (wxWindow *)this;
+    while ( win && !win->HasCustomPalette() )
+    {
+        win = win->GetParent();
+    }
+
+    return win;
+}
+
+#endif // wxUSE_PALETTE
+
 #if wxUSE_CARET
 void wxWindowBase::SetCaret(wxCaret *caret)
 {
 #if wxUSE_CARET
 void wxWindowBase::SetCaret(wxCaret *caret)
 {
@@ -965,7 +1035,7 @@ void wxWindowBase::OnHelp(wxHelpEvent& event)
 #endif // wxUSE_HELP
 
 // ----------------------------------------------------------------------------
 #endif // wxUSE_HELP
 
 // ----------------------------------------------------------------------------
-// tooltips
+// tooltipsroot.Replace("\\", "/");
 // ----------------------------------------------------------------------------
 
 #if wxUSE_TOOLTIPS
 // ----------------------------------------------------------------------------
 
 #if wxUSE_TOOLTIPS
@@ -1511,6 +1581,11 @@ void wxWindowBase::OnMiddleClick( wxMouseEvent& event )
     {
         // don't translate these strings
         wxString port;
     {
         // don't translate these strings
         wxString port;
+
+#ifdef __WXUNIVERSAL__
+        port = _T("Univ/");
+#endif // __WXUNIVERSAL__
+
         switch ( wxGetOsVersion() )
         {
             case wxMOTIF_X:     port = _T("Motif"); break;
         switch ( wxGetOsVersion() )
         {
             case wxMOTIF_X:     port = _T("Motif"); break;
@@ -1538,7 +1613,7 @@ void wxWindowBase::OnMiddleClick( wxMouseEvent& event )
 
         wxMessageBox(wxString::Format(
                                       _T(
 
         wxMessageBox(wxString::Format(
                                       _T(
-                                        "       wxWindows Library (%s port)\nVersion %u.%u.%u%s, compiled at %s %s\n   Copyright (c) 1995-2001 wxWindows team"
+                                        "       wxWindows Library (%s port)\nVersion %u.%u.%u%s, compiled at %s %s\n   Copyright (c) 1995-2002 wxWindows team"
                                         ),
                                       port.c_str(),
                                       wxMAJOR_VERSION,
                                         ),
                                       port.c_str(),
                                       wxMAJOR_VERSION,
@@ -1620,9 +1695,9 @@ struct WXDLLEXPORT wxWindowNext
 {
     wxWindow *win;
     wxWindowNext *next;
 {
     wxWindow *win;
     wxWindowNext *next;
-} *wxWindow::ms_winCaptureNext = NULL;
+} *wxWindowBase::ms_winCaptureNext = NULL;
 
 
-void wxWindow::CaptureMouse()
+void wxWindowBase::CaptureMouse()
 {
     wxLogTrace(_T("mousecapture"), _T("CaptureMouse(0x%08x)"), this);
 
 {
     wxLogTrace(_T("mousecapture"), _T("CaptureMouse(0x%08x)"), this);
 
@@ -1640,8 +1715,12 @@ void wxWindow::CaptureMouse()
     DoCaptureMouse();
 }
 
     DoCaptureMouse();
 }
 
-void wxWindow::ReleaseMouse()
+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 )
     DoReleaseMouse();
 
     if ( ms_winCaptureNext )