1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface file for wxDC, wxBrush, wxPen, wxFont, etc.
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
18 #include <wx/metafile.h>
19 #include <wx/imaglist.h>
25 //----------------------------------------------------------------------
28 %include my_typemaps.i
30 // Import some definitions of other classes, etc.
34 //---------------------------------------------------------------------------
38 wxBitmap(const wxString& name, long type);
42 void Create(int width, int height, int depth = -1);
46 wxPalette* GetPalette();
49 bool LoadFile(const wxString& name, long flags);
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);
56 void SetPalette(wxPalette& palette);
58 void SetWidth(int width);
61 %new wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1);
62 wxBitmap* wxNoRefBitmap(char* name, long flags);
64 %{ // Alternate 'constructor'
65 wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1) {
66 return new wxBitmap(width, height, depth);
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
73 wxBitmap* wxNoRefBitmap(char* name, long flags) {
74 return new wxBitmap(name, flags);
78 //---------------------------------------------------------------------------
82 wxMask(const wxBitmap& bitmap);
86 %new wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour);
88 wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour) {
89 return new wxMask(bitmap, colour);
94 //---------------------------------------------------------------------------
97 class wxIcon : public wxBitmap {
100 wxIcon(const wxString& name, long flags,
101 int desiredWidth = -1, int desiredHeight = -1);
108 bool LoadFile(const wxString& name, long flags);
110 void SetDepth(int depth);
111 void SetHeight(int height);
112 void SetWidth(int width);
115 //---------------------------------------------------------------------------
117 class wxCursor : public wxBitmap {
120 wxCursor(const wxString& cursorName, long flags, int hotSpotX=0, int hotSpotY=0);
126 %name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id);
127 %{ // Alternate 'constructor'
128 wxCursor* wxPyStockCursor(int id) {
129 return new wxCursor(id);
133 //----------------------------------------------------------------------
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.
140 wxFont( int pointSize, int family, int style, int weight,
141 int underline=FALSE, char* faceName = "") {
143 return wxTheFontList->FindOrCreateFont(pointSize, family, style, weight,
144 underline, faceName);
150 wxString GetFaceName();
157 bool GetUnderlined();
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);
167 //----------------------------------------------------------------------
171 wxColour(unsigned char red=0, unsigned char green=0, unsigned char blue=0);
174 unsigned char Green();
175 unsigned char Blue();
177 void Set(unsigned char red, unsigned char green, unsigned char blue);
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()));
189 %new wxColour* wxNamedColour(const wxString& colorName);
190 %{ // Alternate 'constructor'
191 wxColour* wxNamedColour(const wxString& colorName) {
192 return new wxColour(colorName);
197 //----------------------------------------------------------------------
199 typedef unsigned long wxDash;
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.
206 wxPen(wxColour* colour, int width=1, int style=wxSOLID) {
207 return wxThePenList->FindOrCreatePen(*colour, width, style);
213 wxColour& GetColour();
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);
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);
234 //----------------------------------------------------------------------
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.
241 wxBrush(wxColour* colour, int style=wxSOLID) {
242 return wxTheBrushList->FindOrCreateBrush(*colour, style);
247 wxColour& GetColour();
248 wxBitmap * GetStipple();
251 void SetColour(wxColour &colour);
252 void SetStipple(wxBitmap& bitmap);
253 void SetStyle(int style);
256 //----------------------------------------------------------------------
262 // wxDC(); **** abstract base class, can't instantiate.
266 bool Blit(long xdest, long ydest, long width, long height,
267 wxDC *source, long xsrc, long ysrc, long logical_func);
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);
291 void FloodFill(long x, long y, const wxColour& colour, int style=wxFLOOD_SURFACE);
292 wxBrush& GetBackground();
294 long GetCharHeight();
296 void GetClippingBox(long *OUTPUT, long *OUTPUT,
297 long *OUTPUT, long *OUTPUT);
299 int GetLogicalFunction();
301 bool GetOptimization();
304 %new wxColour* GetPixel(long x, long y) {
305 wxColour* wc = new wxColour();
306 self->GetPixel(x, y, wc);
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);
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);
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);
350 self->SetPalette(*bitmap.GetPalette());
351 self->Blit(x, y, bitmap.GetWidth(), bitmap.GetHeight(), memDC,
352 0, 0, self->GetLogicalFunction());
353 memDC->SelectObject(wxNullBitmap);
360 //----------------------------------------------------------------------
362 class wxMemoryDC : public wxDC {
366 void SelectObject(const wxBitmap& bitmap);
369 %new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC);
370 %{ // Alternate 'constructor'
371 wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) {
372 return new wxMemoryDC(oldDC);
377 //---------------------------------------------------------------------------
379 class wxScreenDC : public wxDC {
383 bool StartDrawingOnTop(wxWindow* window);
384 %name(StartDrawingOnTopRect) bool StartDrawingOnTop(wxRect* rect = NULL);
385 bool EndDrawingOnTop();
388 //---------------------------------------------------------------------------
390 class wxClientDC : public wxDC {
392 wxClientDC(wxWindow* win);
395 //---------------------------------------------------------------------------
397 class wxPaintDC : public wxDC {
399 wxPaintDC(wxWindow* win);
402 //---------------------------------------------------------------------------
404 class wxWindowDC : public wxDC {
406 wxWindowDC(wxWindow* win);
409 //---------------------------------------------------------------------------
412 class wxPostScriptDC : public wxDC {
414 wxPostScriptDC(const wxString& output, bool interactive = TRUE, wxWindow* win = NULL);
418 //---------------------------------------------------------------------------
421 class wxPrinterDC : public wxDC {
423 wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output,
424 bool interactive = TRUE, int orientation = wxPORTRAIT);
428 //---------------------------------------------------------------------------
431 class wxMetaFileDC : public wxDC {
433 wxMetaFileDC(const wxString& filename = wxPyEmptyStr);
438 //---------------------------------------------------------------------------
439 //---------------------------------------------------------------------------
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;
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;
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;
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;
481 extern wxCursor *wxSTANDARD_CURSOR;
482 extern wxCursor *wxHOURGLASS_CURSOR;
483 extern wxCursor *wxCROSS_CURSOR;
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;
499 //---------------------------------------------------------------------------
503 wxPalette(int LCOUNT, byte* LIST, byte* LIST, byte* LIST);
506 int GetPixel(byte red, byte green, byte blue);
507 bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT);
511 //---------------------------------------------------------------------------
514 wxIMAGELIST_DRAW_NORMAL ,
515 wxIMAGELIST_DRAW_TRANSPARENT,
516 wxIMAGELIST_DRAW_SELECTED,
517 wxIMAGELIST_DRAW_FOCUSED,
525 wxImageList(int width, int height, const bool mask=TRUE, int initialCount=1);
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);
535 int Add(const wxBitmap& bitmap);
536 bool Replace(int index, const wxBitmap& bitmap);
539 bool Draw(int index, wxDC& dc, int x, int x, int flags = wxIMAGELIST_DRAW_NORMAL,
540 const bool solidBackground = FALSE);
543 bool Remove(int index);
548 //---------------------------------------------------------------------------