]> git.saurik.com Git - wxWidgets.git/blame - utils/wxPython/src/gdi.i
code cleanup
[wxWidgets.git] / utils / wxPython / src / gdi.i
CommitLineData
7bf85405
RD
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
03e9bead
RD
14%module gdi
15
16%{
7bf85405 17#include "helpers.h"
7bf85405 18#include <wx/metafile.h>
af309447 19#include <wx/imaglist.h>
105e45b9 20#ifndef __WXMSW__
08127323 21#include <wx/dcps.h>
105e45b9 22#endif
7bf85405
RD
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
36class wxBitmap {
37public:
38 wxBitmap(const wxString& name, long type);
39 ~wxBitmap();
40
fb5e0af0 41#ifdef __WXMSW__
7bf85405 42 void Create(int width, int height, int depth = -1);
fb5e0af0 43#endif
7bf85405
RD
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);
fb5e0af0 55#ifdef __WXMSW__
b8b8dda7 56 void SetPalette(wxPalette& palette);
fb5e0af0 57#endif
7bf85405
RD
58 void SetWidth(int width);
59};
60
61%new wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1);
62wxBitmap* wxNoRefBitmap(char* name, long flags);
9c039d08 63
8bf5d46e
RD
64#ifdef __WXMSW__
65%new wxBitmap* wxBitmapFromData(char* data, long type,
66 int width, int height, int depth = 1);
67#endif
68
7bf85405
RD
69%{ // Alternate 'constructor'
70 wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1) {
71 return new wxBitmap(width, height, depth);
72 }
73
cf694132
RD
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.
7bf85405
RD
78 wxBitmap* wxNoRefBitmap(char* name, long flags) {
79 return new wxBitmap(name, flags);
80 }
8bf5d46e
RD
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
7bf85405
RD
88%}
89
90//---------------------------------------------------------------------------
91
92class wxMask {
93public:
94 wxMask(const wxBitmap& bitmap);
eb715945 95 //~wxMask();
7bf85405
RD
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
109class wxIcon : public wxBitmap {
110public:
fb5e0af0
RD
111 wxIcon(const wxString& name, long flags,
112 int desiredWidth = -1, int desiredHeight = -1);
7bf85405
RD
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);
7bf85405
RD
122 void SetWidth(int width);
123};
124
8bf5d46e 125
7bf85405
RD
126//---------------------------------------------------------------------------
127
128class wxCursor : public wxBitmap {
129public:
fb5e0af0 130#ifdef __WXMSW__
7bf85405 131 wxCursor(const wxString& cursorName, long flags, int hotSpotX=0, int hotSpotY=0);
fb5e0af0 132#endif
7bf85405
RD
133 ~wxCursor();
134 bool Ok();
135};
136
9c039d08 137%name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id);
7bf85405 138%{ // Alternate 'constructor'
9c039d08 139 wxCursor* wxPyStockCursor(int id) {
7bf85405
RD
140 return new wxCursor(id);
141 }
142%}
143
144//----------------------------------------------------------------------
145
f0261a72
RD
146
147enum 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
7bf85405
RD
191class wxFont {
192public:
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,
f0261a72
RD
197 int underline=FALSE, char* faceName = "",
198 wxFontEncoding encoding=wxFONTENCODING_DEFAULT) {
7bf85405
RD
199
200 return wxTheFontList->FindOrCreateFont(pointSize, family, style, weight,
694759cf 201 underline, faceName, encoding);
7bf85405
RD
202 }
203 // NO Destructor.
204 }
205
694759cf 206 bool Ok();
7bf85405
RD
207
208 wxString GetFaceName();
209 int GetFamily();
08127323 210#ifdef __WXMSW__
7bf85405 211 int GetFontId();
08127323 212#endif
7bf85405
RD
213 int GetPointSize();
214 int GetStyle();
215 bool GetUnderlined();
216 int GetWeight();
f0261a72 217 wxFontEncoding GetEncoding();
7bf85405
RD
218 void SetFaceName(const wxString& faceName);
219 void SetFamily(int family);
220 void SetPointSize(int pointSize);
221 void SetStyle(int style);
222 void SetUnderlined(bool underlined);
223 void SetWeight(int weight);
f0261a72
RD
224 void SetEncoding(wxFontEncoding encoding);
225 wxString GetFamilyString();
226 wxString GetStyleString();
227 wxString GetWeightString();
7bf85405
RD
228};
229
f0261a72
RD
230%inline %{
231 wxFontEncoding wxFont_GetDefaultEncoding() {
232 return wxFont::GetDefaultEncoding();
233 }
234
235 void wxFont_SetDefaultEncoding(wxFontEncoding encoding) {
236 wxFont::SetDefaultEncoding(encoding);
237 }
238%}
239
7bf85405
RD
240//----------------------------------------------------------------------
241
242class wxColour {
243public:
244 wxColour(unsigned char red=0, unsigned char green=0, unsigned char blue=0);
245 ~wxColour();
246 unsigned char Red();
247 unsigned char Green();
248 unsigned char Blue();
249 bool Ok();
250 void Set(unsigned char red, unsigned char green, unsigned char blue);
251 %addmethods {
252 PyObject* Get() {
253 PyObject* rv = PyTuple_New(3);
254 PyTuple_SetItem(rv, 0, PyInt_FromLong(self->Red()));
255 PyTuple_SetItem(rv, 1, PyInt_FromLong(self->Green()));
256 PyTuple_SetItem(rv, 2, PyInt_FromLong(self->Blue()));
257 return rv;
258 }
259 }
260};
261
262%new wxColour* wxNamedColour(const wxString& colorName);
263%{ // Alternate 'constructor'
264 wxColour* wxNamedColour(const wxString& colorName) {
265 return new wxColour(colorName);
266 }
267%}
268
269
270//----------------------------------------------------------------------
271
272typedef unsigned long wxDash;
273
274class wxPen {
275public:
276 // I'll do it this way to use long-lived objects and not have to
277 // worry about when python may delete the object.
278 %addmethods {
279 wxPen(wxColour* colour, int width=1, int style=wxSOLID) {
280 return wxThePenList->FindOrCreatePen(*colour, width, style);
281 }
282 // NO Destructor.
283 }
284
285 int GetCap();
286 wxColour& GetColour();
287
fb5e0af0 288 int GetJoin();
7bf85405
RD
289 int GetStyle();
290 int GetWidth();
291 bool Ok();
292 void SetCap(int cap_style);
293 void SetColour(wxColour& colour);
aeeb6a44
RR
294 void SetJoin(int join_style);
295 void SetStyle(int style);
296 void SetWidth(int width);
08127323 297
fb5e0af0 298#ifdef __WXMSW__
aeeb6a44
RR
299 // **** This one needs to return a list of ints (wxDash)
300 int GetDashes(wxDash **dashes);
301 wxBitmap* GetStipple();
7bf85405 302 void SetDashes(int LCOUNT, wxDash* LIST);
b8b8dda7 303 void SetStipple(wxBitmap& stipple);
fb5e0af0 304#endif
7bf85405
RD
305};
306
307//----------------------------------------------------------------------
308
309class wxBrush {
310public:
311 // I'll do it this way to use long-lived objects and not have to
312 // worry about when python may delete the object.
313 %addmethods {
314 wxBrush(wxColour* colour, int style=wxSOLID) {
315 return wxTheBrushList->FindOrCreateBrush(*colour, style);
316 }
317 // NO Destructor.
318 }
319
320 wxColour& GetColour();
321 wxBitmap * GetStipple();
322 int GetStyle();
323 bool Ok();
324 void SetColour(wxColour &colour);
b8b8dda7 325 void SetStipple(wxBitmap& bitmap);
7bf85405
RD
326 void SetStyle(int style);
327};
328
329//----------------------------------------------------------------------
330
331
332
333class wxDC {
334public:
fb5e0af0 335// wxDC(); **** abstract base class, can't instantiate.
7bf85405
RD
336 ~wxDC();
337
338 void BeginDrawing();
efc5f224
RD
339// %name(BlitXY)
340 bool Blit(long xdest, long ydest,
341 long width, long height,
342 wxDC *source, long xsrc, long ysrc,
343 int logicalFunc = wxCOPY, int useMask = FALSE);
344// bool Blit(const wxPoint& destPt, const wxSize& sz,
345// wxDC *source, const wxPoint& srcPt,
346// int logicalFunc = wxCOPY, int useMask = FALSE);
347
7bf85405
RD
348 void Clear();
349 void CrossHair(long x, long y);
350 void DestroyClippingRegion();
351 long DeviceToLogicalX(long x);
352 long DeviceToLogicalXRel(long x);
353 long DeviceToLogicalY(long y);
354 long DeviceToLogicalYRel(long y);
355 void DrawArc(long x1, long y1, long x2, long y2, long xc, long yc);
bb0054cd 356 void DrawCircle(long x, long y, long radius);
7bf85405
RD
357 void DrawEllipse(long x, long y, long width, long height);
358 void DrawEllipticArc(long x, long y, long width, long height, long start, long end);
359 void DrawIcon(const wxIcon& icon, long x, long y);
360 void DrawLine(long x1, long y1, long x2, long y2);
361 void DrawLines(int LCOUNT, wxPoint* LIST, long xoffset=0, long yoffset=0);
362 void DrawPolygon(int LCOUNT, wxPoint* LIST, long xoffset=0, long yoffset=0,
363 int fill_style=wxODDEVEN_RULE);
364 void DrawPoint(long x, long y);
365 void DrawRectangle(long x, long y, long width, long height);
366 void DrawRoundedRectangle(long x, long y, long width, long height, long radius=20);
367 void DrawSpline(int LCOUNT, wxPoint* LIST);
368 void DrawText(const wxString& text, long x, long y);
369 void EndDoc();
370 void EndDrawing();
371 void EndPage();
372 void FloodFill(long x, long y, const wxColour& colour, int style=wxFLOOD_SURFACE);
b8b8dda7
RD
373 wxBrush& GetBackground();
374 wxBrush& GetBrush();
7bf85405
RD
375 long GetCharHeight();
376 long GetCharWidth();
377 void GetClippingBox(long *OUTPUT, long *OUTPUT,
378 long *OUTPUT, long *OUTPUT);
b8b8dda7 379 wxFont& GetFont();
7bf85405
RD
380 int GetLogicalFunction();
381 int GetMapMode();
382 bool GetOptimization();
b8b8dda7 383 wxPen& GetPen();
fb5e0af0
RD
384 %addmethods {
385 %new wxColour* GetPixel(long x, long y) {
386 wxColour* wc = new wxColour();
387 self->GetPixel(x, y, wc);
388 return wc;
389 }
390 }
bb0054cd
RD
391 %name(GetSizeTuple)void GetSize(int* OUTPUT, int* OUTPUT);
392 wxSize GetSize();
7bf85405 393 wxColour& GetTextBackground();
af309447
RD
394 void GetTextExtent(const wxString& string, long *OUTPUT, long *OUTPUT);
395 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
396 long *OUTPUT, long *OUTPUT, long *OUTPUT, long* OUTPUT,
397 const wxFont* font = NULL);
7bf85405
RD
398 wxColour& GetTextForeground();
399 long LogicalToDeviceX(long x);
400 long LogicalToDeviceXRel(long x);
401 long LogicalToDeviceY(long y);
402 long LogicalToDeviceYRel(long y);
403 long MaxX();
404 long MaxY();
405 long MinX();
406 long MinY();
407 bool Ok();
408 void SetDeviceOrigin(long x, long y);
409 void SetBackground(const wxBrush& brush);
410 void SetBackgroundMode(int mode);
411 void SetClippingRegion(long x, long y, long width, long height);
412 void SetPalette(const wxPalette& colourMap);
413 void SetBrush(const wxBrush& brush);
414 void SetFont(const wxFont& font);
415 void SetLogicalFunction(int function);
416 void SetMapMode(int mode);
417 void SetOptimization(bool optimize);
418 void SetPen(const wxPen& pen);
419 void SetTextBackground(const wxColour& colour);
420 void SetTextForeground(const wxColour& colour);
421 void SetUserScale(double x_scale, double y_scale);
422 bool StartDoc(const wxString& message);
423 void StartPage();
424
425
efc5f224
RD
426// Don't need this one anymore as wxWindows has one...
427// %addmethods {
428// // This one is my own creation...
429// void DrawBitmap(wxBitmap& bitmap, long x, long y, bool swapPalette=TRUE) {
430// wxMemoryDC* memDC = new wxMemoryDC;
431// memDC->SelectObject(bitmap);
432// #ifdef __WXMSW__
433// if (swapPalette)
434// self->SetPalette(*bitmap.GetPalette());
435// #endif
436// self->Blit(x, y, bitmap.GetWidth(), bitmap.GetHeight(), memDC,
437// 0, 0, self->GetLogicalFunction());
438// memDC->SelectObject(wxNullBitmap);
439// delete memDC;
440// }
441// }
442
443 void DrawBitmap(const wxBitmap& bitmap, long x, long y,
444 int useMask = FALSE);
445
7bf85405
RD
446};
447
448
449//----------------------------------------------------------------------
450
451class wxMemoryDC : public wxDC {
452public:
453 wxMemoryDC();
454
455 void SelectObject(const wxBitmap& bitmap);
456}
457
458%new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC);
459%{ // Alternate 'constructor'
460 wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) {
461 return new wxMemoryDC(oldDC);
462 }
463%}
464
465
466//---------------------------------------------------------------------------
467
468class wxScreenDC : public wxDC {
469public:
470 wxScreenDC();
471
472 bool StartDrawingOnTop(wxWindow* window);
473 %name(StartDrawingOnTopRect) bool StartDrawingOnTop(wxRect* rect = NULL);
474 bool EndDrawingOnTop();
475};
476
477//---------------------------------------------------------------------------
478
479class wxClientDC : public wxDC {
480public:
481 wxClientDC(wxWindow* win);
482};
483
484//---------------------------------------------------------------------------
485
486class wxPaintDC : public wxDC {
487public:
488 wxPaintDC(wxWindow* win);
489};
490
491//---------------------------------------------------------------------------
492
b639c3c5
RD
493class wxWindowDC : public wxDC {
494public:
495 wxWindowDC(wxWindow* win);
496};
b639c3c5
RD
497
498//---------------------------------------------------------------------------
499
be4d9c1f 500#ifndef __WXMSW__
7bf85405
RD
501class wxPostScriptDC : public wxDC {
502public:
503 wxPostScriptDC(const wxString& output, bool interactive = TRUE, wxWindow* win = NULL);
504};
be4d9c1f 505#endif
7bf85405
RD
506
507//---------------------------------------------------------------------------
508
fb5e0af0 509#ifdef __WXMSW__
7bf85405
RD
510class wxPrinterDC : public wxDC {
511public:
512 wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output,
513 bool interactive = TRUE, int orientation = wxPORTRAIT);
514};
fb5e0af0 515#endif
7bf85405
RD
516
517//---------------------------------------------------------------------------
518
fb5e0af0 519#ifdef __WXMSW__
7bf85405
RD
520class wxMetaFileDC : public wxDC {
521public:
522 wxMetaFileDC(const wxString& filename = wxPyEmptyStr);
523 wxMetaFile* Close();
524};
fb5e0af0 525#endif
7bf85405
RD
526
527//---------------------------------------------------------------------------
528//---------------------------------------------------------------------------
529
530
531%readonly
af309447
RD
532%{
533#if 0
534%}
7bf85405
RD
535extern wxFont *wxNORMAL_FONT;
536extern wxFont *wxSMALL_FONT;
537extern wxFont *wxITALIC_FONT;
538extern wxFont *wxSWISS_FONT;
7bf85405 539
1afc06c2 540extern wxPen *wxRED_PEN;
7bf85405
RD
541extern wxPen *wxCYAN_PEN;
542extern wxPen *wxGREEN_PEN;
543extern wxPen *wxBLACK_PEN;
544extern wxPen *wxWHITE_PEN;
545extern wxPen *wxTRANSPARENT_PEN;
546extern wxPen *wxBLACK_DASHED_PEN;
547extern wxPen *wxGREY_PEN;
548extern wxPen *wxMEDIUM_GREY_PEN;
549extern wxPen *wxLIGHT_GREY_PEN;
550
551extern wxBrush *wxBLUE_BRUSH;
552extern wxBrush *wxGREEN_BRUSH;
553extern wxBrush *wxWHITE_BRUSH;
554extern wxBrush *wxBLACK_BRUSH;
555extern wxBrush *wxTRANSPARENT_BRUSH;
556extern wxBrush *wxCYAN_BRUSH;
557extern wxBrush *wxRED_BRUSH;
558extern wxBrush *wxGREY_BRUSH;
559extern wxBrush *wxMEDIUM_GREY_BRUSH;
560extern wxBrush *wxLIGHT_GREY_BRUSH;
561
562extern wxColour *wxBLACK;
563extern wxColour *wxWHITE;
564extern wxColour *wxRED;
565extern wxColour *wxBLUE;
566extern wxColour *wxGREEN;
567extern wxColour *wxCYAN;
568extern wxColour *wxLIGHT_GREY;
569
570extern wxCursor *wxSTANDARD_CURSOR;
571extern wxCursor *wxHOURGLASS_CURSOR;
572extern wxCursor *wxCROSS_CURSOR;
573
574extern wxBitmap wxNullBitmap;
575extern wxIcon wxNullIcon;
576extern wxCursor wxNullCursor;
577extern wxPen wxNullPen;
578extern wxBrush wxNullBrush;
579extern wxPalette wxNullPalette;
580extern wxFont wxNullFont;
581extern wxColour wxNullColour;
582
af309447
RD
583%readwrite
584%{
585#endif
586%}
587
b639c3c5
RD
588//---------------------------------------------------------------------------
589
590class wxPalette {
591public:
592 wxPalette(int LCOUNT, byte* LIST, byte* LIST, byte* LIST);
593 ~wxPalette();
594
595 int GetPixel(byte red, byte green, byte blue);
596 bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT);
597 bool Ok();
598};
599
600//---------------------------------------------------------------------------
601
af309447
RD
602enum {
603 wxIMAGELIST_DRAW_NORMAL ,
604 wxIMAGELIST_DRAW_TRANSPARENT,
605 wxIMAGELIST_DRAW_SELECTED,
606 wxIMAGELIST_DRAW_FOCUSED,
607 wxIMAGE_LIST_NORMAL,
608 wxIMAGE_LIST_SMALL,
609 wxIMAGE_LIST_STATE
610};
611
612class wxImageList {
613public:
614 wxImageList(int width, int height, const bool mask=TRUE, int initialCount=1);
615 ~wxImageList();
616
b57bdb5a 617#ifdef __WXMSW__
af309447
RD
618 int Add(const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
619 %name(AddWithColourMask)int Add(const wxBitmap& bitmap, const wxColour& maskColour);
620 %name(AddIcon)int Add(const wxIcon& icon);
b57bdb5a
RD
621 bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
622 %name(ReplaceIcon)bool Replace(int index, const wxIcon& icon);
623#else
624 int Add(const wxBitmap& bitmap);
625 bool Replace(int index, const wxBitmap& bitmap);
626#endif
af309447
RD
627
628 bool Draw(int index, wxDC& dc, int x, int x, int flags = wxIMAGELIST_DRAW_NORMAL,
629 const bool solidBackground = FALSE);
630
631 int GetImageCount();
632 bool Remove(int index);
633 bool RemoveAll();
af309447
RD
634};
635
b639c3c5 636
7bf85405
RD
637//---------------------------------------------------------------------------
638