]> git.saurik.com Git - wxWidgets.git/blob - wxPython/contrib/ogl/oglbasic.i
fixed slider value rounding once again
[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 %module oglbasic
15
16 %{
17 #include "export.h"
18 #include "oglhelpers.h"
19 %}
20
21 //---------------------------------------------------------------------------
22
23 %include typemaps.i
24 %include my_typemaps.i
25
26 %extern wx.i
27 %import windows.i
28 %extern _defs.i
29 %extern misc.i
30 %extern gdi.i
31
32 %include _ogldefs.i
33
34 //%extern oglcanvas.i
35
36
37 %pragma(python) code = "import wx"
38 %pragma(python) code = "from oglcanvas import wxPyShapeCanvasPtr"
39
40 //---------------------------------------------------------------------------
41 //---------------------------------------------------------------------------
42 //---------------------------------------------------------------------------
43
44
45 class wxShapeRegion : public wxObject {
46 public:
47 wxShapeRegion();
48 //~wxShapeRegion();
49
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);
59
60 wxString GetText();
61 wxFont *GetFont();
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);
66 int GetFormatMode();
67 wxString GetName();
68 wxString GetColour();
69 wxColour *GetActualColourObject();
70 wxList& GetFormattedText();
71 wxString GetPenColour();
72 int GetPenStyle();
73 void SetPenStyle(int style);
74 void SetPenColour(const wxString& col);
75 wxPen *GetActualPen();
76 double GetWidth();
77 double GetHeight();
78
79 void ClearText();
80 };
81
82
83 //---------------------------------------------------------------------------
84
85 %{
86 WXSHAPE_IMP_CALLBACKS(wxPyShapeEvtHandler,wxShapeEvtHandler);
87 %}
88
89
90 class wxPyShapeEvtHandler : public wxObject {
91 public:
92 wxPyShapeEvtHandler(wxPyShapeEvtHandler *prev = NULL,
93 wxPyShape *shape = NULL);
94
95 void _setSelf(PyObject* self, PyObject* _class);
96 %pragma(python) addtomethod = "__init__:self._setSelf(self, wxPyShapeEvtHandler)"
97
98 %addmethods { void Destroy() { delete self; } }
99
100 void SetShape(wxPyShape *sh);
101 wxPyShape *GetShape();
102 void SetPreviousHandler(wxPyShapeEvtHandler* handler);
103 wxPyShapeEvtHandler* GetPreviousHandler();
104 wxPyShapeEvtHandler* CreateNewCopy();
105
106 void base_OnDelete();
107 void base_OnDraw(wxDC& dc);
108 void base_OnDrawContents(wxDC& dc);
109 void base_OnDrawBranches(wxDC& dc, bool erase = FALSE);
110 void base_OnMoveLinks(wxDC& dc);
111 void base_OnErase(wxDC& dc);
112 void base_OnEraseContents(wxDC& dc);
113 void base_OnHighlight(wxDC& dc);
114 void base_OnLeftClick(double x, double y, int keys = 0, int attachment = 0);
115 void base_OnLeftDoubleClick(double x, double y, int keys = 0, int attachment = 0);
116 void base_OnRightClick(double x, double y, int keys = 0, int attachment = 0);
117 void base_OnSize(double x, double y);
118 bool base_OnMovePre(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
119 void base_OnMovePost(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
120 void base_OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0);
121 void base_OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0);
122 void base_OnEndDragLeft(double x, double y, int keys=0, int attachment = 0);
123 void base_OnDragRight(bool draw, double x, double y, int keys=0, int attachment = 0);
124 void base_OnBeginDragRight(double x, double y, int keys=0, int attachment = 0);
125 void base_OnEndDragRight(double x, double y, int keys=0, int attachment = 0);
126 void base_OnDrawOutline(wxDC& dc, double x, double y, double w, double h);
127 void base_OnDrawControlPoints(wxDC& dc);
128 void base_OnEraseControlPoints(wxDC& dc);
129 void base_OnMoveLink(wxDC& dc, bool moveControlPoints = TRUE);
130 void base_OnSizingDragLeft(wxPyControlPoint* pt, bool draw, double x, double y, int keys=0, int attachment = 0);
131 void base_OnSizingBeginDragLeft(wxPyControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
132 void base_OnSizingEndDragLeft(wxPyControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
133 void base_OnBeginSize(double w, double h);
134 void base_OnEndSize(double w, double h);
135 // void base_OnChangeAttachment(int attachment, wxPyLineShape* line, wxList& ordering);
136 };
137
138 //---------------------------------------------------------------------------
139 %{
140 WXSHAPE_IMP_CALLBACKS(wxPyShape, wxShape);
141 %}
142
143
144 class wxPyShape : public wxPyShapeEvtHandler {
145 public:
146 // wxPyShape(wxPyShapeCanvas *can = NULL); abstract base class...
147
148 void _setSelf(PyObject* self, PyObject* _class);
149 %pragma(python) addtomethod = "__init__:self._setSelf(self, wxPyShape)"
150
151 %addmethods {
152 void Destroy() { delete self; }
153 }
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 %addmethods {
176 PyObject* GetChildren() {
177 wxList& list = self->GetChildren();
178 return wxPy_ConvertList(&list, "wxPyShape");
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 %addmethods {
220 PyObject* GetLines() {
221 wxList& list = self->GetLines();
222 return wxPy_ConvertList(&list, "wxPyLineShape");
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 %addmethods {
240 void SetClientData(PyObject* userData) {
241 wxPyUserData* data = NULL;
242 if (userData)
243 data = new wxPyUserData(userData);
244 self->SetClientData(data);
245 }
246
247 PyObject* GetClientData() {
248 wxPyUserData* data = (wxPyUserData*)self->GetClientData();
249 if (data) {
250 Py_INCREF(data->m_obj);
251 return data->m_obj;
252 } else {
253 Py_INCREF(Py_None);
254 return Py_None;
255 }
256 }
257 }
258
259 void Show(bool show);
260 bool IsShown();
261 void Move(wxDC& dc, double x1, double y1, bool display = TRUE);
262 void Erase(wxDC& dc);
263 void EraseContents(wxDC& dc);
264 void Draw(wxDC& dc);
265 void Flash();
266 void MoveLinks(wxDC& dc);
267 void DrawContents(wxDC& dc);
268 void SetSize(double x, double y, bool recursive = TRUE);
269 void SetAttachmentSize(double x, double y);
270 void Attach(wxPyShapeCanvas *can);
271 void Detach();
272 bool Constrain();
273 void AddLine(wxPyLineShape *line, wxPyShape *other,
274 int attachFrom = 0, int attachTo = 0,
275 int positionFrom = -1, int positionTo = -1);
276 int GetLinePosition(wxPyLineShape* line);
277 void AddText(const wxString& string);
278 wxPen *GetPen();
279 wxBrush *GetBrush();
280 void SetDefaultRegionSize();
281 void FormatText(wxDC& dc, const wxString& s, int regionId = 0);
282 void SetFormatMode(int mode, int regionId = 0);
283 int GetFormatMode(int regionId = 0);
284 void SetFont(wxFont *font, int regionId = 0);
285 wxFont *GetFont(int regionId = 0);
286 void SetTextColour(const wxString& colour, int regionId = 0);
287 wxString GetTextColour(int regionId = 0);
288 int GetNumberOfTextRegions();
289 void SetRegionName(const wxString& name, int regionId = 0);
290 wxString GetRegionName(int regionId);
291 int GetRegionId(const wxString& name);
292 void NameRegions(const wxString& parentName = "");
293
294 // wxList& GetRegions();
295 %addmethods {
296 PyObject* GetRegions() {
297 wxList& list = self->GetRegions();
298 return wxPy_ConvertList(&list, "wxShapeRegion");
299 }
300 }
301
302 void AddRegion(wxShapeRegion *region);
303 void ClearRegions();
304 void AssignNewIds();
305 wxPyShape *FindRegion(const wxString& regionName, int *OUTPUT);
306 void FindRegionNames(wxStringList& list);
307 void ClearText(int regionId = 0);
308 void RemoveLine(wxPyLineShape *line);
309
310 #ifdef PROLOGIO
311 void WriteAttributes(wxExpr *clause);
312 void ReadAttributes(wxExpr *clause);
313 void ReadConstraints(wxExpr *clause, wxExprDatabase *database);
314 void WriteRegions(wxExpr *clause);
315 void ReadRegions(wxExpr *clause);
316 #endif
317
318 bool GetAttachmentPosition(int attachment, double *OUTPUT, double *OUTPUT,
319 int nth = 0, int no_arcs = 1, wxPyLineShape *line = NULL);
320 int GetNumberOfAttachments();
321 bool AttachmentIsValid(int attachment);
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 %addmethods {
334 void ApplyAttachmentOrdering(PyObject* linesToSort) {
335 wxList* list = wxPy_wxListHelper(linesToSort, "_wxPyLineShape_p");
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 ClearAttachments();
365 void Recentre(wxDC& dc);
366 void ClearPointList(wxList& list);
367
368 void base_OnDelete();
369 void base_OnDraw(wxDC& dc);
370 void base_OnDrawContents(wxDC& dc);
371 void base_OnDrawBranches(wxDC& dc, bool erase = FALSE);
372 void base_OnMoveLinks(wxDC& dc);
373 void base_OnErase(wxDC& dc);
374 void base_OnEraseContents(wxDC& dc);
375 void base_OnHighlight(wxDC& dc);
376 void base_OnLeftClick(double x, double y, int keys = 0, int attachment = 0);
377 void base_OnLeftDoubleClick(double x, double y, int keys = 0, int attachment = 0);
378 void base_OnRightClick(double x, double y, int keys = 0, int attachment = 0);
379 void base_OnSize(double x, double y);
380 bool base_OnMovePre(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
381 void base_OnMovePost(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
382 void base_OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0);
383 void base_OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0);
384 void base_OnEndDragLeft(double x, double y, int keys=0, int attachment = 0);
385 void base_OnDragRight(bool draw, double x, double y, int keys=0, int attachment = 0);
386 void base_OnBeginDragRight(double x, double y, int keys=0, int attachment = 0);
387 void base_OnEndDragRight(double x, double y, int keys=0, int attachment = 0);
388 void base_OnDrawOutline(wxDC& dc, double x, double y, double w, double h);
389 void base_OnDrawControlPoints(wxDC& dc);
390 void base_OnEraseControlPoints(wxDC& dc);
391 void base_OnMoveLink(wxDC& dc, bool moveControlPoints = TRUE);
392 void base_OnSizingDragLeft(wxPyControlPoint* pt, bool draw, double x, double y, int keys=0, int attachment = 0);
393 void base_OnSizingBeginDragLeft(wxPyControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
394 void base_OnSizingEndDragLeft(wxPyControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
395 void base_OnBeginSize(double w, double h);
396 void base_OnEndSize(double w, double h);
397 // void base_OnChangeAttachment(int attachment, wxPyLineShape* line, wxList& ordering);
398 };
399
400 //---------------------------------------------------------------------------
401