]> git.saurik.com Git - wxWidgets.git/blob - include/wx/motif/dcclient.h
made GetMultiLineTextExtent() const (part of patch 1595123)
[wxWidgets.git] / include / wx / motif / dcclient.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/motif/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
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_DCCLIENT_H_
13 #define _WX_DCCLIENT_H_
14
15 #include "wx/dc.h"
16
17 // ----------------------------------------------------------------------------
18 // fwd declarations
19 // ----------------------------------------------------------------------------
20
21 class WXDLLEXPORT wxWindowDC;
22 class WXDLLEXPORT wxWindow;
23
24 // Under Windows, wxClientDC, wxPaintDC and wxWindowDC are implemented
25 // differently. On many platforms, however, they will be the same.
26
27 //-----------------------------------------------------------------------------
28 // wxWindowDC
29 //-----------------------------------------------------------------------------
30
31 class WXDLLEXPORT wxWindowDC : public wxDC
32 {
33 DECLARE_DYNAMIC_CLASS(wxWindowDC)
34
35 public:
36 wxWindowDC();
37 wxWindowDC( wxWindow *win );
38
39 virtual ~wxWindowDC();
40
41 // TODO this function is Motif-only for now - should it go into base class?
42 void Clear(const wxRect& rect);
43
44 // implement base class pure virtuals
45 // ----------------------------------
46
47 virtual void Clear();
48
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);
55 virtual void SetLogicalFunction( int function );
56
57 virtual void SetTextForeground(const wxColour& colour);
58 virtual void SetTextBackground(const wxColour& colour);
59
60 virtual wxCoord GetCharHeight() const;
61 virtual wxCoord GetCharWidth() const;
62 virtual void DoGetTextExtent(const wxString& string,
63 wxCoord *x, wxCoord *y,
64 wxCoord *descent = NULL,
65 wxCoord *externalLeading = NULL,
66 wxFont *theFont = NULL) const;
67
68 virtual bool CanDrawBitmap() const;
69 virtual bool CanGetTextExtent() const;
70
71 virtual int GetDepth() const;
72 virtual wxSize GetPPI() const;
73
74 virtual void DestroyClippingRegion();
75
76 // Helper function for setting clipping
77 void SetDCClipping(WXRegion region);
78
79 // implementation from now on
80 // --------------------------
81
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 != 0); } // See comment in dcclient.cpp
86 void SetAutoSetting(bool flag) { m_autoSetting = flag; }
87
88 protected:
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
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
94 // black unless it id RGB 0xffffff
95 WXPixel 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(WXPixel pixel);
100
101 virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
102 int style = wxFLOOD_SURFACE);
103
104 virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const;
105
106 virtual void DoDrawPoint(wxCoord x, wxCoord y);
107 virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
108
109 virtual void DoDrawArc(wxCoord x1, wxCoord y1,
110 wxCoord x2, wxCoord y2,
111 wxCoord xc, wxCoord yc);
112 virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
113 double sa, double ea);
114
115 virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
116 virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
117 wxCoord width, wxCoord height,
118 double radius);
119 virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
120
121 virtual void DoCrossHair(wxCoord x, wxCoord y);
122
123 virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y);
124 virtual void DoDrawRotatedText(const wxString &text, wxCoord x, wxCoord y, double angle);
125
126 virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
127 wxDC *source, wxCoord xsrc, wxCoord ysrc,
128 int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1);
129
130 virtual void DoSetClippingRegionAsRegion(const wxRegion& region);
131 virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
132 wxCoord width, wxCoord height);
133
134 virtual void DoDrawLines(int n, wxPoint points[],
135 wxCoord xoffset, wxCoord yoffset);
136 virtual void DoDrawPolygon(int n, wxPoint points[],
137 wxCoord xoffset, wxCoord yoffset,
138 int fillStyle = wxODDEVEN_RULE);
139
140 void DoGetSize( int *width, int *height ) const;
141
142 // common part of constructors
143 void Init();
144
145 WXGC m_gc;
146 WXGC m_gcBacking;
147 WXDisplay* m_display;
148 wxWindow* m_window;
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
155 // Not sure if we'll need all of these
156 WXPixel m_backgroundPixel;
157 wxColour m_currentColour;
158 int m_currentPenWidth ;
159 int m_currentPenJoin ;
160 int m_currentPenCap ;
161 int m_currentPenDashCount ;
162 wxX11Dash* m_currentPenDash ;
163 wxBitmap m_currentStipple ;
164 int m_currentStyle ;
165 int m_currentFill ;
166 int m_autoSetting ; // See comment in dcclient.cpp
167 };
168
169 class WXDLLEXPORT wxPaintDC: public wxWindowDC
170 {
171 DECLARE_DYNAMIC_CLASS(wxPaintDC)
172
173 public:
174 wxPaintDC() { }
175 wxPaintDC(wxWindow* win);
176
177 virtual ~wxPaintDC();
178 };
179
180 class WXDLLEXPORT wxClientDC: public wxWindowDC
181 {
182 DECLARE_DYNAMIC_CLASS(wxClientDC)
183
184 public:
185 wxClientDC() { }
186 wxClientDC(wxWindow* win) : wxWindowDC(win) { }
187 };
188
189 #endif // _WX_DCCLIENT_H_