+ m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
+ m_foregroundColour = *wxBLACK;
+
+ //// TODO: we should probably optimize by only creating a
+ //// a drawing area if we have one or more scrollbars (wxVSCROLL/wxHSCROLL).
+ //// But for now, let's simplify things by always creating the
+ //// drawing area, since otherwise the translations are different.
+
+ // New translations for getting mouse motion feedback
+ static const 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();
+ m_borderWidget = wxCreateBorderWidget( (WXWidget)parentWidget, style );
+
+ m_scrolledWindow = (WXWidget)XtVaCreateManagedWidget
+ (
+ "scrolledWindow",
+ xmScrolledWindowWidgetClass,
+ m_borderWidget ? (Widget) m_borderWidget
+ : parentWidget,
+ XmNresizePolicy, XmRESIZE_NONE,
+ XmNspacing, 0,
+ XmNscrollingPolicy, XmAPPLICATION_DEFINED,
+ //XmNscrollBarDisplayPolicy, XmAS_NEEDED,
+ NULL
+ );
+
+ XtTranslations ptr = XtParseTranslationTable(translations);
+ m_drawingArea = (WXWidget)XtVaCreateWidget
+ (
+ name,
+ xmDrawingAreaWidgetClass, (Widget) m_scrolledWindow,
+ XmNunitType, XmPIXELS,
+ // XmNresizePolicy, XmRESIZE_ANY,
+ XmNresizePolicy, XmRESIZE_NONE,
+ XmNmarginHeight, 0,
+ XmNmarginWidth, 0,
+ XmNtranslations, ptr,
+ NULL
+ );
+ XtFree((char *) ptr);
+
+#if 0
+ if (GetWindowStyleFlag() & wxOVERRIDE_KEY_TRANSLATIONS)
+ {
+ ptr = XtParseTranslationTable ("<Key>: DrawingAreaInput()");
+ XtOverrideTranslations ((Widget) m_drawingArea, ptr);
+ XtFree ((char *) ptr);
+ }
+#endif // 0
+
+ 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);
+
+ ptr = XtParseTranslationTable("<Configure>: resize()");
+ XtOverrideTranslations((Widget) m_drawingArea, ptr);
+ XtFree ((char *) ptr);
+
+ XtAddCallback ((Widget) m_drawingArea, XmNexposeCallback, (XtCallbackProc) wxCanvasRepaintProc, (XtPointer) this);
+ XtAddCallback ((Widget) m_drawingArea, XmNinputCallback, (XtCallbackProc) wxCanvasInputEvent, (XtPointer) this);
+
+ XtAddEventHandler(
+ (Widget)m_drawingArea,
+ PointerMotionHintMask | EnterWindowMask |
+ LeaveWindowMask | FocusChangeMask,
+ False,
+ (XtEventHandler) wxCanvasEnterLeave,
+ (XtPointer) this
+ );
+
+ // Scrolled widget needs to have its colour changed or we get a little blue
+ // square where the scrollbars abutt
+ wxColour backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
+ wxDoChangeBackgroundColour(m_scrolledWindow, backgroundColour, TRUE);
+ wxDoChangeBackgroundColour(m_drawingArea, backgroundColour, TRUE);
+
+ XmScrolledWindowSetAreas(
+ (Widget)m_scrolledWindow,
+ (Widget) 0, (Widget) 0,
+ (Widget) m_drawingArea);
+
+ // Without this, the cursor may not be restored properly (e.g. in splitter
+ // sample).
+ SetCursor(*wxSTANDARD_CURSOR);
+ SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
+ DoSetSizeIntr(pos.x, pos.y, size.x,size.y, wxSIZE_AUTO, TRUE);
+ return TRUE;
+}
+
+// Destructor
+wxWindow::~wxWindow()
+{
+ if (g_captureWindow == this)
+ g_captureWindow = NULL;
+
+ m_isBeingDeleted = TRUE;
+
+ // Motif-specific actions first
+ WXWidget wMain = GetMainWidget();
+ if ( wMain )
+ {
+ // Removes event handlers
+ DetachWidget(wMain);
+ }
+
+ // If m_drawingArea, we're a fully-fledged window with drawing area,
+ // scrollbars etc. (what wxCanvas used to be)
+ if ( m_drawingArea )