]> git.saurik.com Git - wxWidgets.git/blob - wxPython/include/wx/wxPython/pseudodc.h
Remove some items from the Recent additions list
[wxWidgets.git] / wxPython / include / wx / wxPython / pseudodc.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: pseudodc.h
3 // Purpose: wxPseudoDC class
4 // Author: Paul Lanier
5 // Modified by:
6 // Created: 05/25/06
7 // RCS-ID: $Id$
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_PSUEDO_DC_H_BASE_
12 #define _WX_PSUEDO_DC_H_BASE_
13
14 //----------------------------------------------------------------------------
15 // Base class for all pdcOp classes
16 //----------------------------------------------------------------------------
17 class pdcOp
18 {
19 public:
20 // Constructor and Destructor
21 pdcOp() {}
22 virtual ~pdcOp() {}
23
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() {}
28 };
29
30 //----------------------------------------------------------------------------
31 // declare a list class for list of pdcOps
32 //----------------------------------------------------------------------------
33 WX_DECLARE_LIST(pdcOp, pdcOpList);
34
35
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);
44
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
50 {
51 public:
52 pdcSetFontOp(const wxFont& font)
53 {m_font=font;}
54 virtual void DrawToDC(wxDC *dc, bool WXUNUSED(grey)=false) {dc->SetFont(m_font);}
55 protected:
56 wxFont m_font;
57 };
58
59 class pdcSetBrushOp : public pdcOp
60 {
61 public:
62 pdcSetBrushOp(const wxBrush& brush)
63 {m_greybrush=m_brush=brush;}
64 virtual void DrawToDC(wxDC *dc, bool grey=false)
65 {
66 if (!grey) dc->SetBrush(m_brush);
67 else dc->SetBrush(m_greybrush);
68 }
69 virtual void CacheGrey() {m_greybrush=GetGreyBrush(m_brush);}
70 protected:
71 wxBrush m_brush;
72 wxBrush m_greybrush;
73 };
74
75 class pdcSetBackgroundOp : public pdcOp
76 {
77 public:
78 pdcSetBackgroundOp(const wxBrush& brush)
79 {m_greybrush=m_brush=brush;}
80 virtual void DrawToDC(wxDC *dc, bool grey=false)
81 {
82 if (!grey) dc->SetBackground(m_brush);
83 else dc->SetBackground(m_greybrush);
84 }
85 virtual void CacheGrey() {m_greybrush=GetGreyBrush(m_brush);}
86 protected:
87 wxBrush m_brush;
88 wxBrush m_greybrush;
89 };
90
91 class pdcSetPenOp : public pdcOp
92 {
93 public:
94 pdcSetPenOp(const wxPen& pen)
95 {m_greypen=m_pen=pen;}
96 virtual void DrawToDC(wxDC *dc, bool grey=false)
97 {
98 if (!grey) dc->SetPen(m_pen);
99 else dc->SetPen(m_greypen);
100 }
101 virtual void CacheGrey() {m_greypen=GetGreyPen(m_pen);}
102 protected:
103 wxPen m_pen;
104 wxPen m_greypen;
105 };
106
107 class pdcSetTextBackgroundOp : public pdcOp
108 {
109 public:
110 pdcSetTextBackgroundOp(const wxColour& colour)
111 {m_colour=colour;}
112 virtual void DrawToDC(wxDC *dc, bool grey=false)
113 {
114 if (!grey) dc->SetTextBackground(m_colour);
115 else dc->SetTextBackground(MakeColourGrey(m_colour));
116 }
117 protected:
118 wxColour m_colour;
119 };
120
121 class pdcSetTextForegroundOp : public pdcOp
122 {
123 public:
124 pdcSetTextForegroundOp(const wxColour& colour)
125 {m_colour=colour;}
126 virtual void DrawToDC(wxDC *dc, bool grey=false)
127 {
128 if (!grey) dc->SetTextForeground(m_colour);
129 else dc->SetTextForeground(MakeColourGrey(m_colour));
130 }
131 protected:
132 wxColour m_colour;
133 };
134
135 class pdcDrawRectangleOp : public pdcOp
136 {
137 public:
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)
142 {m_x+=dx;m_y+=dy;}
143 protected:
144 wxCoord m_x,m_y,m_w,m_h;
145 };
146
147 class pdcDrawLineOp : public pdcOp
148 {
149 public:
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;}
155 protected:
156 wxCoord m_x1,m_y1,m_x2,m_y2;
157 };
158
159 class pdcSetBackgroundModeOp : public pdcOp
160 {
161 public:
162 pdcSetBackgroundModeOp(int mode) {m_mode=mode;}
163 virtual void DrawToDC(wxDC *dc, bool WXUNUSED(grey)=false) {dc->SetBackgroundMode(m_mode);}
164 protected:
165 int m_mode;
166 };
167
168 class pdcDrawTextOp : public pdcOp
169 {
170 public:
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)
175 {m_x+=dx; m_y+=dy;}
176 protected:
177 wxString m_text;
178 wxCoord m_x, m_y;
179 };
180
181 class pdcClearOp : public pdcOp
182 {
183 public:
184 pdcClearOp() {}
185 virtual void DrawToDC(wxDC *dc, bool WXUNUSED(grey)=false) {dc->Clear();}
186 };
187
188 class pdcBeginDrawingOp : public pdcOp
189 {
190 public:
191 pdcBeginDrawingOp() {}
192 virtual void DrawToDC(wxDC *WXUNUSED(dc), bool WXUNUSED(grey)=false) {}
193 };
194
195 class pdcEndDrawingOp : public pdcOp
196 {
197 public:
198 pdcEndDrawingOp() {}
199 virtual void DrawToDC(wxDC *WXUNUSED(dc), bool WXUNUSED(grey)=false) {}
200 };
201
202 class pdcFloodFillOp : public pdcOp
203 {
204 public:
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)
208 {
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);
211 }
212 virtual void Translate(wxCoord dx, wxCoord dy)
213 {m_x+=dx; m_y+=dy;}
214 protected:
215 wxCoord m_x,m_y;
216 wxColour m_col;
217 int m_style;
218 };
219
220 class pdcCrossHairOp : public pdcOp
221 {
222 public:
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)
226 {m_x+=dx; m_y+=dy;}
227 protected:
228 wxCoord m_x,m_y;
229 };
230
231 class pdcDrawArcOp : public pdcOp
232 {
233 public:
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;}
241 protected:
242 wxCoord m_x1,m_x2,m_xc;
243 wxCoord m_y1,m_y2,m_yc;
244 };
245
246 class pdcDrawCheckMarkOp : public pdcOp
247 {
248 public:
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)
255 {m_x+=dx; m_y+=dy;}
256 protected:
257 wxCoord m_x,m_y,m_w,m_h;
258 };
259
260 class pdcDrawEllipticArcOp : public pdcOp
261 {
262 public:
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)
269 {m_x+=dx; m_y+=dy;}
270 protected:
271 wxCoord m_x,m_y,m_w,m_h;
272 double m_sa,m_ea;
273 };
274
275 class pdcDrawPointOp : public pdcOp
276 {
277 public:
278 pdcDrawPointOp(wxCoord x, wxCoord y)
279 {m_x=x; m_y=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)
282 {m_x+=dx; m_y+=dy;}
283 protected:
284 wxCoord m_x,m_y;
285 };
286
287 class pdcDrawRoundedRectangleOp : public pdcOp
288 {
289 public:
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)
296 {m_x+=dx; m_y+=dy;}
297 protected:
298 wxCoord m_x,m_y,m_w,m_h;
299 double m_r;
300 };
301
302 class pdcDrawEllipseOp : public pdcOp
303 {
304 public:
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)
309 {m_x+=dx; m_y+=dy;}
310 protected:
311 wxCoord m_x,m_y,m_w,m_h;
312 };
313
314 class pdcDrawIconOp : public pdcOp
315 {
316 public:
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)
320 {
321 if (grey) dc->DrawIcon(m_greyicon,m_x,m_y);
322 else dc->DrawIcon(m_icon,m_x,m_y);
323 }
324 virtual void CacheGrey() {m_greyicon=GetGreyIcon(m_icon);}
325 virtual void Translate(wxCoord dx, wxCoord dy)
326 {m_x+=dx; m_y+=dy;}
327 protected:
328 wxIcon m_icon;
329 wxIcon m_greyicon;
330 wxCoord m_x,m_y;
331 };
332
333 class pdcDrawLinesOp : public pdcOp
334 {
335 public:
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)
342 {
343 for(int i=0; i<m_n; i++)
344 {
345 m_points[i].x+=dx;
346 m_points[i].y+=dy;
347 }
348 }
349 protected:
350 int m_n;
351 wxPoint *m_points;
352 wxCoord m_xoffset,m_yoffset;
353 };
354
355 class pdcDrawPolygonOp : public pdcOp
356 {
357 public:
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);}
364
365 virtual void Translate(wxCoord dx, wxCoord dy)
366 {
367 for(int i=0; i<m_n; i++)
368 {
369 m_points[i].x+=dx;
370 m_points[i].y+=dy;
371 }
372 }
373 protected:
374 int m_n;
375 wxPoint *m_points;
376 wxCoord m_xoffset,m_yoffset;
377 int m_fillStyle;
378 };
379
380 class pdcDrawPolyPolygonOp : public pdcOp
381 {
382 public:
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)
391 {
392 for(int i=0; i<m_totaln; i++)
393 {
394 m_points[i].x += dx;
395 m_points[i].y += dy;
396 }
397 }
398 protected:
399 int m_n;
400 int m_totaln;
401 int *m_count;
402 wxPoint *m_points;
403 wxCoord m_xoffset, m_yoffset;
404 int m_fillStyle;
405 };
406
407 class pdcDrawRotatedTextOp : public pdcOp
408 {
409 public:
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)
415 {m_x+=dx; m_y+=dy;}
416 protected:
417 wxString m_text;
418 wxCoord m_x,m_y;
419 double m_angle;
420 };
421
422 class pdcDrawBitmapOp : public pdcOp
423 {
424 public:
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)
429 {
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);
432 }
433 virtual void CacheGrey() {m_greybmp=GetGreyBitmap(m_bmp);}
434 virtual void Translate(wxCoord dx, wxCoord dy)
435 {m_x+=dx; m_y+=dy;}
436 protected:
437 wxBitmap m_bmp;
438 wxBitmap m_greybmp;
439 wxCoord m_x,m_y;
440 bool m_useMask;
441 };
442
443 class pdcDrawLabelOp : public pdcOp
444 {
445 public:
446 pdcDrawLabelOp(const wxString& text,
447 const wxBitmap& image,
448 const wxRect& rect,
449 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
450 int indexAccel = -1)
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;}
457 protected:
458 wxString m_text;
459 wxBitmap m_image;
460 wxRect m_rect;
461 int m_align;
462 int m_iAccel;
463 };
464
465 #if wxUSE_SPLINES
466 class pdcDrawSplineOp : public pdcOp
467 {
468 public:
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)
473 {
474 int i;
475 for(i=0; i<m_n; i++)
476 m_points[i].x+=dx; m_points[i].y+=dy;
477 }
478 protected:
479 wxPoint *m_points;
480 int m_n;
481 };
482 #endif // wxUSE_SPLINES
483
484 #if wxUSE_PALETTE
485 class pdcSetPaletteOp : public pdcOp
486 {
487 public:
488 pdcSetPaletteOp(const wxPalette& palette) {m_palette=palette;}
489 virtual void DrawToDC(wxDC *dc, bool WXUNUSED(grey)=false) {dc->SetPalette(m_palette);}
490 protected:
491 wxPalette m_palette;
492 };
493 #endif // wxUSE_PALETTE
494
495 class pdcSetLogicalFunctionOp : public pdcOp
496 {
497 public:
498 pdcSetLogicalFunctionOp(int function) {m_function=function;}
499 virtual void DrawToDC(wxDC *dc, bool WXUNUSED(grey)=false) {dc->SetLogicalFunction(m_function);}
500 protected:
501 int m_function;
502 };
503
504 //----------------------------------------------------------------------------
505 // pdcObject type to contain list of operations for each real (Python) object
506 //----------------------------------------------------------------------------
507 class pdcObject
508 {
509 public:
510 pdcObject(int id)
511 {m_id=id; m_bounded=false; m_oplist.DeleteContents(true);
512 m_greyedout=false;}
513
514 virtual ~pdcObject() {m_oplist.Clear();}
515
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;}
525
526 // Op List Management Methods
527 void Clear() {m_oplist.Clear();}
528 void AddOp(pdcOp *op)
529 {
530 m_oplist.Append(op);
531 if (m_greyedout) op->CacheGrey();
532 }
533 int GetLen() {return m_oplist.GetCount();}
534 virtual void Translate(wxCoord dx, wxCoord dy);
535
536 // Drawing Method
537 virtual void DrawToDC(wxDC *dc);
538 protected:
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
545 };
546
547
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 //----------------------------------------------------------------------------
552 class pdcObjectList;
553 WX_DECLARE_LIST(pdcObject, pdcObjectList);
554
555
556 // ----------------------------------------------------------------------------
557 // wxPseudoDC class
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
566 {
567 public:
568 wxPseudoDC()
569 {m_currId=-1; m_lastObjNode=NULL; m_objectlist.DeleteContents(true);}
570 ~wxPseudoDC();
571 // ------------------------------------------------------------------------
572 // List managment methods
573 //
574 void RemoveAll();
575 int GetLen();
576
577 // ------------------------------------------------------------------------
578 // methods for managing operations by ID
579 //
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);
602
603 // ------------------------------------------------------------------------
604 // Playback Methods
605 //
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
609 // clipping
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);
616
617 // ------------------------------------------------------------------------
618 // Hit Detection Methods
619 //
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)
625
626
627 // ------------------------------------------------------------------------
628 // Methods mirrored from wxDC
629 //
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); }
636
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); }
641
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); }
646
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); }
652
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); }
658
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); }
665
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); }
670
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));}
675
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));}
680
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); }
687
688 void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height,
689 double radius)
690 {AddToList(new pdcDrawRoundedRectangleOp(x,y,width,height,radius));}
691 void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz,
692 double radius)
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); }
696
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); }
701
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); }
708
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); }
713
714 void DrawLines(int n, wxPoint points[],
715 wxCoord xoffset = 0, wxCoord yoffset = 0)
716 {AddToList(new pdcDrawLinesOp(n,points,xoffset,yoffset));}
717
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); }
724
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); }
729
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); }
734
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,
740 const wxRect& rect,
741 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
742 int indexAccel = -1)
743 {AddToList(new pdcDrawLabelOp(text,image,rect,alignment,indexAccel));}
744
745 void DrawLabel(const wxString& text, const wxRect& rect,
746 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
747 int indexAccel = -1)
748 { DrawLabel(text, wxNullBitmap, rect, alignment, indexAccel); }
749
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)
759 {
760 Blit(destPt.x, destPt.y, sz.x, sz.y, source, srcPt.x, srcPt.y,
761 rop, useMask, srcPtMask.x, srcPtMask.y);
762 }
763 ??????*/
764
765 #if wxUSE_SPLINES
766 void DrawSpline(int n, wxPoint points[])
767 {AddToList(new pdcDrawSplineOp(n,points));}
768 #endif // wxUSE_SPLINES
769
770 #if wxUSE_PALETTE
771 void SetPalette(const wxPalette& palette)
772 {AddToList(new pdcSetPaletteOp(palette));}
773 #endif // wxUSE_PALETTE
774
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));}
791
792 void Clear()
793 {AddToList(new pdcClearOp());}
794 void BeginDrawing()
795 {AddToList(new pdcBeginDrawingOp());}
796 void EndDrawing()
797 {AddToList(new pdcEndDrawingOp());}
798
799 protected:
800 // ------------------------------------------------------------------------
801 // protected helper methods
802 void AddToList(pdcOp *newOp);
803 pdcObjectList::Node *FindObjNode(int id, bool create=false);
804
805 // ------------------------------------------------------------------------
806 // Data members
807 //
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
811 };
812
813 #endif
814