-// ----------------------------------------------------------------------------
-// CanvaseXXXSize() functions
-// ----------------------------------------------------------------------------
-
-void wxWindow::CanvasSetSize(int x, int y, int w, int h, int sizeFlags)
-{
- CanvasSetSizeIntr(x, y, w, h, sizeFlags, FALSE);
-}
-
-// SetSize, but as per old wxCanvas (with drawing widget etc.)
-void wxWindow::CanvasSetSizeIntr(int x, int y, int w, int h, int sizeFlags,
- bool fromCtor)
-{
- // A bit of optimization to help sort out the flickers.
- int oldX = 0, oldY = 0, oldW = 0, oldH = 0;
- // see the top of the file, near DoSetSizeIntr
- if( !fromCtor )
- {
- 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(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);
-
-#if 0
- XtVaSetValues(drawingArea, XmNwidth, w, NULL);
-#endif // 0
- }
- 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);
-
-#if 0
- XtVaSetValues(drawingArea, XmNheight, h, NULL);
-#endif // 0
- }
- }
-
- if (managed)
- XtManageChild (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow);
- XtVaSetValues(drawingArea, XmNresizePolicy, XmRESIZE_NONE, NULL);
-
-#if 0
- int ww, hh;
- GetClientSize (&ww, &hh);
- wxSizeEvent sizeEvent(wxSize(ww, hh), GetId());
- sizeEvent.SetEventObject(this);
-
- GetEventHandler()->ProcessEvent(sizeEvent);
-#endif // 0
-}
-
-void wxWindow::CanvasSetClientSize (int w, int h)
-{
- Widget drawingArea = (Widget) m_drawingArea;
-
- XtVaSetValues(drawingArea, XmNresizePolicy, XmRESIZE_ANY, NULL);
-
- if (w > -1)
- XtVaSetValues(drawingArea, XmNwidth, w, NULL);
- if (h > -1)
- XtVaSetValues(drawingArea, XmNheight, h, NULL);
-
-#if 0
- // 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);
- }
-#endif // 0
-
- XtVaSetValues(drawingArea, XmNresizePolicy, XmRESIZE_NONE, NULL);
-
-#if 0
- allowRepainting = TRUE;
- DoRefresh ();
-
- wxSizeEvent sizeEvent(wxSize(w, h), GetId());
- sizeEvent.SetEventObject(this);
-
- GetEventHandler()->ProcessEvent(sizeEvent);
-#endif // 0
-}
-
-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;
-}
-
-void wxWindow::CanvasGetSize (int *w, int *h) const
-{
- Dimension xx, yy;
- if ((Widget) m_borderWidget)
- XtVaGetValues ((Widget) m_borderWidget, XmNwidth, &xx, XmNheight, &yy, NULL);
- else if ((Widget) m_scrolledWindow)
- XtVaGetValues ((Widget) m_scrolledWindow, XmNwidth, &xx, XmNheight, &yy, NULL);
- else
- XtVaGetValues ((Widget) m_drawingArea, XmNwidth, &xx, XmNheight, &yy, NULL);
-
- *w = xx;
- *h = yy;
-}
-
-void wxWindow::CanvasGetPosition (int *x, int *y) const
-{
- Position xx, yy;
- XtVaGetValues (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow, XmNx, &xx, XmNy, &yy, NULL);
-
- // We may be faking the client origin.
- // So a window that's really at (0, 30) may appear
- // (to wxWin apps) to be at (0, 0).
- if (GetParent())
- {
- wxPoint pt(GetParent()->GetClientAreaOrigin());
- xx -= pt.x;
- yy -= pt.y;
- }
-
- *x = xx;
- *y = yy;
-}
-