From cbc3893c76a5785c211daa06491c0fc8d3646e7b Mon Sep 17 00:00:00 2001 From: Kevin Ollivier Date: Thu, 26 Oct 2006 19:17:24 +0000 Subject: [PATCH] Updating bindings for wxGraphicsContext and wxRichTextCtrl. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42465 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/src/_graphics.i | 137 +++++++++++++++++++++++++++++++-------- wxPython/src/richtext.i | 42 ++++++++++-- 2 files changed, 144 insertions(+), 35 deletions(-) diff --git a/wxPython/src/_graphics.i b/wxPython/src/_graphics.i index 6df55591bb..5f03ea36a7 100644 --- a/wxPython/src/_graphics.i +++ b/wxPython/src/_graphics.i @@ -31,6 +31,39 @@ #if !wxUSE_GRAPHICS_CONTEXT // C++ stub classes for platforms that don't have wxGraphicsContext yet. +class wxGraphicsObject : public wxObject +{ +public : + wxGraphicsObject( wxGraphicsRenderer* renderer ) {} + wxGraphicsObject( const wxGraphicsObject& obj ) {} + virtual ~wxGraphicsObject() {} + wxGraphicsRenderer* GetRenderer() const {} +} ; + +class wxGraphicsPen : public wxGraphicsObject +{ + //wxGraphicsPen(wxGraphicsRenderer* renderer) : wxGraphicsObject(renderer) {} + virtual ~wxGraphicsPen() {} + virtual void Apply( wxGraphicsContext* context) {} + virtual wxDouble GetWidth() {} +} ; + +class wxGraphicsBrush : public wxGraphicsObject +{ +public : + //wxGraphicsBrush(wxGraphicsRenderer* renderer) {} + virtual ~wxGraphicsBrush() {} + virtual void Apply( wxGraphicsContext* context) {} +} ; + +class wxGraphicsFont : public wxGraphicsObject +{ +public : + //wxGraphicsFont(wxGraphicsRenderer* renderer) {} + virtual ~wxGraphicsFont() {} + virtual void Apply( wxGraphicsContext* context) {} +} ; + class wxGraphicsPath { public : @@ -87,7 +120,20 @@ public: "wxGraphicsContext is not available on this platform."); wxPyEndBlockThreads(blocked); return NULL; - } + } + + virtual wxGraphicsPen* CreatePen(const wxPen& pen) {} + + virtual wxGraphicsBrush* CreateBrush(const wxBrush& brush ) {} + + virtual wxGraphicsBrush* CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2, + const wxColour&c1, const wxColour&c2) {} + + virtual wxGraphicsBrush* CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius, + const wxColour &oColor, const wxColour &cColor) {} + + virtual wxGraphicsFont* CreateFont( const wxFont &font , const wxColour &col = *wxBLACK ) {} + wxGraphicsPath * CreatePath() { return NULL; } void PushState() {} @@ -99,14 +145,8 @@ public: void Translate( wxDouble , wxDouble ) {} void Scale( wxDouble , wxDouble ) {} void Rotate( wxDouble ) {} - void SetPen( const wxPen & ) {} - void SetBrush( const wxBrush & ) {} - void SetLinearGradientBrush( wxDouble , wxDouble , wxDouble , wxDouble , - const wxColour&, const wxColour&) {} - void SetRadialGradientBrush( wxDouble , wxDouble , wxDouble , wxDouble , wxDouble , - const wxColour &, const wxColour &) {} - void SetFont( const wxFont & ) {} - void SetTextColour( const wxColour & ) {} + void SetFont( const wxFont &, bool ) {} + void SetFont( const wxFont &, const wxColour &) {} void StrokePath( const wxGraphicsPath * ) {} void FillPath( const wxGraphicsPath *, int ) {} void DrawPath( const wxGraphicsPath *, int ) {} @@ -177,6 +217,40 @@ typedef double wxDouble; // TODO: Decide which of the overloaded methods should use the primary names +class wxGraphicsObject : public wxObject +{ +public : + wxGraphicsObject( wxGraphicsRenderer* renderer = NULL ); + wxGraphicsObject( const wxGraphicsObject& obj ); + virtual ~wxGraphicsObject(); + wxGraphicsRenderer* GetRenderer() const; +} ; + +class wxGraphicsPen : public wxGraphicsObject +{ +public : + //wxGraphicsPen(wxGraphicsRenderer* renderer); + virtual ~wxGraphicsPen(); + virtual void Apply( wxGraphicsContext* context); + virtual wxDouble GetWidth(); +} ; + +class wxGraphicsBrush : public wxGraphicsObject +{ +public : + //wxGraphicsBrush(wxGraphicsRenderer* renderer); + virtual ~wxGraphicsBrush(); + virtual void Apply( wxGraphicsContext* context); +} ; + +class wxGraphicsFont : public wxGraphicsObject +{ +public : + //wxGraphicsFont(wxGraphicsRenderer* renderer); + virtual ~wxGraphicsFont(); + virtual void Apply( wxGraphicsContext* context); +} ; + class wxGraphicsPath { public : @@ -313,6 +387,28 @@ public: "", ""); /* + + %newobject CreatePen + virtual wxGraphicsPen* CreatePen(const wxPen& pen); + + %newobject CreateBrush + virtual wxGraphicsBrush* CreateBrush(const wxBrush& brush ); + + %newobject CreateLinearGradientBrush + // sets the brush to a linear gradient, starting at (x1,y1) with color c1 to (x2,y2) with color c2 + virtual wxGraphicsBrush* CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2, + const wxColour&c1, const wxColour&c2); + + %newobject CreateRadialGradientBrush + // sets the brush to a radial gradient originating at (xo,yc) with color oColor and ends on a circle around (xc,yc) + // with radius r and color cColor + virtual wxGraphicsBrush* CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius, + const wxColour &oColor, const wxColour &cColor); + + %newobject CreateFont + // sets the font + virtual wxGraphicsFont* CreateFont( const wxFont &font , const wxColour &col = *wxBLACK ); + // create a 'native' matrix corresponding to these values virtual wxGraphicsMatrix* CreateMatrix( wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0, @@ -395,33 +491,18 @@ public: "", ""); - // sets the brush to a linear gradient, starting at (x1,y1) with color c1 to (x2,y2) with color c2 - DocDeclStr( - virtual void , SetLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2, - const wxColour&c1, const wxColour&c2), - "", ""); - - - // sets the brush to a radial gradient originating at (xo,yc) with color oColour and ends on a circle around (xc,yc) - // with radius r and color cColour - DocDeclStr( - virtual void , SetRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, - wxDouble radius, - const wxColour &oColour, const wxColour &cColour), - "", ""); - - // sets the font DocDeclStr( - virtual void , SetFont( const wxFont &font ), + virtual void , SetFont( const wxFont &font, bool release = true ), "", ""); - // sets the text color + // sets the font DocDeclStr( - virtual void , SetTextColour( const wxColour &col ), + void , SetFont( const wxFont &font, const wxColour& colour ), "", ""); + // strokes along a path with the current pen DocDeclStr( diff --git a/wxPython/src/richtext.i b/wxPython/src/richtext.i index fe76d47b95..f32b63b11b 100644 --- a/wxPython/src/richtext.i +++ b/wxPython/src/richtext.i @@ -115,7 +115,6 @@ enum { wxTEXT_ATTR_PARAGRAPH_STYLE_NAME, wxTEXT_ATTR_BULLET_STYLE, wxTEXT_ATTR_BULLET_NUMBER, - wxTEXT_ATTR_BULLET_SYMBOL, wxTEXT_ATTR_BULLET_STYLE_NONE, wxTEXT_ATTR_BULLET_STYLE_ARABIC, @@ -378,7 +377,7 @@ public: void SetLineSpacing(int spacing); void SetBulletStyle(int style); void SetBulletNumber(int n); - void SetBulletSymbol(wxChar symbol); + void SetBulletText(wxChar symbol); void SetBulletFont(const wxString& bulletFont); const wxColour& GetTextColour() const; @@ -403,7 +402,7 @@ public: int GetLineSpacing() const; int GetBulletStyle() const; int GetBulletNumber() const; - wxChar GetBulletSymbol() const; + const wxString& GetBulletText() const; const wxString& GetBulletFont() const; // accessors @@ -427,7 +426,7 @@ public: bool HasParagraphStyleName() const; bool HasBulletStyle() const; bool HasBulletNumber() const; - bool HasBulletSymbol() const; + bool HasBulletText() const; bool HasFlag(long flag) const; @@ -452,7 +451,7 @@ public: %property(BulletFont, GetBulletFont, SetBulletFont, doc="See `GetBulletFont` and `SetBulletFont`"); %property(BulletNumber, GetBulletNumber, SetBulletNumber, doc="See `GetBulletNumber` and `SetBulletNumber`"); %property(BulletStyle, GetBulletStyle, SetBulletStyle, doc="See `GetBulletStyle` and `SetBulletStyle`"); - %property(BulletSymbol, GetBulletSymbol, SetBulletSymbol, doc="See `GetBulletSymbol` and `SetBulletSymbol`"); + %property(BulletText, GetBulletText, SetBulletText, doc="See `GetBulletText` and `SetBulletText`"); %property(CharacterStyleName, GetCharacterStyleName, SetCharacterStyleName, doc="See `GetCharacterStyleName` and `SetCharacterStyleName`"); %property(Flags, GetFlags, SetFlags, doc="See `GetFlags` and `SetFlags`"); %property(Font, GetFont, SetFont, doc="See `GetFont` and `SetFont`"); @@ -616,6 +615,14 @@ during sizing.", ""); empty string is passed then to the filename set with `SetFilename`.", ""); + DocDeclStr( + void , SetHandlerFlags(int flags), + "Set the handler flags, controlling loading and saving.", ""); + + DocDeclStr( + int , GetHandlerFlags() const, + "Get the handler flags, controlling loading and saving.", ""); + // sets/clears the dirty flag DocDeclStr( virtual void , MarkDirty(), @@ -1060,7 +1067,7 @@ flag.", ""); /// Begin symbol bullet DocDeclStr( - bool , BeginSymbolBullet(char symbol, + bool , BeginSymbolBullet(const wxString& symbol, int leftIndent, int leftSubIndent, int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_SYMBOL), @@ -1097,6 +1104,20 @@ flag.", ""); "", ""); + DocDeclStr( + bool , BeginListStyle(const wxString& listStyle, int level = 1, int number = 1), + "Begin named list style.", ""); + + DocDeclStr( + bool , EndListStyle(), "End named list style.", ""); + + DocDeclStr( + bool , BeginURL(const wxString& url, const wxString& characterStyle = wxEmptyString), + "Begin URL.", ""); + + DocDeclStr( + bool , EndURL(), "End URL.", ""); + /// Sets the default style to the style under the cursor DocDeclStr( bool , SetDefaultStyleToCursorStyle(), @@ -1511,7 +1532,10 @@ flag.", ""); %constant wxEventType wxEVT_COMMAND_RICHTEXT_MIDDLE_CLICK; %constant wxEventType wxEVT_COMMAND_RICHTEXT_LEFT_DCLICK; %constant wxEventType wxEVT_COMMAND_RICHTEXT_RETURN; - +%constant wxEventType wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING; +%constant wxEventType wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGED; +%constant wxEventType wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACING; +%constant wxEventType wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACED; %pythoncode { EVT_RICHTEXT_ITEM_SELECTED = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_ITEM_SELECTED, 1) @@ -1521,6 +1545,10 @@ EVT_RICHTEXT_RIGHT_CLICK = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_RIGHT_CLICK, EVT_RICHTEXT_MIDDLE_CLICK = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_MIDDLE_CLICK, 1) EVT_RICHTEXT_LEFT_DCLICK = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_LEFT_DCLICK, 1) EVT_RICHTEXT_RETURN = wx.PyEventBinder( wxEVT_COMMAND_RICHTEXT_RETURN, 1) +EVT_RICHTEXT_STYLESHEET_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING, 1) +EVT_RICHTEXT_STYLESHEET_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGED, 1) +EVT_RICHTEXT_STYLESHEET_REPLACING = wx.PyEventBinder( wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACING, 1) +EVT_RICHTEXT_STYLESHEET_REPLACED = wx.PyEventBinder( wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACED, 1) }