+ // A bit of optimization to help sort out the flickers.
+ int oldX, oldY, oldW, oldH;
+ GetSize(& oldW, & oldH);
+ GetPosition(& oldX, & oldY);
+
+ bool useOldPos = FALSE;
+ bool useOldSize = FALSE;
+
+ if ((x == -1) && (x == -1) && ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0))
+ useOldPos = TRUE;
+ else if (x == oldX && y == oldY)
+ useOldPos = TRUE;
+
+ if ((w == -1) && (h == -1))
+ useOldSize = TRUE;
+ else if (w == oldW && h == oldH)
+ useOldSize = TRUE;
+
+ if (!wxNoOptimize::CanOptimize())
+ {
+ useOldSize = FALSE; useOldPos = FALSE;
+ }
+
+ if (useOldPos && useOldSize)
+ return;
+
+ Widget drawingArea = (Widget) m_drawingArea;
+ bool managed = XtIsManaged(m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow);
+
+ if (managed)
+ XtUnmanageChild (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow);
+ XtVaSetValues((Widget) m_drawingArea, XmNresizePolicy, XmRESIZE_ANY, NULL);
+
+ int xx = x; int yy = y;
+ AdjustForParentClientOrigin(xx, yy, sizeFlags);
+
+ if (!useOldPos)
+ {
+ if (x > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+ {
+ XtVaSetValues (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow,
+ XmNx, xx, NULL);
+ }
+
+ if (y > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+ {
+ XtVaSetValues (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow,
+ XmNy, yy, NULL);
+ }
+ }
+
+ if (!useOldSize)
+ {
+
+ if (w > -1)
+ {
+ if (m_borderWidget)
+ {
+ XtVaSetValues ((Widget) m_borderWidget, XmNwidth, w, NULL);
+ short thick, margin;
+ XtVaGetValues ((Widget) m_borderWidget,
+ XmNshadowThickness, &thick,
+ XmNmarginWidth, &margin,
+ NULL);
+ w -= 2 * (thick + margin);
+ }
+
+ XtVaSetValues ((Widget) m_scrolledWindow, XmNwidth, w, NULL);
+
+ Dimension spacing;
+ Widget sbar;
+ XtVaGetValues ((Widget) m_scrolledWindow,
+ XmNspacing, &spacing,
+ XmNverticalScrollBar, &sbar,
+ NULL);
+ Dimension wsbar;
+ if (sbar)
+ XtVaGetValues (sbar, XmNwidth, &wsbar, NULL);
+ else
+ wsbar = 0;
+
+ w -= (spacing + wsbar);
+
+ // XtVaSetValues ((Widget) m_drawingArea, XmNwidth, w, NULL);
+ }
+ if (h > -1)
+ {
+ if (m_borderWidget)
+ {
+ XtVaSetValues ((Widget) m_borderWidget, XmNheight, h, NULL);
+ short thick, margin;
+ XtVaGetValues ((Widget) m_borderWidget,
+ XmNshadowThickness, &thick,
+ XmNmarginHeight, &margin,
+ NULL);
+ h -= 2 * (thick + margin);
+ }
+
+ XtVaSetValues ((Widget) m_scrolledWindow, XmNheight, h, NULL);
+
+ Dimension spacing;
+ Widget sbar;
+ XtVaGetValues ((Widget) m_scrolledWindow,
+ XmNspacing, &spacing,
+ XmNhorizontalScrollBar, &sbar,
+ NULL);
+ Dimension wsbar;
+ if (sbar)
+ XtVaGetValues (sbar, XmNheight, &wsbar, NULL);
+ else
+ wsbar = 0;
+
+ h -= (spacing + wsbar);
+
+ // XtVaSetValues ((Widget) m_drawingArea, XmNheight, h, NULL);
+
+ }
+ }
+
+ if (managed)
+ XtManageChild (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow);
+ XtVaSetValues((Widget) m_drawingArea, XmNresizePolicy, XmRESIZE_NONE, NULL);
+
+ /*
+ int ww, hh;
+ GetClientSize (&ww, &hh);
+ wxSizeEvent sizeEvent(wxSize(ww, hh), GetId());
+ sizeEvent.SetEventObject(this);
+
+ GetEventHandler()->ProcessEvent(sizeEvent);
+ */
+
+}
+
+void wxWindow::CanvasSetClientSize (int w, int h)
+{
+ Widget drawingArea = (Widget) m_drawingArea;
+
+ XtVaSetValues((Widget) m_drawingArea, XmNresizePolicy, XmRESIZE_ANY, NULL);
+
+ if (w > -1)
+ XtVaSetValues ((Widget) m_drawingArea, XmNwidth, w, NULL);
+ if (h > -1)
+ XtVaSetValues ((Widget) m_drawingArea, XmNheight, h, NULL);
+ /* TODO: is this necessary?
+ allowRepainting = FALSE;
+
+ XSync (XtDisplay (drawingArea), FALSE);
+ XEvent event;
+ while (XtAppPending (wxTheApp->appContext))
+ {
+ XFlush (XtDisplay (drawingArea));
+ XtAppNextEvent (wxTheApp->appContext, &event);
+ XtDispatchEvent (&event);
+ }
+ */
+
+ XtVaSetValues((Widget) m_drawingArea, XmNresizePolicy, XmRESIZE_NONE, NULL);
+
+ /* TODO
+ allowRepainting = TRUE;
+ DoRefresh ();
+ */
+
+ /*
+ wxSizeEvent sizeEvent(wxSize(w, h), GetId());
+ sizeEvent.SetEventObject(this);
+
+ GetEventHandler()->ProcessEvent(sizeEvent);
+ */
+}
+
+void wxWindow::CanvasGetClientSize (int *w, int *h) const
+{
+ // Must return the same thing that was set via SetClientSize
+ Dimension xx, yy;
+ XtVaGetValues ((Widget) m_drawingArea, XmNwidth, &xx, XmNheight, &yy, NULL);
+ *w = xx;
+ *h = yy;
+}