]> git.saurik.com Git - wxWidgets.git/blame - utils/wxPython/src/gdi.i
Version 0.4 of wxPython for MSW.
[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
405class wxPostScriptDC : public wxDC {
406public:
407 wxPostScriptDC(const wxString& output, bool interactive = TRUE, wxWindow* win = NULL);
408};
409
410//---------------------------------------------------------------------------
411
fb5e0af0 412#ifdef __WXMSW__
7bf85405
RD
413class wxPrinterDC : public wxDC {
414public:
415 wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output,
416 bool interactive = TRUE, int orientation = wxPORTRAIT);
417};
fb5e0af0 418#endif
7bf85405
RD
419
420//---------------------------------------------------------------------------
421
fb5e0af0 422#ifdef __WXMSW__
7bf85405
RD
423class wxMetaFileDC : public wxDC {
424public:
425 wxMetaFileDC(const wxString& filename = wxPyEmptyStr);
426 wxMetaFile* Close();
427};
fb5e0af0 428#endif
7bf85405
RD
429
430//---------------------------------------------------------------------------
431//---------------------------------------------------------------------------
432
433
434%readonly
435extern wxFont *wxNORMAL_FONT;
436extern wxFont *wxSMALL_FONT;
437extern wxFont *wxITALIC_FONT;
438extern wxFont *wxSWISS_FONT;
439extern wxPen *wxRED_PEN;
440
441extern wxPen *wxCYAN_PEN;
442extern wxPen *wxGREEN_PEN;
443extern wxPen *wxBLACK_PEN;
444extern wxPen *wxWHITE_PEN;
445extern wxPen *wxTRANSPARENT_PEN;
446extern wxPen *wxBLACK_DASHED_PEN;
447extern wxPen *wxGREY_PEN;
448extern wxPen *wxMEDIUM_GREY_PEN;
449extern wxPen *wxLIGHT_GREY_PEN;
450
451extern wxBrush *wxBLUE_BRUSH;
452extern wxBrush *wxGREEN_BRUSH;
453extern wxBrush *wxWHITE_BRUSH;
454extern wxBrush *wxBLACK_BRUSH;
455extern wxBrush *wxTRANSPARENT_BRUSH;
456extern wxBrush *wxCYAN_BRUSH;
457extern wxBrush *wxRED_BRUSH;
458extern wxBrush *wxGREY_BRUSH;
459extern wxBrush *wxMEDIUM_GREY_BRUSH;
460extern wxBrush *wxLIGHT_GREY_BRUSH;
461
462extern wxColour *wxBLACK;
463extern wxColour *wxWHITE;
464extern wxColour *wxRED;
465extern wxColour *wxBLUE;
466extern wxColour *wxGREEN;
467extern wxColour *wxCYAN;
468extern wxColour *wxLIGHT_GREY;
469
470extern wxCursor *wxSTANDARD_CURSOR;
471extern wxCursor *wxHOURGLASS_CURSOR;
472extern wxCursor *wxCROSS_CURSOR;
473
474extern wxBitmap wxNullBitmap;
475extern wxIcon wxNullIcon;
476extern wxCursor wxNullCursor;
477extern wxPen wxNullPen;
478extern wxBrush wxNullBrush;
479extern wxPalette wxNullPalette;
480extern wxFont wxNullFont;
481extern wxColour wxNullColour;
482
483//---------------------------------------------------------------------------
484
485/////////////////////////////////////////////////////////////////////////////
486//
487// $Log$
9c039d08
RD
488// Revision 1.4 1998/10/02 06:40:38 RD
489// Version 0.4 of wxPython for MSW.
490//
fb5e0af0
RD
491// Revision 1.3 1998/08/18 19:48:16 RD
492// more wxGTK compatibility things.
493//
494// It builds now but there are serious runtime problems...
495//
03e9bead
RD
496// Revision 1.2 1998/08/15 07:36:35 RD
497// - Moved the header in the .i files out of the code that gets put into
498// the .cpp files. It caused CVS conflicts because of the RCS ID being
499// different each time.
500//
501// - A few minor fixes.
502//
7bf85405
RD
503// Revision 1.1 1998/08/09 08:25:50 RD
504// Initial version
505//
506//