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