]> git.saurik.com Git - wxWidgets.git/blob - wxPython/contrib/ogl/_oglbasic.i
prevent a reference leak when OOR objects are created
[wxWidgets.git] / wxPython / contrib / ogl / _oglbasic.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: oglbasic.i
3 // Purpose: SWIG definitions for the wxWindows Object Graphics Library
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 3-Sept-1999
8 // RCS-ID: $Id$
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13
14 // Not a %module
15
16
17 //---------------------------------------------------------------------------
18 %newgroup;
19
20
21 class wxShapeRegion : public wxObject {
22 public:
23 wxShapeRegion();
24 //~wxShapeRegion();
25
26 void SetText(const wxString& s);
27 void SetFont(wxFont *f);
28 void SetMinSize(double w, double h);
29 void SetSize(double w, double h);
30 void SetPosition(double x, double y);
31 void SetProportions(double x, double y);
32 void SetFormatMode(int mode);
33 void SetName(const wxString& s);
34 void SetColour(const wxString& col);
35
36 wxString GetText();
37 wxFont *GetFont();
38 void GetMinSize(double *OUTPUT, double *OUTPUT);
39 void GetProportion(double *OUTPUT, double *OUTPUT);
40 void GetSize(double *OUTPUT, double *OUTPUT);
41 void GetPosition(double *OUTPUT, double *OUTPUT);
42 int GetFormatMode();
43 wxString GetName();
44 wxString GetColour();
45 wxColour GetActualColourObject();
46 wxList& GetFormattedText();
47 wxString GetPenColour();
48 int GetPenStyle();
49 void SetPenStyle(int style);
50 void SetPenColour(const wxString& col);
51 wxPen *GetActualPen();
52 double GetWidth();
53 double GetHeight();
54
55 void ClearText();
56 };
57
58
59 //---------------------------------------------------------------------------
60
61 /*
62 * User-defined attachment point
63 */
64
65 class wxAttachmentPoint: public wxObject
66 {
67 public:
68 wxAttachmentPoint(int id=0, double x=0.0, double y=0.0);
69 int m_id; // Identifier
70 double m_x; // x offset from centre of object
71 double m_y; // y offset from centre of object
72 };
73
74
75 //---------------------------------------------------------------------------
76
77 %{
78 WXSHAPE_IMP_CALLBACKS(wxPyShapeEvtHandler,wxShapeEvtHandler);
79 %}
80
81
82 class wxPyShapeEvtHandler : public wxObject {
83 public:
84 %pythonAppend wxPyShapeEvtHandler "self._setOORandCallbackInfo(PyShapeEvtHandler)"
85
86 wxPyShapeEvtHandler(wxPyShapeEvtHandler *prev = NULL,
87 wxPyShape *shape = NULL);
88
89 void _setCallbackInfo(PyObject* self, PyObject* _class);
90 %extend {
91 void _setOORInfo(PyObject* _self) {
92 if (!self->GetClientObject())
93 self->SetClientObject(new wxPyOORClientData(_self));
94 }
95 }
96 %pythoncode {
97 def _setOORandCallbackInfo(self, _class):
98 self._setOORInfo(self)
99 self._setCallbackInfo(self, _class)
100 }
101
102
103 void SetShape(wxPyShape *sh);
104 wxPyShape *GetShape();
105 void SetPreviousHandler(wxPyShapeEvtHandler* handler);
106 wxPyShapeEvtHandler* GetPreviousHandler();
107 wxPyShapeEvtHandler* CreateNewCopy();
108
109 void base_OnDelete();
110 void base_OnDraw(wxDC& dc);
111 void base_OnDrawContents(wxDC& dc);
112 void base_OnDrawBranches(wxDC& dc, bool erase = False);
113 void base_OnMoveLinks(wxDC& dc);
114 void base_OnErase(wxDC& dc);
115 void base_OnEraseContents(wxDC& dc);
116 void base_OnHighlight(wxDC& dc);
117 void base_OnLeftClick(double x, double y, int keys = 0, int attachment = 0);
118 void base_OnLeftDoubleClick(double x, double y, int keys = 0, int attachment = 0);
119 void base_OnRightClick(double x, double y, int keys = 0, int attachment = 0);
120 void base_OnSize(double x, double y);
121 bool base_OnMovePre(wxDC& dc, double x, double y, double old_x, double old_y, bool display = True);
122 void base_OnMovePost(wxDC& dc, double x, double y, double old_x, double old_y, bool display = True);
123 void base_OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0);
124 void base_OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0);
125 void base_OnEndDragLeft(double x, double y, int keys=0, int attachment = 0);
126 void base_OnDragRight(bool draw, double x, double y, int keys=0, int attachment = 0);
127 void base_OnBeginDragRight(double x, double y, int keys=0, int attachment = 0);
128 void base_OnEndDragRight(double x, double y, int keys=0, int attachment = 0);
129 void base_OnDrawOutline(wxDC& dc, double x, double y, double w, double h);
130 void base_OnDrawControlPoints(wxDC& dc);
131 void base_OnEraseControlPoints(wxDC& dc);
132 void base_OnMoveLink(wxDC& dc, bool moveControlPoints = True);
133 void base_OnSizingDragLeft(wxPyControlPoint* pt, bool draw, double x, double y, int keys=0, int attachment = 0);
134 void base_OnSizingBeginDragLeft(wxPyControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
135 void base_OnSizingEndDragLeft(wxPyControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
136 void base_OnBeginSize(double w, double h);
137 void base_OnEndSize(double w, double h);
138 // void base_OnChangeAttachment(int attachment, wxPyLineShape* line, wxList& ordering);
139 };
140
141 //---------------------------------------------------------------------------
142 %{
143 WXSHAPE_IMP_CALLBACKS(wxPyShape, wxShape);
144 %}
145
146
147 class wxPyShape : public wxPyShapeEvtHandler {
148 public:
149 %pythonAppend wxPyShape "self._setOORandCallbackInfo(PyShape)"
150
151 wxPyShape(wxPyShapeCanvas *can = NULL);
152
153 void _setCallbackInfo(PyObject* self, PyObject* _class);
154
155 void GetBoundingBoxMax(double *OUTPUT, double *OUTPUT);
156 void GetBoundingBoxMin(double *OUTPUT, double *OUTPUT);
157 bool GetPerimeterPoint(double x1, double y1,
158 double x2, double y2,
159 double *OUTPUT, double *OUTPUT);
160 wxPyShapeCanvas *GetCanvas();
161 void SetCanvas(wxPyShapeCanvas *the_canvas);
162 void AddToCanvas(wxPyShapeCanvas *the_canvas, wxPyShape *addAfter = NULL);
163 void InsertInCanvas(wxPyShapeCanvas *the_canvas);
164 void RemoveFromCanvas(wxPyShapeCanvas *the_canvas);
165 double GetX();
166 double GetY();
167 void SetX(double x);
168 void SetY(double y);
169 wxPyShape *GetParent();
170 void SetParent(wxPyShape *p);
171 wxPyShape *GetTopAncestor();
172
173
174 // wxList& GetChildren();
175 %extend {
176 PyObject* GetChildren() {
177 wxList& list = self->GetChildren();
178 return wxPy_ConvertShapeList(&list);
179 }
180 }
181
182
183 void Unlink();
184 void SetDrawHandles(bool drawH);
185 bool GetDrawHandles();
186 void MakeControlPoints();
187 void DeleteControlPoints(wxDC *dc = NULL);
188 void ResetControlPoints();
189 wxPyShapeEvtHandler *GetEventHandler();
190 void SetEventHandler(wxPyShapeEvtHandler *handler);
191 void MakeMandatoryControlPoints();
192 void ResetMandatoryControlPoints();
193 bool Recompute();
194 void CalculateSize();
195 void Select(bool select = True, wxDC* dc = NULL);
196 void SetHighlight(bool hi = True, bool recurse = False);
197 bool IsHighlighted() ;
198 bool Selected();
199 bool AncestorSelected();
200 void SetSensitivityFilter(int sens = OP_ALL, bool recursive = False);
201 int GetSensitivityFilter();
202 void SetDraggable(bool drag, bool recursive = False);
203 void SetFixedSize(bool x, bool y);
204 void GetFixedSize(bool *OUTPUT, bool *OUTPUT) ;
205 bool GetFixedWidth();
206 bool GetFixedHeight();
207 void SetSpaceAttachments(bool sp);
208 bool GetSpaceAttachments() ;
209 void SetShadowMode(int mode, bool redraw = False);
210 int GetShadowMode();
211 bool HitTest(double x, double y, int *OUTPUT, double *OUTPUT);
212 void SetCentreResize(bool cr);
213 bool GetCentreResize();
214 void SetMaintainAspectRatio(bool ar);
215 bool GetMaintainAspectRatio();
216
217
218 // wxList& GetLines();
219 %extend {
220 PyObject* GetLines() {
221 wxList& list = self->GetLines();
222 return wxPy_ConvertShapeList(&list);
223 }
224 }
225
226 void SetDisableLabel(bool flag);
227 bool GetDisableLabel();
228 void SetAttachmentMode(int mode);
229 int GetAttachmentMode();
230 void SetId(long i);
231 long GetId();
232
233 void SetPen(wxPen *pen);
234 void SetBrush(wxBrush *brush);
235
236
237 // void SetClientData(wxObject *client_data);
238 // wxObject *GetClientData();
239
240 // The real client data methods are being used for OOR, so just fake it.
241 %pythoncode {
242 def SetClientData(self, data):
243 self.clientData = data
244 def GetClientData(self):
245 if hasattr(self, 'clientData'):
246 return self.clientData
247 else:
248 return None
249 }
250
251 void Show(bool show);
252 bool IsShown();
253 void Move(wxDC& dc, double x1, double y1, bool display = True);
254 void Erase(wxDC& dc);
255 void EraseContents(wxDC& dc);
256 void Draw(wxDC& dc);
257 void Flash();
258 void MoveLinks(wxDC& dc);
259 void DrawContents(wxDC& dc);
260 void SetSize(double x, double y, bool recursive = True);
261 void SetAttachmentSize(double x, double y);
262 void Attach(wxPyShapeCanvas *can);
263 void Detach();
264 bool Constrain();
265 void AddLine(wxPyLineShape *line, wxPyShape *other,
266 int attachFrom = 0, int attachTo = 0,
267 int positionFrom = -1, int positionTo = -1);
268 int GetLinePosition(wxPyLineShape* line);
269 void AddText(const wxString& string);
270 wxPen *GetPen();
271 wxBrush *GetBrush();
272 void SetDefaultRegionSize();
273 void FormatText(wxDC& dc, const wxString& s, int regionId = 0);
274 void SetFormatMode(int mode, int regionId = 0);
275 int GetFormatMode(int regionId = 0);
276 void SetFont(wxFont *font, int regionId = 0);
277 wxFont *GetFont(int regionId = 0);
278 void SetTextColour(const wxString& colour, int regionId = 0);
279 wxString GetTextColour(int regionId = 0);
280 int GetNumberOfTextRegions();
281 void SetRegionName(const wxString& name, int regionId = 0);
282 wxString GetRegionName(int regionId);
283 int GetRegionId(const wxString& name);
284 void NameRegions(const wxString& parentName = wxPyEmptyString);
285
286 // wxList& GetRegions();
287 %extend {
288 PyObject* GetRegions() {
289 wxList& list = self->GetRegions();
290 return wxPy_ConvertList(&list);
291 }
292 }
293
294 void AddRegion(wxShapeRegion *region);
295 void ClearRegions();
296 void AssignNewIds();
297 wxPyShape *FindRegion(const wxString& regionName, int *OUTPUT);
298 void FindRegionNames(wxStringList& list);
299 void ClearText(int regionId = 0);
300 void RemoveLine(wxPyLineShape *line);
301
302 #ifdef wxUSE_PROLOGIO
303 void WriteAttributes(wxExpr *clause);
304 void ReadAttributes(wxExpr *clause);
305 void ReadConstraints(wxExpr *clause, wxExprDatabase *database);
306 void WriteRegions(wxExpr *clause);
307 void ReadRegions(wxExpr *clause);
308 #endif
309
310 bool GetAttachmentPosition(int attachment, double *OUTPUT, double *OUTPUT,
311 int nth = 0, int no_arcs = 1, wxPyLineShape *line = NULL);
312 int GetNumberOfAttachments();
313 bool AttachmentIsValid(int attachment);
314
315 %extend {
316 PyObject* GetAttachments() {
317 wxList& list = self->GetAttachments();
318 return wxPy_ConvertList(&list);
319 }
320 }
321
322 bool GetAttachmentPositionEdge(int attachment, double *OUTPUT, double *OUTPUT,
323 int nth = 0, int no_arcs = 1, wxPyLineShape *line = NULL);
324 wxRealPoint CalcSimpleAttachment(const wxRealPoint& pt1, const wxRealPoint& pt2,
325 int nth, int noArcs, wxPyLineShape* line);
326 bool AttachmentSortTest(int attachmentPoint, const wxRealPoint& pt1, const wxRealPoint& pt2);
327 void EraseLinks(wxDC& dc, int attachment = -1, bool recurse = False);
328 void DrawLinks(wxDC& dc, int attachment = -1, bool recurse = False);
329 bool MoveLineToNewAttachment(wxDC& dc, wxPyLineShape *to_move,
330 double x, double y);
331
332 //void ApplyAttachmentOrdering(wxList& linesToSort);
333 %extend {
334 void ApplyAttachmentOrdering(PyObject* linesToSort) {
335 wxList* list = wxPy_wxListHelper(linesToSort, wxT("wxPyLineShape"));
336 self->ApplyAttachmentOrdering(*list);
337 delete list;
338 }
339 }
340
341 wxRealPoint GetBranchingAttachmentRoot(int attachment);
342 bool GetBranchingAttachmentInfo(int attachment, wxRealPoint& root, wxRealPoint& neck,
343 wxRealPoint& shoulder1, wxRealPoint& shoulder2);
344 bool GetBranchingAttachmentPoint(int attachment, int n, wxRealPoint& attachmentPoint,
345 wxRealPoint& stemPoint);
346 int GetAttachmentLineCount(int attachment);
347 void SetBranchNeckLength(int len);
348 int GetBranchNeckLength();
349 void SetBranchStemLength(int len);
350 int GetBranchStemLength();
351 void SetBranchSpacing(int len);
352 int GetBranchSpacing();
353 void SetBranchStyle(long style);
354 long GetBranchStyle();
355 int PhysicalToLogicalAttachment(int physicalAttachment);
356 int LogicalToPhysicalAttachment(int logicalAttachment);
357 bool Draggable();
358 bool HasDescendant(wxPyShape *image);
359 wxPyShape *CreateNewCopy(bool resetMapping = True, bool recompute = True);
360 void Copy(wxPyShape& copy);
361 void CopyWithHandler(wxPyShape& copy);
362 void Rotate(double x, double y, double theta);
363 double GetRotation();
364 void SetRotation(double rotation);
365 void ClearAttachments();
366 void Recentre(wxDC& dc);
367 void ClearPointList(wxList& list);
368 wxPen GetBackgroundPen();
369 wxBrush GetBackgroundBrush();
370
371 void base_OnDelete();
372 void base_OnDraw(wxDC& dc);
373 void base_OnDrawContents(wxDC& dc);
374 void base_OnDrawBranches(wxDC& dc, bool erase = False);
375 void base_OnMoveLinks(wxDC& dc);
376 void base_OnErase(wxDC& dc);
377 void base_OnEraseContents(wxDC& dc);
378 void base_OnHighlight(wxDC& dc);
379 void base_OnLeftClick(double x, double y, int keys = 0, int attachment = 0);
380 void base_OnLeftDoubleClick(double x, double y, int keys = 0, int attachment = 0);
381 void base_OnRightClick(double x, double y, int keys = 0, int attachment = 0);
382 void base_OnSize(double x, double y);
383 bool base_OnMovePre(wxDC& dc, double x, double y, double old_x, double old_y, bool display = True);
384 void base_OnMovePost(wxDC& dc, double x, double y, double old_x, double old_y, bool display = True);
385 void base_OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0);
386 void base_OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0);
387 void base_OnEndDragLeft(double x, double y, int keys=0, int attachment = 0);
388 void base_OnDragRight(bool draw, double x, double y, int keys=0, int attachment = 0);
389 void base_OnBeginDragRight(double x, double y, int keys=0, int attachment = 0);
390 void base_OnEndDragRight(double x, double y, int keys=0, int attachment = 0);
391 void base_OnDrawOutline(wxDC& dc, double x, double y, double w, double h);
392 void base_OnDrawControlPoints(wxDC& dc);
393 void base_OnEraseControlPoints(wxDC& dc);
394 void base_OnMoveLink(wxDC& dc, bool moveControlPoints = True);
395 void base_OnSizingDragLeft(wxPyControlPoint* pt, bool draw, double x, double y, int keys=0, int attachment = 0);
396 void base_OnSizingBeginDragLeft(wxPyControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
397 void base_OnSizingEndDragLeft(wxPyControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
398 void base_OnBeginSize(double w, double h);
399 void base_OnEndSize(double w, double h);
400 // void base_OnChangeAttachment(int attachment, wxPyLineShape* line, wxList& ordering);
401 };
402
403 //---------------------------------------------------------------------------
404