]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/gdi.i
jconfig.h uses configures results
[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
70 // won't call the dtor, this is good for
71 // toolbars and such where the parent will
72 // manage the bitmap.
73 wxBitmap* wxNoRefBitmap(char* name, long flags) {
74 return new wxBitmap(name, flags);
75 }
76 %}
77
78 //---------------------------------------------------------------------------
79
80 class wxMask {
81 public:
82 wxMask(const wxBitmap& bitmap);
83 ~wxMask();
84 };
85
86 %new wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour);
87 %{
88 wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour) {
89 return new wxMask(bitmap, colour);
90 }
91 %}
92
93
94 //---------------------------------------------------------------------------
95
96
97 class wxIcon : public wxBitmap {
98 public:
99 #ifdef __WXMSW__
100 wxIcon(const wxString& name, long flags,
101 int desiredWidth = -1, int desiredHeight = -1);
102 #endif
103 ~wxIcon();
104
105 int GetDepth();
106 int GetHeight();
107 int GetWidth();
108 bool LoadFile(const wxString& name, long flags);
109 bool Ok();
110 void SetDepth(int depth);
111 void SetHeight(int height);
112 void SetWidth(int width);
113 };
114
115 //---------------------------------------------------------------------------
116
117 class wxCursor : public wxBitmap {
118 public:
119 #ifdef __WXMSW__
120 wxCursor(const wxString& cursorName, long flags, int hotSpotX=0, int hotSpotY=0);
121 #endif
122 ~wxCursor();
123 bool Ok();
124 };
125
126 %name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id);
127 %{ // Alternate 'constructor'
128 wxCursor* wxPyStockCursor(int id) {
129 return new wxCursor(id);
130 }
131 %}
132
133 //----------------------------------------------------------------------
134
135 class wxFont {
136 public:
137 // I'll do it this way to use long-lived objects and not have to
138 // worry about when python may delete the object.
139 %addmethods {
140 wxFont( int pointSize, int family, int style, int weight,
141 int underline=FALSE, char* faceName = "") {
142
143 return wxTheFontList->FindOrCreateFont(pointSize, family, style, weight,
144 underline, faceName);
145 }
146 // NO Destructor.
147 }
148
149
150 wxString GetFaceName();
151 int GetFamily();
152 #ifdef __WXMSW__
153 int GetFontId();
154 #endif
155 int GetPointSize();
156 int GetStyle();
157 bool GetUnderlined();
158 int GetWeight();
159 void SetFaceName(const wxString& faceName);
160 void SetFamily(int family);
161 void SetPointSize(int pointSize);
162 void SetStyle(int style);
163 void SetUnderlined(bool underlined);
164 void SetWeight(int weight);
165 };
166
167 //----------------------------------------------------------------------
168
169 class wxColour {
170 public:
171 wxColour(unsigned char red=0, unsigned char green=0, unsigned char blue=0);
172 ~wxColour();
173 unsigned char Red();
174 unsigned char Green();
175 unsigned char Blue();
176 bool Ok();
177 void Set(unsigned char red, unsigned char green, unsigned char blue);
178 %addmethods {
179 PyObject* Get() {
180 PyObject* rv = PyTuple_New(3);
181 PyTuple_SetItem(rv, 0, PyInt_FromLong(self->Red()));
182 PyTuple_SetItem(rv, 1, PyInt_FromLong(self->Green()));
183 PyTuple_SetItem(rv, 2, PyInt_FromLong(self->Blue()));
184 return rv;
185 }
186 }
187 };
188
189 %new wxColour* wxNamedColour(const wxString& colorName);
190 %{ // Alternate 'constructor'
191 wxColour* wxNamedColour(const wxString& colorName) {
192 return new wxColour(colorName);
193 }
194 %}
195
196
197 //----------------------------------------------------------------------
198
199 typedef unsigned long wxDash;
200
201 class wxPen {
202 public:
203 // I'll do it this way to use long-lived objects and not have to
204 // worry about when python may delete the object.
205 %addmethods {
206 wxPen(wxColour* colour, int width=1, int style=wxSOLID) {
207 return wxThePenList->FindOrCreatePen(*colour, width, style);
208 }
209 // NO Destructor.
210 }
211
212 int GetCap();
213 wxColour& GetColour();
214
215 int GetJoin();
216 int GetStyle();
217 int GetWidth();
218 bool Ok();
219 void SetCap(int cap_style);
220 void SetColour(wxColour& colour);
221 void SetJoin(int join_style);
222 void SetStyle(int style);
223 void SetWidth(int width);
224
225 #ifdef __WXMSW__
226 // **** This one needs to return a list of ints (wxDash)
227 int GetDashes(wxDash **dashes);
228 wxBitmap* GetStipple();
229 void SetDashes(int LCOUNT, wxDash* LIST);
230 void SetStipple(wxBitmap& stipple);
231 #endif
232 };
233
234 //----------------------------------------------------------------------
235
236 class wxBrush {
237 public:
238 // I'll do it this way to use long-lived objects and not have to
239 // worry about when python may delete the object.
240 %addmethods {
241 wxBrush(wxColour* colour, int style=wxSOLID) {
242 return wxTheBrushList->FindOrCreateBrush(*colour, style);
243 }
244 // NO Destructor.
245 }
246
247 wxColour& GetColour();
248 wxBitmap * GetStipple();
249 int GetStyle();
250 bool Ok();
251 void SetColour(wxColour &colour);
252 void SetStipple(wxBitmap& bitmap);
253 void SetStyle(int style);
254 };
255
256 //----------------------------------------------------------------------
257
258
259
260 class wxDC {
261 public:
262 // wxDC(); **** abstract base class, can't instantiate.
263 ~wxDC();
264
265 void BeginDrawing();
266 bool Blit(long xdest, long ydest, long width, long height,
267 wxDC *source, long xsrc, long ysrc, long logical_func);
268 void Clear();
269 void CrossHair(long x, long y);
270 void DestroyClippingRegion();
271 long DeviceToLogicalX(long x);
272 long DeviceToLogicalXRel(long x);
273 long DeviceToLogicalY(long y);
274 long DeviceToLogicalYRel(long y);
275 void DrawArc(long x1, long y1, long x2, long y2, long xc, long yc);
276 void DrawEllipse(long x, long y, long width, long height);
277 void DrawEllipticArc(long x, long y, long width, long height, long start, long end);
278 void DrawIcon(const wxIcon& icon, long x, long y);
279 void DrawLine(long x1, long y1, long x2, long y2);
280 void DrawLines(int LCOUNT, wxPoint* LIST, long xoffset=0, long yoffset=0);
281 void DrawPolygon(int LCOUNT, wxPoint* LIST, long xoffset=0, long yoffset=0,
282 int fill_style=wxODDEVEN_RULE);
283 void DrawPoint(long x, long y);
284 void DrawRectangle(long x, long y, long width, long height);
285 void DrawRoundedRectangle(long x, long y, long width, long height, long radius=20);
286 void DrawSpline(int LCOUNT, wxPoint* LIST);
287 void DrawText(const wxString& text, long x, long y);
288 void EndDoc();
289 void EndDrawing();
290 void EndPage();
291 void FloodFill(long x, long y, const wxColour& colour, int style=wxFLOOD_SURFACE);
292 wxBrush& GetBackground();
293 wxBrush& GetBrush();
294 long GetCharHeight();
295 long GetCharWidth();
296 void GetClippingBox(long *OUTPUT, long *OUTPUT,
297 long *OUTPUT, long *OUTPUT);
298 wxFont& GetFont();
299 int GetLogicalFunction();
300 int GetMapMode();
301 bool GetOptimization();
302 wxPen& GetPen();
303 %addmethods {
304 %new wxColour* GetPixel(long x, long y) {
305 wxColour* wc = new wxColour();
306 self->GetPixel(x, y, wc);
307 return wc;
308 }
309 }
310 void GetSize(int* OUTPUT, int* OUTPUT); //void GetSize(long* OUTPUT, long* OUTPUT);
311 wxColour& GetTextBackground();
312 void GetTextExtent(const wxString& string, long *OUTPUT, long *OUTPUT);
313 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
314 long *OUTPUT, long *OUTPUT, long *OUTPUT, long* OUTPUT,
315 const wxFont* font = NULL);
316 wxColour& GetTextForeground();
317 long LogicalToDeviceX(long x);
318 long LogicalToDeviceXRel(long x);
319 long LogicalToDeviceY(long y);
320 long LogicalToDeviceYRel(long y);
321 long MaxX();
322 long MaxY();
323 long MinX();
324 long MinY();
325 bool Ok();
326 void SetDeviceOrigin(long x, long y);
327 void SetBackground(const wxBrush& brush);
328 void SetBackgroundMode(int mode);
329 void SetClippingRegion(long x, long y, long width, long height);
330 void SetPalette(const wxPalette& colourMap);
331 void SetBrush(const wxBrush& brush);
332 void SetFont(const wxFont& font);
333 void SetLogicalFunction(int function);
334 void SetMapMode(int mode);
335 void SetOptimization(bool optimize);
336 void SetPen(const wxPen& pen);
337 void SetTextBackground(const wxColour& colour);
338 void SetTextForeground(const wxColour& colour);
339 void SetUserScale(double x_scale, double y_scale);
340 bool StartDoc(const wxString& message);
341 void StartPage();
342
343
344 %addmethods {
345 // This one is my own creation...
346 void DrawBitmap(wxBitmap& bitmap, long x, long y, bool swapPalette=TRUE) {
347 wxMemoryDC* memDC = new wxMemoryDC;
348 memDC->SelectObject(bitmap);
349 if (swapPalette)
350 self->SetPalette(*bitmap.GetPalette());
351 self->Blit(x, y, bitmap.GetWidth(), bitmap.GetHeight(), memDC,
352 0, 0, self->GetLogicalFunction());
353 memDC->SelectObject(wxNullBitmap);
354 delete memDC;
355 }
356 }
357 };
358
359
360 //----------------------------------------------------------------------
361
362 class wxMemoryDC : public wxDC {
363 public:
364 wxMemoryDC();
365
366 void SelectObject(const wxBitmap& bitmap);
367 }
368
369 %new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC);
370 %{ // Alternate 'constructor'
371 wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) {
372 return new wxMemoryDC(oldDC);
373 }
374 %}
375
376
377 //---------------------------------------------------------------------------
378
379 class wxScreenDC : public wxDC {
380 public:
381 wxScreenDC();
382
383 bool StartDrawingOnTop(wxWindow* window);
384 %name(StartDrawingOnTopRect) bool StartDrawingOnTop(wxRect* rect = NULL);
385 bool EndDrawingOnTop();
386 };
387
388 //---------------------------------------------------------------------------
389
390 class wxClientDC : public wxDC {
391 public:
392 wxClientDC(wxWindow* win);
393 };
394
395 //---------------------------------------------------------------------------
396
397 class wxPaintDC : public wxDC {
398 public:
399 wxPaintDC(wxWindow* win);
400 };
401
402 //---------------------------------------------------------------------------
403
404 class wxWindowDC : public wxDC {
405 public:
406 wxWindowDC(wxWindow* win);
407 };
408
409 //---------------------------------------------------------------------------
410
411 #ifndef __WXMSW__
412 class wxPostScriptDC : public wxDC {
413 public:
414 wxPostScriptDC(const wxString& output, bool interactive = TRUE, wxWindow* win = NULL);
415 };
416 #endif
417
418 //---------------------------------------------------------------------------
419
420 #ifdef __WXMSW__
421 class wxPrinterDC : public wxDC {
422 public:
423 wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output,
424 bool interactive = TRUE, int orientation = wxPORTRAIT);
425 };
426 #endif
427
428 //---------------------------------------------------------------------------
429
430 #ifdef __WXMSW__
431 class wxMetaFileDC : public wxDC {
432 public:
433 wxMetaFileDC(const wxString& filename = wxPyEmptyStr);
434 wxMetaFile* Close();
435 };
436 #endif
437
438 //---------------------------------------------------------------------------
439 //---------------------------------------------------------------------------
440
441
442 %readonly
443 %{
444 #if 0
445 %}
446 extern wxFont *wxNORMAL_FONT;
447 extern wxFont *wxSMALL_FONT;
448 extern wxFont *wxITALIC_FONT;
449 extern wxFont *wxSWISS_FONT;
450 extern wxPen *wxRED_PEN;
451
452 extern wxPen *wxCYAN_PEN;
453 extern wxPen *wxGREEN_PEN;
454 extern wxPen *wxBLACK_PEN;
455 extern wxPen *wxWHITE_PEN;
456 extern wxPen *wxTRANSPARENT_PEN;
457 extern wxPen *wxBLACK_DASHED_PEN;
458 extern wxPen *wxGREY_PEN;
459 extern wxPen *wxMEDIUM_GREY_PEN;
460 extern wxPen *wxLIGHT_GREY_PEN;
461
462 extern wxBrush *wxBLUE_BRUSH;
463 extern wxBrush *wxGREEN_BRUSH;
464 extern wxBrush *wxWHITE_BRUSH;
465 extern wxBrush *wxBLACK_BRUSH;
466 extern wxBrush *wxTRANSPARENT_BRUSH;
467 extern wxBrush *wxCYAN_BRUSH;
468 extern wxBrush *wxRED_BRUSH;
469 extern wxBrush *wxGREY_BRUSH;
470 extern wxBrush *wxMEDIUM_GREY_BRUSH;
471 extern wxBrush *wxLIGHT_GREY_BRUSH;
472
473 extern wxColour *wxBLACK;
474 extern wxColour *wxWHITE;
475 extern wxColour *wxRED;
476 extern wxColour *wxBLUE;
477 extern wxColour *wxGREEN;
478 extern wxColour *wxCYAN;
479 extern wxColour *wxLIGHT_GREY;
480
481 extern wxCursor *wxSTANDARD_CURSOR;
482 extern wxCursor *wxHOURGLASS_CURSOR;
483 extern wxCursor *wxCROSS_CURSOR;
484
485 extern wxBitmap wxNullBitmap;
486 extern wxIcon wxNullIcon;
487 extern wxCursor wxNullCursor;
488 extern wxPen wxNullPen;
489 extern wxBrush wxNullBrush;
490 extern wxPalette wxNullPalette;
491 extern wxFont wxNullFont;
492 extern wxColour wxNullColour;
493
494 %readwrite
495 %{
496 #endif
497 %}
498
499 //---------------------------------------------------------------------------
500
501 class wxPalette {
502 public:
503 wxPalette(int LCOUNT, byte* LIST, byte* LIST, byte* LIST);
504 ~wxPalette();
505
506 int GetPixel(byte red, byte green, byte blue);
507 bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT);
508 bool Ok();
509 };
510
511 //---------------------------------------------------------------------------
512
513 enum {
514 wxIMAGELIST_DRAW_NORMAL ,
515 wxIMAGELIST_DRAW_TRANSPARENT,
516 wxIMAGELIST_DRAW_SELECTED,
517 wxIMAGELIST_DRAW_FOCUSED,
518 wxIMAGE_LIST_NORMAL,
519 wxIMAGE_LIST_SMALL,
520 wxIMAGE_LIST_STATE
521 };
522
523 class wxImageList {
524 public:
525 wxImageList(int width, int height, const bool mask=TRUE, int initialCount=1);
526 ~wxImageList();
527
528 #ifdef __WXMSW__
529 int Add(const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
530 %name(AddWithColourMask)int Add(const wxBitmap& bitmap, const wxColour& maskColour);
531 %name(AddIcon)int Add(const wxIcon& icon);
532 bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
533 %name(ReplaceIcon)bool Replace(int index, const wxIcon& icon);
534 #else
535 int Add(const wxBitmap& bitmap);
536 bool Replace(int index, const wxBitmap& bitmap);
537 #endif
538
539 bool Draw(int index, wxDC& dc, int x, int x, int flags = wxIMAGELIST_DRAW_NORMAL,
540 const bool solidBackground = FALSE);
541
542 int GetImageCount();
543 bool Remove(int index);
544 bool RemoveAll();
545 };
546
547
548 //---------------------------------------------------------------------------
549