- case FocusIn:
- {
- if (local_event.xfocus.detail != NotifyPointer)
- {
- wxFocusEvent event(wxEVT_SET_FOCUS, canvas->GetId());
- event.SetEventObject(canvas);
- canvas->GetEventHandler()->ProcessEvent(event);
- }
- break;
- }
- case FocusOut:
- {
- if (local_event.xfocus.detail != NotifyPointer)
- {
- wxFocusEvent event(wxEVT_KILL_FOCUS, canvas->GetId());
- event.SetEventObject(canvas);
- canvas->GetEventHandler()->ProcessEvent(event);
- }
- break;
- }
- default:
- break;
- }
-}
-
-void wxWindow::DoPaint()
-{
- //TODO : make a temporary gc so we can do the XCopyArea below
- if (m_backingPixmap && !m_needsRefresh)
- {
- wxPaintDC dc(this);
-
- GC tempGC = (GC) dc.GetBackingGC();
-
- Widget widget = (Widget) GetMainWidget();
-
- int scrollPosX = 0;
- int scrollPosY = 0;
-
- // We have to test whether it's a wxScrolledWindow (hack!)
- // because otherwise we don't know how many pixels have been
- // scrolled. We might solve this in the future by defining
- // virtual wxWindow functions to get the scroll position in pixels.
- // Or, each kind of scrolled window has to implement backing
- // stores itself, using generic wxWindows code.
- if (this->IsKindOf(CLASSINFO(wxScrolledWindow)))
- {
- wxScrolledWindow* scrolledWindow = (wxScrolledWindow*) this;
- int x, y;
- scrolledWindow->CalcScrolledPosition(0, 0, & x, & y);
-
- scrollPosX = - x;
- scrollPosY = - y;
- }
-
- // TODO: This could be optimized further by only copying the
- // areas in the current update region.
-
- // Only blit the part visible in the client area. The backing pixmap
- // always starts at 0, 0 but we may be looking at only a portion of it.
- wxSize clientArea = GetClientSize();
- int toBlitX = m_pixmapWidth - scrollPosX;
- int toBlitY = m_pixmapHeight - scrollPosY;
-
- // Copy whichever is samller, the amount of pixmap we have to copy,
- // or the size of the client area.
- toBlitX = wxMin(toBlitX, clientArea.x);
- toBlitY = wxMin(toBlitY, clientArea.y);
-
- // Make sure we're not negative
- toBlitX = wxMax(0, toBlitX);
- toBlitY = wxMax(0, toBlitY);
-
- XCopyArea (XtDisplay (widget), (Pixmap) m_backingPixmap, XtWindow (widget), tempGC,
- scrollPosX, scrollPosY, // Start at the scroll position
- toBlitX, toBlitY, // How much of the pixmap to copy
- 0, 0); // Destination
- }
- else
- {
- // Set an erase event first
- wxEraseEvent eraseEvent(GetId());
- eraseEvent.SetEventObject(this);
- GetEventHandler()->ProcessEvent(eraseEvent);
-
- wxPaintEvent event(GetId());
- event.SetEventObject(this);
- GetEventHandler()->ProcessEvent(event);
-
- m_needsRefresh = FALSE;
- }
-}
-
-// SetSize, but as per old wxCanvas (with drawing widget etc.)
-void wxWindow::CanvasSetSize (int x, int y, int w, int h, int sizeFlags)
-{
- // 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);