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