1 ///////////////////////////////////////////////////////////////////////////// 2 // Name: wx/gtk/dcclient.h 3 // Purpose: 4 // Author: Robert Roebling 5 // Copyright: (c) 1998 Robert Roebling 6 // Licence: wxWindows licence 7 ///////////////////////////////////////////////////////////////////////////// 8 9 #ifndef _WX_GTKDCCLIENT_H_ 10 #define _WX_GTKDCCLIENT_H_ 11 12 #include "wx/gtk/dc.h" 13 14 //----------------------------------------------------------------------------- 15 // wxWindowDCImpl 16 //----------------------------------------------------------------------------- 17 18 class WXDLLIMPEXP_CORE wxWindowDCImpl : public wxGTKDCImpl 19 { 20 public: 21 wxWindowDCImpl( wxDC *owner ); 22 wxWindowDCImpl( wxDC *owner, wxWindow *win ); 23 24 virtual ~wxWindowDCImpl(); 25 CanDrawBitmap()26 virtual bool CanDrawBitmap() const { return true; } CanGetTextExtent()27 virtual bool CanGetTextExtent() const { return true; } 28 29 virtual void DoGetSize(int *width, int *height) const; 30 virtual bool DoFloodFill( wxCoord x, wxCoord y, const wxColour& col, 31 wxFloodFillStyle style=wxFLOOD_SURFACE ); 32 virtual bool DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const; 33 34 virtual void DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 ); 35 virtual void DoCrossHair( wxCoord x, wxCoord y ); 36 virtual void DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, 37 wxCoord xc, wxCoord yc ); 38 virtual void DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxCoord height, 39 double sa, double ea ); 40 virtual void DoDrawPoint( wxCoord x, wxCoord y ); 41 42 virtual void DoDrawLines(int n, const wxPoint points[], 43 wxCoord xoffset, wxCoord yoffset); 44 virtual void DoDrawPolygon(int n, const wxPoint points[], 45 wxCoord xoffset, wxCoord yoffset, 46 wxPolygonFillMode fillStyle = wxODDEVEN_RULE); 47 48 virtual void DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height ); 49 virtual void DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius = 20.0 ); 50 virtual void DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord height ); 51 52 virtual void DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y ); 53 virtual void DoDrawBitmap( const wxBitmap &bitmap, wxCoord x, wxCoord y, 54 bool useMask = false ); 55 56 virtual bool DoBlit( wxCoord xdest, wxCoord ydest, 57 wxCoord width, wxCoord height, 58 wxDC *source, wxCoord xsrc, wxCoord ysrc, 59 wxRasterOperationMode logical_func = wxCOPY, 60 bool useMask = false, 61 wxCoord xsrcMask = -1, wxCoord ysrcMask = -1 ); 62 63 virtual void DoDrawText( const wxString &text, wxCoord x, wxCoord y ); 64 virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, 65 double angle); 66 virtual void DoGetTextExtent( const wxString &string, 67 wxCoord *width, wxCoord *height, 68 wxCoord *descent = NULL, 69 wxCoord *externalLeading = NULL, 70 const wxFont *theFont = NULL) const; 71 virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const; 72 virtual void DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height ); 73 virtual void DoSetDeviceClippingRegion( const wxRegion ®ion ); 74 75 virtual wxCoord GetCharWidth() const; 76 virtual wxCoord GetCharHeight() const; 77 78 virtual void Clear(); 79 80 virtual void SetFont( const wxFont &font ); 81 virtual void SetPen( const wxPen &pen ); 82 virtual void SetBrush( const wxBrush &brush ); 83 virtual void SetBackground( const wxBrush &brush ); 84 virtual void SetLogicalFunction( wxRasterOperationMode function ); 85 virtual void SetTextForeground( const wxColour &col ); 86 virtual void SetTextBackground( const wxColour &col ); 87 virtual void SetBackgroundMode( int mode ); 88 virtual void SetPalette( const wxPalette& palette ); 89 90 virtual void DestroyClippingRegion(); 91 92 // Resolution in pixels per logical inch 93 virtual wxSize GetPPI() const; 94 virtual int GetDepth() const; 95 96 // overrriden here for RTL 97 virtual void SetDeviceOrigin( wxCoord x, wxCoord y ); 98 virtual void SetAxisOrientation( bool xLeftRight, bool yBottomUp ); 99 100 // protected: 101 // implementation 102 // -------------- 103 104 GdkWindow *m_gdkwindow; 105 GdkGC *m_penGC; 106 GdkGC *m_brushGC; 107 GdkGC *m_textGC; 108 GdkGC *m_bgGC; 109 GdkColormap *m_cmap; 110 bool m_isScreenDC; 111 wxRegion m_currentClippingRegion; 112 wxRegion m_paintClippingRegion; 113 114 // PangoContext stuff for GTK 2.0 115 PangoContext *m_context; 116 PangoLayout *m_layout; 117 PangoFontDescription *m_fontdesc; 118 119 void SetUpDC( bool ismem = false ); 120 void Destroy(); 121 122 virtual void ComputeScaleAndOrigin(); 123 GetGDKWindow()124 virtual GdkWindow *GetGDKWindow() const { return m_gdkwindow; } 125 126 private: 127 void DrawingSetup(GdkGC*& gc, bool& originChanged); 128 GdkPixmap* MonoToColor(GdkPixmap* monoPixmap, int x, int y, int w, int h) const; 129 130 DECLARE_ABSTRACT_CLASS(wxWindowDCImpl) 131 }; 132 133 //----------------------------------------------------------------------------- 134 // wxClientDCImpl 135 //----------------------------------------------------------------------------- 136 137 class WXDLLIMPEXP_CORE wxClientDCImpl : public wxWindowDCImpl 138 { 139 public: 140 wxClientDCImpl( wxDC *owner ); 141 wxClientDCImpl( wxDC *owner, wxWindow *win ); 142 143 virtual void DoGetSize(int *width, int *height) const; 144 145 DECLARE_ABSTRACT_CLASS(wxClientDCImpl) 146 }; 147 148 //----------------------------------------------------------------------------- 149 // wxPaintDCImpl 150 //----------------------------------------------------------------------------- 151 152 class WXDLLIMPEXP_CORE wxPaintDCImpl : public wxClientDCImpl 153 { 154 public: 155 wxPaintDCImpl( wxDC *owner ); 156 wxPaintDCImpl( wxDC *owner, wxWindow *win ); 157 158 DECLARE_ABSTRACT_CLASS(wxPaintDCImpl) 159 }; 160 161 #endif // _WX_GTKDCCLIENT_H_ 162