]> git.saurik.com Git - wxWidgets.git/blame - include/wx/dfb/dc.h
add Inflate(wxSize) overload
[wxWidgets.git] / include / wx / dfb / dc.h
CommitLineData
b3c86150
VS
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/dfb/dc.h
3// Purpose: wxDC class
4// Author: Vaclav Slavik
5// Created: 2006-08-07
6// RCS-ID: $Id$
7// Copyright: (c) 2006 REA Elektronik GmbH
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_DFB_DC_H_
12#define _WX_DFB_DC_H_
13
14#include "wx/defs.h"
15#include "wx/region.h"
52c8d32a 16#include "wx/dfb/dfbptr.h"
b3c86150
VS
17
18wxDFB_DECLARE_INTERFACE(IDirectFBSurface);
19
20//-----------------------------------------------------------------------------
21// wxDC
22//-----------------------------------------------------------------------------
23
24class WXDLLIMPEXP_CORE wxDC : public wxDCBase
25{
26public:
27 wxDC();
28
29 // Ctor.
52c8d32a 30 wxDC(const wxIDirectFBSurfacePtr& surface);
b3c86150
VS
31
32public:
33 // implement base class pure virtuals
34 // ----------------------------------
35
36 virtual void Clear();
37
38 virtual bool StartDoc(const wxString& message);
39 virtual void EndDoc();
40
41 virtual void StartPage();
42 virtual void EndPage();
43
44 virtual void SetFont(const wxFont& font);
45 virtual void SetPen(const wxPen& pen);
46 virtual void SetBrush(const wxBrush& brush);
47 virtual void SetBackground(const wxBrush& brush);
48 virtual void SetBackgroundMode(int mode);
49#if wxUSE_PALETTE
50 virtual void SetPalette(const wxPalette& palette);
51#endif
52
53 virtual void DestroyClippingRegion();
54
55 virtual wxCoord GetCharHeight() const;
56 virtual wxCoord GetCharWidth() const;
57 virtual void DoGetTextExtent(const wxString& string,
58 wxCoord *x, wxCoord *y,
59 wxCoord *descent = NULL,
60 wxCoord *externalLeading = NULL,
61 wxFont *theFont = NULL) const;
62
63 virtual bool CanDrawBitmap() const { return true; }
64 virtual bool CanGetTextExtent() const { return true; }
65 virtual int GetDepth() const;
66 virtual wxSize GetPPI() const;
67
68 virtual void SetMapMode(int mode);
69 virtual void SetUserScale(double x, double y);
70 virtual void SetLogicalScale(double x, double y);
71 virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
72 virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
73 virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
74 virtual void SetLogicalFunction(int function);
75
76 // implementation from now on
77 // --------------------------
78
79 virtual void ComputeScaleAndOrigin();
80
81 wxCoord XDEV2LOG(wxCoord x) const
82 {
83 wxCoord new_x = x - m_deviceOriginX;
84 if (new_x > 0)
85 return (wxCoord)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX;
86 else
87 return (wxCoord)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX;
88 }
89 wxCoord XDEV2LOGREL(wxCoord x) const
90 {
91 if (x > 0)
92 return (wxCoord)((double)(x) / m_scaleX + 0.5);
93 else
94 return (wxCoord)((double)(x) / m_scaleX - 0.5);
95 }
96 wxCoord YDEV2LOG(wxCoord y) const
97 {
98 wxCoord new_y = y - m_deviceOriginY;
99 if (new_y > 0)
100 return (wxCoord)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY;
101 else
102 return (wxCoord)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY;
103 }
104 wxCoord YDEV2LOGREL(wxCoord y) const
105 {
106 if (y > 0)
107 return (wxCoord)((double)(y) / m_scaleY + 0.5);
108 else
109 return (wxCoord)((double)(y) / m_scaleY - 0.5);
110 }
111 wxCoord XLOG2DEV(wxCoord x) const
112 {
113 wxCoord new_x = x - m_logicalOriginX;
114 if (new_x > 0)
115 return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX;
116 else
117 return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX;
118 }
119 wxCoord XLOG2DEVREL(wxCoord x) const
120 {
121 if (x > 0)
122 return (wxCoord)((double)(x) * m_scaleX + 0.5);
123 else
124 return (wxCoord)((double)(x) * m_scaleX - 0.5);
125 }
126 wxCoord YLOG2DEV(wxCoord y) const
127 {
128 wxCoord new_y = y - m_logicalOriginY;
129 if (new_y > 0)
130 return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY;
131 else
132 return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY;
133 }
134 wxCoord YLOG2DEVREL(wxCoord y) const
135 {
136 if (y > 0)
137 return (wxCoord)((double)(y) * m_scaleY + 0.5);
138 else
139 return (wxCoord)((double)(y) * m_scaleY - 0.5);
140 }
141
142 // Returns the surface (and increases its ref count)
52c8d32a 143 wxIDirectFBSurfacePtr GetDirectFBSurface() const { return m_surface; }
b3c86150
VS
144
145protected:
146 // initializes the DC from a surface, must be called if default ctor
147 // was used
52c8d32a 148 void Init(const wxIDirectFBSurfacePtr& surface);
b3c86150
VS
149
150 virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
151 int style = wxFLOOD_SURFACE);
152
153 virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const;
154
155 virtual void DoDrawPoint(wxCoord x, wxCoord y);
156 virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
157
158 virtual void DoDrawArc(wxCoord x1, wxCoord y1,
159 wxCoord x2, wxCoord y2,
160 wxCoord xc, wxCoord yc);
161 virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
162 double sa, double ea);
163
164 virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
165 virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
166 wxCoord width, wxCoord height,
167 double radius);
168 virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
169
170 virtual void DoCrossHair(wxCoord x, wxCoord y);
171
172 virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
173 virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
174 bool useMask = false);
175
176 virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y);
177 virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y,
178 double angle);
179
180 virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
181 wxDC *source, wxCoord xsrc, wxCoord ysrc,
182 int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1);
183
184 // this is gnarly - we can't even call this function DoSetClippingRegion()
185 // because of virtual function hiding
186 virtual void DoSetClippingRegionAsRegion(const wxRegion& region);
187 virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
188 wxCoord width, wxCoord height);
189
190 virtual void DoGetSize(int *width, int *height) const;
191 virtual void DoGetSizeMM(int* width, int* height) const;
192
193 virtual void DoDrawLines(int n, wxPoint points[],
194 wxCoord xoffset, wxCoord yoffset);
195 virtual void DoDrawPolygon(int n, wxPoint points[],
196 wxCoord xoffset, wxCoord yoffset,
197 int fillStyle = wxODDEVEN_RULE);
198
199 // implementation from now on:
200
201private:
202 // Unified implementation of DrawIcon, DrawBitmap and Blit:
203 void DoDrawSubBitmap(const wxBitmap &bmp,
204 wxCoord x, wxCoord y, wxCoord w, wxCoord h,
205 wxCoord destx, wxCoord desty, int rop, bool useMask);
5942996c
VS
206 bool DoBlitFromSurface(const wxIDirectFBSurfacePtr& src,
207 wxCoord srcx, wxCoord srcy,
208 wxCoord w, wxCoord h,
209 wxCoord dstx, wxCoord dsty);
b3c86150
VS
210
211 // selects colour into surface's state
212 void SelectColour(const wxColour& clr);
213
214protected:
52c8d32a 215 wxIDirectFBSurfacePtr m_surface;
b3c86150
VS
216
217 double m_mm_to_pix_x, m_mm_to_pix_y;
218
219 DECLARE_DYNAMIC_CLASS(wxDC)
220};
221
222#endif // _WX_DFB_DC_H_