]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/gdi.i
Changes needed to enable wxGTK compatibility.
[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 #include <wx/imaglist.h>
20 #ifndef __WXMSW__
21 #include <wx/dcps.h>
22 #endif
23 %}
24
25 //----------------------------------------------------------------------
26
27 %include typemaps.i
28 %include my_typemaps.i
29
30 // Import some definitions of other classes, etc.
31 %import _defs.i
32 %import misc.i
33
34 //---------------------------------------------------------------------------
35
36 class wxBitmap {
37 public:
38 wxBitmap(const wxString& name, long type);
39 ~wxBitmap();
40
41 #ifdef __WXMSW__
42 void Create(int width, int height, int depth = -1);
43 #endif
44 int GetDepth();
45 int GetHeight();
46 wxPalette* GetPalette();
47 wxMask* GetMask();
48 int GetWidth();
49 bool LoadFile(const wxString& name, long flags);
50 bool Ok();
51 bool SaveFile(const wxString& name, int type, wxPalette* palette = NULL);
52 void SetDepth(int depth);
53 void SetHeight(int height);
54 void SetMask(wxMask* mask);
55 #ifdef __WXMSW__
56 void SetPalette(wxPalette& palette);
57 #endif
58 void SetWidth(int width);
59 };
60
61 %new wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1);
62 wxBitmap* wxNoRefBitmap(char* name, long flags);
63
64 %{ // Alternate 'constructor'
65 wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1) {
66 return new wxBitmap(width, height, depth);
67 }
68
69 // This one won't own the reference, so Python won't call
70 // the dtor, this is good for toolbars and such where
71 // the parent will manage the bitmap.
72 wxBitmap* wxNoRefBitmap(char* name, long flags) {
73 return new wxBitmap(name, flags);
74 }
75 %}
76
77 //---------------------------------------------------------------------------
78
79 class wxMask {
80 public:
81 wxMask(const wxBitmap& bitmap);
82 ~wxMask();
83 };
84
85 %new wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour);
86 %{
87 wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour) {
88 return new wxMask(bitmap, colour);
89 }
90 %}
91
92
93 //---------------------------------------------------------------------------
94
95
96 class wxIcon : public wxBitmap {
97 public:
98 #ifdef __WXMSW__
99 wxIcon(const wxString& name, long flags,
100 int desiredWidth = -1, int desiredHeight = -1);
101 #endif
102 ~wxIcon();
103
104 int GetDepth();
105 int GetHeight();
106 int GetWidth();
107 bool LoadFile(const wxString& name, long flags);
108 bool Ok();
109 void SetDepth(int depth);
110 void SetHeight(int height);
111 void SetWidth(int width);
112 };
113
114 //---------------------------------------------------------------------------
115
116 class wxCursor : public wxBitmap {
117 public:
118 #ifdef __WXMSW__
119 wxCursor(const wxString& cursorName, long flags, int hotSpotX=0, int hotSpotY=0);
120 #endif
121 ~wxCursor();
122 bool Ok();
123 };
124
125 %name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id);
126 %{ // Alternate 'constructor'
127 wxCursor* wxPyStockCursor(int id) {
128 return new wxCursor(id);
129 }
130 %}
131
132 //----------------------------------------------------------------------
133
134 class wxFont {
135 public:
136 // I'll do it this way to use long-lived objects and not have to
137 // worry about when python may delete the object.
138 %addmethods {
139 wxFont( int pointSize, int family, int style, int weight,
140 int underline=FALSE, char* faceName = "") {
141
142 return wxTheFontList->FindOrCreateFont(pointSize, family, style, weight,
143 underline, faceName);
144 }
145 // NO Destructor.
146 }
147
148
149 wxString GetFaceName();
150 int GetFamily();
151 #ifdef __WXMSW__
152 int GetFontId();
153 #endif
154 int GetPointSize();
155 int GetStyle();
156 bool GetUnderlined();
157 int GetWeight();
158 void SetFaceName(const wxString& faceName);
159 void SetFamily(int family);
160 void SetPointSize(int pointSize);
161 void SetStyle(int style);
162 void SetUnderlined(bool underlined);
163 void SetWeight(int weight);
164 };
165
166 //----------------------------------------------------------------------
167
168 class wxColour {
169 public:
170 wxColour(unsigned char red=0, unsigned char green=0, unsigned char blue=0);
171 ~wxColour();
172 unsigned char Red();
173 unsigned char Green();
174 unsigned char Blue();
175 bool Ok();
176 void Set(unsigned char red, unsigned char green, unsigned char blue);
177 %addmethods {
178 PyObject* Get() {
179 PyObject* rv = PyTuple_New(3);
180 PyTuple_SetItem(rv, 0, PyInt_FromLong(self->Red()));
181 PyTuple_SetItem(rv, 1, PyInt_FromLong(self->Green()));
182 PyTuple_SetItem(rv, 2, PyInt_FromLong(self->Blue()));
183 return rv;
184 }
185 }
186 };
187
188 %new wxColour* wxNamedColour(const wxString& colorName);
189 %{ // Alternate 'constructor'
190 wxColour* wxNamedColour(const wxString& colorName) {
191 return new wxColour(colorName);
192 }
193 %}
194
195
196 //----------------------------------------------------------------------
197
198 typedef unsigned long wxDash;
199
200 class wxPen {
201 public:
202 // I'll do it this way to use long-lived objects and not have to
203 // worry about when python may delete the object.
204 %addmethods {
205 wxPen(wxColour* colour, int width=1, int style=wxSOLID) {
206 return wxThePenList->FindOrCreatePen(*colour, width, style);
207 }
208 // NO Destructor.
209 }
210
211 int GetCap();
212 wxColour& GetColour();
213
214 int GetJoin();
215 int GetStyle();
216 int GetWidth();
217 bool Ok();
218 void SetCap(int cap_style);
219 void SetColour(wxColour& colour);
220 void SetJoin(int join_style);
221 void SetStyle(int style);
222 void SetWidth(int width);
223
224 #ifdef __WXMSW__
225 // **** This one needs to return a list of ints (wxDash)
226 int GetDashes(wxDash **dashes);
227 wxBitmap* GetStipple();
228 void SetDashes(int LCOUNT, wxDash* LIST);
229 void SetStipple(wxBitmap& stipple);
230 #endif
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 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
313 long *OUTPUT, long *OUTPUT, long *OUTPUT, long* OUTPUT,
314 const wxFont* font = NULL);
315 wxColour& GetTextForeground();
316 long LogicalToDeviceX(long x);
317 long LogicalToDeviceXRel(long x);
318 long LogicalToDeviceY(long y);
319 long LogicalToDeviceYRel(long y);
320 long MaxX();
321 long MaxY();
322 long MinX();
323 long MinY();
324 bool Ok();
325 void SetDeviceOrigin(long x, long y);
326 void SetBackground(const wxBrush& brush);
327 void SetBackgroundMode(int mode);
328 void SetClippingRegion(long x, long y, long width, long height);
329 void SetPalette(const wxPalette& colourMap);
330 void SetBrush(const wxBrush& brush);
331 void SetFont(const wxFont& font);
332 void SetLogicalFunction(int function);
333 void SetMapMode(int mode);
334 void SetOptimization(bool optimize);
335 void SetPen(const wxPen& pen);
336 void SetTextBackground(const wxColour& colour);
337 void SetTextForeground(const wxColour& colour);
338 void SetUserScale(double x_scale, double y_scale);
339 bool StartDoc(const wxString& message);
340 void StartPage();
341
342
343 %addmethods {
344 // This one is my own creation...
345 void DrawBitmap(wxBitmap& bitmap, long x, long y, bool swapPalette=TRUE) {
346 wxMemoryDC* memDC = new wxMemoryDC;
347 memDC->SelectObject(bitmap);
348 if (swapPalette)
349 self->SetPalette(*bitmap.GetPalette());
350 self->Blit(x, y, bitmap.GetWidth(), bitmap.GetHeight(), memDC,
351 0, 0, self->GetLogicalFunction());
352 memDC->SelectObject(wxNullBitmap);
353 delete memDC;
354 }
355 }
356 };
357
358
359 //----------------------------------------------------------------------
360
361 class wxMemoryDC : public wxDC {
362 public:
363 wxMemoryDC();
364
365 void SelectObject(const wxBitmap& bitmap);
366 }
367
368 %new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC);
369 %{ // Alternate 'constructor'
370 wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) {
371 return new wxMemoryDC(oldDC);
372 }
373 %}
374
375
376 //---------------------------------------------------------------------------
377
378 class wxScreenDC : public wxDC {
379 public:
380 wxScreenDC();
381
382 bool StartDrawingOnTop(wxWindow* window);
383 %name(StartDrawingOnTopRect) bool StartDrawingOnTop(wxRect* rect = NULL);
384 bool EndDrawingOnTop();
385 };
386
387 //---------------------------------------------------------------------------
388
389 class wxClientDC : public wxDC {
390 public:
391 wxClientDC(wxWindow* win);
392 };
393
394 //---------------------------------------------------------------------------
395
396 class wxPaintDC : public wxDC {
397 public:
398 wxPaintDC(wxWindow* win);
399 };
400
401 //---------------------------------------------------------------------------
402
403 class wxWindowDC : public wxDC {
404 public:
405 wxWindowDC(wxWindow* win);
406 };
407
408 //---------------------------------------------------------------------------
409
410 #ifndef __WXMSW__
411 class wxPostScriptDC : public wxDC {
412 public:
413 wxPostScriptDC(const wxString& output, bool interactive = TRUE, wxWindow* win = NULL);
414 };
415 #endif
416
417 //---------------------------------------------------------------------------
418
419 #ifdef __WXMSW__
420 class wxPrinterDC : public wxDC {
421 public:
422 wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output,
423 bool interactive = TRUE, int orientation = wxPORTRAIT);
424 };
425 #endif
426
427 //---------------------------------------------------------------------------
428
429 #ifdef __WXMSW__
430 class wxMetaFileDC : public wxDC {
431 public:
432 wxMetaFileDC(const wxString& filename = wxPyEmptyStr);
433 wxMetaFile* Close();
434 };
435 #endif
436
437 //---------------------------------------------------------------------------
438 //---------------------------------------------------------------------------
439
440
441 %readonly
442 %{
443 #if 0
444 %}
445 extern wxFont *wxNORMAL_FONT;
446 extern wxFont *wxSMALL_FONT;
447 extern wxFont *wxITALIC_FONT;
448 extern wxFont *wxSWISS_FONT;
449 extern wxPen *wxRED_PEN;
450
451 extern wxPen *wxCYAN_PEN;
452 extern wxPen *wxGREEN_PEN;
453 extern wxPen *wxBLACK_PEN;
454 extern wxPen *wxWHITE_PEN;
455 extern wxPen *wxTRANSPARENT_PEN;
456 extern wxPen *wxBLACK_DASHED_PEN;
457 extern wxPen *wxGREY_PEN;
458 extern wxPen *wxMEDIUM_GREY_PEN;
459 extern wxPen *wxLIGHT_GREY_PEN;
460
461 extern wxBrush *wxBLUE_BRUSH;
462 extern wxBrush *wxGREEN_BRUSH;
463 extern wxBrush *wxWHITE_BRUSH;
464 extern wxBrush *wxBLACK_BRUSH;
465 extern wxBrush *wxTRANSPARENT_BRUSH;
466 extern wxBrush *wxCYAN_BRUSH;
467 extern wxBrush *wxRED_BRUSH;
468 extern wxBrush *wxGREY_BRUSH;
469 extern wxBrush *wxMEDIUM_GREY_BRUSH;
470 extern wxBrush *wxLIGHT_GREY_BRUSH;
471
472 extern wxColour *wxBLACK;
473 extern wxColour *wxWHITE;
474 extern wxColour *wxRED;
475 extern wxColour *wxBLUE;
476 extern wxColour *wxGREEN;
477 extern wxColour *wxCYAN;
478 extern wxColour *wxLIGHT_GREY;
479
480 extern wxCursor *wxSTANDARD_CURSOR;
481 extern wxCursor *wxHOURGLASS_CURSOR;
482 extern wxCursor *wxCROSS_CURSOR;
483
484 extern wxBitmap wxNullBitmap;
485 extern wxIcon wxNullIcon;
486 extern wxCursor wxNullCursor;
487 extern wxPen wxNullPen;
488 extern wxBrush wxNullBrush;
489 extern wxPalette wxNullPalette;
490 extern wxFont wxNullFont;
491 extern wxColour wxNullColour;
492
493 %readwrite
494 %{
495 #endif
496 %}
497
498 //---------------------------------------------------------------------------
499
500 class wxPalette {
501 public:
502 wxPalette(int LCOUNT, byte* LIST, byte* LIST, byte* LIST);
503 ~wxPalette();
504
505 int GetPixel(byte red, byte green, byte blue);
506 bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT);
507 bool Ok();
508 };
509
510 //---------------------------------------------------------------------------
511
512 enum {
513 wxIMAGELIST_DRAW_NORMAL ,
514 wxIMAGELIST_DRAW_TRANSPARENT,
515 wxIMAGELIST_DRAW_SELECTED,
516 wxIMAGELIST_DRAW_FOCUSED,
517 wxIMAGE_LIST_NORMAL,
518 wxIMAGE_LIST_SMALL,
519 wxIMAGE_LIST_STATE
520 };
521
522 class wxImageList {
523 public:
524 wxImageList(int width, int height, const bool mask=TRUE, int initialCount=1);
525 ~wxImageList();
526
527 #ifdef __WXMSW__
528 int Add(const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
529 %name(AddWithColourMask)int Add(const wxBitmap& bitmap, const wxColour& maskColour);
530 %name(AddIcon)int Add(const wxIcon& icon);
531 bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
532 %name(ReplaceIcon)bool Replace(int index, const wxIcon& icon);
533 #else
534 int Add(const wxBitmap& bitmap);
535 bool Replace(int index, const wxBitmap& bitmap);
536 #endif
537
538 bool Draw(int index, wxDC& dc, int x, int x, int flags = wxIMAGELIST_DRAW_NORMAL,
539 const bool solidBackground = FALSE);
540
541 int GetImageCount();
542 bool Remove(int index);
543 bool RemoveAll();
544 };
545
546
547 //---------------------------------------------------------------------------
548
549 /////////////////////////////////////////////////////////////////////////////
550 //
551 // $Log$
552 // Revision 1.14 1999/02/20 10:02:36 RD
553 // Changes needed to enable wxGTK compatibility.
554 //
555 // Revision 1.13 1999/02/20 09:02:58 RD
556 // Added wxWindow_FromHWND(hWnd) for wxMSW to construct a wxWindow from a
557 // window handle. If you can get the window handle into the python code,
558 // it should just work... More news on this later.
559 //
560 // Added wxImageList, wxToolTip.
561 //
562 // Re-enabled wxConfig.DeleteAll() since it is reportedly fixed for the
563 // wxRegConfig class.
564 //
565 // As usual, some bug fixes, tweaks, etc.
566 //
567 // Revision 1.12 1999/01/30 07:30:11 RD
568 //
569 // Added wxSashWindow, wxSashEvent, wxLayoutAlgorithm, etc.
570 //
571 // Various cleanup, tweaks, minor additions, etc. to maintain
572 // compatibility with the current wxWindows.
573 //
574 // Revision 1.11 1998/12/18 15:49:05 RR
575 //
576 // wxClipboard now serves the primary selection as well
577 // wxPython fixes
578 // warning mesages
579 //
580 // Revision 1.10 1998/12/17 18:05:50 RD
581 //
582 // wxPython 0.5.2
583 // Minor fixes and SWIG code generation for RR's changes. MSW and GTK
584 // versions are much closer now!
585 //
586 // Revision 1.9 1998/12/17 14:07:37 RR
587 //
588 // Removed minor differences between wxMSW and wxGTK
589 //
590 // Revision 1.8 1998/12/16 22:10:54 RD
591 //
592 // Tweaks needed to be able to build wxPython with wxGTK.
593 //
594 // Revision 1.7 1998/12/15 20:41:18 RD
595 // Changed the import semantics from "from wxPython import *" to "from
596 // wxPython.wx import *" This is for people who are worried about
597 // namespace pollution, they can use "from wxPython import wx" and then
598 // prefix all the wxPython identifiers with "wx."
599 //
600 // Added wxTaskbarIcon for wxMSW.
601 //
602 // Made the events work for wxGrid.
603 //
604 // Added wxConfig.
605 //
606 // Added wxMiniFrame for wxGTK, (untested.)
607 //
608 // Changed many of the args and return values that were pointers to gdi
609 // objects to references to reflect changes in the wxWindows API.
610 //
611 // Other assorted fixes and additions.
612 //
613 // Revision 1.6 1998/11/25 08:45:24 RD
614 //
615 // Added wxPalette, wxRegion, wxRegionIterator, wxTaskbarIcon
616 // Added events for wxGrid
617 // Other various fixes and additions
618 //
619 // Revision 1.5 1998/10/20 06:43:57 RD
620 // New wxTreeCtrl wrappers (untested)
621 // some changes in helpers
622 // etc.
623 //
624 // Revision 1.4 1998/10/02 06:40:38 RD
625 //
626 // Version 0.4 of wxPython for MSW.
627 //
628 // Revision 1.3 1998/08/18 19:48:16 RD
629 // more wxGTK compatibility things.
630 //
631 // It builds now but there are serious runtime problems...
632 //
633 // Revision 1.2 1998/08/15 07:36:35 RD
634 // - Moved the header in the .i files out of the code that gets put into
635 // the .cpp files. It caused CVS conflicts because of the RCS ID being
636 // different each time.
637 //
638 // - A few minor fixes.
639 //
640 // Revision 1.1 1998/08/09 08:25:50 RD
641 // Initial version
642 //
643 //