]> git.saurik.com Git - wxWidgets.git/blame - utils/wxPython/src/gdi.i
no 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 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();
155 void SetFaceName(const wxString& faceName);
156 void SetFamily(int family);
157 void SetPointSize(int pointSize);
158 void SetStyle(int style);
159 void SetUnderlined(bool underlined);
160 void SetWeight(int weight);
161};
162
163//----------------------------------------------------------------------
164
165class wxColour {
166public:
167 wxColour(unsigned char red=0, unsigned char green=0, unsigned char blue=0);
168 ~wxColour();
169 unsigned char Red();
170 unsigned char Green();
171 unsigned char Blue();
172 bool Ok();
173 void Set(unsigned char red, unsigned char green, unsigned char blue);
174 %addmethods {
175 PyObject* Get() {
176 PyObject* rv = PyTuple_New(3);
177 PyTuple_SetItem(rv, 0, PyInt_FromLong(self->Red()));
178 PyTuple_SetItem(rv, 1, PyInt_FromLong(self->Green()));
179 PyTuple_SetItem(rv, 2, PyInt_FromLong(self->Blue()));
180 return rv;
181 }
182 }
183};
184
185%new wxColour* wxNamedColour(const wxString& colorName);
186%{ // Alternate 'constructor'
187 wxColour* wxNamedColour(const wxString& colorName) {
188 return new wxColour(colorName);
189 }
190%}
191
192
193//----------------------------------------------------------------------
194
195typedef unsigned long wxDash;
196
197class wxPen {
198public:
199 // I'll do it this way to use long-lived objects and not have to
200 // worry about when python may delete the object.
201 %addmethods {
202 wxPen(wxColour* colour, int width=1, int style=wxSOLID) {
203 return wxThePenList->FindOrCreatePen(*colour, width, style);
204 }
205 // NO Destructor.
206 }
207
208 int GetCap();
209 wxColour& GetColour();
210
fb5e0af0 211 int GetJoin();
7bf85405
RD
212 int GetStyle();
213 int GetWidth();
214 bool Ok();
215 void SetCap(int cap_style);
216 void SetColour(wxColour& colour);
aeeb6a44
RR
217 void SetJoin(int join_style);
218 void SetStyle(int style);
219 void SetWidth(int width);
220
fb5e0af0 221#ifdef __WXMSW__
aeeb6a44
RR
222 // **** This one needs to return a list of ints (wxDash)
223 int GetDashes(wxDash **dashes);
224 wxBitmap* GetStipple();
7bf85405 225 void SetDashes(int LCOUNT, wxDash* LIST);
b8b8dda7 226 void SetStipple(wxBitmap& stipple);
fb5e0af0 227#endif
7bf85405
RD
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();
247 void SetColour(wxColour &colour);
b8b8dda7 248 void SetStipple(wxBitmap& bitmap);
7bf85405
RD
249 void SetStyle(int style);
250};
251
252//----------------------------------------------------------------------
253
254
255
256class wxDC {
257public:
fb5e0af0 258// wxDC(); **** abstract base class, can't instantiate.
7bf85405
RD
259 ~wxDC();
260
261 void BeginDrawing();
262 bool Blit(long xdest, long ydest, long width, long height,
263 wxDC *source, long xsrc, long ysrc, long logical_func);
264 void Clear();
265 void CrossHair(long x, long y);
266 void DestroyClippingRegion();
267 long DeviceToLogicalX(long x);
268 long DeviceToLogicalXRel(long x);
269 long DeviceToLogicalY(long y);
270 long DeviceToLogicalYRel(long y);
271 void DrawArc(long x1, long y1, long x2, long y2, long xc, long yc);
272 void DrawEllipse(long x, long y, long width, long height);
273 void DrawEllipticArc(long x, long y, long width, long height, long start, long end);
274 void DrawIcon(const wxIcon& icon, long x, long y);
275 void DrawLine(long x1, long y1, long x2, long y2);
276 void DrawLines(int LCOUNT, wxPoint* LIST, long xoffset=0, long yoffset=0);
277 void DrawPolygon(int LCOUNT, wxPoint* LIST, long xoffset=0, long yoffset=0,
278 int fill_style=wxODDEVEN_RULE);
279 void DrawPoint(long x, long y);
280 void DrawRectangle(long x, long y, long width, long height);
281 void DrawRoundedRectangle(long x, long y, long width, long height, long radius=20);
282 void DrawSpline(int LCOUNT, wxPoint* LIST);
283 void DrawText(const wxString& text, long x, long y);
284 void EndDoc();
285 void EndDrawing();
286 void EndPage();
287 void FloodFill(long x, long y, const wxColour& colour, int style=wxFLOOD_SURFACE);
b8b8dda7
RD
288 wxBrush& GetBackground();
289 wxBrush& GetBrush();
7bf85405
RD
290 long GetCharHeight();
291 long GetCharWidth();
292 void GetClippingBox(long *OUTPUT, long *OUTPUT,
293 long *OUTPUT, long *OUTPUT);
b8b8dda7 294 wxFont& GetFont();
7bf85405
RD
295 int GetLogicalFunction();
296 int GetMapMode();
297 bool GetOptimization();
b8b8dda7 298 wxPen& GetPen();
fb5e0af0
RD
299 %addmethods {
300 %new wxColour* GetPixel(long x, long y) {
301 wxColour* wc = new wxColour();
302 self->GetPixel(x, y, wc);
303 return wc;
304 }
305 }
7bf85405
RD
306 void GetSize(int* OUTPUT, int* OUTPUT); //void GetSize(long* OUTPUT, long* OUTPUT);
307 wxColour& GetTextBackground();
308 void GetTextExtent(const wxString& string, long *OUTPUT, long *OUTPUT,
309 long *OUTPUT, long *OUTPUT);
310 wxColour& GetTextForeground();
311 long LogicalToDeviceX(long x);
312 long LogicalToDeviceXRel(long x);
313 long LogicalToDeviceY(long y);
314 long LogicalToDeviceYRel(long y);
315 long MaxX();
316 long MaxY();
317 long MinX();
318 long MinY();
319 bool Ok();
320 void SetDeviceOrigin(long x, long y);
321 void SetBackground(const wxBrush& brush);
322 void SetBackgroundMode(int mode);
323 void SetClippingRegion(long x, long y, long width, long height);
324 void SetPalette(const wxPalette& colourMap);
325 void SetBrush(const wxBrush& brush);
326 void SetFont(const wxFont& font);
327 void SetLogicalFunction(int function);
328 void SetMapMode(int mode);
329 void SetOptimization(bool optimize);
330 void SetPen(const wxPen& pen);
331 void SetTextBackground(const wxColour& colour);
332 void SetTextForeground(const wxColour& colour);
333 void SetUserScale(double x_scale, double y_scale);
334 bool StartDoc(const wxString& message);
335 void StartPage();
336
337
338 %addmethods {
7bf85405 339 // This one is my own creation...
b8b8dda7 340 void DrawBitmap(wxBitmap& bitmap, long x, long y, bool swapPalette=TRUE) {
7bf85405
RD
341 wxMemoryDC* memDC = new wxMemoryDC;
342 memDC->SelectObject(bitmap);
343 if (swapPalette)
b8b8dda7
RD
344 self->SetPalette(*bitmap.GetPalette());
345 self->Blit(x, y, bitmap.GetWidth(), bitmap.GetHeight(), memDC,
7bf85405
RD
346 0, 0, self->GetLogicalFunction());
347 memDC->SelectObject(wxNullBitmap);
348 delete memDC;
349 }
350 }
351};
352
353
354//----------------------------------------------------------------------
355
356class wxMemoryDC : public wxDC {
357public:
358 wxMemoryDC();
359
360 void SelectObject(const wxBitmap& bitmap);
361}
362
363%new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC);
364%{ // Alternate 'constructor'
365 wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) {
366 return new wxMemoryDC(oldDC);
367 }
368%}
369
370
371//---------------------------------------------------------------------------
372
373class wxScreenDC : public wxDC {
374public:
375 wxScreenDC();
376
377 bool StartDrawingOnTop(wxWindow* window);
378 %name(StartDrawingOnTopRect) bool StartDrawingOnTop(wxRect* rect = NULL);
379 bool EndDrawingOnTop();
380};
381
382//---------------------------------------------------------------------------
383
384class wxClientDC : public wxDC {
385public:
386 wxClientDC(wxWindow* win);
387};
388
389//---------------------------------------------------------------------------
390
391class wxPaintDC : public wxDC {
392public:
393 wxPaintDC(wxWindow* win);
394};
395
396//---------------------------------------------------------------------------
397
b639c3c5
RD
398class wxWindowDC : public wxDC {
399public:
400 wxWindowDC(wxWindow* win);
401};
b639c3c5
RD
402
403//---------------------------------------------------------------------------
404
be4d9c1f 405#ifndef __WXMSW__
7bf85405
RD
406class wxPostScriptDC : public wxDC {
407public:
408 wxPostScriptDC(const wxString& output, bool interactive = TRUE, wxWindow* win = NULL);
409};
be4d9c1f 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
b639c3c5
RD
485//---------------------------------------------------------------------------
486
487class wxPalette {
488public:
489 wxPalette(int LCOUNT, byte* LIST, byte* LIST, byte* LIST);
490 ~wxPalette();
491
492 int GetPixel(byte red, byte green, byte blue);
493 bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT);
494 bool Ok();
495};
496
497//---------------------------------------------------------------------------
498
499
7bf85405
RD
500//---------------------------------------------------------------------------
501
502/////////////////////////////////////////////////////////////////////////////
503//
504// $Log$
aeeb6a44
RR
505// Revision 1.11 1998/12/18 15:49:05 RR
506// wxClipboard now serves the primary selection as well
507// wxPython fixes
508// warning mesages
509//
be4d9c1f 510// Revision 1.10 1998/12/17 18:05:50 RD
aeeb6a44 511//
be4d9c1f
RD
512// wxPython 0.5.2
513// Minor fixes and SWIG code generation for RR's changes. MSW and GTK
514// versions are much closer now!
515//
4f22cf8d 516// Revision 1.9 1998/12/17 14:07:37 RR
be4d9c1f 517//
4f22cf8d
RR
518// Removed minor differences between wxMSW and wxGTK
519//
105e45b9 520// Revision 1.8 1998/12/16 22:10:54 RD
4f22cf8d 521//
105e45b9
RD
522// Tweaks needed to be able to build wxPython with wxGTK.
523//
b8b8dda7
RD
524// Revision 1.7 1998/12/15 20:41:18 RD
525// Changed the import semantics from "from wxPython import *" to "from
526// wxPython.wx import *" This is for people who are worried about
527// namespace pollution, they can use "from wxPython import wx" and then
528// prefix all the wxPython identifiers with "wx."
529//
530// Added wxTaskbarIcon for wxMSW.
531//
532// Made the events work for wxGrid.
533//
534// Added wxConfig.
535//
536// Added wxMiniFrame for wxGTK, (untested.)
537//
538// Changed many of the args and return values that were pointers to gdi
539// objects to references to reflect changes in the wxWindows API.
540//
541// Other assorted fixes and additions.
542//
b639c3c5 543// Revision 1.6 1998/11/25 08:45:24 RD
b8b8dda7 544//
b639c3c5
RD
545// Added wxPalette, wxRegion, wxRegionIterator, wxTaskbarIcon
546// Added events for wxGrid
547// Other various fixes and additions
548//
d5c9047a
RD
549// Revision 1.5 1998/10/20 06:43:57 RD
550// New wxTreeCtrl wrappers (untested)
551// some changes in helpers
552// etc.
553//
9c039d08 554// Revision 1.4 1998/10/02 06:40:38 RD
d5c9047a 555//
9c039d08
RD
556// Version 0.4 of wxPython for MSW.
557//
fb5e0af0
RD
558// Revision 1.3 1998/08/18 19:48:16 RD
559// more wxGTK compatibility things.
560//
561// It builds now but there are serious runtime problems...
562//
03e9bead
RD
563// Revision 1.2 1998/08/15 07:36:35 RD
564// - Moved the header in the .i files out of the code that gets put into
565// the .cpp files. It caused CVS conflicts because of the RCS ID being
566// different each time.
567//
568// - A few minor fixes.
569//
7bf85405
RD
570// Revision 1.1 1998/08/09 08:25:50 RD
571// Initial version
572//
573//