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