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
274 wxFont( int pointSize, int family, int style, int weight,
275 int underline=FALSE, char* faceName = "",
276 wxFontEncoding encoding=wxFONTENCODING_DEFAULT);
280 wxString GetFaceName();
287 bool GetUnderlined();
289 wxFontEncoding GetEncoding();
290 void SetFaceName(const wxString& faceName);
291 void SetFamily(int family);
292 void SetPointSize(int pointSize);
293 void SetStyle(int style);
294 void SetUnderlined(bool underlined);
295 void SetWeight(int weight);
296 void SetEncoding(wxFontEncoding encoding);
297 wxString GetFamilyString();
298 wxString GetStyleString();
299 wxString GetWeightString();
303 wxFontEncoding wxFont_GetDefaultEncoding() {
304 return wxFont::GetDefaultEncoding();
307 void wxFont_SetDefaultEncoding(wxFontEncoding encoding) {
308 wxFont::SetDefaultEncoding(encoding);
316 void AddFont(wxFont* font);
317 wxFont * FindOrCreateFont(int point_size, int family, int style, int weight,
318 bool underline = FALSE, const char* facename = NULL,
319 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
320 void RemoveFont(wxFont *font);
324 //----------------------------------------------------------------------
328 wxColour(unsigned char red=0, unsigned char green=0, unsigned char blue=0);
331 unsigned char Green();
332 unsigned char Blue();
334 void Set(unsigned char red, unsigned char green, unsigned char blue);
337 PyObject* rv = PyTuple_New(3);
338 PyTuple_SetItem(rv, 0, PyInt_FromLong(self->Red()));
339 PyTuple_SetItem(rv, 1, PyInt_FromLong(self->Green()));
340 PyTuple_SetItem(rv, 2, PyInt_FromLong(self->Blue()));
344 %pragma(python) addtoclass = "asTuple = Get"
345 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
346 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
350 %new wxColour* wxNamedColour(const wxString& colorName);
352 %{ // Alternate 'constructor'
353 wxColour* wxNamedColour(const wxString& colorName) {
354 return new wxColour(colorName);
360 class wxColourDatabase {
363 wxColour *FindColour(const wxString& colour);
364 wxString FindName(const wxColour& colour) const;
367 void Append(const wxString& name, int red, int green, int blue) {
368 self->Append(name.c_str(), new wxColour(red, green, blue));
374 //----------------------------------------------------------------------
379 wxPen(wxColour& colour, int width=1, int style=wxSOLID);
383 wxColour& GetColour();
389 void SetCap(int cap_style);
390 void SetColour(wxColour& colour);
391 void SetJoin(int join_style);
392 void SetStyle(int style);
393 void SetWidth(int width);
395 // **** This one needs to return a list of ints (wxDash)
396 int GetDashes(wxDash **dashes);
397 void SetDashes(int LCOUNT, wxDash* choices);
400 wxBitmap* GetStipple();
401 void SetStipple(wxBitmap& stipple);
409 void AddPen(wxPen* pen);
410 wxPen* FindOrCreatePen(const wxColour& colour, int width, int style);
411 void RemovePen(wxPen* pen);
416 //----------------------------------------------------------------------
420 wxBrush(const wxColour& colour, int style=wxSOLID);
423 wxColour& GetColour();
424 wxBitmap * GetStipple();
427 void SetColour(wxColour &colour);
428 void SetStipple(wxBitmap& bitmap);
429 void SetStyle(int style);
436 void AddBrush(wxBrush *brush);
437 wxBrush * FindOrCreateBrush(const wxColour& colour, int style);
438 void RemoveBrush(wxBrush *brush);
441 //----------------------------------------------------------------------
447 // wxDC(); **** abstract base class, can't instantiate.
452 bool Blit(long xdest, long ydest,
453 long width, long height,
454 wxDC *source, long xsrc, long ysrc,
455 int logicalFunc = wxCOPY, int useMask = FALSE);
456 // bool Blit(const wxPoint& destPt, const wxSize& sz,
457 // wxDC *source, const wxPoint& srcPt,
458 // int logicalFunc = wxCOPY, int useMask = FALSE);
461 void CrossHair(long x, long y);
462 void DestroyClippingRegion();
463 long DeviceToLogicalX(long x);
464 long DeviceToLogicalXRel(long x);
465 long DeviceToLogicalY(long y);
466 long DeviceToLogicalYRel(long y);
467 void DrawArc(long x1, long y1, long x2, long y2, long xc, long yc);
468 void DrawCircle(long x, long y, long radius);
469 void DrawEllipse(long x, long y, long width, long height);
470 void DrawEllipticArc(long x, long y, long width, long height, long start, long end);
471 void DrawIcon(const wxIcon& icon, long x, long y);
472 void DrawLine(long x1, long y1, long x2, long y2);
473 void DrawLines(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0);
474 void DrawPolygon(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0,
475 int fill_style=wxODDEVEN_RULE);
476 void DrawPoint(long x, long y);
477 void DrawRectangle(long x, long y, long width, long height);
478 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
479 void DrawRoundedRectangle(long x, long y, long width, long height, long radius=20);
480 void DrawSpline(int PCOUNT, wxPoint* points);
481 void DrawText(const wxString& text, long x, long y);
485 void FloodFill(long x, long y, const wxColour& colour, int style=wxFLOOD_SURFACE);
486 wxBrush& GetBackground();
488 long GetCharHeight();
490 void GetClippingBox(long *OUTPUT, long *OUTPUT,
491 long *OUTPUT, long *OUTPUT);
493 int GetLogicalFunction();
494 void GetLogicalScale(double *OUTPUT, double *OUTPUT);
496 bool GetOptimization();
499 %new wxColour* GetPixel(long x, long y) {
500 wxColour* wc = new wxColour();
501 self->GetPixel(x, y, wc);
505 %name(GetSizeTuple)void GetSize(int* OUTPUT, int* OUTPUT);
508 wxColour& GetTextBackground();
509 void GetTextExtent(const wxString& string, long *OUTPUT, long *OUTPUT);
510 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
511 long *OUTPUT, long *OUTPUT, long *OUTPUT, long* OUTPUT,
512 const wxFont* font = NULL);
513 wxColour& GetTextForeground();
514 void GetUserScale(double *OUTPUT, double *OUTPUT);
515 long LogicalToDeviceX(long x);
516 long LogicalToDeviceXRel(long x);
517 long LogicalToDeviceY(long y);
518 long LogicalToDeviceYRel(long y);
524 void SetDeviceOrigin(long x, long y);
525 void SetBackground(const wxBrush& brush);
526 void SetBackgroundMode(int mode);
527 void SetClippingRegion(long x, long y, long width, long height);
528 void SetPalette(const wxPalette& colourMap);
529 void SetBrush(const wxBrush& brush);
530 void SetFont(const wxFont& font);
531 void SetLogicalFunction(int function);
532 void SetLogicalScale(double x, double y);
533 void SetMapMode(int mode);
534 void SetOptimization(bool optimize);
535 void SetPen(const wxPen& pen);
536 void SetTextBackground(const wxColour& colour);
537 void SetTextForeground(const wxColour& colour);
538 void SetUserScale(double x_scale, double y_scale);
539 bool StartDoc(const wxString& message);
544 void DrawBitmap(const wxBitmap& bitmap, long x, long y,
545 int useMask = FALSE);
547 bool CanDrawBitmap();
548 bool CanGetTextExtent();
552 void GetLogicalOrigin(int *OUTPUT, int *OUTPUT);
553 void SetLogicalOrigin(int x, int y);
554 void GetDeviceOrigin(int *OUTPUT, int *OUTPUT);
555 void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
557 void CalcBoundingBox(int x, int y);
558 void ResetBoundingBox();
562 //----------------------------------------------------------------------
564 class wxMemoryDC : public wxDC {
568 void SelectObject(const wxBitmap& bitmap);
571 %new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC);
572 %{ // Alternate 'constructor'
573 wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) {
574 return new wxMemoryDC(oldDC);
579 //---------------------------------------------------------------------------
581 class wxScreenDC : public wxDC {
585 %name(StartDrawingOnTopWin) bool StartDrawingOnTop(wxWindow* window);
586 bool StartDrawingOnTop(wxRect* rect = NULL);
587 bool EndDrawingOnTop();
590 //---------------------------------------------------------------------------
592 class wxClientDC : public wxDC {
594 wxClientDC(wxWindow* win);
597 //---------------------------------------------------------------------------
599 class wxPaintDC : public wxDC {
601 wxPaintDC(wxWindow* win);
604 //---------------------------------------------------------------------------
606 class wxWindowDC : public wxDC {
608 wxWindowDC(wxWindow* win);
611 //---------------------------------------------------------------------------
614 class wxPostScriptDC : public wxDC {
616 wxPostScriptDC(const wxString& output, bool interactive = TRUE, wxWindow* win = NULL);
620 //---------------------------------------------------------------------------
624 class wxMetaFileDC : public wxDC {
626 wxMetaFileDC(const wxString& filename = wxPyEmptyStr);
631 //---------------------------------------------------------------------------
632 //---------------------------------------------------------------------------
639 extern wxFont *wxNORMAL_FONT;
640 extern wxFont *wxSMALL_FONT;
641 extern wxFont *wxITALIC_FONT;
642 extern wxFont *wxSWISS_FONT;
644 extern wxPen *wxRED_PEN;
645 extern wxPen *wxCYAN_PEN;
646 extern wxPen *wxGREEN_PEN;
647 extern wxPen *wxBLACK_PEN;
648 extern wxPen *wxWHITE_PEN;
649 extern wxPen *wxTRANSPARENT_PEN;
650 extern wxPen *wxBLACK_DASHED_PEN;
651 extern wxPen *wxGREY_PEN;
652 extern wxPen *wxMEDIUM_GREY_PEN;
653 extern wxPen *wxLIGHT_GREY_PEN;
655 extern wxBrush *wxBLUE_BRUSH;
656 extern wxBrush *wxGREEN_BRUSH;
657 extern wxBrush *wxWHITE_BRUSH;
658 extern wxBrush *wxBLACK_BRUSH;
659 extern wxBrush *wxTRANSPARENT_BRUSH;
660 extern wxBrush *wxCYAN_BRUSH;
661 extern wxBrush *wxRED_BRUSH;
662 extern wxBrush *wxGREY_BRUSH;
663 extern wxBrush *wxMEDIUM_GREY_BRUSH;
664 extern wxBrush *wxLIGHT_GREY_BRUSH;
666 extern wxColour *wxBLACK;
667 extern wxColour *wxWHITE;
668 extern wxColour *wxRED;
669 extern wxColour *wxBLUE;
670 extern wxColour *wxGREEN;
671 extern wxColour *wxCYAN;
672 extern wxColour *wxLIGHT_GREY;
674 extern wxCursor *wxSTANDARD_CURSOR;
675 extern wxCursor *wxHOURGLASS_CURSOR;
676 extern wxCursor *wxCROSS_CURSOR;
678 extern wxBitmap wxNullBitmap;
679 extern wxIcon wxNullIcon;
680 extern wxCursor wxNullCursor;
681 extern wxPen wxNullPen;
682 extern wxBrush wxNullBrush;
683 extern wxPalette wxNullPalette;
684 extern wxFont wxNullFont;
685 extern wxColour wxNullColour;
688 extern wxFontList* wxTheFontList;
689 extern wxPenList* wxThePenList;
690 extern wxBrushlist* wxTheBrushList;
691 extern wxColourDatabase* wxTheColourDatabase;
699 //---------------------------------------------------------------------------
703 wxPalette(int LCOUNT, byte* choices, byte* choices, byte* choices);
706 int GetPixel(byte red, byte green, byte blue);
707 bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT);
711 //---------------------------------------------------------------------------
714 wxIMAGELIST_DRAW_NORMAL ,
715 wxIMAGELIST_DRAW_TRANSPARENT,
716 wxIMAGELIST_DRAW_SELECTED,
717 wxIMAGELIST_DRAW_FOCUSED,
725 wxImageList(int width, int height, int mask=TRUE, int initialCount=1);
728 int Add(const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
729 %name(AddWithColourMask)int Add(const wxBitmap& bitmap, const wxColour& maskColour);
730 %name(AddIcon)int Add(const wxIcon& icon);
732 bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
734 // %name(ReplaceIcon)bool Replace(int index, const wxIcon& icon);
735 // int Add(const wxBitmap& bitmap);
736 bool Replace(int index, const wxBitmap& bitmap);
739 bool Draw(int index, wxDC& dc, int x, int x, int flags = wxIMAGELIST_DRAW_NORMAL,
740 const bool solidBackground = FALSE);
743 bool Remove(int index);
745 void GetSize(int index, int& OUTPUT, int& OUTPUT);
749 //---------------------------------------------------------------------------