]> git.saurik.com Git - wxWidgets.git/blob - include/wx/os2/dc.h
90a77078b517bdc7d3880dec22e2c2f1265665f3
[wxWidgets.git] / include / wx / os2 / dc.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: dc.h
3 // Purpose: wxDC class
4 // Author: AUTHOR
5 // Modified by:
6 // Created: ??/??/98
7 // RCS-ID: $Id$
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_DC_H_
13 #define _WX_DC_H_
14
15 #ifdef __GNUG__
16 #pragma interface "dc.h"
17 #endif
18
19 #include "wx/pen.h"
20 #include "wx/brush.h"
21 #include "wx/icon.h"
22 #include "wx/font.h"
23 #include "wx/gdicmn.h"
24
25 //-----------------------------------------------------------------------------
26 // constants
27 //-----------------------------------------------------------------------------
28
29 #ifndef MM_TEXT
30 #define MM_TEXT 0
31 #define MM_ISOTROPIC 1
32 #define MM_ANISOTROPIC 2
33 #define MM_LOMETRIC 3
34 #define MM_HIMETRIC 4
35 #define MM_TWIPS 5
36 #define MM_POINTS 6
37 #define MM_METRIC 7
38 #endif
39
40 //-----------------------------------------------------------------------------
41 // global variables
42 //-----------------------------------------------------------------------------
43
44 extern int wxPageNumber;
45
46 //-----------------------------------------------------------------------------
47 // wxDC
48 //-----------------------------------------------------------------------------
49
50 class WXDLLEXPORT wxDC: public wxDCBase
51 {
52 DECLARE_ABSTRACT_CLASS(wxDC)
53
54 public:
55
56 wxDC(void);
57 ~wxDC(void);
58
59 virtual void BeginDrawing(void) { };
60 virtual void EndDrawing(void) { };
61
62 //-----------------------------------------------------------------------------
63 // Pure virtuals from wxDCBase that need defining
64 //-----------------------------------------------------------------------------
65 virtual bool CanDrawBitmap(void) const { return TRUE; };
66 virtual bool CanGetTextExtent(void) const { return TRUE; };
67 virtual int GetDepth(void) const;
68 virtual wxSize GetPPI(void) const;
69 virtual void GetTextExtent( const wxString& string
70 ,long* width
71 ,long* height
72 ,long* descent = NULL
73 ,long* externalLeading = NULL
74 ,wxFont* theFont = NULL
75 ) const;
76 virtual long GetCharWidth(void) const;
77 virtual long GetCharHeight(void) const;
78 virtual void Clear(void);
79 virtual void SetFont(const wxFont& font);
80 virtual void SetPen(const wxPen& pen);
81 virtual void SetBrush(const wxBrush& brush);
82 virtual void SetBackground(const wxBrush& brush);
83 virtual void SetLogicalFunction(int function);
84 virtual void SetBackgroundMode(int mode);
85 virtual void SetPalette(const wxPalette& palette);
86 virtual void SetMapMode(int mode);
87 virtual void DestroyClippingRegion(void);
88 virtual void SetUserScale(double x, double y);
89 virtual void SetLogicalOrigin(long x, long y);
90 virtual void SetDeviceOrigin(long x, long y);
91 virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
92
93 virtual void DoFloodFill( long x
94 ,long y
95 ,const wxColour& col
96 ,int style = wxFLOOD_SURFACE
97 );
98 virtual bool DoGetPixel(long x, long y, wxColour *col) const;
99 virtual void DoDrawPoint(long x, long y);
100 virtual void DoDrawLine(long x1, long y1, long x2, long y2);
101 virtual void DoDrawArc(long x1, long y1,
102 long x2, long y2,
103 long xc, long yc
104 );
105 virtual void DoDrawEllipticArc( long x, long y
106 ,long w, long h
107 ,double sa, double ea
108 );
109 virtual void DoDrawRectangle(long x, long y, long width, long height);
110 virtual void DoDrawRoundedRectangle( long x, long y
111 ,long width, long height
112 ,double radius
113 );
114 virtual void DoDrawEllipse(long x, long y, long width, long height);
115 virtual void DoCrossHair(long x, long y);
116 virtual void DoDrawIcon(const wxIcon& icon, long x, long y);
117 virtual void DoDrawBitmap( const wxBitmap &bmp
118 ,long x, long y
119 ,bool useMask = FALSE
120 );
121 virtual void DoDrawText(const wxString& text, long x, long y);
122 virtual bool DoBlit( long xdest, long ydest
123 ,long width, long height
124 ,wxDC *source
125 ,long xsrc, long ysrc
126 ,int rop = wxCOPY, bool useMask = FALSE
127 );
128 virtual void DoGetSize(int *width, int *height) const;
129 virtual void DoGetSizeMM(int* width, int* height) const;
130 virtual void DoDrawLines( int n, wxPoint points[]
131 ,long xoffset, long yoffset
132 );
133 virtual void DoDrawPolygon( int n, wxPoint points[]
134 ,long xoffset, long yoffset
135 ,int fillStyle = wxODDEVEN_RULE
136 );
137 virtual void DoSetClippingRegionAsRegion(const wxRegion& region);
138 virtual void DoSetClippingRegion( long x, long y
139 ,long width, long height
140 );
141 #if wxUSE_SPLINES
142 virtual void DoDrawSpline(wxList *points);
143 #endif
144
145 //-----------------------------------------------------------------------------
146 // Other virtuals from wxDCBase that are overridden here
147 //-----------------------------------------------------------------------------
148
149 virtual void SetLogicalScale( double x, double y );
150
151 //-----------------------------------------------------------------------------
152 // Our own new stuff
153 //-----------------------------------------------------------------------------
154 virtual void SetInternalDeviceOrigin( long x, long y );
155 virtual void GetInternalDeviceOrigin( long *x, long *y );
156
157 private:
158
159 void ComputeScaleAndOrigin(void);
160 long XDEV2LOG(long x) const;
161 long XDEV2LOGREL(long x) const;
162 long YDEV2LOG(long y) const;
163 long YDEV2LOGREL(long y) const;
164 long XLOG2DEV(long x) const;
165 long XLOG2DEVREL(long x) const;
166 long YLOG2DEV(long y) const;
167 long YLOG2DEVREL(long y) const;
168
169 #if WXWIN_COMPATIBILITY
170 // function hiding warning supression
171 virtual void GetTextExtent( const wxString& string
172 ,long* width
173 ,long* height
174 ,long* descent = NULL
175 ,long* externalLeading = NULL
176 ,wxFont* theFont = NULL
177 ,bool use16 = FALSE
178 ) const
179 { wxDCBase::GetTextExtent(string, width, height, descent, externalLeading, theFont, use16); };
180 #endif
181
182 protected:
183
184 // ------------------------------------------------------------------------
185 // Some additional data we need
186 // ------------------------------------------------------------------------
187
188 // Owner canvas and selected in bitmap (if bitmap is GDI object selected)
189 wxWindow* m_owner;
190 wxBitmap* m_bitmap;
191
192 // our HDC and its usage count: we only free it when the usage count drops
193 // to 0
194 WXHDC m_hDC;
195 int m_hDCCount;
196
197 // Store all old GDI objects when do a SelectObject, so we can select them
198 // back in (this unselecting user's objects) so we can safely delete the
199 // DC.
200 WXHBITMAP m_oldBitmap;
201 WXHPEN m_oldPen;
202 WXHBRUSH m_oldBrush;
203 WXHFONT m_oldFont;
204 WXHPALETTE m_oldPalette;
205 };
206
207 #endif
208 // _WX_DC_H_