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
; }
182 HDC hDC
= ::GpiQueryDevice(hPS
);
185 const wxBitmap
& GetSelectedBitmap(void) const { return m_vSelectedBitmap
; }
186 wxBitmap
& GetSelectedBitmap(void) { return m_vSelectedBitmap
; }
188 void UpdateClipBox();
190 #if wxUSE_DC_CACHEING
191 static wxDCCacheEntry
* FindBitmapInCache( HPS hPS
195 static wxDCCacheEntry
* FindDCInCache( wxDCCacheEntry
* pNotThis
199 static void AddToBitmapCache(wxDCCacheEntry
* pEntry
);
200 static void AddToDCCache(wxDCCacheEntry
* pEntry
);
201 static void ClearCache(void);
205 virtual void DoFloodFill( wxCoord vX
207 ,const wxColour
& rCol
208 ,int nStyle
= wxFLOOD_SURFACE
211 virtual bool DoGetPixel( wxCoord vX
216 virtual void DoDrawPoint( wxCoord vX
219 virtual void DoDrawLine( wxCoord vX1
225 virtual void DoDrawArc( wxCoord vX1
232 virtual void DoDrawCheckMark( wxCoord vX
237 virtual void DoDrawEllipticArc( wxCoord vX
245 virtual void DoDrawRectangle( wxCoord vX
250 virtual void DoDrawRoundedRectangle( wxCoord vX
256 virtual void DoDrawEllipse( wxCoord vX
262 virtual void DoCrossHair( wxCoord vX
266 virtual void DoDrawIcon( const wxIcon
& rIcon
270 virtual void DoDrawBitmap( const wxBitmap
& rBmp
273 ,bool bUseMask
= FALSE
276 virtual void DoDrawText( const wxString
& rsText
280 virtual void DoDrawRotatedText( const wxString
& rsText
286 virtual bool DoBlit( wxCoord vXdest
294 ,bool bUseMask
= FALSE
295 ,wxCoord vXsrcMask
= -1
296 ,wxCoord vYsrcMask
= -1
299 virtual void DoSetClippingRegionAsRegion(const wxRegion
& rRegion
);
300 virtual void DoSetClippingRegion( wxCoord vX
305 virtual void DoGetClippingRegion( wxCoord
* pX
317 virtual void DoGetSize( int* pWidth
320 virtual void DoGetSizeMM( int* pWidth
324 virtual void DoDrawLines( int n
329 virtual void DoDrawPolygon( int n
333 ,int nFillStyle
= wxODDEVEN_RULE
337 void DoSelectPalette(bool bRealize
= FALSE
);
338 void InitializePalette(void);
339 #endif // wxUSE_PALETTE
342 // common part of DoDrawText() and DoDrawRotatedText()
344 void DrawAnyText( const wxString
& rsText
349 // OS2-specific member variables ?? do we even need this under OS/2?
354 // the window associated with this DC (may be NULL)
357 wxBitmap m_vSelectedBitmap
;
362 HPS m_hOldPS
; // old hPS, if any
363 bool m_bIsPaintTime
;// True at Paint Time
365 RECTL m_vRclPaint
; // Bounding rectangle at Paint time etc.
367 // TRUE => DeleteDC() in dtor, FALSE => only ReleaseDC() it
377 // Store all old GDI objects when do a SelectObject, so we can select them
378 // back in (this unselecting user's objects) so we can safely delete the
381 WXHBITMAP m_hOldBitmap
;
383 WXHBRUSH m_hOldBrush
;
385 WXHPALETTE m_hOldPalette
;
387 #if wxUSE_DC_CACHEING
388 static wxList m_svBitmapCache
;
389 static wxList m_svDCCache
;
391 }; // end of CLASS wxDC