]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/gdi.i
Commented out constructor causing ambiguity
[wxWidgets.git] / utils / wxPython / src / gdi.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: gdi.i
3 // Purpose: SWIG interface file for wxDC, wxBrush, wxPen, wxFont, etc.
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 7/7/97
8 // RCS-ID: $Id$
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13
14 %module gdi
15
16 %{
17 #include "helpers.h"
18 #include <wx/metafile.h>
19 %}
20
21 //----------------------------------------------------------------------
22
23 %include typemaps.i
24 %include my_typemaps.i
25
26 // Import some definitions of other classes, etc.
27 %import _defs.i
28 %import misc.i
29
30 //---------------------------------------------------------------------------
31
32 class wxBitmap {
33 public:
34 wxBitmap(const wxString& name, long type);
35 ~wxBitmap();
36
37 #ifdef __WXMSW__
38 void Create(int width, int height, int depth = -1);
39 #endif
40 int GetDepth();
41 int GetHeight();
42 wxPalette* GetPalette();
43 wxMask* GetMask();
44 int GetWidth();
45 bool LoadFile(const wxString& name, long flags);
46 bool Ok();
47 bool SaveFile(const wxString& name, int type, wxPalette* palette = NULL);
48 void SetDepth(int depth);
49 void SetHeight(int height);
50 void SetMask(wxMask* mask);
51 #ifdef __WXMSW__
52 void SetPalette(wxPalette* palette);
53 #endif
54 void SetWidth(int width);
55 };
56
57 %new wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1);
58 wxBitmap* wxNoRefBitmap(char* name, long flags);
59
60 %{ // Alternate 'constructor'
61 wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1) {
62 return new wxBitmap(width, height, depth);
63 }
64
65 // This one won't own the reference, so Python won't call
66 // the dtor, this is good for toolbars and such where
67 // the parent will manage the bitmap.
68 wxBitmap* wxNoRefBitmap(char* name, long flags) {
69 return new wxBitmap(name, flags);
70 }
71 %}
72
73 //---------------------------------------------------------------------------
74
75 class wxMask {
76 public:
77 wxMask(const wxBitmap& bitmap);
78 ~wxMask();
79 };
80
81 %new wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour);
82 %{
83 wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour) {
84 return new wxMask(bitmap, colour);
85 }
86 %}
87
88
89 //---------------------------------------------------------------------------
90
91
92 class wxIcon : public wxBitmap {
93 public:
94 #ifdef __WXMSW__
95 wxIcon(const wxString& name, long flags,
96 int desiredWidth = -1, int desiredHeight = -1);
97 #endif
98 ~wxIcon();
99
100 int GetDepth();
101 int GetHeight();
102 int GetWidth();
103 bool LoadFile(const wxString& name, long flags);
104 bool Ok();
105 void SetDepth(int depth);
106 void SetHeight(int height);
107 void SetWidth(int width);
108 };
109
110 //---------------------------------------------------------------------------
111
112 class wxCursor : public wxBitmap {
113 public:
114 #ifdef __WXMSW__
115 wxCursor(const wxString& cursorName, long flags, int hotSpotX=0, int hotSpotY=0);
116 #endif
117 ~wxCursor();
118 bool Ok();
119 };
120
121 %name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id);
122 %{ // Alternate 'constructor'
123 wxCursor* wxPyStockCursor(int id) {
124 return new wxCursor(id);
125 }
126 %}
127
128 //----------------------------------------------------------------------
129
130 class wxFont {
131 public:
132 // I'll do it this way to use long-lived objects and not have to
133 // worry about when python may delete the object.
134 %addmethods {
135 wxFont( int pointSize, int family, int style, int weight,
136 int underline=FALSE, char* faceName = "") {
137
138 return wxTheFontList->FindOrCreateFont(pointSize, family, style, weight,
139 underline, faceName);
140 }
141 // NO Destructor.
142 }
143
144
145 wxString GetFaceName();
146 int GetFamily();
147 int GetFontId();
148 int GetPointSize();
149 int GetStyle();
150 bool GetUnderlined();
151 int GetWeight();
152 #ifdef __WXMSW__
153 void SetFaceName(const wxString& faceName);
154 void SetFamily(int family);
155 void SetPointSize(int pointSize);
156 void SetStyle(int style);
157 void SetUnderlined(bool underlined);
158 void SetWeight(int weight);
159 #endif
160 };
161
162 //----------------------------------------------------------------------
163
164 class wxColour {
165 public:
166 wxColour(unsigned char red=0, unsigned char green=0, unsigned char blue=0);
167 ~wxColour();
168 unsigned char Red();
169 unsigned char Green();
170 unsigned char Blue();
171 bool Ok();
172 void Set(unsigned char red, unsigned char green, unsigned char blue);
173 %addmethods {
174 PyObject* Get() {
175 PyObject* rv = PyTuple_New(3);
176 PyTuple_SetItem(rv, 0, PyInt_FromLong(self->Red()));
177 PyTuple_SetItem(rv, 1, PyInt_FromLong(self->Green()));
178 PyTuple_SetItem(rv, 2, PyInt_FromLong(self->Blue()));
179 return rv;
180 }
181 }
182 };
183
184 %new wxColour* wxNamedColour(const wxString& colorName);
185 %{ // Alternate 'constructor'
186 wxColour* wxNamedColour(const wxString& colorName) {
187 return new wxColour(colorName);
188 }
189 %}
190
191
192 //----------------------------------------------------------------------
193
194 typedef unsigned long wxDash;
195
196 class wxPen {
197 public:
198 // I'll do it this way to use long-lived objects and not have to
199 // worry about when python may delete the object.
200 %addmethods {
201 wxPen(wxColour* colour, int width=1, int style=wxSOLID) {
202 return wxThePenList->FindOrCreatePen(*colour, width, style);
203 }
204 // NO Destructor.
205 }
206
207 int GetCap();
208 wxColour& GetColour();
209
210 #ifdef __WXMSW__
211 // **** This one needs to return a list of ints (wxDash)
212 int GetDashes(wxDash **dashes);
213 wxBitmap* GetStipple();
214 #endif
215 int GetJoin();
216 int GetStyle();
217 int GetWidth();
218 bool Ok();
219 void SetCap(int cap_style);
220 void SetColour(wxColour& colour);
221 #ifdef __WXMSW__
222 void SetDashes(int LCOUNT, wxDash* LIST);
223 void SetStipple(wxBitmap * stipple);
224 #endif
225 void SetJoin(int join_style);
226 void SetStyle(int style);
227 void SetWidth(int width);
228 };
229
230 //----------------------------------------------------------------------
231
232 class wxBrush {
233 public:
234 // I'll do it this way to use long-lived objects and not have to
235 // worry about when python may delete the object.
236 %addmethods {
237 wxBrush(wxColour* colour, int style=wxSOLID) {
238 return wxTheBrushList->FindOrCreateBrush(*colour, style);
239 }
240 // NO Destructor.
241 }
242
243 wxColour& GetColour();
244 wxBitmap * GetStipple();
245 int GetStyle();
246 bool Ok();
247 #ifdef __WXMSW__
248 void SetColour(wxColour &colour);
249 void SetStipple(wxBitmap *bitmap);
250 void SetStyle(int style);
251 #endif
252 };
253
254 //----------------------------------------------------------------------
255
256
257
258 class wxDC {
259 public:
260 // wxDC(); **** abstract base class, can't instantiate.
261 ~wxDC();
262
263 void BeginDrawing();
264 bool Blit(long xdest, long ydest, long width, long height,
265 wxDC *source, long xsrc, long ysrc, long logical_func);
266 void Clear();
267 void CrossHair(long x, long y);
268 void DestroyClippingRegion();
269 long DeviceToLogicalX(long x);
270 long DeviceToLogicalXRel(long x);
271 long DeviceToLogicalY(long y);
272 long DeviceToLogicalYRel(long y);
273 void DrawArc(long x1, long y1, long x2, long y2, long xc, long yc);
274 void DrawEllipse(long x, long y, long width, long height);
275 void DrawEllipticArc(long x, long y, long width, long height, long start, long end);
276 void DrawIcon(const wxIcon& icon, long x, long y);
277 void DrawLine(long x1, long y1, long x2, long y2);
278 void DrawLines(int LCOUNT, wxPoint* LIST, long xoffset=0, long yoffset=0);
279 void DrawPolygon(int LCOUNT, wxPoint* LIST, long xoffset=0, long yoffset=0,
280 int fill_style=wxODDEVEN_RULE);
281 void DrawPoint(long x, long y);
282 void DrawRectangle(long x, long y, long width, long height);
283 void DrawRoundedRectangle(long x, long y, long width, long height, long radius=20);
284 void DrawSpline(int LCOUNT, wxPoint* LIST);
285 void DrawText(const wxString& text, long x, long y);
286 void EndDoc();
287 void EndDrawing();
288 void EndPage();
289 #ifdef __WXWIN__
290 void FloodFill(long x, long y, const wxColour& colour, int style=wxFLOOD_SURFACE);
291 #endif
292 #ifdef __WXGTK__
293 void FloodFill(long x, long y, wxColour* colour, int style=wxFLOOD_SURFACE);
294 #endif
295 wxBrush * GetBackground();
296 wxBrush * GetBrush();
297 long GetCharHeight();
298 long GetCharWidth();
299 void GetClippingBox(long *OUTPUT, long *OUTPUT,
300 long *OUTPUT, long *OUTPUT);
301 wxFont * GetFont();
302 int GetLogicalFunction();
303 int GetMapMode();
304 bool GetOptimization();
305 wxPen * GetPen();
306 %addmethods {
307 %new wxColour* GetPixel(long x, long y) {
308 wxColour* wc = new wxColour();
309 self->GetPixel(x, y, wc);
310 return wc;
311 }
312 }
313 void GetSize(int* OUTPUT, int* OUTPUT); //void GetSize(long* OUTPUT, long* OUTPUT);
314 wxColour& GetTextBackground();
315 void GetTextExtent(const wxString& string, long *OUTPUT, long *OUTPUT,
316 long *OUTPUT, long *OUTPUT);
317 wxColour& GetTextForeground();
318 long LogicalToDeviceX(long x);
319 long LogicalToDeviceXRel(long x);
320 long LogicalToDeviceY(long y);
321 long LogicalToDeviceYRel(long y);
322 long MaxX();
323 long MaxY();
324 long MinX();
325 long MinY();
326 bool Ok();
327 void SetDeviceOrigin(long x, long y);
328 void SetBackground(const wxBrush& brush);
329 void SetBackgroundMode(int mode);
330 void SetClippingRegion(long x, long y, long width, long height);
331 void SetPalette(const wxPalette& colourMap);
332 void SetBrush(const wxBrush& brush);
333 void SetFont(const wxFont& font);
334 void SetLogicalFunction(int function);
335 void SetMapMode(int mode);
336 void SetOptimization(bool optimize);
337 void SetPen(const wxPen& pen);
338 void SetTextBackground(const wxColour& colour);
339 void SetTextForeground(const wxColour& colour);
340 void SetUserScale(double x_scale, double y_scale);
341 bool StartDoc(const wxString& message);
342 void StartPage();
343
344
345 %addmethods {
346 // This one is my own creation...
347 void DrawBitmap(wxBitmap* bitmap, long x, long y, bool swapPalette=TRUE) {
348 wxMemoryDC* memDC = new wxMemoryDC;
349 memDC->SelectObject(bitmap);
350 if (swapPalette)
351 self->SetPalette(bitmap->GetPalette());
352 self->Blit(x, y, bitmap->GetWidth(), bitmap->GetHeight(), memDC,
353 0, 0, self->GetLogicalFunction());
354 memDC->SelectObject(wxNullBitmap);
355 delete memDC;
356 }
357 }
358 };
359
360
361 //----------------------------------------------------------------------
362
363 class wxMemoryDC : public wxDC {
364 public:
365 wxMemoryDC();
366
367 void SelectObject(const wxBitmap& bitmap);
368 }
369
370 %new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC);
371 %{ // Alternate 'constructor'
372 wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) {
373 return new wxMemoryDC(oldDC);
374 }
375 %}
376
377
378 //---------------------------------------------------------------------------
379
380 class wxScreenDC : public wxDC {
381 public:
382 wxScreenDC();
383
384 bool StartDrawingOnTop(wxWindow* window);
385 %name(StartDrawingOnTopRect) bool StartDrawingOnTop(wxRect* rect = NULL);
386 bool EndDrawingOnTop();
387 };
388
389 //---------------------------------------------------------------------------
390
391 class wxClientDC : public wxDC {
392 public:
393 wxClientDC(wxWindow* win);
394 };
395
396 //---------------------------------------------------------------------------
397
398 class wxPaintDC : public wxDC {
399 public:
400 wxPaintDC(wxWindow* win);
401 };
402
403 //---------------------------------------------------------------------------
404
405 class wxPostScriptDC : public wxDC {
406 public:
407 wxPostScriptDC(const wxString& output, bool interactive = TRUE, wxWindow* win = NULL);
408 };
409
410 //---------------------------------------------------------------------------
411
412 #ifdef __WXMSW__
413 class wxPrinterDC : public wxDC {
414 public:
415 wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output,
416 bool interactive = TRUE, int orientation = wxPORTRAIT);
417 };
418 #endif
419
420 //---------------------------------------------------------------------------
421
422 #ifdef __WXMSW__
423 class wxMetaFileDC : public wxDC {
424 public:
425 wxMetaFileDC(const wxString& filename = wxPyEmptyStr);
426 wxMetaFile* Close();
427 };
428 #endif
429
430 //---------------------------------------------------------------------------
431 //---------------------------------------------------------------------------
432
433
434 %readonly
435 extern wxFont *wxNORMAL_FONT;
436 extern wxFont *wxSMALL_FONT;
437 extern wxFont *wxITALIC_FONT;
438 extern wxFont *wxSWISS_FONT;
439 extern wxPen *wxRED_PEN;
440
441 extern wxPen *wxCYAN_PEN;
442 extern wxPen *wxGREEN_PEN;
443 extern wxPen *wxBLACK_PEN;
444 extern wxPen *wxWHITE_PEN;
445 extern wxPen *wxTRANSPARENT_PEN;
446 extern wxPen *wxBLACK_DASHED_PEN;
447 extern wxPen *wxGREY_PEN;
448 extern wxPen *wxMEDIUM_GREY_PEN;
449 extern wxPen *wxLIGHT_GREY_PEN;
450
451 extern wxBrush *wxBLUE_BRUSH;
452 extern wxBrush *wxGREEN_BRUSH;
453 extern wxBrush *wxWHITE_BRUSH;
454 extern wxBrush *wxBLACK_BRUSH;
455 extern wxBrush *wxTRANSPARENT_BRUSH;
456 extern wxBrush *wxCYAN_BRUSH;
457 extern wxBrush *wxRED_BRUSH;
458 extern wxBrush *wxGREY_BRUSH;
459 extern wxBrush *wxMEDIUM_GREY_BRUSH;
460 extern wxBrush *wxLIGHT_GREY_BRUSH;
461
462 extern wxColour *wxBLACK;
463 extern wxColour *wxWHITE;
464 extern wxColour *wxRED;
465 extern wxColour *wxBLUE;
466 extern wxColour *wxGREEN;
467 extern wxColour *wxCYAN;
468 extern wxColour *wxLIGHT_GREY;
469
470 extern wxCursor *wxSTANDARD_CURSOR;
471 extern wxCursor *wxHOURGLASS_CURSOR;
472 extern wxCursor *wxCROSS_CURSOR;
473
474 extern wxBitmap wxNullBitmap;
475 extern wxIcon wxNullIcon;
476 extern wxCursor wxNullCursor;
477 extern wxPen wxNullPen;
478 extern wxBrush wxNullBrush;
479 extern wxPalette wxNullPalette;
480 extern wxFont wxNullFont;
481 extern wxColour wxNullColour;
482
483 //---------------------------------------------------------------------------
484
485 /////////////////////////////////////////////////////////////////////////////
486 //
487 // $Log$
488 // Revision 1.4 1998/10/02 06:40:38 RD
489 // Version 0.4 of wxPython for MSW.
490 //
491 // Revision 1.3 1998/08/18 19:48:16 RD
492 // more wxGTK compatibility things.
493 //
494 // It builds now but there are serious runtime problems...
495 //
496 // Revision 1.2 1998/08/15 07:36:35 RD
497 // - Moved the header in the .i files out of the code that gets put into
498 // the .cpp files. It caused CVS conflicts because of the RCS ID being
499 // different each time.
500 //
501 // - A few minor fixes.
502 //
503 // Revision 1.1 1998/08/09 08:25:50 RD
504 // Initial version
505 //
506 //