1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: graphics context device bridge header
4 // Author: Stefan Csomor
7 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_GRAPHICS_DC_H_
13 #define _WX_GRAPHICS_DC_H_
15 #if wxUSE_GRAPHICS_CONTEXT
18 #include "wx/geometry.h"
19 #include "wx/graphics.h"
21 class WXDLLIMPEXP_FWD_CORE wxWindowDC
;
24 class WXDLLIMPEXP_CORE wxGCDC
: public wxDC
27 wxGCDC( const wxWindowDC
& dc
);
28 wxGCDC( const wxMemoryDC
& dc
);
29 #if wxUSE_PRINTING_ARCHITECTURE
30 wxGCDC( const wxPrinterDC
& dc
);
35 wxGraphicsContext
* GetGraphicsContext();
36 void SetGraphicsContext( wxGraphicsContext
* ctx
);
39 // override wxDC virtual functions to provide access to HDC associated with
40 // this Graphics object (implemented in src/msw/graphics.cpp)
41 virtual WXHDC
AcquireHDC();
42 virtual void ReleaseHDC(WXHDC hdc
);
46 DECLARE_DYNAMIC_CLASS(wxGCDC
)
47 wxDECLARE_NO_COPY_CLASS(wxGCDC
);
51 class WXDLLIMPEXP_CORE wxGCDCImpl
: public wxDCImpl
54 wxGCDCImpl( wxDC
*owner
, const wxWindowDC
& dc
);
55 wxGCDCImpl( wxDC
*owner
, const wxMemoryDC
& dc
);
56 #if wxUSE_PRINTING_ARCHITECTURE
57 wxGCDCImpl( wxDC
*owner
, const wxPrinterDC
& dc
);
59 wxGCDCImpl( wxDC
*owner
);
61 virtual ~wxGCDCImpl();
66 // implement base class pure virtuals
67 // ----------------------------------
71 virtual bool StartDoc( const wxString
& message
);
72 virtual void EndDoc();
74 virtual void StartPage();
75 virtual void EndPage();
77 // flushing the content of this dc immediately onto screen
80 virtual void SetFont(const wxFont
& font
);
81 virtual void SetPen(const wxPen
& pen
);
82 virtual void SetBrush(const wxBrush
& brush
);
83 virtual void SetBackground(const wxBrush
& brush
);
84 virtual void SetBackgroundMode(int mode
);
85 virtual void SetPalette(const wxPalette
& palette
);
87 virtual void DestroyClippingRegion();
89 virtual wxCoord
GetCharHeight() const;
90 virtual wxCoord
GetCharWidth() const;
92 virtual bool CanDrawBitmap() const;
93 virtual bool CanGetTextExtent() const;
94 virtual int GetDepth() const;
95 virtual wxSize
GetPPI() const;
97 virtual void SetMapMode(wxMappingMode mode
);
99 virtual void SetLogicalFunction(wxRasterOperationMode function
);
101 virtual void SetTextForeground(const wxColour
& colour
);
102 virtual void SetTextBackground(const wxColour
& colour
);
104 virtual void ComputeScaleAndOrigin();
106 wxGraphicsContext
* GetGraphicsContext() { return m_graphicContext
; }
107 virtual void SetGraphicsContext( wxGraphicsContext
* ctx
);
109 // the true implementations
110 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
111 wxFloodFillStyle style
= wxFLOOD_SURFACE
);
113 virtual void DoGradientFillLinear(const wxRect
& rect
,
114 const wxColour
& initialColour
,
115 const wxColour
& destColour
,
116 wxDirection nDirection
= wxEAST
);
118 virtual void DoGradientFillConcentric(const wxRect
& rect
,
119 const wxColour
& initialColour
,
120 const wxColour
& destColour
,
121 const wxPoint
& circleCenter
);
123 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const;
125 virtual void DoDrawPoint(wxCoord x
, wxCoord y
);
128 virtual void DoDrawSpline(const wxPointList
*points
);
131 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
);
133 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
134 wxCoord x2
, wxCoord y2
,
135 wxCoord xc
, wxCoord yc
);
137 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
138 wxCoord width
, wxCoord height
);
140 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
141 double sa
, double ea
);
143 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
144 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
145 wxCoord width
, wxCoord height
,
147 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
149 virtual void DoCrossHair(wxCoord x
, wxCoord y
);
151 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
);
152 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
153 bool useMask
= false);
155 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
156 virtual void DoDrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
,
159 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
160 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
161 wxRasterOperationMode rop
= wxCOPY
, bool useMask
= false,
162 wxCoord xsrcMask
= -1, wxCoord ysrcMask
= -1);
164 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
165 wxCoord dstWidth
, wxCoord dstHeight
,
167 wxCoord xsrc
, wxCoord ysrc
,
168 wxCoord srcWidth
, wxCoord srcHeight
,
169 wxRasterOperationMode
= wxCOPY
, bool useMask
= false,
170 wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
);
172 virtual void DoGetSize(int *,int *) const;
173 virtual void DoGetSizeMM(int* width
, int* height
) const;
175 virtual void DoDrawLines(int n
, wxPoint points
[],
176 wxCoord xoffset
, wxCoord yoffset
);
177 virtual void DoDrawPolygon(int n
, wxPoint points
[],
178 wxCoord xoffset
, wxCoord yoffset
,
179 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
);
180 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
181 wxCoord xoffset
, wxCoord yoffset
,
182 wxPolygonFillMode fillStyle
);
184 virtual void DoSetDeviceClippingRegion(const wxRegion
& region
);
185 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
186 wxCoord width
, wxCoord height
);
188 virtual void DoGetTextExtent(const wxString
& string
,
189 wxCoord
*x
, wxCoord
*y
,
190 wxCoord
*descent
= NULL
,
191 wxCoord
*externalLeading
= NULL
,
192 const wxFont
*theFont
= NULL
) const;
194 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
198 bool m_logicalFunctionSupported
;
199 double m_mm_to_pix_x
, m_mm_to_pix_y
;
200 wxGraphicsMatrix m_matrixOriginal
;
201 wxGraphicsMatrix m_matrixCurrent
;
203 double m_formerScaleX
, m_formerScaleY
;
205 wxGraphicsContext
* m_graphicContext
;
207 DECLARE_CLASS(wxGCDCImpl
)
208 wxDECLARE_NO_COPY_CLASS(wxGCDCImpl
);
211 #endif // wxUSE_GRAPHICS_CONTEXT
212 #endif // _WX_GRAPHICS_DC_H_