/[pcsx2_0.9.7]/trunk/3rdparty/wxWidgets/include/wx/dc.h
ViewVC logotype

Annotation of /trunk/3rdparty/wxWidgets/include/wx/dc.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 31 - (hide annotations) (download)
Tue Sep 7 03:24:11 2010 UTC (9 years, 10 months ago) by william
File MIME type: text/plain
File size: 35087 byte(s)
committing r3113 initial commit again...
1 william 31 /////////////////////////////////////////////////////////////////////////////
2     // Name: wx/dc.h
3     // Purpose: wxDC class
4     // Author: Vadim Zeitlin
5     // Modified by:
6     // Created: 05/25/99
7     // RCS-ID: $Id: dc.h 55927 2008-09-28 09:12:16Z VS $
8     // Copyright: (c) wxWidgets team
9     // Licence: wxWindows licence
10     /////////////////////////////////////////////////////////////////////////////
11    
12     #ifndef _WX_DC_H_BASE_
13     #define _WX_DC_H_BASE_
14    
15     // ----------------------------------------------------------------------------
16     // headers which we must include here
17     // ----------------------------------------------------------------------------
18    
19     #include "wx/object.h" // the base class
20    
21     #include "wx/intl.h" // for wxLayoutDirection
22     #include "wx/cursor.h" // we have member variables of these classes
23     #include "wx/font.h" // so we can't do without them
24     #include "wx/colour.h"
25     #include "wx/bitmap.h" // for wxNullBitmap
26     #include "wx/brush.h"
27     #include "wx/pen.h"
28     #include "wx/palette.h"
29     #include "wx/list.h" // we use wxList in inline functions
30     #include "wx/dynarray.h"
31     #include "wx/math.h"
32    
33     class WXDLLIMPEXP_FWD_CORE wxDC;
34     class WXDLLIMPEXP_FWD_CORE wxDCBase;
35    
36     class WXDLLEXPORT wxDrawObject
37     {
38     public:
39    
40     wxDrawObject()
41     : m_isBBoxValid(false)
42     , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
43     { }
44    
45     virtual ~wxDrawObject() { }
46    
47     virtual void Draw(wxDCBase&) const { }
48    
49     virtual void CalcBoundingBox(wxCoord x, wxCoord y)
50     {
51     if ( m_isBBoxValid )
52     {
53     if ( x < m_minX ) m_minX = x;
54     if ( y < m_minY ) m_minY = y;
55     if ( x > m_maxX ) m_maxX = x;
56     if ( y > m_maxY ) m_maxY = y;
57     }
58     else
59     {
60     m_isBBoxValid = true;
61    
62     m_minX = x;
63     m_minY = y;
64     m_maxX = x;
65     m_maxY = y;
66     }
67     }
68    
69     void ResetBoundingBox()
70     {
71     m_isBBoxValid = false;
72    
73     m_minX = m_maxX = m_minY = m_maxY = 0;
74     }
75    
76     // Get the final bounding box of the PostScript or Metafile picture.
77    
78     wxCoord MinX() const { return m_minX; }
79     wxCoord MaxX() const { return m_maxX; }
80     wxCoord MinY() const { return m_minY; }
81     wxCoord MaxY() const { return m_maxY; }
82    
83     //to define the type of object for derived objects
84     virtual int GetType()=0;
85    
86     protected:
87     //for boundingbox calculation
88     bool m_isBBoxValid:1;
89     //for boundingbox calculation
90     wxCoord m_minX, m_minY, m_maxX, m_maxY;
91     };
92    
93     // ---------------------------------------------------------------------------
94     // global variables
95     // ---------------------------------------------------------------------------
96    
97     // ---------------------------------------------------------------------------
98     // wxDC is the device context - object on which any drawing is done
99     // ---------------------------------------------------------------------------
100    
101     class WXDLLEXPORT wxDCBase : public wxObject
102     {
103     public:
104     wxDCBase()
105     : m_colour(wxColourDisplay())
106     , m_ok(true)
107     , m_clipping(false)
108     , m_isInteractive(0)
109     , m_isBBoxValid(false)
110     , m_logicalOriginX(0), m_logicalOriginY(0)
111     , m_deviceOriginX(0), m_deviceOriginY(0)
112     , m_logicalScaleX(1.0), m_logicalScaleY(1.0)
113     , m_userScaleX(1.0), m_userScaleY(1.0)
114     , m_scaleX(1.0), m_scaleY(1.0)
115     , m_signX(1), m_signY(1)
116     , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
117     , m_clipX1(0), m_clipY1(0), m_clipX2(0), m_clipY2(0)
118     , m_logicalFunction(wxCOPY)
119     , m_backgroundMode(wxTRANSPARENT)
120     , m_mappingMode(wxMM_TEXT)
121     , m_pen()
122     , m_brush()
123     , m_backgroundBrush(*wxTRANSPARENT_BRUSH)
124     , m_textForegroundColour(*wxBLACK)
125     , m_textBackgroundColour(*wxWHITE)
126     , m_font()
127     #if wxUSE_PALETTE
128     , m_palette()
129     , m_hasCustomPalette(false)
130     #endif // wxUSE_PALETTE
131     {
132     ResetBoundingBox();
133     ResetClipping();
134     }
135    
136     virtual ~wxDCBase() { }
137    
138     // graphic primitives
139     // ------------------
140    
141     virtual void DrawObject(wxDrawObject* drawobject)
142     {
143     drawobject->Draw(*this);
144     CalcBoundingBox(drawobject->MinX(),drawobject->MinY());
145     CalcBoundingBox(drawobject->MaxX(),drawobject->MaxY());
146     }
147    
148     bool FloodFill(wxCoord x, wxCoord y, const wxColour& col,
149     int style = wxFLOOD_SURFACE)
150     { return DoFloodFill(x, y, col, style); }
151     bool FloodFill(const wxPoint& pt, const wxColour& col,
152     int style = wxFLOOD_SURFACE)
153     { return DoFloodFill(pt.x, pt.y, col, style); }
154    
155     // fill the area specified by rect with a radial gradient, starting from
156     // initialColour in the centre of the cercle and fading to destColour.
157     void GradientFillConcentric(const wxRect& rect,
158     const wxColour& initialColour,
159     const wxColour& destColour)
160     { GradientFillConcentric(rect, initialColour, destColour,
161     wxPoint(rect.GetWidth() / 2,
162     rect.GetHeight() / 2)); }
163    
164     void GradientFillConcentric(const wxRect& rect,
165     const wxColour& initialColour,
166     const wxColour& destColour,
167     const wxPoint& circleCenter)
168     { DoGradientFillConcentric(rect, initialColour, destColour, circleCenter); }
169    
170     // fill the area specified by rect with a linear gradient
171     void GradientFillLinear(const wxRect& rect,
172     const wxColour& initialColour,
173     const wxColour& destColour,
174     wxDirection nDirection = wxEAST)
175     { DoGradientFillLinear(rect, initialColour, destColour, nDirection); }
176    
177     bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const
178     { return DoGetPixel(x, y, col); }
179     bool GetPixel(const wxPoint& pt, wxColour *col) const
180     { return DoGetPixel(pt.x, pt.y, col); }
181    
182     void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
183     { DoDrawLine(x1, y1, x2, y2); }
184     void DrawLine(const wxPoint& pt1, const wxPoint& pt2)
185     { DoDrawLine(pt1.x, pt1.y, pt2.x, pt2.y); }
186    
187     void CrossHair(wxCoord x, wxCoord y)
188     { DoCrossHair(x, y); }
189     void CrossHair(const wxPoint& pt)
190     { DoCrossHair(pt.x, pt.y); }
191    
192     void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2,
193     wxCoord xc, wxCoord yc)
194     { DoDrawArc(x1, y1, x2, y2, xc, yc); }
195     void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre)
196     { DoDrawArc(pt1.x, pt1.y, pt2.x, pt2.y, centre.x, centre.y); }
197    
198     void DrawCheckMark(wxCoord x, wxCoord y,
199     wxCoord width, wxCoord height)
200     { DoDrawCheckMark(x, y, width, height); }
201     void DrawCheckMark(const wxRect& rect)
202     { DoDrawCheckMark(rect.x, rect.y, rect.width, rect.height); }
203    
204     void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
205     double sa, double ea)
206     { DoDrawEllipticArc(x, y, w, h, sa, ea); }
207     void DrawEllipticArc(const wxPoint& pt, const wxSize& sz,
208     double sa, double ea)
209     { DoDrawEllipticArc(pt.x, pt.y, sz.x, sz.y, sa, ea); }
210    
211     void DrawPoint(wxCoord x, wxCoord y)
212     { DoDrawPoint(x, y); }
213     void DrawPoint(const wxPoint& pt)
214     { DoDrawPoint(pt.x, pt.y); }
215    
216     void DrawLines(int n, wxPoint points[],
217     wxCoord xoffset = 0, wxCoord yoffset = 0)
218     { DoDrawLines(n, points, xoffset, yoffset); }
219     void DrawLines(const wxList *list,
220     wxCoord xoffset = 0, wxCoord yoffset = 0);
221    
222     void DrawPolygon(int n, wxPoint points[],
223     wxCoord xoffset = 0, wxCoord yoffset = 0,
224     int fillStyle = wxODDEVEN_RULE)
225     { DoDrawPolygon(n, points, xoffset, yoffset, fillStyle); }
226    
227     void DrawPolygon(const wxList *list,
228     wxCoord xoffset = 0, wxCoord yoffset = 0,
229     int fillStyle = wxODDEVEN_RULE);
230    
231     void DrawPolyPolygon(int n, int count[], wxPoint points[],
232     wxCoord xoffset = 0, wxCoord yoffset = 0,
233     int fillStyle = wxODDEVEN_RULE)
234     { DoDrawPolyPolygon(n, count, points, xoffset, yoffset, fillStyle); }
235    
236     void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
237     { DoDrawRectangle(x, y, width, height); }
238     void DrawRectangle(const wxPoint& pt, const wxSize& sz)
239     { DoDrawRectangle(pt.x, pt.y, sz.x, sz.y); }
240     void DrawRectangle(const wxRect& rect)
241     { DoDrawRectangle(rect.x, rect.y, rect.width, rect.height); }
242    
243     void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height,
244     double radius)
245     { DoDrawRoundedRectangle(x, y, width, height, radius); }
246     void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz,
247     double radius)
248     { DoDrawRoundedRectangle(pt.x, pt.y, sz.x, sz.y, radius); }
249     void DrawRoundedRectangle(const wxRect& r, double radius)
250     { DoDrawRoundedRectangle(r.x, r.y, r.width, r.height, radius); }
251    
252     void DrawCircle(wxCoord x, wxCoord y, wxCoord radius)
253     { DoDrawEllipse(x - radius, y - radius, 2*radius, 2*radius); }
254     void DrawCircle(const wxPoint& pt, wxCoord radius)
255     { DrawCircle(pt.x, pt.y, radius); }
256    
257     void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
258     { DoDrawEllipse(x, y, width, height); }
259     void DrawEllipse(const wxPoint& pt, const wxSize& sz)
260     { DoDrawEllipse(pt.x, pt.y, sz.x, sz.y); }
261     void DrawEllipse(const wxRect& rect)
262     { DoDrawEllipse(rect.x, rect.y, rect.width, rect.height); }
263    
264     void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
265     { DoDrawIcon(icon, x, y); }
266     void DrawIcon(const wxIcon& icon, const wxPoint& pt)
267     { DoDrawIcon(icon, pt.x, pt.y); }
268    
269     void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
270     bool useMask = false)
271     { DoDrawBitmap(bmp, x, y, useMask); }
272     void DrawBitmap(const wxBitmap &bmp, const wxPoint& pt,
273     bool useMask = false)
274     { DoDrawBitmap(bmp, pt.x, pt.y, useMask); }
275    
276     void DrawText(const wxString& text, wxCoord x, wxCoord y)
277     { DoDrawText(text, x, y); }
278     void DrawText(const wxString& text, const wxPoint& pt)
279     { DoDrawText(text, pt.x, pt.y); }
280    
281     void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle)
282     { DoDrawRotatedText(text, x, y, angle); }
283     void DrawRotatedText(const wxString& text, const wxPoint& pt, double angle)
284     { DoDrawRotatedText(text, pt.x, pt.y, angle); }
285    
286     // this version puts both optional bitmap and the text into the given
287     // rectangle and aligns is as specified by alignment parameter; it also
288     // will emphasize the character with the given index if it is != -1 and
289     // return the bounding rectangle if required
290     virtual void DrawLabel(const wxString& text,
291     const wxBitmap& image,
292     const wxRect& rect,
293     int alignment = wxALIGN_LEFT | wxALIGN_TOP,
294     int indexAccel = -1,
295     wxRect *rectBounding = NULL);
296    
297     void DrawLabel(const wxString& text, const wxRect& rect,
298     int alignment = wxALIGN_LEFT | wxALIGN_TOP,
299     int indexAccel = -1)
300     { DrawLabel(text, wxNullBitmap, rect, alignment, indexAccel); }
301    
302     bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
303     wxDC *source, wxCoord xsrc, wxCoord ysrc,
304     int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord)
305     {
306     return DoBlit(xdest, ydest, width, height,
307     source, xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask);
308     }
309     bool Blit(const wxPoint& destPt, const wxSize& sz,
310     wxDC *source, const wxPoint& srcPt,
311     int rop = wxCOPY, bool useMask = false, const wxPoint& srcPtMask = wxDefaultPosition)
312     {
313     return DoBlit(destPt.x, destPt.y, sz.x, sz.y,
314     source, srcPt.x, srcPt.y, rop, useMask, srcPtMask.x, srcPtMask.y);
315     }
316    
317     wxBitmap GetAsBitmap(const wxRect *subrect = (const wxRect *) NULL) const
318     {
319     return DoGetAsBitmap(subrect);
320     }
321    
322     #if wxUSE_SPLINES
323     // TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?)
324     void DrawSpline(wxCoord x1, wxCoord y1,
325     wxCoord x2, wxCoord y2,
326     wxCoord x3, wxCoord y3);
327     void DrawSpline(int n, wxPoint points[]);
328    
329     void DrawSpline(wxList *points) { DoDrawSpline(points); }
330     #endif // wxUSE_SPLINES
331    
332     // Eventually we will have wxUSE_GENERIC_DRAWELLIPSE
333     #ifdef __WXWINCE__
334     //! Generic method to draw ellipses, circles and arcs with current pen and brush.
335     /*! \param x Upper left corner of bounding box.
336     * \param y Upper left corner of bounding box.
337     * \param w Width of bounding box.
338     * \param h Height of bounding box.
339     * \param sa Starting angle of arc
340     * (counterclockwise, start at 3 o'clock, 360 is full circle).
341     * \param ea Ending angle of arc.
342     * \param angle Rotation angle, the Arc will be rotated after
343     * calculating begin and end.
344     */
345     void DrawEllipticArcRot( wxCoord x, wxCoord y,
346     wxCoord width, wxCoord height,
347     double sa = 0, double ea = 0, double angle = 0 )
348     { DoDrawEllipticArcRot( x, y, width, height, sa, ea, angle ); }
349    
350     void DrawEllipticArcRot( const wxPoint& pt,
351     const wxSize& sz,
352     double sa = 0, double ea = 0, double angle = 0 )
353     { DoDrawEllipticArcRot( pt.x, pt.y, sz.x, sz.y, sa, ea, angle ); }
354    
355     void DrawEllipticArcRot( const wxRect& rect,
356     double sa = 0, double ea = 0, double angle = 0 )
357     { DoDrawEllipticArcRot( rect.x, rect.y, rect.width, rect.height, sa, ea, angle ); }
358    
359     virtual void DoDrawEllipticArcRot( wxCoord x, wxCoord y,
360     wxCoord w, wxCoord h,
361     double sa = 0, double ea = 0, double angle = 0 );
362    
363     //! Rotates points around center.
364     /*! This is a quite straight method, it calculates in pixels
365     * and so it produces rounding errors.
366     * \param points The points inside will be rotated.
367     * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle).
368     * \param center Center of rotation.
369     */
370     void Rotate( wxList* points, double angle, wxPoint center = wxPoint(0,0) );
371    
372     // used by DrawEllipticArcRot
373     // Careful: wxList gets filled with points you have to delete later.
374     void CalculateEllipticPoints( wxList* points,
375     wxCoord xStart, wxCoord yStart,
376     wxCoord w, wxCoord h,
377     double sa, double ea );
378     #endif
379    
380     // global DC operations
381     // --------------------
382    
383     virtual void Clear() = 0;
384    
385     virtual bool StartDoc(const wxString& WXUNUSED(message)) { return true; }
386     virtual void EndDoc() { }
387    
388     virtual void StartPage() { }
389     virtual void EndPage() { }
390    
391     #if WXWIN_COMPATIBILITY_2_6
392     wxDEPRECATED( void BeginDrawing() );
393     wxDEPRECATED( void EndDrawing() );
394     #endif // WXWIN_COMPATIBILITY_2_6
395    
396    
397     // set objects to use for drawing
398     // ------------------------------
399    
400     virtual void SetFont(const wxFont& font) = 0;
401     virtual void SetPen(const wxPen& pen) = 0;
402     virtual void SetBrush(const wxBrush& brush) = 0;
403     virtual void SetBackground(const wxBrush& brush) = 0;
404     virtual void SetBackgroundMode(int mode) = 0;
405     #if wxUSE_PALETTE
406     virtual void SetPalette(const wxPalette& palette) = 0;
407     #endif // wxUSE_PALETTE
408    
409     // clipping region
410     // ---------------
411    
412     void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
413     { DoSetClippingRegion(x, y, width, height); }
414     void SetClippingRegion(const wxPoint& pt, const wxSize& sz)
415     { DoSetClippingRegion(pt.x, pt.y, sz.x, sz.y); }
416     void SetClippingRegion(const wxRect& rect)
417     { DoSetClippingRegion(rect.x, rect.y, rect.width, rect.height); }
418     void SetClippingRegion(const wxRegion& region)
419     { DoSetClippingRegionAsRegion(region); }
420    
421     virtual void DestroyClippingRegion() { ResetClipping(); }
422    
423     void GetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const
424     { DoGetClippingBox(x, y, w, h); }
425     void GetClippingBox(wxRect& rect) const
426     {
427     DoGetClippingBox(&rect.x, &rect.y, &rect.width, &rect.height);
428     }
429    
430     // text extent
431     // -----------
432    
433     virtual wxCoord GetCharHeight() const = 0;
434     virtual wxCoord GetCharWidth() const = 0;
435    
436     // only works for single line strings
437     void GetTextExtent(const wxString& string,
438     wxCoord *x, wxCoord *y,
439     wxCoord *descent = NULL,
440     wxCoord *externalLeading = NULL,
441     wxFont *theFont = NULL) const
442     { DoGetTextExtent(string, x, y, descent, externalLeading, theFont); }
443    
444     wxSize GetTextExtent(const wxString& string) const
445     {
446     wxCoord w, h;
447     DoGetTextExtent(string, &w, &h);
448     return wxSize(w, h);
449     }
450    
451     // works for single as well as multi-line strings
452     virtual void GetMultiLineTextExtent(const wxString& string,
453     wxCoord *width,
454     wxCoord *height,
455     wxCoord *heightLine = NULL,
456     wxFont *font = NULL) const;
457    
458     wxSize GetMultiLineTextExtent(const wxString& string) const
459     {
460     wxCoord w, h;
461     GetMultiLineTextExtent(string, &w, &h);
462     return wxSize(w, h);
463     }
464    
465     // Measure cumulative width of text after each character
466     bool GetPartialTextExtents(const wxString& text, wxArrayInt& widths) const
467     { return DoGetPartialTextExtents(text, widths); }
468    
469     // size and resolution
470     // -------------------
471    
472     // in device units
473     void GetSize(int *width, int *height) const
474     { DoGetSize(width, height); }
475     wxSize GetSize() const
476     {
477     int w, h;
478     DoGetSize(&w, &h);
479    
480     return wxSize(w, h);
481     }
482    
483     // in mm
484     void GetSizeMM(int* width, int* height) const
485     { DoGetSizeMM(width, height); }
486     wxSize GetSizeMM() const
487     {
488     int w, h;
489     DoGetSizeMM(&w, &h);
490    
491     return wxSize(w, h);
492     }
493    
494     // coordinates conversions
495     // -----------------------
496    
497     // This group of functions does actual conversion of the input, as you'd
498     // expect.
499     wxCoord DeviceToLogicalX(wxCoord x) const;
500     wxCoord DeviceToLogicalY(wxCoord y) const;
501     wxCoord DeviceToLogicalXRel(wxCoord x) const;
502     wxCoord DeviceToLogicalYRel(wxCoord y) const;
503     wxCoord LogicalToDeviceX(wxCoord x) const;
504     wxCoord LogicalToDeviceY(wxCoord y) const;
505     wxCoord LogicalToDeviceXRel(wxCoord x) const;
506     wxCoord LogicalToDeviceYRel(wxCoord y) const;
507    
508     // query DC capabilities
509     // ---------------------
510    
511     virtual bool CanDrawBitmap() const = 0;
512     virtual bool CanGetTextExtent() const = 0;
513    
514     // colour depth
515     virtual int GetDepth() const = 0;
516    
517     // Resolution in Pixels per inch
518     virtual wxSize GetPPI() const = 0;
519    
520     virtual bool Ok() const { return IsOk(); }
521     virtual bool IsOk() const { return m_ok; }
522    
523     // accessors and setters
524     // ---------------------
525    
526     virtual int GetBackgroundMode() const { return m_backgroundMode; }
527     virtual const wxBrush& GetBackground() const { return m_backgroundBrush; }
528     virtual const wxBrush& GetBrush() const { return m_brush; }
529     virtual const wxFont& GetFont() const { return m_font; }
530     virtual const wxPen& GetPen() const { return m_pen; }
531    
532     virtual const wxColour& GetTextForeground() const { return m_textForegroundColour; }
533     virtual const wxColour& GetTextBackground() const { return m_textBackgroundColour; }
534     virtual void SetTextForeground(const wxColour& colour)
535     { m_textForegroundColour = colour; }
536     virtual void SetTextBackground(const wxColour& colour)
537     { m_textBackgroundColour = colour; }
538    
539     virtual int GetMapMode() const { return m_mappingMode; }
540     virtual void SetMapMode(int mode) = 0;
541    
542     virtual void GetUserScale(double *x, double *y) const
543     {
544     if ( x ) *x = m_userScaleX;
545     if ( y ) *y = m_userScaleY;
546     }
547     virtual void SetUserScale(double x, double y) = 0;
548    
549     virtual void GetLogicalScale(double *x, double *y)
550     {
551     if ( x ) *x = m_logicalScaleX;
552     if ( y ) *y = m_logicalScaleY;
553     }
554     virtual void SetLogicalScale(double x, double y)
555     {
556     m_logicalScaleX = x;
557     m_logicalScaleY = y;
558     }
559    
560     void GetLogicalOrigin(wxCoord *x, wxCoord *y) const
561     { DoGetLogicalOrigin(x, y); }
562     wxPoint GetLogicalOrigin() const
563     { wxCoord x, y; DoGetLogicalOrigin(&x, &y); return wxPoint(x, y); }
564     virtual void SetLogicalOrigin(wxCoord x, wxCoord y) = 0;
565    
566     void GetDeviceOrigin(wxCoord *x, wxCoord *y) const
567     { DoGetDeviceOrigin(x, y); }
568     wxPoint GetDeviceOrigin() const
569     { wxCoord x, y; DoGetDeviceOrigin(&x, &y); return wxPoint(x, y); }
570     virtual void SetDeviceOrigin(wxCoord x, wxCoord y) = 0;
571    
572     virtual void ComputeScaleAndOrigin() {}
573    
574     virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp) = 0;
575    
576     virtual int GetLogicalFunction() const { return m_logicalFunction; }
577     virtual void SetLogicalFunction(int function) = 0;
578    
579     #if WXWIN_COMPATIBILITY_2_4
580     virtual void SetOptimization(bool WXUNUSED(opt)) { }
581     virtual bool GetOptimization() { return false; }
582     #endif
583    
584     // bounding box
585     // ------------
586    
587     virtual void CalcBoundingBox(wxCoord x, wxCoord y)
588     {
589     if ( m_isBBoxValid )
590     {
591     if ( x < m_minX ) m_minX = x;
592     if ( y < m_minY ) m_minY = y;
593     if ( x > m_maxX ) m_maxX = x;
594     if ( y > m_maxY ) m_maxY = y;
595     }
596     else
597     {
598     m_isBBoxValid = true;
599    
600     m_minX = x;
601     m_minY = y;
602     m_maxX = x;
603     m_maxY = y;
604     }
605     }
606    
607     void ResetBoundingBox()
608     {
609     m_isBBoxValid = false;
610    
611     m_minX = m_maxX = m_minY = m_maxY = 0;
612     }
613    
614     // Get the final bounding box of the PostScript or Metafile picture.
615     wxCoord MinX() const { return m_minX; }
616     wxCoord MaxX() const { return m_maxX; }
617     wxCoord MinY() const { return m_minY; }
618     wxCoord MaxY() const { return m_maxY; }
619    
620     // misc old functions
621     // ------------------
622    
623     // for compatibility with the old code when wxCoord was long everywhere
624     void GetTextExtent(const wxString& string,
625     long *x, long *y,
626     long *descent = NULL,
627     long *externalLeading = NULL,
628     wxFont *theFont = NULL) const
629     {
630     wxCoord x2, y2, descent2, externalLeading2;
631     DoGetTextExtent(string, &x2, &y2,
632     &descent2, &externalLeading2,
633     theFont);
634     if ( x )
635     *x = x2;
636     if ( y )
637     *y = y2;
638     if ( descent )
639     *descent = descent2;
640     if ( externalLeading )
641     *externalLeading = externalLeading2;
642     }
643    
644     void GetLogicalOrigin(long *x, long *y) const
645     {
646     wxCoord x2, y2;
647     DoGetLogicalOrigin(&x2, &y2);
648     if ( x )
649     *x = x2;
650     if ( y )
651     *y = y2;
652     }
653    
654     void GetDeviceOrigin(long *x, long *y) const
655     {
656     wxCoord x2, y2;
657     DoGetDeviceOrigin(&x2, &y2);
658     if ( x )
659     *x = x2;
660     if ( y )
661     *y = y2;
662     }
663     void GetClippingBox(long *x, long *y, long *w, long *h) const
664     {
665     wxCoord xx,yy,ww,hh;
666     DoGetClippingBox(&xx, &yy, &ww, &hh);
667     if (x) *x = xx;
668     if (y) *y = yy;
669     if (w) *w = ww;
670     if (h) *h = hh;
671     }
672    
673     // RTL related functions
674     // ---------------------
675    
676     // get or change the layout direction (LTR or RTL) for this dc,
677     // wxLayout_Default is returned if layout direction is not supported
678     virtual wxLayoutDirection GetLayoutDirection() const
679     { return wxLayout_Default; }
680     virtual void SetLayoutDirection(wxLayoutDirection WXUNUSED(dir))
681     { }
682    
683     protected:
684     // the pure virtual functions which should be implemented by wxDC
685     virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
686     int style = wxFLOOD_SURFACE) = 0;
687    
688     virtual void DoGradientFillLinear(const wxRect& rect,
689     const wxColour& initialColour,
690     const wxColour& destColour,
691     wxDirection nDirection = wxEAST);
692    
693     virtual void DoGradientFillConcentric(const wxRect& rect,
694     const wxColour& initialColour,
695     const wxColour& destColour,
696     const wxPoint& circleCenter);
697    
698     virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const = 0;
699    
700     virtual void DoDrawPoint(wxCoord x, wxCoord y) = 0;
701     virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) = 0;
702    
703     virtual void DoDrawArc(wxCoord x1, wxCoord y1,
704     wxCoord x2, wxCoord y2,
705     wxCoord xc, wxCoord yc) = 0;
706     virtual void DoDrawCheckMark(wxCoord x, wxCoord y,
707     wxCoord width, wxCoord height);
708     virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
709     double sa, double ea) = 0;
710    
711     virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) = 0;
712     virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
713     wxCoord width, wxCoord height,
714     double radius) = 0;
715     virtual void DoDrawEllipse(wxCoord x, wxCoord y,
716     wxCoord width, wxCoord height) = 0;
717    
718     virtual void DoCrossHair(wxCoord x, wxCoord y) = 0;
719    
720     virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) = 0;
721     virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
722     bool useMask = false) = 0;
723    
724     virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y) = 0;
725     virtual void DoDrawRotatedText(const wxString& text,
726     wxCoord x, wxCoord y, double angle) = 0;
727    
728     virtual bool DoBlit(wxCoord xdest, wxCoord ydest,
729     wxCoord width, wxCoord height,
730     wxDC *source, wxCoord xsrc, wxCoord ysrc,
731     int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord) = 0;
732    
733     virtual wxBitmap DoGetAsBitmap(const wxRect *WXUNUSED(subrect)) const { return wxNullBitmap; }
734    
735     virtual void DoGetSize(int *width, int *height) const = 0;
736     virtual void DoGetSizeMM(int* width, int* height) const = 0;
737    
738     virtual void DoDrawLines(int n, wxPoint points[],
739     wxCoord xoffset, wxCoord yoffset) = 0;
740     virtual void DoDrawPolygon(int n, wxPoint points[],
741     wxCoord xoffset, wxCoord yoffset,
742     int fillStyle = wxODDEVEN_RULE) = 0;
743     virtual void DoDrawPolyPolygon(int n, int count[], wxPoint points[],
744     wxCoord xoffset, wxCoord yoffset,
745     int fillStyle);
746    
747     virtual void DoSetClippingRegionAsRegion(const wxRegion& region) = 0;
748     virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
749     wxCoord width, wxCoord height) = 0;
750    
751     #if WXWIN_COMPATIBILITY_2_4
752     // this was only for confusing people, use DoGetClippingBox only
753     virtual void DoGetClippingRegion(wxCoord *x, wxCoord *y,
754     wxCoord *w, wxCoord *h)
755     { DoGetClippingBox(x, y, w, h); }
756     #endif
757    
758     virtual void DoGetClippingBox(wxCoord *x, wxCoord *y,
759     wxCoord *w, wxCoord *h) const
760     {
761     if ( x )
762     *x = m_clipX1;
763     if ( y )
764     *y = m_clipY1;
765     if ( w )
766     *w = m_clipX2 - m_clipX1;
767     if ( h )
768     *h = m_clipY2 - m_clipY1;
769     }
770    
771     virtual void DoGetLogicalOrigin(wxCoord *x, wxCoord *y) const
772     {
773     if ( x ) *x = m_logicalOriginX;
774     if ( y ) *y = m_logicalOriginY;
775     }
776    
777     virtual void DoGetDeviceOrigin(wxCoord *x, wxCoord *y) const
778     {
779     if ( x ) *x = m_deviceOriginX;
780     if ( y ) *y = m_deviceOriginY;
781     }
782    
783     virtual void DoGetTextExtent(const wxString& string,
784     wxCoord *x, wxCoord *y,
785     wxCoord *descent = NULL,
786     wxCoord *externalLeading = NULL,
787     wxFont *theFont = NULL) const = 0;
788    
789     virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;
790    
791     #if wxUSE_SPLINES
792     virtual void DoDrawSpline(wxList *points);
793     #endif
794    
795     #if wxABI_VERSION >= 20810
796     // returns adjustment factor for converting wxFont "point size"; in wx
797     // it is point size on screen and needs to be multiplied by this value
798     // for rendering on higher-resolution DCs such as printer ones
799     static float GetFontPointSizeAdjustment(float dpi);
800     #endif
801    
802     protected:
803     // unset clipping variables (after clipping region was destroyed)
804     void ResetClipping()
805     {
806     m_clipping = false;
807    
808     m_clipX1 = m_clipX2 = m_clipY1 = m_clipY2 = 0;
809     }
810    
811     // flags
812     bool m_colour:1;
813     bool m_ok:1;
814     bool m_clipping:1;
815     bool m_isInteractive:1;
816     bool m_isBBoxValid:1;
817    
818     // coordinate system variables
819    
820     // TODO short descriptions of what exactly they are would be nice...
821    
822     wxCoord m_logicalOriginX, m_logicalOriginY;
823     wxCoord m_deviceOriginX, m_deviceOriginY;
824    
825     double m_logicalScaleX, m_logicalScaleY;
826     double m_userScaleX, m_userScaleY;
827     double m_scaleX, m_scaleY;
828    
829     // Used by SetAxisOrientation() to invert the axes
830     int m_signX, m_signY;
831    
832     // bounding and clipping boxes
833     wxCoord m_minX, m_minY, m_maxX, m_maxY;
834     wxCoord m_clipX1, m_clipY1, m_clipX2, m_clipY2;
835    
836     int m_logicalFunction;
837     int m_backgroundMode;
838     int m_mappingMode;
839    
840     // GDI objects
841     wxPen m_pen;
842     wxBrush m_brush;
843     wxBrush m_backgroundBrush;
844     wxColour m_textForegroundColour;
845     wxColour m_textBackgroundColour;
846     wxFont m_font;
847    
848     #if wxUSE_PALETTE
849     wxPalette m_palette;
850     bool m_hasCustomPalette;
851     #endif // wxUSE_PALETTE
852    
853     private:
854     DECLARE_NO_COPY_CLASS(wxDCBase)
855     DECLARE_ABSTRACT_CLASS(wxDCBase)
856     };
857    
858     // ----------------------------------------------------------------------------
859     // now include the declaration of wxDC class
860     // ----------------------------------------------------------------------------
861    
862     #if defined(__WXPALMOS__)
863     #include "wx/palmos/dc.h"
864     #elif defined(__WXMSW__)
865     #include "wx/msw/dc.h"
866     #elif defined(__WXMOTIF__)
867     #include "wx/motif/dc.h"
868     #elif defined(__WXGTK20__)
869     #include "wx/gtk/dc.h"
870     #elif defined(__WXGTK__)
871     #include "wx/gtk1/dc.h"
872     #elif defined(__WXX11__)
873     #include "wx/x11/dc.h"
874     #elif defined(__WXMGL__)
875     #include "wx/mgl/dc.h"
876     #elif defined(__WXDFB__)
877     #include "wx/dfb/dc.h"
878     #elif defined(__WXMAC__)
879     #include "wx/mac/dc.h"
880     #elif defined(__WXCOCOA__)
881     #include "wx/cocoa/dc.h"
882     #elif defined(__WXPM__)
883     #include "wx/os2/dc.h"
884     #endif
885    
886     #if wxUSE_GRAPHICS_CONTEXT
887     #include "wx/dcgraph.h"
888     #endif
889    
890     // ----------------------------------------------------------------------------
891     // helper class: you can use it to temporarily change the DC text colour and
892     // restore it automatically when the object goes out of scope
893     // ----------------------------------------------------------------------------
894    
895     class WXDLLEXPORT wxDCTextColourChanger
896     {
897     public:
898     wxDCTextColourChanger(wxDC& dc) : m_dc(dc), m_colFgOld() { }
899    
900     wxDCTextColourChanger(wxDC& dc, const wxColour& col) : m_dc(dc)
901     {
902     Set(col);
903     }
904    
905     ~wxDCTextColourChanger()
906     {
907     if ( m_colFgOld.Ok() )
908     m_dc.SetTextForeground(m_colFgOld);
909     }
910    
911     void Set(const wxColour& col)
912     {
913     if ( !m_colFgOld.Ok() )
914     m_colFgOld = m_dc.GetTextForeground();
915     m_dc.SetTextForeground(col);
916     }
917    
918     private:
919     wxDC& m_dc;
920    
921     wxColour m_colFgOld;
922    
923     DECLARE_NO_COPY_CLASS(wxDCTextColourChanger)
924     };
925    
926     // ----------------------------------------------------------------------------
927     // helper class: you can use it to temporarily change the DC pen and
928     // restore it automatically when the object goes out of scope
929     // ----------------------------------------------------------------------------
930    
931     class WXDLLEXPORT wxDCPenChanger
932     {
933     public:
934     wxDCPenChanger(wxDC& dc, const wxPen& pen) : m_dc(dc), m_penOld(dc.GetPen())
935     {
936     m_dc.SetPen(pen);
937     }
938    
939     ~wxDCPenChanger()
940     {
941     if ( m_penOld.Ok() )
942     m_dc.SetPen(m_penOld);
943     }
944    
945     private:
946     wxDC& m_dc;
947    
948     wxPen m_penOld;
949    
950     DECLARE_NO_COPY_CLASS(wxDCPenChanger)
951     };
952    
953     // ----------------------------------------------------------------------------
954     // helper class: you can use it to temporarily change the DC brush and
955     // restore it automatically when the object goes out of scope
956     // ----------------------------------------------------------------------------
957    
958     class WXDLLEXPORT wxDCBrushChanger
959     {
960     public:
961     wxDCBrushChanger(wxDC& dc, const wxBrush& brush) : m_dc(dc), m_brushOld(dc.GetBrush())
962     {
963     m_dc.SetBrush(brush);
964     }
965    
966     ~wxDCBrushChanger()
967     {
968     if ( m_brushOld.Ok() )
969     m_dc.SetBrush(m_brushOld);
970     }
971    
972     private:
973     wxDC& m_dc;
974    
975     wxBrush m_brushOld;
976    
977     DECLARE_NO_COPY_CLASS(wxDCBrushChanger)
978     };
979    
980     // ----------------------------------------------------------------------------
981     // another small helper class: sets the clipping region in its ctor and
982     // destroys it in the dtor
983     // ----------------------------------------------------------------------------
984    
985     class WXDLLEXPORT wxDCClipper
986     {
987     public:
988     wxDCClipper(wxDC& dc, const wxRegion& r) : m_dc(dc)
989     { dc.SetClippingRegion(r); }
990     wxDCClipper(wxDC& dc, const wxRect& r) : m_dc(dc)
991     { dc.SetClippingRegion(r.x, r.y, r.width, r.height); }
992     wxDCClipper(wxDC& dc, wxCoord x, wxCoord y, wxCoord w, wxCoord h) : m_dc(dc)
993     { dc.SetClippingRegion(x, y, w, h); }
994    
995     ~wxDCClipper() { m_dc.DestroyClippingRegion(); }
996    
997     private:
998     wxDC& m_dc;
999    
1000     DECLARE_NO_COPY_CLASS(wxDCClipper)
1001     };
1002    
1003     #endif // _WX_DC_H_BASE_

  ViewVC Help
Powered by ViewVC 1.1.22