]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/gdi.i
support Show() in wxFlexGridSizer (patch 737850)
[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
1e4a197e 37%pragma(python) code = "import wx"
b68dc582 38
137b5242
RD
39//---------------------------------------------------------------------------
40%{
41 // Put some wx default wxChar* values into wxStrings.
42 static const wxString wxPyEmptyString(wxT(""));
43%}
7bf85405
RD
44//---------------------------------------------------------------------------
45
9416aa89
RD
46class wxGDIObject : public wxObject {
47public:
48 wxGDIObject();
49 ~wxGDIObject();
50
51 bool GetVisible();
52 void SetVisible( bool visible );
53
54 bool IsNull();
55
56};
6999b0d8
RD
57
58//---------------------------------------------------------------------------
59
9cbf6f6e
RD
60
61// TODO: When the API stabalizes and is available on other platforms, add
62// wrappers for the new wxBitmap, wxRawBitmap, wxDIB stuff...
63
9416aa89 64class wxBitmap : public wxGDIObject
5bff6bb8 65{
7bf85405 66public:
96de41c2 67 wxBitmap(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_ANY);
7bf85405
RD
68 ~wxBitmap();
69
7bf85405
RD
70 wxPalette* GetPalette();
71 wxMask* GetMask();
96de41c2 72 bool LoadFile(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_ANY);
e6056257 73 bool SaveFile(const wxString& name, wxBitmapType type, wxPalette* palette = NULL);
7bf85405 74 void SetMask(wxMask* mask);
1e4a197e
RD
75 %pragma(python) addtoclass = "
76 def SetMaskColour(self, colour):
77 mask = wxMaskColour(self, colour)
78 self.SetMask(mask)
79 "
fb5e0af0 80#ifdef __WXMSW__
b8b8dda7 81 void SetPalette(wxPalette& palette);
fb5e0af0 82#endif
5bff6bb8
RD
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
f6bcfd97
BP
99
100 wxBitmap GetSubBitmap( const wxRect& rect );
f6bcfd97 101 bool CopyFromIcon(const wxIcon& icon);
ecc08ead 102#ifdef __WXMSW__
f6bcfd97
BP
103 bool CopyFromCursor(const wxCursor& cursor);
104 int GetQuality();
105 void SetQuality(int q);
106#endif
107
7bf85405
RD
108};
109
5bff6bb8 110
96bfd053 111// Declarations of some alternate "constructors"
7bf85405 112%new wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1);
96bfd053
RD
113%new wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings);
114%new wxBitmap* wxBitmapFromIcon(const wxIcon& icon);
3eb221f6 115%new wxBitmap* wxBitmapFromBits(PyObject* bits, int width, int height, int depth = 1 );
9c039d08 116
d56cebe7
RD
117// #ifdef __WXMSW__
118// %new wxBitmap* wxBitmapFromData(PyObject* data, long type,
119// int width, int height, int depth = 1);
120// #endif
8bf5d46e 121
96bfd053
RD
122
123
124%{ // Implementations of some alternate "constructors"
125
7bf85405
RD
126 wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1) {
127 return new wxBitmap(width, height, depth);
128 }
129
96bfd053
RD
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
d56cebe7 148
96bfd053
RD
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
3eb221f6
RD
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);
d56cebe7 172 }
926bb76c 173
4c9993c3 174
d56cebe7
RD
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
7bf85405
RD
185%}
186
187//---------------------------------------------------------------------------
188
9416aa89 189class wxMask : public wxObject {
7bf85405
RD
190public:
191 wxMask(const wxBitmap& bitmap);
eb715945 192 //~wxMask();
96bfd053
RD
193
194 %addmethods { void Destroy() { delete self; } }
7bf85405
RD
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
9416aa89 208class wxIcon : public wxGDIObject
5bff6bb8 209{
7bf85405 210public:
fb5e0af0
RD
211 wxIcon(const wxString& name, long flags,
212 int desiredWidth = -1, int desiredHeight = -1);
7bf85405
RD
213 ~wxIcon();
214
6abe8375 215#ifndef __WXMAC__
7bf85405 216 bool LoadFile(const wxString& name, long flags);
6abe8375 217#endif
5bff6bb8
RD
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
96bfd053
RD
234 void CopyFromBitmap(const wxBitmap& bmp);
235
7bf85405
RD
236};
237
8bf5d46e 238
96bfd053
RD
239// Declarations of some alternate "constructors"
240%new wxIcon* wxEmptyIcon();
241%new wxIcon* wxIconFromXPMData(PyObject* listOfStrings);
7248a051 242%new wxIcon* wxIconFromBitmap(const wxBitmap& bmp);
96bfd053
RD
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 }
7248a051
RD
260
261 wxIcon* wxIconFromBitmap(const wxBitmap& bmp) {
262 wxIcon* icon = new wxIcon();
263 icon->CopyFromBitmap(bmp);
264 return icon;
265 }
96bfd053
RD
266%}
267
7bf85405
RD
268//---------------------------------------------------------------------------
269
0e9b78ce
RD
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
9416aa89 302class wxCursor : public wxGDIObject
5bff6bb8 303{
7bf85405 304public:
fb5e0af0 305#ifdef __WXMSW__
7bf85405 306 wxCursor(const wxString& cursorName, long flags, int hotSpotX=0, int hotSpotY=0);
fb5e0af0 307#endif
7bf85405 308 ~wxCursor();
5bff6bb8
RD
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
7bf85405
RD
325};
326
9c039d08 327%name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id);
7bf85405 328%{ // Alternate 'constructor'
9c039d08 329 wxCursor* wxPyStockCursor(int id) {
7bf85405
RD
330 return new wxCursor(id);
331 }
332%}
333
1e4a197e
RD
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
7bf85405
RD
345//----------------------------------------------------------------------
346
9416aa89 347class wxColour : public wxObject {
7bf85405
RD
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);
1e4a197e
RD
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));
7bf85405
RD
370 return rv;
371 }
1e4a197e
RD
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 }
7bf85405 388 }
1e4a197e
RD
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"
9b3d3bc4 398
7bf85405
RD
399};
400
401%new wxColour* wxNamedColour(const wxString& colorName);
de20db99 402
7bf85405
RD
403%{ // Alternate 'constructor'
404 wxColour* wxNamedColour(const wxString& colorName) {
405 return new wxColour(colorName);
406 }
407%}
408
409
7bf85405 410
9416aa89 411class wxColourDatabase : public wxObject {
7bf85405 412public:
0569df0f
RD
413
414 wxColour *FindColour(const wxString& colour);
415 wxString FindName(const wxColour& colour) const;
416
7bf85405 417 %addmethods {
0569df0f 418 void Append(const wxString& name, int red, int green, int blue) {
fe40185d
RD
419 // first see if the name is already there
420 wxString cName = name;
421 cName.MakeUpper();
422 wxString cName2 = cName;
a541c325 423 if ( !cName2.Replace(wxT("GRAY"), wxT("GREY")) )
fe40185d
RD
424 cName2.clear();
425
1e4a197e 426 wxNode *node = self->GetFirst();
fe40185d
RD
427 while ( node ) {
428 const wxChar *key = node->GetKeyString();
429 if ( cName == key || cName2 == key ) {
1e4a197e 430 wxColour* c = (wxColour *)node->GetData();
fe40185d
RD
431 c->Set(red, green, blue);
432 return;
433 }
1e4a197e 434 node = node->GetNext();
fe40185d
RD
435 }
436
437 // otherwise append the new colour
0569df0f 438 self->Append(name.c_str(), new wxColour(red, green, blue));
7bf85405 439 }
7bf85405 440 }
0569df0f
RD
441};
442
443
444//----------------------------------------------------------------------
445
9416aa89 446class wxPen : public wxGDIObject {
0569df0f
RD
447public:
448 wxPen(wxColour& colour, int width=1, int style=wxSOLID);
449 ~wxPen();
7bf85405
RD
450
451 int GetCap();
25832b3f 452 wxColour GetColour();
7bf85405 453
fb5e0af0 454 int GetJoin();
7bf85405
RD
455 int GetStyle();
456 int GetWidth();
457 bool Ok();
458 void SetCap(int cap_style);
459 void SetColour(wxColour& colour);
aeeb6a44
RR
460 void SetJoin(int join_style);
461 void SetStyle(int style);
462 void SetWidth(int width);
08127323 463
756ed80c 464
eec92d76 465 void SetDashes(int LCOUNT, wxDash* choices);
756ed80c
RD
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 }
6999b0d8
RD
479
480#ifdef __WXMSW__
481 wxBitmap* GetStipple();
b8b8dda7 482 void SetStipple(wxBitmap& stipple);
fb5e0af0 483#endif
7bf85405
RD
484};
485
0569df0f 486
ecc08ead 487
05f30eec
RD
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
ecc08ead
RD
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)
05f30eec 501 delete [] m_dash;
ecc08ead
RD
502 }
503
504 void SetDashes(int nb_dashes, const wxDash *dash) {
05f30eec
RD
505 if (m_dash)
506 delete [] m_dash;
ecc08ead 507 m_dash = new wxDash[nb_dashes];
05f30eec 508 for (int i=0; i<nb_dashes; i++) {
ecc08ead 509 m_dash[i] = dash[i];
05f30eec 510 }
ecc08ead
RD
511 wxPen::SetDashes(nb_dashes, m_dash);
512 }
513
514private:
515 wxDash* m_dash;
516};
517%}
518
519
ecc08ead
RD
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
05f30eec 530
9416aa89 531class wxPenList : public wxObject {
0569df0f
RD
532public:
533
534 void AddPen(wxPen* pen);
535 wxPen* FindOrCreatePen(const wxColour& colour, int width, int style);
536 void RemovePen(wxPen* pen);
2f4e9287
RD
537
538 int GetCount();
0569df0f
RD
539};
540
541
542
7bf85405
RD
543//----------------------------------------------------------------------
544
9416aa89 545class wxBrush : public wxGDIObject {
7bf85405 546public:
0569df0f
RD
547 wxBrush(const wxColour& colour, int style=wxSOLID);
548 ~wxBrush();
26b9cf27 549
25832b3f 550 wxColour GetColour();
7bf85405
RD
551 wxBitmap * GetStipple();
552 int GetStyle();
553 bool Ok();
554 void SetColour(wxColour &colour);
b8b8dda7 555 void SetStipple(wxBitmap& bitmap);
7bf85405
RD
556 void SetStyle(int style);
557};
558
0569df0f 559
6ee2116b 560class wxBrushList : public wxObject {
0569df0f
RD
561public:
562
563 void AddBrush(wxBrush *brush);
564 wxBrush * FindOrCreateBrush(const wxColour& colour, int style);
565 void RemoveBrush(wxBrush *brush);
2f4e9287
RD
566
567 int GetCount();
0569df0f
RD
568};
569
7bf85405
RD
570//----------------------------------------------------------------------
571
572
9416aa89 573class wxDC : public wxObject {
7bf85405 574public:
fb5e0af0 575// wxDC(); **** abstract base class, can't instantiate.
7bf85405
RD
576 ~wxDC();
577
578 void BeginDrawing();
1e4a197e 579
efc5f224 580// %name(BlitXY)
1e4a197e
RD
581 bool Blit(wxCoord xdest, wxCoord ydest,
582 wxCoord width, wxCoord height,
583 wxDC *source, wxCoord xsrc, wxCoord ysrc,
efc5f224
RD
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
7bf85405 589 void Clear();
1e4a197e 590 void CrossHair(wxCoord x, wxCoord y);
7bf85405 591 void DestroyClippingRegion();
1e4a197e
RD
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);
23bed520
RD
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
1e4a197e
RD
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,
7bf85405 621 int fill_style=wxODDEVEN_RULE);
1e4a197e
RD
622 void DrawPoint(wxCoord x, wxCoord y);
623 void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
33ffdd72 624 %name(DrawRectangleRect)void DrawRectangle(const wxRect& rect);
6999b0d8 625 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
1e4a197e 626 void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, wxCoord radius=20);
eec92d76 627 void DrawSpline(int PCOUNT, wxPoint* points);
1e4a197e 628 void DrawText(const wxString& text, wxCoord x, wxCoord y);
7bf85405
RD
629 void EndDoc();
630 void EndDrawing();
631 void EndPage();
1e4a197e 632 bool FloodFill(wxCoord x, wxCoord y, const wxColour& colour, int style=wxFLOOD_SURFACE);
c5943253
RD
633 wxBrush GetBackground();
634 wxBrush GetBrush();
1e4a197e
RD
635 wxCoord GetCharHeight();
636 wxCoord GetCharWidth();
637 void GetClippingBox(wxCoord *OUTPUT, wxCoord *OUTPUT,
638 wxCoord *OUTPUT, wxCoord *OUTPUT);
c5943253 639 wxFont GetFont();
7bf85405 640 int GetLogicalFunction();
eec92d76 641 void GetLogicalScale(double *OUTPUT, double *OUTPUT);
7bf85405
RD
642 int GetMapMode();
643 bool GetOptimization();
c5943253 644 wxPen GetPen();
fb5e0af0 645 %addmethods {
1e4a197e 646 %new wxColour* GetPixel(wxCoord x, wxCoord y) {
fb5e0af0
RD
647 wxColour* wc = new wxColour();
648 self->GetPixel(x, y, wc);
649 return wc;
650 }
651 }
bb0054cd
RD
652 %name(GetSizeTuple)void GetSize(int* OUTPUT, int* OUTPUT);
653 wxSize GetSize();
eec92d76 654 wxSize GetSizeMM();
25832b3f 655 wxColour GetTextBackground();
1e4a197e 656 void GetTextExtent(const wxString& string, wxCoord *OUTPUT, wxCoord *OUTPUT);
af309447 657 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
1e4a197e 658 wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord* OUTPUT,
af309447 659 const wxFont* font = NULL);
1e4a197e
RD
660 void GetMultiLineTextExtent(const wxString& text, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT,
661 wxFont *font = NULL);
25832b3f 662 wxColour GetTextForeground();
eec92d76 663 void GetUserScale(double *OUTPUT, double *OUTPUT);
1e4a197e
RD
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();
7bf85405 672 bool Ok();
1e4a197e 673 void SetDeviceOrigin(wxCoord x, wxCoord y);
7bf85405
RD
674 void SetBackground(const wxBrush& brush);
675 void SetBackgroundMode(int mode);
1e4a197e 676 void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
19a97bd6 677 %name(SetClippingRegionAsRegion) void SetClippingRegion(const wxRegion& region);
33ffdd72 678 %name(SetClippingRect) void SetClippingRegion(const wxRect& rect);
7bf85405
RD
679 void SetPalette(const wxPalette& colourMap);
680 void SetBrush(const wxBrush& brush);
681 void SetFont(const wxFont& font);
682 void SetLogicalFunction(int function);
eec92d76 683 void SetLogicalScale(double x, double y);
7bf85405
RD
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
efc5f224 694
1e4a197e 695 void DrawBitmap(const wxBitmap& bitmap, wxCoord x, wxCoord y,
efc5f224
RD
696 int useMask = FALSE);
697
eec92d76
RD
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);
eec92d76
RD
706 void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
707
f6bcfd97
BP
708 void CalcBoundingBox(int x, int y);
709 void ResetBoundingBox();
c7e7022c 710
9d37f964
RD
711 %addmethods {
712 void GetBoundingBox(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
713 // See below for implementation
714 }
715
c7e7022c
RD
716#ifdef __WXMSW__
717 long GetHDC();
718#endif
9d37f964
RD
719
720
1e4a197e 721 %addmethods { // See drawlist.cpp for impplementaion of these...
9d37f964 722
1e4a197e
RD
723 PyObject* _DrawPointList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
724 {
725 return wxPyDrawXXXList(*self, wxPyDrawXXXPoint, pyCoords, pyPens, pyBrushes);
9d37f964
RD
726 }
727
1e4a197e
RD
728 PyObject* _DrawLineList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
729 {
730 return wxPyDrawXXXList(*self, wxPyDrawXXXLine, pyCoords, pyPens, pyBrushes);
731 }
9d37f964 732
1e4a197e
RD
733 PyObject* _DrawRectangleList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
734 {
735 return wxPyDrawXXXList(*self, wxPyDrawXXXRectangle, pyCoords, pyPens, pyBrushes);
736 }
9d37f964 737
1e4a197e
RD
738 PyObject* _DrawEllipseList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
739 {
740 return wxPyDrawXXXList(*self, wxPyDrawXXXEllipse, pyCoords, pyPens, pyBrushes);
741 }
fd512ba2 742
1e4a197e
RD
743 PyObject* _DrawPolygonList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
744 {
745 return wxPyDrawXXXList(*self, wxPyDrawXXXPolygon, pyCoords, pyPens, pyBrushes);
746 }
fd512ba2 747
1e4a197e
RD
748 PyObject* _DrawTextList(PyObject* textList, PyObject* pyPoints,
749 PyObject* foregroundList, PyObject* backgroundList) {
750 return wxPyDrawTextList(*self, textList, pyPoints, foregroundList, backgroundList);
9d37f964
RD
751 }
752 }
753
9d37f964
RD
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')
1e4a197e
RD
762 return self._DrawPointList(points, pens, [])
763
9d37f964
RD
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')
1e4a197e
RD
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)
9d37f964
RD
849"
850
851
7bf85405
RD
852};
853
854
9d37f964
RD
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
7bf85405
RD
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
e9159fe8
RD
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 );
d3bfec74
RD
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"
e9159fe8
RD
906};
907
908
909class wxBufferedPaintDC : public wxBufferedDC
910{
911public:
912 wxBufferedPaintDC( wxWindow *window, const wxBitmap &buffer = wxNullBitmap );
913};
914
7bf85405
RD
915//---------------------------------------------------------------------------
916
917class wxScreenDC : public wxDC {
918public:
919 wxScreenDC();
920
26b9cf27
RD
921 %name(StartDrawingOnTopWin) bool StartDrawingOnTop(wxWindow* window);
922 bool StartDrawingOnTop(wxRect* rect = NULL);
7bf85405
RD
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
b639c3c5
RD
942class wxWindowDC : public wxDC {
943public:
944 wxWindowDC(wxWindow* win);
945};
b639c3c5
RD
946
947//---------------------------------------------------------------------------
948
7bf85405 949
d063802f 950#ifdef __WXMSW__
17c0e08c
RD
951
952%{
953#include <wx/metafile.h>
954%}
955
956class wxMetaFile : public wxObject {
957public:
137b5242 958 wxMetaFile(const wxString& filename = wxPyEmptyString);
17c0e08c
RD
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
7bf85405
RD
976class wxMetaFileDC : public wxDC {
977public:
137b5242 978 wxMetaFileDC(const wxString& filename = wxPyEmptyString,
17c0e08c 979 int width = 0, int height = 0,
137b5242 980 const wxString& description = wxPyEmptyString);
7bf85405
RD
981 wxMetaFile* Close();
982};
17c0e08c 983
fb5e0af0 984#endif
7bf85405 985
b639c3c5
RD
986//---------------------------------------------------------------------------
987
9416aa89 988class wxPalette : public wxGDIObject {
b639c3c5 989public:
eec92d76 990 wxPalette(int LCOUNT, byte* choices, byte* choices, byte* choices);
b639c3c5
RD
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
af309447
RD
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
9416aa89 1010class wxImageList : public wxObject {
af309447 1011public:
dcd38683 1012 wxImageList(int width, int height, int mask=TRUE, int initialCount=1);
af309447
RD
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);
f6bcfd97 1018#ifdef __WXMSW__
b57bdb5a 1019 bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
b57bdb5a 1020#else
f6bcfd97
BP
1021// %name(ReplaceIcon)bool Replace(int index, const wxIcon& icon);
1022// int Add(const wxBitmap& bitmap);
b57bdb5a
RD
1023 bool Replace(int index, const wxBitmap& bitmap);
1024#endif
af309447
RD
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();
f6bcfd97 1032 void GetSize(int index, int& OUTPUT, int& OUTPUT);
af309447
RD
1033};
1034
b639c3c5 1035
9416aa89
RD
1036//---------------------------------------------------------------------------
1037// Regions, etc.
1038
1039enum wxRegionContain {
1040 wxOutRegion, wxPartRegion, wxInRegion
1041};
1042
1043
1044class wxRegion : public wxGDIObject {
1045public:
1e4a197e 1046 wxRegion(wxCoord x=0, wxCoord y=0, wxCoord width=0, wxCoord height=0);
8038a802 1047#ifndef __WXMAC__
3de0866e 1048 %name(wxRegionFromPoints)wxRegion(int PCOUNT, wxPoint* points, int fillStyle = wxWINDING_RULE);
8038a802 1049#endif
1542ea39
RD
1050 %name(wxRegionFromBitmap)wxRegion(const wxBitmap& bmp,
1051 const wxColour& transColour = wxNullColour,
1052 int tolerance = 0);
9416aa89
RD
1053 ~wxRegion();
1054
1542ea39 1055
9416aa89 1056 void Clear();
d063802f 1057#ifndef __WXMAC__
23bed520 1058 bool Offset(wxCoord x, wxCoord y);
d063802f 1059#endif
23bed520 1060
1e4a197e 1061 wxRegionContain Contains(wxCoord x, wxCoord y);
9416aa89
RD
1062 %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt);
1063 %name(ContainsRect)wxRegionContain Contains(const wxRect& rect);
1e4a197e 1064 %name(ContainsRectDim)wxRegionContain Contains(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
9416aa89
RD
1065
1066 wxRect GetBox();
1067
1e4a197e 1068 bool Intersect(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
9416aa89
RD
1069 %name(IntersectRect)bool Intersect(const wxRect& rect);
1070 %name(IntersectRegion)bool Intersect(const wxRegion& region);
1071
1072 bool IsEmpty();
1073
1e4a197e 1074 bool Union(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
9416aa89
RD
1075 %name(UnionRect)bool Union(const wxRect& rect);
1076 %name(UnionRegion)bool Union(const wxRegion& region);
1077
1e4a197e 1078 bool Subtract(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
9416aa89
RD
1079 %name(SubtractRect)bool Subtract(const wxRect& rect);
1080 %name(SubtractRegion)bool Subtract(const wxRegion& region);
1081
1e4a197e 1082 bool Xor(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
9416aa89
RD
1083 %name(XorRect)bool Xor(const wxRect& rect);
1084 %name(XorRegion)bool Xor(const wxRegion& region);
1542ea39
RD
1085
1086 // Convert the region to a B&W bitmap with the black pixels being inside
1087 // the region.
1088 wxBitmap ConvertToBitmap();
1089
1090 // Use the non-transparent pixels of a wxBitmap for the region to combine
1091 // with this region. If the bitmap has a mask then it will be used,
1092 // otherwise the colour to be treated as transparent may be specified,
1093 // along with an optional tolerance value.
1094 %name(UnionBitmap)bool Union(const wxBitmap& bmp,
1095 const wxColour& transColour = wxNullColour,
1096 int tolerance = 0);
9416aa89
RD
1097};
1098
1099
1100
1101class wxRegionIterator : public wxObject {
1102public:
1103 wxRegionIterator(const wxRegion& region);
1104 ~wxRegionIterator();
1105
1e4a197e
RD
1106 wxCoord GetX();
1107 wxCoord GetY();
1108 wxCoord GetW();
1109 wxCoord GetWidth();
1110 wxCoord GetH();
1111 wxCoord GetHeight();
9416aa89
RD
1112 wxRect GetRect();
1113 bool HaveRects();
1114 void Reset();
1115
1116 %addmethods {
1117 void Next() {
1118 (*self) ++;
1119 }
1120 };
1121};
1122
1123
7bf85405
RD
1124//---------------------------------------------------------------------------
1125
1542ea39 1126
c5943253
RD
1127%readonly
1128%{
1129#if 0
1130%}
1131
1132extern wxFont *wxNORMAL_FONT;
1133extern wxFont *wxSMALL_FONT;
1134extern wxFont *wxITALIC_FONT;
1135extern wxFont *wxSWISS_FONT;
1136
1137extern wxPen *wxRED_PEN;
1138extern wxPen *wxCYAN_PEN;
1139extern wxPen *wxGREEN_PEN;
1140extern wxPen *wxBLACK_PEN;
1141extern wxPen *wxWHITE_PEN;
1142extern wxPen *wxTRANSPARENT_PEN;
1143extern wxPen *wxBLACK_DASHED_PEN;
1144extern wxPen *wxGREY_PEN;
1145extern wxPen *wxMEDIUM_GREY_PEN;
1146extern wxPen *wxLIGHT_GREY_PEN;
1147
1148extern wxBrush *wxBLUE_BRUSH;
1149extern wxBrush *wxGREEN_BRUSH;
1150extern wxBrush *wxWHITE_BRUSH;
1151extern wxBrush *wxBLACK_BRUSH;
1152extern wxBrush *wxTRANSPARENT_BRUSH;
1153extern wxBrush *wxCYAN_BRUSH;
1154extern wxBrush *wxRED_BRUSH;
1155extern wxBrush *wxGREY_BRUSH;
1156extern wxBrush *wxMEDIUM_GREY_BRUSH;
1157extern wxBrush *wxLIGHT_GREY_BRUSH;
1158
1159extern wxColour *wxBLACK;
1160extern wxColour *wxWHITE;
1161extern wxColour *wxRED;
1162extern wxColour *wxBLUE;
1163extern wxColour *wxGREEN;
1164extern wxColour *wxCYAN;
1165extern wxColour *wxLIGHT_GREY;
1166
1167extern wxCursor *wxSTANDARD_CURSOR;
1168extern wxCursor *wxHOURGLASS_CURSOR;
1169extern wxCursor *wxCROSS_CURSOR;
1170
1171
1172extern wxBitmap wxNullBitmap;
1173extern wxIcon wxNullIcon;
1174extern wxCursor wxNullCursor;
1175extern wxPen wxNullPen;
1176extern wxBrush wxNullBrush;
1177extern wxPalette wxNullPalette;
1178extern wxFont wxNullFont;
1179extern wxColour wxNullColour;
1180
1181
1182extern wxFontList* wxTheFontList;
1183extern wxPenList* wxThePenList;
1184extern wxBrushList* wxTheBrushList;
1185extern wxColourDatabase* wxTheColourDatabase;
1186
1187
1188%readwrite
1189%{
1190#endif
1191%}
1192
1193//---------------------------------------------------------------------------
1194//---------------------------------------------------------------------------
1195