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
);
32 wxGraphicsContext
* GetGraphicsContext();
33 void SetGraphicsContext( wxGraphicsContext
* ctx
);
35 DECLARE_DYNAMIC_CLASS(wxGCDC
)
36 DECLARE_NO_COPY_CLASS(wxGCDC
)
40 class WXDLLIMPEXP_CORE wxGCDCImpl
: public wxDCImpl
43 wxGCDCImpl( wxDC
*owner
, const wxWindowDC
& dc
);
44 wxGCDCImpl( wxDC
*owner
, const wxMemoryDC
& dc
);
45 wxGCDCImpl( wxDC
*owner
);
47 virtual ~wxGCDCImpl();
52 // implement base class pure virtuals
53 // ----------------------------------
57 virtual bool StartDoc( const wxString
& message
);
58 virtual void EndDoc();
60 virtual void StartPage();
61 virtual void EndPage();
63 // flushing the content of this dc immediately onto screen
66 virtual void SetFont(const wxFont
& font
);
67 virtual void SetPen(const wxPen
& pen
);
68 virtual void SetBrush(const wxBrush
& brush
);
69 virtual void SetBackground(const wxBrush
& brush
);
70 virtual void SetBackgroundMode(int mode
);
71 virtual void SetPalette(const wxPalette
& palette
);
73 virtual void DestroyClippingRegion();
75 virtual wxCoord
GetCharHeight() const;
76 virtual wxCoord
GetCharWidth() const;
78 virtual bool CanDrawBitmap() const;
79 virtual bool CanGetTextExtent() const;
80 virtual int GetDepth() const;
81 virtual wxSize
GetPPI() const;
83 virtual void SetMapMode(int mode
);
85 virtual void SetLogicalFunction(int function
);
87 virtual void SetTextForeground(const wxColour
& colour
);
88 virtual void SetTextBackground(const wxColour
& colour
);
90 virtual void ComputeScaleAndOrigin();
92 wxGraphicsContext
* GetGraphicsContext() { return m_graphicContext
; }
93 virtual void SetGraphicsContext( wxGraphicsContext
* ctx
);
95 // the true implementations
96 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
97 int style
= wxFLOOD_SURFACE
);
99 virtual void DoGradientFillLinear(const wxRect
& rect
,
100 const wxColour
& initialColour
,
101 const wxColour
& destColour
,
102 wxDirection nDirection
= wxEAST
);
104 virtual void DoGradientFillConcentric(const wxRect
& rect
,
105 const wxColour
& initialColour
,
106 const wxColour
& destColour
,
107 const wxPoint
& circleCenter
);
109 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const;
111 virtual void DoDrawPoint(wxCoord x
, wxCoord y
);
114 virtual void DoDrawSpline(const wxPointList
*points
);
117 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
);
119 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
120 wxCoord x2
, wxCoord y2
,
121 wxCoord xc
, wxCoord yc
);
123 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
124 wxCoord width
, wxCoord height
);
126 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
127 double sa
, double ea
);
129 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
130 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
131 wxCoord width
, wxCoord height
,
133 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
135 virtual void DoCrossHair(wxCoord x
, wxCoord y
);
137 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
);
138 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
139 bool useMask
= false);
141 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
142 virtual void DoDrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
,
145 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
146 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
147 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= -1, wxCoord ysrcMask
= -1);
149 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
150 wxCoord dstWidth
, wxCoord dstHeight
,
152 wxCoord xsrc
, wxCoord ysrc
,
153 wxCoord srcWidth
, wxCoord srcHeight
,
154 int rop
= wxCOPY
, bool useMask
= false,
155 wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
);
157 virtual void DoGetSize(int *,int *) const;
158 virtual void DoGetSizeMM(int* width
, int* height
) const;
160 virtual void DoDrawLines(int n
, wxPoint points
[],
161 wxCoord xoffset
, wxCoord yoffset
);
162 virtual void DoDrawPolygon(int n
, wxPoint points
[],
163 wxCoord xoffset
, wxCoord yoffset
,
164 int fillStyle
= wxODDEVEN_RULE
);
165 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
166 wxCoord xoffset
, wxCoord yoffset
,
169 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
);
170 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
171 wxCoord width
, wxCoord height
);
173 virtual void DoGetTextExtent(const wxString
& string
,
174 wxCoord
*x
, wxCoord
*y
,
175 wxCoord
*descent
= NULL
,
176 wxCoord
*externalLeading
= NULL
,
177 const wxFont
*theFont
= NULL
) const;
179 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
183 bool m_logicalFunctionSupported
;
184 double m_mm_to_pix_x
, m_mm_to_pix_y
;
185 wxGraphicsMatrix m_matrixOriginal
;
186 wxGraphicsMatrix m_matrixCurrent
;
188 double m_formerScaleX
, m_formerScaleY
;
190 wxGraphicsContext
* m_graphicContext
;
192 DECLARE_CLASS(wxGCDCImpl
)
193 DECLARE_NO_COPY_CLASS(wxGCDCImpl
)
196 #endif // wxUSE_GRAPHICS_CONTEXT
197 #endif // _WX_GRAPHICS_DC_H_