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