]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/gdi.i
*** empty log message ***
[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 wxGDIImage {
37 // public:
38 // long GetHandle();
39 // void SetHandle(long handle);
40 // bool Ok();
41 // int GetWidth();
42 // int GetHeight();
43 // int GetDepth();
44 // void SetWidth(int w);
45 // void SetHeight(int h);
46 // void SetDepth(int d);
47 // void SetSize(const wxSize& size);
48 // };
49
50 //---------------------------------------------------------------------------
51
52 class wxBitmap
53 //: public wxGDIImage
54 {
55 public:
56 wxBitmap(const wxString& name, long type);
57 ~wxBitmap();
58
59 wxPalette* GetPalette();
60 wxMask* GetMask();
61 bool LoadFile(const wxString& name, long flags);
62 bool SaveFile(const wxString& name, int type, wxPalette* palette = NULL);
63 void SetMask(wxMask* mask);
64 #ifdef __WXMSW__
65 void SetPalette(wxPalette& palette);
66 #endif
67
68 // wxGDIImage methods
69 #ifdef __WXMSW__
70 long GetHandle();
71 void SetHandle(long handle);
72 #endif
73 bool Ok();
74 int GetWidth();
75 int GetHeight();
76 int GetDepth();
77 void SetWidth(int w);
78 void SetHeight(int h);
79 void SetDepth(int d);
80 #ifdef __WXMSW__
81 void SetSize(const wxSize& size);
82 #endif
83 };
84
85
86 %new wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1);
87
88 #ifdef __WXMSW__
89 %new wxBitmap* wxBitmapFromData(PyObject* data, long type,
90 int width, int height, int depth = 1);
91 #endif
92
93 %{ // Alternate 'constructor'
94 wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1) {
95 return new wxBitmap(width, height, depth);
96 }
97
98 #ifdef __WXMSW__
99 wxBitmap* wxBitmapFromData(PyObject* data, long type,
100 int width, int height, int depth = 1) {
101 if (! PyString_Check(data)) {
102 PyErr_SetString(PyExc_TypeError, "Expected string object");
103 return NULL;
104 }
105
106 return new wxBitmap((void*)PyString_AsString(data), type, width, height, depth);
107 }
108 #endif
109 %}
110
111 //---------------------------------------------------------------------------
112
113 class wxMask {
114 public:
115 wxMask(const wxBitmap& bitmap);
116 //~wxMask();
117 };
118
119 %new wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour);
120 %{
121 wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour) {
122 return new wxMask(bitmap, colour);
123 }
124 %}
125
126
127 //---------------------------------------------------------------------------
128
129
130 class wxIcon
131 //: public wxGDIImage
132 {
133 public:
134 wxIcon(const wxString& name, long flags,
135 int desiredWidth = -1, int desiredHeight = -1);
136 ~wxIcon();
137
138 bool LoadFile(const wxString& name, long flags);
139
140 // wxGDIImage methods
141 #ifdef __WXMSW__
142 long GetHandle();
143 void SetHandle(long handle);
144 #endif
145 bool Ok();
146 int GetWidth();
147 int GetHeight();
148 int GetDepth();
149 void SetWidth(int w);
150 void SetHeight(int h);
151 void SetDepth(int d);
152 #ifdef __WXMSW__
153 void SetSize(const wxSize& size);
154 #endif
155 };
156
157
158 //---------------------------------------------------------------------------
159
160 class wxCursor
161 //: public wxGDIImage
162 {
163 public:
164 #ifdef __WXMSW__
165 wxCursor(const wxString& cursorName, long flags, int hotSpotX=0, int hotSpotY=0);
166 #endif
167 ~wxCursor();
168
169 // wxGDIImage methods
170 #ifdef __WXMSW__
171 long GetHandle();
172 void SetHandle(long handle);
173 #endif
174 bool Ok();
175 #ifdef __WXMSW__
176 int GetWidth();
177 int GetHeight();
178 int GetDepth();
179 void SetWidth(int w);
180 void SetHeight(int h);
181 void SetDepth(int d);
182 void SetSize(const wxSize& size);
183 #endif
184 };
185
186 %name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id);
187 %{ // Alternate 'constructor'
188 wxCursor* wxPyStockCursor(int id) {
189 return new wxCursor(id);
190 }
191 %}
192
193 //----------------------------------------------------------------------
194
195
196 enum wxFontEncoding
197 {
198 wxFONTENCODING_SYSTEM = -1, // system default
199 wxFONTENCODING_DEFAULT, // current default encoding
200
201 // ISO8859 standard defines a number of single-byte charsets
202 wxFONTENCODING_ISO8859_1, // West European (Latin1)
203 wxFONTENCODING_ISO8859_2, // Central and East European (Latin2)
204 wxFONTENCODING_ISO8859_3, // Esperanto (Latin3)
205 wxFONTENCODING_ISO8859_4, // Baltic languages (Estonian) (Latin4)
206 wxFONTENCODING_ISO8859_5, // Cyrillic
207 wxFONTENCODING_ISO8859_6, // Arabic
208 wxFONTENCODING_ISO8859_7, // Greek
209 wxFONTENCODING_ISO8859_8, // Hebrew
210 wxFONTENCODING_ISO8859_9, // Turkish (Latin5)
211 wxFONTENCODING_ISO8859_10, // Variation of Latin4 (Latin6)
212 wxFONTENCODING_ISO8859_11, // Thai
213 wxFONTENCODING_ISO8859_12, // doesn't exist currently, but put it
214 // here anyhow to make all ISO8859
215 // consecutive numbers
216 wxFONTENCODING_ISO8859_13, // Latin7
217 wxFONTENCODING_ISO8859_14, // Latin8
218 wxFONTENCODING_ISO8859_15, // Latin9 (a.k.a. Latin0, includes euro)
219
220 // Cyrillic charset soup (see http://czyborra.com/charsets/cyrillic.html)
221 wxFONTENCODING_KOI8, // we don't support any of KOI8 variants
222 wxFONTENCODING_ALTERNATIVE, // same as MS-DOS CP866
223 wxFONTENCODING_BULGARIAN, // used under Linux in Bulgaria
224
225 // what would we do without Microsoft? They have their own encodings
226 // for DOS
227 wxFONTENCODING_CP437, // original MS-DOS codepage
228 wxFONTENCODING_CP850, // CP437 merged with Latin1
229 wxFONTENCODING_CP852, // CP437 merged with Latin2
230 wxFONTENCODING_CP855, // another cyrillic encoding
231 wxFONTENCODING_CP866, // and another one
232 // and for Windows
233 wxFONTENCODING_CP1250, // WinLatin2
234 wxFONTENCODING_CP1251, // WinCyrillic
235 wxFONTENCODING_CP1252, // WinLatin1
236
237 wxFONTENCODING_MAX
238 };
239
240 class wxFont {
241 public:
242 // I'll do it this way to use long-lived objects and not have to
243 // worry about when python may delete the object.
244 %addmethods {
245 wxFont( int pointSize, int family, int style, int weight,
246 int underline=FALSE, char* faceName = "",
247 wxFontEncoding encoding=wxFONTENCODING_DEFAULT) {
248
249 return wxTheFontList->FindOrCreateFont(pointSize, family, style, weight,
250 underline, faceName, encoding);
251 }
252 // NO Destructor.
253 }
254
255 bool Ok();
256
257 wxString GetFaceName();
258 int GetFamily();
259 #ifdef __WXMSW__
260 int GetFontId();
261 #endif
262 int GetPointSize();
263 int GetStyle();
264 bool GetUnderlined();
265 int GetWeight();
266 wxFontEncoding GetEncoding();
267 void SetFaceName(const wxString& faceName);
268 void SetFamily(int family);
269 void SetPointSize(int pointSize);
270 void SetStyle(int style);
271 void SetUnderlined(bool underlined);
272 void SetWeight(int weight);
273 void SetEncoding(wxFontEncoding encoding);
274 wxString GetFamilyString();
275 wxString GetStyleString();
276 wxString GetWeightString();
277 };
278
279 %inline %{
280 wxFontEncoding wxFont_GetDefaultEncoding() {
281 return wxFont::GetDefaultEncoding();
282 }
283
284 void wxFont_SetDefaultEncoding(wxFontEncoding encoding) {
285 wxFont::SetDefaultEncoding(encoding);
286 }
287 %}
288
289 //----------------------------------------------------------------------
290
291 class wxColour {
292 public:
293 wxColour(unsigned char red=0, unsigned char green=0, unsigned char blue=0);
294 ~wxColour();
295 unsigned char Red();
296 unsigned char Green();
297 unsigned char Blue();
298 bool Ok();
299 void Set(unsigned char red, unsigned char green, unsigned char blue);
300 %addmethods {
301 PyObject* Get() {
302 PyObject* rv = PyTuple_New(3);
303 PyTuple_SetItem(rv, 0, PyInt_FromLong(self->Red()));
304 PyTuple_SetItem(rv, 1, PyInt_FromLong(self->Green()));
305 PyTuple_SetItem(rv, 2, PyInt_FromLong(self->Blue()));
306 return rv;
307 }
308 }
309 %pragma(python) addtoclass = "asTuple = Get"
310 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
311 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
312
313 };
314
315 %new wxColour* wxNamedColour(const wxString& colorName);
316 %{ // Alternate 'constructor'
317 wxColour* wxNamedColour(const wxString& colorName) {
318 return new wxColour(colorName);
319 }
320 %}
321
322
323 //----------------------------------------------------------------------
324
325 #ifdef __WXMSW__
326 typedef unsigned long wxDash;
327 #else
328 typedef char wxDash;
329 #endif
330
331
332 class wxPen {
333 public:
334 // I'll do it this way to use long-lived objects and not have to
335 // worry about when python may delete the object.
336 %addmethods {
337 wxPen(wxColour* colour, int width=1, int style=wxSOLID) {
338 return wxThePenList->FindOrCreatePen(*colour, width, style);
339 }
340 // NO Destructor.
341 }
342
343 int GetCap();
344 wxColour& GetColour();
345
346 int GetJoin();
347 int GetStyle();
348 int GetWidth();
349 bool Ok();
350 void SetCap(int cap_style);
351 void SetColour(wxColour& colour);
352 void SetJoin(int join_style);
353 void SetStyle(int style);
354 void SetWidth(int width);
355
356 // **** This one needs to return a list of ints (wxDash)
357 int GetDashes(wxDash **dashes);
358 void SetDashes(int LCOUNT, wxDash* choices);
359
360 #ifdef __WXMSW__
361 wxBitmap* GetStipple();
362 void SetStipple(wxBitmap& stipple);
363 #endif
364 };
365
366 //----------------------------------------------------------------------
367
368 class wxBrush {
369 public:
370 // I'll do it this way to use long-lived objects and not have to
371 // worry about when python may delete the object.
372 %addmethods {
373 wxBrush(const wxColour* colour, int style=wxSOLID) {
374 return wxTheBrushList->FindOrCreateBrush(*colour, style);
375 }
376 // NO Destructor.
377 }
378
379 // wxBrush(const wxColour& colour, int style=wxSOLID);
380
381 wxColour& GetColour();
382 wxBitmap * GetStipple();
383 int GetStyle();
384 bool Ok();
385 void SetColour(wxColour &colour);
386 void SetStipple(wxBitmap& bitmap);
387 void SetStyle(int style);
388 };
389
390 //----------------------------------------------------------------------
391
392
393
394 class wxDC {
395 public:
396 // wxDC(); **** abstract base class, can't instantiate.
397 ~wxDC();
398
399 void BeginDrawing();
400 // %name(BlitXY)
401 bool Blit(long xdest, long ydest,
402 long width, long height,
403 wxDC *source, long xsrc, long ysrc,
404 int logicalFunc = wxCOPY, int useMask = FALSE);
405 // bool Blit(const wxPoint& destPt, const wxSize& sz,
406 // wxDC *source, const wxPoint& srcPt,
407 // int logicalFunc = wxCOPY, int useMask = FALSE);
408
409 void Clear();
410 void CrossHair(long x, long y);
411 void DestroyClippingRegion();
412 long DeviceToLogicalX(long x);
413 long DeviceToLogicalXRel(long x);
414 long DeviceToLogicalY(long y);
415 long DeviceToLogicalYRel(long y);
416 void DrawArc(long x1, long y1, long x2, long y2, long xc, long yc);
417 void DrawCircle(long x, long y, long radius);
418 void DrawEllipse(long x, long y, long width, long height);
419 void DrawEllipticArc(long x, long y, long width, long height, long start, long end);
420 void DrawIcon(const wxIcon& icon, long x, long y);
421 void DrawLine(long x1, long y1, long x2, long y2);
422 void DrawLines(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0);
423 void DrawPolygon(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0,
424 int fill_style=wxODDEVEN_RULE);
425 void DrawPoint(long x, long y);
426 void DrawRectangle(long x, long y, long width, long height);
427 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
428 void DrawRoundedRectangle(long x, long y, long width, long height, long radius=20);
429 void DrawSpline(int PCOUNT, wxPoint* points);
430 void DrawText(const wxString& text, long x, long y);
431 void EndDoc();
432 void EndDrawing();
433 void EndPage();
434 void FloodFill(long x, long y, const wxColour& colour, int style=wxFLOOD_SURFACE);
435 wxBrush& GetBackground();
436 wxBrush& GetBrush();
437 long GetCharHeight();
438 long GetCharWidth();
439 void GetClippingBox(long *OUTPUT, long *OUTPUT,
440 long *OUTPUT, long *OUTPUT);
441 wxFont& GetFont();
442 int GetLogicalFunction();
443 void GetLogicalScale(double *OUTPUT, double *OUTPUT);
444 int GetMapMode();
445 bool GetOptimization();
446 wxPen& GetPen();
447 %addmethods {
448 %new wxColour* GetPixel(long x, long y) {
449 wxColour* wc = new wxColour();
450 self->GetPixel(x, y, wc);
451 return wc;
452 }
453 }
454 %name(GetSizeTuple)void GetSize(int* OUTPUT, int* OUTPUT);
455 wxSize GetSize();
456 wxSize GetSizeMM();
457 wxColour& GetTextBackground();
458 void GetTextExtent(const wxString& string, long *OUTPUT, long *OUTPUT);
459 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
460 long *OUTPUT, long *OUTPUT, long *OUTPUT, long* OUTPUT,
461 const wxFont* font = NULL);
462 wxColour& GetTextForeground();
463 void GetUserScale(double *OUTPUT, double *OUTPUT);
464 long LogicalToDeviceX(long x);
465 long LogicalToDeviceXRel(long x);
466 long LogicalToDeviceY(long y);
467 long LogicalToDeviceYRel(long y);
468 long MaxX();
469 long MaxY();
470 long MinX();
471 long MinY();
472 bool Ok();
473 void SetDeviceOrigin(long x, long y);
474 void SetBackground(const wxBrush& brush);
475 void SetBackgroundMode(int mode);
476 void SetClippingRegion(long x, long y, long width, long height);
477 void SetPalette(const wxPalette& colourMap);
478 void SetBrush(const wxBrush& brush);
479 void SetFont(const wxFont& font);
480 void SetLogicalFunction(int function);
481 void SetLogicalScale(double x, double y);
482 void SetMapMode(int mode);
483 void SetOptimization(bool optimize);
484 void SetPen(const wxPen& pen);
485 void SetTextBackground(const wxColour& colour);
486 void SetTextForeground(const wxColour& colour);
487 void SetUserScale(double x_scale, double y_scale);
488 bool StartDoc(const wxString& message);
489 void StartPage();
490
491
492
493 void DrawBitmap(const wxBitmap& bitmap, long x, long y,
494 int useMask = FALSE);
495
496 bool CanDrawBitmap();
497 bool CanGetTextExtent();
498 int GetDepth();
499 wxSize GetPPI();
500
501 void GetLogicalOrigin(int *OUTPUT, int *OUTPUT);
502 void SetLogicalOrigin(int x, int y);
503 void GetDeviceOrigin(int *OUTPUT, int *OUTPUT);
504 void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
505
506 };
507
508
509 //----------------------------------------------------------------------
510
511 class wxMemoryDC : public wxDC {
512 public:
513 wxMemoryDC();
514
515 void SelectObject(const wxBitmap& bitmap);
516 }
517
518 %new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC);
519 %{ // Alternate 'constructor'
520 wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) {
521 return new wxMemoryDC(oldDC);
522 }
523 %}
524
525
526 //---------------------------------------------------------------------------
527
528 class wxScreenDC : public wxDC {
529 public:
530 wxScreenDC();
531
532 %name(StartDrawingOnTopWin) bool StartDrawingOnTop(wxWindow* window);
533 bool StartDrawingOnTop(wxRect* rect = NULL);
534 bool EndDrawingOnTop();
535 };
536
537 //---------------------------------------------------------------------------
538
539 class wxClientDC : public wxDC {
540 public:
541 wxClientDC(wxWindow* win);
542 };
543
544 //---------------------------------------------------------------------------
545
546 class wxPaintDC : public wxDC {
547 public:
548 wxPaintDC(wxWindow* win);
549 };
550
551 //---------------------------------------------------------------------------
552
553 class wxWindowDC : public wxDC {
554 public:
555 wxWindowDC(wxWindow* win);
556 };
557
558 //---------------------------------------------------------------------------
559
560 #ifndef __WXMSW__
561 class wxPostScriptDC : public wxDC {
562 public:
563 wxPostScriptDC(const wxString& output, bool interactive = TRUE, wxWindow* win = NULL);
564 };
565 #endif
566
567 //---------------------------------------------------------------------------
568
569 #ifdef __WXMSW__
570 class wxPrinterDC : public wxDC {
571 public:
572 wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output,
573 bool interactive = TRUE, int orientation = wxPORTRAIT);
574 };
575 #endif
576
577 //---------------------------------------------------------------------------
578
579 #ifdef __WXMSW__
580 class wxMetaFileDC : public wxDC {
581 public:
582 wxMetaFileDC(const wxString& filename = wxPyEmptyStr);
583 wxMetaFile* Close();
584 };
585 #endif
586
587 //---------------------------------------------------------------------------
588 //---------------------------------------------------------------------------
589
590
591 %readonly
592 %{
593 #if 0
594 %}
595 extern wxFont *wxNORMAL_FONT;
596 extern wxFont *wxSMALL_FONT;
597 extern wxFont *wxITALIC_FONT;
598 extern wxFont *wxSWISS_FONT;
599
600 extern wxPen *wxRED_PEN;
601 extern wxPen *wxCYAN_PEN;
602 extern wxPen *wxGREEN_PEN;
603 extern wxPen *wxBLACK_PEN;
604 extern wxPen *wxWHITE_PEN;
605 extern wxPen *wxTRANSPARENT_PEN;
606 extern wxPen *wxBLACK_DASHED_PEN;
607 extern wxPen *wxGREY_PEN;
608 extern wxPen *wxMEDIUM_GREY_PEN;
609 extern wxPen *wxLIGHT_GREY_PEN;
610
611 extern wxBrush *wxBLUE_BRUSH;
612 extern wxBrush *wxGREEN_BRUSH;
613 extern wxBrush *wxWHITE_BRUSH;
614 extern wxBrush *wxBLACK_BRUSH;
615 extern wxBrush *wxTRANSPARENT_BRUSH;
616 extern wxBrush *wxCYAN_BRUSH;
617 extern wxBrush *wxRED_BRUSH;
618 extern wxBrush *wxGREY_BRUSH;
619 extern wxBrush *wxMEDIUM_GREY_BRUSH;
620 extern wxBrush *wxLIGHT_GREY_BRUSH;
621
622 extern wxColour *wxBLACK;
623 extern wxColour *wxWHITE;
624 extern wxColour *wxRED;
625 extern wxColour *wxBLUE;
626 extern wxColour *wxGREEN;
627 extern wxColour *wxCYAN;
628 extern wxColour *wxLIGHT_GREY;
629
630 extern wxCursor *wxSTANDARD_CURSOR;
631 extern wxCursor *wxHOURGLASS_CURSOR;
632 extern wxCursor *wxCROSS_CURSOR;
633
634 extern wxBitmap wxNullBitmap;
635 extern wxIcon wxNullIcon;
636 extern wxCursor wxNullCursor;
637 extern wxPen wxNullPen;
638 extern wxBrush wxNullBrush;
639 extern wxPalette wxNullPalette;
640 extern wxFont wxNullFont;
641 extern wxColour wxNullColour;
642
643 %readwrite
644 %{
645 #endif
646 %}
647
648 //---------------------------------------------------------------------------
649
650 class wxPalette {
651 public:
652 wxPalette(int LCOUNT, byte* choices, byte* choices, byte* choices);
653 ~wxPalette();
654
655 int GetPixel(byte red, byte green, byte blue);
656 bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT);
657 bool Ok();
658 };
659
660 //---------------------------------------------------------------------------
661
662 enum {
663 wxIMAGELIST_DRAW_NORMAL ,
664 wxIMAGELIST_DRAW_TRANSPARENT,
665 wxIMAGELIST_DRAW_SELECTED,
666 wxIMAGELIST_DRAW_FOCUSED,
667 wxIMAGE_LIST_NORMAL,
668 wxIMAGE_LIST_SMALL,
669 wxIMAGE_LIST_STATE
670 };
671
672 class wxImageList {
673 public:
674 wxImageList(int width, int height, int mask=TRUE, int initialCount=1);
675 ~wxImageList();
676
677 #ifdef __WXMSW__
678 int Add(const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
679 %name(AddWithColourMask)int Add(const wxBitmap& bitmap, const wxColour& maskColour);
680 %name(AddIcon)int Add(const wxIcon& icon);
681 bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
682 %name(ReplaceIcon)bool Replace(int index, const wxIcon& icon);
683 #else
684 int Add(const wxBitmap& bitmap);
685 bool Replace(int index, const wxBitmap& bitmap);
686 #endif
687
688 bool Draw(int index, wxDC& dc, int x, int x, int flags = wxIMAGELIST_DRAW_NORMAL,
689 const bool solidBackground = FALSE);
690
691 int GetImageCount();
692 bool Remove(int index);
693 bool RemoveAll();
694 };
695
696
697 //---------------------------------------------------------------------------
698