]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/gdi.i
7ed99fbc21b369e1dfcaf122d78efda6dfe6a4dc
[wxWidgets.git] / 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/imaglist.h>
19 #ifndef __WXMSW__
20 #include <wx/dcps.h>
21 #endif
22 #include <wx/fontmap.h>
23 #include <wx/fontenc.h>
24 #include <wx/fontmap.h>
25 #include <wx/fontutil.h>
26 %}
27
28 //----------------------------------------------------------------------
29
30 %include typemaps.i
31 %include my_typemaps.i
32
33 // Import some definitions of other classes, etc.
34 %import _defs.i
35 %import misc.i
36
37 %{
38 static wxString wxPyEmptyStr("");
39 %}
40
41 //---------------------------------------------------------------------------
42
43 class wxGDIObject : public wxObject {
44 public:
45 wxGDIObject();
46 ~wxGDIObject();
47
48 bool GetVisible();
49 void SetVisible( bool visible );
50
51 bool IsNull();
52
53 };
54
55 //---------------------------------------------------------------------------
56
57 class wxBitmap : public wxGDIObject
58 {
59 public:
60 wxBitmap(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_BMP);
61 ~wxBitmap();
62
63 wxPalette* GetPalette();
64 wxMask* GetMask();
65 bool LoadFile(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_BMP);
66 bool SaveFile(const wxString& name, wxBitmapType type, wxPalette* palette = NULL);
67 void SetMask(wxMask* mask);
68 #ifdef __WXMSW__
69 void SetPalette(wxPalette& palette);
70 #endif
71
72 // wxGDIImage methods
73 #ifdef __WXMSW__
74 long GetHandle();
75 void SetHandle(long handle);
76 #endif
77 bool Ok();
78 int GetWidth();
79 int GetHeight();
80 int GetDepth();
81 void SetWidth(int w);
82 void SetHeight(int h);
83 void SetDepth(int d);
84 #ifdef __WXMSW__
85 void SetSize(const wxSize& size);
86 #endif
87
88 wxBitmap GetSubBitmap( const wxRect& rect );
89 bool CopyFromIcon(const wxIcon& icon);
90 #ifdef __WXMSW__
91 bool CopyFromCursor(const wxCursor& cursor);
92 int GetQuality();
93 void SetQuality(int q);
94 #endif
95
96 %pragma(python) addtoclass = "
97 def __del__(self,gdic=gdic):
98 try:
99 if self.thisown == 1 :
100 gdic.delete_wxBitmap(self)
101 except:
102 pass
103 "
104 };
105
106
107 // Declarations of some alternate "constructors"
108 %new wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1);
109 %new wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings);
110 %new wxBitmap* wxBitmapFromIcon(const wxIcon& icon);
111 %new wxBitmap* wxBitmapFromBits(char* bits, int width, int height, int depth = 1 );
112
113 // #ifdef __WXMSW__
114 // %new wxBitmap* wxBitmapFromData(PyObject* data, long type,
115 // int width, int height, int depth = 1);
116 // #endif
117
118
119
120 %{ // Implementations of some alternate "constructors"
121
122 wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1) {
123 return new wxBitmap(width, height, depth);
124 }
125
126 static char** ConvertListOfStrings(PyObject* listOfStrings) {
127 char** cArray = NULL;
128 int count;
129
130 if (!PyList_Check(listOfStrings)) {
131 PyErr_SetString(PyExc_TypeError, "Expected a list of strings.");
132 return NULL;
133 }
134 count = PyList_Size(listOfStrings);
135 cArray = new char*[count];
136
137 for(int x=0; x<count; x++) {
138 // TODO: Need some validation and error checking here
139 cArray[x] = PyString_AsString(PyList_GET_ITEM(listOfStrings, x));
140 }
141 return cArray;
142 }
143
144
145 wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings) {
146 char** cArray = NULL;
147 wxBitmap* bmp;
148
149 cArray = ConvertListOfStrings(listOfStrings);
150 if (! cArray)
151 return NULL;
152 bmp = new wxBitmap(cArray);
153 delete [] cArray;
154 return bmp;
155 }
156
157
158 wxBitmap* wxBitmapFromIcon(const wxIcon& icon) {
159 return new wxBitmap(icon);
160 }
161
162
163 wxBitmap* wxBitmapFromBits(char* bits, int width, int height, int depth = 1 ) {
164 return new wxBitmap(bits, width, height, depth);
165 }
166
167
168 // #ifdef __WXMSW__
169 // wxBitmap* wxBitmapFromData(PyObject* data, long type,
170 // int width, int height, int depth = 1) {
171 // if (! PyString_Check(data)) {
172 // PyErr_SetString(PyExc_TypeError, "Expected string object");
173 // return NULL;
174 // }
175 // return new wxBitmap((void*)PyString_AsString(data), type, width, height, depth);
176 // }
177 // #endif
178 %}
179
180 //---------------------------------------------------------------------------
181
182 class wxMask : public wxObject {
183 public:
184 wxMask(const wxBitmap& bitmap);
185 //~wxMask();
186
187 %addmethods { void Destroy() { delete self; } }
188 };
189
190 %new wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour);
191 %{
192 wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour) {
193 return new wxMask(bitmap, colour);
194 }
195 %}
196
197
198 //---------------------------------------------------------------------------
199
200
201 class wxIcon : public wxGDIObject
202 {
203 public:
204 wxIcon(const wxString& name, long flags,
205 int desiredWidth = -1, int desiredHeight = -1);
206 ~wxIcon();
207
208 bool LoadFile(const wxString& name, long flags);
209
210 // wxGDIImage methods
211 #ifdef __WXMSW__
212 long GetHandle();
213 void SetHandle(long handle);
214 #endif
215 bool Ok();
216 int GetWidth();
217 int GetHeight();
218 int GetDepth();
219 void SetWidth(int w);
220 void SetHeight(int h);
221 void SetDepth(int d);
222 #ifdef __WXMSW__
223 void SetSize(const wxSize& size);
224 #endif
225 void CopyFromBitmap(const wxBitmap& bmp);
226
227 %pragma(python) addtoclass = "
228 def __del__(self,gdic=gdic):
229 try:
230 if self.thisown == 1 :
231 gdic.delete_wxIcon(self)
232 except:
233 pass
234 "
235 };
236
237
238 // Declarations of some alternate "constructors"
239 %new wxIcon* wxEmptyIcon();
240 %new wxIcon* wxIconFromXPMData(PyObject* listOfStrings);
241
242 %{ // Implementations of some alternate "constructors"
243 wxIcon* wxEmptyIcon() {
244 return new wxIcon();
245 }
246
247 wxIcon* wxIconFromXPMData(PyObject* listOfStrings) {
248 char** cArray = NULL;
249 wxIcon* icon;
250
251 cArray = ConvertListOfStrings(listOfStrings);
252 if (! cArray)
253 return NULL;
254 icon = new wxIcon(cArray);
255 delete [] cArray;
256 return icon;
257 }
258 %}
259
260 //---------------------------------------------------------------------------
261
262 class wxCursor : public wxGDIObject
263 {
264 public:
265 #ifdef __WXMSW__
266 wxCursor(const wxString& cursorName, long flags, int hotSpotX=0, int hotSpotY=0);
267 #endif
268 ~wxCursor();
269
270 // wxGDIImage methods
271 #ifdef __WXMSW__
272 long GetHandle();
273 void SetHandle(long handle);
274 #endif
275 bool Ok();
276 #ifdef __WXMSW__
277 int GetWidth();
278 int GetHeight();
279 int GetDepth();
280 void SetWidth(int w);
281 void SetHeight(int h);
282 void SetDepth(int d);
283 void SetSize(const wxSize& size);
284 #endif
285 };
286
287 %name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id);
288 %{ // Alternate 'constructor'
289 wxCursor* wxPyStockCursor(int id) {
290 return new wxCursor(id);
291 }
292 %}
293
294 //----------------------------------------------------------------------
295
296
297 enum wxFontFamily
298 {
299 wxFONTFAMILY_DEFAULT = wxDEFAULT,
300 wxFONTFAMILY_DECORATIVE = wxDECORATIVE,
301 wxFONTFAMILY_ROMAN = wxROMAN,
302 wxFONTFAMILY_SCRIPT = wxSCRIPT,
303 wxFONTFAMILY_SWISS = wxSWISS,
304 wxFONTFAMILY_MODERN = wxMODERN,
305 wxFONTFAMILY_TELETYPE = wxTELETYPE,
306 wxFONTFAMILY_MAX
307 };
308
309 // font styles
310 enum wxFontStyle
311 {
312 wxFONTSTYLE_NORMAL = wxNORMAL,
313 wxFONTSTYLE_ITALIC = wxITALIC,
314 wxFONTSTYLE_SLANT = wxSLANT,
315 wxFONTSTYLE_MAX
316 };
317
318 // font weights
319 enum wxFontWeight
320 {
321 wxFONTWEIGHT_NORMAL = wxNORMAL,
322 wxFONTWEIGHT_LIGHT = wxLIGHT,
323 wxFONTWEIGHT_BOLD = wxBOLD,
324 wxFONTWEIGHT_MAX
325 };
326
327
328 // font encodings
329 enum wxFontEncoding
330 {
331 wxFONTENCODING_SYSTEM = -1, // system default
332 wxFONTENCODING_DEFAULT, // current default encoding
333
334 // ISO8859 standard defines a number of single-byte charsets
335 wxFONTENCODING_ISO8859_1, // West European (Latin1)
336 wxFONTENCODING_ISO8859_2, // Central and East European (Latin2)
337 wxFONTENCODING_ISO8859_3, // Esperanto (Latin3)
338 wxFONTENCODING_ISO8859_4, // Baltic (old) (Latin4)
339 wxFONTENCODING_ISO8859_5, // Cyrillic
340 wxFONTENCODING_ISO8859_6, // Arabic
341 wxFONTENCODING_ISO8859_7, // Greek
342 wxFONTENCODING_ISO8859_8, // Hebrew
343 wxFONTENCODING_ISO8859_9, // Turkish (Latin5)
344 wxFONTENCODING_ISO8859_10, // Variation of Latin4 (Latin6)
345 wxFONTENCODING_ISO8859_11, // Thai
346 wxFONTENCODING_ISO8859_12, // doesn't exist currently, but put it
347 // here anyhow to make all ISO8859
348 // consecutive numbers
349 wxFONTENCODING_ISO8859_13, // Baltic (Latin7)
350 wxFONTENCODING_ISO8859_14, // Latin8
351 wxFONTENCODING_ISO8859_15, // Latin9 (a.k.a. Latin0, includes euro)
352 wxFONTENCODING_ISO8859_MAX,
353
354 // Cyrillic charset soup (see http://czyborra.com/charsets/cyrillic.html)
355 wxFONTENCODING_KOI8, // we don't support any of KOI8 variants
356 wxFONTENCODING_ALTERNATIVE, // same as MS-DOS CP866
357 wxFONTENCODING_BULGARIAN, // used under Linux in Bulgaria
358
359 // what would we do without Microsoft? They have their own encodings
360 // for DOS
361 wxFONTENCODING_CP437, // original MS-DOS codepage
362 wxFONTENCODING_CP850, // CP437 merged with Latin1
363 wxFONTENCODING_CP852, // CP437 merged with Latin2
364 wxFONTENCODING_CP855, // another cyrillic encoding
365 wxFONTENCODING_CP866, // and another one
366 // and for Windows
367 wxFONTENCODING_CP874, // WinThai
368 wxFONTENCODING_CP1250, // WinLatin2
369 wxFONTENCODING_CP1251, // WinCyrillic
370 wxFONTENCODING_CP1252, // WinLatin1
371 wxFONTENCODING_CP1253, // WinGreek (8859-7)
372 wxFONTENCODING_CP1254, // WinTurkish
373 wxFONTENCODING_CP1255, // WinHebrew
374 wxFONTENCODING_CP1256, // WinArabic
375 wxFONTENCODING_CP1257, // WinBaltic (same as Latin 7)
376 wxFONTENCODING_CP12_MAX,
377
378 wxFONTENCODING_UTF7, // UTF-7 Unicode encoding
379 wxFONTENCODING_UTF8, // UTF-8 Unicode encoding
380
381 wxFONTENCODING_UNICODE, // Unicode - currently used only by
382 // wxEncodingConverter class
383
384 wxFONTENCODING_MAX
385 };
386
387
388
389 // wxNativeFontInfo is platform-specific font representation: this struct
390 // should be considered as opaque font description only used by the native
391 // functions, the user code can only get the objects of this type from
392 // somewhere and pass it somewhere else (possibly save them somewhere using
393 // ToString() and restore them using FromString())
394 struct wxNativeFontInfo
395 {
396 // it is important to be able to serialize wxNativeFontInfo objects to be
397 // able to store them (in config file, for example)
398 bool FromString(const wxString& s);
399 wxString ToString() const;
400
401 %addmethods {
402 wxString __str__() {
403 return self->ToString();
404 }
405 }
406 };
407
408
409 // wxFontMapper manages user-definable correspondence between logical font
410 // names and the fonts present on the machine.
411 //
412 // The default implementations of all functions will ask the user if they are
413 // not capable of finding the answer themselves and store the answer in a
414 // config file (configurable via SetConfigXXX functions). This behaviour may
415 // be disabled by giving the value of FALSE to "interactive" parameter.
416 // However, the functions will always consult the config file to allow the
417 // user-defined values override the default logic and there is no way to
418 // disable this - which shouldn't be ever needed because if "interactive" was
419 // never TRUE, the config file is never created anyhow.
420 class wxFontMapper
421 {
422 public:
423 wxFontMapper();
424 ~wxFontMapper();
425
426
427 // find an alternative for the given encoding (which is supposed to not be
428 // available on this system). If successful, return TRUE and rwxFontEcoding
429 // that can be used it wxFont ctor otherwise return FALSE
430 //bool GetAltForEncoding(wxFontEncoding encoding,
431 // wxFontEncoding *alt_encoding,
432 // const wxString& facename = wxEmptyString,
433 // bool interactive = TRUE);
434
435
436 // Find an alternative for the given encoding (which is supposed to not be
437 // available on this system). If successful, returns the encoding otherwise
438 // returns None.
439 %addmethods {
440 PyObject* GetAltForEncoding(wxFontEncoding encoding,
441 const wxString& facename = wxEmptyString,
442 bool interactive = TRUE) {
443 wxFontEncoding alt_enc;
444 if (self->GetAltForEncoding(encoding, &alt_enc, facename, interactive))
445 return PyInt_FromLong(alt_enc);
446 else {
447 Py_INCREF(Py_None);
448 return Py_None;
449 }
450 }
451 }
452
453
454 // checks whether given encoding is available in given face or not.
455 // If no facename is given,
456 bool IsEncodingAvailable(wxFontEncoding encoding,
457 const wxString& facename = wxEmptyString);
458
459 // returns the encoding for the given charset (in the form of RFC 2046) or
460 // wxFONTENCODING_SYSTEM if couldn't decode it
461 wxFontEncoding CharsetToEncoding(const wxString& charset,
462 bool interactive = TRUE);
463
464 // return internal string identifier for the encoding (see also
465 // GetEncodingDescription())
466 static wxString GetEncodingName(wxFontEncoding encoding);
467
468 // return user-readable string describing the given encoding
469 //
470 // NB: hard-coded now, but might change later (read it from config?)
471 static wxString GetEncodingDescription(wxFontEncoding encoding);
472
473 // the parent window for modal dialogs
474 void SetDialogParent(wxWindow *parent);
475
476 // the title for the dialogs (note that default is quite reasonable)
477 void SetDialogTitle(const wxString& title);
478
479 // functions which allow to configure the config object used: by default,
480 // the global one (from wxConfigBase::Get() will be used) and the default
481 // root path for the config settings is the string returned by
482 // GetDefaultConfigPath()
483
484
485 // set the config object to use (may be NULL to use default)
486 void SetConfig(wxConfigBase *config);
487
488 // set the root config path to use (should be an absolute path)
489 void SetConfigPath(const wxString& prefix);
490
491 // return default config path
492 static const wxChar *GetDefaultConfigPath();
493 };
494
495
496
497
498 class wxFont : public wxGDIObject {
499 public:
500 wxFont( int pointSize, int family, int style, int weight,
501 int underline=FALSE, char* faceName = "",
502 wxFontEncoding encoding=wxFONTENCODING_DEFAULT);
503
504 %name(wxFontFromNativeInfo)wxFont(const wxNativeFontInfo& info);
505
506 ~wxFont();
507
508 bool Ok() const;
509 int GetPointSize() const;
510 int GetFamily() const;
511 int GetStyle() const;
512 int GetWeight() const;
513 bool GetUnderlined() const;
514 wxString GetFaceName() const;
515 wxFontEncoding GetEncoding() const;
516 wxNativeFontInfo* GetNativeFontInfo() const;
517
518 void SetPointSize(int pointSize);
519 void SetFamily(int family);
520 void SetStyle(int style);
521 void SetWeight(int weight);
522 void SetFaceName(const wxString& faceName);
523 void SetUnderlined(bool underlined);
524 void SetEncoding(wxFontEncoding encoding);
525 void SetNativeFontInfo(const wxNativeFontInfo& info);
526
527 wxString GetFamilyString() const;
528 wxString GetStyleString() const;
529 wxString GetWeightString() const;
530
531 static wxFontEncoding GetDefaultEncoding();
532 static void SetDefaultEncoding(wxFontEncoding encoding);
533
534 };
535
536
537 class wxFontList : public wxObject {
538 public:
539
540 void AddFont(wxFont* font);
541 wxFont * FindOrCreateFont(int point_size, int family, int style, int weight,
542 bool underline = FALSE, const char* facename = NULL,
543 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
544 void RemoveFont(wxFont *font);
545 };
546
547
548 //----------------------------------------------------------------------
549
550 class wxColour : public wxObject {
551 public:
552 wxColour(unsigned char red=0, unsigned char green=0, unsigned char blue=0);
553 ~wxColour();
554 unsigned char Red();
555 unsigned char Green();
556 unsigned char Blue();
557 bool Ok();
558 void Set(unsigned char red, unsigned char green, unsigned char blue);
559 %addmethods {
560 PyObject* Get() {
561 PyObject* rv = PyTuple_New(3);
562 PyTuple_SetItem(rv, 0, PyInt_FromLong(self->Red()));
563 PyTuple_SetItem(rv, 1, PyInt_FromLong(self->Green()));
564 PyTuple_SetItem(rv, 2, PyInt_FromLong(self->Blue()));
565 return rv;
566 }
567 }
568 %pragma(python) addtoclass = "asTuple = Get"
569 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
570 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
571
572 };
573
574 %new wxColour* wxNamedColour(const wxString& colorName);
575
576 %{ // Alternate 'constructor'
577 wxColour* wxNamedColour(const wxString& colorName) {
578 return new wxColour(colorName);
579 }
580 %}
581
582
583
584 class wxColourDatabase : public wxObject {
585 public:
586
587 wxColour *FindColour(const wxString& colour);
588 wxString FindName(const wxColour& colour) const;
589
590 %addmethods {
591 void Append(const wxString& name, int red, int green, int blue) {
592 self->Append(name.c_str(), new wxColour(red, green, blue));
593 }
594 }
595 };
596
597
598 //----------------------------------------------------------------------
599
600 class wxPen : public wxGDIObject {
601 public:
602 wxPen(wxColour& colour, int width=1, int style=wxSOLID);
603 ~wxPen();
604
605 int GetCap();
606 wxColour GetColour();
607
608 int GetJoin();
609 int GetStyle();
610 int GetWidth();
611 bool Ok();
612 void SetCap(int cap_style);
613 void SetColour(wxColour& colour);
614 void SetJoin(int join_style);
615 void SetStyle(int style);
616 void SetWidth(int width);
617
618 // **** This one needs to return a list of ints (wxDash)
619 //int GetDashes(wxDash **dashes);
620 void SetDashes(int LCOUNT, wxDash* choices);
621
622 #ifdef __WXMSW__
623 wxBitmap* GetStipple();
624 void SetStipple(wxBitmap& stipple);
625 #endif
626 };
627
628
629
630 %{
631 class wxPyPen : public wxPen {
632 public:
633 wxPyPen(wxColour& colour, int width=1, int style=wxSOLID)
634 : wxPen(colour, width, style)
635 { m_dash = NULL; }
636 ~wxPyPen() {
637 if (m_dash)
638 delete m_dash;
639 }
640
641 void SetDashes(int nb_dashes, const wxDash *dash) {
642 m_dash = new wxDash[nb_dashes];
643 for (int i=0; i<nb_dashes; i++)
644 m_dash[i] = dash[i];
645 wxPen::SetDashes(nb_dashes, m_dash);
646 }
647
648 private:
649 wxDash* m_dash;
650 };
651 %}
652
653
654
655 class wxPyPen : public wxPen {
656 public:
657 wxPyPen(wxColour& colour, int width=1, int style=wxSOLID);
658 ~wxPyPen();
659
660 void SetDashes(int LCOUNT, wxDash* choices);
661 };
662
663
664
665 class wxPenList : public wxObject {
666 public:
667
668 void AddPen(wxPen* pen);
669 wxPen* FindOrCreatePen(const wxColour& colour, int width, int style);
670 void RemovePen(wxPen* pen);
671 };
672
673
674
675 //----------------------------------------------------------------------
676
677 class wxBrush : public wxGDIObject {
678 public:
679 wxBrush(const wxColour& colour, int style=wxSOLID);
680 ~wxBrush();
681
682 wxColour GetColour();
683 wxBitmap * GetStipple();
684 int GetStyle();
685 bool Ok();
686 void SetColour(wxColour &colour);
687 void SetStipple(wxBitmap& bitmap);
688 void SetStyle(int style);
689 };
690
691
692 class wxBrushList : public wxObject {
693 public:
694
695 void AddBrush(wxBrush *brush);
696 wxBrush * FindOrCreateBrush(const wxColour& colour, int style);
697 void RemoveBrush(wxBrush *brush);
698 };
699
700 //----------------------------------------------------------------------
701
702
703
704 class wxDC : public wxObject {
705 public:
706 // wxDC(); **** abstract base class, can't instantiate.
707 ~wxDC();
708
709 void BeginDrawing();
710 // %name(BlitXY)
711 bool Blit(long xdest, long ydest,
712 long width, long height,
713 wxDC *source, long xsrc, long ysrc,
714 int logicalFunc = wxCOPY, int useMask = FALSE);
715 // bool Blit(const wxPoint& destPt, const wxSize& sz,
716 // wxDC *source, const wxPoint& srcPt,
717 // int logicalFunc = wxCOPY, int useMask = FALSE);
718
719 void Clear();
720 void CrossHair(long x, long y);
721 void DestroyClippingRegion();
722 long DeviceToLogicalX(long x);
723 long DeviceToLogicalXRel(long x);
724 long DeviceToLogicalY(long y);
725 long DeviceToLogicalYRel(long y);
726 void DrawArc(long x1, long y1, long x2, long y2, long xc, long yc);
727 void DrawCircle(long x, long y, long radius);
728 void DrawEllipse(long x, long y, long width, long height);
729 void DrawEllipticArc(long x, long y, long width, long height, long start, long end);
730 void DrawIcon(const wxIcon& icon, long x, long y);
731 void DrawLine(long x1, long y1, long x2, long y2);
732 void DrawLines(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0);
733 void DrawPolygon(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0,
734 int fill_style=wxODDEVEN_RULE);
735 void DrawPoint(long x, long y);
736 void DrawRectangle(long x, long y, long width, long height);
737 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
738 void DrawRoundedRectangle(long x, long y, long width, long height, long radius=20);
739 void DrawSpline(int PCOUNT, wxPoint* points);
740 void DrawText(const wxString& text, long x, long y);
741 void EndDoc();
742 void EndDrawing();
743 void EndPage();
744 void FloodFill(long x, long y, const wxColour& colour, int style=wxFLOOD_SURFACE);
745 wxBrush& GetBackground();
746 wxBrush& GetBrush();
747 long GetCharHeight();
748 long GetCharWidth();
749 void GetClippingBox(long *OUTPUT, long *OUTPUT,
750 long *OUTPUT, long *OUTPUT);
751 wxFont& GetFont();
752 int GetLogicalFunction();
753 void GetLogicalScale(double *OUTPUT, double *OUTPUT);
754 int GetMapMode();
755 bool GetOptimization();
756 wxPen& GetPen();
757 %addmethods {
758 %new wxColour* GetPixel(long x, long y) {
759 wxColour* wc = new wxColour();
760 self->GetPixel(x, y, wc);
761 return wc;
762 }
763 }
764 %name(GetSizeTuple)void GetSize(int* OUTPUT, int* OUTPUT);
765 wxSize GetSize();
766 wxSize GetSizeMM();
767 wxColour GetTextBackground();
768 void GetTextExtent(const wxString& string, long *OUTPUT, long *OUTPUT);
769 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
770 long *OUTPUT, long *OUTPUT, long *OUTPUT, long* OUTPUT,
771 const wxFont* font = NULL);
772 wxColour GetTextForeground();
773 void GetUserScale(double *OUTPUT, double *OUTPUT);
774 long LogicalToDeviceX(long x);
775 long LogicalToDeviceXRel(long x);
776 long LogicalToDeviceY(long y);
777 long LogicalToDeviceYRel(long y);
778 long MaxX();
779 long MaxY();
780 long MinX();
781 long MinY();
782 bool Ok();
783 void SetDeviceOrigin(long x, long y);
784 void SetBackground(const wxBrush& brush);
785 void SetBackgroundMode(int mode);
786 void SetClippingRegion(long x, long y, long width, long height);
787 %name(SetClippingRegionAsRegion) void SetClippingRegion(const wxRegion& region);
788 void SetPalette(const wxPalette& colourMap);
789 void SetBrush(const wxBrush& brush);
790 void SetFont(const wxFont& font);
791 void SetLogicalFunction(int function);
792 void SetLogicalScale(double x, double y);
793 void SetMapMode(int mode);
794 void SetOptimization(bool optimize);
795 void SetPen(const wxPen& pen);
796 void SetTextBackground(const wxColour& colour);
797 void SetTextForeground(const wxColour& colour);
798 void SetUserScale(double x_scale, double y_scale);
799 bool StartDoc(const wxString& message);
800 void StartPage();
801
802
803
804 void DrawBitmap(const wxBitmap& bitmap, long x, long y,
805 int useMask = FALSE);
806
807 bool CanDrawBitmap();
808 bool CanGetTextExtent();
809 int GetDepth();
810 wxSize GetPPI();
811
812 void GetLogicalOrigin(int *OUTPUT, int *OUTPUT);
813 void SetLogicalOrigin(int x, int y);
814 void GetDeviceOrigin(int *OUTPUT, int *OUTPUT);
815 void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
816
817 void CalcBoundingBox(int x, int y);
818 void ResetBoundingBox();
819
820 %addmethods {
821 void GetBoundingBox(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
822 // See below for implementation
823 }
824
825 #ifdef __WXMSW__
826 long GetHDC();
827 #endif
828
829
830 %addmethods {
831 // NOTE: These methods are VERY SIMILAR in implentation. It would be
832 // nice to factor out common code and or turn them into a set of
833 // template-like macros.
834
835 // Draw a point for every set of coordinants in pyPoints, optionally
836 // setting a new pen for each
837 PyObject* _DrawPointList(PyObject* pyPoints, PyObject* pyPens) {
838 bool isFastSeq = PyList_Check(pyPoints) || PyTuple_Check(pyPoints);
839 bool isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens);
840 int numObjs = 0;
841 int numPens = 0;
842 wxPen* pen;
843 PyObject* obj;
844 int x1, y1;
845 int i = 0;
846
847 if (!PySequence_Check(pyPoints)) {
848 goto err0;
849 }
850 if (!PySequence_Check(pyPens)) {
851 goto err1;
852 }
853 numObjs = PySequence_Length(pyPoints);
854 numPens = PySequence_Length(pyPens);
855
856 for (i = 0; i < numObjs; i++) {
857 // Use a new pen?
858 if (i < numPens) {
859 if (isFastPens) {
860 obj = PySequence_Fast_GET_ITEM(pyPens, i);
861 }
862 else {
863 obj = PySequence_GetItem(pyPens, i);
864 }
865 if (SWIG_GetPtrObj(obj, (void **) &pen, "_wxPen_p")) {
866 if (!isFastPens)
867 Py_DECREF(obj);
868 goto err1;
869 }
870
871 self->SetPen(*pen);
872 if (!isFastPens)
873 Py_DECREF(obj);
874 }
875
876 // Get the point coordinants
877 if (isFastSeq) {
878 obj = PySequence_Fast_GET_ITEM(pyPoints, i);
879 }
880 else {
881 obj = PySequence_GetItem(pyPoints, i);
882 }
883 if (! _2int_seq_helper(obj, &x1, &y1)) {
884 if (!isFastPens)
885 Py_DECREF(obj);
886 goto err0;
887 }
888
889 // Now draw the point
890 self->DrawPoint(x1, y1);
891
892 if (!isFastSeq)
893 Py_DECREF(obj);
894 }
895
896 Py_INCREF(Py_None);
897 return Py_None;
898
899 err1:
900 PyErr_SetString(PyExc_TypeError, "Expected a sequence of wxPens");
901 return NULL;
902 err0:
903 PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x,y) sequences.");
904 return NULL;
905 }
906
907
908 // Draw a line for every set of coordinants in pyLines, optionally
909 // setting a new pen for each
910 PyObject* _DrawLineList(PyObject* pyLines, PyObject* pyPens) {
911 bool isFastSeq = PyList_Check(pyLines) || PyTuple_Check(pyLines);
912 bool isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens);
913 int numObjs = 0;
914 int numPens = 0;
915 wxPen* pen;
916 PyObject* obj;
917 int x1, y1, x2, y2;
918 int i = 0;
919
920 if (!PySequence_Check(pyLines)) {
921 goto err0;
922 }
923 if (!PySequence_Check(pyPens)) {
924 goto err1;
925 }
926 numObjs = PySequence_Length(pyLines);
927 numPens = PySequence_Length(pyPens);
928
929 for (i = 0; i < numObjs; i++) {
930 // Use a new pen?
931 if (i < numPens) {
932 if (isFastPens) {
933 obj = PySequence_Fast_GET_ITEM(pyPens, i);
934 }
935 else {
936 obj = PySequence_GetItem(pyPens, i);
937 }
938 if (SWIG_GetPtrObj(obj, (void **) &pen, "_wxPen_p")) {
939 if (!isFastPens)
940 Py_DECREF(obj);
941 goto err1;
942 }
943
944 self->SetPen(*pen);
945 if (!isFastPens)
946 Py_DECREF(obj);
947 }
948
949 // Get the line coordinants
950 if (isFastSeq) {
951 obj = PySequence_Fast_GET_ITEM(pyLines, i);
952 }
953 else {
954 obj = PySequence_GetItem(pyLines, i);
955 }
956 if (! _4int_seq_helper(obj, &x1, &y1, &x2, &y2)) {
957 if (!isFastPens)
958 Py_DECREF(obj);
959 goto err0;
960 }
961
962 // Now draw the line
963 self->DrawLine(x1, y1, x2, y2);
964
965 if (!isFastSeq)
966 Py_DECREF(obj);
967 }
968
969 Py_INCREF(Py_None);
970 return Py_None;
971
972 err1:
973 PyErr_SetString(PyExc_TypeError, "Expected a sequence of wxPens");
974 return NULL;
975 err0:
976 PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x1,y1, x2,y2) sequences.");
977 return NULL;
978 }
979 }
980
981
982 %pragma(python) addtoclass = "
983 def DrawPointList(self, points, pens=None):
984 if pens is None:
985 pens = []
986 elif isinstance(pens, wxPenPtr):
987 pens = [pens]
988 elif len(pens) != len(points):
989 raise ValueError('points and pens must have same length')
990 return self._DrawPointList(points, pens)
991
992 def DrawLineList(self, lines, pens=None):
993 if pens is None:
994 pens = []
995 elif isinstance(pens, wxPenPtr):
996 pens = [pens]
997 elif len(pens) != len(lines):
998 raise ValueError('lines and pens must have same length')
999 return self._DrawLineList(lines, pens)
1000 "
1001
1002
1003 };
1004
1005
1006
1007 %{
1008 static void wxDC_GetBoundingBox(wxDC* dc, int* x1, int* y1, int* x2, int* y2) {
1009 *x1 = dc->MinX();
1010 *y1 = dc->MinY();
1011 *x2 = dc->MaxX();
1012 *y2 = dc->MaxY();
1013 }
1014 %}
1015
1016 //----------------------------------------------------------------------
1017
1018 class wxMemoryDC : public wxDC {
1019 public:
1020 wxMemoryDC();
1021
1022 void SelectObject(const wxBitmap& bitmap);
1023 }
1024
1025 %new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC);
1026 %{ // Alternate 'constructor'
1027 wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) {
1028 return new wxMemoryDC(oldDC);
1029 }
1030 %}
1031
1032
1033 //---------------------------------------------------------------------------
1034
1035 class wxScreenDC : public wxDC {
1036 public:
1037 wxScreenDC();
1038
1039 %name(StartDrawingOnTopWin) bool StartDrawingOnTop(wxWindow* window);
1040 bool StartDrawingOnTop(wxRect* rect = NULL);
1041 bool EndDrawingOnTop();
1042 };
1043
1044 //---------------------------------------------------------------------------
1045
1046 class wxClientDC : public wxDC {
1047 public:
1048 wxClientDC(wxWindow* win);
1049 };
1050
1051 //---------------------------------------------------------------------------
1052
1053 class wxPaintDC : public wxDC {
1054 public:
1055 wxPaintDC(wxWindow* win);
1056 };
1057
1058 //---------------------------------------------------------------------------
1059
1060 class wxWindowDC : public wxDC {
1061 public:
1062 wxWindowDC(wxWindow* win);
1063 };
1064
1065 //---------------------------------------------------------------------------
1066
1067 #ifndef __WXMSW__
1068 class wxPostScriptDC : public wxDC {
1069 public:
1070 wxPostScriptDC(const wxString& output, bool interactive = TRUE, wxWindow* win = NULL);
1071 };
1072 #endif
1073
1074 //---------------------------------------------------------------------------
1075
1076
1077 #ifdef __WXMSW__
1078
1079 %{
1080 #include <wx/metafile.h>
1081 %}
1082
1083 class wxMetaFile : public wxObject {
1084 public:
1085 wxMetaFile(const wxString& filename = wxPyEmptyStr);
1086 ~wxMetaFile();
1087
1088 bool Ok();
1089 bool SetClipboard(int width = 0, int height = 0);
1090
1091 wxSize GetSize();
1092 int GetWidth();
1093 int GetHeight();
1094
1095 const wxString& GetFileName() const { return m_filename; }
1096
1097 };
1098
1099 // bool wxMakeMetaFilePlaceable(const wxString& filename,
1100 // int minX, int minY, int maxX, int maxY, float scale=1.0);
1101
1102
1103 class wxMetaFileDC : public wxDC {
1104 public:
1105 wxMetaFileDC(const wxString& filename = wxPyEmptyStr,
1106 int width = 0, int height = 0,
1107 const wxString& description = wxPyEmptyStr);
1108 wxMetaFile* Close();
1109 };
1110
1111 #endif
1112
1113 //---------------------------------------------------------------------------
1114 //---------------------------------------------------------------------------
1115
1116
1117 %readonly
1118 %{
1119 #if 0
1120 %}
1121 extern wxFont *wxNORMAL_FONT;
1122 extern wxFont *wxSMALL_FONT;
1123 extern wxFont *wxITALIC_FONT;
1124 extern wxFont *wxSWISS_FONT;
1125
1126 extern wxPen *wxRED_PEN;
1127 extern wxPen *wxCYAN_PEN;
1128 extern wxPen *wxGREEN_PEN;
1129 extern wxPen *wxBLACK_PEN;
1130 extern wxPen *wxWHITE_PEN;
1131 extern wxPen *wxTRANSPARENT_PEN;
1132 extern wxPen *wxBLACK_DASHED_PEN;
1133 extern wxPen *wxGREY_PEN;
1134 extern wxPen *wxMEDIUM_GREY_PEN;
1135 extern wxPen *wxLIGHT_GREY_PEN;
1136
1137 extern wxBrush *wxBLUE_BRUSH;
1138 extern wxBrush *wxGREEN_BRUSH;
1139 extern wxBrush *wxWHITE_BRUSH;
1140 extern wxBrush *wxBLACK_BRUSH;
1141 extern wxBrush *wxTRANSPARENT_BRUSH;
1142 extern wxBrush *wxCYAN_BRUSH;
1143 extern wxBrush *wxRED_BRUSH;
1144 extern wxBrush *wxGREY_BRUSH;
1145 extern wxBrush *wxMEDIUM_GREY_BRUSH;
1146 extern wxBrush *wxLIGHT_GREY_BRUSH;
1147
1148 extern wxColour *wxBLACK;
1149 extern wxColour *wxWHITE;
1150 extern wxColour *wxRED;
1151 extern wxColour *wxBLUE;
1152 extern wxColour *wxGREEN;
1153 extern wxColour *wxCYAN;
1154 extern wxColour *wxLIGHT_GREY;
1155
1156 extern wxCursor *wxSTANDARD_CURSOR;
1157 extern wxCursor *wxHOURGLASS_CURSOR;
1158 extern wxCursor *wxCROSS_CURSOR;
1159
1160 extern wxBitmap wxNullBitmap;
1161 extern wxIcon wxNullIcon;
1162 extern wxCursor wxNullCursor;
1163 extern wxPen wxNullPen;
1164 extern wxBrush wxNullBrush;
1165 extern wxPalette wxNullPalette;
1166 extern wxFont wxNullFont;
1167 extern wxColour wxNullColour;
1168
1169
1170 extern wxFontList* wxTheFontList;
1171 extern wxPenList* wxThePenList;
1172 extern wxBrushList* wxTheBrushList;
1173 extern wxColourDatabase* wxTheColourDatabase;
1174
1175
1176 %readwrite
1177 %{
1178 #endif
1179 %}
1180
1181 //---------------------------------------------------------------------------
1182
1183 class wxPalette : public wxGDIObject {
1184 public:
1185 wxPalette(int LCOUNT, byte* choices, byte* choices, byte* choices);
1186 ~wxPalette();
1187
1188 int GetPixel(byte red, byte green, byte blue);
1189 bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT);
1190 bool Ok();
1191 };
1192
1193 //---------------------------------------------------------------------------
1194
1195 enum {
1196 wxIMAGELIST_DRAW_NORMAL ,
1197 wxIMAGELIST_DRAW_TRANSPARENT,
1198 wxIMAGELIST_DRAW_SELECTED,
1199 wxIMAGELIST_DRAW_FOCUSED,
1200 wxIMAGE_LIST_NORMAL,
1201 wxIMAGE_LIST_SMALL,
1202 wxIMAGE_LIST_STATE
1203 };
1204
1205 class wxImageList : public wxObject {
1206 public:
1207 wxImageList(int width, int height, int mask=TRUE, int initialCount=1);
1208 ~wxImageList();
1209
1210 int Add(const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
1211 %name(AddWithColourMask)int Add(const wxBitmap& bitmap, const wxColour& maskColour);
1212 %name(AddIcon)int Add(const wxIcon& icon);
1213 #ifdef __WXMSW__
1214 bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
1215 #else
1216 // %name(ReplaceIcon)bool Replace(int index, const wxIcon& icon);
1217 // int Add(const wxBitmap& bitmap);
1218 bool Replace(int index, const wxBitmap& bitmap);
1219 #endif
1220
1221 bool Draw(int index, wxDC& dc, int x, int x, int flags = wxIMAGELIST_DRAW_NORMAL,
1222 const bool solidBackground = FALSE);
1223
1224 int GetImageCount();
1225 bool Remove(int index);
1226 bool RemoveAll();
1227 void GetSize(int index, int& OUTPUT, int& OUTPUT);
1228 };
1229
1230
1231 //---------------------------------------------------------------------------
1232 // Regions, etc.
1233
1234 enum wxRegionContain {
1235 wxOutRegion, wxPartRegion, wxInRegion
1236 };
1237
1238
1239 class wxRegion : public wxGDIObject {
1240 public:
1241 wxRegion(long x=0, long y=0, long width=0, long height=0);
1242 ~wxRegion();
1243
1244 void Clear();
1245 wxRegionContain Contains(long x, long y);
1246 %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt);
1247 %name(ContainsRect)wxRegionContain Contains(const wxRect& rect);
1248 %name(ContainsRectDim)wxRegionContain Contains(long x, long y, long w, long h);
1249
1250 wxRect GetBox();
1251
1252 bool Intersect(long x, long y, long width, long height);
1253 %name(IntersectRect)bool Intersect(const wxRect& rect);
1254 %name(IntersectRegion)bool Intersect(const wxRegion& region);
1255
1256 bool IsEmpty();
1257
1258 bool Union(long x, long y, long width, long height);
1259 %name(UnionRect)bool Union(const wxRect& rect);
1260 %name(UnionRegion)bool Union(const wxRegion& region);
1261
1262 bool Subtract(long x, long y, long width, long height);
1263 %name(SubtractRect)bool Subtract(const wxRect& rect);
1264 %name(SubtractRegion)bool Subtract(const wxRegion& region);
1265
1266 bool Xor(long x, long y, long width, long height);
1267 %name(XorRect)bool Xor(const wxRect& rect);
1268 %name(XorRegion)bool Xor(const wxRegion& region);
1269 };
1270
1271
1272
1273 class wxRegionIterator : public wxObject {
1274 public:
1275 wxRegionIterator(const wxRegion& region);
1276 ~wxRegionIterator();
1277
1278 long GetX();
1279 long GetY();
1280 long GetW();
1281 long GetWidth();
1282 long GetH();
1283 long GetHeight();
1284 wxRect GetRect();
1285 bool HaveRects();
1286 void Reset();
1287
1288 %addmethods {
1289 void Next() {
1290 (*self) ++;
1291 }
1292 };
1293 };
1294
1295
1296 //---------------------------------------------------------------------------
1297