]> git.saurik.com Git - wxWidgets.git/blame - utils/wxPython/src/gdi.i
minimal now works in Unicode mode
[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>
af309447 19#include <wx/imaglist.h>
105e45b9 20#ifndef __WXMSW__
08127323 21#include <wx/dcps.h>
105e45b9 22#endif
7bf85405
RD
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
36class wxBitmap {
37public:
38 wxBitmap(const wxString& name, long type);
39 ~wxBitmap();
40
fb5e0af0 41#ifdef __WXMSW__
7bf85405 42 void Create(int width, int height, int depth = -1);
fb5e0af0 43#endif
7bf85405
RD
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);
fb5e0af0 55#ifdef __WXMSW__
b8b8dda7 56 void SetPalette(wxPalette& palette);
fb5e0af0 57#endif
7bf85405
RD
58 void SetWidth(int width);
59};
60
61%new wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1);
62wxBitmap* wxNoRefBitmap(char* name, long flags);
9c039d08 63
7bf85405
RD
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
79class wxMask {
80public:
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
96class wxIcon : public wxBitmap {
97public:
fb5e0af0
RD
98#ifdef __WXMSW__
99 wxIcon(const wxString& name, long flags,
100 int desiredWidth = -1, int desiredHeight = -1);
101#endif
7bf85405
RD
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);
7bf85405
RD
111 void SetWidth(int width);
112};
113
114//---------------------------------------------------------------------------
115
116class wxCursor : public wxBitmap {
117public:
fb5e0af0 118#ifdef __WXMSW__
7bf85405 119 wxCursor(const wxString& cursorName, long flags, int hotSpotX=0, int hotSpotY=0);
fb5e0af0 120#endif
7bf85405
RD
121 ~wxCursor();
122 bool Ok();
123};
124
9c039d08 125%name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id);
7bf85405 126%{ // Alternate 'constructor'
9c039d08 127 wxCursor* wxPyStockCursor(int id) {
7bf85405
RD
128 return new wxCursor(id);
129 }
130%}
131
132//----------------------------------------------------------------------
133
134class wxFont {
135public:
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();
08127323 151#ifdef __WXMSW__
7bf85405 152 int GetFontId();
08127323 153#endif
7bf85405
RD
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
168class wxColour {
169public:
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
198typedef unsigned long wxDash;
199
200class wxPen {
201public:
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
fb5e0af0 214 int GetJoin();
7bf85405
RD
215 int GetStyle();
216 int GetWidth();
217 bool Ok();
218 void SetCap(int cap_style);
219 void SetColour(wxColour& colour);
aeeb6a44
RR
220 void SetJoin(int join_style);
221 void SetStyle(int style);
222 void SetWidth(int width);
08127323 223
fb5e0af0 224#ifdef __WXMSW__
aeeb6a44
RR
225 // **** This one needs to return a list of ints (wxDash)
226 int GetDashes(wxDash **dashes);
227 wxBitmap* GetStipple();
7bf85405 228 void SetDashes(int LCOUNT, wxDash* LIST);
b8b8dda7 229 void SetStipple(wxBitmap& stipple);
fb5e0af0 230#endif
7bf85405
RD
231};
232
233//----------------------------------------------------------------------
234
235class wxBrush {
236public:
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);
b8b8dda7 251 void SetStipple(wxBitmap& bitmap);
7bf85405
RD
252 void SetStyle(int style);
253};
254
255//----------------------------------------------------------------------
256
257
258
259class wxDC {
260public:
fb5e0af0 261// wxDC(); **** abstract base class, can't instantiate.
7bf85405
RD
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);
b8b8dda7
RD
291 wxBrush& GetBackground();
292 wxBrush& GetBrush();
7bf85405
RD
293 long GetCharHeight();
294 long GetCharWidth();
295 void GetClippingBox(long *OUTPUT, long *OUTPUT,
296 long *OUTPUT, long *OUTPUT);
b8b8dda7 297 wxFont& GetFont();
7bf85405
RD
298 int GetLogicalFunction();
299 int GetMapMode();
300 bool GetOptimization();
b8b8dda7 301 wxPen& GetPen();
fb5e0af0
RD
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 }
7bf85405
RD
309 void GetSize(int* OUTPUT, int* OUTPUT); //void GetSize(long* OUTPUT, long* OUTPUT);
310 wxColour& GetTextBackground();
af309447
RD
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);
7bf85405
RD
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 {
7bf85405 344 // This one is my own creation...
b8b8dda7 345 void DrawBitmap(wxBitmap& bitmap, long x, long y, bool swapPalette=TRUE) {
7bf85405
RD
346 wxMemoryDC* memDC = new wxMemoryDC;
347 memDC->SelectObject(bitmap);
348 if (swapPalette)
b8b8dda7
RD
349 self->SetPalette(*bitmap.GetPalette());
350 self->Blit(x, y, bitmap.GetWidth(), bitmap.GetHeight(), memDC,
7bf85405
RD
351 0, 0, self->GetLogicalFunction());
352 memDC->SelectObject(wxNullBitmap);
353 delete memDC;
354 }
355 }
356};
357
358
359//----------------------------------------------------------------------
360
361class wxMemoryDC : public wxDC {
362public:
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
378class wxScreenDC : public wxDC {
379public:
380 wxScreenDC();
381
382 bool StartDrawingOnTop(wxWindow* window);
383 %name(StartDrawingOnTopRect) bool StartDrawingOnTop(wxRect* rect = NULL);
384 bool EndDrawingOnTop();
385};
386
387//---------------------------------------------------------------------------
388
389class wxClientDC : public wxDC {
390public:
391 wxClientDC(wxWindow* win);
392};
393
394//---------------------------------------------------------------------------
395
396class wxPaintDC : public wxDC {
397public:
398 wxPaintDC(wxWindow* win);
399};
400
401//---------------------------------------------------------------------------
402
b639c3c5
RD
403class wxWindowDC : public wxDC {
404public:
405 wxWindowDC(wxWindow* win);
406};
b639c3c5
RD
407
408//---------------------------------------------------------------------------
409
be4d9c1f 410#ifndef __WXMSW__
7bf85405
RD
411class wxPostScriptDC : public wxDC {
412public:
413 wxPostScriptDC(const wxString& output, bool interactive = TRUE, wxWindow* win = NULL);
414};
be4d9c1f 415#endif
7bf85405
RD
416
417//---------------------------------------------------------------------------
418
fb5e0af0 419#ifdef __WXMSW__
7bf85405
RD
420class wxPrinterDC : public wxDC {
421public:
422 wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output,
423 bool interactive = TRUE, int orientation = wxPORTRAIT);
424};
fb5e0af0 425#endif
7bf85405
RD
426
427//---------------------------------------------------------------------------
428
fb5e0af0 429#ifdef __WXMSW__
7bf85405
RD
430class wxMetaFileDC : public wxDC {
431public:
432 wxMetaFileDC(const wxString& filename = wxPyEmptyStr);
433 wxMetaFile* Close();
434};
fb5e0af0 435#endif
7bf85405
RD
436
437//---------------------------------------------------------------------------
438//---------------------------------------------------------------------------
439
440
441%readonly
af309447
RD
442%{
443#if 0
444%}
7bf85405
RD
445extern wxFont *wxNORMAL_FONT;
446extern wxFont *wxSMALL_FONT;
447extern wxFont *wxITALIC_FONT;
448extern wxFont *wxSWISS_FONT;
449extern wxPen *wxRED_PEN;
450
451extern wxPen *wxCYAN_PEN;
452extern wxPen *wxGREEN_PEN;
453extern wxPen *wxBLACK_PEN;
454extern wxPen *wxWHITE_PEN;
455extern wxPen *wxTRANSPARENT_PEN;
456extern wxPen *wxBLACK_DASHED_PEN;
457extern wxPen *wxGREY_PEN;
458extern wxPen *wxMEDIUM_GREY_PEN;
459extern wxPen *wxLIGHT_GREY_PEN;
460
461extern wxBrush *wxBLUE_BRUSH;
462extern wxBrush *wxGREEN_BRUSH;
463extern wxBrush *wxWHITE_BRUSH;
464extern wxBrush *wxBLACK_BRUSH;
465extern wxBrush *wxTRANSPARENT_BRUSH;
466extern wxBrush *wxCYAN_BRUSH;
467extern wxBrush *wxRED_BRUSH;
468extern wxBrush *wxGREY_BRUSH;
469extern wxBrush *wxMEDIUM_GREY_BRUSH;
470extern wxBrush *wxLIGHT_GREY_BRUSH;
471
472extern wxColour *wxBLACK;
473extern wxColour *wxWHITE;
474extern wxColour *wxRED;
475extern wxColour *wxBLUE;
476extern wxColour *wxGREEN;
477extern wxColour *wxCYAN;
478extern wxColour *wxLIGHT_GREY;
479
480extern wxCursor *wxSTANDARD_CURSOR;
481extern wxCursor *wxHOURGLASS_CURSOR;
482extern wxCursor *wxCROSS_CURSOR;
483
484extern wxBitmap wxNullBitmap;
485extern wxIcon wxNullIcon;
486extern wxCursor wxNullCursor;
487extern wxPen wxNullPen;
488extern wxBrush wxNullBrush;
489extern wxPalette wxNullPalette;
490extern wxFont wxNullFont;
491extern wxColour wxNullColour;
492
af309447
RD
493%readwrite
494%{
495#endif
496%}
497
b639c3c5
RD
498//---------------------------------------------------------------------------
499
500class wxPalette {
501public:
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
af309447
RD
512enum {
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
522class wxImageList {
523public:
524 wxImageList(int width, int height, const bool mask=TRUE, int initialCount=1);
525 ~wxImageList();
526
b57bdb5a 527#ifdef __WXMSW__
af309447
RD
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);
b57bdb5a
RD
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
af309447
RD
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();
af309447
RD
544};
545
b639c3c5 546
7bf85405
RD
547//---------------------------------------------------------------------------
548
549/////////////////////////////////////////////////////////////////////////////
550//
551// $Log$
b57bdb5a
RD
552// Revision 1.14 1999/02/20 10:02:36 RD
553// Changes needed to enable wxGTK compatibility.
554//
af309447
RD
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//
08127323 567// Revision 1.12 1999/01/30 07:30:11 RD
af309447 568//
08127323
RD
569// Added wxSashWindow, wxSashEvent, wxLayoutAlgorithm, etc.
570//
571// Various cleanup, tweaks, minor additions, etc. to maintain
572// compatibility with the current wxWindows.
573//
aeeb6a44 574// Revision 1.11 1998/12/18 15:49:05 RR
08127323 575//
aeeb6a44
RR
576// wxClipboard now serves the primary selection as well
577// wxPython fixes
578// warning mesages
579//
be4d9c1f 580// Revision 1.10 1998/12/17 18:05:50 RD
aeeb6a44 581//
be4d9c1f
RD
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//
4f22cf8d 586// Revision 1.9 1998/12/17 14:07:37 RR
be4d9c1f 587//
4f22cf8d
RR
588// Removed minor differences between wxMSW and wxGTK
589//
105e45b9 590// Revision 1.8 1998/12/16 22:10:54 RD
4f22cf8d 591//
105e45b9
RD
592// Tweaks needed to be able to build wxPython with wxGTK.
593//
b8b8dda7
RD
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//
b639c3c5 613// Revision 1.6 1998/11/25 08:45:24 RD
b8b8dda7 614//
b639c3c5
RD
615// Added wxPalette, wxRegion, wxRegionIterator, wxTaskbarIcon
616// Added events for wxGrid
617// Other various fixes and additions
618//
d5c9047a
RD
619// Revision 1.5 1998/10/20 06:43:57 RD
620// New wxTreeCtrl wrappers (untested)
621// some changes in helpers
622// etc.
623//
9c039d08 624// Revision 1.4 1998/10/02 06:40:38 RD
d5c9047a 625//
9c039d08
RD
626// Version 0.4 of wxPython for MSW.
627//
fb5e0af0
RD
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//
03e9bead
RD
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//
7bf85405
RD
640// Revision 1.1 1998/08/09 08:25:50 RD
641// Initial version
642//
643//