]> git.saurik.com Git - wxWidgets.git/blame - utils/wxPython/src/gdi.i
Follow up for changes in wxWindows to various event classes
[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 19#ifndef __WXMSW__
08127323 20#include <wx/dcps.h>
105e45b9 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();
08127323 150#ifdef __WXMSW__
7bf85405 151 int GetFontId();
08127323 152#endif
7bf85405
RD
153 int GetPointSize();
154 int GetStyle();
155 bool GetUnderlined();
156 int GetWeight();
157 void SetFaceName(const wxString& faceName);
158 void SetFamily(int family);
159 void SetPointSize(int pointSize);
160 void SetStyle(int style);
161 void SetUnderlined(bool underlined);
162 void SetWeight(int weight);
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 int GetJoin();
7bf85405
RD
214 int GetStyle();
215 int GetWidth();
216 bool Ok();
217 void SetCap(int cap_style);
218 void SetColour(wxColour& colour);
aeeb6a44
RR
219 void SetJoin(int join_style);
220 void SetStyle(int style);
221 void SetWidth(int width);
08127323 222
fb5e0af0 223#ifdef __WXMSW__
aeeb6a44
RR
224 // **** This one needs to return a list of ints (wxDash)
225 int GetDashes(wxDash **dashes);
226 wxBitmap* GetStipple();
7bf85405 227 void SetDashes(int LCOUNT, wxDash* LIST);
b8b8dda7 228 void SetStipple(wxBitmap& stipple);
fb5e0af0 229#endif
7bf85405
RD
230};
231
232//----------------------------------------------------------------------
233
234class wxBrush {
235public:
236 // I'll do it this way to use long-lived objects and not have to
237 // worry about when python may delete the object.
238 %addmethods {
239 wxBrush(wxColour* colour, int style=wxSOLID) {
240 return wxTheBrushList->FindOrCreateBrush(*colour, style);
241 }
242 // NO Destructor.
243 }
244
245 wxColour& GetColour();
246 wxBitmap * GetStipple();
247 int GetStyle();
248 bool Ok();
249 void SetColour(wxColour &colour);
b8b8dda7 250 void SetStipple(wxBitmap& bitmap);
7bf85405
RD
251 void SetStyle(int style);
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();
289 void FloodFill(long x, long y, const wxColour& colour, int style=wxFLOOD_SURFACE);
b8b8dda7
RD
290 wxBrush& GetBackground();
291 wxBrush& GetBrush();
7bf85405
RD
292 long GetCharHeight();
293 long GetCharWidth();
294 void GetClippingBox(long *OUTPUT, long *OUTPUT,
295 long *OUTPUT, long *OUTPUT);
b8b8dda7 296 wxFont& GetFont();
7bf85405
RD
297 int GetLogicalFunction();
298 int GetMapMode();
299 bool GetOptimization();
b8b8dda7 300 wxPen& GetPen();
fb5e0af0
RD
301 %addmethods {
302 %new wxColour* GetPixel(long x, long y) {
303 wxColour* wc = new wxColour();
304 self->GetPixel(x, y, wc);
305 return wc;
306 }
307 }
7bf85405
RD
308 void GetSize(int* OUTPUT, int* OUTPUT); //void GetSize(long* OUTPUT, long* OUTPUT);
309 wxColour& GetTextBackground();
310 void GetTextExtent(const wxString& string, long *OUTPUT, long *OUTPUT,
311 long *OUTPUT, long *OUTPUT);
312 wxColour& GetTextForeground();
313 long LogicalToDeviceX(long x);
314 long LogicalToDeviceXRel(long x);
315 long LogicalToDeviceY(long y);
316 long LogicalToDeviceYRel(long y);
317 long MaxX();
318 long MaxY();
319 long MinX();
320 long MinY();
321 bool Ok();
322 void SetDeviceOrigin(long x, long y);
323 void SetBackground(const wxBrush& brush);
324 void SetBackgroundMode(int mode);
325 void SetClippingRegion(long x, long y, long width, long height);
326 void SetPalette(const wxPalette& colourMap);
327 void SetBrush(const wxBrush& brush);
328 void SetFont(const wxFont& font);
329 void SetLogicalFunction(int function);
330 void SetMapMode(int mode);
331 void SetOptimization(bool optimize);
332 void SetPen(const wxPen& pen);
333 void SetTextBackground(const wxColour& colour);
334 void SetTextForeground(const wxColour& colour);
335 void SetUserScale(double x_scale, double y_scale);
336 bool StartDoc(const wxString& message);
337 void StartPage();
338
339
340 %addmethods {
7bf85405 341 // This one is my own creation...
b8b8dda7 342 void DrawBitmap(wxBitmap& bitmap, long x, long y, bool swapPalette=TRUE) {
7bf85405
RD
343 wxMemoryDC* memDC = new wxMemoryDC;
344 memDC->SelectObject(bitmap);
345 if (swapPalette)
b8b8dda7
RD
346 self->SetPalette(*bitmap.GetPalette());
347 self->Blit(x, y, bitmap.GetWidth(), bitmap.GetHeight(), memDC,
7bf85405
RD
348 0, 0, self->GetLogicalFunction());
349 memDC->SelectObject(wxNullBitmap);
350 delete memDC;
351 }
352 }
353};
354
355
356//----------------------------------------------------------------------
357
358class wxMemoryDC : public wxDC {
359public:
360 wxMemoryDC();
361
362 void SelectObject(const wxBitmap& bitmap);
363}
364
365%new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC);
366%{ // Alternate 'constructor'
367 wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) {
368 return new wxMemoryDC(oldDC);
369 }
370%}
371
372
373//---------------------------------------------------------------------------
374
375class wxScreenDC : public wxDC {
376public:
377 wxScreenDC();
378
379 bool StartDrawingOnTop(wxWindow* window);
380 %name(StartDrawingOnTopRect) bool StartDrawingOnTop(wxRect* rect = NULL);
381 bool EndDrawingOnTop();
382};
383
384//---------------------------------------------------------------------------
385
386class wxClientDC : public wxDC {
387public:
388 wxClientDC(wxWindow* win);
389};
390
391//---------------------------------------------------------------------------
392
393class wxPaintDC : public wxDC {
394public:
395 wxPaintDC(wxWindow* win);
396};
397
398//---------------------------------------------------------------------------
399
b639c3c5
RD
400class wxWindowDC : public wxDC {
401public:
402 wxWindowDC(wxWindow* win);
403};
b639c3c5
RD
404
405//---------------------------------------------------------------------------
406
be4d9c1f 407#ifndef __WXMSW__
7bf85405
RD
408class wxPostScriptDC : public wxDC {
409public:
410 wxPostScriptDC(const wxString& output, bool interactive = TRUE, wxWindow* win = NULL);
411};
be4d9c1f 412#endif
7bf85405
RD
413
414//---------------------------------------------------------------------------
415
fb5e0af0 416#ifdef __WXMSW__
7bf85405
RD
417class wxPrinterDC : public wxDC {
418public:
419 wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output,
420 bool interactive = TRUE, int orientation = wxPORTRAIT);
421};
fb5e0af0 422#endif
7bf85405
RD
423
424//---------------------------------------------------------------------------
425
fb5e0af0 426#ifdef __WXMSW__
7bf85405
RD
427class wxMetaFileDC : public wxDC {
428public:
429 wxMetaFileDC(const wxString& filename = wxPyEmptyStr);
430 wxMetaFile* Close();
431};
fb5e0af0 432#endif
7bf85405
RD
433
434//---------------------------------------------------------------------------
435//---------------------------------------------------------------------------
436
437
438%readonly
439extern wxFont *wxNORMAL_FONT;
440extern wxFont *wxSMALL_FONT;
441extern wxFont *wxITALIC_FONT;
442extern wxFont *wxSWISS_FONT;
443extern wxPen *wxRED_PEN;
444
445extern wxPen *wxCYAN_PEN;
446extern wxPen *wxGREEN_PEN;
447extern wxPen *wxBLACK_PEN;
448extern wxPen *wxWHITE_PEN;
449extern wxPen *wxTRANSPARENT_PEN;
450extern wxPen *wxBLACK_DASHED_PEN;
451extern wxPen *wxGREY_PEN;
452extern wxPen *wxMEDIUM_GREY_PEN;
453extern wxPen *wxLIGHT_GREY_PEN;
454
455extern wxBrush *wxBLUE_BRUSH;
456extern wxBrush *wxGREEN_BRUSH;
457extern wxBrush *wxWHITE_BRUSH;
458extern wxBrush *wxBLACK_BRUSH;
459extern wxBrush *wxTRANSPARENT_BRUSH;
460extern wxBrush *wxCYAN_BRUSH;
461extern wxBrush *wxRED_BRUSH;
462extern wxBrush *wxGREY_BRUSH;
463extern wxBrush *wxMEDIUM_GREY_BRUSH;
464extern wxBrush *wxLIGHT_GREY_BRUSH;
465
466extern wxColour *wxBLACK;
467extern wxColour *wxWHITE;
468extern wxColour *wxRED;
469extern wxColour *wxBLUE;
470extern wxColour *wxGREEN;
471extern wxColour *wxCYAN;
472extern wxColour *wxLIGHT_GREY;
473
474extern wxCursor *wxSTANDARD_CURSOR;
475extern wxCursor *wxHOURGLASS_CURSOR;
476extern wxCursor *wxCROSS_CURSOR;
477
478extern wxBitmap wxNullBitmap;
479extern wxIcon wxNullIcon;
480extern wxCursor wxNullCursor;
481extern wxPen wxNullPen;
482extern wxBrush wxNullBrush;
483extern wxPalette wxNullPalette;
484extern wxFont wxNullFont;
485extern wxColour wxNullColour;
486
b639c3c5
RD
487//---------------------------------------------------------------------------
488
489class wxPalette {
490public:
491 wxPalette(int LCOUNT, byte* LIST, byte* LIST, byte* LIST);
492 ~wxPalette();
493
494 int GetPixel(byte red, byte green, byte blue);
495 bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT);
496 bool Ok();
497};
498
499//---------------------------------------------------------------------------
500
501
7bf85405
RD
502//---------------------------------------------------------------------------
503
504/////////////////////////////////////////////////////////////////////////////
505//
506// $Log$
08127323
RD
507// Revision 1.12 1999/01/30 07:30:11 RD
508// Added wxSashWindow, wxSashEvent, wxLayoutAlgorithm, etc.
509//
510// Various cleanup, tweaks, minor additions, etc. to maintain
511// compatibility with the current wxWindows.
512//
aeeb6a44 513// Revision 1.11 1998/12/18 15:49:05 RR
08127323 514//
aeeb6a44
RR
515// wxClipboard now serves the primary selection as well
516// wxPython fixes
517// warning mesages
518//
be4d9c1f 519// Revision 1.10 1998/12/17 18:05:50 RD
aeeb6a44 520//
be4d9c1f
RD
521// wxPython 0.5.2
522// Minor fixes and SWIG code generation for RR's changes. MSW and GTK
523// versions are much closer now!
524//
4f22cf8d 525// Revision 1.9 1998/12/17 14:07:37 RR
be4d9c1f 526//
4f22cf8d
RR
527// Removed minor differences between wxMSW and wxGTK
528//
105e45b9 529// Revision 1.8 1998/12/16 22:10:54 RD
4f22cf8d 530//
105e45b9
RD
531// Tweaks needed to be able to build wxPython with wxGTK.
532//
b8b8dda7
RD
533// Revision 1.7 1998/12/15 20:41:18 RD
534// Changed the import semantics from "from wxPython import *" to "from
535// wxPython.wx import *" This is for people who are worried about
536// namespace pollution, they can use "from wxPython import wx" and then
537// prefix all the wxPython identifiers with "wx."
538//
539// Added wxTaskbarIcon for wxMSW.
540//
541// Made the events work for wxGrid.
542//
543// Added wxConfig.
544//
545// Added wxMiniFrame for wxGTK, (untested.)
546//
547// Changed many of the args and return values that were pointers to gdi
548// objects to references to reflect changes in the wxWindows API.
549//
550// Other assorted fixes and additions.
551//
b639c3c5 552// Revision 1.6 1998/11/25 08:45:24 RD
b8b8dda7 553//
b639c3c5
RD
554// Added wxPalette, wxRegion, wxRegionIterator, wxTaskbarIcon
555// Added events for wxGrid
556// Other various fixes and additions
557//
d5c9047a
RD
558// Revision 1.5 1998/10/20 06:43:57 RD
559// New wxTreeCtrl wrappers (untested)
560// some changes in helpers
561// etc.
562//
9c039d08 563// Revision 1.4 1998/10/02 06:40:38 RD
d5c9047a 564//
9c039d08
RD
565// Version 0.4 of wxPython for MSW.
566//
fb5e0af0
RD
567// Revision 1.3 1998/08/18 19:48:16 RD
568// more wxGTK compatibility things.
569//
570// It builds now but there are serious runtime problems...
571//
03e9bead
RD
572// Revision 1.2 1998/08/15 07:36:35 RD
573// - Moved the header in the .i files out of the code that gets put into
574// the .cpp files. It caused CVS conflicts because of the RCS ID being
575// different each time.
576//
577// - A few minor fixes.
578//
7bf85405
RD
579// Revision 1.1 1998/08/09 08:25:50 RD
580// Initial version
581//
582//