]> git.saurik.com Git - wxWidgets.git/blobdiff - src/x11/window.cpp
Fix for mistake with const for non pointer/reference with corrections in documentation.
[wxWidgets.git] / src / x11 / window.cpp
index 8f9b0c337fec0d9f11c56ce9d054b4e078f213bb..000e1721e1459f68e7270c6857192fec94253c96 100644 (file)
 // headers
 // ----------------------------------------------------------------------------
 
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-    #pragma implementation "window.h"
-#endif
-
 #include "wx/setup.h"
 #include "wx/menu.h"
 #include "wx/dc.h"
@@ -62,8 +58,6 @@
 // global variables for this module
 // ----------------------------------------------------------------------------
 
-extern wxHashTable *wxWidgetHashTable;
-extern wxHashTable *wxClientWidgetHashTable;
 static wxWindow* g_captureWindow = NULL;
 static GC g_eraseGC;
 
@@ -99,9 +93,6 @@ END_EVENT_TABLE()
 
 void wxWindowX11::Init()
 {
-    // generic initializations first
-    InitBase();
-
     // X11-specific
     m_mainWindow = (WXWindow) 0;
     m_clientWindow = (WXWindow) 0;
@@ -111,7 +102,6 @@ void wxWindowX11::Init()
     m_winCaptured = FALSE;
     m_needsInputFocus = FALSE;
     m_isShown = TRUE;
-    m_isBeingDeleted = FALSE;
     m_lastTS = 0;
     m_lastButton = 0;
 }
@@ -224,7 +214,7 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id,
             KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask |
             PropertyChangeMask | VisibilityChangeMask ;
 
-        if (HasFlag( wxNO_FULL_REPAINT_ON_RESIZE ))
+        if (!HasFlag( wxFULL_REPAINT_ON_RESIZE ))
         {
             xattributes_mask |= CWBitGravity;
             xattributes.bit_gravity = StaticGravity;
@@ -304,7 +294,7 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id,
             KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask |
             PropertyChangeMask | VisibilityChangeMask ;
 
-        if (HasFlag( wxNO_FULL_REPAINT_ON_RESIZE ))
+        if (!HasFlag( wxFULL_REPAINT_ON_RESIZE ))
         {
             xattributes_mask |= CWBitGravity;
             xattributes.bit_gravity = NorthWestGravity;
@@ -348,9 +338,6 @@ wxWindowX11::~wxWindowX11()
 
     m_isBeingDeleted = TRUE;
 
-    if (m_parent)
-        m_parent->RemoveChild( this );
-
     DestroyChildren();
 
     if (m_clientWindow != m_mainWindow)
@@ -379,7 +366,11 @@ void wxWindowX11::SetFocus()
 
     wxCHECK_RET( xwindow, wxT("invalid window") );
 
-    wxCHECK_RET( AcceptsFocus(), wxT("set focus on window that doesn't accept the focus") );
+    // Don't assert; we might be trying to set the focus for a panel
+    // with only static controls, so the panel returns false from AcceptsFocus.
+    // The app should be not be expected to deal with this.
+    if (!AcceptsFocus())
+        return;
 
 #if 0
     if (GetName() == "scrollBar")
@@ -403,7 +394,7 @@ void wxWindowX11::SetFocus()
 }
 
 // Get the window with the focus
-wxWindow *wxWindowBase::FindFocus()
+wxWindow *wxWindowBase::DoFindFocus()
 {
     Window xfocus = (Window) 0;
     int revert = 0;
@@ -676,6 +667,26 @@ void wxWindowX11::ScrollWindow(int dx, int dy, const wxRect *rect)
     }
 
     XFreeGC( xdisplay, xgc );
+
+    // Move Clients, but not the scrollbars
+    // FIXME: There may be a better method to move a lot of Windows within X11
+    wxScrollBar *sbH = ((wxWindow *) this)->GetScrollbar( wxHORIZONTAL );
+    wxScrollBar *sbV = ((wxWindow *) this)->GetScrollbar( wxVERTICAL );
+    wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
+    while ( node )
+    {
+        // Only propagate to non-top-level windows
+        wxWindow *win = node->GetData();
+        if ( win->GetParent() && win != sbH && win != sbV )
+        {
+            wxPoint pos = win->GetPosition();
+            // Add the delta to the old Position
+            pos.x += dx;
+            pos.y += dy;
+            win->SetPosition(pos);
+        }
+        node = node->GetNext();
+    }
 }
 
 // ---------------------------------------------------------------------------
@@ -882,13 +893,6 @@ void wxWindowX11::DoSetClientSize(int width, int height)
     }
 }
 
-// For implementation purposes - sometimes decorations make the client area
-// smaller
-wxPoint wxWindowX11::GetClientAreaOrigin() const
-{
-    return wxPoint(0, 0);
-}
-
 void wxWindowX11::DoMoveWindow(int x, int y, int width, int height)
 {
     Window xwindow = (Window) m_mainWindow;
@@ -949,7 +953,7 @@ void wxWindowX11::DoMoveWindow(int x, int y, int width, int height)
 #endif
 }
 
-void wxWindowX11::SetSizeHints(int minW, int minH, int maxW, int maxH, int incW, int incH)
+void wxWindowX11::DoSetSizeHints(int minW, int minH, int maxW, int maxH, int incW, int incH)
 {
     m_minWidth = minW;
     m_minHeight = minH;
@@ -1261,7 +1265,7 @@ void wxWindowX11::OnSysColourChanged(wxSysColourChangedEvent& event)
         if ( win->GetParent() )
         {
             wxSysColourChangedEvent event2;
-            event.m_eventObject = win;
+            event.SetEventObject(win);
             win->GetEventHandler()->ProcessEvent(event2);
         }
 
@@ -1300,73 +1304,71 @@ void wxWindowX11::OnInternalIdle()
 }
 
 // ----------------------------------------------------------------------------
-// function which maintain the global hash table mapping Widgets to wxWindows
+// function which maintain the global hash table mapping Widgets to wxWidgets
 // ----------------------------------------------------------------------------
 
-bool wxAddWindowToTable(Window w, wxWindow *win)
+static bool DoAddWindowToTable(wxWindowHash *hash, Window w, wxWindow *win)
 {
-    wxWindow *oldItem = NULL;
-    if ((oldItem = (wxWindow *)wxWidgetHashTable->Get ((long) w)))
+    if ( !hash->insert(wxWindowHash::value_type(w, win)).second )
     {
-        wxLogDebug( wxT("Widget table clash: new widget is %ld, %s"),
-                    (long)w, win->GetClassInfo()->GetClassName());
+        wxLogDebug( wxT("Widget table clash: new widget is 0x%08x, %s"),
+                    (unsigned int)w, win->GetClassInfo()->GetClassName());
         return FALSE;
     }
 
-    wxWidgetHashTable->Put((long) w, win);
-
     wxLogTrace( wxT("widget"), wxT("XWindow 0x%08x <-> window %p (%s)"),
                 (unsigned int) w, win, win->GetClassInfo()->GetClassName());
 
     return TRUE;
 }
 
-wxWindow *wxGetWindowFromTable(Window w)
+static inline wxWindow *DoGetWindowFromTable(wxWindowHash *hash, Window w)
 {
-    return (wxWindow *)wxWidgetHashTable->Get((long) w);
+    wxWindowHash::iterator i = hash->find(w);
+    return i == hash->end() ? NULL : i->second;
 }
 
-void wxDeleteWindowFromTable(Window w)
+static inline void DoDeleteWindowFromTable(wxWindowHash *hash, Window w)
 {
-    wxWidgetHashTable->Delete((long)w);
+    wxLogTrace( wxT("widget"), wxT("XWindow 0x%08x deleted"), (unsigned int) w);
+
+    hash->erase(w);
 }
 
 // ----------------------------------------------------------------------------
-// function which maintain the global hash table mapping client widgets
+// public wrappers
 // ----------------------------------------------------------------------------
 
-bool wxAddClientWindowToTable(Window w, wxWindow *win)
+bool wxAddWindowToTable(Window w, wxWindow *win)
 {
-    wxWindow *oldItem = NULL;
-    if ((oldItem = (wxWindow *)wxClientWidgetHashTable->Get ((long) w)))
-    {
-        wxLogDebug( wxT("Client window table clash: new window is %ld, %s"),
-                    (long)w, win->GetClassInfo()->GetClassName());
-        return FALSE;
-    }
+    return DoAddWindowToTable(wxWidgetHashTable, w, win);
+}
 
-    wxClientWidgetHashTable->Put((long) w, win);
+wxWindow *wxGetWindowFromTable(Window w)
+{
+    return DoGetWindowFromTable(wxWidgetHashTable, w);
+}
 
-    wxLogTrace( wxT("widget"), wxT("XWindow 0x%08x <-> window %p (%s)"),
-                (unsigned int) w, win, win->GetClassInfo()->GetClassName());
+void wxDeleteWindowFromTable(Window w)
+{
+    DoDeleteWindowFromTable(wxWidgetHashTable, w);
+}
 
-    return TRUE;
+bool wxAddClientWindowToTable(Window w, wxWindow *win)
+{
+    return DoAddWindowToTable(wxClientWidgetHashTable, w, win);
 }
 
 wxWindow *wxGetClientWindowFromTable(Window w)
 {
-    return (wxWindow *)wxClientWidgetHashTable->Get((long) w);
+    return DoGetWindowFromTable(wxClientWidgetHashTable, w);
 }
 
 void wxDeleteClientWindowFromTable(Window w)
 {
-    wxClientWidgetHashTable->Delete((long)w);
+    DoDeleteWindowFromTable(wxClientWidgetHashTable, w);
 }
 
-// ----------------------------------------------------------------------------
-// add/remove window from the table
-// ----------------------------------------------------------------------------
-
 // ----------------------------------------------------------------------------
 // X11-specific accessors
 // ----------------------------------------------------------------------------