]> git.saurik.com Git - wxWidgets.git/blame - utils/wxPython/src/gdi.i
1. wxStaticLine implemented (generic (ugly) and MSW versions)
[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
cf694132
RD
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.
7bf85405
RD
73 wxBitmap* wxNoRefBitmap(char* name, long flags) {
74 return new wxBitmap(name, flags);
75 }
76%}
77
78//---------------------------------------------------------------------------
79
80class wxMask {
81public:
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
97class wxIcon : public wxBitmap {
98public:
fb5e0af0
RD
99#ifdef __WXMSW__
100 wxIcon(const wxString& name, long flags,
101 int desiredWidth = -1, int desiredHeight = -1);
102#endif
7bf85405
RD
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);
7bf85405
RD
112 void SetWidth(int width);
113};
114
115//---------------------------------------------------------------------------
116
117class wxCursor : public wxBitmap {
118public:
fb5e0af0 119#ifdef __WXMSW__
7bf85405 120 wxCursor(const wxString& cursorName, long flags, int hotSpotX=0, int hotSpotY=0);
fb5e0af0 121#endif
7bf85405
RD
122 ~wxCursor();
123 bool Ok();
124};
125
9c039d08 126%name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id);
7bf85405 127%{ // Alternate 'constructor'
9c039d08 128 wxCursor* wxPyStockCursor(int id) {
7bf85405
RD
129 return new wxCursor(id);
130 }
131%}
132
133//----------------------------------------------------------------------
134
135class wxFont {
136public:
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();
08127323 152#ifdef __WXMSW__
7bf85405 153 int GetFontId();
08127323 154#endif
7bf85405
RD
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
169class wxColour {
170public:
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
199typedef unsigned long wxDash;
200
201class wxPen {
202public:
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
fb5e0af0 215 int GetJoin();
7bf85405
RD
216 int GetStyle();
217 int GetWidth();
218 bool Ok();
219 void SetCap(int cap_style);
220 void SetColour(wxColour& colour);
aeeb6a44
RR
221 void SetJoin(int join_style);
222 void SetStyle(int style);
223 void SetWidth(int width);
08127323 224
fb5e0af0 225#ifdef __WXMSW__
aeeb6a44
RR
226 // **** This one needs to return a list of ints (wxDash)
227 int GetDashes(wxDash **dashes);
228 wxBitmap* GetStipple();
7bf85405 229 void SetDashes(int LCOUNT, wxDash* LIST);
b8b8dda7 230 void SetStipple(wxBitmap& stipple);
fb5e0af0 231#endif
7bf85405
RD
232};
233
234//----------------------------------------------------------------------
235
236class wxBrush {
237public:
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);
b8b8dda7 252 void SetStipple(wxBitmap& bitmap);
7bf85405
RD
253 void SetStyle(int style);
254};
255
256//----------------------------------------------------------------------
257
258
259
260class wxDC {
261public:
fb5e0af0 262// wxDC(); **** abstract base class, can't instantiate.
7bf85405
RD
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);
bb0054cd 276 void DrawCircle(long x, long y, long radius);
7bf85405
RD
277 void DrawEllipse(long x, long y, long width, long height);
278 void DrawEllipticArc(long x, long y, long width, long height, long start, long end);
279 void DrawIcon(const wxIcon& icon, long x, long y);
280 void DrawLine(long x1, long y1, long x2, long y2);
281 void DrawLines(int LCOUNT, wxPoint* LIST, long xoffset=0, long yoffset=0);
282 void DrawPolygon(int LCOUNT, wxPoint* LIST, long xoffset=0, long yoffset=0,
283 int fill_style=wxODDEVEN_RULE);
284 void DrawPoint(long x, long y);
285 void DrawRectangle(long x, long y, long width, long height);
286 void DrawRoundedRectangle(long x, long y, long width, long height, long radius=20);
287 void DrawSpline(int LCOUNT, wxPoint* LIST);
288 void DrawText(const wxString& text, long x, long y);
289 void EndDoc();
290 void EndDrawing();
291 void EndPage();
292 void FloodFill(long x, long y, const wxColour& colour, int style=wxFLOOD_SURFACE);
b8b8dda7
RD
293 wxBrush& GetBackground();
294 wxBrush& GetBrush();
7bf85405
RD
295 long GetCharHeight();
296 long GetCharWidth();
297 void GetClippingBox(long *OUTPUT, long *OUTPUT,
298 long *OUTPUT, long *OUTPUT);
b8b8dda7 299 wxFont& GetFont();
7bf85405
RD
300 int GetLogicalFunction();
301 int GetMapMode();
302 bool GetOptimization();
b8b8dda7 303 wxPen& GetPen();
fb5e0af0
RD
304 %addmethods {
305 %new wxColour* GetPixel(long x, long y) {
306 wxColour* wc = new wxColour();
307 self->GetPixel(x, y, wc);
308 return wc;
309 }
310 }
bb0054cd
RD
311 %name(GetSizeTuple)void GetSize(int* OUTPUT, int* OUTPUT);
312 wxSize GetSize();
7bf85405 313 wxColour& GetTextBackground();
af309447
RD
314 void GetTextExtent(const wxString& string, long *OUTPUT, long *OUTPUT);
315 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
316 long *OUTPUT, long *OUTPUT, long *OUTPUT, long* OUTPUT,
317 const wxFont* font = NULL);
7bf85405
RD
318 wxColour& GetTextForeground();
319 long LogicalToDeviceX(long x);
320 long LogicalToDeviceXRel(long x);
321 long LogicalToDeviceY(long y);
322 long LogicalToDeviceYRel(long y);
323 long MaxX();
324 long MaxY();
325 long MinX();
326 long MinY();
327 bool Ok();
328 void SetDeviceOrigin(long x, long y);
329 void SetBackground(const wxBrush& brush);
330 void SetBackgroundMode(int mode);
331 void SetClippingRegion(long x, long y, long width, long height);
332 void SetPalette(const wxPalette& colourMap);
333 void SetBrush(const wxBrush& brush);
334 void SetFont(const wxFont& font);
335 void SetLogicalFunction(int function);
336 void SetMapMode(int mode);
337 void SetOptimization(bool optimize);
338 void SetPen(const wxPen& pen);
339 void SetTextBackground(const wxColour& colour);
340 void SetTextForeground(const wxColour& colour);
341 void SetUserScale(double x_scale, double y_scale);
342 bool StartDoc(const wxString& message);
343 void StartPage();
344
345
346 %addmethods {
7bf85405 347 // This one is my own creation...
b8b8dda7 348 void DrawBitmap(wxBitmap& bitmap, long x, long y, bool swapPalette=TRUE) {
7bf85405
RD
349 wxMemoryDC* memDC = new wxMemoryDC;
350 memDC->SelectObject(bitmap);
351 if (swapPalette)
b8b8dda7
RD
352 self->SetPalette(*bitmap.GetPalette());
353 self->Blit(x, y, bitmap.GetWidth(), bitmap.GetHeight(), memDC,
7bf85405
RD
354 0, 0, self->GetLogicalFunction());
355 memDC->SelectObject(wxNullBitmap);
356 delete memDC;
357 }
358 }
359};
360
361
362//----------------------------------------------------------------------
363
364class wxMemoryDC : public wxDC {
365public:
366 wxMemoryDC();
367
368 void SelectObject(const wxBitmap& bitmap);
369}
370
371%new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC);
372%{ // Alternate 'constructor'
373 wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) {
374 return new wxMemoryDC(oldDC);
375 }
376%}
377
378
379//---------------------------------------------------------------------------
380
381class wxScreenDC : public wxDC {
382public:
383 wxScreenDC();
384
385 bool StartDrawingOnTop(wxWindow* window);
386 %name(StartDrawingOnTopRect) bool StartDrawingOnTop(wxRect* rect = NULL);
387 bool EndDrawingOnTop();
388};
389
390//---------------------------------------------------------------------------
391
392class wxClientDC : public wxDC {
393public:
394 wxClientDC(wxWindow* win);
395};
396
397//---------------------------------------------------------------------------
398
399class wxPaintDC : public wxDC {
400public:
401 wxPaintDC(wxWindow* win);
402};
403
404//---------------------------------------------------------------------------
405
b639c3c5
RD
406class wxWindowDC : public wxDC {
407public:
408 wxWindowDC(wxWindow* win);
409};
b639c3c5
RD
410
411//---------------------------------------------------------------------------
412
be4d9c1f 413#ifndef __WXMSW__
7bf85405
RD
414class wxPostScriptDC : public wxDC {
415public:
416 wxPostScriptDC(const wxString& output, bool interactive = TRUE, wxWindow* win = NULL);
417};
be4d9c1f 418#endif
7bf85405
RD
419
420//---------------------------------------------------------------------------
421
fb5e0af0 422#ifdef __WXMSW__
7bf85405
RD
423class wxPrinterDC : public wxDC {
424public:
425 wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output,
426 bool interactive = TRUE, int orientation = wxPORTRAIT);
427};
fb5e0af0 428#endif
7bf85405
RD
429
430//---------------------------------------------------------------------------
431
fb5e0af0 432#ifdef __WXMSW__
7bf85405
RD
433class wxMetaFileDC : public wxDC {
434public:
435 wxMetaFileDC(const wxString& filename = wxPyEmptyStr);
436 wxMetaFile* Close();
437};
fb5e0af0 438#endif
7bf85405
RD
439
440//---------------------------------------------------------------------------
441//---------------------------------------------------------------------------
442
443
444%readonly
af309447
RD
445%{
446#if 0
447%}
7bf85405
RD
448extern wxFont *wxNORMAL_FONT;
449extern wxFont *wxSMALL_FONT;
450extern wxFont *wxITALIC_FONT;
451extern wxFont *wxSWISS_FONT;
452extern wxPen *wxRED_PEN;
453
454extern wxPen *wxCYAN_PEN;
455extern wxPen *wxGREEN_PEN;
456extern wxPen *wxBLACK_PEN;
457extern wxPen *wxWHITE_PEN;
458extern wxPen *wxTRANSPARENT_PEN;
459extern wxPen *wxBLACK_DASHED_PEN;
460extern wxPen *wxGREY_PEN;
461extern wxPen *wxMEDIUM_GREY_PEN;
462extern wxPen *wxLIGHT_GREY_PEN;
463
464extern wxBrush *wxBLUE_BRUSH;
465extern wxBrush *wxGREEN_BRUSH;
466extern wxBrush *wxWHITE_BRUSH;
467extern wxBrush *wxBLACK_BRUSH;
468extern wxBrush *wxTRANSPARENT_BRUSH;
469extern wxBrush *wxCYAN_BRUSH;
470extern wxBrush *wxRED_BRUSH;
471extern wxBrush *wxGREY_BRUSH;
472extern wxBrush *wxMEDIUM_GREY_BRUSH;
473extern wxBrush *wxLIGHT_GREY_BRUSH;
474
475extern wxColour *wxBLACK;
476extern wxColour *wxWHITE;
477extern wxColour *wxRED;
478extern wxColour *wxBLUE;
479extern wxColour *wxGREEN;
480extern wxColour *wxCYAN;
481extern wxColour *wxLIGHT_GREY;
482
483extern wxCursor *wxSTANDARD_CURSOR;
484extern wxCursor *wxHOURGLASS_CURSOR;
485extern wxCursor *wxCROSS_CURSOR;
486
487extern wxBitmap wxNullBitmap;
488extern wxIcon wxNullIcon;
489extern wxCursor wxNullCursor;
490extern wxPen wxNullPen;
491extern wxBrush wxNullBrush;
492extern wxPalette wxNullPalette;
493extern wxFont wxNullFont;
494extern wxColour wxNullColour;
495
af309447
RD
496%readwrite
497%{
498#endif
499%}
500
b639c3c5
RD
501//---------------------------------------------------------------------------
502
503class wxPalette {
504public:
505 wxPalette(int LCOUNT, byte* LIST, byte* LIST, byte* LIST);
506 ~wxPalette();
507
508 int GetPixel(byte red, byte green, byte blue);
509 bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT);
510 bool Ok();
511};
512
513//---------------------------------------------------------------------------
514
af309447
RD
515enum {
516 wxIMAGELIST_DRAW_NORMAL ,
517 wxIMAGELIST_DRAW_TRANSPARENT,
518 wxIMAGELIST_DRAW_SELECTED,
519 wxIMAGELIST_DRAW_FOCUSED,
520 wxIMAGE_LIST_NORMAL,
521 wxIMAGE_LIST_SMALL,
522 wxIMAGE_LIST_STATE
523};
524
525class wxImageList {
526public:
527 wxImageList(int width, int height, const bool mask=TRUE, int initialCount=1);
528 ~wxImageList();
529
b57bdb5a 530#ifdef __WXMSW__
af309447
RD
531 int Add(const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
532 %name(AddWithColourMask)int Add(const wxBitmap& bitmap, const wxColour& maskColour);
533 %name(AddIcon)int Add(const wxIcon& icon);
b57bdb5a
RD
534 bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
535 %name(ReplaceIcon)bool Replace(int index, const wxIcon& icon);
536#else
537 int Add(const wxBitmap& bitmap);
538 bool Replace(int index, const wxBitmap& bitmap);
539#endif
af309447
RD
540
541 bool Draw(int index, wxDC& dc, int x, int x, int flags = wxIMAGELIST_DRAW_NORMAL,
542 const bool solidBackground = FALSE);
543
544 int GetImageCount();
545 bool Remove(int index);
546 bool RemoveAll();
af309447
RD
547};
548
b639c3c5 549
7bf85405
RD
550//---------------------------------------------------------------------------
551