]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/gdi.i
Added calendar contributed by Lorne White
[wxWidgets.git] / utils / wxPython / src / gdi.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: gdi.i
3 // Purpose: SWIG interface file for wxDC, wxBrush, wxPen, wxFont, 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/metafile.h>
19 #include <wx/imaglist.h>
20 #ifndef __WXMSW__
21 #include <wx/dcps.h>
22 #endif
23 %}
24
25 //----------------------------------------------------------------------
26
27 %include typemaps.i
28 %include my_typemaps.i
29
30 // Import some definitions of other classes, etc.
31 %import _defs.i
32 %import misc.i
33
34 //---------------------------------------------------------------------------
35
36 class wxBitmap {
37 public:
38 wxBitmap(const wxString& name, long type);
39 ~wxBitmap();
40
41 #ifdef __WXMSW__
42 void Create(int width, int height, int depth = -1);
43 #endif
44 int GetDepth();
45 int GetHeight();
46 wxPalette* GetPalette();
47 wxMask* GetMask();
48 int GetWidth();
49 bool LoadFile(const wxString& name, long flags);
50 bool Ok();
51 bool SaveFile(const wxString& name, int type, wxPalette* palette = NULL);
52 void SetDepth(int depth);
53 void SetHeight(int height);
54 void SetMask(wxMask* mask);
55 #ifdef __WXMSW__
56 void SetPalette(wxPalette& palette);
57 #endif
58 void SetWidth(int width);
59 };
60
61 %new wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1);
62 wxBitmap* wxNoRefBitmap(char* name, long flags);
63
64 #ifdef __WXMSW__
65 %new wxBitmap* wxBitmapFromData(char* data, long type,
66 int width, int height, int depth = 1);
67 #endif
68
69 %{ // Alternate 'constructor'
70 wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1) {
71 return new wxBitmap(width, height, depth);
72 }
73
74 // This one won't own the reference, so Python
75 // won't call the dtor, this is good for
76 // toolbars and such where the parent will
77 // manage the bitmap.
78 wxBitmap* wxNoRefBitmap(char* name, long flags) {
79 return new wxBitmap(name, flags);
80 }
81
82 #ifdef __WXMSW__
83 wxBitmap* wxBitmapFromData(char* data, long type,
84 int width, int height, int depth = 1) {
85 return new wxBitmap((void*)data, type, width, height, depth);
86 }
87 #endif
88 %}
89
90 //---------------------------------------------------------------------------
91
92 class wxMask {
93 public:
94 wxMask(const wxBitmap& bitmap);
95 ~wxMask();
96 };
97
98 %new wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour);
99 %{
100 wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour) {
101 return new wxMask(bitmap, colour);
102 }
103 %}
104
105
106 //---------------------------------------------------------------------------
107
108
109 class wxIcon : public wxBitmap {
110 public:
111 wxIcon(const wxString& name, long flags,
112 int desiredWidth = -1, int desiredHeight = -1);
113 ~wxIcon();
114
115 int GetDepth();
116 int GetHeight();
117 int GetWidth();
118 bool LoadFile(const wxString& name, long flags);
119 bool Ok();
120 void SetDepth(int depth);
121 void SetHeight(int height);
122 void SetWidth(int width);
123 };
124
125
126 //---------------------------------------------------------------------------
127
128 class wxCursor : public wxBitmap {
129 public:
130 #ifdef __WXMSW__
131 wxCursor(const wxString& cursorName, long flags, int hotSpotX=0, int hotSpotY=0);
132 #endif
133 ~wxCursor();
134 bool Ok();
135 };
136
137 %name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id);
138 %{ // Alternate 'constructor'
139 wxCursor* wxPyStockCursor(int id) {
140 return new wxCursor(id);
141 }
142 %}
143
144 //----------------------------------------------------------------------
145
146
147 enum wxFontEncoding
148 {
149 wxFONTENCODING_SYSTEM = -1, // system default
150 wxFONTENCODING_DEFAULT, // current default encoding
151
152 // ISO8859 standard defines a number of single-byte charsets
153 wxFONTENCODING_ISO8859_1, // West European (Latin1)
154 wxFONTENCODING_ISO8859_2, // Central and East European (Latin2)
155 wxFONTENCODING_ISO8859_3, // Esperanto (Latin3)
156 wxFONTENCODING_ISO8859_4, // Baltic languages (Estonian) (Latin4)
157 wxFONTENCODING_ISO8859_5, // Cyrillic
158 wxFONTENCODING_ISO8859_6, // Arabic
159 wxFONTENCODING_ISO8859_7, // Greek
160 wxFONTENCODING_ISO8859_8, // Hebrew
161 wxFONTENCODING_ISO8859_9, // Turkish (Latin5)
162 wxFONTENCODING_ISO8859_10, // Variation of Latin4 (Latin6)
163 wxFONTENCODING_ISO8859_11, // Thai
164 wxFONTENCODING_ISO8859_12, // doesn't exist currently, but put it
165 // here anyhow to make all ISO8859
166 // consecutive numbers
167 wxFONTENCODING_ISO8859_13, // Latin7
168 wxFONTENCODING_ISO8859_14, // Latin8
169 wxFONTENCODING_ISO8859_15, // Latin9 (a.k.a. Latin0, includes euro)
170
171 // Cyrillic charset soup (see http://czyborra.com/charsets/cyrillic.html)
172 wxFONTENCODING_KOI8, // we don't support any of KOI8 variants
173 wxFONTENCODING_ALTERNATIVE, // same as MS-DOS CP866
174 wxFONTENCODING_BULGARIAN, // used under Linux in Bulgaria
175
176 // what would we do without Microsoft? They have their own encodings
177 // for DOS
178 wxFONTENCODING_CP437, // original MS-DOS codepage
179 wxFONTENCODING_CP850, // CP437 merged with Latin1
180 wxFONTENCODING_CP852, // CP437 merged with Latin2
181 wxFONTENCODING_CP855, // another cyrillic encoding
182 wxFONTENCODING_CP866, // and another one
183 // and for Windows
184 wxFONTENCODING_CP1250, // WinLatin2
185 wxFONTENCODING_CP1251, // WinCyrillic
186 wxFONTENCODING_CP1252, // WinLatin1
187
188 wxFONTENCODING_MAX
189 };
190
191 class wxFont {
192 public:
193 // I'll do it this way to use long-lived objects and not have to
194 // worry about when python may delete the object.
195 %addmethods {
196 wxFont( int pointSize, int family, int style, int weight,
197 int underline=FALSE, char* faceName = "",
198 wxFontEncoding encoding=wxFONTENCODING_DEFAULT) {
199
200 return wxTheFontList->FindOrCreateFont(pointSize, family, style, weight,
201 underline, faceName);
202 }
203 // NO Destructor.
204 }
205
206
207 wxString GetFaceName();
208 int GetFamily();
209 #ifdef __WXMSW__
210 int GetFontId();
211 #endif
212 int GetPointSize();
213 int GetStyle();
214 bool GetUnderlined();
215 int GetWeight();
216 wxFontEncoding GetEncoding();
217 void SetFaceName(const wxString& faceName);
218 void SetFamily(int family);
219 void SetPointSize(int pointSize);
220 void SetStyle(int style);
221 void SetUnderlined(bool underlined);
222 void SetWeight(int weight);
223 void SetEncoding(wxFontEncoding encoding);
224 wxString GetFamilyString();
225 wxString GetStyleString();
226 wxString GetWeightString();
227 };
228
229 %inline %{
230 wxFontEncoding wxFont_GetDefaultEncoding() {
231 return wxFont::GetDefaultEncoding();
232 }
233
234 void wxFont_SetDefaultEncoding(wxFontEncoding encoding) {
235 wxFont::SetDefaultEncoding(encoding);
236 }
237 %}
238
239 //----------------------------------------------------------------------
240
241 class wxColour {
242 public:
243 wxColour(unsigned char red=0, unsigned char green=0, unsigned char blue=0);
244 ~wxColour();
245 unsigned char Red();
246 unsigned char Green();
247 unsigned char Blue();
248 bool Ok();
249 void Set(unsigned char red, unsigned char green, unsigned char blue);
250 %addmethods {
251 PyObject* Get() {
252 PyObject* rv = PyTuple_New(3);
253 PyTuple_SetItem(rv, 0, PyInt_FromLong(self->Red()));
254 PyTuple_SetItem(rv, 1, PyInt_FromLong(self->Green()));
255 PyTuple_SetItem(rv, 2, PyInt_FromLong(self->Blue()));
256 return rv;
257 }
258 }
259 };
260
261 %new wxColour* wxNamedColour(const wxString& colorName);
262 %{ // Alternate 'constructor'
263 wxColour* wxNamedColour(const wxString& colorName) {
264 return new wxColour(colorName);
265 }
266 %}
267
268
269 //----------------------------------------------------------------------
270
271 typedef unsigned long wxDash;
272
273 class wxPen {
274 public:
275 // I'll do it this way to use long-lived objects and not have to
276 // worry about when python may delete the object.
277 %addmethods {
278 wxPen(wxColour* colour, int width=1, int style=wxSOLID) {
279 return wxThePenList->FindOrCreatePen(*colour, width, style);
280 }
281 // NO Destructor.
282 }
283
284 int GetCap();
285 wxColour& GetColour();
286
287 int GetJoin();
288 int GetStyle();
289 int GetWidth();
290 bool Ok();
291 void SetCap(int cap_style);
292 void SetColour(wxColour& colour);
293 void SetJoin(int join_style);
294 void SetStyle(int style);
295 void SetWidth(int width);
296
297 #ifdef __WXMSW__
298 // **** This one needs to return a list of ints (wxDash)
299 int GetDashes(wxDash **dashes);
300 wxBitmap* GetStipple();
301 void SetDashes(int LCOUNT, wxDash* LIST);
302 void SetStipple(wxBitmap& stipple);
303 #endif
304 };
305
306 //----------------------------------------------------------------------
307
308 class wxBrush {
309 public:
310 // I'll do it this way to use long-lived objects and not have to
311 // worry about when python may delete the object.
312 %addmethods {
313 wxBrush(wxColour* colour, int style=wxSOLID) {
314 return wxTheBrushList->FindOrCreateBrush(*colour, style);
315 }
316 // NO Destructor.
317 }
318
319 wxColour& GetColour();
320 wxBitmap * GetStipple();
321 int GetStyle();
322 bool Ok();
323 void SetColour(wxColour &colour);
324 void SetStipple(wxBitmap& bitmap);
325 void SetStyle(int style);
326 };
327
328 //----------------------------------------------------------------------
329
330
331
332 class wxDC {
333 public:
334 // wxDC(); **** abstract base class, can't instantiate.
335 ~wxDC();
336
337 void BeginDrawing();
338 // %name(BlitXY)
339 bool Blit(long xdest, long ydest,
340 long width, long height,
341 wxDC *source, long xsrc, long ysrc,
342 int logicalFunc = wxCOPY, int useMask = FALSE);
343 // bool Blit(const wxPoint& destPt, const wxSize& sz,
344 // wxDC *source, const wxPoint& srcPt,
345 // int logicalFunc = wxCOPY, int useMask = FALSE);
346
347 void Clear();
348 void CrossHair(long x, long y);
349 void DestroyClippingRegion();
350 long DeviceToLogicalX(long x);
351 long DeviceToLogicalXRel(long x);
352 long DeviceToLogicalY(long y);
353 long DeviceToLogicalYRel(long y);
354 void DrawArc(long x1, long y1, long x2, long y2, long xc, long yc);
355 void DrawCircle(long x, long y, long radius);
356 void DrawEllipse(long x, long y, long width, long height);
357 void DrawEllipticArc(long x, long y, long width, long height, long start, long end);
358 void DrawIcon(const wxIcon& icon, long x, long y);
359 void DrawLine(long x1, long y1, long x2, long y2);
360 void DrawLines(int LCOUNT, wxPoint* LIST, long xoffset=0, long yoffset=0);
361 void DrawPolygon(int LCOUNT, wxPoint* LIST, long xoffset=0, long yoffset=0,
362 int fill_style=wxODDEVEN_RULE);
363 void DrawPoint(long x, long y);
364 void DrawRectangle(long x, long y, long width, long height);
365 void DrawRoundedRectangle(long x, long y, long width, long height, long radius=20);
366 void DrawSpline(int LCOUNT, wxPoint* LIST);
367 void DrawText(const wxString& text, long x, long y);
368 void EndDoc();
369 void EndDrawing();
370 void EndPage();
371 void FloodFill(long x, long y, const wxColour& colour, int style=wxFLOOD_SURFACE);
372 wxBrush& GetBackground();
373 wxBrush& GetBrush();
374 long GetCharHeight();
375 long GetCharWidth();
376 void GetClippingBox(long *OUTPUT, long *OUTPUT,
377 long *OUTPUT, long *OUTPUT);
378 wxFont& GetFont();
379 int GetLogicalFunction();
380 int GetMapMode();
381 bool GetOptimization();
382 wxPen& GetPen();
383 %addmethods {
384 %new wxColour* GetPixel(long x, long y) {
385 wxColour* wc = new wxColour();
386 self->GetPixel(x, y, wc);
387 return wc;
388 }
389 }
390 %name(GetSizeTuple)void GetSize(int* OUTPUT, int* OUTPUT);
391 wxSize GetSize();
392 wxColour& GetTextBackground();
393 void GetTextExtent(const wxString& string, long *OUTPUT, long *OUTPUT);
394 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
395 long *OUTPUT, long *OUTPUT, long *OUTPUT, long* OUTPUT,
396 const wxFont* font = NULL);
397 wxColour& GetTextForeground();
398 long LogicalToDeviceX(long x);
399 long LogicalToDeviceXRel(long x);
400 long LogicalToDeviceY(long y);
401 long LogicalToDeviceYRel(long y);
402 long MaxX();
403 long MaxY();
404 long MinX();
405 long MinY();
406 bool Ok();
407 void SetDeviceOrigin(long x, long y);
408 void SetBackground(const wxBrush& brush);
409 void SetBackgroundMode(int mode);
410 void SetClippingRegion(long x, long y, long width, long height);
411 void SetPalette(const wxPalette& colourMap);
412 void SetBrush(const wxBrush& brush);
413 void SetFont(const wxFont& font);
414 void SetLogicalFunction(int function);
415 void SetMapMode(int mode);
416 void SetOptimization(bool optimize);
417 void SetPen(const wxPen& pen);
418 void SetTextBackground(const wxColour& colour);
419 void SetTextForeground(const wxColour& colour);
420 void SetUserScale(double x_scale, double y_scale);
421 bool StartDoc(const wxString& message);
422 void StartPage();
423
424
425 // Don't need this one anymore as wxWindows has one...
426 // %addmethods {
427 // // This one is my own creation...
428 // void DrawBitmap(wxBitmap& bitmap, long x, long y, bool swapPalette=TRUE) {
429 // wxMemoryDC* memDC = new wxMemoryDC;
430 // memDC->SelectObject(bitmap);
431 // #ifdef __WXMSW__
432 // if (swapPalette)
433 // self->SetPalette(*bitmap.GetPalette());
434 // #endif
435 // self->Blit(x, y, bitmap.GetWidth(), bitmap.GetHeight(), memDC,
436 // 0, 0, self->GetLogicalFunction());
437 // memDC->SelectObject(wxNullBitmap);
438 // delete memDC;
439 // }
440 // }
441
442 void DrawBitmap(const wxBitmap& bitmap, long x, long y,
443 int useMask = FALSE);
444
445 };
446
447
448 //----------------------------------------------------------------------
449
450 class wxMemoryDC : public wxDC {
451 public:
452 wxMemoryDC();
453
454 void SelectObject(const wxBitmap& bitmap);
455 }
456
457 %new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC);
458 %{ // Alternate 'constructor'
459 wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) {
460 return new wxMemoryDC(oldDC);
461 }
462 %}
463
464
465 //---------------------------------------------------------------------------
466
467 class wxScreenDC : public wxDC {
468 public:
469 wxScreenDC();
470
471 bool StartDrawingOnTop(wxWindow* window);
472 %name(StartDrawingOnTopRect) bool StartDrawingOnTop(wxRect* rect = NULL);
473 bool EndDrawingOnTop();
474 };
475
476 //---------------------------------------------------------------------------
477
478 class wxClientDC : public wxDC {
479 public:
480 wxClientDC(wxWindow* win);
481 };
482
483 //---------------------------------------------------------------------------
484
485 class wxPaintDC : public wxDC {
486 public:
487 wxPaintDC(wxWindow* win);
488 };
489
490 //---------------------------------------------------------------------------
491
492 class wxWindowDC : public wxDC {
493 public:
494 wxWindowDC(wxWindow* win);
495 };
496
497 //---------------------------------------------------------------------------
498
499 #ifndef __WXMSW__
500 class wxPostScriptDC : public wxDC {
501 public:
502 wxPostScriptDC(const wxString& output, bool interactive = TRUE, wxWindow* win = NULL);
503 };
504 #endif
505
506 //---------------------------------------------------------------------------
507
508 #ifdef __WXMSW__
509 class wxPrinterDC : public wxDC {
510 public:
511 wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output,
512 bool interactive = TRUE, int orientation = wxPORTRAIT);
513 };
514 #endif
515
516 //---------------------------------------------------------------------------
517
518 #ifdef __WXMSW__
519 class wxMetaFileDC : public wxDC {
520 public:
521 wxMetaFileDC(const wxString& filename = wxPyEmptyStr);
522 wxMetaFile* Close();
523 };
524 #endif
525
526 //---------------------------------------------------------------------------
527 //---------------------------------------------------------------------------
528
529
530 %readonly
531 %{
532 #if 0
533 %}
534 extern wxFont *wxNORMAL_FONT;
535 extern wxFont *wxSMALL_FONT;
536 extern wxFont *wxITALIC_FONT;
537 extern wxFont *wxSWISS_FONT;
538
539 extern wxPen *wxRED_PEN;
540 extern wxPen *wxCYAN_PEN;
541 extern wxPen *wxGREEN_PEN;
542 extern wxPen *wxBLACK_PEN;
543 extern wxPen *wxWHITE_PEN;
544 extern wxPen *wxTRANSPARENT_PEN;
545 extern wxPen *wxBLACK_DASHED_PEN;
546 extern wxPen *wxGREY_PEN;
547 extern wxPen *wxMEDIUM_GREY_PEN;
548 extern wxPen *wxLIGHT_GREY_PEN;
549
550 extern wxBrush *wxBLUE_BRUSH;
551 extern wxBrush *wxGREEN_BRUSH;
552 extern wxBrush *wxWHITE_BRUSH;
553 extern wxBrush *wxBLACK_BRUSH;
554 extern wxBrush *wxTRANSPARENT_BRUSH;
555 extern wxBrush *wxCYAN_BRUSH;
556 extern wxBrush *wxRED_BRUSH;
557 extern wxBrush *wxGREY_BRUSH;
558 extern wxBrush *wxMEDIUM_GREY_BRUSH;
559 extern wxBrush *wxLIGHT_GREY_BRUSH;
560
561 extern wxColour *wxBLACK;
562 extern wxColour *wxWHITE;
563 extern wxColour *wxRED;
564 extern wxColour *wxBLUE;
565 extern wxColour *wxGREEN;
566 extern wxColour *wxCYAN;
567 extern wxColour *wxLIGHT_GREY;
568
569 extern wxCursor *wxSTANDARD_CURSOR;
570 extern wxCursor *wxHOURGLASS_CURSOR;
571 extern wxCursor *wxCROSS_CURSOR;
572
573 extern wxBitmap wxNullBitmap;
574 extern wxIcon wxNullIcon;
575 extern wxCursor wxNullCursor;
576 extern wxPen wxNullPen;
577 extern wxBrush wxNullBrush;
578 extern wxPalette wxNullPalette;
579 extern wxFont wxNullFont;
580 extern wxColour wxNullColour;
581
582 %readwrite
583 %{
584 #endif
585 %}
586
587 //---------------------------------------------------------------------------
588
589 class wxPalette {
590 public:
591 wxPalette(int LCOUNT, byte* LIST, byte* LIST, byte* LIST);
592 ~wxPalette();
593
594 int GetPixel(byte red, byte green, byte blue);
595 bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT);
596 bool Ok();
597 };
598
599 //---------------------------------------------------------------------------
600
601 enum {
602 wxIMAGELIST_DRAW_NORMAL ,
603 wxIMAGELIST_DRAW_TRANSPARENT,
604 wxIMAGELIST_DRAW_SELECTED,
605 wxIMAGELIST_DRAW_FOCUSED,
606 wxIMAGE_LIST_NORMAL,
607 wxIMAGE_LIST_SMALL,
608 wxIMAGE_LIST_STATE
609 };
610
611 class wxImageList {
612 public:
613 wxImageList(int width, int height, const bool mask=TRUE, int initialCount=1);
614 ~wxImageList();
615
616 #ifdef __WXMSW__
617 int Add(const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
618 %name(AddWithColourMask)int Add(const wxBitmap& bitmap, const wxColour& maskColour);
619 %name(AddIcon)int Add(const wxIcon& icon);
620 bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
621 %name(ReplaceIcon)bool Replace(int index, const wxIcon& icon);
622 #else
623 int Add(const wxBitmap& bitmap);
624 bool Replace(int index, const wxBitmap& bitmap);
625 #endif
626
627 bool Draw(int index, wxDC& dc, int x, int x, int flags = wxIMAGELIST_DRAW_NORMAL,
628 const bool solidBackground = FALSE);
629
630 int GetImageCount();
631 bool Remove(int index);
632 bool RemoveAll();
633 };
634
635
636 //---------------------------------------------------------------------------
637