]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/gdi.i
Committing in .
[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
326 class wxPen {
327 public:
328 // I'll do it this way to use long-lived objects and not have to
329 // worry about when python may delete the object.
330 %addmethods {
331 wxPen(wxColour* colour, int width=1, int style=wxSOLID) {
332 return wxThePenList->FindOrCreatePen(*colour, width, style);
333 }
334 // NO Destructor.
335 }
336
337 int GetCap();
338 wxColour& GetColour();
339
340 int GetJoin();
341 int GetStyle();
342 int GetWidth();
343 bool Ok();
344 void SetCap(int cap_style);
345 void SetColour(wxColour& colour);
346 void SetJoin(int join_style);
347 void SetStyle(int style);
348 void SetWidth(int width);
349
350 // **** This one needs to return a list of ints (wxDash)
351 int GetDashes(wxDash **dashes);
352 void SetDashes(int LCOUNT, wxDash* choices);
353
354 #ifdef __WXMSW__
355 wxBitmap* GetStipple();
356 void SetStipple(wxBitmap& stipple);
357 #endif
358 };
359
360 //----------------------------------------------------------------------
361
362 class wxBrush {
363 public:
364 // I'll do it this way to use long-lived objects and not have to
365 // worry about when python may delete the object.
366 %addmethods {
367 wxBrush(const wxColour* colour, int style=wxSOLID) {
368 return wxTheBrushList->FindOrCreateBrush(*colour, style);
369 }
370 // NO Destructor.
371 }
372
373 // wxBrush(const wxColour& colour, int style=wxSOLID);
374
375 wxColour& GetColour();
376 wxBitmap * GetStipple();
377 int GetStyle();
378 bool Ok();
379 void SetColour(wxColour &colour);
380 void SetStipple(wxBitmap& bitmap);
381 void SetStyle(int style);
382 };
383
384 //----------------------------------------------------------------------
385
386
387
388 class wxDC {
389 public:
390 // wxDC(); **** abstract base class, can't instantiate.
391 ~wxDC();
392
393 void BeginDrawing();
394 // %name(BlitXY)
395 bool Blit(long xdest, long ydest,
396 long width, long height,
397 wxDC *source, long xsrc, long ysrc,
398 int logicalFunc = wxCOPY, int useMask = FALSE);
399 // bool Blit(const wxPoint& destPt, const wxSize& sz,
400 // wxDC *source, const wxPoint& srcPt,
401 // int logicalFunc = wxCOPY, int useMask = FALSE);
402
403 void Clear();
404 void CrossHair(long x, long y);
405 void DestroyClippingRegion();
406 long DeviceToLogicalX(long x);
407 long DeviceToLogicalXRel(long x);
408 long DeviceToLogicalY(long y);
409 long DeviceToLogicalYRel(long y);
410 void DrawArc(long x1, long y1, long x2, long y2, long xc, long yc);
411 void DrawCircle(long x, long y, long radius);
412 void DrawEllipse(long x, long y, long width, long height);
413 void DrawEllipticArc(long x, long y, long width, long height, long start, long end);
414 void DrawIcon(const wxIcon& icon, long x, long y);
415 void DrawLine(long x1, long y1, long x2, long y2);
416 void DrawLines(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0);
417 void DrawPolygon(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0,
418 int fill_style=wxODDEVEN_RULE);
419 void DrawPoint(long x, long y);
420 void DrawRectangle(long x, long y, long width, long height);
421 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
422 void DrawRoundedRectangle(long x, long y, long width, long height, long radius=20);
423 void DrawSpline(int PCOUNT, wxPoint* points);
424 void DrawText(const wxString& text, long x, long y);
425 void EndDoc();
426 void EndDrawing();
427 void EndPage();
428 void FloodFill(long x, long y, const wxColour& colour, int style=wxFLOOD_SURFACE);
429 wxBrush& GetBackground();
430 wxBrush& GetBrush();
431 long GetCharHeight();
432 long GetCharWidth();
433 void GetClippingBox(long *OUTPUT, long *OUTPUT,
434 long *OUTPUT, long *OUTPUT);
435 wxFont& GetFont();
436 int GetLogicalFunction();
437 void GetLogicalScale(double *OUTPUT, double *OUTPUT);
438 int GetMapMode();
439 bool GetOptimization();
440 wxPen& GetPen();
441 %addmethods {
442 %new wxColour* GetPixel(long x, long y) {
443 wxColour* wc = new wxColour();
444 self->GetPixel(x, y, wc);
445 return wc;
446 }
447 }
448 %name(GetSizeTuple)void GetSize(int* OUTPUT, int* OUTPUT);
449 wxSize GetSize();
450 wxSize GetSizeMM();
451 wxColour& GetTextBackground();
452 void GetTextExtent(const wxString& string, long *OUTPUT, long *OUTPUT);
453 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
454 long *OUTPUT, long *OUTPUT, long *OUTPUT, long* OUTPUT,
455 const wxFont* font = NULL);
456 wxColour& GetTextForeground();
457 void GetUserScale(double *OUTPUT, double *OUTPUT);
458 long LogicalToDeviceX(long x);
459 long LogicalToDeviceXRel(long x);
460 long LogicalToDeviceY(long y);
461 long LogicalToDeviceYRel(long y);
462 long MaxX();
463 long MaxY();
464 long MinX();
465 long MinY();
466 bool Ok();
467 void SetDeviceOrigin(long x, long y);
468 void SetBackground(const wxBrush& brush);
469 void SetBackgroundMode(int mode);
470 void SetClippingRegion(long x, long y, long width, long height);
471 void SetPalette(const wxPalette& colourMap);
472 void SetBrush(const wxBrush& brush);
473 void SetFont(const wxFont& font);
474 void SetLogicalFunction(int function);
475 void SetLogicalScale(double x, double y);
476 void SetMapMode(int mode);
477 void SetOptimization(bool optimize);
478 void SetPen(const wxPen& pen);
479 void SetTextBackground(const wxColour& colour);
480 void SetTextForeground(const wxColour& colour);
481 void SetUserScale(double x_scale, double y_scale);
482 bool StartDoc(const wxString& message);
483 void StartPage();
484
485
486
487 void DrawBitmap(const wxBitmap& bitmap, long x, long y,
488 int useMask = FALSE);
489
490 bool CanDrawBitmap();
491 bool CanGetTextExtent();
492 int GetDepth();
493 wxSize GetPPI();
494
495 void GetLogicalOrigin(int *OUTPUT, int *OUTPUT);
496 void SetLogicalOrigin(int x, int y);
497 void GetDeviceOrigin(int *OUTPUT, int *OUTPUT);
498 void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
499
500 };
501
502
503 //----------------------------------------------------------------------
504
505 class wxMemoryDC : public wxDC {
506 public:
507 wxMemoryDC();
508
509 void SelectObject(const wxBitmap& bitmap);
510 }
511
512 %new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC);
513 %{ // Alternate 'constructor'
514 wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) {
515 return new wxMemoryDC(oldDC);
516 }
517 %}
518
519
520 //---------------------------------------------------------------------------
521
522 class wxScreenDC : public wxDC {
523 public:
524 wxScreenDC();
525
526 %name(StartDrawingOnTopWin) bool StartDrawingOnTop(wxWindow* window);
527 bool StartDrawingOnTop(wxRect* rect = NULL);
528 bool EndDrawingOnTop();
529 };
530
531 //---------------------------------------------------------------------------
532
533 class wxClientDC : public wxDC {
534 public:
535 wxClientDC(wxWindow* win);
536 };
537
538 //---------------------------------------------------------------------------
539
540 class wxPaintDC : public wxDC {
541 public:
542 wxPaintDC(wxWindow* win);
543 };
544
545 //---------------------------------------------------------------------------
546
547 class wxWindowDC : public wxDC {
548 public:
549 wxWindowDC(wxWindow* win);
550 };
551
552 //---------------------------------------------------------------------------
553
554 #ifndef __WXMSW__
555 class wxPostScriptDC : public wxDC {
556 public:
557 wxPostScriptDC(const wxString& output, bool interactive = TRUE, wxWindow* win = NULL);
558 };
559 #endif
560
561 //---------------------------------------------------------------------------
562
563 #ifdef __WXMSW__
564 class wxPrinterDC : public wxDC {
565 public:
566 wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output,
567 bool interactive = TRUE, int orientation = wxPORTRAIT);
568 };
569 #endif
570
571 //---------------------------------------------------------------------------
572
573 #ifdef __WXMSW__
574 class wxMetaFileDC : public wxDC {
575 public:
576 wxMetaFileDC(const wxString& filename = wxPyEmptyStr);
577 wxMetaFile* Close();
578 };
579 #endif
580
581 //---------------------------------------------------------------------------
582 //---------------------------------------------------------------------------
583
584
585 %readonly
586 %{
587 #if 0
588 %}
589 extern wxFont *wxNORMAL_FONT;
590 extern wxFont *wxSMALL_FONT;
591 extern wxFont *wxITALIC_FONT;
592 extern wxFont *wxSWISS_FONT;
593
594 extern wxPen *wxRED_PEN;
595 extern wxPen *wxCYAN_PEN;
596 extern wxPen *wxGREEN_PEN;
597 extern wxPen *wxBLACK_PEN;
598 extern wxPen *wxWHITE_PEN;
599 extern wxPen *wxTRANSPARENT_PEN;
600 extern wxPen *wxBLACK_DASHED_PEN;
601 extern wxPen *wxGREY_PEN;
602 extern wxPen *wxMEDIUM_GREY_PEN;
603 extern wxPen *wxLIGHT_GREY_PEN;
604
605 extern wxBrush *wxBLUE_BRUSH;
606 extern wxBrush *wxGREEN_BRUSH;
607 extern wxBrush *wxWHITE_BRUSH;
608 extern wxBrush *wxBLACK_BRUSH;
609 extern wxBrush *wxTRANSPARENT_BRUSH;
610 extern wxBrush *wxCYAN_BRUSH;
611 extern wxBrush *wxRED_BRUSH;
612 extern wxBrush *wxGREY_BRUSH;
613 extern wxBrush *wxMEDIUM_GREY_BRUSH;
614 extern wxBrush *wxLIGHT_GREY_BRUSH;
615
616 extern wxColour *wxBLACK;
617 extern wxColour *wxWHITE;
618 extern wxColour *wxRED;
619 extern wxColour *wxBLUE;
620 extern wxColour *wxGREEN;
621 extern wxColour *wxCYAN;
622 extern wxColour *wxLIGHT_GREY;
623
624 extern wxCursor *wxSTANDARD_CURSOR;
625 extern wxCursor *wxHOURGLASS_CURSOR;
626 extern wxCursor *wxCROSS_CURSOR;
627
628 extern wxBitmap wxNullBitmap;
629 extern wxIcon wxNullIcon;
630 extern wxCursor wxNullCursor;
631 extern wxPen wxNullPen;
632 extern wxBrush wxNullBrush;
633 extern wxPalette wxNullPalette;
634 extern wxFont wxNullFont;
635 extern wxColour wxNullColour;
636
637 %readwrite
638 %{
639 #endif
640 %}
641
642 //---------------------------------------------------------------------------
643
644 class wxPalette {
645 public:
646 wxPalette(int LCOUNT, byte* choices, byte* choices, byte* choices);
647 ~wxPalette();
648
649 int GetPixel(byte red, byte green, byte blue);
650 bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT);
651 bool Ok();
652 };
653
654 //---------------------------------------------------------------------------
655
656 enum {
657 wxIMAGELIST_DRAW_NORMAL ,
658 wxIMAGELIST_DRAW_TRANSPARENT,
659 wxIMAGELIST_DRAW_SELECTED,
660 wxIMAGELIST_DRAW_FOCUSED,
661 wxIMAGE_LIST_NORMAL,
662 wxIMAGE_LIST_SMALL,
663 wxIMAGE_LIST_STATE
664 };
665
666 class wxImageList {
667 public:
668 wxImageList(int width, int height, int mask=TRUE, int initialCount=1);
669 ~wxImageList();
670
671 #ifdef __WXMSW__
672 int Add(const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
673 %name(AddWithColourMask)int Add(const wxBitmap& bitmap, const wxColour& maskColour);
674 %name(AddIcon)int Add(const wxIcon& icon);
675 bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
676 %name(ReplaceIcon)bool Replace(int index, const wxIcon& icon);
677 #else
678 int Add(const wxBitmap& bitmap);
679 bool Replace(int index, const wxBitmap& bitmap);
680 #endif
681
682 bool Draw(int index, wxDC& dc, int x, int x, int flags = wxIMAGELIST_DRAW_NORMAL,
683 const bool solidBackground = FALSE);
684
685 int GetImageCount();
686 bool Remove(int index);
687 bool RemoveAll();
688 };
689
690
691 //---------------------------------------------------------------------------
692