X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e39af974ef7846e26686ae39d74e4696c1fef0c3..5c250a10332dc17263c66deb629b5fa8c4320f8a:/src/motif/window.cpp diff --git a/src/motif/window.cpp b/src/motif/window.cpp index d9555d5917..f9610d3223 100644 --- a/src/motif/window.cpp +++ b/src/motif/window.cpp @@ -17,7 +17,7 @@ // headers // ---------------------------------------------------------------------------- -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "window.h" #endif @@ -200,9 +200,6 @@ bool wxWindow::MapOrUnmap(WXWidget widget, bool domap) void wxWindow::Init() { - // generic initializations first - InitBase(); - // Motif-specific m_needsRefresh = TRUE; m_mainWidget = (WXWidget) 0; @@ -210,7 +207,6 @@ void wxWindow::Init() m_winCaptured = FALSE; m_isShown = TRUE; - m_isBeingDeleted = FALSE; m_hScrollBar = m_vScrollBar = @@ -374,9 +370,6 @@ wxWindow::~wxWindow() 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 ) @@ -577,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; - for ( wxWindowList::Node *node = wxTopLevelWindows.GetFirst(); + for ( wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst(); node; node = node->GetNext() ) { @@ -904,7 +897,7 @@ void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect) 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(); @@ -1000,7 +993,7 @@ void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect) // Now send expose events - wxList::Node* node = updateRects.GetFirst(); + wxList::compatibility_iterator node = updateRects.GetFirst(); while (node) { wxRect* rect = (wxRect*) node->GetData(); @@ -1411,6 +1404,7 @@ void wxWindow::DoMoveWindowIntr(int xx, int yy, int w, int h, w -= 2 * (thick + margin); } + if( w < 1 ) w = 1; XtVaSetValues ((Widget) m_scrolledWindow, XmNwidth, w, NULL); } @@ -1427,6 +1421,7 @@ void wxWindow::DoMoveWindowIntr(int xx, int yy, int w, int h, h -= 2 * (thick + margin); } + if( h < 1 ) h = 1; XtVaSetValues ((Widget) m_scrolledWindow, XmNheight, h, NULL); } @@ -1577,14 +1572,6 @@ void wxWindow::Refresh(bool eraseBack, const wxRect *rect) 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 @@ -1666,7 +1653,7 @@ void wxWindow::DoPaint() // 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 @@ -1867,6 +1854,15 @@ bool wxWindow::DetachWidget(WXWidget widget) // 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 { @@ -2016,14 +2012,162 @@ static void wxCanvasInputEvent(Widget drawingArea, case ButtonPress: case ButtonRelease: case MotionNotify: - { - wxMouseEvent wxevent; - if(wxTranslateMouseEvent(wxevent, canvas, drawingArea, &local_event)) { - canvas->GetEventHandler()->ProcessEvent(wxevent); - } - break; - } + // FIXME: most of this mouse event code is more or less + // duplicated in wxTranslateMouseEvent + // + wxEventType eventType = wxEVT_NULL; + + if (local_event.xany.type == EnterNotify) + { + //if (local_event.xcrossing.mode!=NotifyNormal) + // return ; // Ignore grab events + eventType = wxEVT_ENTER_WINDOW; + // canvas->GetEventHandler()->OnSetFocus(); + } + else if (local_event.xany.type == LeaveNotify) + { + //if (local_event.xcrossingr.mode!=NotifyNormal) + // return ; // Ignore grab events + eventType = wxEVT_LEAVE_WINDOW; + // canvas->GetEventHandler()->OnKillFocus(); + } + else if (local_event.xany.type == MotionNotify) + { + eventType = wxEVT_MOTION; + } + + else if (local_event.xany.type == ButtonPress) + { + if (local_event.xbutton.button == Button1) + { + eventType = wxEVT_LEFT_DOWN; + } + else if (local_event.xbutton.button == Button2) + { + eventType = wxEVT_MIDDLE_DOWN; + } + else if (local_event.xbutton.button == Button3) + { + eventType = wxEVT_RIGHT_DOWN; + } + } + else if (local_event.xany.type == ButtonRelease) + { + if (local_event.xbutton.button == Button1) + { + eventType = wxEVT_LEFT_UP; + } + else if (local_event.xbutton.button == Button2) + { + eventType = wxEVT_MIDDLE_UP; + } + else if (local_event.xbutton.button == Button3) + { + eventType = wxEVT_RIGHT_UP; + } + } + + wxMouseEvent wxevent (eventType); + + wxevent.m_leftDown = ((eventType == wxEVT_LEFT_DOWN) + || (event_left_is_down (&local_event) + && (eventType != wxEVT_LEFT_UP))); + wxevent.m_middleDown = ((eventType == wxEVT_MIDDLE_DOWN) + || (event_middle_is_down (&local_event) + && (eventType != wxEVT_MIDDLE_UP))); + wxevent.m_rightDown = ((eventType == wxEVT_RIGHT_DOWN) + || (event_right_is_down (&local_event) + && (eventType != wxEVT_RIGHT_UP))); + + wxevent.m_shiftDown = local_event.xbutton.state & ShiftMask; + wxevent.m_controlDown = local_event.xbutton.state & ControlMask; + wxevent.m_altDown = local_event.xbutton.state & Mod3Mask; + wxevent.m_metaDown = local_event.xbutton.state & Mod1Mask; + wxevent.SetTimestamp(local_event.xbutton.time); + + if ( eventType == wxEVT_MOTION ) + { + if (local_event.xmotion.is_hint == NotifyHint) + { + Window root, child; + Display *dpy = XtDisplay (drawingArea); + + XQueryPointer (dpy, XtWindow (drawingArea), + &root, &child, + &local_event.xmotion.x_root, + &local_event.xmotion.y_root, + &local_event.xmotion.x, + &local_event.xmotion.y, + &local_event.xmotion.state); + } + else + { + } + } + + // Now check if we need to translate this event into a double click + if (TRUE) // canvas->doubleClickAllowed) + { + if (wxevent.ButtonDown()) + { + long dclickTime = XtGetMultiClickTime((Display*) wxGetDisplay()); + + // get button and time-stamp + int button = 0; + if (wxevent.LeftDown()) + button = 1; + else if (wxevent.MiddleDown()) + button = 2; + else if (wxevent.RightDown()) + button = 3; + long ts = wxevent.GetTimestamp(); + + // check, if single or double click + int buttonLast = canvas->GetLastClickedButton(); + long lastTS = canvas->GetLastClickTime(); + if ( buttonLast && buttonLast == button && (ts - lastTS) < dclickTime ) + { + // I have a dclick + canvas->SetLastClick(0, ts); + + wxEventType typeDouble; + if ( eventType == wxEVT_LEFT_DOWN ) + typeDouble = wxEVT_LEFT_DCLICK; + else if ( eventType == wxEVT_MIDDLE_DOWN ) + typeDouble = wxEVT_MIDDLE_DCLICK; + else if ( eventType == wxEVT_RIGHT_DOWN ) + typeDouble = wxEVT_RIGHT_DCLICK; + else + typeDouble = wxEVT_NULL; + + if ( typeDouble != wxEVT_NULL ) + { + wxevent.SetEventType(typeDouble); + } + } + else + { + // not fast enough or different button + canvas->SetLastClick(button, ts); + } + } + } + + wxevent.SetId(canvas->GetId()); + wxevent.SetEventObject(canvas); + wxevent.m_x = local_event.xbutton.x; + wxevent.m_y = local_event.xbutton.y; + canvas->GetEventHandler()->ProcessEvent (wxevent); +#if 0 + if (eventType == wxEVT_ENTER_WINDOW || + eventType == wxEVT_LEAVE_WINDOW || + eventType == wxEVT_MOTION + ) + return; +#endif // 0 + break; + } case KeyPress: { wxKeyEvent event (wxEVT_CHAR);