1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface file for wxDC, wxBrush, wxPen, wxFont, etc.
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
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 #include <wx/dcbuffer.h>
24 #include <wx/iconbndl.h>
27 //----------------------------------------------------------------------
30 %include my_typemaps.i
32 // Import some definitions of other classes, etc.
37 //---------------------------------------------------------------------------
39 // Put some wx default wxChar* values into wxStrings.
40 static const wxString wxPyEmptyString(wxT(""));
42 //---------------------------------------------------------------------------
44 class wxGDIObject : public wxObject {
50 void SetVisible( bool visible );
56 //---------------------------------------------------------------------------
58 class wxBitmap : public wxGDIObject
61 wxBitmap(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_ANY);
64 wxPalette* GetPalette();
66 bool LoadFile(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_ANY);
67 bool SaveFile(const wxString& name, wxBitmapType type, wxPalette* palette = NULL);
68 void SetMask(wxMask* mask);
70 void SetPalette(wxPalette& palette);
76 void SetHandle(long handle);
83 void SetHeight(int h);
86 void SetSize(const wxSize& size);
89 wxBitmap GetSubBitmap( const wxRect& rect );
90 bool CopyFromIcon(const wxIcon& icon);
92 bool CopyFromCursor(const wxCursor& cursor);
94 void SetQuality(int q);
97 %pragma(python) addtoclass = "
98 def __del__(self,gdic=gdic):
100 if self.thisown == 1 :
101 gdic.delete_wxBitmap(self)
108 // Declarations of some alternate "constructors"
109 %new wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1);
110 %new wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings);
111 %new wxBitmap* wxBitmapFromIcon(const wxIcon& icon);
112 %new wxBitmap* wxBitmapFromBits(char* bits, int width, int height, int depth = 1 );
115 // %new wxBitmap* wxBitmapFromData(PyObject* data, long type,
116 // int width, int height, int depth = 1);
121 %{ // Implementations of some alternate "constructors"
123 wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1) {
124 return new wxBitmap(width, height, depth);
127 static char** ConvertListOfStrings(PyObject* listOfStrings) {
128 char** cArray = NULL;
131 if (!PyList_Check(listOfStrings)) {
132 PyErr_SetString(PyExc_TypeError, "Expected a list of strings.");
135 count = PyList_Size(listOfStrings);
136 cArray = new char*[count];
138 for(int x=0; x<count; x++) {
139 // TODO: Need some validation and error checking here
140 cArray[x] = PyString_AsString(PyList_GET_ITEM(listOfStrings, x));
146 wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings) {
147 char** cArray = NULL;
150 cArray = ConvertListOfStrings(listOfStrings);
153 bmp = new wxBitmap(cArray);
159 wxBitmap* wxBitmapFromIcon(const wxIcon& icon) {
160 return new wxBitmap(icon);
164 wxBitmap* wxBitmapFromBits(char* bits, int width, int height, int depth = 1 ) {
165 return new wxBitmap(bits, width, height, depth);
170 // wxBitmap* wxBitmapFromData(PyObject* data, long type,
171 // int width, int height, int depth = 1) {
172 // if (! PyString_Check(data)) {
173 // PyErr_SetString(PyExc_TypeError, "Expected string object");
176 // return new wxBitmap((void*)PyString_AsString(data), type, width, height, depth);
181 //---------------------------------------------------------------------------
183 class wxMask : public wxObject {
185 wxMask(const wxBitmap& bitmap);
188 %addmethods { void Destroy() { delete self; } }
191 %new wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour);
193 wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour) {
194 return new wxMask(bitmap, colour);
199 //---------------------------------------------------------------------------
202 class wxIcon : public wxGDIObject
205 wxIcon(const wxString& name, long flags,
206 int desiredWidth = -1, int desiredHeight = -1);
210 bool LoadFile(const wxString& name, long flags);
213 // wxGDIImage methods
216 void SetHandle(long handle);
222 void SetWidth(int w);
223 void SetHeight(int h);
224 void SetDepth(int d);
226 void SetSize(const wxSize& size);
228 void CopyFromBitmap(const wxBitmap& bmp);
230 %pragma(python) addtoclass = "
231 def __del__(self,gdic=gdic):
233 if self.thisown == 1 :
234 gdic.delete_wxIcon(self)
241 // Declarations of some alternate "constructors"
242 %new wxIcon* wxEmptyIcon();
243 %new wxIcon* wxIconFromXPMData(PyObject* listOfStrings);
244 %new wxIcon* wxIconFromBitmap(const wxBitmap& bmp);
246 %{ // Implementations of some alternate "constructors"
247 wxIcon* wxEmptyIcon() {
251 wxIcon* wxIconFromXPMData(PyObject* listOfStrings) {
252 char** cArray = NULL;
255 cArray = ConvertListOfStrings(listOfStrings);
258 icon = new wxIcon(cArray);
263 wxIcon* wxIconFromBitmap(const wxBitmap& bmp) {
264 wxIcon* icon = new wxIcon();
265 icon->CopyFromBitmap(bmp);
270 //---------------------------------------------------------------------------
275 // default constructor
278 // initializes the bundle with the icon(s) found in the file
279 %name(wxIconBundleFromFile) wxIconBundle( const wxString& file, long type );
281 // initializes the bundle with a single icon
282 %name(wxIconBundleFromIcon)wxIconBundle( const wxIcon& icon );
286 // adds the icon to the collection, if the collection already
287 // contains an icon with the same width and height, it is
289 void AddIcon( const wxIcon& icon );
291 // adds all the icons contained in the file to the collection,
292 // if the collection already contains icons with the same
293 // width and height, they are replaced
294 %name(AddIconFromFile)void AddIcon( const wxString& file, long type );
296 // returns the icon with the given size; if no such icon exists,
297 // returns the icon with size wxSYS_ICON_[XY]; if no such icon exists,
298 // returns the first icon in the bundle
299 const wxIcon& GetIcon( const wxSize& size ) const;
302 //---------------------------------------------------------------------------
304 class wxCursor : public wxGDIObject
308 wxCursor(const wxString& cursorName, long flags, int hotSpotX=0, int hotSpotY=0);
312 // wxGDIImage methods
315 void SetHandle(long handle);
322 void SetWidth(int w);
323 void SetHeight(int h);
324 void SetDepth(int d);
325 void SetSize(const wxSize& size);
329 %name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id);
330 %{ // Alternate 'constructor'
331 wxCursor* wxPyStockCursor(int id) {
332 return new wxCursor(id);
336 //----------------------------------------------------------------------
341 wxFONTFAMILY_DEFAULT = wxDEFAULT,
342 wxFONTFAMILY_DECORATIVE = wxDECORATIVE,
343 wxFONTFAMILY_ROMAN = wxROMAN,
344 wxFONTFAMILY_SCRIPT = wxSCRIPT,
345 wxFONTFAMILY_SWISS = wxSWISS,
346 wxFONTFAMILY_MODERN = wxMODERN,
347 wxFONTFAMILY_TELETYPE = wxTELETYPE,
355 wxFONTSTYLE_NORMAL = wxNORMAL,
356 wxFONTSTYLE_ITALIC = wxITALIC,
357 wxFONTSTYLE_SLANT = wxSLANT,
364 wxFONTWEIGHT_NORMAL = wxNORMAL,
365 wxFONTWEIGHT_LIGHT = wxLIGHT,
366 wxFONTWEIGHT_BOLD = wxBOLD,
374 wxFONTENCODING_SYSTEM = -1, // system default
375 wxFONTENCODING_DEFAULT, // current default encoding
377 // ISO8859 standard defines a number of single-byte charsets
378 wxFONTENCODING_ISO8859_1, // West European (Latin1)
379 wxFONTENCODING_ISO8859_2, // Central and East European (Latin2)
380 wxFONTENCODING_ISO8859_3, // Esperanto (Latin3)
381 wxFONTENCODING_ISO8859_4, // Baltic (old) (Latin4)
382 wxFONTENCODING_ISO8859_5, // Cyrillic
383 wxFONTENCODING_ISO8859_6, // Arabic
384 wxFONTENCODING_ISO8859_7, // Greek
385 wxFONTENCODING_ISO8859_8, // Hebrew
386 wxFONTENCODING_ISO8859_9, // Turkish (Latin5)
387 wxFONTENCODING_ISO8859_10, // Variation of Latin4 (Latin6)
388 wxFONTENCODING_ISO8859_11, // Thai
389 wxFONTENCODING_ISO8859_12, // doesn't exist currently, but put it
390 // here anyhow to make all ISO8859
391 // consecutive numbers
392 wxFONTENCODING_ISO8859_13, // Baltic (Latin7)
393 wxFONTENCODING_ISO8859_14, // Latin8
394 wxFONTENCODING_ISO8859_15, // Latin9 (a.k.a. Latin0, includes euro)
395 wxFONTENCODING_ISO8859_MAX,
397 // Cyrillic charset soup (see http://czyborra.com/charsets/cyrillic.html)
398 wxFONTENCODING_KOI8, // we don't support any of KOI8 variants
399 wxFONTENCODING_ALTERNATIVE, // same as MS-DOS CP866
400 wxFONTENCODING_BULGARIAN, // used under Linux in Bulgaria
402 // what would we do without Microsoft? They have their own encodings
404 wxFONTENCODING_CP437, // original MS-DOS codepage
405 wxFONTENCODING_CP850, // CP437 merged with Latin1
406 wxFONTENCODING_CP852, // CP437 merged with Latin2
407 wxFONTENCODING_CP855, // another cyrillic encoding
408 wxFONTENCODING_CP866, // and another one
410 wxFONTENCODING_CP874, // WinThai
411 wxFONTENCODING_CP932, // Japanese (shift-JIS)
412 wxFONTENCODING_CP936, // Chiniese simplified (GB)
413 wxFONTENCODING_CP949, // Korean (Hangul charset)
414 wxFONTENCODING_CP950, // Chinese (traditional - Big5)
415 wxFONTENCODING_CP1250, // WinLatin2
416 wxFONTENCODING_CP1251, // WinCyrillic
417 wxFONTENCODING_CP1252, // WinLatin1
418 wxFONTENCODING_CP1253, // WinGreek (8859-7)
419 wxFONTENCODING_CP1254, // WinTurkish
420 wxFONTENCODING_CP1255, // WinHebrew
421 wxFONTENCODING_CP1256, // WinArabic
422 wxFONTENCODING_CP1257, // WinBaltic (same as Latin 7)
423 wxFONTENCODING_CP12_MAX,
425 wxFONTENCODING_UTF7, // UTF-7 Unicode encoding
426 wxFONTENCODING_UTF8, // UTF-8 Unicode encoding
428 wxFONTENCODING_UNICODE, // Unicode - currently used only by
429 // wxEncodingConverter class
436 // wxNativeFontInfo is platform-specific font representation: this struct
437 // should be considered as opaque font description only used by the native
438 // functions, the user code can only get the objects of this type from
439 // somewhere and pass it somewhere else (possibly save them somewhere using
440 // ToString() and restore them using FromString())
441 struct wxNativeFontInfo
444 // init the elements from an XLFD, return TRUE if ok
445 bool FromXFontName(const wxString& xFontName);
447 // return false if we were never initialized with a valid XLFD
448 bool IsDefault() const;
450 // generate an XLFD using the fontElements
451 wxString GetXFontName() const;
454 void SetXFontName(const wxString& xFontName);
457 wxNativeFontInfo() { Init(); }
459 // reset to the default state
463 // accessors and modifiers for the font elements
464 int GetPointSize() const;
465 wxFontStyle GetStyle() const;
466 wxFontWeight GetWeight() const;
467 bool GetUnderlined() const;
468 wxString GetFaceName() const;
469 wxFontFamily GetFamily() const;
470 wxFontEncoding GetEncoding() const;
472 void SetPointSize(int pointsize);
473 void SetStyle(wxFontStyle style);
474 void SetWeight(wxFontWeight weight);
475 void SetUnderlined(bool underlined);
476 void SetFaceName(wxString facename);
477 void SetFamily(wxFontFamily family);
478 void SetEncoding(wxFontEncoding encoding);
481 // it is important to be able to serialize wxNativeFontInfo objects to be
482 // able to store them (in config file, for example)
483 bool FromString(const wxString& s);
484 wxString ToString() const;
488 return self->ToString();
492 // we also want to present the native font descriptions to the user in some
493 // human-readable form (it is not platform independent neither, but can
494 // hopefully be understood by the user)
495 bool FromUserString(const wxString& s);
496 wxString ToUserString() const;
500 // wxFontMapper manages user-definable correspondence between logical font
501 // names and the fonts present on the machine.
503 // The default implementations of all functions will ask the user if they are
504 // not capable of finding the answer themselves and store the answer in a
505 // config file (configurable via SetConfigXXX functions). This behaviour may
506 // be disabled by giving the value of FALSE to "interactive" parameter.
507 // However, the functions will always consult the config file to allow the
508 // user-defined values override the default logic and there is no way to
509 // disable this - which shouldn't be ever needed because if "interactive" was
510 // never TRUE, the config file is never created anyhow.
518 // find an alternative for the given encoding (which is supposed to not be
519 // available on this system). If successful, return TRUE and rwxFontEcoding
520 // that can be used it wxFont ctor otherwise return FALSE
521 //bool GetAltForEncoding(wxFontEncoding encoding,
522 // wxFontEncoding *alt_encoding,
523 // const wxString& facename = wxPyEmptyString,
524 // bool interactive = TRUE);
527 // Find an alternative for the given encoding (which is supposed to not be
528 // available on this system). If successful, returns the encoding otherwise
531 PyObject* GetAltForEncoding(wxFontEncoding encoding,
532 const wxString& facename = wxPyEmptyString,
533 bool interactive = TRUE) {
534 wxFontEncoding alt_enc;
535 if (self->GetAltForEncoding(encoding, &alt_enc, facename, interactive))
536 return PyInt_FromLong(alt_enc);
545 // checks whether given encoding is available in given face or not.
546 // If no facename is given,
547 bool IsEncodingAvailable(wxFontEncoding encoding,
548 const wxString& facename = wxPyEmptyString);
550 // returns the encoding for the given charset (in the form of RFC 2046) or
551 // wxFONTENCODING_SYSTEM if couldn't decode it
552 wxFontEncoding CharsetToEncoding(const wxString& charset,
553 bool interactive = TRUE);
555 // return internal string identifier for the encoding (see also
556 // GetEncodingDescription())
557 static wxString GetEncodingName(wxFontEncoding encoding);
559 // return user-readable string describing the given encoding
561 // NB: hard-coded now, but might change later (read it from config?)
562 static wxString GetEncodingDescription(wxFontEncoding encoding);
564 // the parent window for modal dialogs
565 void SetDialogParent(wxWindow *parent);
567 // the title for the dialogs (note that default is quite reasonable)
568 void SetDialogTitle(const wxString& title);
570 // functions which allow to configure the config object used: by default,
571 // the global one (from wxConfigBase::Get() will be used) and the default
572 // root path for the config settings is the string returned by
573 // GetDefaultConfigPath()
576 // set the config object to use (may be NULL to use default)
577 void SetConfig(wxConfigBase *config);
579 // set the root config path to use (should be an absolute path)
580 void SetConfigPath(const wxString& prefix);
582 // return default config path
583 static wxString GetDefaultConfigPath();
589 class wxFont : public wxGDIObject {
591 wxFont( int pointSize, int family, int style, int weight,
592 int underline=FALSE, const wxString& faceName = wxPyEmptyString,
593 wxFontEncoding encoding=wxFONTENCODING_DEFAULT);
595 %name(wxFontFromNativeInfo)wxFont(const wxNativeFontInfo& info);
600 int GetPointSize() const;
601 int GetFamily() const;
602 int GetStyle() const;
603 int GetWeight() const;
604 bool GetUnderlined() const;
605 wxString GetFaceName() const;
606 wxFontEncoding GetEncoding() const;
610 wxNativeFontInfo* GetNativeFontInfo() const;
611 wxString GetNativeFontInfoDesc() const;
612 wxString GetNativeFontInfoUserDesc() const;
614 void SetPointSize(int pointSize);
615 void SetFamily(int family);
616 void SetStyle(int style);
617 void SetWeight(int weight);
618 void SetFaceName(const wxString& faceName);
619 void SetUnderlined(bool underlined);
620 void SetEncoding(wxFontEncoding encoding);
621 void SetNativeFontInfo(const wxNativeFontInfo& info);
622 // void SetNativeFontInfo(const wxString& info);
623 void SetNativeFontInfoUserDesc(const wxString& info);
625 wxString GetFamilyString() const;
626 wxString GetStyleString() const;
627 wxString GetWeightString() const;
629 static wxFontEncoding GetDefaultEncoding();
630 static void SetDefaultEncoding(wxFontEncoding encoding);
635 class wxFontList : public wxObject {
638 void AddFont(wxFont* font);
639 wxFont * FindOrCreateFont(int point_size, int family, int style, int weight,
640 bool underline = FALSE, const wxString& facename = wxPyEmptyString,
641 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
642 void RemoveFont(wxFont *font);
648 //----------------------------------------------------------------------
650 class wxColour : public wxObject {
652 wxColour(unsigned char red=0, unsigned char green=0, unsigned char blue=0);
655 unsigned char Green();
656 unsigned char Blue();
658 void Set(unsigned char red, unsigned char green, unsigned char blue);
661 PyObject* rv = PyTuple_New(3);
662 PyTuple_SetItem(rv, 0, PyInt_FromLong(self->Red()));
663 PyTuple_SetItem(rv, 1, PyInt_FromLong(self->Green()));
664 PyTuple_SetItem(rv, 2, PyInt_FromLong(self->Blue()));
668 %pragma(python) addtoclass = "asTuple = Get"
669 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
670 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
674 %new wxColour* wxNamedColour(const wxString& colorName);
676 %{ // Alternate 'constructor'
677 wxColour* wxNamedColour(const wxString& colorName) {
678 return new wxColour(colorName);
684 class wxColourDatabase : public wxObject {
687 wxColour *FindColour(const wxString& colour);
688 wxString FindName(const wxColour& colour) const;
691 void Append(const wxString& name, int red, int green, int blue) {
692 // first see if the name is already there
693 wxString cName = name;
695 wxString cName2 = cName;
696 if ( !cName2.Replace(wxT("GRAY"), wxT("GREY")) )
699 wxNode *node = self->First();
701 const wxChar *key = node->GetKeyString();
702 if ( cName == key || cName2 == key ) {
703 wxColour* c = (wxColour *)node->Data();
704 c->Set(red, green, blue);
710 // otherwise append the new colour
711 self->Append(name.c_str(), new wxColour(red, green, blue));
717 //----------------------------------------------------------------------
719 class wxPen : public wxGDIObject {
721 wxPen(wxColour& colour, int width=1, int style=wxSOLID);
725 wxColour GetColour();
731 void SetCap(int cap_style);
732 void SetColour(wxColour& colour);
733 void SetJoin(int join_style);
734 void SetStyle(int style);
735 void SetWidth(int width);
737 // **** This one needs to return a list of ints (wxDash)
738 //int GetDashes(wxDash **dashes);
739 void SetDashes(int LCOUNT, wxDash* choices);
742 wxBitmap* GetStipple();
743 void SetStipple(wxBitmap& stipple);
750 // The list of ints for the dashes needs to exist for the life of the pen
751 // so we make it part of the class to save it. wxPyPen is aliased to wxPen
755 class wxPyPen : public wxPen {
757 wxPyPen(wxColour& colour, int width=1, int style=wxSOLID)
758 : wxPen(colour, width, style)
765 void SetDashes(int nb_dashes, const wxDash *dash) {
768 m_dash = new wxDash[nb_dashes];
769 for (int i=0; i<nb_dashes; i++) {
772 wxPen::SetDashes(nb_dashes, m_dash);
781 class wxPyPen : public wxPen {
783 wxPyPen(wxColour& colour, int width=1, int style=wxSOLID);
786 void SetDashes(int LCOUNT, wxDash* choices);
792 class wxPenList : public wxObject {
795 void AddPen(wxPen* pen);
796 wxPen* FindOrCreatePen(const wxColour& colour, int width, int style);
797 void RemovePen(wxPen* pen);
804 //----------------------------------------------------------------------
806 class wxBrush : public wxGDIObject {
808 wxBrush(const wxColour& colour, int style=wxSOLID);
811 wxColour GetColour();
812 wxBitmap * GetStipple();
815 void SetColour(wxColour &colour);
816 void SetStipple(wxBitmap& bitmap);
817 void SetStyle(int style);
821 class wxBrushList : public wxObject {
824 void AddBrush(wxBrush *brush);
825 wxBrush * FindOrCreateBrush(const wxColour& colour, int style);
826 void RemoveBrush(wxBrush *brush);
831 //----------------------------------------------------------------------
835 class wxDC : public wxObject {
837 // wxDC(); **** abstract base class, can't instantiate.
842 bool Blit(long xdest, long ydest,
843 long width, long height,
844 wxDC *source, long xsrc, long ysrc,
845 int logicalFunc = wxCOPY, int useMask = FALSE);
846 // bool Blit(const wxPoint& destPt, const wxSize& sz,
847 // wxDC *source, const wxPoint& srcPt,
848 // int logicalFunc = wxCOPY, int useMask = FALSE);
851 void CrossHair(long x, long y);
852 void DestroyClippingRegion();
853 long DeviceToLogicalX(long x);
854 long DeviceToLogicalXRel(long x);
855 long DeviceToLogicalY(long y);
856 long DeviceToLogicalYRel(long y);
857 void DrawArc(long x1, long y1, long x2, long y2, long xc, long yc);
858 void DrawCircle(long x, long y, long radius);
859 void DrawEllipse(long x, long y, long width, long height);
860 void DrawEllipticArc(long x, long y, long width, long height, long start, long end);
861 void DrawIcon(const wxIcon& icon, long x, long y);
863 void DrawLabel(const wxString& text, const wxRect& rect,
864 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
865 int indexAccel = -1);
868 wxRect DrawImageLabel(const wxString& text,
869 const wxBitmap& image,
871 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
872 int indexAccel = -1) {
874 self->DrawLabel(text, image, rect, alignment, indexAccel, &rv);
879 void DrawLine(long x1, long y1, long x2, long y2);
880 void DrawLines(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0);
881 void DrawPolygon(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0,
882 int fill_style=wxODDEVEN_RULE);
883 void DrawPoint(long x, long y);
884 void DrawRectangle(long x, long y, long width, long height);
885 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
886 void DrawRoundedRectangle(long x, long y, long width, long height, long radius=20);
887 void DrawSpline(int PCOUNT, wxPoint* points);
888 void DrawText(const wxString& text, long x, long y);
892 void FloodFill(long x, long y, const wxColour& colour, int style=wxFLOOD_SURFACE);
893 wxBrush GetBackground();
895 long GetCharHeight();
897 void GetClippingBox(long *OUTPUT, long *OUTPUT,
898 long *OUTPUT, long *OUTPUT);
900 int GetLogicalFunction();
901 void GetLogicalScale(double *OUTPUT, double *OUTPUT);
903 bool GetOptimization();
906 %new wxColour* GetPixel(long x, long y) {
907 wxColour* wc = new wxColour();
908 self->GetPixel(x, y, wc);
912 %name(GetSizeTuple)void GetSize(int* OUTPUT, int* OUTPUT);
915 wxColour GetTextBackground();
916 void GetTextExtent(const wxString& string, long *OUTPUT, long *OUTPUT);
917 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
918 long *OUTPUT, long *OUTPUT, long *OUTPUT, long* OUTPUT,
919 const wxFont* font = NULL);
920 wxColour GetTextForeground();
921 void GetUserScale(double *OUTPUT, double *OUTPUT);
922 long LogicalToDeviceX(long x);
923 long LogicalToDeviceXRel(long x);
924 long LogicalToDeviceY(long y);
925 long LogicalToDeviceYRel(long y);
931 void SetDeviceOrigin(long x, long y);
932 void SetBackground(const wxBrush& brush);
933 void SetBackgroundMode(int mode);
934 void SetClippingRegion(long x, long y, long width, long height);
935 %name(SetClippingRegionAsRegion) void SetClippingRegion(const wxRegion& region);
936 void SetPalette(const wxPalette& colourMap);
937 void SetBrush(const wxBrush& brush);
938 void SetFont(const wxFont& font);
939 void SetLogicalFunction(int function);
940 void SetLogicalScale(double x, double y);
941 void SetMapMode(int mode);
942 void SetOptimization(bool optimize);
943 void SetPen(const wxPen& pen);
944 void SetTextBackground(const wxColour& colour);
945 void SetTextForeground(const wxColour& colour);
946 void SetUserScale(double x_scale, double y_scale);
947 bool StartDoc(const wxString& message);
952 void DrawBitmap(const wxBitmap& bitmap, long x, long y,
953 int useMask = FALSE);
955 bool CanDrawBitmap();
956 bool CanGetTextExtent();
960 void GetLogicalOrigin(int *OUTPUT, int *OUTPUT);
961 void SetLogicalOrigin(int x, int y);
962 void GetDeviceOrigin(int *OUTPUT, int *OUTPUT);
963 void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
965 void CalcBoundingBox(int x, int y);
966 void ResetBoundingBox();
969 void GetBoundingBox(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
970 // See below for implementation
979 // NOTE: These methods are VERY SIMILAR in implentation. It would be
980 // nice to factor out common code and or turn them into a set of
981 // template-like macros.
983 // Draw a point for every set of coordinants in pyPoints, optionally
984 // setting a new pen for each
985 PyObject* _DrawPointList(PyObject* pyPoints, PyObject* pyPens) {
986 bool isFastSeq = PyList_Check(pyPoints) || PyTuple_Check(pyPoints);
987 bool isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens);
995 if (!PySequence_Check(pyPoints)) {
998 if (!PySequence_Check(pyPens)) {
1001 numObjs = PySequence_Length(pyPoints);
1002 numPens = PySequence_Length(pyPens);
1004 for (i = 0; i < numObjs; i++) {
1008 obj = PySequence_Fast_GET_ITEM(pyPens, i);
1011 obj = PySequence_GetItem(pyPens, i);
1013 if (SWIG_GetPtrObj(obj, (void **) &pen, "_wxPen_p")) {
1024 // Get the point coordinants
1026 obj = PySequence_Fast_GET_ITEM(pyPoints, i);
1029 obj = PySequence_GetItem(pyPoints, i);
1031 if (! _2int_seq_helper(obj, &x1, &y1)) {
1037 // Now draw the point
1038 self->DrawPoint(x1, y1);
1048 PyErr_SetString(PyExc_TypeError, "Expected a sequence of wxPens");
1051 PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x,y) sequences.");
1056 // Draw a line for every set of coordinants in pyLines, optionally
1057 // setting a new pen for each
1058 PyObject* _DrawLineList(PyObject* pyLines, PyObject* pyPens) {
1059 bool isFastSeq = PyList_Check(pyLines) || PyTuple_Check(pyLines);
1060 bool isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens);
1068 if (!PySequence_Check(pyLines)) {
1071 if (!PySequence_Check(pyPens)) {
1074 numObjs = PySequence_Length(pyLines);
1075 numPens = PySequence_Length(pyPens);
1077 for (i = 0; i < numObjs; i++) {
1081 obj = PySequence_Fast_GET_ITEM(pyPens, i);
1084 obj = PySequence_GetItem(pyPens, i);
1086 if (SWIG_GetPtrObj(obj, (void **) &pen, "_wxPen_p")) {
1097 // Get the line coordinants
1099 obj = PySequence_Fast_GET_ITEM(pyLines, i);
1102 obj = PySequence_GetItem(pyLines, i);
1104 if (! _4int_seq_helper(obj, &x1, &y1, &x2, &y2)) {
1110 // Now draw the line
1111 self->DrawLine(x1, y1, x2, y2);
1121 PyErr_SetString(PyExc_TypeError, "Expected a sequence of wxPens");
1124 PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x1,y1, x2,y2) sequences.");
1130 %pragma(python) addtoclass = "
1131 def DrawPointList(self, points, pens=None):
1134 elif isinstance(pens, wxPenPtr):
1136 elif len(pens) != len(points):
1137 raise ValueError('points and pens must have same length')
1138 return self._DrawPointList(points, pens)
1140 def DrawLineList(self, lines, pens=None):
1143 elif isinstance(pens, wxPenPtr):
1145 elif len(pens) != len(lines):
1146 raise ValueError('lines and pens must have same length')
1147 return self._DrawLineList(lines, pens)
1156 static void wxDC_GetBoundingBox(wxDC* dc, int* x1, int* y1, int* x2, int* y2) {
1164 //----------------------------------------------------------------------
1166 class wxMemoryDC : public wxDC {
1170 void SelectObject(const wxBitmap& bitmap);
1173 %new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC);
1174 %{ // Alternate 'constructor'
1175 wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) {
1176 return new wxMemoryDC(oldDC);
1181 //---------------------------------------------------------------------------
1183 class wxBufferedDC : public wxMemoryDC {
1185 // Construct a wxBufferedDC using a user supplied buffer.
1186 wxBufferedDC( wxDC *dc, const wxBitmap &buffer );
1188 // Construct a wxBufferedDC with an internal buffer of 'area'
1189 // (where area is usually something like the size of the window
1191 %name(wxBufferedDCInternalBuffer)wxBufferedDC( wxDC *dc, const wxSize &area );
1195 class wxBufferedPaintDC : public wxBufferedDC
1198 wxBufferedPaintDC( wxWindow *window, const wxBitmap &buffer = wxNullBitmap );
1201 //---------------------------------------------------------------------------
1203 class wxScreenDC : public wxDC {
1207 %name(StartDrawingOnTopWin) bool StartDrawingOnTop(wxWindow* window);
1208 bool StartDrawingOnTop(wxRect* rect = NULL);
1209 bool EndDrawingOnTop();
1212 //---------------------------------------------------------------------------
1214 class wxClientDC : public wxDC {
1216 wxClientDC(wxWindow* win);
1219 //---------------------------------------------------------------------------
1221 class wxPaintDC : public wxDC {
1223 wxPaintDC(wxWindow* win);
1226 //---------------------------------------------------------------------------
1228 class wxWindowDC : public wxDC {
1230 wxWindowDC(wxWindow* win);
1233 //---------------------------------------------------------------------------
1239 #include <wx/metafile.h>
1242 class wxMetaFile : public wxObject {
1244 wxMetaFile(const wxString& filename = wxPyEmptyString);
1248 bool SetClipboard(int width = 0, int height = 0);
1254 const wxString& GetFileName() const { return m_filename; }
1258 // bool wxMakeMetaFilePlaceable(const wxString& filename,
1259 // int minX, int minY, int maxX, int maxY, float scale=1.0);
1262 class wxMetaFileDC : public wxDC {
1264 wxMetaFileDC(const wxString& filename = wxPyEmptyString,
1265 int width = 0, int height = 0,
1266 const wxString& description = wxPyEmptyString);
1267 wxMetaFile* Close();
1272 //---------------------------------------------------------------------------
1274 class wxPalette : public wxGDIObject {
1276 wxPalette(int LCOUNT, byte* choices, byte* choices, byte* choices);
1279 int GetPixel(byte red, byte green, byte blue);
1280 bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT);
1284 //---------------------------------------------------------------------------
1287 wxIMAGELIST_DRAW_NORMAL ,
1288 wxIMAGELIST_DRAW_TRANSPARENT,
1289 wxIMAGELIST_DRAW_SELECTED,
1290 wxIMAGELIST_DRAW_FOCUSED,
1291 wxIMAGE_LIST_NORMAL,
1296 class wxImageList : public wxObject {
1298 wxImageList(int width, int height, int mask=TRUE, int initialCount=1);
1301 int Add(const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
1302 %name(AddWithColourMask)int Add(const wxBitmap& bitmap, const wxColour& maskColour);
1303 %name(AddIcon)int Add(const wxIcon& icon);
1305 bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
1307 // %name(ReplaceIcon)bool Replace(int index, const wxIcon& icon);
1308 // int Add(const wxBitmap& bitmap);
1309 bool Replace(int index, const wxBitmap& bitmap);
1312 bool Draw(int index, wxDC& dc, int x, int x, int flags = wxIMAGELIST_DRAW_NORMAL,
1313 const bool solidBackground = FALSE);
1315 int GetImageCount();
1316 bool Remove(int index);
1318 void GetSize(int index, int& OUTPUT, int& OUTPUT);
1322 //---------------------------------------------------------------------------
1325 enum wxRegionContain {
1326 wxOutRegion, wxPartRegion, wxInRegion
1330 class wxRegion : public wxGDIObject {
1332 wxRegion(long x=0, long y=0, long width=0, long height=0);
1337 bool Offset(wxCoord x, wxCoord y);
1340 wxRegionContain Contains(long x, long y);
1341 %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt);
1342 %name(ContainsRect)wxRegionContain Contains(const wxRect& rect);
1343 %name(ContainsRectDim)wxRegionContain Contains(long x, long y, long w, long h);
1347 bool Intersect(long x, long y, long width, long height);
1348 %name(IntersectRect)bool Intersect(const wxRect& rect);
1349 %name(IntersectRegion)bool Intersect(const wxRegion& region);
1353 bool Union(long x, long y, long width, long height);
1354 %name(UnionRect)bool Union(const wxRect& rect);
1355 %name(UnionRegion)bool Union(const wxRegion& region);
1357 bool Subtract(long x, long y, long width, long height);
1358 %name(SubtractRect)bool Subtract(const wxRect& rect);
1359 %name(SubtractRegion)bool Subtract(const wxRegion& region);
1361 bool Xor(long x, long y, long width, long height);
1362 %name(XorRect)bool Xor(const wxRect& rect);
1363 %name(XorRegion)bool Xor(const wxRegion& region);
1368 class wxRegionIterator : public wxObject {
1370 wxRegionIterator(const wxRegion& region);
1371 ~wxRegionIterator();
1391 //---------------------------------------------------------------------------
1398 extern wxFont *wxNORMAL_FONT;
1399 extern wxFont *wxSMALL_FONT;
1400 extern wxFont *wxITALIC_FONT;
1401 extern wxFont *wxSWISS_FONT;
1403 extern wxPen *wxRED_PEN;
1404 extern wxPen *wxCYAN_PEN;
1405 extern wxPen *wxGREEN_PEN;
1406 extern wxPen *wxBLACK_PEN;
1407 extern wxPen *wxWHITE_PEN;
1408 extern wxPen *wxTRANSPARENT_PEN;
1409 extern wxPen *wxBLACK_DASHED_PEN;
1410 extern wxPen *wxGREY_PEN;
1411 extern wxPen *wxMEDIUM_GREY_PEN;
1412 extern wxPen *wxLIGHT_GREY_PEN;
1414 extern wxBrush *wxBLUE_BRUSH;
1415 extern wxBrush *wxGREEN_BRUSH;
1416 extern wxBrush *wxWHITE_BRUSH;
1417 extern wxBrush *wxBLACK_BRUSH;
1418 extern wxBrush *wxTRANSPARENT_BRUSH;
1419 extern wxBrush *wxCYAN_BRUSH;
1420 extern wxBrush *wxRED_BRUSH;
1421 extern wxBrush *wxGREY_BRUSH;
1422 extern wxBrush *wxMEDIUM_GREY_BRUSH;
1423 extern wxBrush *wxLIGHT_GREY_BRUSH;
1425 extern wxColour *wxBLACK;
1426 extern wxColour *wxWHITE;
1427 extern wxColour *wxRED;
1428 extern wxColour *wxBLUE;
1429 extern wxColour *wxGREEN;
1430 extern wxColour *wxCYAN;
1431 extern wxColour *wxLIGHT_GREY;
1433 extern wxCursor *wxSTANDARD_CURSOR;
1434 extern wxCursor *wxHOURGLASS_CURSOR;
1435 extern wxCursor *wxCROSS_CURSOR;
1438 extern wxBitmap wxNullBitmap;
1439 extern wxIcon wxNullIcon;
1440 extern wxCursor wxNullCursor;
1441 extern wxPen wxNullPen;
1442 extern wxBrush wxNullBrush;
1443 extern wxPalette wxNullPalette;
1444 extern wxFont wxNullFont;
1445 extern wxColour wxNullColour;
1448 extern wxFontList* wxTheFontList;
1449 extern wxPenList* wxThePenList;
1450 extern wxBrushList* wxTheBrushList;
1451 extern wxColourDatabase* wxTheColourDatabase;
1459 //---------------------------------------------------------------------------
1460 //---------------------------------------------------------------------------