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
This commit is contained in:
Włodzimierz Skiba
2005-10-19 17:00:58 +00:00
parent 7f9d2f2aaf
commit 7fe8059f58
6 changed files with 318 additions and 319 deletions

View File

@@ -1,10 +1,10 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: richtextbuffer.h // Name: wx/richtext/richtextbuffer.h
// Purpose: Buffer for wxRichTextCtrl // Purpose: Buffer for wxRichTextCtrl
// Author: Julian Smart // Author: Julian Smart
// Modified by: // Modified by:
// Created: 2005-09-30 // Created: 2005-09-30
// RCS-ID: // RCS-ID: $Id$
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@@ -81,7 +81,7 @@
it can report a partial size, so that wrapping can be implemented, it can report a partial size, so that wrapping can be implemented,
hit test calculations performed, etc. So GetRangeSize must be implemented hit test calculations performed, etc. So GetRangeSize must be implemented
for each object. for each object.
*/ */
#ifndef _WX_RICHTEXTBUFFER_H_ #ifndef _WX_RICHTEXTBUFFER_H_
@@ -511,7 +511,7 @@ public:
/// Lay the item out at the specified position with the given size constraint. /// Lay the item out at the specified position with the given size constraint.
/// Layout must set the cached size. /// 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 /// Hit-testing: returns a flag indicating hit test details, plus
/// information about position /// 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); virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& rect, int descent, int style);
/// Lay the item out /// 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 /// Get/set the object size for the given range. Returns false if the range
/// is invalid for this object. /// 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); virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& rect, int descent, int style);
/// Lay the item out /// 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 /// Get/set the object size for the given range. Returns false if the range
/// is invalid for this object. /// is invalid for this object.
@@ -850,10 +850,10 @@ public:
virtual wxRichTextObject* GetLeafObjectAtPosition(long position) const; virtual wxRichTextObject* GetLeafObjectAtPosition(long position) const;
/// Get the paragraph by number /// Get the paragraph by number
virtual wxRichTextParagraph* GetParagraphAtLine(long paragraphNumber) const; virtual wxRichTextParagraph* GetParagraphAtLine(long paragraphNumber) const;
/// Get the paragraph for a given line /// 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 /// Get the length of the paragraph
virtual int GetParagraphLength(long paragraphNumber) const; virtual int GetParagraphLength(long paragraphNumber) const;
@@ -909,9 +909,6 @@ public:
/// Copy /// Copy
void Copy(const wxRichTextParagraphLayoutBox& obj); void Copy(const wxRichTextParagraphLayoutBox& obj);
/// Clone
virtual wxRichTextObject* Clone() { return new wxRichTextParagraphLayoutBox(*this); }
/// Calculate ranges /// Calculate ranges
virtual void UpdateRanges() { long end; CalculateRange(0, end); } virtual void UpdateRanges() { long end; CalculateRange(0, end); }
@@ -969,7 +966,7 @@ public:
void Copy(const wxRichTextFragment& obj); void Copy(const wxRichTextFragment& obj);
/// Clone /// Clone
virtual wxRichTextObject* Clone() { return new wxRichTextFragment(*this); } virtual wxRichTextObject* Clone() const { return new wxRichTextFragment(*this); }
protected: protected:
@@ -1077,7 +1074,7 @@ public:
virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& rect, int descent, int style); virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& rect, int descent, int style);
/// Lay the item out /// 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 /// Get/set the object size for the given range. Returns false if the range
/// is invalid for this object. /// 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); virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& rect, int descent, int style);
/// Lay the item out /// 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 /// Get/set the object size for the given range. Returns false if the range
/// is invalid for this object. /// is invalid for this object.
@@ -1186,7 +1183,7 @@ public:
virtual bool DeleteRange(const wxRichTextRange& range); virtual bool DeleteRange(const wxRichTextRange& range);
/// Returns true if the object is empty /// 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. /// Returns true if this object can merge itself with the given one.
virtual bool CanMerge(wxRichTextObject* object) const; virtual bool CanMerge(wxRichTextObject* object) const;
@@ -1240,7 +1237,7 @@ public:
// to conserve space. // to conserve space.
// If it's not a JPEG we can make use of 'image', already scaled, so we don't have to // 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. // 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 // Make an image block from the wxImage in the given
// format. // format.
@@ -1319,7 +1316,7 @@ public:
virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& rect, int descent, int style); virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& rect, int descent, int style);
/// Lay the item out /// 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 /// Get the object size for the given range. Returns false if the range
/// is invalid for this object. /// is invalid for this object.
@@ -1671,7 +1668,7 @@ class WXDLLIMPEXP_ADV wxRichTextCommand: public wxCommand
public: public:
// Ctor for one action // Ctor for one action
wxRichTextCommand(const wxString& name, wxRichTextCommandId id, wxRichTextBuffer* buffer, wxRichTextCommand(const wxString& name, wxRichTextCommandId id, wxRichTextBuffer* buffer,
wxRichTextCtrl* ctrl, bool ignoreFirstTime = FALSE); wxRichTextCtrl* ctrl, bool ignoreFirstTime = false);
// Ctor for multiple actions // Ctor for multiple actions
wxRichTextCommand(const wxString& name); wxRichTextCommand(const wxString& name);
@@ -1700,7 +1697,7 @@ class WXDLLIMPEXP_ADV wxRichTextAction: public wxObject
{ {
public: public:
wxRichTextAction(wxRichTextCommand* cmd, const wxString& name, wxRichTextCommandId id, wxRichTextBuffer* buffer, wxRichTextAction(wxRichTextCommand* cmd, const wxString& name, wxRichTextCommandId id, wxRichTextBuffer* buffer,
wxRichTextCtrl* ctrl, bool ignoreFirstTime = FALSE); wxRichTextCtrl* ctrl, bool ignoreFirstTime = false);
~wxRichTextAction(); ~wxRichTextAction();
@@ -1771,12 +1768,14 @@ public:
{ } { }
#if wxUSE_STREAMS #if wxUSE_STREAMS
virtual bool LoadFile(wxRichTextBuffer *buffer, wxInputStream& stream) = 0; bool LoadFile(wxRichTextBuffer *buffer, wxInputStream& stream)
virtual bool SaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream) = 0; { return DoLoadFile(buffer, stream); }
bool SaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream)
{ return DoSaveFile(buffer, stream); }
#endif #endif
virtual bool LoadFile(wxRichTextBuffer *buffer, const wxString& filename); bool LoadFile(wxRichTextBuffer *buffer, const wxString& filename);
virtual bool SaveFile(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. /// Can we handle this filename (if using files)? By default, checks the extension.
virtual bool CanHandle(const wxString& filename) const; virtual bool CanHandle(const wxString& filename) const;
@@ -1802,6 +1801,11 @@ public:
protected: 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_name;
wxString m_extension; wxString m_extension;
int m_type; int m_type;
@@ -1821,11 +1825,6 @@ public:
: wxRichTextFileHandler(name, ext, type) : 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? /// Can we save using this handler?
virtual bool CanSave() const { return true; } virtual bool CanSave() const { return true; }
@@ -1834,6 +1833,11 @@ public:
protected: 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 #endif
// _WX_RICHTEXTBUFFER_H_ // _WX_RICHTEXTBUFFER_H_

View File

@@ -1,10 +1,10 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: richtextctrl.h // Name: wx/richtext/richtextctrl.h
// Purpose: A rich edit control // Purpose: A rich edit control
// Author: Julian Smart // Author: Julian Smart
// Modified by: // Modified by:
// Created: 2005-09-30 // Created: 2005-09-30
// RCS-ID: // RCS-ID: $Id$
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@@ -84,7 +84,7 @@ class WXDLLIMPEXP_ADV wxRichTextCtrl:
#else #else
public wxScrolledWindow public wxScrolledWindow
#endif #endif
{ {
DECLARE_CLASS( wxRichTextCtrl ) DECLARE_CLASS( wxRichTextCtrl )
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
@@ -520,7 +520,7 @@ public:
// Show a context menu for Rich Edit controls (the standard // Show a context menu for Rich Edit controls (the standard
// EDIT control has one already) // EDIT control has one already)
void OnContextMenu(wxContextMenuEvent& event); void OnContextMenu(wxContextMenuEvent& event);
// Event handlers // Event handlers
/// Painting /// Painting
@@ -568,7 +568,7 @@ public:
/// Paint the background /// Paint the background
virtual void PaintBackground(wxDC& dc); virtual void PaintBackground(wxDC& dc);
/// Recreate buffer bitmap if necessary /// Recreate buffer bitmap if necessary
virtual bool RecreateBuffer(const wxSize& size = wxDefaultSize); virtual bool RecreateBuffer(const wxSize& size = wxDefaultSize);
@@ -652,7 +652,7 @@ public:
// Data members // Data members
private: private:
/// Allows nested Freeze/Thaw /// Allows nested Freeze/Thaw
int m_freezeCount; int m_freezeCount;
/// Buffer bitmap /// Buffer bitmap

View File

@@ -1,10 +1,10 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: richeditxml.h // Name: wx/richtext/richeditxml.h
// Purpose: XML and HTML I/O for wxRichTextCtrl // Purpose: XML and HTML I/O for wxRichTextCtrl
// Author: Julian Smart // Author: Julian Smart
// Modified by: // Modified by:
// Created: 2005-09-30 // Created: 2005-09-30
// RCS-ID: // RCS-ID: $Id$
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@@ -37,8 +37,8 @@ public:
{ } { }
#if wxUSE_STREAMS #if wxUSE_STREAMS
virtual bool LoadFile(wxRichTextBuffer *buffer, wxInputStream& stream); virtual bool DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& stream);
virtual bool SaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream); virtual bool DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream);
/// Recursively export an object /// Recursively export an object
bool ExportXML(wxOutputStream& stream, wxMBConv* convMem, wxMBConv* convFile, wxRichTextObject& obj, int level); bool ExportXML(wxOutputStream& stream, wxMBConv* convMem, wxMBConv* convFile, wxRichTextObject& obj, int level);
@@ -84,8 +84,8 @@ public:
{ } { }
#if wxUSE_STREAMS #if wxUSE_STREAMS
virtual bool LoadFile(wxRichTextBuffer *buffer, wxInputStream& stream); virtual bool DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& stream);
virtual bool SaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream); virtual bool DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream);
#endif #endif
/// Can we save using this handler? /// Can we save using this handler?

File diff suppressed because it is too large Load Diff

View File

@@ -1,10 +1,10 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: richeditctrl.cpp // Name: richtext/richeditctrl.cpp
// Purpose: A rich edit control // Purpose: A rich edit control
// Author: Julian Smart // Author: Julian Smart
// Modified by: // Modified by:
// Created: 2005-09-30 // Created: 2005-09-30
// RCS-ID: // RCS-ID: $Id$
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@@ -128,7 +128,7 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos
{ {
SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
} }
GetBuffer().SetRichTextCtrl(this); GetBuffer().SetRichTextCtrl(this);
wxTextAttrEx attributes; wxTextAttrEx attributes;
@@ -141,12 +141,12 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos
SetDefaultStyle(attributes); SetDefaultStyle(attributes);
SetBasicStyle(attributes); SetBasicStyle(attributes);
SetBackgroundColour(*wxWHITE); SetBackgroundColour(*wxWHITE);
SetBackgroundStyle(wxBG_STYLE_CUSTOM); 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); SetBestFittingSize(size);
// Create a buffer // Create a buffer
RecreateBuffer(size); RecreateBuffer(size);
@@ -156,7 +156,7 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos
PositionCaret(); PositionCaret();
SetCursor(wxCursor(wxCURSOR_IBEAM)); SetCursor(wxCursor(wxCURSOR_IBEAM));
return true; return true;
} }
@@ -225,14 +225,14 @@ void wxRichTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
return; return;
dc.SetFont(GetFont()); dc.SetFont(GetFont());
// Paint the background // Paint the background
PaintBackground(dc); PaintBackground(dc);
wxRegion dirtyRegion = GetUpdateRegion(); wxRegion dirtyRegion = GetUpdateRegion();
wxRect drawingArea(GetLogicalPoint(wxPoint(0, 0)), GetClientSize()); wxRect drawingArea(GetLogicalPoint(wxPoint(0, 0)), GetClientSize());
wxRect availableSpace(wxPoint(0, 0), GetClientSize()); wxRect availableSpace(GetClientSize());
if (GetBuffer().GetDirty()) if (GetBuffer().GetDirty())
{ {
GetBuffer().Layout(dc, availableSpace, GetBuffer().GetRange(), wxRICHTEXT_FIXED_WIDTH|wxRICHTEXT_VARIABLE_HEIGHT); GetBuffer().Layout(dc, availableSpace, GetBuffer().GetRange(), wxRICHTEXT_FIXED_WIDTH|wxRICHTEXT_VARIABLE_HEIGHT);
@@ -269,7 +269,7 @@ void wxRichTextCtrl::OnLeftClick(wxMouseEvent& event)
wxClientDC dc(this); wxClientDC dc(this);
PrepareDC(dc); PrepareDC(dc);
dc.SetFont(GetFont()); dc.SetFont(GetFont());
long position = 0; long position = 0;
int hit = GetBuffer().HitTest(dc, event.GetLogicalPosition(dc), position); int hit = GetBuffer().HitTest(dc, event.GetLogicalPosition(dc), position);
@@ -339,7 +339,7 @@ void wxRichTextCtrl::OnMoveMouse(wxMouseEvent& event)
wxClientDC dc(this); wxClientDC dc(this);
PrepareDC(dc); PrepareDC(dc);
dc.SetFont(GetFont()); dc.SetFont(GetFont());
long position = 0; long position = 0;
wxPoint logicalPt = event.GetLogicalPosition(dc); wxPoint logicalPt = event.GetLogicalPosition(dc);
int hit = GetBuffer().HitTest(dc, logicalPt, position); int hit = GetBuffer().HitTest(dc, logicalPt, position);
@@ -366,10 +366,10 @@ void wxRichTextCtrl::OnMoveMouse(wxMouseEvent& event)
if (m_caretPosition != position) if (m_caretPosition != position)
{ {
bool extendSel = ExtendSelection(m_caretPosition, position, wxRICHTEXT_SHIFT_DOWN); bool extendSel = ExtendSelection(m_caretPosition, position, wxRICHTEXT_SHIFT_DOWN);
MoveCaret(position, caretAtLineStart); MoveCaret(position, caretAtLineStart);
SetDefaultStyleToCursorStyle(); SetDefaultStyleToCursorStyle();
if (extendSel) if (extendSel)
Refresh(); Refresh();
} }
@@ -663,7 +663,7 @@ bool wxRichTextCtrl::ExtendSelection(long oldPos, long newPos, int flags)
{ {
wxLogDebug(wxT("Strange selection range")); wxLogDebug(wxT("Strange selection range"));
} }
return true; return true;
} }
else else
@@ -809,7 +809,7 @@ void wxRichTextCtrl::MoveCaretForward(long oldPosition)
// the same position but indicate that we're to show // the same position but indicate that we're to show
// at the start of the next line. // at the start of the next line.
m_caretPosition = oldPosition; m_caretPosition = oldPosition;
m_caretAtLineStart = true; m_caretAtLineStart = true;
} }
SetDefaultStyleToCursorStyle(); SetDefaultStyleToCursorStyle();
return; return;
@@ -900,7 +900,7 @@ bool wxRichTextCtrl::MoveRight(int noPositions, int flags)
return true; return true;
} }
else else
return false; return false;
} }
/// Move left /// Move left
@@ -929,7 +929,7 @@ bool wxRichTextCtrl::MoveLeft(int noPositions, int flags)
return true; return true;
} }
else else
return false; return false;
} }
/// Move up /// Move up
@@ -963,8 +963,8 @@ bool wxRichTextCtrl::MoveDown(int noLines, int flags)
wxRichTextLine* lineObj = GetBuffer().GetLineForVisibleLineNumber(newLine); wxRichTextLine* lineObj = GetBuffer().GetLineForVisibleLineNumber(newLine);
if (lineObj) if (lineObj)
{ {
pt.y = lineObj->GetAbsolutePosition().y + 2; pt.y = lineObj->GetAbsolutePosition().y + 2;
} }
else else
return false; return false;
@@ -973,9 +973,9 @@ bool wxRichTextCtrl::MoveDown(int noLines, int flags)
wxClientDC dc(this); wxClientDC dc(this);
PrepareDC(dc); PrepareDC(dc);
dc.SetFont(GetFont()); dc.SetFont(GetFont());
int hitTest = GetBuffer().HitTest(dc, pt, newPos); int hitTest = GetBuffer().HitTest(dc, pt, newPos);
if (hitTest != wxRICHTEXT_HITTEST_NONE) if (hitTest != wxRICHTEXT_HITTEST_NONE)
{ {
// If end of previous line, and hitTest is wxRICHTEXT_HITTEST_BEFORE, // If end of previous line, and hitTest is wxRICHTEXT_HITTEST_BEFORE,
@@ -1127,7 +1127,7 @@ bool wxRichTextCtrl::MoveHome(int flags)
return true; return true;
} }
else else
return false; return false;
} }
/// Move to the end of the buffer /// Move to the end of the buffer
@@ -1149,7 +1149,7 @@ bool wxRichTextCtrl::MoveEnd(int flags)
return true; return true;
} }
else else
return false; return false;
} }
/// Move noPages pages up /// Move noPages pages up
@@ -1195,19 +1195,19 @@ bool wxRichTextCtrl::PageDown(int noPages, int flags)
// Finds the caret position for the next word // Finds the caret position for the next word
long wxRichTextCtrl::FindNextWordPosition(int direction) const long wxRichTextCtrl::FindNextWordPosition(int direction) const
{ {
long endPos = GetBuffer().GetRange().GetEnd(); long endPos = GetBuffer().GetRange().GetEnd();
if (direction > 0) if (direction > 0)
{ {
long i = m_caretPosition+1+direction; // +1 for conversion to character pos long i = m_caretPosition+1+direction; // +1 for conversion to character pos
// First skip current text to space // First skip current text to space
while (i < endPos && i > -1) while (i < endPos && i > -1)
{ {
// i is in character, not caret positions // i is in character, not caret positions
wxString text = GetBuffer().GetTextForRange(wxRichTextRange(i, i)); wxString text = GetBuffer().GetTextForRange(wxRichTextRange(i, i));
if (text != wxT(" ") && !text.IsEmpty()) if (text != wxT(" ") && !text.empty())
i += direction; i += direction;
else else
{ {
@@ -1218,9 +1218,9 @@ long wxRichTextCtrl::FindNextWordPosition(int direction) const
{ {
// i is in character, not caret positions // i is in character, not caret positions
wxString text = GetBuffer().GetTextForRange(wxRichTextRange(i, i)); 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); return wxMax(-1, i - 1);
else if (text == wxT(" ") || text.IsEmpty()) else if (text == wxT(" ") || text.empty())
i += direction; i += direction;
else else
{ {
@@ -1241,9 +1241,9 @@ long wxRichTextCtrl::FindNextWordPosition(int direction) const
{ {
// i is in character, not caret positions // i is in character, not caret positions
wxString text = GetBuffer().GetTextForRange(wxRichTextRange(i, i)); 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; break;
else if (text == wxT(" ") || text.IsEmpty()) else if (text == wxT(" ") || text.empty())
i += direction; i += direction;
else else
break; break;
@@ -1253,12 +1253,11 @@ long wxRichTextCtrl::FindNextWordPosition(int direction) const
{ {
// i is in character, not caret positions // i is in character, not caret positions
wxString text = GetBuffer().GetTextForRange(wxRichTextRange(i, i)); wxString text = GetBuffer().GetTextForRange(wxRichTextRange(i, i));
if (text != wxT(" ") /* && !text.IsEmpty() */) if (text != wxT(" ") /* && !text.empty() */)
i += direction; i += direction;
else else
{ {
return i; return i;
break;
} }
} }
if (i < -1) if (i < -1)
@@ -1274,10 +1273,10 @@ bool wxRichTextCtrl::WordLeft(int WXUNUSED(n), int flags)
if (pos != m_caretPosition) if (pos != m_caretPosition)
{ {
wxRichTextParagraph* para = GetBuffer().GetParagraphAtPosition(pos, true); wxRichTextParagraph* para = GetBuffer().GetParagraphAtPosition(pos, true);
if (!ExtendSelection(m_caretPosition, pos, flags)) if (!ExtendSelection(m_caretPosition, pos, flags))
SelectNone(); SelectNone();
SetCaretPosition(pos, para->GetRange().GetStart() != pos); SetCaretPosition(pos, para->GetRange().GetStart() != pos);
PositionCaret(); PositionCaret();
SetDefaultStyleToCursorStyle(); SetDefaultStyleToCursorStyle();
@@ -1286,7 +1285,7 @@ bool wxRichTextCtrl::WordLeft(int WXUNUSED(n), int flags)
Refresh(); Refresh();
return true; return true;
} }
return false; return false;
} }
@@ -1297,10 +1296,10 @@ bool wxRichTextCtrl::WordRight(int WXUNUSED(n), int flags)
if (pos != m_caretPosition) if (pos != m_caretPosition)
{ {
wxRichTextParagraph* para = GetBuffer().GetParagraphAtPosition(pos, true); wxRichTextParagraph* para = GetBuffer().GetParagraphAtPosition(pos, true);
if (!ExtendSelection(m_caretPosition, pos, flags)) if (!ExtendSelection(m_caretPosition, pos, flags))
SelectNone(); SelectNone();
SetCaretPosition(pos, para->GetRange().GetStart() != pos); SetCaretPosition(pos, para->GetRange().GetStart() != pos);
PositionCaret(); PositionCaret();
SetDefaultStyleToCursorStyle(); SetDefaultStyleToCursorStyle();
@@ -1309,7 +1308,7 @@ bool wxRichTextCtrl::WordRight(int WXUNUSED(n), int flags)
Refresh(); Refresh();
return true; return true;
} }
return false; return false;
} }
@@ -1317,7 +1316,7 @@ bool wxRichTextCtrl::WordRight(int WXUNUSED(n), int flags)
void wxRichTextCtrl::OnSize(wxSizeEvent& event) void wxRichTextCtrl::OnSize(wxSizeEvent& event)
{ {
GetBuffer().SetDirty(true); GetBuffer().SetDirty(true);
RecreateBuffer(); RecreateBuffer();
event.Skip(); event.Skip();
@@ -1346,10 +1345,10 @@ void wxRichTextCtrl::SetupScrollbars()
int startX, startY; int startX, startY;
GetViewStart(& startX, & startY); GetViewStart(& startX, & startY);
int maxPositionX = 0; // wxMax(sz.x - clientSize.x, 0); int maxPositionX = 0; // wxMax(sz.x - clientSize.x, 0);
int maxPositionY = (wxMax(maxHeight - clientSize.y, 0))/pixelsPerUnit; int maxPositionY = (wxMax(maxHeight - clientSize.y, 0))/pixelsPerUnit;
// Move to previous scroll position if // Move to previous scroll position if
// possible // possible
SetScrollbars(0, pixelsPerUnit, SetScrollbars(0, pixelsPerUnit,
@@ -1367,10 +1366,10 @@ void wxRichTextCtrl::PaintBackground(wxDC& dc)
// Clear the background // Clear the background
dc.SetBrush(wxBrush(backgroundColour)); dc.SetBrush(wxBrush(backgroundColour));
dc.SetPen(*wxTRANSPARENT_PEN); dc.SetPen(*wxTRANSPARENT_PEN);
wxRect windowRect(wxPoint(0, 0), GetClientSize()); wxRect windowRect(GetClientSize());
windowRect.x -= 2; windowRect.y -= 2; windowRect.x -= 2; windowRect.y -= 2;
windowRect.width += 4; windowRect.height += 4; windowRect.width += 4; windowRect.height += 4;
// We need to shift the rectangle to take into account // We need to shift the rectangle to take into account
// scrolling. Converting device to logical coordinates. // scrolling. Converting device to logical coordinates.
CalcUnscrolledPosition(windowRect.x, windowRect.y, & windowRect.x, & windowRect.y); CalcUnscrolledPosition(windowRect.x, windowRect.y, & windowRect.x, & windowRect.y);
@@ -1383,10 +1382,10 @@ bool wxRichTextCtrl::RecreateBuffer(const wxSize& size)
wxSize sz = size; wxSize sz = size;
if (sz == wxDefaultSize) if (sz == wxDefaultSize)
sz = GetClientSize(); sz = GetClientSize();
if (sz.x < 1 || sz.y < 1) if (sz.x < 1 || sz.y < 1)
return false; return false;
if (!m_bufferBitmap.Ok() || m_bufferBitmap.GetWidth() < sz.x || m_bufferBitmap.GetHeight() < sz.y) if (!m_bufferBitmap.Ok() || m_bufferBitmap.GetWidth() < sz.x || m_bufferBitmap.GetHeight() < sz.y)
m_bufferBitmap = wxBitmap(sz.x, sz.y); m_bufferBitmap = wxBitmap(sz.x, sz.y);
return m_bufferBitmap.Ok(); return m_bufferBitmap.Ok();
@@ -1414,7 +1413,7 @@ bool wxRichTextCtrl::LoadFile(const wxString& filename, int type)
else else
{ {
wxLogError(_("File couldn't be loaded.")); wxLogError(_("File couldn't be loaded."));
return false; return false;
} }
} }
@@ -1630,7 +1629,7 @@ bool wxRichTextCtrl::WriteImage(const wxBitmap& bitmap, int bitmapType)
if (bitmap.Ok()) if (bitmap.Ok())
{ {
wxRichTextImageBlock imageBlock; wxRichTextImageBlock imageBlock;
wxImage image = bitmap.ConvertToImage(); wxImage image = bitmap.ConvertToImage();
if (image.Ok() && imageBlock.MakeImageBlock(image, bitmapType)) if (image.Ok() && imageBlock.MakeImageBlock(image, bitmapType))
return WriteImage(imageBlock); return WriteImage(imageBlock);
@@ -1678,10 +1677,10 @@ void wxRichTextCtrl::Paste()
if (CanPaste()) if (CanPaste())
{ {
BeginBatchUndo(_("Paste")); BeginBatchUndo(_("Paste"));
long newPos = m_caretPosition; long newPos = m_caretPosition;
DeleteSelectedContent(& newPos); DeleteSelectedContent(& newPos);
GetBuffer().PasteFromClipboard(newPos); GetBuffer().PasteFromClipboard(newPos);
EndBatchUndo(); EndBatchUndo();
@@ -2147,7 +2146,7 @@ bool wxRichTextCtrl::GetCaretPositionForIndex(long position, wxRect& rect)
{ {
wxClientDC dc(this); wxClientDC dc(this);
dc.SetFont(GetFont()); dc.SetFont(GetFont());
PrepareDC(dc); PrepareDC(dc);
wxPoint pt; wxPoint pt;
@@ -2205,7 +2204,7 @@ bool wxRichTextCtrl::MoveCaret(long pos, bool showAtLineStart)
/// setting the caret position. /// setting the caret position.
bool wxRichTextCtrl::Layout() bool wxRichTextCtrl::Layout()
{ {
wxRect availableSpace(wxPoint(0, 0), GetClientSize()); wxRect availableSpace(GetClientSize());
if (availableSpace.width == 0) if (availableSpace.width == 0)
availableSpace.width = 10; availableSpace.width = 10;
if (availableSpace.height == 0) if (availableSpace.height == 0)
@@ -2213,14 +2212,14 @@ bool wxRichTextCtrl::Layout()
wxClientDC dc(this); wxClientDC dc(this);
dc.SetFont(GetFont()); dc.SetFont(GetFont());
PrepareDC(dc); PrepareDC(dc);
GetBuffer().Defragment(); GetBuffer().Defragment();
GetBuffer().UpdateRanges(); // If items were deleted, ranges need recalculation GetBuffer().UpdateRanges(); // If items were deleted, ranges need recalculation
GetBuffer().Layout(dc, availableSpace, GetBuffer().GetRange(), wxRICHTEXT_FIXED_WIDTH|wxRICHTEXT_VARIABLE_HEIGHT); GetBuffer().Layout(dc, availableSpace, GetBuffer().GetRange(), wxRICHTEXT_FIXED_WIDTH|wxRICHTEXT_VARIABLE_HEIGHT);
GetBuffer().SetDirty(false); GetBuffer().SetDirty(false);
if (!IsFrozen()) if (!IsFrozen())
SetupScrollbars(); SetupScrollbars();
@@ -2236,7 +2235,7 @@ bool wxRichTextCtrl::IsSelectionBold() const
wxRichTextRange range = GetSelectionRange(); wxRichTextRange range = GetSelectionRange();
attr.SetFlags(wxTEXT_ATTR_FONT_WEIGHT); attr.SetFlags(wxTEXT_ATTR_FONT_WEIGHT);
attr.SetFontWeight(wxBOLD); attr.SetFontWeight(wxBOLD);
return HasCharacterAttributes(range, attr); return HasCharacterAttributes(range, attr);
} }
else else
@@ -2263,7 +2262,7 @@ bool wxRichTextCtrl::IsSelectionItalics() const
wxRichTextAttr attr; wxRichTextAttr attr;
attr.SetFlags(wxTEXT_ATTR_FONT_ITALIC); attr.SetFlags(wxTEXT_ATTR_FONT_ITALIC);
attr.SetFontStyle(wxITALIC); attr.SetFontStyle(wxITALIC);
return HasCharacterAttributes(range, attr); return HasCharacterAttributes(range, attr);
} }
else else
@@ -2290,7 +2289,7 @@ bool wxRichTextCtrl::IsSelectionUnderlined() const
wxRichTextAttr attr; wxRichTextAttr attr;
attr.SetFlags(wxTEXT_ATTR_FONT_UNDERLINE); attr.SetFlags(wxTEXT_ATTR_FONT_UNDERLINE);
attr.SetFontUnderlined(true); attr.SetFontUnderlined(true);
return HasCharacterAttributes(range, attr); return HasCharacterAttributes(range, attr);
} }
else else
@@ -2358,7 +2357,7 @@ bool wxRichTextCtrl::IsSelectionAligned(wxTextAttrAlignment alignment) const
wxRichTextRange range = GetSelectionRange(); wxRichTextRange range = GetSelectionRange();
wxRichTextAttr attr; wxRichTextAttr attr;
attr.SetAlignment(alignment); attr.SetAlignment(alignment);
return HasParagraphAttributes(range, attr); return HasParagraphAttributes(range, attr);
} }
else else

View File

@@ -1,10 +1,10 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: richtextxml.cpp // Name: richtext/richtextxml.cpp
// Purpose: XML and HTML I/O for wxRichTextCtrl // Purpose: XML and HTML I/O for wxRichTextCtrl
// Author: Julian Smart // Author: Julian Smart
// Modified by: // Modified by:
// Created: 2005-09-30 // Created: 2005-09-30
// RCS-ID: // RCS-ID: $Id$
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@@ -37,7 +37,7 @@
IMPLEMENT_DYNAMIC_CLASS(wxRichTextXMLHandler, wxRichTextFileHandler) IMPLEMENT_DYNAMIC_CLASS(wxRichTextXMLHandler, wxRichTextFileHandler)
#if wxUSE_STREAMS #if wxUSE_STREAMS
bool wxRichTextXMLHandler::LoadFile(wxRichTextBuffer *buffer, wxInputStream& stream) bool wxRichTextXMLHandler::DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& stream)
{ {
if (!stream.IsOk()) if (!stream.IsOk())
return false; return false;
@@ -67,7 +67,7 @@ bool wxRichTextXMLHandler::LoadFile(wxRichTextBuffer *buffer, wxInputStream& str
else else
ImportXML(buffer, child); ImportXML(buffer, child);
} }
child = child->GetNext(); child = child->GetNext();
} }
} }
@@ -76,7 +76,7 @@ bool wxRichTextXMLHandler::LoadFile(wxRichTextBuffer *buffer, wxInputStream& str
success = false; success = false;
} }
} }
delete xmlDoc; delete xmlDoc;
buffer->UpdateRanges(); buffer->UpdateRanges();
@@ -145,7 +145,7 @@ bool wxRichTextXMLHandler::ImportXML(wxRichTextBuffer* buffer, wxXmlNode* node)
{ {
int imageType = wxBITMAP_TYPE_PNG; int imageType = wxBITMAP_TYPE_PNG;
wxString value = node->GetPropVal(wxT("imagetype"), wxEmptyString); wxString value = node->GetPropVal(wxT("imagetype"), wxEmptyString);
if (!value.IsEmpty()) if (!value.empty())
imageType = wxAtoi(value); imageType = wxAtoi(value);
wxString data; wxString data;
@@ -163,12 +163,12 @@ bool wxRichTextXMLHandler::ImportXML(wxRichTextBuffer* buffer, wxXmlNode* node)
// wxLogDebug(data); // wxLogDebug(data);
dataChild = dataChild->GetNext(); dataChild = dataChild->GetNext();
} }
} }
imageChild = imageChild->GetNext(); imageChild = imageChild->GetNext();
} }
if (!data.IsEmpty()) if (!data.empty())
{ {
wxRichTextImage* imageObj = new wxRichTextImage(para); wxRichTextImage* imageObj = new wxRichTextImage(para);
para->AppendChild(imageObj); para->AppendChild(imageObj);
@@ -192,7 +192,7 @@ bool wxRichTextXMLHandler::ImportXML(wxRichTextBuffer* buffer, wxXmlNode* node)
ImportXML(buffer, child); ImportXML(buffer, child);
child = child->GetNext(); child = child->GetNext();
} }
} }
return true; return true;
} }
@@ -242,7 +242,7 @@ wxString wxRichTextXMLHandler::GetNodeContent(wxXmlNode *node)
wxString wxRichTextXMLHandler::GetParamValue(wxXmlNode *node, const wxString& param) wxString wxRichTextXMLHandler::GetParamValue(wxXmlNode *node, const wxString& param)
{ {
if (param.IsEmpty()) if (param.empty())
return GetNodeContent(node); return GetNodeContent(node);
else else
return GetNodeContent(GetParamNode(node, param)); return GetNodeContent(GetParamNode(node, param));
@@ -259,9 +259,9 @@ wxString wxRichTextXMLHandler::GetText(wxXmlNode *node, const wxString& param, b
// write string to output: // write string to output:
inline static void OutputString(wxOutputStream& stream, const wxString& str, 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 #if wxUSE_UNICODE
const wxWX2MBbuf buf(str.mb_str(convFile ? *convFile : wxConvUTF8)); const wxWX2MBbuf buf(str.mb_str(convFile ? *convFile : wxConvUTF8));
stream.Write((const char*)buf, strlen((const char*)buf)); stream.Write((const char*)buf, strlen((const char*)buf));
@@ -284,7 +284,7 @@ static void OutputStringEnt(wxOutputStream& stream, const wxString& str,
wxString buf; wxString buf;
size_t i, last, len; size_t i, last, len;
wxChar c; wxChar c;
len = str.Len(); len = str.Len();
last = 0; last = 0;
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
@@ -359,17 +359,14 @@ static wxString ColourToHexString(const wxColour& col)
// Convert 6-digit hex string to a colour // Convert 6-digit hex string to a colour
wxColour HexStringToColour(const wxString& hex) wxColour HexStringToColour(const wxString& hex)
{ {
unsigned int r = 0; unsigned char r = (unsigned char)wxHexToDec(hex.Mid(0, 2));
unsigned int g = 0; unsigned char g = (unsigned char)wxHexToDec(hex.Mid(2, 2));
unsigned int b = 0; unsigned char b = (unsigned char)wxHexToDec(hex.Mid(4, 2));
r = wxHexToDec(hex.Mid(0, 2));
g = wxHexToDec(hex.Mid(2, 2));
b = wxHexToDec(hex.Mid(4, 2));
return wxColour(r, g, b); return wxColour(r, g, b);
} }
bool wxRichTextXMLHandler::SaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream) bool wxRichTextXMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream)
{ {
if (!stream.IsOk()) if (!stream.IsOk())
return false; return false;
@@ -383,7 +380,7 @@ bool wxRichTextXMLHandler::SaveFile(wxRichTextBuffer *buffer, wxOutputStream& st
wxString memencoding(wxT("ISO-8859-1")) ; wxString memencoding(wxT("ISO-8859-1")) ;
#endif #endif
wxString s ; wxString s ;
wxMBConv *convMem = NULL, *convFile = NULL; wxMBConv *convMem = NULL, *convFile = NULL;
#if wxUSE_UNICODE #if wxUSE_UNICODE
convFile = new wxCSConv(fileencoding); convFile = new wxCSConv(fileencoding);
@@ -394,7 +391,7 @@ bool wxRichTextXMLHandler::SaveFile(wxRichTextBuffer *buffer, wxOutputStream& st
convMem = new wxCSConv(memencoding); convMem = new wxCSConv(memencoding);
} }
#endif #endif
s.Printf(wxT("<?xml version=\"%s\" encoding=\"%s\"?>\n"), s.Printf(wxT("<?xml version=\"%s\" encoding=\"%s\"?>\n"),
(const wxChar*) version, (const wxChar*) fileencoding ); (const wxChar*) version, (const wxChar*) fileencoding );
OutputString(stream, s, NULL, NULL); OutputString(stream, s, NULL, NULL);
@@ -405,7 +402,7 @@ bool wxRichTextXMLHandler::SaveFile(wxRichTextBuffer *buffer, wxOutputStream& st
OutputString(stream, wxT("\n</richtext>") , NULL, NULL); OutputString(stream, wxT("\n</richtext>") , NULL, NULL);
OutputString(stream, wxT("\n"), NULL, NULL); OutputString(stream, wxT("\n"), NULL, NULL);
delete convFile; delete convFile;
delete convMem; delete convMem;
@@ -433,11 +430,11 @@ bool wxRichTextXMLHandler::ExportXML(wxOutputStream& stream, wxMBConv* convMem,
OutputIndentation(stream, indent); OutputIndentation(stream, indent);
stream << wxT("<") << objectName; stream << wxT("<") << objectName;
wxString style = CreateStyle(obj.GetAttributes(), false); wxString style = CreateStyle(obj.GetAttributes(), false);
stream << style << wxT(">"); stream << style << wxT(">");
wxString str = text.GetText(); wxString str = text.GetText();
if (str.Length() > 0 && (str[0] == wxT(' ') || str[str.Length()-1] == wxT(' '))) 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); OutputIndentation(stream, indent);
stream << wxT("<") << objectName; stream << wxT("<") << objectName;
bool isPara = false; bool isPara = false;
if (objectName == wxT("paragraph") || objectName == wxT("paragraphlayout")) if (objectName == wxT("paragraph") || objectName == wxT("paragraphlayout"))
isPara = true; isPara = true;
wxString style = CreateStyle(obj.GetAttributes(), isPara); wxString style = CreateStyle(obj.GetAttributes(), isPara);
stream << style << wxT(">"); stream << style << wxT(">");
wxRichTextCompositeObject& composite = (wxRichTextCompositeObject&) obj; wxRichTextCompositeObject& composite = (wxRichTextCompositeObject&) obj;
size_t i; size_t i;
for (i = 0; i < composite.GetChildCount(); 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("\""); str << wxT(" fontface=\"") << attr.GetFont().GetFaceName() << wxT("\"");
} }
if (!attr.GetCharacterStyleName().IsEmpty()) if (!attr.GetCharacterStyleName().empty())
str << wxT(" charactertyle=\"") << wxString(attr.GetCharacterStyleName()) << wxT("\""); str << wxT(" charactertyle=\"") << wxString(attr.GetCharacterStyleName()) << wxT("\"");
if (isPara) if (isPara)
@@ -543,7 +540,7 @@ wxString wxRichTextXMLHandler::CreateStyle(const wxTextAttrEx& attr, bool isPara
str << wxT(" bulletnumber=\"") << (int) attr.GetBulletNumber() << wxT("\""); str << wxT(" bulletnumber=\"") << (int) attr.GetBulletNumber() << wxT("\"");
str << wxT(" bulletsymbol=\"") << wxString(attr.GetBulletSymbol()) << wxT("\""); str << wxT(" bulletsymbol=\"") << wxString(attr.GetBulletSymbol()) << wxT("\"");
if (!attr.GetParagraphStyleName().IsEmpty()) if (!attr.GetParagraphStyleName().empty())
str << wxT(" parstyle=\"") << wxString(attr.GetParagraphStyleName()) << wxT("\""); 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); fontFacename = node->GetPropVal(wxT("fontface"), wxEmptyString);
wxString value = node->GetPropVal(wxT("fontfamily"), wxEmptyString); wxString value = node->GetPropVal(wxT("fontfamily"), wxEmptyString);
if (!value.IsEmpty()) if (!value.empty())
fontFamily = wxAtoi(value); fontFamily = wxAtoi(value);
value = node->GetPropVal(wxT("fontstyle"), wxEmptyString); value = node->GetPropVal(wxT("fontstyle"), wxEmptyString);
if (!value.IsEmpty()) if (!value.empty())
fontStyle = wxAtoi(value); fontStyle = wxAtoi(value);
value = node->GetPropVal(wxT("fontsize"), wxEmptyString); value = node->GetPropVal(wxT("fontsize"), wxEmptyString);
if (!value.IsEmpty()) if (!value.empty())
fontSize = wxAtoi(value); fontSize = wxAtoi(value);
value = node->GetPropVal(wxT("fontweight"), wxEmptyString); value = node->GetPropVal(wxT("fontweight"), wxEmptyString);
if (!value.IsEmpty()) if (!value.empty())
fontWeight = wxAtoi(value); fontWeight = wxAtoi(value);
value = node->GetPropVal(wxT("fontunderlined"), wxEmptyString); value = node->GetPropVal(wxT("fontunderlined"), wxEmptyString);
if (!value.IsEmpty()) if (!value.empty())
fontUnderlined = wxAtoi(value) != 0; fontUnderlined = wxAtoi(value) != 0;
attr.SetFont(* wxTheFontList->FindOrCreateFont(fontSize, fontFamily, fontStyle, fontWeight, fontUnderlined, fontFacename)); attr.SetFont(* wxTheFontList->FindOrCreateFont(fontSize, fontFamily, fontStyle, fontWeight, fontUnderlined, fontFacename));
value = node->GetPropVal(wxT("textcolor"), wxEmptyString); value = node->GetPropVal(wxT("textcolor"), wxEmptyString);
if (!value.IsEmpty()) if (!value.empty())
{ {
if (value[0] == wxT('#')) if (value[0] == wxT('#'))
attr.SetTextColour(HexStringToColour(value.Mid(1))); 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); value = node->GetPropVal(wxT("backgroundcolor"), wxEmptyString);
if (!value.IsEmpty()) if (!value.empty())
{ {
if (value[0] == wxT('#')) if (value[0] == wxT('#'))
attr.SetBackgroundColour(HexStringToColour(value.Mid(1))); 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); value = node->GetPropVal(wxT("characterstyle"), wxEmptyString);
if (!value.IsEmpty()) if (!value.empty())
attr.SetCharacterStyleName(value); attr.SetCharacterStyleName(value);
// Set paragraph attributes // Set paragraph attributes
if (isPara) if (isPara)
{ {
value = node->GetPropVal(wxT("alignment"), wxEmptyString); value = node->GetPropVal(wxT("alignment"), wxEmptyString);
if (!value.IsEmpty()) if (!value.empty())
attr.SetAlignment((wxTextAttrAlignment) wxAtoi(value)); attr.SetAlignment((wxTextAttrAlignment) wxAtoi(value));
int leftSubIndent = 0; int leftSubIndent = 0;
int leftIndent = 0; int leftIndent = 0;
value = node->GetPropVal(wxT("leftindent"), wxEmptyString); value = node->GetPropVal(wxT("leftindent"), wxEmptyString);
if (!value.IsEmpty()) if (!value.empty())
leftIndent = wxAtoi(value); leftIndent = wxAtoi(value);
value = node->GetPropVal(wxT("leftsubindent"), wxEmptyString); value = node->GetPropVal(wxT("leftsubindent"), wxEmptyString);
if (!value.IsEmpty()) if (!value.empty())
leftSubIndent = wxAtoi(value); leftSubIndent = wxAtoi(value);
attr.SetLeftIndent(leftIndent, leftSubIndent); attr.SetLeftIndent(leftIndent, leftSubIndent);
value = node->GetPropVal(wxT("rightindent"), wxEmptyString); value = node->GetPropVal(wxT("rightindent"), wxEmptyString);
if (!value.IsEmpty()) if (!value.empty())
attr.SetRightIndent(wxAtoi(value)); attr.SetRightIndent(wxAtoi(value));
value = node->GetPropVal(wxT("parspacingbefore"), wxEmptyString); value = node->GetPropVal(wxT("parspacingbefore"), wxEmptyString);
if (!value.IsEmpty()) if (!value.empty())
attr.SetParagraphSpacingBefore(wxAtoi(value)); attr.SetParagraphSpacingBefore(wxAtoi(value));
value = node->GetPropVal(wxT("parspacingafter"), wxEmptyString); value = node->GetPropVal(wxT("parspacingafter"), wxEmptyString);
if (!value.IsEmpty()) if (!value.empty())
attr.SetParagraphSpacingAfter(wxAtoi(value)); attr.SetParagraphSpacingAfter(wxAtoi(value));
value = node->GetPropVal(wxT("linespacing"), wxEmptyString); value = node->GetPropVal(wxT("linespacing"), wxEmptyString);
if (!value.IsEmpty()) if (!value.empty())
attr.SetLineSpacing(wxAtoi(value)); attr.SetLineSpacing(wxAtoi(value));
value = node->GetPropVal(wxT("bulletstyle"), wxEmptyString); value = node->GetPropVal(wxT("bulletstyle"), wxEmptyString);
if (!value.IsEmpty()) if (!value.empty())
attr.SetBulletStyle(wxAtoi(value)); attr.SetBulletStyle(wxAtoi(value));
value = node->GetPropVal(wxT("bulletnumber"), wxEmptyString); value = node->GetPropVal(wxT("bulletnumber"), wxEmptyString);
if (!value.IsEmpty()) if (!value.empty())
attr.SetBulletNumber(wxAtoi(value)); attr.SetBulletNumber(wxAtoi(value));
value = node->GetPropVal(wxT("bulletsymbol"), wxEmptyString); value = node->GetPropVal(wxT("bulletsymbol"), wxEmptyString);
if (!value.IsEmpty()) if (!value.empty())
attr.SetBulletSymbol(value[0]); attr.SetBulletSymbol(value[0]);
value = node->GetPropVal(wxT("parstyle"), wxEmptyString); value = node->GetPropVal(wxT("parstyle"), wxEmptyString);
if (!value.IsEmpty()) if (!value.empty())
attr.SetParagraphStyleName(value); attr.SetParagraphStyleName(value);
} }
@@ -674,7 +671,7 @@ bool wxRichTextHTMLHandler::CanHandle(const wxString& filename) const
#if wxUSE_STREAMS #if wxUSE_STREAMS
bool wxRichTextHTMLHandler::LoadFile(wxRichTextBuffer *WXUNUSED(buffer), wxInputStream& WXUNUSED(stream)) bool wxRichTextHTMLHandler::DoLoadFile(wxRichTextBuffer *WXUNUSED(buffer), wxInputStream& WXUNUSED(stream))
{ {
return false; return false;
} }
@@ -683,7 +680,7 @@ bool wxRichTextHTMLHandler::LoadFile(wxRichTextBuffer *WXUNUSED(buffer), wxInput
* We need to output only _changes_ in character formatting. * 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(); buffer->Defragment();
@@ -719,7 +716,7 @@ bool wxRichTextHTMLHandler::SaveFile(wxRichTextBuffer *buffer, wxOutputStream& s
} }
node2 = node2->GetNext(); node2 = node2->GetNext();
} }
OutputParagraphFormatting(currentParaStyle, para->GetAttributes(), stream, false); OutputParagraphFormatting(currentParaStyle, para->GetAttributes(), stream, false);
@@ -805,4 +802,3 @@ void wxRichTextHTMLHandler::OutputParagraphFormatting(const wxTextAttrEx& WXUNUS
#endif #endif
// wxUSE_RICHTEXT // wxUSE_RICHTEXT