]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/gdi.i
Added missing header files
[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 wxColour *FindColourNoAdd(const wxString& colour) const;
437 wxString FindName(const wxColour& colour) const;
438
439 %addmethods {
440 void AddColour(const wxString& name, wxColour* colour) {
441 // make a copy since the python one will be GC'd
442 wxColour* c = new wxColour(*colour);
443 self->AddColour(name, c);
444 }
445
446 void Append(const wxString& name, int red, int green, int blue) {
447 wxColour* c = new wxColour(red, green, blue);
448 self->AddColour(name, c);
449 }
450 }
451 };
452
453
454 //----------------------------------------------------------------------
455
456 class wxPen : public wxGDIObject {
457 public:
458 wxPen(wxColour& colour, int width=1, int style=wxSOLID);
459 ~wxPen();
460
461 int GetCap();
462 wxColour GetColour();
463
464 int GetJoin();
465 int GetStyle();
466 int GetWidth();
467 bool Ok();
468 void SetCap(int cap_style);
469 void SetColour(wxColour& colour);
470 void SetJoin(int join_style);
471 void SetStyle(int style);
472 void SetWidth(int width);
473
474
475 void SetDashes(int LCOUNT, wxDash* choices);
476 //int GetDashes(wxDash **dashes);
477 %addmethods {
478 PyObject* GetDashes() {
479 wxDash* dashes;
480 int count = self->GetDashes(&dashes);
481 wxPyBeginBlockThreads();
482 PyObject* retval = PyList_New(0);
483 for (int x=0; x<count; x++)
484 PyList_Append(retval, PyInt_FromLong(dashes[x]));
485 wxPyEndBlockThreads();
486 return retval;
487 }
488 }
489
490 #ifdef __WXMSW__
491 wxBitmap* GetStipple();
492 void SetStipple(wxBitmap& stipple);
493 #endif
494
495 %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
496 };
497
498
499
500
501 // The list of ints for the dashes needs to exist for the life of the pen
502 // so we make it part of the class to save it. wxPyPen is aliased to wxPen
503 // in _extras.py
504
505 %{
506 class wxPyPen : public wxPen {
507 public:
508 wxPyPen(wxColour& colour, int width=1, int style=wxSOLID)
509 : wxPen(colour, width, style)
510 { m_dash = NULL; }
511 ~wxPyPen() {
512 if (m_dash)
513 delete [] m_dash;
514 }
515
516 void SetDashes(int nb_dashes, const wxDash *dash) {
517 if (m_dash)
518 delete [] m_dash;
519 m_dash = new wxDash[nb_dashes];
520 for (int i=0; i<nb_dashes; i++) {
521 m_dash[i] = dash[i];
522 }
523 wxPen::SetDashes(nb_dashes, m_dash);
524 }
525
526 private:
527 wxDash* m_dash;
528 };
529 %}
530
531
532 class wxPyPen : public wxPen {
533 public:
534 wxPyPen(wxColour& colour, int width=1, int style=wxSOLID);
535 ~wxPyPen();
536
537 void SetDashes(int LCOUNT, wxDash* choices);
538 };
539
540
541
542
543 class wxPenList : public wxObject {
544 public:
545
546 void AddPen(wxPen* pen);
547 wxPen* FindOrCreatePen(const wxColour& colour, int width, int style);
548 void RemovePen(wxPen* pen);
549
550 int GetCount();
551 };
552
553
554
555 //----------------------------------------------------------------------
556
557 class wxBrush : public wxGDIObject {
558 public:
559 wxBrush(const wxColour& colour, int style=wxSOLID);
560 ~wxBrush();
561
562 wxColour GetColour();
563 wxBitmap * GetStipple();
564 int GetStyle();
565 bool Ok();
566 void SetColour(wxColour &colour);
567 void SetStipple(wxBitmap& bitmap);
568 void SetStyle(int style);
569
570 #ifdef __WXMAC__
571 short GetMacTheme();
572 void SetMacTheme(short macThemeBrush);
573 #endif
574
575 %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
576 };
577
578
579 class wxBrushList : public wxObject {
580 public:
581
582 void AddBrush(wxBrush *brush);
583 wxBrush * FindOrCreateBrush(const wxColour& colour, int style);
584 void RemoveBrush(wxBrush *brush);
585
586 int GetCount();
587 };
588
589 //----------------------------------------------------------------------
590
591
592 class wxDC : public wxObject {
593 public:
594 // wxDC(); **** abstract base class, can't instantiate.
595 ~wxDC();
596
597 void BeginDrawing();
598
599 // %name(BlitXY)
600 bool Blit(wxCoord xdest, wxCoord ydest,
601 wxCoord width, wxCoord height,
602 wxDC *source, wxCoord xsrc, wxCoord ysrc,
603 int logicalFunc = wxCOPY, int useMask = FALSE);
604 // bool Blit(const wxPoint& destPt, const wxSize& sz,
605 // wxDC *source, const wxPoint& srcPt,
606 // int logicalFunc = wxCOPY, int useMask = FALSE);
607
608 void Clear();
609 void CrossHair(wxCoord x, wxCoord y);
610 void DestroyClippingRegion();
611 wxCoord DeviceToLogicalX(wxCoord x);
612 wxCoord DeviceToLogicalXRel(wxCoord x);
613 wxCoord DeviceToLogicalY(wxCoord y);
614 wxCoord DeviceToLogicalYRel(wxCoord y);
615 void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc);
616 void DrawCircle(wxCoord x, wxCoord y, wxCoord radius);
617 void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
618 void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord width, wxCoord height, wxCoord start, wxCoord end);
619 void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
620
621 void DrawLabel(const wxString& text, const wxRect& rect,
622 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
623 int indexAccel = -1);
624
625 %addmethods {
626 wxRect DrawImageLabel(const wxString& text,
627 const wxBitmap& image,
628 const wxRect& rect,
629 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
630 int indexAccel = -1) {
631 wxRect rv;
632 self->DrawLabel(text, image, rect, alignment, indexAccel, &rv);
633 return rv;
634 }
635 }
636
637 void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
638 void DrawLines(int PCOUNT, wxPoint* points, wxCoord xoffset=0, wxCoord yoffset=0);
639 void DrawPolygon(int PCOUNT, wxPoint* points, wxCoord xoffset=0, wxCoord yoffset=0,
640 int fill_style=wxODDEVEN_RULE);
641 void DrawPoint(wxCoord x, wxCoord y);
642 void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
643 %name(DrawRectangleRect)void DrawRectangle(const wxRect& rect);
644 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
645 void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, wxCoord radius=20);
646 void DrawSpline(int PCOUNT, wxPoint* points);
647 void DrawText(const wxString& text, wxCoord x, wxCoord y);
648 void EndDoc();
649 void EndDrawing();
650 void EndPage();
651 bool FloodFill(wxCoord x, wxCoord y, const wxColour& colour, int style=wxFLOOD_SURFACE);
652 wxBrush GetBackground();
653 wxBrush GetBrush();
654 wxCoord GetCharHeight();
655 wxCoord GetCharWidth();
656 void GetClippingBox(wxCoord *OUTPUT, wxCoord *OUTPUT,
657 wxCoord *OUTPUT, wxCoord *OUTPUT);
658 wxFont GetFont();
659 int GetLogicalFunction();
660 void GetLogicalScale(double *OUTPUT, double *OUTPUT);
661 int GetMapMode();
662 bool GetOptimization();
663 wxPen GetPen();
664 %addmethods {
665 %new wxColour* GetPixel(wxCoord x, wxCoord y) {
666 wxColour* wc = new wxColour();
667 self->GetPixel(x, y, wc);
668 return wc;
669 }
670 }
671 %name(GetSizeTuple)void GetSize(int* OUTPUT, int* OUTPUT);
672 wxSize GetSize();
673 wxSize GetSizeMM();
674 wxColour GetTextBackground();
675 void GetTextExtent(const wxString& string, wxCoord *OUTPUT, wxCoord *OUTPUT);
676 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
677 wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord* OUTPUT,
678 const wxFont* font = NULL);
679 void GetMultiLineTextExtent(const wxString& text, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT,
680 wxFont *font = NULL);
681 wxColour GetTextForeground();
682 void GetUserScale(double *OUTPUT, double *OUTPUT);
683 wxCoord LogicalToDeviceX(wxCoord x);
684 wxCoord LogicalToDeviceXRel(wxCoord x);
685 wxCoord LogicalToDeviceY(wxCoord y);
686 wxCoord LogicalToDeviceYRel(wxCoord y);
687 wxCoord MaxX();
688 wxCoord MaxY();
689 wxCoord MinX();
690 wxCoord MinY();
691 bool Ok();
692 void SetDeviceOrigin(wxCoord x, wxCoord y);
693 void SetBackground(const wxBrush& brush);
694 void SetBackgroundMode(int mode);
695 void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
696 %name(SetClippingRegionAsRegion) void SetClippingRegion(const wxRegion& region);
697 %name(SetClippingRect) void SetClippingRegion(const wxRect& rect);
698 void SetPalette(const wxPalette& colourMap);
699 void SetBrush(const wxBrush& brush);
700 void SetFont(const wxFont& font);
701 void SetLogicalFunction(int function);
702 void SetLogicalScale(double x, double y);
703 void SetMapMode(int mode);
704 void SetOptimization(bool optimize);
705 void SetPen(const wxPen& pen);
706 void SetTextBackground(const wxColour& colour);
707 void SetTextForeground(const wxColour& colour);
708 void SetUserScale(double x_scale, double y_scale);
709 bool StartDoc(const wxString& message);
710 void StartPage();
711
712
713
714 void DrawBitmap(const wxBitmap& bitmap, wxCoord x, wxCoord y,
715 int useMask = FALSE);
716
717 bool CanDrawBitmap();
718 bool CanGetTextExtent();
719 int GetDepth();
720 wxSize GetPPI();
721
722 void GetLogicalOrigin(int *OUTPUT, int *OUTPUT);
723 void SetLogicalOrigin(int x, int y);
724 void GetDeviceOrigin(int *OUTPUT, int *OUTPUT);
725 void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
726
727 void CalcBoundingBox(int x, int y);
728 void ResetBoundingBox();
729
730 %addmethods {
731 void GetBoundingBox(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
732 // See below for implementation
733 }
734
735 %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
736
737 #ifdef __WXMSW__
738 long GetHDC();
739 #endif
740
741
742 %addmethods { // See drawlist.cpp for impplementaion of these...
743
744 PyObject* _DrawPointList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
745 {
746 return wxPyDrawXXXList(*self, wxPyDrawXXXPoint, pyCoords, pyPens, pyBrushes);
747 }
748
749 PyObject* _DrawLineList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
750 {
751 return wxPyDrawXXXList(*self, wxPyDrawXXXLine, pyCoords, pyPens, pyBrushes);
752 }
753
754 PyObject* _DrawRectangleList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
755 {
756 return wxPyDrawXXXList(*self, wxPyDrawXXXRectangle, pyCoords, pyPens, pyBrushes);
757 }
758
759 PyObject* _DrawEllipseList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
760 {
761 return wxPyDrawXXXList(*self, wxPyDrawXXXEllipse, pyCoords, pyPens, pyBrushes);
762 }
763
764 PyObject* _DrawPolygonList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
765 {
766 return wxPyDrawXXXList(*self, wxPyDrawXXXPolygon, pyCoords, pyPens, pyBrushes);
767 }
768
769 PyObject* _DrawTextList(PyObject* textList, PyObject* pyPoints,
770 PyObject* foregroundList, PyObject* backgroundList) {
771 return wxPyDrawTextList(*self, textList, pyPoints, foregroundList, backgroundList);
772 }
773 }
774
775 %pragma(python) addtoclass = "
776 def DrawPointList(self, points, pens=None):
777 if pens is None:
778 pens = []
779 elif isinstance(pens, wxPenPtr):
780 pens = [pens]
781 elif len(pens) != len(points):
782 raise ValueError('points and pens must have same length')
783 return self._DrawPointList(points, pens, [])
784
785
786 def DrawLineList(self, lines, pens=None):
787 if pens is None:
788 pens = []
789 elif isinstance(pens, wxPenPtr):
790 pens = [pens]
791 elif len(pens) != len(lines):
792 raise ValueError('lines and pens must have same length')
793 return self._DrawLineList(lines, pens, [])
794
795
796 def DrawRectangleList(self, rectangles, pens=None, brushes=None):
797 if pens is None:
798 pens = []
799 elif isinstance(pens, wxPenPtr):
800 pens = [pens]
801 elif len(pens) != len(rectangles):
802 raise ValueError('rectangles and pens must have same length')
803 if brushes is None:
804 brushes = []
805 elif isinstance(brushes, wxBrushPtr):
806 brushes = [brushes]
807 elif len(brushes) != len(rectangles):
808 raise ValueError('rectangles and brushes must have same length')
809 return self._DrawRectangleList(rectangles, pens, brushes)
810
811
812 def DrawEllipseList(self, ellipses, pens=None, brushes=None):
813 if pens is None:
814 pens = []
815 elif isinstance(pens, wxPenPtr):
816 pens = [pens]
817 elif len(pens) != len(ellipses):
818 raise ValueError('ellipses and pens must have same length')
819 if brushes is None:
820 brushes = []
821 elif isinstance(brushes, wxBrushPtr):
822 brushes = [brushes]
823 elif len(brushes) != len(ellipses):
824 raise ValueError('ellipses and brushes must have same length')
825 return self._DrawEllipseList(ellipses, pens, brushes)
826
827
828 def DrawPolygonList(self, polygons, pens=None, brushes=None):
829 ## Note: This does not currently support fill style or offset
830 ## you can always use the non-List version if need be.
831 ## I really would like to support fill-style, however,
832 ## but wxODDEVEN_RULE does not appear to be defined at the Python level
833 ## [It's in wx.py... --Robin]
834 if pens is None:
835 pens = []
836 elif isinstance(pens, wxPenPtr):
837 pens = [pens]
838 elif len(pens) != len(polygons):
839 raise ValueError('polygons and pens must have same length')
840 if brushes is None:
841 brushes = []
842 elif isinstance(brushes, wxBrushPtr):
843 brushes = [brushes]
844 elif len(brushes) != len(polygons):
845 raise ValueError('polygons and brushes must have same length')
846 return self._DrawPolygonList(polygons, pens, brushes)
847
848
849 def DrawTextList(self, textList, coords, foregrounds = None, backgrounds = None, fonts = None):
850 ## NOTE: this does not currently support changing the font
851 ## Make sure you set Background mode to wxSolid (DC.SetBackgroundMode)
852 ## If you want backgounds to do anything.
853 if type(textList) == type(''):
854 textList = [textList]
855 elif len(textList) != len(coords):
856 raise ValueError('textlist and coords must have same length')
857 if foregrounds is None:
858 foregrounds = []
859 elif isinstance(foregrounds, wxColourPtr):
860 foregrounds = [foregrounds]
861 elif len(foregrounds) != len(coords):
862 raise ValueError('foregrounds and coords must have same length')
863 if backgrounds is None:
864 backgrounds = []
865 elif isinstance(backgrounds, wxColourPtr):
866 backgrounds = [backgrounds]
867 elif len(backgrounds) != len(coords):
868 raise ValueError('backgrounds and coords must have same length')
869 return self._DrawTextList(textList, coords, foregrounds, backgrounds)
870 "
871
872
873 };
874
875
876
877 %{
878 static void wxDC_GetBoundingBox(wxDC* dc, int* x1, int* y1, int* x2, int* y2) {
879 *x1 = dc->MinX();
880 *y1 = dc->MinY();
881 *x2 = dc->MaxX();
882 *y2 = dc->MaxY();
883 }
884 %}
885
886 //----------------------------------------------------------------------
887
888 class wxMemoryDC : public wxDC {
889 public:
890 wxMemoryDC();
891
892 void SelectObject(const wxBitmap& bitmap);
893 }
894
895 %new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC);
896 %{ // Alternate 'constructor'
897 wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) {
898 return new wxMemoryDC(oldDC);
899 }
900 %}
901
902
903 //---------------------------------------------------------------------------
904
905 class wxBufferedDC : public wxMemoryDC {
906 public:
907 // Construct a wxBufferedDC using a user supplied buffer.
908 wxBufferedDC( wxDC *dc, const wxBitmap &buffer );
909
910 // Construct a wxBufferedDC with an internal buffer of 'area'
911 // (where area is usually something like the size of the window
912 // being buffered)
913 %name(wxBufferedDCInternalBuffer)wxBufferedDC( wxDC *dc, const wxSize &area );
914
915 // Blits the buffer to the dc, and detaches the dc from
916 // the buffer. Usually called in the dtor or by the dtor
917 // of derived classes if the BufferedDC must blit before
918 // the derived class (which may own the dc it's blitting
919 // to) is destroyed.
920 void UnMask();
921
922
923 %pragma(python) addtomethod =
924 "__init__:self._dc = _args[0] # save a ref so the other dc won't be deleted before self"
925 %pragma(python) addtomethod =
926 "wxBufferedDCInternalBuffer:val._dc = _args[0] # save a ref so the other dc won't be deleted before self"
927 };
928
929
930 class wxBufferedPaintDC : public wxBufferedDC
931 {
932 public:
933 wxBufferedPaintDC( wxWindow *window, const wxBitmap &buffer = wxNullBitmap );
934 };
935
936 //---------------------------------------------------------------------------
937
938 class wxScreenDC : public wxDC {
939 public:
940 wxScreenDC();
941
942 %name(StartDrawingOnTopWin) bool StartDrawingOnTop(wxWindow* window);
943 bool StartDrawingOnTop(wxRect* rect = NULL);
944 bool EndDrawingOnTop();
945 };
946
947 //---------------------------------------------------------------------------
948
949 class wxClientDC : public wxDC {
950 public:
951 wxClientDC(wxWindow* win);
952 };
953
954 //---------------------------------------------------------------------------
955
956 class wxPaintDC : public wxDC {
957 public:
958 wxPaintDC(wxWindow* win);
959 };
960
961 //---------------------------------------------------------------------------
962
963 class wxWindowDC : public wxDC {
964 public:
965 wxWindowDC(wxWindow* win);
966 };
967
968 //---------------------------------------------------------------------------
969
970
971 #ifdef __WXMSW__
972
973 %{
974 #include <wx/metafile.h>
975 %}
976
977 class wxMetaFile : public wxObject {
978 public:
979 wxMetaFile(const wxString& filename = wxPyEmptyString);
980 ~wxMetaFile();
981
982 bool Ok();
983 bool SetClipboard(int width = 0, int height = 0);
984
985 wxSize GetSize();
986 int GetWidth();
987 int GetHeight();
988
989 const wxString& GetFileName() const { return m_filename; }
990
991 %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
992 };
993
994 // bool wxMakeMetaFilePlaceable(const wxString& filename,
995 // int minX, int minY, int maxX, int maxY, float scale=1.0);
996
997
998 class wxMetaFileDC : public wxDC {
999 public:
1000 wxMetaFileDC(const wxString& filename = wxPyEmptyString,
1001 int width = 0, int height = 0,
1002 const wxString& description = wxPyEmptyString);
1003 wxMetaFile* Close();
1004 };
1005
1006 #endif
1007
1008 //---------------------------------------------------------------------------
1009
1010 class wxPalette : public wxGDIObject {
1011 public:
1012 wxPalette(int LCOUNT, byte* choices, byte* choices, byte* choices);
1013 ~wxPalette();
1014
1015 int GetPixel(byte red, byte green, byte blue);
1016 bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT);
1017 bool Ok();
1018
1019 %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
1020 };
1021
1022 //---------------------------------------------------------------------------
1023
1024 enum {
1025 wxIMAGELIST_DRAW_NORMAL ,
1026 wxIMAGELIST_DRAW_TRANSPARENT,
1027 wxIMAGELIST_DRAW_SELECTED,
1028 wxIMAGELIST_DRAW_FOCUSED,
1029 wxIMAGE_LIST_NORMAL,
1030 wxIMAGE_LIST_SMALL,
1031 wxIMAGE_LIST_STATE
1032 };
1033
1034 class wxImageList : public wxObject {
1035 public:
1036 wxImageList(int width, int height, int mask=TRUE, int initialCount=1);
1037 ~wxImageList();
1038
1039 int Add(const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
1040 %name(AddWithColourMask)int Add(const wxBitmap& bitmap, const wxColour& maskColour);
1041 %name(AddIcon)int Add(const wxIcon& icon);
1042 #ifdef __WXMSW__
1043 bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
1044 #else
1045 // %name(ReplaceIcon)bool Replace(int index, const wxIcon& icon);
1046 // int Add(const wxBitmap& bitmap);
1047 bool Replace(int index, const wxBitmap& bitmap);
1048 #endif
1049
1050 bool Draw(int index, wxDC& dc, int x, int x, int flags = wxIMAGELIST_DRAW_NORMAL,
1051 const bool solidBackground = FALSE);
1052
1053 int GetImageCount();
1054 bool Remove(int index);
1055 bool RemoveAll();
1056 void GetSize(int index, int& OUTPUT, int& OUTPUT);
1057 };
1058
1059
1060 //---------------------------------------------------------------------------
1061 // Regions, etc.
1062
1063 enum wxRegionContain {
1064 wxOutRegion, wxPartRegion, wxInRegion
1065 };
1066
1067
1068 class wxRegion : public wxGDIObject {
1069 public:
1070 wxRegion(wxCoord x=0, wxCoord y=0, wxCoord width=0, wxCoord height=0);
1071 #ifndef __WXMAC__
1072 %name(wxRegionFromPoints)wxRegion(int PCOUNT, wxPoint* points, int fillStyle = wxWINDING_RULE);
1073 #endif
1074 %name(wxRegionFromBitmap)wxRegion(const wxBitmap& bmp,
1075 const wxColour& transColour = wxNullColour,
1076 int tolerance = 0);
1077 ~wxRegion();
1078
1079
1080 void Clear();
1081 #ifndef __WXMAC__
1082 bool Offset(wxCoord x, wxCoord y);
1083 #endif
1084
1085 wxRegionContain Contains(wxCoord x, wxCoord y);
1086 %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt);
1087 %name(ContainsRect)wxRegionContain Contains(const wxRect& rect);
1088 %name(ContainsRectDim)wxRegionContain Contains(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
1089
1090 wxRect GetBox();
1091
1092 bool Intersect(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
1093 %name(IntersectRect)bool Intersect(const wxRect& rect);
1094 %name(IntersectRegion)bool Intersect(const wxRegion& region);
1095
1096 bool IsEmpty();
1097
1098 bool Union(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
1099 %name(UnionRect)bool Union(const wxRect& rect);
1100 %name(UnionRegion)bool Union(const wxRegion& region);
1101
1102 bool Subtract(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
1103 %name(SubtractRect)bool Subtract(const wxRect& rect);
1104 %name(SubtractRegion)bool Subtract(const wxRegion& region);
1105
1106 bool Xor(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
1107 %name(XorRect)bool Xor(const wxRect& rect);
1108 %name(XorRegion)bool Xor(const wxRegion& region);
1109
1110 // Convert the region to a B&W bitmap with the white pixels being inside
1111 // the region.
1112 wxBitmap ConvertToBitmap();
1113
1114 // Use the non-transparent pixels of a wxBitmap for the region to combine
1115 // with this region. If the bitmap has a mask then it will be used,
1116 // otherwise the colour to be treated as transparent may be specified,
1117 // along with an optional tolerance value.
1118 %name(UnionBitmap)bool Union(const wxBitmap& bmp,
1119 const wxColour& transColour = wxNullColour,
1120 int tolerance = 0);
1121 };
1122
1123
1124
1125 class wxRegionIterator : public wxObject {
1126 public:
1127 wxRegionIterator(const wxRegion& region);
1128 ~wxRegionIterator();
1129
1130 wxCoord GetX();
1131 wxCoord GetY();
1132 wxCoord GetW();
1133 wxCoord GetWidth();
1134 wxCoord GetH();
1135 wxCoord GetHeight();
1136 wxRect GetRect();
1137 bool HaveRects();
1138 void Reset();
1139
1140 %addmethods {
1141 void Next() {
1142 (*self) ++;
1143 }
1144 };
1145 };
1146
1147
1148 //---------------------------------------------------------------------------
1149
1150
1151 %readonly
1152 %{
1153 #if 0
1154 %}
1155
1156 // See also wxPy_ReinitStockObjects in helpers.cpp
1157
1158 extern wxFont *wxNORMAL_FONT;
1159 extern wxFont *wxSMALL_FONT;
1160 extern wxFont *wxITALIC_FONT;
1161 extern wxFont *wxSWISS_FONT;
1162
1163 extern wxPen *wxRED_PEN;
1164 extern wxPen *wxCYAN_PEN;
1165 extern wxPen *wxGREEN_PEN;
1166 extern wxPen *wxBLACK_PEN;
1167 extern wxPen *wxWHITE_PEN;
1168 extern wxPen *wxTRANSPARENT_PEN;
1169 extern wxPen *wxBLACK_DASHED_PEN;
1170 extern wxPen *wxGREY_PEN;
1171 extern wxPen *wxMEDIUM_GREY_PEN;
1172 extern wxPen *wxLIGHT_GREY_PEN;
1173
1174 extern wxBrush *wxBLUE_BRUSH;
1175 extern wxBrush *wxGREEN_BRUSH;
1176 extern wxBrush *wxWHITE_BRUSH;
1177 extern wxBrush *wxBLACK_BRUSH;
1178 extern wxBrush *wxTRANSPARENT_BRUSH;
1179 extern wxBrush *wxCYAN_BRUSH;
1180 extern wxBrush *wxRED_BRUSH;
1181 extern wxBrush *wxGREY_BRUSH;
1182 extern wxBrush *wxMEDIUM_GREY_BRUSH;
1183 extern wxBrush *wxLIGHT_GREY_BRUSH;
1184
1185 extern wxColour *wxBLACK;
1186 extern wxColour *wxWHITE;
1187 extern wxColour *wxRED;
1188 extern wxColour *wxBLUE;
1189 extern wxColour *wxGREEN;
1190 extern wxColour *wxCYAN;
1191 extern wxColour *wxLIGHT_GREY;
1192
1193 extern wxCursor *wxSTANDARD_CURSOR;
1194 extern wxCursor *wxHOURGLASS_CURSOR;
1195 extern wxCursor *wxCROSS_CURSOR;
1196
1197
1198 extern wxBitmap wxNullBitmap;
1199 extern wxIcon wxNullIcon;
1200 extern wxCursor wxNullCursor;
1201 extern wxPen wxNullPen;
1202 extern wxBrush wxNullBrush;
1203 extern wxPalette wxNullPalette;
1204 extern wxFont wxNullFont;
1205 extern wxColour wxNullColour;
1206
1207
1208 extern wxFontList* wxTheFontList;
1209 extern wxPenList* wxThePenList;
1210 extern wxBrushList* wxTheBrushList;
1211 extern wxColourDatabase* wxTheColourDatabase;
1212
1213
1214 %readwrite
1215 %{
1216 #endif
1217 %}
1218
1219 //---------------------------------------------------------------------------
1220 //---------------------------------------------------------------------------
1221