]> git.saurik.com Git - wxWidgets.git/blobdiff - src/motif/window.cpp
Test whether GTK+ is 2.18 or newer in configure.
[wxWidgets.git] / src / motif / window.cpp
index 17373e001a633252bf5fa2894566afc5fd75f1c6..0d3e0b548eabf875e1ae015acb40a1fa2c5aee45 100644 (file)
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
-#ifdef __VMS
-#define XtDisplay XTDISPLAY
-#define XtWindow XTWINDOW
-#define XtScreen XTSCREEN
-#endif
-
 #ifndef WX_PRECOMP
     #include "wx/hash.h"
     #include "wx/log.h"
@@ -80,6 +74,7 @@
 #endif
 
 #include "wx/motif/private.h"
+#include "wx/motif/dcclient.h"
 
 #include <string.h>
 
@@ -350,11 +345,11 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id,
 // Destructor
 wxWindow::~wxWindow()
 {
+    SendDestroyEvent();
+
     if (g_captureWindow == this)
         g_captureWindow = NULL;
 
-    m_isBeingDeleted = true;
-
     // Motif-specific actions first
     WXWidget wMain = GetMainWidget();
     if ( wMain )
@@ -562,7 +557,7 @@ wxWindow *wxWindowBase::DoFindFocus()
     // currently active.
     // (2) The widget with the focus may not be in the widget table
     // depending on which widgets I put in the table
-    wxWindow *winFocus = (wxWindow *)NULL;
+    wxWindow *winFocus = NULL;
     for ( wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst();
           node;
           node = node->GetNext() )
@@ -880,6 +875,9 @@ void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect)
     int y2 = (dy >= 0) ? y + dy : y;
 
     wxClientDC dc(this);
+    wxClientDCImpl * const
+        dcimpl = static_cast<wxClientDCImpl *>(dc.GetImpl());
+    GC const gc = (GC) dcimpl->GetGC();
 
     dc.SetLogicalFunction (wxCOPY);
 
@@ -887,10 +885,9 @@ void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect)
     Window window = XtWindow(widget);
     Display* display = XtDisplay(widget);
 
-    XCopyArea(display, window, window, (GC) dc.GetGC(),
-              x1, y1, w1, h1, x2, y2);
+    XCopyArea(display, window, window, gc, x1, y1, w1, h1, x2, y2);
 
-    dc.SetAutoSetting(true);
+    dcimpl->SetAutoSetting(true);
     wxBrush brush(GetBackgroundColour(), wxSOLID);
     dc.SetBrush(brush); // FIXME: needed?
 
@@ -918,8 +915,7 @@ void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect)
         rect->width = dx;
         rect->height = h;
 
-        XFillRectangle(display, window,
-            (GC) dc.GetGC(), rect->x, rect->y, rect->width, rect->height);
+        XFillRectangle(display, window, gc, rect->x, rect->y, rect->width, rect->height);
 
         rect->x = rect->x;
         rect->y = rect->y;
@@ -937,9 +933,7 @@ void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect)
         rect->width = -dx;
         rect->height = h;
 
-        XFillRectangle(display, window,
-            (GC) dc.GetGC(), rect->x, rect->y, rect->width,
-            rect->height);
+        XFillRectangle(display, window, gc, rect->x, rect->y, rect->width, rect->height);
 
         rect->x = rect->x;
         rect->y = rect->y;
@@ -957,8 +951,7 @@ void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect)
         rect->width = w;
         rect->height = dy;
 
-        XFillRectangle(display, window,
-            (GC) dc.GetGC(), rect->x, rect->y, rect->width, rect->height);
+        XFillRectangle(display, window, gc, rect->x, rect->y, rect->width, rect->height);
 
         rect->x = rect->x;
         rect->y = rect->y;
@@ -976,8 +969,7 @@ void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect)
         rect->width = w;
         rect->height = -dy;
 
-        XFillRectangle(display, window,
-            (GC) dc.GetGC(), rect->x, rect->y, rect->width, rect->height);
+        XFillRectangle(display, window, gc, rect->x, rect->y, rect->width, rect->height);
 
         rect->x = rect->x;
         rect->y = rect->y;
@@ -1486,10 +1478,11 @@ int wxWindow::GetCharWidth() const
     return width;
 }
 
-void wxWindow::GetTextExtent(const wxString& string,
-                             int *x, int *y,
-                             int *descent, int *externalLeading,
-                             const wxFont *theFont) const
+void wxWindow::DoGetTextExtent(const wxString& string,
+                               int *x, int *y,
+                               int *descent,
+                               int *externalLeading,
+                               const wxFont *theFont) const
 {
     const wxFont *fontToUse = theFont ? theFont : &m_font;
 
@@ -1549,10 +1542,13 @@ void wxWindow::Refresh(bool eraseBack, const wxRect *rect)
         wxClientDC dc(this);
         wxBrush backgroundBrush(GetBackgroundColour(), wxSOLID);
         dc.SetBackground(backgroundBrush);
+
+        wxClientDCImpl * const
+            dcimpl = static_cast<wxClientDCImpl *>(dc.GetImpl());
         if (rect)
-            dc.Clear(*rect);
+            dcimpl->Clear(*rect);
         else
-            dc.Clear();
+            dcimpl->Clear();
     }
 
     XSendEvent(display, thisWindow, False, ExposureMask, (XEvent *)&dummyEvent);
@@ -1565,7 +1561,10 @@ void wxWindow::DoPaint()
     {
       wxPaintDC dc(this);
 
-      GC tempGC = (GC) dc.GetBackingGC();
+      wxPaintDCImpl * const
+          dcimpl = static_cast<wxPaintDCImpl *>(dc.GetImpl());
+
+      GC tempGC = (GC) dcimpl->GetBackingGC();
 
       Widget widget = (Widget) GetMainWidget();
 
@@ -1622,11 +1621,11 @@ void wxWindow::DoPaint()
         // Set an erase event first
         wxEraseEvent eraseEvent(GetId(), &dc);
         eraseEvent.SetEventObject(this);
-        GetEventHandler()->ProcessEvent(eraseEvent);
+        HandleWindowEvent(eraseEvent);
 
         wxPaintEvent event(GetId());
         event.SetEventObject(this);
-        GetEventHandler()->ProcessEvent(event);
+        HandleWindowEvent(event);
 
         m_needsRefresh = false;
     }
@@ -1648,7 +1647,7 @@ void wxWindow::OnSysColourChanged(wxSysColourChangedEvent& event)
         {
             wxSysColourChangedEvent event2;
             event.SetEventObject(win);
-            win->GetEventHandler()->ProcessEvent(event2);
+            win->HandleWindowEvent(event2);
         }
 
         node = node->GetNext();
@@ -1659,7 +1658,7 @@ void wxWindow::OnInternalIdle()
 {
     // This calls the UI-update mechanism (querying windows for
     // menu/toolbar/control state information)
-    if (wxUpdateUIEvent::CanUpdate(this) && IsShown())
+    if (wxUpdateUIEvent::CanUpdate(this) && IsShownOnScreen())
         UpdateWindowUI(wxUPDATE_UI_FROMIDLE);
 }
 
@@ -1708,7 +1707,7 @@ bool wxWindow::ProcessAccelerator(wxKeyEvent& event)
 
                         // If ProcessEvent returns true (it was handled), then
                         // the calling code will skip the event handling.
-                        return frame->GetEventHandler()->ProcessEvent(commandEvent);
+                        return frame->HandleWindowEvent(commandEvent);
                     }
                 }
 #endif
@@ -1727,7 +1726,7 @@ bool wxWindow::ProcessAccelerator(wxKeyEvent& event)
             {
                 wxCommandEvent commandEvent (wxEVT_COMMAND_BUTTON_CLICKED, child->GetId());
                 commandEvent.SetEventObject(child);
-                return child->GetEventHandler()->ProcessEvent(commandEvent);
+                return child->HandleWindowEvent(commandEvent);
             }
 
             return false;
@@ -1866,7 +1865,7 @@ WXDisplay *wxWindow::GetXDisplay() const
     if ( wMain )
         return (WXDisplay*) XtDisplay(wMain);
     else
-        return (WXDisplay*) NULL;
+        return NULL;
 }
 
 WXWidget wxWindow::GetMainWidget() const
@@ -1913,7 +1912,7 @@ void wxWidgetResizeProc(Widget w, XConfigureEvent *WXUNUSED(event),
         wxSize newSize(win->GetSize());
         wxSizeEvent sizeEvent(newSize, win->GetId());
         sizeEvent.SetEventObject(win);
-        win->GetEventHandler()->ProcessEvent(sizeEvent);
+        win->HandleWindowEvent(sizeEvent);
     }
 }
 
@@ -1999,7 +1998,7 @@ static void wxCanvasInputEvent(Widget drawingArea,
             wxMouseEvent wxevent(0);
             if (wxTranslateMouseEvent(wxevent, canvas, drawingArea, xevent))
             {
-                canvas->GetEventHandler()->ProcessEvent(wxevent);
+                canvas->HandleWindowEvent(wxevent);
             }
             break;
         }
@@ -2016,7 +2015,7 @@ static void wxCanvasInputEvent(Widget drawingArea,
                 if (parent)
                 {
                     event.SetEventType(wxEVT_CHAR_HOOK);
-                    if (parent->GetEventHandler()->ProcessEvent(event))
+                    if (parent->HandleWindowEvent(event))
                         return;
                 }
 
@@ -2025,10 +2024,10 @@ static void wxCanvasInputEvent(Widget drawingArea,
                 event.SetEventType(wxEVT_KEY_DOWN);
 
                 // Only process OnChar if OnKeyDown didn't swallow it
-                if (!canvas->GetEventHandler()->ProcessEvent (event))
+                if (!canvas->HandleWindowEvent (event))
                 {
                     event.SetEventType(wxEVT_CHAR);
-                    canvas->GetEventHandler()->ProcessEvent (event);
+                    canvas->HandleWindowEvent (event);
                 }
             }
             break;
@@ -2038,7 +2037,7 @@ static void wxCanvasInputEvent(Widget drawingArea,
             wxKeyEvent event (wxEVT_KEY_UP);
             if (wxTranslateKeyEvent (event, canvas, (Widget) 0, xevent))
             {
-                canvas->GetEventHandler()->ProcessEvent (event);
+                canvas->HandleWindowEvent (event);
             }
             break;
         }
@@ -2048,7 +2047,7 @@ static void wxCanvasInputEvent(Widget drawingArea,
             {
                 wxFocusEvent event(wxEVT_SET_FOCUS, canvas->GetId());
                 event.SetEventObject(canvas);
-                canvas->GetEventHandler()->ProcessEvent(event);
+                canvas->HandleWindowEvent(event);
             }
             break;
         }
@@ -2058,7 +2057,7 @@ static void wxCanvasInputEvent(Widget drawingArea,
             {
                 wxFocusEvent event(wxEVT_KILL_FOCUS, canvas->GetId());
                 event.SetEventObject(canvas);
-                canvas->GetEventHandler()->ProcessEvent(event);
+                canvas->HandleWindowEvent(event);
             }
             break;
         }
@@ -2080,7 +2079,7 @@ static void wxPanelItemEventHandler(Widget    wid,
         wxMouseEvent wxevent(0);
         if (wxTranslateMouseEvent(wxevent, window, wid, event))
         {
-            window->GetEventHandler()->ProcessEvent(wxevent);
+            window->HandleWindowEvent(wxevent);
         }
     }
 
@@ -2099,7 +2098,7 @@ static void wxScrollBarCallback(Widget scrollbar,
                                 XmScrollBarCallbackStruct *cbs)
 {
     wxWindow *win = wxGetWindowFromTable(scrollbar);
-    wxCHECK_RET( win, _T("invalid widget in scrollbar callback") );
+    wxCHECK_RET( win, wxT("invalid widget in scrollbar callback") );
 
     wxOrientation orientation = (wxOrientation)wxPtrToUInt(clientData);
 
@@ -2158,7 +2157,7 @@ static void wxScrollBarCallback(Widget scrollbar,
                            cbs->value,
                            orientation);
     event.SetEventObject( win );
-    win->GetEventHandler()->ProcessEvent(event);
+    win->HandleWindowEvent(event);
 }
 
 // For repainting arbitrary windows