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>
25 //----------------------------------------------------------------------
28 %include my_typemaps.i
30 // Import some definitions of other classes, etc.
35 //---------------------------------------------------------------------------
37 class wxGDIObject : public wxObject {
43 void SetVisible( bool visible );
49 //---------------------------------------------------------------------------
51 class wxBitmap : public wxGDIObject
54 wxBitmap(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_ANY);
57 wxPalette* GetPalette();
59 bool LoadFile(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_ANY);
60 bool SaveFile(const wxString& name, wxBitmapType type, wxPalette* palette = NULL);
61 void SetMask(wxMask* mask);
63 void SetPalette(wxPalette& palette);
69 void SetHandle(long handle);
76 void SetHeight(int h);
79 void SetSize(const wxSize& size);
82 wxBitmap GetSubBitmap( const wxRect& rect );
83 bool CopyFromIcon(const wxIcon& icon);
85 bool CopyFromCursor(const wxCursor& cursor);
87 void SetQuality(int q);
90 %pragma(python) addtoclass = "
91 def __del__(self,gdic=gdic):
93 if self.thisown == 1 :
94 gdic.delete_wxBitmap(self)
101 // Declarations of some alternate "constructors"
102 %new wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1);
103 %new wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings);
104 %new wxBitmap* wxBitmapFromIcon(const wxIcon& icon);
105 %new wxBitmap* wxBitmapFromBits(char* bits, int width, int height, int depth = 1 );
108 // %new wxBitmap* wxBitmapFromData(PyObject* data, long type,
109 // int width, int height, int depth = 1);
114 %{ // Implementations of some alternate "constructors"
116 wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1) {
117 return new wxBitmap(width, height, depth);
120 static char** ConvertListOfStrings(PyObject* listOfStrings) {
121 char** cArray = NULL;
124 if (!PyList_Check(listOfStrings)) {
125 PyErr_SetString(PyExc_TypeError, "Expected a list of strings.");
128 count = PyList_Size(listOfStrings);
129 cArray = new char*[count];
131 for(int x=0; x<count; x++) {
132 // TODO: Need some validation and error checking here
133 cArray[x] = PyString_AsString(PyList_GET_ITEM(listOfStrings, x));
139 wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings) {
140 char** cArray = NULL;
143 cArray = ConvertListOfStrings(listOfStrings);
146 bmp = new wxBitmap(cArray);
152 wxBitmap* wxBitmapFromIcon(const wxIcon& icon) {
153 return new wxBitmap(icon);
157 wxBitmap* wxBitmapFromBits(char* bits, int width, int height, int depth = 1 ) {
158 return new wxBitmap(bits, width, height, depth);
163 // wxBitmap* wxBitmapFromData(PyObject* data, long type,
164 // int width, int height, int depth = 1) {
165 // if (! PyString_Check(data)) {
166 // PyErr_SetString(PyExc_TypeError, "Expected string object");
169 // return new wxBitmap((void*)PyString_AsString(data), type, width, height, depth);
174 //---------------------------------------------------------------------------
176 class wxMask : public wxObject {
178 wxMask(const wxBitmap& bitmap);
181 %addmethods { void Destroy() { delete self; } }
184 %new wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour);
186 wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour) {
187 return new wxMask(bitmap, colour);
192 //---------------------------------------------------------------------------
195 class wxIcon : public wxGDIObject
198 wxIcon(const wxString& name, long flags,
199 int desiredWidth = -1, int desiredHeight = -1);
203 bool LoadFile(const wxString& name, long flags);
206 // wxGDIImage methods
209 void SetHandle(long handle);
215 void SetWidth(int w);
216 void SetHeight(int h);
217 void SetDepth(int d);
219 void SetSize(const wxSize& size);
221 void CopyFromBitmap(const wxBitmap& bmp);
223 %pragma(python) addtoclass = "
224 def __del__(self,gdic=gdic):
226 if self.thisown == 1 :
227 gdic.delete_wxIcon(self)
234 // Declarations of some alternate "constructors"
235 %new wxIcon* wxEmptyIcon();
236 %new wxIcon* wxIconFromXPMData(PyObject* listOfStrings);
237 %new wxIcon* wxIconFromBitmap(const wxBitmap& bmp);
239 %{ // Implementations of some alternate "constructors"
240 wxIcon* wxEmptyIcon() {
244 wxIcon* wxIconFromXPMData(PyObject* listOfStrings) {
245 char** cArray = NULL;
248 cArray = ConvertListOfStrings(listOfStrings);
251 icon = new wxIcon(cArray);
256 wxIcon* wxIconFromBitmap(const wxBitmap& bmp) {
257 wxIcon* icon = new wxIcon();
258 icon->CopyFromBitmap(bmp);
263 //---------------------------------------------------------------------------
265 class wxCursor : public wxGDIObject
269 wxCursor(const wxString& cursorName, long flags, int hotSpotX=0, int hotSpotY=0);
273 // wxGDIImage methods
276 void SetHandle(long handle);
283 void SetWidth(int w);
284 void SetHeight(int h);
285 void SetDepth(int d);
286 void SetSize(const wxSize& size);
290 %name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id);
291 %{ // Alternate 'constructor'
292 wxCursor* wxPyStockCursor(int id) {
293 return new wxCursor(id);
297 //----------------------------------------------------------------------
302 wxFONTFAMILY_DEFAULT = wxDEFAULT,
303 wxFONTFAMILY_DECORATIVE = wxDECORATIVE,
304 wxFONTFAMILY_ROMAN = wxROMAN,
305 wxFONTFAMILY_SCRIPT = wxSCRIPT,
306 wxFONTFAMILY_SWISS = wxSWISS,
307 wxFONTFAMILY_MODERN = wxMODERN,
308 wxFONTFAMILY_TELETYPE = wxTELETYPE,
316 wxFONTSTYLE_NORMAL = wxNORMAL,
317 wxFONTSTYLE_ITALIC = wxITALIC,
318 wxFONTSTYLE_SLANT = wxSLANT,
325 wxFONTWEIGHT_NORMAL = wxNORMAL,
326 wxFONTWEIGHT_LIGHT = wxLIGHT,
327 wxFONTWEIGHT_BOLD = wxBOLD,
335 wxFONTENCODING_SYSTEM = -1, // system default
336 wxFONTENCODING_DEFAULT, // current default encoding
338 // ISO8859 standard defines a number of single-byte charsets
339 wxFONTENCODING_ISO8859_1, // West European (Latin1)
340 wxFONTENCODING_ISO8859_2, // Central and East European (Latin2)
341 wxFONTENCODING_ISO8859_3, // Esperanto (Latin3)
342 wxFONTENCODING_ISO8859_4, // Baltic (old) (Latin4)
343 wxFONTENCODING_ISO8859_5, // Cyrillic
344 wxFONTENCODING_ISO8859_6, // Arabic
345 wxFONTENCODING_ISO8859_7, // Greek
346 wxFONTENCODING_ISO8859_8, // Hebrew
347 wxFONTENCODING_ISO8859_9, // Turkish (Latin5)
348 wxFONTENCODING_ISO8859_10, // Variation of Latin4 (Latin6)
349 wxFONTENCODING_ISO8859_11, // Thai
350 wxFONTENCODING_ISO8859_12, // doesn't exist currently, but put it
351 // here anyhow to make all ISO8859
352 // consecutive numbers
353 wxFONTENCODING_ISO8859_13, // Baltic (Latin7)
354 wxFONTENCODING_ISO8859_14, // Latin8
355 wxFONTENCODING_ISO8859_15, // Latin9 (a.k.a. Latin0, includes euro)
356 wxFONTENCODING_ISO8859_MAX,
358 // Cyrillic charset soup (see http://czyborra.com/charsets/cyrillic.html)
359 wxFONTENCODING_KOI8, // we don't support any of KOI8 variants
360 wxFONTENCODING_ALTERNATIVE, // same as MS-DOS CP866
361 wxFONTENCODING_BULGARIAN, // used under Linux in Bulgaria
363 // what would we do without Microsoft? They have their own encodings
365 wxFONTENCODING_CP437, // original MS-DOS codepage
366 wxFONTENCODING_CP850, // CP437 merged with Latin1
367 wxFONTENCODING_CP852, // CP437 merged with Latin2
368 wxFONTENCODING_CP855, // another cyrillic encoding
369 wxFONTENCODING_CP866, // and another one
371 wxFONTENCODING_CP874, // WinThai
372 wxFONTENCODING_CP932, // Japanese (shift-JIS)
373 wxFONTENCODING_CP936, // Chiniese simplified (GB)
374 wxFONTENCODING_CP949, // Korean (Hangul charset)
375 wxFONTENCODING_CP950, // Chinese (traditional - Big5)
376 wxFONTENCODING_CP1250, // WinLatin2
377 wxFONTENCODING_CP1251, // WinCyrillic
378 wxFONTENCODING_CP1252, // WinLatin1
379 wxFONTENCODING_CP1253, // WinGreek (8859-7)
380 wxFONTENCODING_CP1254, // WinTurkish
381 wxFONTENCODING_CP1255, // WinHebrew
382 wxFONTENCODING_CP1256, // WinArabic
383 wxFONTENCODING_CP1257, // WinBaltic (same as Latin 7)
384 wxFONTENCODING_CP12_MAX,
386 wxFONTENCODING_UTF7, // UTF-7 Unicode encoding
387 wxFONTENCODING_UTF8, // UTF-8 Unicode encoding
389 wxFONTENCODING_UNICODE, // Unicode - currently used only by
390 // wxEncodingConverter class
397 // wxNativeFontInfo is platform-specific font representation: this struct
398 // should be considered as opaque font description only used by the native
399 // functions, the user code can only get the objects of this type from
400 // somewhere and pass it somewhere else (possibly save them somewhere using
401 // ToString() and restore them using FromString())
402 struct wxNativeFontInfo
405 // init the elements from an XLFD, return TRUE if ok
406 bool FromXFontName(const wxString& xFontName);
408 // return false if we were never initialized with a valid XLFD
409 bool IsDefault() const;
411 // generate an XLFD using the fontElements
412 wxString GetXFontName() const;
415 void SetXFontName(const wxString& xFontName);
418 wxNativeFontInfo() { Init(); }
420 // reset to the default state
424 // accessors and modifiers for the font elements
425 int GetPointSize() const;
426 wxFontStyle GetStyle() const;
427 wxFontWeight GetWeight() const;
428 bool GetUnderlined() const;
429 wxString GetFaceName() const;
430 wxFontFamily GetFamily() const;
431 wxFontEncoding GetEncoding() const;
433 void SetPointSize(int pointsize);
434 void SetStyle(wxFontStyle style);
435 void SetWeight(wxFontWeight weight);
436 void SetUnderlined(bool underlined);
437 void SetFaceName(wxString facename);
438 void SetFamily(wxFontFamily family);
439 void SetEncoding(wxFontEncoding encoding);
442 // it is important to be able to serialize wxNativeFontInfo objects to be
443 // able to store them (in config file, for example)
444 bool FromString(const wxString& s);
445 wxString ToString() const;
449 return self->ToString();
453 // we also want to present the native font descriptions to the user in some
454 // human-readable form (it is not platform independent neither, but can
455 // hopefully be understood by the user)
456 bool FromUserString(const wxString& s);
457 wxString ToUserString() const;
461 // wxFontMapper manages user-definable correspondence between logical font
462 // names and the fonts present on the machine.
464 // The default implementations of all functions will ask the user if they are
465 // not capable of finding the answer themselves and store the answer in a
466 // config file (configurable via SetConfigXXX functions). This behaviour may
467 // be disabled by giving the value of FALSE to "interactive" parameter.
468 // However, the functions will always consult the config file to allow the
469 // user-defined values override the default logic and there is no way to
470 // disable this - which shouldn't be ever needed because if "interactive" was
471 // never TRUE, the config file is never created anyhow.
479 // find an alternative for the given encoding (which is supposed to not be
480 // available on this system). If successful, return TRUE and rwxFontEcoding
481 // that can be used it wxFont ctor otherwise return FALSE
482 //bool GetAltForEncoding(wxFontEncoding encoding,
483 // wxFontEncoding *alt_encoding,
484 // const wxString& facename = wxEmptyString,
485 // bool interactive = TRUE);
488 // Find an alternative for the given encoding (which is supposed to not be
489 // available on this system). If successful, returns the encoding otherwise
492 PyObject* GetAltForEncoding(wxFontEncoding encoding,
493 const wxString& facename = wxEmptyString,
494 bool interactive = TRUE) {
495 wxFontEncoding alt_enc;
496 if (self->GetAltForEncoding(encoding, &alt_enc, facename, interactive))
497 return PyInt_FromLong(alt_enc);
506 // checks whether given encoding is available in given face or not.
507 // If no facename is given,
508 bool IsEncodingAvailable(wxFontEncoding encoding,
509 const wxString& facename = wxEmptyString);
511 // returns the encoding for the given charset (in the form of RFC 2046) or
512 // wxFONTENCODING_SYSTEM if couldn't decode it
513 wxFontEncoding CharsetToEncoding(const wxString& charset,
514 bool interactive = TRUE);
516 // return internal string identifier for the encoding (see also
517 // GetEncodingDescription())
518 static wxString GetEncodingName(wxFontEncoding encoding);
520 // return user-readable string describing the given encoding
522 // NB: hard-coded now, but might change later (read it from config?)
523 static wxString GetEncodingDescription(wxFontEncoding encoding);
525 // the parent window for modal dialogs
526 void SetDialogParent(wxWindow *parent);
528 // the title for the dialogs (note that default is quite reasonable)
529 void SetDialogTitle(const wxString& title);
531 // functions which allow to configure the config object used: by default,
532 // the global one (from wxConfigBase::Get() will be used) and the default
533 // root path for the config settings is the string returned by
534 // GetDefaultConfigPath()
537 // set the config object to use (may be NULL to use default)
538 void SetConfig(wxConfigBase *config);
540 // set the root config path to use (should be an absolute path)
541 void SetConfigPath(const wxString& prefix);
543 // return default config path
544 static const wxChar *GetDefaultConfigPath();
550 class wxFont : public wxGDIObject {
552 wxFont( int pointSize, int family, int style, int weight,
553 int underline=FALSE, char* faceName = "",
554 wxFontEncoding encoding=wxFONTENCODING_DEFAULT);
556 %name(wxFontFromNativeInfo)wxFont(const wxNativeFontInfo& info);
561 int GetPointSize() const;
562 int GetFamily() const;
563 int GetStyle() const;
564 int GetWeight() const;
565 bool GetUnderlined() const;
566 wxString GetFaceName() const;
567 wxFontEncoding GetEncoding() const;
571 wxNativeFontInfo* GetNativeFontInfo() const;
572 wxString GetNativeFontInfoDesc() const;
573 wxString GetNativeFontInfoUserDesc() const;
575 void SetPointSize(int pointSize);
576 void SetFamily(int family);
577 void SetStyle(int style);
578 void SetWeight(int weight);
579 void SetFaceName(const wxString& faceName);
580 void SetUnderlined(bool underlined);
581 void SetEncoding(wxFontEncoding encoding);
582 void SetNativeFontInfo(const wxNativeFontInfo& info);
583 // void SetNativeFontInfo(const wxString& info);
584 void SetNativeFontInfoUserDesc(const wxString& info);
586 wxString GetFamilyString() const;
587 wxString GetStyleString() const;
588 wxString GetWeightString() const;
590 static wxFontEncoding GetDefaultEncoding();
591 static void SetDefaultEncoding(wxFontEncoding encoding);
596 class wxFontList : public wxObject {
599 void AddFont(wxFont* font);
600 wxFont * FindOrCreateFont(int point_size, int family, int style, int weight,
601 bool underline = FALSE, const char* facename = NULL,
602 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
603 void RemoveFont(wxFont *font);
609 //----------------------------------------------------------------------
611 class wxColour : public wxObject {
613 wxColour(unsigned char red=0, unsigned char green=0, unsigned char blue=0);
616 unsigned char Green();
617 unsigned char Blue();
619 void Set(unsigned char red, unsigned char green, unsigned char blue);
622 PyObject* rv = PyTuple_New(3);
623 PyTuple_SetItem(rv, 0, PyInt_FromLong(self->Red()));
624 PyTuple_SetItem(rv, 1, PyInt_FromLong(self->Green()));
625 PyTuple_SetItem(rv, 2, PyInt_FromLong(self->Blue()));
629 %pragma(python) addtoclass = "asTuple = Get"
630 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
631 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
635 %new wxColour* wxNamedColour(const wxString& colorName);
637 %{ // Alternate 'constructor'
638 wxColour* wxNamedColour(const wxString& colorName) {
639 return new wxColour(colorName);
645 class wxColourDatabase : public wxObject {
648 wxColour *FindColour(const wxString& colour);
649 wxString FindName(const wxColour& colour) const;
652 void Append(const wxString& name, int red, int green, int blue) {
653 // first see if the name is already there
654 wxString cName = name;
656 wxString cName2 = cName;
657 if ( !cName2.Replace("GRAY", "GREY") )
660 wxNode *node = self->First();
662 const wxChar *key = node->GetKeyString();
663 if ( cName == key || cName2 == key ) {
664 wxColour* c = (wxColour *)node->Data();
665 c->Set(red, green, blue);
671 // otherwise append the new colour
672 self->Append(name.c_str(), new wxColour(red, green, blue));
678 //----------------------------------------------------------------------
680 class wxPen : public wxGDIObject {
682 wxPen(wxColour& colour, int width=1, int style=wxSOLID);
686 wxColour GetColour();
692 void SetCap(int cap_style);
693 void SetColour(wxColour& colour);
694 void SetJoin(int join_style);
695 void SetStyle(int style);
696 void SetWidth(int width);
698 // **** This one needs to return a list of ints (wxDash)
699 //int GetDashes(wxDash **dashes);
700 void SetDashes(int LCOUNT, wxDash* choices);
703 wxBitmap* GetStipple();
704 void SetStipple(wxBitmap& stipple);
711 // The list of ints for the dashes needs to exist for the life of the pen
712 // so we make it part of the class to save it. wxPyPen is aliased to wxPen
716 class wxPyPen : public wxPen {
718 wxPyPen(wxColour& colour, int width=1, int style=wxSOLID)
719 : wxPen(colour, width, style)
726 void SetDashes(int nb_dashes, const wxDash *dash) {
729 m_dash = new wxDash[nb_dashes];
730 for (int i=0; i<nb_dashes; i++) {
733 wxPen::SetDashes(nb_dashes, m_dash);
742 class wxPyPen : public wxPen {
744 wxPyPen(wxColour& colour, int width=1, int style=wxSOLID);
747 void SetDashes(int LCOUNT, wxDash* choices);
753 class wxPenList : public wxObject {
756 void AddPen(wxPen* pen);
757 wxPen* FindOrCreatePen(const wxColour& colour, int width, int style);
758 void RemovePen(wxPen* pen);
765 //----------------------------------------------------------------------
767 class wxBrush : public wxGDIObject {
769 wxBrush(const wxColour& colour, int style=wxSOLID);
772 wxColour GetColour();
773 wxBitmap * GetStipple();
776 void SetColour(wxColour &colour);
777 void SetStipple(wxBitmap& bitmap);
778 void SetStyle(int style);
782 class wxBrushList : public wxObject {
785 void AddBrush(wxBrush *brush);
786 wxBrush * FindOrCreateBrush(const wxColour& colour, int style);
787 void RemoveBrush(wxBrush *brush);
792 //----------------------------------------------------------------------
796 class wxDC : public wxObject {
798 // wxDC(); **** abstract base class, can't instantiate.
803 bool Blit(long xdest, long ydest,
804 long width, long height,
805 wxDC *source, long xsrc, long ysrc,
806 int logicalFunc = wxCOPY, int useMask = FALSE);
807 // bool Blit(const wxPoint& destPt, const wxSize& sz,
808 // wxDC *source, const wxPoint& srcPt,
809 // int logicalFunc = wxCOPY, int useMask = FALSE);
812 void CrossHair(long x, long y);
813 void DestroyClippingRegion();
814 long DeviceToLogicalX(long x);
815 long DeviceToLogicalXRel(long x);
816 long DeviceToLogicalY(long y);
817 long DeviceToLogicalYRel(long y);
818 void DrawArc(long x1, long y1, long x2, long y2, long xc, long yc);
819 void DrawCircle(long x, long y, long radius);
820 void DrawEllipse(long x, long y, long width, long height);
821 void DrawEllipticArc(long x, long y, long width, long height, long start, long end);
822 void DrawIcon(const wxIcon& icon, long x, long y);
824 void DrawLabel(const wxString& text, const wxRect& rect,
825 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
826 int indexAccel = -1);
829 wxRect DrawImageLabel(const wxString& text,
830 const wxBitmap& image,
832 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
833 int indexAccel = -1) {
835 self->DrawLabel(text, image, rect, alignment, indexAccel, &rv);
840 void DrawLine(long x1, long y1, long x2, long y2);
841 void DrawLines(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0);
842 void DrawPolygon(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0,
843 int fill_style=wxODDEVEN_RULE);
844 void DrawPoint(long x, long y);
845 void DrawRectangle(long x, long y, long width, long height);
846 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
847 void DrawRoundedRectangle(long x, long y, long width, long height, long radius=20);
848 void DrawSpline(int PCOUNT, wxPoint* points);
849 void DrawText(const wxString& text, long x, long y);
853 void FloodFill(long x, long y, const wxColour& colour, int style=wxFLOOD_SURFACE);
854 wxBrush GetBackground();
856 long GetCharHeight();
858 void GetClippingBox(long *OUTPUT, long *OUTPUT,
859 long *OUTPUT, long *OUTPUT);
861 int GetLogicalFunction();
862 void GetLogicalScale(double *OUTPUT, double *OUTPUT);
864 bool GetOptimization();
867 %new wxColour* GetPixel(long x, long y) {
868 wxColour* wc = new wxColour();
869 self->GetPixel(x, y, wc);
873 %name(GetSizeTuple)void GetSize(int* OUTPUT, int* OUTPUT);
876 wxColour GetTextBackground();
877 void GetTextExtent(const wxString& string, long *OUTPUT, long *OUTPUT);
878 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
879 long *OUTPUT, long *OUTPUT, long *OUTPUT, long* OUTPUT,
880 const wxFont* font = NULL);
881 wxColour GetTextForeground();
882 void GetUserScale(double *OUTPUT, double *OUTPUT);
883 long LogicalToDeviceX(long x);
884 long LogicalToDeviceXRel(long x);
885 long LogicalToDeviceY(long y);
886 long LogicalToDeviceYRel(long y);
892 void SetDeviceOrigin(long x, long y);
893 void SetBackground(const wxBrush& brush);
894 void SetBackgroundMode(int mode);
895 void SetClippingRegion(long x, long y, long width, long height);
896 %name(SetClippingRegionAsRegion) void SetClippingRegion(const wxRegion& region);
897 void SetPalette(const wxPalette& colourMap);
898 void SetBrush(const wxBrush& brush);
899 void SetFont(const wxFont& font);
900 void SetLogicalFunction(int function);
901 void SetLogicalScale(double x, double y);
902 void SetMapMode(int mode);
903 void SetOptimization(bool optimize);
904 void SetPen(const wxPen& pen);
905 void SetTextBackground(const wxColour& colour);
906 void SetTextForeground(const wxColour& colour);
907 void SetUserScale(double x_scale, double y_scale);
908 bool StartDoc(const wxString& message);
913 void DrawBitmap(const wxBitmap& bitmap, long x, long y,
914 int useMask = FALSE);
916 bool CanDrawBitmap();
917 bool CanGetTextExtent();
921 void GetLogicalOrigin(int *OUTPUT, int *OUTPUT);
922 void SetLogicalOrigin(int x, int y);
923 void GetDeviceOrigin(int *OUTPUT, int *OUTPUT);
924 void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
926 void CalcBoundingBox(int x, int y);
927 void ResetBoundingBox();
930 void GetBoundingBox(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
931 // See below for implementation
940 // NOTE: These methods are VERY SIMILAR in implentation. It would be
941 // nice to factor out common code and or turn them into a set of
942 // template-like macros.
944 // Draw a point for every set of coordinants in pyPoints, optionally
945 // setting a new pen for each
946 PyObject* _DrawPointList(PyObject* pyPoints, PyObject* pyPens) {
947 bool isFastSeq = PyList_Check(pyPoints) || PyTuple_Check(pyPoints);
948 bool isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens);
956 if (!PySequence_Check(pyPoints)) {
959 if (!PySequence_Check(pyPens)) {
962 numObjs = PySequence_Length(pyPoints);
963 numPens = PySequence_Length(pyPens);
965 for (i = 0; i < numObjs; i++) {
969 obj = PySequence_Fast_GET_ITEM(pyPens, i);
972 obj = PySequence_GetItem(pyPens, i);
974 if (SWIG_GetPtrObj(obj, (void **) &pen, "_wxPen_p")) {
985 // Get the point coordinants
987 obj = PySequence_Fast_GET_ITEM(pyPoints, i);
990 obj = PySequence_GetItem(pyPoints, i);
992 if (! _2int_seq_helper(obj, &x1, &y1)) {
998 // Now draw the point
999 self->DrawPoint(x1, y1);
1009 PyErr_SetString(PyExc_TypeError, "Expected a sequence of wxPens");
1012 PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x,y) sequences.");
1017 // Draw a line for every set of coordinants in pyLines, optionally
1018 // setting a new pen for each
1019 PyObject* _DrawLineList(PyObject* pyLines, PyObject* pyPens) {
1020 bool isFastSeq = PyList_Check(pyLines) || PyTuple_Check(pyLines);
1021 bool isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens);
1029 if (!PySequence_Check(pyLines)) {
1032 if (!PySequence_Check(pyPens)) {
1035 numObjs = PySequence_Length(pyLines);
1036 numPens = PySequence_Length(pyPens);
1038 for (i = 0; i < numObjs; i++) {
1042 obj = PySequence_Fast_GET_ITEM(pyPens, i);
1045 obj = PySequence_GetItem(pyPens, i);
1047 if (SWIG_GetPtrObj(obj, (void **) &pen, "_wxPen_p")) {
1058 // Get the line coordinants
1060 obj = PySequence_Fast_GET_ITEM(pyLines, i);
1063 obj = PySequence_GetItem(pyLines, i);
1065 if (! _4int_seq_helper(obj, &x1, &y1, &x2, &y2)) {
1071 // Now draw the line
1072 self->DrawLine(x1, y1, x2, y2);
1082 PyErr_SetString(PyExc_TypeError, "Expected a sequence of wxPens");
1085 PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x1,y1, x2,y2) sequences.");
1091 %pragma(python) addtoclass = "
1092 def DrawPointList(self, points, pens=None):
1095 elif isinstance(pens, wxPenPtr):
1097 elif len(pens) != len(points):
1098 raise ValueError('points and pens must have same length')
1099 return self._DrawPointList(points, pens)
1101 def DrawLineList(self, lines, pens=None):
1104 elif isinstance(pens, wxPenPtr):
1106 elif len(pens) != len(lines):
1107 raise ValueError('lines and pens must have same length')
1108 return self._DrawLineList(lines, pens)
1117 static void wxDC_GetBoundingBox(wxDC* dc, int* x1, int* y1, int* x2, int* y2) {
1125 //----------------------------------------------------------------------
1127 class wxMemoryDC : public wxDC {
1131 void SelectObject(const wxBitmap& bitmap);
1134 %new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC);
1135 %{ // Alternate 'constructor'
1136 wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) {
1137 return new wxMemoryDC(oldDC);
1142 //---------------------------------------------------------------------------
1144 class wxScreenDC : public wxDC {
1148 %name(StartDrawingOnTopWin) bool StartDrawingOnTop(wxWindow* window);
1149 bool StartDrawingOnTop(wxRect* rect = NULL);
1150 bool EndDrawingOnTop();
1153 //---------------------------------------------------------------------------
1155 class wxClientDC : public wxDC {
1157 wxClientDC(wxWindow* win);
1160 //---------------------------------------------------------------------------
1162 class wxPaintDC : public wxDC {
1164 wxPaintDC(wxWindow* win);
1167 //---------------------------------------------------------------------------
1169 class wxWindowDC : public wxDC {
1171 wxWindowDC(wxWindow* win);
1174 //---------------------------------------------------------------------------
1180 #include <wx/metafile.h>
1183 class wxMetaFile : public wxObject {
1185 wxMetaFile(const wxString& filename = wxEmptyString);
1189 bool SetClipboard(int width = 0, int height = 0);
1195 const wxString& GetFileName() const { return m_filename; }
1199 // bool wxMakeMetaFilePlaceable(const wxString& filename,
1200 // int minX, int minY, int maxX, int maxY, float scale=1.0);
1203 class wxMetaFileDC : public wxDC {
1205 wxMetaFileDC(const wxString& filename = wxEmptyString,
1206 int width = 0, int height = 0,
1207 const wxString& description = wxEmptyString);
1208 wxMetaFile* Close();
1213 //---------------------------------------------------------------------------
1215 class wxPalette : public wxGDIObject {
1217 wxPalette(int LCOUNT, byte* choices, byte* choices, byte* choices);
1220 int GetPixel(byte red, byte green, byte blue);
1221 bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT);
1225 //---------------------------------------------------------------------------
1228 wxIMAGELIST_DRAW_NORMAL ,
1229 wxIMAGELIST_DRAW_TRANSPARENT,
1230 wxIMAGELIST_DRAW_SELECTED,
1231 wxIMAGELIST_DRAW_FOCUSED,
1232 wxIMAGE_LIST_NORMAL,
1237 class wxImageList : public wxObject {
1239 wxImageList(int width, int height, int mask=TRUE, int initialCount=1);
1242 int Add(const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
1243 %name(AddWithColourMask)int Add(const wxBitmap& bitmap, const wxColour& maskColour);
1244 %name(AddIcon)int Add(const wxIcon& icon);
1246 bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
1248 // %name(ReplaceIcon)bool Replace(int index, const wxIcon& icon);
1249 // int Add(const wxBitmap& bitmap);
1250 bool Replace(int index, const wxBitmap& bitmap);
1253 bool Draw(int index, wxDC& dc, int x, int x, int flags = wxIMAGELIST_DRAW_NORMAL,
1254 const bool solidBackground = FALSE);
1256 int GetImageCount();
1257 bool Remove(int index);
1259 void GetSize(int index, int& OUTPUT, int& OUTPUT);
1263 //---------------------------------------------------------------------------
1266 enum wxRegionContain {
1267 wxOutRegion, wxPartRegion, wxInRegion
1271 class wxRegion : public wxGDIObject {
1273 wxRegion(long x=0, long y=0, long width=0, long height=0);
1278 bool Offset(wxCoord x, wxCoord y);
1281 wxRegionContain Contains(long x, long y);
1282 %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt);
1283 %name(ContainsRect)wxRegionContain Contains(const wxRect& rect);
1284 %name(ContainsRectDim)wxRegionContain Contains(long x, long y, long w, long h);
1288 bool Intersect(long x, long y, long width, long height);
1289 %name(IntersectRect)bool Intersect(const wxRect& rect);
1290 %name(IntersectRegion)bool Intersect(const wxRegion& region);
1294 bool Union(long x, long y, long width, long height);
1295 %name(UnionRect)bool Union(const wxRect& rect);
1296 %name(UnionRegion)bool Union(const wxRegion& region);
1298 bool Subtract(long x, long y, long width, long height);
1299 %name(SubtractRect)bool Subtract(const wxRect& rect);
1300 %name(SubtractRegion)bool Subtract(const wxRegion& region);
1302 bool Xor(long x, long y, long width, long height);
1303 %name(XorRect)bool Xor(const wxRect& rect);
1304 %name(XorRegion)bool Xor(const wxRegion& region);
1309 class wxRegionIterator : public wxObject {
1311 wxRegionIterator(const wxRegion& region);
1312 ~wxRegionIterator();
1332 //---------------------------------------------------------------------------
1339 extern wxFont *wxNORMAL_FONT;
1340 extern wxFont *wxSMALL_FONT;
1341 extern wxFont *wxITALIC_FONT;
1342 extern wxFont *wxSWISS_FONT;
1344 extern wxPen *wxRED_PEN;
1345 extern wxPen *wxCYAN_PEN;
1346 extern wxPen *wxGREEN_PEN;
1347 extern wxPen *wxBLACK_PEN;
1348 extern wxPen *wxWHITE_PEN;
1349 extern wxPen *wxTRANSPARENT_PEN;
1350 extern wxPen *wxBLACK_DASHED_PEN;
1351 extern wxPen *wxGREY_PEN;
1352 extern wxPen *wxMEDIUM_GREY_PEN;
1353 extern wxPen *wxLIGHT_GREY_PEN;
1355 extern wxBrush *wxBLUE_BRUSH;
1356 extern wxBrush *wxGREEN_BRUSH;
1357 extern wxBrush *wxWHITE_BRUSH;
1358 extern wxBrush *wxBLACK_BRUSH;
1359 extern wxBrush *wxTRANSPARENT_BRUSH;
1360 extern wxBrush *wxCYAN_BRUSH;
1361 extern wxBrush *wxRED_BRUSH;
1362 extern wxBrush *wxGREY_BRUSH;
1363 extern wxBrush *wxMEDIUM_GREY_BRUSH;
1364 extern wxBrush *wxLIGHT_GREY_BRUSH;
1366 extern wxColour *wxBLACK;
1367 extern wxColour *wxWHITE;
1368 extern wxColour *wxRED;
1369 extern wxColour *wxBLUE;
1370 extern wxColour *wxGREEN;
1371 extern wxColour *wxCYAN;
1372 extern wxColour *wxLIGHT_GREY;
1374 extern wxCursor *wxSTANDARD_CURSOR;
1375 extern wxCursor *wxHOURGLASS_CURSOR;
1376 extern wxCursor *wxCROSS_CURSOR;
1379 extern wxBitmap wxNullBitmap;
1380 extern wxIcon wxNullIcon;
1381 extern wxCursor wxNullCursor;
1382 extern wxPen wxNullPen;
1383 extern wxBrush wxNullBrush;
1384 extern wxPalette wxNullPalette;
1385 extern wxFont wxNullFont;
1386 extern wxColour wxNullColour;
1389 extern wxFontList* wxTheFontList;
1390 extern wxPenList* wxThePenList;
1391 extern wxBrushList* wxTheBrushList;
1392 extern wxColourDatabase* wxTheColourDatabase;
1400 //---------------------------------------------------------------------------
1401 //---------------------------------------------------------------------------