]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: gdi.i | |
3 | // Purpose: SWIG interface file for wxDC, wxBrush, wxPen, etc. | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 7/7/97 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 1998 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | ||
14 | %module gdi | |
15 | ||
16 | %{ | |
17 | #include "helpers.h" | |
18 | #include <wx/imaglist.h> | |
19 | #include <wx/fontmap.h> | |
20 | #include <wx/fontenc.h> | |
21 | #include <wx/fontmap.h> | |
22 | #include <wx/fontutil.h> | |
23 | #include <wx/dcbuffer.h> | |
24 | #include <wx/iconbndl.h> | |
25 | %} | |
26 | ||
27 | //---------------------------------------------------------------------- | |
28 | ||
29 | %include typemaps.i | |
30 | %include my_typemaps.i | |
31 | ||
32 | // Import some definitions of other classes, etc. | |
33 | %import _defs.i | |
34 | %import misc.i | |
35 | %import fonts.i | |
36 | ||
37 | ||
38 | //--------------------------------------------------------------------------- | |
39 | %{ | |
40 | // Put some wx default wxChar* values into wxStrings. | |
41 | static const wxString wxPyEmptyString(wxT("")); | |
42 | %} | |
43 | //--------------------------------------------------------------------------- | |
44 | ||
45 | class wxGDIObject : public wxObject { | |
46 | public: | |
47 | wxGDIObject(); | |
48 | ~wxGDIObject(); | |
49 | ||
50 | bool GetVisible(); | |
51 | void SetVisible( bool visible ); | |
52 | ||
53 | bool IsNull(); | |
54 | ||
55 | }; | |
56 | ||
57 | //--------------------------------------------------------------------------- | |
58 | ||
59 | class wxBitmap : public wxGDIObject | |
60 | { | |
61 | public: | |
62 | wxBitmap(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_ANY); | |
63 | ~wxBitmap(); | |
64 | ||
65 | wxPalette* GetPalette(); | |
66 | wxMask* GetMask(); | |
67 | bool LoadFile(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_ANY); | |
68 | bool SaveFile(const wxString& name, wxBitmapType type, wxPalette* palette = NULL); | |
69 | void SetMask(wxMask* mask); | |
70 | #ifdef __WXMSW__ | |
71 | void SetPalette(wxPalette& palette); | |
72 | #endif | |
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 | |
89 | ||
90 | wxBitmap GetSubBitmap( const wxRect& rect ); | |
91 | bool CopyFromIcon(const wxIcon& icon); | |
92 | #ifdef __WXMSW__ | |
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 | " | |
106 | }; | |
107 | ||
108 | ||
109 | // Declarations of some alternate "constructors" | |
110 | %new wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1); | |
111 | %new wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings); | |
112 | %new wxBitmap* wxBitmapFromIcon(const wxIcon& icon); | |
113 | %new wxBitmap* wxBitmapFromBits(PyObject* bits, int width, int height, int depth = 1 ); | |
114 | ||
115 | // #ifdef __WXMSW__ | |
116 | // %new wxBitmap* wxBitmapFromData(PyObject* data, long type, | |
117 | // int width, int height, int depth = 1); | |
118 | // #endif | |
119 | ||
120 | ||
121 | ||
122 | %{ // Implementations of some alternate "constructors" | |
123 | ||
124 | wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1) { | |
125 | return new wxBitmap(width, height, depth); | |
126 | } | |
127 | ||
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 | ||
146 | ||
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 | ||
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); | |
170 | } | |
171 | ||
172 | ||
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 | |
183 | %} | |
184 | ||
185 | //--------------------------------------------------------------------------- | |
186 | ||
187 | class wxMask : public wxObject { | |
188 | public: | |
189 | wxMask(const wxBitmap& bitmap); | |
190 | //~wxMask(); | |
191 | ||
192 | %addmethods { void Destroy() { delete self; } } | |
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 | ||
206 | class wxIcon : public wxGDIObject | |
207 | { | |
208 | public: | |
209 | wxIcon(const wxString& name, long flags, | |
210 | int desiredWidth = -1, int desiredHeight = -1); | |
211 | ~wxIcon(); | |
212 | ||
213 | #ifndef __WXMAC__ | |
214 | bool LoadFile(const wxString& name, long flags); | |
215 | #endif | |
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 | |
232 | void CopyFromBitmap(const wxBitmap& bmp); | |
233 | ||
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 | " | |
242 | }; | |
243 | ||
244 | ||
245 | // Declarations of some alternate "constructors" | |
246 | %new wxIcon* wxEmptyIcon(); | |
247 | %new wxIcon* wxIconFromXPMData(PyObject* listOfStrings); | |
248 | %new wxIcon* wxIconFromBitmap(const wxBitmap& bmp); | |
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 | } | |
266 | ||
267 | wxIcon* wxIconFromBitmap(const wxBitmap& bmp) { | |
268 | wxIcon* icon = new wxIcon(); | |
269 | icon->CopyFromBitmap(bmp); | |
270 | return icon; | |
271 | } | |
272 | %} | |
273 | ||
274 | //--------------------------------------------------------------------------- | |
275 | ||
276 | class wxIconBundle | |
277 | { | |
278 | public: | |
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 | ||
308 | class wxCursor : public wxGDIObject | |
309 | { | |
310 | public: | |
311 | #ifdef __WXMSW__ | |
312 | wxCursor(const wxString& cursorName, long flags, int hotSpotX=0, int hotSpotY=0); | |
313 | #endif | |
314 | ~wxCursor(); | |
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 | |
331 | }; | |
332 | ||
333 | %name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id); | |
334 | %{ // Alternate 'constructor' | |
335 | wxCursor* wxPyStockCursor(int id) { | |
336 | return new wxCursor(id); | |
337 | } | |
338 | %} | |
339 | ||
340 | //---------------------------------------------------------------------- | |
341 | ||
342 | class wxColour : public wxObject { | |
343 | public: | |
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 | } | |
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 | ||
364 | }; | |
365 | ||
366 | %new wxColour* wxNamedColour(const wxString& colorName); | |
367 | ||
368 | %{ // Alternate 'constructor' | |
369 | wxColour* wxNamedColour(const wxString& colorName) { | |
370 | return new wxColour(colorName); | |
371 | } | |
372 | %} | |
373 | ||
374 | ||
375 | ||
376 | class wxColourDatabase : public wxObject { | |
377 | public: | |
378 | ||
379 | wxColour *FindColour(const wxString& colour); | |
380 | wxString FindName(const wxColour& colour) const; | |
381 | ||
382 | %addmethods { | |
383 | void Append(const wxString& name, int red, int green, int blue) { | |
384 | // first see if the name is already there | |
385 | wxString cName = name; | |
386 | cName.MakeUpper(); | |
387 | wxString cName2 = cName; | |
388 | if ( !cName2.Replace(wxT("GRAY"), wxT("GREY")) ) | |
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 | |
403 | self->Append(name.c_str(), new wxColour(red, green, blue)); | |
404 | } | |
405 | } | |
406 | }; | |
407 | ||
408 | ||
409 | //---------------------------------------------------------------------- | |
410 | ||
411 | class wxPen : public wxGDIObject { | |
412 | public: | |
413 | wxPen(wxColour& colour, int width=1, int style=wxSOLID); | |
414 | ~wxPen(); | |
415 | ||
416 | int GetCap(); | |
417 | wxColour GetColour(); | |
418 | ||
419 | int GetJoin(); | |
420 | int GetStyle(); | |
421 | int GetWidth(); | |
422 | bool Ok(); | |
423 | void SetCap(int cap_style); | |
424 | void SetColour(wxColour& colour); | |
425 | void SetJoin(int join_style); | |
426 | void SetStyle(int style); | |
427 | void SetWidth(int width); | |
428 | ||
429 | ||
430 | void SetDashes(int LCOUNT, wxDash* choices); | |
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 | } | |
444 | ||
445 | #ifdef __WXMSW__ | |
446 | wxBitmap* GetStipple(); | |
447 | void SetStipple(wxBitmap& stipple); | |
448 | #endif | |
449 | }; | |
450 | ||
451 | ||
452 | ||
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 | ||
458 | %{ | |
459 | class wxPyPen : public wxPen { | |
460 | public: | |
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) | |
466 | delete [] m_dash; | |
467 | } | |
468 | ||
469 | void SetDashes(int nb_dashes, const wxDash *dash) { | |
470 | if (m_dash) | |
471 | delete [] m_dash; | |
472 | m_dash = new wxDash[nb_dashes]; | |
473 | for (int i=0; i<nb_dashes; i++) { | |
474 | m_dash[i] = dash[i]; | |
475 | } | |
476 | wxPen::SetDashes(nb_dashes, m_dash); | |
477 | } | |
478 | ||
479 | private: | |
480 | wxDash* m_dash; | |
481 | }; | |
482 | %} | |
483 | ||
484 | ||
485 | class wxPyPen : public wxPen { | |
486 | public: | |
487 | wxPyPen(wxColour& colour, int width=1, int style=wxSOLID); | |
488 | ~wxPyPen(); | |
489 | ||
490 | void SetDashes(int LCOUNT, wxDash* choices); | |
491 | }; | |
492 | ||
493 | ||
494 | ||
495 | ||
496 | class wxPenList : public wxObject { | |
497 | public: | |
498 | ||
499 | void AddPen(wxPen* pen); | |
500 | wxPen* FindOrCreatePen(const wxColour& colour, int width, int style); | |
501 | void RemovePen(wxPen* pen); | |
502 | ||
503 | int GetCount(); | |
504 | }; | |
505 | ||
506 | ||
507 | ||
508 | //---------------------------------------------------------------------- | |
509 | ||
510 | class wxBrush : public wxGDIObject { | |
511 | public: | |
512 | wxBrush(const wxColour& colour, int style=wxSOLID); | |
513 | ~wxBrush(); | |
514 | ||
515 | wxColour GetColour(); | |
516 | wxBitmap * GetStipple(); | |
517 | int GetStyle(); | |
518 | bool Ok(); | |
519 | void SetColour(wxColour &colour); | |
520 | void SetStipple(wxBitmap& bitmap); | |
521 | void SetStyle(int style); | |
522 | }; | |
523 | ||
524 | ||
525 | class wxBrushList : public wxObject { | |
526 | public: | |
527 | ||
528 | void AddBrush(wxBrush *brush); | |
529 | wxBrush * FindOrCreateBrush(const wxColour& colour, int style); | |
530 | void RemoveBrush(wxBrush *brush); | |
531 | ||
532 | int GetCount(); | |
533 | }; | |
534 | ||
535 | //---------------------------------------------------------------------- | |
536 | ||
537 | ||
538 | ||
539 | class wxDC : public wxObject { | |
540 | public: | |
541 | // wxDC(); **** abstract base class, can't instantiate. | |
542 | ~wxDC(); | |
543 | ||
544 | void BeginDrawing(); | |
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 | ||
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); | |
562 | void DrawCircle(long x, long y, long radius); | |
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); | |
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 | ||
583 | void DrawLine(long x1, long y1, long x2, long y2); | |
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, | |
586 | int fill_style=wxODDEVEN_RULE); | |
587 | void DrawPoint(long x, long y); | |
588 | void DrawRectangle(long x, long y, long width, long height); | |
589 | %name(DrawRectangleRect)void DrawRectangle(const wxRect& rect); | |
590 | void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle); | |
591 | void DrawRoundedRectangle(long x, long y, long width, long height, long radius=20); | |
592 | void DrawSpline(int PCOUNT, wxPoint* points); | |
593 | void DrawText(const wxString& text, long x, long y); | |
594 | void EndDoc(); | |
595 | void EndDrawing(); | |
596 | void EndPage(); | |
597 | bool FloodFill(long x, long y, const wxColour& colour, int style=wxFLOOD_SURFACE); | |
598 | wxBrush GetBackground(); | |
599 | wxBrush GetBrush(); | |
600 | long GetCharHeight(); | |
601 | long GetCharWidth(); | |
602 | void GetClippingBox(long *OUTPUT, long *OUTPUT, | |
603 | long *OUTPUT, long *OUTPUT); | |
604 | wxFont GetFont(); | |
605 | int GetLogicalFunction(); | |
606 | void GetLogicalScale(double *OUTPUT, double *OUTPUT); | |
607 | int GetMapMode(); | |
608 | bool GetOptimization(); | |
609 | wxPen GetPen(); | |
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 | } | |
617 | %name(GetSizeTuple)void GetSize(int* OUTPUT, int* OUTPUT); | |
618 | wxSize GetSize(); | |
619 | wxSize GetSizeMM(); | |
620 | wxColour GetTextBackground(); | |
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); | |
625 | wxColour GetTextForeground(); | |
626 | void GetUserScale(double *OUTPUT, double *OUTPUT); | |
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); | |
640 | %name(SetClippingRegionAsRegion) void SetClippingRegion(const wxRegion& region); | |
641 | %name(SetClippingRect) void SetClippingRegion(const wxRect& rect); | |
642 | void SetPalette(const wxPalette& colourMap); | |
643 | void SetBrush(const wxBrush& brush); | |
644 | void SetFont(const wxFont& font); | |
645 | void SetLogicalFunction(int function); | |
646 | void SetLogicalScale(double x, double y); | |
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 | ||
657 | ||
658 | void DrawBitmap(const wxBitmap& bitmap, long x, long y, | |
659 | int useMask = FALSE); | |
660 | ||
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); | |
669 | void SetAxisOrientation(bool xLeftRight, bool yBottomUp); | |
670 | ||
671 | void CalcBoundingBox(int x, int y); | |
672 | void ResetBoundingBox(); | |
673 | ||
674 | %addmethods { | |
675 | void GetBoundingBox(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT); | |
676 | // See below for implementation | |
677 | } | |
678 | ||
679 | #ifdef __WXMSW__ | |
680 | long GetHDC(); | |
681 | #endif | |
682 | ||
683 | ||
684 | %addmethods { | |
685 | // NOTE: These methods are VERY SIMILAR in implentation. It would be | |
686 | // nice to factor out common code and or turn them into a set of | |
687 | // template-like macros. | |
688 | ||
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) { | |
692 | bool isFastSeq = PyList_Check(pyPoints) || PyTuple_Check(pyPoints); | |
693 | bool isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens); | |
694 | int numObjs = 0; | |
695 | int numPens = 0; | |
696 | wxPen* pen; | |
697 | PyObject* obj; | |
698 | int x1, y1; | |
699 | int i = 0; | |
700 | ||
701 | if (!PySequence_Check(pyPoints)) { | |
702 | goto err0; | |
703 | } | |
704 | if (!PySequence_Check(pyPens)) { | |
705 | goto err1; | |
706 | } | |
707 | numObjs = PySequence_Length(pyPoints); | |
708 | numPens = PySequence_Length(pyPens); | |
709 | ||
710 | for (i = 0; i < numObjs; i++) { | |
711 | // Use a new pen? | |
712 | if (i < numPens) { | |
713 | if (isFastPens) { | |
714 | obj = PySequence_Fast_GET_ITEM(pyPens, i); | |
715 | } | |
716 | else { | |
717 | obj = PySequence_GetItem(pyPens, i); | |
718 | } | |
719 | if (SWIG_GetPtrObj(obj, (void **) &pen, "_wxPen_p")) { | |
720 | if (!isFastPens) | |
721 | Py_DECREF(obj); | |
722 | goto err1; | |
723 | } | |
724 | ||
725 | self->SetPen(*pen); | |
726 | if (!isFastPens) | |
727 | Py_DECREF(obj); | |
728 | } | |
729 | ||
730 | // Get the point coordinants | |
731 | if (isFastSeq) { | |
732 | obj = PySequence_Fast_GET_ITEM(pyPoints, i); | |
733 | } | |
734 | else { | |
735 | obj = PySequence_GetItem(pyPoints, i); | |
736 | } | |
737 | if (! _2int_seq_helper(obj, &x1, &y1)) { | |
738 | if (!isFastPens) | |
739 | Py_DECREF(obj); | |
740 | goto err0; | |
741 | } | |
742 | ||
743 | // Now draw the point | |
744 | self->DrawPoint(x1, y1); | |
745 | ||
746 | if (!isFastSeq) | |
747 | Py_DECREF(obj); | |
748 | } | |
749 | ||
750 | Py_INCREF(Py_None); | |
751 | return Py_None; | |
752 | ||
753 | err1: | |
754 | PyErr_SetString(PyExc_TypeError, "Expected a sequence of wxPens"); | |
755 | return NULL; | |
756 | err0: | |
757 | PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x,y) sequences."); | |
758 | return NULL; | |
759 | } | |
760 | ||
761 | ||
762 | // Draw a line for every set of coordinants in pyLines, optionally | |
763 | // setting a new pen for each | |
764 | PyObject* _DrawLineList(PyObject* pyLines, PyObject* pyPens) { | |
765 | bool isFastSeq = PyList_Check(pyLines) || PyTuple_Check(pyLines); | |
766 | bool isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens); | |
767 | int numObjs = 0; | |
768 | int numPens = 0; | |
769 | wxPen* pen; | |
770 | PyObject* obj; | |
771 | int x1, y1, x2, y2; | |
772 | int i = 0; | |
773 | ||
774 | if (!PySequence_Check(pyLines)) { | |
775 | goto err0; | |
776 | } | |
777 | if (!PySequence_Check(pyPens)) { | |
778 | goto err1; | |
779 | } | |
780 | numObjs = PySequence_Length(pyLines); | |
781 | numPens = PySequence_Length(pyPens); | |
782 | ||
783 | for (i = 0; i < numObjs; i++) { | |
784 | // Use a new pen? | |
785 | if (i < numPens) { | |
786 | if (isFastPens) { | |
787 | obj = PySequence_Fast_GET_ITEM(pyPens, i); | |
788 | } | |
789 | else { | |
790 | obj = PySequence_GetItem(pyPens, i); | |
791 | } | |
792 | if (SWIG_GetPtrObj(obj, (void **) &pen, "_wxPen_p")) { | |
793 | if (!isFastPens) | |
794 | Py_DECREF(obj); | |
795 | goto err1; | |
796 | } | |
797 | ||
798 | self->SetPen(*pen); | |
799 | if (!isFastPens) | |
800 | Py_DECREF(obj); | |
801 | } | |
802 | ||
803 | // Get the line coordinants | |
804 | if (isFastSeq) { | |
805 | obj = PySequence_Fast_GET_ITEM(pyLines, i); | |
806 | } | |
807 | else { | |
808 | obj = PySequence_GetItem(pyLines, i); | |
809 | } | |
810 | if (! _4int_seq_helper(obj, &x1, &y1, &x2, &y2)) { | |
811 | if (!isFastPens) | |
812 | Py_DECREF(obj); | |
813 | goto err0; | |
814 | } | |
815 | ||
816 | // Now draw the line | |
817 | self->DrawLine(x1, y1, x2, y2); | |
818 | ||
819 | if (!isFastSeq) | |
820 | Py_DECREF(obj); | |
821 | } | |
822 | ||
823 | Py_INCREF(Py_None); | |
824 | return Py_None; | |
825 | ||
826 | err1: | |
827 | PyErr_SetString(PyExc_TypeError, "Expected a sequence of wxPens"); | |
828 | return NULL; | |
829 | err0: | |
830 | PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x1,y1, x2,y2) sequences."); | |
831 | return NULL; | |
832 | } | |
833 | } | |
834 | ||
835 | ||
836 | %pragma(python) addtoclass = " | |
837 | def DrawPointList(self, points, pens=None): | |
838 | if pens is None: | |
839 | pens = [] | |
840 | elif isinstance(pens, wxPenPtr): | |
841 | pens = [pens] | |
842 | elif len(pens) != len(points): | |
843 | raise ValueError('points and pens must have same length') | |
844 | return self._DrawPointList(points, pens) | |
845 | ||
846 | def DrawLineList(self, lines, pens=None): | |
847 | if pens is None: | |
848 | pens = [] | |
849 | elif isinstance(pens, wxPenPtr): | |
850 | pens = [pens] | |
851 | elif len(pens) != len(lines): | |
852 | raise ValueError('lines and pens must have same length') | |
853 | return self._DrawLineList(lines, pens) | |
854 | " | |
855 | ||
856 | ||
857 | }; | |
858 | ||
859 | ||
860 | ||
861 | %{ | |
862 | static void wxDC_GetBoundingBox(wxDC* dc, int* x1, int* y1, int* x2, int* y2) { | |
863 | *x1 = dc->MinX(); | |
864 | *y1 = dc->MinY(); | |
865 | *x2 = dc->MaxX(); | |
866 | *y2 = dc->MaxY(); | |
867 | } | |
868 | %} | |
869 | ||
870 | //---------------------------------------------------------------------- | |
871 | ||
872 | class wxMemoryDC : public wxDC { | |
873 | public: | |
874 | wxMemoryDC(); | |
875 | ||
876 | void SelectObject(const wxBitmap& bitmap); | |
877 | } | |
878 | ||
879 | %new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC); | |
880 | %{ // Alternate 'constructor' | |
881 | wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) { | |
882 | return new wxMemoryDC(oldDC); | |
883 | } | |
884 | %} | |
885 | ||
886 | ||
887 | //--------------------------------------------------------------------------- | |
888 | ||
889 | class wxBufferedDC : public wxMemoryDC { | |
890 | public: | |
891 | // Construct a wxBufferedDC using a user supplied buffer. | |
892 | wxBufferedDC( wxDC *dc, const wxBitmap &buffer ); | |
893 | ||
894 | // Construct a wxBufferedDC with an internal buffer of 'area' | |
895 | // (where area is usually something like the size of the window | |
896 | // being buffered) | |
897 | %name(wxBufferedDCInternalBuffer)wxBufferedDC( wxDC *dc, const wxSize &area ); | |
898 | ||
899 | // Blits the buffer to the dc, and detaches the dc from | |
900 | // the buffer. Usually called in the dtor or by the dtor | |
901 | // of derived classes if the BufferedDC must blit before | |
902 | // the derived class (which may own the dc it's blitting | |
903 | // to) is destroyed. | |
904 | void UnMask(); | |
905 | ||
906 | ||
907 | %pragma(python) addtomethod = | |
908 | "__init__:self._dc = _args[0] # save a ref so the other dc won't be deleted before self" | |
909 | %pragma(python) addtomethod = | |
910 | "wxBufferedDCInternalBuffer:val._dc = _args[0] # save a ref so the other dc won't be deleted before self" | |
911 | }; | |
912 | ||
913 | ||
914 | class wxBufferedPaintDC : public wxBufferedDC | |
915 | { | |
916 | public: | |
917 | wxBufferedPaintDC( wxWindow *window, const wxBitmap &buffer = wxNullBitmap ); | |
918 | }; | |
919 | ||
920 | //--------------------------------------------------------------------------- | |
921 | ||
922 | class wxScreenDC : public wxDC { | |
923 | public: | |
924 | wxScreenDC(); | |
925 | ||
926 | %name(StartDrawingOnTopWin) bool StartDrawingOnTop(wxWindow* window); | |
927 | bool StartDrawingOnTop(wxRect* rect = NULL); | |
928 | bool EndDrawingOnTop(); | |
929 | }; | |
930 | ||
931 | //--------------------------------------------------------------------------- | |
932 | ||
933 | class wxClientDC : public wxDC { | |
934 | public: | |
935 | wxClientDC(wxWindow* win); | |
936 | }; | |
937 | ||
938 | //--------------------------------------------------------------------------- | |
939 | ||
940 | class wxPaintDC : public wxDC { | |
941 | public: | |
942 | wxPaintDC(wxWindow* win); | |
943 | }; | |
944 | ||
945 | //--------------------------------------------------------------------------- | |
946 | ||
947 | class wxWindowDC : public wxDC { | |
948 | public: | |
949 | wxWindowDC(wxWindow* win); | |
950 | }; | |
951 | ||
952 | //--------------------------------------------------------------------------- | |
953 | ||
954 | ||
955 | #ifdef __WXMSW__ | |
956 | ||
957 | %{ | |
958 | #include <wx/metafile.h> | |
959 | %} | |
960 | ||
961 | class wxMetaFile : public wxObject { | |
962 | public: | |
963 | wxMetaFile(const wxString& filename = wxPyEmptyString); | |
964 | ~wxMetaFile(); | |
965 | ||
966 | bool Ok(); | |
967 | bool SetClipboard(int width = 0, int height = 0); | |
968 | ||
969 | wxSize GetSize(); | |
970 | int GetWidth(); | |
971 | int GetHeight(); | |
972 | ||
973 | const wxString& GetFileName() const { return m_filename; } | |
974 | ||
975 | }; | |
976 | ||
977 | // bool wxMakeMetaFilePlaceable(const wxString& filename, | |
978 | // int minX, int minY, int maxX, int maxY, float scale=1.0); | |
979 | ||
980 | ||
981 | class wxMetaFileDC : public wxDC { | |
982 | public: | |
983 | wxMetaFileDC(const wxString& filename = wxPyEmptyString, | |
984 | int width = 0, int height = 0, | |
985 | const wxString& description = wxPyEmptyString); | |
986 | wxMetaFile* Close(); | |
987 | }; | |
988 | ||
989 | #endif | |
990 | ||
991 | //--------------------------------------------------------------------------- | |
992 | ||
993 | class wxPalette : public wxGDIObject { | |
994 | public: | |
995 | wxPalette(int LCOUNT, byte* choices, byte* choices, byte* choices); | |
996 | ~wxPalette(); | |
997 | ||
998 | int GetPixel(byte red, byte green, byte blue); | |
999 | bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT); | |
1000 | bool Ok(); | |
1001 | }; | |
1002 | ||
1003 | //--------------------------------------------------------------------------- | |
1004 | ||
1005 | enum { | |
1006 | wxIMAGELIST_DRAW_NORMAL , | |
1007 | wxIMAGELIST_DRAW_TRANSPARENT, | |
1008 | wxIMAGELIST_DRAW_SELECTED, | |
1009 | wxIMAGELIST_DRAW_FOCUSED, | |
1010 | wxIMAGE_LIST_NORMAL, | |
1011 | wxIMAGE_LIST_SMALL, | |
1012 | wxIMAGE_LIST_STATE | |
1013 | }; | |
1014 | ||
1015 | class wxImageList : public wxObject { | |
1016 | public: | |
1017 | wxImageList(int width, int height, int mask=TRUE, int initialCount=1); | |
1018 | ~wxImageList(); | |
1019 | ||
1020 | int Add(const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap); | |
1021 | %name(AddWithColourMask)int Add(const wxBitmap& bitmap, const wxColour& maskColour); | |
1022 | %name(AddIcon)int Add(const wxIcon& icon); | |
1023 | #ifdef __WXMSW__ | |
1024 | bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap); | |
1025 | #else | |
1026 | // %name(ReplaceIcon)bool Replace(int index, const wxIcon& icon); | |
1027 | // int Add(const wxBitmap& bitmap); | |
1028 | bool Replace(int index, const wxBitmap& bitmap); | |
1029 | #endif | |
1030 | ||
1031 | bool Draw(int index, wxDC& dc, int x, int x, int flags = wxIMAGELIST_DRAW_NORMAL, | |
1032 | const bool solidBackground = FALSE); | |
1033 | ||
1034 | int GetImageCount(); | |
1035 | bool Remove(int index); | |
1036 | bool RemoveAll(); | |
1037 | void GetSize(int index, int& OUTPUT, int& OUTPUT); | |
1038 | }; | |
1039 | ||
1040 | ||
1041 | //--------------------------------------------------------------------------- | |
1042 | // Regions, etc. | |
1043 | ||
1044 | enum wxRegionContain { | |
1045 | wxOutRegion, wxPartRegion, wxInRegion | |
1046 | }; | |
1047 | ||
1048 | ||
1049 | class wxRegion : public wxGDIObject { | |
1050 | public: | |
1051 | wxRegion(long x=0, long y=0, long width=0, long height=0); | |
1052 | ~wxRegion(); | |
1053 | ||
1054 | void Clear(); | |
1055 | #ifndef __WXMAC__ | |
1056 | bool Offset(wxCoord x, wxCoord y); | |
1057 | #endif | |
1058 | ||
1059 | wxRegionContain Contains(long x, long y); | |
1060 | %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt); | |
1061 | %name(ContainsRect)wxRegionContain Contains(const wxRect& rect); | |
1062 | %name(ContainsRectDim)wxRegionContain Contains(long x, long y, long w, long h); | |
1063 | ||
1064 | wxRect GetBox(); | |
1065 | ||
1066 | bool Intersect(long x, long y, long width, long height); | |
1067 | %name(IntersectRect)bool Intersect(const wxRect& rect); | |
1068 | %name(IntersectRegion)bool Intersect(const wxRegion& region); | |
1069 | ||
1070 | bool IsEmpty(); | |
1071 | ||
1072 | bool Union(long x, long y, long width, long height); | |
1073 | %name(UnionRect)bool Union(const wxRect& rect); | |
1074 | %name(UnionRegion)bool Union(const wxRegion& region); | |
1075 | ||
1076 | bool Subtract(long x, long y, long width, long height); | |
1077 | %name(SubtractRect)bool Subtract(const wxRect& rect); | |
1078 | %name(SubtractRegion)bool Subtract(const wxRegion& region); | |
1079 | ||
1080 | bool Xor(long x, long y, long width, long height); | |
1081 | %name(XorRect)bool Xor(const wxRect& rect); | |
1082 | %name(XorRegion)bool Xor(const wxRegion& region); | |
1083 | }; | |
1084 | ||
1085 | ||
1086 | ||
1087 | class wxRegionIterator : public wxObject { | |
1088 | public: | |
1089 | wxRegionIterator(const wxRegion& region); | |
1090 | ~wxRegionIterator(); | |
1091 | ||
1092 | long GetX(); | |
1093 | long GetY(); | |
1094 | long GetW(); | |
1095 | long GetWidth(); | |
1096 | long GetH(); | |
1097 | long GetHeight(); | |
1098 | wxRect GetRect(); | |
1099 | bool HaveRects(); | |
1100 | void Reset(); | |
1101 | ||
1102 | %addmethods { | |
1103 | void Next() { | |
1104 | (*self) ++; | |
1105 | } | |
1106 | }; | |
1107 | }; | |
1108 | ||
1109 | ||
1110 | //--------------------------------------------------------------------------- | |
1111 | ||
1112 | %readonly | |
1113 | %{ | |
1114 | #if 0 | |
1115 | %} | |
1116 | ||
1117 | extern wxFont *wxNORMAL_FONT; | |
1118 | extern wxFont *wxSMALL_FONT; | |
1119 | extern wxFont *wxITALIC_FONT; | |
1120 | extern wxFont *wxSWISS_FONT; | |
1121 | ||
1122 | extern wxPen *wxRED_PEN; | |
1123 | extern wxPen *wxCYAN_PEN; | |
1124 | extern wxPen *wxGREEN_PEN; | |
1125 | extern wxPen *wxBLACK_PEN; | |
1126 | extern wxPen *wxWHITE_PEN; | |
1127 | extern wxPen *wxTRANSPARENT_PEN; | |
1128 | extern wxPen *wxBLACK_DASHED_PEN; | |
1129 | extern wxPen *wxGREY_PEN; | |
1130 | extern wxPen *wxMEDIUM_GREY_PEN; | |
1131 | extern wxPen *wxLIGHT_GREY_PEN; | |
1132 | ||
1133 | extern wxBrush *wxBLUE_BRUSH; | |
1134 | extern wxBrush *wxGREEN_BRUSH; | |
1135 | extern wxBrush *wxWHITE_BRUSH; | |
1136 | extern wxBrush *wxBLACK_BRUSH; | |
1137 | extern wxBrush *wxTRANSPARENT_BRUSH; | |
1138 | extern wxBrush *wxCYAN_BRUSH; | |
1139 | extern wxBrush *wxRED_BRUSH; | |
1140 | extern wxBrush *wxGREY_BRUSH; | |
1141 | extern wxBrush *wxMEDIUM_GREY_BRUSH; | |
1142 | extern wxBrush *wxLIGHT_GREY_BRUSH; | |
1143 | ||
1144 | extern wxColour *wxBLACK; | |
1145 | extern wxColour *wxWHITE; | |
1146 | extern wxColour *wxRED; | |
1147 | extern wxColour *wxBLUE; | |
1148 | extern wxColour *wxGREEN; | |
1149 | extern wxColour *wxCYAN; | |
1150 | extern wxColour *wxLIGHT_GREY; | |
1151 | ||
1152 | extern wxCursor *wxSTANDARD_CURSOR; | |
1153 | extern wxCursor *wxHOURGLASS_CURSOR; | |
1154 | extern wxCursor *wxCROSS_CURSOR; | |
1155 | ||
1156 | ||
1157 | extern wxBitmap wxNullBitmap; | |
1158 | extern wxIcon wxNullIcon; | |
1159 | extern wxCursor wxNullCursor; | |
1160 | extern wxPen wxNullPen; | |
1161 | extern wxBrush wxNullBrush; | |
1162 | extern wxPalette wxNullPalette; | |
1163 | extern wxFont wxNullFont; | |
1164 | extern wxColour wxNullColour; | |
1165 | ||
1166 | ||
1167 | extern wxFontList* wxTheFontList; | |
1168 | extern wxPenList* wxThePenList; | |
1169 | extern wxBrushList* wxTheBrushList; | |
1170 | extern wxColourDatabase* wxTheColourDatabase; | |
1171 | ||
1172 | ||
1173 | %readwrite | |
1174 | %{ | |
1175 | #endif | |
1176 | %} | |
1177 | ||
1178 | //--------------------------------------------------------------------------- | |
1179 | //--------------------------------------------------------------------------- | |
1180 |