1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxPseudoDC class
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_PSUEDO_DC_H_BASE_
12 #define _WX_PSUEDO_DC_H_BASE_
14 //----------------------------------------------------------------------------
15 // Base class for all pdcOp classes
16 //----------------------------------------------------------------------------
20 // Constructor and Destructor
24 // Virtual Drawing Methods
25 virtual void DrawToDC(wxDC
*dc
, bool grey
=false)=0;
26 virtual void Translate(wxCoord
WXUNUSED(dx
), wxCoord
WXUNUSED(dy
)) {}
27 virtual void CacheGrey() {}
30 //----------------------------------------------------------------------------
31 // declare a list class for list of pdcOps
32 //----------------------------------------------------------------------------
33 WX_DECLARE_LIST(pdcOp
, pdcOpList
);
36 //----------------------------------------------------------------------------
37 // Helper functions used for drawing greyed out versions of objects
38 //----------------------------------------------------------------------------
39 wxColour
&MakeColourGrey(const wxColour
&c
);
40 wxBrush
&GetGreyBrush(wxBrush
&brush
);
41 wxPen
&GetGreyPen(wxPen
&pen
);
42 wxIcon
&GetGreyIcon(wxIcon
&icon
);
43 wxBitmap
&GetGreyBitmap(wxBitmap
&bmp
);
45 //----------------------------------------------------------------------------
46 // Classes derived from pdcOp
47 // There is one class for each method mirrored from wxDC to wxPseudoDC
48 //----------------------------------------------------------------------------
49 class pdcSetFontOp
: public pdcOp
52 pdcSetFontOp(const wxFont
& font
)
54 virtual void DrawToDC(wxDC
*dc
, bool WXUNUSED(grey
)=false) {dc
->SetFont(m_font
);}
59 class pdcSetBrushOp
: public pdcOp
62 pdcSetBrushOp(const wxBrush
& brush
)
63 {m_greybrush
=m_brush
=brush
;}
64 virtual void DrawToDC(wxDC
*dc
, bool grey
=false)
66 if (!grey
) dc
->SetBrush(m_brush
);
67 else dc
->SetBrush(m_greybrush
);
69 virtual void CacheGrey() {m_greybrush
=GetGreyBrush(m_brush
);}
75 class pdcSetBackgroundOp
: public pdcOp
78 pdcSetBackgroundOp(const wxBrush
& brush
)
79 {m_greybrush
=m_brush
=brush
;}
80 virtual void DrawToDC(wxDC
*dc
, bool grey
=false)
82 if (!grey
) dc
->SetBackground(m_brush
);
83 else dc
->SetBackground(m_greybrush
);
85 virtual void CacheGrey() {m_greybrush
=GetGreyBrush(m_brush
);}
91 class pdcSetPenOp
: public pdcOp
94 pdcSetPenOp(const wxPen
& pen
)
95 {m_greypen
=m_pen
=pen
;}
96 virtual void DrawToDC(wxDC
*dc
, bool grey
=false)
98 if (!grey
) dc
->SetPen(m_pen
);
99 else dc
->SetPen(m_greypen
);
101 virtual void CacheGrey() {m_greypen
=GetGreyPen(m_pen
);}
107 class pdcSetTextBackgroundOp
: public pdcOp
110 pdcSetTextBackgroundOp(const wxColour
& colour
)
112 virtual void DrawToDC(wxDC
*dc
, bool grey
=false)
114 if (!grey
) dc
->SetTextBackground(m_colour
);
115 else dc
->SetTextBackground(MakeColourGrey(m_colour
));
121 class pdcSetTextForegroundOp
: public pdcOp
124 pdcSetTextForegroundOp(const wxColour
& colour
)
126 virtual void DrawToDC(wxDC
*dc
, bool grey
=false)
128 if (!grey
) dc
->SetTextForeground(m_colour
);
129 else dc
->SetTextForeground(MakeColourGrey(m_colour
));
135 class pdcDrawRectangleOp
: public pdcOp
138 pdcDrawRectangleOp(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
)
139 {m_x
=x
; m_y
=y
; m_w
=w
; m_h
=h
;}
140 virtual void DrawToDC(wxDC
*dc
, bool WXUNUSED(grey
)=false) {dc
->DrawRectangle(m_x
,m_y
,m_w
,m_h
);}
141 virtual void Translate(wxCoord dx
, wxCoord dy
)
144 wxCoord m_x
,m_y
,m_w
,m_h
;
147 class pdcDrawLineOp
: public pdcOp
150 pdcDrawLineOp(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
151 {m_x1
=x1
; m_y1
=y1
; m_x2
=x2
; m_y2
=y2
;}
152 virtual void DrawToDC(wxDC
*dc
, bool WXUNUSED(grey
)=false) {dc
->DrawLine(m_x1
,m_y1
,m_x2
,m_y2
);}
153 virtual void Translate(wxCoord dx
, wxCoord dy
)
154 {m_x1
+=dx
; m_y1
+=dy
; m_x2
+=dx
; m_y2
+=dy
;}
156 wxCoord m_x1
,m_y1
,m_x2
,m_y2
;
159 class pdcSetBackgroundModeOp
: public pdcOp
162 pdcSetBackgroundModeOp(int mode
) {m_mode
=mode
;}
163 virtual void DrawToDC(wxDC
*dc
, bool WXUNUSED(grey
)=false) {dc
->SetBackgroundMode(m_mode
);}
168 class pdcDrawTextOp
: public pdcOp
171 pdcDrawTextOp(const wxString
& text
, wxCoord x
, wxCoord y
)
172 {m_text
=text
; m_x
=x
; m_y
=y
;}
173 virtual void DrawToDC(wxDC
*dc
, bool WXUNUSED(grey
)=false) {dc
->DrawText(m_text
, m_x
, m_y
);}
174 virtual void Translate(wxCoord dx
, wxCoord dy
)
181 class pdcClearOp
: public pdcOp
185 virtual void DrawToDC(wxDC
*dc
, bool WXUNUSED(grey
)=false) {dc
->Clear();}
188 class pdcBeginDrawingOp
: public pdcOp
191 pdcBeginDrawingOp() {}
192 virtual void DrawToDC(wxDC
*dc
, bool WXUNUSED(grey
)=false) {dc
->BeginDrawing();}
195 class pdcEndDrawingOp
: public pdcOp
199 virtual void DrawToDC(wxDC
*dc
, bool WXUNUSED(grey
)=false) {dc
->EndDrawing();}
202 class pdcFloodFillOp
: public pdcOp
205 pdcFloodFillOp(wxCoord x
, wxCoord y
, const wxColour
& col
,
206 int style
) {m_x
=x
; m_y
=y
; m_col
=col
; m_style
=style
;}
207 virtual void DrawToDC(wxDC
*dc
, bool grey
=false)
209 if (!grey
) dc
->FloodFill(m_x
,m_y
,m_col
,m_style
);
210 else dc
->FloodFill(m_x
,m_y
,MakeColourGrey(m_col
),m_style
);
212 virtual void Translate(wxCoord dx
, wxCoord dy
)
220 class pdcCrossHairOp
: public pdcOp
223 pdcCrossHairOp(wxCoord x
, wxCoord y
) {m_x
=x
; m_y
=y
;}
224 virtual void DrawToDC(wxDC
*dc
, bool WXUNUSED(grey
)=false) {dc
->CrossHair(m_x
,m_y
);}
225 virtual void Translate(wxCoord dx
, wxCoord dy
)
231 class pdcDrawArcOp
: public pdcOp
234 pdcDrawArcOp(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
235 wxCoord xc
, wxCoord yc
)
236 {m_x1
=x1
; m_y1
=y1
; m_x2
=x2
; m_y2
=y2
; m_xc
=xc
; m_yc
=yc
;}
237 virtual void DrawToDC(wxDC
*dc
, bool WXUNUSED(grey
)=false)
238 {dc
->DrawArc(m_x1
,m_y1
,m_x2
,m_y2
,m_xc
,m_yc
);}
239 virtual void Translate(wxCoord dx
, wxCoord dy
)
240 {m_x1
+=dx
; m_x2
+=dx
; m_y1
+=dy
; m_y2
+=dy
;}
242 wxCoord m_x1
,m_x2
,m_xc
;
243 wxCoord m_y1
,m_y2
,m_yc
;
246 class pdcDrawCheckMarkOp
: public pdcOp
249 pdcDrawCheckMarkOp(wxCoord x
, wxCoord y
,
250 wxCoord width
, wxCoord height
)
251 {m_x
=x
; m_y
=y
; m_w
=width
; m_h
=height
;}
252 virtual void DrawToDC(wxDC
*dc
, bool WXUNUSED(grey
)=false)
253 {dc
->DrawCheckMark(m_x
,m_y
,m_w
,m_h
);}
254 virtual void Translate(wxCoord dx
, wxCoord dy
)
257 wxCoord m_x
,m_y
,m_w
,m_h
;
260 class pdcDrawEllipticArcOp
: public pdcOp
263 pdcDrawEllipticArcOp(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
264 double sa
, double ea
)
265 {m_x
=x
; m_y
=y
; m_w
=w
; m_h
=h
; m_sa
=sa
; m_ea
=ea
;}
266 virtual void DrawToDC(wxDC
*dc
, bool WXUNUSED(grey
)=false)
267 {dc
->DrawEllipticArc(m_x
,m_y
,m_w
,m_h
,m_sa
,m_ea
);}
268 virtual void Translate(wxCoord dx
, wxCoord dy
)
271 wxCoord m_x
,m_y
,m_w
,m_h
;
275 class pdcDrawPointOp
: public pdcOp
278 pdcDrawPointOp(wxCoord x
, wxCoord y
)
280 virtual void DrawToDC(wxDC
*dc
, bool WXUNUSED(grey
)=false) {dc
->DrawPoint(m_x
,m_y
);}
281 virtual void Translate(wxCoord dx
, wxCoord dy
)
287 class pdcDrawRoundedRectangleOp
: public pdcOp
290 pdcDrawRoundedRectangleOp(wxCoord x
, wxCoord y
, wxCoord width
,
291 wxCoord height
, double radius
)
292 {m_x
=x
; m_y
=y
; m_w
=width
; m_h
=height
; m_r
=radius
;}
293 virtual void DrawToDC(wxDC
*dc
, bool WXUNUSED(grey
)=false)
294 {dc
->DrawRoundedRectangle(m_x
,m_y
,m_w
,m_h
,m_r
);}
295 virtual void Translate(wxCoord dx
, wxCoord dy
)
298 wxCoord m_x
,m_y
,m_w
,m_h
;
302 class pdcDrawEllipseOp
: public pdcOp
305 pdcDrawEllipseOp(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
306 {m_x
=x
; m_y
=y
; m_w
=width
; m_h
=height
;}
307 virtual void DrawToDC(wxDC
*dc
, bool WXUNUSED(grey
)=false) {dc
->DrawEllipse(m_x
,m_y
,m_w
,m_h
);}
308 virtual void Translate(wxCoord dx
, wxCoord dy
)
311 wxCoord m_x
,m_y
,m_w
,m_h
;
314 class pdcDrawIconOp
: public pdcOp
317 pdcDrawIconOp(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
318 {m_icon
=icon
; m_x
=x
; m_y
=y
;}
319 virtual void DrawToDC(wxDC
*dc
, bool grey
=false)
321 if (grey
) dc
->DrawIcon(m_greyicon
,m_x
,m_y
);
322 else dc
->DrawIcon(m_icon
,m_x
,m_y
);
324 virtual void CacheGrey() {m_greyicon
=GetGreyIcon(m_icon
);}
325 virtual void Translate(wxCoord dx
, wxCoord dy
)
333 class pdcDrawLinesOp
: public pdcOp
336 pdcDrawLinesOp(int n
, wxPoint points
[],
337 wxCoord xoffset
= 0, wxCoord yoffset
= 0);
338 virtual ~pdcDrawLinesOp();
339 virtual void DrawToDC(wxDC
*dc
, bool WXUNUSED(grey
)=false)
340 {dc
->DrawLines(m_n
,m_points
,m_xoffset
,m_yoffset
);}
341 virtual void Translate(wxCoord dx
, wxCoord dy
)
343 for(int i
=0; i
<m_n
; i
++)
352 wxCoord m_xoffset
,m_yoffset
;
355 class pdcDrawPolygonOp
: public pdcOp
358 pdcDrawPolygonOp(int n
, wxPoint points
[],
359 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
360 int fillStyle
= wxODDEVEN_RULE
);
361 virtual ~pdcDrawPolygonOp();
362 virtual void DrawToDC(wxDC
*dc
, bool WXUNUSED(grey
)=false)
363 {dc
->DrawPolygon(m_n
,m_points
,m_xoffset
,m_yoffset
,m_fillStyle
);}
365 virtual void Translate(wxCoord dx
, wxCoord dy
)
367 for(int i
=0; i
<m_n
; i
++)
376 wxCoord m_xoffset
,m_yoffset
;
380 class pdcDrawPolyPolygonOp
: public pdcOp
383 pdcDrawPolyPolygonOp(int n
, int count
[], wxPoint points
[],
384 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
385 int fillStyle
= wxODDEVEN_RULE
);
386 virtual ~pdcDrawPolyPolygonOp();
387 virtual void DrawToDC(wxDC
*dc
, bool WXUNUSED(grey
)=false)
388 {dc
->DrawPolyPolygon(m_n
,m_count
,m_points
,
389 m_xoffset
,m_yoffset
,m_fillStyle
);}
390 virtual void Translate(wxCoord dx
, wxCoord dy
)
392 for(int i
=0; i
<m_totaln
; i
++)
403 wxCoord m_xoffset
, m_yoffset
;
407 class pdcDrawRotatedTextOp
: public pdcOp
410 pdcDrawRotatedTextOp(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
411 {m_text
=text
; m_x
=x
; m_y
=y
; m_angle
=angle
;}
412 virtual void DrawToDC(wxDC
*dc
, bool WXUNUSED(grey
)=false)
413 {dc
->DrawRotatedText(m_text
,m_x
,m_y
,m_angle
);}
414 virtual void Translate(wxCoord dx
, wxCoord dy
)
422 class pdcDrawBitmapOp
: public pdcOp
425 pdcDrawBitmapOp(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
426 bool useMask
= false)
427 {m_bmp
=bmp
; m_x
=x
; m_y
=y
; m_useMask
=useMask
;}
428 virtual void DrawToDC(wxDC
*dc
, bool grey
=false)
430 if (grey
) dc
->DrawBitmap(m_greybmp
,m_x
,m_y
,m_useMask
);
431 else dc
->DrawBitmap(m_bmp
,m_x
,m_y
,m_useMask
);
433 virtual void CacheGrey() {m_greybmp
=GetGreyBitmap(m_bmp
);}
434 virtual void Translate(wxCoord dx
, wxCoord dy
)
443 class pdcDrawLabelOp
: public pdcOp
446 pdcDrawLabelOp(const wxString
& text
,
447 const wxBitmap
& image
,
449 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
451 {m_text
=text
; m_image
=image
; m_rect
=rect
;
452 m_align
=alignment
; m_iAccel
=indexAccel
;}
453 virtual void DrawToDC(wxDC
*dc
, bool WXUNUSED(grey
)=false)
454 {dc
->DrawLabel(m_text
,m_image
,m_rect
,m_align
,m_iAccel
);}
455 virtual void Translate(wxCoord dx
, wxCoord dy
)
456 {m_rect
.x
+=dx
; m_rect
.y
+=dy
;}
466 class pdcDrawSplineOp
: public pdcOp
469 pdcDrawSplineOp(int n
, wxPoint points
[]);
470 virtual ~pdcDrawSplineOp();
471 virtual void DrawToDC(wxDC
*dc
, bool WXUNUSED(grey
)=false) {dc
->DrawSpline(m_n
,m_points
);}
472 virtual void Translate(wxCoord dx
, wxCoord dy
)
476 m_points
[i
].x
+=dx
; m_points
[i
].y
+=dy
;
482 #endif // wxUSE_SPLINES
485 class pdcSetPaletteOp
: public pdcOp
488 pdcSetPaletteOp(const wxPalette
& palette
) {m_palette
=palette
;}
489 virtual void DrawToDC(wxDC
*dc
, bool WXUNUSED(grey
)=false) {dc
->SetPalette(m_palette
);}
493 #endif // wxUSE_PALETTE
495 class pdcSetLogicalFunctionOp
: public pdcOp
498 pdcSetLogicalFunctionOp(int function
) {m_function
=function
;}
499 virtual void DrawToDC(wxDC
*dc
, bool WXUNUSED(grey
)=false) {dc
->SetLogicalFunction(m_function
);}
504 //----------------------------------------------------------------------------
505 // pdcObject type to contain list of operations for each real (Python) object
506 //----------------------------------------------------------------------------
511 {m_id
=id
; m_bounded
=false; m_oplist
.DeleteContents(true);
514 virtual ~pdcObject() {m_oplist
.Clear();}
516 // Protected Member Access
517 void SetId(int id
) {m_id
=id
;}
518 int GetId() {return m_id
;}
519 void SetBounds(wxRect
& rect
) {m_bounds
=rect
; m_bounded
=true;}
520 wxRect
GetBounds() {return m_bounds
;}
521 void SetBounded(bool bounded
) {m_bounded
=bounded
;}
522 bool IsBounded() {return m_bounded
;}
523 void SetGreyedOut(bool greyout
=true);
524 bool GetGreyedOut() {return m_greyedout
;}
526 // Op List Management Methods
527 void Clear() {m_oplist
.Clear();}
528 void AddOp(pdcOp
*op
)
531 if (m_greyedout
) op
->CacheGrey();
533 int GetLen() {return m_oplist
.GetCount();}
534 virtual void Translate(wxCoord dx
, wxCoord dy
);
537 virtual void DrawToDC(wxDC
*dc
);
539 int m_id
; // id of object (associates this pdcObject
540 // with a Python object with same id)
541 wxRect m_bounds
; // bounding rect of this object
542 bool m_bounded
; // true if bounds is valid, false by default
543 pdcOpList m_oplist
; // list of operations for this object
544 bool m_greyedout
; // if true then draw this object in greys only
548 //----------------------------------------------------------------------------
549 // Declare a wxList to hold all the objects. List order reflects drawing
550 // order (Z order) and is the same order as objects are added to the list
551 //----------------------------------------------------------------------------
553 WX_DECLARE_LIST(pdcObject
, pdcObjectList
);
556 // ----------------------------------------------------------------------------
558 // ----------------------------------------------------------------------------
559 // This is the actual PseudoDC class
560 // This class stores a list of recorded dc operations in m_list
561 // and plays them back to a real dc using DrawToDC or DrawToDCClipped.
562 // Drawing methods are mirrored from wxDC but add nodes to m_list
563 // instead of doing any real drawing.
564 // ----------------------------------------------------------------------------
565 class wxPseudoDC
: public wxObject
569 {m_currId
=-1; m_lastObjNode
=NULL
; m_objectlist
.DeleteContents(true);}
571 // ------------------------------------------------------------------------
572 // List managment methods
577 // ------------------------------------------------------------------------
578 // methods for managing operations by ID
580 // Set the Id for all subsequent operations (until SetId is called again)
581 void SetId(int id
) {m_currId
= id
;}
582 // Remove all the operations associated with an id so it can be redrawn
583 void ClearId(int id
);
584 // Remove the object node (and all operations) associated with an id
585 void RemoveId(int id
);
586 // Set the bounding rect of a given object
587 // This will create an object node if one doesn't exist
588 void SetIdBounds(int id
, wxRect
& rect
);
589 void GetIdBounds(int id
, wxRect
& rect
);
590 // Translate all the operations for this id
591 void TranslateId(int id
, wxCoord dx
, wxCoord dy
);
592 // Grey-out an object
593 void SetIdGreyedOut(int id
, bool greyout
=true);
594 bool GetIdGreyedOut(int id
);
595 // Find Objects at a point. Returns Python list of id's
596 // sorted in reverse drawing order (result[0] is top object)
597 // This version looks at drawn pixels
598 PyObject
*FindObjects(wxCoord x
, wxCoord y
,
599 wxCoord radius
=1, const wxColor
& bg
=*wxWHITE
);
600 // This version only looks at bounding boxes
601 PyObject
*FindObjectsByBBox(wxCoord x
, wxCoord y
);
603 // ------------------------------------------------------------------------
606 // draw to dc but skip objects known to be outside of rect
607 // This is a coarse level of clipping to speed things up
608 // when lots of objects are off screen and doesn't affect the dc level
610 void DrawToDCClipped(wxDC
*dc
, const wxRect
& rect
);
611 void DrawToDCClippedRgn(wxDC
*dc
, const wxRegion
& region
);
612 // draw to dc with no clipping (well the dc will still clip)
613 void DrawToDC(wxDC
*dc
);
614 // draw a single object to the dc
615 void DrawIdToDC(int id
, wxDC
*dc
);
617 // ------------------------------------------------------------------------
618 // Hit Detection Methods
620 // returns list of object with a drawn pixel within radius pixels of (x,y)
621 // the list is in reverse draw order so last drawn is first in list
622 // PyObject *HitTest(wxCoord x, wxCoord y, double radius)
623 // returns list of objects whose bounding boxes include (x,y)
624 // PyObject *HitTestBB(wxCoord x, wxCoord y)
627 // ------------------------------------------------------------------------
628 // Methods mirrored from wxDC
630 void FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
631 int style
= wxFLOOD_SURFACE
)
632 {AddToList(new pdcFloodFillOp(x
,y
,col
,style
));}
633 void FloodFill(const wxPoint
& pt
, const wxColour
& col
,
634 int style
= wxFLOOD_SURFACE
)
635 { FloodFill(pt
.x
, pt
.y
, col
, style
); }
637 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
638 {AddToList(new pdcDrawLineOp(x1
, y1
, x2
, y2
));}
639 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
640 { DrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
642 void CrossHair(wxCoord x
, wxCoord y
)
643 {AddToList(new pdcCrossHairOp(x
,y
));}
644 void CrossHair(const wxPoint
& pt
)
645 { CrossHair(pt
.x
, pt
.y
); }
647 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
648 wxCoord xc
, wxCoord yc
)
649 {AddToList(new pdcDrawArcOp(x1
,y1
,x2
,y2
,xc
,yc
));}
650 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
651 { DrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
653 void DrawCheckMark(wxCoord x
, wxCoord y
,
654 wxCoord width
, wxCoord height
)
655 {AddToList(new pdcDrawCheckMarkOp(x
,y
,width
,height
));}
656 void DrawCheckMark(const wxRect
& rect
)
657 { DrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
659 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
660 double sa
, double ea
)
661 {AddToList(new pdcDrawEllipticArcOp(x
,y
,w
,h
,sa
,ea
));}
662 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
663 double sa
, double ea
)
664 { DrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
666 void DrawPoint(wxCoord x
, wxCoord y
)
667 {AddToList(new pdcDrawPointOp(x
,y
));}
668 void DrawPoint(const wxPoint
& pt
)
669 { DrawPoint(pt
.x
, pt
.y
); }
671 void DrawPolygon(int n
, wxPoint points
[],
672 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
673 int fillStyle
= wxODDEVEN_RULE
)
674 {AddToList(new pdcDrawPolygonOp(n
,points
,xoffset
,yoffset
,fillStyle
));}
676 void DrawPolyPolygon(int n
, int count
[], wxPoint points
[],
677 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
678 int fillStyle
= wxODDEVEN_RULE
)
679 {AddToList(new pdcDrawPolyPolygonOp(n
,count
,points
,xoffset
,yoffset
,fillStyle
));}
681 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
682 {AddToList(new pdcDrawRectangleOp(x
, y
, width
, height
));}
683 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
684 { DrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
685 void DrawRectangle(const wxRect
& rect
)
686 { DrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
688 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
690 {AddToList(new pdcDrawRoundedRectangleOp(x
,y
,width
,height
,radius
));}
691 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
693 { DrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
694 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
695 { DrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
697 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
698 { DrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
699 void DrawCircle(const wxPoint
& pt
, wxCoord radius
)
700 { DrawCircle(pt
.x
, pt
.y
, radius
); }
702 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
703 {AddToList(new pdcDrawEllipseOp(x
,y
,width
,height
));}
704 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
705 { DrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
706 void DrawEllipse(const wxRect
& rect
)
707 { DrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
709 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
710 {AddToList(new pdcDrawIconOp(icon
,x
,y
));}
711 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
712 { DrawIcon(icon
, pt
.x
, pt
.y
); }
714 void DrawLines(int n
, wxPoint points
[],
715 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
716 {AddToList(new pdcDrawLinesOp(n
,points
,xoffset
,yoffset
));}
718 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
719 bool useMask
= false)
720 {AddToList(new pdcDrawBitmapOp(bmp
,x
,y
,useMask
));}
721 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
722 bool useMask
= false)
723 { DrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
725 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
726 {AddToList(new pdcDrawTextOp(text
, x
, y
));}
727 void DrawText(const wxString
& text
, const wxPoint
& pt
)
728 { DrawText(text
, pt
.x
, pt
.y
); }
730 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
731 {AddToList(new pdcDrawRotatedTextOp(text
,x
,y
,angle
));}
732 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
733 { DrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
735 // this version puts both optional bitmap and the text into the given
736 // rectangle and aligns is as specified by alignment parameter; it also
737 // will emphasize the character with the given index if it is != -1
738 void DrawLabel(const wxString
& text
,
739 const wxBitmap
& image
,
741 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
743 {AddToList(new pdcDrawLabelOp(text
,image
,rect
,alignment
,indexAccel
));}
745 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
746 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
748 { DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
750 /*?????? I don't think that the source dc would stick around
751 void Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
752 wxDC *source, wxCoord xsrc, wxCoord ysrc,
753 int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord)
754 {AddToList(new pdcBlitOp(xdest,ydest,width,height,source,xsrc,
755 ysrc,rop,useMask,xsrcMask,ysrcMask));}
756 void Blit(const wxPoint& destPt, const wxSize& sz,
757 wxDC *source, const wxPoint& srcPt,
758 int rop = wxCOPY, bool useMask = false, const wxPoint& srcPtMask = wxDefaultPosition)
760 Blit(destPt.x, destPt.y, sz.x, sz.y, source, srcPt.x, srcPt.y,
761 rop, useMask, srcPtMask.x, srcPtMask.y);
766 void DrawSpline(int n
, wxPoint points
[])
767 {AddToList(new pdcDrawSplineOp(n
,points
));}
768 #endif // wxUSE_SPLINES
771 void SetPalette(const wxPalette
& palette
)
772 {AddToList(new pdcSetPaletteOp(palette
));}
773 #endif // wxUSE_PALETTE
775 void SetLogicalFunction(int function
)
776 {AddToList(new pdcSetLogicalFunctionOp(function
));}
777 void SetFont(const wxFont
& font
)
778 {AddToList(new pdcSetFontOp(font
));}
779 void SetPen(const wxPen
& pen
)
780 {AddToList(new pdcSetPenOp(pen
));}
781 void SetBrush(const wxBrush
& brush
)
782 {AddToList(new pdcSetBrushOp(brush
));}
783 void SetBackground(const wxBrush
& brush
)
784 {AddToList(new pdcSetBackgroundOp(brush
));}
785 void SetBackgroundMode(int mode
)
786 {AddToList(new pdcSetBackgroundModeOp(mode
));}
787 void SetTextBackground(const wxColour
& colour
)
788 {AddToList(new pdcSetTextBackgroundOp(colour
));}
789 void SetTextForeground(const wxColour
& colour
)
790 {AddToList(new pdcSetTextForegroundOp(colour
));}
793 {AddToList(new pdcClearOp());}
795 {AddToList(new pdcBeginDrawingOp());}
797 {AddToList(new pdcEndDrawingOp());}
800 // ------------------------------------------------------------------------
801 // protected helper methods
802 void AddToList(pdcOp
*newOp
);
803 pdcObjectList::Node
*FindObjNode(int id
, bool create
=false);
805 // ------------------------------------------------------------------------
808 int m_currId
; // id to use for operations done on the PseudoDC
809 pdcObjectList::Node
*m_lastObjNode
; // used to find last used object quickly
810 pdcObjectList m_objectlist
; // list of objects