- // New translations for getting mouse motion feedback
- String translations =
- "<Btn1Motion>: wxCanvasMotionEvent() DrawingAreaInput() ManagerGadgetButtonMotion()\n\
- <Btn2Motion>: wxCanvasMotionEvent() DrawingAreaInput() ManagerGadgetButtonMotion()\n\
- <Btn3Motion>: wxCanvasMotionEvent() DrawingAreaInput() ManagerGadgetButtonMotion()\n\
- <BtnMotion>: wxCanvasMotionEvent() DrawingAreaInput() ManagerGadgetButtonMotion()\n\
- <Btn1Down>: DrawingAreaInput() ManagerGadgetArm()\n\
- <Btn2Down>: DrawingAreaInput() ManagerGadgetArm()\n\
- <Btn3Down>: DrawingAreaInput() ManagerGadgetArm()\n\
- <Btn1Up>: DrawingAreaInput() ManagerGadgetActivate()\n\
- <Btn2Up>: DrawingAreaInput() ManagerGadgetActivate()\n\
- <Btn3Up>: DrawingAreaInput() ManagerGadgetActivate()\n\
- <Motion>: wxCanvasMotionEvent() DrawingAreaInput()\n\
- <EnterWindow>: wxCanvasMotionEvent() DrawingAreaInput()\n\
- <LeaveWindow>: wxCanvasMotionEvent() DrawingAreaInput()\n\
- <Key>: DrawingAreaInput()";
-
- XtActionsRec actions[1];
- actions[0].string = "wxCanvasMotionEvent";
- actions[0].proc = (XtActionProc) wxCanvasMotionEvent;
- XtAppAddActions ((XtAppContext) wxTheApp->GetAppContext(), actions, 1);
-
- Widget parentWidget = (Widget) parent->GetClientWidget();
- if (style & wxBORDER)
- m_borderWidget = (WXWidget) XtVaCreateManagedWidget ("canvasBorder",
- xmFrameWidgetClass, parentWidget,
- XmNshadowType, XmSHADOW_IN,
- NULL);
-
- m_scrolledWindow = (WXWidget) XtVaCreateManagedWidget ("scrolledWindow",
- xmScrolledWindowWidgetClass, m_borderWidget ? (Widget) m_borderWidget : parentWidget,
- XmNspacing, 0,
- XmNscrollingPolicy, XmAPPLICATION_DEFINED,
- NULL);
-
- XtTranslations ptr;
- m_drawingArea = (WXWidget) XtVaCreateWidget ((char*) (const char*) name,
- xmDrawingAreaWidgetClass, (Widget) m_scrolledWindow,
- XmNunitType, XmPIXELS,
-// XmNresizePolicy, XmRESIZE_ANY,
- XmNresizePolicy, XmRESIZE_NONE,
- XmNmarginHeight, 0,
- XmNmarginWidth, 0,
- XmNtranslations, ptr = XtParseTranslationTable (translations),
- NULL);
- /*
- if (GetWindowStyleFlag() & wxOVERRIDE_KEY_TRANSLATIONS)
- {
- XtFree ((char *) ptr);
- ptr = XtParseTranslationTable ("<Key>: DrawingAreaInput()");
- XtOverrideTranslations ((Widget) m_drawingArea, ptr);
- XtFree ((char *) ptr);
- }
- */
-
- wxAddWindowToTable((Widget) m_drawingArea, this);
- wxAddWindowToTable((Widget) m_scrolledWindow, this);
-
- /*
- * This order is very important in Motif 1.2.1
- *
- */
-
- XtRealizeWidget ((Widget) m_scrolledWindow);
- XtRealizeWidget ((Widget) m_drawingArea);
- XtManageChild ((Widget) m_drawingArea);
-
- XtOverrideTranslations ((Widget) m_drawingArea,
- ptr = XtParseTranslationTable ("<Configure>: resize()"));
- XtFree ((char *) ptr);
-
- XtAddCallback ((Widget) m_drawingArea, XmNexposeCallback, (XtCallbackProc) wxCanvasRepaintProc, (XtPointer) this);
- XtAddCallback ((Widget) m_drawingArea, XmNinputCallback, (XtCallbackProc) wxCanvasInputEvent, (XtPointer) this);
-
- /* TODO?
- display = XtDisplay (scrolledWindow);
- xwindow = XtWindow (drawingArea);
- */
-
- XtAddEventHandler ((Widget) m_drawingArea, PointerMotionHintMask | EnterWindowMask | LeaveWindowMask | FocusChangeMask,
- False, (XtEventHandler) wxCanvasEnterLeave, (XtPointer) this);
-
- // Add scrollbars if required
- if (m_windowStyle & wxHSCROLL)
- {
- Widget hScrollBar = XtVaCreateManagedWidget ("hsb",
- xmScrollBarWidgetClass, (Widget) m_scrolledWindow,
- XmNorientation, XmHORIZONTAL,
- NULL);
- // 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);
- XtAddCallback (hScrollBar, XmNpageIncrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
- XtAddCallback (hScrollBar, XmNpageDecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
- XtAddCallback (hScrollBar, XmNtoTopCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
- XtAddCallback (hScrollBar, XmNtoBottomCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
-
- XtVaSetValues (hScrollBar,
- XmNincrement, 1,
- XmNvalue, 0,
- NULL);
-
- m_hScrollBar = (WXWidget) hScrollBar;
- m_hScroll = TRUE;
- }
- if (m_windowStyle & wxVSCROLL)
- {
- Widget vScrollBar = XtVaCreateManagedWidget ("vsb",
- xmScrollBarWidgetClass, (Widget) m_scrolledWindow,
- XmNorientation, XmVERTICAL,
- NULL);
- // 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);
- XtAddCallback (vScrollBar, XmNpageIncrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
- XtAddCallback (vScrollBar, XmNpageDecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
- XtAddCallback (vScrollBar, XmNtoTopCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
- XtAddCallback (vScrollBar, XmNtoBottomCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
-
- XtVaSetValues (vScrollBar,
- XmNincrement, 1,
- XmNvalue, 0,
- NULL);
-
- m_vScrollBar = (WXWidget) vScrollBar;
- m_vScroll = TRUE;
- }
-
- if (m_hScrollBar || m_vScrollBar)
- XmScrolledWindowSetAreas ((Widget) m_scrolledWindow, (Widget) m_hScrollBar, (Widget) m_vScrollBar, (Widget) m_drawingArea);
-
- if (m_hScrollBar)
- XtRealizeWidget ((Widget) m_hScrollBar);
- if (m_vScrollBar)
- XtRealizeWidget ((Widget) m_vScrollBar);
-
- // Without this, the cursor may not be restored properly
- // (e.g. in splitter sample).
- SetCursor(*wxSTANDARD_CURSOR);
- SetSize(pos.x, pos.y, size.x, size.y);
-
- return TRUE;