+}
+
+// real construction (Init() must have been called before!)
+bool wxWindow::Create(wxWindow *parent, wxWindowID id,
+ const wxPoint& pos,
+ const wxSize& size,
+ long style,
+ const wxString& name)
+{
+ wxCHECK_MSG( parent, FALSE, "can't create wxWindow without parent" );
+
+ CreateBase(parent, id, pos, size, style, wxDefaultValidator, name);
+
+ parent->AddChild(this);
+
+ m_backgroundColour = wxSystemSettings::GetSystemColour(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();
+
+ 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
+ (
+ "canvasBorder",
+ xmFrameWidgetClass, parentWidget,
+ XmNshadowType, XmSHADOW_IN,
+ NULL
+ );
+ } else if (style & wxRAISED_BORDER)
+ {
+ m_borderWidget = (WXWidget)XtVaCreateManagedWidget
+ (
+ "canvasBorder",
+ xmFrameWidgetClass, parentWidget,
+ XmNshadowType, XmSHADOW_OUT,
+ NULL
+ );
+ }
+
+ 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);
+
+ // TODO?
+#if 0
+ display = XtDisplay (scrolledWindow);
+ xwindow = XtWindow (drawingArea);
+#endif // 0
+
+ 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::GetSystemColour(wxSYS_COLOUR_3DFACE);
+ DoChangeBackgroundColour(m_scrolledWindow, backgroundColour, TRUE);
+ DoChangeBackgroundColour(m_drawingArea, backgroundColour, TRUE);
+
+ XmScrolledWindowSetAreas(
+ (Widget)m_scrolledWindow,
+ (Widget) 0, (Widget) 0,
+ (Widget) m_drawingArea);
+
+#if 0
+ if (m_hScrollBar)
+ XtRealizeWidget ((Widget) m_hScrollBar);
+ if (m_vScrollBar)
+ XtRealizeWidget ((Widget) m_vScrollBar);
+#endif // 0
+
+ // Without this, the cursor may not be restored properly (e.g. in splitter
+ // sample).
+ SetCursor(*wxSTANDARD_CURSOR);
+ SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
+ SetSize(pos.x, pos.y, size.x, size.y);
+
+ return TRUE;