]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/gdi.i
Removed minor differences between wxMSW and wxGTK
[wxWidgets.git] / utils / wxPython / src / gdi.i
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
14 %module gdi
15
16 %{
17 #include "helpers.h"
18 #include <wx/metafile.h>
19 #ifndef __WXMSW__
20 #include <wx/postscrp.h>
21 #endif
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
35 class wxBitmap {
36 public:
37 wxBitmap(const wxString& name, long type);
38 ~wxBitmap();
39
40 #ifdef __WXMSW__
41 void Create(int width, int height, int depth = -1);
42 #endif
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);
54 #ifdef __WXMSW__
55 void SetPalette(wxPalette& palette);
56 #endif
57 void SetWidth(int width);
58 };
59
60 %new wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1);
61 wxBitmap* wxNoRefBitmap(char* name, long flags);
62
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
78 class wxMask {
79 public:
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
95 class wxIcon : public wxBitmap {
96 public:
97 #ifdef __WXMSW__
98 wxIcon(const wxString& name, long flags,
99 int desiredWidth = -1, int desiredHeight = -1);
100 #endif
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);
110 void SetWidth(int width);
111 };
112
113 //---------------------------------------------------------------------------
114
115 class wxCursor : public wxBitmap {
116 public:
117 #ifdef __WXMSW__
118 wxCursor(const wxString& cursorName, long flags, int hotSpotX=0, int hotSpotY=0);
119 #endif
120 ~wxCursor();
121 bool Ok();
122 };
123
124 %name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id);
125 %{ // Alternate 'constructor'
126 wxCursor* wxPyStockCursor(int id) {
127 return new wxCursor(id);
128 }
129 %}
130
131 //----------------------------------------------------------------------
132
133 class wxFont {
134 public:
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 #ifdef __WXMSW__
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);
162 #endif
163 };
164
165 //----------------------------------------------------------------------
166
167 class wxColour {
168 public:
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
197 typedef unsigned long wxDash;
198
199 class wxPen {
200 public:
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
213 #ifdef __WXMSW__
214 // **** This one needs to return a list of ints (wxDash)
215 int GetDashes(wxDash **dashes);
216 wxBitmap* GetStipple();
217 #endif
218 int GetJoin();
219 int GetStyle();
220 int GetWidth();
221 bool Ok();
222 void SetCap(int cap_style);
223 void SetColour(wxColour& colour);
224 #ifdef __WXMSW__
225 void SetDashes(int LCOUNT, wxDash* LIST);
226 void SetStipple(wxBitmap& stipple);
227 #endif
228 void SetJoin(int join_style);
229 void SetStyle(int style);
230 void SetWidth(int width);
231 };
232
233 //----------------------------------------------------------------------
234
235 class wxBrush {
236 public:
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();
250 void SetColour(wxColour &colour);
251 void SetStipple(wxBitmap& bitmap);
252 void SetStyle(int style);
253 };
254
255 //----------------------------------------------------------------------
256
257
258
259 class wxDC {
260 public:
261 // wxDC(); **** abstract base class, can't instantiate.
262 ~wxDC();
263
264 void BeginDrawing();
265 bool Blit(long xdest, long ydest, long width, long height,
266 wxDC *source, long xsrc, long ysrc, long logical_func);
267 void Clear();
268 void CrossHair(long x, long y);
269 void DestroyClippingRegion();
270 long DeviceToLogicalX(long x);
271 long DeviceToLogicalXRel(long x);
272 long DeviceToLogicalY(long y);
273 long DeviceToLogicalYRel(long y);
274 void DrawArc(long x1, long y1, long x2, long y2, long xc, long yc);
275 void DrawEllipse(long x, long y, long width, long height);
276 void DrawEllipticArc(long x, long y, long width, long height, long start, long end);
277 void DrawIcon(const wxIcon& icon, long x, long y);
278 void DrawLine(long x1, long y1, long x2, long y2);
279 void DrawLines(int LCOUNT, wxPoint* LIST, long xoffset=0, long yoffset=0);
280 void DrawPolygon(int LCOUNT, wxPoint* LIST, long xoffset=0, long yoffset=0,
281 int fill_style=wxODDEVEN_RULE);
282 void DrawPoint(long x, long y);
283 void DrawRectangle(long x, long y, long width, long height);
284 void DrawRoundedRectangle(long x, long y, long width, long height, long radius=20);
285 void DrawSpline(int LCOUNT, wxPoint* LIST);
286 void DrawText(const wxString& text, long x, long y);
287 void EndDoc();
288 void EndDrawing();
289 void EndPage();
290 void FloodFill(long x, long y, const wxColour& colour, int style=wxFLOOD_SURFACE);
291 wxBrush& GetBackground();
292 wxBrush& GetBrush();
293 long GetCharHeight();
294 long GetCharWidth();
295 void GetClippingBox(long *OUTPUT, long *OUTPUT,
296 long *OUTPUT, long *OUTPUT);
297 wxFont& GetFont();
298 int GetLogicalFunction();
299 int GetMapMode();
300 bool GetOptimization();
301 wxPen& GetPen();
302 %addmethods {
303 %new wxColour* GetPixel(long x, long y) {
304 wxColour* wc = new wxColour();
305 self->GetPixel(x, y, wc);
306 return wc;
307 }
308 }
309 void GetSize(int* OUTPUT, int* OUTPUT); //void GetSize(long* OUTPUT, long* OUTPUT);
310 wxColour& GetTextBackground();
311 void GetTextExtent(const wxString& string, long *OUTPUT, long *OUTPUT,
312 long *OUTPUT, long *OUTPUT);
313 wxColour& GetTextForeground();
314 long LogicalToDeviceX(long x);
315 long LogicalToDeviceXRel(long x);
316 long LogicalToDeviceY(long y);
317 long LogicalToDeviceYRel(long y);
318 long MaxX();
319 long MaxY();
320 long MinX();
321 long MinY();
322 bool Ok();
323 void SetDeviceOrigin(long x, long y);
324 void SetBackground(const wxBrush& brush);
325 void SetBackgroundMode(int mode);
326 void SetClippingRegion(long x, long y, long width, long height);
327 void SetPalette(const wxPalette& colourMap);
328 void SetBrush(const wxBrush& brush);
329 void SetFont(const wxFont& font);
330 void SetLogicalFunction(int function);
331 void SetMapMode(int mode);
332 void SetOptimization(bool optimize);
333 void SetPen(const wxPen& pen);
334 void SetTextBackground(const wxColour& colour);
335 void SetTextForeground(const wxColour& colour);
336 void SetUserScale(double x_scale, double y_scale);
337 bool StartDoc(const wxString& message);
338 void StartPage();
339
340
341 %addmethods {
342 // This one is my own creation...
343 void DrawBitmap(wxBitmap& bitmap, long x, long y, bool swapPalette=TRUE) {
344 wxMemoryDC* memDC = new wxMemoryDC;
345 memDC->SelectObject(bitmap);
346 if (swapPalette)
347 self->SetPalette(*bitmap.GetPalette());
348 self->Blit(x, y, bitmap.GetWidth(), bitmap.GetHeight(), memDC,
349 0, 0, self->GetLogicalFunction());
350 memDC->SelectObject(wxNullBitmap);
351 delete memDC;
352 }
353 }
354 };
355
356
357 //----------------------------------------------------------------------
358
359 class wxMemoryDC : public wxDC {
360 public:
361 wxMemoryDC();
362
363 void SelectObject(const wxBitmap& bitmap);
364 }
365
366 %new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC);
367 %{ // Alternate 'constructor'
368 wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) {
369 return new wxMemoryDC(oldDC);
370 }
371 %}
372
373
374 //---------------------------------------------------------------------------
375
376 class wxScreenDC : public wxDC {
377 public:
378 wxScreenDC();
379
380 bool StartDrawingOnTop(wxWindow* window);
381 %name(StartDrawingOnTopRect) bool StartDrawingOnTop(wxRect* rect = NULL);
382 bool EndDrawingOnTop();
383 };
384
385 //---------------------------------------------------------------------------
386
387 class wxClientDC : public wxDC {
388 public:
389 wxClientDC(wxWindow* win);
390 };
391
392 //---------------------------------------------------------------------------
393
394 class wxPaintDC : public wxDC {
395 public:
396 wxPaintDC(wxWindow* win);
397 };
398
399 //---------------------------------------------------------------------------
400
401 class wxWindowDC : public wxDC {
402 public:
403 wxWindowDC(wxWindow* win);
404 };
405
406 //---------------------------------------------------------------------------
407
408 class wxPostScriptDC : public wxDC {
409 public:
410 wxPostScriptDC(const wxString& output, bool interactive = TRUE, wxWindow* win = NULL);
411 };
412
413 //---------------------------------------------------------------------------
414
415 #ifdef __WXMSW__
416 class wxPrinterDC : public wxDC {
417 public:
418 wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output,
419 bool interactive = TRUE, int orientation = wxPORTRAIT);
420 };
421 #endif
422
423 //---------------------------------------------------------------------------
424
425 #ifdef __WXMSW__
426 class wxMetaFileDC : public wxDC {
427 public:
428 wxMetaFileDC(const wxString& filename = wxPyEmptyStr);
429 wxMetaFile* Close();
430 };
431 #endif
432
433 //---------------------------------------------------------------------------
434 //---------------------------------------------------------------------------
435
436
437 %readonly
438 extern wxFont *wxNORMAL_FONT;
439 extern wxFont *wxSMALL_FONT;
440 extern wxFont *wxITALIC_FONT;
441 extern wxFont *wxSWISS_FONT;
442 extern wxPen *wxRED_PEN;
443
444 extern wxPen *wxCYAN_PEN;
445 extern wxPen *wxGREEN_PEN;
446 extern wxPen *wxBLACK_PEN;
447 extern wxPen *wxWHITE_PEN;
448 extern wxPen *wxTRANSPARENT_PEN;
449 extern wxPen *wxBLACK_DASHED_PEN;
450 extern wxPen *wxGREY_PEN;
451 extern wxPen *wxMEDIUM_GREY_PEN;
452 extern wxPen *wxLIGHT_GREY_PEN;
453
454 extern wxBrush *wxBLUE_BRUSH;
455 extern wxBrush *wxGREEN_BRUSH;
456 extern wxBrush *wxWHITE_BRUSH;
457 extern wxBrush *wxBLACK_BRUSH;
458 extern wxBrush *wxTRANSPARENT_BRUSH;
459 extern wxBrush *wxCYAN_BRUSH;
460 extern wxBrush *wxRED_BRUSH;
461 extern wxBrush *wxGREY_BRUSH;
462 extern wxBrush *wxMEDIUM_GREY_BRUSH;
463 extern wxBrush *wxLIGHT_GREY_BRUSH;
464
465 extern wxColour *wxBLACK;
466 extern wxColour *wxWHITE;
467 extern wxColour *wxRED;
468 extern wxColour *wxBLUE;
469 extern wxColour *wxGREEN;
470 extern wxColour *wxCYAN;
471 extern wxColour *wxLIGHT_GREY;
472
473 extern wxCursor *wxSTANDARD_CURSOR;
474 extern wxCursor *wxHOURGLASS_CURSOR;
475 extern wxCursor *wxCROSS_CURSOR;
476
477 extern wxBitmap wxNullBitmap;
478 extern wxIcon wxNullIcon;
479 extern wxCursor wxNullCursor;
480 extern wxPen wxNullPen;
481 extern wxBrush wxNullBrush;
482 extern wxPalette wxNullPalette;
483 extern wxFont wxNullFont;
484 extern wxColour wxNullColour;
485
486 //---------------------------------------------------------------------------
487
488 class wxPalette {
489 public:
490 wxPalette(int LCOUNT, byte* LIST, byte* LIST, byte* LIST);
491 ~wxPalette();
492
493 int GetPixel(byte red, byte green, byte blue);
494 bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT);
495 bool Ok();
496 };
497
498 //---------------------------------------------------------------------------
499
500
501 //---------------------------------------------------------------------------
502
503 /////////////////////////////////////////////////////////////////////////////
504 //
505 // $Log$
506 // Revision 1.9 1998/12/17 14:07:37 RR
507 // Removed minor differences between wxMSW and wxGTK
508 //
509 // Revision 1.8 1998/12/16 22:10:54 RD
510 //
511 // Tweaks needed to be able to build wxPython with wxGTK.
512 //
513 // Revision 1.7 1998/12/15 20:41:18 RD
514 // Changed the import semantics from "from wxPython import *" to "from
515 // wxPython.wx import *" This is for people who are worried about
516 // namespace pollution, they can use "from wxPython import wx" and then
517 // prefix all the wxPython identifiers with "wx."
518 //
519 // Added wxTaskbarIcon for wxMSW.
520 //
521 // Made the events work for wxGrid.
522 //
523 // Added wxConfig.
524 //
525 // Added wxMiniFrame for wxGTK, (untested.)
526 //
527 // Changed many of the args and return values that were pointers to gdi
528 // objects to references to reflect changes in the wxWindows API.
529 //
530 // Other assorted fixes and additions.
531 //
532 // Revision 1.6 1998/11/25 08:45:24 RD
533 //
534 // Added wxPalette, wxRegion, wxRegionIterator, wxTaskbarIcon
535 // Added events for wxGrid
536 // Other various fixes and additions
537 //
538 // Revision 1.5 1998/10/20 06:43:57 RD
539 // New wxTreeCtrl wrappers (untested)
540 // some changes in helpers
541 // etc.
542 //
543 // Revision 1.4 1998/10/02 06:40:38 RD
544 //
545 // Version 0.4 of wxPython for MSW.
546 //
547 // Revision 1.3 1998/08/18 19:48:16 RD
548 // more wxGTK compatibility things.
549 //
550 // It builds now but there are serious runtime problems...
551 //
552 // Revision 1.2 1998/08/15 07:36:35 RD
553 // - Moved the header in the .i files out of the code that gets put into
554 // the .cpp files. It caused CVS conflicts because of the RCS ID being
555 // different each time.
556 //
557 // - A few minor fixes.
558 //
559 // Revision 1.1 1998/08/09 08:25:50 RD
560 // Initial version
561 //
562 //