%{
#include "helpers.h"
-#include <wx/metafile.h>
#include <wx/imaglist.h>
-#ifndef __WXMSW__
-#include <wx/dcps.h>
-#endif
#include <wx/fontmap.h>
#include <wx/fontenc.h>
#include <wx/fontmap.h>
%import _defs.i
%import misc.i
-%{
- static wxString wxPyEmptyStr("");
-%}
//---------------------------------------------------------------------------
class wxBitmap : public wxGDIObject
{
public:
- wxBitmap(const wxString& name, wxBitmapType type);
+ wxBitmap(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_ANY);
~wxBitmap();
wxPalette* GetPalette();
wxMask* GetMask();
- bool LoadFile(const wxString& name, long flags);
- bool SaveFile(const wxString& name, int type, wxPalette* palette = NULL);
+ bool LoadFile(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_ANY);
+ bool SaveFile(const wxString& name, wxBitmapType type, wxPalette* palette = NULL);
void SetMask(wxMask* mask);
#ifdef __WXMSW__
void SetPalette(wxPalette& palette);
#endif
wxBitmap GetSubBitmap( const wxRect& rect );
-#ifdef __WXMSW__
bool CopyFromIcon(const wxIcon& icon);
+#ifdef __WXMSW__
bool CopyFromCursor(const wxCursor& cursor);
int GetQuality();
void SetQuality(int q);
int desiredWidth = -1, int desiredHeight = -1);
~wxIcon();
+#ifndef __WXMAC__
bool LoadFile(const wxString& name, long flags);
+#endif
// wxGDIImage methods
#ifdef __WXMSW__
wxFONTFAMILY_SWISS = wxSWISS,
wxFONTFAMILY_MODERN = wxMODERN,
wxFONTFAMILY_TELETYPE = wxTELETYPE,
- wxFONTFAMILY_MAX
+ wxFONTFAMILY_MAX,
+ wxFONTFAMILY_UNKNOWN
};
// font styles
wxFONTENCODING_CP866, // and another one
// and for Windows
wxFONTENCODING_CP874, // WinThai
+ wxFONTENCODING_CP932, // Japanese (shift-JIS)
+ wxFONTENCODING_CP936, // Chiniese simplified (GB)
+ wxFONTENCODING_CP949, // Korean (Hangul charset)
+ wxFONTENCODING_CP950, // Chinese (traditional - Big5)
wxFONTENCODING_CP1250, // WinLatin2
wxFONTENCODING_CP1251, // WinCyrillic
wxFONTENCODING_CP1252, // WinLatin1
// ToString() and restore them using FromString())
struct wxNativeFontInfo
{
+#ifdef __WXGTK__
+ // init the elements from an XLFD, return TRUE if ok
+ bool FromXFontName(const wxString& xFontName);
+
+ // return false if we were never initialized with a valid XLFD
+ bool IsDefault() const;
+
+ // generate an XLFD using the fontElements
+ wxString GetXFontName() const;
+
+ // set the XFLD
+ void SetXFontName(const wxString& xFontName);
+#endif
+
+ wxNativeFontInfo() { Init(); }
+
+ // reset to the default state
+ void Init();
+
+#ifndef __WXGTK__
+ // accessors and modifiers for the font elements
+ int GetPointSize() const;
+ wxFontStyle GetStyle() const;
+ wxFontWeight GetWeight() const;
+ bool GetUnderlined() const;
+ wxString GetFaceName() const;
+ wxFontFamily GetFamily() const;
+ wxFontEncoding GetEncoding() const;
+
+ void SetPointSize(int pointsize);
+ void SetStyle(wxFontStyle style);
+ void SetWeight(wxFontWeight weight);
+ void SetUnderlined(bool underlined);
+ void SetFaceName(wxString facename);
+ void SetFamily(wxFontFamily family);
+ void SetEncoding(wxFontEncoding encoding);
+#endif
+
// it is important to be able to serialize wxNativeFontInfo objects to be
// able to store them (in config file, for example)
bool FromString(const wxString& s);
return self->ToString();
}
}
+
+ // we also want to present the native font descriptions to the user in some
+ // human-readable form (it is not platform independent neither, but can
+ // hopefully be understood by the user)
+ bool FromUserString(const wxString& s);
+ wxString ToUserString() const;
};
bool GetUnderlined() const;
wxString GetFaceName() const;
wxFontEncoding GetEncoding() const;
+
+ bool IsFixedWidth();
+
wxNativeFontInfo* GetNativeFontInfo() const;
+ wxString GetNativeFontInfoDesc() const;
+ wxString GetNativeFontInfoUserDesc() const;
void SetPointSize(int pointSize);
void SetFamily(int family);
void SetUnderlined(bool underlined);
void SetEncoding(wxFontEncoding encoding);
void SetNativeFontInfo(const wxNativeFontInfo& info);
+ // void SetNativeFontInfo(const wxString& info);
+ void SetNativeFontInfoUserDesc(const wxString& info);
wxString GetFamilyString() const;
wxString GetStyleString() const;
bool underline = FALSE, const char* facename = NULL,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
void RemoveFont(wxFont *font);
+
+ int GetCount();
};
%addmethods {
void Append(const wxString& name, int red, int green, int blue) {
+ // first see if the name is already there
+ wxString cName = name;
+ cName.MakeUpper();
+ wxString cName2 = cName;
+ if ( !cName2.Replace("GRAY", "GREY") )
+ cName2.clear();
+
+ wxNode *node = self->First();
+ while ( node ) {
+ const wxChar *key = node->GetKeyString();
+ if ( cName == key || cName2 == key ) {
+ wxColour* c = (wxColour *)node->Data();
+ c->Set(red, green, blue);
+ return;
+ }
+ node = node->Next();
+ }
+
+ // otherwise append the new colour
self->Append(name.c_str(), new wxColour(red, green, blue));
}
}
//----------------------------------------------------------------------
-
class wxPen : public wxGDIObject {
public:
wxPen(wxColour& colour, int width=1, int style=wxSOLID);
void SetWidth(int width);
// **** This one needs to return a list of ints (wxDash)
- int GetDashes(wxDash **dashes);
+ //int GetDashes(wxDash **dashes);
void SetDashes(int LCOUNT, wxDash* choices);
#ifdef __WXMSW__
};
+
+
+// The list of ints for the dashes needs to exist for the life of the pen
+// so we make it part of the class to save it. wxPyPen is aliased to wxPen
+// in _extras.py
+
+%{
+class wxPyPen : public wxPen {
+public:
+ wxPyPen(wxColour& colour, int width=1, int style=wxSOLID)
+ : wxPen(colour, width, style)
+ { m_dash = NULL; }
+ ~wxPyPen() {
+ if (m_dash)
+ delete [] m_dash;
+ }
+
+ void SetDashes(int nb_dashes, const wxDash *dash) {
+ if (m_dash)
+ delete [] m_dash;
+ m_dash = new wxDash[nb_dashes];
+ for (int i=0; i<nb_dashes; i++) {
+ m_dash[i] = dash[i];
+ }
+ wxPen::SetDashes(nb_dashes, m_dash);
+ }
+
+private:
+ wxDash* m_dash;
+};
+%}
+
+
+class wxPyPen : public wxPen {
+public:
+ wxPyPen(wxColour& colour, int width=1, int style=wxSOLID);
+ ~wxPyPen();
+
+ void SetDashes(int LCOUNT, wxDash* choices);
+};
+
+
+
+
class wxPenList : public wxObject {
public:
void AddPen(wxPen* pen);
wxPen* FindOrCreatePen(const wxColour& colour, int width, int style);
void RemovePen(wxPen* pen);
+
+ int GetCount();
};
void AddBrush(wxBrush *brush);
wxBrush * FindOrCreateBrush(const wxColour& colour, int style);
void RemoveBrush(wxBrush *brush);
+
+ int GetCount();
};
//----------------------------------------------------------------------
void DrawEllipse(long x, long y, long width, long height);
void DrawEllipticArc(long x, long y, long width, long height, long start, long end);
void DrawIcon(const wxIcon& icon, long x, long y);
+
+ void DrawLabel(const wxString& text, const wxRect& rect,
+ int alignment = wxALIGN_LEFT | wxALIGN_TOP,
+ int indexAccel = -1);
+
+ %addmethods {
+ wxRect DrawImageLabel(const wxString& text,
+ const wxBitmap& image,
+ const wxRect& rect,
+ int alignment = wxALIGN_LEFT | wxALIGN_TOP,
+ int indexAccel = -1) {
+ wxRect rv;
+ self->DrawLabel(text, image, rect, alignment, indexAccel, &rv);
+ return rv;
+ }
+ }
+
void DrawLine(long x1, long y1, long x2, long y2);
void DrawLines(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0);
void DrawPolygon(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0,
void EndDrawing();
void EndPage();
void FloodFill(long x, long y, const wxColour& colour, int style=wxFLOOD_SURFACE);
- wxBrush& GetBackground();
- wxBrush& GetBrush();
+ wxBrush GetBackground();
+ wxBrush GetBrush();
long GetCharHeight();
long GetCharWidth();
void GetClippingBox(long *OUTPUT, long *OUTPUT,
long *OUTPUT, long *OUTPUT);
- wxFont& GetFont();
+ wxFont GetFont();
int GetLogicalFunction();
void GetLogicalScale(double *OUTPUT, double *OUTPUT);
int GetMapMode();
bool GetOptimization();
- wxPen& GetPen();
+ wxPen GetPen();
%addmethods {
%new wxColour* GetPixel(long x, long y) {
wxColour* wc = new wxColour();
void CalcBoundingBox(int x, int y);
void ResetBoundingBox();
+ %addmethods {
+ void GetBoundingBox(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
+ // See below for implementation
+ }
+
#ifdef __WXMSW__
long GetHDC();
#endif
+
+
+ %addmethods {
+ // NOTE: These methods are VERY SIMILAR in implentation. It would be
+ // nice to factor out common code and or turn them into a set of
+ // template-like macros.
+
+ // Draw a point for every set of coordinants in pyPoints, optionally
+ // setting a new pen for each
+ PyObject* _DrawPointList(PyObject* pyPoints, PyObject* pyPens) {
+ bool isFastSeq = PyList_Check(pyPoints) || PyTuple_Check(pyPoints);
+ bool isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens);
+ int numObjs = 0;
+ int numPens = 0;
+ wxPen* pen;
+ PyObject* obj;
+ int x1, y1;
+ int i = 0;
+
+ if (!PySequence_Check(pyPoints)) {
+ goto err0;
+ }
+ if (!PySequence_Check(pyPens)) {
+ goto err1;
+ }
+ numObjs = PySequence_Length(pyPoints);
+ numPens = PySequence_Length(pyPens);
+
+ for (i = 0; i < numObjs; i++) {
+ // Use a new pen?
+ if (i < numPens) {
+ if (isFastPens) {
+ obj = PySequence_Fast_GET_ITEM(pyPens, i);
+ }
+ else {
+ obj = PySequence_GetItem(pyPens, i);
+ }
+ if (SWIG_GetPtrObj(obj, (void **) &pen, "_wxPen_p")) {
+ if (!isFastPens)
+ Py_DECREF(obj);
+ goto err1;
+ }
+
+ self->SetPen(*pen);
+ if (!isFastPens)
+ Py_DECREF(obj);
+ }
+
+ // Get the point coordinants
+ if (isFastSeq) {
+ obj = PySequence_Fast_GET_ITEM(pyPoints, i);
+ }
+ else {
+ obj = PySequence_GetItem(pyPoints, i);
+ }
+ if (! _2int_seq_helper(obj, &x1, &y1)) {
+ if (!isFastPens)
+ Py_DECREF(obj);
+ goto err0;
+ }
+
+ // Now draw the point
+ self->DrawPoint(x1, y1);
+
+ if (!isFastSeq)
+ Py_DECREF(obj);
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+
+ err1:
+ PyErr_SetString(PyExc_TypeError, "Expected a sequence of wxPens");
+ return NULL;
+ err0:
+ PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x,y) sequences.");
+ return NULL;
+ }
+
+
+ // Draw a line for every set of coordinants in pyLines, optionally
+ // setting a new pen for each
+ PyObject* _DrawLineList(PyObject* pyLines, PyObject* pyPens) {
+ bool isFastSeq = PyList_Check(pyLines) || PyTuple_Check(pyLines);
+ bool isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens);
+ int numObjs = 0;
+ int numPens = 0;
+ wxPen* pen;
+ PyObject* obj;
+ int x1, y1, x2, y2;
+ int i = 0;
+
+ if (!PySequence_Check(pyLines)) {
+ goto err0;
+ }
+ if (!PySequence_Check(pyPens)) {
+ goto err1;
+ }
+ numObjs = PySequence_Length(pyLines);
+ numPens = PySequence_Length(pyPens);
+
+ for (i = 0; i < numObjs; i++) {
+ // Use a new pen?
+ if (i < numPens) {
+ if (isFastPens) {
+ obj = PySequence_Fast_GET_ITEM(pyPens, i);
+ }
+ else {
+ obj = PySequence_GetItem(pyPens, i);
+ }
+ if (SWIG_GetPtrObj(obj, (void **) &pen, "_wxPen_p")) {
+ if (!isFastPens)
+ Py_DECREF(obj);
+ goto err1;
+ }
+
+ self->SetPen(*pen);
+ if (!isFastPens)
+ Py_DECREF(obj);
+ }
+
+ // Get the line coordinants
+ if (isFastSeq) {
+ obj = PySequence_Fast_GET_ITEM(pyLines, i);
+ }
+ else {
+ obj = PySequence_GetItem(pyLines, i);
+ }
+ if (! _4int_seq_helper(obj, &x1, &y1, &x2, &y2)) {
+ if (!isFastPens)
+ Py_DECREF(obj);
+ goto err0;
+ }
+
+ // Now draw the line
+ self->DrawLine(x1, y1, x2, y2);
+
+ if (!isFastSeq)
+ Py_DECREF(obj);
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+
+ err1:
+ PyErr_SetString(PyExc_TypeError, "Expected a sequence of wxPens");
+ return NULL;
+ err0:
+ PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x1,y1, x2,y2) sequences.");
+ return NULL;
+ }
+ }
+
+
+ %pragma(python) addtoclass = "
+ def DrawPointList(self, points, pens=None):
+ if pens is None:
+ pens = []
+ elif isinstance(pens, wxPenPtr):
+ pens = [pens]
+ elif len(pens) != len(points):
+ raise ValueError('points and pens must have same length')
+ return self._DrawPointList(points, pens)
+
+ def DrawLineList(self, lines, pens=None):
+ if pens is None:
+ pens = []
+ elif isinstance(pens, wxPenPtr):
+ pens = [pens]
+ elif len(pens) != len(lines):
+ raise ValueError('lines and pens must have same length')
+ return self._DrawLineList(lines, pens)
+"
+
+
};
+
+%{
+static void wxDC_GetBoundingBox(wxDC* dc, int* x1, int* y1, int* x2, int* y2) {
+ *x1 = dc->MinX();
+ *y1 = dc->MinY();
+ *x2 = dc->MaxX();
+ *y2 = dc->MaxY();
+}
+%}
+
//----------------------------------------------------------------------
class wxMemoryDC : public wxDC {
//---------------------------------------------------------------------------
-#ifndef __WXMSW__
-class wxPostScriptDC : public wxDC {
-public:
- wxPostScriptDC(const wxString& output, bool interactive = TRUE, wxWindow* win = NULL);
-};
-#endif
-
-//---------------------------------------------------------------------------
-
#ifdef __WXMSW__
-class wxMetaFileDC : public wxDC {
-public:
- wxMetaFileDC(const wxString& filename = wxPyEmptyStr);
- wxMetaFile* Close();
-};
-#endif
-
-//---------------------------------------------------------------------------
-//---------------------------------------------------------------------------
-
-%readonly
%{
-#if 0
+#include <wx/metafile.h>
%}
-extern wxFont *wxNORMAL_FONT;
-extern wxFont *wxSMALL_FONT;
-extern wxFont *wxITALIC_FONT;
-extern wxFont *wxSWISS_FONT;
-extern wxPen *wxRED_PEN;
-extern wxPen *wxCYAN_PEN;
-extern wxPen *wxGREEN_PEN;
-extern wxPen *wxBLACK_PEN;
-extern wxPen *wxWHITE_PEN;
-extern wxPen *wxTRANSPARENT_PEN;
-extern wxPen *wxBLACK_DASHED_PEN;
-extern wxPen *wxGREY_PEN;
-extern wxPen *wxMEDIUM_GREY_PEN;
-extern wxPen *wxLIGHT_GREY_PEN;
+class wxMetaFile : public wxObject {
+public:
+ wxMetaFile(const wxString& filename = wxEmptyString);
+ ~wxMetaFile();
-extern wxBrush *wxBLUE_BRUSH;
-extern wxBrush *wxGREEN_BRUSH;
-extern wxBrush *wxWHITE_BRUSH;
-extern wxBrush *wxBLACK_BRUSH;
-extern wxBrush *wxTRANSPARENT_BRUSH;
-extern wxBrush *wxCYAN_BRUSH;
-extern wxBrush *wxRED_BRUSH;
-extern wxBrush *wxGREY_BRUSH;
-extern wxBrush *wxMEDIUM_GREY_BRUSH;
-extern wxBrush *wxLIGHT_GREY_BRUSH;
+ bool Ok();
+ bool SetClipboard(int width = 0, int height = 0);
-extern wxColour *wxBLACK;
-extern wxColour *wxWHITE;
-extern wxColour *wxRED;
-extern wxColour *wxBLUE;
-extern wxColour *wxGREEN;
-extern wxColour *wxCYAN;
-extern wxColour *wxLIGHT_GREY;
+ wxSize GetSize();
+ int GetWidth();
+ int GetHeight();
-extern wxCursor *wxSTANDARD_CURSOR;
-extern wxCursor *wxHOURGLASS_CURSOR;
-extern wxCursor *wxCROSS_CURSOR;
+ const wxString& GetFileName() const { return m_filename; }
-extern wxBitmap wxNullBitmap;
-extern wxIcon wxNullIcon;
-extern wxCursor wxNullCursor;
-extern wxPen wxNullPen;
-extern wxBrush wxNullBrush;
-extern wxPalette wxNullPalette;
-extern wxFont wxNullFont;
-extern wxColour wxNullColour;
+};
+// bool wxMakeMetaFilePlaceable(const wxString& filename,
+// int minX, int minY, int maxX, int maxY, float scale=1.0);
-extern wxFontList* wxTheFontList;
-extern wxPenList* wxThePenList;
-extern wxBrushList* wxTheBrushList;
-extern wxColourDatabase* wxTheColourDatabase;
+class wxMetaFileDC : public wxDC {
+public:
+ wxMetaFileDC(const wxString& filename = wxEmptyString,
+ int width = 0, int height = 0,
+ const wxString& description = wxEmptyString);
+ wxMetaFile* Close();
+};
-%readwrite
-%{
#endif
-%}
//---------------------------------------------------------------------------
~wxRegion();
void Clear();
+#ifndef __WXMAC__
+ bool Offset(wxCoord x, wxCoord y);
+#endif
+
wxRegionContain Contains(long x, long y);
%name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt);
%name(ContainsRect)wxRegionContain Contains(const wxRect& rect);
//---------------------------------------------------------------------------
+%readonly
+%{
+#if 0
+%}
+
+extern wxFont *wxNORMAL_FONT;
+extern wxFont *wxSMALL_FONT;
+extern wxFont *wxITALIC_FONT;
+extern wxFont *wxSWISS_FONT;
+
+extern wxPen *wxRED_PEN;
+extern wxPen *wxCYAN_PEN;
+extern wxPen *wxGREEN_PEN;
+extern wxPen *wxBLACK_PEN;
+extern wxPen *wxWHITE_PEN;
+extern wxPen *wxTRANSPARENT_PEN;
+extern wxPen *wxBLACK_DASHED_PEN;
+extern wxPen *wxGREY_PEN;
+extern wxPen *wxMEDIUM_GREY_PEN;
+extern wxPen *wxLIGHT_GREY_PEN;
+
+extern wxBrush *wxBLUE_BRUSH;
+extern wxBrush *wxGREEN_BRUSH;
+extern wxBrush *wxWHITE_BRUSH;
+extern wxBrush *wxBLACK_BRUSH;
+extern wxBrush *wxTRANSPARENT_BRUSH;
+extern wxBrush *wxCYAN_BRUSH;
+extern wxBrush *wxRED_BRUSH;
+extern wxBrush *wxGREY_BRUSH;
+extern wxBrush *wxMEDIUM_GREY_BRUSH;
+extern wxBrush *wxLIGHT_GREY_BRUSH;
+
+extern wxColour *wxBLACK;
+extern wxColour *wxWHITE;
+extern wxColour *wxRED;
+extern wxColour *wxBLUE;
+extern wxColour *wxGREEN;
+extern wxColour *wxCYAN;
+extern wxColour *wxLIGHT_GREY;
+
+extern wxCursor *wxSTANDARD_CURSOR;
+extern wxCursor *wxHOURGLASS_CURSOR;
+extern wxCursor *wxCROSS_CURSOR;
+
+
+extern wxBitmap wxNullBitmap;
+extern wxIcon wxNullIcon;
+extern wxCursor wxNullCursor;
+extern wxPen wxNullPen;
+extern wxBrush wxNullBrush;
+extern wxPalette wxNullPalette;
+extern wxFont wxNullFont;
+extern wxColour wxNullColour;
+
+
+extern wxFontList* wxTheFontList;
+extern wxPenList* wxThePenList;
+extern wxBrushList* wxTheBrushList;
+extern wxColourDatabase* wxTheColourDatabase;
+
+
+%readwrite
+%{
+#endif
+%}
+
+//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
+