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