X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/311227c3fe69ac4d3f45999c2234d8276cf5e761..7b9da2077d0975db6c965a85c91d5aca671ab5e3:/src/motif/window.cpp diff --git a/src/motif/window.cpp b/src/motif/window.cpp index 2c8c3758cb..3dd230e4e3 100644 --- a/src/motif/window.cpp +++ b/src/motif/window.cpp @@ -40,8 +40,6 @@ #include "wx/menuitem.h" #include "wx/log.h" -#include "wx/listimpl.cpp" - #if wxUSE_DRAG_AND_DROP #include "wx/dnd.h" #endif @@ -129,12 +127,6 @@ static int str16len(const char *s) // implementation // ============================================================================ -// ---------------------------------------------------------------------------- -// list types -// ---------------------------------------------------------------------------- - -WX_DEFINE_LIST(wxRectList); - // ---------------------------------------------------------------------------- // helper functions // ---------------------------------------------------------------------------- @@ -253,7 +245,18 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id, XtAppAddActions ((XtAppContext) wxTheApp->GetAppContext(), actions, 1); Widget parentWidget = (Widget) parent->GetClientWidget(); - if (style & wxBORDER) + + if (style & wxSIMPLE_BORDER) + { + m_borderWidget = (WXWidget)XtVaCreateManagedWidget + ( + "canvasBorder", + xmFrameWidgetClass, parentWidget, + XmNshadowType, XmSHADOW_IN, + XmNshadowThickness, 1, + NULL + ); + } else if (style & wxSUNKEN_BORDER) { m_borderWidget = (WXWidget)XtVaCreateManagedWidget ( @@ -262,6 +265,15 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id, XmNshadowType, XmSHADOW_IN, NULL ); + } else if (style & wxRAISED_BORDER) + { + m_borderWidget = (WXWidget)XtVaCreateManagedWidget + ( + "canvasBorder", + xmFrameWidgetClass, parentWidget, + XmNshadowType, XmSHADOW_OUT, + NULL + ); } m_scrolledWindow = (WXWidget)XtVaCreateManagedWidget @@ -719,7 +731,7 @@ bool wxWindow::SetCursor(const wxCursor& cursor) } wxASSERT_MSG( m_cursor.Ok(), - _T("cursor must be valid after call to the base version")); + wxT("cursor must be valid after call to the base version")); WXDisplay *dpy = GetXDisplay(); WXCursor x_cursor = m_cursor.GetXCursor(dpy); @@ -888,6 +900,18 @@ void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect) GetClientSize(& w, & h); } + wxNode *cnode = m_children.First(); + while (cnode) + { + wxWindow *child = (wxWindow*) cnode->Data(); + int sx = 0; + int sy = 0; + child->GetSize( &sx, &sy ); + wxPoint pos( child->GetPosition() ); + child->SetSize( pos.x + dx, pos.y + dy, sx, sy, wxSIZE_ALLOW_MINUS_ONE ); + cnode = cnode->Next(); + } + int x1 = (dx >= 0) ? x : x - dx; int y1 = (dy >= 0) ? y : y - dy; int w1 = w - abs(dx); @@ -1591,7 +1615,7 @@ void wxWindow::OnSysColourChanged(wxSysColourChangedEvent& event) } } -void wxWindow::OnIdle(wxIdleEvent& event) +void wxWindow::OnIdle(wxIdleEvent& WXUNUSED(event)) { // This calls the UI-update mechanism (querying windows for // menu/toolbar/control state information) @@ -1633,7 +1657,7 @@ bool wxWindow::ProcessAccelerator(wxKeyEvent& event) // Try for a menu command if (frame->GetMenuBar()) { - wxMenuItem* item = frame->GetMenuBar()->FindItemForId(entry->GetCommand()); + wxMenuItem* item = frame->GetMenuBar()->FindItem(entry->GetCommand()); if (item) { wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, entry->GetCommand()); @@ -1711,7 +1735,7 @@ void wxDeleteWindowFromTable(Widget w) // ---------------------------------------------------------------------------- // Add to hash table, add event handler -bool wxWindow::AttachWidget (wxWindow* parent, WXWidget mainWidget, +bool wxWindow::AttachWidget (wxWindow* WXUNUSED(parent), WXWidget mainWidget, WXWidget formWidget, int x, int y, int width, int height) { wxAddWindowToTable((Widget) mainWidget, this); @@ -1825,7 +1849,7 @@ WXWidget wxWindow::GetLabelWidget() const // All widgets should have this as their resize proc. // OnSize sent to wxWindow via client data. -void wxWidgetResizeProc(Widget w, XConfigureEvent *event, String args[], int *num_args) +void wxWidgetResizeProc(Widget w, XConfigureEvent *WXUNUSED(event), String WXUNUSED(args)[], int *WXUNUSED(num_args)) { wxWindow *win = wxGetWindowFromTable(w); if (!win) @@ -1870,7 +1894,7 @@ static void wxCanvasRepaintProc(Widget drawingArea, // Unable to deal with Enter/Leave without a separate EventHandler (Motif 1.1.4) static void wxCanvasEnterLeave(Widget drawingArea, - XtPointer clientData, + XtPointer WXUNUSED(clientData), XCrossingEvent * event) { XmDrawingAreaCallbackStruct cbs; @@ -1885,7 +1909,7 @@ static void wxCanvasEnterLeave(Widget drawingArea, } // Fix to make it work under Motif 1.0 (!) -static void wxCanvasMotionEvent (Widget drawingArea, XButtonEvent * event) +static void wxCanvasMotionEvent (Widget WXUNUSED(drawingArea), XButtonEvent * WXUNUSED(event)) { #if XmVersion <= 1000 XmDrawingAreaCallbackStruct cbs; @@ -1900,7 +1924,7 @@ static void wxCanvasMotionEvent (Widget drawingArea, XButtonEvent * event) } static void wxCanvasInputEvent(Widget drawingArea, - XtPointer data, + XtPointer WXUNUSED(data), XmDrawingAreaCallbackStruct * cbs) { wxWindow *canvas = wxGetWindowFromTable(drawingArea); @@ -1922,6 +1946,9 @@ static void wxCanvasInputEvent(Widget drawingArea, case ButtonRelease: case MotionNotify: { + // FIXME: most of this mouse event code is more or less + // duplicated in wxTranslateMouseEvent + // wxEventType eventType = wxEVT_NULL; if (local_event.xany.type == EnterNotify) @@ -1933,7 +1960,7 @@ static void wxCanvasInputEvent(Widget drawingArea, } else if (local_event.xany.type == LeaveNotify) { - //if (local_event.xcrossing.mode!=NotifyNormal) + //if (local_event.xcrossingr.mode!=NotifyNormal) // return ; // Ignore grab events eventType = wxEVT_LEAVE_WINDOW; // canvas->GetEventHandler()->OnKillFocus(); @@ -2183,7 +2210,7 @@ static void wxCanvasInputEvent(Widget drawingArea, } static void wxPanelItemEventHandler(Widget wid, - XtPointer client_data, + XtPointer WXUNUSED(client_data), XEvent* event, Boolean *continueToDispatch) { @@ -2542,14 +2569,16 @@ bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win, Widget widget, { switch (xevent->xany.type) { - case EnterNotify: - case LeaveNotify: - case ButtonPress: - case ButtonRelease: - case MotionNotify: + case EnterNotify: // never received here - yes ? MB + case LeaveNotify: // never received here - yes ? MB + case ButtonPress: + case ButtonRelease: + case MotionNotify: { wxEventType eventType = wxEVT_NULL; + // FIXME: this is never true I think - MB + // if (xevent->xany.type == LeaveNotify) { win->SetButton1(FALSE); @@ -2563,20 +2592,59 @@ bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win, Widget widget, } else if (xevent->xany.type == ButtonPress) { + wxevent.SetTimestamp(xevent->xbutton.time); + int button = 0; if (xevent->xbutton.button == Button1) { eventType = wxEVT_LEFT_DOWN; win->SetButton1(TRUE); + button = 1; } else if (xevent->xbutton.button == Button2) { eventType = wxEVT_MIDDLE_DOWN; win->SetButton2(TRUE); + button = 2; } else if (xevent->xbutton.button == Button3) { eventType = wxEVT_RIGHT_DOWN; win->SetButton3(TRUE); + button = 3; + } + + // check for a double click + // + long dclickTime = XtGetMultiClickTime((Display*) wxGetDisplay()); + long ts = wxevent.GetTimestamp(); + + int buttonLast = win->GetLastClickedButton(); + long lastTS = win->GetLastClickTime(); + if ( buttonLast && buttonLast == button && (ts - lastTS) < dclickTime ) + { + // 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; + } + + } + else + { + // not fast enough or different button + win->SetLastClick(button, ts); } } else if (xevent->xany.type == ButtonRelease) @@ -2637,13 +2705,19 @@ bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win, Widget widget, wxevent.m_shiftDown = xevent->xbutton.state & ShiftMask; wxevent.m_controlDown = xevent->xbutton.state & ControlMask; + wxevent.m_altDown = xevent->xbutton.state & Mod3Mask; + wxevent.m_metaDown = xevent->xbutton.state & Mod1Mask; + + wxevent.SetId(win->GetId()); + wxevent.SetEventObject(win); + return TRUE; } } return FALSE; } -bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win, Widget widget, XEvent *xevent) +bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win, Widget WXUNUSED(widget), XEvent *xevent) { switch (xevent->xany.type) {