]>
Commit | Line | Data |
---|---|---|
9b6dbb09 JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: dcclient.h | |
3 | // Purpose: wxClientDC, wxPaintDC and wxWindowDC classes | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 17/09/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
65571936 | 9 | // Licence: wxWindows licence |
9b6dbb09 JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_DCCLIENT_H_ | |
13 | #define _WX_DCCLIENT_H_ | |
14 | ||
9b6dbb09 JS |
15 | #include "wx/dc.h" |
16 | ||
76208c7e | 17 | // ---------------------------------------------------------------------------- |
af0bb3b1 | 18 | // fwd declarations |
76208c7e | 19 | // ---------------------------------------------------------------------------- |
9b6dbb09 | 20 | |
dfc54541 | 21 | class WXDLLEXPORT wxWindowDC; |
9b6dbb09 JS |
22 | class WXDLLEXPORT wxWindow; |
23 | ||
af0bb3b1 VZ |
24 | // Under Windows, wxClientDC, wxPaintDC and wxWindowDC are implemented |
25 | // differently. On many platforms, however, they will be the same. | |
9b6dbb09 | 26 | |
9b6dbb09 | 27 | //----------------------------------------------------------------------------- |
dfc54541 | 28 | // wxWindowDC |
9b6dbb09 JS |
29 | //----------------------------------------------------------------------------- |
30 | ||
af0bb3b1 | 31 | class WXDLLEXPORT wxWindowDC : public wxDC |
9b6dbb09 | 32 | { |
af0bb3b1 | 33 | DECLARE_DYNAMIC_CLASS(wxWindowDC) |
83df96d6 | 34 | |
af0bb3b1 VZ |
35 | public: |
36 | wxWindowDC(); | |
dfc54541 | 37 | wxWindowDC( wxWindow *win ); |
83df96d6 | 38 | |
af0bb3b1 | 39 | ~wxWindowDC(); |
83df96d6 | 40 | |
af0bb3b1 VZ |
41 | // TODO this function is Motif-only for now - should it go into base class? |
42 | void Clear(const wxRect& rect); | |
83df96d6 | 43 | |
af0bb3b1 VZ |
44 | // implement base class pure virtuals |
45 | // ---------------------------------- | |
83df96d6 | 46 | |
af0bb3b1 | 47 | virtual void Clear(); |
83df96d6 | 48 | |
af0bb3b1 VZ |
49 | virtual void SetFont(const wxFont& font); |
50 | virtual void SetPen(const wxPen& pen); | |
51 | virtual void SetBrush(const wxBrush& brush); | |
52 | virtual void SetBackground(const wxBrush& brush); | |
53 | virtual void SetBackgroundMode(int mode); | |
54 | virtual void SetPalette(const wxPalette& palette); | |
9b6dbb09 | 55 | virtual void SetLogicalFunction( int function ); |
83df96d6 | 56 | |
af0bb3b1 VZ |
57 | virtual void SetTextForeground(const wxColour& colour); |
58 | virtual void SetTextBackground(const wxColour& colour); | |
83df96d6 | 59 | |
7b65ea1a MB |
60 | virtual wxCoord GetCharHeight() const; |
61 | virtual wxCoord GetCharWidth() const; | |
62 | virtual void DoGetTextExtent(const wxString& string, | |
83df96d6 JS |
63 | wxCoord *x, wxCoord *y, |
64 | wxCoord *descent = NULL, | |
65 | wxCoord *externalLeading = NULL, | |
66 | wxFont *theFont = NULL) const; | |
67 | ||
af0bb3b1 VZ |
68 | virtual bool CanDrawBitmap() const; |
69 | virtual bool CanGetTextExtent() const; | |
83df96d6 | 70 | |
af0bb3b1 VZ |
71 | virtual int GetDepth() const; |
72 | virtual wxSize GetPPI() const; | |
83df96d6 | 73 | |
af0bb3b1 | 74 | virtual void DestroyClippingRegion(); |
83df96d6 | 75 | |
af0bb3b1 | 76 | // Helper function for setting clipping |
148b44a1 | 77 | void SetDCClipping(WXRegion region); |
83df96d6 | 78 | |
af0bb3b1 VZ |
79 | // implementation from now on |
80 | // -------------------------- | |
83df96d6 | 81 | |
af0bb3b1 VZ |
82 | WXGC GetGC() const { return m_gc; } |
83 | WXGC GetBackingGC() const { return m_gcBacking; } | |
84 | WXDisplay* GetDisplay() const { return m_display; } | |
85 | bool GetAutoSetting() const { return m_autoSetting; } | |
86 | void SetAutoSetting(bool flag) { m_autoSetting = flag; } | |
83df96d6 | 87 | |
dfc54541 | 88 | protected: |
395539f9 MB |
89 | // note that this function will call colour.SetPixel, |
90 | // and will do one of curCol = colour, curCol = wxWHITE, curCol = wxBLACK | |
91 | // roundToWhite has an effect for monochrome display only | |
96be256b MB |
92 | // if roundToWhite == true then the colour will be set to white unless |
93 | // it is RGB 0x000000;if roundToWhite == true the colour wull be set to | |
395539f9 MB |
94 | // black unless it id RGB 0xffffff |
95 | int CalculatePixel(wxColour& colour, wxColour& curCol, | |
96 | bool roundToWhite) const; | |
97 | // sets the foreground pixel taking into account the | |
98 | // currently selected logical operation | |
99 | void SetForegroundPixelWithLogicalFunction(int pixel); | |
100 | ||
387ebd3e | 101 | virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, |
83df96d6 JS |
102 | int style = wxFLOOD_SURFACE); |
103 | ||
7b65ea1a | 104 | virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const; |
83df96d6 | 105 | |
7b65ea1a MB |
106 | virtual void DoDrawPoint(wxCoord x, wxCoord y); |
107 | virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); | |
83df96d6 | 108 | |
7b65ea1a | 109 | virtual void DoDrawArc(wxCoord x1, wxCoord y1, |
83df96d6 JS |
110 | wxCoord x2, wxCoord y2, |
111 | wxCoord xc, wxCoord yc); | |
7b65ea1a | 112 | virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, |
83df96d6 JS |
113 | double sa, double ea); |
114 | ||
7b65ea1a MB |
115 | virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
116 | virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y, | |
83df96d6 JS |
117 | wxCoord width, wxCoord height, |
118 | double radius); | |
7b65ea1a | 119 | virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
83df96d6 | 120 | |
7b65ea1a | 121 | virtual void DoCrossHair(wxCoord x, wxCoord y); |
83df96d6 | 122 | |
7b65ea1a | 123 | virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y); |
e4e901d1 | 124 | virtual void DoDrawRotatedText(const wxString &text, wxCoord x, wxCoord y, double angle); |
83df96d6 | 125 | |
7b65ea1a | 126 | virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, |
83df96d6 | 127 | wxDC *source, wxCoord xsrc, wxCoord ysrc, |
96be256b | 128 | int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1); |
83df96d6 | 129 | |
af0bb3b1 | 130 | virtual void DoSetClippingRegionAsRegion(const wxRegion& region); |
7b65ea1a | 131 | virtual void DoSetClippingRegion(wxCoord x, wxCoord y, |
83df96d6 JS |
132 | wxCoord width, wxCoord height); |
133 | ||
af0bb3b1 | 134 | virtual void DoDrawLines(int n, wxPoint points[], |
83df96d6 | 135 | wxCoord xoffset, wxCoord yoffset); |
af0bb3b1 | 136 | virtual void DoDrawPolygon(int n, wxPoint points[], |
83df96d6 JS |
137 | wxCoord xoffset, wxCoord yoffset, |
138 | int fillStyle = wxODDEVEN_RULE); | |
76208c7e MB |
139 | |
140 | void DoGetSize( int *width, int *height ) const; | |
141 | ||
142 | // common part of constructors | |
143 | void Init(); | |
144 | ||
dfc54541 JS |
145 | WXGC m_gc; |
146 | WXGC m_gcBacking; | |
147 | WXDisplay* m_display; | |
148 | wxWindow* m_window; | |
148b44a1 MB |
149 | // Pixmap for drawing on |
150 | WXPixmap m_pixmap; | |
151 | // Last clipping region set on th GC, this is the combination | |
152 | // of paint clipping region and all user-defined clipping regions | |
153 | WXRegion m_clipRegion; | |
154 | ||
dfc54541 JS |
155 | // Not sure if we'll need all of these |
156 | int m_backgroundPixel; | |
157 | wxColour m_currentColour; | |
dfc54541 JS |
158 | int m_currentPenWidth ; |
159 | int m_currentPenJoin ; | |
160 | int m_currentPenCap ; | |
161 | int m_currentPenDashCount ; | |
69c44812 | 162 | wxX11Dash* m_currentPenDash ; |
dfc54541 JS |
163 | wxBitmap m_currentStipple ; |
164 | int m_currentStyle ; | |
165 | int m_currentFill ; | |
16c1f7f3 | 166 | int m_autoSetting ; // See comment in dcclient.cpp |
c74b77ed VZ |
167 | |
168 | // this is useless and should be removed, kept for now just for backwards | |
169 | // compatibility | |
170 | #if wxCHECK_VERSION(2, 7, 0) | |
171 | #error "Remove wxClientDC::m_oldFont" | |
172 | #endif | |
e97f20a0 | 173 | WXFont m_oldFont; |
16c1f7f3 JS |
174 | }; |
175 | ||
176 | class WXDLLEXPORT wxPaintDC: public wxWindowDC | |
177 | { | |
af0bb3b1 | 178 | DECLARE_DYNAMIC_CLASS(wxPaintDC) |
83df96d6 | 179 | |
16c1f7f3 | 180 | public: |
af0bb3b1 VZ |
181 | wxPaintDC() { } |
182 | wxPaintDC(wxWindow* win); | |
83df96d6 | 183 | |
af0bb3b1 | 184 | ~wxPaintDC(); |
16c1f7f3 JS |
185 | }; |
186 | ||
187 | class WXDLLEXPORT wxClientDC: public wxWindowDC | |
188 | { | |
af0bb3b1 | 189 | DECLARE_DYNAMIC_CLASS(wxClientDC) |
83df96d6 | 190 | |
16c1f7f3 | 191 | public: |
af0bb3b1 VZ |
192 | wxClientDC() { } |
193 | wxClientDC(wxWindow* win) : wxWindowDC(win) { } | |
9b6dbb09 JS |
194 | }; |
195 | ||
196 | #endif | |
83df96d6 | 197 | // _WX_DCCLIENT_H_ |