X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b159c5c4815594c9a15365dd2a520c3f21a3b3b6..4263de1e0586d20cb49d0dde23f0d227c5ef25cb:/wxPython/src/_dc.i diff --git a/wxPython/src/_dc.i b/wxPython/src/_dc.i index 7d0fa94a4f..e61213b451 100644 --- a/wxPython/src/_dc.i +++ b/wxPython/src/_dc.i @@ -168,12 +168,13 @@ public: wxCoord xoffset = 0, wxCoord yoffset = 0, int fillStyle = wxODDEVEN_RULE); - // TODO: Figure out what the start parameter means and devise a - // good typemap for this - //void DrawPolyPolygon(int n, int start[], wxPoint points[], - // 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 @@ -277,6 +278,15 @@ public: "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 // ------------------- @@ -560,26 +570,105 @@ public: //--------------------------------------------------------------------------- %newgroup -enum + +%{ +//-=-=-=-=-=-=-=-=-=-=- + +#if 1 +// Use the standard wxBufferedDC +#include + +#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 { - // this is more efficient and hence default - wxBUFFER_DC_OVERWRITE_BG = 0, +private: + wxDC *m_dc; + wxBitmap m_buffer; + +public: + + 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; + } +}; + - // preserve the old background: more time consuming - wxBUFFER_DC_PRESERVE_BG = 1, +class wxBufferedPaintDC : public wxBufferedDC +{ +private: + wxPaintDC m_paintdc; - // flags used by default - wxBUFFER_DC_DEFAULT = wxBUFFER_DC_OVERWRITE_BG +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( wxDC *dc, const wxBitmap &buffer ) + %pythonAppend wxBufferedDC "self._dc = args[0] # save a ref so the other dc will not be deleted before self"; - %pythonAppend wxBufferedDC( wxDC *dc, const wxSize &area, int flags = wxBUFFER_DC_DEFAULT ) - "val._dc = args[0] # save a ref so the other dc will not be deleted before self"; %nokwargs wxBufferedDC; @@ -589,11 +678,19 @@ public: // 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, int flags = wxBUFFER_DC_DEFAULT ); + wxBufferedDC( wxDC *dc, const wxSize &area ); + // TODO: Keep this one too? - %name(BufferedDCInternalBuffer) wxBufferedDC( wxDC *dc, const wxSize &area, int flags = wxBUFFER_DC_DEFAULT ); + %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 ); + + + // 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 @@ -603,16 +700,16 @@ public: }; + + +// Creates a double buffered wxPaintDC, optionally allowing the +// user to specify their own buffer to use. class wxBufferedPaintDC : public wxBufferedDC { public: - %nokwargs wxBufferedPaintDC; - - wxBufferedPaintDC( wxWindow *window, const wxBitmap &buffer ); - - // this ctor creates a bitmap of the size of the window for buffering - wxBufferedPaintDC(wxWindow *window, int flags = wxBUFFER_DC_DEFAULT); + // If no bitmap is supplied by the user, a temporary one will be created. + wxBufferedPaintDC( wxWindow *window, const wxBitmap &buffer = wxNullBitmap ); }; @@ -693,7 +790,7 @@ public: %newgroup -#ifdef __WXMSW__ +#if defined(__WXMSW__) || defined(__WXMAC__) %{ #include @@ -711,8 +808,10 @@ public: int GetWidth(); int GetHeight(); +#ifdef __WXMSW__ const wxString& GetFileName() const; - +#endif + %pythoncode { def __nonzero__(self): return self.Ok() } };