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