X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0148fe1e2a2ea076bcd7a647c0b7946de0e0f990..c96ea65713a8dd58ae40b10718723b5c92a303e3:/src/motif/window.cpp diff --git a/src/motif/window.cpp b/src/motif/window.cpp index 204e0a0bff..ba7350acb3 100644 --- a/src/motif/window.cpp +++ b/src/motif/window.cpp @@ -21,6 +21,12 @@ #pragma implementation "window.h" #endif +#ifdef __VMS +#define XtDisplay XTDISPLAY +#define XtWindow XTWINDOW +#define XtScreen XTSCREEN +#endif + #include "wx/setup.h" #include "wx/menu.h" #include "wx/dc.h" @@ -408,10 +414,9 @@ wxWindow::~wxWindow() if (w) { XtDestroyWidget(w); + m_drawingArea = (WXWidget) 0; } - m_mainWidget = (WXWidget) 0; - // Only if we're _really_ a canvas (not a dialog box/panel) if (m_scrolledWindow) { @@ -421,14 +426,19 @@ wxWindow::~wxWindow() if (m_hScrollBar) { wxDeleteWindowFromTable((Widget) m_hScrollBar); + XtUnmanageChild((Widget) m_hScrollBar); } if (m_vScrollBar) { wxDeleteWindowFromTable((Widget) m_vScrollBar); + XtUnmanageChild((Widget) m_vScrollBar); } - UnmanageAndDestroy(m_hScrollBar); - UnmanageAndDestroy(m_vScrollBar); + if (m_hScrollBar) + XtDestroyWidget((Widget) m_hScrollBar); + if (m_vScrollBar) + XtDestroyWidget((Widget) m_vScrollBar); + UnmanageAndDestroy(m_scrolledWindow); if (m_borderWidget) @@ -437,6 +447,9 @@ wxWindow::~wxWindow() m_borderWidget = (WXWidget) 0; } } + else // Why wasn't this here before? JACS 8/3/2000 + DestroyChildren(); + // Destroy the window if (GetMainWidget()) @@ -446,6 +459,12 @@ wxWindow::~wxWindow() // or dialog is destroyed, but before that you may get some memory // leaks and potential layout problems if you delete and then add // child windows. + + // GRG, Feb/2000: commented this out when adding support for + // wxSCROLL[WIN]_THUMBRELEASE events. Also it was reported + // that this call crashed wxMotif under OS/2, so it seems + // that leaving it out is the right thing to do. + // SN, Feb/2000: newgrid/griddemo shows why it is needed :-( XtDestroyWidget((Widget) GetMainWidget()); SetMainWidget((WXWidget) NULL); } @@ -469,7 +488,7 @@ void wxWindow::CreateScrollbar(wxOrientation orientation) xmScrollBarWidgetClass, (Widget) m_scrolledWindow, XmNorientation, XmHORIZONTAL, NULL); - // XtAddCallback (hScrollBar, XmNvalueChangedCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL); + XtAddCallback (hScrollBar, XmNvalueChangedCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL); XtAddCallback (hScrollBar, XmNdragCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL); XtAddCallback (hScrollBar, XmNincrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL); XtAddCallback (hScrollBar, XmNdecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL); @@ -505,7 +524,7 @@ void wxWindow::CreateScrollbar(wxOrientation orientation) xmScrollBarWidgetClass, (Widget) m_scrolledWindow, XmNorientation, XmVERTICAL, NULL); - // XtAddCallback (vScrollBar, XmNvalueChangedCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL); + XtAddCallback (vScrollBar, XmNvalueChangedCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL); XtAddCallback (vScrollBar, XmNdragCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL); XtAddCallback (vScrollBar, XmNincrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL); XtAddCallback (vScrollBar, XmNdecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL); @@ -567,7 +586,7 @@ void wxWindow::DestroyScrollbar(wxOrientation orientation) XtDestroyWidget((Widget) m_vScrollBar); } m_vScrollBar = (WXWidget) 0; - m_vScroll = TRUE; + m_vScroll = FALSE; XtVaSetValues((Widget) m_scrolledWindow, XmNverticalScrollBar, (Widget) 0, @@ -734,11 +753,16 @@ bool wxWindow::SetCursor(const wxCursor& cursor) return FALSE; } - wxASSERT_MSG( m_cursor.Ok(), - wxT("cursor must be valid after call to the base version")); + // wxASSERT_MSG( m_cursor.Ok(), + // wxT("cursor must be valid after call to the base version")); + wxCursor* cursor2 = NULL; + if (m_cursor.Ok()) + cursor2 = & m_cursor; + else + cursor2 = wxSTANDARD_CURSOR; WXDisplay *dpy = GetXDisplay(); - WXCursor x_cursor = m_cursor.GetXCursor(dpy); + WXCursor x_cursor = cursor2->GetXCursor(dpy); Widget w = (Widget) GetMainWidget(); Window win = XtWindow(w); @@ -1181,7 +1205,7 @@ void wxWindow::DoGetSize(int *x, int *y) const Widget widget = (Widget) GetTopWidget(); Dimension xx, yy; XtVaGetValues(widget, XmNwidth, &xx, XmNheight, &yy, NULL); - *x = xx; *y = yy; + if(x) *x = xx; if(y) *y = yy; } void wxWindow::DoGetPosition(int *x, int *y) const @@ -1204,7 +1228,7 @@ void wxWindow::DoGetPosition(int *x, int *y) const yy -= pt.y; } - *x = xx; *y = yy; + if(x) *x = xx; if(y) *y = yy; } void wxWindow::DoScreenToClient(int *x, int *y) const @@ -1240,7 +1264,7 @@ void wxWindow::DoGetClientSize(int *x, int *y) const Widget widget = (Widget) GetClientWidget(); Dimension xx, yy; XtVaGetValues(widget, XmNwidth, &xx, XmNheight, &yy, NULL); - *x = xx; *y = yy; + if(x) *x = xx; if(y) *y = yy; } void wxWindow::DoSetSize(int x, int y, int width, int height, int sizeFlags) @@ -2075,22 +2099,21 @@ static void wxCanvasInputEvent(Widget drawingArea, { // I have a dclick canvas->SetLastClick(0, ts); - switch ( eventType ) + + 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 ) { - case wxEVT_LEFT_DOWN: - wxevent.SetEventType(wxEVT_LEFT_DCLICK); - break; - case wxEVT_MIDDLE_DOWN: - wxevent.SetEventType(wxEVT_MIDDLE_DCLICK); - break; - case wxEVT_RIGHT_DOWN: - wxevent.SetEventType(wxEVT_RIGHT_DCLICK); - break; - - default : - break; + wxevent.SetEventType(typeDouble); } - } else { @@ -2273,9 +2296,7 @@ static void wxScrollBarCallback(Widget scrollbar, } case XmCR_VALUE_CHANGED: { - // TODO: Should this be intercepted too, or will it cause - // duplicate events? - eventType = wxEVT_SCROLLWIN_THUMBTRACK; + eventType = wxEVT_SCROLLWIN_THUMBRELEASE; break; } case XmCR_PAGE_INCREMENT: @@ -2634,22 +2655,12 @@ bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win, Widget widget, { // I have a dclick win->SetLastClick(0, ts); - switch ( eventType ) - { - case wxEVT_LEFT_DOWN: - eventType = wxEVT_LEFT_DCLICK; - break; - case wxEVT_MIDDLE_DOWN: - eventType = wxEVT_MIDDLE_DCLICK; - break; - case wxEVT_RIGHT_DOWN: - eventType = wxEVT_RIGHT_DCLICK; - break; - - default : - break; - } - + if ( eventType == wxEVT_LEFT_DOWN ) + eventType = wxEVT_LEFT_DCLICK; + else if ( eventType == wxEVT_MIDDLE_DOWN ) + eventType = wxEVT_MIDDLE_DCLICK; + else if ( eventType == wxEVT_RIGHT_DOWN ) + eventType = wxEVT_RIGHT_DCLICK; } else { @@ -2962,9 +2973,34 @@ void wxWindow::ChangeFont(bool keepOriginalSize) wxWindow *wxGetActiveWindow() { // TODO + wxFAIL_MSG("Not implemented"); return NULL; } +// Find the wxWindow at the current mouse position, returning the mouse +// position. +wxWindow* wxFindWindowAtPointer(wxPoint& pt) +{ + return wxFindWindowAtPoint(wxGetMousePosition()); +} + +// Get the current mouse position. +wxPoint wxGetMousePosition() +{ + Display *display = (Display*) wxGetDisplay(); + Window rootWindow = RootWindowOfScreen (DefaultScreenOfDisplay(display)); + Window rootReturn, childReturn; + int rootX, rootY, winX, winY; + unsigned int maskReturn; + + XQueryPointer (display, + rootWindow, + &rootReturn, + &childReturn, + &rootX, &rootY, &winX, &winY, &maskReturn); + return wxPoint(rootX, rootY); +} + // ---------------------------------------------------------------------------- // wxNoOptimize: switch off size optimization // ----------------------------------------------------------------------------