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 class wxGDIObject : public wxObject {
44 void SetVisible( bool visible );
50 //---------------------------------------------------------------------------
52 class wxBitmap : public wxGDIObject
55 wxBitmap(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_ANY);
58 wxPalette* GetPalette();
60 bool LoadFile(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_ANY);
61 bool SaveFile(const wxString& name, wxBitmapType type, wxPalette* palette = NULL);
62 void SetMask(wxMask* mask);
64 void SetPalette(wxPalette& palette);
70 void SetHandle(long handle);
77 void SetHeight(int h);
80 void SetSize(const wxSize& size);
83 wxBitmap GetSubBitmap( const wxRect& rect );
84 bool CopyFromIcon(const wxIcon& icon);
86 bool CopyFromCursor(const wxCursor& cursor);
88 void SetQuality(int q);
91 %pragma(python) addtoclass = "
92 def __del__(self,gdic=gdic):
94 if self.thisown == 1 :
95 gdic.delete_wxBitmap(self)
102 // Declarations of some alternate "constructors"
103 %new wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1);
104 %new wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings);
105 %new wxBitmap* wxBitmapFromIcon(const wxIcon& icon);
106 %new wxBitmap* wxBitmapFromBits(char* bits, int width, int height, int depth = 1 );
109 // %new wxBitmap* wxBitmapFromData(PyObject* data, long type,
110 // int width, int height, int depth = 1);
115 %{ // Implementations of some alternate "constructors"
117 wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1) {
118 return new wxBitmap(width, height, depth);
121 static char** ConvertListOfStrings(PyObject* listOfStrings) {
122 char** cArray = NULL;
125 if (!PyList_Check(listOfStrings)) {
126 PyErr_SetString(PyExc_TypeError, "Expected a list of strings.");
129 count = PyList_Size(listOfStrings);
130 cArray = new char*[count];
132 for(int x=0; x<count; x++) {
133 // TODO: Need some validation and error checking here
134 cArray[x] = PyString_AsString(PyList_GET_ITEM(listOfStrings, x));
140 wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings) {
141 char** cArray = NULL;
144 cArray = ConvertListOfStrings(listOfStrings);
147 bmp = new wxBitmap(cArray);
153 wxBitmap* wxBitmapFromIcon(const wxIcon& icon) {
154 return new wxBitmap(icon);
158 wxBitmap* wxBitmapFromBits(char* bits, int width, int height, int depth = 1 ) {
159 return new wxBitmap(bits, width, height, depth);
164 // wxBitmap* wxBitmapFromData(PyObject* data, long type,
165 // int width, int height, int depth = 1) {
166 // if (! PyString_Check(data)) {
167 // PyErr_SetString(PyExc_TypeError, "Expected string object");
170 // return new wxBitmap((void*)PyString_AsString(data), type, width, height, depth);
175 //---------------------------------------------------------------------------
177 class wxMask : public wxObject {
179 wxMask(const wxBitmap& bitmap);
182 %addmethods { void Destroy() { delete self; } }
185 %new wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour);
187 wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour) {
188 return new wxMask(bitmap, colour);
193 //---------------------------------------------------------------------------
196 class wxIcon : public wxGDIObject
199 wxIcon(const wxString& name, long flags,
200 int desiredWidth = -1, int desiredHeight = -1);
204 bool LoadFile(const wxString& name, long flags);
207 // wxGDIImage methods
210 void SetHandle(long handle);
216 void SetWidth(int w);
217 void SetHeight(int h);
218 void SetDepth(int d);
220 void SetSize(const wxSize& size);
222 void CopyFromBitmap(const wxBitmap& bmp);
224 %pragma(python) addtoclass = "
225 def __del__(self,gdic=gdic):
227 if self.thisown == 1 :
228 gdic.delete_wxIcon(self)
235 // Declarations of some alternate "constructors"
236 %new wxIcon* wxEmptyIcon();
237 %new wxIcon* wxIconFromXPMData(PyObject* listOfStrings);
238 %new wxIcon* wxIconFromBitmap(const wxBitmap& bmp);
240 %{ // Implementations of some alternate "constructors"
241 wxIcon* wxEmptyIcon() {
245 wxIcon* wxIconFromXPMData(PyObject* listOfStrings) {
246 char** cArray = NULL;
249 cArray = ConvertListOfStrings(listOfStrings);
252 icon = new wxIcon(cArray);
257 wxIcon* wxIconFromBitmap(const wxBitmap& bmp) {
258 wxIcon* icon = new wxIcon();
259 icon->CopyFromBitmap(bmp);
264 //---------------------------------------------------------------------------
266 class wxCursor : public wxGDIObject
270 wxCursor(const wxString& cursorName, long flags, int hotSpotX=0, int hotSpotY=0);
274 // wxGDIImage methods
277 void SetHandle(long handle);
284 void SetWidth(int w);
285 void SetHeight(int h);
286 void SetDepth(int d);
287 void SetSize(const wxSize& size);
291 %name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id);
292 %{ // Alternate 'constructor'
293 wxCursor* wxPyStockCursor(int id) {
294 return new wxCursor(id);
298 //----------------------------------------------------------------------
303 wxFONTFAMILY_DEFAULT = wxDEFAULT,
304 wxFONTFAMILY_DECORATIVE = wxDECORATIVE,
305 wxFONTFAMILY_ROMAN = wxROMAN,
306 wxFONTFAMILY_SCRIPT = wxSCRIPT,
307 wxFONTFAMILY_SWISS = wxSWISS,
308 wxFONTFAMILY_MODERN = wxMODERN,
309 wxFONTFAMILY_TELETYPE = wxTELETYPE,
317 wxFONTSTYLE_NORMAL = wxNORMAL,
318 wxFONTSTYLE_ITALIC = wxITALIC,
319 wxFONTSTYLE_SLANT = wxSLANT,
326 wxFONTWEIGHT_NORMAL = wxNORMAL,
327 wxFONTWEIGHT_LIGHT = wxLIGHT,
328 wxFONTWEIGHT_BOLD = wxBOLD,
336 wxFONTENCODING_SYSTEM = -1, // system default
337 wxFONTENCODING_DEFAULT, // current default encoding
339 // ISO8859 standard defines a number of single-byte charsets
340 wxFONTENCODING_ISO8859_1, // West European (Latin1)
341 wxFONTENCODING_ISO8859_2, // Central and East European (Latin2)
342 wxFONTENCODING_ISO8859_3, // Esperanto (Latin3)
343 wxFONTENCODING_ISO8859_4, // Baltic (old) (Latin4)
344 wxFONTENCODING_ISO8859_5, // Cyrillic
345 wxFONTENCODING_ISO8859_6, // Arabic
346 wxFONTENCODING_ISO8859_7, // Greek
347 wxFONTENCODING_ISO8859_8, // Hebrew
348 wxFONTENCODING_ISO8859_9, // Turkish (Latin5)
349 wxFONTENCODING_ISO8859_10, // Variation of Latin4 (Latin6)
350 wxFONTENCODING_ISO8859_11, // Thai
351 wxFONTENCODING_ISO8859_12, // doesn't exist currently, but put it
352 // here anyhow to make all ISO8859
353 // consecutive numbers
354 wxFONTENCODING_ISO8859_13, // Baltic (Latin7)
355 wxFONTENCODING_ISO8859_14, // Latin8
356 wxFONTENCODING_ISO8859_15, // Latin9 (a.k.a. Latin0, includes euro)
357 wxFONTENCODING_ISO8859_MAX,
359 // Cyrillic charset soup (see http://czyborra.com/charsets/cyrillic.html)
360 wxFONTENCODING_KOI8, // we don't support any of KOI8 variants
361 wxFONTENCODING_ALTERNATIVE, // same as MS-DOS CP866
362 wxFONTENCODING_BULGARIAN, // used under Linux in Bulgaria
364 // what would we do without Microsoft? They have their own encodings
366 wxFONTENCODING_CP437, // original MS-DOS codepage
367 wxFONTENCODING_CP850, // CP437 merged with Latin1
368 wxFONTENCODING_CP852, // CP437 merged with Latin2
369 wxFONTENCODING_CP855, // another cyrillic encoding
370 wxFONTENCODING_CP866, // and another one
372 wxFONTENCODING_CP874, // WinThai
373 wxFONTENCODING_CP932, // Japanese (shift-JIS)
374 wxFONTENCODING_CP936, // Chiniese simplified (GB)
375 wxFONTENCODING_CP949, // Korean (Hangul charset)
376 wxFONTENCODING_CP950, // Chinese (traditional - Big5)
377 wxFONTENCODING_CP1250, // WinLatin2
378 wxFONTENCODING_CP1251, // WinCyrillic
379 wxFONTENCODING_CP1252, // WinLatin1
380 wxFONTENCODING_CP1253, // WinGreek (8859-7)
381 wxFONTENCODING_CP1254, // WinTurkish
382 wxFONTENCODING_CP1255, // WinHebrew
383 wxFONTENCODING_CP1256, // WinArabic
384 wxFONTENCODING_CP1257, // WinBaltic (same as Latin 7)
385 wxFONTENCODING_CP12_MAX,
387 wxFONTENCODING_UTF7, // UTF-7 Unicode encoding
388 wxFONTENCODING_UTF8, // UTF-8 Unicode encoding
390 wxFONTENCODING_UNICODE, // Unicode - currently used only by
391 // wxEncodingConverter class
398 // wxNativeFontInfo is platform-specific font representation: this struct
399 // should be considered as opaque font description only used by the native
400 // functions, the user code can only get the objects of this type from
401 // somewhere and pass it somewhere else (possibly save them somewhere using
402 // ToString() and restore them using FromString())
403 struct wxNativeFontInfo
406 // init the elements from an XLFD, return TRUE if ok
407 bool FromXFontName(const wxString& xFontName);
409 // return false if we were never initialized with a valid XLFD
410 bool IsDefault() const;
412 // generate an XLFD using the fontElements
413 wxString GetXFontName() const;
416 void SetXFontName(const wxString& xFontName);
419 wxNativeFontInfo() { Init(); }
421 // reset to the default state
425 // accessors and modifiers for the font elements
426 int GetPointSize() const;
427 wxFontStyle GetStyle() const;
428 wxFontWeight GetWeight() const;
429 bool GetUnderlined() const;
430 wxString GetFaceName() const;
431 wxFontFamily GetFamily() const;
432 wxFontEncoding GetEncoding() const;
434 void SetPointSize(int pointsize);
435 void SetStyle(wxFontStyle style);
436 void SetWeight(wxFontWeight weight);
437 void SetUnderlined(bool underlined);
438 void SetFaceName(wxString facename);
439 void SetFamily(wxFontFamily family);
440 void SetEncoding(wxFontEncoding encoding);
443 // it is important to be able to serialize wxNativeFontInfo objects to be
444 // able to store them (in config file, for example)
445 bool FromString(const wxString& s);
446 wxString ToString() const;
450 return self->ToString();
454 // we also want to present the native font descriptions to the user in some
455 // human-readable form (it is not platform independent neither, but can
456 // hopefully be understood by the user)
457 bool FromUserString(const wxString& s);
458 wxString ToUserString() const;
462 // wxFontMapper manages user-definable correspondence between logical font
463 // names and the fonts present on the machine.
465 // The default implementations of all functions will ask the user if they are
466 // not capable of finding the answer themselves and store the answer in a
467 // config file (configurable via SetConfigXXX functions). This behaviour may
468 // be disabled by giving the value of FALSE to "interactive" parameter.
469 // However, the functions will always consult the config file to allow the
470 // user-defined values override the default logic and there is no way to
471 // disable this - which shouldn't be ever needed because if "interactive" was
472 // never TRUE, the config file is never created anyhow.
480 // find an alternative for the given encoding (which is supposed to not be
481 // available on this system). If successful, return TRUE and rwxFontEcoding
482 // that can be used it wxFont ctor otherwise return FALSE
483 //bool GetAltForEncoding(wxFontEncoding encoding,
484 // wxFontEncoding *alt_encoding,
485 // const wxString& facename = wxEmptyString,
486 // bool interactive = TRUE);
489 // Find an alternative for the given encoding (which is supposed to not be
490 // available on this system). If successful, returns the encoding otherwise
493 PyObject* GetAltForEncoding(wxFontEncoding encoding,
494 const wxString& facename = wxEmptyString,
495 bool interactive = TRUE) {
496 wxFontEncoding alt_enc;
497 if (self->GetAltForEncoding(encoding, &alt_enc, facename, interactive))
498 return PyInt_FromLong(alt_enc);
507 // checks whether given encoding is available in given face or not.
508 // If no facename is given,
509 bool IsEncodingAvailable(wxFontEncoding encoding,
510 const wxString& facename = wxEmptyString);
512 // returns the encoding for the given charset (in the form of RFC 2046) or
513 // wxFONTENCODING_SYSTEM if couldn't decode it
514 wxFontEncoding CharsetToEncoding(const wxString& charset,
515 bool interactive = TRUE);
517 // return internal string identifier for the encoding (see also
518 // GetEncodingDescription())
519 static wxString GetEncodingName(wxFontEncoding encoding);
521 // return user-readable string describing the given encoding
523 // NB: hard-coded now, but might change later (read it from config?)
524 static wxString GetEncodingDescription(wxFontEncoding encoding);
526 // the parent window for modal dialogs
527 void SetDialogParent(wxWindow *parent);
529 // the title for the dialogs (note that default is quite reasonable)
530 void SetDialogTitle(const wxString& title);
532 // functions which allow to configure the config object used: by default,
533 // the global one (from wxConfigBase::Get() will be used) and the default
534 // root path for the config settings is the string returned by
535 // GetDefaultConfigPath()
538 // set the config object to use (may be NULL to use default)
539 void SetConfig(wxConfigBase *config);
541 // set the root config path to use (should be an absolute path)
542 void SetConfigPath(const wxString& prefix);
544 // return default config path
545 static const wxChar *GetDefaultConfigPath();
551 class wxFont : public wxGDIObject {
553 wxFont( int pointSize, int family, int style, int weight,
554 int underline=FALSE, char* faceName = "",
555 wxFontEncoding encoding=wxFONTENCODING_DEFAULT);
557 %name(wxFontFromNativeInfo)wxFont(const wxNativeFontInfo& info);
562 int GetPointSize() const;
563 int GetFamily() const;
564 int GetStyle() const;
565 int GetWeight() const;
566 bool GetUnderlined() const;
567 wxString GetFaceName() const;
568 wxFontEncoding GetEncoding() const;
572 wxNativeFontInfo* GetNativeFontInfo() const;
573 wxString GetNativeFontInfoDesc() const;
574 wxString GetNativeFontInfoUserDesc() const;
576 void SetPointSize(int pointSize);
577 void SetFamily(int family);
578 void SetStyle(int style);
579 void SetWeight(int weight);
580 void SetFaceName(const wxString& faceName);
581 void SetUnderlined(bool underlined);
582 void SetEncoding(wxFontEncoding encoding);
583 void SetNativeFontInfo(const wxNativeFontInfo& info);
584 // void SetNativeFontInfo(const wxString& info);
585 void SetNativeFontInfoUserDesc(const wxString& info);
587 wxString GetFamilyString() const;
588 wxString GetStyleString() const;
589 wxString GetWeightString() const;
591 static wxFontEncoding GetDefaultEncoding();
592 static void SetDefaultEncoding(wxFontEncoding encoding);
597 class wxFontList : public wxObject {
600 void AddFont(wxFont* font);
601 wxFont * FindOrCreateFont(int point_size, int family, int style, int weight,
602 bool underline = FALSE, const char* facename = NULL,
603 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
604 void RemoveFont(wxFont *font);
610 //----------------------------------------------------------------------
612 class wxColour : public wxObject {
614 wxColour(unsigned char red=0, unsigned char green=0, unsigned char blue=0);
617 unsigned char Green();
618 unsigned char Blue();
620 void Set(unsigned char red, unsigned char green, unsigned char blue);
623 PyObject* rv = PyTuple_New(3);
624 PyTuple_SetItem(rv, 0, PyInt_FromLong(self->Red()));
625 PyTuple_SetItem(rv, 1, PyInt_FromLong(self->Green()));
626 PyTuple_SetItem(rv, 2, PyInt_FromLong(self->Blue()));
630 %pragma(python) addtoclass = "asTuple = Get"
631 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
632 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
636 %new wxColour* wxNamedColour(const wxString& colorName);
638 %{ // Alternate 'constructor'
639 wxColour* wxNamedColour(const wxString& colorName) {
640 return new wxColour(colorName);
646 class wxColourDatabase : public wxObject {
649 wxColour *FindColour(const wxString& colour);
650 wxString FindName(const wxColour& colour) const;
653 void Append(const wxString& name, int red, int green, int blue) {
654 // first see if the name is already there
655 wxString cName = name;
657 wxString cName2 = cName;
658 if ( !cName2.Replace(wxT("GRAY"), wxT("GREY")) )
661 wxNode *node = self->First();
663 const wxChar *key = node->GetKeyString();
664 if ( cName == key || cName2 == key ) {
665 wxColour* c = (wxColour *)node->Data();
666 c->Set(red, green, blue);
672 // otherwise append the new colour
673 self->Append(name.c_str(), new wxColour(red, green, blue));
679 //----------------------------------------------------------------------
681 class wxPen : public wxGDIObject {
683 wxPen(wxColour& colour, int width=1, int style=wxSOLID);
687 wxColour GetColour();
693 void SetCap(int cap_style);
694 void SetColour(wxColour& colour);
695 void SetJoin(int join_style);
696 void SetStyle(int style);
697 void SetWidth(int width);
699 // **** This one needs to return a list of ints (wxDash)
700 //int GetDashes(wxDash **dashes);
701 void SetDashes(int LCOUNT, wxDash* choices);
704 wxBitmap* GetStipple();
705 void SetStipple(wxBitmap& stipple);
712 // The list of ints for the dashes needs to exist for the life of the pen
713 // so we make it part of the class to save it. wxPyPen is aliased to wxPen
717 class wxPyPen : public wxPen {
719 wxPyPen(wxColour& colour, int width=1, int style=wxSOLID)
720 : wxPen(colour, width, style)
727 void SetDashes(int nb_dashes, const wxDash *dash) {
730 m_dash = new wxDash[nb_dashes];
731 for (int i=0; i<nb_dashes; i++) {
734 wxPen::SetDashes(nb_dashes, m_dash);
743 class wxPyPen : public wxPen {
745 wxPyPen(wxColour& colour, int width=1, int style=wxSOLID);
748 void SetDashes(int LCOUNT, wxDash* choices);
754 class wxPenList : public wxObject {
757 void AddPen(wxPen* pen);
758 wxPen* FindOrCreatePen(const wxColour& colour, int width, int style);
759 void RemovePen(wxPen* pen);
766 //----------------------------------------------------------------------
768 class wxBrush : public wxGDIObject {
770 wxBrush(const wxColour& colour, int style=wxSOLID);
773 wxColour GetColour();
774 wxBitmap * GetStipple();
777 void SetColour(wxColour &colour);
778 void SetStipple(wxBitmap& bitmap);
779 void SetStyle(int style);
783 class wxBrushList : public wxObject {
786 void AddBrush(wxBrush *brush);
787 wxBrush * FindOrCreateBrush(const wxColour& colour, int style);
788 void RemoveBrush(wxBrush *brush);
793 //----------------------------------------------------------------------
797 class wxDC : public wxObject {
799 // wxDC(); **** abstract base class, can't instantiate.
804 bool Blit(long xdest, long ydest,
805 long width, long height,
806 wxDC *source, long xsrc, long ysrc,
807 int logicalFunc = wxCOPY, int useMask = FALSE);
808 // bool Blit(const wxPoint& destPt, const wxSize& sz,
809 // wxDC *source, const wxPoint& srcPt,
810 // int logicalFunc = wxCOPY, int useMask = FALSE);
813 void CrossHair(long x, long y);
814 void DestroyClippingRegion();
815 long DeviceToLogicalX(long x);
816 long DeviceToLogicalXRel(long x);
817 long DeviceToLogicalY(long y);
818 long DeviceToLogicalYRel(long y);
819 void DrawArc(long x1, long y1, long x2, long y2, long xc, long yc);
820 void DrawCircle(long x, long y, long radius);
821 void DrawEllipse(long x, long y, long width, long height);
822 void DrawEllipticArc(long x, long y, long width, long height, long start, long end);
823 void DrawIcon(const wxIcon& icon, long x, long y);
825 void DrawLabel(const wxString& text, const wxRect& rect,
826 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
827 int indexAccel = -1);
830 wxRect DrawImageLabel(const wxString& text,
831 const wxBitmap& image,
833 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
834 int indexAccel = -1) {
836 self->DrawLabel(text, image, rect, alignment, indexAccel, &rv);
841 void DrawLine(long x1, long y1, long x2, long y2);
842 void DrawLines(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0);
843 void DrawPolygon(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0,
844 int fill_style=wxODDEVEN_RULE);
845 void DrawPoint(long x, long y);
846 void DrawRectangle(long x, long y, long width, long height);
847 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
848 void DrawRoundedRectangle(long x, long y, long width, long height, long radius=20);
849 void DrawSpline(int PCOUNT, wxPoint* points);
850 void DrawText(const wxString& text, long x, long y);
854 void FloodFill(long x, long y, const wxColour& colour, int style=wxFLOOD_SURFACE);
855 wxBrush GetBackground();
857 long GetCharHeight();
859 void GetClippingBox(long *OUTPUT, long *OUTPUT,
860 long *OUTPUT, long *OUTPUT);
862 int GetLogicalFunction();
863 void GetLogicalScale(double *OUTPUT, double *OUTPUT);
865 bool GetOptimization();
868 %new wxColour* GetPixel(long x, long y) {
869 wxColour* wc = new wxColour();
870 self->GetPixel(x, y, wc);
874 %name(GetSizeTuple)void GetSize(int* OUTPUT, int* OUTPUT);
877 wxColour GetTextBackground();
878 void GetTextExtent(const wxString& string, long *OUTPUT, long *OUTPUT);
879 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
880 long *OUTPUT, long *OUTPUT, long *OUTPUT, long* OUTPUT,
881 const wxFont* font = NULL);
882 wxColour GetTextForeground();
883 void GetUserScale(double *OUTPUT, double *OUTPUT);
884 long LogicalToDeviceX(long x);
885 long LogicalToDeviceXRel(long x);
886 long LogicalToDeviceY(long y);
887 long LogicalToDeviceYRel(long y);
893 void SetDeviceOrigin(long x, long y);
894 void SetBackground(const wxBrush& brush);
895 void SetBackgroundMode(int mode);
896 void SetClippingRegion(long x, long y, long width, long height);
897 %name(SetClippingRegionAsRegion) void SetClippingRegion(const wxRegion& region);
898 void SetPalette(const wxPalette& colourMap);
899 void SetBrush(const wxBrush& brush);
900 void SetFont(const wxFont& font);
901 void SetLogicalFunction(int function);
902 void SetLogicalScale(double x, double y);
903 void SetMapMode(int mode);
904 void SetOptimization(bool optimize);
905 void SetPen(const wxPen& pen);
906 void SetTextBackground(const wxColour& colour);
907 void SetTextForeground(const wxColour& colour);
908 void SetUserScale(double x_scale, double y_scale);
909 bool StartDoc(const wxString& message);
914 void DrawBitmap(const wxBitmap& bitmap, long x, long y,
915 int useMask = FALSE);
917 bool CanDrawBitmap();
918 bool CanGetTextExtent();
922 void GetLogicalOrigin(int *OUTPUT, int *OUTPUT);
923 void SetLogicalOrigin(int x, int y);
924 void GetDeviceOrigin(int *OUTPUT, int *OUTPUT);
925 void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
927 void CalcBoundingBox(int x, int y);
928 void ResetBoundingBox();
931 void GetBoundingBox(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
932 // See below for implementation
941 // NOTE: These methods are VERY SIMILAR in implentation. It would be
942 // nice to factor out common code and or turn them into a set of
943 // template-like macros.
945 // Draw a point for every set of coordinants in pyPoints, optionally
946 // setting a new pen for each
947 PyObject* _DrawPointList(PyObject* pyPoints, PyObject* pyPens) {
948 bool isFastSeq = PyList_Check(pyPoints) || PyTuple_Check(pyPoints);
949 bool isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens);
957 if (!PySequence_Check(pyPoints)) {
960 if (!PySequence_Check(pyPens)) {
963 numObjs = PySequence_Length(pyPoints);
964 numPens = PySequence_Length(pyPens);
966 for (i = 0; i < numObjs; i++) {
970 obj = PySequence_Fast_GET_ITEM(pyPens, i);
973 obj = PySequence_GetItem(pyPens, i);
975 if (SWIG_GetPtrObj(obj, (void **) &pen, "_wxPen_p")) {
986 // Get the point coordinants
988 obj = PySequence_Fast_GET_ITEM(pyPoints, i);
991 obj = PySequence_GetItem(pyPoints, i);
993 if (! _2int_seq_helper(obj, &x1, &y1)) {
999 // Now draw the point
1000 self->DrawPoint(x1, y1);
1010 PyErr_SetString(PyExc_TypeError, "Expected a sequence of wxPens");
1013 PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x,y) sequences.");
1018 // Draw a line for every set of coordinants in pyLines, optionally
1019 // setting a new pen for each
1020 PyObject* _DrawLineList(PyObject* pyLines, PyObject* pyPens) {
1021 bool isFastSeq = PyList_Check(pyLines) || PyTuple_Check(pyLines);
1022 bool isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens);
1030 if (!PySequence_Check(pyLines)) {
1033 if (!PySequence_Check(pyPens)) {
1036 numObjs = PySequence_Length(pyLines);
1037 numPens = PySequence_Length(pyPens);
1039 for (i = 0; i < numObjs; i++) {
1043 obj = PySequence_Fast_GET_ITEM(pyPens, i);
1046 obj = PySequence_GetItem(pyPens, i);
1048 if (SWIG_GetPtrObj(obj, (void **) &pen, "_wxPen_p")) {
1059 // Get the line coordinants
1061 obj = PySequence_Fast_GET_ITEM(pyLines, i);
1064 obj = PySequence_GetItem(pyLines, i);
1066 if (! _4int_seq_helper(obj, &x1, &y1, &x2, &y2)) {
1072 // Now draw the line
1073 self->DrawLine(x1, y1, x2, y2);
1083 PyErr_SetString(PyExc_TypeError, "Expected a sequence of wxPens");
1086 PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x1,y1, x2,y2) sequences.");
1092 %pragma(python) addtoclass = "
1093 def DrawPointList(self, points, pens=None):
1096 elif isinstance(pens, wxPenPtr):
1098 elif len(pens) != len(points):
1099 raise ValueError('points and pens must have same length')
1100 return self._DrawPointList(points, pens)
1102 def DrawLineList(self, lines, pens=None):
1105 elif isinstance(pens, wxPenPtr):
1107 elif len(pens) != len(lines):
1108 raise ValueError('lines and pens must have same length')
1109 return self._DrawLineList(lines, pens)
1118 static void wxDC_GetBoundingBox(wxDC* dc, int* x1, int* y1, int* x2, int* y2) {
1126 //----------------------------------------------------------------------
1128 class wxMemoryDC : public wxDC {
1132 void SelectObject(const wxBitmap& bitmap);
1135 %new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC);
1136 %{ // Alternate 'constructor'
1137 wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) {
1138 return new wxMemoryDC(oldDC);
1143 //---------------------------------------------------------------------------
1145 class wxBufferedDC : public wxMemoryDC {
1147 // Construct a wxBufferedDC using a user supplied buffer.
1148 wxBufferedDC( wxDC *dc, const wxBitmap &buffer );
1150 // Construct a wxBufferedDC with an internal buffer of 'area'
1151 // (where area is usually something like the size of the window
1153 %name(wxBufferedDCInternalBuffer)wxBufferedDC( wxDC *dc, const wxSize &area );
1157 class wxBufferedPaintDC : public wxBufferedDC
1160 wxBufferedPaintDC( wxWindow *window, const wxBitmap &buffer = wxNullBitmap );
1163 //---------------------------------------------------------------------------
1165 class wxScreenDC : public wxDC {
1169 %name(StartDrawingOnTopWin) bool StartDrawingOnTop(wxWindow* window);
1170 bool StartDrawingOnTop(wxRect* rect = NULL);
1171 bool EndDrawingOnTop();
1174 //---------------------------------------------------------------------------
1176 class wxClientDC : public wxDC {
1178 wxClientDC(wxWindow* win);
1181 //---------------------------------------------------------------------------
1183 class wxPaintDC : public wxDC {
1185 wxPaintDC(wxWindow* win);
1188 //---------------------------------------------------------------------------
1190 class wxWindowDC : public wxDC {
1192 wxWindowDC(wxWindow* win);
1195 //---------------------------------------------------------------------------
1201 #include <wx/metafile.h>
1204 class wxMetaFile : public wxObject {
1206 wxMetaFile(const wxString& filename = wxEmptyString);
1210 bool SetClipboard(int width = 0, int height = 0);
1216 const wxString& GetFileName() const { return m_filename; }
1220 // bool wxMakeMetaFilePlaceable(const wxString& filename,
1221 // int minX, int minY, int maxX, int maxY, float scale=1.0);
1224 class wxMetaFileDC : public wxDC {
1226 wxMetaFileDC(const wxString& filename = wxEmptyString,
1227 int width = 0, int height = 0,
1228 const wxString& description = wxEmptyString);
1229 wxMetaFile* Close();
1234 //---------------------------------------------------------------------------
1236 class wxPalette : public wxGDIObject {
1238 wxPalette(int LCOUNT, byte* choices, byte* choices, byte* choices);
1241 int GetPixel(byte red, byte green, byte blue);
1242 bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT);
1246 //---------------------------------------------------------------------------
1249 wxIMAGELIST_DRAW_NORMAL ,
1250 wxIMAGELIST_DRAW_TRANSPARENT,
1251 wxIMAGELIST_DRAW_SELECTED,
1252 wxIMAGELIST_DRAW_FOCUSED,
1253 wxIMAGE_LIST_NORMAL,
1258 class wxImageList : public wxObject {
1260 wxImageList(int width, int height, int mask=TRUE, int initialCount=1);
1263 int Add(const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
1264 %name(AddWithColourMask)int Add(const wxBitmap& bitmap, const wxColour& maskColour);
1265 %name(AddIcon)int Add(const wxIcon& icon);
1267 bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
1269 // %name(ReplaceIcon)bool Replace(int index, const wxIcon& icon);
1270 // int Add(const wxBitmap& bitmap);
1271 bool Replace(int index, const wxBitmap& bitmap);
1274 bool Draw(int index, wxDC& dc, int x, int x, int flags = wxIMAGELIST_DRAW_NORMAL,
1275 const bool solidBackground = FALSE);
1277 int GetImageCount();
1278 bool Remove(int index);
1280 void GetSize(int index, int& OUTPUT, int& OUTPUT);
1284 //---------------------------------------------------------------------------
1287 enum wxRegionContain {
1288 wxOutRegion, wxPartRegion, wxInRegion
1292 class wxRegion : public wxGDIObject {
1294 wxRegion(long x=0, long y=0, long width=0, long height=0);
1299 bool Offset(wxCoord x, wxCoord y);
1302 wxRegionContain Contains(long x, long y);
1303 %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt);
1304 %name(ContainsRect)wxRegionContain Contains(const wxRect& rect);
1305 %name(ContainsRectDim)wxRegionContain Contains(long x, long y, long w, long h);
1309 bool Intersect(long x, long y, long width, long height);
1310 %name(IntersectRect)bool Intersect(const wxRect& rect);
1311 %name(IntersectRegion)bool Intersect(const wxRegion& region);
1315 bool Union(long x, long y, long width, long height);
1316 %name(UnionRect)bool Union(const wxRect& rect);
1317 %name(UnionRegion)bool Union(const wxRegion& region);
1319 bool Subtract(long x, long y, long width, long height);
1320 %name(SubtractRect)bool Subtract(const wxRect& rect);
1321 %name(SubtractRegion)bool Subtract(const wxRegion& region);
1323 bool Xor(long x, long y, long width, long height);
1324 %name(XorRect)bool Xor(const wxRect& rect);
1325 %name(XorRegion)bool Xor(const wxRegion& region);
1330 class wxRegionIterator : public wxObject {
1332 wxRegionIterator(const wxRegion& region);
1333 ~wxRegionIterator();
1353 //---------------------------------------------------------------------------
1360 extern wxFont *wxNORMAL_FONT;
1361 extern wxFont *wxSMALL_FONT;
1362 extern wxFont *wxITALIC_FONT;
1363 extern wxFont *wxSWISS_FONT;
1365 extern wxPen *wxRED_PEN;
1366 extern wxPen *wxCYAN_PEN;
1367 extern wxPen *wxGREEN_PEN;
1368 extern wxPen *wxBLACK_PEN;
1369 extern wxPen *wxWHITE_PEN;
1370 extern wxPen *wxTRANSPARENT_PEN;
1371 extern wxPen *wxBLACK_DASHED_PEN;
1372 extern wxPen *wxGREY_PEN;
1373 extern wxPen *wxMEDIUM_GREY_PEN;
1374 extern wxPen *wxLIGHT_GREY_PEN;
1376 extern wxBrush *wxBLUE_BRUSH;
1377 extern wxBrush *wxGREEN_BRUSH;
1378 extern wxBrush *wxWHITE_BRUSH;
1379 extern wxBrush *wxBLACK_BRUSH;
1380 extern wxBrush *wxTRANSPARENT_BRUSH;
1381 extern wxBrush *wxCYAN_BRUSH;
1382 extern wxBrush *wxRED_BRUSH;
1383 extern wxBrush *wxGREY_BRUSH;
1384 extern wxBrush *wxMEDIUM_GREY_BRUSH;
1385 extern wxBrush *wxLIGHT_GREY_BRUSH;
1387 extern wxColour *wxBLACK;
1388 extern wxColour *wxWHITE;
1389 extern wxColour *wxRED;
1390 extern wxColour *wxBLUE;
1391 extern wxColour *wxGREEN;
1392 extern wxColour *wxCYAN;
1393 extern wxColour *wxLIGHT_GREY;
1395 extern wxCursor *wxSTANDARD_CURSOR;
1396 extern wxCursor *wxHOURGLASS_CURSOR;
1397 extern wxCursor *wxCROSS_CURSOR;
1400 extern wxBitmap wxNullBitmap;
1401 extern wxIcon wxNullIcon;
1402 extern wxCursor wxNullCursor;
1403 extern wxPen wxNullPen;
1404 extern wxBrush wxNullBrush;
1405 extern wxPalette wxNullPalette;
1406 extern wxFont wxNullFont;
1407 extern wxColour wxNullColour;
1410 extern wxFontList* wxTheFontList;
1411 extern wxPenList* wxThePenList;
1412 extern wxBrushList* wxTheBrushList;
1413 extern wxColourDatabase* wxTheColourDatabase;
1421 //---------------------------------------------------------------------------
1422 //---------------------------------------------------------------------------