From 2b77c3fce750925bdd0cb33505439ddc5493a18e Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Fri, 30 Nov 2007 15:26:05 +0000 Subject: [PATCH] converted most of X11 DC code git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50354 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/x11/dc.h | 11 +- include/wx/x11/dcclient.h | 39 ++- include/wx/x11/dcmemory.h | 22 +- src/x11/dc.cpp | 14 +- src/x11/dcclient.cpp | 569 ++++++++++++++++++++------------------ src/x11/dcmemory.cpp | 52 +++- 6 files changed, 377 insertions(+), 330 deletions(-) diff --git a/include/wx/x11/dc.h b/include/wx/x11/dc.h index 595126236c..af0a97e96c 100644 --- a/include/wx/x11/dc.h +++ b/include/wx/x11/dc.h @@ -22,14 +22,11 @@ // wxDC //----------------------------------------------------------------------------- -class WXDLLEXPORT wxDC : public wxDCBase +class WXDLLEXPORT wxX11DCImpl : public wxDCImpl { public: - wxDC(); - virtual ~wxDC() { } - - // implement base class pure virtuals - // ---------------------------------- + wxX11DCImpl( wxDC *owner ); + virtual ~wxX11DCImpl() { } virtual wxSize GetPPI() const; @@ -49,7 +46,7 @@ protected: wxCoord YLOG2DEVREL(wxCoord y) const { return LogicalToDeviceYRel(y); } private: - DECLARE_ABSTRACT_CLASS(wxDC) + DECLARE_CLASS(wxX11DCImpl) }; #endif diff --git a/include/wx/x11/dcclient.h b/include/wx/x11/dcclient.h index 542606604b..928edfaf56 100644 --- a/include/wx/x11/dcclient.h +++ b/include/wx/x11/dcclient.h @@ -13,6 +13,8 @@ #define _WX_DCCLIENT_H_ #include "wx/dc.h" +#include "wx/dcclient.h" +#include "wx/x11/dc.h" #include "wx/region.h" // ----------------------------------------------------------------------------- @@ -21,21 +23,17 @@ class WXDLLIMPEXP_FWD_CORE wxWindow; -class WXDLLIMPEXP_FWD_CORE wxWindowDC; -class WXDLLIMPEXP_FWD_CORE wxPaintDC; -class WXDLLIMPEXP_FWD_CORE wxClientDC; - //----------------------------------------------------------------------------- -// wxWindowDC +// wxWindowDCImpl //----------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxWindowDC : public wxDC +class WXDLLIMPEXP_CORE wxWindowDCImpl : public wxX11DCImpl { public: - wxWindowDC() { Init(); } - wxWindowDC( wxWindow *win ); - - virtual ~wxWindowDC(); + wxWindowDCImpl( wxDC *owner ); + wxWindowDCImpl( wxDC *owner, wxWindow *win ); + + virtual ~wxWindowDCImpl(); virtual bool CanDrawBitmap() const { return true; } virtual bool CanGetTextExtent() const { return true; } @@ -121,7 +119,7 @@ protected: void Init(); WXDisplay *m_display; - WXWindow m_window; + WXWindow m_x11window; WXGC m_penGC; WXGC m_brushGC; WXGC m_textGC; @@ -129,7 +127,6 @@ protected: WXColormap m_cmap; bool m_isMemDC; bool m_isScreenDC; - wxWindow *m_owner; wxRegion m_currentClippingRegion; wxRegion m_paintClippingRegion; @@ -142,38 +139,38 @@ protected: void Destroy(); private: - DECLARE_DYNAMIC_CLASS(wxWindowDC) + DECLARE_CLASS(wxWindowDCImpl) }; //----------------------------------------------------------------------------- // wxClientDC //----------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxClientDC : public wxWindowDC +class WXDLLIMPEXP_CORE wxClientDCImpl : public wxWindowDCImpl { public: - wxClientDC() { } - wxClientDC( wxWindow *win ); + wxClientDCImpl( wxDC *owner ) : wxWindowDCImpl( owner ) { } + wxClientDCImpl( wxDC *owner, wxWindow *win ); protected: virtual void DoGetSize(int *width, int *height) const; private: - DECLARE_DYNAMIC_CLASS(wxClientDC) + DECLARE_CLASS(wxClientDCImpl) }; //----------------------------------------------------------------------------- // wxPaintDC //----------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxPaintDC : public wxClientDC +class WXDLLIMPEXP_CORE wxPaintDCImpl : public wxClientDCImpl { public: - wxPaintDC() { } - wxPaintDC( wxWindow *win ); + wxPaintDCImpl( wxDC *owner ) : wxClientDCImpl( owner ) { } + wxPaintDCImpl( wxDC *owner, wxWindow *win ); private: - DECLARE_DYNAMIC_CLASS(wxPaintDC) + DECLARE_CLASS(wxPaintDCImpl) }; #endif diff --git a/include/wx/x11/dcmemory.h b/include/wx/x11/dcmemory.h index 0a86134f66..687fea8ffa 100644 --- a/include/wx/x11/dcmemory.h +++ b/include/wx/x11/dcmemory.h @@ -12,16 +12,21 @@ #ifndef _WX_DCMEMORY_H_ #define _WX_DCMEMORY_H_ -#include "wx/dcclient.h" +#include "wx/dc.h" +#include "wx/dcmemory.h" +#include "wx/x11/dcclient.h" -class WXDLLIMPEXP_CORE wxMemoryDC : public wxWindowDC, public wxMemoryDCBase +class WXDLLIMPEXP_CORE wxMemoryDCImpl : public wxWindowDCImpl { public: - wxMemoryDC() { Init(); } - wxMemoryDC(wxBitmap& bitmap) { Init(); SelectObject(bitmap); } - wxMemoryDC( wxDC *dc ); // Create compatible DC - virtual ~wxMemoryDC(); - + wxMemoryDCImpl( wxDC* owner ); + wxMemoryDCImpl( wxDC* owner, wxBitmap& bitmap); + wxMemoryDCImpl( wxDC* owner, wxDC *dc ); + virtual ~wxMemoryDCImpl(); + + virtual const wxBitmap& GetSelectedBitmap() const; + virtual wxBitmap& GetSelectedBitmap(); + // implementation wxBitmap m_selected; @@ -32,7 +37,8 @@ protected: private: void Init(); - DECLARE_DYNAMIC_CLASS(wxMemoryDC) +private: + DECLARE_CLASS(wxMemoryDCImpl) }; #endif diff --git a/src/x11/dc.cpp b/src/x11/dc.cpp index 1433d94f4a..d391e78b97 100644 --- a/src/x11/dc.cpp +++ b/src/x11/dc.cpp @@ -13,18 +13,20 @@ #include "wx/wxprec.h" #include "wx/dc.h" +#include "wx/x11/dc.h" #ifndef WX_PRECOMP #include "wx/dcmemory.h" #endif -IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject) +IMPLEMENT_ABSTRACT_CLASS(wxX11DCImpl, wxDCImpl) //----------------------------------------------------------------------------- // wxDC //----------------------------------------------------------------------------- -wxDC::wxDC() +wxX11DCImpl::wxX11DCImpl( wxDC *owner ) : + wxDCImpl( owner ) { m_ok = false; @@ -35,7 +37,7 @@ wxDC::wxDC() m_backgroundMode = wxTRANSPARENT; } -void wxDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) +void wxX11DCImpl::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) { m_clipping = true; m_clipX1 = x; @@ -44,10 +46,10 @@ void wxDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord hei m_clipY2 = y + height; } -void wxDC::DoGetSizeMM( int* width, int* height ) const +void wxX11DCImpl::DoGetSizeMM( int* width, int* height ) const { int w, h; - GetSize( &w, &h ); + DoGetSize( &w, &h ); if ( width ) *width = int( double(w) / (m_scaleX*m_mm_to_pix_x) ); @@ -56,7 +58,7 @@ void wxDC::DoGetSizeMM( int* width, int* height ) const } // Resolution in pixels per logical inch -wxSize wxDC::GetPPI() const +wxSize wxX11DCImpl::GetPPI() const { // TODO (should probably be pure virtual) return wxSize(0, 0); diff --git a/src/x11/dcclient.cpp b/src/x11/dcclient.cpp index 5e19609f43..264bd88993 100644 --- a/src/x11/dcclient.cpp +++ b/src/x11/dcclient.cpp @@ -17,7 +17,6 @@ #ifndef WX_PRECOMP #include "wx/app.h" #include "wx/window.h" - #include "wx/dcmemory.h" #include "wx/math.h" #include "wx/image.h" #include "wx/module.h" @@ -26,6 +25,8 @@ #include "wx/fontutil.h" #include "wx/x11/private.h" +#include "wx/x11/dcclient.h" +#include "wx/x11/dcmemory.h" #if wxUSE_UNICODE #include "glib.h" @@ -164,27 +165,16 @@ static void wxFreePoolGC( GC gc ) // wxWindowDC // ---------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC) +IMPLEMENT_ABSTRACT_CLASS(wxWindowDCImpl, wxX11DCImpl) -void wxWindowDC::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_owner = (wxWindow *)NULL; - -#if wxUSE_UNICODE - m_context = wxTheApp->GetPangoContext(); - m_fontdesc = (PangoFontDescription *)NULL; -#endif +wxWindowDCImpl::wxWindowDCImpl( wxDC *owner ) + : wxX11DCImpl( owner ) +{ + Init(); } -wxWindowDC::wxWindowDC( wxWindow *window ) +wxWindowDCImpl::wxWindowDCImpl( wxDC* owner, wxWindow *window ) + : wxX11DCImpl( owner ) { wxASSERT_MSG( window, wxT("DC needs a window") ); @@ -192,10 +182,10 @@ wxWindowDC::wxWindowDC( wxWindow *window ) 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; @@ -216,46 +206,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 */ @@ -326,43 +342,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... @@ -371,9 +387,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) ); } @@ -382,30 +398,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); @@ -443,7 +459,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) { @@ -453,7 +469,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 ); @@ -463,7 +479,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 ); @@ -473,7 +489,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 ); @@ -484,27 +500,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 ); } } @@ -513,9 +529,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); @@ -526,7 +542,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); @@ -539,7 +555,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 ); @@ -549,7 +565,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 ); @@ -559,7 +575,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 ); @@ -570,21 +586,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 ); } } @@ -593,20 +609,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; @@ -619,16 +635,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[], +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; @@ -642,7 +658,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) { @@ -653,7 +669,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 ); @@ -663,7 +679,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 ); @@ -673,7 +689,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 ); @@ -684,14 +700,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); } } @@ -702,16 +718,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); @@ -725,7 +741,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) { @@ -735,7 +751,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 ); @@ -745,7 +761,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 ); @@ -755,7 +771,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 ); @@ -766,21 +782,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 ); } } @@ -789,9 +805,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); @@ -809,7 +825,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; } @@ -825,7 +841,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 @@ -841,34 +857,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) @@ -876,34 +892,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 ); } } @@ -912,9 +928,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); @@ -925,7 +941,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) { @@ -935,7 +951,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 ); @@ -945,7 +961,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 ); @@ -955,7 +971,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 ); @@ -966,21 +982,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 ); } } @@ -989,19 +1005,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); @@ -1015,7 +1031,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); @@ -1071,7 +1087,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 @@ -1089,18 +1105,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 */ @@ -1114,13 +1130,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); @@ -1134,7 +1150,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); @@ -1234,10 +1250,10 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap, // 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, 0, 0, ww, hh, 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, 0, 0, ww, hh, xx, yy ); // remove mask again if any @@ -1262,7 +1278,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 ) { @@ -1271,11 +1287,11 @@ 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->LogicalToDeviceX(xsrc); @@ -1283,6 +1299,7 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he wxClientDC *srcDC = (wxClientDC*)source; wxMemoryDC *memDC = (wxMemoryDC*)source; + wxWindowDCImpl *src_impl = (wxWindowDCImpl*) srcDC->GetImpl(); bool use_bitmap_method = false; bool is_mono = false; @@ -1294,9 +1311,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 @@ -1304,14 +1323,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 @@ -1320,8 +1339,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 @@ -1359,9 +1378,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 ); @@ -1371,7 +1392,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 @@ -1383,7 +1404,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 @@ -1439,10 +1460,10 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he // 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 @@ -1497,7 +1518,7 @@ 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 @@ -1506,7 +1527,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) m_window, + XCopyArea( (Display*) m_display, (Window) srcDC->GetWindow(), (Window) m_x11window, (GC) m_penGC, xsrc, ysrc, width, height, xx, yy ); XSetSubwindowMode( (Display*) m_display, (GC) m_penGC, ClipByChildren ); } @@ -1517,11 +1538,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); @@ -1540,7 +1561,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 ) ); @@ -1553,7 +1574,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; @@ -1573,7 +1594,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()); @@ -1586,7 +1607,7 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) if (1) // (xfont->min_byte1 == 0) && (xfont->max_byte1 == 0)) #endif { - XDrawString( (Display*) m_display, (Window) m_window, + XDrawString( (Display*) m_display, (Window) m_x11window, (GC) m_textGC, x, y + XFontStructGetAscent(xfont), text.c_str(), text.length() ); } @@ -1595,7 +1616,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); @@ -1607,18 +1628,18 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) #endif } -void wxWindowDC::DoDrawRotatedText(const wxString& WXUNUSED(text), +void wxWindowDCImpl::DoDrawRotatedText(const wxString& WXUNUSED(text), wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), double WXUNUSED(angle)) { 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, const wxFont *font ) const { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); if (string.empty()) { @@ -1656,7 +1677,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 ); @@ -1679,9 +1700,9 @@ 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 ); @@ -1698,7 +1719,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 ); @@ -1713,9 +1734,9 @@ 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 ); @@ -1732,7 +1753,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 ); @@ -1747,11 +1768,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. @@ -1760,26 +1781,26 @@ 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; @@ -1788,17 +1809,17 @@ void wxWindowDC::SetFont( const wxFont &font ) #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) @@ -1915,24 +1936,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()) { @@ -1960,20 +1981,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() ); @@ -1983,7 +2004,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()) { @@ -2005,9 +2026,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; @@ -2015,7 +2036,7 @@ void wxWindowDC::SetLogicalFunction( int function ) return; // VZ: shouldn't this be a CHECK? - if (!m_window) + if (!m_x11window) return; switch (function) @@ -2082,45 +2103,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; @@ -2128,7 +2149,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 @@ -2140,28 +2161,28 @@ void wxWindowDC::SetBackgroundMode( int mode ) } } -void wxWindowDC::SetPalette( const wxPalette& WXUNUSED(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_window) return; + if (!m_x11window) return; if (width <= 0) width = 1; @@ -2187,7 +2208,7 @@ void wxWindowDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoo wxCoord xx, yy, ww, hh; m_currentClippingRegion.GetBox( xx, yy, ww, hh ); - wxDC::DoSetClippingRegion( xx, yy, ww, hh ); + wxDCImpl::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() ); @@ -2195,9 +2216,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::DoSetClippingRegionAsRegion( const wxRegion& region ) { - wxCHECK_RET( Ok(), wxT("invalid window dc") ); + wxCHECK_RET( IsOk(), wxT("invalid window dc") ); if (region.Empty()) { @@ -2205,7 +2226,7 @@ void wxWindowDC::DoSetClippingRegionAsRegion( const wxRegion& region ) return; } - if (!m_window) return; + if (!m_x11window) return; if (!m_currentClippingRegion.IsEmpty()) m_currentClippingRegion.Intersect( region ); @@ -2219,7 +2240,7 @@ void wxWindowDC::DoSetClippingRegionAsRegion( const wxRegion& region ) wxCoord xx, yy, ww, hh; m_currentClippingRegion.GetBox( xx, yy, ww, hh ); - wxDC::DoSetClippingRegion( xx, yy, ww, hh ); + wxDCImpl::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() ); @@ -2227,11 +2248,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(); @@ -2240,7 +2261,7 @@ void wxWindowDC::DestroyClippingRegion() m_currentClippingRegion.Union( m_paintClippingRegion ); #endif - if (!m_window) return; + if (!m_x11window) return; if (m_currentClippingRegion.IsEmpty()) { @@ -2258,7 +2279,7 @@ void wxWindowDC::DestroyClippingRegion() } } -void wxWindowDC::Destroy() +void wxWindowDCImpl::Destroy() { if (m_penGC) wxFreePoolGC( (GC) m_penGC ); m_penGC = NULL; @@ -2270,17 +2291,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 */ @@ -2290,12 +2311,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")); @@ -2308,38 +2329,38 @@ int wxWindowDC::GetDepth() const IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC) -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()) diff --git a/src/x11/dcmemory.cpp b/src/x11/dcmemory.cpp index f2019230e0..be343b1a3b 100644 --- a/src/x11/dcmemory.cpp +++ b/src/x11/dcmemory.cpp @@ -20,10 +20,30 @@ #endif #include "wx/x11/private.h" +#include "wx/x11/dcmemory.h" -IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxWindowDC) +IMPLEMENT_ABSTRACT_CLASS(wxMemoryDCImpl,wxWindowDCImpl) -void wxMemoryDC::Init() +wxMemoryDCImpl::wxMemoryDCImpl( wxDC *owner ) + : wxWindowDCImpl( owner ) +{ + Init(); +} + +wxMemoryDCImpl::wxMemoryDCImpl( wxDC *owner, wxBitmap& bitmap ) + : wxWindowDCImpl( owner ) +{ + Init(); + DoSelect(bitmap); +} + +wxMemoryDCImpl::wxMemoryDCImpl( wxDC* owner, wxDC *WXUNUSED(dc) ) + : wxWindowDCImpl( owner ) +{ + Init(); +} + +void wxMemoryDCImpl::Init() { m_ok = false; @@ -33,17 +53,11 @@ void wxMemoryDC::Init() m_cmap = (WXColormap) DefaultColormap( wxGlobalDisplay(), screen ); } -wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) ) - : wxWindowDC() +wxMemoryDCImpl::~wxMemoryDCImpl() { - Init(); } -wxMemoryDC::~wxMemoryDC() -{ -} - -void wxMemoryDC::DoSelect( const wxBitmap& bitmap ) +void wxMemoryDCImpl::DoSelect( const wxBitmap& bitmap ) { Destroy(); @@ -52,11 +66,11 @@ void wxMemoryDC::DoSelect( const wxBitmap& bitmap ) { if (m_selected.GetPixmap()) { - m_window = (WXWindow) m_selected.GetPixmap(); + m_x11window = (WXWindow) m_selected.GetPixmap(); } else { - m_window = m_selected.GetBitmap(); + m_x11window = m_selected.GetBitmap(); } m_isMemDC = true; @@ -66,11 +80,11 @@ void wxMemoryDC::DoSelect( const wxBitmap& bitmap ) else { m_ok = false; - m_window = NULL; + m_x11window = NULL; } } -void wxMemoryDC::DoGetSize( int *width, int *height ) const +void wxMemoryDCImpl::DoGetSize( int *width, int *height ) const { if (m_selected.Ok()) { @@ -83,3 +97,13 @@ void wxMemoryDC::DoGetSize( int *width, int *height ) const if (height) (*height) = 0; } } + +const wxBitmap& wxMemoryDCImpl::GetSelectedBitmap() const +{ + return m_selected; +} + +wxBitmap& wxMemoryDCImpl::GetSelectedBitmap() +{ + return m_selected; +} -- 2.45.2