m_userRegion = (WXRegion) 0;
m_pixmap = (WXPixmap) 0;
m_autoSetting = 0;
+ m_oldFont = (WXFont) 0;
};
wxWindowDC::wxWindowDC( wxWindow *window )
}
m_backgroundPixel = (int) gcvalues.background;
+
+ // Get the current Font so we can set it back later
+ XGCValues valReturn;
+ XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn);
+ m_oldFont = (WXFont) valReturn.font;
};
wxWindowDC::~wxWindowDC(void)
{
+ if (m_gc && (m_oldFont != (WXFont) 0) && ((long) m_oldFont != -1))
+ {
+ XSetFont ((Display*) m_display, (GC) m_gc, (Font) m_oldFont);
+
+ if (m_window && m_window->GetBackingPixmap())
+ XSetFont ((Display*) m_display,(GC) m_gcBacking, (Font) m_oldFont);
+ }
+
if (m_gc)
XFreeGC ((Display*) m_display, (GC) m_gc);
m_gc = (WXGC) 0;
if (m_font.Ok())
{
- WXFontStructPtr pFontStruct = m_font.FindOrCreateFontStruct(m_userScaleY*m_logicalScaleY);
+ WXFontStructPtr pFontStruct = m_font.GetFontStruct(m_userScaleY*m_logicalScaleY, m_display);
int direction, descent;
XCharStruct overall_return;
if (use16)
return;
}
- WXFontStructPtr pFontStruct = theFont->FindOrCreateFontStruct(m_userScaleY*m_logicalScaleY);
+ WXFontStructPtr pFontStruct = theFont->GetFontStruct(m_userScaleY*m_logicalScaleY, m_display);
int direction, ascent, descent2;
XCharStruct overall;
if (!m_font.Ok())
return 0;
- WXFontStructPtr pFontStruct = m_font.FindOrCreateFontStruct(m_userScaleY * m_logicalScaleY);
+ WXFontStructPtr pFontStruct = m_font.GetFontStruct(m_userScaleY * m_logicalScaleY, m_display);
int direction, ascent, descent;
XCharStruct overall;
if (!m_font.Ok())
return 0;
- WXFontStructPtr pFontStruct = m_font.FindOrCreateFontStruct(m_userScaleY*m_logicalScaleY);
+ WXFontStructPtr pFontStruct = m_font.GetFontStruct(m_userScaleY*m_logicalScaleY, m_display);
int direction, ascent, descent;
XCharStruct overall;
m_font = font;
if (!m_font.Ok())
+ {
+ if ((m_oldFont != (WXFont) 0) && ((long) m_oldFont != -1))
+ {
+ XSetFont ((Display*) m_display, (GC) m_gc, (Font) m_oldFont);
+
+ if (m_window && m_window->GetBackingPixmap())
+ XSetFont ((Display*) m_display,(GC) m_gcBacking, (Font) m_oldFont);
+ }
return;
+ }
- WXFontStructPtr pFontStruct = m_font.FindOrCreateFontStruct(m_userScaleY*m_logicalScaleY);
+ WXFontStructPtr pFontStruct = m_font.GetFontStruct(m_userScaleY*m_logicalScaleY, m_display);
Font fontId = ((XFontStruct*)pFontStruct)->fid;
XSetFont ((Display*) m_display, (GC) m_gc, fontId);
if (!Ok()) return;
m_pen = pen;
- if (m_pen.Ok())
+ if (!m_pen.Ok())
return;
wxBitmap oldStipple = m_currentStipple;
{
Pixmap myStipple;
- oldStipple = NULL; // For later reset!!
+ oldStipple = (wxBitmap*) NULL; // For later reset!!
switch (m_currentFill)
{
int pixel = m_backgroundBrush.GetColour().AllocColour(m_display);
- XSetWindowBackground ((Display*) m_display, (Pixmap) m_pixmap, pixel);
+ // XSetWindowBackground doesn't work for non-Window pixmaps
+ if (!this->IsKindOf(CLASSINFO(wxMemoryDC)))
+ XSetWindowBackground ((Display*) m_display, (Pixmap) m_pixmap, pixel);
// Necessary for ::DrawIcon, which use fg/bg pixel or the GC.
// And Blit,... (Any fct that use XCopyPlane, in fact.)
// clipping imposed on a window by a repaint.
// We'll combine it with the user region. But for now,
// just use the currently-defined user clipping region.
- if (m_userRegion || (m_window && m_window->GetPaintRegion()) )
+ if (m_userRegion || (m_window && m_window->GetUpdateRegion().Ok()) )
m_currentRegion = (WXRegion) XCreateRegion ();
else
m_currentRegion = (WXRegion) NULL;
- if ((m_window && m_window->GetPaintRegion()) && m_userRegion)
- XIntersectRegion ((Region) m_window->GetPaintRegion(), (Region) m_userRegion, (Region) m_currentRegion);
+ if ((m_window && m_window->GetUpdateRegion().Ok()) && m_userRegion)
+ XIntersectRegion ((Region) m_window->GetUpdateRegion().GetXRegion(), (Region) m_userRegion, (Region) m_currentRegion);
else if (m_userRegion)
XIntersectRegion ((Region) m_userRegion, (Region) m_userRegion, (Region) m_currentRegion);
- else if (m_window && m_window->GetPaintRegion())
- XIntersectRegion ((Region) m_window->GetPaintRegion(), (Region) m_window->GetPaintRegion(),
+ else if (m_window && m_window->GetUpdateRegion().Ok())
+ XIntersectRegion ((Region) m_window->GetUpdateRegion().GetXRegion(), (Region) m_window->GetUpdateRegion().GetXRegion(),
(Region) m_currentRegion);
if (m_currentRegion)
}
};
+void wxWindowDC::SetClippingRegion( const wxRegion& region )
+{
+ wxRect box = region.GetBox();
+
+ wxDC::SetClippingRegion( box.x, box.y, box.width, box.height );
+
+ if (m_userRegion)
+ XDestroyRegion ((Region) m_userRegion);
+ m_userRegion = (WXRegion) XCreateRegion ();
+
+ XUnionRegion((Region) m_userRegion, (Region) region.GetXRegion(), (Region) m_userRegion);
+
+ SetDCClipping ();
+
+ // Needs to work differently for Pixmap: without this,
+ // there's a nasty (Display*) m_display bug. 8/12/94
+ if (m_window && m_window->GetBackingPixmap())
+ {
+ XRectangle rects[1];
+ rects[0].x = XLOG2DEV_2(box.x);
+ rects[0].y = YLOG2DEV_2(box.y);
+ rects[0].width = XLOG2DEVREL(box.width);
+ rects[0].height = YLOG2DEVREL(box.height);
+ XSetClipRectangles((Display*) m_display, (GC) m_gcBacking, 0, 0, rects, 1, Unsorted);
+ }
+};
+
+
void wxWindowDC::DestroyClippingRegion(void)
{
wxDC::DestroyClippingRegion();
}
}
-void wxWindowDC::DrawOpenSpline( wxList *points )
+void wxWindowDC::DrawSpline( wxList *points )
{
wxPoint *p;
double cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4;
wx_spline_draw_point_array( this );
};
+
+/*
+ * wxPaintDC
+ */
+
+wxPaintDC::wxPaintDC(wxWindow* win): wxWindowDC(win)
+{
+ wxRegion* region = NULL;
+
+ // Combine all the update rects into a region
+ if (win->m_updateRects.Number() > 0)
+ {
+ int i = 0;
+ for (i = 0; i < win->m_updateRects.Number(); i++)
+ {
+ wxRect* rect = (wxRect*) win->m_updateRects.Nth(i)->Data();
+ /*
+ cout << "wxPaintDC. wxRect: " << rect->x << ", " << rect->y << ", ";
+ cout << rect->width << ", " << rect->height << "\n\n";
+ */
+
+ if (!region)
+ region = new wxRegion(*rect);
+ else
+ // TODO: is this correct? In SetDCClipping above,
+ // XIntersectRegion is used to combine paint and user
+ // regions. XIntersectRegion appears to work in that case...
+ region->Union(*rect);
+ }
+ }
+ else
+ {
+ int cw, ch;
+ win->GetClientSize(&cw, &ch);
+ region = new wxRegion(wxRect(0, 0, cw, ch));
+ }
+
+ win->m_updateRegion = *region;
+
+ // Set the clipping region. Any user-defined region will be combined with this
+ // one in SetDCClipping.
+ XSetRegion ((Display*) m_display, (GC) m_gc, (Region) region->GetXRegion());
+
+ delete region;
+}
+
+wxPaintDC::~wxPaintDC()
+{
+ XSetClipMask ((Display*) m_display, (GC) m_gc, None);
+ if (m_window)
+ m_window->m_updateRegion.Clear();
+}
+