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.
36 static wxString wxPyEmptyStr("");
39 //---------------------------------------------------------------------------
44 // void SetHandle(long handle);
49 // void SetWidth(int w);
50 // void SetHeight(int h);
51 // void SetDepth(int d);
52 // void SetSize(const wxSize& size);
55 //---------------------------------------------------------------------------
61 wxBitmap(const wxString& name, long type);
64 wxPalette* GetPalette();
66 bool LoadFile(const wxString& name, long flags);
67 bool SaveFile(const wxString& name, int type, wxPalette* palette = NULL);
68 void SetMask(wxMask* mask);
70 void SetPalette(wxPalette& palette);
76 void SetHandle(long handle);
83 void SetHeight(int h);
86 void SetSize(const wxSize& size);
89 wxBitmap GetSubBitmap( const wxRect& rect );
91 bool CopyFromIcon(const wxIcon& icon);
92 bool CopyFromCursor(const wxCursor& cursor);
94 void SetQuality(int q);
97 %pragma(python) addtoclass = "
98 def __del__(self,gdic=gdic):
100 if self.thisown == 1 :
101 gdic.delete_wxBitmap(self)
108 %new wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1);
111 %new wxBitmap* wxBitmapFromData(PyObject* data, long type,
112 int width, int height, int depth = 1);
115 %{ // Alternate 'constructor'
116 wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1) {
117 return new wxBitmap(width, height, depth);
121 wxBitmap* wxBitmapFromData(PyObject* data, long type,
122 int width, int height, int depth = 1) {
123 if (! PyString_Check(data)) {
124 PyErr_SetString(PyExc_TypeError, "Expected string object");
128 return new wxBitmap((void*)PyString_AsString(data), type, width, height, depth);
133 //---------------------------------------------------------------------------
137 wxMask(const wxBitmap& bitmap);
141 %new wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour);
143 wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour) {
144 return new wxMask(bitmap, colour);
149 //---------------------------------------------------------------------------
153 //: public wxGDIImage
156 wxIcon(const wxString& name, long flags,
157 int desiredWidth = -1, int desiredHeight = -1);
160 bool LoadFile(const wxString& name, long flags);
162 // wxGDIImage methods
165 void SetHandle(long handle);
171 void SetWidth(int w);
172 void SetHeight(int h);
173 void SetDepth(int d);
175 void SetSize(const wxSize& size);
177 %pragma(python) addtoclass = "
178 def __del__(self,gdic=gdic):
180 if self.thisown == 1 :
181 gdic.delete_wxIcon(self)
189 //---------------------------------------------------------------------------
192 //: public wxGDIImage
196 wxCursor(const wxString& cursorName, long flags, int hotSpotX=0, int hotSpotY=0);
200 // wxGDIImage methods
203 void SetHandle(long handle);
210 void SetWidth(int w);
211 void SetHeight(int h);
212 void SetDepth(int d);
213 void SetSize(const wxSize& size);
217 %name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id);
218 %{ // Alternate 'constructor'
219 wxCursor* wxPyStockCursor(int id) {
220 return new wxCursor(id);
224 //----------------------------------------------------------------------
229 wxFONTENCODING_SYSTEM = -1, // system default
230 wxFONTENCODING_DEFAULT, // current default encoding
232 // ISO8859 standard defines a number of single-byte charsets
233 wxFONTENCODING_ISO8859_1, // West European (Latin1)
234 wxFONTENCODING_ISO8859_2, // Central and East European (Latin2)
235 wxFONTENCODING_ISO8859_3, // Esperanto (Latin3)
236 wxFONTENCODING_ISO8859_4, // Baltic languages (Estonian) (Latin4)
237 wxFONTENCODING_ISO8859_5, // Cyrillic
238 wxFONTENCODING_ISO8859_6, // Arabic
239 wxFONTENCODING_ISO8859_7, // Greek
240 wxFONTENCODING_ISO8859_8, // Hebrew
241 wxFONTENCODING_ISO8859_9, // Turkish (Latin5)
242 wxFONTENCODING_ISO8859_10, // Variation of Latin4 (Latin6)
243 wxFONTENCODING_ISO8859_11, // Thai
244 wxFONTENCODING_ISO8859_12, // doesn't exist currently, but put it
245 // here anyhow to make all ISO8859
246 // consecutive numbers
247 wxFONTENCODING_ISO8859_13, // Latin7
248 wxFONTENCODING_ISO8859_14, // Latin8
249 wxFONTENCODING_ISO8859_15, // Latin9 (a.k.a. Latin0, includes euro)
251 // Cyrillic charset soup (see http://czyborra.com/charsets/cyrillic.html)
252 wxFONTENCODING_KOI8, // we don't support any of KOI8 variants
253 wxFONTENCODING_ALTERNATIVE, // same as MS-DOS CP866
254 wxFONTENCODING_BULGARIAN, // used under Linux in Bulgaria
256 // what would we do without Microsoft? They have their own encodings
258 wxFONTENCODING_CP437, // original MS-DOS codepage
259 wxFONTENCODING_CP850, // CP437 merged with Latin1
260 wxFONTENCODING_CP852, // CP437 merged with Latin2
261 wxFONTENCODING_CP855, // another cyrillic encoding
262 wxFONTENCODING_CP866, // and another one
264 wxFONTENCODING_CP1250, // WinLatin2
265 wxFONTENCODING_CP1251, // WinCyrillic
266 wxFONTENCODING_CP1252, // WinLatin1
273 // I'll do it this way to use long-lived objects and not have to
274 // worry about when python may delete the object.
276 wxFont( int pointSize, int family, int style, int weight,
277 int underline=FALSE, char* faceName = "",
278 wxFontEncoding encoding=wxFONTENCODING_DEFAULT) {
280 return wxTheFontList->FindOrCreateFont(pointSize, family, style, weight,
281 underline, faceName, encoding);
288 wxString GetFaceName();
295 bool GetUnderlined();
297 wxFontEncoding GetEncoding();
298 void SetFaceName(const wxString& faceName);
299 void SetFamily(int family);
300 void SetPointSize(int pointSize);
301 void SetStyle(int style);
302 void SetUnderlined(bool underlined);
303 void SetWeight(int weight);
304 void SetEncoding(wxFontEncoding encoding);
305 wxString GetFamilyString();
306 wxString GetStyleString();
307 wxString GetWeightString();
311 wxFontEncoding wxFont_GetDefaultEncoding() {
312 return wxFont::GetDefaultEncoding();
315 void wxFont_SetDefaultEncoding(wxFontEncoding encoding) {
316 wxFont::SetDefaultEncoding(encoding);
320 //----------------------------------------------------------------------
324 wxColour(unsigned char red=0, unsigned char green=0, unsigned char blue=0);
327 unsigned char Green();
328 unsigned char Blue();
330 void Set(unsigned char red, unsigned char green, unsigned char blue);
333 PyObject* rv = PyTuple_New(3);
334 PyTuple_SetItem(rv, 0, PyInt_FromLong(self->Red()));
335 PyTuple_SetItem(rv, 1, PyInt_FromLong(self->Green()));
336 PyTuple_SetItem(rv, 2, PyInt_FromLong(self->Blue()));
340 %pragma(python) addtoclass = "asTuple = Get"
341 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
342 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
346 %new wxColour* wxNamedColour(const wxString& colorName);
348 %{ // Alternate 'constructor'
349 wxColour* wxNamedColour(const wxString& colorName) {
350 return new wxColour(colorName);
355 //----------------------------------------------------------------------
360 // I'll do it this way to use long-lived objects and not have to
361 // worry about when python may delete the object.
363 wxPen(wxColour* colour, int width=1, int style=wxSOLID) {
364 return wxThePenList->FindOrCreatePen(*colour, width, style);
370 wxColour& GetColour();
376 void SetCap(int cap_style);
377 void SetColour(wxColour& colour);
378 void SetJoin(int join_style);
379 void SetStyle(int style);
380 void SetWidth(int width);
382 // **** This one needs to return a list of ints (wxDash)
383 int GetDashes(wxDash **dashes);
384 void SetDashes(int LCOUNT, wxDash* choices);
387 wxBitmap* GetStipple();
388 void SetStipple(wxBitmap& stipple);
392 //----------------------------------------------------------------------
396 // I'll do it this way to use long-lived objects and not have to
397 // worry about when python may delete the object.
399 wxBrush(const wxColour* colour, int style=wxSOLID) {
400 return wxTheBrushList->FindOrCreateBrush(*colour, style);
405 // wxBrush(const wxColour& colour, int style=wxSOLID);
407 wxColour& GetColour();
408 wxBitmap * GetStipple();
411 void SetColour(wxColour &colour);
412 void SetStipple(wxBitmap& bitmap);
413 void SetStyle(int style);
416 //----------------------------------------------------------------------
422 // wxDC(); **** abstract base class, can't instantiate.
427 bool Blit(long xdest, long ydest,
428 long width, long height,
429 wxDC *source, long xsrc, long ysrc,
430 int logicalFunc = wxCOPY, int useMask = FALSE);
431 // bool Blit(const wxPoint& destPt, const wxSize& sz,
432 // wxDC *source, const wxPoint& srcPt,
433 // int logicalFunc = wxCOPY, int useMask = FALSE);
436 void CrossHair(long x, long y);
437 void DestroyClippingRegion();
438 long DeviceToLogicalX(long x);
439 long DeviceToLogicalXRel(long x);
440 long DeviceToLogicalY(long y);
441 long DeviceToLogicalYRel(long y);
442 void DrawArc(long x1, long y1, long x2, long y2, long xc, long yc);
443 void DrawCircle(long x, long y, long radius);
444 void DrawEllipse(long x, long y, long width, long height);
445 void DrawEllipticArc(long x, long y, long width, long height, long start, long end);
446 void DrawIcon(const wxIcon& icon, long x, long y);
447 void DrawLine(long x1, long y1, long x2, long y2);
448 void DrawLines(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0);
449 void DrawPolygon(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0,
450 int fill_style=wxODDEVEN_RULE);
451 void DrawPoint(long x, long y);
452 void DrawRectangle(long x, long y, long width, long height);
453 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
454 void DrawRoundedRectangle(long x, long y, long width, long height, long radius=20);
455 void DrawSpline(int PCOUNT, wxPoint* points);
456 void DrawText(const wxString& text, long x, long y);
460 void FloodFill(long x, long y, const wxColour& colour, int style=wxFLOOD_SURFACE);
461 wxBrush& GetBackground();
463 long GetCharHeight();
465 void GetClippingBox(long *OUTPUT, long *OUTPUT,
466 long *OUTPUT, long *OUTPUT);
468 int GetLogicalFunction();
469 void GetLogicalScale(double *OUTPUT, double *OUTPUT);
471 bool GetOptimization();
474 %new wxColour* GetPixel(long x, long y) {
475 wxColour* wc = new wxColour();
476 self->GetPixel(x, y, wc);
480 %name(GetSizeTuple)void GetSize(int* OUTPUT, int* OUTPUT);
483 wxColour& GetTextBackground();
484 void GetTextExtent(const wxString& string, long *OUTPUT, long *OUTPUT);
485 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
486 long *OUTPUT, long *OUTPUT, long *OUTPUT, long* OUTPUT,
487 const wxFont* font = NULL);
488 wxColour& GetTextForeground();
489 void GetUserScale(double *OUTPUT, double *OUTPUT);
490 long LogicalToDeviceX(long x);
491 long LogicalToDeviceXRel(long x);
492 long LogicalToDeviceY(long y);
493 long LogicalToDeviceYRel(long y);
499 void SetDeviceOrigin(long x, long y);
500 void SetBackground(const wxBrush& brush);
501 void SetBackgroundMode(int mode);
502 void SetClippingRegion(long x, long y, long width, long height);
503 void SetPalette(const wxPalette& colourMap);
504 void SetBrush(const wxBrush& brush);
505 void SetFont(const wxFont& font);
506 void SetLogicalFunction(int function);
507 void SetLogicalScale(double x, double y);
508 void SetMapMode(int mode);
509 void SetOptimization(bool optimize);
510 void SetPen(const wxPen& pen);
511 void SetTextBackground(const wxColour& colour);
512 void SetTextForeground(const wxColour& colour);
513 void SetUserScale(double x_scale, double y_scale);
514 bool StartDoc(const wxString& message);
519 void DrawBitmap(const wxBitmap& bitmap, long x, long y,
520 int useMask = FALSE);
522 bool CanDrawBitmap();
523 bool CanGetTextExtent();
527 void GetLogicalOrigin(int *OUTPUT, int *OUTPUT);
528 void SetLogicalOrigin(int x, int y);
529 void GetDeviceOrigin(int *OUTPUT, int *OUTPUT);
530 void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
532 void CalcBoundingBox(int x, int y);
533 void ResetBoundingBox();
537 //----------------------------------------------------------------------
539 class wxMemoryDC : public wxDC {
543 void SelectObject(const wxBitmap& bitmap);
546 %new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC);
547 %{ // Alternate 'constructor'
548 wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) {
549 return new wxMemoryDC(oldDC);
554 //---------------------------------------------------------------------------
556 class wxScreenDC : public wxDC {
560 %name(StartDrawingOnTopWin) bool StartDrawingOnTop(wxWindow* window);
561 bool StartDrawingOnTop(wxRect* rect = NULL);
562 bool EndDrawingOnTop();
565 //---------------------------------------------------------------------------
567 class wxClientDC : public wxDC {
569 wxClientDC(wxWindow* win);
572 //---------------------------------------------------------------------------
574 class wxPaintDC : public wxDC {
576 wxPaintDC(wxWindow* win);
579 //---------------------------------------------------------------------------
581 class wxWindowDC : public wxDC {
583 wxWindowDC(wxWindow* win);
586 //---------------------------------------------------------------------------
589 class wxPostScriptDC : public wxDC {
591 wxPostScriptDC(const wxString& output, bool interactive = TRUE, wxWindow* win = NULL);
595 //---------------------------------------------------------------------------
598 class wxPrinterDC : public wxDC {
600 wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output,
601 bool interactive = TRUE, int orientation = wxPORTRAIT);
605 //---------------------------------------------------------------------------
608 class wxMetaFileDC : public wxDC {
610 wxMetaFileDC(const wxString& filename = wxPyEmptyStr);
615 //---------------------------------------------------------------------------
616 //---------------------------------------------------------------------------
623 extern wxFont *wxNORMAL_FONT;
624 extern wxFont *wxSMALL_FONT;
625 extern wxFont *wxITALIC_FONT;
626 extern wxFont *wxSWISS_FONT;
628 extern wxPen *wxRED_PEN;
629 extern wxPen *wxCYAN_PEN;
630 extern wxPen *wxGREEN_PEN;
631 extern wxPen *wxBLACK_PEN;
632 extern wxPen *wxWHITE_PEN;
633 extern wxPen *wxTRANSPARENT_PEN;
634 extern wxPen *wxBLACK_DASHED_PEN;
635 extern wxPen *wxGREY_PEN;
636 extern wxPen *wxMEDIUM_GREY_PEN;
637 extern wxPen *wxLIGHT_GREY_PEN;
639 extern wxBrush *wxBLUE_BRUSH;
640 extern wxBrush *wxGREEN_BRUSH;
641 extern wxBrush *wxWHITE_BRUSH;
642 extern wxBrush *wxBLACK_BRUSH;
643 extern wxBrush *wxTRANSPARENT_BRUSH;
644 extern wxBrush *wxCYAN_BRUSH;
645 extern wxBrush *wxRED_BRUSH;
646 extern wxBrush *wxGREY_BRUSH;
647 extern wxBrush *wxMEDIUM_GREY_BRUSH;
648 extern wxBrush *wxLIGHT_GREY_BRUSH;
650 extern wxColour *wxBLACK;
651 extern wxColour *wxWHITE;
652 extern wxColour *wxRED;
653 extern wxColour *wxBLUE;
654 extern wxColour *wxGREEN;
655 extern wxColour *wxCYAN;
656 extern wxColour *wxLIGHT_GREY;
658 extern wxCursor *wxSTANDARD_CURSOR;
659 extern wxCursor *wxHOURGLASS_CURSOR;
660 extern wxCursor *wxCROSS_CURSOR;
662 extern wxBitmap wxNullBitmap;
663 extern wxIcon wxNullIcon;
664 extern wxCursor wxNullCursor;
665 extern wxPen wxNullPen;
666 extern wxBrush wxNullBrush;
667 extern wxPalette wxNullPalette;
668 extern wxFont wxNullFont;
669 extern wxColour wxNullColour;
676 //---------------------------------------------------------------------------
680 wxPalette(int LCOUNT, byte* choices, byte* choices, byte* choices);
683 int GetPixel(byte red, byte green, byte blue);
684 bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT);
688 //---------------------------------------------------------------------------
691 wxIMAGELIST_DRAW_NORMAL ,
692 wxIMAGELIST_DRAW_TRANSPARENT,
693 wxIMAGELIST_DRAW_SELECTED,
694 wxIMAGELIST_DRAW_FOCUSED,
702 wxImageList(int width, int height, int mask=TRUE, int initialCount=1);
705 int Add(const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
706 %name(AddWithColourMask)int Add(const wxBitmap& bitmap, const wxColour& maskColour);
707 %name(AddIcon)int Add(const wxIcon& icon);
709 bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
711 // %name(ReplaceIcon)bool Replace(int index, const wxIcon& icon);
712 // int Add(const wxBitmap& bitmap);
713 bool Replace(int index, const wxBitmap& bitmap);
716 bool Draw(int index, wxDC& dc, int x, int x, int flags = wxIMAGELIST_DRAW_NORMAL,
717 const bool solidBackground = FALSE);
720 bool Remove(int index);
722 void GetSize(int index, int& OUTPUT, int& OUTPUT);
726 //---------------------------------------------------------------------------