]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/gdi.i
wxClipboard now serves the primary selection as well
[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 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
165 class wxColour {
166 public:
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
195 typedef unsigned long wxDash;
196
197 class wxPen {
198 public:
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
211 int GetJoin();
212 int GetStyle();
213 int GetWidth();
214 bool Ok();
215 void SetCap(int cap_style);
216 void SetColour(wxColour& colour);
217 void SetJoin(int join_style);
218 void SetStyle(int style);
219 void SetWidth(int width);
220
221 #ifdef __WXMSW__
222 // **** This one needs to return a list of ints (wxDash)
223 int GetDashes(wxDash **dashes);
224 wxBitmap* GetStipple();
225 void SetDashes(int LCOUNT, wxDash* LIST);
226 void SetStipple(wxBitmap& stipple);
227 #endif
228 };
229
230 //----------------------------------------------------------------------
231
232 class wxBrush {
233 public:
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);
248 void SetStipple(wxBitmap& bitmap);
249 void SetStyle(int style);
250 };
251
252 //----------------------------------------------------------------------
253
254
255
256 class wxDC {
257 public:
258 // wxDC(); **** abstract base class, can't instantiate.
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);
288 wxBrush& GetBackground();
289 wxBrush& GetBrush();
290 long GetCharHeight();
291 long GetCharWidth();
292 void GetClippingBox(long *OUTPUT, long *OUTPUT,
293 long *OUTPUT, long *OUTPUT);
294 wxFont& GetFont();
295 int GetLogicalFunction();
296 int GetMapMode();
297 bool GetOptimization();
298 wxPen& GetPen();
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 }
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 {
339 // This one is my own creation...
340 void DrawBitmap(wxBitmap& bitmap, long x, long y, bool swapPalette=TRUE) {
341 wxMemoryDC* memDC = new wxMemoryDC;
342 memDC->SelectObject(bitmap);
343 if (swapPalette)
344 self->SetPalette(*bitmap.GetPalette());
345 self->Blit(x, y, bitmap.GetWidth(), bitmap.GetHeight(), memDC,
346 0, 0, self->GetLogicalFunction());
347 memDC->SelectObject(wxNullBitmap);
348 delete memDC;
349 }
350 }
351 };
352
353
354 //----------------------------------------------------------------------
355
356 class wxMemoryDC : public wxDC {
357 public:
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
373 class wxScreenDC : public wxDC {
374 public:
375 wxScreenDC();
376
377 bool StartDrawingOnTop(wxWindow* window);
378 %name(StartDrawingOnTopRect) bool StartDrawingOnTop(wxRect* rect = NULL);
379 bool EndDrawingOnTop();
380 };
381
382 //---------------------------------------------------------------------------
383
384 class wxClientDC : public wxDC {
385 public:
386 wxClientDC(wxWindow* win);
387 };
388
389 //---------------------------------------------------------------------------
390
391 class wxPaintDC : public wxDC {
392 public:
393 wxPaintDC(wxWindow* win);
394 };
395
396 //---------------------------------------------------------------------------
397
398 class wxWindowDC : public wxDC {
399 public:
400 wxWindowDC(wxWindow* win);
401 };
402
403 //---------------------------------------------------------------------------
404
405 #ifndef __WXMSW__
406 class wxPostScriptDC : public wxDC {
407 public:
408 wxPostScriptDC(const wxString& output, bool interactive = TRUE, wxWindow* win = NULL);
409 };
410 #endif
411
412 //---------------------------------------------------------------------------
413
414 #ifdef __WXMSW__
415 class wxPrinterDC : public wxDC {
416 public:
417 wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output,
418 bool interactive = TRUE, int orientation = wxPORTRAIT);
419 };
420 #endif
421
422 //---------------------------------------------------------------------------
423
424 #ifdef __WXMSW__
425 class wxMetaFileDC : public wxDC {
426 public:
427 wxMetaFileDC(const wxString& filename = wxPyEmptyStr);
428 wxMetaFile* Close();
429 };
430 #endif
431
432 //---------------------------------------------------------------------------
433 //---------------------------------------------------------------------------
434
435
436 %readonly
437 extern wxFont *wxNORMAL_FONT;
438 extern wxFont *wxSMALL_FONT;
439 extern wxFont *wxITALIC_FONT;
440 extern wxFont *wxSWISS_FONT;
441 extern wxPen *wxRED_PEN;
442
443 extern wxPen *wxCYAN_PEN;
444 extern wxPen *wxGREEN_PEN;
445 extern wxPen *wxBLACK_PEN;
446 extern wxPen *wxWHITE_PEN;
447 extern wxPen *wxTRANSPARENT_PEN;
448 extern wxPen *wxBLACK_DASHED_PEN;
449 extern wxPen *wxGREY_PEN;
450 extern wxPen *wxMEDIUM_GREY_PEN;
451 extern wxPen *wxLIGHT_GREY_PEN;
452
453 extern wxBrush *wxBLUE_BRUSH;
454 extern wxBrush *wxGREEN_BRUSH;
455 extern wxBrush *wxWHITE_BRUSH;
456 extern wxBrush *wxBLACK_BRUSH;
457 extern wxBrush *wxTRANSPARENT_BRUSH;
458 extern wxBrush *wxCYAN_BRUSH;
459 extern wxBrush *wxRED_BRUSH;
460 extern wxBrush *wxGREY_BRUSH;
461 extern wxBrush *wxMEDIUM_GREY_BRUSH;
462 extern wxBrush *wxLIGHT_GREY_BRUSH;
463
464 extern wxColour *wxBLACK;
465 extern wxColour *wxWHITE;
466 extern wxColour *wxRED;
467 extern wxColour *wxBLUE;
468 extern wxColour *wxGREEN;
469 extern wxColour *wxCYAN;
470 extern wxColour *wxLIGHT_GREY;
471
472 extern wxCursor *wxSTANDARD_CURSOR;
473 extern wxCursor *wxHOURGLASS_CURSOR;
474 extern wxCursor *wxCROSS_CURSOR;
475
476 extern wxBitmap wxNullBitmap;
477 extern wxIcon wxNullIcon;
478 extern wxCursor wxNullCursor;
479 extern wxPen wxNullPen;
480 extern wxBrush wxNullBrush;
481 extern wxPalette wxNullPalette;
482 extern wxFont wxNullFont;
483 extern wxColour wxNullColour;
484
485 //---------------------------------------------------------------------------
486
487 class wxPalette {
488 public:
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
500 //---------------------------------------------------------------------------
501
502 /////////////////////////////////////////////////////////////////////////////
503 //
504 // $Log$
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 //
510 // Revision 1.10 1998/12/17 18:05:50 RD
511 //
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 //
516 // Revision 1.9 1998/12/17 14:07:37 RR
517 //
518 // Removed minor differences between wxMSW and wxGTK
519 //
520 // Revision 1.8 1998/12/16 22:10:54 RD
521 //
522 // Tweaks needed to be able to build wxPython with wxGTK.
523 //
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 //
543 // Revision 1.6 1998/11/25 08:45:24 RD
544 //
545 // Added wxPalette, wxRegion, wxRegionIterator, wxTaskbarIcon
546 // Added events for wxGrid
547 // Other various fixes and additions
548 //
549 // Revision 1.5 1998/10/20 06:43:57 RD
550 // New wxTreeCtrl wrappers (untested)
551 // some changes in helpers
552 // etc.
553 //
554 // Revision 1.4 1998/10/02 06:40:38 RD
555 //
556 // Version 0.4 of wxPython for MSW.
557 //
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 //
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 //
570 // Revision 1.1 1998/08/09 08:25:50 RD
571 // Initial version
572 //
573 //