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
88 virtual ~wxDCCacheEntry();
95 }; // end of CLASS wxDCCacheEntry
98 // this is an ABC: use one of the derived classes to create a DC associated
99 // with a window, screen, printer and so on
100 class WXDLLIMPEXP_CORE wxPMDCImpl
: public wxDCImpl
102 DECLARE_DYNAMIC_CLASS(wxDC
)
105 wxPMDCImpl(wxDC
*owner
, WXHDC hDC
);
106 virtual ~wxPMDCImpl();
108 // implement base class pure virtuals
109 // ----------------------------------
111 virtual void Clear(void);
113 virtual bool StartDoc(const wxString
& rsMessage
);
114 virtual void EndDoc(void);
116 virtual void StartPage(void);
117 virtual void EndPage(void);
119 virtual void SetFont(const wxFont
& rFont
);
120 virtual void SetPen(const wxPen
& rPen
);
121 virtual void SetBrush(const wxBrush
& rBrush
);
122 virtual void SetBackground(const wxBrush
& rBrush
);
123 virtual void SetBackgroundMode(int nMode
);
124 virtual void SetPalette(const wxPalette
& rPalette
);
126 virtual void DestroyClippingRegion(void);
128 virtual wxCoord
GetCharHeight(void) const;
129 virtual wxCoord
GetCharWidth(void) const;
131 virtual bool CanDrawBitmap(void) const;
132 virtual bool CanGetTextExtent(void) const;
133 virtual int GetDepth(void) const;
134 virtual wxSize
GetPPI(void) const;
136 virtual void SetMapMode(int nMode
);
137 virtual void SetUserScale( double dX
140 virtual void SetLogicalScale( double dX
143 virtual void SetLogicalOrigin( wxCoord vX
146 virtual void SetDeviceOrigin( wxCoord vX
149 virtual void SetAxisOrientation( bool bXLeftRight
152 virtual void SetLogicalFunction(wxRasterOperationMode nFunction
);
154 // implementation from now on
155 // --------------------------
157 virtual void SetRop(WXHDC hCdc
);
158 virtual void SelectOldObjects(WXHDC hDc
);
160 wxWindow
* GetWindow(void) const { return m_pCanvas
; }
161 void SetWindow(wxWindow
* pWin
) { m_pCanvas
= pWin
; }
163 WXHDC
GetHDC(void) const { return m_hDC
; }
164 void SetHDC( WXHDC hDc
165 ,bool bOwnsDC
= FALSE
172 HPS
GetHPS(void) const { return m_hPS
; }
177 const wxBitmap
& GetSelectedBitmap(void) const { return m_vSelectedBitmap
; }
178 wxBitmap
& GetSelectedBitmap(void) { return m_vSelectedBitmap
; }
180 void UpdateClipBox();
182 #if wxUSE_DC_CACHEING
183 static wxDCCacheEntry
* FindBitmapInCache( HPS hPS
187 static wxDCCacheEntry
* FindDCInCache( wxDCCacheEntry
* pNotThis
191 static void AddToBitmapCache(wxDCCacheEntry
* pEntry
);
192 static void AddToDCCache(wxDCCacheEntry
* pEntry
);
193 static void ClearCache(void);
206 #endif // wxUSE_PALETTE
212 m_bIsPaintTime
= false; // True at Paint Time
214 m_pen
.SetColour(*wxBLACK
);
215 m_brush
.SetColour(*wxWHITE
);
218 // create an uninitialized DC: this should be only used by the derived
220 wxPMDCImpl( wxDC
*owner
) : wxDCImpl( owner
) { Init(); }
223 virtual void DoGetTextExtent( const wxString
& rsString
226 ,wxCoord
* pDescent
= NULL
227 ,wxCoord
* pExternalLeading
= NULL
228 ,const wxFont
* pTheFont
= NULL
230 virtual bool DoFloodFill( wxCoord vX
232 ,const wxColour
& rCol
233 ,wxFloodFillStyle nStyle
= wxFLOOD_SURFACE
236 virtual bool DoGetPixel( wxCoord vX
241 virtual void DoDrawPoint( wxCoord vX
244 virtual void DoDrawLine( wxCoord vX1
250 virtual void DoDrawArc( wxCoord vX1
257 virtual void DoDrawCheckMark( wxCoord vX
262 virtual void DoDrawEllipticArc( wxCoord vX
270 virtual void DoDrawRectangle( wxCoord vX
275 virtual void DoDrawRoundedRectangle( wxCoord vX
281 virtual void DoDrawEllipse( wxCoord vX
287 virtual void DoCrossHair( wxCoord vX
291 virtual void DoDrawIcon( const wxIcon
& rIcon
295 virtual void DoDrawBitmap( const wxBitmap
& rBmp
298 ,bool bUseMask
= FALSE
301 virtual void DoDrawText( const wxString
& rsText
305 virtual void DoDrawRotatedText( const wxString
& rsText
311 virtual bool DoBlit( wxCoord vXdest
318 ,wxRasterOperationMode nRop
= wxCOPY
319 ,bool bUseMask
= FALSE
320 ,wxCoord vXsrcMask
= -1
321 ,wxCoord vYsrcMask
= -1
324 virtual void DoSetClippingRegion( wxCoord vX
329 virtual void DoSetDeviceClippingRegion(const wxRegion
& rRegion
);
331 virtual void DoGetSize( int* pWidth
334 virtual void DoGetSizeMM( int* pWidth
338 virtual void DoDrawLines( int n
343 virtual void DoDrawPolygon( int n
347 ,wxPolygonFillMode nFillStyle
= wxODDEVEN_RULE
351 void DoSelectPalette(bool bRealize
= FALSE
);
352 void InitializePalette(void);
353 #endif // wxUSE_PALETTE
357 // common part of DoDrawText() and DoDrawRotatedText()
359 void DrawAnyText( const wxString
& rsText
364 // OS2-specific member variables ?? do we even need this under OS/2?
369 // the window associated with this DC (may be NULL)
372 wxBitmap m_vSelectedBitmap
;
377 HPS m_hOldPS
; // old hPS, if any
378 bool m_bIsPaintTime
;// True at Paint Time
380 RECTL m_vRclPaint
; // Bounding rectangle at Paint time etc.
382 // TRUE => DeleteDC() in dtor, FALSE => only ReleaseDC() it
392 // Store all old GDI objects when do a SelectObject, so we can select them
393 // back in (this unselecting user's objects) so we can safely delete the
396 WXHBITMAP m_hOldBitmap
;
398 WXHBRUSH m_hOldBrush
;
400 WXHPALETTE m_hOldPalette
;
402 #if wxUSE_DC_CACHEING
403 static wxList m_svBitmapCache
;
404 static wxList m_svDCCache
;
406 }; // end of CLASS wxDC