From 7fe8059f5825e58af0864e5933e43e5f0526bc76 Mon Sep 17 00:00:00 2001 From: =?utf8?q?W=C5=82odzimierz=20Skiba?= Date: Wed, 19 Oct 2005 17:00:58 +0000 Subject: [PATCH] const consistent for Clone(). Load/Save split to DoLoad/DoSave. Build fixes, warning fixes and other source cleaning. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35953 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/richtext/richtextbuffer.h | 63 +++--- include/wx/richtext/richtextctrl.h | 14 +- include/wx/richtext/richtextxml.h | 14 +- src/richtext/richtextbuffer.cpp | 325 ++++++++++++++------------- src/richtext/richtextctrl.cpp | 115 +++++----- src/richtext/richtextxml.cpp | 106 +++++---- 6 files changed, 318 insertions(+), 319 deletions(-) diff --git a/include/wx/richtext/richtextbuffer.h b/include/wx/richtext/richtextbuffer.h index f0b9a90dac..30db130e42 100644 --- a/include/wx/richtext/richtextbuffer.h +++ b/include/wx/richtext/richtextbuffer.h @@ -1,10 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: richtextbuffer.h +// Name: wx/richtext/richtextbuffer.h // Purpose: Buffer for wxRichTextCtrl // Author: Julian Smart -// Modified by: +// Modified by: // Created: 2005-09-30 -// RCS-ID: +// RCS-ID: $Id$ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -81,7 +81,7 @@ it can report a partial size, so that wrapping can be implemented, hit test calculations performed, etc. So GetRangeSize must be implemented for each object. - + */ #ifndef _WX_RICHTEXTBUFFER_H_ @@ -511,7 +511,7 @@ public: /// 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; + virtual bool Layout(wxDC& dc, const wxRect& rect, const wxRichTextRange& affected, int style) = 0; /// Hit-testing: returns a flag indicating hit test details, plus /// information about position @@ -743,7 +743,7 @@ public: virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& rect, int descent, int style); /// Lay the item out - virtual bool Layout(wxDC& dc, const wxRect& rect, int style); + virtual bool Layout(wxDC& dc, const wxRect& rect, const wxRichTextRange& affected, int style); /// Get/set the object size for the given range. Returns false if the range /// is invalid for this object. @@ -782,7 +782,7 @@ public: virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& rect, int descent, int style); /// Lay the item out - virtual bool Layout(wxDC& dc, const wxRect& rect, int style); + virtual bool Layout(wxDC& dc, const wxRect& rect, const wxRichTextRange& affected, int style); /// Get/set the object size for the given range. Returns false if the range /// is invalid for this object. @@ -850,10 +850,10 @@ public: virtual wxRichTextObject* GetLeafObjectAtPosition(long position) const; /// Get the paragraph by number - virtual wxRichTextParagraph* GetParagraphAtLine(long paragraphNumber) const; + virtual wxRichTextParagraph* GetParagraphAtLine(long paragraphNumber) const; /// Get the paragraph for a given line - virtual wxRichTextParagraph* GetParagraphForLine(wxRichTextLine* line) const; + virtual wxRichTextParagraph* GetParagraphForLine(wxRichTextLine* line) const; /// Get the length of the paragraph virtual int GetParagraphLength(long paragraphNumber) const; @@ -909,9 +909,6 @@ public: /// Copy void Copy(const wxRichTextParagraphLayoutBox& obj); - /// Clone - virtual wxRichTextObject* Clone() { return new wxRichTextParagraphLayoutBox(*this); } - /// Calculate ranges virtual void UpdateRanges() { long end; CalculateRange(0, end); } @@ -969,7 +966,7 @@ public: void Copy(const wxRichTextFragment& obj); /// Clone - virtual wxRichTextObject* Clone() { return new wxRichTextFragment(*this); } + virtual wxRichTextObject* Clone() const { return new wxRichTextFragment(*this); } protected: @@ -1077,7 +1074,7 @@ public: virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& rect, int descent, int style); /// Lay the item out - virtual bool Layout(wxDC& dc, const wxRect& rect, int style); + virtual bool Layout(wxDC& dc, const wxRect& rect, const wxRichTextRange& affected, int style); /// Get/set the object size for the given range. Returns false if the range /// is invalid for this object. @@ -1166,7 +1163,7 @@ public: virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& rect, int descent, int style); /// Lay the item out - virtual bool Layout(wxDC& dc, const wxRect& rect, int style); + virtual bool Layout(wxDC& dc, const wxRect& rect, const wxRichTextRange& affected, int style); /// Get/set the object size for the given range. Returns false if the range /// is invalid for this object. @@ -1186,7 +1183,7 @@ public: virtual bool DeleteRange(const wxRichTextRange& range); /// Returns true if the object is empty - virtual bool IsEmpty() const { return m_text.IsEmpty(); } + virtual bool IsEmpty() const { return m_text.empty(); } /// Returns true if this object can merge itself with the given one. virtual bool CanMerge(wxRichTextObject* object) const; @@ -1240,7 +1237,7 @@ public: // to conserve space. // If it's not a JPEG we can make use of 'image', already scaled, so we don't have to // load the image a 2nd time. - virtual bool MakeImageBlock(const wxString& filename, int imageType, wxImage& image, bool convertToJPEG = TRUE); + virtual bool MakeImageBlock(const wxString& filename, int imageType, wxImage& image, bool convertToJPEG = true); // Make an image block from the wxImage in the given // format. @@ -1319,7 +1316,7 @@ public: virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& rect, int descent, int style); /// Lay the item out - virtual bool Layout(wxDC& dc, const wxRect& rect, int style); + virtual bool Layout(wxDC& dc, const wxRect& rect, const wxRichTextRange& affected, int style); /// Get the object size for the given range. Returns false if the range /// is invalid for this object. @@ -1671,7 +1668,7 @@ class WXDLLIMPEXP_ADV wxRichTextCommand: public wxCommand public: // Ctor for one action wxRichTextCommand(const wxString& name, wxRichTextCommandId id, wxRichTextBuffer* buffer, - wxRichTextCtrl* ctrl, bool ignoreFirstTime = FALSE); + wxRichTextCtrl* ctrl, bool ignoreFirstTime = false); // Ctor for multiple actions wxRichTextCommand(const wxString& name); @@ -1700,7 +1697,7 @@ class WXDLLIMPEXP_ADV wxRichTextAction: public wxObject { public: wxRichTextAction(wxRichTextCommand* cmd, const wxString& name, wxRichTextCommandId id, wxRichTextBuffer* buffer, - wxRichTextCtrl* ctrl, bool ignoreFirstTime = FALSE); + wxRichTextCtrl* ctrl, bool ignoreFirstTime = false); ~wxRichTextAction(); @@ -1771,12 +1768,14 @@ public: { } #if wxUSE_STREAMS - virtual bool LoadFile(wxRichTextBuffer *buffer, wxInputStream& stream) = 0; - virtual bool SaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream) = 0; + bool LoadFile(wxRichTextBuffer *buffer, wxInputStream& stream) + { return DoLoadFile(buffer, stream); } + bool SaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream) + { return DoSaveFile(buffer, stream); } #endif - virtual bool LoadFile(wxRichTextBuffer *buffer, const wxString& filename); - virtual bool SaveFile(wxRichTextBuffer *buffer, const wxString& filename); + bool LoadFile(wxRichTextBuffer *buffer, const wxString& filename); + bool SaveFile(wxRichTextBuffer *buffer, const wxString& filename); /// Can we handle this filename (if using files)? By default, checks the extension. virtual bool CanHandle(const wxString& filename) const; @@ -1802,6 +1801,11 @@ public: protected: +#if wxUSE_STREAMS + virtual bool DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& stream) = 0; + virtual bool DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream) = 0; +#endif + wxString m_name; wxString m_extension; int m_type; @@ -1821,11 +1825,6 @@ public: : wxRichTextFileHandler(name, ext, type) { } -#if wxUSE_STREAMS - virtual bool LoadFile(wxRichTextBuffer *buffer, wxInputStream& stream); - virtual bool SaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream); -#endif - /// Can we save using this handler? virtual bool CanSave() const { return true; } @@ -1834,6 +1833,11 @@ public: protected: +#if wxUSE_STREAMS + virtual bool DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& stream); + virtual bool DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream); +#endif + }; /*! @@ -1865,4 +1869,3 @@ bool wxRichTextApplyStyle(wxTextAttrEx& destStyle, const wxRichTextAttr& style); #endif // _WX_RICHTEXTBUFFER_H_ - diff --git a/include/wx/richtext/richtextctrl.h b/include/wx/richtext/richtextctrl.h index aebc1a60b3..a1e9c69772 100644 --- a/include/wx/richtext/richtextctrl.h +++ b/include/wx/richtext/richtextctrl.h @@ -1,10 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: richtextctrl.h +// Name: wx/richtext/richtextctrl.h // Purpose: A rich edit control // Author: Julian Smart -// Modified by: +// Modified by: // Created: 2005-09-30 -// RCS-ID: +// RCS-ID: $Id$ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -84,7 +84,7 @@ class WXDLLIMPEXP_ADV wxRichTextCtrl: #else public wxScrolledWindow #endif -{ +{ DECLARE_CLASS( wxRichTextCtrl ) DECLARE_EVENT_TABLE() @@ -520,7 +520,7 @@ public: // Show a context menu for Rich Edit controls (the standard // EDIT control has one already) void OnContextMenu(wxContextMenuEvent& event); - + // Event handlers /// Painting @@ -568,7 +568,7 @@ public: /// Paint the background virtual void PaintBackground(wxDC& dc); - + /// Recreate buffer bitmap if necessary virtual bool RecreateBuffer(const wxSize& size = wxDefaultSize); @@ -652,7 +652,7 @@ public: // Data members private: - /// Allows nested Freeze/Thaw + /// Allows nested Freeze/Thaw int m_freezeCount; /// Buffer bitmap diff --git a/include/wx/richtext/richtextxml.h b/include/wx/richtext/richtextxml.h index be318f9f3a..c83df66146 100644 --- a/include/wx/richtext/richtextxml.h +++ b/include/wx/richtext/richtextxml.h @@ -1,10 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: richeditxml.h +// Name: wx/richtext/richeditxml.h // Purpose: XML and HTML I/O for wxRichTextCtrl // Author: Julian Smart -// Modified by: +// Modified by: // Created: 2005-09-30 -// RCS-ID: +// RCS-ID: $Id$ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -37,8 +37,8 @@ public: { } #if wxUSE_STREAMS - virtual bool LoadFile(wxRichTextBuffer *buffer, wxInputStream& stream); - virtual bool SaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream); + virtual bool DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& stream); + virtual bool DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream); /// Recursively export an object bool ExportXML(wxOutputStream& stream, wxMBConv* convMem, wxMBConv* convFile, wxRichTextObject& obj, int level); @@ -84,8 +84,8 @@ public: { } #if wxUSE_STREAMS - virtual bool LoadFile(wxRichTextBuffer *buffer, wxInputStream& stream); - virtual bool SaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream); + virtual bool DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& stream); + virtual bool DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream); #endif /// Can we save using this handler? diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp index e6de20bf16..0108f3728e 100644 --- a/src/richtext/richtextbuffer.cpp +++ b/src/richtext/richtextbuffer.cpp @@ -1,10 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: richtextbuffer.cpp +// Name: richtext/richtextbuffer.cpp // Purpose: Buffer for wxRichTextCtrl // Author: Julian Smart -// Modified by: +// Modified by: // Created: 2005-09-30 -// RCS-ID: +// RCS-ID: $Id$ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -293,12 +293,12 @@ void wxRichTextCompositeObject::CalculateRange(long start, long& end) bool wxRichTextCompositeObject::DeleteRange(const wxRichTextRange& range) { wxRichTextObjectList::compatibility_iterator node = m_children.GetFirst(); - + while (node) { wxRichTextObject* obj = (wxRichTextObject*) node->GetData(); wxRichTextObjectList::compatibility_iterator next = node->GetNext(); - + // Delete the range in each paragraph // When a chunk has been deleted, internally the content does not @@ -307,7 +307,7 @@ bool wxRichTextCompositeObject::DeleteRange(const wxRichTextRange& range) // If you may delete content from the same object twice, recalculate // the ranges inbetween DeleteRange calls by calling CalculateRanges, and // adjust the range you're deleting accordingly. - + if (!obj->GetRange().IsOutside(range)) { obj->DeleteRange(range); @@ -318,13 +318,13 @@ bool wxRichTextCompositeObject::DeleteRange(const wxRichTextRange& range) { // An empty paragraph has length 1, so won't be deleted unless the // whole range is deleted. - RemoveChild(obj, true); + RemoveChild(obj, true); } } - + node = next; } - + return true; } @@ -340,9 +340,9 @@ wxString wxRichTextCompositeObject::GetTextForRange(const wxRichTextRange& range if (!child->GetRange().IsOutside(range)) { childRange.LimitTo(child->GetRange()); - + wxString childText = child->GetTextForRange(childRange); - + text += childText; } node = node->GetNext(); @@ -359,7 +359,7 @@ bool wxRichTextCompositeObject::Defragment() { wxRichTextObject* child = node->GetData(); wxRichTextCompositeObject* composite = wxDynamicCast(child, wxRichTextCompositeObject); - if (composite) + if (composite) composite->Defragment(); if (node->GetNext()) @@ -494,11 +494,11 @@ bool wxRichTextParagraphLayoutBox::Draw(wxDC& dc, const wxRichTextRange& range, { wxRichTextParagraph* child = wxDynamicCast(node->GetData(), wxRichTextParagraph); wxASSERT (child != NULL); - + if (child && !child->GetRange().IsOutside(range)) { wxRect childRect(child->GetPosition(), child->GetCachedSize()); - + if (childRect.GetTop() > rect.GetBottom() || childRect.GetBottom() < rect.GetTop()) { // Skip @@ -521,9 +521,9 @@ bool wxRichTextParagraphLayoutBox::Layout(wxDC& dc, const wxRect& rect, const wx rect.height - m_topMargin - m_bottomMargin); int maxWidth = 0; - + wxRichTextObjectList::compatibility_iterator node = m_children.GetFirst(); - + // If we know what range is affected, start laying out from that point on. if (affected.GetStart() > GetRange().GetStart()) { @@ -536,7 +536,7 @@ bool wxRichTextParagraphLayoutBox::Layout(wxDC& dc, const wxRect& rect, const wx { wxRichTextParagraph* previousParagraph = wxDynamicCast(previousNode->GetData(), wxRichTextParagraph); availableSpace.y = previousParagraph->GetPosition().y + previousParagraph->GetCachedSize().y; - + // Now we're going to start iterating from the first affected paragraph. node = firstNode; } @@ -549,7 +549,7 @@ bool wxRichTextParagraphLayoutBox::Layout(wxDC& dc, const wxRect& rect, const wx wxRichTextParagraph* child = wxDynamicCast(node->GetData(), wxRichTextParagraph); wxASSERT (child != NULL); - + if (child && !child->GetRange().IsOutside(affected)) { child->Layout(dc, availableSpace, affected, style); @@ -564,9 +564,9 @@ bool wxRichTextParagraphLayoutBox::Layout(wxDC& dc, const wxRect& rect, const wx // move everything up or down. This assumes that all the children have previously // been laid out and have wrapped line lists associated with them. // TODO: check all paragraphs before the affected range. - + int inc = availableSpace.y - child->GetPosition().y; - + while (node) { wxRichTextParagraph* child = wxDynamicCast(node->GetData(), wxRichTextParagraph); @@ -576,12 +576,12 @@ bool wxRichTextParagraphLayoutBox::Layout(wxDC& dc, const wxRect& rect, const wx child->Layout(dc, availableSpace, affected, style); else child->SetPosition(wxPoint(child->GetPosition().x, child->GetPosition().y + inc)); - + availableSpace.y += child->GetCachedSize().y; maxWidth = wxMax(maxWidth, child->GetCachedSize().x); } - - node = node->GetNext(); + + node = node->GetNext(); } break; } @@ -728,7 +728,7 @@ wxRichTextLine* wxRichTextParagraphLayoutBox::GetLineAtPosition(long pos, bool c return line; node2 = node2->GetNext(); - } + } node = node->GetNext(); } @@ -760,7 +760,7 @@ wxRichTextLine* wxRichTextParagraphLayoutBox::GetLineAtYPosition(int y) const return line; node2 = node2->GetNext(); - } + } node = node->GetNext(); } @@ -870,7 +870,7 @@ wxRichTextRange wxRichTextParagraphLayoutBox::AddParagraphs(const wxString& text i ++; } - if (!line.IsEmpty()) + if (!line.empty()) { lastPara = new wxRichTextParagraph(line, this, & style); //wxLogDebug("Para Face = %s", lastPara->GetAttributes().GetFont().GetFaceName()); @@ -952,7 +952,7 @@ bool wxRichTextParagraphLayoutBox::InsertFragment(long position, wxRichTextFragm while (objectNode) { wxRichTextObject* newObj = objectNode->GetData()->Clone(); - + if (!nextObject) { // Append @@ -963,7 +963,7 @@ bool wxRichTextParagraphLayoutBox::InsertFragment(long position, wxRichTextFragm // Insert before nextObject para->InsertChild(newObj, nextObject); } - + objectNode = objectNode->GetNext(); } @@ -999,10 +999,10 @@ bool wxRichTextParagraphLayoutBox::InsertFragment(long position, wxRichTextFragm while (objectNode) { wxRichTextObject* newObj = objectNode->GetData()->Clone(); - + // Append para->AppendChild(newObj); - + objectNode = objectNode->GetNext(); } @@ -1028,7 +1028,7 @@ bool wxRichTextParagraphLayoutBox::InsertFragment(long position, wxRichTextFragm if (nextParagraph) InsertChild(finalPara, nextParagraph); else - AppendChild(finalPara); + AppendChild(finalPara); } else while (i) { @@ -1041,7 +1041,7 @@ bool wxRichTextParagraphLayoutBox::InsertFragment(long position, wxRichTextFragm InsertChild(finalPara, nextParagraph); else AppendChild(finalPara); - + i = i->GetNext(); } @@ -1053,7 +1053,7 @@ bool wxRichTextParagraphLayoutBox::InsertFragment(long position, wxRichTextFragm // Ensure there's at least one object if (finalPara->GetChildCount() == 0) { - wxRichTextPlainText* text = new wxRichTextPlainText(wxT("")); + wxRichTextPlainText* text = new wxRichTextPlainText(wxEmptyString); text->SetAttributes(finalPara->GetAttributes()); finalPara->AppendChild(text); @@ -1071,9 +1071,9 @@ bool wxRichTextParagraphLayoutBox::InsertFragment(long position, wxRichTextFragm { wxRichTextParagraph* para = wxDynamicCast(i->GetData(), wxRichTextParagraph); wxASSERT( para != NULL ); - + AppendChild(para->Clone()); - + i = i->GetNext(); } @@ -1096,7 +1096,7 @@ bool wxRichTextParagraphLayoutBox::CopyFragment(const wxRichTextRange& range, wx if (!para->GetRange().IsOutside(range)) { fragment.AppendChild(para->Clone()); - } + } i = i->GetNext(); } @@ -1173,7 +1173,7 @@ long wxRichTextParagraphLayoutBox::GetVisibleLineNumber(long pos, bool caretPosi while (node2) { wxRichTextLine* line = node2->GetData(); - + if (line->GetRange().Contains(pos)) { // If the caret is displayed at the end of the previous wrapped line, @@ -1186,7 +1186,7 @@ long wxRichTextParagraphLayoutBox::GetVisibleLineNumber(long pos, bool caretPosi } lineCount ++; - + node2 = node2->GetNext(); } // If we didn't find it in the lines, it must be @@ -1220,14 +1220,14 @@ wxRichTextLine* wxRichTextParagraphLayoutBox::GetLineForVisibleLineNumber(long l while (node2) { wxRichTextLine* line = node2->GetData(); - + if (lineCount == lineNumber) return line; lineCount ++; - + node2 = node2->GetNext(); - } + } } else lineCount += child->GetLines().GetCount(); @@ -1243,14 +1243,14 @@ wxRichTextLine* wxRichTextParagraphLayoutBox::GetLineForVisibleLineNumber(long l bool wxRichTextParagraphLayoutBox::DeleteRange(const wxRichTextRange& range) { wxRichTextObjectList::compatibility_iterator node = m_children.GetFirst(); - + while (node) { wxRichTextParagraph* obj = wxDynamicCast(node->GetData(), wxRichTextParagraph); wxASSERT (obj != NULL); wxRichTextObjectList::compatibility_iterator next = node->GetNext(); - + // Delete the range in each paragraph if (!obj->GetRange().IsOutside(range)) @@ -1308,14 +1308,14 @@ bool wxRichTextParagraphLayoutBox::DeleteRange(const wxRichTextRange& range) RemoveChild(nextParagraph, true); } - } + } } } - + node = next; } - + return true; } @@ -1334,9 +1334,9 @@ wxString wxRichTextParagraphLayoutBox::GetTextForRange(const wxRichTextRange& ra text += wxT("\n"); wxRichTextRange childRange = range; childRange.LimitTo(child->GetRange()); - + wxString childText = child->GetTextForRange(childRange); - + text += childText; lineCount ++; @@ -1428,13 +1428,13 @@ wxRichTextObject* wxRichTextParagraphLayoutBox::GetLeafObjectAtPosition(long pos if (para) { wxRichTextObjectList::compatibility_iterator node = para->GetChildren().GetFirst(); - + while (node) { wxRichTextObject* child = node->GetData(); if (child->GetRange().Contains(position)) return child; - + node = node->GetNext(); } if (position == para->GetRange().GetEnd() && para->GetChildCount() > 0) @@ -1460,7 +1460,7 @@ bool wxRichTextParagraphLayoutBox::SetStyle(const wxRichTextRange& range, const bool haveControl = (GetRichTextCtrl() != NULL); wxRichTextAction* action = NULL; - + if (haveControl && withUndo) { action = new wxRichTextAction(NULL, _("Change Style"), wxRICHTEXT_CHANGE_STYLE, & GetRichTextCtrl()->GetBuffer(), GetRichTextCtrl()); @@ -1485,7 +1485,7 @@ bool wxRichTextParagraphLayoutBox::SetStyle(const wxRichTextRange& range, const // We'll be using a copy of the paragraph to make style changes, // not updating the buffer directly. wxRichTextParagraph* newPara = NULL; - + if (haveControl && withUndo) { newPara = new wxRichTextParagraph(*para); @@ -1504,24 +1504,24 @@ bool wxRichTextParagraphLayoutBox::SetStyle(const wxRichTextRange& range, const { wxRichTextRange childRange(range); childRange.LimitTo(newPara->GetRange()); - + // Find the starting position and if necessary split it so // we can start applying a different style. // TODO: check that the style actually changes or is different // from style outside of range wxRichTextObject* firstObject = NULL; wxRichTextObject* lastObject = NULL; - + if (childRange.GetStart() == newPara->GetRange().GetStart()) firstObject = newPara->GetChildren().GetFirst()->GetData(); else firstObject = newPara->SplitAt(range.GetStart()); - + // Increment by 1 because we're apply the style one _after_ the split point long splitPoint = childRange.GetEnd(); if (splitPoint != newPara->GetRange().GetEnd()) splitPoint ++; - + // Find last object if (splitPoint == newPara->GetRange().GetEnd() || splitPoint == (newPara->GetRange().GetEnd() - 1)) lastObject = newPara->GetChildren().GetLast()->GetData(); @@ -1529,29 +1529,29 @@ bool wxRichTextParagraphLayoutBox::SetStyle(const wxRichTextRange& range, const // lastObject is set as a side-effect of splitting. It's // returned as the object before the new object. (void) newPara->SplitAt(splitPoint, & lastObject); - + wxASSERT(firstObject != NULL); wxASSERT(lastObject != NULL); - + if (!firstObject || !lastObject) continue; - + wxRichTextObjectList::compatibility_iterator firstNode = newPara->GetChildren().Find(firstObject); wxRichTextObjectList::compatibility_iterator lastNode = newPara->GetChildren().Find(lastObject); - + wxASSERT(firstNode != NULL); wxASSERT(lastNode != NULL); - + wxRichTextObjectList::compatibility_iterator node2 = firstNode; - + while (node2) { wxRichTextObject* child = node2->GetData(); - + wxRichTextApplyStyle(child->GetAttributes(), style); if (node2 == lastNode) break; - + node2 = node2->GetNext(); } } @@ -1718,7 +1718,7 @@ void wxRichTextParagraphLayoutBox::Reset() { Clear(); - AddParagraph(wxT("")); + AddParagraph(wxEmptyString); } /*! @@ -1796,19 +1796,19 @@ bool wxRichTextParagraph::Draw(wxDC& dc, const wxRichTextRange& WXUNUSED(range), else { wxString bulletText = GetBulletText(); - if (!bulletText.IsEmpty()) + if (!bulletText.empty()) { if (GetAttributes().GetFont().Ok()) dc.SetFont(GetAttributes().GetFont()); - + if (GetAttributes().GetTextColour().Ok()) dc.SetTextForeground(GetAttributes().GetTextColour()); - + dc.SetBackgroundMode(wxTRANSPARENT); - + // Get line height from first line, if any wxRichTextLine* line = m_cachedLines.GetFirst() ? (wxRichTextLine* ) m_cachedLines.GetFirst()->GetData() : (wxRichTextLine*) NULL; - + wxPoint linePos; int lineHeight = 0; if (line) @@ -1822,18 +1822,18 @@ bool wxRichTextParagraph::Draw(wxDC& dc, const wxRichTextRange& WXUNUSED(range), linePos = GetPosition(); linePos.y += spaceBeforePara; } - + int charHeight = dc.GetCharHeight(); - + int x = GetPosition().x + leftIndent; int y = linePos.y + (lineHeight - charHeight); - + dc.DrawText(bulletText, x, y); } } } } - + // Draw the range for each line, one object at a time. wxRichTextLineList::compatibility_iterator node = m_cachedLines.GetFirst(); @@ -1877,7 +1877,7 @@ bool wxRichTextParagraph::Draw(wxDC& dc, const wxRichTextRange& WXUNUSED(range), } node = node->GetNext(); - } + } return true; } @@ -1993,7 +1993,7 @@ bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, const wxRichTextR wrapPosition = wxMax(lastCompletedEndPos+1,child->GetRange().GetEnd()); // wxLogDebug(wxT("Split at %ld"), wrapPosition); - + // Let's find the actual size of the current line now wxSize actualSize; wxRichTextRange actualRange(lastCompletedEndPos+1, wrapPosition); @@ -2001,28 +2001,28 @@ bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, const wxRichTextR currentWidth = actualSize.x; lineHeight = wxMax(lineHeight, actualSize.y); maxDescent = wxMax(childDescent, maxDescent); - + // Add a new line - wxRichTextLine* line = new wxRichTextLine(this); + wxRichTextLine* line = new wxRichTextLine(this); line->SetRange(actualRange); line->SetPosition(currentPosition); line->SetSize(wxSize(currentWidth, lineHeight)); line->SetDescent(maxDescent); m_cachedLines.Append(line); - + // Now move down a line. TODO: add margins, spacing currentPosition.y += lineHeight; currentPosition.y += lineSpacing; currentWidth = 0; maxDescent = 0; - maxWidth = wxMax(maxWidth, currentWidth); - + maxWidth = wxMax(maxWidth, currentWidth); + lineCount ++; // TODO: account for zero-length objects, such as fields wxASSERT(wrapPosition > lastCompletedEndPos); - + lastEndPos = wrapPosition; lastCompletedEndPos = lastEndPos; @@ -2056,7 +2056,7 @@ bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, const wxRichTextR currentPosition.x = (lineCount == 0 ? startPositionFirstLine : startPositionSubsequentLines); wxRichTextLine* line = new wxRichTextLine(this); - + line->SetRange(lastCompletedEndPos+1, GetRange().GetEnd()-1); line->SetPosition(currentPosition); @@ -2077,7 +2077,7 @@ bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, const wxRichTextR currentPosition.y += lineHeight; currentPosition.y += lineSpacing; lineCount ++; - + m_cachedLines.Append(line); } @@ -2166,7 +2166,7 @@ bool wxRichTextParagraph::InsertText(long pos, const wxString& text) wxRichTextObject* child = node->GetData(); child->SetRange(wxRichTextRange(textObject->GetRange().GetStart() + textLength, textObject->GetRange().GetEnd() + textLength)); - + node = node->GetNext(); } @@ -2223,11 +2223,11 @@ bool wxRichTextParagraph::GetRangeSize(const wxRichTextRange& range, wxSize& siz if (!child->GetRange().IsOutside(range)) { wxSize childSize; - + wxRichTextRange rangeToUse = range; rangeToUse.LimitTo(child->GetRange()); int childDescent = 0; - + if (child->GetRangeSize(rangeToUse, childSize, childDescent, dc, flags)) { sz.y = wxMax(sz.y, childSize.y); @@ -2259,17 +2259,17 @@ bool wxRichTextParagraph::GetRangeSize(const wxRichTextRange& range, wxSize& siz if (!line->GetRange().IsOutside(range)) { wxSize lineSize; - + wxRichTextObjectList::compatibility_iterator node2 = m_children.GetFirst(); while (node2) { wxRichTextObject* child = node2->GetData(); - + if (!child->GetRange().IsOutside(line->GetRange())) { wxRichTextRange rangeToUse = line->GetRange(); rangeToUse.LimitTo(child->GetRange()); - + wxSize childSize; int childDescent = 0; if (child->GetRangeSize(rangeToUse, childSize, childDescent, dc, flags)) @@ -2279,7 +2279,7 @@ bool wxRichTextParagraph::GetRangeSize(const wxRichTextRange& range, wxSize& siz } descent = wxMax(descent, childDescent); } - + node2 = node2->GetNext(); } @@ -2421,9 +2421,9 @@ int wxRichTextParagraph::HitTest(wxDC& dc, const wxPoint& pt, long& textPosition { wxSize childSize; int descent = 0; - + wxRichTextRange rangeToUse(line->GetRange().GetStart(), i); - + GetRangeSize(rangeToUse, childSize, descent, dc, wxRICHTEXT_UNFORMATTED); int nextX = childSize.x + linePos.x; @@ -2449,7 +2449,7 @@ int wxRichTextParagraph::HitTest(wxDC& dc, const wxPoint& pt, long& textPosition } } } - + node = node->GetNext(); } @@ -2554,7 +2554,7 @@ wxRichTextObject* wxRichTextParagraph::FindObjectAtPosition(long position) wxRichTextObject* obj = node->GetData(); if (obj->GetRange().Contains(position)) return obj; - + node = node->GetNext(); } return NULL; @@ -2816,7 +2816,7 @@ bool wxRichTextPlainText::Draw(wxDC& dc, const wxRichTextRange& range, const wxR // Let's draw unselected chunk, selected chunk, then unselected chunk. dc.SetBackgroundMode(wxTRANSPARENT); - + // 1. Initial unselected chunk, if any, up until start of selection. if (selectionRange.GetStart() > range.GetStart() && selectionRange.GetStart() <= range.GetEnd()) { @@ -2872,7 +2872,7 @@ bool wxRichTextPlainText::Draw(wxDC& dc, const wxRichTextRange& range, const wxR dc.SetTextForeground(GetAttributes().GetTextColour()); dc.DrawText(stringFragment, x, y); - } + } } return true; @@ -2989,7 +2989,7 @@ wxString wxRichTextPlainText::GetTextForRange(const wxRichTextRange& range) cons bool wxRichTextPlainText::CanMerge(wxRichTextObject* object) const { return object->GetClassInfo() == CLASSINFO(wxRichTextPlainText) && - (m_text.IsEmpty() || wxTextAttrEq(GetAttributes(), object->GetAttributes())); + (m_text.empty() || wxTextAttrEq(GetAttributes(), object->GetAttributes())); } /// Returns true if this object merged itself with the given one. @@ -3054,7 +3054,7 @@ void wxRichTextBuffer::Clear() void wxRichTextBuffer::Reset() { DeleteChildren(); - AddParagraph(wxT("")); + AddParagraph(wxEmptyString); GetCommandProcessor()->ClearCommands(); Modify(false); } @@ -3072,9 +3072,9 @@ bool wxRichTextBuffer::InsertTextWithUndo(long pos, const wxString& text, wxRich // Set the range we'll need to delete in Undo action->SetRange(wxRichTextRange(pos, pos + text.Length() - 1)); - + SubmitAction(action); - + return true; } @@ -3085,8 +3085,8 @@ bool wxRichTextBuffer::InsertNewlineWithUndo(long pos, wxRichTextCtrl* ctrl) wxTextAttrEx attr(GetBasicStyle()); wxRichTextApplyStyle(attr, GetDefaultStyle()); - - wxRichTextParagraph* newPara = new wxRichTextParagraph(wxT(""), this, & attr); + + wxRichTextParagraph* newPara = new wxRichTextParagraph(wxEmptyString, this, & attr); action->GetNewParagraphs().AppendChild(newPara); action->GetNewParagraphs().UpdateRanges(); action->GetNewParagraphs().SetPartialParagraph(false); @@ -3094,9 +3094,9 @@ bool wxRichTextBuffer::InsertNewlineWithUndo(long pos, wxRichTextCtrl* ctrl) // Set the range we'll need to delete in Undo action->SetRange(wxRichTextRange(pos, pos)); - + SubmitAction(action); - + return true; } @@ -3107,7 +3107,7 @@ bool wxRichTextBuffer::InsertImageWithUndo(long pos, const wxRichTextImageBlock& wxTextAttrEx attr(GetBasicStyle()); wxRichTextApplyStyle(attr, GetDefaultStyle()); - + wxRichTextParagraph* newPara = new wxRichTextParagraph(this, & attr); wxRichTextImage* imageObject = new wxRichTextImage(imageBlock, newPara); newPara->AppendChild(imageObject); @@ -3120,9 +3120,9 @@ bool wxRichTextBuffer::InsertImageWithUndo(long pos, const wxRichTextImageBlock& // Set the range we'll need to delete in Undo action->SetRange(wxRichTextRange(pos, pos)); - + SubmitAction(action); - + return true; } @@ -3130,12 +3130,12 @@ bool wxRichTextBuffer::InsertImageWithUndo(long pos, const wxRichTextImageBlock& bool wxRichTextBuffer::DeleteRangeWithUndo(const wxRichTextRange& range, long initialCaretPosition, long WXUNUSED(newCaretPositon), wxRichTextCtrl* ctrl) { wxRichTextAction* action = new wxRichTextAction(NULL, _("Delete"), wxRICHTEXT_DELETE, this, ctrl); - + action->SetPosition(initialCaretPosition); // Set the range to delete action->SetRange(range); - + // Copy the fragment that we'll need to restore in Undo CopyFragment(range, action->GetOldParagraphs()); @@ -3160,7 +3160,7 @@ bool wxRichTextBuffer::DeleteRangeWithUndo(const wxRichTextRange& range, long in } SubmitAction(action); - + return true; } @@ -3177,7 +3177,7 @@ bool wxRichTextBuffer::BeginBatchUndo(const wxString& cmdName) m_batchedCommand = new wxRichTextCommand(cmdName); } - m_batchedCommandDepth ++; + m_batchedCommandDepth ++; return true; } @@ -3219,7 +3219,7 @@ bool wxRichTextBuffer::SubmitAction(wxRichTextAction* action) /// Begin suppressing undo/redo commands. bool wxRichTextBuffer::BeginSuppressUndo() { - m_suppressUndo ++; + m_suppressUndo ++; return true; } @@ -3227,7 +3227,7 @@ bool wxRichTextBuffer::BeginSuppressUndo() /// End suppressing undo/redo commands. bool wxRichTextBuffer::EndSuppressUndo() { - m_suppressUndo --; + m_suppressUndo --; return true; } @@ -3293,7 +3293,7 @@ bool wxRichTextBuffer::BeginBold() wxTextAttrEx attr; attr.SetFont(font,wxTEXT_ATTR_FONT_WEIGHT); - + return BeginStyle(attr); } @@ -3305,7 +3305,7 @@ bool wxRichTextBuffer::BeginItalic() wxTextAttrEx attr; attr.SetFont(font, wxTEXT_ATTR_FONT_ITALIC); - + return BeginStyle(attr); } @@ -3317,7 +3317,7 @@ bool wxRichTextBuffer::BeginUnderline() wxTextAttrEx attr; attr.SetFont(font, wxTEXT_ATTR_FONT_UNDERLINE); - + return BeginStyle(attr); } @@ -3329,7 +3329,7 @@ bool wxRichTextBuffer::BeginFontSize(int pointSize) wxTextAttrEx attr; attr.SetFont(font, wxTEXT_ATTR_FONT_SIZE); - + return BeginStyle(attr); } @@ -3339,7 +3339,7 @@ bool wxRichTextBuffer::BeginFont(const wxFont& font) wxTextAttrEx attr; attr.SetFlags(wxTEXT_ATTR_FONT); attr.SetFont(font); - + return BeginStyle(attr); } @@ -3349,7 +3349,7 @@ bool wxRichTextBuffer::BeginTextColour(const wxColour& colour) wxTextAttrEx attr; attr.SetFlags(wxTEXT_ATTR_TEXT_COLOUR); attr.SetTextColour(colour); - + return BeginStyle(attr); } @@ -3359,7 +3359,7 @@ bool wxRichTextBuffer::BeginAlignment(wxTextAttrAlignment alignment) wxTextAttrEx attr; attr.SetFlags(wxTEXT_ATTR_ALIGNMENT); attr.SetAlignment(alignment); - + return BeginStyle(attr); } @@ -3369,7 +3369,7 @@ bool wxRichTextBuffer::BeginLeftIndent(int leftIndent, int leftSubIndent) wxTextAttrEx attr; attr.SetFlags(wxTEXT_ATTR_LEFT_INDENT); attr.SetLeftIndent(leftIndent, leftSubIndent); - + return BeginStyle(attr); } @@ -3379,7 +3379,7 @@ bool wxRichTextBuffer::BeginRightIndent(int rightIndent) wxTextAttrEx attr; attr.SetFlags(wxTEXT_ATTR_RIGHT_INDENT); attr.SetRightIndent(rightIndent); - + return BeginStyle(attr); } @@ -3396,7 +3396,7 @@ bool wxRichTextBuffer::BeginParagraphSpacing(int before, int after) attr.SetFlags(flags); attr.SetParagraphSpacingBefore(before); attr.SetParagraphSpacingAfter(after); - + return BeginStyle(attr); } @@ -3406,7 +3406,7 @@ bool wxRichTextBuffer::BeginLineSpacing(int lineSpacing) wxTextAttrEx attr; attr.SetFlags(wxTEXT_ATTR_LINE_SPACING); attr.SetLineSpacing(lineSpacing); - + return BeginStyle(attr); } @@ -3418,7 +3418,7 @@ bool wxRichTextBuffer::BeginNumberedBullet(int bulletNumber, int leftIndent, int attr.SetBulletStyle(bulletStyle); attr.SetBulletNumber(bulletNumber); attr.SetLeftIndent(leftIndent, leftSubIndent); - + return BeginStyle(attr); } @@ -3430,7 +3430,7 @@ bool wxRichTextBuffer::BeginSymbolBullet(wxChar symbol, int leftIndent, int left attr.SetBulletStyle(bulletStyle); attr.SetLeftIndent(leftIndent, leftSubIndent); attr.SetBulletSymbol(symbol); - + return BeginStyle(attr); } @@ -3654,7 +3654,7 @@ bool wxRichTextBuffer::CopyToClipboard(const wxRichTextRange& range) bool success = false; wxString text = GetTextForRange(range); if (wxTheClipboard->Open()) - { + { success = wxTheClipboard->SetData(new wxTextDataObject(text)); wxTheClipboard->Close(); } @@ -3676,7 +3676,7 @@ bool wxRichTextBuffer::PasteFromClipboard(long position) wxString text(data.GetText()); InsertTextWithUndo(position+1, text, GetRichTextCtrl()); - + success = true; } else if (wxTheClipboard->IsSupported(wxDF_BITMAP)) @@ -3687,17 +3687,17 @@ bool wxRichTextBuffer::PasteFromClipboard(long position) wxImage image(bitmap.ConvertToImage()); wxRichTextAction* action = new wxRichTextAction(NULL, _("Insert Image"), wxRICHTEXT_INSERT, this, GetRichTextCtrl(), false); - + action->GetNewParagraphs().AddImage(image); if (action->GetNewParagraphs().GetChildCount() == 1) action->GetNewParagraphs().SetPartialParagraph(true); - + action->SetPosition(position); - + // Set the range we'll need to delete in Undo action->SetRange(wxRichTextRange(position, position)); - + SubmitAction(action); success = true; @@ -3711,12 +3711,12 @@ bool wxRichTextBuffer::PasteFromClipboard(long position) /// Can we paste from the clipboard? bool wxRichTextBuffer::CanPasteFromClipboard() const { - bool canPaste = FALSE; + bool canPaste = false; if (wxTheClipboard->Open()) { if (wxTheClipboard->IsSupported(wxDF_TEXT) || wxTheClipboard->IsSupported(wxDF_BITMAP)) { - canPaste = TRUE; + canPaste = true; } wxTheClipboard->Close(); } @@ -3759,12 +3759,12 @@ IMPLEMENT_DYNAMIC_CLASS(wxRichTextModule, wxModule) */ wxRichTextCommand::wxRichTextCommand(const wxString& name, wxRichTextCommandId id, wxRichTextBuffer* buffer, - wxRichTextCtrl* ctrl, bool ignoreFirstTime): wxCommand(TRUE, name) + wxRichTextCtrl* ctrl, bool ignoreFirstTime): wxCommand(true, name) { /* wxRichTextAction* action = */ new wxRichTextAction(this, name, id, buffer, ctrl, ignoreFirstTime); } -wxRichTextCommand::wxRichTextCommand(const wxString& name): wxCommand(TRUE, name) +wxRichTextCommand::wxRichTextCommand(const wxString& name): wxCommand(true, name) { } @@ -3931,7 +3931,7 @@ void wxRichTextAction::UpdateAppearance(long caretPosition, bool sendUpdateEvent if (sendUpdateEvent) m_ctrl->SendUpdateEvent(); } - } + } } /// Replace the buffer paragraphs with the new ones. @@ -4390,7 +4390,7 @@ bool wxRichTextApplyStyle(wxRichTextAttr& destStyle, const wxTextAttrEx& style) bool wxRichTextApplyStyle(wxTextAttrEx& destStyle, const wxRichTextAttr& style) { - + // Whole font. Avoiding setting individual attributes if possible, since // it recreates the font each time. if ((style.GetFlags() & (wxTEXT_ATTR_FONT)) == (wxTEXT_ATTR_FONT)) @@ -4404,16 +4404,16 @@ bool wxRichTextApplyStyle(wxTextAttrEx& destStyle, const wxRichTextAttr& style) if (style.GetFlags() & wxTEXT_ATTR_FONT_FACE) font.SetFaceName(style.GetFontFaceName()); - + if (style.GetFlags() & wxTEXT_ATTR_FONT_SIZE) font.SetPointSize(style.GetFontSize()); - + if (style.GetFlags() & wxTEXT_ATTR_FONT_ITALIC) font.SetStyle(style.GetFontStyle()); - + if (style.GetFlags() & wxTEXT_ATTR_FONT_WEIGHT) font.SetWeight(style.GetFontWeight()); - + if (style.GetFlags() & wxTEXT_ATTR_FONT_UNDERLINE) font.SetUnderlined(style.GetFontUnderlined()); @@ -4673,6 +4673,7 @@ void wxTextAttrEx::operator= (const wxTextAttr& attr) IMPLEMENT_CLASS(wxRichTextFileHandler, wxObject) +#if wxUSE_STREAMS bool wxRichTextFileHandler::LoadFile(wxRichTextBuffer *buffer, const wxString& filename) { wxFFileInputStream stream(filename); @@ -4690,6 +4691,7 @@ bool wxRichTextFileHandler::SaveFile(wxRichTextBuffer *buffer, const wxString& f else return false; } +#endif // wxUSE_STREAMS /// Can we handle this filename (if using files)? By default, checks the extension. bool wxRichTextFileHandler::CanHandle(const wxString& filename) const @@ -4708,7 +4710,7 @@ bool wxRichTextFileHandler::CanHandle(const wxString& filename) const IMPLEMENT_CLASS(wxRichTextPlainTextHandler, wxRichTextFileHandler) #if wxUSE_STREAMS -bool wxRichTextPlainTextHandler::LoadFile(wxRichTextBuffer *buffer, wxInputStream& stream) +bool wxRichTextPlainTextHandler::DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& stream) { if (!stream.IsOk()) return false; @@ -4721,7 +4723,7 @@ bool wxRichTextPlainTextHandler::LoadFile(wxRichTextBuffer *buffer, wxInputStrea ch = stream.GetC(); if (ch > 0) - str += ch; + str += wxChar(ch); } buffer->Clear(); @@ -4732,7 +4734,7 @@ bool wxRichTextPlainTextHandler::LoadFile(wxRichTextBuffer *buffer, wxInputStrea } -bool wxRichTextPlainTextHandler::SaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream) +bool wxRichTextPlainTextHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream) { if (!stream.IsOk()) return false; @@ -4743,8 +4745,7 @@ bool wxRichTextPlainTextHandler::SaveFile(wxRichTextBuffer *buffer, wxOutputStre stream.Write((const char*) buf, text.Length()); return true; } - -#endif +#endif // wxUSE_STREAMS /* * Stores information about an image, in binary in-memory form @@ -4798,10 +4799,10 @@ bool wxRichTextImageBlock::MakeImageBlock(const wxString& filename, int imageTyp m_imageType = imageType; wxString filenameToRead(filename); - bool removeFile = FALSE; + bool removeFile = false; if (imageType == -1) - return FALSE; // Could not determine image type + return false; // Could not determine image type if ((imageType != wxBITMAP_TYPE_JPEG) && convertToJPEG) { @@ -4814,13 +4815,13 @@ bool wxRichTextImageBlock::MakeImageBlock(const wxString& filename, int imageTyp image.SaveFile(tempFile, wxBITMAP_TYPE_JPEG); filenameToRead = tempFile; - removeFile = TRUE; + removeFile = true; m_imageType = wxBITMAP_TYPE_JPEG; } wxFile file; if (!file.Open(filenameToRead)) - return FALSE; + return false; m_dataSize = (size_t) file.Length(); file.Close(); @@ -4843,24 +4844,24 @@ bool wxRichTextImageBlock::MakeImageBlock(wxImage& image, int imageType, int qua image.SetOption(wxT("quality"), quality); if (imageType == -1) - return FALSE; // Could not determine image type + return false; // Could not determine image type wxString tempFile; bool success = wxGetTempFileName(_("image"), tempFile) ; - + wxASSERT(success); wxUnusedVar(success); - + if (!image.SaveFile(tempFile, m_imageType)) { if (wxFileExists(tempFile)) wxRemoveFile(tempFile); - return FALSE; + return false; } wxFile file; if (!file.Open(tempFile)) - return FALSE; + return false; m_dataSize = (size_t) file.Length(); file.Close(); @@ -4909,7 +4910,7 @@ void wxRichTextImageBlock::operator=(const wxRichTextImageBlock& block) bool wxRichTextImageBlock::Load(wxImage& image) { if (!m_data) - return FALSE; + return false; // Read in the image. #if 1 @@ -4922,7 +4923,7 @@ bool wxRichTextImageBlock::Load(wxImage& image) if (!WriteBlock(tempFile, m_data, m_dataSize)) { - return FALSE; + return false; } success = image.LoadFile(tempFile, GetImageType()); wxRemoveFile(tempFile); @@ -4940,7 +4941,7 @@ bool wxRichTextImageBlock::WriteHex(wxOutputStream& stream) { hex = wxDecToHex(m_data[i]); wxCharBuffer buf = hex.ToAscii(); - + stream.Write((const char*) buf, hex.Length()); } @@ -4963,7 +4964,7 @@ bool wxRichTextImageBlock::ReadHex(wxInputStream& stream, int length, int imageT str[0] = stream.GetC(); str[1] = stream.GetC(); - m_data[i] = wxHexToDec(str); + m_data[i] = (unsigned char)wxHexToDec(str); } m_dataSize = dataSize; @@ -5007,7 +5008,7 @@ bool wxRichTextImageBlock::WriteBlock(const wxString& filename, unsigned char* b { wxFileOutputStream outStream(filename); if (!outStream.Ok()) - return FALSE; + return false; return WriteBlock(outStream, block, size); } diff --git a/src/richtext/richtextctrl.cpp b/src/richtext/richtextctrl.cpp index d470dd8c9f..0dfa365185 100644 --- a/src/richtext/richtextctrl.cpp +++ b/src/richtext/richtextctrl.cpp @@ -1,10 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: richeditctrl.cpp +// Name: richtext/richeditctrl.cpp // Purpose: A rich edit control // Author: Julian Smart -// Modified by: +// Modified by: // Created: 2005-09-30 -// RCS-ID: +// RCS-ID: $Id$ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -128,7 +128,7 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos { SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); } - + GetBuffer().SetRichTextCtrl(this); wxTextAttrEx attributes; @@ -141,12 +141,12 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos SetDefaultStyle(attributes); SetBasicStyle(attributes); - SetBackgroundColour(*wxWHITE); + SetBackgroundColour(*wxWHITE); SetBackgroundStyle(wxBG_STYLE_CUSTOM); - // Tell the sizers to use the given or best size + // Tell the sizers to use the given or best size SetBestFittingSize(size); - + // Create a buffer RecreateBuffer(size); @@ -156,7 +156,7 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos PositionCaret(); SetCursor(wxCursor(wxCURSOR_IBEAM)); - + return true; } @@ -225,14 +225,14 @@ void wxRichTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(event)) return; dc.SetFont(GetFont()); - + // Paint the background PaintBackground(dc); wxRegion dirtyRegion = GetUpdateRegion(); wxRect drawingArea(GetLogicalPoint(wxPoint(0, 0)), GetClientSize()); - wxRect availableSpace(wxPoint(0, 0), GetClientSize()); + wxRect availableSpace(GetClientSize()); if (GetBuffer().GetDirty()) { GetBuffer().Layout(dc, availableSpace, GetBuffer().GetRange(), wxRICHTEXT_FIXED_WIDTH|wxRICHTEXT_VARIABLE_HEIGHT); @@ -269,7 +269,7 @@ void wxRichTextCtrl::OnLeftClick(wxMouseEvent& event) wxClientDC dc(this); PrepareDC(dc); dc.SetFont(GetFont()); - + long position = 0; int hit = GetBuffer().HitTest(dc, event.GetLogicalPosition(dc), position); @@ -339,7 +339,7 @@ void wxRichTextCtrl::OnMoveMouse(wxMouseEvent& event) wxClientDC dc(this); PrepareDC(dc); dc.SetFont(GetFont()); - + long position = 0; wxPoint logicalPt = event.GetLogicalPosition(dc); int hit = GetBuffer().HitTest(dc, logicalPt, position); @@ -366,10 +366,10 @@ void wxRichTextCtrl::OnMoveMouse(wxMouseEvent& event) if (m_caretPosition != position) { bool extendSel = ExtendSelection(m_caretPosition, position, wxRICHTEXT_SHIFT_DOWN); - + MoveCaret(position, caretAtLineStart); SetDefaultStyleToCursorStyle(); - + if (extendSel) Refresh(); } @@ -663,7 +663,7 @@ bool wxRichTextCtrl::ExtendSelection(long oldPos, long newPos, int flags) { wxLogDebug(wxT("Strange selection range")); } - + return true; } else @@ -809,7 +809,7 @@ void wxRichTextCtrl::MoveCaretForward(long oldPosition) // the same position but indicate that we're to show // at the start of the next line. m_caretPosition = oldPosition; - m_caretAtLineStart = true; + m_caretAtLineStart = true; } SetDefaultStyleToCursorStyle(); return; @@ -900,7 +900,7 @@ bool wxRichTextCtrl::MoveRight(int noPositions, int flags) return true; } else - return false; + return false; } /// Move left @@ -929,7 +929,7 @@ bool wxRichTextCtrl::MoveLeft(int noPositions, int flags) return true; } else - return false; + return false; } /// Move up @@ -963,8 +963,8 @@ bool wxRichTextCtrl::MoveDown(int noLines, int flags) wxRichTextLine* lineObj = GetBuffer().GetLineForVisibleLineNumber(newLine); if (lineObj) - { - pt.y = lineObj->GetAbsolutePosition().y + 2; + { + pt.y = lineObj->GetAbsolutePosition().y + 2; } else return false; @@ -973,9 +973,9 @@ bool wxRichTextCtrl::MoveDown(int noLines, int flags) wxClientDC dc(this); PrepareDC(dc); dc.SetFont(GetFont()); - + int hitTest = GetBuffer().HitTest(dc, pt, newPos); - + if (hitTest != wxRICHTEXT_HITTEST_NONE) { // If end of previous line, and hitTest is wxRICHTEXT_HITTEST_BEFORE, @@ -1127,7 +1127,7 @@ bool wxRichTextCtrl::MoveHome(int flags) return true; } else - return false; + return false; } /// Move to the end of the buffer @@ -1149,7 +1149,7 @@ bool wxRichTextCtrl::MoveEnd(int flags) return true; } else - return false; + return false; } /// Move noPages pages up @@ -1195,19 +1195,19 @@ bool wxRichTextCtrl::PageDown(int noPages, int flags) // Finds the caret position for the next word long wxRichTextCtrl::FindNextWordPosition(int direction) const -{ +{ long endPos = GetBuffer().GetRange().GetEnd(); if (direction > 0) { long i = m_caretPosition+1+direction; // +1 for conversion to character pos - + // First skip current text to space while (i < endPos && i > -1) { // i is in character, not caret positions wxString text = GetBuffer().GetTextForRange(wxRichTextRange(i, i)); - if (text != wxT(" ") && !text.IsEmpty()) + if (text != wxT(" ") && !text.empty()) i += direction; else { @@ -1218,9 +1218,9 @@ long wxRichTextCtrl::FindNextWordPosition(int direction) const { // i is in character, not caret positions wxString text = GetBuffer().GetTextForRange(wxRichTextRange(i, i)); - if (text.IsEmpty()) // End of paragraph, or maybe an image + if (text.empty()) // End of paragraph, or maybe an image return wxMax(-1, i - 1); - else if (text == wxT(" ") || text.IsEmpty()) + else if (text == wxT(" ") || text.empty()) i += direction; else { @@ -1241,9 +1241,9 @@ long wxRichTextCtrl::FindNextWordPosition(int direction) const { // i is in character, not caret positions wxString text = GetBuffer().GetTextForRange(wxRichTextRange(i, i)); - if (text.IsEmpty()) // End of paragraph, or maybe an image + if (text.empty()) // End of paragraph, or maybe an image break; - else if (text == wxT(" ") || text.IsEmpty()) + else if (text == wxT(" ") || text.empty()) i += direction; else break; @@ -1253,12 +1253,11 @@ long wxRichTextCtrl::FindNextWordPosition(int direction) const { // i is in character, not caret positions wxString text = GetBuffer().GetTextForRange(wxRichTextRange(i, i)); - if (text != wxT(" ") /* && !text.IsEmpty() */) + if (text != wxT(" ") /* && !text.empty() */) i += direction; else { return i; - break; } } if (i < -1) @@ -1274,10 +1273,10 @@ bool wxRichTextCtrl::WordLeft(int WXUNUSED(n), int flags) if (pos != m_caretPosition) { wxRichTextParagraph* para = GetBuffer().GetParagraphAtPosition(pos, true); - + if (!ExtendSelection(m_caretPosition, pos, flags)) SelectNone(); - + SetCaretPosition(pos, para->GetRange().GetStart() != pos); PositionCaret(); SetDefaultStyleToCursorStyle(); @@ -1286,7 +1285,7 @@ bool wxRichTextCtrl::WordLeft(int WXUNUSED(n), int flags) Refresh(); return true; } - + return false; } @@ -1297,10 +1296,10 @@ bool wxRichTextCtrl::WordRight(int WXUNUSED(n), int flags) if (pos != m_caretPosition) { wxRichTextParagraph* para = GetBuffer().GetParagraphAtPosition(pos, true); - + if (!ExtendSelection(m_caretPosition, pos, flags)) SelectNone(); - + SetCaretPosition(pos, para->GetRange().GetStart() != pos); PositionCaret(); SetDefaultStyleToCursorStyle(); @@ -1309,7 +1308,7 @@ bool wxRichTextCtrl::WordRight(int WXUNUSED(n), int flags) Refresh(); return true; } - + return false; } @@ -1317,7 +1316,7 @@ bool wxRichTextCtrl::WordRight(int WXUNUSED(n), int flags) void wxRichTextCtrl::OnSize(wxSizeEvent& event) { GetBuffer().SetDirty(true); - + RecreateBuffer(); event.Skip(); @@ -1346,10 +1345,10 @@ void wxRichTextCtrl::SetupScrollbars() int startX, startY; GetViewStart(& startX, & startY); - + int maxPositionX = 0; // wxMax(sz.x - clientSize.x, 0); int maxPositionY = (wxMax(maxHeight - clientSize.y, 0))/pixelsPerUnit; - + // Move to previous scroll position if // possible SetScrollbars(0, pixelsPerUnit, @@ -1367,10 +1366,10 @@ void wxRichTextCtrl::PaintBackground(wxDC& dc) // Clear the background dc.SetBrush(wxBrush(backgroundColour)); dc.SetPen(*wxTRANSPARENT_PEN); - wxRect windowRect(wxPoint(0, 0), GetClientSize()); + wxRect windowRect(GetClientSize()); windowRect.x -= 2; windowRect.y -= 2; windowRect.width += 4; windowRect.height += 4; - + // We need to shift the rectangle to take into account // scrolling. Converting device to logical coordinates. CalcUnscrolledPosition(windowRect.x, windowRect.y, & windowRect.x, & windowRect.y); @@ -1383,10 +1382,10 @@ bool wxRichTextCtrl::RecreateBuffer(const wxSize& size) wxSize sz = size; if (sz == wxDefaultSize) sz = GetClientSize(); - + if (sz.x < 1 || sz.y < 1) return false; - + if (!m_bufferBitmap.Ok() || m_bufferBitmap.GetWidth() < sz.x || m_bufferBitmap.GetHeight() < sz.y) m_bufferBitmap = wxBitmap(sz.x, sz.y); return m_bufferBitmap.Ok(); @@ -1414,7 +1413,7 @@ bool wxRichTextCtrl::LoadFile(const wxString& filename, int type) else { wxLogError(_("File couldn't be loaded.")); - + return false; } } @@ -1630,7 +1629,7 @@ bool wxRichTextCtrl::WriteImage(const wxBitmap& bitmap, int bitmapType) if (bitmap.Ok()) { wxRichTextImageBlock imageBlock; - + wxImage image = bitmap.ConvertToImage(); if (image.Ok() && imageBlock.MakeImageBlock(image, bitmapType)) return WriteImage(imageBlock); @@ -1678,10 +1677,10 @@ void wxRichTextCtrl::Paste() if (CanPaste()) { BeginBatchUndo(_("Paste")); - + long newPos = m_caretPosition; DeleteSelectedContent(& newPos); - + GetBuffer().PasteFromClipboard(newPos); EndBatchUndo(); @@ -2147,7 +2146,7 @@ bool wxRichTextCtrl::GetCaretPositionForIndex(long position, wxRect& rect) { wxClientDC dc(this); dc.SetFont(GetFont()); - + PrepareDC(dc); wxPoint pt; @@ -2205,7 +2204,7 @@ bool wxRichTextCtrl::MoveCaret(long pos, bool showAtLineStart) /// setting the caret position. bool wxRichTextCtrl::Layout() { - wxRect availableSpace(wxPoint(0, 0), GetClientSize()); + wxRect availableSpace(GetClientSize()); if (availableSpace.width == 0) availableSpace.width = 10; if (availableSpace.height == 0) @@ -2213,14 +2212,14 @@ bool wxRichTextCtrl::Layout() wxClientDC dc(this); dc.SetFont(GetFont()); - + PrepareDC(dc); GetBuffer().Defragment(); GetBuffer().UpdateRanges(); // If items were deleted, ranges need recalculation GetBuffer().Layout(dc, availableSpace, GetBuffer().GetRange(), wxRICHTEXT_FIXED_WIDTH|wxRICHTEXT_VARIABLE_HEIGHT); GetBuffer().SetDirty(false); - + if (!IsFrozen()) SetupScrollbars(); @@ -2236,7 +2235,7 @@ bool wxRichTextCtrl::IsSelectionBold() const wxRichTextRange range = GetSelectionRange(); attr.SetFlags(wxTEXT_ATTR_FONT_WEIGHT); attr.SetFontWeight(wxBOLD); - + return HasCharacterAttributes(range, attr); } else @@ -2263,7 +2262,7 @@ bool wxRichTextCtrl::IsSelectionItalics() const wxRichTextAttr attr; attr.SetFlags(wxTEXT_ATTR_FONT_ITALIC); attr.SetFontStyle(wxITALIC); - + return HasCharacterAttributes(range, attr); } else @@ -2290,7 +2289,7 @@ bool wxRichTextCtrl::IsSelectionUnderlined() const wxRichTextAttr attr; attr.SetFlags(wxTEXT_ATTR_FONT_UNDERLINE); attr.SetFontUnderlined(true); - + return HasCharacterAttributes(range, attr); } else @@ -2358,7 +2357,7 @@ bool wxRichTextCtrl::IsSelectionAligned(wxTextAttrAlignment alignment) const wxRichTextRange range = GetSelectionRange(); wxRichTextAttr attr; attr.SetAlignment(alignment); - + return HasParagraphAttributes(range, attr); } else diff --git a/src/richtext/richtextxml.cpp b/src/richtext/richtextxml.cpp index 2e171c5d07..516fb41a28 100644 --- a/src/richtext/richtextxml.cpp +++ b/src/richtext/richtextxml.cpp @@ -1,10 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: richtextxml.cpp +// Name: richtext/richtextxml.cpp // Purpose: XML and HTML I/O for wxRichTextCtrl // Author: Julian Smart -// Modified by: +// Modified by: // Created: 2005-09-30 -// RCS-ID: +// RCS-ID: $Id$ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -37,7 +37,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxRichTextXMLHandler, wxRichTextFileHandler) #if wxUSE_STREAMS -bool wxRichTextXMLHandler::LoadFile(wxRichTextBuffer *buffer, wxInputStream& stream) +bool wxRichTextXMLHandler::DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& stream) { if (!stream.IsOk()) return false; @@ -67,7 +67,7 @@ bool wxRichTextXMLHandler::LoadFile(wxRichTextBuffer *buffer, wxInputStream& str else ImportXML(buffer, child); } - + child = child->GetNext(); } } @@ -76,7 +76,7 @@ bool wxRichTextXMLHandler::LoadFile(wxRichTextBuffer *buffer, wxInputStream& str success = false; } } - + delete xmlDoc; buffer->UpdateRanges(); @@ -145,7 +145,7 @@ bool wxRichTextXMLHandler::ImportXML(wxRichTextBuffer* buffer, wxXmlNode* node) { int imageType = wxBITMAP_TYPE_PNG; wxString value = node->GetPropVal(wxT("imagetype"), wxEmptyString); - if (!value.IsEmpty()) + if (!value.empty()) imageType = wxAtoi(value); wxString data; @@ -163,12 +163,12 @@ bool wxRichTextXMLHandler::ImportXML(wxRichTextBuffer* buffer, wxXmlNode* node) // wxLogDebug(data); dataChild = dataChild->GetNext(); } - + } imageChild = imageChild->GetNext(); } - if (!data.IsEmpty()) + if (!data.empty()) { wxRichTextImage* imageObj = new wxRichTextImage(para); para->AppendChild(imageObj); @@ -192,7 +192,7 @@ bool wxRichTextXMLHandler::ImportXML(wxRichTextBuffer* buffer, wxXmlNode* node) ImportXML(buffer, child); child = child->GetNext(); } - } + } return true; } @@ -242,7 +242,7 @@ wxString wxRichTextXMLHandler::GetNodeContent(wxXmlNode *node) wxString wxRichTextXMLHandler::GetParamValue(wxXmlNode *node, const wxString& param) { - if (param.IsEmpty()) + if (param.empty()) return GetNodeContent(node); else return GetNodeContent(GetParamNode(node, param)); @@ -259,9 +259,9 @@ wxString wxRichTextXMLHandler::GetText(wxXmlNode *node, const wxString& param, b // write string to output: inline static void OutputString(wxOutputStream& stream, const wxString& str, - wxMBConv *convMem = NULL, wxMBConv *convFile = NULL) + wxMBConv *WXUNUSED_IN_UNICODE(convMem) = NULL, wxMBConv *convFile = NULL) { - if (str.IsEmpty()) return; + if (str.empty()) return; #if wxUSE_UNICODE const wxWX2MBbuf buf(str.mb_str(convFile ? *convFile : wxConvUTF8)); stream.Write((const char*)buf, strlen((const char*)buf)); @@ -284,7 +284,7 @@ static void OutputStringEnt(wxOutputStream& stream, const wxString& str, wxString buf; size_t i, last, len; wxChar c; - + len = str.Len(); last = 0; for (i = 0; i < len; i++) @@ -359,17 +359,14 @@ static wxString ColourToHexString(const wxColour& col) // Convert 6-digit hex string to a colour wxColour HexStringToColour(const wxString& hex) { - unsigned int r = 0; - unsigned int g = 0; - unsigned int b = 0; - r = wxHexToDec(hex.Mid(0, 2)); - g = wxHexToDec(hex.Mid(2, 2)); - b = wxHexToDec(hex.Mid(4, 2)); + unsigned char r = (unsigned char)wxHexToDec(hex.Mid(0, 2)); + unsigned char g = (unsigned char)wxHexToDec(hex.Mid(2, 2)); + unsigned char b = (unsigned char)wxHexToDec(hex.Mid(4, 2)); return wxColour(r, g, b); } -bool wxRichTextXMLHandler::SaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream) +bool wxRichTextXMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream) { if (!stream.IsOk()) return false; @@ -383,7 +380,7 @@ bool wxRichTextXMLHandler::SaveFile(wxRichTextBuffer *buffer, wxOutputStream& st wxString memencoding(wxT("ISO-8859-1")) ; #endif wxString s ; - + wxMBConv *convMem = NULL, *convFile = NULL; #if wxUSE_UNICODE convFile = new wxCSConv(fileencoding); @@ -394,7 +391,7 @@ bool wxRichTextXMLHandler::SaveFile(wxRichTextBuffer *buffer, wxOutputStream& st convMem = new wxCSConv(memencoding); } #endif - + s.Printf(wxT("\n"), (const wxChar*) version, (const wxChar*) fileencoding ); OutputString(stream, s, NULL, NULL); @@ -405,7 +402,7 @@ bool wxRichTextXMLHandler::SaveFile(wxRichTextBuffer *buffer, wxOutputStream& st OutputString(stream, wxT("\n") , NULL, NULL); OutputString(stream, wxT("\n"), NULL, NULL); - + delete convFile; delete convMem; @@ -433,11 +430,11 @@ bool wxRichTextXMLHandler::ExportXML(wxOutputStream& stream, wxMBConv* convMem, OutputIndentation(stream, indent); stream << wxT("<") << objectName; - + wxString style = CreateStyle(obj.GetAttributes(), false); - + stream << style << wxT(">"); - + wxString str = text.GetText(); if (str.Length() > 0 && (str[0] == wxT(' ') || str[str.Length()-1] == wxT(' '))) { @@ -478,15 +475,15 @@ bool wxRichTextXMLHandler::ExportXML(wxOutputStream& stream, wxMBConv* convMem, { OutputIndentation(stream, indent); stream << wxT("<") << objectName; - + bool isPara = false; if (objectName == wxT("paragraph") || objectName == wxT("paragraphlayout")) isPara = true; wxString style = CreateStyle(obj.GetAttributes(), isPara); - + stream << style << wxT(">"); - + wxRichTextCompositeObject& composite = (wxRichTextCompositeObject&) obj; size_t i; for (i = 0; i < composite.GetChildCount(); i++) @@ -527,7 +524,7 @@ wxString wxRichTextXMLHandler::CreateStyle(const wxTextAttrEx& attr, bool isPara str << wxT(" fontface=\"") << attr.GetFont().GetFaceName() << wxT("\""); } - if (!attr.GetCharacterStyleName().IsEmpty()) + if (!attr.GetCharacterStyleName().empty()) str << wxT(" charactertyle=\"") << wxString(attr.GetCharacterStyleName()) << wxT("\""); if (isPara) @@ -543,7 +540,7 @@ wxString wxRichTextXMLHandler::CreateStyle(const wxTextAttrEx& attr, bool isPara str << wxT(" bulletnumber=\"") << (int) attr.GetBulletNumber() << wxT("\""); str << wxT(" bulletsymbol=\"") << wxString(attr.GetBulletSymbol()) << wxT("\""); - if (!attr.GetParagraphStyleName().IsEmpty()) + if (!attr.GetParagraphStyleName().empty()) str << wxT(" parstyle=\"") << wxString(attr.GetParagraphStyleName()) << wxT("\""); } @@ -563,29 +560,29 @@ bool wxRichTextXMLHandler::GetStyle(wxTextAttrEx& attr, wxXmlNode* node, bool is fontFacename = node->GetPropVal(wxT("fontface"), wxEmptyString); wxString value = node->GetPropVal(wxT("fontfamily"), wxEmptyString); - if (!value.IsEmpty()) + if (!value.empty()) fontFamily = wxAtoi(value); value = node->GetPropVal(wxT("fontstyle"), wxEmptyString); - if (!value.IsEmpty()) + if (!value.empty()) fontStyle = wxAtoi(value); value = node->GetPropVal(wxT("fontsize"), wxEmptyString); - if (!value.IsEmpty()) + if (!value.empty()) fontSize = wxAtoi(value); value = node->GetPropVal(wxT("fontweight"), wxEmptyString); - if (!value.IsEmpty()) + if (!value.empty()) fontWeight = wxAtoi(value); value = node->GetPropVal(wxT("fontunderlined"), wxEmptyString); - if (!value.IsEmpty()) + if (!value.empty()) fontUnderlined = wxAtoi(value) != 0; attr.SetFont(* wxTheFontList->FindOrCreateFont(fontSize, fontFamily, fontStyle, fontWeight, fontUnderlined, fontFacename)); value = node->GetPropVal(wxT("textcolor"), wxEmptyString); - if (!value.IsEmpty()) + if (!value.empty()) { if (value[0] == wxT('#')) attr.SetTextColour(HexStringToColour(value.Mid(1))); @@ -594,7 +591,7 @@ bool wxRichTextXMLHandler::GetStyle(wxTextAttrEx& attr, wxXmlNode* node, bool is } value = node->GetPropVal(wxT("backgroundcolor"), wxEmptyString); - if (!value.IsEmpty()) + if (!value.empty()) { if (value[0] == wxT('#')) attr.SetBackgroundColour(HexStringToColour(value.Mid(1))); @@ -603,56 +600,56 @@ bool wxRichTextXMLHandler::GetStyle(wxTextAttrEx& attr, wxXmlNode* node, bool is } value = node->GetPropVal(wxT("characterstyle"), wxEmptyString); - if (!value.IsEmpty()) + if (!value.empty()) attr.SetCharacterStyleName(value); // Set paragraph attributes if (isPara) { value = node->GetPropVal(wxT("alignment"), wxEmptyString); - if (!value.IsEmpty()) + if (!value.empty()) attr.SetAlignment((wxTextAttrAlignment) wxAtoi(value)); int leftSubIndent = 0; int leftIndent = 0; value = node->GetPropVal(wxT("leftindent"), wxEmptyString); - if (!value.IsEmpty()) + if (!value.empty()) leftIndent = wxAtoi(value); value = node->GetPropVal(wxT("leftsubindent"), wxEmptyString); - if (!value.IsEmpty()) + if (!value.empty()) leftSubIndent = wxAtoi(value); attr.SetLeftIndent(leftIndent, leftSubIndent); value = node->GetPropVal(wxT("rightindent"), wxEmptyString); - if (!value.IsEmpty()) + if (!value.empty()) attr.SetRightIndent(wxAtoi(value)); value = node->GetPropVal(wxT("parspacingbefore"), wxEmptyString); - if (!value.IsEmpty()) + if (!value.empty()) attr.SetParagraphSpacingBefore(wxAtoi(value)); value = node->GetPropVal(wxT("parspacingafter"), wxEmptyString); - if (!value.IsEmpty()) + if (!value.empty()) attr.SetParagraphSpacingAfter(wxAtoi(value)); value = node->GetPropVal(wxT("linespacing"), wxEmptyString); - if (!value.IsEmpty()) + if (!value.empty()) attr.SetLineSpacing(wxAtoi(value)); value = node->GetPropVal(wxT("bulletstyle"), wxEmptyString); - if (!value.IsEmpty()) + if (!value.empty()) attr.SetBulletStyle(wxAtoi(value)); value = node->GetPropVal(wxT("bulletnumber"), wxEmptyString); - if (!value.IsEmpty()) + if (!value.empty()) attr.SetBulletNumber(wxAtoi(value)); value = node->GetPropVal(wxT("bulletsymbol"), wxEmptyString); - if (!value.IsEmpty()) + if (!value.empty()) attr.SetBulletSymbol(value[0]); value = node->GetPropVal(wxT("parstyle"), wxEmptyString); - if (!value.IsEmpty()) + if (!value.empty()) attr.SetParagraphStyleName(value); } @@ -674,7 +671,7 @@ bool wxRichTextHTMLHandler::CanHandle(const wxString& filename) const #if wxUSE_STREAMS -bool wxRichTextHTMLHandler::LoadFile(wxRichTextBuffer *WXUNUSED(buffer), wxInputStream& WXUNUSED(stream)) +bool wxRichTextHTMLHandler::DoLoadFile(wxRichTextBuffer *WXUNUSED(buffer), wxInputStream& WXUNUSED(stream)) { return false; } @@ -683,7 +680,7 @@ bool wxRichTextHTMLHandler::LoadFile(wxRichTextBuffer *WXUNUSED(buffer), wxInput * We need to output only _changes_ in character formatting. */ -bool wxRichTextHTMLHandler::SaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream) +bool wxRichTextHTMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream) { buffer->Defragment(); @@ -719,7 +716,7 @@ bool wxRichTextHTMLHandler::SaveFile(wxRichTextBuffer *buffer, wxOutputStream& s } node2 = node2->GetNext(); - } + } OutputParagraphFormatting(currentParaStyle, para->GetAttributes(), stream, false); @@ -805,4 +802,3 @@ void wxRichTextHTMLHandler::OutputParagraphFormatting(const wxTextAttrEx& WXUNUS #endif // wxUSE_RICHTEXT - -- 2.45.2