]> git.saurik.com Git - wxWidgets.git/blame - utils/wxPython/src/gdi.i
Tweaks needed to be able to build wxPython with wxGTK.
[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>
105e45b9
RD
19#ifndef __WXMSW__
20#include <wx/postscrp.h>
21#endif
7bf85405
RD
22%}
23
24//----------------------------------------------------------------------
25
26%include typemaps.i
27%include my_typemaps.i
28
29// Import some definitions of other classes, etc.
30%import _defs.i
31%import misc.i
32
33//---------------------------------------------------------------------------
34
35class wxBitmap {
36public:
37 wxBitmap(const wxString& name, long type);
38 ~wxBitmap();
39
fb5e0af0 40#ifdef __WXMSW__
7bf85405 41 void Create(int width, int height, int depth = -1);
fb5e0af0 42#endif
7bf85405
RD
43 int GetDepth();
44 int GetHeight();
45 wxPalette* GetPalette();
46 wxMask* GetMask();
47 int GetWidth();
48 bool LoadFile(const wxString& name, long flags);
49 bool Ok();
50 bool SaveFile(const wxString& name, int type, wxPalette* palette = NULL);
51 void SetDepth(int depth);
52 void SetHeight(int height);
53 void SetMask(wxMask* mask);
fb5e0af0 54#ifdef __WXMSW__
b8b8dda7 55 void SetPalette(wxPalette& palette);
fb5e0af0 56#endif
7bf85405
RD
57 void SetWidth(int width);
58};
59
60%new wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1);
61wxBitmap* wxNoRefBitmap(char* name, long flags);
9c039d08 62
7bf85405
RD
63%{ // Alternate 'constructor'
64 wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1) {
65 return new wxBitmap(width, height, depth);
66 }
67
68 // This one won't own the reference, so Python won't call
69 // the dtor, this is good for toolbars and such where
70 // the parent will manage the bitmap.
71 wxBitmap* wxNoRefBitmap(char* name, long flags) {
72 return new wxBitmap(name, flags);
73 }
74%}
75
76//---------------------------------------------------------------------------
77
78class wxMask {
79public:
80 wxMask(const wxBitmap& bitmap);
81 ~wxMask();
82};
83
84%new wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour);
85%{
86 wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour) {
87 return new wxMask(bitmap, colour);
88 }
89%}
90
91
92//---------------------------------------------------------------------------
93
94
95class wxIcon : public wxBitmap {
96public:
fb5e0af0
RD
97#ifdef __WXMSW__
98 wxIcon(const wxString& name, long flags,
99 int desiredWidth = -1, int desiredHeight = -1);
100#endif
7bf85405
RD
101 ~wxIcon();
102
103 int GetDepth();
104 int GetHeight();
105 int GetWidth();
106 bool LoadFile(const wxString& name, long flags);
107 bool Ok();
108 void SetDepth(int depth);
109 void SetHeight(int height);
7bf85405
RD
110 void SetWidth(int width);
111};
112
113//---------------------------------------------------------------------------
114
115class wxCursor : public wxBitmap {
116public:
fb5e0af0 117#ifdef __WXMSW__
7bf85405 118 wxCursor(const wxString& cursorName, long flags, int hotSpotX=0, int hotSpotY=0);
fb5e0af0 119#endif
7bf85405
RD
120 ~wxCursor();
121 bool Ok();
122};
123
9c039d08 124%name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id);
7bf85405 125%{ // Alternate 'constructor'
9c039d08 126 wxCursor* wxPyStockCursor(int id) {
7bf85405
RD
127 return new wxCursor(id);
128 }
129%}
130
131//----------------------------------------------------------------------
132
133class wxFont {
134public:
135 // I'll do it this way to use long-lived objects and not have to
136 // worry about when python may delete the object.
137 %addmethods {
138 wxFont( int pointSize, int family, int style, int weight,
139 int underline=FALSE, char* faceName = "") {
140
141 return wxTheFontList->FindOrCreateFont(pointSize, family, style, weight,
142 underline, faceName);
143 }
144 // NO Destructor.
145 }
146
147
148 wxString GetFaceName();
149 int GetFamily();
150 int GetFontId();
151 int GetPointSize();
152 int GetStyle();
153 bool GetUnderlined();
154 int GetWeight();
fb5e0af0 155#ifdef __WXMSW__
7bf85405
RD
156 void SetFaceName(const wxString& faceName);
157 void SetFamily(int family);
158 void SetPointSize(int pointSize);
159 void SetStyle(int style);
160 void SetUnderlined(bool underlined);
161 void SetWeight(int weight);
fb5e0af0 162#endif
7bf85405
RD
163};
164
165//----------------------------------------------------------------------
166
167class wxColour {
168public:
169 wxColour(unsigned char red=0, unsigned char green=0, unsigned char blue=0);
170 ~wxColour();
171 unsigned char Red();
172 unsigned char Green();
173 unsigned char Blue();
174 bool Ok();
175 void Set(unsigned char red, unsigned char green, unsigned char blue);
176 %addmethods {
177 PyObject* Get() {
178 PyObject* rv = PyTuple_New(3);
179 PyTuple_SetItem(rv, 0, PyInt_FromLong(self->Red()));
180 PyTuple_SetItem(rv, 1, PyInt_FromLong(self->Green()));
181 PyTuple_SetItem(rv, 2, PyInt_FromLong(self->Blue()));
182 return rv;
183 }
184 }
185};
186
187%new wxColour* wxNamedColour(const wxString& colorName);
188%{ // Alternate 'constructor'
189 wxColour* wxNamedColour(const wxString& colorName) {
190 return new wxColour(colorName);
191 }
192%}
193
194
195//----------------------------------------------------------------------
196
197typedef unsigned long wxDash;
198
199class wxPen {
200public:
201 // I'll do it this way to use long-lived objects and not have to
202 // worry about when python may delete the object.
203 %addmethods {
204 wxPen(wxColour* colour, int width=1, int style=wxSOLID) {
205 return wxThePenList->FindOrCreatePen(*colour, width, style);
206 }
207 // NO Destructor.
208 }
209
210 int GetCap();
211 wxColour& GetColour();
212
fb5e0af0 213#ifdef __WXMSW__
7bf85405
RD
214 // **** This one needs to return a list of ints (wxDash)
215 int GetDashes(wxDash **dashes);
7bf85405 216 wxBitmap* GetStipple();
fb5e0af0
RD
217#endif
218 int GetJoin();
7bf85405
RD
219 int GetStyle();
220 int GetWidth();
221 bool Ok();
222 void SetCap(int cap_style);
223 void SetColour(wxColour& colour);
fb5e0af0 224#ifdef __WXMSW__
7bf85405 225 void SetDashes(int LCOUNT, wxDash* LIST);
b8b8dda7 226 void SetStipple(wxBitmap& stipple);
fb5e0af0
RD
227#endif
228 void SetJoin(int join_style);
7bf85405
RD
229 void SetStyle(int style);
230 void SetWidth(int width);
231};
232
233//----------------------------------------------------------------------
234
235class wxBrush {
236public:
237 // I'll do it this way to use long-lived objects and not have to
238 // worry about when python may delete the object.
239 %addmethods {
240 wxBrush(wxColour* colour, int style=wxSOLID) {
241 return wxTheBrushList->FindOrCreateBrush(*colour, style);
242 }
243 // NO Destructor.
244 }
245
246 wxColour& GetColour();
247 wxBitmap * GetStipple();
248 int GetStyle();
249 bool Ok();
fb5e0af0 250#ifdef __WXMSW__
7bf85405 251 void SetColour(wxColour &colour);
b8b8dda7 252 void SetStipple(wxBitmap& bitmap);
7bf85405 253 void SetStyle(int style);
fb5e0af0 254#endif
7bf85405
RD
255};
256
257//----------------------------------------------------------------------
258
259
260
261class wxDC {
262public:
fb5e0af0 263// wxDC(); **** abstract base class, can't instantiate.
7bf85405
RD
264 ~wxDC();
265
266 void BeginDrawing();
267 bool Blit(long xdest, long ydest, long width, long height,
268 wxDC *source, long xsrc, long ysrc, long logical_func);
269 void Clear();
270 void CrossHair(long x, long y);
271 void DestroyClippingRegion();
272 long DeviceToLogicalX(long x);
273 long DeviceToLogicalXRel(long x);
274 long DeviceToLogicalY(long y);
275 long DeviceToLogicalYRel(long y);
276 void DrawArc(long x1, long y1, long x2, long y2, long xc, long yc);
277 void DrawEllipse(long x, long y, long width, long height);
278 void DrawEllipticArc(long x, long y, long width, long height, long start, long end);
279 void DrawIcon(const wxIcon& icon, long x, long y);
280 void DrawLine(long x1, long y1, long x2, long y2);
281 void DrawLines(int LCOUNT, wxPoint* LIST, long xoffset=0, long yoffset=0);
282 void DrawPolygon(int LCOUNT, wxPoint* LIST, long xoffset=0, long yoffset=0,
283 int fill_style=wxODDEVEN_RULE);
284 void DrawPoint(long x, long y);
285 void DrawRectangle(long x, long y, long width, long height);
286 void DrawRoundedRectangle(long x, long y, long width, long height, long radius=20);
287 void DrawSpline(int LCOUNT, wxPoint* LIST);
288 void DrawText(const wxString& text, long x, long y);
289 void EndDoc();
290 void EndDrawing();
291 void EndPage();
292 void FloodFill(long x, long y, const wxColour& colour, int style=wxFLOOD_SURFACE);
105e45b9 293#ifdef __WXMSW__
b8b8dda7
RD
294 wxBrush& GetBackground();
295 wxBrush& GetBrush();
105e45b9
RD
296#else
297 wxBrush GetBackground();
298 wxBrush GetBrush();
299#endif
7bf85405
RD
300 long GetCharHeight();
301 long GetCharWidth();
302 void GetClippingBox(long *OUTPUT, long *OUTPUT,
303 long *OUTPUT, long *OUTPUT);
105e45b9 304#ifdef __WXMSW__
b8b8dda7 305 wxFont& GetFont();
105e45b9
RD
306#else
307 wxFont GetFont();
308#endif
7bf85405
RD
309 int GetLogicalFunction();
310 int GetMapMode();
311 bool GetOptimization();
105e45b9 312#ifdef __WXMSW__
b8b8dda7 313 wxPen& GetPen();
105e45b9
RD
314#else
315 wxPen GetPen();
316#endif
fb5e0af0
RD
317 %addmethods {
318 %new wxColour* GetPixel(long x, long y) {
319 wxColour* wc = new wxColour();
320 self->GetPixel(x, y, wc);
321 return wc;
322 }
323 }
7bf85405
RD
324 void GetSize(int* OUTPUT, int* OUTPUT); //void GetSize(long* OUTPUT, long* OUTPUT);
325 wxColour& GetTextBackground();
326 void GetTextExtent(const wxString& string, long *OUTPUT, long *OUTPUT,
327 long *OUTPUT, long *OUTPUT);
328 wxColour& GetTextForeground();
329 long LogicalToDeviceX(long x);
330 long LogicalToDeviceXRel(long x);
331 long LogicalToDeviceY(long y);
332 long LogicalToDeviceYRel(long y);
333 long MaxX();
334 long MaxY();
335 long MinX();
336 long MinY();
337 bool Ok();
338 void SetDeviceOrigin(long x, long y);
339 void SetBackground(const wxBrush& brush);
340 void SetBackgroundMode(int mode);
341 void SetClippingRegion(long x, long y, long width, long height);
342 void SetPalette(const wxPalette& colourMap);
343 void SetBrush(const wxBrush& brush);
344 void SetFont(const wxFont& font);
345 void SetLogicalFunction(int function);
346 void SetMapMode(int mode);
347 void SetOptimization(bool optimize);
348 void SetPen(const wxPen& pen);
349 void SetTextBackground(const wxColour& colour);
350 void SetTextForeground(const wxColour& colour);
351 void SetUserScale(double x_scale, double y_scale);
352 bool StartDoc(const wxString& message);
353 void StartPage();
354
355
356 %addmethods {
7bf85405 357 // This one is my own creation...
b8b8dda7 358 void DrawBitmap(wxBitmap& bitmap, long x, long y, bool swapPalette=TRUE) {
7bf85405
RD
359 wxMemoryDC* memDC = new wxMemoryDC;
360 memDC->SelectObject(bitmap);
361 if (swapPalette)
b8b8dda7
RD
362 self->SetPalette(*bitmap.GetPalette());
363 self->Blit(x, y, bitmap.GetWidth(), bitmap.GetHeight(), memDC,
7bf85405
RD
364 0, 0, self->GetLogicalFunction());
365 memDC->SelectObject(wxNullBitmap);
366 delete memDC;
367 }
368 }
369};
370
371
372//----------------------------------------------------------------------
373
374class wxMemoryDC : public wxDC {
375public:
376 wxMemoryDC();
377
378 void SelectObject(const wxBitmap& bitmap);
379}
380
381%new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC);
382%{ // Alternate 'constructor'
383 wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) {
384 return new wxMemoryDC(oldDC);
385 }
386%}
387
388
389//---------------------------------------------------------------------------
390
391class wxScreenDC : public wxDC {
392public:
393 wxScreenDC();
394
395 bool StartDrawingOnTop(wxWindow* window);
396 %name(StartDrawingOnTopRect) bool StartDrawingOnTop(wxRect* rect = NULL);
397 bool EndDrawingOnTop();
398};
399
400//---------------------------------------------------------------------------
401
402class wxClientDC : public wxDC {
403public:
404 wxClientDC(wxWindow* win);
405};
406
407//---------------------------------------------------------------------------
408
409class wxPaintDC : public wxDC {
410public:
411 wxPaintDC(wxWindow* win);
412};
413
414//---------------------------------------------------------------------------
415
b639c3c5
RD
416#ifdef __WXMSW__
417class wxWindowDC : public wxDC {
418public:
419 wxWindowDC(wxWindow* win);
420};
421#endif
422
423//---------------------------------------------------------------------------
424
d5c9047a 425#ifndef __WXMSW__
7bf85405
RD
426class wxPostScriptDC : public wxDC {
427public:
428 wxPostScriptDC(const wxString& output, bool interactive = TRUE, wxWindow* win = NULL);
429};
d5c9047a 430#endif
7bf85405
RD
431
432//---------------------------------------------------------------------------
433
fb5e0af0 434#ifdef __WXMSW__
7bf85405
RD
435class wxPrinterDC : public wxDC {
436public:
437 wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output,
438 bool interactive = TRUE, int orientation = wxPORTRAIT);
439};
fb5e0af0 440#endif
7bf85405
RD
441
442//---------------------------------------------------------------------------
443
fb5e0af0 444#ifdef __WXMSW__
7bf85405
RD
445class wxMetaFileDC : public wxDC {
446public:
447 wxMetaFileDC(const wxString& filename = wxPyEmptyStr);
448 wxMetaFile* Close();
449};
fb5e0af0 450#endif
7bf85405
RD
451
452//---------------------------------------------------------------------------
453//---------------------------------------------------------------------------
454
455
456%readonly
457extern wxFont *wxNORMAL_FONT;
458extern wxFont *wxSMALL_FONT;
459extern wxFont *wxITALIC_FONT;
460extern wxFont *wxSWISS_FONT;
461extern wxPen *wxRED_PEN;
462
463extern wxPen *wxCYAN_PEN;
464extern wxPen *wxGREEN_PEN;
465extern wxPen *wxBLACK_PEN;
466extern wxPen *wxWHITE_PEN;
467extern wxPen *wxTRANSPARENT_PEN;
468extern wxPen *wxBLACK_DASHED_PEN;
469extern wxPen *wxGREY_PEN;
470extern wxPen *wxMEDIUM_GREY_PEN;
471extern wxPen *wxLIGHT_GREY_PEN;
472
473extern wxBrush *wxBLUE_BRUSH;
474extern wxBrush *wxGREEN_BRUSH;
475extern wxBrush *wxWHITE_BRUSH;
476extern wxBrush *wxBLACK_BRUSH;
477extern wxBrush *wxTRANSPARENT_BRUSH;
478extern wxBrush *wxCYAN_BRUSH;
479extern wxBrush *wxRED_BRUSH;
480extern wxBrush *wxGREY_BRUSH;
481extern wxBrush *wxMEDIUM_GREY_BRUSH;
482extern wxBrush *wxLIGHT_GREY_BRUSH;
483
484extern wxColour *wxBLACK;
485extern wxColour *wxWHITE;
486extern wxColour *wxRED;
487extern wxColour *wxBLUE;
488extern wxColour *wxGREEN;
489extern wxColour *wxCYAN;
490extern wxColour *wxLIGHT_GREY;
491
492extern wxCursor *wxSTANDARD_CURSOR;
493extern wxCursor *wxHOURGLASS_CURSOR;
494extern wxCursor *wxCROSS_CURSOR;
495
496extern wxBitmap wxNullBitmap;
497extern wxIcon wxNullIcon;
498extern wxCursor wxNullCursor;
499extern wxPen wxNullPen;
500extern wxBrush wxNullBrush;
501extern wxPalette wxNullPalette;
502extern wxFont wxNullFont;
503extern wxColour wxNullColour;
504
b639c3c5
RD
505//---------------------------------------------------------------------------
506
507class wxPalette {
508public:
509 wxPalette(int LCOUNT, byte* LIST, byte* LIST, byte* LIST);
510 ~wxPalette();
511
512 int GetPixel(byte red, byte green, byte blue);
513 bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT);
514 bool Ok();
515};
516
517//---------------------------------------------------------------------------
518
519
7bf85405
RD
520//---------------------------------------------------------------------------
521
522/////////////////////////////////////////////////////////////////////////////
523//
524// $Log$
105e45b9
RD
525// Revision 1.8 1998/12/16 22:10:54 RD
526// Tweaks needed to be able to build wxPython with wxGTK.
527//
b8b8dda7
RD
528// Revision 1.7 1998/12/15 20:41:18 RD
529// Changed the import semantics from "from wxPython import *" to "from
530// wxPython.wx import *" This is for people who are worried about
531// namespace pollution, they can use "from wxPython import wx" and then
532// prefix all the wxPython identifiers with "wx."
533//
534// Added wxTaskbarIcon for wxMSW.
535//
536// Made the events work for wxGrid.
537//
538// Added wxConfig.
539//
540// Added wxMiniFrame for wxGTK, (untested.)
541//
542// Changed many of the args and return values that were pointers to gdi
543// objects to references to reflect changes in the wxWindows API.
544//
545// Other assorted fixes and additions.
546//
b639c3c5 547// Revision 1.6 1998/11/25 08:45:24 RD
b8b8dda7 548//
b639c3c5
RD
549// Added wxPalette, wxRegion, wxRegionIterator, wxTaskbarIcon
550// Added events for wxGrid
551// Other various fixes and additions
552//
d5c9047a
RD
553// Revision 1.5 1998/10/20 06:43:57 RD
554// New wxTreeCtrl wrappers (untested)
555// some changes in helpers
556// etc.
557//
9c039d08 558// Revision 1.4 1998/10/02 06:40:38 RD
d5c9047a 559//
9c039d08
RD
560// Version 0.4 of wxPython for MSW.
561//
fb5e0af0
RD
562// Revision 1.3 1998/08/18 19:48:16 RD
563// more wxGTK compatibility things.
564//
565// It builds now but there are serious runtime problems...
566//
03e9bead
RD
567// Revision 1.2 1998/08/15 07:36:35 RD
568// - Moved the header in the .i files out of the code that gets put into
569// the .cpp files. It caused CVS conflicts because of the RCS ID being
570// different each time.
571//
572// - A few minor fixes.
573//
7bf85405
RD
574// Revision 1.1 1998/08/09 08:25:50 RD
575// Initial version
576//
577//