]> git.saurik.com Git - wxWidgets.git/blobdiff - src/x11/window.cpp
Workaround for special menu items not always being enabled. Use
[wxWidgets.git] / src / x11 / window.cpp
index bc515eef7d4cc6faa29932ded65152bbb47cbbf7..675d1a8b2fc1e17e6c3f4e6d2787fdab9f48672d 100644 (file)
@@ -62,8 +62,6 @@
 // global variables for this module
 // ----------------------------------------------------------------------------
 
-extern wxHashTable *wxWidgetHashTable;
-extern wxHashTable *wxClientWidgetHashTable;
 static wxWindow* g_captureWindow = NULL;
 static GC g_eraseGC;
 
@@ -396,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;
@@ -942,7 +940,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;
@@ -1296,70 +1294,68 @@ void wxWindowX11::OnInternalIdle()
 // 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
 // ----------------------------------------------------------------------------