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
);
38 DECLARE_DYNAMIC_CLASS(wxGCDC
)
39 wxDECLARE_NO_COPY_CLASS(wxGCDC
);
43 class WXDLLIMPEXP_CORE wxGCDCImpl
: public wxDCImpl
46 wxGCDCImpl( wxDC
*owner
, const wxWindowDC
& dc
);
47 wxGCDCImpl( wxDC
*owner
, const wxMemoryDC
& dc
);
48 #if wxUSE_PRINTING_ARCHITECTURE
49 wxGCDCImpl( wxDC
*owner
, const wxPrinterDC
& dc
);
51 wxGCDCImpl( wxDC
*owner
);
53 virtual ~wxGCDCImpl();
58 // implement base class pure virtuals
59 // ----------------------------------
63 virtual bool StartDoc( const wxString
& message
);
64 virtual void EndDoc();
66 virtual void StartPage();
67 virtual void EndPage();
69 // flushing the content of this dc immediately onto screen
72 virtual void SetFont(const wxFont
& font
);
73 virtual void SetPen(const wxPen
& pen
);
74 virtual void SetBrush(const wxBrush
& brush
);
75 virtual void SetBackground(const wxBrush
& brush
);
76 virtual void SetBackgroundMode(int mode
);
77 virtual void SetPalette(const wxPalette
& palette
);
79 virtual void DestroyClippingRegion();
81 virtual wxCoord
GetCharHeight() const;
82 virtual wxCoord
GetCharWidth() const;
84 virtual bool CanDrawBitmap() const;
85 virtual bool CanGetTextExtent() const;
86 virtual int GetDepth() const;
87 virtual wxSize
GetPPI() const;
89 virtual void SetMapMode(wxMappingMode mode
);
91 virtual void SetLogicalFunction(wxRasterOperationMode function
);
93 virtual void SetTextForeground(const wxColour
& colour
);
94 virtual void SetTextBackground(const wxColour
& colour
);
96 virtual void ComputeScaleAndOrigin();
98 wxGraphicsContext
* GetGraphicsContext() { return m_graphicContext
; }
99 virtual void SetGraphicsContext( wxGraphicsContext
* ctx
);
101 // the true implementations
102 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
103 wxFloodFillStyle style
= wxFLOOD_SURFACE
);
105 virtual void DoGradientFillLinear(const wxRect
& rect
,
106 const wxColour
& initialColour
,
107 const wxColour
& destColour
,
108 wxDirection nDirection
= wxEAST
);
110 virtual void DoGradientFillConcentric(const wxRect
& rect
,
111 const wxColour
& initialColour
,
112 const wxColour
& destColour
,
113 const wxPoint
& circleCenter
);
115 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const;
117 virtual void DoDrawPoint(wxCoord x
, wxCoord y
);
120 virtual void DoDrawSpline(const wxPointList
*points
);
123 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
);
125 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
126 wxCoord x2
, wxCoord y2
,
127 wxCoord xc
, wxCoord yc
);
129 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
130 wxCoord width
, wxCoord height
);
132 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
133 double sa
, double ea
);
135 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
136 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
137 wxCoord width
, wxCoord height
,
139 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
141 virtual void DoCrossHair(wxCoord x
, wxCoord y
);
143 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
);
144 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
145 bool useMask
= false);
147 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
148 virtual void DoDrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
,
151 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
152 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
153 wxRasterOperationMode rop
= wxCOPY
, bool useMask
= false,
154 wxCoord xsrcMask
= -1, wxCoord ysrcMask
= -1);
156 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
157 wxCoord dstWidth
, wxCoord dstHeight
,
159 wxCoord xsrc
, wxCoord ysrc
,
160 wxCoord srcWidth
, wxCoord srcHeight
,
161 wxRasterOperationMode
= wxCOPY
, bool useMask
= false,
162 wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
);
164 virtual void DoGetSize(int *,int *) const;
165 virtual void DoGetSizeMM(int* width
, int* height
) const;
167 virtual void DoDrawLines(int n
, wxPoint points
[],
168 wxCoord xoffset
, wxCoord yoffset
);
169 virtual void DoDrawPolygon(int n
, wxPoint points
[],
170 wxCoord xoffset
, wxCoord yoffset
,
171 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
);
172 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
173 wxCoord xoffset
, wxCoord yoffset
,
174 wxPolygonFillMode fillStyle
);
176 virtual void DoSetDeviceClippingRegion(const wxRegion
& region
);
177 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
178 wxCoord width
, wxCoord height
);
180 virtual void DoGetTextExtent(const wxString
& string
,
181 wxCoord
*x
, wxCoord
*y
,
182 wxCoord
*descent
= NULL
,
183 wxCoord
*externalLeading
= NULL
,
184 const wxFont
*theFont
= NULL
) const;
186 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
190 bool m_logicalFunctionSupported
;
191 double m_mm_to_pix_x
, m_mm_to_pix_y
;
192 wxGraphicsMatrix m_matrixOriginal
;
193 wxGraphicsMatrix m_matrixCurrent
;
195 double m_formerScaleX
, m_formerScaleY
;
197 wxGraphicsContext
* m_graphicContext
;
199 DECLARE_CLASS(wxGCDCImpl
)
200 wxDECLARE_NO_COPY_CLASS(wxGCDCImpl
);
203 #endif // wxUSE_GRAPHICS_CONTEXT
204 #endif // _WX_GRAPHICS_DC_H_