]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/src/gdi.i
Beginning of bitmap updates
[wxWidgets.git] / wxPython / src / gdi.i
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: gdi.i
3// Purpose: SWIG interface file for wxDC, wxBrush, wxPen, wxFont, etc.
4//
5// Author: Robin Dunn
6//
7// Created: 7/7/97
8// RCS-ID: $Id$
9// Copyright: (c) 1998 by Total Control Software
10// Licence: wxWindows license
11/////////////////////////////////////////////////////////////////////////////
12
13
14%module gdi
15
16%{
17#include "helpers.h"
18#include <wx/metafile.h>
19#include <wx/imaglist.h>
20#ifndef __WXMSW__
21#include <wx/dcps.h>
22#endif
23%}
24
25//----------------------------------------------------------------------
26
27%include typemaps.i
28%include my_typemaps.i
29
30// Import some definitions of other classes, etc.
31%import _defs.i
32%import misc.i
33
34//---------------------------------------------------------------------------
35
36// class wxGDIImage {
37// public:
38// long GetHandle();
39// void SetHandle(long handle);
40// bool Ok();
41// int GetWidth();
42// int GetHeight();
43// int GetDepth();
44// void SetWidth(int w);
45// void SetHeight(int h);
46// void SetDepth(int d);
47// void SetSize(const wxSize& size);
48// };
49
50//---------------------------------------------------------------------------
51
52class wxBitmap
53//: public wxGDIImage
54{
55public:
56 wxBitmap(const wxString& name, long type);
57 ~wxBitmap();
58
59 wxPalette* GetPalette();
60 wxMask* GetMask();
61 bool LoadFile(const wxString& name, long flags);
62 bool SaveFile(const wxString& name, int type, wxPalette* palette = NULL);
63 void SetMask(wxMask* mask);
64#ifdef __WXMSW__
65 void SetPalette(wxPalette& palette);
66#endif
67
68 // wxGDIImage methods
69#ifdef __WXMSW__
70 long GetHandle();
71 void SetHandle(long handle);
72#endif
73 bool Ok();
74 int GetWidth();
75 int GetHeight();
76 int GetDepth();
77 void SetWidth(int w);
78 void SetHeight(int h);
79 void SetDepth(int d);
80#ifdef __WXMSW__
81 void SetSize(const wxSize& size);
82#endif
83
84 wxBitmap GetSubBitmap( const wxRect& rect );
85#ifdef __WXMSW__
86 bool CopyFromIcon(const wxIcon& icon);
87 bool CopyFromCursor(const wxCursor& cursor);
88 int GetQuality();
89 void SetQuality(int q);
90#endif
91
92 %pragma(python) addtoclass = "
93 def __del__(self,gdic=gdic):
94 try:
95 if self.thisown == 1 :
96 gdic.delete_wxBitmap(self)
97 except:
98 pass
99"
100};
101
102
103%new wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1);
104
105#ifdef __WXMSW__
106%new wxBitmap* wxBitmapFromData(PyObject* data, long type,
107 int width, int height, int depth = 1);
108#endif
109
110%{ // Alternate 'constructor'
111 wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1) {
112 return new wxBitmap(width, height, depth);
113 }
114
115#ifdef __WXMSW__
116 wxBitmap* wxBitmapFromData(PyObject* data, long type,
117 int width, int height, int depth = 1) {
118 if (! PyString_Check(data)) {
119 PyErr_SetString(PyExc_TypeError, "Expected string object");
120 return NULL;
121 }
122
123 return new wxBitmap((void*)PyString_AsString(data), type, width, height, depth);
124 }
125#endif
126%}
127
128//---------------------------------------------------------------------------
129
130class wxMask {
131public:
132 wxMask(const wxBitmap& bitmap);
133 //~wxMask();
134};
135
136%new wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour);
137%{
138 wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour) {
139 return new wxMask(bitmap, colour);
140 }
141%}
142
143
144//---------------------------------------------------------------------------
145
146
147class wxIcon
148//: public wxGDIImage
149{
150public:
151 wxIcon(const wxString& name, long flags,
152 int desiredWidth = -1, int desiredHeight = -1);
153 ~wxIcon();
154
155 bool LoadFile(const wxString& name, long flags);
156
157 // wxGDIImage methods
158#ifdef __WXMSW__
159 long GetHandle();
160 void SetHandle(long handle);
161#endif
162 bool Ok();
163 int GetWidth();
164 int GetHeight();
165 int GetDepth();
166 void SetWidth(int w);
167 void SetHeight(int h);
168 void SetDepth(int d);
169#ifdef __WXMSW__
170 void SetSize(const wxSize& size);
171#endif
172 %pragma(python) addtoclass = "
173 def __del__(self,gdic=gdic):
174 try:
175 if self.thisown == 1 :
176 gdic.delete_wxIcon(self)
177 except:
178 pass
179"
180
181};
182
183
184//---------------------------------------------------------------------------
185
186class wxCursor
187//: public wxGDIImage
188{
189public:
190#ifdef __WXMSW__
191 wxCursor(const wxString& cursorName, long flags, int hotSpotX=0, int hotSpotY=0);
192#endif
193 ~wxCursor();
194
195 // wxGDIImage methods
196#ifdef __WXMSW__
197 long GetHandle();
198 void SetHandle(long handle);
199#endif
200 bool Ok();
201#ifdef __WXMSW__
202 int GetWidth();
203 int GetHeight();
204 int GetDepth();
205 void SetWidth(int w);
206 void SetHeight(int h);
207 void SetDepth(int d);
208 void SetSize(const wxSize& size);
209#endif
210};
211
212%name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id);
213%{ // Alternate 'constructor'
214 wxCursor* wxPyStockCursor(int id) {
215 return new wxCursor(id);
216 }
217%}
218
219//----------------------------------------------------------------------
220
221
222enum wxFontEncoding
223{
224 wxFONTENCODING_SYSTEM = -1, // system default
225 wxFONTENCODING_DEFAULT, // current default encoding
226
227 // ISO8859 standard defines a number of single-byte charsets
228 wxFONTENCODING_ISO8859_1, // West European (Latin1)
229 wxFONTENCODING_ISO8859_2, // Central and East European (Latin2)
230 wxFONTENCODING_ISO8859_3, // Esperanto (Latin3)
231 wxFONTENCODING_ISO8859_4, // Baltic languages (Estonian) (Latin4)
232 wxFONTENCODING_ISO8859_5, // Cyrillic
233 wxFONTENCODING_ISO8859_6, // Arabic
234 wxFONTENCODING_ISO8859_7, // Greek
235 wxFONTENCODING_ISO8859_8, // Hebrew
236 wxFONTENCODING_ISO8859_9, // Turkish (Latin5)
237 wxFONTENCODING_ISO8859_10, // Variation of Latin4 (Latin6)
238 wxFONTENCODING_ISO8859_11, // Thai
239 wxFONTENCODING_ISO8859_12, // doesn't exist currently, but put it
240 // here anyhow to make all ISO8859
241 // consecutive numbers
242 wxFONTENCODING_ISO8859_13, // Latin7
243 wxFONTENCODING_ISO8859_14, // Latin8
244 wxFONTENCODING_ISO8859_15, // Latin9 (a.k.a. Latin0, includes euro)
245
246 // Cyrillic charset soup (see http://czyborra.com/charsets/cyrillic.html)
247 wxFONTENCODING_KOI8, // we don't support any of KOI8 variants
248 wxFONTENCODING_ALTERNATIVE, // same as MS-DOS CP866
249 wxFONTENCODING_BULGARIAN, // used under Linux in Bulgaria
250
251 // what would we do without Microsoft? They have their own encodings
252 // for DOS
253 wxFONTENCODING_CP437, // original MS-DOS codepage
254 wxFONTENCODING_CP850, // CP437 merged with Latin1
255 wxFONTENCODING_CP852, // CP437 merged with Latin2
256 wxFONTENCODING_CP855, // another cyrillic encoding
257 wxFONTENCODING_CP866, // and another one
258 // and for Windows
259 wxFONTENCODING_CP1250, // WinLatin2
260 wxFONTENCODING_CP1251, // WinCyrillic
261 wxFONTENCODING_CP1252, // WinLatin1
262
263 wxFONTENCODING_MAX
264};
265
266class wxFont {
267public:
268 // I'll do it this way to use long-lived objects and not have to
269 // worry about when python may delete the object.
270 %addmethods {
271 wxFont( int pointSize, int family, int style, int weight,
272 int underline=FALSE, char* faceName = "",
273 wxFontEncoding encoding=wxFONTENCODING_DEFAULT) {
274
275 return wxTheFontList->FindOrCreateFont(pointSize, family, style, weight,
276 underline, faceName, encoding);
277 }
278 // NO Destructor.
279 }
280
281 bool Ok();
282
283 wxString GetFaceName();
284 int GetFamily();
285#ifdef __WXMSW__
286 int GetFontId();
287#endif
288 int GetPointSize();
289 int GetStyle();
290 bool GetUnderlined();
291 int GetWeight();
292 wxFontEncoding GetEncoding();
293 void SetFaceName(const wxString& faceName);
294 void SetFamily(int family);
295 void SetPointSize(int pointSize);
296 void SetStyle(int style);
297 void SetUnderlined(bool underlined);
298 void SetWeight(int weight);
299 void SetEncoding(wxFontEncoding encoding);
300 wxString GetFamilyString();
301 wxString GetStyleString();
302 wxString GetWeightString();
303};
304
305%inline %{
306 wxFontEncoding wxFont_GetDefaultEncoding() {
307 return wxFont::GetDefaultEncoding();
308 }
309
310 void wxFont_SetDefaultEncoding(wxFontEncoding encoding) {
311 wxFont::SetDefaultEncoding(encoding);
312 }
313%}
314
315//----------------------------------------------------------------------
316
317class wxColour {
318public:
319 wxColour(unsigned char red=0, unsigned char green=0, unsigned char blue=0);
320 ~wxColour();
321 unsigned char Red();
322 unsigned char Green();
323 unsigned char Blue();
324 bool Ok();
325 void Set(unsigned char red, unsigned char green, unsigned char blue);
326 %addmethods {
327 PyObject* Get() {
328 PyObject* rv = PyTuple_New(3);
329 PyTuple_SetItem(rv, 0, PyInt_FromLong(self->Red()));
330 PyTuple_SetItem(rv, 1, PyInt_FromLong(self->Green()));
331 PyTuple_SetItem(rv, 2, PyInt_FromLong(self->Blue()));
332 return rv;
333 }
334 }
335 %pragma(python) addtoclass = "asTuple = Get"
336 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
337 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
338
339};
340
341%new wxColour* wxNamedColour(const wxString& colorName);
342
343%{ // Alternate 'constructor'
344 wxColour* wxNamedColour(const wxString& colorName) {
345 return new wxColour(colorName);
346 }
347%}
348
349
350//----------------------------------------------------------------------
351
352
353class wxPen {
354public:
355 // I'll do it this way to use long-lived objects and not have to
356 // worry about when python may delete the object.
357 %addmethods {
358 wxPen(wxColour* colour, int width=1, int style=wxSOLID) {
359 return wxThePenList->FindOrCreatePen(*colour, width, style);
360 }
361 // NO Destructor.
362 }
363
364 int GetCap();
365 wxColour& GetColour();
366
367 int GetJoin();
368 int GetStyle();
369 int GetWidth();
370 bool Ok();
371 void SetCap(int cap_style);
372 void SetColour(wxColour& colour);
373 void SetJoin(int join_style);
374 void SetStyle(int style);
375 void SetWidth(int width);
376
377 // **** This one needs to return a list of ints (wxDash)
378 int GetDashes(wxDash **dashes);
379 void SetDashes(int LCOUNT, wxDash* choices);
380
381#ifdef __WXMSW__
382 wxBitmap* GetStipple();
383 void SetStipple(wxBitmap& stipple);
384#endif
385};
386
387//----------------------------------------------------------------------
388
389class wxBrush {
390public:
391 // I'll do it this way to use long-lived objects and not have to
392 // worry about when python may delete the object.
393 %addmethods {
394 wxBrush(const wxColour* colour, int style=wxSOLID) {
395 return wxTheBrushList->FindOrCreateBrush(*colour, style);
396 }
397 // NO Destructor.
398 }
399
400// wxBrush(const wxColour& colour, int style=wxSOLID);
401
402 wxColour& GetColour();
403 wxBitmap * GetStipple();
404 int GetStyle();
405 bool Ok();
406 void SetColour(wxColour &colour);
407 void SetStipple(wxBitmap& bitmap);
408 void SetStyle(int style);
409};
410
411//----------------------------------------------------------------------
412
413
414
415class wxDC {
416public:
417// wxDC(); **** abstract base class, can't instantiate.
418 ~wxDC();
419
420 void BeginDrawing();
421// %name(BlitXY)
422 bool Blit(long xdest, long ydest,
423 long width, long height,
424 wxDC *source, long xsrc, long ysrc,
425 int logicalFunc = wxCOPY, int useMask = FALSE);
426// bool Blit(const wxPoint& destPt, const wxSize& sz,
427// wxDC *source, const wxPoint& srcPt,
428// int logicalFunc = wxCOPY, int useMask = FALSE);
429
430 void Clear();
431 void CrossHair(long x, long y);
432 void DestroyClippingRegion();
433 long DeviceToLogicalX(long x);
434 long DeviceToLogicalXRel(long x);
435 long DeviceToLogicalY(long y);
436 long DeviceToLogicalYRel(long y);
437 void DrawArc(long x1, long y1, long x2, long y2, long xc, long yc);
438 void DrawCircle(long x, long y, long radius);
439 void DrawEllipse(long x, long y, long width, long height);
440 void DrawEllipticArc(long x, long y, long width, long height, long start, long end);
441 void DrawIcon(const wxIcon& icon, long x, long y);
442 void DrawLine(long x1, long y1, long x2, long y2);
443 void DrawLines(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0);
444 void DrawPolygon(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0,
445 int fill_style=wxODDEVEN_RULE);
446 void DrawPoint(long x, long y);
447 void DrawRectangle(long x, long y, long width, long height);
448 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
449 void DrawRoundedRectangle(long x, long y, long width, long height, long radius=20);
450 void DrawSpline(int PCOUNT, wxPoint* points);
451 void DrawText(const wxString& text, long x, long y);
452 void EndDoc();
453 void EndDrawing();
454 void EndPage();
455 void FloodFill(long x, long y, const wxColour& colour, int style=wxFLOOD_SURFACE);
456 wxBrush& GetBackground();
457 wxBrush& GetBrush();
458 long GetCharHeight();
459 long GetCharWidth();
460 void GetClippingBox(long *OUTPUT, long *OUTPUT,
461 long *OUTPUT, long *OUTPUT);
462 wxFont& GetFont();
463 int GetLogicalFunction();
464 void GetLogicalScale(double *OUTPUT, double *OUTPUT);
465 int GetMapMode();
466 bool GetOptimization();
467 wxPen& GetPen();
468 %addmethods {
469 %new wxColour* GetPixel(long x, long y) {
470 wxColour* wc = new wxColour();
471 self->GetPixel(x, y, wc);
472 return wc;
473 }
474 }
475 %name(GetSizeTuple)void GetSize(int* OUTPUT, int* OUTPUT);
476 wxSize GetSize();
477 wxSize GetSizeMM();
478 wxColour& GetTextBackground();
479 void GetTextExtent(const wxString& string, long *OUTPUT, long *OUTPUT);
480 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
481 long *OUTPUT, long *OUTPUT, long *OUTPUT, long* OUTPUT,
482 const wxFont* font = NULL);
483 wxColour& GetTextForeground();
484 void GetUserScale(double *OUTPUT, double *OUTPUT);
485 long LogicalToDeviceX(long x);
486 long LogicalToDeviceXRel(long x);
487 long LogicalToDeviceY(long y);
488 long LogicalToDeviceYRel(long y);
489 long MaxX();
490 long MaxY();
491 long MinX();
492 long MinY();
493 bool Ok();
494 void SetDeviceOrigin(long x, long y);
495 void SetBackground(const wxBrush& brush);
496 void SetBackgroundMode(int mode);
497 void SetClippingRegion(long x, long y, long width, long height);
498 void SetPalette(const wxPalette& colourMap);
499 void SetBrush(const wxBrush& brush);
500 void SetFont(const wxFont& font);
501 void SetLogicalFunction(int function);
502 void SetLogicalScale(double x, double y);
503 void SetMapMode(int mode);
504 void SetOptimization(bool optimize);
505 void SetPen(const wxPen& pen);
506 void SetTextBackground(const wxColour& colour);
507 void SetTextForeground(const wxColour& colour);
508 void SetUserScale(double x_scale, double y_scale);
509 bool StartDoc(const wxString& message);
510 void StartPage();
511
512
513
514 void DrawBitmap(const wxBitmap& bitmap, long x, long y,
515 int useMask = FALSE);
516
517 bool CanDrawBitmap();
518 bool CanGetTextExtent();
519 int GetDepth();
520 wxSize GetPPI();
521
522 void GetLogicalOrigin(int *OUTPUT, int *OUTPUT);
523 void SetLogicalOrigin(int x, int y);
524 void GetDeviceOrigin(int *OUTPUT, int *OUTPUT);
525 void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
526
527 void CalcBoundingBox(int x, int y);
528 void ResetBoundingBox();
529};
530
531
532//----------------------------------------------------------------------
533
534class wxMemoryDC : public wxDC {
535public:
536 wxMemoryDC();
537
538 void SelectObject(const wxBitmap& bitmap);
539}
540
541%new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC);
542%{ // Alternate 'constructor'
543 wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) {
544 return new wxMemoryDC(oldDC);
545 }
546%}
547
548
549//---------------------------------------------------------------------------
550
551class wxScreenDC : public wxDC {
552public:
553 wxScreenDC();
554
555 %name(StartDrawingOnTopWin) bool StartDrawingOnTop(wxWindow* window);
556 bool StartDrawingOnTop(wxRect* rect = NULL);
557 bool EndDrawingOnTop();
558};
559
560//---------------------------------------------------------------------------
561
562class wxClientDC : public wxDC {
563public:
564 wxClientDC(wxWindow* win);
565};
566
567//---------------------------------------------------------------------------
568
569class wxPaintDC : public wxDC {
570public:
571 wxPaintDC(wxWindow* win);
572};
573
574//---------------------------------------------------------------------------
575
576class wxWindowDC : public wxDC {
577public:
578 wxWindowDC(wxWindow* win);
579};
580
581//---------------------------------------------------------------------------
582
583#ifndef __WXMSW__
584class wxPostScriptDC : public wxDC {
585public:
586 wxPostScriptDC(const wxString& output, bool interactive = TRUE, wxWindow* win = NULL);
587};
588#endif
589
590//---------------------------------------------------------------------------
591
592#ifdef __WXMSW__
593class wxPrinterDC : public wxDC {
594public:
595 wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output,
596 bool interactive = TRUE, int orientation = wxPORTRAIT);
597};
598#endif
599
600//---------------------------------------------------------------------------
601
602#ifdef __WXMSW__
603class wxMetaFileDC : public wxDC {
604public:
605 wxMetaFileDC(const wxString& filename = wxPyEmptyStr);
606 wxMetaFile* Close();
607};
608#endif
609
610//---------------------------------------------------------------------------
611//---------------------------------------------------------------------------
612
613
614%readonly
615%{
616#if 0
617%}
618extern wxFont *wxNORMAL_FONT;
619extern wxFont *wxSMALL_FONT;
620extern wxFont *wxITALIC_FONT;
621extern wxFont *wxSWISS_FONT;
622
623extern wxPen *wxRED_PEN;
624extern wxPen *wxCYAN_PEN;
625extern wxPen *wxGREEN_PEN;
626extern wxPen *wxBLACK_PEN;
627extern wxPen *wxWHITE_PEN;
628extern wxPen *wxTRANSPARENT_PEN;
629extern wxPen *wxBLACK_DASHED_PEN;
630extern wxPen *wxGREY_PEN;
631extern wxPen *wxMEDIUM_GREY_PEN;
632extern wxPen *wxLIGHT_GREY_PEN;
633
634extern wxBrush *wxBLUE_BRUSH;
635extern wxBrush *wxGREEN_BRUSH;
636extern wxBrush *wxWHITE_BRUSH;
637extern wxBrush *wxBLACK_BRUSH;
638extern wxBrush *wxTRANSPARENT_BRUSH;
639extern wxBrush *wxCYAN_BRUSH;
640extern wxBrush *wxRED_BRUSH;
641extern wxBrush *wxGREY_BRUSH;
642extern wxBrush *wxMEDIUM_GREY_BRUSH;
643extern wxBrush *wxLIGHT_GREY_BRUSH;
644
645extern wxColour *wxBLACK;
646extern wxColour *wxWHITE;
647extern wxColour *wxRED;
648extern wxColour *wxBLUE;
649extern wxColour *wxGREEN;
650extern wxColour *wxCYAN;
651extern wxColour *wxLIGHT_GREY;
652
653extern wxCursor *wxSTANDARD_CURSOR;
654extern wxCursor *wxHOURGLASS_CURSOR;
655extern wxCursor *wxCROSS_CURSOR;
656
657extern wxBitmap wxNullBitmap;
658extern wxIcon wxNullIcon;
659extern wxCursor wxNullCursor;
660extern wxPen wxNullPen;
661extern wxBrush wxNullBrush;
662extern wxPalette wxNullPalette;
663extern wxFont wxNullFont;
664extern wxColour wxNullColour;
665
666%readwrite
667%{
668#endif
669%}
670
671//---------------------------------------------------------------------------
672
673class wxPalette {
674public:
675 wxPalette(int LCOUNT, byte* choices, byte* choices, byte* choices);
676 ~wxPalette();
677
678 int GetPixel(byte red, byte green, byte blue);
679 bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT);
680 bool Ok();
681};
682
683//---------------------------------------------------------------------------
684
685enum {
686 wxIMAGELIST_DRAW_NORMAL ,
687 wxIMAGELIST_DRAW_TRANSPARENT,
688 wxIMAGELIST_DRAW_SELECTED,
689 wxIMAGELIST_DRAW_FOCUSED,
690 wxIMAGE_LIST_NORMAL,
691 wxIMAGE_LIST_SMALL,
692 wxIMAGE_LIST_STATE
693};
694
695class wxImageList {
696public:
697 wxImageList(int width, int height, int mask=TRUE, int initialCount=1);
698 ~wxImageList();
699
700 int Add(const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
701 %name(AddWithColourMask)int Add(const wxBitmap& bitmap, const wxColour& maskColour);
702 %name(AddIcon)int Add(const wxIcon& icon);
703#ifdef __WXMSW__
704 bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
705#else
706// %name(ReplaceIcon)bool Replace(int index, const wxIcon& icon);
707// int Add(const wxBitmap& bitmap);
708 bool Replace(int index, const wxBitmap& bitmap);
709#endif
710
711 bool Draw(int index, wxDC& dc, int x, int x, int flags = wxIMAGELIST_DRAW_NORMAL,
712 const bool solidBackground = FALSE);
713
714 int GetImageCount();
715 bool Remove(int index);
716 bool RemoveAll();
717 void GetSize(int index, int& OUTPUT, int& OUTPUT);
718};
719
720
721//---------------------------------------------------------------------------
722