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