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>
26 //----------------------------------------------------------------------
29 %include my_typemaps.i
31 // Import some definitions of other classes, etc.
36 //---------------------------------------------------------------------------
38 // Put some wx default wxChar* values into wxStrings.
39 static const wxString wxPyEmptyString(wxT(""));
41 //---------------------------------------------------------------------------
43 class wxGDIObject : public wxObject {
49 void SetVisible( bool visible );
55 //---------------------------------------------------------------------------
57 class wxBitmap : public wxGDIObject
60 wxBitmap(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_ANY);
63 wxPalette* GetPalette();
65 bool LoadFile(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_ANY);
66 bool SaveFile(const wxString& name, wxBitmapType type, wxPalette* palette = NULL);
67 void SetMask(wxMask* mask);
69 void SetPalette(wxPalette& palette);
75 void SetHandle(long handle);
82 void SetHeight(int h);
85 void SetSize(const wxSize& size);
88 wxBitmap GetSubBitmap( const wxRect& rect );
89 bool CopyFromIcon(const wxIcon& icon);
91 bool CopyFromCursor(const wxCursor& cursor);
93 void SetQuality(int q);
96 %pragma(python) addtoclass = "
97 def __del__(self,gdic=gdic):
99 if self.thisown == 1 :
100 gdic.delete_wxBitmap(self)
107 // Declarations of some alternate "constructors"
108 %new wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1);
109 %new wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings);
110 %new wxBitmap* wxBitmapFromIcon(const wxIcon& icon);
111 %new wxBitmap* wxBitmapFromBits(char* bits, int width, int height, int depth = 1 );
114 // %new wxBitmap* wxBitmapFromData(PyObject* data, long type,
115 // int width, int height, int depth = 1);
120 %{ // Implementations of some alternate "constructors"
122 wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1) {
123 return new wxBitmap(width, height, depth);
126 static char** ConvertListOfStrings(PyObject* listOfStrings) {
127 char** cArray = NULL;
130 if (!PyList_Check(listOfStrings)) {
131 PyErr_SetString(PyExc_TypeError, "Expected a list of strings.");
134 count = PyList_Size(listOfStrings);
135 cArray = new char*[count];
137 for(int x=0; x<count; x++) {
138 // TODO: Need some validation and error checking here
139 cArray[x] = PyString_AsString(PyList_GET_ITEM(listOfStrings, x));
145 wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings) {
146 char** cArray = NULL;
149 cArray = ConvertListOfStrings(listOfStrings);
152 bmp = new wxBitmap(cArray);
158 wxBitmap* wxBitmapFromIcon(const wxIcon& icon) {
159 return new wxBitmap(icon);
163 wxBitmap* wxBitmapFromBits(char* bits, int width, int height, int depth = 1 ) {
164 return new wxBitmap(bits, width, height, depth);
169 // wxBitmap* wxBitmapFromData(PyObject* data, long type,
170 // int width, int height, int depth = 1) {
171 // if (! PyString_Check(data)) {
172 // PyErr_SetString(PyExc_TypeError, "Expected string object");
175 // return new wxBitmap((void*)PyString_AsString(data), type, width, height, depth);
180 //---------------------------------------------------------------------------
182 class wxMask : public wxObject {
184 wxMask(const wxBitmap& bitmap);
187 %addmethods { void Destroy() { delete self; } }
190 %new wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour);
192 wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour) {
193 return new wxMask(bitmap, colour);
198 //---------------------------------------------------------------------------
201 class wxIcon : public wxGDIObject
204 wxIcon(const wxString& name, long flags,
205 int desiredWidth = -1, int desiredHeight = -1);
209 bool LoadFile(const wxString& name, long flags);
212 // wxGDIImage methods
215 void SetHandle(long handle);
221 void SetWidth(int w);
222 void SetHeight(int h);
223 void SetDepth(int d);
225 void SetSize(const wxSize& size);
227 void CopyFromBitmap(const wxBitmap& bmp);
229 %pragma(python) addtoclass = "
230 def __del__(self,gdic=gdic):
232 if self.thisown == 1 :
233 gdic.delete_wxIcon(self)
240 // Declarations of some alternate "constructors"
241 %new wxIcon* wxEmptyIcon();
242 %new wxIcon* wxIconFromXPMData(PyObject* listOfStrings);
243 %new wxIcon* wxIconFromBitmap(const wxBitmap& bmp);
245 %{ // Implementations of some alternate "constructors"
246 wxIcon* wxEmptyIcon() {
250 wxIcon* wxIconFromXPMData(PyObject* listOfStrings) {
251 char** cArray = NULL;
254 cArray = ConvertListOfStrings(listOfStrings);
257 icon = new wxIcon(cArray);
262 wxIcon* wxIconFromBitmap(const wxBitmap& bmp) {
263 wxIcon* icon = new wxIcon();
264 icon->CopyFromBitmap(bmp);
269 //---------------------------------------------------------------------------
271 class wxCursor : public wxGDIObject
275 wxCursor(const wxString& cursorName, long flags, int hotSpotX=0, int hotSpotY=0);
279 // wxGDIImage methods
282 void SetHandle(long handle);
289 void SetWidth(int w);
290 void SetHeight(int h);
291 void SetDepth(int d);
292 void SetSize(const wxSize& size);
296 %name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id);
297 %{ // Alternate 'constructor'
298 wxCursor* wxPyStockCursor(int id) {
299 return new wxCursor(id);
303 //----------------------------------------------------------------------
308 wxFONTFAMILY_DEFAULT = wxDEFAULT,
309 wxFONTFAMILY_DECORATIVE = wxDECORATIVE,
310 wxFONTFAMILY_ROMAN = wxROMAN,
311 wxFONTFAMILY_SCRIPT = wxSCRIPT,
312 wxFONTFAMILY_SWISS = wxSWISS,
313 wxFONTFAMILY_MODERN = wxMODERN,
314 wxFONTFAMILY_TELETYPE = wxTELETYPE,
322 wxFONTSTYLE_NORMAL = wxNORMAL,
323 wxFONTSTYLE_ITALIC = wxITALIC,
324 wxFONTSTYLE_SLANT = wxSLANT,
331 wxFONTWEIGHT_NORMAL = wxNORMAL,
332 wxFONTWEIGHT_LIGHT = wxLIGHT,
333 wxFONTWEIGHT_BOLD = wxBOLD,
341 wxFONTENCODING_SYSTEM = -1, // system default
342 wxFONTENCODING_DEFAULT, // current default encoding
344 // ISO8859 standard defines a number of single-byte charsets
345 wxFONTENCODING_ISO8859_1, // West European (Latin1)
346 wxFONTENCODING_ISO8859_2, // Central and East European (Latin2)
347 wxFONTENCODING_ISO8859_3, // Esperanto (Latin3)
348 wxFONTENCODING_ISO8859_4, // Baltic (old) (Latin4)
349 wxFONTENCODING_ISO8859_5, // Cyrillic
350 wxFONTENCODING_ISO8859_6, // Arabic
351 wxFONTENCODING_ISO8859_7, // Greek
352 wxFONTENCODING_ISO8859_8, // Hebrew
353 wxFONTENCODING_ISO8859_9, // Turkish (Latin5)
354 wxFONTENCODING_ISO8859_10, // Variation of Latin4 (Latin6)
355 wxFONTENCODING_ISO8859_11, // Thai
356 wxFONTENCODING_ISO8859_12, // doesn't exist currently, but put it
357 // here anyhow to make all ISO8859
358 // consecutive numbers
359 wxFONTENCODING_ISO8859_13, // Baltic (Latin7)
360 wxFONTENCODING_ISO8859_14, // Latin8
361 wxFONTENCODING_ISO8859_15, // Latin9 (a.k.a. Latin0, includes euro)
362 wxFONTENCODING_ISO8859_MAX,
364 // Cyrillic charset soup (see http://czyborra.com/charsets/cyrillic.html)
365 wxFONTENCODING_KOI8, // we don't support any of KOI8 variants
366 wxFONTENCODING_ALTERNATIVE, // same as MS-DOS CP866
367 wxFONTENCODING_BULGARIAN, // used under Linux in Bulgaria
369 // what would we do without Microsoft? They have their own encodings
371 wxFONTENCODING_CP437, // original MS-DOS codepage
372 wxFONTENCODING_CP850, // CP437 merged with Latin1
373 wxFONTENCODING_CP852, // CP437 merged with Latin2
374 wxFONTENCODING_CP855, // another cyrillic encoding
375 wxFONTENCODING_CP866, // and another one
377 wxFONTENCODING_CP874, // WinThai
378 wxFONTENCODING_CP932, // Japanese (shift-JIS)
379 wxFONTENCODING_CP936, // Chiniese simplified (GB)
380 wxFONTENCODING_CP949, // Korean (Hangul charset)
381 wxFONTENCODING_CP950, // Chinese (traditional - Big5)
382 wxFONTENCODING_CP1250, // WinLatin2
383 wxFONTENCODING_CP1251, // WinCyrillic
384 wxFONTENCODING_CP1252, // WinLatin1
385 wxFONTENCODING_CP1253, // WinGreek (8859-7)
386 wxFONTENCODING_CP1254, // WinTurkish
387 wxFONTENCODING_CP1255, // WinHebrew
388 wxFONTENCODING_CP1256, // WinArabic
389 wxFONTENCODING_CP1257, // WinBaltic (same as Latin 7)
390 wxFONTENCODING_CP12_MAX,
392 wxFONTENCODING_UTF7, // UTF-7 Unicode encoding
393 wxFONTENCODING_UTF8, // UTF-8 Unicode encoding
395 wxFONTENCODING_UNICODE, // Unicode - currently used only by
396 // wxEncodingConverter class
403 // wxNativeFontInfo is platform-specific font representation: this struct
404 // should be considered as opaque font description only used by the native
405 // functions, the user code can only get the objects of this type from
406 // somewhere and pass it somewhere else (possibly save them somewhere using
407 // ToString() and restore them using FromString())
408 struct wxNativeFontInfo
411 // init the elements from an XLFD, return TRUE if ok
412 bool FromXFontName(const wxString& xFontName);
414 // return false if we were never initialized with a valid XLFD
415 bool IsDefault() const;
417 // generate an XLFD using the fontElements
418 wxString GetXFontName() const;
421 void SetXFontName(const wxString& xFontName);
424 wxNativeFontInfo() { Init(); }
426 // reset to the default state
430 // accessors and modifiers for the font elements
431 int GetPointSize() const;
432 wxFontStyle GetStyle() const;
433 wxFontWeight GetWeight() const;
434 bool GetUnderlined() const;
435 wxString GetFaceName() const;
436 wxFontFamily GetFamily() const;
437 wxFontEncoding GetEncoding() const;
439 void SetPointSize(int pointsize);
440 void SetStyle(wxFontStyle style);
441 void SetWeight(wxFontWeight weight);
442 void SetUnderlined(bool underlined);
443 void SetFaceName(wxString facename);
444 void SetFamily(wxFontFamily family);
445 void SetEncoding(wxFontEncoding encoding);
448 // it is important to be able to serialize wxNativeFontInfo objects to be
449 // able to store them (in config file, for example)
450 bool FromString(const wxString& s);
451 wxString ToString() const;
455 return self->ToString();
459 // we also want to present the native font descriptions to the user in some
460 // human-readable form (it is not platform independent neither, but can
461 // hopefully be understood by the user)
462 bool FromUserString(const wxString& s);
463 wxString ToUserString() const;
467 // wxFontMapper manages user-definable correspondence between logical font
468 // names and the fonts present on the machine.
470 // The default implementations of all functions will ask the user if they are
471 // not capable of finding the answer themselves and store the answer in a
472 // config file (configurable via SetConfigXXX functions). This behaviour may
473 // be disabled by giving the value of FALSE to "interactive" parameter.
474 // However, the functions will always consult the config file to allow the
475 // user-defined values override the default logic and there is no way to
476 // disable this - which shouldn't be ever needed because if "interactive" was
477 // never TRUE, the config file is never created anyhow.
485 // find an alternative for the given encoding (which is supposed to not be
486 // available on this system). If successful, return TRUE and rwxFontEcoding
487 // that can be used it wxFont ctor otherwise return FALSE
488 //bool GetAltForEncoding(wxFontEncoding encoding,
489 // wxFontEncoding *alt_encoding,
490 // const wxString& facename = wxPyEmptyString,
491 // bool interactive = TRUE);
494 // Find an alternative for the given encoding (which is supposed to not be
495 // available on this system). If successful, returns the encoding otherwise
498 PyObject* GetAltForEncoding(wxFontEncoding encoding,
499 const wxString& facename = wxPyEmptyString,
500 bool interactive = TRUE) {
501 wxFontEncoding alt_enc;
502 if (self->GetAltForEncoding(encoding, &alt_enc, facename, interactive))
503 return PyInt_FromLong(alt_enc);
512 // checks whether given encoding is available in given face or not.
513 // If no facename is given,
514 bool IsEncodingAvailable(wxFontEncoding encoding,
515 const wxString& facename = wxPyEmptyString);
517 // returns the encoding for the given charset (in the form of RFC 2046) or
518 // wxFONTENCODING_SYSTEM if couldn't decode it
519 wxFontEncoding CharsetToEncoding(const wxString& charset,
520 bool interactive = TRUE);
522 // return internal string identifier for the encoding (see also
523 // GetEncodingDescription())
524 static wxString GetEncodingName(wxFontEncoding encoding);
526 // return user-readable string describing the given encoding
528 // NB: hard-coded now, but might change later (read it from config?)
529 static wxString GetEncodingDescription(wxFontEncoding encoding);
531 // the parent window for modal dialogs
532 void SetDialogParent(wxWindow *parent);
534 // the title for the dialogs (note that default is quite reasonable)
535 void SetDialogTitle(const wxString& title);
537 // functions which allow to configure the config object used: by default,
538 // the global one (from wxConfigBase::Get() will be used) and the default
539 // root path for the config settings is the string returned by
540 // GetDefaultConfigPath()
543 // set the config object to use (may be NULL to use default)
544 void SetConfig(wxConfigBase *config);
546 // set the root config path to use (should be an absolute path)
547 void SetConfigPath(const wxString& prefix);
549 // return default config path
550 static wxString GetDefaultConfigPath();
556 class wxFont : public wxGDIObject {
558 wxFont( int pointSize, int family, int style, int weight,
559 int underline=FALSE, const wxString& faceName = wxPyEmptyString,
560 wxFontEncoding encoding=wxFONTENCODING_DEFAULT);
562 %name(wxFontFromNativeInfo)wxFont(const wxNativeFontInfo& info);
567 int GetPointSize() const;
568 int GetFamily() const;
569 int GetStyle() const;
570 int GetWeight() const;
571 bool GetUnderlined() const;
572 wxString GetFaceName() const;
573 wxFontEncoding GetEncoding() const;
577 wxNativeFontInfo* GetNativeFontInfo() const;
578 wxString GetNativeFontInfoDesc() const;
579 wxString GetNativeFontInfoUserDesc() const;
581 void SetPointSize(int pointSize);
582 void SetFamily(int family);
583 void SetStyle(int style);
584 void SetWeight(int weight);
585 void SetFaceName(const wxString& faceName);
586 void SetUnderlined(bool underlined);
587 void SetEncoding(wxFontEncoding encoding);
588 void SetNativeFontInfo(const wxNativeFontInfo& info);
589 // void SetNativeFontInfo(const wxString& info);
590 void SetNativeFontInfoUserDesc(const wxString& info);
592 wxString GetFamilyString() const;
593 wxString GetStyleString() const;
594 wxString GetWeightString() const;
596 static wxFontEncoding GetDefaultEncoding();
597 static void SetDefaultEncoding(wxFontEncoding encoding);
602 class wxFontList : public wxObject {
605 void AddFont(wxFont* font);
606 wxFont * FindOrCreateFont(int point_size, int family, int style, int weight,
607 bool underline = FALSE, const wxString& facename = wxPyEmptyString,
608 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
609 void RemoveFont(wxFont *font);
615 //----------------------------------------------------------------------
617 class wxColour : public wxObject {
619 wxColour(unsigned char red=0, unsigned char green=0, unsigned char blue=0);
622 unsigned char Green();
623 unsigned char Blue();
625 void Set(unsigned char red, unsigned char green, unsigned char blue);
628 PyObject* rv = PyTuple_New(3);
629 PyTuple_SetItem(rv, 0, PyInt_FromLong(self->Red()));
630 PyTuple_SetItem(rv, 1, PyInt_FromLong(self->Green()));
631 PyTuple_SetItem(rv, 2, PyInt_FromLong(self->Blue()));
635 %pragma(python) addtoclass = "asTuple = Get"
636 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
637 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
641 %new wxColour* wxNamedColour(const wxString& colorName);
643 %{ // Alternate 'constructor'
644 wxColour* wxNamedColour(const wxString& colorName) {
645 return new wxColour(colorName);
651 class wxColourDatabase : public wxObject {
654 wxColour *FindColour(const wxString& colour);
655 wxString FindName(const wxColour& colour) const;
658 void Append(const wxString& name, int red, int green, int blue) {
659 // first see if the name is already there
660 wxString cName = name;
662 wxString cName2 = cName;
663 if ( !cName2.Replace(wxT("GRAY"), wxT("GREY")) )
666 wxNode *node = self->First();
668 const wxChar *key = node->GetKeyString();
669 if ( cName == key || cName2 == key ) {
670 wxColour* c = (wxColour *)node->Data();
671 c->Set(red, green, blue);
677 // otherwise append the new colour
678 self->Append(name.c_str(), new wxColour(red, green, blue));
684 //----------------------------------------------------------------------
686 class wxPen : public wxGDIObject {
688 wxPen(wxColour& colour, int width=1, int style=wxSOLID);
692 wxColour GetColour();
698 void SetCap(int cap_style);
699 void SetColour(wxColour& colour);
700 void SetJoin(int join_style);
701 void SetStyle(int style);
702 void SetWidth(int width);
704 // **** This one needs to return a list of ints (wxDash)
705 //int GetDashes(wxDash **dashes);
706 void SetDashes(int LCOUNT, wxDash* choices);
709 wxBitmap* GetStipple();
710 void SetStipple(wxBitmap& stipple);
717 // The list of ints for the dashes needs to exist for the life of the pen
718 // so we make it part of the class to save it. wxPyPen is aliased to wxPen
722 class wxPyPen : public wxPen {
724 wxPyPen(wxColour& colour, int width=1, int style=wxSOLID)
725 : wxPen(colour, width, style)
732 void SetDashes(int nb_dashes, const wxDash *dash) {
735 m_dash = new wxDash[nb_dashes];
736 for (int i=0; i<nb_dashes; i++) {
739 wxPen::SetDashes(nb_dashes, m_dash);
748 class wxPyPen : public wxPen {
750 wxPyPen(wxColour& colour, int width=1, int style=wxSOLID);
753 void SetDashes(int LCOUNT, wxDash* choices);
759 class wxPenList : public wxObject {
762 void AddPen(wxPen* pen);
763 wxPen* FindOrCreatePen(const wxColour& colour, int width, int style);
764 void RemovePen(wxPen* pen);
771 //----------------------------------------------------------------------
773 class wxBrush : public wxGDIObject {
775 wxBrush(const wxColour& colour, int style=wxSOLID);
778 wxColour GetColour();
779 wxBitmap * GetStipple();
782 void SetColour(wxColour &colour);
783 void SetStipple(wxBitmap& bitmap);
784 void SetStyle(int style);
788 class wxBrushList : public wxObject {
791 void AddBrush(wxBrush *brush);
792 wxBrush * FindOrCreateBrush(const wxColour& colour, int style);
793 void RemoveBrush(wxBrush *brush);
798 //----------------------------------------------------------------------
802 class wxDC : public wxObject {
804 // wxDC(); **** abstract base class, can't instantiate.
809 bool Blit(long xdest, long ydest,
810 long width, long height,
811 wxDC *source, long xsrc, long ysrc,
812 int logicalFunc = wxCOPY, int useMask = FALSE);
813 // bool Blit(const wxPoint& destPt, const wxSize& sz,
814 // wxDC *source, const wxPoint& srcPt,
815 // int logicalFunc = wxCOPY, int useMask = FALSE);
818 void CrossHair(long x, long y);
819 void DestroyClippingRegion();
820 long DeviceToLogicalX(long x);
821 long DeviceToLogicalXRel(long x);
822 long DeviceToLogicalY(long y);
823 long DeviceToLogicalYRel(long y);
824 void DrawArc(long x1, long y1, long x2, long y2, long xc, long yc);
825 void DrawCircle(long x, long y, long radius);
826 void DrawEllipse(long x, long y, long width, long height);
827 void DrawEllipticArc(long x, long y, long width, long height, long start, long end);
828 void DrawIcon(const wxIcon& icon, long x, long y);
830 void DrawLabel(const wxString& text, const wxRect& rect,
831 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
832 int indexAccel = -1);
835 wxRect DrawImageLabel(const wxString& text,
836 const wxBitmap& image,
838 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
839 int indexAccel = -1) {
841 self->DrawLabel(text, image, rect, alignment, indexAccel, &rv);
846 void DrawLine(long x1, long y1, long x2, long y2);
847 void DrawLines(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0);
848 void DrawPolygon(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0,
849 int fill_style=wxODDEVEN_RULE);
850 void DrawPoint(long x, long y);
851 void DrawRectangle(long x, long y, long width, long height);
852 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
853 void DrawRoundedRectangle(long x, long y, long width, long height, long radius=20);
854 void DrawSpline(int PCOUNT, wxPoint* points);
855 void DrawText(const wxString& text, long x, long y);
859 void FloodFill(long x, long y, const wxColour& colour, int style=wxFLOOD_SURFACE);
860 wxBrush GetBackground();
862 long GetCharHeight();
864 void GetClippingBox(long *OUTPUT, long *OUTPUT,
865 long *OUTPUT, long *OUTPUT);
867 int GetLogicalFunction();
868 void GetLogicalScale(double *OUTPUT, double *OUTPUT);
870 bool GetOptimization();
873 %new wxColour* GetPixel(long x, long y) {
874 wxColour* wc = new wxColour();
875 self->GetPixel(x, y, wc);
879 %name(GetSizeTuple)void GetSize(int* OUTPUT, int* OUTPUT);
882 wxColour GetTextBackground();
883 void GetTextExtent(const wxString& string, long *OUTPUT, long *OUTPUT);
884 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
885 long *OUTPUT, long *OUTPUT, long *OUTPUT, long* OUTPUT,
886 const wxFont* font = NULL);
887 wxColour GetTextForeground();
888 void GetUserScale(double *OUTPUT, double *OUTPUT);
889 long LogicalToDeviceX(long x);
890 long LogicalToDeviceXRel(long x);
891 long LogicalToDeviceY(long y);
892 long LogicalToDeviceYRel(long y);
898 void SetDeviceOrigin(long x, long y);
899 void SetBackground(const wxBrush& brush);
900 void SetBackgroundMode(int mode);
901 void SetClippingRegion(long x, long y, long width, long height);
902 %name(SetClippingRegionAsRegion) void SetClippingRegion(const wxRegion& region);
903 void SetPalette(const wxPalette& colourMap);
904 void SetBrush(const wxBrush& brush);
905 void SetFont(const wxFont& font);
906 void SetLogicalFunction(int function);
907 void SetLogicalScale(double x, double y);
908 void SetMapMode(int mode);
909 void SetOptimization(bool optimize);
910 void SetPen(const wxPen& pen);
911 void SetTextBackground(const wxColour& colour);
912 void SetTextForeground(const wxColour& colour);
913 void SetUserScale(double x_scale, double y_scale);
914 bool StartDoc(const wxString& message);
919 void DrawBitmap(const wxBitmap& bitmap, long x, long y,
920 int useMask = FALSE);
922 bool CanDrawBitmap();
923 bool CanGetTextExtent();
927 void GetLogicalOrigin(int *OUTPUT, int *OUTPUT);
928 void SetLogicalOrigin(int x, int y);
929 void GetDeviceOrigin(int *OUTPUT, int *OUTPUT);
930 void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
932 void CalcBoundingBox(int x, int y);
933 void ResetBoundingBox();
936 void GetBoundingBox(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
937 // See below for implementation
946 // NOTE: These methods are VERY SIMILAR in implentation. It would be
947 // nice to factor out common code and or turn them into a set of
948 // template-like macros.
950 // Draw a point for every set of coordinants in pyPoints, optionally
951 // setting a new pen for each
952 PyObject* _DrawPointList(PyObject* pyPoints, PyObject* pyPens) {
953 bool isFastSeq = PyList_Check(pyPoints) || PyTuple_Check(pyPoints);
954 bool isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens);
962 if (!PySequence_Check(pyPoints)) {
965 if (!PySequence_Check(pyPens)) {
968 numObjs = PySequence_Length(pyPoints);
969 numPens = PySequence_Length(pyPens);
971 for (i = 0; i < numObjs; i++) {
975 obj = PySequence_Fast_GET_ITEM(pyPens, i);
978 obj = PySequence_GetItem(pyPens, i);
980 if (SWIG_GetPtrObj(obj, (void **) &pen, "_wxPen_p")) {
991 // Get the point coordinants
993 obj = PySequence_Fast_GET_ITEM(pyPoints, i);
996 obj = PySequence_GetItem(pyPoints, i);
998 if (! _2int_seq_helper(obj, &x1, &y1)) {
1004 // Now draw the point
1005 self->DrawPoint(x1, y1);
1015 PyErr_SetString(PyExc_TypeError, "Expected a sequence of wxPens");
1018 PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x,y) sequences.");
1023 // Draw a line for every set of coordinants in pyLines, optionally
1024 // setting a new pen for each
1025 PyObject* _DrawLineList(PyObject* pyLines, PyObject* pyPens) {
1026 bool isFastSeq = PyList_Check(pyLines) || PyTuple_Check(pyLines);
1027 bool isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens);
1035 if (!PySequence_Check(pyLines)) {
1038 if (!PySequence_Check(pyPens)) {
1041 numObjs = PySequence_Length(pyLines);
1042 numPens = PySequence_Length(pyPens);
1044 for (i = 0; i < numObjs; i++) {
1048 obj = PySequence_Fast_GET_ITEM(pyPens, i);
1051 obj = PySequence_GetItem(pyPens, i);
1053 if (SWIG_GetPtrObj(obj, (void **) &pen, "_wxPen_p")) {
1064 // Get the line coordinants
1066 obj = PySequence_Fast_GET_ITEM(pyLines, i);
1069 obj = PySequence_GetItem(pyLines, i);
1071 if (! _4int_seq_helper(obj, &x1, &y1, &x2, &y2)) {
1077 // Now draw the line
1078 self->DrawLine(x1, y1, x2, y2);
1088 PyErr_SetString(PyExc_TypeError, "Expected a sequence of wxPens");
1091 PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x1,y1, x2,y2) sequences.");
1097 %pragma(python) addtoclass = "
1098 def DrawPointList(self, points, pens=None):
1101 elif isinstance(pens, wxPenPtr):
1103 elif len(pens) != len(points):
1104 raise ValueError('points and pens must have same length')
1105 return self._DrawPointList(points, pens)
1107 def DrawLineList(self, lines, pens=None):
1110 elif isinstance(pens, wxPenPtr):
1112 elif len(pens) != len(lines):
1113 raise ValueError('lines and pens must have same length')
1114 return self._DrawLineList(lines, pens)
1123 static void wxDC_GetBoundingBox(wxDC* dc, int* x1, int* y1, int* x2, int* y2) {
1131 //----------------------------------------------------------------------
1133 class wxMemoryDC : public wxDC {
1137 void SelectObject(const wxBitmap& bitmap);
1140 %new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC);
1141 %{ // Alternate 'constructor'
1142 wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) {
1143 return new wxMemoryDC(oldDC);
1148 //---------------------------------------------------------------------------
1150 class wxBufferedDC : public wxMemoryDC {
1152 // Construct a wxBufferedDC using a user supplied buffer.
1153 wxBufferedDC( wxDC *dc, const wxBitmap &buffer );
1155 // Construct a wxBufferedDC with an internal buffer of 'area'
1156 // (where area is usually something like the size of the window
1158 %name(wxBufferedDCInternalBuffer)wxBufferedDC( wxDC *dc, const wxSize &area );
1162 class wxBufferedPaintDC : public wxBufferedDC
1165 wxBufferedPaintDC( wxWindow *window, const wxBitmap &buffer = wxNullBitmap );
1168 //---------------------------------------------------------------------------
1170 class wxScreenDC : public wxDC {
1174 %name(StartDrawingOnTopWin) bool StartDrawingOnTop(wxWindow* window);
1175 bool StartDrawingOnTop(wxRect* rect = NULL);
1176 bool EndDrawingOnTop();
1179 //---------------------------------------------------------------------------
1181 class wxClientDC : public wxDC {
1183 wxClientDC(wxWindow* win);
1186 //---------------------------------------------------------------------------
1188 class wxPaintDC : public wxDC {
1190 wxPaintDC(wxWindow* win);
1193 //---------------------------------------------------------------------------
1195 class wxWindowDC : public wxDC {
1197 wxWindowDC(wxWindow* win);
1200 //---------------------------------------------------------------------------
1206 #include <wx/metafile.h>
1209 class wxMetaFile : public wxObject {
1211 wxMetaFile(const wxString& filename = wxPyEmptyString);
1215 bool SetClipboard(int width = 0, int height = 0);
1221 const wxString& GetFileName() const { return m_filename; }
1225 // bool wxMakeMetaFilePlaceable(const wxString& filename,
1226 // int minX, int minY, int maxX, int maxY, float scale=1.0);
1229 class wxMetaFileDC : public wxDC {
1231 wxMetaFileDC(const wxString& filename = wxPyEmptyString,
1232 int width = 0, int height = 0,
1233 const wxString& description = wxPyEmptyString);
1234 wxMetaFile* Close();
1239 //---------------------------------------------------------------------------
1241 class wxPalette : public wxGDIObject {
1243 wxPalette(int LCOUNT, byte* choices, byte* choices, byte* choices);
1246 int GetPixel(byte red, byte green, byte blue);
1247 bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT);
1251 //---------------------------------------------------------------------------
1254 wxIMAGELIST_DRAW_NORMAL ,
1255 wxIMAGELIST_DRAW_TRANSPARENT,
1256 wxIMAGELIST_DRAW_SELECTED,
1257 wxIMAGELIST_DRAW_FOCUSED,
1258 wxIMAGE_LIST_NORMAL,
1263 class wxImageList : public wxObject {
1265 wxImageList(int width, int height, int mask=TRUE, int initialCount=1);
1268 int Add(const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
1269 %name(AddWithColourMask)int Add(const wxBitmap& bitmap, const wxColour& maskColour);
1270 %name(AddIcon)int Add(const wxIcon& icon);
1272 bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
1274 // %name(ReplaceIcon)bool Replace(int index, const wxIcon& icon);
1275 // int Add(const wxBitmap& bitmap);
1276 bool Replace(int index, const wxBitmap& bitmap);
1279 bool Draw(int index, wxDC& dc, int x, int x, int flags = wxIMAGELIST_DRAW_NORMAL,
1280 const bool solidBackground = FALSE);
1282 int GetImageCount();
1283 bool Remove(int index);
1285 void GetSize(int index, int& OUTPUT, int& OUTPUT);
1289 //---------------------------------------------------------------------------
1292 enum wxRegionContain {
1293 wxOutRegion, wxPartRegion, wxInRegion
1297 class wxRegion : public wxGDIObject {
1299 wxRegion(long x=0, long y=0, long width=0, long height=0);
1304 bool Offset(wxCoord x, wxCoord y);
1307 wxRegionContain Contains(long x, long y);
1308 %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt);
1309 %name(ContainsRect)wxRegionContain Contains(const wxRect& rect);
1310 %name(ContainsRectDim)wxRegionContain Contains(long x, long y, long w, long h);
1314 bool Intersect(long x, long y, long width, long height);
1315 %name(IntersectRect)bool Intersect(const wxRect& rect);
1316 %name(IntersectRegion)bool Intersect(const wxRegion& region);
1320 bool Union(long x, long y, long width, long height);
1321 %name(UnionRect)bool Union(const wxRect& rect);
1322 %name(UnionRegion)bool Union(const wxRegion& region);
1324 bool Subtract(long x, long y, long width, long height);
1325 %name(SubtractRect)bool Subtract(const wxRect& rect);
1326 %name(SubtractRegion)bool Subtract(const wxRegion& region);
1328 bool Xor(long x, long y, long width, long height);
1329 %name(XorRect)bool Xor(const wxRect& rect);
1330 %name(XorRegion)bool Xor(const wxRegion& region);
1335 class wxRegionIterator : public wxObject {
1337 wxRegionIterator(const wxRegion& region);
1338 ~wxRegionIterator();
1358 //---------------------------------------------------------------------------
1365 extern wxFont *wxNORMAL_FONT;
1366 extern wxFont *wxSMALL_FONT;
1367 extern wxFont *wxITALIC_FONT;
1368 extern wxFont *wxSWISS_FONT;
1370 extern wxPen *wxRED_PEN;
1371 extern wxPen *wxCYAN_PEN;
1372 extern wxPen *wxGREEN_PEN;
1373 extern wxPen *wxBLACK_PEN;
1374 extern wxPen *wxWHITE_PEN;
1375 extern wxPen *wxTRANSPARENT_PEN;
1376 extern wxPen *wxBLACK_DASHED_PEN;
1377 extern wxPen *wxGREY_PEN;
1378 extern wxPen *wxMEDIUM_GREY_PEN;
1379 extern wxPen *wxLIGHT_GREY_PEN;
1381 extern wxBrush *wxBLUE_BRUSH;
1382 extern wxBrush *wxGREEN_BRUSH;
1383 extern wxBrush *wxWHITE_BRUSH;
1384 extern wxBrush *wxBLACK_BRUSH;
1385 extern wxBrush *wxTRANSPARENT_BRUSH;
1386 extern wxBrush *wxCYAN_BRUSH;
1387 extern wxBrush *wxRED_BRUSH;
1388 extern wxBrush *wxGREY_BRUSH;
1389 extern wxBrush *wxMEDIUM_GREY_BRUSH;
1390 extern wxBrush *wxLIGHT_GREY_BRUSH;
1392 extern wxColour *wxBLACK;
1393 extern wxColour *wxWHITE;
1394 extern wxColour *wxRED;
1395 extern wxColour *wxBLUE;
1396 extern wxColour *wxGREEN;
1397 extern wxColour *wxCYAN;
1398 extern wxColour *wxLIGHT_GREY;
1400 extern wxCursor *wxSTANDARD_CURSOR;
1401 extern wxCursor *wxHOURGLASS_CURSOR;
1402 extern wxCursor *wxCROSS_CURSOR;
1405 extern wxBitmap wxNullBitmap;
1406 extern wxIcon wxNullIcon;
1407 extern wxCursor wxNullCursor;
1408 extern wxPen wxNullPen;
1409 extern wxBrush wxNullBrush;
1410 extern wxPalette wxNullPalette;
1411 extern wxFont wxNullFont;
1412 extern wxColour wxNullColour;
1415 extern wxFontList* wxTheFontList;
1416 extern wxPenList* wxThePenList;
1417 extern wxBrushList* wxTheBrushList;
1418 extern wxColourDatabase* wxTheColourDatabase;
1426 //---------------------------------------------------------------------------
1427 //---------------------------------------------------------------------------