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
17 #include "wx/geometry.h"
18 #include "wx/dynarray.h"
19 #include "wx/graphics.h"
21 class WXDLLIMPEXP_FWD_CORE wxWindowDC
;
24 class WXDLLEXPORT wxGCDC
: public wxDC
27 wxGCDC( const wxWindowDC
& dc
);
28 wxGCDC( const wxMemoryDC
& dc
);
31 wxGraphicsContext
* GetGraphicsContext();
32 void SetGraphicsContext( wxGraphicsContext
* ctx
);
35 DECLARE_DYNAMIC_CLASS(wxGCDC
)
36 DECLARE_NO_COPY_CLASS(wxGCDC
)
41 class WXDLLEXPORT wxGCDCImpl
: public wxDCImpl
44 wxGCDCImpl( wxDC
*owner
, const wxWindowDC
& dc
);
45 wxGCDCImpl( wxDC
*owner
, const wxMemoryDC
& dc
);
46 wxGCDCImpl( wxDC
*owner
);
48 virtual ~wxGCDCImpl();
53 // implement base class pure virtuals
54 // ----------------------------------
58 virtual bool StartDoc( const wxString
& message
);
59 virtual void EndDoc();
61 virtual void StartPage();
62 virtual void EndPage();
64 // flushing the content of this dc immediately onto screen
67 virtual void SetFont(const wxFont
& font
);
68 virtual void SetPen(const wxPen
& pen
);
69 virtual void SetBrush(const wxBrush
& brush
);
70 virtual void SetBackground(const wxBrush
& brush
);
71 virtual void SetBackgroundMode(int mode
);
72 virtual void SetPalette(const wxPalette
& palette
);
74 virtual void DestroyClippingRegion();
76 virtual wxCoord
GetCharHeight() const;
77 virtual wxCoord
GetCharWidth() const;
79 virtual bool CanDrawBitmap() const;
80 virtual bool CanGetTextExtent() const;
81 virtual int GetDepth() const;
82 virtual wxSize
GetPPI() const;
84 virtual void SetMapMode(int mode
);
86 virtual void SetLogicalFunction(int function
);
88 virtual void SetTextForeground(const wxColour
& colour
);
89 virtual void SetTextBackground(const wxColour
& colour
);
91 virtual void ComputeScaleAndOrigin();
93 wxGraphicsContext
* GetGraphicsContext() { return m_graphicContext
; }
94 virtual void SetGraphicsContext( wxGraphicsContext
* ctx
);
97 // the true implementations
98 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
99 int style
= wxFLOOD_SURFACE
);
101 virtual void DoGradientFillLinear(const wxRect
& rect
,
102 const wxColour
& initialColour
,
103 const wxColour
& destColour
,
104 wxDirection nDirection
= wxEAST
);
106 virtual void DoGradientFillConcentric(const wxRect
& rect
,
107 const wxColour
& initialColour
,
108 const wxColour
& destColour
,
109 const wxPoint
& circleCenter
);
111 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const;
113 virtual void DoDrawPoint(wxCoord x
, wxCoord y
);
116 virtual void DoDrawSpline(const wxPointList
*points
);
119 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
);
121 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
122 wxCoord x2
, wxCoord y2
,
123 wxCoord xc
, wxCoord yc
);
125 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
126 wxCoord width
, wxCoord height
);
128 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
129 double sa
, double ea
);
131 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
132 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
133 wxCoord width
, wxCoord height
,
135 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
137 virtual void DoCrossHair(wxCoord x
, wxCoord y
);
139 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
);
140 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
141 bool useMask
= false);
143 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
144 virtual void DoDrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
,
147 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
148 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
149 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= -1, wxCoord ysrcMask
= -1);
151 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
152 wxCoord dstWidth
, wxCoord dstHeight
,
154 wxCoord xsrc
, wxCoord ysrc
,
155 wxCoord srcWidth
, wxCoord srcHeight
,
156 int rop
= wxCOPY
, bool useMask
= false,
157 wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
);
159 virtual void DoGetSize(int *,int *) const;
160 virtual void DoGetSizeMM(int* width
, int* height
) const;
162 virtual void DoDrawLines(int n
, wxPoint points
[],
163 wxCoord xoffset
, wxCoord yoffset
);
164 virtual void DoDrawPolygon(int n
, wxPoint points
[],
165 wxCoord xoffset
, wxCoord yoffset
,
166 int fillStyle
= wxODDEVEN_RULE
);
167 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
168 wxCoord xoffset
, wxCoord yoffset
,
171 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
);
172 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
173 wxCoord width
, wxCoord height
);
175 virtual void DoGetTextExtent(const wxString
& string
,
176 wxCoord
*x
, wxCoord
*y
,
177 wxCoord
*descent
= NULL
,
178 wxCoord
*externalLeading
= NULL
,
179 const wxFont
*theFont
= NULL
) const;
181 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
185 bool m_logicalFunctionSupported
;
186 double m_mm_to_pix_x
, m_mm_to_pix_y
;
187 wxGraphicsMatrix m_matrixOriginal
;
188 wxGraphicsMatrix m_matrixCurrent
;
190 double m_formerScaleX
, m_formerScaleY
;
192 wxGraphicsContext
* m_graphicContext
;
195 DECLARE_CLASS(wxGCDCImpl
)
196 DECLARE_NO_COPY_CLASS(wxGCDCImpl
)
201 #endif // _WX_GRAPHICS_DC_H_