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