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