1 /////////////////////////////////////////////////////////////////////////////
 
   3 // Purpose:     SWIG definitions for the wxWindows Object Graphics Library
 
   7 // Created:     3-Sept-1999
 
   9 // Copyright:   (c) 1998 by Total Control Software
 
  10 // Licence:     wxWindows license
 
  11 /////////////////////////////////////////////////////////////////////////////
 
  18 #include "oglhelpers.h"
 
  21 //---------------------------------------------------------------------------
 
  24 %include my_typemaps.i
 
  37 %pragma(python) code = "import wx"
 
  38 %pragma(python) code = "from oglcanvas import wxPyShapeCanvasPtr"
 
  40 //---------------------------------------------------------------------------
 
  41 //---------------------------------------------------------------------------
 
  42 //---------------------------------------------------------------------------
 
  50     void SetText(const wxString& s);
 
  51     void SetFont(wxFont *f);
 
  52     void SetMinSize(double w, double h);
 
  53     void SetSize(double w, double h);
 
  54     void SetPosition(double x, double y);
 
  55     void SetProportions(double x, double y);
 
  56     void SetFormatMode(int mode);
 
  57     void SetName(const wxString& s);
 
  58     void SetColour(const wxString& col);
 
  62     void GetMinSize(double *OUTPUT, double *OUTPUT);
 
  63     void GetProportion(double *OUTPUT, double *OUTPUT);
 
  64     void GetSize(double *OUTPUT, double *OUTPUT);
 
  65     void GetPosition(double *OUTPUT, double *OUTPUT);
 
  69     wxColour *GetActualColourObject();
 
  70     wxList& GetFormattedText();
 
  71     wxString GetPenColour();
 
  73     void SetPenStyle(int style);
 
  74     void SetPenColour(const wxString& col);
 
  75     wxPen *GetActualPen();
 
  83 //---------------------------------------------------------------------------
 
  86     WXSHAPE_IMP_CALLBACKS(wxPyShapeEvtHandler,wxShapeEvtHandler);
 
  90 class wxPyShapeEvtHandler {
 
  92     wxPyShapeEvtHandler(wxPyShapeEvtHandler *prev = NULL,
 
  93                         wxPyShape *shape = NULL);
 
  95     void _setSelf(PyObject* self, PyObject* _class);
 
  96     %pragma(python) addtomethod = "__init__:self._setSelf(self, wxPyShapeEvtHandler)"
 
  99         void Destroy() { delete self; }
 
 102     void SetShape(wxPyShape *sh);
 
 103     wxPyShape *GetShape();
 
 104     void SetPreviousHandler(wxPyShapeEvtHandler* handler);
 
 105     wxPyShapeEvtHandler* GetPreviousHandler();
 
 106     wxPyShapeEvtHandler* CreateNewCopy();
 
 108     void base_OnDelete();
 
 109     void base_OnDraw(wxDC& dc);
 
 110     void base_OnDrawContents(wxDC& dc);
 
 111     void base_OnDrawBranches(wxDC& dc, bool erase = FALSE);
 
 112     void base_OnMoveLinks(wxDC& dc);
 
 113     void base_OnErase(wxDC& dc);
 
 114     void base_OnEraseContents(wxDC& dc);
 
 115     void base_OnHighlight(wxDC& dc);
 
 116     void base_OnLeftClick(double x, double y, int keys = 0, int attachment = 0);
 
 117     void base_OnLeftDoubleClick(double x, double y, int keys = 0, int attachment = 0);
 
 118     void base_OnRightClick(double x, double y, int keys = 0, int attachment = 0);
 
 119     void base_OnSize(double x, double y);
 
 120     bool base_OnMovePre(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
 
 121     void base_OnMovePost(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
 
 122     void base_OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0);
 
 123     void base_OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0);
 
 124     void base_OnEndDragLeft(double x, double y, int keys=0, int attachment = 0);
 
 125     void base_OnDragRight(bool draw, double x, double y, int keys=0, int attachment = 0);
 
 126     void base_OnBeginDragRight(double x, double y, int keys=0, int attachment = 0);
 
 127     void base_OnEndDragRight(double x, double y, int keys=0, int attachment = 0);
 
 128     void base_OnDrawOutline(wxDC& dc, double x, double y, double w, double h);
 
 129     void base_OnDrawControlPoints(wxDC& dc);
 
 130     void base_OnEraseControlPoints(wxDC& dc);
 
 131     void base_OnMoveLink(wxDC& dc, bool moveControlPoints = TRUE);
 
 132     void base_OnSizingDragLeft(wxPyControlPoint* pt, bool draw, double x, double y, int keys=0, int attachment = 0);
 
 133     void base_OnSizingBeginDragLeft(wxPyControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
 
 134     void base_OnSizingEndDragLeft(wxPyControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
 
 135     void base_OnBeginSize(double w, double h);
 
 136     void base_OnEndSize(double w, double h);
 
 137 //    void base_OnChangeAttachment(int attachment, wxPyLineShape* line, wxList& ordering);
 
 140 //---------------------------------------------------------------------------
 
 142     WXSHAPE_IMP_CALLBACKS(wxPyShape, wxShape);
 
 146 class wxPyShape : public wxPyShapeEvtHandler {
 
 148     // wxPyShape(wxPyShapeCanvas *can = NULL);     abstract base class...
 
 150     void _setSelf(PyObject* self, PyObject* _class);
 
 151     %pragma(python) addtomethod = "__init__:self._setSelf(self, wxPyShape)"
 
 154         void Destroy() { delete self; }
 
 157     void GetBoundingBoxMax(double *OUTPUT, double *OUTPUT);
 
 158     void GetBoundingBoxMin(double *OUTPUT, double *OUTPUT);
 
 159     bool GetPerimeterPoint(double x1, double y1,
 
 160                            double x2, double y2,
 
 161                            double *OUTPUT, double *OUTPUT);
 
 162     wxPyShapeCanvas *GetCanvas();
 
 163     void SetCanvas(wxPyShapeCanvas *the_canvas);
 
 164     void AddToCanvas(wxPyShapeCanvas *the_canvas, wxPyShape *addAfter = NULL);
 
 165     void InsertInCanvas(wxPyShapeCanvas *the_canvas);
 
 166     void RemoveFromCanvas(wxPyShapeCanvas *the_canvas);
 
 171     wxPyShape *GetParent();
 
 172     void SetParent(wxPyShape *p);
 
 173     wxPyShape *GetTopAncestor();
 
 176     // wxList& GetChildren();
 
 178         PyObject* GetChildren() {
 
 179             wxList& list = self->GetChildren();
 
 180             return wxPy_ConvertList(&list, "wxPyShape");
 
 186     void SetDrawHandles(bool drawH);
 
 187     bool GetDrawHandles();
 
 188     void MakeControlPoints();
 
 189     void DeleteControlPoints(wxDC *dc = NULL);
 
 190     void ResetControlPoints();
 
 191     wxPyShapeEvtHandler *GetEventHandler();
 
 192     void SetEventHandler(wxPyShapeEvtHandler *handler);
 
 193     void MakeMandatoryControlPoints();
 
 194     void ResetMandatoryControlPoints();
 
 196     void CalculateSize();
 
 197     void Select(bool select = TRUE, wxDC* dc = NULL);
 
 198     void SetHighlight(bool hi = TRUE, bool recurse = FALSE);
 
 199     bool IsHighlighted() ;
 
 201     bool AncestorSelected();
 
 202     void SetSensitivityFilter(int sens = OP_ALL, bool recursive = FALSE);
 
 203     int GetSensitivityFilter();
 
 204     void SetDraggable(bool drag, bool recursive = FALSE);
 
 205     void SetFixedSize(bool x, bool y);
 
 206     void GetFixedSize(bool *OUTPUT, bool *OUTPUT) ;
 
 207     bool GetFixedWidth();
 
 208     bool GetFixedHeight();
 
 209     void SetSpaceAttachments(bool sp);
 
 210     bool GetSpaceAttachments() ;
 
 211     void SetShadowMode(int mode, bool redraw = FALSE);
 
 213     bool HitTest(double x, double y, int *OUTPUT, double *OUTPUT);
 
 214     void SetCentreResize(bool cr);
 
 215     bool GetCentreResize();
 
 216     void SetMaintainAspectRatio(bool ar);
 
 217     bool GetMaintainAspectRatio();
 
 220     // wxList& GetLines();
 
 222         PyObject* GetLines() {
 
 223             wxList& list = self->GetLines();
 
 224             return wxPy_ConvertList(&list, "wxPyLineShape");
 
 228     void SetDisableLabel(bool flag);
 
 229     bool GetDisableLabel();
 
 230     void SetAttachmentMode(int mode);
 
 231     int GetAttachmentMode();
 
 235     void SetPen(wxPen *pen);
 
 236     void SetBrush(wxBrush *brush);
 
 239     // void SetClientData(wxObject *client_data);
 
 240     // wxObject *GetClientData();
 
 242         void SetClientData(PyObject* userData) {
 
 243             wxPyUserData* data = NULL;
 
 245                 data = new wxPyUserData(userData);
 
 246             self->SetClientData(data);
 
 249         PyObject* GetClientData() {
 
 250             wxPyUserData* data = (wxPyUserData*)self->GetClientData();
 
 252                 Py_INCREF(data->m_obj);
 
 261     void Show(bool show);
 
 263     void Move(wxDC& dc, double x1, double y1, bool display = TRUE);
 
 264     void Erase(wxDC& dc);
 
 265     void EraseContents(wxDC& dc);
 
 268     void MoveLinks(wxDC& dc);
 
 269     void DrawContents(wxDC& dc);
 
 270     void SetSize(double x, double y, bool recursive = TRUE);
 
 271     void SetAttachmentSize(double x, double y);
 
 272     void Attach(wxPyShapeCanvas *can);
 
 275     void AddLine(wxPyLineShape *line, wxPyShape *other,
 
 276                  int attachFrom = 0, int attachTo = 0,
 
 277                  int positionFrom = -1, int positionTo = -1);
 
 278     int GetLinePosition(wxPyLineShape* line);
 
 279     void AddText(const wxString& string);
 
 282     void SetDefaultRegionSize();
 
 283     void FormatText(wxDC& dc, const wxString& s, int regionId = 0);
 
 284     void SetFormatMode(int mode, int regionId = 0);
 
 285     int GetFormatMode(int regionId = 0);
 
 286     void SetFont(wxFont *font, int regionId = 0);
 
 287     wxFont *GetFont(int regionId = 0);
 
 288     void SetTextColour(const wxString& colour, int regionId = 0);
 
 289     wxString GetTextColour(int regionId = 0);
 
 290     int GetNumberOfTextRegions();
 
 291     void SetRegionName(const wxString& name, int regionId = 0);
 
 292     wxString GetRegionName(int regionId);
 
 293     int GetRegionId(const wxString& name);
 
 294     void NameRegions(const wxString& parentName = "");
 
 296     // wxList& GetRegions();
 
 298         PyObject* GetRegions() {
 
 299             wxList& list = self->GetRegions();
 
 300             return wxPy_ConvertList(&list, "wxShapeRegion");
 
 304     void AddRegion(wxShapeRegion *region);
 
 307     wxPyShape *FindRegion(const wxString& regionName, int *OUTPUT);
 
 308     void FindRegionNames(wxStringList& list);
 
 309     void ClearText(int regionId = 0);
 
 310     void RemoveLine(wxPyLineShape *line);
 
 313     void WriteAttributes(wxExpr *clause);
 
 314     void ReadAttributes(wxExpr *clause);
 
 315     void ReadConstraints(wxExpr *clause, wxExprDatabase *database);
 
 316     void WriteRegions(wxExpr *clause);
 
 317     void ReadRegions(wxExpr *clause);
 
 320     bool GetAttachmentPosition(int attachment, double *OUTPUT, double *OUTPUT,
 
 321                                int nth = 0, int no_arcs = 1, wxPyLineShape *line = NULL);
 
 322     int GetNumberOfAttachments();
 
 323     bool AttachmentIsValid(int attachment);
 
 324     bool GetAttachmentPositionEdge(int attachment, double *OUTPUT, double *OUTPUT,
 
 325                                    int nth = 0, int no_arcs = 1, wxPyLineShape *line = NULL);
 
 326     wxRealPoint CalcSimpleAttachment(const wxRealPoint& pt1, const wxRealPoint& pt2,
 
 327                                      int nth, int noArcs, wxPyLineShape* line);
 
 328     bool AttachmentSortTest(int attachmentPoint, const wxRealPoint& pt1, const wxRealPoint& pt2);
 
 329     void EraseLinks(wxDC& dc, int attachment = -1, bool recurse = FALSE);
 
 330     void DrawLinks(wxDC& dc, int attachment = -1, bool recurse = FALSE);
 
 331     bool MoveLineToNewAttachment(wxDC& dc, wxPyLineShape *to_move,
 
 334     //void ApplyAttachmentOrdering(wxList& linesToSort);
 
 336         void ApplyAttachmentOrdering(PyObject* linesToSort) {
 
 337             wxList* list = wxPy_wxListHelper(linesToSort, "_wxPyLineShape_p");
 
 338             self->ApplyAttachmentOrdering(*list);
 
 343     wxRealPoint GetBranchingAttachmentRoot(int attachment);
 
 344     bool GetBranchingAttachmentInfo(int attachment, wxRealPoint& root, wxRealPoint& neck,
 
 345                                     wxRealPoint& shoulder1, wxRealPoint& shoulder2);
 
 346     bool GetBranchingAttachmentPoint(int attachment, int n, wxRealPoint& attachmentPoint,
 
 347                                      wxRealPoint& stemPoint);
 
 348     int GetAttachmentLineCount(int attachment);
 
 349     void SetBranchNeckLength(int len);
 
 350     int GetBranchNeckLength();
 
 351     void SetBranchStemLength(int len);
 
 352     int GetBranchStemLength();
 
 353     void SetBranchSpacing(int len);
 
 354     int GetBranchSpacing();
 
 355     void SetBranchStyle(long style);
 
 356     long GetBranchStyle();
 
 357     int PhysicalToLogicalAttachment(int physicalAttachment);
 
 358     int LogicalToPhysicalAttachment(int logicalAttachment);
 
 360     bool HasDescendant(wxPyShape *image);
 
 361     wxPyShape *CreateNewCopy(bool resetMapping = TRUE, bool recompute = TRUE);
 
 362     void Copy(wxPyShape& copy);
 
 363     void CopyWithHandler(wxPyShape& copy);
 
 364     void Rotate(double x, double y, double theta);
 
 365     double GetRotation();
 
 366     void ClearAttachments();
 
 367     void Recentre(wxDC& dc);
 
 368     void ClearPointList(wxList& list);
 
 370     void base_OnDelete();
 
 371     void base_OnDraw(wxDC& dc);
 
 372     void base_OnDrawContents(wxDC& dc);
 
 373     void base_OnDrawBranches(wxDC& dc, bool erase = FALSE);
 
 374     void base_OnMoveLinks(wxDC& dc);
 
 375     void base_OnErase(wxDC& dc);
 
 376     void base_OnEraseContents(wxDC& dc);
 
 377     void base_OnHighlight(wxDC& dc);
 
 378     void base_OnLeftClick(double x, double y, int keys = 0, int attachment = 0);
 
 379     void base_OnLeftDoubleClick(double x, double y, int keys = 0, int attachment = 0);
 
 380     void base_OnRightClick(double x, double y, int keys = 0, int attachment = 0);
 
 381     void base_OnSize(double x, double y);
 
 382     bool base_OnMovePre(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
 
 383     void base_OnMovePost(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
 
 384     void base_OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0);
 
 385     void base_OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0);
 
 386     void base_OnEndDragLeft(double x, double y, int keys=0, int attachment = 0);
 
 387     void base_OnDragRight(bool draw, double x, double y, int keys=0, int attachment = 0);
 
 388     void base_OnBeginDragRight(double x, double y, int keys=0, int attachment = 0);
 
 389     void base_OnEndDragRight(double x, double y, int keys=0, int attachment = 0);
 
 390     void base_OnDrawOutline(wxDC& dc, double x, double y, double w, double h);
 
 391     void base_OnDrawControlPoints(wxDC& dc);
 
 392     void base_OnEraseControlPoints(wxDC& dc);
 
 393     void base_OnMoveLink(wxDC& dc, bool moveControlPoints = TRUE);
 
 394     void base_OnSizingDragLeft(wxPyControlPoint* pt, bool draw, double x, double y, int keys=0, int attachment = 0);
 
 395     void base_OnSizingBeginDragLeft(wxPyControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
 
 396     void base_OnSizingEndDragLeft(wxPyControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
 
 397     void base_OnBeginSize(double w, double h);
 
 398     void base_OnEndSize(double w, double h);
 
 399 //    void base_OnChangeAttachment(int attachment, wxPyLineShape* line, wxList& ordering);
 
 402 //---------------------------------------------------------------------------