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/metafile.h>
19 #include <wx/imaglist.h>
25 //----------------------------------------------------------------------
28 %include my_typemaps.i
30 // Import some definitions of other classes, etc.
34 //---------------------------------------------------------------------------
39 // void SetHandle(long handle);
44 // void SetWidth(int w);
45 // void SetHeight(int h);
46 // void SetDepth(int d);
47 // void SetSize(const wxSize& size);
50 //---------------------------------------------------------------------------
56 wxBitmap(const wxString& name, long type);
59 wxPalette* GetPalette();
61 bool LoadFile(const wxString& name, long flags);
62 bool SaveFile(const wxString& name, int type, wxPalette* palette = NULL);
63 void SetMask(wxMask* mask);
65 void SetPalette(wxPalette& palette);
71 void SetHandle(long handle);
78 void SetHeight(int h);
81 void SetSize(const wxSize& size);
86 %new wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1);
89 %new wxBitmap* wxBitmapFromData(PyObject* data, long type,
90 int width, int height, int depth = 1);
93 %{ // Alternate 'constructor'
94 wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1) {
95 return new wxBitmap(width, height, depth);
99 wxBitmap* wxBitmapFromData(PyObject* data, long type,
100 int width, int height, int depth = 1) {
101 if (! PyString_Check(data)) {
102 PyErr_SetString(PyExc_TypeError, "Expected string object");
106 return new wxBitmap((void*)PyString_AsString(data), type, width, height, depth);
111 //---------------------------------------------------------------------------
115 wxMask(const wxBitmap& bitmap);
119 %new wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour);
121 wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour) {
122 return new wxMask(bitmap, colour);
127 //---------------------------------------------------------------------------
131 //: public wxGDIImage
134 wxIcon(const wxString& name, long flags,
135 int desiredWidth = -1, int desiredHeight = -1);
138 bool LoadFile(const wxString& name, long flags);
140 // wxGDIImage methods
143 void SetHandle(long handle);
149 void SetWidth(int w);
150 void SetHeight(int h);
151 void SetDepth(int d);
153 void SetSize(const wxSize& size);
158 //---------------------------------------------------------------------------
161 //: public wxGDIImage
165 wxCursor(const wxString& cursorName, long flags, int hotSpotX=0, int hotSpotY=0);
169 // wxGDIImage methods
172 void SetHandle(long handle);
179 void SetWidth(int w);
180 void SetHeight(int h);
181 void SetDepth(int d);
182 void SetSize(const wxSize& size);
186 %name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id);
187 %{ // Alternate 'constructor'
188 wxCursor* wxPyStockCursor(int id) {
189 return new wxCursor(id);
193 //----------------------------------------------------------------------
198 wxFONTENCODING_SYSTEM = -1, // system default
199 wxFONTENCODING_DEFAULT, // current default encoding
201 // ISO8859 standard defines a number of single-byte charsets
202 wxFONTENCODING_ISO8859_1, // West European (Latin1)
203 wxFONTENCODING_ISO8859_2, // Central and East European (Latin2)
204 wxFONTENCODING_ISO8859_3, // Esperanto (Latin3)
205 wxFONTENCODING_ISO8859_4, // Baltic languages (Estonian) (Latin4)
206 wxFONTENCODING_ISO8859_5, // Cyrillic
207 wxFONTENCODING_ISO8859_6, // Arabic
208 wxFONTENCODING_ISO8859_7, // Greek
209 wxFONTENCODING_ISO8859_8, // Hebrew
210 wxFONTENCODING_ISO8859_9, // Turkish (Latin5)
211 wxFONTENCODING_ISO8859_10, // Variation of Latin4 (Latin6)
212 wxFONTENCODING_ISO8859_11, // Thai
213 wxFONTENCODING_ISO8859_12, // doesn't exist currently, but put it
214 // here anyhow to make all ISO8859
215 // consecutive numbers
216 wxFONTENCODING_ISO8859_13, // Latin7
217 wxFONTENCODING_ISO8859_14, // Latin8
218 wxFONTENCODING_ISO8859_15, // Latin9 (a.k.a. Latin0, includes euro)
220 // Cyrillic charset soup (see http://czyborra.com/charsets/cyrillic.html)
221 wxFONTENCODING_KOI8, // we don't support any of KOI8 variants
222 wxFONTENCODING_ALTERNATIVE, // same as MS-DOS CP866
223 wxFONTENCODING_BULGARIAN, // used under Linux in Bulgaria
225 // what would we do without Microsoft? They have their own encodings
227 wxFONTENCODING_CP437, // original MS-DOS codepage
228 wxFONTENCODING_CP850, // CP437 merged with Latin1
229 wxFONTENCODING_CP852, // CP437 merged with Latin2
230 wxFONTENCODING_CP855, // another cyrillic encoding
231 wxFONTENCODING_CP866, // and another one
233 wxFONTENCODING_CP1250, // WinLatin2
234 wxFONTENCODING_CP1251, // WinCyrillic
235 wxFONTENCODING_CP1252, // WinLatin1
242 // I'll do it this way to use long-lived objects and not have to
243 // worry about when python may delete the object.
245 wxFont( int pointSize, int family, int style, int weight,
246 int underline=FALSE, char* faceName = "",
247 wxFontEncoding encoding=wxFONTENCODING_DEFAULT) {
249 return wxTheFontList->FindOrCreateFont(pointSize, family, style, weight,
250 underline, faceName, encoding);
257 wxString GetFaceName();
264 bool GetUnderlined();
266 wxFontEncoding GetEncoding();
267 void SetFaceName(const wxString& faceName);
268 void SetFamily(int family);
269 void SetPointSize(int pointSize);
270 void SetStyle(int style);
271 void SetUnderlined(bool underlined);
272 void SetWeight(int weight);
273 void SetEncoding(wxFontEncoding encoding);
274 wxString GetFamilyString();
275 wxString GetStyleString();
276 wxString GetWeightString();
280 wxFontEncoding wxFont_GetDefaultEncoding() {
281 return wxFont::GetDefaultEncoding();
284 void wxFont_SetDefaultEncoding(wxFontEncoding encoding) {
285 wxFont::SetDefaultEncoding(encoding);
289 //----------------------------------------------------------------------
293 wxColour(unsigned char red=0, unsigned char green=0, unsigned char blue=0);
296 unsigned char Green();
297 unsigned char Blue();
299 void Set(unsigned char red, unsigned char green, unsigned char blue);
302 PyObject* rv = PyTuple_New(3);
303 PyTuple_SetItem(rv, 0, PyInt_FromLong(self->Red()));
304 PyTuple_SetItem(rv, 1, PyInt_FromLong(self->Green()));
305 PyTuple_SetItem(rv, 2, PyInt_FromLong(self->Blue()));
309 %pragma(python) addtoclass = "asTuple = Get"
310 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
311 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
315 %new wxColour* wxNamedColour(const wxString& colorName);
316 %{ // Alternate 'constructor'
317 wxColour* wxNamedColour(const wxString& colorName) {
318 return new wxColour(colorName);
323 //----------------------------------------------------------------------
326 typedef unsigned long wxDash;
334 // I'll do it this way to use long-lived objects and not have to
335 // worry about when python may delete the object.
337 wxPen(wxColour* colour, int width=1, int style=wxSOLID) {
338 return wxThePenList->FindOrCreatePen(*colour, width, style);
344 wxColour& GetColour();
350 void SetCap(int cap_style);
351 void SetColour(wxColour& colour);
352 void SetJoin(int join_style);
353 void SetStyle(int style);
354 void SetWidth(int width);
356 // **** This one needs to return a list of ints (wxDash)
357 int GetDashes(wxDash **dashes);
358 void SetDashes(int LCOUNT, wxDash* choices);
361 wxBitmap* GetStipple();
362 void SetStipple(wxBitmap& stipple);
366 //----------------------------------------------------------------------
370 // I'll do it this way to use long-lived objects and not have to
371 // worry about when python may delete the object.
373 wxBrush(const wxColour* colour, int style=wxSOLID) {
374 return wxTheBrushList->FindOrCreateBrush(*colour, style);
379 // wxBrush(const wxColour& colour, int style=wxSOLID);
381 wxColour& GetColour();
382 wxBitmap * GetStipple();
385 void SetColour(wxColour &colour);
386 void SetStipple(wxBitmap& bitmap);
387 void SetStyle(int style);
390 //----------------------------------------------------------------------
396 // wxDC(); **** abstract base class, can't instantiate.
401 bool Blit(long xdest, long ydest,
402 long width, long height,
403 wxDC *source, long xsrc, long ysrc,
404 int logicalFunc = wxCOPY, int useMask = FALSE);
405 // bool Blit(const wxPoint& destPt, const wxSize& sz,
406 // wxDC *source, const wxPoint& srcPt,
407 // int logicalFunc = wxCOPY, int useMask = FALSE);
410 void CrossHair(long x, long y);
411 void DestroyClippingRegion();
412 long DeviceToLogicalX(long x);
413 long DeviceToLogicalXRel(long x);
414 long DeviceToLogicalY(long y);
415 long DeviceToLogicalYRel(long y);
416 void DrawArc(long x1, long y1, long x2, long y2, long xc, long yc);
417 void DrawCircle(long x, long y, long radius);
418 void DrawEllipse(long x, long y, long width, long height);
419 void DrawEllipticArc(long x, long y, long width, long height, long start, long end);
420 void DrawIcon(const wxIcon& icon, long x, long y);
421 void DrawLine(long x1, long y1, long x2, long y2);
422 void DrawLines(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0);
423 void DrawPolygon(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0,
424 int fill_style=wxODDEVEN_RULE);
425 void DrawPoint(long x, long y);
426 void DrawRectangle(long x, long y, long width, long height);
427 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
428 void DrawRoundedRectangle(long x, long y, long width, long height, long radius=20);
429 void DrawSpline(int PCOUNT, wxPoint* points);
430 void DrawText(const wxString& text, long x, long y);
434 void FloodFill(long x, long y, const wxColour& colour, int style=wxFLOOD_SURFACE);
435 wxBrush& GetBackground();
437 long GetCharHeight();
439 void GetClippingBox(long *OUTPUT, long *OUTPUT,
440 long *OUTPUT, long *OUTPUT);
442 int GetLogicalFunction();
443 void GetLogicalScale(double *OUTPUT, double *OUTPUT);
445 bool GetOptimization();
448 %new wxColour* GetPixel(long x, long y) {
449 wxColour* wc = new wxColour();
450 self->GetPixel(x, y, wc);
454 %name(GetSizeTuple)void GetSize(int* OUTPUT, int* OUTPUT);
457 wxColour& GetTextBackground();
458 void GetTextExtent(const wxString& string, long *OUTPUT, long *OUTPUT);
459 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
460 long *OUTPUT, long *OUTPUT, long *OUTPUT, long* OUTPUT,
461 const wxFont* font = NULL);
462 wxColour& GetTextForeground();
463 void GetUserScale(double *OUTPUT, double *OUTPUT);
464 long LogicalToDeviceX(long x);
465 long LogicalToDeviceXRel(long x);
466 long LogicalToDeviceY(long y);
467 long LogicalToDeviceYRel(long y);
473 void SetDeviceOrigin(long x, long y);
474 void SetBackground(const wxBrush& brush);
475 void SetBackgroundMode(int mode);
476 void SetClippingRegion(long x, long y, long width, long height);
477 void SetPalette(const wxPalette& colourMap);
478 void SetBrush(const wxBrush& brush);
479 void SetFont(const wxFont& font);
480 void SetLogicalFunction(int function);
481 void SetLogicalScale(double x, double y);
482 void SetMapMode(int mode);
483 void SetOptimization(bool optimize);
484 void SetPen(const wxPen& pen);
485 void SetTextBackground(const wxColour& colour);
486 void SetTextForeground(const wxColour& colour);
487 void SetUserScale(double x_scale, double y_scale);
488 bool StartDoc(const wxString& message);
493 void DrawBitmap(const wxBitmap& bitmap, long x, long y,
494 int useMask = FALSE);
496 bool CanDrawBitmap();
497 bool CanGetTextExtent();
501 void GetLogicalOrigin(int *OUTPUT, int *OUTPUT);
502 void SetLogicalOrigin(int x, int y);
503 void GetDeviceOrigin(int *OUTPUT, int *OUTPUT);
504 void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
509 //----------------------------------------------------------------------
511 class wxMemoryDC : public wxDC {
515 void SelectObject(const wxBitmap& bitmap);
518 %new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC);
519 %{ // Alternate 'constructor'
520 wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) {
521 return new wxMemoryDC(oldDC);
526 //---------------------------------------------------------------------------
528 class wxScreenDC : public wxDC {
532 %name(StartDrawingOnTopWin) bool StartDrawingOnTop(wxWindow* window);
533 bool StartDrawingOnTop(wxRect* rect = NULL);
534 bool EndDrawingOnTop();
537 //---------------------------------------------------------------------------
539 class wxClientDC : public wxDC {
541 wxClientDC(wxWindow* win);
544 //---------------------------------------------------------------------------
546 class wxPaintDC : public wxDC {
548 wxPaintDC(wxWindow* win);
551 //---------------------------------------------------------------------------
553 class wxWindowDC : public wxDC {
555 wxWindowDC(wxWindow* win);
558 //---------------------------------------------------------------------------
561 class wxPostScriptDC : public wxDC {
563 wxPostScriptDC(const wxString& output, bool interactive = TRUE, wxWindow* win = NULL);
567 //---------------------------------------------------------------------------
570 class wxPrinterDC : public wxDC {
572 wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output,
573 bool interactive = TRUE, int orientation = wxPORTRAIT);
577 //---------------------------------------------------------------------------
580 class wxMetaFileDC : public wxDC {
582 wxMetaFileDC(const wxString& filename = wxPyEmptyStr);
587 //---------------------------------------------------------------------------
588 //---------------------------------------------------------------------------
595 extern wxFont *wxNORMAL_FONT;
596 extern wxFont *wxSMALL_FONT;
597 extern wxFont *wxITALIC_FONT;
598 extern wxFont *wxSWISS_FONT;
600 extern wxPen *wxRED_PEN;
601 extern wxPen *wxCYAN_PEN;
602 extern wxPen *wxGREEN_PEN;
603 extern wxPen *wxBLACK_PEN;
604 extern wxPen *wxWHITE_PEN;
605 extern wxPen *wxTRANSPARENT_PEN;
606 extern wxPen *wxBLACK_DASHED_PEN;
607 extern wxPen *wxGREY_PEN;
608 extern wxPen *wxMEDIUM_GREY_PEN;
609 extern wxPen *wxLIGHT_GREY_PEN;
611 extern wxBrush *wxBLUE_BRUSH;
612 extern wxBrush *wxGREEN_BRUSH;
613 extern wxBrush *wxWHITE_BRUSH;
614 extern wxBrush *wxBLACK_BRUSH;
615 extern wxBrush *wxTRANSPARENT_BRUSH;
616 extern wxBrush *wxCYAN_BRUSH;
617 extern wxBrush *wxRED_BRUSH;
618 extern wxBrush *wxGREY_BRUSH;
619 extern wxBrush *wxMEDIUM_GREY_BRUSH;
620 extern wxBrush *wxLIGHT_GREY_BRUSH;
622 extern wxColour *wxBLACK;
623 extern wxColour *wxWHITE;
624 extern wxColour *wxRED;
625 extern wxColour *wxBLUE;
626 extern wxColour *wxGREEN;
627 extern wxColour *wxCYAN;
628 extern wxColour *wxLIGHT_GREY;
630 extern wxCursor *wxSTANDARD_CURSOR;
631 extern wxCursor *wxHOURGLASS_CURSOR;
632 extern wxCursor *wxCROSS_CURSOR;
634 extern wxBitmap wxNullBitmap;
635 extern wxIcon wxNullIcon;
636 extern wxCursor wxNullCursor;
637 extern wxPen wxNullPen;
638 extern wxBrush wxNullBrush;
639 extern wxPalette wxNullPalette;
640 extern wxFont wxNullFont;
641 extern wxColour wxNullColour;
648 //---------------------------------------------------------------------------
652 wxPalette(int LCOUNT, byte* choices, byte* choices, byte* choices);
655 int GetPixel(byte red, byte green, byte blue);
656 bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT);
660 //---------------------------------------------------------------------------
663 wxIMAGELIST_DRAW_NORMAL ,
664 wxIMAGELIST_DRAW_TRANSPARENT,
665 wxIMAGELIST_DRAW_SELECTED,
666 wxIMAGELIST_DRAW_FOCUSED,
674 wxImageList(int width, int height, int mask=TRUE, int initialCount=1);
678 int Add(const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
679 %name(AddWithColourMask)int Add(const wxBitmap& bitmap, const wxColour& maskColour);
680 %name(AddIcon)int Add(const wxIcon& icon);
681 bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
682 %name(ReplaceIcon)bool Replace(int index, const wxIcon& icon);
684 int Add(const wxBitmap& bitmap);
685 bool Replace(int index, const wxBitmap& bitmap);
688 bool Draw(int index, wxDC& dc, int x, int x, int flags = wxIMAGELIST_DRAW_NORMAL,
689 const bool solidBackground = FALSE);
692 bool Remove(int index);
697 //---------------------------------------------------------------------------