1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Vaclav Slavik
7 // Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
15 #include "wx/region.h"
17 //-----------------------------------------------------------------------------
19 //-----------------------------------------------------------------------------
21 class WXDLLIMPEXP_FWD_CORE wxDC
;
23 //-----------------------------------------------------------------------------
25 //-----------------------------------------------------------------------------
29 #define MM_ISOTROPIC 1
30 #define MM_ANISOTROPIC 2
38 //-----------------------------------------------------------------------------
40 //-----------------------------------------------------------------------------
43 // MGL fwd declarations:
48 class WXDLLIMPEXP_CORE wxDC
: public wxDCBase
50 DECLARE_DYNAMIC_CLASS(wxDC
)
56 // implement base class pure virtuals
57 // ----------------------------------
61 virtual bool StartDoc(const wxString
& message
);
62 virtual void EndDoc();
64 virtual void StartPage();
65 virtual void EndPage();
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;
78 virtual void DoGetTextExtent(const wxString
& string
,
79 wxCoord
*x
, wxCoord
*y
,
80 wxCoord
*descent
= NULL
,
81 wxCoord
*externalLeading
= NULL
,
82 const wxFont
*theFont
= NULL
) const;
84 virtual bool CanDrawBitmap() const;
85 virtual bool CanGetTextExtent() const;
86 virtual int GetDepth() const;
87 virtual wxSize
GetPPI() const;
89 virtual void SetLogicalFunction(wxRasterOperationMode function
);
91 // implementation from now on
92 // --------------------------
94 virtual void ComputeScaleAndOrigin();
96 wxCoord
XDEV2LOG(wxCoord x
) const { return DeviceToLogicalX(x
); }
97 wxCoord
XDEV2LOGREL(wxCoord x
) const { return DeviceToLogicalXRel(x
); }
98 wxCoord
YDEV2LOG(wxCoord y
) const { return DeviceToLogicalY(y
); }
99 wxCoord
YDEV2LOGREL(wxCoord y
) const { return DeviceToLogicalYRel(y
); }
100 wxCoord
XLOG2DEV(wxCoord x
) const { return LogicalToDeviceX(x
); }
101 wxCoord
XLOG2DEVREL(wxCoord x
) const { return LogicalToDeviceXRel(x
); }
102 wxCoord
YLOG2DEV(wxCoord y
) const { return LogicalToDeviceY(y
); }
103 wxCoord
YLOG2DEVREL(wxCoord y
) const { return LogicalToDeviceYRel(y
); }
105 MGLDevCtx
*GetMGLDC() const { return m_MGLDC
; }
106 void SetMGLDC(MGLDevCtx
*mgldc
, bool OwnsMGLDC
= false);
109 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
110 wxFloodFillStyle style
= wxFLOOD_SURFACE
);
112 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const;
114 virtual void DoDrawPoint(wxCoord x
, wxCoord y
);
115 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
);
117 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
118 wxCoord x2
, wxCoord y2
,
119 wxCoord xc
, wxCoord yc
);
120 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
121 double sa
, double ea
);
123 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
124 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
125 wxCoord width
, wxCoord height
,
127 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
129 virtual void DoCrossHair(wxCoord x
, wxCoord y
);
131 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
);
132 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
133 bool useMask
= false);
135 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
136 virtual void DoDrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
,
139 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
140 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
141 wxRasterOperationMode rop
= wxCOPY
, bool useMask
= false,
142 wxCoord xsrcMask
= -1, wxCoord ysrcMask
= -1);
144 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
145 wxCoord width
, wxCoord height
);
146 virtual void DoSetDeviceClippingRegion(const wxRegion
& region
);
148 virtual void DoGetSize(int *width
, int *height
) const;
149 virtual void DoGetSizeMM(int* width
, int* height
) const;
151 virtual void DoDrawLines(int n
, wxPoint points
[],
152 wxCoord xoffset
, wxCoord yoffset
);
153 virtual void DoDrawPolygon(int n
, wxPoint points
[],
154 wxCoord xoffset
, wxCoord yoffset
,
155 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
);
157 // implementation from now on:
160 // setup newly attached MGLDevCtx for wxDC's use
161 // (does things like setting RGB blending mode for antialiased texts):
162 void InitializeMGLDC();
164 // common part of DoDrawText() and DoDrawRotatedText()
165 void DrawAnyText(const wxString
& text
, wxCoord x
, wxCoord y
);
167 // MGL uses pens as both wxPens and wxBrushes, so we have to
168 // switch them as needed:
171 void SelectMGLStipplePen(int style
);
172 void SelectMGLFatPen(int style
, int flag
);
174 // Select m_font into m_MGLDC:
175 bool SelectMGLFont();
177 // Convert wxWin logical function to MGL rop:
178 int LogicalFunctionToMGLRop(int logFunc
) const;
180 // Unified implementation of DrawIcon, DrawBitmap and Blit:
181 void DoDrawSubBitmap(const wxBitmap
&bmp
,
182 wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
183 wxCoord destx
, wxCoord desty
, int rop
, bool useMask
);
185 // MGL DC class we use:
189 // helper variables for SelectXXXX():
191 bool m_brushSelected
;
192 bool m_downloadedPatterns
[2];
194 // MGL does not render lines with width>1 with endings centered
195 // at given coords but with top left corner of the pen at them,
196 // these offsets are used to correct it. They are computed by
198 int m_penOfsX
, m_penOfsY
;
200 double m_mm_to_pix_x
, m_mm_to_pix_y
;
202 wxPalette m_oldPalette
;
204 wxRegion m_currentClippingRegion
;
205 wxRegion m_globalClippingRegion
;
207 // wxDC::Blit handles memoryDCs as special cases :(