]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/gdi.i
added wcslen prototype declaration for Darwin/FreeBSD, wcslen is in wxchar.cpp
[wxWidgets.git] / wxPython / src / gdi.i
CommitLineData
7bf85405
RD
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
03e9bead
RD
14%module gdi
15
16%{
7bf85405 17#include "helpers.h"
af309447 18#include <wx/imaglist.h>
6d8b4f8d
RD
19#include <wx/fontmap.h>
20#include <wx/fontenc.h>
21#include <wx/fontmap.h>
22#include <wx/fontutil.h>
7bf85405
RD
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
b68dc582
RD
34%{
35 static wxString wxPyEmptyStr("");
36%}
37
7bf85405
RD
38//---------------------------------------------------------------------------
39
9416aa89
RD
40class wxGDIObject : public wxObject {
41public:
42 wxGDIObject();
43 ~wxGDIObject();
44
45 bool GetVisible();
46 void SetVisible( bool visible );
47
48 bool IsNull();
49
50};
6999b0d8
RD
51
52//---------------------------------------------------------------------------
53
9416aa89 54class wxBitmap : public wxGDIObject
5bff6bb8 55{
7bf85405 56public:
e6056257 57 wxBitmap(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_BMP);
7bf85405
RD
58 ~wxBitmap();
59
7bf85405
RD
60 wxPalette* GetPalette();
61 wxMask* GetMask();
e6056257
RD
62 bool LoadFile(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_BMP);
63 bool SaveFile(const wxString& name, wxBitmapType type, wxPalette* palette = NULL);
7bf85405 64 void SetMask(wxMask* mask);
fb5e0af0 65#ifdef __WXMSW__
b8b8dda7 66 void SetPalette(wxPalette& palette);
fb5e0af0 67#endif
5bff6bb8
RD
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
f6bcfd97
BP
84
85 wxBitmap GetSubBitmap( const wxRect& rect );
f6bcfd97 86 bool CopyFromIcon(const wxIcon& icon);
ecc08ead 87#ifdef __WXMSW__
f6bcfd97
BP
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"
7bf85405
RD
101};
102
5bff6bb8 103
96bfd053 104// Declarations of some alternate "constructors"
7bf85405 105%new wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1);
96bfd053
RD
106%new wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings);
107%new wxBitmap* wxBitmapFromIcon(const wxIcon& icon);
d56cebe7 108%new wxBitmap* wxBitmapFromBits(char* bits, int width, int height, int depth = 1 );
9c039d08 109
d56cebe7
RD
110// #ifdef __WXMSW__
111// %new wxBitmap* wxBitmapFromData(PyObject* data, long type,
112// int width, int height, int depth = 1);
113// #endif
8bf5d46e 114
96bfd053
RD
115
116
117%{ // Implementations of some alternate "constructors"
118
7bf85405
RD
119 wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1) {
120 return new wxBitmap(width, height, depth);
121 }
122
96bfd053
RD
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
d56cebe7 141
96bfd053
RD
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
d56cebe7
RD
160 wxBitmap* wxBitmapFromBits(char* bits, int width, int height, int depth = 1 ) {
161 return new wxBitmap(bits, width, height, depth);
162 }
926bb76c 163
4c9993c3 164
d56cebe7
RD
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
7bf85405
RD
175%}
176
177//---------------------------------------------------------------------------
178
9416aa89 179class wxMask : public wxObject {
7bf85405
RD
180public:
181 wxMask(const wxBitmap& bitmap);
eb715945 182 //~wxMask();
96bfd053
RD
183
184 %addmethods { void Destroy() { delete self; } }
7bf85405
RD
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
9416aa89 198class wxIcon : public wxGDIObject
5bff6bb8 199{
7bf85405 200public:
fb5e0af0
RD
201 wxIcon(const wxString& name, long flags,
202 int desiredWidth = -1, int desiredHeight = -1);
7bf85405
RD
203 ~wxIcon();
204
7bf85405 205 bool LoadFile(const wxString& name, long flags);
5bff6bb8
RD
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
96bfd053
RD
222 void CopyFromBitmap(const wxBitmap& bmp);
223
f6bcfd97
BP
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"
7bf85405
RD
232};
233
8bf5d46e 234
96bfd053
RD
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
7bf85405
RD
257//---------------------------------------------------------------------------
258
9416aa89 259class wxCursor : public wxGDIObject
5bff6bb8 260{
7bf85405 261public:
fb5e0af0 262#ifdef __WXMSW__
7bf85405 263 wxCursor(const wxString& cursorName, long flags, int hotSpotX=0, int hotSpotY=0);
fb5e0af0 264#endif
7bf85405 265 ~wxCursor();
5bff6bb8
RD
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
7bf85405
RD
282};
283
9c039d08 284%name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id);
7bf85405 285%{ // Alternate 'constructor'
9c039d08 286 wxCursor* wxPyStockCursor(int id) {
7bf85405
RD
287 return new wxCursor(id);
288 }
289%}
290
291//----------------------------------------------------------------------
292
f0261a72 293
6d8b4f8d
RD
294enum 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
307enum wxFontStyle
308{
309 wxFONTSTYLE_NORMAL = wxNORMAL,
310 wxFONTSTYLE_ITALIC = wxITALIC,
311 wxFONTSTYLE_SLANT = wxSLANT,
312 wxFONTSTYLE_MAX
313};
314
315// font weights
316enum wxFontWeight
317{
318 wxFONTWEIGHT_NORMAL = wxNORMAL,
319 wxFONTWEIGHT_LIGHT = wxLIGHT,
320 wxFONTWEIGHT_BOLD = wxBOLD,
321 wxFONTWEIGHT_MAX
322};
323
324
325// font encodings
f0261a72
RD
326enum 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)
6d8b4f8d 335 wxFONTENCODING_ISO8859_4, // Baltic (old) (Latin4)
f0261a72
RD
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
6d8b4f8d 346 wxFONTENCODING_ISO8859_13, // Baltic (Latin7)
f0261a72
RD
347 wxFONTENCODING_ISO8859_14, // Latin8
348 wxFONTENCODING_ISO8859_15, // Latin9 (a.k.a. Latin0, includes euro)
6d8b4f8d 349 wxFONTENCODING_ISO8859_MAX,
f0261a72
RD
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
6d8b4f8d 364 wxFONTENCODING_CP874, // WinThai
f0261a72
RD
365 wxFONTENCODING_CP1250, // WinLatin2
366 wxFONTENCODING_CP1251, // WinCyrillic
367 wxFONTENCODING_CP1252, // WinLatin1
6d8b4f8d
RD
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
f0261a72
RD
380
381 wxFONTENCODING_MAX
382};
383
0569df0f 384
6d8b4f8d
RD
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())
391struct 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.
417class wxFontMapper
418{
419public:
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
9416aa89 495class wxFont : public wxGDIObject {
7bf85405 496public:
0569df0f
RD
497 wxFont( int pointSize, int family, int style, int weight,
498 int underline=FALSE, char* faceName = "",
499 wxFontEncoding encoding=wxFONTENCODING_DEFAULT);
6d8b4f8d
RD
500
501 %name(wxFontFromNativeInfo)wxFont(const wxNativeFontInfo& info);
502
0569df0f 503 ~wxFont();
7bf85405 504
6d8b4f8d
RD
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
7bf85405 515 void SetPointSize(int pointSize);
6d8b4f8d 516 void SetFamily(int family);
7bf85405 517 void SetStyle(int style);
7bf85405 518 void SetWeight(int weight);
6d8b4f8d
RD
519 void SetFaceName(const wxString& faceName);
520 void SetUnderlined(bool underlined);
f0261a72 521 void SetEncoding(wxFontEncoding encoding);
6d8b4f8d 522 void SetNativeFontInfo(const wxNativeFontInfo& info);
7bf85405 523
6d8b4f8d
RD
524 wxString GetFamilyString() const;
525 wxString GetStyleString() const;
526 wxString GetWeightString() const;
f0261a72 527
6d8b4f8d
RD
528 static wxFontEncoding GetDefaultEncoding();
529 static void SetDefaultEncoding(wxFontEncoding encoding);
530
531};
f0261a72 532
0569df0f 533
9416aa89 534class wxFontList : public wxObject {
0569df0f
RD
535public:
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
7bf85405
RD
545//----------------------------------------------------------------------
546
9416aa89 547class wxColour : public wxObject {
7bf85405
RD
548public:
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 }
9b3d3bc4
RD
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
7bf85405
RD
569};
570
571%new wxColour* wxNamedColour(const wxString& colorName);
de20db99 572
7bf85405
RD
573%{ // Alternate 'constructor'
574 wxColour* wxNamedColour(const wxString& colorName) {
575 return new wxColour(colorName);
576 }
577%}
578
579
7bf85405 580
9416aa89 581class wxColourDatabase : public wxObject {
7bf85405 582public:
0569df0f
RD
583
584 wxColour *FindColour(const wxString& colour);
585 wxString FindName(const wxColour& colour) const;
586
7bf85405 587 %addmethods {
0569df0f
RD
588 void Append(const wxString& name, int red, int green, int blue) {
589 self->Append(name.c_str(), new wxColour(red, green, blue));
7bf85405 590 }
7bf85405 591 }
0569df0f
RD
592};
593
594
595//----------------------------------------------------------------------
596
9416aa89 597class wxPen : public wxGDIObject {
0569df0f
RD
598public:
599 wxPen(wxColour& colour, int width=1, int style=wxSOLID);
600 ~wxPen();
7bf85405
RD
601
602 int GetCap();
25832b3f 603 wxColour GetColour();
7bf85405 604
fb5e0af0 605 int GetJoin();
7bf85405
RD
606 int GetStyle();
607 int GetWidth();
608 bool Ok();
609 void SetCap(int cap_style);
610 void SetColour(wxColour& colour);
aeeb6a44
RR
611 void SetJoin(int join_style);
612 void SetStyle(int style);
613 void SetWidth(int width);
08127323 614
aeeb6a44 615 // **** This one needs to return a list of ints (wxDash)
ecc08ead 616 //int GetDashes(wxDash **dashes);
eec92d76 617 void SetDashes(int LCOUNT, wxDash* choices);
6999b0d8
RD
618
619#ifdef __WXMSW__
620 wxBitmap* GetStipple();
b8b8dda7 621 void SetStipple(wxBitmap& stipple);
fb5e0af0 622#endif
7bf85405
RD
623};
624
0569df0f 625
ecc08ead
RD
626
627%{
628class wxPyPen : public wxPen {
629public:
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
645private:
646 wxDash* m_dash;
647};
648%}
649
650
651
652class wxPyPen : public wxPen {
653public:
654 wxPyPen(wxColour& colour, int width=1, int style=wxSOLID);
655 ~wxPyPen();
656
657 void SetDashes(int LCOUNT, wxDash* choices);
658};
659
660
661
9416aa89 662class wxPenList : public wxObject {
0569df0f
RD
663public:
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
7bf85405
RD
672//----------------------------------------------------------------------
673
9416aa89 674class wxBrush : public wxGDIObject {
7bf85405 675public:
0569df0f
RD
676 wxBrush(const wxColour& colour, int style=wxSOLID);
677 ~wxBrush();
26b9cf27 678
25832b3f 679 wxColour GetColour();
7bf85405
RD
680 wxBitmap * GetStipple();
681 int GetStyle();
682 bool Ok();
683 void SetColour(wxColour &colour);
b8b8dda7 684 void SetStipple(wxBitmap& bitmap);
7bf85405
RD
685 void SetStyle(int style);
686};
687
0569df0f 688
6ee2116b 689class wxBrushList : public wxObject {
0569df0f
RD
690public:
691
692 void AddBrush(wxBrush *brush);
693 wxBrush * FindOrCreateBrush(const wxColour& colour, int style);
694 void RemoveBrush(wxBrush *brush);
695};
696
7bf85405
RD
697//----------------------------------------------------------------------
698
699
700
9416aa89 701class wxDC : public wxObject {
7bf85405 702public:
fb5e0af0 703// wxDC(); **** abstract base class, can't instantiate.
7bf85405
RD
704 ~wxDC();
705
706 void BeginDrawing();
efc5f224
RD
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
7bf85405
RD
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);
bb0054cd 724 void DrawCircle(long x, long y, long radius);
7bf85405
RD
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);
eec92d76
RD
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,
7bf85405
RD
731 int fill_style=wxODDEVEN_RULE);
732 void DrawPoint(long x, long y);
733 void DrawRectangle(long x, long y, long width, long height);
6999b0d8 734 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
7bf85405 735 void DrawRoundedRectangle(long x, long y, long width, long height, long radius=20);
eec92d76 736 void DrawSpline(int PCOUNT, wxPoint* points);
7bf85405
RD
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);
b8b8dda7
RD
742 wxBrush& GetBackground();
743 wxBrush& GetBrush();
7bf85405
RD
744 long GetCharHeight();
745 long GetCharWidth();
746 void GetClippingBox(long *OUTPUT, long *OUTPUT,
747 long *OUTPUT, long *OUTPUT);
b8b8dda7 748 wxFont& GetFont();
7bf85405 749 int GetLogicalFunction();
eec92d76 750 void GetLogicalScale(double *OUTPUT, double *OUTPUT);
7bf85405
RD
751 int GetMapMode();
752 bool GetOptimization();
b8b8dda7 753 wxPen& GetPen();
fb5e0af0
RD
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 }
bb0054cd
RD
761 %name(GetSizeTuple)void GetSize(int* OUTPUT, int* OUTPUT);
762 wxSize GetSize();
eec92d76 763 wxSize GetSizeMM();
25832b3f 764 wxColour GetTextBackground();
af309447
RD
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);
25832b3f 769 wxColour GetTextForeground();
eec92d76 770 void GetUserScale(double *OUTPUT, double *OUTPUT);
7bf85405
RD
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);
19a97bd6 784 %name(SetClippingRegionAsRegion) void SetClippingRegion(const wxRegion& region);
7bf85405
RD
785 void SetPalette(const wxPalette& colourMap);
786 void SetBrush(const wxBrush& brush);
787 void SetFont(const wxFont& font);
788 void SetLogicalFunction(int function);
eec92d76 789 void SetLogicalScale(double x, double y);
7bf85405
RD
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
efc5f224
RD
800
801 void DrawBitmap(const wxBitmap& bitmap, long x, long y,
802 int useMask = FALSE);
803
eec92d76
RD
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);
eec92d76
RD
812 void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
813
f6bcfd97
BP
814 void CalcBoundingBox(int x, int y);
815 void ResetBoundingBox();
c7e7022c 816
9d37f964
RD
817 %addmethods {
818 void GetBoundingBox(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
819 // See below for implementation
820 }
821
c7e7022c
RD
822#ifdef __WXMSW__
823 long GetHDC();
824#endif
9d37f964
RD
825
826
827 %addmethods {
76e280e7 828 // NOTE: These methods are VERY SIMILAR in implentation. It would be
17c0e08c 829 // nice to factor out common code and or turn them into a set of
76e280e7
RD
830 // template-like macros.
831
9d37f964
RD
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")) {
76e280e7
RD
863 if (!isFastPens)
864 Py_DECREF(obj);
9d37f964
RD
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)) {
76e280e7
RD
881 if (!isFastPens)
882 Py_DECREF(obj);
9d37f964
RD
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")) {
76e280e7
RD
936 if (!isFastPens)
937 Py_DECREF(obj);
9d37f964
RD
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)) {
76e280e7
RD
954 if (!isFastPens)
955 Py_DECREF(obj);
9d37f964
RD
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
7bf85405
RD
1000};
1001
1002
9d37f964
RD
1003
1004%{
1005static 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
7bf85405
RD
1013//----------------------------------------------------------------------
1014
1015class wxMemoryDC : public wxDC {
1016public:
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
1032class wxScreenDC : public wxDC {
1033public:
1034 wxScreenDC();
1035
26b9cf27
RD
1036 %name(StartDrawingOnTopWin) bool StartDrawingOnTop(wxWindow* window);
1037 bool StartDrawingOnTop(wxRect* rect = NULL);
7bf85405
RD
1038 bool EndDrawingOnTop();
1039};
1040
1041//---------------------------------------------------------------------------
1042
1043class wxClientDC : public wxDC {
1044public:
1045 wxClientDC(wxWindow* win);
1046};
1047
1048//---------------------------------------------------------------------------
1049
1050class wxPaintDC : public wxDC {
1051public:
1052 wxPaintDC(wxWindow* win);
1053};
1054
1055//---------------------------------------------------------------------------
1056
b639c3c5
RD
1057class wxWindowDC : public wxDC {
1058public:
1059 wxWindowDC(wxWindow* win);
1060};
b639c3c5
RD
1061
1062//---------------------------------------------------------------------------
1063
7bf85405 1064
fb5e0af0 1065#ifdef __WXMSW__
17c0e08c
RD
1066
1067%{
1068#include <wx/metafile.h>
1069%}
1070
1071class wxMetaFile : public wxObject {
1072public:
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
7bf85405
RD
1091class wxMetaFileDC : public wxDC {
1092public:
17c0e08c
RD
1093 wxMetaFileDC(const wxString& filename = wxPyEmptyStr,
1094 int width = 0, int height = 0,
1095 const wxString& description = wxPyEmptyStr);
7bf85405
RD
1096 wxMetaFile* Close();
1097};
17c0e08c 1098
fb5e0af0 1099#endif
7bf85405
RD
1100
1101//---------------------------------------------------------------------------
1102//---------------------------------------------------------------------------
1103
1104
1105%readonly
af309447
RD
1106%{
1107#if 0
1108%}
7bf85405
RD
1109extern wxFont *wxNORMAL_FONT;
1110extern wxFont *wxSMALL_FONT;
1111extern wxFont *wxITALIC_FONT;
1112extern wxFont *wxSWISS_FONT;
7bf85405 1113
1afc06c2 1114extern wxPen *wxRED_PEN;
7bf85405
RD
1115extern wxPen *wxCYAN_PEN;
1116extern wxPen *wxGREEN_PEN;
1117extern wxPen *wxBLACK_PEN;
1118extern wxPen *wxWHITE_PEN;
1119extern wxPen *wxTRANSPARENT_PEN;
1120extern wxPen *wxBLACK_DASHED_PEN;
1121extern wxPen *wxGREY_PEN;
1122extern wxPen *wxMEDIUM_GREY_PEN;
1123extern wxPen *wxLIGHT_GREY_PEN;
1124
1125extern wxBrush *wxBLUE_BRUSH;
1126extern wxBrush *wxGREEN_BRUSH;
1127extern wxBrush *wxWHITE_BRUSH;
1128extern wxBrush *wxBLACK_BRUSH;
1129extern wxBrush *wxTRANSPARENT_BRUSH;
1130extern wxBrush *wxCYAN_BRUSH;
1131extern wxBrush *wxRED_BRUSH;
1132extern wxBrush *wxGREY_BRUSH;
1133extern wxBrush *wxMEDIUM_GREY_BRUSH;
1134extern wxBrush *wxLIGHT_GREY_BRUSH;
1135
1136extern wxColour *wxBLACK;
1137extern wxColour *wxWHITE;
1138extern wxColour *wxRED;
1139extern wxColour *wxBLUE;
1140extern wxColour *wxGREEN;
1141extern wxColour *wxCYAN;
1142extern wxColour *wxLIGHT_GREY;
1143
1144extern wxCursor *wxSTANDARD_CURSOR;
1145extern wxCursor *wxHOURGLASS_CURSOR;
1146extern wxCursor *wxCROSS_CURSOR;
1147
1148extern wxBitmap wxNullBitmap;
1149extern wxIcon wxNullIcon;
1150extern wxCursor wxNullCursor;
1151extern wxPen wxNullPen;
1152extern wxBrush wxNullBrush;
1153extern wxPalette wxNullPalette;
1154extern wxFont wxNullFont;
1155extern wxColour wxNullColour;
1156
0569df0f
RD
1157
1158extern wxFontList* wxTheFontList;
1159extern wxPenList* wxThePenList;
6ee2116b 1160extern wxBrushList* wxTheBrushList;
0569df0f
RD
1161extern wxColourDatabase* wxTheColourDatabase;
1162
1163
af309447
RD
1164%readwrite
1165%{
1166#endif
1167%}
1168
b639c3c5
RD
1169//---------------------------------------------------------------------------
1170
9416aa89 1171class wxPalette : public wxGDIObject {
b639c3c5 1172public:
eec92d76 1173 wxPalette(int LCOUNT, byte* choices, byte* choices, byte* choices);
b639c3c5
RD
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
af309447
RD
1183enum {
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
9416aa89 1193class wxImageList : public wxObject {
af309447 1194public:
dcd38683 1195 wxImageList(int width, int height, int mask=TRUE, int initialCount=1);
af309447
RD
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);
f6bcfd97 1201#ifdef __WXMSW__
b57bdb5a 1202 bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
b57bdb5a 1203#else
f6bcfd97
BP
1204// %name(ReplaceIcon)bool Replace(int index, const wxIcon& icon);
1205// int Add(const wxBitmap& bitmap);
b57bdb5a
RD
1206 bool Replace(int index, const wxBitmap& bitmap);
1207#endif
af309447
RD
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();
f6bcfd97 1215 void GetSize(int index, int& OUTPUT, int& OUTPUT);
af309447
RD
1216};
1217
b639c3c5 1218
9416aa89
RD
1219//---------------------------------------------------------------------------
1220// Regions, etc.
1221
1222enum wxRegionContain {
1223 wxOutRegion, wxPartRegion, wxInRegion
1224};
1225
1226
1227class wxRegion : public wxGDIObject {
1228public:
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
1261class wxRegionIterator : public wxObject {
1262public:
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
7bf85405
RD
1284//---------------------------------------------------------------------------
1285