1 ///////////////////////////////////////////////////////////////////////////// 2 // Name: wx/gtk/dc.h 3 // Purpose: 4 // Author: Robert Roebling 5 // Copyright: (c) 1998 Robert Roebling 6 // Licence: wxWindows licence 7 ///////////////////////////////////////////////////////////////////////////// 8 9 #ifndef _WX_GTKDC_H_ 10 #define _WX_GTKDC_H_ 11 12 #ifdef __WXGTK3__ 13 14 #include "wx/dcgraph.h" 15 16 class wxGTKCairoDCImpl: public wxGCDCImpl 17 { 18 typedef wxGCDCImpl BaseType; 19 public: 20 wxGTKCairoDCImpl(wxDC* owner); 21 wxGTKCairoDCImpl(wxDC* owner, wxWindow* window, wxLayoutDirection dir = wxLayout_Default, int width = 0); 22 23 virtual void DoDrawBitmap(const wxBitmap& bitmap, int x, int y, bool useMask) wxOVERRIDE; 24 virtual void DoDrawCheckMark(int x, int y, int width, int height) wxOVERRIDE; 25 virtual void DoDrawIcon(const wxIcon& icon, int x, int y) wxOVERRIDE; 26 virtual void DoDrawText(const wxString& text, int x, int y) wxOVERRIDE; 27 virtual void DoDrawRotatedText(const wxString& text, int x, int y, double angle) wxOVERRIDE; 28 #if wxUSE_IMAGE 29 virtual bool DoFloodFill(int x, int y, const wxColour& col, wxFloodFillStyle style) wxOVERRIDE; 30 #endif 31 virtual wxBitmap DoGetAsBitmap(const wxRect* subrect) const wxOVERRIDE; 32 virtual bool DoGetPixel(int x, int y, wxColour* col) const wxOVERRIDE; 33 virtual void DoGetSize(int* width, int* height) const wxOVERRIDE; 34 virtual bool DoStretchBlit(int xdest, int ydest, int dstWidth, int dstHeight, wxDC* source, int xsrc, int ysrc, int srcWidth, int srcHeight, wxRasterOperationMode rop, bool useMask, int xsrcMask, int ysrcMask) wxOVERRIDE; 35 virtual void* GetCairoContext() const wxOVERRIDE; 36 37 virtual wxSize GetPPI() const wxOVERRIDE; 38 virtual void SetLayoutDirection(wxLayoutDirection dir) wxOVERRIDE; 39 virtual wxLayoutDirection GetLayoutDirection() const wxOVERRIDE; 40 41 protected: 42 // Set m_size from the given (valid) GdkWindow. 43 void InitSize(GdkWindow* window); 44 void AdjustForRTL(cairo_t* cr); 45 46 wxSize m_size; 47 wxLayoutDirection m_layoutDir; 48 49 wxDECLARE_NO_COPY_CLASS(wxGTKCairoDCImpl); 50 }; 51 //----------------------------------------------------------------------------- 52 53 class wxWindowDCImpl: public wxGTKCairoDCImpl 54 { 55 public: 56 wxWindowDCImpl(wxWindowDC* owner, wxWindow* window); 57 58 wxDECLARE_NO_COPY_CLASS(wxWindowDCImpl); 59 }; 60 //----------------------------------------------------------------------------- 61 62 class wxClientDCImpl: public wxGTKCairoDCImpl 63 { 64 public: 65 wxClientDCImpl(wxClientDC* owner, wxWindow* window); 66 67 wxDECLARE_NO_COPY_CLASS(wxClientDCImpl); 68 }; 69 //----------------------------------------------------------------------------- 70 71 class wxPaintDCImpl: public wxGTKCairoDCImpl 72 { 73 typedef wxGTKCairoDCImpl BaseType; 74 public: 75 wxPaintDCImpl(wxPaintDC* owner, wxWindow* window); 76 virtual void DestroyClippingRegion() wxOVERRIDE; 77 78 private: 79 const wxRegion& m_clip; 80 81 wxDECLARE_NO_COPY_CLASS(wxPaintDCImpl); 82 }; 83 //----------------------------------------------------------------------------- 84 85 class wxScreenDCImpl: public wxGTKCairoDCImpl 86 { 87 public: 88 wxScreenDCImpl(wxScreenDC* owner); 89 90 virtual wxSize GetPPI() const wxOVERRIDE; 91 92 wxDECLARE_NO_COPY_CLASS(wxScreenDCImpl); 93 }; 94 //----------------------------------------------------------------------------- 95 96 class wxMemoryDCImpl: public wxGTKCairoDCImpl 97 { 98 public: 99 wxMemoryDCImpl(wxMemoryDC* owner); 100 wxMemoryDCImpl(wxMemoryDC* owner, wxBitmap& bitmap); 101 wxMemoryDCImpl(wxMemoryDC* owner, wxDC* dc); 102 virtual wxBitmap DoGetAsBitmap(const wxRect* subrect) const wxOVERRIDE; 103 virtual void DoSelect(const wxBitmap& bitmap) wxOVERRIDE; 104 virtual const wxBitmap& GetSelectedBitmap() const wxOVERRIDE; 105 virtual wxBitmap& GetSelectedBitmap() wxOVERRIDE; 106 107 private: 108 void Setup(); 109 wxBitmap m_bitmap; 110 111 wxDECLARE_NO_COPY_CLASS(wxMemoryDCImpl); 112 }; 113 //----------------------------------------------------------------------------- 114 115 class WXDLLIMPEXP_CORE wxGTKCairoDC: public wxDC 116 { 117 public: 118 wxGTKCairoDC(cairo_t* cr, wxWindow* window, wxLayoutDirection dir = wxLayout_LeftToRight, int width = 0); 119 120 wxDECLARE_NO_COPY_CLASS(wxGTKCairoDC); 121 }; 122 123 #else 124 125 #include "wx/dc.h" 126 127 //----------------------------------------------------------------------------- 128 // wxDC 129 //----------------------------------------------------------------------------- 130 131 class WXDLLIMPEXP_CORE wxGTKDCImpl : public wxDCImpl 132 { 133 public: 134 wxGTKDCImpl( wxDC *owner ); 135 virtual ~wxGTKDCImpl(); 136 137 #if wxUSE_PALETTE SetColourMap(const wxPalette & palette)138 void SetColourMap( const wxPalette& palette ) { SetPalette(palette); } 139 #endif // wxUSE_PALETTE 140 141 // Resolution in pixels per logical inch 142 virtual wxSize GetPPI() const wxOVERRIDE; 143 StartDoc(const wxString & WXUNUSED (message))144 virtual bool StartDoc( const wxString& WXUNUSED(message) ) wxOVERRIDE { return true; } EndDoc()145 virtual void EndDoc() wxOVERRIDE { } StartPage()146 virtual void StartPage() wxOVERRIDE { } EndPage()147 virtual void EndPage() wxOVERRIDE { } 148 GetGDKWindow()149 virtual GdkWindow* GetGDKWindow() const { return NULL; } GetHandle()150 virtual void* GetHandle() const wxOVERRIDE { return GetGDKWindow(); } 151 152 // base class pure virtuals implemented here 153 virtual void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height) wxOVERRIDE; 154 virtual void DoGetSizeMM(int* width, int* height) const wxOVERRIDE; 155 156 wxDECLARE_ABSTRACT_CLASS(wxGTKDCImpl); 157 }; 158 159 // this must be defined when wxDC::Blit() honours the DC origin and needed to 160 // allow wxUniv code in univ/winuniv.cpp to work with versions of wxGTK 161 // 2.3.[23] 162 #ifndef wxHAS_WORKING_GTK_DC_BLIT 163 #define wxHAS_WORKING_GTK_DC_BLIT 164 #endif 165 166 #endif 167 #endif // _WX_GTKDC_H_ 168