1//---------------------------------------------------------------------------
2// This file is generated by wxPython's SIP generator.  Do not edit by hand.
3//
4// Copyright: (c) 2018 by Total Control Software
5// License:   wxWindows License
6//
7// This file will be included by _adv.sip
8//
9//---------------------------------------------------------------------------
10
11%ModuleHeaderCode
12#include "pseudodc.h"
13%End
14
15%ModuleCode
16/////////////////////////////////////////////////////////////////////////////
17// Name:        src/pseudodc.cpp
18// Purpose:     Implementation of the wxPseudoDC classes
19// Author:      Paul Lanier
20// Modified by: Robin Dunn
21//
22// Created:     25-May-2006
23// Copyright:   (c) 2006-2018 Total Control Software
24// Licence:     wxWindows licence
25/////////////////////////////////////////////////////////////////////////////
26
27// For compilers that support precompilation, includes "wx.h".
28//include "wx/wxprec.h"
29
30//#undef DEBUG
31
32// wxList based class definitions
33#include <wx/listimpl.cpp>
34WX_DEFINE_LIST(pdcOpList);
35WX_DEFINE_LIST(pdcObjectList);
36
37//----------------------------------------------------------------------------
38// Helper functions used for drawing greyed out versions of objects
39//----------------------------------------------------------------------------
40wxColour &MakeColourGrey(const wxColour &c)
41{
42    static wxColour rval;
43    rval.Set(byte((230-c.Red())*0.7+c.Red()),
44             byte((230-c.Green())*0.7+c.Green()),
45             byte((230-c.Blue())*0.7+c.Blue()));
46    return rval;
47}
48wxBrush &GetGreyBrush(wxBrush &brush)
49{
50    static wxBrush b;
51    wxColour c;
52    b = brush;
53    c = MakeColourGrey(brush.GetColour());
54    b.SetColour(c);
55    return b;
56}
57
58wxPen &GetGreyPen(wxPen &pen)
59{
60    static wxPen p;
61    wxColour c;
62    p = pen;
63    c = MakeColourGrey(pen.GetColour());
64    p.SetColour(c);
65    return p;
66}
67
68void GreyOutImage(wxImage &img)
69{
70    unsigned char *data = img.GetData();
71    unsigned char r,g,b;
72    unsigned char mr,mg,mb;
73    int i, tst;
74    int len = img.GetHeight()*img.GetWidth()*3;
75    if (img.HasMask())
76    {
77        mr = img.GetMaskRed();
78        mg = img.GetMaskGreen();
79        mb = img.GetMaskBlue();
80    }
81    tst=0;
82    for (i=0;i<len;i+=3)
83    {
84        r=data[i]; g=data[i+1]; b=data[i+2];
85        if (!img.HasMask() ||
86            r!=mr || g!=mg || b!=mb)
87        {
88            if (!tst)
89            {
90                tst=1;
91            }
92            r = (unsigned char)((230.0-r)*0.7+r);
93            g = (unsigned char)((230.0-g)*0.7+g);
94            b = (unsigned char)((230.0-b)*0.7+b);
95            data[i]=r; data[i+1]=g; data[i+2]=b;
96        }
97    }
98}
99
100wxIcon &GetGreyIcon(wxIcon &icon)
101{
102    wxBitmap bmp;
103    bmp.CopyFromIcon(icon);
104    wxImage img = bmp.ConvertToImage();
105    GreyOutImage(img);
106    wxBitmap bmp2(img,32);
107    static wxIcon rval;
108    rval.CopyFromBitmap(bmp2);
109    return rval;
110}
111
112wxBitmap &GetGreyBitmap(wxBitmap &bmp)
113{
114    wxImage img = bmp.ConvertToImage();
115    GreyOutImage(img);
116    static wxBitmap rval(img,32);
117    return rval;
118}
119
120// ============================================================================
121// various pdcOp class implementation methods
122// ============================================================================
123
124// ----------------------------------------------------------------------------
125// pdcDrawPolyPolygonOp
126// ----------------------------------------------------------------------------
127pdcDrawPolyPolygonOp::pdcDrawPolyPolygonOp(int n, int count[], wxPoint points[],
128                 wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle)
129{
130    m_n=n; m_xoffset=xoffset; m_yoffset=yoffset; m_fillStyle=fillStyle;
131    int total_n=0;
132    if (n)
133    {
134        m_count = new int[n];
135        for(int i=0; i<n; i++)
136        {
137            total_n+=count[i];
138            m_count[i]=count[i];
139        }
140        if (total_n)
141        {
142            m_points = new wxPoint[total_n];
143            for(int j=0; j<total_n; j++)
144                m_points[j] = points[j];
145        }
146        else m_points=NULL;
147    }
148    else
149    {
150        m_points=NULL;
151        m_count=NULL;
152    }
153    m_totaln = total_n;
154}
155
156
157pdcDrawPolyPolygonOp::~pdcDrawPolyPolygonOp()
158{
159    if (m_points) delete m_points;
160    if (m_count) delete m_count;
161    m_points=NULL;
162    m_count=NULL;
163}
164
165// ----------------------------------------------------------------------------
166// pdcDrawLinesOp
167// ----------------------------------------------------------------------------
168pdcDrawLinesOp::pdcDrawLinesOp(const wxPointList* points,
169                               wxCoord xoffset,
170                               wxCoord yoffset)
171{
172    m_xoffset = xoffset;
173    m_yoffset = yoffset;
174
175    m_points = new wxPointList;
176    wxPointList::const_iterator iter;
177    for (iter = points->begin(); iter != points->end(); iter++)
178    {
179        // The first * gives us a wxPoint ptr, second * dereferences that ptr
180        m_points->push_back(new wxPoint(**iter));
181    }
182}
183
184
185pdcDrawLinesOp::~pdcDrawLinesOp()
186{
187    m_points->clear();
188    delete m_points;
189    m_points = NULL;
190}
191
192
193void pdcDrawLinesOp::Translate(wxCoord dx, wxCoord dy)
194{
195    wxPointList::const_iterator iter;
196    for (iter = m_points->begin(); iter != m_points->end(); iter++)
197    {
198        (*iter)->x += dx;
199        (*iter)->y += dy;
200    }
201}
202
203// ----------------------------------------------------------------------------
204// pdcDrawPolygonOp
205// ----------------------------------------------------------------------------
206pdcDrawPolygonOp::pdcDrawPolygonOp(const wxPointList* points,
207                                   wxCoord xoffset,
208                                   wxCoord yoffset,
209                                   wxPolygonFillMode fillStyle)
210{
211    m_xoffset = xoffset;
212    m_yoffset = yoffset;
213    m_fillStyle = fillStyle;
214
215    m_points = new wxPointList;
216    wxPointList::const_iterator iter;
217    for (iter = points->begin(); iter != points->end(); ++iter)
218    {
219        // The first * gives us a wxPoint ptr, second * dereferences that ptr
220        m_points->push_back(new wxPoint(**iter));
221    }
222}
223
224
225pdcDrawPolygonOp::~pdcDrawPolygonOp()
226{
227    m_points->clear();
228    delete m_points;
229}
230
231
232void pdcDrawPolygonOp::Translate(wxCoord dx, wxCoord dy)
233{
234    wxPointList::const_iterator iter;
235    for (iter = m_points->begin(); iter != m_points->end(); iter++)
236    {
237        (*iter)->x += dx;
238        (*iter)->y += dy;
239    }
240}
241
242#if wxUSE_SPLINES
243// ----------------------------------------------------------------------------
244// pdcDrawSplineOp
245// ----------------------------------------------------------------------------
246pdcDrawSplineOp::pdcDrawSplineOp(const wxPointList* points)
247{
248    m_points = new wxPointList;
249    wxPointList::const_iterator iter;
250    for (iter = points->begin(); iter != points->end(); iter++)
251    {
252        // The first * gives us a wxPoint ptr, second * dereferences that ptr
253        m_points->push_back(new wxPoint(**iter));
254    }
255}
256
257
258pdcDrawSplineOp::~pdcDrawSplineOp()
259{
260    m_points->clear();
261    delete m_points;
262}
263
264
265void pdcDrawSplineOp::Translate(wxCoord dx, wxCoord dy)
266{
267    wxPointList::const_iterator iter;
268    for (iter = m_points->begin(); iter != m_points->end(); iter++)
269    {
270        (*iter)->x += dx;
271        (*iter)->y += dy;
272    }
273}
274
275#endif // wxUSE_SPLINES
276
277// ============================================================================
278// pdcObject implementation
279// ============================================================================
280
281// ----------------------------------------------------------------------------
282// DrawToDC - play back the op list to the DC
283// ----------------------------------------------------------------------------
284void pdcObject::DrawToDC(wxDC *dc)
285{
286    pdcOpList::compatibility_iterator node = m_oplist.GetFirst();
287    while(node)
288    {
289        node->GetData()->DrawToDC(dc, m_greyedout);
290        node = node->GetNext();
291    }
292}
293
294// ----------------------------------------------------------------------------
295// Translate - translate all the operations by some dx,dy
296// ----------------------------------------------------------------------------
297void pdcObject::Translate(wxCoord dx, wxCoord dy)
298{
299    pdcOpList::compatibility_iterator node = m_oplist.GetFirst();
300    while(node)
301    {
302        node->GetData()->Translate(dx,dy);
303        node = node->GetNext();
304    }
305    if (m_bounded)
306    {
307        m_bounds.x += dx;
308        m_bounds.y += dy;
309    }
310}
311
312// ----------------------------------------------------------------------------
313// SetGreyedOut - set the greyout member and cache grey versions of everything
314// if greyout is true
315// ----------------------------------------------------------------------------
316void pdcObject::SetGreyedOut(bool greyout)
317{
318    m_greyedout=greyout;
319    if (greyout)
320    {
321        pdcOpList::compatibility_iterator node = m_oplist.GetFirst();
322        pdcOp *obj;
323        while(node)
324        {
325            obj = node->GetData();
326            obj->CacheGrey();
327            node = node->GetNext();
328        }
329    }
330}
331
332// ============================================================================
333// wxPseudoDC implementation
334// ============================================================================
335
336// ----------------------------------------------------------------------------
337// Destructor
338// ----------------------------------------------------------------------------
339wxPseudoDC::~wxPseudoDC()
340{
341    // delete all the nodes in the list
342    RemoveAll();
343
344}
345
346// ----------------------------------------------------------------------------
347// ClearAll - remove all nodes from list
348// ----------------------------------------------------------------------------
349void wxPseudoDC::RemoveAll(void)
350{
351    m_objectlist.Clear();
352    m_objectIndex.clear();
353    m_currId = -1;
354    m_lastObject = NULL;
355
356}
357
358// ----------------------------------------------------------------------------
359// GetLen - return the number of operations in the current op list
360// ----------------------------------------------------------------------------
361int wxPseudoDC::GetLen(void)
362{
363    pdcObjectList::compatibility_iterator pt = m_objectlist.GetFirst();
364    int len=0;
365    while (pt)
366    {
367        len += pt->GetData()->GetLen();
368        pt = pt->GetNext();
369    }
370    return len;
371}
372
373// ----------------------------------------------------------------------------
374// FindObject - find and return an object node by id.  If node doesn't exist
375//               and create is true then create one and return it.  Otherwise
376//               return NULL.
377// ----------------------------------------------------------------------------
378pdcObject *wxPseudoDC::FindObject(int id, bool create)
379{
380    // see if last operation was for same id
381    //~ if (m_lastObject && m_lastObject->GetId() == id)
382        //~ return m_lastObject;
383    // if not then search for it
384    pdcObjectHash::iterator lookup = m_objectIndex.find(id);
385    if (lookup == m_objectIndex.end()) {//not found
386        if (create) {
387            m_lastObject = new pdcObject(id);
388            m_objectlist.Append(m_lastObject);
389            pdcObjectHash::value_type insert(id, m_lastObject);
390            m_objectIndex.insert(insert);
391            return m_lastObject;
392        } else {
393            return NULL;
394        }
395    } else { //found
396        return lookup->second;
397    }
398}
399
400// ----------------------------------------------------------------------------
401// AddToList - Add a node to the list at the end (preserve draw order)
402// ----------------------------------------------------------------------------
403void wxPseudoDC::AddToList(pdcOp *newOp)
404{
405    pdcObject *obj = FindObject(m_currId, true);
406    obj->AddOp(newOp);
407}
408
409// ----------------------------------------------------------------------------
410// ClearID - remove all the operations associated with a single ID
411// ----------------------------------------------------------------------------
412void wxPseudoDC::ClearId(int id)
413{
414    pdcObject *obj = FindObject(id);
415    if (obj) obj->Clear();
416}
417
418// ----------------------------------------------------------------------------
419// RemoveID - Remove the object node (and all operations) associated with an id
420// ----------------------------------------------------------------------------
421void wxPseudoDC::RemoveId(int id)
422{
423    pdcObject *obj = FindObject(id);
424    if (obj)
425    {
426        if (m_lastObject == obj)
427            m_lastObject = obj;
428        m_objectlist.DeleteObject(obj);
429    }
430    m_objectIndex.erase(id);
431}
432
433// ----------------------------------------------------------------------------
434// SetIdBounds - Set the bounding rect for a given id
435// ----------------------------------------------------------------------------
436void wxPseudoDC::SetIdBounds(int id, wxRect& rect)
437{
438    pdcObject *obj = FindObject(id, true);
439    obj->SetBounds(rect);
440}
441
442// ----------------------------------------------------------------------------
443// GetIdBounds - Get the bounding rect for a given id
444// ----------------------------------------------------------------------------
445wxRect wxPseudoDC::GetIdBounds(int id)
446{
447    wxRect rect;
448
449    pdcObject *obj = FindObject(id);
450    if (obj && obj->IsBounded())
451        rect = obj->GetBounds();
452    else
453        rect.x = rect.y = rect.width = rect.height = 0;
454    return rect;
455}
456
457// ----------------------------------------------------------------------------
458// TranslateId - Translate all the operations of a single id
459// ----------------------------------------------------------------------------
460void wxPseudoDC::TranslateId(int id, wxCoord dx, wxCoord dy)
461{
462    pdcObject *obj = FindObject(id);
463    if (obj) obj->Translate(dx,dy);
464}
465
466// ----------------------------------------------------------------------------
467// DrawIdToDC - Draw a specific id to the dc passed in
468// ----------------------------------------------------------------------------
469void wxPseudoDC::DrawIdToDC(int id, wxDC *dc)
470{
471    pdcObject *obj = FindObject(id);
472    if (obj) obj->DrawToDC(dc);
473}
474
475// ----------------------------------------------------------------------------
476// SetIdGreyedOut - Set the greyedout member of id
477// ----------------------------------------------------------------------------
478void wxPseudoDC::SetIdGreyedOut(int id, bool greyout)
479{
480    pdcObject *obj = FindObject(id);
481    if (obj) obj->SetGreyedOut(greyout);
482}
483
484// ----------------------------------------------------------------------------
485// GetIdGreyedOut - Get the greyedout member of id
486// ----------------------------------------------------------------------------
487bool wxPseudoDC::GetIdGreyedOut(int id)
488{
489    pdcObject *obj = FindObject(id);
490    if (obj) return obj->GetGreyedOut();
491    else return false;
492}
493
494// ----------------------------------------------------------------------------
495// FindObjectsByBBox - Return a list of all the ids whose bounding boxes
496//                     contain (x,y)
497// ----------------------------------------------------------------------------
498PyObject *wxPseudoDC::FindObjectsByBBox(wxCoord x, wxCoord y)
499{
500    //wxPyBlock_t blocked = wxPyBeginBlockThreads();
501    pdcObjectList::compatibility_iterator pt = m_objectlist.GetFirst();
502    pdcObject *obj;
503    PyObject* pyList = NULL;
504    pyList = PyList_New(0);
505    wxRect r;
506    while (pt)
507    {
508        obj = pt->GetData();
509        r = obj->GetBounds();
510        if (obj->IsBounded() && r.Contains(x,y))
511        {
512            PyObject* pyObj = wxPyInt_FromLong((long)obj->GetId());
513            PyList_Insert(pyList, 0, pyObj);
514            Py_DECREF(pyObj);
515        }
516        pt = pt->GetNext();
517    }
518    //wxPyEndBlockThreads(blocked);
519    return pyList;
520}
521
522// ----------------------------------------------------------------------------
523// FindObjects - Return a list of all the ids that draw to (x,y)
524// ----------------------------------------------------------------------------
525PyObject *wxPseudoDC::FindObjects(wxCoord x, wxCoord y,
526                                  wxCoord radius, const wxColor& bg)
527{
528    //wxPyBlock_t blocked = wxPyBeginBlockThreads();
529    pdcObjectList::compatibility_iterator pt = m_objectlist.GetFirst();
530    pdcObject *obj;
531    PyObject* pyList = NULL;
532    pyList = PyList_New(0);
533    wxBrush bgbrush(bg);
534    wxPen bgpen(bg);
535    // special case radius = 0
536    if (radius == 0)
537    {
538        wxBitmap bmp(4,4,24);
539        wxMemoryDC memdc;
540        wxColor pix;
541        wxRect viewrect(x-2,y-2,4,4);
542        // setup the memdc for rendering
543        memdc.SelectObject(bmp);
544        memdc.SetBackground(bgbrush);
545        memdc.Clear();
546        memdc.SetDeviceOrigin(2-x,2-y);
547        while (pt)
548        {
549            obj = pt->GetData();
550            if (obj->IsBounded() && obj->GetBounds().Contains(x,y))
551            {
552                // start clean
553                memdc.SetBrush(bgbrush);
554                memdc.SetPen(bgpen);
555                memdc.DrawRectangle(viewrect);
556                // draw the object
557                obj->DrawToDC(&memdc);
558                memdc.GetPixel(x,y,&pix);
559                // clear and update rgn2
560                if (pix != bg)
561                {
562                    PyObject* pyObj = wxPyInt_FromLong((long)obj->GetId());
563                    PyList_Insert(pyList, 0, pyObj);
564                    Py_DECREF(pyObj);
565                }
566            }
567            pt = pt->GetNext();
568        }
569        memdc.SelectObject(wxNullBitmap);
570    }
571    else
572    {
573        wxRect viewrect(x-radius,y-radius,2*radius,2*radius);
574        wxBitmap maskbmp(2*radius,2*radius,24);
575        wxMemoryDC maskdc;
576        // create bitmap with circle for masking
577        maskdc.SelectObject(maskbmp);
578        maskdc.SetBackground(*wxBLACK_BRUSH);
579        maskdc.Clear();
580        maskdc.SetBrush(*wxWHITE_BRUSH);
581        maskdc.SetPen(*wxWHITE_PEN);
582        maskdc.DrawCircle(radius,radius,radius);
583        // now setup a memdc for rendering our object
584        wxBitmap bmp(2*radius,2*radius,24);
585        wxMemoryDC memdc;
586        memdc.SelectObject(bmp);
587        // set the origin so (x,y) is in the bmp center
588        memdc.SetDeviceOrigin(radius-x,radius-y);
589        // a region will be used to see if the result is empty
590        wxRegion rgn2;
591        while (pt)
592        {
593            obj = pt->GetData();
594            if (obj->IsBounded() && viewrect.Intersects(obj->GetBounds()))
595            {
596                // start clean
597                //memdc.Clear();
598                memdc.SetBrush(bgbrush);
599                memdc.SetPen(bgpen);
600                memdc.DrawRectangle(viewrect);
601                // draw the object
602                obj->DrawToDC(&memdc);
603                // remove background color
604                memdc.SetLogicalFunction(wxXOR);
605                memdc.SetBrush(bgbrush);
606                memdc.SetPen(bgpen);
607                memdc.DrawRectangle(viewrect);
608                memdc.SetLogicalFunction(wxCOPY);
609                memdc.Blit(x-radius,y-radius,2*radius,2*radius,&maskdc,0,0,wxCOPY);
610                // clear and update rgn2
611                memdc.SelectObject(wxNullBitmap);
612                rgn2.Clear();
613                rgn2.Union(bmp, *wxBLACK);
614                //rgn2.Intersect(rgn);
615                memdc.SelectObject(bmp);
616                if (!rgn2.IsEmpty())
617                {
618                    PyObject* pyObj = wxPyInt_FromLong((long)obj->GetId());
619                    PyList_Insert(pyList, 0, pyObj);
620                    Py_DECREF(pyObj);
621                }
622            }
623            pt = pt->GetNext();
624        }
625        maskdc.SelectObject(wxNullBitmap);
626        memdc.SelectObject(wxNullBitmap);
627    }
628    //wxPyEndBlockThreads(blocked);
629    return pyList;
630}
631
632// ----------------------------------------------------------------------------
633// DrawToDCClipped - play back the op list to the DC but clip any objects
634//                   known to be not in rect.  This is a coarse level of
635//                   clipping to speed things up when lots of objects are off
636//                   screen and doesn't affect the dc level clipping
637// ----------------------------------------------------------------------------
638void wxPseudoDC::DrawToDCClipped(wxDC *dc, const wxRect& rect)
639{
640    pdcObjectList::compatibility_iterator pt = m_objectlist.GetFirst();
641    pdcObject *obj;
642    while (pt)
643    {
644        obj = pt->GetData();
645        if (!obj->IsBounded() || rect.Intersects(obj->GetBounds()))
646            obj->DrawToDC(dc);
647        pt = pt->GetNext();
648    }
649}
650void wxPseudoDC::DrawToDCClippedRgn(wxDC *dc, const wxRegion& region)
651{
652    pdcObjectList::compatibility_iterator pt = m_objectlist.GetFirst();
653    pdcObject *obj;
654    while (pt)
655    {
656        obj = pt->GetData();
657        if (!obj->IsBounded() ||
658            (region.Contains(obj->GetBounds()) != wxOutRegion))
659            obj->DrawToDC(dc);
660        pt = pt->GetNext();
661    }
662}
663
664// ----------------------------------------------------------------------------
665// DrawToDC - play back the op list to the DC
666// ----------------------------------------------------------------------------
667void wxPseudoDC::DrawToDC(wxDC *dc)
668{
669    pdcObjectList::compatibility_iterator pt = m_objectlist.GetFirst();
670    while (pt)
671    {
672        pt->GetData()->DrawToDC(dc);
673        pt = pt->GetNext();
674    }
675}
676
677
678%End
679
680//---------------------------------------------------------------------------
681
682class wxPseudoDC : wxObject
683{
684    %Docstring
685        PseudoDC()
686
687        A PseudoDC is an object that can be used much like real
688        :class:`wx.DC`, however it provides some additional features for
689        object recording and manipulation beyond what a ``wx.DC`` can
690        provide.
691
692        All commands issued to the ``PseudoDC`` are stored in a list.  You
693        can then play these commands back to a real DC object as often as
694        needed, using the :meth:`DrawToDC` method or one of the similar
695        methods.  Commands in the command list can be tagged by an ID. You
696        can use this ID to clear the operations associated with a single
697        ID, redraw the objects associated with that ID, grey them, adjust
698        their position, etc.
699    %End
700public:
701    wxPseudoDC();
702
703    ~wxPseudoDC();
704
705    void RemoveAll();
706    %Docstring
707        RemoveAll()
708
709        Removes all objects and operations from the recorded list.
710    %End
711
712    int GetLen();
713    %Docstring
714        GetLen() -> int
715
716        Returns the number of operations in the recorded list.
717    %End
718
719    void SetId(
720        int id
721    );
722    %Docstring
723        SetId(id)
724
725        Sets the id to be associated with subsequent operations.
726    %End
727
728    void ClearId(
729        int id
730    );
731    %Docstring
732        ClearId(id)
733
734        Removes all operations associated with id so the object can be
735        redrawn.
736    %End
737
738    void RemoveId(
739        int id
740    );
741    %Docstring
742        RemoveId(id)
743
744        Remove the object node (and all operations) associated with an id.
745    %End
746
747    void TranslateId(
748        int id,
749        wxCoord dx,
750        wxCoord dy
751    );
752    %Docstring
753        TranslateId(id, dx, dy)
754
755        Translate the position of the operations of tag `id` by (`dx`, `dy`).
756    %End
757
758    void SetIdGreyedOut(
759        int id,
760        bool greyout
761    );
762    %Docstring
763        SetIdGreyedOut(id, greyout)
764
765        Set whether the set of objects with tag `id` are drawn greyed out or
766        not.
767    %End
768
769    bool GetIdGreyedOut(
770        int id
771    );
772    %Docstring
773        GetIdGreyedOut(id) -> bool
774
775        Get whether the set of objects with tag `id` are drawn greyed out or
776        not.
777    %End
778
779    PyObject* FindObjects(
780        wxCoord x,
781        wxCoord y,
782        wxCoord radius = 1,
783        const wxColour & bg = *wxWHITE
784    );
785    %Docstring
786        FindObjects(x, y, radius=1, bg=wx.WHITE) -> PyObject
787
788        Returns a list of all the id's that draw a pixel with
789        color not equal to bg within radius of (x,y). Returns an
790        empty list if nothing is found.  The list is in reverse
791        drawing order so list[0] is the top id.
792    %End
793
794    PyObject* FindObjectsByBBox(
795        wxCoord x,
796        wxCoord y
797    );
798    %Docstring
799        FindObjectsByBBox(x, y) -> PyObject
800
801        Returns a list of all the id's whose bounding boxes include (x,y).
802        Returns an empty list if nothing is found.  The list is in
803        reverse drawing order so list[0] is the top id.
804    %End
805
806    void DrawIdToDC(
807        int id,
808        wxDC * dc
809    );
810    %Docstring
811        DrawIdToDC(id, dc)
812
813        Draw recorded operations tagged with id to dc.
814    %End
815
816    void SetIdBounds(
817        int id,
818        wxRect & rect
819    );
820    %Docstring
821        SetIdBounds(id, rect)
822
823        Set the bounding rect of a given object.
824        This will create an object node if one doesn't exist.
825    %End
826
827    wxRect GetIdBounds(
828        int id
829    );
830    %Docstring
831        GetIdBounds(id) -> wx.Rect
832
833        Returns the bounding rectangle previously set with `SetIdBounds`.
834        If no bounds have been set, it returns wx.Rect(0,0,0,0).
835    %End
836
837    void DrawToDCClipped(
838        wxDC * dc,
839        const wxRect & rect
840    );
841    %Docstring
842        DrawToDCClipped(dc, rect)
843
844        Draws the recorded operations to dc,
845        unless the operation is known to be outside of rect.
846    %End
847
848    void DrawToDCClippedRgn(
849        wxDC * dc,
850        const wxRegion & region
851    );
852    %Docstring
853        DrawToDCClippedRgn(dc, region)
854
855        Draws the recorded operations to dc,
856        unless the operation is known to be outside the given region.
857    %End
858
859    void DrawToDC(
860        wxDC * dc
861    );
862    %Docstring
863        DrawToDC(dc)
864
865        Draws the recorded operations to dc.
866    %End
867
868    void FloodFill(
869        wxCoord x,
870        wxCoord y,
871        const wxColour & col,
872        wxFloodFillStyle style = wxFLOOD_SURFACE
873    );
874    %Docstring
875        FloodFill(x, y, col, style=wx.FLOOD_SURFACE)
876        FloodFill(pt, col, style=wx.FLOOD_SURFACE)
877
878        Flood fills the device context starting from the given point,
879        using the current brush colour, and using a style:
880
881            - ``wx.FLOOD_SURFACE``: the flooding occurs until a colour other
882        than the given colour is encountered.
883
884            - ``wx.FLOOD_BORDER``: the area to be flooded is bounded by the
885        given colour.
886    %End
887
888    void FloodFill(
889        const wxPoint & pt,
890        const wxColour & col,
891        wxFloodFillStyle style = wxFLOOD_SURFACE
892    );
893
894    void DrawLine(
895        wxCoord x1,
896        wxCoord y1,
897        wxCoord x2,
898        wxCoord y2
899    );
900    %Docstring
901        DrawLine(x1, y1, x2, y2)
902        DrawLine(pt1, pt2)
903
904        Draws a line from the first point to the second.
905        The current pen is used for drawing the line. Note that
906        the second point is *not* part of the line and is not
907        drawn by this function (this is consistent with the
908        behaviour of many other toolkits).
909    %End
910
911    void DrawLine(
912        const wxPoint & pt1,
913        const wxPoint & pt2
914    );
915
916    void CrossHair(
917        wxCoord x,
918        wxCoord y
919    );
920    %Docstring
921        CrossHair(x, y)
922        CrossHair(pt)
923
924        Displays a cross hair using the current pen. This is a
925        vertical and horizontal line the height and width of the
926        window, centred on the given point.
927    %End
928
929    void CrossHair(
930        const wxPoint & pt
931    );
932
933    void DrawArc(
934        wxCoord x1,
935        wxCoord y1,
936        wxCoord x2,
937        wxCoord y2,
938        wxCoord xc,
939        wxCoord yc
940    );
941    %Docstring
942        DrawArc(x1, y1, x2, y2, xc, yc)
943
944        Draws an arc of a circle, centred on the *center* point
945        (xc, yc), from the first point to the second. The current
946        pen is used for the outline and the current brush for
947        filling the shape.
948
949        The arc is drawn in an anticlockwise direction from the
950        start point to the end point.
951    %End
952
953    void DrawCheckMark(
954        wxCoord x,
955        wxCoord y,
956        wxCoord width,
957        wxCoord height
958    );
959    %Docstring
960        DrawCheckMark(x, y, width, height)
961        DrawCheckMark(rect)
962
963        Draws a check mark inside the given rectangle
964    %End
965
966    void DrawCheckMark(
967        const wxRect & rect
968    );
969
970    void DrawEllipticArc(
971        wxCoord x,
972        wxCoord y,
973        wxCoord w,
974        wxCoord h,
975        double start,
976        double end
977    );
978    %Docstring
979        DrawEllipticArc(x, y, w, h, start, end)
980        DrawEllipticArc(pt, sz, start, end)
981
982        Draws an arc of an ellipse, with the given rectangle
983        defining the bounds of the ellipse. The current pen is
984        used for drawing the arc and the current brush is used for
985        drawing the pie.
986
987        The *start* and *end* parameters specify the start and end
988        of the arc relative to the three-o'clock position from the
989        center of the rectangle. Angles are specified in degrees
990        (360 is a complete circle). Positive values mean
991        counter-clockwise motion. If start is equal to end, a
992        complete ellipse will be drawn.
993    %End
994
995    void DrawEllipticArc(
996        const wxPoint & pt,
997        const wxSize & sz,
998        double start,
999        double end
1000    );
1001
1002    void DrawPoint(
1003        wxCoord x,
1004        wxCoord y
1005    );
1006    %Docstring
1007        DrawPoint(x, y)
1008        DrawPoint(pt)
1009
1010        Draws a point using the current pen.
1011    %End
1012
1013    void DrawPoint(
1014        const wxPoint & pt
1015    );
1016
1017    void DrawRectangle(
1018        wxCoord x,
1019        wxCoord y,
1020        wxCoord width,
1021        wxCoord height
1022    );
1023    %Docstring
1024        DrawRectangle(x, y, width, height)
1025        DrawRectangle(rect)
1026        DrawRectangle(pt, sz)
1027
1028        Draws a rectangle with the given top left corner, and with
1029        the given size. The current pen is used for the outline
1030        and the current brush for filling the shape.
1031    %End
1032
1033    void DrawRectangle(
1034        const wxRect & rect
1035    );
1036
1037    void DrawRectangle(
1038        const wxPoint & pt,
1039        const wxSize & sz
1040    );
1041
1042    void DrawRoundedRectangle(
1043        wxCoord x,
1044        wxCoord y,
1045        wxCoord width,
1046        wxCoord height,
1047        double radius
1048    );
1049    %Docstring
1050        DrawRoundedRectangle(x, y, width, height, radius)
1051        DrawRoundedRectangle(rect, radius)
1052        DrawRoundedRectangle(pt, sz, radius)
1053
1054        Draws a rectangle with the given top left corner, and with
1055        the given size. The current pen is used for the outline
1056        and the current brush for filling the shape.
1057    %End
1058
1059    void DrawRoundedRectangle(
1060        const wxRect & rect,
1061        double radius
1062    );
1063
1064    void DrawRoundedRectangle(
1065        const wxPoint & pt,
1066        const wxSize & sz,
1067        double radius
1068    );
1069
1070    void DrawCircle(
1071        wxCoord x,
1072        wxCoord y,
1073        wxCoord radius
1074    );
1075    %Docstring
1076        DrawCircle(x, y, radius)
1077        DrawCircle(pt, radius)
1078
1079        Draws a circle with the given center point and radius.
1080        The current pen is used for the outline and the current
1081        brush for filling the shape.
1082
1083        :see: `DrawEllipse`
1084    %End
1085
1086    void DrawCircle(
1087        const wxPoint & pt,
1088        wxCoord radius
1089    );
1090
1091    void DrawEllipse(
1092        wxCoord x,
1093        wxCoord y,
1094        wxCoord width,
1095        wxCoord height
1096    );
1097    %Docstring
1098        DrawEllipse(x, y, width, height)
1099        DrawEllipse(rect)
1100        DrawEllipse(pt, sz)
1101
1102        Draws an ellipse contained in the specified rectangle. The current pen
1103        is used for the outline and the current brush for filling the shape.",
1104        "
1105
1106        :see: `DrawCircle`
1107    %End
1108
1109    void DrawEllipse(
1110        const wxRect & rect
1111    );
1112
1113    void DrawEllipse(
1114        const wxPoint & pt,
1115        const wxSize & sz
1116    );
1117
1118    void DrawIcon(
1119        const wxIcon & icon,
1120        wxCoord x,
1121        wxCoord y
1122    );
1123    %Docstring
1124        DrawIcon(icon, x, y)
1125        DrawIcon(icon, pt)
1126
1127        Draw an icon on the display at the given position.
1128    %End
1129
1130    void DrawIcon(
1131        const wxIcon & icon,
1132        const wxPoint & pt
1133    );
1134
1135    void DrawBitmap(
1136        const wxBitmap & bmp,
1137        wxCoord x,
1138        wxCoord y,
1139        bool useMask = false
1140    );
1141    %Docstring
1142        DrawBitmap(bmp, x, y, useMask=False)
1143        DrawBitmap(bmp, pt, useMask=False)
1144
1145        Draw a bitmap on the device context at the specified
1146        point. If *useMask* is true and the bitmap has a
1147        transparency mask, (or alpha channel on the platforms that
1148        support it) then the bitmap will be drawn transparently.
1149
1150        When drawing a mono-bitmap, the current text foreground
1151        colour will be used to draw the foreground of the bitmap
1152        (all bits set to 1), and the current text background
1153        colour to draw the background (all bits set to 0).
1154
1155        :see: `SetTextForeground`, `SetTextBackground` and `wx.MemoryDC`
1156    %End
1157
1158    void DrawBitmap(
1159        const wxBitmap & bmp,
1160        const wxPoint & pt,
1161        bool useMask = false
1162    );
1163
1164    void DrawText(
1165        const wxString & text,
1166        wxCoord x,
1167        wxCoord y
1168    );
1169    %Docstring
1170        DrawText(text, x, y)
1171        DrawText(text, pt)
1172
1173        Draws a text string at the specified point, using the
1174        current text font, and the current text foreground and
1175        background colours.
1176
1177        The coordinates refer to the top-left corner of the
1178        rectangle bounding the string. See `wx.DC.GetTextExtent`
1179        for how to get the dimensions of a text string, which can
1180        be used to position the text more precisely, (you will
1181        need to use a real DC with GetTextExtent as wx.PseudoDC
1182        does not implement it.)
1183
1184        **NOTE**: under wxGTK the current logical function is used
1185        *by this function but it is ignored by wxMSW. Thus, you
1186        *should avoid using logical functions with this function
1187        *in portable programs.", "
1188
1189        :see: `DrawRotatedText`
1190    %End
1191
1192    void DrawText(
1193        const wxString & text,
1194        const wxPoint & pt
1195    );
1196
1197    void DrawRotatedText(
1198        const wxString & text,
1199        wxCoord x,
1200        wxCoord y,
1201        double angle
1202    );
1203    %Docstring
1204        DrawRotatedText(text, x, y, angle)
1205        DrawRotatedText(text, pt, angle)
1206
1207        Draws the text rotated by *angle* degrees, if supported by the
1208        platform.
1209    %End
1210
1211    void DrawRotatedText(
1212        const wxString & text,
1213        const wxPoint & pt,
1214        double angle
1215    );
1216
1217    void DrawLabel(
1218        const wxString & text,
1219        const wxRect & rect,
1220        int alignment = wxALIGN_LEFT|wxALIGN_TOP,
1221        int indexAccel = -1
1222    );
1223    %Docstring
1224        DrawLabel(text, rect, alignment=wx.ALIGN_LEFT|wx.ALIGN_TOP, indexAccel=-1)
1225        DrawLabel(text, image, rect, alignment=wx.ALIGN_LEFT|wx.ALIGN_TOP, indexAccel=-1)
1226
1227        Draw *text* within the specified rectangle, abiding by the
1228        alignment flags.  Will additionally emphasize the
1229        character at *indexAccel* if it is not -1.
1230    %End
1231
1232    void DrawLabel(
1233        const wxString & text,
1234        const wxBitmap & image,
1235        const wxRect & rect,
1236        int alignment = wxALIGN_LEFT|wxALIGN_TOP,
1237        int indexAccel = -1
1238    );
1239
1240    void Clear();
1241    %Docstring
1242        Clear()
1243
1244        Clears the device context using the current background brush.
1245    %End
1246
1247    void SetFont(
1248        const wxFont & font
1249    );
1250    %Docstring
1251        SetFont(font)
1252
1253        Sets the current font for the DC. It must be a valid font, in
1254        particular you should not pass ``wx.NullFont`` to this method.
1255
1256        :see: `wx.Font`
1257    %End
1258
1259    void SetPen(
1260        const wxPen & pen
1261    );
1262    %Docstring
1263        SetPen(pen)
1264
1265        Sets the current pen for the DC.
1266
1267        If the argument is ``wx.NullPen``, the current pen is selected out of
1268        the
1269        device context, and the original pen restored.
1270
1271        :see: `wx.Pen`
1272    %End
1273
1274    void SetBrush(
1275        const wxBrush & brush
1276    );
1277    %Docstring
1278        SetBrush(brush)
1279
1280        Sets the current brush for the DC.
1281
1282        If the argument is ``wx.NullBrush``, the current brush is selected out
1283        of the device context, and the original brush restored, allowing the
1284        current brush to be destroyed safely.
1285
1286        :see: `wx.Brush`
1287    %End
1288
1289    void SetBackground(
1290        const wxBrush & brush
1291    );
1292    %Docstring
1293        SetBackground(brush)
1294
1295        Sets the current background brush for the DC.
1296    %End
1297
1298    void SetBackgroundMode(
1299        int mode
1300    );
1301    %Docstring
1302        SetBackgroundMode(mode)
1303
1304        The *mode* parameter may be one of ``wx.SOLID`` and
1305        ``wx.TRANSPARENT``. This setting determines whether text
1306        will be drawn with a background colour or not.
1307    %End
1308
1309    void SetTextForeground(
1310        const wxColour & colour
1311    );
1312    %Docstring
1313        SetTextForeground(colour)
1314
1315        Sets the current text foreground colour for the DC.
1316    %End
1317
1318    void SetTextBackground(
1319        const wxColour& colour
1320    );
1321    %Docstring
1322        SetTextBackground(colour)
1323
1324        Sets the current text background colour for the DC.
1325    %End
1326
1327    void SetLogicalFunction(
1328        wxRasterOperationMode function
1329    );
1330    %Docstring
1331        SetLogicalFunction(function)
1332
1333        Sets the current logical function for the device context. This
1334        determines how a source pixel (from a pen or brush colour, combines
1335        with a destination pixel in the current device context.
1336
1337        The possible values and their meaning in terms of source and
1338        destination pixel values are defined in the
1339        :ref:`wx.RasterOperationMode`
1340        enumeration.
1341
1342        The default is wx.COPY, which simply draws with the current
1343        colour. The others combine the current colour and the background using
1344        a logical operation. wx.INVERT is commonly used for drawing rubber
1345        bands or moving outlines, since drawing twice reverts to the original
1346        colour.
1347    %End
1348
1349    void DrawLines(
1350        const wxPointList * points,
1351        wxCoord xoffset = 0,
1352        wxCoord yoffset = 0
1353    );
1354    %Docstring
1355        DrawLines(points, xoffset=0, yoffset=0)
1356
1357        Draws lines using a sequence of `wx.Point` objects, adding the
1358        optional offset coordinate. The current pen is used for drawing the
1359        lines.
1360    %End
1361
1362    void DrawPolygon(
1363        const wxPointList * points,
1364        wxCoord xoffset = 0,
1365        wxCoord yoffset = 0,
1366        wxPolygonFillMode fillStyle = wxODDEVEN_RULE
1367    );
1368    %Docstring
1369        DrawPolygon(points, xoffset=0, yoffset=0, fillStyle=wx.ODDEVEN_RULE)
1370
1371        Draws a filled polygon using a sequence of `wx.Point` objects, adding
1372        the optional offset coordinate.  The last argument specifies the fill
1373        rule: ``wx.ODDEVEN_RULE`` (the default) or ``wx.WINDING_RULE``.
1374
1375        The current pen is used for drawing the outline, and the current brush
1376        for filling the shape. Using a transparent brush suppresses
1377        filling. Note that wxWidgets automatically closes the first and last
1378        points.
1379    %End
1380
1381    void DrawSpline(
1382        const wxPointList * points
1383    );
1384    %Docstring
1385        DrawSpline(points)
1386
1387        Draws a spline between all given control points, (a list of `wx.Point`
1388        objects) using the current pen. The spline is drawn using a series of
1389        lines, using an algorithm taken from the X drawing program 'XFIG'.
1390    %End
1391
1392    public:
1393
1394
1395    %Property(name=Len, get=GetLen)
1396};  // end of class wxPseudoDC
1397
1398
1399%Extract(id=pycode_adv)
1400PseudoDC.BeginDrawing = wx.deprecated(lambda *args: None, 'BeginDrawing has been removed.')
1401PseudoDC.EndDrawing = wx.deprecated(lambda *args: None, 'EndDrawing has been removed.')
1402PseudoDC.FloodFillPoint = wx.deprecated(PseudoDC.FloodFill, 'Use FloodFill instead.')
1403PseudoDC.DrawLinePoint = wx.deprecated(PseudoDC.DrawLine, 'Use DrawLine instead.')
1404PseudoDC.CrossHairPoint = wx.deprecated(PseudoDC.CrossHair, 'Use CrossHair instead.')
1405PseudoDC.DrawArcPoint = wx.deprecated(PseudoDC.DrawArc, 'Use DrawArc instead.')
1406PseudoDC.DrawCheckMarkRect = wx.deprecated(PseudoDC.DrawCheckMark, 'Use DrawArc instead.')
1407PseudoDC.DrawEllipticArcPointSize = wx.deprecated(PseudoDC.DrawEllipticArc, 'Use DrawEllipticArc instead.')
1408PseudoDC.DrawPointPoint = wx.deprecated(PseudoDC.DrawPoint, 'Use DrawPoint instead.')
1409PseudoDC.DrawRectangleRect = wx.deprecated(PseudoDC.DrawRectangle, 'Use DrawRectangle instead.')
1410PseudoDC.DrawRectanglePointSize = wx.deprecated(PseudoDC.DrawRectangle, 'Use DrawRectangle instead.')
1411PseudoDC.DrawRoundedRectangleRect = wx.deprecated(PseudoDC.DrawRoundedRectangle, 'Use DrawRectangle instead.')
1412PseudoDC.DrawRoundedRectanglePointSize = wx.deprecated(PseudoDC.DrawRoundedRectangle, 'Use DrawRectangle instead.')
1413PseudoDC.DrawCirclePoint = wx.deprecated(PseudoDC.DrawCircle, 'Use DrawCircle instead.')
1414PseudoDC.DrawEllipseRect = wx.deprecated(PseudoDC.DrawEllipse, 'Use DrawEllipse instead.')
1415PseudoDC.DrawEllipsePointSize = wx.deprecated(PseudoDC.DrawEllipse, 'Use DrawEllipse instead.')
1416PseudoDC.DrawIconPoint = wx.deprecated(PseudoDC.DrawIcon, 'Use DrawIcon instead.')
1417PseudoDC.DrawBitmapPoint = wx.deprecated(PseudoDC.DrawBitmap, 'Use DrawBitmap instead.')
1418PseudoDC.DrawTextPoint = wx.deprecated(PseudoDC.DrawText, 'Use DrawText instead.')
1419PseudoDC.DrawRotatedTextPoint = wx.deprecated(PseudoDC.DrawRotatedText, 'Use DrawRotatedText instead.')
1420PseudoDC.DrawImageLabel = wx.deprecated(PseudoDC.DrawLabel, 'Use DrawLabel instead.')
1421
1422%End
1423
1424
1425//---------------------------------------------------------------------------
1426
1427