root / trunk / install / launcher / izpack-launcher-1.3_linux / src / wx / include / wx / msw / dc.h @ 6834
History | View | Annotate | Download (8.39 KB)
1 |
/////////////////////////////////////////////////////////////////////////////
|
---|---|
2 |
// Name: dc.h
|
3 |
// Purpose: wxDC class
|
4 |
// Author: Julian Smart
|
5 |
// Modified by:
|
6 |
// Created: 01/02/97
|
7 |
// RCS-ID: $Id: dc.h 6834 2006-08-24 08:23:24Z jmvivo $
|
8 |
// Copyright: (c) Julian Smart
|
9 |
// Licence: wxWindows licence
|
10 |
/////////////////////////////////////////////////////////////////////////////
|
11 |
|
12 |
#ifndef _WX_DC_H_
|
13 |
#define _WX_DC_H_
|
14 |
|
15 |
#include "wx/defs.h" |
16 |
#include "wx/dc.h" |
17 |
|
18 |
// ---------------------------------------------------------------------------
|
19 |
// macros
|
20 |
// ---------------------------------------------------------------------------
|
21 |
|
22 |
#if wxUSE_DC_CACHEING
|
23 |
/*
|
24 |
* Cached blitting, maintaining a cache
|
25 |
* of bitmaps required for transparent blitting
|
26 |
* instead of constant creation/deletion
|
27 |
*/
|
28 |
|
29 |
class wxDCCacheEntry: public wxObject |
30 |
{ |
31 |
public:
|
32 |
wxDCCacheEntry(WXHBITMAP hBitmap, int w, int h, int depth); |
33 |
wxDCCacheEntry(WXHDC hDC, int depth);
|
34 |
~wxDCCacheEntry(); |
35 |
|
36 |
WXHBITMAP m_bitmap; |
37 |
WXHDC m_dc; |
38 |
int m_width;
|
39 |
int m_height;
|
40 |
int m_depth;
|
41 |
}; |
42 |
#endif
|
43 |
|
44 |
class WXDLLEXPORT wxDC : public wxDCBase |
45 |
{ |
46 |
public:
|
47 |
wxDC(); |
48 |
~wxDC(); |
49 |
|
50 |
// implement base class pure virtuals
|
51 |
// ----------------------------------
|
52 |
|
53 |
virtual void Clear();
|
54 |
|
55 |
virtual bool StartDoc(const wxString& message); |
56 |
virtual void EndDoc();
|
57 |
|
58 |
virtual void StartPage();
|
59 |
virtual void EndPage();
|
60 |
|
61 |
virtual void SetFont(const wxFont& font); |
62 |
virtual void SetPen(const wxPen& pen); |
63 |
virtual void SetBrush(const wxBrush& brush); |
64 |
virtual void SetBackground(const wxBrush& brush); |
65 |
virtual void SetBackgroundMode(int mode); |
66 |
#if wxUSE_PALETTE
|
67 |
virtual void SetPalette(const wxPalette& palette); |
68 |
#endif // wxUSE_PALETTE |
69 |
|
70 |
virtual void DestroyClippingRegion();
|
71 |
|
72 |
virtual wxCoord GetCharHeight() const;
|
73 |
virtual wxCoord GetCharWidth() const;
|
74 |
virtual void DoGetTextExtent(const wxString& string, |
75 |
wxCoord *x, wxCoord *y, |
76 |
wxCoord *descent = NULL,
|
77 |
wxCoord *externalLeading = NULL,
|
78 |
wxFont *theFont = NULL) const; |
79 |
|
80 |
virtual bool CanDrawBitmap() const; |
81 |
virtual bool CanGetTextExtent() const; |
82 |
virtual int GetDepth() const; |
83 |
virtual wxSize GetPPI() const;
|
84 |
|
85 |
virtual void SetMapMode(int mode); |
86 |
virtual void SetUserScale(double x, double y); |
87 |
virtual void SetSystemScale(double x, double y); |
88 |
virtual void SetLogicalScale(double x, double y); |
89 |
virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
|
90 |
virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
|
91 |
virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp); |
92 |
virtual void SetLogicalFunction(int function); |
93 |
|
94 |
// implementation from now on
|
95 |
// --------------------------
|
96 |
|
97 |
virtual void SetRop(WXHDC cdc);
|
98 |
virtual void SelectOldObjects(WXHDC dc);
|
99 |
|
100 |
wxWindow *GetWindow() const { return m_canvas; } |
101 |
void SetWindow(wxWindow *win)
|
102 |
{ |
103 |
m_canvas = win; |
104 |
|
105 |
#if wxUSE_PALETTE
|
106 |
// if we have palettes use the correct one for this window
|
107 |
InitializePalette(); |
108 |
#endif // wxUSE_PALETTE |
109 |
} |
110 |
|
111 |
WXHDC GetHDC() const { return m_hDC; } |
112 |
void SetHDC(WXHDC dc, bool bOwnsDC = FALSE) |
113 |
{ |
114 |
m_hDC = dc; |
115 |
m_bOwnsDC = bOwnsDC; |
116 |
} |
117 |
|
118 |
const wxBitmap& GetSelectedBitmap() const { return m_selectedBitmap; } |
119 |
wxBitmap& GetSelectedBitmap() { return m_selectedBitmap; }
|
120 |
|
121 |
// update the internal clip box variables
|
122 |
void UpdateClipBox();
|
123 |
|
124 |
#if wxUSE_DC_CACHEING
|
125 |
static wxDCCacheEntry* FindBitmapInCache(WXHDC hDC, int w, int h); |
126 |
static wxDCCacheEntry* FindDCInCache(wxDCCacheEntry* notThis, WXHDC hDC);
|
127 |
|
128 |
static void AddToBitmapCache(wxDCCacheEntry* entry); |
129 |
static void AddToDCCache(wxDCCacheEntry* entry); |
130 |
static void ClearCache(); |
131 |
#endif
|
132 |
|
133 |
protected:
|
134 |
virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, |
135 |
int style = wxFLOOD_SURFACE);
|
136 |
|
137 |
virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const; |
138 |
|
139 |
virtual void DoDrawPoint(wxCoord x, wxCoord y);
|
140 |
virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
|
141 |
|
142 |
virtual void DoDrawArc(wxCoord x1, wxCoord y1,
|
143 |
wxCoord x2, wxCoord y2, |
144 |
wxCoord xc, wxCoord yc); |
145 |
virtual void DoDrawCheckMark(wxCoord x, wxCoord y,
|
146 |
wxCoord width, wxCoord height); |
147 |
virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
|
148 |
double sa, double ea); |
149 |
|
150 |
virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
|
151 |
virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
|
152 |
wxCoord width, wxCoord height, |
153 |
double radius);
|
154 |
virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
|
155 |
|
156 |
virtual void DoCrossHair(wxCoord x, wxCoord y);
|
157 |
|
158 |
virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y); |
159 |
virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, |
160 |
bool useMask = FALSE);
|
161 |
|
162 |
virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y); |
163 |
virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, |
164 |
double angle);
|
165 |
|
166 |
virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
|
167 |
wxDC *source, wxCoord xsrc, wxCoord ysrc, |
168 |
int rop = wxCOPY, bool useMask = FALSE, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1); |
169 |
|
170 |
// this is gnarly - we can't even call this function DoSetClippingRegion()
|
171 |
// because of virtual function hiding
|
172 |
virtual void DoSetClippingRegionAsRegion(const wxRegion& region); |
173 |
virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
|
174 |
wxCoord width, wxCoord height); |
175 |
virtual void DoGetClippingRegion(wxCoord *x, wxCoord *y,
|
176 |
wxCoord *width, wxCoord *height) |
177 |
{ |
178 |
GetClippingBox(x, y, width, height); |
179 |
} |
180 |
|
181 |
virtual void DoGetSize(int *width, int *height) const; |
182 |
virtual void DoGetSizeMM(int* width, int* height) const; |
183 |
|
184 |
virtual void DoDrawLines(int n, wxPoint points[], |
185 |
wxCoord xoffset, wxCoord yoffset); |
186 |
virtual void DoDrawPolygon(int n, wxPoint points[], |
187 |
wxCoord xoffset, wxCoord yoffset, |
188 |
int fillStyle = wxODDEVEN_RULE);
|
189 |
|
190 |
|
191 |
#if wxUSE_PALETTE
|
192 |
// MSW specific, select a logical palette into the HDC
|
193 |
// (tell windows to translate pixel from other palettes to our custom one
|
194 |
// and vice versa)
|
195 |
// Realize tells it to also reset the system palette to this one.
|
196 |
void DoSelectPalette(bool realize = FALSE); |
197 |
|
198 |
// Find out what palette our parent window has, then select it into the dc
|
199 |
void InitializePalette();
|
200 |
#endif // wxUSE_PALETTE |
201 |
|
202 |
// common part of DoDrawText() and DoDrawRotatedText()
|
203 |
void DrawAnyText(const wxString& text, wxCoord x, wxCoord y); |
204 |
|
205 |
// common part of DoSetClippingRegion() and DoSetClippingRegionAsRegion()
|
206 |
void SetClippingHrgn(WXHRGN hrgn);
|
207 |
|
208 |
// MSW-specific member variables
|
209 |
// -----------------------------
|
210 |
|
211 |
// the window associated with this DC (may be NULL)
|
212 |
wxWindow *m_canvas; |
213 |
|
214 |
wxBitmap m_selectedBitmap; |
215 |
|
216 |
// TRUE => DeleteDC() in dtor, FALSE => only ReleaseDC() it
|
217 |
bool m_bOwnsDC:1; |
218 |
|
219 |
// our HDC
|
220 |
WXHDC m_hDC; |
221 |
|
222 |
// Store all old GDI objects when do a SelectObject, so we can select them
|
223 |
// back in (this unselecting user's objects) so we can safely delete the
|
224 |
// DC.
|
225 |
WXHBITMAP m_oldBitmap; |
226 |
WXHPEN m_oldPen; |
227 |
WXHBRUSH m_oldBrush; |
228 |
WXHFONT m_oldFont; |
229 |
|
230 |
#if wxUSE_PALETTE
|
231 |
WXHPALETTE m_oldPalette; |
232 |
#endif // wxUSE_PALETTE |
233 |
|
234 |
#if wxUSE_DC_CACHEING
|
235 |
static wxList sm_bitmapCache;
|
236 |
static wxList sm_dcCache;
|
237 |
#endif
|
238 |
|
239 |
DECLARE_DYNAMIC_CLASS(wxDC) |
240 |
}; |
241 |
|
242 |
// ----------------------------------------------------------------------------
|
243 |
// wxDCTemp: a wxDC which doesn't free the given HDC (used by wxWindows
|
244 |
// only/mainly)
|
245 |
// ----------------------------------------------------------------------------
|
246 |
|
247 |
class WXDLLEXPORT wxDCTemp : public wxDC |
248 |
{ |
249 |
public:
|
250 |
wxDCTemp(WXHDC hdc) { SetHDC(hdc); } |
251 |
virtual ~wxDCTemp() { SetHDC((WXHDC)NULL); }
|
252 |
}; |
253 |
|
254 |
#endif
|
255 |
// _WX_DC_H_
|