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 ,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 SetSystemScale( double dX
146 virtual void SetLogicalScale( double dX
149 virtual void SetLogicalOrigin( wxCoord vX
152 virtual void SetDeviceOrigin( wxCoord vX
155 virtual void SetAxisOrientation( bool bXLeftRight
158 virtual void SetLogicalFunction(int nFunction
);
160 // implementation from now on
161 // --------------------------
163 virtual void SetRop(WXHDC hCdc
);
164 virtual void SelectOldObjects(WXHDC hDc
);
166 wxWindow
* GetWindow(void) const { return m_pCanvas
; }
167 void SetWindow(wxWindow
* pWin
) { m_pCanvas
= pWin
; }
169 WXHDC
GetHDC(void) const { return m_hDC
; }
170 void SetHDC( WXHDC hDc
171 ,bool bOwnsDC
= FALSE
178 HPS
GetHPS(void) const { return m_hPS
; }
183 const wxBitmap
& GetSelectedBitmap(void) const { return m_vSelectedBitmap
; }
184 wxBitmap
& GetSelectedBitmap(void) { return m_vSelectedBitmap
; }
186 void UpdateClipBox();
188 #if wxUSE_DC_CACHEING
189 static wxDCCacheEntry
* FindBitmapInCache( HPS hPS
193 static wxDCCacheEntry
* FindDCInCache( wxDCCacheEntry
* pNotThis
197 static void AddToBitmapCache(wxDCCacheEntry
* pEntry
);
198 static void AddToDCCache(wxDCCacheEntry
* pEntry
);
199 static void ClearCache(void);
203 virtual bool DoFloodFill( wxCoord vX
205 ,const wxColour
& rCol
206 ,int nStyle
= wxFLOOD_SURFACE
209 virtual bool DoGetPixel( wxCoord vX
214 virtual void DoDrawPoint( wxCoord vX
217 virtual void DoDrawLine( wxCoord vX1
223 virtual void DoDrawArc( wxCoord vX1
230 virtual void DoDrawCheckMark( wxCoord vX
235 virtual void DoDrawEllipticArc( wxCoord vX
243 virtual void DoDrawRectangle( wxCoord vX
248 virtual void DoDrawRoundedRectangle( wxCoord vX
254 virtual void DoDrawEllipse( wxCoord vX
260 virtual void DoCrossHair( wxCoord vX
264 virtual void DoDrawIcon( const wxIcon
& rIcon
268 virtual void DoDrawBitmap( const wxBitmap
& rBmp
271 ,bool bUseMask
= FALSE
274 virtual void DoDrawText( const wxString
& rsText
278 virtual void DoDrawRotatedText( const wxString
& rsText
284 virtual bool DoBlit( wxCoord vXdest
292 ,bool bUseMask
= FALSE
293 ,wxCoord vXsrcMask
= -1
294 ,wxCoord vYsrcMask
= -1
297 virtual void DoSetClippingRegionAsRegion(const wxRegion
& rRegion
);
298 virtual void DoSetClippingRegion( wxCoord vX
304 virtual void DoGetSize( int* pWidth
307 virtual void DoGetSizeMM( int* pWidth
311 virtual void DoDrawLines( int n
316 virtual void DoDrawPolygon( int n
320 ,int nFillStyle
= wxODDEVEN_RULE
324 void DoSelectPalette(bool bRealize
= FALSE
);
325 void InitializePalette(void);
326 #endif // wxUSE_PALETTE
329 // common part of DoDrawText() and DoDrawRotatedText()
331 void DrawAnyText( const wxString
& rsText
336 // OS2-specific member variables ?? do we even need this under OS/2?
341 // the window associated with this DC (may be NULL)
344 wxBitmap m_vSelectedBitmap
;
349 HPS m_hOldPS
; // old hPS, if any
350 bool m_bIsPaintTime
;// True at Paint Time
352 RECTL m_vRclPaint
; // Bounding rectangle at Paint time etc.
354 // TRUE => DeleteDC() in dtor, FALSE => only ReleaseDC() it
364 // Store all old GDI objects when do a SelectObject, so we can select them
365 // back in (this unselecting user's objects) so we can safely delete the
368 WXHBITMAP m_hOldBitmap
;
370 WXHBRUSH m_hOldBrush
;
372 WXHPALETTE m_hOldPalette
;
374 #if wxUSE_DC_CACHEING
375 static wxList m_svBitmapCache
;
376 static wxList m_svDCCache
;
378 }; // end of CLASS wxDC