// Not a %module
+
//---------------------------------------------------------------------------
%{
-#if 0 // The old way
+#if defined(wxUSE_DC_OLD_METHODS)
bool FloodFill(wxCoord x, wxCoord y, const wxColour& col, int style = wxFLOOD_SURFACE);
//bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const;
#else // The new way
-
+
%name(FloodFillXY) bool FloodFill(wxCoord x, wxCoord y, const wxColour& col, int style = wxFLOOD_SURFACE);
bool FloodFill(const wxPoint& pt, const wxColour& col, int style = wxFLOOD_SURFACE);
%name(DrawRotatedTextXY) void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
void DrawRotatedText(const wxString& text, const wxPoint& pt, double angle);
-
+
%name(BlitXY) bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
wxDC *source, wxCoord xsrc, wxCoord ysrc,
int rop = wxCOPY, bool useMask = False,
wxCoord xsrcMask = -1, wxCoord ysrcMask = -1);
- bool Blit(const wxPoint& destPt, const wxSize& sz,
+ bool Blit(const wxPoint& destPt, const wxSize& sz,
wxDC *source, const wxPoint& srcPt,
int rop = wxCOPY, bool useMask = False,
const wxPoint& srcPtMask = wxDefaultPosition);
#endif
-
+
void DrawLines(int points, wxPoint* points_array, wxCoord xoffset = 0, wxCoord yoffset = 0);
void DrawPolygon(int points, wxPoint* points_array,
wxCoord xoffset = 0, wxCoord yoffset = 0,
int fillStyle = wxODDEVEN_RULE);
+ // TODO: Figure out a good typemap for this...
+ // Convert the first 3 args from a sequence of sequences?
+// void DrawPolyPolygon(int n, int count[], wxPoint points[],
+// wxCoord xoffset = 0, wxCoord yoffset = 0,
+// int fillStyle = wxODDEVEN_RULE);
+
// this version puts both optional bitmap and the text into the given
// rectangle and aligns is as specified by alignment parameter; it also
// will emphasize the character with the given index if it is != -1 and
void DrawSpline(int points, wxPoint* points_array);
-
+
// global DC operations
// --------------------
virtual void StartPage();
virtual void EndPage();
-
+
// set objects to use for drawing
// ------------------------------
virtual void SetBackgroundMode(int mode);
virtual void SetPalette(const wxPalette& palette);
-
+
// clipping region
// ---------------
- void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
- //void SetClippingRegion(const wxPoint& pt, const wxSize& sz)
+ %name(SetClippingRegionXY)void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
+ void SetClippingRegion(const wxPoint& pt, const wxSize& sz);
%name(SetClippingRect) void SetClippingRegion(const wxRect& rect);
%name(SetClippingRegionAsRegion) void SetClippingRegion(const wxRegion& region);
DocDeclA(
void, GetClippingBox(wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT) const,
"GetClippingBox() -> (x, y, width, height)");
-
+
%extend {
wxRect GetClippingRect() {
wxRect rect;
return rect;
}
}
-
-
+
+
// text extent
// -----------
"Only works for single line strings.");
DocDeclAStrName(
void, GetTextExtent(const wxString& string,
- wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord* OUTPUT,
+ wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord* OUTPUT,
wxFont* font = NULL),
"GetFullTextExtent(wxString string, Font font=None) ->\n (width, height, descent, externalLeading)",
"Get the width, height, decent and leading of the text using the current or specified font.\n"
"Only works for single line strings.",
GetFullTextExtent);
-
+
// works for single as well as multi-line strings
DocDeclAStr(
void, GetMultiLineTextExtent(const wxString& text,
"Get the width, height, decent and leading of the text using the current or specified font.\n"
"Works for single as well as multi-line strings.");
+
+ %extend {
+ wxArrayInt GetPartialTextExtents(const wxString& text) {
+ wxArrayInt widths;
+ self->GetPartialTextExtents(text, widths);
+ return widths;
+ }
+ }
+
// size and resolution
// -------------------
void, GetSize( int *OUTPUT, int *OUTPUT ),
"GetSizeTuple() -> (width, height)",
GetSizeTuple);
-
+
DocStr(GetSizeMM, "Get the DC size in milimeters.");
wxSize GetSizeMM() const;
void, GetSizeMM( int *OUTPUT, int *OUTPUT ) const,
"GetSizeMMTuple() -> (width, height)",
GetSizeMMTuple);
-
-
+
+
// coordinates conversions
// -----------------------
virtual bool Ok() const;
-
+
int GetBackgroundMode() const;
const wxBrush& GetBackground() const;
int GetMapMode() const;
virtual void SetMapMode(int mode);
-
+
DocDeclA(
virtual void, GetUserScale(double *OUTPUT, double *OUTPUT) const,
"GetUserScale() -> (xScale, yScale)");
-
+
virtual void SetUserScale(double x, double y);
-
+
DocDeclA(
virtual void, GetLogicalScale(double *OUTPUT, double *OUTPUT),
"GetLogicalScale() -> (xScale, yScale)");
void, GetLogicalOrigin(wxCoord *OUTPUT, wxCoord *OUTPUT) const,
"GetLogicalOriginTuple() -> (x,y)",
GetLogicalOriginTuple);
-
+
virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
-
+
wxPoint GetDeviceOrigin() const;
DocDeclAName(
void, GetDeviceOrigin(wxCoord *OUTPUT, wxCoord *OUTPUT) const,
"GetDeviceOriginTuple() -> (x,y)",
GetDeviceOriginTuple);
-
+
virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
virtual void SetOptimization(bool opt);
virtual bool GetOptimization();
-
+
// bounding box
// ------------
%extend {
void GetBoundingBox(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
// See below for implementation
- }
+ }
%pythoncode { def __nonzero__(self): return self.Ok() };
def DrawPolygonList(self, polygons, pens=None, brushes=None):
- ## Note: This does not currently support fill style or offset
- ## you can always use the non-List version if need be.
+ %## Note: This does not currently support fill style or offset
+ %## you can always use the non-List version if need be.
if pens is None:
pens = []
elif isinstance(pens, wx.Pen):
def DrawTextList(self, textList, coords, foregrounds = None, backgrounds = None, fonts = None):
- ## NOTE: this does not currently support changing the font
- ## Make sure you set Background mode to wxSolid (DC.SetBackgroundMode)
- ## If you want backgounds to do anything.
+ %## NOTE: this does not currently support changing the font
+ %## Make sure you set Background mode to wxSolid (DC.SetBackgroundMode)
+ %## If you want backgounds to do anything.
if type(textList) == type(''):
textList = [textList]
elif len(textList) != len(coords):
raise ValueError('textlist and coords must have same length')
if foregrounds is None:
foregrounds = []
- elif isinstance(foregrounds, wxColour):
+ elif isinstance(foregrounds, wx.Colour):
foregrounds = [foregrounds]
elif len(foregrounds) != len(coords):
raise ValueError('foregrounds and coords must have same length')
if backgrounds is None:
backgrounds = []
- elif isinstance(backgrounds, wxColour):
+ elif isinstance(backgrounds, wx.Colour):
backgrounds = [backgrounds]
elif len(backgrounds) != len(coords):
raise ValueError('backgrounds and coords must have same length')
public:
wxMemoryDC();
%name(MemoryDCFromDC) wxMemoryDC(wxDC* oldDC);
-
+
void SelectObject(const wxBitmap& bitmap);
};
//---------------------------------------------------------------------------
%newgroup
+
+%{
+//-=-=-=-=-=-=-=-=-=-=-
+
+#if 1
+// Use the standard wxBufferedDC
+#include <wx/dcbuffer.h>
+
+#else
+
+// Or, temporarily put a set of classes here similar to the old buffered DC
+// classes until the real ones can be fixed to work "correctly" again.
+
class wxBufferedDC : public wxMemoryDC
{
+private:
+ wxDC *m_dc;
+ wxBitmap m_buffer;
+
public:
- %addtofunc wxBufferedDC( wxDC *dc, const wxBitmap &buffer )
+
+ wxBufferedDC() : m_dc( 0 ) {}
+
+ wxBufferedDC( wxDC *dc, const wxBitmap &buffer )
+ : m_dc( dc ), m_buffer( buffer )
+ {
+ SelectObject( m_buffer );
+ }
+
+ wxBufferedDC( wxDC *dc, const wxSize &area )
+ : m_dc( dc ), m_buffer( area.GetWidth(), area.GetHeight() )
+ {
+ SelectObject( m_buffer );
+ }
+
+ ~wxBufferedDC() {
+ if( m_dc != 0 )
+ UnMask();
+ }
+
+
+ void Init( wxDC *dc, const wxBitmap &buffer ) {
+ wxASSERT_MSG( m_dc == 0 && m_buffer == wxNullBitmap,
+ _T("wxBufferedDC already initialised") );
+ m_dc = dc;
+ m_buffer = buffer;
+ SelectObject( m_buffer );
+ }
+
+ void Init( wxDC *dc, const wxSize &area ) {
+ wxASSERT_MSG( m_dc == 0 && m_buffer == wxNullBitmap,
+ _T("wxBufferedDC already initialised") );
+ m_dc = dc;
+ m_buffer = wxBitmap( area.GetWidth(), area.GetHeight() );
+ SelectObject( m_buffer );
+ }
+
+ void UnMask() {
+ wxASSERT_MSG( m_dc != 0, _T("No low level DC associated with buffer (anymore)") );
+ m_dc->Blit( 0, 0, m_buffer.GetWidth(), m_buffer.GetHeight(), this, 0, 0 );
+ m_dc = 0;
+ }
+};
+
+
+class wxBufferedPaintDC : public wxBufferedDC
+{
+private:
+ wxPaintDC m_paintdc;
+
+public:
+ wxBufferedPaintDC( wxWindow *window, const wxBitmap &buffer = wxNullBitmap )
+ : m_paintdc( window )
+ {
+ window->PrepareDC( m_paintdc );
+
+ if( buffer != wxNullBitmap )
+ Init( &m_paintdc, buffer );
+ else
+ Init( &m_paintdc, window->GetClientSize() );
+ }
+
+ ~wxBufferedPaintDC() {
+ UnMask();
+ }
+};
+
+#endif
+//-=-=-=-=-=-=-=-=-=-=-
+%}
+
+
+
+
+class wxBufferedDC : public wxMemoryDC
+{
+public:
+ %pythonAppend wxBufferedDC
"self._dc = args[0] # save a ref so the other dc will not be deleted before self";
- %addtofunc wxBufferedDC( wxDC *dc, const wxSize &area )
- "val._dc = args[0] # save a ref so the other dc will not be deleted before self";
+ %nokwargs wxBufferedDC;
+
// Construct a wxBufferedDC using a user supplied buffer.
wxBufferedDC( wxDC *dc, const wxBitmap &buffer );
- // Construct a wxBufferedDC with an internal buffer of 'area'
- // (where area is usually something like the size of the window
- // being buffered)
+ // Construct a wxBufferedDC with an internal buffer of 'area'
+ // (where area is usually something like the size of the window
+ // being buffered)
+ wxBufferedDC( wxDC *dc, const wxSize &area );
+
+
+ // TODO: Keep this one too?
+ %pythonAppend wxBufferedDC( wxDC *dc, const wxSize &area )
+ "val._dc = args[0] # save a ref so the other dc will not be deleted before self";
%name(BufferedDCInternalBuffer) wxBufferedDC( wxDC *dc, const wxSize &area );
- // Blits the buffer to the dc, and detaches the dc from
- // the buffer. Usually called in the dtor or by the dtor
- // of derived classes if the BufferedDC must blit before
- // the derived class (which may own the dc it's blitting
- // to) is destroyed.
+
+ // The buffer is blit to the real DC when the BufferedDC is destroyed.
+ ~wxBufferedDC();
+
+
+ // Blits the buffer to the dc, and detaches the dc from
+ // the buffer. Usually called in the dtor or by the dtor
+ // of derived classes if the BufferedDC must blit before
+ // the derived class (which may own the dc it's blitting
+ // to) is destroyed.
void UnMask();
};
+
+
+// Creates a double buffered wxPaintDC, optionally allowing the
+// user to specify their own buffer to use.
class wxBufferedPaintDC : public wxBufferedDC
{
public:
+
+ // If no bitmap is supplied by the user, a temporary one will be created.
wxBufferedPaintDC( wxWindow *window, const wxBitmap &buffer = wxNullBitmap );
+
};
%newgroup
-#ifdef __WXMSW__
+#if defined(__WXMSW__) || defined(__WXMAC__)
%{
#include <wx/metafile.h>
int GetWidth();
int GetHeight();
+#ifdef __WXMSW__
const wxString& GetFileName() const;
-
+#endif
+
%pythoncode { def __nonzero__(self): return self.Ok() }
};
class wxMetaFile : public wxObject {
public:
wxMetaFile(const wxString&)
- { PyErr_SetNone(PyExc_NotImplementedError); }
+ { wxPyRaiseNotImplemented(); }
};
class wxMetaFileDC : public wxClientDC {
public:
wxMetaFileDC(const wxString&, int, int, const wxString&)
- { PyErr_SetNone(PyExc_NotImplementedError); }
+ { wxPyRaiseNotImplemented(); }
};
%}
class wxPrinterDC : public wxClientDC {
public:
wxPrinterDC(const wxPrintData&)
- { PyErr_SetNone(PyExc_NotImplementedError); }
-
+ { wxPyRaiseNotImplemented(); }
+
// wxPrinterDC(const wxString&, const wxString&, const wxString&, bool, int)
-// { PyErr_SetNone(PyExc_NotImplementedError); }
+// { wxPyRaiseNotImplemented(); }
};
%}
-
+
class wxPrinterDC : public wxDC {
public:
wxPrinterDC(const wxPrintData& printData);
};
#endif
+//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
+
+// Now define some Python classes that rename the Draw methods to be
+// compatible with the DC Draw methods in 2.4. See also wxPython/_wx.py.
+
+
+%define MAKE_OLD_DC_CLASS(classname)
+ %pythoncode {
+ class classname##_old(classname):
+ """DC class that has methods with 2.4 compatible parameters."""
+ FloodFill = classname.FloodFillXY
+ GetPixel = classname.GetPixelXY
+ DrawLine = classname.DrawLineXY
+ CrossHair = classname.CrossHairXY
+ DrawArc = classname.DrawArcXY
+ DrawCheckMark = classname.DrawCheckMarkXY
+ DrawEllipticArc = classname.DrawEllipticArcXY
+ DrawPoint = classname.DrawPointXY
+ DrawRectangle = classname.DrawRectangleXY
+ DrawRoundedRectangle = classname.DrawRoundedRectangleXY
+ DrawCircle = classname.DrawCircleXY
+ DrawEllipse = classname.DrawEllipseXY
+ DrawIcon = classname.DrawIconXY
+ DrawBitmap = classname.DrawBitmapXY
+ DrawText = classname.DrawTextXY
+ DrawRotatedText = classname.DrawRotatedTextXY
+ Blit = classname.BlitXY
+ }
+%enddef
+
+MAKE_OLD_DC_CLASS(DC);
+MAKE_OLD_DC_CLASS(MemoryDC);
+MAKE_OLD_DC_CLASS(BufferedDC);
+MAKE_OLD_DC_CLASS(BufferedPaintDC);
+MAKE_OLD_DC_CLASS(ScreenDC);
+MAKE_OLD_DC_CLASS(ClientDC);
+MAKE_OLD_DC_CLASS(PaintDC);
+MAKE_OLD_DC_CLASS(WindowDC);
+MAKE_OLD_DC_CLASS(MirrorDC);
+MAKE_OLD_DC_CLASS(PostScriptDC);
+MAKE_OLD_DC_CLASS(MetaFileDC);
+MAKE_OLD_DC_CLASS(PrinterDC);
+
+
//---------------------------------------------------------------------------