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