1 /////////////////////////////////////////////////////////////////////////////
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
17 // ---------------------------------------------------------------------------
19 // ---------------------------------------------------------------------------
23 #define XLOG2DEV(x) (x)
24 #define YLOG2DEV(y) (y)
27 #define XLOG2DEVREL(x) (x)
28 #define YLOG2DEVREL(y) (y)
32 #define XDEV2LOG(x) (x)
34 #define YDEV2LOG(y) (y)
37 #define XDEV2LOGREL(x) (x)
38 #define YDEV2LOGREL(y) (y)
41 * Have the same macros as for XView but not for every operation:
42 * just for calculating window/viewport extent (a better way of scaling).
47 #define MS_XLOG2DEV(x) LogicalToDevice(x)
49 #define MS_YLOG2DEV(y) LogicalToDevice(y)
52 #define MS_XLOG2DEVREL(x) LogicalToDeviceXRel(x)
53 #define MS_YLOG2DEVREL(y) LogicalToDeviceYRel(y)
57 #define MS_XDEV2LOG(x) DeviceToLogicalX(x)
59 #define MS_YDEV2LOG(y) DeviceToLogicalY(y)
62 #define MS_XDEV2LOGREL(x) DeviceToLogicalXRel(x)
63 #define MS_YDEV2LOGREL(y) DeviceToLogicalYRel(y)
65 #define YSCALE(y) (yorigin - (y))
67 #define wx_round(a) (int)((a)+.5)
71 * Cached blitting, maintaining a cache
72 * of bitmaps required for transparent blitting
73 * instead of constant creation/deletion
76 class wxDCCacheEntry
: public wxObject
79 wxDCCacheEntry( WXHBITMAP hBitmap
84 wxDCCacheEntry( HPS hPS
87 virtual ~wxDCCacheEntry();
94 }; // end of CLASS wxDCCacheEntry
97 class WXDLLEXPORT wxDC
: public wxDCBase
99 DECLARE_DYNAMIC_CLASS(wxDC
)
105 // implement base class pure virtuals
106 // ----------------------------------
108 virtual void Clear(void);
110 virtual bool StartDoc(const wxString
& rsMessage
);
111 virtual void EndDoc(void);
113 virtual void StartPage(void);
114 virtual void EndPage(void);
116 virtual void SetFont(const wxFont
& rFont
);
117 virtual void SetPen(const wxPen
& rPen
);
118 virtual void SetBrush(const wxBrush
& rBrush
);
119 virtual void SetBackground(const wxBrush
& rBrush
);
120 virtual void SetBackgroundMode(int nMode
);
121 virtual void SetPalette(const wxPalette
& rPalette
);
123 virtual void DestroyClippingRegion(void);
125 virtual wxCoord
GetCharHeight(void) const;
126 virtual wxCoord
GetCharWidth(void) const;
127 virtual void DoGetTextExtent( const wxString
& rsString
130 ,wxCoord
* pDescent
= NULL
131 ,wxCoord
* pExternalLeading
= NULL
132 ,const wxFont
* pTheFont
= NULL
134 virtual bool CanDrawBitmap(void) const;
135 virtual bool CanGetTextExtent(void) const;
136 virtual int GetDepth(void) const;
137 virtual wxSize
GetPPI(void) const;
139 virtual void SetMapMode(int nMode
);
140 virtual void SetUserScale( double dX
143 virtual void SetLogicalScale( double dX
146 virtual void SetLogicalOrigin( wxCoord vX
149 virtual void SetDeviceOrigin( wxCoord vX
152 virtual void SetAxisOrientation( bool bXLeftRight
155 virtual void SetLogicalFunction(int nFunction
);
157 // implementation from now on
158 // --------------------------
160 virtual void SetRop(WXHDC hCdc
);
161 virtual void SelectOldObjects(WXHDC hDc
);
163 wxWindow
* GetWindow(void) const { return m_pCanvas
; }
164 void SetWindow(wxWindow
* pWin
) { m_pCanvas
= pWin
; }
166 WXHDC
GetHDC(void) const { return m_hDC
; }
167 void SetHDC( WXHDC hDc
168 ,bool bOwnsDC
= FALSE
175 HPS
GetHPS(void) const { return m_hPS
; }
180 const wxBitmap
& GetSelectedBitmap(void) const { return m_vSelectedBitmap
; }
181 wxBitmap
& GetSelectedBitmap(void) { return m_vSelectedBitmap
; }
183 void UpdateClipBox();
185 #if wxUSE_DC_CACHEING
186 static wxDCCacheEntry
* FindBitmapInCache( HPS hPS
190 static wxDCCacheEntry
* FindDCInCache( wxDCCacheEntry
* pNotThis
194 static void AddToBitmapCache(wxDCCacheEntry
* pEntry
);
195 static void AddToDCCache(wxDCCacheEntry
* pEntry
);
196 static void ClearCache(void);
200 virtual bool DoFloodFill( wxCoord vX
202 ,const wxColour
& rCol
203 ,int nStyle
= wxFLOOD_SURFACE
206 virtual bool DoGetPixel( wxCoord vX
211 virtual void DoDrawPoint( wxCoord vX
214 virtual void DoDrawLine( wxCoord vX1
220 virtual void DoDrawArc( wxCoord vX1
227 virtual void DoDrawCheckMark( wxCoord vX
232 virtual void DoDrawEllipticArc( wxCoord vX
240 virtual void DoDrawRectangle( wxCoord vX
245 virtual void DoDrawRoundedRectangle( wxCoord vX
251 virtual void DoDrawEllipse( wxCoord vX
257 virtual void DoCrossHair( wxCoord vX
261 virtual void DoDrawIcon( const wxIcon
& rIcon
265 virtual void DoDrawBitmap( const wxBitmap
& rBmp
268 ,bool bUseMask
= FALSE
271 virtual void DoDrawText( const wxString
& rsText
275 virtual void DoDrawRotatedText( const wxString
& rsText
281 virtual bool DoBlit( wxCoord vXdest
289 ,bool bUseMask
= FALSE
290 ,wxCoord vXsrcMask
= -1
291 ,wxCoord vYsrcMask
= -1
294 virtual void DoSetClippingRegionAsRegion(const wxRegion
& rRegion
);
295 virtual void DoSetClippingRegion( wxCoord vX
301 virtual void DoGetSize( int* pWidth
304 virtual void DoGetSizeMM( int* pWidth
308 virtual void DoDrawLines( int n
313 virtual void DoDrawPolygon( int n
317 ,int nFillStyle
= wxODDEVEN_RULE
321 void DoSelectPalette(bool bRealize
= FALSE
);
322 void InitializePalette(void);
323 #endif // wxUSE_PALETTE
326 // common part of DoDrawText() and DoDrawRotatedText()
328 void DrawAnyText( const wxString
& rsText
333 // OS2-specific member variables ?? do we even need this under OS/2?
338 // the window associated with this DC (may be NULL)
341 wxBitmap m_vSelectedBitmap
;
346 HPS m_hOldPS
; // old hPS, if any
347 bool m_bIsPaintTime
;// True at Paint Time
349 RECTL m_vRclPaint
; // Bounding rectangle at Paint time etc.
351 // TRUE => DeleteDC() in dtor, FALSE => only ReleaseDC() it
361 // Store all old GDI objects when do a SelectObject, so we can select them
362 // back in (this unselecting user's objects) so we can safely delete the
365 WXHBITMAP m_hOldBitmap
;
367 WXHBRUSH m_hOldBrush
;
369 WXHPALETTE m_hOldPalette
;
371 #if wxUSE_DC_CACHEING
372 static wxList m_svBitmapCache
;
373 static wxList m_svDCCache
;
375 }; // end of CLASS wxDC