1 /////////////////////////////////////////////////////////////////////////////
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
18 // ---------------------------------------------------------------------------
20 // ---------------------------------------------------------------------------
24 #define XLOG2DEV(x) (x)
25 #define YLOG2DEV(y) (y)
28 #define XLOG2DEVREL(x) (x)
29 #define YLOG2DEVREL(y) (y)
33 #define XDEV2LOG(x) (x)
35 #define YDEV2LOG(y) (y)
38 #define XDEV2LOGREL(x) (x)
39 #define YDEV2LOGREL(y) (y)
42 * Have the same macros as for XView but not for every operation:
43 * just for calculating window/viewport extent (a better way of scaling).
48 #define MS_XLOG2DEV(x) LogicalToDevice(x)
50 #define MS_YLOG2DEV(y) LogicalToDevice(y)
53 #define MS_XLOG2DEVREL(x) LogicalToDeviceXRel(x)
54 #define MS_YLOG2DEVREL(y) LogicalToDeviceYRel(y)
58 #define MS_XDEV2LOG(x) DeviceToLogicalX(x)
60 #define MS_YDEV2LOG(y) DeviceToLogicalY(y)
63 #define MS_XDEV2LOGREL(x) DeviceToLogicalXRel(x)
64 #define MS_YDEV2LOGREL(y) DeviceToLogicalYRel(y)
66 #define YSCALE(y) (yorigin - (y))
68 #define wx_round(a) (int)((a)+.5)
72 * Cached blitting, maintaining a cache
73 * of bitmaps required for transparent blitting
74 * instead of constant creation/deletion
77 class wxDCCacheEntry
: public wxObject
80 wxDCCacheEntry( WXHBITMAP hBitmap
85 wxDCCacheEntry( HPS hPS
95 }; // end of CLASS wxDCCacheEntry
98 class WXDLLEXPORT wxDC
: public wxDCBase
100 DECLARE_DYNAMIC_CLASS(wxDC
)
106 // implement base class pure virtuals
107 // ----------------------------------
109 virtual void Clear(void);
111 virtual bool StartDoc(const wxString
& rsMessage
);
112 virtual void EndDoc(void);
114 virtual void StartPage(void);
115 virtual void EndPage(void);
117 virtual void SetFont(const wxFont
& rFont
);
118 virtual void SetPen(const wxPen
& rPen
);
119 virtual void SetBrush(const wxBrush
& rBrush
);
120 virtual void SetBackground(const wxBrush
& rBrush
);
121 virtual void SetBackgroundMode(int nMode
);
122 virtual void SetPalette(const wxPalette
& rPalette
);
124 virtual void DestroyClippingRegion(void);
126 virtual wxCoord
GetCharHeight(void) const;
127 virtual wxCoord
GetCharWidth(void) const;
128 virtual void DoGetTextExtent( const wxString
& rsString
131 ,wxCoord
* pDescent
= NULL
132 ,wxCoord
* pExternalLeading
= NULL
133 ,wxFont
* pTheFont
= NULL
135 virtual bool CanDrawBitmap(void) const;
136 virtual bool CanGetTextExtent(void) const;
137 virtual int GetDepth(void) const;
138 virtual wxSize
GetPPI(void) const;
140 virtual void SetMapMode(int nMode
);
141 virtual void SetUserScale( double dX
144 virtual void SetSystemScale( double dX
147 virtual void SetLogicalScale( double dX
150 virtual void SetLogicalOrigin( wxCoord vX
153 virtual void SetDeviceOrigin( wxCoord vX
156 virtual void SetAxisOrientation( bool bXLeftRight
159 virtual void SetLogicalFunction(int nFunction
);
161 // implementation from now on
162 // --------------------------
164 virtual void SetRop(WXHDC hCdc
);
165 virtual void SelectOldObjects(WXHDC hDc
);
167 wxWindow
* GetWindow(void) const { return m_pCanvas
; }
168 void SetWindow(wxWindow
* pWin
) { m_pCanvas
= pWin
; }
170 WXHDC
GetHDC(void) const { return m_hDC
; }
171 void SetHDC( WXHDC hDc
172 ,bool bOwnsDC
= FALSE
179 HPS
GetHPS(void) const { return m_hPS
; }
184 const wxBitmap
& GetSelectedBitmap(void) const { return m_vSelectedBitmap
; }
185 wxBitmap
& GetSelectedBitmap(void) { return m_vSelectedBitmap
; }
187 void UpdateClipBox();
189 #if wxUSE_DC_CACHEING
190 static wxDCCacheEntry
* FindBitmapInCache( HPS hPS
194 static wxDCCacheEntry
* FindDCInCache( wxDCCacheEntry
* pNotThis
198 static void AddToBitmapCache(wxDCCacheEntry
* pEntry
);
199 static void AddToDCCache(wxDCCacheEntry
* pEntry
);
200 static void ClearCache(void);
204 virtual bool DoFloodFill( wxCoord vX
206 ,const wxColour
& rCol
207 ,int nStyle
= wxFLOOD_SURFACE
210 virtual bool DoGetPixel( wxCoord vX
215 virtual void DoDrawPoint( wxCoord vX
218 virtual void DoDrawLine( wxCoord vX1
224 virtual void DoDrawArc( wxCoord vX1
231 virtual void DoDrawCheckMark( wxCoord vX
236 virtual void DoDrawEllipticArc( wxCoord vX
244 virtual void DoDrawRectangle( wxCoord vX
249 virtual void DoDrawRoundedRectangle( wxCoord vX
255 virtual void DoDrawEllipse( wxCoord vX
261 virtual void DoCrossHair( wxCoord vX
265 virtual void DoDrawIcon( const wxIcon
& rIcon
269 virtual void DoDrawBitmap( const wxBitmap
& rBmp
272 ,bool bUseMask
= FALSE
275 virtual void DoDrawText( const wxString
& rsText
279 virtual void DoDrawRotatedText( const wxString
& rsText
285 virtual bool DoBlit( wxCoord vXdest
293 ,bool bUseMask
= FALSE
294 ,wxCoord vXsrcMask
= -1
295 ,wxCoord vYsrcMask
= -1
298 virtual void DoSetClippingRegionAsRegion(const wxRegion
& rRegion
);
299 virtual void DoSetClippingRegion( wxCoord vX
304 virtual void DoGetClippingRegion( wxCoord
* pX
316 virtual void DoGetSize( int* pWidth
319 virtual void DoGetSizeMM( int* pWidth
323 virtual void DoDrawLines( int n
328 virtual void DoDrawPolygon( int n
332 ,int nFillStyle
= wxODDEVEN_RULE
336 void DoSelectPalette(bool bRealize
= FALSE
);
337 void InitializePalette(void);
338 #endif // wxUSE_PALETTE
341 // common part of DoDrawText() and DoDrawRotatedText()
343 void DrawAnyText( const wxString
& rsText
348 // OS2-specific member variables ?? do we even need this under OS/2?
353 // the window associated with this DC (may be NULL)
356 wxBitmap m_vSelectedBitmap
;
361 HPS m_hOldPS
; // old hPS, if any
362 bool m_bIsPaintTime
;// True at Paint Time
364 RECTL m_vRclPaint
; // Bounding rectangle at Paint time etc.
366 // TRUE => DeleteDC() in dtor, FALSE => only ReleaseDC() it
376 // Store all old GDI objects when do a SelectObject, so we can select them
377 // back in (this unselecting user's objects) so we can safely delete the
380 WXHBITMAP m_hOldBitmap
;
382 WXHBRUSH m_hOldBrush
;
384 WXHPALETTE m_hOldPalette
;
386 #if wxUSE_DC_CACHEING
387 static wxList m_svBitmapCache
;
388 static wxList m_svDCCache
;
390 }; // end of CLASS wxDC