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