]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/gdi.i
cut-and-paste is not good idea, removed duplicated code
[wxWidgets.git] / wxPython / src / gdi.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: gdi.i
3 // Purpose: SWIG interface file for wxDC, wxBrush, wxPen, 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/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>
24 #include <wx/iconbndl.h>
25 %}
26
27 //----------------------------------------------------------------------
28
29 %include typemaps.i
30 %include my_typemaps.i
31
32 // Import some definitions of other classes, etc.
33 %import _defs.i
34 %import misc.i
35 %import fonts.i
36
37 %pragma(python) code = "import wx"
38
39 //---------------------------------------------------------------------------
40 %{
41 // Put some wx default wxChar* values into wxStrings.
42 static const wxString wxPyEmptyString(wxT(""));
43 %}
44 //---------------------------------------------------------------------------
45
46 class wxGDIObject : public wxObject {
47 public:
48 wxGDIObject();
49 ~wxGDIObject();
50
51 bool GetVisible();
52 void SetVisible( bool visible );
53
54 bool IsNull();
55
56 };
57
58 //---------------------------------------------------------------------------
59
60
61 // TODO: When the API stabalizes and is available on other platforms, add
62 // wrappers for the new wxBitmap, wxRawBitmap, wxDIB stuff...
63
64 class wxBitmap : public wxGDIObject
65 {
66 public:
67 wxBitmap(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_ANY);
68 ~wxBitmap();
69
70 wxPalette* GetPalette();
71 wxMask* GetMask();
72 bool LoadFile(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_ANY);
73 bool SaveFile(const wxString& name, wxBitmapType type, wxPalette* palette = NULL);
74 void SetMask(wxMask* mask);
75 %pragma(python) addtoclass = "
76 def SetMaskColour(self, colour):
77 mask = wxMaskColour(self, colour)
78 self.SetMask(mask)
79 "
80 #ifdef __WXMSW__
81 void SetPalette(wxPalette& palette);
82 #endif
83
84 // wxGDIImage methods
85 #ifdef __WXMSW__
86 long GetHandle();
87 void SetHandle(long handle);
88 #endif
89 bool Ok();
90 int GetWidth();
91 int GetHeight();
92 int GetDepth();
93 void SetWidth(int w);
94 void SetHeight(int h);
95 void SetDepth(int d);
96 #ifdef __WXMSW__
97 void SetSize(const wxSize& size);
98 #endif
99
100 wxBitmap GetSubBitmap( const wxRect& rect );
101 bool CopyFromIcon(const wxIcon& icon);
102 #ifdef __WXMSW__
103 bool CopyFromCursor(const wxCursor& cursor);
104 int GetQuality();
105 void SetQuality(int q);
106 #endif
107
108 %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
109 };
110
111
112 // Declarations of some alternate "constructors"
113 %new wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1);
114 %new wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings);
115 %new wxBitmap* wxBitmapFromIcon(const wxIcon& icon);
116 %new wxBitmap* wxBitmapFromBits(PyObject* bits, int width, int height, int depth = 1 );
117
118 // #ifdef __WXMSW__
119 // %new wxBitmap* wxBitmapFromData(PyObject* data, long type,
120 // int width, int height, int depth = 1);
121 // #endif
122
123
124
125 %{ // Implementations of some alternate "constructors"
126
127 wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1) {
128 return new wxBitmap(width, height, depth);
129 }
130
131 static char** ConvertListOfStrings(PyObject* listOfStrings) {
132 char** cArray = NULL;
133 int count;
134
135 if (!PyList_Check(listOfStrings)) {
136 PyErr_SetString(PyExc_TypeError, "Expected a list of strings.");
137 return NULL;
138 }
139 count = PyList_Size(listOfStrings);
140 cArray = new char*[count];
141
142 for(int x=0; x<count; x++) {
143 // TODO: Need some validation and error checking here
144 cArray[x] = PyString_AsString(PyList_GET_ITEM(listOfStrings, x));
145 }
146 return cArray;
147 }
148
149
150 wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings) {
151 char** cArray = NULL;
152 wxBitmap* bmp;
153
154 cArray = ConvertListOfStrings(listOfStrings);
155 if (! cArray)
156 return NULL;
157 bmp = new wxBitmap(cArray);
158 delete [] cArray;
159 return bmp;
160 }
161
162
163 wxBitmap* wxBitmapFromIcon(const wxIcon& icon) {
164 return new wxBitmap(icon);
165 }
166
167
168 wxBitmap* wxBitmapFromBits(PyObject* bits, int width, int height, int depth = 1 ) {
169 char* buf;
170 int length;
171 PyString_AsStringAndSize(bits, &buf, &length);
172 return new wxBitmap(buf, width, height, depth);
173 }
174
175
176 // #ifdef __WXMSW__
177 // wxBitmap* wxBitmapFromData(PyObject* data, long type,
178 // int width, int height, int depth = 1) {
179 // if (! PyString_Check(data)) {
180 // PyErr_SetString(PyExc_TypeError, "Expected string object");
181 // return NULL;
182 // }
183 // return new wxBitmap((void*)PyString_AsString(data), type, width, height, depth);
184 // }
185 // #endif
186 %}
187
188 //---------------------------------------------------------------------------
189
190 class wxMask : public wxObject {
191 public:
192 wxMask(const wxBitmap& bitmap);
193 //~wxMask();
194
195 %addmethods { void Destroy() { delete self; } }
196 };
197
198 %new wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour);
199 %{
200 wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour) {
201 return new wxMask(bitmap, colour);
202 }
203 %}
204
205
206 //---------------------------------------------------------------------------
207
208
209 class wxIcon : public wxGDIObject
210 {
211 public:
212 wxIcon(const wxString& name, long flags,
213 int desiredWidth = -1, int desiredHeight = -1);
214 ~wxIcon();
215
216 #ifndef __WXMAC__
217 bool LoadFile(const wxString& name, long flags);
218 #endif
219
220 // wxGDIImage methods
221 #ifdef __WXMSW__
222 long GetHandle();
223 void SetHandle(long handle);
224 #endif
225 bool Ok();
226 int GetWidth();
227 int GetHeight();
228 int GetDepth();
229 void SetWidth(int w);
230 void SetHeight(int h);
231 void SetDepth(int d);
232 #ifdef __WXMSW__
233 void SetSize(const wxSize& size);
234 #endif
235 void CopyFromBitmap(const wxBitmap& bmp);
236
237 %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
238 };
239
240
241 // Declarations of some alternate "constructors"
242 %new wxIcon* wxEmptyIcon();
243 %new wxIcon* wxIconFromXPMData(PyObject* listOfStrings);
244 %new wxIcon* wxIconFromBitmap(const wxBitmap& bmp);
245
246 %{ // Implementations of some alternate "constructors"
247 wxIcon* wxEmptyIcon() {
248 return new wxIcon();
249 }
250
251 wxIcon* wxIconFromXPMData(PyObject* listOfStrings) {
252 char** cArray = NULL;
253 wxIcon* icon;
254
255 cArray = ConvertListOfStrings(listOfStrings);
256 if (! cArray)
257 return NULL;
258 icon = new wxIcon(cArray);
259 delete [] cArray;
260 return icon;
261 }
262
263 wxIcon* wxIconFromBitmap(const wxBitmap& bmp) {
264 wxIcon* icon = new wxIcon();
265 icon->CopyFromBitmap(bmp);
266 return icon;
267 }
268 %}
269
270 //---------------------------------------------------------------------------
271
272 class wxIconBundle
273 {
274 public:
275 // default constructor
276 wxIconBundle();
277
278 // initializes the bundle with the icon(s) found in the file
279 %name(wxIconBundleFromFile) wxIconBundle( const wxString& file, long type );
280
281 // initializes the bundle with a single icon
282 %name(wxIconBundleFromIcon)wxIconBundle( const wxIcon& icon );
283
284 ~wxIconBundle();
285
286 // adds the icon to the collection, if the collection already
287 // contains an icon with the same width and height, it is
288 // replaced
289 void AddIcon( const wxIcon& icon );
290
291 // adds all the icons contained in the file to the collection,
292 // if the collection already contains icons with the same
293 // width and height, they are replaced
294 %name(AddIconFromFile)void AddIcon( const wxString& file, long type );
295
296 // returns the icon with the given size; if no such icon exists,
297 // returns the icon with size wxSYS_ICON_[XY]; if no such icon exists,
298 // returns the first icon in the bundle
299 const wxIcon& GetIcon( const wxSize& size ) const;
300 };
301
302 //---------------------------------------------------------------------------
303
304 class wxCursor : public wxGDIObject
305 {
306 public:
307 %addmethods {
308 wxCursor(const wxString* cursorName, long flags, int hotSpotX=0, int hotSpotY=0) {
309 #ifdef __WXGTK__
310 wxCHECK_MSG(FALSE, NULL,
311 wxT("wxCursor constructor not implemented for wxGTK, use wxStockCursor, wxCursorFromImage, or wxCursorFromBits instead."));
312 #else
313 return new wxCursor(*cursorName, flags, hotSpotX, hotSpotY);
314 #endif
315 }
316 }
317
318 ~wxCursor();
319
320 // wxGDIImage methods
321 #ifdef __WXMSW__
322 long GetHandle();
323 void SetHandle(long handle);
324 #endif
325 bool Ok();
326 #ifdef __WXMSW__
327 int GetWidth();
328 int GetHeight();
329 int GetDepth();
330 void SetWidth(int w);
331 void SetHeight(int h);
332 void SetDepth(int d);
333 void SetSize(const wxSize& size);
334 #endif
335 %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
336 };
337
338 %name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id);
339 %new wxCursor* wxCursorFromImage(const wxImage& image);
340 %new wxCursor* wxCursorFromBits(PyObject* bits, int width, int height,
341 int hotSpotX=-1, int hotSpotY=-1,
342 PyObject* maskBits=0);
343
344 %{
345 wxCursor* wxPyStockCursor(int id) {
346 return new wxCursor(id);
347 }
348
349 wxCursor* wxCursorFromImage(const wxImage& image) {
350 return new wxCursor(image);
351 }
352
353 wxCursor* wxCursorFromBits(PyObject* bits, int width, int height,
354 int hotSpotX=-1, int hotSpotY=-1,
355 PyObject* maskBits=0) {
356 char* bitsbuf;
357 char* maskbuf = NULL;
358 int length;
359 PyString_AsStringAndSize(bits, &bitsbuf, &length);
360 if (maskBits)
361 PyString_AsStringAndSize(maskBits, &maskbuf, &length);
362 return new wxCursor(bitsbuf, width, height, hotSpotX, hotSpotY, maskbuf);
363 }
364 %}
365
366 //----------------------------------------------------------------------
367
368 class wxColour : public wxObject {
369 public:
370 wxColour(unsigned char red=0, unsigned char green=0, unsigned char blue=0);
371 ~wxColour();
372 unsigned char Red();
373 unsigned char Green();
374 unsigned char Blue();
375 bool Ok();
376 void Set(unsigned char red, unsigned char green, unsigned char blue);
377 %addmethods {
378 PyObject* Get() {
379 PyObject* rv = PyTuple_New(3);
380 int red = -1;
381 int green = -1;
382 int blue = -1;
383 if (self->Ok()) {
384 red = self->Red();
385 green = self->Green();
386 blue = self->Blue();
387 }
388 PyTuple_SetItem(rv, 0, PyInt_FromLong(red));
389 PyTuple_SetItem(rv, 1, PyInt_FromLong(green));
390 PyTuple_SetItem(rv, 2, PyInt_FromLong(blue));
391 return rv;
392 }
393 bool __eq__(PyObject* obj) {
394 wxColour tmp;
395 wxColour* ptr = &tmp;
396 if (obj == Py_None) return FALSE;
397 wxPyBLOCK_THREADS(bool success = wxColour_helper(obj, &ptr); PyErr_Clear());
398 if (! success) return FALSE;
399 return *self == *ptr;
400 }
401 bool __ne__(PyObject* obj) {
402 wxColour tmp;
403 wxColour* ptr = &tmp;
404 if (obj == Py_None) return TRUE;
405 wxPyBLOCK_THREADS(bool success = wxColour_helper(obj, &ptr); PyErr_Clear());
406 if (! success) return TRUE;
407 return *self != *ptr;
408 }
409 }
410
411 %pragma(python) addtoclass = "asTuple = Get
412 def __str__(self): return str(self.asTuple())
413 def __repr__(self): return 'wxColour:' + str(self.asTuple())
414 def __nonzero__(self): return self.Ok()
415 def __getinitargs__(self): return ()
416 def __getstate__(self): return self.asTuple()
417 def __setstate__(self, state): self.Set(*state)
418 "
419
420 };
421
422 %new wxColour* wxNamedColour(const wxString& colorName);
423
424 %{ // Alternate 'constructor'
425 wxColour* wxNamedColour(const wxString& colorName) {
426 return new wxColour(colorName);
427 }
428 %}
429
430
431
432 class wxColourDatabase : public wxObject {
433 public:
434
435 wxColour *FindColour(const wxString& colour);
436 wxString FindName(const wxColour& colour) const;
437
438 %addmethods {
439 void Append(const wxString& name, int red, int green, int blue) {
440 // first see if the name is already there
441 wxString cName = name;
442 cName.MakeUpper();
443 wxString cName2 = cName;
444 if ( !cName2.Replace(wxT("GRAY"), wxT("GREY")) )
445 cName2.clear();
446
447 wxNode *node = self->GetFirst();
448 while ( node ) {
449 const wxChar *key = node->GetKeyString();
450 if ( cName == key || cName2 == key ) {
451 wxColour* c = (wxColour *)node->GetData();
452 c->Set(red, green, blue);
453 return;
454 }
455 node = node->GetNext();
456 }
457
458 // otherwise append the new colour
459 self->Append(name.c_str(), new wxColour(red, green, blue));
460 }
461 }
462 };
463
464
465 //----------------------------------------------------------------------
466
467 class wxPen : public wxGDIObject {
468 public:
469 wxPen(wxColour& colour, int width=1, int style=wxSOLID);
470 ~wxPen();
471
472 int GetCap();
473 wxColour GetColour();
474
475 int GetJoin();
476 int GetStyle();
477 int GetWidth();
478 bool Ok();
479 void SetCap(int cap_style);
480 void SetColour(wxColour& colour);
481 void SetJoin(int join_style);
482 void SetStyle(int style);
483 void SetWidth(int width);
484
485
486 void SetDashes(int LCOUNT, wxDash* choices);
487 //int GetDashes(wxDash **dashes);
488 %addmethods {
489 PyObject* GetDashes() {
490 wxDash* dashes;
491 int count = self->GetDashes(&dashes);
492 wxPyBeginBlockThreads();
493 PyObject* retval = PyList_New(0);
494 for (int x=0; x<count; x++)
495 PyList_Append(retval, PyInt_FromLong(dashes[x]));
496 wxPyEndBlockThreads();
497 return retval;
498 }
499 }
500
501 #ifdef __WXMSW__
502 wxBitmap* GetStipple();
503 void SetStipple(wxBitmap& stipple);
504 #endif
505
506 %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
507 };
508
509
510
511
512 // The list of ints for the dashes needs to exist for the life of the pen
513 // so we make it part of the class to save it. wxPyPen is aliased to wxPen
514 // in _extras.py
515
516 %{
517 class wxPyPen : public wxPen {
518 public:
519 wxPyPen(wxColour& colour, int width=1, int style=wxSOLID)
520 : wxPen(colour, width, style)
521 { m_dash = NULL; }
522 ~wxPyPen() {
523 if (m_dash)
524 delete [] m_dash;
525 }
526
527 void SetDashes(int nb_dashes, const wxDash *dash) {
528 if (m_dash)
529 delete [] m_dash;
530 m_dash = new wxDash[nb_dashes];
531 for (int i=0; i<nb_dashes; i++) {
532 m_dash[i] = dash[i];
533 }
534 wxPen::SetDashes(nb_dashes, m_dash);
535 }
536
537 private:
538 wxDash* m_dash;
539 };
540 %}
541
542
543 class wxPyPen : public wxPen {
544 public:
545 wxPyPen(wxColour& colour, int width=1, int style=wxSOLID);
546 ~wxPyPen();
547
548 void SetDashes(int LCOUNT, wxDash* choices);
549 };
550
551
552
553
554 class wxPenList : public wxObject {
555 public:
556
557 void AddPen(wxPen* pen);
558 wxPen* FindOrCreatePen(const wxColour& colour, int width, int style);
559 void RemovePen(wxPen* pen);
560
561 int GetCount();
562 };
563
564
565
566 //----------------------------------------------------------------------
567
568 class wxBrush : public wxGDIObject {
569 public:
570 wxBrush(const wxColour& colour, int style=wxSOLID);
571 ~wxBrush();
572
573 wxColour GetColour();
574 wxBitmap * GetStipple();
575 int GetStyle();
576 bool Ok();
577 void SetColour(wxColour &colour);
578 void SetStipple(wxBitmap& bitmap);
579 void SetStyle(int style);
580
581 #ifdef __WXMAC__
582 short GetMacTheme();
583 void SetMacTheme(short macThemeBrush);
584 #endif
585
586 %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
587 };
588
589
590 class wxBrushList : public wxObject {
591 public:
592
593 void AddBrush(wxBrush *brush);
594 wxBrush * FindOrCreateBrush(const wxColour& colour, int style);
595 void RemoveBrush(wxBrush *brush);
596
597 int GetCount();
598 };
599
600 //----------------------------------------------------------------------
601
602
603 class wxDC : public wxObject {
604 public:
605 // wxDC(); **** abstract base class, can't instantiate.
606 ~wxDC();
607
608 void BeginDrawing();
609
610 // %name(BlitXY)
611 bool Blit(wxCoord xdest, wxCoord ydest,
612 wxCoord width, wxCoord height,
613 wxDC *source, wxCoord xsrc, wxCoord ysrc,
614 int logicalFunc = wxCOPY, int useMask = FALSE);
615 // bool Blit(const wxPoint& destPt, const wxSize& sz,
616 // wxDC *source, const wxPoint& srcPt,
617 // int logicalFunc = wxCOPY, int useMask = FALSE);
618
619 void Clear();
620 void CrossHair(wxCoord x, wxCoord y);
621 void DestroyClippingRegion();
622 wxCoord DeviceToLogicalX(wxCoord x);
623 wxCoord DeviceToLogicalXRel(wxCoord x);
624 wxCoord DeviceToLogicalY(wxCoord y);
625 wxCoord DeviceToLogicalYRel(wxCoord y);
626 void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc);
627 void DrawCircle(wxCoord x, wxCoord y, wxCoord radius);
628 void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
629 void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord width, wxCoord height, wxCoord start, wxCoord end);
630 void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
631
632 void DrawLabel(const wxString& text, const wxRect& rect,
633 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
634 int indexAccel = -1);
635
636 %addmethods {
637 wxRect DrawImageLabel(const wxString& text,
638 const wxBitmap& image,
639 const wxRect& rect,
640 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
641 int indexAccel = -1) {
642 wxRect rv;
643 self->DrawLabel(text, image, rect, alignment, indexAccel, &rv);
644 return rv;
645 }
646 }
647
648 void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
649 void DrawLines(int PCOUNT, wxPoint* points, wxCoord xoffset=0, wxCoord yoffset=0);
650 void DrawPolygon(int PCOUNT, wxPoint* points, wxCoord xoffset=0, wxCoord yoffset=0,
651 int fill_style=wxODDEVEN_RULE);
652 void DrawPoint(wxCoord x, wxCoord y);
653 void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
654 %name(DrawRectangleRect)void DrawRectangle(const wxRect& rect);
655 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
656 void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, wxCoord radius=20);
657 void DrawSpline(int PCOUNT, wxPoint* points);
658 void DrawText(const wxString& text, wxCoord x, wxCoord y);
659 void EndDoc();
660 void EndDrawing();
661 void EndPage();
662 bool FloodFill(wxCoord x, wxCoord y, const wxColour& colour, int style=wxFLOOD_SURFACE);
663 wxBrush GetBackground();
664 wxBrush GetBrush();
665 wxCoord GetCharHeight();
666 wxCoord GetCharWidth();
667 void GetClippingBox(wxCoord *OUTPUT, wxCoord *OUTPUT,
668 wxCoord *OUTPUT, wxCoord *OUTPUT);
669 wxFont GetFont();
670 int GetLogicalFunction();
671 void GetLogicalScale(double *OUTPUT, double *OUTPUT);
672 int GetMapMode();
673 bool GetOptimization();
674 wxPen GetPen();
675 %addmethods {
676 %new wxColour* GetPixel(wxCoord x, wxCoord y) {
677 wxColour* wc = new wxColour();
678 self->GetPixel(x, y, wc);
679 return wc;
680 }
681 }
682 %name(GetSizeTuple)void GetSize(int* OUTPUT, int* OUTPUT);
683 wxSize GetSize();
684 wxSize GetSizeMM();
685 wxColour GetTextBackground();
686 void GetTextExtent(const wxString& string, wxCoord *OUTPUT, wxCoord *OUTPUT);
687 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
688 wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord* OUTPUT,
689 const wxFont* font = NULL);
690 void GetMultiLineTextExtent(const wxString& text, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT,
691 wxFont *font = NULL);
692 wxColour GetTextForeground();
693 void GetUserScale(double *OUTPUT, double *OUTPUT);
694 wxCoord LogicalToDeviceX(wxCoord x);
695 wxCoord LogicalToDeviceXRel(wxCoord x);
696 wxCoord LogicalToDeviceY(wxCoord y);
697 wxCoord LogicalToDeviceYRel(wxCoord y);
698 wxCoord MaxX();
699 wxCoord MaxY();
700 wxCoord MinX();
701 wxCoord MinY();
702 bool Ok();
703 void SetDeviceOrigin(wxCoord x, wxCoord y);
704 void SetBackground(const wxBrush& brush);
705 void SetBackgroundMode(int mode);
706 void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
707 %name(SetClippingRegionAsRegion) void SetClippingRegion(const wxRegion& region);
708 %name(SetClippingRect) void SetClippingRegion(const wxRect& rect);
709 void SetPalette(const wxPalette& colourMap);
710 void SetBrush(const wxBrush& brush);
711 void SetFont(const wxFont& font);
712 void SetLogicalFunction(int function);
713 void SetLogicalScale(double x, double y);
714 void SetMapMode(int mode);
715 void SetOptimization(bool optimize);
716 void SetPen(const wxPen& pen);
717 void SetTextBackground(const wxColour& colour);
718 void SetTextForeground(const wxColour& colour);
719 void SetUserScale(double x_scale, double y_scale);
720 bool StartDoc(const wxString& message);
721 void StartPage();
722
723
724
725 void DrawBitmap(const wxBitmap& bitmap, wxCoord x, wxCoord y,
726 int useMask = FALSE);
727
728 bool CanDrawBitmap();
729 bool CanGetTextExtent();
730 int GetDepth();
731 wxSize GetPPI();
732
733 void GetLogicalOrigin(int *OUTPUT, int *OUTPUT);
734 void SetLogicalOrigin(int x, int y);
735 void GetDeviceOrigin(int *OUTPUT, int *OUTPUT);
736 void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
737
738 void CalcBoundingBox(int x, int y);
739 void ResetBoundingBox();
740
741 %addmethods {
742 void GetBoundingBox(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
743 // See below for implementation
744 }
745
746 %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
747
748 #ifdef __WXMSW__
749 long GetHDC();
750 #endif
751
752
753 %addmethods { // See drawlist.cpp for impplementaion of these...
754
755 PyObject* _DrawPointList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
756 {
757 return wxPyDrawXXXList(*self, wxPyDrawXXXPoint, pyCoords, pyPens, pyBrushes);
758 }
759
760 PyObject* _DrawLineList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
761 {
762 return wxPyDrawXXXList(*self, wxPyDrawXXXLine, pyCoords, pyPens, pyBrushes);
763 }
764
765 PyObject* _DrawRectangleList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
766 {
767 return wxPyDrawXXXList(*self, wxPyDrawXXXRectangle, pyCoords, pyPens, pyBrushes);
768 }
769
770 PyObject* _DrawEllipseList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
771 {
772 return wxPyDrawXXXList(*self, wxPyDrawXXXEllipse, pyCoords, pyPens, pyBrushes);
773 }
774
775 PyObject* _DrawPolygonList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
776 {
777 return wxPyDrawXXXList(*self, wxPyDrawXXXPolygon, pyCoords, pyPens, pyBrushes);
778 }
779
780 PyObject* _DrawTextList(PyObject* textList, PyObject* pyPoints,
781 PyObject* foregroundList, PyObject* backgroundList) {
782 return wxPyDrawTextList(*self, textList, pyPoints, foregroundList, backgroundList);
783 }
784 }
785
786 %pragma(python) addtoclass = "
787 def DrawPointList(self, points, pens=None):
788 if pens is None:
789 pens = []
790 elif isinstance(pens, wxPenPtr):
791 pens = [pens]
792 elif len(pens) != len(points):
793 raise ValueError('points and pens must have same length')
794 return self._DrawPointList(points, pens, [])
795
796
797 def DrawLineList(self, lines, pens=None):
798 if pens is None:
799 pens = []
800 elif isinstance(pens, wxPenPtr):
801 pens = [pens]
802 elif len(pens) != len(lines):
803 raise ValueError('lines and pens must have same length')
804 return self._DrawLineList(lines, pens, [])
805
806
807 def DrawRectangleList(self, rectangles, pens=None, brushes=None):
808 if pens is None:
809 pens = []
810 elif isinstance(pens, wxPenPtr):
811 pens = [pens]
812 elif len(pens) != len(rectangles):
813 raise ValueError('rectangles and pens must have same length')
814 if brushes is None:
815 brushes = []
816 elif isinstance(brushes, wxBrushPtr):
817 brushes = [brushes]
818 elif len(brushes) != len(rectangles):
819 raise ValueError('rectangles and brushes must have same length')
820 return self._DrawRectangleList(rectangles, pens, brushes)
821
822
823 def DrawEllipseList(self, ellipses, pens=None, brushes=None):
824 if pens is None:
825 pens = []
826 elif isinstance(pens, wxPenPtr):
827 pens = [pens]
828 elif len(pens) != len(ellipses):
829 raise ValueError('ellipses and pens must have same length')
830 if brushes is None:
831 brushes = []
832 elif isinstance(brushes, wxBrushPtr):
833 brushes = [brushes]
834 elif len(brushes) != len(ellipses):
835 raise ValueError('ellipses and brushes must have same length')
836 return self._DrawEllipseList(ellipses, pens, brushes)
837
838
839 def DrawPolygonList(self, polygons, pens=None, brushes=None):
840 ## Note: This does not currently support fill style or offset
841 ## you can always use the non-List version if need be.
842 ## I really would like to support fill-style, however,
843 ## but wxODDEVEN_RULE does not appear to be defined at the Python level
844 ## [It's in wx.py... --Robin]
845 if pens is None:
846 pens = []
847 elif isinstance(pens, wxPenPtr):
848 pens = [pens]
849 elif len(pens) != len(polygons):
850 raise ValueError('polygons and pens must have same length')
851 if brushes is None:
852 brushes = []
853 elif isinstance(brushes, wxBrushPtr):
854 brushes = [brushes]
855 elif len(brushes) != len(polygons):
856 raise ValueError('polygons and brushes must have same length')
857 return self._DrawPolygonList(polygons, pens, brushes)
858
859
860 def DrawTextList(self, textList, coords, foregrounds = None, backgrounds = None, fonts = None):
861 ## NOTE: this does not currently support changing the font
862 ## Make sure you set Background mode to wxSolid (DC.SetBackgroundMode)
863 ## If you want backgounds to do anything.
864 if type(textList) == type(''):
865 textList = [textList]
866 elif len(textList) != len(coords):
867 raise ValueError('textlist and coords must have same length')
868 if foregrounds is None:
869 foregrounds = []
870 elif isinstance(foregrounds, wxColourPtr):
871 foregrounds = [foregrounds]
872 elif len(foregrounds) != len(coords):
873 raise ValueError('foregrounds and coords must have same length')
874 if backgrounds is None:
875 backgrounds = []
876 elif isinstance(backgrounds, wxColourPtr):
877 backgrounds = [backgrounds]
878 elif len(backgrounds) != len(coords):
879 raise ValueError('backgrounds and coords must have same length')
880 return self._DrawTextList(textList, coords, foregrounds, backgrounds)
881 "
882
883
884 };
885
886
887
888 %{
889 static void wxDC_GetBoundingBox(wxDC* dc, int* x1, int* y1, int* x2, int* y2) {
890 *x1 = dc->MinX();
891 *y1 = dc->MinY();
892 *x2 = dc->MaxX();
893 *y2 = dc->MaxY();
894 }
895 %}
896
897 //----------------------------------------------------------------------
898
899 class wxMemoryDC : public wxDC {
900 public:
901 wxMemoryDC();
902
903 void SelectObject(const wxBitmap& bitmap);
904 }
905
906 %new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC);
907 %{ // Alternate 'constructor'
908 wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) {
909 return new wxMemoryDC(oldDC);
910 }
911 %}
912
913
914 //---------------------------------------------------------------------------
915
916 class wxBufferedDC : public wxMemoryDC {
917 public:
918 // Construct a wxBufferedDC using a user supplied buffer.
919 wxBufferedDC( wxDC *dc, const wxBitmap &buffer );
920
921 // Construct a wxBufferedDC with an internal buffer of 'area'
922 // (where area is usually something like the size of the window
923 // being buffered)
924 %name(wxBufferedDCInternalBuffer)wxBufferedDC( wxDC *dc, const wxSize &area );
925
926 // Blits the buffer to the dc, and detaches the dc from
927 // the buffer. Usually called in the dtor or by the dtor
928 // of derived classes if the BufferedDC must blit before
929 // the derived class (which may own the dc it's blitting
930 // to) is destroyed.
931 void UnMask();
932
933
934 %pragma(python) addtomethod =
935 "__init__:self._dc = _args[0] # save a ref so the other dc won't be deleted before self"
936 %pragma(python) addtomethod =
937 "wxBufferedDCInternalBuffer:val._dc = _args[0] # save a ref so the other dc won't be deleted before self"
938 };
939
940
941 class wxBufferedPaintDC : public wxBufferedDC
942 {
943 public:
944 wxBufferedPaintDC( wxWindow *window, const wxBitmap &buffer = wxNullBitmap );
945 };
946
947 //---------------------------------------------------------------------------
948
949 class wxScreenDC : public wxDC {
950 public:
951 wxScreenDC();
952
953 %name(StartDrawingOnTopWin) bool StartDrawingOnTop(wxWindow* window);
954 bool StartDrawingOnTop(wxRect* rect = NULL);
955 bool EndDrawingOnTop();
956 };
957
958 //---------------------------------------------------------------------------
959
960 class wxClientDC : public wxDC {
961 public:
962 wxClientDC(wxWindow* win);
963 };
964
965 //---------------------------------------------------------------------------
966
967 class wxPaintDC : public wxDC {
968 public:
969 wxPaintDC(wxWindow* win);
970 };
971
972 //---------------------------------------------------------------------------
973
974 class wxWindowDC : public wxDC {
975 public:
976 wxWindowDC(wxWindow* win);
977 };
978
979 //---------------------------------------------------------------------------
980
981
982 #ifdef __WXMSW__
983
984 %{
985 #include <wx/metafile.h>
986 %}
987
988 class wxMetaFile : public wxObject {
989 public:
990 wxMetaFile(const wxString& filename = wxPyEmptyString);
991 ~wxMetaFile();
992
993 bool Ok();
994 bool SetClipboard(int width = 0, int height = 0);
995
996 wxSize GetSize();
997 int GetWidth();
998 int GetHeight();
999
1000 const wxString& GetFileName() const { return m_filename; }
1001
1002 %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
1003 };
1004
1005 // bool wxMakeMetaFilePlaceable(const wxString& filename,
1006 // int minX, int minY, int maxX, int maxY, float scale=1.0);
1007
1008
1009 class wxMetaFileDC : public wxDC {
1010 public:
1011 wxMetaFileDC(const wxString& filename = wxPyEmptyString,
1012 int width = 0, int height = 0,
1013 const wxString& description = wxPyEmptyString);
1014 wxMetaFile* Close();
1015 };
1016
1017 #endif
1018
1019 //---------------------------------------------------------------------------
1020
1021 class wxPalette : public wxGDIObject {
1022 public:
1023 wxPalette(int LCOUNT, byte* choices, byte* choices, byte* choices);
1024 ~wxPalette();
1025
1026 int GetPixel(byte red, byte green, byte blue);
1027 bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT);
1028 bool Ok();
1029
1030 %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
1031 };
1032
1033 //---------------------------------------------------------------------------
1034
1035 enum {
1036 wxIMAGELIST_DRAW_NORMAL ,
1037 wxIMAGELIST_DRAW_TRANSPARENT,
1038 wxIMAGELIST_DRAW_SELECTED,
1039 wxIMAGELIST_DRAW_FOCUSED,
1040 wxIMAGE_LIST_NORMAL,
1041 wxIMAGE_LIST_SMALL,
1042 wxIMAGE_LIST_STATE
1043 };
1044
1045 class wxImageList : public wxObject {
1046 public:
1047 wxImageList(int width, int height, int mask=TRUE, int initialCount=1);
1048 ~wxImageList();
1049
1050 int Add(const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
1051 %name(AddWithColourMask)int Add(const wxBitmap& bitmap, const wxColour& maskColour);
1052 %name(AddIcon)int Add(const wxIcon& icon);
1053 #ifdef __WXMSW__
1054 bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
1055 #else
1056 // %name(ReplaceIcon)bool Replace(int index, const wxIcon& icon);
1057 // int Add(const wxBitmap& bitmap);
1058 bool Replace(int index, const wxBitmap& bitmap);
1059 #endif
1060
1061 bool Draw(int index, wxDC& dc, int x, int x, int flags = wxIMAGELIST_DRAW_NORMAL,
1062 const bool solidBackground = FALSE);
1063
1064 int GetImageCount();
1065 bool Remove(int index);
1066 bool RemoveAll();
1067 void GetSize(int index, int& OUTPUT, int& OUTPUT);
1068 };
1069
1070
1071 //---------------------------------------------------------------------------
1072 // Regions, etc.
1073
1074 enum wxRegionContain {
1075 wxOutRegion, wxPartRegion, wxInRegion
1076 };
1077
1078
1079 class wxRegion : public wxGDIObject {
1080 public:
1081 wxRegion(wxCoord x=0, wxCoord y=0, wxCoord width=0, wxCoord height=0);
1082 #ifndef __WXMAC__
1083 %name(wxRegionFromPoints)wxRegion(int PCOUNT, wxPoint* points, int fillStyle = wxWINDING_RULE);
1084 #endif
1085 %name(wxRegionFromBitmap)wxRegion(const wxBitmap& bmp,
1086 const wxColour& transColour = wxNullColour,
1087 int tolerance = 0);
1088 ~wxRegion();
1089
1090
1091 void Clear();
1092 #ifndef __WXMAC__
1093 bool Offset(wxCoord x, wxCoord y);
1094 #endif
1095
1096 wxRegionContain Contains(wxCoord x, wxCoord y);
1097 %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt);
1098 %name(ContainsRect)wxRegionContain Contains(const wxRect& rect);
1099 %name(ContainsRectDim)wxRegionContain Contains(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
1100
1101 wxRect GetBox();
1102
1103 bool Intersect(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
1104 %name(IntersectRect)bool Intersect(const wxRect& rect);
1105 %name(IntersectRegion)bool Intersect(const wxRegion& region);
1106
1107 bool IsEmpty();
1108
1109 bool Union(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
1110 %name(UnionRect)bool Union(const wxRect& rect);
1111 %name(UnionRegion)bool Union(const wxRegion& region);
1112
1113 bool Subtract(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
1114 %name(SubtractRect)bool Subtract(const wxRect& rect);
1115 %name(SubtractRegion)bool Subtract(const wxRegion& region);
1116
1117 bool Xor(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
1118 %name(XorRect)bool Xor(const wxRect& rect);
1119 %name(XorRegion)bool Xor(const wxRegion& region);
1120
1121 // Convert the region to a B&W bitmap with the white pixels being inside
1122 // the region.
1123 wxBitmap ConvertToBitmap();
1124
1125 // Use the non-transparent pixels of a wxBitmap for the region to combine
1126 // with this region. If the bitmap has a mask then it will be used,
1127 // otherwise the colour to be treated as transparent may be specified,
1128 // along with an optional tolerance value.
1129 %name(UnionBitmap)bool Union(const wxBitmap& bmp,
1130 const wxColour& transColour = wxNullColour,
1131 int tolerance = 0);
1132 };
1133
1134
1135
1136 class wxRegionIterator : public wxObject {
1137 public:
1138 wxRegionIterator(const wxRegion& region);
1139 ~wxRegionIterator();
1140
1141 wxCoord GetX();
1142 wxCoord GetY();
1143 wxCoord GetW();
1144 wxCoord GetWidth();
1145 wxCoord GetH();
1146 wxCoord GetHeight();
1147 wxRect GetRect();
1148 bool HaveRects();
1149 void Reset();
1150
1151 %addmethods {
1152 void Next() {
1153 (*self) ++;
1154 }
1155 };
1156 };
1157
1158
1159 //---------------------------------------------------------------------------
1160
1161
1162 %readonly
1163 %{
1164 #if 0
1165 %}
1166
1167 extern wxFont *wxNORMAL_FONT;
1168 extern wxFont *wxSMALL_FONT;
1169 extern wxFont *wxITALIC_FONT;
1170 extern wxFont *wxSWISS_FONT;
1171
1172 extern wxPen *wxRED_PEN;
1173 extern wxPen *wxCYAN_PEN;
1174 extern wxPen *wxGREEN_PEN;
1175 extern wxPen *wxBLACK_PEN;
1176 extern wxPen *wxWHITE_PEN;
1177 extern wxPen *wxTRANSPARENT_PEN;
1178 extern wxPen *wxBLACK_DASHED_PEN;
1179 extern wxPen *wxGREY_PEN;
1180 extern wxPen *wxMEDIUM_GREY_PEN;
1181 extern wxPen *wxLIGHT_GREY_PEN;
1182
1183 extern wxBrush *wxBLUE_BRUSH;
1184 extern wxBrush *wxGREEN_BRUSH;
1185 extern wxBrush *wxWHITE_BRUSH;
1186 extern wxBrush *wxBLACK_BRUSH;
1187 extern wxBrush *wxTRANSPARENT_BRUSH;
1188 extern wxBrush *wxCYAN_BRUSH;
1189 extern wxBrush *wxRED_BRUSH;
1190 extern wxBrush *wxGREY_BRUSH;
1191 extern wxBrush *wxMEDIUM_GREY_BRUSH;
1192 extern wxBrush *wxLIGHT_GREY_BRUSH;
1193
1194 extern wxColour *wxBLACK;
1195 extern wxColour *wxWHITE;
1196 extern wxColour *wxRED;
1197 extern wxColour *wxBLUE;
1198 extern wxColour *wxGREEN;
1199 extern wxColour *wxCYAN;
1200 extern wxColour *wxLIGHT_GREY;
1201
1202 extern wxCursor *wxSTANDARD_CURSOR;
1203 extern wxCursor *wxHOURGLASS_CURSOR;
1204 extern wxCursor *wxCROSS_CURSOR;
1205
1206
1207 extern wxBitmap wxNullBitmap;
1208 extern wxIcon wxNullIcon;
1209 extern wxCursor wxNullCursor;
1210 extern wxPen wxNullPen;
1211 extern wxBrush wxNullBrush;
1212 extern wxPalette wxNullPalette;
1213 extern wxFont wxNullFont;
1214 extern wxColour wxNullColour;
1215
1216
1217 extern wxFontList* wxTheFontList;
1218 extern wxPenList* wxThePenList;
1219 extern wxBrushList* wxTheBrushList;
1220 extern wxColourDatabase* wxTheColourDatabase;
1221
1222
1223 %readwrite
1224 %{
1225 #endif
1226 %}
1227
1228 //---------------------------------------------------------------------------
1229 //---------------------------------------------------------------------------
1230