From 706465df1f0d5b356424cc0aeee6c21ac403999e Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Fri, 25 Feb 2011 11:37:20 +0000 Subject: [PATCH] Applied #12941: Fixes and enhancements for wxRTC (Robert Hoffman) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67020 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/richtext/richtextbuffer.h | 804 ++++++++++++++++++------- src/richtext/richtextbuffer.cpp | 5 +- src/richtext/richtextbulletspage.cpp | 4 + src/richtext/richtextdialogs.pjd | 36 +- src/richtext/richtextformatdlg.cpp | 11 +- src/richtext/richtextindentspage.cpp | 4 +- src/richtext/richtextliststylepage.cpp | 8 +- src/richtext/richtextsizepage.cpp | 2 + src/richtext/richtextxml.cpp | 125 ++-- 9 files changed, 704 insertions(+), 295 deletions(-) diff --git a/include/wx/richtext/richtextbuffer.h b/include/wx/richtext/richtextbuffer.h index a471703861..ffff1c8428 100644 --- a/include/wx/richtext/richtextbuffer.h +++ b/include/wx/richtext/richtextbuffer.h @@ -99,14 +99,14 @@ // Include the faster, direct implementation for output #define wxRICHTEXT_HAVE_DIRECT_OUTPUT 1 -/* - * Special characters +/** + The line break character that can be embedded in content. */ extern WXDLLIMPEXP_RICHTEXT const wxChar wxRichTextLineBreakChar; -/*! - * File types in wxRichText context. +/** + File types in wxRichText context. */ enum wxRichTextFileType { @@ -140,9 +140,11 @@ class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextParagraphLayoutBox; class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextImageBlock; class WXDLLIMPEXP_FWD_XML wxXmlNode; class wxRichTextFloatCollector; +class WXDLLIMPEXP_FWD_BASE wxDataInputStream; +class WXDLLIMPEXP_FWD_BASE wxDataOutputStream; -/*! - * Flags determining the available space, passed to Layout +/** + Flags determining the available space, passed to Layout. */ #define wxRICHTEXT_FIXED_WIDTH 0x01 @@ -154,8 +156,8 @@ class wxRichTextFloatCollector; // the rect passed to Layout. #define wxRICHTEXT_LAYOUT_SPECIFIED_RECT 0x10 -/* - * Flags to pass to Draw +/** + Flags to pass to Draw */ // Ignore paragraph cache optimization, e.g. for printing purposes @@ -166,8 +168,8 @@ class wxRichTextFloatCollector; #define wxRICHTEXT_DRAW_PRINT 0x04 #define wxRICHTEXT_DRAW_GUIDELINES 0x08 -/* - * Flags returned from hit-testing, or passed to hit-test function. +/** + Flags returned from hit-testing, or passed to hit-test function. */ enum wxRichTextHitTestFlags { @@ -193,8 +195,8 @@ enum wxRichTextHitTestFlags wxRICHTEXT_HITTEST_NO_FLOATING_OBJECTS = 0x40 }; -/*! - * Flags for GetRangeSize +/** + Flags for GetRangeSize. */ #define wxRICHTEXT_FORMATTED 0x01 @@ -202,8 +204,8 @@ enum wxRichTextHitTestFlags #define wxRICHTEXT_CACHE_SIZE 0x04 #define wxRICHTEXT_HEIGHT_ONLY 0x08 -/*! - * Flags for SetStyle/SetListStyle +/** + Flags for SetStyle/SetListStyle. */ #define wxRICHTEXT_SETSTYLE_NONE 0x00 @@ -239,8 +241,8 @@ enum wxRichTextHitTestFlags // Removes the given style instead of applying it #define wxRICHTEXT_SETSTYLE_REMOVE 0x80 -/*! - * Flags for object insertion +/** + Flags for object insertion. */ #define wxRICHTEXT_INSERT_NONE 0x00 @@ -252,31 +254,40 @@ enum wxRichTextHitTestFlags // flag to InsertFragment and DeleteRange to indicate the appropriate mode. #define wxTEXT_ATTR_KEEP_FIRST_PARA_STYLE 0x10000000 -/*! - * Default superscript/subscript font multiplication factor +/** + Default superscript/subscript font multiplication factor. */ #define wxSCRIPT_MUL_FACTOR 1.5 +/** + The type for wxTextAttrDimension flags. + */ typedef unsigned short wxTextAttrDimensionFlags; -// Miscellaneous text box flags +/** + Miscellaneous text box flags + */ enum wxTextBoxAttrFlags { wxTEXT_BOX_ATTR_FLOAT = 0x00000001, wxTEXT_BOX_ATTR_CLEAR = 0x00000002, wxTEXT_BOX_ATTR_COLLAPSE_BORDERS = 0x00000004, - wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT = 0x00000004 + wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT = 0x00000008 }; -// Whether a value is present, used in dimension flags +/** + Whether a value is present, used in dimension flags. + */ enum wxTextAttrValueFlags { wxTEXT_ATTR_VALUE_VALID = 0x1000, wxTEXT_ATTR_VALUE_VALID_MASK = 0x1000 }; -// Units - included in the dimension value +/** + Units, included in the dimension value. + */ enum wxTextAttrUnits { wxTEXT_ATTR_UNITS_TENTHS_MM = 0x0001, @@ -287,7 +298,9 @@ enum wxTextAttrUnits wxTEXT_ATTR_UNITS_MASK = 0x000F }; -// Position - included in the dimension flags +/** + Position alternatives, included in the dimension flags. + */ enum wxTextBoxAttrPosition { wxTEXT_BOX_ATTR_POSITION_STATIC = 0x0000, // Default is static, i.e. as per normal layout @@ -645,7 +658,9 @@ public: wxSize m_parentSize; }; -// Border styles +/** + Border styles, used with wxTextAttrBorder. + */ enum wxTextAttrBorderStyle { wxTEXT_BOX_ATTR_BORDER_NONE = 0, @@ -659,14 +674,18 @@ enum wxTextAttrBorderStyle wxTEXT_BOX_ATTR_BORDER_OUTSET = 8 }; -// Border style presence flags +/** + Border style presence flags, used with wxTextAttrBorder. + */ enum wxTextAttrBorderFlags { wxTEXT_BOX_ATTR_BORDER_STYLE = 0x0001, wxTEXT_BOX_ATTR_BORDER_COLOUR = 0x0002 }; -// Border width symbols for qualitative widths +/** + Border width symbols for qualitative widths, used with wxTextAttrBorder. + */ enum wxTextAttrBorderWidth { wxTEXT_BOX_ATTR_BORDER_THIN = -1, @@ -674,7 +693,9 @@ enum wxTextAttrBorderWidth wxTEXT_BOX_ATTR_BORDER_THICK = -3 }; -// Float styles +/** + Float styles. + */ enum wxTextBoxAttrFloatStyle { wxTEXT_BOX_ATTR_FLOAT_NONE = 0, @@ -682,7 +703,9 @@ enum wxTextBoxAttrFloatStyle wxTEXT_BOX_ATTR_FLOAT_RIGHT = 2 }; -// Clear styles +/** + Clear styles. + */ enum wxTextBoxAttrClearStyle { wxTEXT_BOX_ATTR_CLEAR_NONE = 0, @@ -691,14 +714,18 @@ enum wxTextBoxAttrClearStyle wxTEXT_BOX_ATTR_CLEAR_BOTH = 3 }; -// Collapse mode styles. TODO: can they be switched on per side? +/** + Collapse mode styles. TODO: can they be switched on per side? + */ enum wxTextBoxAttrCollapseMode { wxTEXT_BOX_ATTR_COLLAPSE_NONE = 0, wxTEXT_BOX_ATTR_COLLAPSE_FULL = 1 }; -// Vertical alignment values +/** + Vertical alignment values. + */ enum wxTextBoxAttrVerticalAlignment { wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_NONE = 0, @@ -1660,12 +1687,12 @@ public: ~wxRichTextRange() {} /** - Assignment operator. + Assigns @a range to this range. */ void operator =(const wxRichTextRange& range) { m_start = range.m_start; m_end = range.m_end; } /** - Equality operator. + Equality operator. Returns @true if @a range is the same as this range. */ bool operator ==(const wxRichTextRange& range) const { return (m_start == range.m_start && m_end == range.m_end); } @@ -1720,7 +1747,7 @@ public: bool IsWithin(const wxRichTextRange& range) const { return m_start >= range.m_start && m_end <= range.m_end; } /** - Returns true if @a pos was within the range. + Returns true if @a pos was within the range. Does not match if the range is empty. */ bool Contains(long pos) const { return pos >= m_start && pos <= m_end ; } @@ -1740,12 +1767,18 @@ public: void Swap() { long tmp = m_start; m_start = m_end; m_end = tmp; } /** - Convert to internal form: (n, n) is the range of a single character. + Converts the API-standard range, whose end is one past the last character in + the range, to the internal form, which uses the first and last character + positions of the range. In other words, one is subtracted from the end position. + (n, n) is the range of a single character. */ wxRichTextRange ToInternal() const { return wxRichTextRange(m_start, m_end-1); } /** - Convert from internal to public API form: (n, n+1) is the range of a single character. + Converts the internal range, which uses the first and last character positions + of the range, to the API-standard range, whose end is one past the last + character in the range. In other words, one is added to the end position. + (n, n+1) is the range of a single character. */ wxRichTextRange FromInternal() const { return wxRichTextRange(m_start, m_end+1); } @@ -1808,7 +1841,7 @@ public: { m_ranges.Clear(); m_ranges.Add(range); m_container = container; } /** - Adds a range. + Adds a range to the selection. */ void Add(const wxRichTextRange& range) { m_ranges.Add(range); } @@ -1922,293 +1955,523 @@ public: wxRichTextParagraphLayoutBox* m_container; }; -/*! - * wxRichTextObject class declaration - * This is the base for drawable objects. - */ +/** + @class wxRichTextObject + + This is the base for drawable rich text objects. + + @library{wxrichtext} + @category{richtext} + + @see wxRichTextBuffer, wxRichTextCtrl +*/ class WXDLLIMPEXP_RICHTEXT wxRichTextObject: public wxObject { DECLARE_CLASS(wxRichTextObject) public: -// Constructors - + /** + Constructor, taking an optional parent pointer. + */ wxRichTextObject(wxRichTextObject* parent = NULL); + virtual ~wxRichTextObject(); // Overrideables - /// Draw the item, within the given range. Some objects may ignore the range (for - /// example paragraphs) while others must obey it (lines, to implement wrapping) + /** + Draw the item, within the given range. Some objects may ignore the range (for + example paragraphs) while others must obey it (lines, to implement wrapping) + */ virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style) = 0; - /// Lay the item out at the specified position with the given size constraint. - /// Layout must set the cached size. + /** + Lay the item out at the specified position with the given size constraint. + Layout must set the cached size. + */ virtual bool Layout(wxDC& dc, const wxRect& rect, int style) = 0; - /// Hit-testing: returns a flag indicating hit test details, plus - /// information about position. contextObj is returned to specify what object - /// position is relevant to, since otherwise there's an ambiguity. - /// obj may not a child of contextObj, since we may be referring to the container itself - /// if we have no hit on a child - for example if we click outside an object. + /** + Hit-testing: returns a flag indicating hit test details, plus + information about position. contextObj is returned to specify what object + position is relevant to, since otherwise there's an ambiguity. + obj may not a child of contextObj, since we may be referring to the container itself + if we have no hit on a child - for example if we click outside an object. + */ virtual int HitTest(wxDC& dc, const wxPoint& pt, long& textPosition, wxRichTextObject** obj, wxRichTextObject** contextObj, int flags = 0); - /// Finds the absolute position and row height for the given character position + /** + Finds the absolute position and row height for the given character position. + */ virtual bool FindPosition(wxDC& WXUNUSED(dc), long WXUNUSED(index), wxPoint& WXUNUSED(pt), int* WXUNUSED(height), bool WXUNUSED(forceLineStart)) { return false; } - /// Get the best size, i.e. the ideal starting size for this object irrespective - /// of available space. For a short text string, it will be the size that exactly encloses - /// the text. For a longer string, it might use the parent width for example. + /** + Returns the best size, i.e. the ideal starting size for this object irrespective + of available space. For a short text string, it will be the size that exactly encloses + the text. For a longer string, it might use the parent width for example. + */ virtual wxSize GetBestSize() const { return m_size; } /** - Gets the object size for the given range. Returns false if the range + Returns the object size for the given range. Returns @false if the range is invalid for this object. */ virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, int flags, wxPoint position = wxPoint(0,0), wxArrayInt* partialExtents = NULL) const = 0; - /// Do a split, returning an object containing the second part, and setting - /// the first part in 'this'. + /** + Do a split from @a pos, returning an object containing the second part, and setting + the first part in 'this'. + */ virtual wxRichTextObject* DoSplit(long WXUNUSED(pos)) { return NULL; } - /// Calculate range. By default, guess that the object is 1 unit long. + /** + Calculates the range of the object. By default, guess that the object is 1 unit long. + */ virtual void CalculateRange(long start, long& end) { end = start ; m_range.SetRange(start, end); } - /// Delete range + /** + Deletes the given range. + */ virtual bool DeleteRange(const wxRichTextRange& WXUNUSED(range)) { return false; } - /// Returns true if the object is empty + /** + Returns @true if the object is empty. + */ virtual bool IsEmpty() const { return false; } - /// Whether this object floatable + /** + Returns @true if this class of object is floatable. + */ virtual bool IsFloatable() const { return false; } - /// Whether this object is currently floating + /** + Returns @true if this object is currently floating. + */ virtual bool IsFloating() const { return GetAttributes().GetTextBoxAttr().IsFloating(); } - /// Whether this object is a place holding one - // virtual bool IsPlaceHolding() const { return false; } - - /// The floating direction + /** + Returns the floating direction. + */ virtual int GetFloatDirection() const { return GetAttributes().GetTextBoxAttr().GetFloatMode(); } - /// Get any text in this object for the given range + /** + Returns any text in this object for the given range. + */ virtual wxString GetTextForRange(const wxRichTextRange& WXUNUSED(range)) const { return wxEmptyString; } - /// Returns true if this object can merge itself with the given one. + /** + Returns @true if this object can merge itself with the given one. + */ virtual bool CanMerge(wxRichTextObject* WXUNUSED(object)) const { return false; } - /// Returns true if this object merged itself with the given one. - /// The calling code will then delete the given object. + /** + Returns @true if this object merged itself with the given one. + The calling code will then delete the given object. + */ virtual bool Merge(wxRichTextObject* WXUNUSED(object)) { return false; } - /// Dump to output stream for debugging + /** + Dump object data to the given output stream for debugging. + */ virtual void Dump(wxTextOutputStream& stream); - /// Can we edit properties via a GUI? + /** + Returns @true if we can edit the object's properties via a GUI. + */ virtual bool CanEditProperties() const { return false; } - /// Edit properties via a GUI + /** + Edits the object's properties via a GUI. + */ virtual bool EditProperties(wxWindow* WXUNUSED(parent), wxRichTextBuffer* WXUNUSED(buffer)) { return false; } - /// Return the label to be used for the properties context menu item. + /** + Returns the label to be used for the properties context menu item. + */ virtual wxString GetPropertiesMenuLabel() const { return wxEmptyString; } - /// Returns true if objects of this class can accept the focus, i.e. a call to SetFocusObject - /// is possible. For example, containers supporting text, such as a text box object, can accept the focus, - /// but a table can't (set the focus to individual cells instead). + /** + Returns @true if objects of this class can accept the focus, i.e. a call to SetFocusObject + is possible. For example, containers supporting text, such as a text box object, can accept the focus, + but a table can't (set the focus to individual cells instead). + */ virtual bool AcceptsFocus() const { return false; } #if wxUSE_XML - /// Import this object from XML + /** + Imports this object from XML. + */ virtual bool ImportFromXML(wxRichTextBuffer* buffer, wxXmlNode* node, wxRichTextXMLHandler* handler, bool* recurse); #endif #if wxRICHTEXT_HAVE_DIRECT_OUTPUT - /// Export this object directly to the given stream. + /** + Exports this object directly to the given stream, bypassing the creation of a wxXmlNode hierarchy. + This method is considerably faster than creating a tree first. However, both versions of ExportXML must be + implemented so that if the tree method is made efficient in the future, we can deprecate the + more verbose direct output method. Compiled only if wxRICHTEXT_HAVE_DIRECT_OUTPUT is defined (on by default). + */ virtual bool ExportXML(wxOutputStream& stream, int indent, wxRichTextXMLHandler* handler); #endif #if wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT - /// Export this object to the given parent node, usually creating at least one child node. + /** + Exports this object to the given parent node, usually creating at least one child node. + This method is less efficient than the direct-to-stream method but is retained to allow for + switching to this method if we make it more efficient. Compiled only if wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT is defined + (on by default). + */ virtual bool ExportXML(wxXmlNode* parent, wxRichTextXMLHandler* handler); #endif - /// Does this object take note of paragraph attributes? Text and image objects don't. + /** + Returns @true if this object takes note of paragraph attributes (text and image objects don't). + */ virtual bool UsesParagraphAttributes() const { return true; } - /// What is the XML node name of this object? + /** + Returns the XML node name of this object. This must be overridden for wxXmlNode-base XML export to work. + */ virtual wxString GetXMLNodeName() const { return wxT("unknown"); } - /// Invalidate the buffer. With no argument, invalidates whole buffer. + /** + Invalidates the object at the given range. With no argument, invalidates the whole object. + */ virtual void Invalidate(const wxRichTextRange& invalidRange = wxRICHTEXT_ALL); - /// Can this object handle the selections of its children? FOr example, a table. + /** + Returns @true if this object can handle the selections of its children, fOr example a table. + Required for composite selection handling to work. + */ virtual bool HandlesChildSelections() const { return false; } - /// Returns a selection object specifying the selections between start and end character positions. - /// For example, a table would deduce what cells (of range length 1) are selected when dragging across the table. + /** + Returns a selection object specifying the selections between start and end character positions. + For example, a table would deduce what cells (of range length 1) are selected when dragging across the table. + */ virtual wxRichTextSelection GetSelection(long WXUNUSED(start), long WXUNUSED(end)) const { return wxRichTextSelection(); } // Accessors - /// Get/set the cached object size as calculated by Layout. + /** + Gets the cached object size as calculated by Layout. + */ virtual wxSize GetCachedSize() const { return m_size; } + + /** + Sets the cached object size as calculated by Layout. + */ virtual void SetCachedSize(const wxSize& sz) { m_size = sz; } - /// Get/set the maximum object size as calculated by Layout. This allows - /// us to fit an object to its contents or allocate extra space if required. + /** + Gets the maximum object size as calculated by Layout. This allows + us to fit an object to its contents or allocate extra space if required. + */ virtual wxSize GetMaxSize() const { return m_maxSize; } + + /** + Sets the maximum object size as calculated by Layout. This allows + us to fit an object to its contents or allocate extra space if required. + */ virtual void SetMaxSize(const wxSize& sz) { m_maxSize = sz; } - /// Get/set the minimum object size as calculated by Layout. This allows - /// us to constrain an object to its absolute minimum size if necessary. + /** + Gets the minimum object size as calculated by Layout. This allows + us to constrain an object to its absolute minimum size if necessary. + */ virtual wxSize GetMinSize() const { return m_minSize; } + + /** + Sets the minimum object size as calculated by Layout. This allows + us to constrain an object to its absolute minimum size if necessary. + */ virtual void SetMinSize(const wxSize& sz) { m_minSize = sz; } - /// Get the 'natural' size for an object. For an image, it would be the - /// image size. + /** + Gets the 'natural' size for an object. For an image, it would be the + image size. + */ virtual wxTextAttrSize GetNaturalSize() const { return wxTextAttrSize(); } - /// Get/set the object position + /** + Returns the object position in pixels. + */ virtual wxPoint GetPosition() const { return m_pos; } + + /** + Sets the object position in pixels. + */ virtual void SetPosition(const wxPoint& pos) { m_pos = pos; } - /// Get the absolute object position, by traversing up the child/parent hierarchy - /// TODO: may not be needed, if all object positions are in fact relative to the - /// top of the coordinate space. + /** + Returns the absolute object position, by traversing up the child/parent hierarchy. + TODO: may not be needed, if all object positions are in fact relative to the + top of the coordinate space. + */ virtual wxPoint GetAbsolutePosition() const; - /// Get the rectangle enclosing the object + /** + Returns the rectangle enclosing the object. + */ virtual wxRect GetRect() const { return wxRect(GetPosition(), GetCachedSize()); } - /// Set the range + /** + Sets the object's range within its container. + */ void SetRange(const wxRichTextRange& range) { m_range = range; } - /// Get the range + /** + Returns the object's range. + */ const wxRichTextRange& GetRange() const { return m_range; } + + /** + Returns the object's range. + */ wxRichTextRange& GetRange() { return m_range; } - /// Set the 'own' range, for a top-level object with its own position space + /** + Set the object's own range, for a top-level object with its own position space. + */ void SetOwnRange(const wxRichTextRange& range) { m_ownRange = range; } - /// Get own range (valid if top-level) + /** + Returns the object's own range (valid if top-level). + */ const wxRichTextRange& GetOwnRange() const { return m_ownRange; } + + /** + Returns the object's own range (valid if top-level). + */ wxRichTextRange& GetOwnRange() { return m_ownRange; } - /// Get own range only if a top-level object + /** + Returns the object's own range only if a top-level object. + */ wxRichTextRange GetOwnRangeIfTopLevel() const { return IsTopLevel() ? m_ownRange : m_range; } - /// Is this composite? + /** + Returns @true if this object this composite. + */ virtual bool IsComposite() const { return false; } - /// Get/set the parent. + /** + Returns a pointer to the parent object. + */ virtual wxRichTextObject* GetParent() const { return m_parent; } + + /** + Sets the pointer to the parent object. + */ virtual void SetParent(wxRichTextObject* parent) { m_parent = parent; } - /// Get/set the top-level container of this object. - /// May return itself if it's a container; use GetParentContainer to return - /// a different container. + /** + Returns the top-level container of this object. + May return itself if it's a container; use GetParentContainer to return + a different container. + */ virtual wxRichTextParagraphLayoutBox* GetContainer() const; - /// Get/set the top-level container of this object. - /// Returns a different container than itself, unless there's no parent, in which case it will return NULL. + /** + Returns the top-level container of this object. + Returns a different container than itself, unless there's no parent, in which case it will return NULL. + */ virtual wxRichTextParagraphLayoutBox* GetParentContainer() const { return GetParent() ? GetParent()->GetContainer() : GetContainer(); } - /// Set the margin around the object, in pixels + /** + Set the margin around the object, in pixels. + */ virtual void SetMargins(int margin); + + /** + Set the margin around the object, in pixels. + */ virtual void SetMargins(int leftMargin, int rightMargin, int topMargin, int bottomMargin); + + /** + Returns the left margin of the object, in pixels. + */ virtual int GetLeftMargin() const; + + /** + Returns the right margin of the object, in pixels. + */ virtual int GetRightMargin() const; + + /** + Returns the top margin of the object, in pixels. + */ virtual int GetTopMargin() const; + + /** + Returns the bottom margin of the object, in pixels. + */ virtual int GetBottomMargin() const; - /// Calculate the available content space in the given rectangle, given the - /// margins, border and padding specified in the object's attributes. + /** + Calculates the available content space in the given rectangle, given the + margins, border and padding specified in the object's attributes. + */ virtual wxRect GetAvailableContentArea(wxDC& dc, const wxRect& outerRect) const; - /// Lays out the object first with a given amount of space, and then if no width was specified in attr, - /// lays out the object again using the minimum size + /** + Lays out the object first with a given amount of space, and then if no width was specified in attr, + lays out the object again using the minimum size + */ virtual bool LayoutToBestSize(wxDC& dc, wxRichTextBuffer* buffer, const wxRichTextAttr& parentAttr, const wxRichTextAttr& attr, const wxRect& availableParentSpace, int style); - /// Set/get attributes object + /** + Sets the object's attributes. + */ void SetAttributes(const wxRichTextAttr& attr) { m_attributes = attr; } + + /** + Returns the object's attributes. + */ const wxRichTextAttr& GetAttributes() const { return m_attributes; } + + /** + Returns the object's attributes. + */ wxRichTextAttr& GetAttributes() { return m_attributes; } - /// Set/get properties + /** + Sets the object's properties. + */ wxRichTextProperties& GetProperties() { return m_properties; } + + /** + Returns the object's properties. + */ const wxRichTextProperties& GetProperties() const { return m_properties; } + + /** + Returns the object's properties. + */ void SetProperties(const wxRichTextProperties& props) { m_properties = props; } - /// Set/get stored descent + /** + Sets the stored descent value. + */ void SetDescent(int descent) { m_descent = descent; } + + /** + Returns the stored descent value. + */ int GetDescent() const { return m_descent; } - /// Gets the containing buffer + /** + Returns the containing buffer. + */ wxRichTextBuffer* GetBuffer() const; - /// Sets the identifying name for this object, as a property. + /** + Sets the identifying name for this object as a property using the "name" key. + */ void SetName(const wxString& name) { m_properties.SetProperty(wxT("name"), name); } - /// Gets the identifying name for this object. + /** + Returns the identifying name for this object from the properties, using the "name" key. + */ wxString GetName() const { return m_properties.GetPropertyString(wxT("name")); } - /// Is this object top-level, i.e. with its own paragraphs, such as a text box? + /** + Returns @true if this object is top-level, i.e. contains its own paragraphs, such as a text box. + */ virtual bool IsTopLevel() const { return false; } - /// Returns @true if the object will be shown, @false otherwise. + /** + Returns @true if the object will be shown, @false otherwise. + */ bool IsShown() const { return m_show; } // Operations - /// Call to show or hide this object. This function does not cause the content to be - /// laid out or redrawn. + /** + Call to show or hide this object. This function does not cause the content to be + laid out or redrawn. + */ virtual void Show(bool show) { m_show = show; } - /// Clone the object + /** + Clones the object. + */ virtual wxRichTextObject* Clone() const { return NULL; } - /// Copy + /** + Copies the object. + */ void Copy(const wxRichTextObject& obj); - /// Reference-counting allows us to use the same object in multiple - /// lists (not yet used) + /** + Reference-counting allows us to use the same object in multiple + lists (not yet used). + */ + void Reference() { m_refCount ++; } + + /** + Reference-counting allows us to use the same object in multiple + lists (not yet used). + */ void Dereference(); - /// Move the object recursively, by adding the offset from old to new + /** + Moves the object recursively, by adding the offset from old to new. + */ virtual void Move(const wxPoint& pt); - /// Convert units in tenths of a millimetre to device units + /** + Converts units in tenths of a millimetre to device units. + */ int ConvertTenthsMMToPixels(wxDC& dc, int units) const; + + /** + Converts units in tenths of a millimetre to device units. + */ static int ConvertTenthsMMToPixels(int ppi, int units, double scale = 1.0); - /// Convert units in pixels to tenths of a millimetre + /** + Convert units in pixels to tenths of a millimetre. + */ int ConvertPixelsToTenthsMM(wxDC& dc, int pixels) const; + + /** + Convert units in pixels to tenths of a millimetre. + */ static int ConvertPixelsToTenthsMM(int ppi, int pixels, double scale = 1.0); - /// Draw the borders and background for the given rectangle and attributes. - /// Width and height are taken to be the outer margin size, not the content. + /** + Draws the borders and background for the given rectangle and attributes. + @a boxRect is taken to be the outer margin box, not the box around the content. + */ static bool DrawBoxAttributes(wxDC& dc, wxRichTextBuffer* buffer, const wxRichTextAttr& attr, const wxRect& boxRect, int flags = 0); - /// Draw a border + /** + Draws a border. + */ static bool DrawBorder(wxDC& dc, wxRichTextBuffer* buffer, const wxTextAttrBorders& attr, const wxRect& rect, int flags = 0); - /// Get the various rectangles of the box model in pixels. You can either specify contentRect (inner) - /// or marginRect (outer), and the other must be the default rectangle (no width or height). - /// Note that the outline doesn't affect the position of the rectangle, it's drawn in whatever space - /// is available. + /** + Returns the various rectangles of the box model in pixels. You can either specify @a contentRect (inner) + or @a marginRect (outer), and the other must be the default rectangle (no width or height). + Note that the outline doesn't affect the position of the rectangle, it's drawn in whatever space + is available. + */ static bool GetBoxRects(wxDC& dc, wxRichTextBuffer* buffer, const wxRichTextAttr& attr, wxRect& marginRect, wxRect& borderRect, wxRect& contentRect, wxRect& paddingRect, wxRect& outlineRect); - /// Get the total margin for the object in pixels, taking into account margin, padding and border size + /** + Returns the total margin for the object in pixels, taking into account margin, padding and border size. + */ static bool GetTotalMargin(wxDC& dc, wxRichTextBuffer* buffer, const wxRichTextAttr& attr, int& leftMargin, int& rightMargin, int& topMargin, int& bottomMargin); - /// Returns the rectangle which the child has available to it given restrictions specified in the - /// child attribute, e.g. 50% width of the parent, 400 pixels, x position 20% of the parent, etc. + /** + Returns the rectangle which the child has available to it given restrictions specified in the + child attribute, e.g. 50% width of the parent, 400 pixels, x position 20% of the parent, etc. + */ static wxRect AdjustAvailableSpace(wxDC& dc, wxRichTextBuffer* buffer, const wxRichTextAttr& parentAttr, const wxRichTextAttr& childAttr, const wxRect& availableParentSpace); protected: @@ -2221,25 +2484,31 @@ protected: bool m_show; wxRichTextObject* m_parent; - /// The range of this object (start position to end position) + // The range of this object (start position to end position) wxRichTextRange m_range; - /// The internal range of this object, if it's a top-level object with its own range space + // The internal range of this object, if it's a top-level object with its own range space wxRichTextRange m_ownRange; - /// Attributes + // Attributes wxRichTextAttr m_attributes; - /// Properties + // Properties wxRichTextProperties m_properties; }; WX_DECLARE_LIST_WITH_DECL( wxRichTextObject, wxRichTextObjectList, class WXDLLIMPEXP_RICHTEXT ); -/*! - * wxRichTextCompositeObject class declaration - * Objects of this class can contain other objects. - */ +/** + @class wxRichTextCompositeObject + + Objects of this class can contain other objects. + + @library{wxrichtext} + @category{richtext} + + @see wxRichTextObject, wxRichTextBuffer, wxRichTextCtrl +*/ class WXDLLIMPEXP_RICHTEXT wxRichTextCompositeObject: public wxRichTextObject { @@ -2329,10 +2598,16 @@ protected: wxRichTextObjectList m_children; }; -/*! - * wxRichTextParagraphBox class declaration - * This box knows how to lay out paragraphs. - */ +/** + @class wxRichTextParagraphBox + + This class knows how to lay out paragraphs. + + @library{wxrichtext} + @category{richtext} + + @see wxRichTextCompositeObject, wxRichTextObject, wxRichTextBuffer, wxRichTextCtrl +*/ class WXDLLIMPEXP_RICHTEXT wxRichTextParagraphLayoutBox: public wxRichTextCompositeObject { @@ -2654,8 +2929,13 @@ protected: /** @class wxRichTextBox - wxRichTextBox is a floating or inline text box, containing paragraphs. - */ + This class implements a floating or inline text box, containing paragraphs. + + @library{wxrichtext} + @category{richtext} + + @see wxRichTextParagraphLayoutBox, wxRichTextObject, wxRichTextBuffer, wxRichTextCtrl +*/ class WXDLLIMPEXP_RICHTEXT wxRichTextBox: public wxRichTextParagraphLayoutBox { @@ -2715,12 +2995,18 @@ public: protected: }; -/*! - * wxRichTextLine class declaration - * This object represents a line in a paragraph, and stores - * offsets from the start of the paragraph representing the - * start and end positions of the line. - */ +/** + @class wxRichTextLine + + This object represents a line in a paragraph, and stores + offsets from the start of the paragraph representing the + start and end positions of the line. + + @library{wxrichtext} + @category{richtext} + + @see wxRichTextBuffer, wxRichTextCtrl +*/ class WXDLLIMPEXP_RICHTEXT wxRichTextLine { @@ -2806,10 +3092,16 @@ protected: WX_DECLARE_LIST_WITH_DECL( wxRichTextLine, wxRichTextLineList , class WXDLLIMPEXP_RICHTEXT ); -/*! - * wxRichTextParagraph class declaration - * This object represents a single paragraph (or in a straight text editor, a line). - */ +/** + @class wxRichTextParagraph + + This object represents a single paragraph containing various objects such as text content, images, and further paragraph layout objects. + + @library{wxrichtext} + @category{richtext} + + @see wxRichTextBuffer, wxRichTextCtrl +*/ class WXDLLIMPEXP_RICHTEXT wxRichTextParagraph: public wxRichTextCompositeObject { @@ -2933,10 +3225,16 @@ protected: friend class wxRichTextFloatCollector; }; -/*! - * wxRichTextPlainText class declaration - * This object represents a single piece of text. - */ +/** + @class wxRichTextPlainText + + This object represents a single piece of text. + + @library{wxrichtext} + @category{richtext} + + @see wxRichTextBuffer, wxRichTextCtrl +*/ class WXDLLIMPEXP_RICHTEXT wxRichTextPlainText: public wxRichTextObject { @@ -3031,12 +3329,16 @@ protected: wxString m_text; }; -/*! - * wxRichTextImageBlock stores information about an image, in binary in-memory form - */ +/** + @class wxRichTextImageBlock -class WXDLLIMPEXP_FWD_BASE wxDataInputStream; -class WXDLLIMPEXP_FWD_BASE wxDataOutputStream; + This class stores information about an image, in binary in-memory form. + + @library{wxrichtext} + @category{richtext} + + @see wxRichTextBuffer, wxRichTextCtrl +*/ class WXDLLIMPEXP_RICHTEXT wxRichTextImageBlock: public wxObject { @@ -3120,10 +3422,16 @@ protected: wxBitmapType m_imageType; }; -/*! - * wxRichTextImage class declaration - * This object represents an image. - */ +/** + @class wxRichTextImage + + This class implements a graphic object. + + @library{wxrichtext} + @category{richtext} + + @see wxRichTextBuffer, wxRichTextCtrl, wxRichTextImageBlock +*/ class WXDLLIMPEXP_RICHTEXT wxRichTextImage: public wxRichTextObject { @@ -3218,15 +3526,20 @@ protected: wxBitmap m_imageCache; }; - -/*! - * wxRichTextBuffer class declaration - * This is a kind of box, used to represent the whole buffer - */ - class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextCommand; class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextAction; +/** + @class wxRichTextBuffer + + This is a kind of paragraph layout box, used to represent the whole buffer. + + @library{wxrichtext} + @category{richtext} + + @see wxRichTextParagraphLayoutBox, wxRichTextCtrl +*/ + class WXDLLIMPEXP_RICHTEXT wxRichTextBuffer: public wxRichTextParagraphLayoutBox { DECLARE_DYNAMIC_CLASS(wxRichTextBuffer) @@ -3865,13 +4178,19 @@ enum wxRichTextCommandId wxRICHTEXT_CHANGE_OBJECT }; -/*! - * A class for specifying an object anywhere in an object hierarchy, - * without using a pointer, necessary since wxRTC commands may delete - * and recreate sub-objects so physical object addresses change. An array - * of positions (one per hierarchy level) is used. - * - */ +/** + @class wxRichTextObjectAddress + + A class for specifying an object anywhere in an object hierarchy, + without using a pointer, necessary since wxRTC commands may delete + and recreate sub-objects so physical object addresses change. An array + of positions (one per hierarchy level) is used. + + @library{wxrichtext} + @category{richtext} + + @see wxRichTextCommand +*/ class WXDLLIMPEXP_RICHTEXT wxRichTextObjectAddress { @@ -3897,12 +4216,20 @@ protected: wxArrayInt m_address; }; -/*! - * Command classes for undo/redo - * - */ - class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextAction; + +/** + @class wxRichTextCommand + + Implements a command on the undo/redo stack. A wxRichTextCommand object contains one or more wxRichTextAction + objects, allowing aggregation of a number of operations into one command. + + @library{wxrichtext} + @category{richtext} + + @see wxRichTextAction +*/ + class WXDLLIMPEXP_RICHTEXT wxRichTextCommand: public wxCommand { public: @@ -3928,10 +4255,16 @@ protected: wxList m_actions; }; -/*! - * wxRichTextAction class declaration - * There can be more than one action in a command. - */ +/** + @class wxRichTextAction + + Implements a part of a command. + + @library{wxrichtext} + @category{richtext} + + @see wxRichTextCommand +*/ class WXDLLIMPEXP_RICHTEXT wxRichTextAction: public wxObject { @@ -4060,10 +4393,16 @@ protected: // in a larger document #define wxRICHTEXT_HANDLER_CONVERT_FACENAMES 0x0100 -/*! - * wxRichTextFileHandler - * Base class for file handlers - */ +/** + @class wxRichTextFileHandler + + The base class for file handlers. + + @library{wxrichtext} + @category{richtext} + + @see wxRichTextBuffer, wxRichTextCtrl +*/ class WXDLLIMPEXP_RICHTEXT wxRichTextFileHandler: public wxObject { @@ -4133,10 +4472,16 @@ protected: bool m_visible; }; -/*! - * wxRichTextPlainTextHandler - * Plain text handler - */ +/** + @class wxRichTextPlainTextHandler + + Implements saving a buffer to plain text. + + @library{wxrichtext} + @category{richtext} + + @see wxRichTextFileHandler, wxRichTextBuffer, wxRichTextCtrl +*/ class WXDLLIMPEXP_RICHTEXT wxRichTextPlainTextHandler: public wxRichTextFileHandler { @@ -4165,9 +4510,16 @@ protected: #if wxUSE_DATAOBJ -/*! - * The data object for a wxRichTextBuffer - */ +/** + @class wxRichTextBufferDataObject + + Implements a rich text data object for clipboard transfer. + + @library{wxrichtext} + @category{richtext} + + @see wxDataObjectSimple, wxRichTextBuffer, wxRichTextCtrl +*/ class WXDLLIMPEXP_RICHTEXT wxRichTextBufferDataObject: public wxDataObjectSimple { @@ -4205,9 +4557,16 @@ private: #endif -/*! - * wxRichTextRenderer isolates common drawing functionality - */ +/** + @class wxRichTextRenderer + + This class isolates some common drawing functionality. + + @library{wxrichtext} + @category{richtext} + + @see wxRichTextBuffer, wxRichTextCtrl +*/ class WXDLLIMPEXP_RICHTEXT wxRichTextRenderer: public wxObject { @@ -4228,9 +4587,16 @@ public: virtual bool EnumerateStandardBulletNames(wxArrayString& bulletNames) = 0; }; -/*! - * wxRichTextStdRenderer: standard renderer - */ +/** + @class wxRichTextStdRenderer + + The standard renderer for drawing bullets. + + @library{wxrichtext} + @category{richtext} + + @see wxRichTextRenderer, wxRichTextBuffer, wxRichTextCtrl +*/ class WXDLLIMPEXP_RICHTEXT wxRichTextStdRenderer: public wxRichTextRenderer { diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp index 687a7c701f..33e6c21b10 100644 --- a/src/richtext/richtextbuffer.cpp +++ b/src/richtext/richtextbuffer.cpp @@ -1919,7 +1919,8 @@ bool wxRichTextParagraphLayoutBox::Layout(wxDC& dc, const wxRect& rect, int styl // Assume this box only contains paragraphs wxRichTextParagraph* child = wxDynamicCast(node->GetData(), wxRichTextParagraph); - wxCHECK_MSG( child, false, wxT("Unknown object in layout") ); + // Unsure if this is needed + // wxCHECK_MSG( child, false, wxT("Unknown object in layout") ); if (child && child->IsShown()) { @@ -8630,8 +8631,6 @@ bool wxRichTextTable::Layout(wxDC& dc, const wxRect& rect, int style) wxRichTextCell* cell = GetCell(j, i); if (cell->IsShown()) { - wxASSERT(colWidths[i] > 0); - // Get max specified cell height // Don't handle percentages for height if (cell->GetAttributes().GetTextBoxAttr().GetHeight().IsValid() && cell->GetAttributes().GetTextBoxAttr().GetHeight().GetUnits() != wxTEXT_ATTR_UNITS_PERCENTAGE) diff --git a/src/richtext/richtextbulletspage.cpp b/src/richtext/richtextbulletspage.cpp index 9e0f30ea61..f6d2c4cbc1 100644 --- a/src/richtext/richtextbulletspage.cpp +++ b/src/richtext/richtextbulletspage.cpp @@ -140,6 +140,8 @@ bool wxRichTextBulletsPage::Create( wxWindow* parent, wxWindowID id, const wxPoi void wxRichTextBulletsPage::CreateControls() { + m_dontUpdate = true; + ////@begin wxRichTextBulletsPage content construction wxRichTextBulletsPage* itemRichTextDialogPage1 = this; @@ -311,6 +313,8 @@ void wxRichTextBulletsPage::CreateControls() facenames.Sort(); m_symbolFontCtrl->Append(facenames); + + m_dontUpdate = false; } /// Transfer data from/to window diff --git a/src/richtext/richtextdialogs.pjd b/src/richtext/richtextdialogs.pjd index d41fafa388..82b5a5ff9e 100644 --- a/src/richtext/richtextdialogs.pjd +++ b/src/richtext/richtextdialogs.pjd @@ -2229,14 +2229,6 @@ "wbBoxSizerProxy" "Vertical" "" - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 0 0 0 @@ -3050,7 +3042,7 @@ "" "" 2 - 4 + 0 0 0 "" @@ -4021,7 +4013,7 @@ "1" "" 2 - 3 + 30 0 0 "" @@ -10562,14 +10554,6 @@ "wbBoxSizerProxy" "Vertical" "" - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 0 0 0 @@ -11222,7 +11206,7 @@ -1 -1 -1 - 140 + 80 "Expand" "Centre" 1 @@ -13213,7 +13197,7 @@ "" "" 2 - 2 + 0 0 0 "" @@ -14047,7 +14031,7 @@ "" "" 2 - 2 + 0 0 0 "" @@ -14637,8 +14621,8 @@ 0 0 0 - 0 - 1 + 1 + 0 0 0 0 @@ -14652,7 +14636,7 @@ -1 -1 350 - 180 + 140 "Expand" "Centre" 0 @@ -15703,7 +15687,7 @@ "" "" "m_unitsW" - "px|cm" + "px|cm|percent" "px" "Units for the object width." "" @@ -15939,7 +15923,7 @@ "" "" "m_unitsH" - "px|cm" + "px|cm|percent" "px" "Units for the object height." "" diff --git a/src/richtext/richtextformatdlg.cpp b/src/richtext/richtextformatdlg.cpp index c440a7736b..d85249f47f 100644 --- a/src/richtext/richtextformatdlg.cpp +++ b/src/richtext/richtextformatdlg.cpp @@ -594,7 +594,7 @@ wxRichTextStyleDefinition* wxRichTextFormattingDialog::GetDialogStyleDefinition( void wxRichTextFormattingDialog::SetDimensionValue(wxTextAttrDimension& dim, wxTextCtrl* valueCtrl, wxComboBox* unitsCtrl, wxCheckBox* checkBox) { int unitsIdx = 0; - + if (!dim.IsValid()) { checkBox->SetValue(false); @@ -611,9 +611,14 @@ void wxRichTextFormattingDialog::SetDimensionValue(wxTextAttrDimension& dim, wxT if (dim.GetUnits() == wxTEXT_ATTR_UNITS_TENTHS_MM) { unitsIdx = 1; - float value = float(dim.GetValue()) / 10.0; + float value = float(dim.GetValue()) / 100.0; valueCtrl->SetValue(wxString::Format(wxT("%.2f"), value)); } + else if (dim.GetUnits() == wxTEXT_ATTR_UNITS_PERCENTAGE) + { + unitsIdx = 2; + valueCtrl->SetValue(wxString::Format(wxT("%d"), (int) dim.GetValue())); + } else { unitsIdx = 0; @@ -634,6 +639,8 @@ void wxRichTextFormattingDialog::GetDimensionValue(wxTextAttrDimension& dim, wxT { if (unitsCtrl->GetSelection() == 1) dim.SetUnits(wxTEXT_ATTR_UNITS_TENTHS_MM); + else if (unitsCtrl->GetSelection() == 2) + dim.SetUnits(wxTEXT_ATTR_UNITS_PERCENTAGE); else dim.SetUnits(wxTEXT_ATTR_UNITS_PIXELS); diff --git a/src/richtext/richtextindentspage.cpp b/src/richtext/richtextindentspage.cpp index 2caf0c61c0..d12d681a9f 100644 --- a/src/richtext/richtextindentspage.cpp +++ b/src/richtext/richtextindentspage.cpp @@ -201,7 +201,7 @@ void wxRichTextIndentsSpacingPage::CreateControls() itemBoxSizer20->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL, 5); - wxFlexGridSizer* itemFlexGridSizer22 = new wxFlexGridSizer(4, 2, 0, 0); + wxFlexGridSizer* itemFlexGridSizer22 = new wxFlexGridSizer(0, 2, 0, 0); itemBoxSizer20->Add(itemFlexGridSizer22, 0, wxALIGN_CENTER_VERTICAL, 5); wxStaticText* itemStaticText23 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Left:"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -279,7 +279,7 @@ void wxRichTextIndentsSpacingPage::CreateControls() itemBoxSizer39->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL, 5); - wxFlexGridSizer* itemFlexGridSizer41 = new wxFlexGridSizer(3, 2, 0, 0); + wxFlexGridSizer* itemFlexGridSizer41 = new wxFlexGridSizer(30, 2, 0, 0); itemFlexGridSizer41->AddGrowableCol(1); itemBoxSizer39->Add(itemFlexGridSizer41, 0, wxALIGN_CENTER_VERTICAL, 5); diff --git a/src/richtext/richtextliststylepage.cpp b/src/richtext/richtextliststylepage.cpp index 914334e362..ec7a360cde 100644 --- a/src/richtext/richtextliststylepage.cpp +++ b/src/richtext/richtextliststylepage.cpp @@ -212,7 +212,7 @@ void wxRichTextListStylePage::CreateControls() itemBoxSizer13->Add(itemStaticText14, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); wxArrayString m_styleListBoxStrings; - m_styleListBox = new wxListBox( itemPanel10, ID_RICHTEXTLISTSTYLEPAGE_STYLELISTBOX, wxDefaultPosition, wxSize(-1, 140), m_styleListBoxStrings, wxLB_SINGLE ); + m_styleListBox = new wxListBox( itemPanel10, ID_RICHTEXTLISTSTYLEPAGE_STYLELISTBOX, wxDefaultPosition, wxSize(-1, 80), m_styleListBoxStrings, wxLB_SINGLE ); m_styleListBox->SetHelpText(_("The available bullet styles.")); if (wxRichTextListStylePage::ShowToolTips()) m_styleListBox->SetToolTip(_("The available bullet styles.")); @@ -377,7 +377,7 @@ void wxRichTextListStylePage::CreateControls() itemBoxSizer53->Add(itemBoxSizer55, 0, wxALIGN_LEFT|wxALL, 5); itemBoxSizer55->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL, 5); - wxFlexGridSizer* itemFlexGridSizer57 = new wxFlexGridSizer(2, 2, 0, 0); + wxFlexGridSizer* itemFlexGridSizer57 = new wxFlexGridSizer(0, 2, 0, 0); itemBoxSizer55->Add(itemFlexGridSizer57, 0, wxALIGN_CENTER_VERTICAL, 5); wxStaticText* itemStaticText58 = new wxStaticText( itemPanel37, wxID_STATIC, _("&Left:"), wxDefaultPosition, wxDefaultSize, 0 ); itemFlexGridSizer57->Add(itemStaticText58, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5); @@ -428,7 +428,7 @@ void wxRichTextListStylePage::CreateControls() itemBoxSizer70->Add(itemBoxSizer72, 0, wxALIGN_LEFT|wxALL, 5); itemBoxSizer72->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL, 5); - wxFlexGridSizer* itemFlexGridSizer74 = new wxFlexGridSizer(2, 2, 0, 0); + wxFlexGridSizer* itemFlexGridSizer74 = new wxFlexGridSizer(0, 2, 0, 0); itemBoxSizer72->Add(itemFlexGridSizer74, 0, wxALIGN_CENTER_VERTICAL, 5); wxStaticText* itemStaticText75 = new wxStaticText( itemPanel37, wxID_STATIC, _("Before a paragraph:"), wxDefaultPosition, wxDefaultSize, 0 ); itemFlexGridSizer74->Add(itemStaticText75, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5); @@ -472,7 +472,7 @@ void wxRichTextListStylePage::CreateControls() itemBoxSizer3->Add(itemNotebook9, 0, wxGROW|wxALL, 5); - m_previewCtrl = new wxRichTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTLISTSTYLEPAGE_RICHTEXTCTRL, wxEmptyString, wxDefaultPosition, wxSize(350, 180), wxSUNKEN_BORDER|wxVSCROLL|wxTE_READONLY ); + m_previewCtrl = new wxRichTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTLISTSTYLEPAGE_RICHTEXTCTRL, wxEmptyString, wxDefaultPosition, wxSize(350, 140), wxBORDER_THEME|wxVSCROLL|wxTE_READONLY ); m_previewCtrl->SetHelpText(_("Shows a preview of the bullet settings.")); if (wxRichTextListStylePage::ShowToolTips()) m_previewCtrl->SetToolTip(_("Shows a preview of the bullet settings.")); diff --git a/src/richtext/richtextsizepage.cpp b/src/richtext/richtextsizepage.cpp index 665adf11fa..7cb8f2ab0e 100644 --- a/src/richtext/richtextsizepage.cpp +++ b/src/richtext/richtextsizepage.cpp @@ -216,6 +216,7 @@ void wxRichTextSizePage::CreateControls() wxArrayString m_unitsWStrings; m_unitsWStrings.Add(_("px")); m_unitsWStrings.Add(_("cm")); + m_unitsWStrings.Add(_("percent")); m_unitsW = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXT_UNITS_W, _("px"), wxDefaultPosition, wxSize(60, -1), m_unitsWStrings, wxCB_READONLY ); m_unitsW->SetStringSelection(_("px")); m_unitsW->SetHelpText(_("Units for the object width.")); @@ -242,6 +243,7 @@ void wxRichTextSizePage::CreateControls() wxArrayString m_unitsHStrings; m_unitsHStrings.Add(_("px")); m_unitsHStrings.Add(_("cm")); + m_unitsHStrings.Add(_("percent")); m_unitsH = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXT_UNITS_H, _("px"), wxDefaultPosition, wxSize(60, -1), m_unitsHStrings, wxCB_READONLY ); m_unitsH->SetStringSelection(_("px")); m_unitsH->SetHelpText(_("Units for the object height.")); diff --git a/src/richtext/richtextxml.cpp b/src/richtext/richtextxml.cpp index de049434c7..a20eb181a0 100644 --- a/src/richtext/richtextxml.cpp +++ b/src/richtext/richtextxml.cpp @@ -181,9 +181,9 @@ bool wxRichTextXMLHandler::ImportXML(wxRichTextBuffer* buffer, wxRichTextObject* { bool recurse = false; obj->ImportFromXML(buffer, node, this, & recurse); - + // TODO: how to control whether to import children. - + wxRichTextCompositeObject* compositeParent = wxDynamicCast(obj, wxRichTextCompositeObject); if (recurse && compositeParent) { @@ -221,7 +221,7 @@ bool wxRichTextXMLHandler::ImportProperties(wxRichTextObject* obj, wxXmlNode* no wxString name = propertyChild->GetAttribute(wxT("name"), wxEmptyString); wxString value = propertyChild->GetAttribute(wxT("value"), wxEmptyString); wxString type = propertyChild->GetAttribute(wxT("type"), wxEmptyString); - + wxVariant var = MakePropertyFromString(name, value, type); if (!var.IsNull()) { @@ -406,6 +406,9 @@ wxString wxRichTextXMLHandler::GetText(wxXmlNode *node, const wxString& param, b wxXmlNode* wxRichTextXMLHandler::FindNode(wxXmlNode* node, const wxString& name) { + if (node->GetName() == name && name == wxT("stylesheet")) + return node; + wxXmlNode* child = node->GetChildren(); while (child) { @@ -744,7 +747,7 @@ bool wxRichTextXMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& return false; wxString version(wxT("1.0") ) ; - + bool deleteConvFile = false; wxString fileEncoding; //wxMBConv* convFile = NULL; @@ -789,7 +792,7 @@ bool wxRichTextXMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& #endif wxXmlDocument* doc = new wxXmlDocument; doc->SetFileEncoding(fileEncoding); - + wxXmlNode* rootNode = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("richtext")); doc->SetRoot(rootNode); rootNode->AddAttribute(wxT("version"), wxT("1.0.0.0")); @@ -799,12 +802,12 @@ bool wxRichTextXMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& { wxXmlNode* styleSheetNode = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("stylesheet")); rootNode->AddChild(styleSheetNode); - + wxString nameAndDescr; - + if (!buffer->GetStyleSheet()->GetName().empty()) styleSheetNode->AddAttribute(wxT("name"), buffer->GetStyleSheet()->GetName()); - + if (!buffer->GetStyleSheet()->GetDescription().empty()) styleSheetNode->AddAttribute(wxT("description"), buffer->GetStyleSheet()->GetDescription()); @@ -943,6 +946,11 @@ bool wxRichTextXMLHandler::ExportStyleDefinition(wxOutputStream& stream, wxRichT wxRichTextListStyleDefinition* listDef = wxDynamicCast(def, wxRichTextListStyleDefinition); wxRichTextBoxStyleDefinition* boxDef = wxDynamicCast(def, wxRichTextBoxStyleDefinition); + wxString name = def->GetName(); + wxString nameProp; + if (!name.empty()) + nameProp = wxT(" name=\"") + name + wxT("\""); + wxString baseStyle = def->GetBaseStyle(); wxString baseStyleProp; if (!baseStyle.empty()) @@ -956,7 +964,7 @@ bool wxRichTextXMLHandler::ExportStyleDefinition(wxOutputStream& stream, wxRichT if (charDef) { OutputIndentation(stream, level); - OutputString(stream, wxT("")); + OutputString(stream, wxT("")); level ++; @@ -980,7 +988,7 @@ bool wxRichTextXMLHandler::ExportStyleDefinition(wxOutputStream& stream, wxRichT if (!listDef->GetNextStyle().empty()) baseStyleProp << wxT(" nextstyle=\"") << listDef->GetNextStyle() << wxT("\""); - OutputString(stream, wxT("")); + OutputString(stream, wxT("")); level ++; @@ -1021,7 +1029,7 @@ bool wxRichTextXMLHandler::ExportStyleDefinition(wxOutputStream& stream, wxRichT if (!paraDef->GetNextStyle().empty()) baseStyleProp << wxT(" nextstyle=\"") << paraDef->GetNextStyle() << wxT("\""); - OutputString(stream, wxT("")); + OutputString(stream, wxT("")); level ++; @@ -1042,7 +1050,7 @@ bool wxRichTextXMLHandler::ExportStyleDefinition(wxOutputStream& stream, wxRichT { OutputIndentation(stream, level); - OutputString(stream, wxT("")); + OutputString(stream, wxT("")); level ++; @@ -1174,15 +1182,29 @@ wxString wxRichTextXMLHandler::AddAttributes(const wxRichTextAttr& attr, bool is if (attr.HasOutlineLevel()) AddAttribute(str, wxT("outlinelevel"), (int) attr.GetOutlineLevel()); } - + AddAttribute(str, wxT("margin"), attr.GetTextBoxAttr().GetMargins()); AddAttribute(str, wxT("padding"), attr.GetTextBoxAttr().GetPadding()); AddAttribute(str, wxT("position"), attr.GetTextBoxAttr().GetPosition()); AddAttribute(str, wxT("border"), attr.GetTextBoxAttr().GetBorder()); AddAttribute(str, wxT("outline"), attr.GetTextBoxAttr().GetOutline()); AddAttribute(str, wxT("width"), attr.GetTextBoxAttr().GetWidth()); - AddAttribute(str, wxT("height"), attr.GetTextBoxAttr().GetWidth()); - + AddAttribute(str, wxT("height"), attr.GetTextBoxAttr().GetHeight()); + + if (attr.GetTextBoxAttr().HasVerticalAlignment()) + { + wxString value; + if (attr.GetTextBoxAttr().GetVerticalAlignment() == wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_TOP) + value = wxT("top"); + else if (attr.GetTextBoxAttr().GetVerticalAlignment() == wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_CENTRE) + value = wxT("centre"); + else if (attr.GetTextBoxAttr().GetVerticalAlignment() == wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_BOTTOM) + value = wxT("bottom"); + else + value = wxT("none"); + AddAttribute(str, wxT("verticalalignment"), value); + } + if (attr.GetTextBoxAttr().HasFloatMode()) { wxString value; @@ -1246,7 +1268,7 @@ bool wxRichTextXMLHandler::WriteProperties(wxOutputStream& stream, const wxRichT { const wxVariant& var = properties[i]; if (!var.IsNull()) - { + { const wxString& name = var.GetName(); wxString value = MakeStringFromProperty(var); @@ -1290,17 +1312,17 @@ bool wxRichTextXMLHandler::ExportStyleDefinition(wxXmlNode* parent, wxRichTextSt wxString baseStyle = def->GetBaseStyle(); wxString descr = def->GetDescription(); - + wxXmlNode* defNode = new wxXmlNode(wxXML_ELEMENT_NODE, wxEmptyString); parent->AddChild(defNode); if (!baseStyle.empty()) defNode->AddAttribute(wxT("basestyle"), baseStyle); if (!descr.empty()) defNode->AddAttribute(wxT("description"), descr); - + wxXmlNode* styleNode = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("style")); defNode->AddChild(styleNode); - + if (charDef) { defNode->SetName(wxT("characterstyle")); @@ -1455,7 +1477,21 @@ bool wxRichTextXMLHandler::AddAttributes(wxXmlNode* node, wxRichTextAttr& attr, AddAttribute(node, wxT("border"), attr.GetTextBoxAttr().GetBorder()); AddAttribute(node, wxT("outline"), attr.GetTextBoxAttr().GetOutline()); AddAttribute(node, wxT("width"), attr.GetTextBoxAttr().GetWidth()); - AddAttribute(node, wxT("height"), attr.GetTextBoxAttr().GetWidth()); + AddAttribute(node, wxT("height"), attr.GetTextBoxAttr().GetHeight()); + + if (attr.GetTextBoxAttr().HasVerticalAlignment()) + { + wxString value; + if (attr.GetTextBoxAttr().GetVerticalAlignment() == wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_TOP) + value = wxT("top"); + else if (attr.GetTextBoxAttr().GetVerticalAlignment() == wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_CENTRE) + value = wxT("centre"); + else if (attr.GetTextBoxAttr().GetVerticalAlignment() == wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_BOTTOM) + value = wxT("bottom"); + else + value = wxT("none"); + AddAttribute(node, wxT("verticalalignment"), value); + } if (attr.GetTextBoxAttr().HasFloatMode()) { @@ -1815,6 +1851,17 @@ bool wxRichTextXMLHandler::ImportStyle(wxRichTextAttr& attr, wxXmlNode* node, bo attr.GetTextBoxAttr().GetHeight().SetValue(wxRichTextParseDimension(value)); } + else if (name == wxT("verticalalignment")) + { + if (value == wxT("top")) + attr.GetTextBoxAttr().SetVerticalAlignment(wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_TOP); + else if (value == wxT("centre")) + attr.GetTextBoxAttr().SetVerticalAlignment(wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_CENTRE); + else if (value == wxT("bottom")) + attr.GetTextBoxAttr().SetVerticalAlignment(wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_BOTTOM); + else if (value == wxT("none")) + attr.GetTextBoxAttr().SetVerticalAlignment(wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_NONE); + } else if (name == wxT("float")) { if (value == wxT("left")) @@ -1930,7 +1977,7 @@ bool wxRichTextXMLHandler::ImportStyle(wxRichTextAttr& attr, wxXmlNode* node, bo attr.GetTextBoxAttr().GetPosition().GetBottom().SetValue(wxRichTextParseDimension(value)); } } - + xmlAttr = xmlAttr->GetNext(); } @@ -1945,7 +1992,7 @@ bool wxRichTextObject::ImportFromXML(wxRichTextBuffer* WXUNUSED(buffer), wxXmlNo { handler->ImportProperties(this, node); handler->ImportStyle(GetAttributes(), node, UsesParagraphAttributes()); - + *recurse = true; return true; @@ -1966,7 +2013,7 @@ bool wxRichTextObject::ExportXML(wxOutputStream& stream, int indent, wxRichTextX { handler->WriteProperties(stream, GetProperties(), indent); } - + wxRichTextCompositeObject* composite = wxDynamicCast(this, wxRichTextCompositeObject); if (composite) { @@ -2012,7 +2059,7 @@ bool wxRichTextObject::ExportXML(wxXmlNode* parent, wxRichTextXMLHandler* handle bool wxRichTextPlainText::ImportFromXML(wxRichTextBuffer* buffer, wxXmlNode* node, wxRichTextXMLHandler* handler, bool* recurse) { wxRichTextObject::ImportFromXML(buffer, node, handler, recurse); - + if (node->GetName() == wxT("text")) { wxString text; @@ -2037,7 +2084,7 @@ bool wxRichTextPlainText::ImportFromXML(wxRichTextBuffer* buffer, wxXmlNode* nod } textChild = textChild->GetNext(); } - + SetText(text); } else if (node->GetName() == wxT("symbol")) @@ -2158,7 +2205,7 @@ bool wxRichTextPlainText::ExportXML(wxOutputStream& stream, int indent, wxRichTe ::OutputString(stream, wxT("GetConvMem(), handler->GetConvFile()); ::OutputString(stream, style + wxT(">"), handler->GetConvMem(), handler->GetConvFile()); - + if (GetProperties().GetCount() > 0) { handler->WriteProperties(stream, GetProperties(), indent); @@ -2218,7 +2265,7 @@ bool wxRichTextPlainText::ExportXML(wxXmlNode* parent, wxRichTextXMLHandler* han parent->AddChild(elementNode); handler->AddAttributes(elementNode, GetAttributes(), false); handler->WriteProperties(elementNode, GetProperties()); - + wxXmlNode* textNode = new wxXmlNode(wxXML_TEXT_NODE, wxT("text")); elementNode->AddChild(textNode); @@ -2232,7 +2279,7 @@ bool wxRichTextPlainText::ExportXML(wxXmlNode* parent, wxRichTextXMLHandler* han // Output this character as a number in a separate tag, because XML can't cope // with entities below 32 except for 10 and 13 - + wxXmlNode* elementNode = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("symbol")); parent->AddChild(elementNode); @@ -2258,14 +2305,14 @@ bool wxRichTextPlainText::ExportXML(wxXmlNode* parent, wxRichTextXMLHandler* han wxXmlNode* elementNode = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("text")); parent->AddChild(elementNode); handler->AddAttributes(elementNode, GetAttributes(), false); - + wxXmlNode* textNode = new wxXmlNode(wxXML_TEXT_NODE, wxT("text")); elementNode->AddChild(textNode); if (fragment[0] == wxT(' ') || fragment[fragment.length()-1] == wxT(' ')) fragment = wxT("\"") + fragment + wxT("\""); - textNode->SetContent(fragment); + textNode->SetContent(fragment); } return true; } @@ -2319,7 +2366,7 @@ bool wxRichTextImage::ImportFromXML(wxRichTextBuffer* buffer, wxXmlNode* node, w wxStringInputStream strStream(data); GetImageBlock().ReadHex(strStream, data.length(), imageType); - + return true; } else @@ -2384,7 +2431,7 @@ bool wxRichTextImage::ExportXML(wxXmlNode* parent, wxRichTextXMLHandler* handler dataNode->AddChild(textNode); wxString strData; -#if 1 +#if 1 { wxMemoryOutputStream stream; if (GetImageBlock().WriteHex(stream)) @@ -2404,12 +2451,12 @@ bool wxRichTextImage::ExportXML(wxXmlNode* parent, wxRichTextXMLHandler* handler else strData = wxEmptyString; } - + } #else { wxStringOutputStream strStream(& strData); - GetImageBlock().WriteHex(strStream); + GetImageBlock().WriteHex(strStream); } #endif @@ -2425,7 +2472,7 @@ bool wxRichTextImage::ExportXML(wxXmlNode* parent, wxRichTextXMLHandler* handler bool wxRichTextParagraphLayoutBox::ImportFromXML(wxRichTextBuffer* buffer, wxXmlNode* node, wxRichTextXMLHandler* handler, bool* recurse) { wxRichTextObject::ImportFromXML(buffer, node, handler, recurse); - + *recurse = true; wxString partial = node->GetAttribute(wxT("partialparagraph"), wxEmptyString); @@ -2477,7 +2524,7 @@ bool wxRichTextParagraphLayoutBox::ExportXML(wxOutputStream& stream, int indent, { handler->WriteProperties(stream, GetProperties(), indent); } - + size_t i; for (i = 0; i < GetChildCount(); i++) { @@ -2518,12 +2565,12 @@ bool wxRichTextParagraphLayoutBox::ExportXML(wxXmlNode* parent, wxRichTextXMLHan bool wxRichTextTable::ImportFromXML(wxRichTextBuffer* buffer, wxXmlNode* node, wxRichTextXMLHandler* handler, bool* recurse) { wxRichTextBox::ImportFromXML(buffer, node, handler, recurse); - + *recurse = false; m_rowCount = wxAtoi(node->GetAttribute(wxT("rows"), wxEmptyString)); m_colCount = wxAtoi(node->GetAttribute(wxT("cols"), wxEmptyString)); - + wxXmlNode* child = node->GetChildren(); while (child) { @@ -2575,7 +2622,7 @@ bool wxRichTextTable::ExportXML(wxOutputStream& stream, int indent, wxRichTextXM { handler->WriteProperties(stream, GetProperties(), indent); } - + int i, j; for (i = 0; i < m_rowCount; i++) { -- 2.47.2