]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/gdi.i
moved OnActivate() logic from wxFrame to wxDialog -- this fixes infinite loop when...
[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
756ed80c 426
eec92d76 427 void SetDashes(int LCOUNT, wxDash* choices);
756ed80c
RD
428 //int GetDashes(wxDash **dashes);
429 %addmethods {
430 PyObject* GetDashes() {
431 wxDash* dashes;
432 int count = self->GetDashes(&dashes);
433 wxPyBeginBlockThreads();
434 PyObject* retval = PyList_New(0);
435 for (int x=0; x<count; x++)
436 PyList_Append(retval, PyInt_FromLong(dashes[x]));
437 wxPyEndBlockThreads();
438 return retval;
439 }
440 }
6999b0d8
RD
441
442#ifdef __WXMSW__
443 wxBitmap* GetStipple();
b8b8dda7 444 void SetStipple(wxBitmap& stipple);
fb5e0af0 445#endif
7bf85405
RD
446};
447
0569df0f 448
ecc08ead 449
05f30eec
RD
450
451// The list of ints for the dashes needs to exist for the life of the pen
452// so we make it part of the class to save it. wxPyPen is aliased to wxPen
453// in _extras.py
454
ecc08ead
RD
455%{
456class wxPyPen : public wxPen {
457public:
458 wxPyPen(wxColour& colour, int width=1, int style=wxSOLID)
459 : wxPen(colour, width, style)
460 { m_dash = NULL; }
461 ~wxPyPen() {
462 if (m_dash)
05f30eec 463 delete [] m_dash;
ecc08ead
RD
464 }
465
466 void SetDashes(int nb_dashes, const wxDash *dash) {
05f30eec
RD
467 if (m_dash)
468 delete [] m_dash;
ecc08ead 469 m_dash = new wxDash[nb_dashes];
05f30eec 470 for (int i=0; i<nb_dashes; i++) {
ecc08ead 471 m_dash[i] = dash[i];
05f30eec 472 }
ecc08ead
RD
473 wxPen::SetDashes(nb_dashes, m_dash);
474 }
475
476private:
477 wxDash* m_dash;
478};
479%}
480
481
ecc08ead
RD
482class wxPyPen : public wxPen {
483public:
484 wxPyPen(wxColour& colour, int width=1, int style=wxSOLID);
485 ~wxPyPen();
486
487 void SetDashes(int LCOUNT, wxDash* choices);
488};
489
490
491
05f30eec 492
9416aa89 493class wxPenList : public wxObject {
0569df0f
RD
494public:
495
496 void AddPen(wxPen* pen);
497 wxPen* FindOrCreatePen(const wxColour& colour, int width, int style);
498 void RemovePen(wxPen* pen);
2f4e9287
RD
499
500 int GetCount();
0569df0f
RD
501};
502
503
504
7bf85405
RD
505//----------------------------------------------------------------------
506
9416aa89 507class wxBrush : public wxGDIObject {
7bf85405 508public:
0569df0f
RD
509 wxBrush(const wxColour& colour, int style=wxSOLID);
510 ~wxBrush();
26b9cf27 511
25832b3f 512 wxColour GetColour();
7bf85405
RD
513 wxBitmap * GetStipple();
514 int GetStyle();
515 bool Ok();
516 void SetColour(wxColour &colour);
b8b8dda7 517 void SetStipple(wxBitmap& bitmap);
7bf85405
RD
518 void SetStyle(int style);
519};
520
0569df0f 521
6ee2116b 522class wxBrushList : public wxObject {
0569df0f
RD
523public:
524
525 void AddBrush(wxBrush *brush);
526 wxBrush * FindOrCreateBrush(const wxColour& colour, int style);
527 void RemoveBrush(wxBrush *brush);
2f4e9287
RD
528
529 int GetCount();
0569df0f
RD
530};
531
7bf85405
RD
532//----------------------------------------------------------------------
533
534
535
9416aa89 536class wxDC : public wxObject {
7bf85405 537public:
fb5e0af0 538// wxDC(); **** abstract base class, can't instantiate.
7bf85405
RD
539 ~wxDC();
540
541 void BeginDrawing();
efc5f224
RD
542// %name(BlitXY)
543 bool Blit(long xdest, long ydest,
544 long width, long height,
545 wxDC *source, long xsrc, long ysrc,
546 int logicalFunc = wxCOPY, int useMask = FALSE);
547// bool Blit(const wxPoint& destPt, const wxSize& sz,
548// wxDC *source, const wxPoint& srcPt,
549// int logicalFunc = wxCOPY, int useMask = FALSE);
550
7bf85405
RD
551 void Clear();
552 void CrossHair(long x, long y);
553 void DestroyClippingRegion();
554 long DeviceToLogicalX(long x);
555 long DeviceToLogicalXRel(long x);
556 long DeviceToLogicalY(long y);
557 long DeviceToLogicalYRel(long y);
558 void DrawArc(long x1, long y1, long x2, long y2, long xc, long yc);
bb0054cd 559 void DrawCircle(long x, long y, long radius);
7bf85405
RD
560 void DrawEllipse(long x, long y, long width, long height);
561 void DrawEllipticArc(long x, long y, long width, long height, long start, long end);
562 void DrawIcon(const wxIcon& icon, long x, long y);
23bed520
RD
563
564 void DrawLabel(const wxString& text, const wxRect& rect,
565 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
566 int indexAccel = -1);
567
568 %addmethods {
569 wxRect DrawImageLabel(const wxString& text,
570 const wxBitmap& image,
571 const wxRect& rect,
572 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
573 int indexAccel = -1) {
574 wxRect rv;
575 self->DrawLabel(text, image, rect, alignment, indexAccel, &rv);
576 return rv;
577 }
578 }
579
7bf85405 580 void DrawLine(long x1, long y1, long x2, long y2);
eec92d76
RD
581 void DrawLines(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0);
582 void DrawPolygon(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0,
7bf85405
RD
583 int fill_style=wxODDEVEN_RULE);
584 void DrawPoint(long x, long y);
585 void DrawRectangle(long x, long y, long width, long height);
6999b0d8 586 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
7bf85405 587 void DrawRoundedRectangle(long x, long y, long width, long height, long radius=20);
eec92d76 588 void DrawSpline(int PCOUNT, wxPoint* points);
7bf85405
RD
589 void DrawText(const wxString& text, long x, long y);
590 void EndDoc();
591 void EndDrawing();
592 void EndPage();
d394edca 593 bool FloodFill(long x, long y, const wxColour& colour, int style=wxFLOOD_SURFACE);
c5943253
RD
594 wxBrush GetBackground();
595 wxBrush GetBrush();
7bf85405
RD
596 long GetCharHeight();
597 long GetCharWidth();
598 void GetClippingBox(long *OUTPUT, long *OUTPUT,
599 long *OUTPUT, long *OUTPUT);
c5943253 600 wxFont GetFont();
7bf85405 601 int GetLogicalFunction();
eec92d76 602 void GetLogicalScale(double *OUTPUT, double *OUTPUT);
7bf85405
RD
603 int GetMapMode();
604 bool GetOptimization();
c5943253 605 wxPen GetPen();
fb5e0af0
RD
606 %addmethods {
607 %new wxColour* GetPixel(long x, long y) {
608 wxColour* wc = new wxColour();
609 self->GetPixel(x, y, wc);
610 return wc;
611 }
612 }
bb0054cd
RD
613 %name(GetSizeTuple)void GetSize(int* OUTPUT, int* OUTPUT);
614 wxSize GetSize();
eec92d76 615 wxSize GetSizeMM();
25832b3f 616 wxColour GetTextBackground();
af309447
RD
617 void GetTextExtent(const wxString& string, long *OUTPUT, long *OUTPUT);
618 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
619 long *OUTPUT, long *OUTPUT, long *OUTPUT, long* OUTPUT,
620 const wxFont* font = NULL);
25832b3f 621 wxColour GetTextForeground();
eec92d76 622 void GetUserScale(double *OUTPUT, double *OUTPUT);
7bf85405
RD
623 long LogicalToDeviceX(long x);
624 long LogicalToDeviceXRel(long x);
625 long LogicalToDeviceY(long y);
626 long LogicalToDeviceYRel(long y);
627 long MaxX();
628 long MaxY();
629 long MinX();
630 long MinY();
631 bool Ok();
632 void SetDeviceOrigin(long x, long y);
633 void SetBackground(const wxBrush& brush);
634 void SetBackgroundMode(int mode);
635 void SetClippingRegion(long x, long y, long width, long height);
19a97bd6 636 %name(SetClippingRegionAsRegion) void SetClippingRegion(const wxRegion& region);
7bf85405
RD
637 void SetPalette(const wxPalette& colourMap);
638 void SetBrush(const wxBrush& brush);
639 void SetFont(const wxFont& font);
640 void SetLogicalFunction(int function);
eec92d76 641 void SetLogicalScale(double x, double y);
7bf85405
RD
642 void SetMapMode(int mode);
643 void SetOptimization(bool optimize);
644 void SetPen(const wxPen& pen);
645 void SetTextBackground(const wxColour& colour);
646 void SetTextForeground(const wxColour& colour);
647 void SetUserScale(double x_scale, double y_scale);
648 bool StartDoc(const wxString& message);
649 void StartPage();
650
651
efc5f224
RD
652
653 void DrawBitmap(const wxBitmap& bitmap, long x, long y,
654 int useMask = FALSE);
655
eec92d76
RD
656 bool CanDrawBitmap();
657 bool CanGetTextExtent();
658 int GetDepth();
659 wxSize GetPPI();
660
661 void GetLogicalOrigin(int *OUTPUT, int *OUTPUT);
662 void SetLogicalOrigin(int x, int y);
663 void GetDeviceOrigin(int *OUTPUT, int *OUTPUT);
eec92d76
RD
664 void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
665
f6bcfd97
BP
666 void CalcBoundingBox(int x, int y);
667 void ResetBoundingBox();
c7e7022c 668
9d37f964
RD
669 %addmethods {
670 void GetBoundingBox(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
671 // See below for implementation
672 }
673
c7e7022c
RD
674#ifdef __WXMSW__
675 long GetHDC();
676#endif
9d37f964
RD
677
678
679 %addmethods {
76e280e7 680 // NOTE: These methods are VERY SIMILAR in implentation. It would be
17c0e08c 681 // nice to factor out common code and or turn them into a set of
76e280e7
RD
682 // template-like macros.
683
9d37f964
RD
684 // Draw a point for every set of coordinants in pyPoints, optionally
685 // setting a new pen for each
686 PyObject* _DrawPointList(PyObject* pyPoints, PyObject* pyPens) {
687 bool isFastSeq = PyList_Check(pyPoints) || PyTuple_Check(pyPoints);
688 bool isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens);
689 int numObjs = 0;
690 int numPens = 0;
691 wxPen* pen;
692 PyObject* obj;
693 int x1, y1;
694 int i = 0;
695
696 if (!PySequence_Check(pyPoints)) {
697 goto err0;
698 }
699 if (!PySequence_Check(pyPens)) {
700 goto err1;
701 }
702 numObjs = PySequence_Length(pyPoints);
703 numPens = PySequence_Length(pyPens);
704
705 for (i = 0; i < numObjs; i++) {
706 // Use a new pen?
707 if (i < numPens) {
708 if (isFastPens) {
709 obj = PySequence_Fast_GET_ITEM(pyPens, i);
710 }
711 else {
712 obj = PySequence_GetItem(pyPens, i);
713 }
714 if (SWIG_GetPtrObj(obj, (void **) &pen, "_wxPen_p")) {
76e280e7
RD
715 if (!isFastPens)
716 Py_DECREF(obj);
9d37f964
RD
717 goto err1;
718 }
719
720 self->SetPen(*pen);
721 if (!isFastPens)
722 Py_DECREF(obj);
723 }
724
725 // Get the point coordinants
726 if (isFastSeq) {
727 obj = PySequence_Fast_GET_ITEM(pyPoints, i);
728 }
729 else {
730 obj = PySequence_GetItem(pyPoints, i);
731 }
732 if (! _2int_seq_helper(obj, &x1, &y1)) {
76e280e7
RD
733 if (!isFastPens)
734 Py_DECREF(obj);
9d37f964
RD
735 goto err0;
736 }
737
738 // Now draw the point
739 self->DrawPoint(x1, y1);
740
741 if (!isFastSeq)
742 Py_DECREF(obj);
743 }
744
745 Py_INCREF(Py_None);
746 return Py_None;
747
748 err1:
749 PyErr_SetString(PyExc_TypeError, "Expected a sequence of wxPens");
750 return NULL;
751 err0:
752 PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x,y) sequences.");
753 return NULL;
754 }
755
756
757 // Draw a line for every set of coordinants in pyLines, optionally
758 // setting a new pen for each
759 PyObject* _DrawLineList(PyObject* pyLines, PyObject* pyPens) {
760 bool isFastSeq = PyList_Check(pyLines) || PyTuple_Check(pyLines);
761 bool isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens);
762 int numObjs = 0;
763 int numPens = 0;
764 wxPen* pen;
765 PyObject* obj;
766 int x1, y1, x2, y2;
767 int i = 0;
768
769 if (!PySequence_Check(pyLines)) {
770 goto err0;
771 }
772 if (!PySequence_Check(pyPens)) {
773 goto err1;
774 }
775 numObjs = PySequence_Length(pyLines);
776 numPens = PySequence_Length(pyPens);
777
778 for (i = 0; i < numObjs; i++) {
779 // Use a new pen?
780 if (i < numPens) {
781 if (isFastPens) {
782 obj = PySequence_Fast_GET_ITEM(pyPens, i);
783 }
784 else {
785 obj = PySequence_GetItem(pyPens, i);
786 }
787 if (SWIG_GetPtrObj(obj, (void **) &pen, "_wxPen_p")) {
76e280e7
RD
788 if (!isFastPens)
789 Py_DECREF(obj);
9d37f964
RD
790 goto err1;
791 }
792
793 self->SetPen(*pen);
794 if (!isFastPens)
795 Py_DECREF(obj);
796 }
797
798 // Get the line coordinants
799 if (isFastSeq) {
800 obj = PySequence_Fast_GET_ITEM(pyLines, i);
801 }
802 else {
803 obj = PySequence_GetItem(pyLines, i);
804 }
805 if (! _4int_seq_helper(obj, &x1, &y1, &x2, &y2)) {
76e280e7
RD
806 if (!isFastPens)
807 Py_DECREF(obj);
9d37f964
RD
808 goto err0;
809 }
810
811 // Now draw the line
812 self->DrawLine(x1, y1, x2, y2);
813
814 if (!isFastSeq)
815 Py_DECREF(obj);
816 }
817
818 Py_INCREF(Py_None);
819 return Py_None;
820
821 err1:
822 PyErr_SetString(PyExc_TypeError, "Expected a sequence of wxPens");
823 return NULL;
824 err0:
825 PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x1,y1, x2,y2) sequences.");
826 return NULL;
827 }
828 }
829
830
831 %pragma(python) addtoclass = "
832 def DrawPointList(self, points, pens=None):
833 if pens is None:
834 pens = []
835 elif isinstance(pens, wxPenPtr):
836 pens = [pens]
837 elif len(pens) != len(points):
838 raise ValueError('points and pens must have same length')
839 return self._DrawPointList(points, pens)
840
841 def DrawLineList(self, lines, pens=None):
842 if pens is None:
843 pens = []
844 elif isinstance(pens, wxPenPtr):
845 pens = [pens]
846 elif len(pens) != len(lines):
847 raise ValueError('lines and pens must have same length')
848 return self._DrawLineList(lines, pens)
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:
1046 wxRegion(long x=0, long y=0, long width=0, long height=0);
1047 ~wxRegion();
1048
1049 void Clear();
d063802f 1050#ifndef __WXMAC__
23bed520 1051 bool Offset(wxCoord x, wxCoord y);
d063802f 1052#endif
23bed520 1053
9416aa89
RD
1054 wxRegionContain Contains(long x, long y);
1055 %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt);
1056 %name(ContainsRect)wxRegionContain Contains(const wxRect& rect);
1057 %name(ContainsRectDim)wxRegionContain Contains(long x, long y, long w, long h);
1058
1059 wxRect GetBox();
1060
1061 bool Intersect(long x, long y, long width, long height);
1062 %name(IntersectRect)bool Intersect(const wxRect& rect);
1063 %name(IntersectRegion)bool Intersect(const wxRegion& region);
1064
1065 bool IsEmpty();
1066
1067 bool Union(long x, long y, long width, long height);
1068 %name(UnionRect)bool Union(const wxRect& rect);
1069 %name(UnionRegion)bool Union(const wxRegion& region);
1070
1071 bool Subtract(long x, long y, long width, long height);
1072 %name(SubtractRect)bool Subtract(const wxRect& rect);
1073 %name(SubtractRegion)bool Subtract(const wxRegion& region);
1074
1075 bool Xor(long x, long y, long width, long height);
1076 %name(XorRect)bool Xor(const wxRect& rect);
1077 %name(XorRegion)bool Xor(const wxRegion& region);
1078};
1079
1080
1081
1082class wxRegionIterator : public wxObject {
1083public:
1084 wxRegionIterator(const wxRegion& region);
1085 ~wxRegionIterator();
1086
1087 long GetX();
1088 long GetY();
1089 long GetW();
1090 long GetWidth();
1091 long GetH();
1092 long GetHeight();
1093 wxRect GetRect();
1094 bool HaveRects();
1095 void Reset();
1096
1097 %addmethods {
1098 void Next() {
1099 (*self) ++;
1100 }
1101 };
1102};
1103
1104
7bf85405
RD
1105//---------------------------------------------------------------------------
1106
c5943253
RD
1107%readonly
1108%{
1109#if 0
1110%}
1111
1112extern wxFont *wxNORMAL_FONT;
1113extern wxFont *wxSMALL_FONT;
1114extern wxFont *wxITALIC_FONT;
1115extern wxFont *wxSWISS_FONT;
1116
1117extern wxPen *wxRED_PEN;
1118extern wxPen *wxCYAN_PEN;
1119extern wxPen *wxGREEN_PEN;
1120extern wxPen *wxBLACK_PEN;
1121extern wxPen *wxWHITE_PEN;
1122extern wxPen *wxTRANSPARENT_PEN;
1123extern wxPen *wxBLACK_DASHED_PEN;
1124extern wxPen *wxGREY_PEN;
1125extern wxPen *wxMEDIUM_GREY_PEN;
1126extern wxPen *wxLIGHT_GREY_PEN;
1127
1128extern wxBrush *wxBLUE_BRUSH;
1129extern wxBrush *wxGREEN_BRUSH;
1130extern wxBrush *wxWHITE_BRUSH;
1131extern wxBrush *wxBLACK_BRUSH;
1132extern wxBrush *wxTRANSPARENT_BRUSH;
1133extern wxBrush *wxCYAN_BRUSH;
1134extern wxBrush *wxRED_BRUSH;
1135extern wxBrush *wxGREY_BRUSH;
1136extern wxBrush *wxMEDIUM_GREY_BRUSH;
1137extern wxBrush *wxLIGHT_GREY_BRUSH;
1138
1139extern wxColour *wxBLACK;
1140extern wxColour *wxWHITE;
1141extern wxColour *wxRED;
1142extern wxColour *wxBLUE;
1143extern wxColour *wxGREEN;
1144extern wxColour *wxCYAN;
1145extern wxColour *wxLIGHT_GREY;
1146
1147extern wxCursor *wxSTANDARD_CURSOR;
1148extern wxCursor *wxHOURGLASS_CURSOR;
1149extern wxCursor *wxCROSS_CURSOR;
1150
1151
1152extern wxBitmap wxNullBitmap;
1153extern wxIcon wxNullIcon;
1154extern wxCursor wxNullCursor;
1155extern wxPen wxNullPen;
1156extern wxBrush wxNullBrush;
1157extern wxPalette wxNullPalette;
1158extern wxFont wxNullFont;
1159extern wxColour wxNullColour;
1160
1161
1162extern wxFontList* wxTheFontList;
1163extern wxPenList* wxThePenList;
1164extern wxBrushList* wxTheBrushList;
1165extern wxColourDatabase* wxTheColourDatabase;
1166
1167
1168%readwrite
1169%{
1170#endif
1171%}
1172
1173//---------------------------------------------------------------------------
1174//---------------------------------------------------------------------------
1175