X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4ae1af0588794ab2b46e376ec20f1b1f6b1715d0..0ef5b1dad1f5d18309d0fdc0b36ad383b58f1a2e:/src/x11/dcclient.cpp diff --git a/src/x11/dcclient.cpp b/src/x11/dcclient.cpp index 1f7200e9cc..ec9b8826b5 100644 --- a/src/x11/dcclient.cpp +++ b/src/x11/dcclient.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: x11/dcclient.cpp +// Name: src/x11/dcclient.cpp // Purpose: wxClientDC class // Author: Julian Smart, Robert Roebling // Modified by: @@ -9,21 +9,25 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) - #pragma implementation "dcclient.h" -#endif +// for compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" #include "wx/dcclient.h" -#include "wx/dcmemory.h" -#include "wx/window.h" -#include "wx/app.h" -#include "wx/image.h" -#include "wx/module.h" + +#ifndef WX_PRECOMP + #include "wx/app.h" + #include "wx/window.h" + #include "wx/math.h" + #include "wx/image.h" + #include "wx/module.h" +#endif + #include "wx/fontutil.h" +#include "wx/vector.h" #include "wx/x11/private.h" - -#include +#include "wx/x11/dcclient.h" +#include "wx/x11/dcmemory.h" #if wxUSE_UNICODE #include "glib.h" @@ -39,7 +43,8 @@ // local defines //----------------------------------------------------------------------------- -#define USE_PAINT_REGION 1 +// VZ: what is this for exactly?? +#define USE_PAINT_REGION 0 //----------------------------------------------------------------------------- // local data @@ -161,45 +166,27 @@ static void wxFreePoolGC( GC gc ) // wxWindowDC // ---------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC) +IMPLEMENT_ABSTRACT_CLASS(wxWindowDCImpl, wxX11DCImpl) -wxWindowDC::wxWindowDC() +wxWindowDCImpl::wxWindowDCImpl( wxDC *owner ) + : wxX11DCImpl( owner ) { - m_display = (WXDisplay *) NULL; - m_penGC = (WXGC *) NULL; - m_brushGC = (WXGC *) NULL; - m_textGC = (WXGC *) NULL; - m_bgGC = (WXGC *) NULL; - m_cmap = (WXColormap *) NULL; - m_isMemDC = false; - m_isScreenDC = false; - m_owner = (wxWindow *)NULL; - -#if wxUSE_UNICODE - m_context = (PangoContext *)NULL; - m_fontdesc = (PangoFontDescription *)NULL; -#endif + Init(); } -wxWindowDC::wxWindowDC( wxWindow *window ) +wxWindowDCImpl::wxWindowDCImpl( wxDC* owner, wxWindow *window ) + : wxX11DCImpl( owner ) { wxASSERT_MSG( window, wxT("DC needs a window") ); - m_display = (WXDisplay *) NULL; - m_penGC = (WXGC *) NULL; - m_brushGC = (WXGC *) NULL; - m_textGC = (WXGC *) NULL; - m_bgGC = (WXGC *) NULL; - m_cmap = (WXColormap *) NULL; - m_owner = (wxWindow *)NULL; - m_isMemDC = false; - m_isScreenDC = false; + Init(); + m_font = window->GetFont(); - m_window = (WXWindow*) window->GetMainWindow(); + m_x11window = (WXWindow*) window->GetMainWindow(); // not realized ? - if (!m_window) + if (!m_x11window) { // don't report problems m_ok = true; @@ -210,7 +197,6 @@ wxWindowDC::wxWindowDC( wxWindow *window ) m_display = (WXDisplay *) wxGlobalDisplay(); #if wxUSE_UNICODE - m_context = wxTheApp->GetPangoContext(); m_fontdesc = window->GetFont().GetNativeFontInfo()->description; #endif @@ -221,46 +207,72 @@ wxWindowDC::wxWindowDC( wxWindow *window ) /* this must be done after SetUpDC, bacause SetUpDC calls the repective SetBrush, SetPen, SetBackground etc functions - to set up the DC. SetBackground call m_owner->SetBackground + to set up the DC. SetBackground call m_window->SetBackground and this might not be desired as the standard dc background is white whereas a window might assume gray to be the standard (as e.g. wxStatusBar) */ - m_owner = window; + m_window = window; } -wxWindowDC::~wxWindowDC() +wxWindowDCImpl::~wxWindowDCImpl() { Destroy(); } -void wxWindowDC::SetUpDC() +void wxWindowDCImpl::Init() +{ + m_display = (WXDisplay *) NULL; + m_penGC = (WXGC *) NULL; + m_brushGC = (WXGC *) NULL; + m_textGC = (WXGC *) NULL; + m_bgGC = (WXGC *) NULL; + m_cmap = (WXColormap *) NULL; + m_isMemDC = false; + m_isScreenDC = false; + m_x11window = (WXWindow*) NULL; + +#if wxUSE_UNICODE + m_context = wxTheApp->GetPangoContext(); + m_fontdesc = (PangoFontDescription *)NULL; +#endif +} + +void wxWindowDCImpl::SetUpDC() { m_ok = true; wxASSERT_MSG( !m_penGC, wxT("GCs already created") ); + bool ismono = false; + if (m_isMemDC) + { + wxMemoryDCImpl *mem_impl = (wxMemoryDCImpl *) this; + if (mem_impl->GetSelectedBitmap().IsOk()) + ismono = mem_impl->GetSelectedBitmap().GetDepth() == 1; + } + if (m_isScreenDC) { - m_penGC = (WXGC*) wxGetPoolGC( (Window) m_window, wxPEN_SCREEN ); - m_brushGC = (WXGC*) wxGetPoolGC( (Window) m_window, wxBRUSH_SCREEN ); - m_textGC = (WXGC*) wxGetPoolGC( (Window) m_window, wxTEXT_SCREEN ); - m_bgGC = (WXGC*) wxGetPoolGC( (Window) m_window, wxBG_SCREEN ); + m_penGC = (WXGC*) wxGetPoolGC( (Window) m_x11window, wxPEN_SCREEN ); + m_brushGC = (WXGC*) wxGetPoolGC( (Window) m_x11window, wxBRUSH_SCREEN ); + m_textGC = (WXGC*) wxGetPoolGC( (Window) m_x11window, wxTEXT_SCREEN ); + m_bgGC = (WXGC*) wxGetPoolGC( (Window) m_x11window, wxBG_SCREEN ); } else - if (m_isMemDC && (((wxMemoryDC*)this)->m_selected.GetDepth() == 1)) + if (m_isMemDC && ismono) { - m_penGC = (WXGC*) wxGetPoolGC( (Window) m_window, wxPEN_MONO ); - m_brushGC = (WXGC*) wxGetPoolGC( (Window) m_window, wxBRUSH_MONO ); - m_textGC = (WXGC*) wxGetPoolGC( (Window) m_window, wxTEXT_MONO ); - m_bgGC = (WXGC*) wxGetPoolGC( (Window) m_window, wxBG_MONO ); + m_penGC = (WXGC*) wxGetPoolGC( (Window) m_x11window, wxPEN_MONO ); + m_brushGC = (WXGC*) wxGetPoolGC( (Window) m_x11window, wxBRUSH_MONO ); + m_textGC = (WXGC*) wxGetPoolGC( (Window) m_x11window, wxTEXT_MONO ); + m_bgGC = (WXGC*) wxGetPoolGC( (Window) m_x11window, wxBG_MONO ); } else { - m_penGC = (WXGC*) wxGetPoolGC( (Window) m_window, wxPEN_COLOUR ); - m_brushGC = (WXGC*) wxGetPoolGC( (Window) m_window, wxBRUSH_COLOUR ); - m_textGC = (WXGC*) wxGetPoolGC( (Window) m_window, wxTEXT_COLOUR ); - m_bgGC = (WXGC*) wxGetPoolGC( (Window) m_window, wxBG_COLOUR ); + m_penGC = (WXGC*) wxGetPoolGC( (Window) m_x11window, wxPEN_COLOUR ); + m_brushGC = (WXGC*) wxGetPoolGC( (Window) m_x11window, wxBRUSH_COLOUR ); + m_textGC = (WXGC*) wxGetPoolGC( (Window) m_x11window, wxTEXT_COLOUR ); + m_bgGC = (WXGC*) wxGetPoolGC( (Window) m_x11window, wxBG_COLOUR ); } /* background colour */ @@ -331,43 +343,43 @@ void wxWindowDC::SetUpDC() } } -void wxWindowDC::DoGetSize( int* width, int* height ) const +void wxWindowDCImpl::DoGetSize( int* width, int* height ) const { - wxCHECK_RET( m_owner, _T("GetSize() doesn't work without window") ); + wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") ); - m_owner->GetSize(width, height); + m_window->GetSize(width, height); } extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y, const wxColour & col, int style); -bool wxWindowDC::DoFloodFill(wxCoord x, wxCoord y, +bool wxWindowDCImpl::DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style) { - return wxDoFloodFill(this, x, y, col, style); + return wxDoFloodFill(GetOwner(), x, y, col, style); } -bool wxWindowDC::DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const +bool wxWindowDCImpl::DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const { // Generic (and therefore rather inefficient) method. // Could be improved. wxMemoryDC memdc; wxBitmap bitmap(1, 1); memdc.SelectObject(bitmap); - memdc.Blit(0, 0, 1, 1, (wxDC*) this, x1, y1); + memdc.Blit(0, 0, 1, 1, GetOwner(), x1, y1); memdc.SelectObject(wxNullBitmap); wxImage image(bitmap.ConvertToImage()); col->Set(image.GetRed(0, 0), image.GetGreen(0, 0), image.GetBlue(0, 0)); return true; } -void wxWindowDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 ) +void wxWindowDCImpl::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 ) { - wxCHECK_RET( Ok(), wxT("invalid window dc") ); + wxCHECK_RET( IsOk(), wxT("invalid window dc") ); if (m_pen.GetStyle() != wxTRANSPARENT) { - if (m_window) + if (m_x11window) { // This hack is for the iPaq: XDrawLine draws // nothing, whereas XDrawLines works... @@ -376,9 +388,9 @@ void wxWindowDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 ) points[0].y = y1; points[1].x = x2; points[1].y = y2; - DrawLines( 2, points, 0, 0 ); + DoDrawLines( 2, points, 0, 0 ); - // XDrawLine( (Display*) m_display, (Window) m_window, + // XDrawLine( (Display*) m_display, (Window) m_x11window, // (GC) m_penGC, XLOG2DEV(x1), YLOG2DEV(y1), XLOG2DEV(x2), YLOG2DEV(y2) ); } @@ -387,30 +399,30 @@ void wxWindowDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 ) } } -void wxWindowDC::DoCrossHair( wxCoord x, wxCoord y ) +void wxWindowDCImpl::DoCrossHair( wxCoord x, wxCoord y ) { - wxCHECK_RET( Ok(), wxT("invalid window dc") ); + wxCHECK_RET( IsOk(), wxT("invalid window dc") ); if (m_pen.GetStyle() != wxTRANSPARENT) { int w = 0; int h = 0; - GetSize( &w, &h ); + DoGetSize( &w, &h ); wxCoord xx = XLOG2DEV(x); wxCoord yy = YLOG2DEV(y); - if (m_window) + if (m_x11window) { - XDrawLine( (Display*) m_display, (Window) m_window, + XDrawLine( (Display*) m_display, (Window) m_x11window, (GC) m_penGC, 0, yy, XLOG2DEVREL(w), yy ); - XDrawLine( (Display*) m_display, (Window) m_window, + XDrawLine( (Display*) m_display, (Window) m_x11window, (GC) m_penGC, xx, 0, xx, YLOG2DEVREL(h) ); } } } -void wxWindowDC::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc ) +void wxWindowDCImpl::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc ) { - wxCHECK_RET( Ok(), wxT("invalid window dc") ); + wxCHECK_RET( IsOk(), wxT("invalid window dc") ); wxCoord xx1 = XLOG2DEV(x1); wxCoord yy1 = YLOG2DEV(y1); @@ -448,7 +460,7 @@ void wxWindowDC::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCo while (alpha2 <= 0) alpha2 += 360*64; while (alpha1 > 360*64) alpha1 -= 360*64; - if (m_window) + if (m_x11window) { if (m_brush.GetStyle() != wxTRANSPARENT) { @@ -458,7 +470,7 @@ void wxWindowDC::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCo m_deviceOriginX % m_brush.GetStipple()->GetWidth(), m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - XFillArc( (Display*) m_display, (Window) m_window, + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 ); XSetTSOrigin( (Display*) m_display, (GC) m_textGC, 0, 0 ); @@ -468,7 +480,7 @@ void wxWindowDC::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCo XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, m_deviceOriginX % 15, m_deviceOriginY % 15 ); - XFillArc( (Display*) m_display, (Window) m_window, + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 ); XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0 ); @@ -478,7 +490,7 @@ void wxWindowDC::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCo XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, m_deviceOriginX % 16, m_deviceOriginY % 16 ); - XFillArc( (Display*) m_display, (Window) m_window, + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 ); XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0 ); @@ -489,27 +501,27 @@ void wxWindowDC::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCo m_deviceOriginX % m_brush.GetStipple()->GetWidth(), m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - XFillArc( (Display*) m_display, (Window) m_window, + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 ); XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0 ); } else { - XFillArc( (Display*) m_display, (Window) m_window, + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 ); } } if (m_pen.GetStyle() != wxTRANSPARENT) { - XDrawArc( (Display*) m_display, (Window) m_window, + XDrawArc( (Display*) m_display, (Window) m_x11window, (GC) m_penGC, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 ); - XDrawLine( (Display*) m_display, (Window) m_window, + XDrawLine( (Display*) m_display, (Window) m_x11window, (GC) m_penGC, xx1, yy1, xxc, yyc ); - XDrawLine( (Display*) m_display, (Window) m_window, + XDrawLine( (Display*) m_display, (Window) m_x11window, (GC) m_penGC, xxc, yyc, xx2, yy2 ); } } @@ -518,9 +530,9 @@ void wxWindowDC::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCo CalcBoundingBox (x2, y2); } -void wxWindowDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double sa, double ea ) +void wxWindowDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double sa, double ea ) { - wxCHECK_RET( Ok(), wxT("invalid window dc") ); + wxCHECK_RET( IsOk(), wxT("invalid window dc") ); wxCoord xx = XLOG2DEV(x); wxCoord yy = YLOG2DEV(y); @@ -531,7 +543,7 @@ void wxWindowDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxCoord if (ww < 0) { ww = -ww; xx = xx - ww; } if (hh < 0) { hh = -hh; yy = yy - hh; } - if (m_window) + if (m_x11window) { wxCoord start = wxCoord(sa * 64.0); wxCoord end = wxCoord((ea-sa) * 64.0); @@ -544,7 +556,7 @@ void wxWindowDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxCoord m_deviceOriginX % m_brush.GetStipple()->GetWidth(), m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - XFillArc( (Display*) m_display, (Window) m_window, + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_textGC, xx, yy, ww, hh, start, end ); XSetTSOrigin( (Display*) m_display, (GC) m_textGC, 0, 0 ); @@ -554,7 +566,7 @@ void wxWindowDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxCoord XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, m_deviceOriginX % 15, m_deviceOriginY % 15 ); - XFillArc( (Display*) m_display, (Window) m_window, + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx, yy, ww, hh, start, end ); XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0 ); @@ -564,7 +576,7 @@ void wxWindowDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxCoord XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, m_deviceOriginX % 16, m_deviceOriginY % 16 ); - XFillArc( (Display*) m_display, (Window) m_window, + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx, yy, ww, hh, start, end ); XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0 ); @@ -575,21 +587,21 @@ void wxWindowDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxCoord m_deviceOriginX % m_brush.GetStipple()->GetWidth(), m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - XFillArc( (Display*) m_display, (Window) m_window, + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx, yy, ww, hh, start, end ); XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0 ); } else { - XFillArc( (Display*) m_display, (Window) m_window, + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx, yy, ww, hh, start, end ); } } if (m_pen.GetStyle() != wxTRANSPARENT) { - XDrawArc( (Display*) m_display, (Window) m_window, + XDrawArc( (Display*) m_display, (Window) m_x11window, (GC) m_penGC, xx, yy, ww, hh, start, end ); } } @@ -598,20 +610,20 @@ void wxWindowDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxCoord CalcBoundingBox (x + width, y + height); } -void wxWindowDC::DoDrawPoint( wxCoord x, wxCoord y ) +void wxWindowDCImpl::DoDrawPoint( wxCoord x, wxCoord y ) { - wxCHECK_RET( Ok(), wxT("invalid window dc") ); + wxCHECK_RET( IsOk(), wxT("invalid window dc") ); - if ((m_pen.GetStyle() != wxTRANSPARENT) && m_window) - XDrawPoint( (Display*) m_display, (Window) m_window, + if ((m_pen.GetStyle() != wxTRANSPARENT) && m_x11window) + XDrawPoint( (Display*) m_display, (Window) m_x11window, (GC) m_penGC, XLOG2DEV(x), YLOG2DEV(y) ); CalcBoundingBox (x, y); } -void wxWindowDC::DoDrawLines( int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset ) +void wxWindowDCImpl::DoDrawLines( int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset ) { - wxCHECK_RET( Ok(), wxT("invalid window dc") ); + wxCHECK_RET( IsOk(), wxT("invalid window dc") ); if (m_pen.GetStyle() == wxTRANSPARENT) return; if (n <= 0) return; @@ -624,15 +636,16 @@ void wxWindowDC::DoDrawLines( int n, wxPoint points[], wxCoord xoffset, wxCoord CalcBoundingBox( points[i].x + xoffset, points[i].y + yoffset ); } - XDrawLines( (Display*) m_display, (Window) m_window, (GC) m_penGC, xpoints, n, 0 ); + XDrawLines( (Display*) m_display, (Window) m_x11window, (GC) m_penGC, xpoints, n, 0 ); delete[] xpoints; } -void wxWindowDC::DoDrawPolygon( int n, wxPoint points[], - wxCoord xoffset, wxCoord yoffset, int fillStyle ) +void wxWindowDCImpl::DoDrawPolygon( int n, wxPoint points[], + wxCoord xoffset, wxCoord yoffset, + int WXUNUSED(fillStyle) ) { - wxCHECK_RET( Ok(), wxT("invalid window dc") ); + wxCHECK_RET( IsOk(), wxT("invalid window dc") ); if (n <= 0) return; @@ -646,7 +659,7 @@ void wxWindowDC::DoDrawPolygon( int n, wxPoint points[], CalcBoundingBox (points[i].x + xoffset, points[i].y + yoffset); } - if (m_window) + if (m_x11window) { if (m_brush.GetStyle() != wxTRANSPARENT) { @@ -657,7 +670,7 @@ void wxWindowDC::DoDrawPolygon( int n, wxPoint points[], m_deviceOriginX % m_brush.GetStipple()->GetWidth(), m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - XFillPolygon( (Display*) m_display, (Window) m_window, + XFillPolygon( (Display*) m_display, (Window) m_x11window, (GC) m_textGC, xpoints, n, Complex, 0); XSetTSOrigin( (Display*) m_display, (GC) m_textGC, 0, 0 ); @@ -667,7 +680,7 @@ void wxWindowDC::DoDrawPolygon( int n, wxPoint points[], XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, m_deviceOriginX % 15, m_deviceOriginY % 15 ); - XFillPolygon( (Display*) m_display, (Window) m_window, + XFillPolygon( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xpoints, n, Complex, 0); XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0 ); @@ -677,7 +690,7 @@ void wxWindowDC::DoDrawPolygon( int n, wxPoint points[], XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, m_deviceOriginX % 16, m_deviceOriginY % 16 ); - XFillPolygon( (Display*) m_display, (Window) m_window, + XFillPolygon( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xpoints, n, Complex, 0); XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0 ); @@ -688,14 +701,14 @@ void wxWindowDC::DoDrawPolygon( int n, wxPoint points[], m_deviceOriginX % m_brush.GetStipple()->GetWidth(), m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - XFillPolygon( (Display*) m_display, (Window) m_window, + XFillPolygon( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xpoints, n, Complex, 0); XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0 ); } else { - XFillPolygon( (Display*) m_display, (Window) m_window, + XFillPolygon( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xpoints, n, Complex, 0); } } @@ -706,16 +719,16 @@ void wxWindowDC::DoDrawPolygon( int n, wxPoint points[], xpoints[i].x = xpoints[0].x; xpoints[i].y = xpoints[0].y; - XDrawLines( (Display*) m_display, (Window) m_window, (GC) m_penGC, xpoints, n + 1, 0); + XDrawLines( (Display*) m_display, (Window) m_x11window, (GC) m_penGC, xpoints, n + 1, 0); } } delete[] xpoints; } -void wxWindowDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) +void wxWindowDCImpl::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) { - wxCHECK_RET( Ok(), wxT("invalid window dc") ); + wxCHECK_RET( IsOk(), wxT("invalid window dc") ); wxCoord xx = XLOG2DEV(x); wxCoord yy = YLOG2DEV(y); @@ -729,7 +742,7 @@ void wxWindowDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord h if (ww < 0) { ww = -ww; xx = xx - ww; } if (hh < 0) { hh = -hh; yy = yy - hh; } - if (m_window) + if (m_x11window) { if (m_brush.GetStyle() != wxTRANSPARENT) { @@ -739,7 +752,7 @@ void wxWindowDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord h m_deviceOriginX % m_brush.GetStipple()->GetWidth(), m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - XFillRectangle( (Display*) m_display, (Window) m_window, + XFillRectangle( (Display*) m_display, (Window) m_x11window, (GC) m_textGC, xx, yy, ww, hh ); XSetTSOrigin( (Display*) m_display, (GC) m_textGC, 0, 0 ); @@ -749,7 +762,7 @@ void wxWindowDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord h XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, m_deviceOriginX % 15, m_deviceOriginY % 15 ); - XFillRectangle( (Display*) m_display, (Window) m_window, + XFillRectangle( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx, yy, ww, hh ); XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0 ); @@ -759,7 +772,7 @@ void wxWindowDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord h XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, m_deviceOriginX % 16, m_deviceOriginY % 16 ); - XFillRectangle( (Display*) m_display, (Window) m_window, + XFillRectangle( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx, yy, ww, hh ); XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0 ); @@ -770,21 +783,21 @@ void wxWindowDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord h m_deviceOriginX % m_brush.GetStipple()->GetWidth(), m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - XFillRectangle( (Display*) m_display, (Window) m_window, + XFillRectangle( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx, yy, ww, hh ); XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0 ); } else { - XFillRectangle( (Display*) m_display, (Window) m_window, + XFillRectangle( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx, yy, ww, hh ); } } if (m_pen.GetStyle () != wxTRANSPARENT) { - XDrawRectangle( (Display*) m_display, (Window) m_window, + XDrawRectangle( (Display*) m_display, (Window) m_x11window, (GC) m_penGC, xx, yy, ww-1, hh-1 ); } } @@ -793,9 +806,9 @@ void wxWindowDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord h CalcBoundingBox( x + width, y + height ); } -void wxWindowDC::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius ) +void wxWindowDCImpl::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius ) { - wxCHECK_RET( Ok(), wxT("invalid window dc") ); + wxCHECK_RET( IsOk(), wxT("invalid window dc") ); if (radius < 0.0) radius = - radius * ((width < height) ? width : height); @@ -813,7 +826,7 @@ void wxWindowDC::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width, wx // X drawing errors with small radii if (rr == 0) { - XDrawRectangle( (Display*) m_display, (Window) m_window, + XDrawRectangle( (Display*) m_display, (Window) m_x11window, (GC) m_penGC, x, y, width, height); return; } @@ -829,7 +842,7 @@ void wxWindowDC::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width, wx hh--; } - if (m_window) + if (m_x11window) { // CMB: ensure dd is not larger than rectangle otherwise we // get an hour glass shape @@ -845,34 +858,34 @@ void wxWindowDC::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width, wx XSetTSOrigin( (Display*) m_display, (GC) m_textGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - XFillRectangle( (Display*) m_display, (Window) m_window, (GC) m_textGC, xx+rr, yy, ww-dd+1, hh ); - XFillRectangle( (Display*) m_display, (Window) m_window, (GC) m_textGC, xx, yy+rr, ww, hh-dd+1 ); - XFillArc( (Display*) m_display, (Window) m_window, (GC) m_textGC, xx, yy, dd, dd, 90*64, 90*64 ); - XFillArc( (Display*) m_display, (Window) m_window, (GC) m_textGC, xx+ww-dd, yy, dd, dd, 0, 90*64 ); - XFillArc( (Display*) m_display, (Window) m_window, (GC) m_textGC, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); - XFillArc( (Display*) m_display, (Window) m_window, (GC) m_textGC, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); + XFillRectangle( (Display*) m_display, (Window) m_x11window, (GC) m_textGC, xx+rr, yy, ww-dd+1, hh ); + XFillRectangle( (Display*) m_display, (Window) m_x11window, (GC) m_textGC, xx, yy+rr, ww, hh-dd+1 ); + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_textGC, xx, yy, dd, dd, 90*64, 90*64 ); + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_textGC, xx+ww-dd, yy, dd, dd, 0, 90*64 ); + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_textGC, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_textGC, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); XSetTSOrigin( (Display*) m_display, (GC) m_textGC, 0, 0); } else if (IS_15_PIX_HATCH(m_brush.GetStyle())) { XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, m_deviceOriginX % 15, m_deviceOriginY % 15 ); - XFillRectangle( (Display*) m_display, (Window) m_window, (GC) m_brushGC, xx+rr, yy, ww-dd+1, hh ); - XFillRectangle( (Display*) m_display, (Window) m_window, (GC) m_brushGC, xx, yy+rr, ww, hh-dd+1 ); - XFillArc( (Display*) m_display, (Window) m_window, (GC) m_brushGC, xx, yy, dd, dd, 90*64, 90*64 ); - XFillArc( (Display*) m_display, (Window) m_window, (GC) m_brushGC, xx+ww-dd, yy, dd, dd, 0, 90*64 ); - XFillArc( (Display*) m_display, (Window) m_window, (GC) m_brushGC, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); - XFillArc( (Display*) m_display, (Window) m_window, (GC) m_brushGC, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); + XFillRectangle( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx+rr, yy, ww-dd+1, hh ); + XFillRectangle( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx, yy+rr, ww, hh-dd+1 ); + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx, yy, dd, dd, 90*64, 90*64 ); + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx+ww-dd, yy, dd, dd, 0, 90*64 ); + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0); } else if (IS_16_PIX_HATCH(m_brush.GetStyle())) { XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, m_deviceOriginX % 16, m_deviceOriginY % 16 ); - XFillRectangle( (Display*) m_display, (Window) m_window, (GC) m_brushGC, xx+rr, yy, ww-dd+1, hh ); - XFillRectangle( (Display*) m_display, (Window) m_window, (GC) m_brushGC, xx, yy+rr, ww, hh-dd+1 ); - XFillArc( (Display*) m_display, (Window) m_window, (GC) m_brushGC, xx, yy, dd, dd, 90*64, 90*64 ); - XFillArc( (Display*) m_display, (Window) m_window, (GC) m_brushGC, xx+ww-dd, yy, dd, dd, 0, 90*64 ); - XFillArc( (Display*) m_display, (Window) m_window, (GC) m_brushGC, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); - XFillArc( (Display*) m_display, (Window) m_window, (GC) m_brushGC, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); + XFillRectangle( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx+rr, yy, ww-dd+1, hh ); + XFillRectangle( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx, yy+rr, ww, hh-dd+1 ); + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx, yy, dd, dd, 90*64, 90*64 ); + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx+ww-dd, yy, dd, dd, 0, 90*64 ); + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0); } else if (m_brush.GetStyle() == wxSTIPPLE) @@ -880,34 +893,34 @@ void wxWindowDC::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width, wx XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - XFillRectangle( (Display*) m_display, (Window) m_window, (GC) m_brushGC, xx+rr, yy, ww-dd+1, hh ); - XFillRectangle( (Display*) m_display, (Window) m_window, (GC) m_brushGC, xx, yy+rr, ww, hh-dd+1 ); - XFillArc( (Display*) m_display, (Window) m_window, (GC) m_brushGC, xx, yy, dd, dd, 90*64, 90*64 ); - XFillArc( (Display*) m_display, (Window) m_window, (GC) m_brushGC, xx+ww-dd, yy, dd, dd, 0, 90*64 ); - XFillArc( (Display*) m_display, (Window) m_window, (GC) m_brushGC, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); - XFillArc( (Display*) m_display, (Window) m_window, (GC) m_brushGC, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); + XFillRectangle( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx+rr, yy, ww-dd+1, hh ); + XFillRectangle( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx, yy+rr, ww, hh-dd+1 ); + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx, yy, dd, dd, 90*64, 90*64 ); + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx+ww-dd, yy, dd, dd, 0, 90*64 ); + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0); } else { - XFillRectangle( (Display*) m_display, (Window) m_window, (GC) m_brushGC, xx+rr, yy, ww-dd+1, hh ); - XFillRectangle( (Display*) m_display, (Window) m_window, (GC) m_brushGC, xx, yy+rr, ww, hh-dd+1 ); - XFillArc( (Display*) m_display, (Window) m_window, (GC) m_brushGC, xx, yy, dd, dd, 90*64, 90*64 ); - XFillArc( (Display*) m_display, (Window) m_window, (GC) m_brushGC, xx+ww-dd, yy, dd, dd, 0, 90*64 ); - XFillArc( (Display*) m_display, (Window) m_window, (GC) m_brushGC, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); - XFillArc( (Display*) m_display, (Window) m_window, (GC) m_brushGC, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); + XFillRectangle( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx+rr, yy, ww-dd+1, hh ); + XFillRectangle( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx, yy+rr, ww, hh-dd+1 ); + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx, yy, dd, dd, 90*64, 90*64 ); + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx+ww-dd, yy, dd, dd, 0, 90*64 ); + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); } } if (m_pen.GetStyle() != wxTRANSPARENT) { - XDrawLine( (Display*) m_display, (Window) m_window, (GC) m_penGC, xx+rr+1, yy, xx+ww-rr, yy ); - XDrawLine( (Display*) m_display, (Window) m_window, (GC) m_penGC, xx+rr+1, yy+hh, xx+ww-rr, yy+hh ); - XDrawLine( (Display*) m_display, (Window) m_window, (GC) m_penGC, xx, yy+rr+1, xx, yy+hh-rr ); - XDrawLine( (Display*) m_display, (Window) m_window, (GC) m_penGC, xx+ww, yy+rr+1, xx+ww, yy+hh-rr ); - XDrawArc( (Display*) m_display, (Window) m_window, (GC) m_penGC, xx, yy, dd, dd, 90*64, 90*64 ); - XDrawArc( (Display*) m_display, (Window) m_window, (GC) m_penGC, xx+ww-dd, yy, dd, dd, 0, 90*64 ); - XDrawArc( (Display*) m_display, (Window) m_window, (GC) m_penGC, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); - XDrawArc( (Display*) m_display, (Window) m_window, (GC) m_penGC, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); + XDrawLine( (Display*) m_display, (Window) m_x11window, (GC) m_penGC, xx+rr+1, yy, xx+ww-rr, yy ); + XDrawLine( (Display*) m_display, (Window) m_x11window, (GC) m_penGC, xx+rr+1, yy+hh, xx+ww-rr, yy+hh ); + XDrawLine( (Display*) m_display, (Window) m_x11window, (GC) m_penGC, xx, yy+rr+1, xx, yy+hh-rr ); + XDrawLine( (Display*) m_display, (Window) m_x11window, (GC) m_penGC, xx+ww, yy+rr+1, xx+ww, yy+hh-rr ); + XDrawArc( (Display*) m_display, (Window) m_x11window, (GC) m_penGC, xx, yy, dd, dd, 90*64, 90*64 ); + XDrawArc( (Display*) m_display, (Window) m_x11window, (GC) m_penGC, xx+ww-dd, yy, dd, dd, 0, 90*64 ); + XDrawArc( (Display*) m_display, (Window) m_x11window, (GC) m_penGC, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); + XDrawArc( (Display*) m_display, (Window) m_x11window, (GC) m_penGC, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); } } @@ -916,9 +929,9 @@ void wxWindowDC::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width, wx CalcBoundingBox( x + width, y + height ); } -void wxWindowDC::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) +void wxWindowDCImpl::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) { - wxCHECK_RET( Ok(), wxT("invalid window dc") ); + wxCHECK_RET( IsOk(), wxT("invalid window dc") ); wxCoord xx = XLOG2DEV(x); wxCoord yy = YLOG2DEV(y); @@ -929,7 +942,7 @@ void wxWindowDC::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord hei if (ww < 0) { ww = -ww; xx = xx - ww; } if (hh < 0) { hh = -hh; yy = yy - hh; } - if (m_window) + if (m_x11window) { if (m_brush.GetStyle() != wxTRANSPARENT) { @@ -939,7 +952,7 @@ void wxWindowDC::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord hei m_deviceOriginX % m_brush.GetStipple()->GetWidth(), m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - XFillArc( (Display*) m_display, (Window) m_window, + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_textGC, xx, yy, ww, hh, 0, 360*64 ); XSetTSOrigin( (Display*) m_display, (GC) m_textGC, 0, 0 ); @@ -949,7 +962,7 @@ void wxWindowDC::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord hei XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, m_deviceOriginX % 15, m_deviceOriginY % 15 ); - XFillArc( (Display*) m_display, (Window) m_window, + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx, yy, ww, hh, 0, 360*64 ); XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0 ); @@ -959,7 +972,7 @@ void wxWindowDC::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord hei XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, m_deviceOriginX % 16, m_deviceOriginY % 16 ); - XFillArc( (Display*) m_display, (Window) m_window, + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx, yy, ww, hh, 0, 360*64 ); XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0 ); @@ -970,21 +983,21 @@ void wxWindowDC::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord hei m_deviceOriginX % m_brush.GetStipple()->GetWidth(), m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - XFillArc( (Display*) m_display, (Window) m_window, + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx, yy, ww, hh, 0, 360*64 ); XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0 ); } else { - XFillArc( (Display*) m_display, (Window) m_window, + XFillArc( (Display*) m_display, (Window) m_x11window, (GC) m_brushGC, xx, yy, ww, hh, 0, 360*64 ); } } if (m_pen.GetStyle () != wxTRANSPARENT) { - XDrawArc( (Display*) m_display, (Window) m_window, + XDrawArc( (Display*) m_display, (Window) m_x11window, (GC) m_penGC, xx, yy, ww, hh, 0, 360*64 ); } } @@ -993,19 +1006,19 @@ void wxWindowDC::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord hei CalcBoundingBox( x + width, y + height ); } -void wxWindowDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y) +void wxWindowDCImpl::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y) { DoDrawBitmap(icon, x, y, true); } #if wxUSE_NANOX -void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap, +void wxWindowDCImpl::DoDrawBitmap( const wxBitmap &bitmap, wxCoord x, wxCoord y, bool useMask ) { - wxCHECK_RET( Ok(), wxT("invalid window dc") ); + wxCHECK_RET( IsOk(), wxT("invalid window dc") ); - wxCHECK_RET( bitmap.Ok(), wxT("invalid bitmap") ); + wxCHECK_RET( bitmap.IsOk(), wxT("invalid bitmap") ); bool is_mono = (bitmap.GetBitmap() != NULL); @@ -1019,7 +1032,7 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap, CalcBoundingBox( x, y ); CalcBoundingBox( x + w, y + h ); - if (!m_window) return; + if (!m_x11window) return; int ww = XLOG2DEVREL(w); int hh = YLOG2DEVREL(h); @@ -1075,7 +1088,7 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap, // In DoBlit, we may be able to eliminate this step // if we check if the rop = copy #if 0 - GrCopyArea(bufPixmap, gc, 0, 0, w, h, (Window) m_window, + GrCopyArea(bufPixmap, gc, 0, 0, w, h, (Window) m_x11window, 0, 0, GR_MODE_COPY); #endif @@ -1093,18 +1106,18 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap, // set unmasked area in dest to BLACK GrSetGCBackground(gc, BLACK); GrSetGCForeground(gc, WHITE); - GrCopyArea((Window) m_window, gc, xx, yy, w, h, maskPixmap, + GrCopyArea((Window) m_x11window, gc, xx, yy, w, h, maskPixmap, 0, 0, GR_MODE_AND); // OR buffer to dest - GrCopyArea((Window) m_window, gc, xx, yy, w, h, bufPixmap, + GrCopyArea((Window) m_x11window, gc, xx, yy, w, h, bufPixmap, 0, 0, GR_MODE_OR); GrDestroyGC(gc); GrDestroyWindow(bufPixmap); } else - XCopyArea( (Display*) m_display, (Pixmap) use_bitmap.GetPixmap(), (Window) m_window, + XCopyArea( (Display*) m_display, (Pixmap) use_bitmap.GetPixmap(), (Window) m_x11window, (GC) m_penGC, 0, 0, w, h, xx, yy ); /* remove mask again if any */ @@ -1118,13 +1131,13 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap, #else // Normal X11 -void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap, +void wxWindowDCImpl::DoDrawBitmap( const wxBitmap &bitmap, wxCoord x, wxCoord y, bool useMask ) { - wxCHECK_RET( Ok(), wxT("invalid window dc") ); + wxCHECK_RET( IsOk(), wxT("invalid window dc") ); - wxCHECK_RET( bitmap.Ok(), wxT("invalid bitmap") ); + wxCHECK_RET( bitmap.IsOk(), wxT("invalid bitmap") ); bool is_mono = (bitmap.GetBitmap() != NULL); @@ -1138,7 +1151,7 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap, CalcBoundingBox( x, y ); CalcBoundingBox( x + w, y + h ); - if (!m_window) return; + if (!m_x11window) return; int ww = XLOG2DEVREL(w); int hh = YLOG2DEVREL(h); @@ -1174,62 +1187,89 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap, WXPixmap mask = NULL; if (use_bitmap.GetMask()) mask = use_bitmap.GetMask()->GetBitmap(); - if (useMask && mask) + bool setClipMask = false; + + if (!m_currentClippingRegion.IsNull() || (useMask && mask)) + { + // XSetClipMask() call is necessary (because of clip region and/or transparent mask) + setClipMask = true; + Pixmap new_pixmap = 0; + + if (!m_currentClippingRegion.IsNull()) { - WXPixmap new_mask = NULL; -#if 0 - if (!m_currentClippingRegion.IsNull()) - { - GdkColor col; - new_mask = gdk_pixmap_new( wxGetRootWindow()->window, ww, hh, 1 ); - GdkGC *gc = gdk_gc_new( new_mask ); - col.pixel = 0; - gdk_gc_set_foreground( gc, &col ); - gdk_draw_rectangle( new_mask, gc, TRUE, 0, 0, ww, hh ); - col.pixel = 0; - gdk_gc_set_background( gc, &col ); - col.pixel = 1; - gdk_gc_set_foreground( gc, &col ); - gdk_gc_set_clip_region( gc, m_currentClippingRegion.GetRegion() ); - gdk_gc_set_clip_origin( gc, -xx, -yy ); - gdk_gc_set_fill( gc, GDK_OPAQUE_STIPPLED ); - gdk_gc_set_stipple( gc, mask ); - gdk_draw_rectangle( new_mask, gc, TRUE, 0, 0, ww, hh ); - gdk_gc_unref( gc ); - } -#endif - if (is_mono) + // clipping necessary => create new_pixmap + Display *xdisplay = (Display*) m_display; + int xscreen = DefaultScreen( xdisplay ); + Window xroot = RootWindow( xdisplay, xscreen ); + + new_pixmap = XCreatePixmap( xdisplay, xroot, ww, hh, 1 ); + GC gc = XCreateGC( xdisplay, new_pixmap, 0, NULL ); + + XSetForeground( xdisplay, gc, BlackPixel(xdisplay,xscreen) ); + + XSetFillStyle( xdisplay, gc, FillSolid ); + XFillRectangle( xdisplay, new_pixmap, gc, 0, 0, ww, hh ); + + XSetForeground( xdisplay, gc, WhitePixel(xdisplay,xscreen) ); + + if (useMask && mask) { - if (new_mask) - XSetClipMask( (Display*) m_display, (GC) m_textGC, (Pixmap) new_mask ); - else - XSetClipMask( (Display*) m_display, (GC) m_textGC, (Pixmap) mask ); - XSetClipOrigin( (Display*) m_display, (GC) m_textGC, xx, yy ); + // transparent mask => call XSetStipple + XSetFillStyle( xdisplay, gc, FillStippled ); + XSetTSOrigin( xdisplay, gc, 0, 0); + XSetStipple( xdisplay, gc, (Pixmap) mask); } - else + + wxVector rects; + for ( wxRegionIterator iter(m_currentClippingRegion); + iter; + ++iter ) { - if (new_mask) - XSetClipMask( (Display*) m_display, (GC) m_penGC, (Pixmap) new_mask ); - else - XSetClipMask( (Display*) m_display, (GC) m_penGC, (Pixmap) mask ); - XSetClipOrigin( (Display*) m_display, (GC) m_penGC, xx, yy ); + XRectangle rect; + rect.x = iter.GetX() - xx; + rect.y = iter.GetY() - yy; + rect.width = iter.GetWidth(); + rect.height = iter.GetHeight(); + rects.push_back(rect); } - if (new_mask) - XFreePixmap( (Display*) m_display, (Pixmap) new_mask ); + XFillRectangles(xdisplay, new_pixmap, gc, &rects[0], rects.size()); + + XFreeGC( xdisplay, gc ); } + if (is_mono) + { + if (new_pixmap) + XSetClipMask( (Display*) m_display, (GC) m_textGC, new_pixmap ); + else + XSetClipMask( (Display*) m_display, (GC) m_textGC, (Pixmap) mask ); + XSetClipOrigin( (Display*) m_display, (GC) m_textGC, xx, yy ); + } + else + { + if (new_pixmap) + XSetClipMask( (Display*) m_display, (GC) m_penGC, new_pixmap ); + else + XSetClipMask( (Display*) m_display, (GC) m_penGC, (Pixmap) mask ); + XSetClipOrigin( (Display*) m_display, (GC) m_penGC, xx, yy ); + } + + if (new_pixmap) + XFreePixmap( (Display*) m_display, new_pixmap ); + } + // Draw XPixmap or XBitmap, depending on what the wxBitmap contains. For // drawing a mono-bitmap (XBitmap) we use the current text GC if (is_mono) - XCopyPlane( (Display*) m_display, (Pixmap) use_bitmap.GetBitmap(), (Window) m_window, - (GC) m_textGC, 0, 0, w, h, xx, yy, 1 ); + XCopyPlane( (Display*) m_display, (Pixmap) use_bitmap.GetBitmap(), (Window) m_x11window, + (GC) m_textGC, 0, 0, ww, hh, xx, yy, 1 ); else - XCopyArea( (Display*) m_display, (Pixmap) use_bitmap.GetPixmap(), (Window) m_window, - (GC) m_penGC, 0, 0, w, h, xx, yy ); + XCopyArea( (Display*) m_display, (Pixmap) use_bitmap.GetPixmap(), (Window) m_x11window, + (GC) m_penGC, 0, 0, ww, hh, xx, yy ); // remove mask again if any - if (useMask && mask) + if (setClipMask) { if (is_mono) { @@ -1250,7 +1290,7 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap, #endif // wxUSE_NANOX/!wxUSE_NANOX -bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, +bool wxWindowDCImpl::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC *source, wxCoord xsrc, wxCoord ysrc, int logical_func, bool useMask, wxCoord xsrcMask, wxCoord ysrcMask ) { @@ -1259,18 +1299,19 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he of the source dc, but scales correctly on the target dc and knows about possible mask information in a memory dc. */ - wxCHECK_MSG( Ok(), false, wxT("invalid window dc") ); + wxCHECK_MSG( IsOk(), false, wxT("invalid window dc") ); wxCHECK_MSG( source, false, wxT("invalid source dc") ); - if (!m_window) return false; + if (!m_x11window) return false; // transform the source DC coords to the device ones - xsrc = source->XLOG2DEV(xsrc); - ysrc = source->YLOG2DEV(ysrc); + xsrc = source->LogicalToDeviceX(xsrc); + ysrc = source->LogicalToDeviceY(ysrc); wxClientDC *srcDC = (wxClientDC*)source; wxMemoryDC *memDC = (wxMemoryDC*)source; + wxWindowDCImpl *src_impl = (wxWindowDCImpl*) srcDC->GetImpl(); bool use_bitmap_method = false; bool is_mono = false; @@ -1282,9 +1323,11 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he ysrcMask = ysrc; } - if (srcDC->m_isMemDC) + if (src_impl->m_isMemDC) { - if (!memDC->m_selected.Ok()) return false; + wxBitmap selected = memDC->GetSelectedBitmap(); + + if (!selected.IsOk()) return false; /* we use the "XCopyArea" way to copy a memory dc into y different window if the memory dc BOTH @@ -1292,14 +1335,14 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he b) it is clipped c) is not 1-bit */ - if (useMask && (memDC->m_selected.GetMask())) + if (useMask && (selected.GetMask())) { /* we HAVE TO use the direct way for memory dcs that have mask since the XCopyArea doesn't know about masks */ use_bitmap_method = true; } - else if (memDC->m_selected.GetDepth() == 1) + else if (selected.GetDepth() == 1) { /* we HAVE TO use the direct way for memory dcs that are bitmaps because XCopyArea doesn't cope @@ -1308,8 +1351,8 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he use_bitmap_method = true; } else if ((xsrc == 0) && (ysrc == 0) && - (width == memDC->m_selected.GetWidth()) && - (height == memDC->m_selected.GetHeight())) + (width == selected.GetWidth()) && + (height == selected.GetHeight())) { /* we SHOULD use the direct way if all of the bitmap in the memory dc is copied in which case XCopyArea @@ -1347,9 +1390,11 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he if (use_bitmap_method) { + wxBitmap selected = memDC->GetSelectedBitmap(); + // scale/translate bitmap size - wxCoord bm_width = memDC->m_selected.GetWidth(); - wxCoord bm_height = memDC->m_selected.GetHeight(); + wxCoord bm_width = selected.GetWidth(); + wxCoord bm_height = selected.GetHeight(); wxCoord bm_ww = XLOG2DEVREL( bm_width ); wxCoord bm_hh = YLOG2DEVREL( bm_height ); @@ -1359,7 +1404,7 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he if ((bm_width != bm_ww) || (bm_height != bm_hh)) { - wxImage image( memDC->m_selected.ConvertToImage() ); + wxImage image( selected.ConvertToImage() ); image = image.Scale( bm_ww, bm_hh ); #if 0 @@ -1371,7 +1416,7 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he } else { - use_bitmap = memDC->m_selected; + use_bitmap = selected; } // apply mask if any @@ -1425,12 +1470,11 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he // Draw XPixmap or XBitmap, depending on what the wxBitmap contains. For // drawing a mono-bitmap (XBitmap) we use the current text GC - if (is_mono) - XCopyPlane( (Display*) m_display, (Pixmap) use_bitmap.GetBitmap(), (Window) m_window, + XCopyPlane( (Display*) m_display, (Pixmap) use_bitmap.GetBitmap(), (Window) m_x11window, (GC) m_textGC, xsrc, ysrc, width, height, xx, yy, 1 ); else - XCopyArea( (Display*) m_display, (Pixmap) use_bitmap.GetPixmap(), (Window) m_window, + XCopyArea( (Display*) m_display, (Pixmap) use_bitmap.GetPixmap(), (Window) m_x11window, (GC) m_penGC, xsrc, ysrc, width, height, xx, yy ); // remove mask again if any @@ -1454,6 +1498,14 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he } else // use_bitmap_method { + wxDCImpl *impl = srcDC->GetImpl(); + wxWindowDCImpl *x11_impl = wxDynamicCast(impl, wxWindowDCImpl); + if (!x11_impl) + { + SetLogicalFunction( old_logical_func ); + return false; + } + if ((width != ww) || (height != hh)) { /* Draw source window into a bitmap as we cannot scale @@ -1473,7 +1525,7 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he // copy including child window contents XSetSubwindowMode( (Display*) m_display, (GC) m_penGC, IncludeInferiors ); - XCopyArea( (Display*) m_display, (Window) srcDC->GetWindow(), (Window) bitmap.GetPixmap(), + XCopyArea( (Display*) m_display, (Window) x11_impl->GetX11Window(), (Window) bitmap.GetPixmap(), (GC) m_penGC, xsrc, ysrc, width, height, 0, 0 ); XSetSubwindowMode( (Display*) m_display, (GC) m_penGC, ClipByChildren ); @@ -1485,16 +1537,15 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he bitmap = image; // draw scaled bitmap - XCopyArea( (Display*) m_display, (Window) bitmap.GetPixmap(), (Window) m_window, + XCopyArea( (Display*) m_display, (Window) bitmap.GetPixmap(), (Window) m_x11window, (GC) m_penGC, 0, 0, width, height, xx, yy ); } else { // No scaling and not a memory dc with a mask either - // copy including child window contents XSetSubwindowMode( (Display*) m_display, (GC) m_penGC, IncludeInferiors ); - XCopyArea( (Display*) m_display, (Window) srcDC->GetWindow(), (Window) m_window, + XCopyArea( (Display*) m_display, (Window) x11_impl->GetX11Window(), (Window) m_x11window, (GC) m_penGC, xsrc, ysrc, width, height, xx, yy ); XSetSubwindowMode( (Display*) m_display, (GC) m_penGC, ClipByChildren ); } @@ -1505,11 +1556,11 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he return true; } -void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) +void wxWindowDCImpl::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) { - wxCHECK_RET( Ok(), wxT("invalid window dc") ); + wxCHECK_RET( IsOk(), wxT("invalid window dc") ); - if (!m_window) return; + if (!m_x11window) return; x = XLOG2DEV(x); y = YLOG2DEV(y); @@ -1528,7 +1579,7 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) wxCoord height = h; // Draw layout. - x11_draw_layout( (Drawable) m_window, (GC) m_textGC, x, y, layout, m_textForegroundColour ); + x11_draw_layout( (Drawable) m_x11window, (GC) m_textGC, x, y, layout, m_textForegroundColour ); g_object_unref( G_OBJECT( layout ) ); @@ -1541,7 +1592,7 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) // First draw a rectangle representing the text background, if a text // background is specified - if (m_textBackgroundColour.Ok () && (m_backgroundMode != wxTRANSPARENT)) + if (m_textBackgroundColour.IsOk () && (m_backgroundMode != wxTRANSPARENT)) { // Since X draws from the baseline of the text, must add the text height int cx = 0; @@ -1553,7 +1604,7 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) slen = strlen(text); XCharStruct overall_return; - (void)XTextExtents(xfont, (char*) text.c_str(), slen, &direction, + (void)XTextExtents(xfont, (const char*) text.c_str(), slen, &direction, &ascent, &descent, &overall_return); cx = overall_return.width; @@ -1561,7 +1612,7 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) m_textBackgroundColour.CalcPixel(m_cmap); m_textForegroundColour.CalcPixel(m_cmap); XSetForeground ((Display*) m_display, (GC) m_textGC, m_textBackgroundColour.GetPixel()); - XFillRectangle( (Display*) m_display, (Window) m_window, + XFillRectangle( (Display*) m_display, (Window) m_x11window, (GC) m_textGC, x, y, cx, cy ); XSetForeground ((Display*) m_display, (GC) m_textGC, m_textForegroundColour.GetPixel()); @@ -1569,11 +1620,13 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) XSetFont( (Display*) m_display, (GC) m_textGC, xfont->fid ); #if !wxUSE_NANOX - if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0)) + // This may be a test for whether the font is 16-bit, but it also + // seems to fail for valid 8-bit fonts too. + if (1) // (xfont->min_byte1 == 0) && (xfont->max_byte1 == 0)) #endif { - XDrawString( (Display*) m_display, (Window) m_window, - (GC) m_textGC, x, y + XFontStructGetAscent(xfont), text.c_str(), text.Len() ); + XDrawString( (Display*) m_display, (Window) m_x11window, + (GC) m_textGC, x, y + XFontStructGetAscent(xfont), text.c_str(), text.length() ); } #if 0 @@ -1581,7 +1634,7 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) { wxCoord ul_y = y + XFontStructGetAscent(font); if (font->descent > 0) ul_y++; - gdk_draw_line( m_window, m_textGC, x, ul_y, x + width, ul_y); + gdk_draw_line( m_x11window, m_textGC, x, ul_y, x + width, ul_y); } width = wxCoord(width / m_scaleX); @@ -1593,16 +1646,18 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) #endif } -void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y, double angle ) +void wxWindowDCImpl::DoDrawRotatedText(const wxString& WXUNUSED(text), + wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), + double WXUNUSED(angle)) { - // later + wxFAIL_MSG( "not implemented" ); } -void wxWindowDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *height, +void wxWindowDCImpl::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *height, wxCoord *descent, wxCoord *externalLeading, - wxFont *font ) const + const wxFont *font ) const { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); if (string.empty()) { @@ -1640,7 +1695,7 @@ void wxWindowDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoor wxFont fontToUse = m_font; if (font) fontToUse = *font; - wxCHECK_RET( fontToUse.Ok(), wxT("invalid font") ); + wxCHECK_RET( fontToUse.IsOk(), wxT("invalid font") ); XFontStruct *xfont = (XFontStruct*) fontToUse.GetFontStruct( m_scaleY, m_display ); @@ -1649,7 +1704,7 @@ void wxWindowDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoor int direction, ascent, descent2; XCharStruct overall; - XTextExtents( xfont, (char*) string.c_str(), string.Len(), &direction, + XTextExtents( xfont, (const char*) string.c_str(), string.length(), &direction, &ascent, &descent2, &overall); if (width) @@ -1663,20 +1718,18 @@ void wxWindowDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoor #endif } -wxCoord wxWindowDC::GetCharWidth() const +wxCoord wxWindowDCImpl::GetCharWidth() const { - wxCHECK_MSG( Ok(), 0, wxT("invalid dc") ); + wxCHECK_MSG( IsOk(), 0, wxT("invalid dc") ); #if wxUSE_UNICODE PangoLayout *layout = pango_layout_new( m_context ); - if (!m_fontdesc) - { - char *crash = NULL; - *crash = 0; - } + if (m_fontdesc) + pango_layout_set_font_description(layout, m_fontdesc); + else + pango_layout_set_font_description(layout, this->GetFont().GetNativeFontInfo()->description); - pango_layout_set_font_description(layout, m_fontdesc); pango_layout_set_text(layout, "H", 1 ); int w,h; pango_layout_get_pixel_size(layout, &w, &h); @@ -1684,7 +1737,7 @@ wxCoord wxWindowDC::GetCharWidth() const return w; #else - wxCHECK_MSG( m_font.Ok(), 0, wxT("invalid font") ); + wxCHECK_MSG( m_font.IsOk(), 0, wxT("invalid font") ); XFontStruct *xfont = (XFontStruct*) m_font.GetFontStruct( m_scaleY, m_display ); @@ -1699,20 +1752,17 @@ wxCoord wxWindowDC::GetCharWidth() const #endif } -wxCoord wxWindowDC::GetCharHeight() const +wxCoord wxWindowDCImpl::GetCharHeight() const { - wxCHECK_MSG( Ok(), 0, wxT("invalid dc") ); + wxCHECK_MSG( IsOk(), 0, wxT("invalid dc") ); #if wxUSE_UNICODE PangoLayout *layout = pango_layout_new( m_context ); - if (!m_fontdesc) - { - char *crash = NULL; - *crash = 0; - } - - pango_layout_set_font_description(layout, m_fontdesc); + if (m_fontdesc) + pango_layout_set_font_description(layout, m_fontdesc); + else + pango_layout_set_font_description(layout, this->GetFont().GetNativeFontInfo()->description); pango_layout_set_text(layout, "H", 1 ); int w,h; @@ -1721,7 +1771,7 @@ wxCoord wxWindowDC::GetCharHeight() const return h; #else - wxCHECK_MSG( m_font.Ok(), 0, wxT("invalid font") ); + wxCHECK_MSG( m_font.IsOk(), 0, wxT("invalid font") ); XFontStruct *xfont = (XFontStruct*) m_font.GetFontStruct( m_scaleY, m_display ); @@ -1736,11 +1786,11 @@ wxCoord wxWindowDC::GetCharHeight() const #endif } -void wxWindowDC::Clear() +void wxWindowDCImpl::Clear() { - wxCHECK_RET( Ok(), wxT("invalid window dc") ); + wxCHECK_RET( IsOk(), wxT("invalid window dc") ); - if (!m_window) return; + if (!m_x11window) return; /* - we either are a memory dc or have a window as the owner. anything else shouldn't happen. @@ -1749,41 +1799,45 @@ void wxWindowDC::Clear() much pain to keep the DC's and the window's back- ground colour in synch. */ - if (m_owner) + if (m_window) { int width,height; - m_owner->GetSize( &width, &height ); - XFillRectangle( (Display*) m_display, (Window) m_window, (GC) m_bgGC, 0, 0, width, height ); + m_window->GetSize( &width, &height ); + XFillRectangle( (Display*) m_display, (Window) m_x11window, (GC) m_bgGC, 0, 0, width, height ); return; } if (m_isMemDC) { int width,height; - GetSize( &width, &height ); - XFillRectangle( (Display*) m_display, (Window) m_window, (GC) m_bgGC, 0, 0, width, height ); + DoGetSize( &width, &height ); + XFillRectangle( (Display*) m_display, (Window) m_x11window, (GC) m_bgGC, 0, 0, width, height ); return; } } -void wxWindowDC::SetFont( const wxFont &font ) +void wxWindowDCImpl::SetFont( const wxFont &font ) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); m_font = font; + +#if wxUSE_UNICODE + m_fontdesc = font.GetNativeFontInfo()->description; +#endif } -void wxWindowDC::SetPen( const wxPen &pen ) +void wxWindowDCImpl::SetPen( const wxPen &pen ) { - wxCHECK_RET( Ok(), wxT("invalid window dc") ); + wxCHECK_RET( IsOk(), wxT("invalid window dc") ); if (m_pen == pen) return; m_pen = pen; - if (!m_pen.Ok()) return; + if (!m_pen.IsOk()) return; - if (!m_window) return; + if (!m_x11window) return; int width = m_pen.GetWidth(); if (width <= 0) @@ -1900,24 +1954,24 @@ void wxWindowDC::SetPen( const wxPen &pen ) XSetForeground( (Display*) m_display, (GC) m_penGC, m_pen.GetColour().GetPixel() ); } -void wxWindowDC::SetBrush( const wxBrush &brush ) +void wxWindowDCImpl::SetBrush( const wxBrush &brush ) { - wxCHECK_RET( Ok(), wxT("invalid window dc") ); + wxCHECK_RET( IsOk(), wxT("invalid window dc") ); if (m_brush == brush) return; m_brush = brush; - if (!m_brush.Ok()) return; + if (!m_brush.IsOk()) return; - if (!m_window) return; + if (!m_x11window) return; m_brush.GetColour().CalcPixel( m_cmap ); XSetForeground( (Display*) m_display, (GC) m_brushGC, m_brush.GetColour().GetPixel() ); XSetFillStyle( (Display*) m_display, (GC) m_brushGC, FillSolid ); - if ((m_brush.GetStyle() == wxSTIPPLE) && (m_brush.GetStipple()->Ok())) + if ((m_brush.GetStyle() == wxSTIPPLE) && (m_brush.GetStipple()->IsOk())) { if (m_brush.GetStipple()->GetPixmap()) { @@ -1945,20 +1999,20 @@ void wxWindowDC::SetBrush( const wxBrush &brush ) } } -void wxWindowDC::SetBackground( const wxBrush &brush ) +void wxWindowDCImpl::SetBackground( const wxBrush &brush ) { /* CMB 21/7/98: Added SetBackground. Sets background brush * for Clear() and bg colour for shapes filled with cross-hatch brush */ - wxCHECK_RET( Ok(), wxT("invalid window dc") ); + wxCHECK_RET( IsOk(), wxT("invalid window dc") ); if (m_backgroundBrush == brush) return; m_backgroundBrush = brush; - if (!m_backgroundBrush.Ok()) return; + if (!m_backgroundBrush.IsOk()) return; - if (!m_window) return; + if (!m_x11window) return; m_backgroundBrush.GetColour().CalcPixel( m_cmap ); XSetBackground( (Display*) m_display, (GC) m_brushGC, m_backgroundBrush.GetColour().GetPixel() ); @@ -1968,7 +2022,7 @@ void wxWindowDC::SetBackground( const wxBrush &brush ) XSetFillStyle( (Display*) m_display, (GC) m_bgGC, FillSolid ); - if ((m_backgroundBrush.GetStyle() == wxSTIPPLE) && (m_backgroundBrush.GetStipple()->Ok())) + if ((m_backgroundBrush.GetStyle() == wxSTIPPLE) && (m_backgroundBrush.GetStipple()->IsOk())) { if (m_backgroundBrush.GetStipple()->GetPixmap()) { @@ -1990,9 +2044,9 @@ void wxWindowDC::SetBackground( const wxBrush &brush ) } } -void wxWindowDC::SetLogicalFunction( int function ) +void wxWindowDCImpl::SetLogicalFunction( int function ) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); int x_function; @@ -2000,7 +2054,7 @@ void wxWindowDC::SetLogicalFunction( int function ) return; // VZ: shouldn't this be a CHECK? - if (!m_window) + if (!m_x11window) return; switch (function) @@ -2067,45 +2121,45 @@ void wxWindowDC::SetLogicalFunction( int function ) m_logicalFunction = function; } -void wxWindowDC::SetTextForeground( const wxColour &col ) +void wxWindowDCImpl::SetTextForeground( const wxColour &col ) { - wxCHECK_RET( Ok(), wxT("invalid window dc") ); + wxCHECK_RET( IsOk(), wxT("invalid window dc") ); // don't set m_textForegroundColour to an invalid colour as we'd crash // later then (we use m_textForegroundColour.GetColor() without checking // in a few places) - if ( !col.Ok() || (m_textForegroundColour == col) ) + if ( !col.IsOk() || (m_textForegroundColour == col) ) return; m_textForegroundColour = col; - if (m_window) + if (m_x11window) { m_textForegroundColour.CalcPixel( m_cmap ); XSetForeground( (Display*) m_display, (GC) m_textGC, m_textForegroundColour.GetPixel() ); } } -void wxWindowDC::SetTextBackground( const wxColour &col ) +void wxWindowDCImpl::SetTextBackground( const wxColour &col ) { - wxCHECK_RET( Ok(), wxT("invalid window dc") ); + wxCHECK_RET( IsOk(), wxT("invalid window dc") ); // same as above - if ( !col.Ok() || (m_textBackgroundColour == col) ) + if ( !col.IsOk() || (m_textBackgroundColour == col) ) return; m_textBackgroundColour = col; - if (m_window) + if (m_x11window) { m_textBackgroundColour.CalcPixel( m_cmap ); XSetBackground( (Display*) m_display, (GC) m_textGC, m_textBackgroundColour.GetPixel() ); } } -void wxWindowDC::SetBackgroundMode( int mode ) +void wxWindowDCImpl::SetBackgroundMode( int mode ) { - wxCHECK_RET( Ok(), wxT("invalid window dc") ); + wxCHECK_RET( IsOk(), wxT("invalid window dc") ); m_backgroundMode = mode; @@ -2113,7 +2167,7 @@ void wxWindowDC::SetBackgroundMode( int mode ) GrSetGCUseBackground((GC) m_textGC, mode == wxTRANSPARENT ? FALSE : TRUE); #endif - if (!m_window) return; + if (!m_x11window) return; // CMB 21/7/98: fill style of cross-hatch brushes is affected by // transparent/solid background mode @@ -2125,28 +2179,34 @@ void wxWindowDC::SetBackgroundMode( int mode ) } } -void wxWindowDC::SetPalette( const wxPalette& palette ) +void wxWindowDCImpl::SetPalette( const wxPalette& WXUNUSED(palette) ) { #if 0 - if (m_window) + if (m_x11window) { - if (palette.Ok()) + if (palette.IsOk()) /* Use GetXColormap */ - XSetWindowColormap ((Display*) m_display, (Window) m_window->GetXWindow(), + XSetWindowColormap ((Display*) m_display, (Window) m_x11window->GetXWindow(), (Colormap) palette.GetXColormap()); else /* Use wxGetMainColormap */ - XSetWindowColormap ((Display*) m_display, (Window) m_window->GetXWindow(), + XSetWindowColormap ((Display*) m_display, (Window) m_x11window->GetXWindow(), (Colormap) wxTheApp->GetMainColormap(m_display)); } #endif } -void wxWindowDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) +void wxWindowDCImpl::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) { - wxCHECK_RET( Ok(), wxT("invalid window dc") ); + wxCHECK_RET( IsOk(), wxT("invalid window dc") ); + + if (!m_x11window) return; + + if (width <= 0) + width = 1; - if (!m_window) return; + if (height <= 0) + height = 1; wxRect rect; rect.x = XLOG2DEV(x); @@ -2154,19 +2214,19 @@ void wxWindowDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoo rect.width = XLOG2DEVREL(width); rect.height = YLOG2DEVREL(height); - if (!m_currentClippingRegion.IsNull()) + if (!m_currentClippingRegion.IsEmpty()) m_currentClippingRegion.Intersect( rect ); else - m_currentClippingRegion.Union( rect ); + m_currentClippingRegion = rect; #if USE_PAINT_REGION - if (!m_paintClippingRegion.IsNull()) + if (!m_paintClippingRegion.IsEmpty()) m_currentClippingRegion.Intersect( m_paintClippingRegion ); #endif wxCoord xx, yy, ww, hh; m_currentClippingRegion.GetBox( xx, yy, ww, hh ); - wxDC::DoSetClippingRegion( xx, yy, ww, hh ); + wxX11DCImpl::DoSetClippingRegion( xx, yy, ww, hh ); XSetRegion( (Display*) m_display, (GC) m_penGC, (Region) m_currentClippingRegion.GetX11Region() ); XSetRegion( (Display*) m_display, (GC) m_brushGC, (Region) m_currentClippingRegion.GetX11Region() ); @@ -2174,9 +2234,9 @@ void wxWindowDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoo XSetRegion( (Display*) m_display, (GC) m_bgGC, (Region) m_currentClippingRegion.GetX11Region() ); } -void wxWindowDC::DoSetClippingRegionAsRegion( const wxRegion& region ) +void wxWindowDCImpl::DoSetDeviceClippingRegion( const wxRegion& region ) { - wxCHECK_RET( Ok(), wxT("invalid window dc") ); + wxCHECK_RET( IsOk(), wxT("invalid window dc") ); if (region.Empty()) { @@ -2184,21 +2244,21 @@ void wxWindowDC::DoSetClippingRegionAsRegion( const wxRegion& region ) return; } - if (!m_window) return; + if (!m_x11window) return; - if (!m_currentClippingRegion.IsNull()) + if (!m_currentClippingRegion.IsEmpty()) m_currentClippingRegion.Intersect( region ); else - m_currentClippingRegion.Union( region ); + m_currentClippingRegion = region; #if USE_PAINT_REGION - if (!m_paintClippingRegion.IsNull()) + if (!m_paintClippingRegion.IsEmpty()) m_currentClippingRegion.Intersect( m_paintClippingRegion ); #endif wxCoord xx, yy, ww, hh; m_currentClippingRegion.GetBox( xx, yy, ww, hh ); - wxDC::DoSetClippingRegion( xx, yy, ww, hh ); + wxX11DCImpl::DoSetClippingRegion( xx, yy, ww, hh ); XSetRegion( (Display*) m_display, (GC) m_penGC, (Region) m_currentClippingRegion.GetX11Region() ); XSetRegion( (Display*) m_display, (GC) m_brushGC, (Region) m_currentClippingRegion.GetX11Region() ); @@ -2206,11 +2266,11 @@ void wxWindowDC::DoSetClippingRegionAsRegion( const wxRegion& region ) XSetRegion( (Display*) m_display, (GC) m_bgGC, (Region) m_currentClippingRegion.GetX11Region() ); } -void wxWindowDC::DestroyClippingRegion() +void wxWindowDCImpl::DestroyClippingRegion() { - wxCHECK_RET( Ok(), wxT("invalid window dc") ); + wxCHECK_RET( IsOk(), wxT("invalid window dc") ); - wxDC::DestroyClippingRegion(); + wxDCImpl::DestroyClippingRegion(); m_currentClippingRegion.Clear(); @@ -2219,7 +2279,7 @@ void wxWindowDC::DestroyClippingRegion() m_currentClippingRegion.Union( m_paintClippingRegion ); #endif - if (!m_window) return; + if (!m_x11window) return; if (m_currentClippingRegion.IsEmpty()) { @@ -2237,7 +2297,7 @@ void wxWindowDC::DestroyClippingRegion() } } -void wxWindowDC::Destroy() +void wxWindowDCImpl::Destroy() { if (m_penGC) wxFreePoolGC( (GC) m_penGC ); m_penGC = NULL; @@ -2249,17 +2309,17 @@ void wxWindowDC::Destroy() m_bgGC = NULL; } -void wxWindowDC::ComputeScaleAndOrigin() +void wxWindowDCImpl::ComputeScaleAndOrigin() { /* CMB: copy scale to see if it changes */ double origScaleX = m_scaleX; double origScaleY = m_scaleY; - wxDC::ComputeScaleAndOrigin(); + wxDCImpl::ComputeScaleAndOrigin(); /* CMB: if scale has changed call SetPen to recalulate the line width */ if ((m_scaleX != origScaleX || m_scaleY != origScaleY) && - (m_pen.Ok())) + (m_pen.IsOk())) { /* this is a bit artificial, but we need to force wxDC to think the pen has changed */ @@ -2269,12 +2329,12 @@ void wxWindowDC::ComputeScaleAndOrigin() } } -wxSize wxWindowDC::GetPPI() const +wxSize wxWindowDCImpl::GetPPI() const { return wxSize(100, 100); } -int wxWindowDC::GetDepth() const +int wxWindowDCImpl::GetDepth() const { wxFAIL_MSG(wxT("not implemented")); @@ -2285,40 +2345,40 @@ int wxWindowDC::GetDepth() const // wxClientDC //----------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC) +IMPLEMENT_ABSTRACT_CLASS(wxClientDCImpl, wxWindowDCImpl) -wxClientDC::wxClientDC( wxWindow *window ) - : wxWindowDC( window ) +wxClientDCImpl::wxClientDCImpl( wxDC *owner, wxWindow *window ) + : wxWindowDCImpl( owner, window ) { wxCHECK_RET( window, _T("NULL window in wxClientDC::wxClientDC") ); - m_window = (WXWindow*) window->GetClientAreaWindow(); + m_x11window = (WXWindow*) window->GetClientAreaWindow(); // Adjust the client area when the wxWindow is not using 2 X11 windows. - if (m_window == (WXWindow*) window->GetMainWindow()) + if (m_x11window == (WXWindow*) window->GetMainWindow()) { wxPoint ptOrigin = window->GetClientAreaOrigin(); SetDeviceOrigin(ptOrigin.x, ptOrigin.y); wxSize size = window->GetClientSize(); - SetClippingRegion(wxPoint(0, 0), size); + DoSetClippingRegion( 0, 0, size.x, size.y ); } } -void wxClientDC::DoGetSize(int *width, int *height) const +void wxClientDCImpl::DoGetSize(int *width, int *height) const { - wxCHECK_RET( m_owner, _T("GetSize() doesn't work without window") ); + wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") ); - m_owner->GetClientSize( width, height ); + m_window->GetClientSize( width, height ); } // ---------------------------------------------------------------------------- // wxPaintDC // ---------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxClientDC) +IMPLEMENT_ABSTRACT_CLASS(wxPaintDCImpl, wxClientDCImpl) -wxPaintDC::wxPaintDC(wxWindow* window) - : wxClientDC(window) +wxPaintDCImpl::wxPaintDCImpl(wxDC *owner, wxWindow* window) + : wxClientDCImpl(owner, window) { #if USE_PAINT_REGION if (!window->GetClipPaintRegion()) @@ -2345,8 +2405,15 @@ wxPaintDC::wxPaintDC(wxWindow* window) class wxDCModule : public wxModule { public: - bool OnInit(); - void OnExit(); + // we must be cleaned up before wxDisplayModule which closes the global + // display + wxDCModule() + { + AddDependency(wxClassInfo::FindClass(_T("wxX11DisplayModule"))); + } + + bool OnInit() { wxInitGCPool(); return true; } + void OnExit() { wxCleanUpGCPool(); } private: DECLARE_DYNAMIC_CLASS(wxDCModule) @@ -2354,13 +2421,3 @@ private: IMPLEMENT_DYNAMIC_CLASS(wxDCModule, wxModule) -bool wxDCModule::OnInit() -{ - wxInitGCPool(); - return true; -} - -void wxDCModule::OnExit() -{ - wxCleanUpGCPool(); -}