]> git.saurik.com Git - wxWidgets.git/blobdiff - src/motif/window.cpp
removed Win16 code (patch 905241), last version with remains of Win16 support tagged...
[wxWidgets.git] / src / motif / window.cpp
index 268429955291286c8d8dfbe28553a227b412f12e..a50692831c0390bf2c78549352f5dbd16eb85250 100644 (file)
@@ -17,7 +17,7 @@
 // headers
 // ----------------------------------------------------------------------------
 
 // headers
 // ----------------------------------------------------------------------------
 
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
     #pragma implementation "window.h"
 #endif
 
     #pragma implementation "window.h"
 #endif
 
@@ -145,7 +145,6 @@ static int str16len(const char *s)
 
     BEGIN_EVENT_TABLE(wxWindow, wxWindowBase)
         EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged)
 
     BEGIN_EVENT_TABLE(wxWindow, wxWindowBase)
         EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged)
-        EVT_IDLE(wxWindow::OnIdle)
     END_EVENT_TABLE()
 
 // ============================================================================
     END_EVENT_TABLE()
 
 // ============================================================================
@@ -201,9 +200,6 @@ bool wxWindow::MapOrUnmap(WXWidget widget, bool domap)
 
 void wxWindow::Init()
 {
 
 void wxWindow::Init()
 {
-    // generic initializations first
-    InitBase();
-
     // Motif-specific
     m_needsRefresh = TRUE;
     m_mainWidget = (WXWidget) 0;
     // Motif-specific
     m_needsRefresh = TRUE;
     m_mainWidget = (WXWidget) 0;
@@ -211,7 +207,6 @@ void wxWindow::Init()
     m_winCaptured = FALSE;
 
     m_isShown = TRUE;
     m_winCaptured = FALSE;
 
     m_isShown = TRUE;
-    m_isBeingDeleted = FALSE;
     
     m_hScrollBar =
     m_vScrollBar =
     
     m_hScrollBar =
     m_vScrollBar =
@@ -375,9 +370,6 @@ wxWindow::~wxWindow()
         DetachWidget(wMain);
     }
 
         DetachWidget(wMain);
     }
 
-    if ( m_parent )
-        m_parent->RemoveChild( this );
-
     // If m_drawingArea, we're a fully-fledged window with drawing area,
     // scrollbars etc. (what wxCanvas used to be)
     if ( m_drawingArea )
     // If m_drawingArea, we're a fully-fledged window with drawing area,
     // scrollbars etc. (what wxCanvas used to be)
     if ( m_drawingArea )
@@ -578,7 +570,7 @@ wxWindow *wxWindowBase::FindFocus()
     // (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;
     // (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;
-    for ( wxWindowList::Node *node = wxTopLevelWindows.GetFirst();
+    for ( wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst();
           node;
           node = node->GetNext() )
     {
           node;
           node = node->GetNext() )
     {
@@ -905,7 +897,7 @@ void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect)
     wxBrush brush(GetBackgroundColour(), wxSOLID);
     dc.SetBrush(brush); // FIXME: needed?
 
     wxBrush brush(GetBackgroundColour(), wxSOLID);
     dc.SetBrush(brush); // FIXME: needed?
 
-    wxWindowList::Node *cnode = m_children.GetFirst();
+    wxWindowList::compatibility_iterator cnode = m_children.GetFirst();
     while (cnode)
     {
         wxWindow *child = cnode->GetData();
     while (cnode)
     {
         wxWindow *child = cnode->GetData();
@@ -1001,7 +993,7 @@ void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect)
 
     // Now send expose events
 
 
     // Now send expose events
 
-    wxList::Node* node = updateRects.GetFirst();
+    wxList::compatibility_iterator  node = updateRects.GetFirst();
     while (node)
     {
         wxRect* rect = (wxRect*) node->GetData();
     while (node)
     {
         wxRect* rect = (wxRect*) node->GetData();
@@ -1412,6 +1404,7 @@ void wxWindow::DoMoveWindowIntr(int xx, int yy, int w, int h,
                 w -= 2 * (thick + margin);
             }
 
                 w -= 2 * (thick + margin);
             }
 
+            if( w < 1 ) w = 1;
             XtVaSetValues ((Widget) m_scrolledWindow, XmNwidth, w, NULL);
         }
 
             XtVaSetValues ((Widget) m_scrolledWindow, XmNwidth, w, NULL);
         }
 
@@ -1428,6 +1421,7 @@ void wxWindow::DoMoveWindowIntr(int xx, int yy, int w, int h,
                 h -= 2 * (thick + margin);
             }
 
                 h -= 2 * (thick + margin);
             }
 
+            if( h < 1 ) h = 1;
             XtVaSetValues ((Widget) m_scrolledWindow, XmNheight, h, NULL);
         }
 
             XtVaSetValues ((Widget) m_scrolledWindow, XmNheight, h, NULL);
         }
 
@@ -1578,14 +1572,6 @@ void wxWindow::Refresh(bool eraseBack, const wxRect *rect)
     XSendEvent(display, thisWindow, False, ExposureMask, (XEvent *)&dummyEvent);
 }
 
     XSendEvent(display, thisWindow, False, ExposureMask, (XEvent *)&dummyEvent);
 }
 
-void wxWindow::Clear()
-{
-    wxClientDC dc(this);
-    wxBrush brush(GetBackgroundColour(), wxSOLID);
-    dc.SetBackground(brush);
-    dc.Clear();
-}
-
 void wxWindow::DoPaint()
 {
     //TODO : make a temporary gc so we can do the XCopyArea below
 void wxWindow::DoPaint()
 {
     //TODO : make a temporary gc so we can do the XCopyArea below
@@ -1667,7 +1653,7 @@ void wxWindow::DoPaint()
 // Responds to colour changes: passes event on to children.
 void wxWindow::OnSysColourChanged(wxSysColourChangedEvent& event)
 {
 // Responds to colour changes: passes event on to children.
 void wxWindow::OnSysColourChanged(wxSysColourChangedEvent& event)
 {
-    wxWindowList::Node *node = GetChildren().GetFirst();
+    wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
     while ( node )
     {
         // Only propagate to non-top-level windows
     while ( node )
     {
         // Only propagate to non-top-level windows
@@ -1683,12 +1669,12 @@ void wxWindow::OnSysColourChanged(wxSysColourChangedEvent& event)
     }
 }
 
     }
 }
 
-void wxWindow::OnIdle(wxIdleEvent& WXUNUSED(event))
+void wxWindow::OnInternalIdle()
 {
     // This calls the UI-update mechanism (querying windows for
     // menu/toolbar/control state information)
 {
     // This calls the UI-update mechanism (querying windows for
     // menu/toolbar/control state information)
-    if (wxUpdateUIEvent::CanUpdate())
-        UpdateWindowUI();
+    if (wxUpdateUIEvent::CanUpdate(this))
+        UpdateWindowUI(wxUPDATE_UI_FROMIDLE);
 }
 
 // ----------------------------------------------------------------------------
 }
 
 // ----------------------------------------------------------------------------
@@ -1868,6 +1854,15 @@ bool wxWindow::DetachWidget(WXWidget widget)
 // Motif-specific accessors
 // ----------------------------------------------------------------------------
 
 // Motif-specific accessors
 // ----------------------------------------------------------------------------
 
+WXWindow wxWindow::GetClientXWindow() const
+{
+    Widget wMain = (Widget)GetClientWidget();
+    if ( wMain )
+        return (WXWindow) XtWindow(wMain);
+    else
+        return (WXWindow) 0;
+}
+
 // Get the underlying X window
 WXWindow wxWindow::GetXWindow() const
 {
 // Get the underlying X window
 WXWindow wxWindow::GetXWindow() const
 {
@@ -2000,7 +1995,7 @@ static void wxCanvasInputEvent(Widget drawingArea,
                                XmDrawingAreaCallbackStruct * cbs)
 {
     wxWindow *canvas = wxGetWindowFromTable(drawingArea);
                                XmDrawingAreaCallbackStruct * cbs)
 {
     wxWindow *canvas = wxGetWindowFromTable(drawingArea);
-    XEvent local_event;
+    XEvent* xevent = cbs->event;
 
     if (canvas==NULL)
         return;
 
     if (canvas==NULL)
         return;
@@ -2008,27 +2003,25 @@ static void wxCanvasInputEvent(Widget drawingArea,
     if (cbs->reason != XmCR_INPUT)
         return;
 
     if (cbs->reason != XmCR_INPUT)
         return;
 
-    local_event = *(cbs->event);    // We must keep a copy!
-
-    switch (local_event.xany.type)
+    switch (xevent->xany.type)
     {
     case EnterNotify:
     case LeaveNotify:
     case ButtonPress:
     case ButtonRelease:
     case MotionNotify:
     {
     case EnterNotify:
     case LeaveNotify:
     case ButtonPress:
     case ButtonRelease:
     case MotionNotify:
-    {
-        wxMouseEvent wxevent;
-        if(wxTranslateMouseEvent(wxevent, canvas, drawingArea, &local_event))
         {
         {
-            canvas->GetEventHandler()->ProcessEvent(wxevent);
+            wxMouseEvent wxevent(0);
+            if (wxTranslateMouseEvent(wxevent, canvas, drawingArea, xevent))
+            {
+                canvas->GetEventHandler()->ProcessEvent(wxevent);
+            }
+            break;
         }
         }
-        break;
-    }
     case KeyPress:
         {
             wxKeyEvent event (wxEVT_CHAR);
     case KeyPress:
         {
             wxKeyEvent event (wxEVT_CHAR);
-            if (wxTranslateKeyEvent (event, canvas, (Widget) 0, &local_event))
+            if (wxTranslateKeyEvent (event, canvas, (Widget) 0, xevent))
             {
                 // Implement wxFrame::OnCharHook by checking ancestor.
                 wxWindow *parent = canvas;
             {
                 // Implement wxFrame::OnCharHook by checking ancestor.
                 wxWindow *parent = canvas;
@@ -2058,7 +2051,7 @@ static void wxCanvasInputEvent(Widget drawingArea,
     case KeyRelease:
         {
             wxKeyEvent event (wxEVT_KEY_UP);
     case KeyRelease:
         {
             wxKeyEvent event (wxEVT_KEY_UP);
-            if (wxTranslateKeyEvent (event, canvas, (Widget) 0, &local_event))
+            if (wxTranslateKeyEvent (event, canvas, (Widget) 0, xevent))
             {
                 canvas->GetEventHandler()->ProcessEvent (event);
             }
             {
                 canvas->GetEventHandler()->ProcessEvent (event);
             }
@@ -2066,7 +2059,7 @@ static void wxCanvasInputEvent(Widget drawingArea,
         }
     case FocusIn:
         {
         }
     case FocusIn:
         {
-            if (local_event.xfocus.detail != NotifyPointer)
+            if (xevent->xfocus.detail != NotifyPointer)
             {
                 wxFocusEvent event(wxEVT_SET_FOCUS, canvas->GetId());
                 event.SetEventObject(canvas);
             {
                 wxFocusEvent event(wxEVT_SET_FOCUS, canvas->GetId());
                 event.SetEventObject(canvas);
@@ -2076,7 +2069,7 @@ static void wxCanvasInputEvent(Widget drawingArea,
         }
     case FocusOut:
         {
         }
     case FocusOut:
         {
-            if (local_event.xfocus.detail != NotifyPointer)
+            if (xevent->xfocus.detail != NotifyPointer)
             {
                 wxFocusEvent event(wxEVT_KILL_FOCUS, canvas->GetId());
                 event.SetEventObject(canvas);
             {
                 wxFocusEvent event(wxEVT_KILL_FOCUS, canvas->GetId());
                 event.SetEventObject(canvas);
@@ -2216,7 +2209,7 @@ void wxUniversalRepaintProc(Widget w, XtPointer WXUNUSED(c_data), XEvent *event,
 // ----------------------------------------------------------------------------
 
 bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win,
 // ----------------------------------------------------------------------------
 
 bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win,
-                           Widget widget, XEvent *xevent)
+                           Widget widget, const XEvent *xevent)
 {
     switch (xevent->xany.type)
     {
 {
     switch (xevent->xany.type)
     {
@@ -2231,6 +2224,8 @@ bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win,
         case ButtonRelease:
         case MotionNotify:
         {
         case ButtonRelease:
         case MotionNotify:
         {
+            int eventx = xevent->xbutton.x, eventy = xevent->xbutton.y;
+
             wxEventType eventType = wxEVT_NULL;
 
             if (xevent->xany.type == LeaveNotify)
             wxEventType eventType = wxEVT_NULL;
 
             if (xevent->xany.type == LeaveNotify)
@@ -2244,6 +2239,18 @@ bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win,
             else if (xevent->xany.type == MotionNotify)
             {
                 eventType = wxEVT_MOTION;
             else if (xevent->xany.type == MotionNotify)
             {
                 eventType = wxEVT_MOTION;
+
+                if (xevent->xmotion.is_hint == NotifyHint)
+                {
+                    Window root, child;
+                    int x_root, y_root;
+                    unsigned int state;
+                    Display *dpy = XtDisplay (widget);
+
+                    XQueryPointer (dpy, XtWindow (widget),
+                        &root, &child,
+                        &x_root, &y_root, &eventx, &eventy, &state);
+                }
             }
             else if (xevent->xany.type == ButtonPress)
             {
             }
             else if (xevent->xany.type == ButtonPress)
             {
@@ -2331,8 +2338,8 @@ bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win,
                 dy = y1;
             }
 
                 dy = y1;
             }
 
-            wxevent.m_x = xevent->xbutton.x + dx;
-            wxevent.m_y = xevent->xbutton.y + dy;
+            wxevent.m_x = eventx + dx;
+            wxevent.m_y = eventy + dy;
 
             wxevent.m_leftDown = ((eventType == wxEVT_LEFT_DOWN)
                 || (event_left_is_down (xevent)
 
             wxevent.m_leftDown = ((eventType == wxEVT_LEFT_DOWN)
                 || (event_left_is_down (xevent)
@@ -2359,7 +2366,7 @@ bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win,
 }
 
 bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win,
 }
 
 bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win,
-                         Widget WXUNUSED(widget), XEvent *xevent)
+                         Widget WXUNUSED(widget), const XEvent *xevent)
 {
     switch (xevent->xany.type)
     {
 {
     switch (xevent->xany.type)
     {