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:
@@ -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
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -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.
|
||||||
@@ -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_
|
||||||
|
|
||||||
|
@@ -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
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
@@ -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?
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: richtextbuffer.cpp
|
// Name: richtext/richtextbuffer.cpp
|
||||||
// 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
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -870,7 +870,7 @@ wxRichTextRange wxRichTextParagraphLayoutBox::AddParagraphs(const wxString& text
|
|||||||
|
|
||||||
i ++;
|
i ++;
|
||||||
}
|
}
|
||||||
if (!line.IsEmpty())
|
if (!line.empty())
|
||||||
{
|
{
|
||||||
lastPara = new wxRichTextParagraph(line, this, & style);
|
lastPara = new wxRichTextParagraph(line, this, & style);
|
||||||
//wxLogDebug("Para Face = %s", lastPara->GetAttributes().GetFont().GetFaceName());
|
//wxLogDebug("Para Face = %s", lastPara->GetAttributes().GetFont().GetFaceName());
|
||||||
@@ -1053,7 +1053,7 @@ bool wxRichTextParagraphLayoutBox::InsertFragment(long position, wxRichTextFragm
|
|||||||
// Ensure there's at least one object
|
// Ensure there's at least one object
|
||||||
if (finalPara->GetChildCount() == 0)
|
if (finalPara->GetChildCount() == 0)
|
||||||
{
|
{
|
||||||
wxRichTextPlainText* text = new wxRichTextPlainText(wxT(""));
|
wxRichTextPlainText* text = new wxRichTextPlainText(wxEmptyString);
|
||||||
text->SetAttributes(finalPara->GetAttributes());
|
text->SetAttributes(finalPara->GetAttributes());
|
||||||
|
|
||||||
finalPara->AppendChild(text);
|
finalPara->AppendChild(text);
|
||||||
@@ -1718,7 +1718,7 @@ void wxRichTextParagraphLayoutBox::Reset()
|
|||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
|
|
||||||
AddParagraph(wxT(""));
|
AddParagraph(wxEmptyString);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -1796,7 +1796,7 @@ bool wxRichTextParagraph::Draw(wxDC& dc, const wxRichTextRange& WXUNUSED(range),
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxString bulletText = GetBulletText();
|
wxString bulletText = GetBulletText();
|
||||||
if (!bulletText.IsEmpty())
|
if (!bulletText.empty())
|
||||||
{
|
{
|
||||||
if (GetAttributes().GetFont().Ok())
|
if (GetAttributes().GetFont().Ok())
|
||||||
dc.SetFont(GetAttributes().GetFont());
|
dc.SetFont(GetAttributes().GetFont());
|
||||||
@@ -2989,7 +2989,7 @@ wxString wxRichTextPlainText::GetTextForRange(const wxRichTextRange& range) cons
|
|||||||
bool wxRichTextPlainText::CanMerge(wxRichTextObject* object) const
|
bool wxRichTextPlainText::CanMerge(wxRichTextObject* object) const
|
||||||
{
|
{
|
||||||
return object->GetClassInfo() == CLASSINFO(wxRichTextPlainText) &&
|
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.
|
/// Returns true if this object merged itself with the given one.
|
||||||
@@ -3054,7 +3054,7 @@ void wxRichTextBuffer::Clear()
|
|||||||
void wxRichTextBuffer::Reset()
|
void wxRichTextBuffer::Reset()
|
||||||
{
|
{
|
||||||
DeleteChildren();
|
DeleteChildren();
|
||||||
AddParagraph(wxT(""));
|
AddParagraph(wxEmptyString);
|
||||||
GetCommandProcessor()->ClearCommands();
|
GetCommandProcessor()->ClearCommands();
|
||||||
Modify(false);
|
Modify(false);
|
||||||
}
|
}
|
||||||
@@ -3086,7 +3086,7 @@ bool wxRichTextBuffer::InsertNewlineWithUndo(long pos, wxRichTextCtrl* ctrl)
|
|||||||
wxTextAttrEx attr(GetBasicStyle());
|
wxTextAttrEx attr(GetBasicStyle());
|
||||||
wxRichTextApplyStyle(attr, GetDefaultStyle());
|
wxRichTextApplyStyle(attr, GetDefaultStyle());
|
||||||
|
|
||||||
wxRichTextParagraph* newPara = new wxRichTextParagraph(wxT(""), this, & attr);
|
wxRichTextParagraph* newPara = new wxRichTextParagraph(wxEmptyString, this, & attr);
|
||||||
action->GetNewParagraphs().AppendChild(newPara);
|
action->GetNewParagraphs().AppendChild(newPara);
|
||||||
action->GetNewParagraphs().UpdateRanges();
|
action->GetNewParagraphs().UpdateRanges();
|
||||||
action->GetNewParagraphs().SetPartialParagraph(false);
|
action->GetNewParagraphs().SetPartialParagraph(false);
|
||||||
@@ -3711,12 +3711,12 @@ bool wxRichTextBuffer::PasteFromClipboard(long position)
|
|||||||
/// Can we paste from the clipboard?
|
/// Can we paste from the clipboard?
|
||||||
bool wxRichTextBuffer::CanPasteFromClipboard() const
|
bool wxRichTextBuffer::CanPasteFromClipboard() const
|
||||||
{
|
{
|
||||||
bool canPaste = FALSE;
|
bool canPaste = false;
|
||||||
if (wxTheClipboard->Open())
|
if (wxTheClipboard->Open())
|
||||||
{
|
{
|
||||||
if (wxTheClipboard->IsSupported(wxDF_TEXT) || wxTheClipboard->IsSupported(wxDF_BITMAP))
|
if (wxTheClipboard->IsSupported(wxDF_TEXT) || wxTheClipboard->IsSupported(wxDF_BITMAP))
|
||||||
{
|
{
|
||||||
canPaste = TRUE;
|
canPaste = true;
|
||||||
}
|
}
|
||||||
wxTheClipboard->Close();
|
wxTheClipboard->Close();
|
||||||
}
|
}
|
||||||
@@ -3759,12 +3759,12 @@ IMPLEMENT_DYNAMIC_CLASS(wxRichTextModule, wxModule)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
wxRichTextCommand::wxRichTextCommand(const wxString& name, wxRichTextCommandId id, wxRichTextBuffer* buffer,
|
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);
|
/* 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)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4673,6 +4673,7 @@ void wxTextAttrEx::operator= (const wxTextAttr& attr)
|
|||||||
|
|
||||||
IMPLEMENT_CLASS(wxRichTextFileHandler, wxObject)
|
IMPLEMENT_CLASS(wxRichTextFileHandler, wxObject)
|
||||||
|
|
||||||
|
#if wxUSE_STREAMS
|
||||||
bool wxRichTextFileHandler::LoadFile(wxRichTextBuffer *buffer, const wxString& filename)
|
bool wxRichTextFileHandler::LoadFile(wxRichTextBuffer *buffer, const wxString& filename)
|
||||||
{
|
{
|
||||||
wxFFileInputStream stream(filename);
|
wxFFileInputStream stream(filename);
|
||||||
@@ -4690,6 +4691,7 @@ bool wxRichTextFileHandler::SaveFile(wxRichTextBuffer *buffer, const wxString& f
|
|||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif // wxUSE_STREAMS
|
||||||
|
|
||||||
/// 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.
|
||||||
bool wxRichTextFileHandler::CanHandle(const wxString& filename) const
|
bool wxRichTextFileHandler::CanHandle(const wxString& filename) const
|
||||||
@@ -4708,7 +4710,7 @@ bool wxRichTextFileHandler::CanHandle(const wxString& filename) const
|
|||||||
IMPLEMENT_CLASS(wxRichTextPlainTextHandler, wxRichTextFileHandler)
|
IMPLEMENT_CLASS(wxRichTextPlainTextHandler, wxRichTextFileHandler)
|
||||||
|
|
||||||
#if wxUSE_STREAMS
|
#if wxUSE_STREAMS
|
||||||
bool wxRichTextPlainTextHandler::LoadFile(wxRichTextBuffer *buffer, wxInputStream& stream)
|
bool wxRichTextPlainTextHandler::DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& stream)
|
||||||
{
|
{
|
||||||
if (!stream.IsOk())
|
if (!stream.IsOk())
|
||||||
return false;
|
return false;
|
||||||
@@ -4721,7 +4723,7 @@ bool wxRichTextPlainTextHandler::LoadFile(wxRichTextBuffer *buffer, wxInputStrea
|
|||||||
ch = stream.GetC();
|
ch = stream.GetC();
|
||||||
|
|
||||||
if (ch > 0)
|
if (ch > 0)
|
||||||
str += ch;
|
str += wxChar(ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer->Clear();
|
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())
|
if (!stream.IsOk())
|
||||||
return false;
|
return false;
|
||||||
@@ -4743,8 +4745,7 @@ bool wxRichTextPlainTextHandler::SaveFile(wxRichTextBuffer *buffer, wxOutputStre
|
|||||||
stream.Write((const char*) buf, text.Length());
|
stream.Write((const char*) buf, text.Length());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#endif // wxUSE_STREAMS
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Stores information about an image, in binary in-memory form
|
* 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;
|
m_imageType = imageType;
|
||||||
|
|
||||||
wxString filenameToRead(filename);
|
wxString filenameToRead(filename);
|
||||||
bool removeFile = FALSE;
|
bool removeFile = false;
|
||||||
|
|
||||||
if (imageType == -1)
|
if (imageType == -1)
|
||||||
return FALSE; // Could not determine image type
|
return false; // Could not determine image type
|
||||||
|
|
||||||
if ((imageType != wxBITMAP_TYPE_JPEG) && convertToJPEG)
|
if ((imageType != wxBITMAP_TYPE_JPEG) && convertToJPEG)
|
||||||
{
|
{
|
||||||
@@ -4814,13 +4815,13 @@ bool wxRichTextImageBlock::MakeImageBlock(const wxString& filename, int imageTyp
|
|||||||
|
|
||||||
image.SaveFile(tempFile, wxBITMAP_TYPE_JPEG);
|
image.SaveFile(tempFile, wxBITMAP_TYPE_JPEG);
|
||||||
filenameToRead = tempFile;
|
filenameToRead = tempFile;
|
||||||
removeFile = TRUE;
|
removeFile = true;
|
||||||
|
|
||||||
m_imageType = wxBITMAP_TYPE_JPEG;
|
m_imageType = wxBITMAP_TYPE_JPEG;
|
||||||
}
|
}
|
||||||
wxFile file;
|
wxFile file;
|
||||||
if (!file.Open(filenameToRead))
|
if (!file.Open(filenameToRead))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
m_dataSize = (size_t) file.Length();
|
m_dataSize = (size_t) file.Length();
|
||||||
file.Close();
|
file.Close();
|
||||||
@@ -4843,7 +4844,7 @@ bool wxRichTextImageBlock::MakeImageBlock(wxImage& image, int imageType, int qua
|
|||||||
image.SetOption(wxT("quality"), quality);
|
image.SetOption(wxT("quality"), quality);
|
||||||
|
|
||||||
if (imageType == -1)
|
if (imageType == -1)
|
||||||
return FALSE; // Could not determine image type
|
return false; // Could not determine image type
|
||||||
|
|
||||||
wxString tempFile;
|
wxString tempFile;
|
||||||
bool success = wxGetTempFileName(_("image"), tempFile) ;
|
bool success = wxGetTempFileName(_("image"), tempFile) ;
|
||||||
@@ -4855,12 +4856,12 @@ bool wxRichTextImageBlock::MakeImageBlock(wxImage& image, int imageType, int qua
|
|||||||
{
|
{
|
||||||
if (wxFileExists(tempFile))
|
if (wxFileExists(tempFile))
|
||||||
wxRemoveFile(tempFile);
|
wxRemoveFile(tempFile);
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFile file;
|
wxFile file;
|
||||||
if (!file.Open(tempFile))
|
if (!file.Open(tempFile))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
m_dataSize = (size_t) file.Length();
|
m_dataSize = (size_t) file.Length();
|
||||||
file.Close();
|
file.Close();
|
||||||
@@ -4909,7 +4910,7 @@ void wxRichTextImageBlock::operator=(const wxRichTextImageBlock& block)
|
|||||||
bool wxRichTextImageBlock::Load(wxImage& image)
|
bool wxRichTextImageBlock::Load(wxImage& image)
|
||||||
{
|
{
|
||||||
if (!m_data)
|
if (!m_data)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
// Read in the image.
|
// Read in the image.
|
||||||
#if 1
|
#if 1
|
||||||
@@ -4922,7 +4923,7 @@ bool wxRichTextImageBlock::Load(wxImage& image)
|
|||||||
|
|
||||||
if (!WriteBlock(tempFile, m_data, m_dataSize))
|
if (!WriteBlock(tempFile, m_data, m_dataSize))
|
||||||
{
|
{
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
success = image.LoadFile(tempFile, GetImageType());
|
success = image.LoadFile(tempFile, GetImageType());
|
||||||
wxRemoveFile(tempFile);
|
wxRemoveFile(tempFile);
|
||||||
@@ -4963,7 +4964,7 @@ bool wxRichTextImageBlock::ReadHex(wxInputStream& stream, int length, int imageT
|
|||||||
str[0] = stream.GetC();
|
str[0] = stream.GetC();
|
||||||
str[1] = stream.GetC();
|
str[1] = stream.GetC();
|
||||||
|
|
||||||
m_data[i] = wxHexToDec(str);
|
m_data[i] = (unsigned char)wxHexToDec(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_dataSize = dataSize;
|
m_dataSize = dataSize;
|
||||||
@@ -5007,7 +5008,7 @@ bool wxRichTextImageBlock::WriteBlock(const wxString& filename, unsigned char* b
|
|||||||
{
|
{
|
||||||
wxFileOutputStream outStream(filename);
|
wxFileOutputStream outStream(filename);
|
||||||
if (!outStream.Ok())
|
if (!outStream.Ok())
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
return WriteBlock(outStream, block, size);
|
return WriteBlock(outStream, block, size);
|
||||||
}
|
}
|
||||||
|
@@ -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
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -232,7 +232,7 @@ void wxRichTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
|
|||||||
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);
|
||||||
@@ -1207,7 +1207,7 @@ 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
|
||||||
{
|
{
|
||||||
@@ -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)
|
||||||
@@ -1367,7 +1366,7 @@ 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;
|
||||||
|
|
||||||
@@ -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)
|
||||||
|
@@ -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;
|
||||||
@@ -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;
|
||||||
@@ -168,7 +168,7 @@ bool wxRichTextXMLHandler::ImportXML(wxRichTextBuffer* buffer, wxXmlNode* node)
|
|||||||
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);
|
||||||
@@ -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));
|
||||||
@@ -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;
|
||||||
@@ -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();
|
||||||
|
|
||||||
@@ -805,4 +802,3 @@ void wxRichTextHTMLHandler::OutputParagraphFormatting(const wxTextAttrEx& WXUNUS
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
// wxUSE_RICHTEXT
|
// wxUSE_RICHTEXT
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user