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 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);
77 //---------------------------------------------------------------------------
81 wxMask(const wxBitmap& bitmap);
85 %new wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour);
87 wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour) {
88 return new wxMask(bitmap, colour);
93 //---------------------------------------------------------------------------
96 class wxIcon : public wxBitmap {
99 wxIcon(const wxString& name, long flags,
100 int desiredWidth = -1, int desiredHeight = -1);
107 bool LoadFile(const wxString& name, long flags);
109 void SetDepth(int depth);
110 void SetHeight(int height);
111 void SetWidth(int width);
114 //---------------------------------------------------------------------------
116 class wxCursor : public wxBitmap {
119 wxCursor(const wxString& cursorName, long flags, int hotSpotX=0, int hotSpotY=0);
125 %name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id);
126 %{ // Alternate 'constructor'
127 wxCursor* wxPyStockCursor(int id) {
128 return new wxCursor(id);
132 //----------------------------------------------------------------------
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.
139 wxFont( int pointSize, int family, int style, int weight,
140 int underline=FALSE, char* faceName = "") {
142 return wxTheFontList->FindOrCreateFont(pointSize, family, style, weight,
143 underline, faceName);
149 wxString GetFaceName();
156 bool GetUnderlined();
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);
166 //----------------------------------------------------------------------
170 wxColour(unsigned char red=0, unsigned char green=0, unsigned char blue=0);
173 unsigned char Green();
174 unsigned char Blue();
176 void Set(unsigned char red, unsigned char green, unsigned char blue);
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()));
188 %new wxColour* wxNamedColour(const wxString& colorName);
189 %{ // Alternate 'constructor'
190 wxColour* wxNamedColour(const wxString& colorName) {
191 return new wxColour(colorName);
196 //----------------------------------------------------------------------
198 typedef unsigned long wxDash;
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.
205 wxPen(wxColour* colour, int width=1, int style=wxSOLID) {
206 return wxThePenList->FindOrCreatePen(*colour, width, style);
212 wxColour& GetColour();
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);
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);
233 //----------------------------------------------------------------------
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.
240 wxBrush(wxColour* colour, int style=wxSOLID) {
241 return wxTheBrushList->FindOrCreateBrush(*colour, style);
246 wxColour& GetColour();
247 wxBitmap * GetStipple();
250 void SetColour(wxColour &colour);
251 void SetStipple(wxBitmap& bitmap);
252 void SetStyle(int style);
255 //----------------------------------------------------------------------
261 // wxDC(); **** abstract base class, can't instantiate.
265 bool Blit(long xdest, long ydest, long width, long height,
266 wxDC *source, long xsrc, long ysrc, long logical_func);
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);
290 void FloodFill(long x, long y, const wxColour& colour, int style=wxFLOOD_SURFACE);
291 wxBrush& GetBackground();
293 long GetCharHeight();
295 void GetClippingBox(long *OUTPUT, long *OUTPUT,
296 long *OUTPUT, long *OUTPUT);
298 int GetLogicalFunction();
300 bool GetOptimization();
303 %new wxColour* GetPixel(long x, long y) {
304 wxColour* wc = new wxColour();
305 self->GetPixel(x, y, wc);
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);
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);
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);
349 self->SetPalette(*bitmap.GetPalette());
350 self->Blit(x, y, bitmap.GetWidth(), bitmap.GetHeight(), memDC,
351 0, 0, self->GetLogicalFunction());
352 memDC->SelectObject(wxNullBitmap);
359 //----------------------------------------------------------------------
361 class wxMemoryDC : public wxDC {
365 void SelectObject(const wxBitmap& bitmap);
368 %new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC);
369 %{ // Alternate 'constructor'
370 wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) {
371 return new wxMemoryDC(oldDC);
376 //---------------------------------------------------------------------------
378 class wxScreenDC : public wxDC {
382 bool StartDrawingOnTop(wxWindow* window);
383 %name(StartDrawingOnTopRect) bool StartDrawingOnTop(wxRect* rect = NULL);
384 bool EndDrawingOnTop();
387 //---------------------------------------------------------------------------
389 class wxClientDC : public wxDC {
391 wxClientDC(wxWindow* win);
394 //---------------------------------------------------------------------------
396 class wxPaintDC : public wxDC {
398 wxPaintDC(wxWindow* win);
401 //---------------------------------------------------------------------------
403 class wxWindowDC : public wxDC {
405 wxWindowDC(wxWindow* win);
408 //---------------------------------------------------------------------------
411 class wxPostScriptDC : public wxDC {
413 wxPostScriptDC(const wxString& output, bool interactive = TRUE, wxWindow* win = NULL);
417 //---------------------------------------------------------------------------
420 class wxPrinterDC : public wxDC {
422 wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output,
423 bool interactive = TRUE, int orientation = wxPORTRAIT);
427 //---------------------------------------------------------------------------
430 class wxMetaFileDC : public wxDC {
432 wxMetaFileDC(const wxString& filename = wxPyEmptyStr);
437 //---------------------------------------------------------------------------
438 //---------------------------------------------------------------------------
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;
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;
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;
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;
480 extern wxCursor *wxSTANDARD_CURSOR;
481 extern wxCursor *wxHOURGLASS_CURSOR;
482 extern wxCursor *wxCROSS_CURSOR;
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;
498 //---------------------------------------------------------------------------
502 wxPalette(int LCOUNT, byte* LIST, byte* LIST, byte* LIST);
505 int GetPixel(byte red, byte green, byte blue);
506 bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT);
510 //---------------------------------------------------------------------------
513 wxIMAGELIST_DRAW_NORMAL ,
514 wxIMAGELIST_DRAW_TRANSPARENT,
515 wxIMAGELIST_DRAW_SELECTED,
516 wxIMAGELIST_DRAW_FOCUSED,
524 wxImageList(int width, int height, const bool mask=TRUE, int initialCount=1);
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);
534 int Add(const wxBitmap& bitmap);
535 bool Replace(int index, const wxBitmap& bitmap);
538 bool Draw(int index, wxDC& dc, int x, int x, int flags = wxIMAGELIST_DRAW_NORMAL,
539 const bool solidBackground = FALSE);
542 bool Remove(int index);
547 //---------------------------------------------------------------------------
549 /////////////////////////////////////////////////////////////////////////////
552 // Revision 1.14 1999/02/20 10:02:36 RD
553 // Changes needed to enable wxGTK compatibility.
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.
560 // Added wxImageList, wxToolTip.
562 // Re-enabled wxConfig.DeleteAll() since it is reportedly fixed for the
563 // wxRegConfig class.
565 // As usual, some bug fixes, tweaks, etc.
567 // Revision 1.12 1999/01/30 07:30:11 RD
569 // Added wxSashWindow, wxSashEvent, wxLayoutAlgorithm, etc.
571 // Various cleanup, tweaks, minor additions, etc. to maintain
572 // compatibility with the current wxWindows.
574 // Revision 1.11 1998/12/18 15:49:05 RR
576 // wxClipboard now serves the primary selection as well
580 // Revision 1.10 1998/12/17 18:05:50 RD
583 // Minor fixes and SWIG code generation for RR's changes. MSW and GTK
584 // versions are much closer now!
586 // Revision 1.9 1998/12/17 14:07:37 RR
588 // Removed minor differences between wxMSW and wxGTK
590 // Revision 1.8 1998/12/16 22:10:54 RD
592 // Tweaks needed to be able to build wxPython with wxGTK.
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."
600 // Added wxTaskbarIcon for wxMSW.
602 // Made the events work for wxGrid.
606 // Added wxMiniFrame for wxGTK, (untested.)
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.
611 // Other assorted fixes and additions.
613 // Revision 1.6 1998/11/25 08:45:24 RD
615 // Added wxPalette, wxRegion, wxRegionIterator, wxTaskbarIcon
616 // Added events for wxGrid
617 // Other various fixes and additions
619 // Revision 1.5 1998/10/20 06:43:57 RD
620 // New wxTreeCtrl wrappers (untested)
621 // some changes in helpers
624 // Revision 1.4 1998/10/02 06:40:38 RD
626 // Version 0.4 of wxPython for MSW.
628 // Revision 1.3 1998/08/18 19:48:16 RD
629 // more wxGTK compatibility things.
631 // It builds now but there are serious runtime problems...
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.
638 // - A few minor fixes.
640 // Revision 1.1 1998/08/09 08:25:50 RD