1 /////////////////////////////////////////////////////////////////////////////
4 // Author: David Webster
7 // Copyright: (c) David Webster
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
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 // this is an ABC: use one of the derived classes to create a DC associated
98 // with a window, screen, printer and so on
99 class WXDLLIMPEXP_CORE wxPMDCImpl
: public wxDCImpl
101 DECLARE_DYNAMIC_CLASS(wxDC
)
104 wxPMDCImpl(wxDC
*owner
, WXHDC hDC
);
105 virtual ~wxPMDCImpl();
107 // implement base class pure virtuals
108 // ----------------------------------
110 virtual void Clear();
112 virtual bool StartDoc(const wxString
& rsMessage
);
113 virtual void EndDoc();
115 virtual void StartPage();
116 virtual void EndPage();
118 virtual void SetFont(const wxFont
& rFont
);
119 virtual void SetPen(const wxPen
& rPen
);
120 virtual void SetBrush(const wxBrush
& rBrush
);
121 virtual void SetBackground(const wxBrush
& rBrush
);
122 virtual void SetBackgroundMode(int nMode
);
123 virtual void SetPalette(const wxPalette
& rPalette
);
125 virtual void DestroyClippingRegion();
127 virtual wxCoord
GetCharHeight() const;
128 virtual wxCoord
GetCharWidth() const;
130 virtual bool CanDrawBitmap() const;
131 virtual bool CanGetTextExtent() const;
132 virtual int GetDepth() const;
133 virtual wxSize
GetPPI() const;
135 virtual void SetMapMode(wxMappingMode nMode
);
136 virtual void SetUserScale( double dX
139 virtual void SetLogicalScale( double dX
142 virtual void SetLogicalOrigin( wxCoord vX
145 virtual void SetDeviceOrigin( wxCoord vX
148 virtual void SetAxisOrientation( bool bXLeftRight
151 virtual void SetLogicalFunction(wxRasterOperationMode nFunction
);
153 // implementation from now on
154 // --------------------------
156 virtual void SetRop(WXHDC hCdc
);
157 virtual void SelectOldObjects(WXHDC hDc
);
159 wxWindow
* GetWindow() const { return m_pCanvas
; }
160 void SetWindow(wxWindow
* pWin
) { m_pCanvas
= pWin
; }
162 WXHDC
GetHDC() const { return m_hDC
; }
163 void SetHDC( WXHDC hDc
164 ,bool bOwnsDC
= FALSE
171 HPS
GetHPS() const { return m_hPS
; }
176 const wxBitmap
& GetSelectedBitmap() const { return m_vSelectedBitmap
; }
177 wxBitmap
& GetSelectedBitmap() { return m_vSelectedBitmap
; }
179 void UpdateClipBox();
181 #if wxUSE_DC_CACHEING
182 static wxDCCacheEntry
* FindBitmapInCache( HPS hPS
186 static wxDCCacheEntry
* FindDCInCache( wxDCCacheEntry
* pNotThis
190 static void AddToBitmapCache(wxDCCacheEntry
* pEntry
);
191 static void AddToDCCache(wxDCCacheEntry
* pEntry
);
192 static void ClearCache();
205 #endif // wxUSE_PALETTE
211 m_bIsPaintTime
= false; // True at Paint Time
213 m_pen
.SetColour(*wxBLACK
);
214 m_brush
.SetColour(*wxWHITE
);
217 // create an uninitialized DC: this should be only used by the derived
219 wxPMDCImpl( wxDC
*owner
) : wxDCImpl( owner
) { Init(); }
222 virtual void DoGetTextExtent( const wxString
& rsString
225 ,wxCoord
* pDescent
= NULL
226 ,wxCoord
* pExternalLeading
= NULL
227 ,const wxFont
* pTheFont
= NULL
229 virtual bool DoFloodFill( wxCoord vX
231 ,const wxColour
& rCol
232 ,wxFloodFillStyle nStyle
= wxFLOOD_SURFACE
235 virtual bool DoGetPixel( wxCoord vX
240 virtual void DoDrawPoint( wxCoord vX
243 virtual void DoDrawLine( wxCoord vX1
249 virtual void DoDrawArc( wxCoord vX1
256 virtual void DoDrawCheckMark( wxCoord vX
261 virtual void DoDrawEllipticArc( wxCoord vX
269 virtual void DoDrawRectangle( wxCoord vX
274 virtual void DoDrawRoundedRectangle( wxCoord vX
280 virtual void DoDrawEllipse( wxCoord vX
286 virtual void DoCrossHair( wxCoord vX
290 virtual void DoDrawIcon( const wxIcon
& rIcon
294 virtual void DoDrawBitmap( const wxBitmap
& rBmp
297 ,bool bUseMask
= FALSE
300 virtual void DoDrawText( const wxString
& rsText
304 virtual void DoDrawRotatedText( const wxString
& rsText
310 virtual bool DoBlit( wxCoord vXdest
317 ,wxRasterOperationMode nRop
= wxCOPY
318 ,bool bUseMask
= FALSE
319 ,wxCoord vXsrcMask
= -1
320 ,wxCoord vYsrcMask
= -1
323 virtual void DoSetClippingRegion( wxCoord vX
328 virtual void DoSetDeviceClippingRegion(const wxRegion
& rRegion
);
330 virtual void DoGetSize( int* pWidth
333 virtual void DoGetSizeMM( int* pWidth
337 virtual void DoDrawLines( int n
338 ,const wxPoint vaPoints
[]
342 virtual void DoDrawPolygon( int n
343 ,const wxPoint vaPoints
[]
346 ,wxPolygonFillMode nFillStyle
= wxODDEVEN_RULE
350 void DoSelectPalette(bool bRealize
= FALSE
);
351 void InitializePalette();
352 #endif // wxUSE_PALETTE
356 // common part of DoDrawText() and DoDrawRotatedText()
358 void DrawAnyText( const wxString
& rsText
363 // OS2-specific member variables ?? do we even need this under OS/2?
368 // the window associated with this DC (may be NULL)
371 wxBitmap m_vSelectedBitmap
;
376 HPS m_hOldPS
; // old hPS, if any
377 bool m_bIsPaintTime
;// True at Paint Time
379 RECTL m_vRclPaint
; // Bounding rectangle at Paint time etc.
381 // TRUE => DeleteDC() in dtor, FALSE => only ReleaseDC() it
391 // Store all old GDI objects when do a SelectObject, so we can select them
392 // back in (this unselecting user's objects) so we can safely delete the
395 WXHBITMAP m_hOldBitmap
;
397 WXHBRUSH m_hOldBrush
;
399 WXHPALETTE m_hOldPalette
;
401 #if wxUSE_DC_CACHEING
402 static wxList m_svBitmapCache
;
403 static wxList m_svDCCache
;
405 }; // end of CLASS wxDC