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
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 2005-09-30
|
||||
// RCS-ID:
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -511,7 +511,7 @@ public:
|
||||
|
||||
/// Lay the item out at the specified position with the given size constraint.
|
||||
/// Layout must set the cached size.
|
||||
virtual bool Layout(wxDC& dc, const wxRect& rect, int style) = 0;
|
||||
virtual bool Layout(wxDC& dc, const wxRect& rect, const wxRichTextRange& affected, int style) = 0;
|
||||
|
||||
/// Hit-testing: returns a flag indicating hit test details, plus
|
||||
/// information about position
|
||||
@@ -743,7 +743,7 @@ public:
|
||||
virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& rect, int descent, int style);
|
||||
|
||||
/// Lay the item out
|
||||
virtual bool Layout(wxDC& dc, const wxRect& rect, int style);
|
||||
virtual bool Layout(wxDC& dc, const wxRect& rect, const wxRichTextRange& affected, int style);
|
||||
|
||||
/// Get/set the object size for the given range. Returns false if the range
|
||||
/// is invalid for this object.
|
||||
@@ -782,7 +782,7 @@ public:
|
||||
virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& rect, int descent, int style);
|
||||
|
||||
/// Lay the item out
|
||||
virtual bool Layout(wxDC& dc, const wxRect& rect, int style);
|
||||
virtual bool Layout(wxDC& dc, const wxRect& rect, const wxRichTextRange& affected, int style);
|
||||
|
||||
/// Get/set the object size for the given range. Returns false if the range
|
||||
/// is invalid for this object.
|
||||
@@ -909,9 +909,6 @@ public:
|
||||
/// Copy
|
||||
void Copy(const wxRichTextParagraphLayoutBox& obj);
|
||||
|
||||
/// Clone
|
||||
virtual wxRichTextObject* Clone() { return new wxRichTextParagraphLayoutBox(*this); }
|
||||
|
||||
/// Calculate ranges
|
||||
virtual void UpdateRanges() { long end; CalculateRange(0, end); }
|
||||
|
||||
@@ -969,7 +966,7 @@ public:
|
||||
void Copy(const wxRichTextFragment& obj);
|
||||
|
||||
/// Clone
|
||||
virtual wxRichTextObject* Clone() { return new wxRichTextFragment(*this); }
|
||||
virtual wxRichTextObject* Clone() const { return new wxRichTextFragment(*this); }
|
||||
|
||||
protected:
|
||||
|
||||
@@ -1077,7 +1074,7 @@ public:
|
||||
virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& rect, int descent, int style);
|
||||
|
||||
/// Lay the item out
|
||||
virtual bool Layout(wxDC& dc, const wxRect& rect, int style);
|
||||
virtual bool Layout(wxDC& dc, const wxRect& rect, const wxRichTextRange& affected, int style);
|
||||
|
||||
/// Get/set the object size for the given range. Returns false if the range
|
||||
/// is invalid for this object.
|
||||
@@ -1166,7 +1163,7 @@ public:
|
||||
virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& rect, int descent, int style);
|
||||
|
||||
/// Lay the item out
|
||||
virtual bool Layout(wxDC& dc, const wxRect& rect, int style);
|
||||
virtual bool Layout(wxDC& dc, const wxRect& rect, const wxRichTextRange& affected, int style);
|
||||
|
||||
/// Get/set the object size for the given range. Returns false if the range
|
||||
/// is invalid for this object.
|
||||
@@ -1186,7 +1183,7 @@ public:
|
||||
virtual bool DeleteRange(const wxRichTextRange& range);
|
||||
|
||||
/// Returns true if the object is empty
|
||||
virtual bool IsEmpty() const { return m_text.IsEmpty(); }
|
||||
virtual bool IsEmpty() const { return m_text.empty(); }
|
||||
|
||||
/// Returns true if this object can merge itself with the given one.
|
||||
virtual bool CanMerge(wxRichTextObject* object) const;
|
||||
@@ -1240,7 +1237,7 @@ public:
|
||||
// to conserve space.
|
||||
// If it's not a JPEG we can make use of 'image', already scaled, so we don't have to
|
||||
// load the image a 2nd time.
|
||||
virtual bool MakeImageBlock(const wxString& filename, int imageType, wxImage& image, bool convertToJPEG = TRUE);
|
||||
virtual bool MakeImageBlock(const wxString& filename, int imageType, wxImage& image, bool convertToJPEG = true);
|
||||
|
||||
// Make an image block from the wxImage in the given
|
||||
// format.
|
||||
@@ -1319,7 +1316,7 @@ public:
|
||||
virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& rect, int descent, int style);
|
||||
|
||||
/// Lay the item out
|
||||
virtual bool Layout(wxDC& dc, const wxRect& rect, int style);
|
||||
virtual bool Layout(wxDC& dc, const wxRect& rect, const wxRichTextRange& affected, int style);
|
||||
|
||||
/// Get the object size for the given range. Returns false if the range
|
||||
/// is invalid for this object.
|
||||
@@ -1671,7 +1668,7 @@ class WXDLLIMPEXP_ADV wxRichTextCommand: public wxCommand
|
||||
public:
|
||||
// Ctor for one action
|
||||
wxRichTextCommand(const wxString& name, wxRichTextCommandId id, wxRichTextBuffer* buffer,
|
||||
wxRichTextCtrl* ctrl, bool ignoreFirstTime = FALSE);
|
||||
wxRichTextCtrl* ctrl, bool ignoreFirstTime = false);
|
||||
|
||||
// Ctor for multiple actions
|
||||
wxRichTextCommand(const wxString& name);
|
||||
@@ -1700,7 +1697,7 @@ class WXDLLIMPEXP_ADV wxRichTextAction: public wxObject
|
||||
{
|
||||
public:
|
||||
wxRichTextAction(wxRichTextCommand* cmd, const wxString& name, wxRichTextCommandId id, wxRichTextBuffer* buffer,
|
||||
wxRichTextCtrl* ctrl, bool ignoreFirstTime = FALSE);
|
||||
wxRichTextCtrl* ctrl, bool ignoreFirstTime = false);
|
||||
|
||||
~wxRichTextAction();
|
||||
|
||||
@@ -1771,12 +1768,14 @@ public:
|
||||
{ }
|
||||
|
||||
#if wxUSE_STREAMS
|
||||
virtual bool LoadFile(wxRichTextBuffer *buffer, wxInputStream& stream) = 0;
|
||||
virtual bool SaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream) = 0;
|
||||
bool LoadFile(wxRichTextBuffer *buffer, wxInputStream& stream)
|
||||
{ return DoLoadFile(buffer, stream); }
|
||||
bool SaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream)
|
||||
{ return DoSaveFile(buffer, stream); }
|
||||
#endif
|
||||
|
||||
virtual bool LoadFile(wxRichTextBuffer *buffer, const wxString& filename);
|
||||
virtual bool SaveFile(wxRichTextBuffer *buffer, const wxString& filename);
|
||||
bool LoadFile(wxRichTextBuffer *buffer, const wxString& filename);
|
||||
bool SaveFile(wxRichTextBuffer *buffer, const wxString& filename);
|
||||
|
||||
/// Can we handle this filename (if using files)? By default, checks the extension.
|
||||
virtual bool CanHandle(const wxString& filename) const;
|
||||
@@ -1802,6 +1801,11 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
#if wxUSE_STREAMS
|
||||
virtual bool DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& stream) = 0;
|
||||
virtual bool DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream) = 0;
|
||||
#endif
|
||||
|
||||
wxString m_name;
|
||||
wxString m_extension;
|
||||
int m_type;
|
||||
@@ -1821,11 +1825,6 @@ public:
|
||||
: wxRichTextFileHandler(name, ext, type)
|
||||
{ }
|
||||
|
||||
#if wxUSE_STREAMS
|
||||
virtual bool LoadFile(wxRichTextBuffer *buffer, wxInputStream& stream);
|
||||
virtual bool SaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream);
|
||||
#endif
|
||||
|
||||
/// Can we save using this handler?
|
||||
virtual bool CanSave() const { return true; }
|
||||
|
||||
@@ -1834,6 +1833,11 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
#if wxUSE_STREAMS
|
||||
virtual bool DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& stream);
|
||||
virtual bool DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream);
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -1865,4 +1869,3 @@ bool wxRichTextApplyStyle(wxTextAttrEx& destStyle, const wxRichTextAttr& style);
|
||||
|
||||
#endif
|
||||
// _WX_RICHTEXTBUFFER_H_
|
||||
|
||||
|
@@ -1,10 +1,10 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: richtextctrl.h
|
||||
// Name: wx/richtext/richtextctrl.h
|
||||
// Purpose: A rich edit control
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 2005-09-30
|
||||
// RCS-ID:
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
@@ -1,10 +1,10 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: richeditxml.h
|
||||
// Name: wx/richtext/richeditxml.h
|
||||
// Purpose: XML and HTML I/O for wxRichTextCtrl
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 2005-09-30
|
||||
// RCS-ID:
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -37,8 +37,8 @@ public:
|
||||
{ }
|
||||
|
||||
#if wxUSE_STREAMS
|
||||
virtual bool LoadFile(wxRichTextBuffer *buffer, wxInputStream& stream);
|
||||
virtual bool SaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream);
|
||||
virtual bool DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& stream);
|
||||
virtual bool DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream);
|
||||
|
||||
/// Recursively export an object
|
||||
bool ExportXML(wxOutputStream& stream, wxMBConv* convMem, wxMBConv* convFile, wxRichTextObject& obj, int level);
|
||||
@@ -84,8 +84,8 @@ public:
|
||||
{ }
|
||||
|
||||
#if wxUSE_STREAMS
|
||||
virtual bool LoadFile(wxRichTextBuffer *buffer, wxInputStream& stream);
|
||||
virtual bool SaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream);
|
||||
virtual bool DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& stream);
|
||||
virtual bool DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream);
|
||||
#endif
|
||||
|
||||
/// Can we save using this handler?
|
||||
|
@@ -1,10 +1,10 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: richtextbuffer.cpp
|
||||
// Name: richtext/richtextbuffer.cpp
|
||||
// Purpose: Buffer for wxRichTextCtrl
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 2005-09-30
|
||||
// RCS-ID:
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -870,7 +870,7 @@ wxRichTextRange wxRichTextParagraphLayoutBox::AddParagraphs(const wxString& text
|
||||
|
||||
i ++;
|
||||
}
|
||||
if (!line.IsEmpty())
|
||||
if (!line.empty())
|
||||
{
|
||||
lastPara = new wxRichTextParagraph(line, this, & style);
|
||||
//wxLogDebug("Para Face = %s", lastPara->GetAttributes().GetFont().GetFaceName());
|
||||
@@ -1053,7 +1053,7 @@ bool wxRichTextParagraphLayoutBox::InsertFragment(long position, wxRichTextFragm
|
||||
// Ensure there's at least one object
|
||||
if (finalPara->GetChildCount() == 0)
|
||||
{
|
||||
wxRichTextPlainText* text = new wxRichTextPlainText(wxT(""));
|
||||
wxRichTextPlainText* text = new wxRichTextPlainText(wxEmptyString);
|
||||
text->SetAttributes(finalPara->GetAttributes());
|
||||
|
||||
finalPara->AppendChild(text);
|
||||
@@ -1718,7 +1718,7 @@ void wxRichTextParagraphLayoutBox::Reset()
|
||||
{
|
||||
Clear();
|
||||
|
||||
AddParagraph(wxT(""));
|
||||
AddParagraph(wxEmptyString);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1796,7 +1796,7 @@ bool wxRichTextParagraph::Draw(wxDC& dc, const wxRichTextRange& WXUNUSED(range),
|
||||
else
|
||||
{
|
||||
wxString bulletText = GetBulletText();
|
||||
if (!bulletText.IsEmpty())
|
||||
if (!bulletText.empty())
|
||||
{
|
||||
if (GetAttributes().GetFont().Ok())
|
||||
dc.SetFont(GetAttributes().GetFont());
|
||||
@@ -2989,7 +2989,7 @@ wxString wxRichTextPlainText::GetTextForRange(const wxRichTextRange& range) cons
|
||||
bool wxRichTextPlainText::CanMerge(wxRichTextObject* object) const
|
||||
{
|
||||
return object->GetClassInfo() == CLASSINFO(wxRichTextPlainText) &&
|
||||
(m_text.IsEmpty() || wxTextAttrEq(GetAttributes(), object->GetAttributes()));
|
||||
(m_text.empty() || wxTextAttrEq(GetAttributes(), object->GetAttributes()));
|
||||
}
|
||||
|
||||
/// Returns true if this object merged itself with the given one.
|
||||
@@ -3054,7 +3054,7 @@ void wxRichTextBuffer::Clear()
|
||||
void wxRichTextBuffer::Reset()
|
||||
{
|
||||
DeleteChildren();
|
||||
AddParagraph(wxT(""));
|
||||
AddParagraph(wxEmptyString);
|
||||
GetCommandProcessor()->ClearCommands();
|
||||
Modify(false);
|
||||
}
|
||||
@@ -3086,7 +3086,7 @@ bool wxRichTextBuffer::InsertNewlineWithUndo(long pos, wxRichTextCtrl* ctrl)
|
||||
wxTextAttrEx attr(GetBasicStyle());
|
||||
wxRichTextApplyStyle(attr, GetDefaultStyle());
|
||||
|
||||
wxRichTextParagraph* newPara = new wxRichTextParagraph(wxT(""), this, & attr);
|
||||
wxRichTextParagraph* newPara = new wxRichTextParagraph(wxEmptyString, this, & attr);
|
||||
action->GetNewParagraphs().AppendChild(newPara);
|
||||
action->GetNewParagraphs().UpdateRanges();
|
||||
action->GetNewParagraphs().SetPartialParagraph(false);
|
||||
@@ -3711,12 +3711,12 @@ bool wxRichTextBuffer::PasteFromClipboard(long position)
|
||||
/// Can we paste from the clipboard?
|
||||
bool wxRichTextBuffer::CanPasteFromClipboard() const
|
||||
{
|
||||
bool canPaste = FALSE;
|
||||
bool canPaste = false;
|
||||
if (wxTheClipboard->Open())
|
||||
{
|
||||
if (wxTheClipboard->IsSupported(wxDF_TEXT) || wxTheClipboard->IsSupported(wxDF_BITMAP))
|
||||
{
|
||||
canPaste = TRUE;
|
||||
canPaste = true;
|
||||
}
|
||||
wxTheClipboard->Close();
|
||||
}
|
||||
@@ -3759,12 +3759,12 @@ IMPLEMENT_DYNAMIC_CLASS(wxRichTextModule, wxModule)
|
||||
*/
|
||||
|
||||
wxRichTextCommand::wxRichTextCommand(const wxString& name, wxRichTextCommandId id, wxRichTextBuffer* buffer,
|
||||
wxRichTextCtrl* ctrl, bool ignoreFirstTime): wxCommand(TRUE, name)
|
||||
wxRichTextCtrl* ctrl, bool ignoreFirstTime): wxCommand(true, name)
|
||||
{
|
||||
/* wxRichTextAction* action = */ new wxRichTextAction(this, name, id, buffer, ctrl, ignoreFirstTime);
|
||||
}
|
||||
|
||||
wxRichTextCommand::wxRichTextCommand(const wxString& name): wxCommand(TRUE, name)
|
||||
wxRichTextCommand::wxRichTextCommand(const wxString& name): wxCommand(true, name)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -4673,6 +4673,7 @@ void wxTextAttrEx::operator= (const wxTextAttr& attr)
|
||||
|
||||
IMPLEMENT_CLASS(wxRichTextFileHandler, wxObject)
|
||||
|
||||
#if wxUSE_STREAMS
|
||||
bool wxRichTextFileHandler::LoadFile(wxRichTextBuffer *buffer, const wxString& filename)
|
||||
{
|
||||
wxFFileInputStream stream(filename);
|
||||
@@ -4690,6 +4691,7 @@ bool wxRichTextFileHandler::SaveFile(wxRichTextBuffer *buffer, const wxString& f
|
||||
else
|
||||
return false;
|
||||
}
|
||||
#endif // wxUSE_STREAMS
|
||||
|
||||
/// Can we handle this filename (if using files)? By default, checks the extension.
|
||||
bool wxRichTextFileHandler::CanHandle(const wxString& filename) const
|
||||
@@ -4708,7 +4710,7 @@ bool wxRichTextFileHandler::CanHandle(const wxString& filename) const
|
||||
IMPLEMENT_CLASS(wxRichTextPlainTextHandler, wxRichTextFileHandler)
|
||||
|
||||
#if wxUSE_STREAMS
|
||||
bool wxRichTextPlainTextHandler::LoadFile(wxRichTextBuffer *buffer, wxInputStream& stream)
|
||||
bool wxRichTextPlainTextHandler::DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& stream)
|
||||
{
|
||||
if (!stream.IsOk())
|
||||
return false;
|
||||
@@ -4721,7 +4723,7 @@ bool wxRichTextPlainTextHandler::LoadFile(wxRichTextBuffer *buffer, wxInputStrea
|
||||
ch = stream.GetC();
|
||||
|
||||
if (ch > 0)
|
||||
str += ch;
|
||||
str += wxChar(ch);
|
||||
}
|
||||
|
||||
buffer->Clear();
|
||||
@@ -4732,7 +4734,7 @@ bool wxRichTextPlainTextHandler::LoadFile(wxRichTextBuffer *buffer, wxInputStrea
|
||||
|
||||
}
|
||||
|
||||
bool wxRichTextPlainTextHandler::SaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream)
|
||||
bool wxRichTextPlainTextHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream)
|
||||
{
|
||||
if (!stream.IsOk())
|
||||
return false;
|
||||
@@ -4743,8 +4745,7 @@ bool wxRichTextPlainTextHandler::SaveFile(wxRichTextBuffer *buffer, wxOutputStre
|
||||
stream.Write((const char*) buf, text.Length());
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // wxUSE_STREAMS
|
||||
|
||||
/*
|
||||
* Stores information about an image, in binary in-memory form
|
||||
@@ -4798,10 +4799,10 @@ bool wxRichTextImageBlock::MakeImageBlock(const wxString& filename, int imageTyp
|
||||
m_imageType = imageType;
|
||||
|
||||
wxString filenameToRead(filename);
|
||||
bool removeFile = FALSE;
|
||||
bool removeFile = false;
|
||||
|
||||
if (imageType == -1)
|
||||
return FALSE; // Could not determine image type
|
||||
return false; // Could not determine image type
|
||||
|
||||
if ((imageType != wxBITMAP_TYPE_JPEG) && convertToJPEG)
|
||||
{
|
||||
@@ -4814,13 +4815,13 @@ bool wxRichTextImageBlock::MakeImageBlock(const wxString& filename, int imageTyp
|
||||
|
||||
image.SaveFile(tempFile, wxBITMAP_TYPE_JPEG);
|
||||
filenameToRead = tempFile;
|
||||
removeFile = TRUE;
|
||||
removeFile = true;
|
||||
|
||||
m_imageType = wxBITMAP_TYPE_JPEG;
|
||||
}
|
||||
wxFile file;
|
||||
if (!file.Open(filenameToRead))
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
m_dataSize = (size_t) file.Length();
|
||||
file.Close();
|
||||
@@ -4843,7 +4844,7 @@ bool wxRichTextImageBlock::MakeImageBlock(wxImage& image, int imageType, int qua
|
||||
image.SetOption(wxT("quality"), quality);
|
||||
|
||||
if (imageType == -1)
|
||||
return FALSE; // Could not determine image type
|
||||
return false; // Could not determine image type
|
||||
|
||||
wxString tempFile;
|
||||
bool success = wxGetTempFileName(_("image"), tempFile) ;
|
||||
@@ -4855,12 +4856,12 @@ bool wxRichTextImageBlock::MakeImageBlock(wxImage& image, int imageType, int qua
|
||||
{
|
||||
if (wxFileExists(tempFile))
|
||||
wxRemoveFile(tempFile);
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
wxFile file;
|
||||
if (!file.Open(tempFile))
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
m_dataSize = (size_t) file.Length();
|
||||
file.Close();
|
||||
@@ -4909,7 +4910,7 @@ void wxRichTextImageBlock::operator=(const wxRichTextImageBlock& block)
|
||||
bool wxRichTextImageBlock::Load(wxImage& image)
|
||||
{
|
||||
if (!m_data)
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
// Read in the image.
|
||||
#if 1
|
||||
@@ -4922,7 +4923,7 @@ bool wxRichTextImageBlock::Load(wxImage& image)
|
||||
|
||||
if (!WriteBlock(tempFile, m_data, m_dataSize))
|
||||
{
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
success = image.LoadFile(tempFile, GetImageType());
|
||||
wxRemoveFile(tempFile);
|
||||
@@ -4963,7 +4964,7 @@ bool wxRichTextImageBlock::ReadHex(wxInputStream& stream, int length, int imageT
|
||||
str[0] = stream.GetC();
|
||||
str[1] = stream.GetC();
|
||||
|
||||
m_data[i] = wxHexToDec(str);
|
||||
m_data[i] = (unsigned char)wxHexToDec(str);
|
||||
}
|
||||
|
||||
m_dataSize = dataSize;
|
||||
@@ -5007,7 +5008,7 @@ bool wxRichTextImageBlock::WriteBlock(const wxString& filename, unsigned char* b
|
||||
{
|
||||
wxFileOutputStream outStream(filename);
|
||||
if (!outStream.Ok())
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
return WriteBlock(outStream, block, size);
|
||||
}
|
||||
|
@@ -1,10 +1,10 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: richeditctrl.cpp
|
||||
// Name: richtext/richeditctrl.cpp
|
||||
// Purpose: A rich edit control
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 2005-09-30
|
||||
// RCS-ID:
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -232,7 +232,7 @@ void wxRichTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
|
||||
wxRegion dirtyRegion = GetUpdateRegion();
|
||||
|
||||
wxRect drawingArea(GetLogicalPoint(wxPoint(0, 0)), GetClientSize());
|
||||
wxRect availableSpace(wxPoint(0, 0), GetClientSize());
|
||||
wxRect availableSpace(GetClientSize());
|
||||
if (GetBuffer().GetDirty())
|
||||
{
|
||||
GetBuffer().Layout(dc, availableSpace, GetBuffer().GetRange(), wxRICHTEXT_FIXED_WIDTH|wxRICHTEXT_VARIABLE_HEIGHT);
|
||||
@@ -1207,7 +1207,7 @@ long wxRichTextCtrl::FindNextWordPosition(int direction) const
|
||||
{
|
||||
// i is in character, not caret positions
|
||||
wxString text = GetBuffer().GetTextForRange(wxRichTextRange(i, i));
|
||||
if (text != wxT(" ") && !text.IsEmpty())
|
||||
if (text != wxT(" ") && !text.empty())
|
||||
i += direction;
|
||||
else
|
||||
{
|
||||
@@ -1218,9 +1218,9 @@ long wxRichTextCtrl::FindNextWordPosition(int direction) const
|
||||
{
|
||||
// i is in character, not caret positions
|
||||
wxString text = GetBuffer().GetTextForRange(wxRichTextRange(i, i));
|
||||
if (text.IsEmpty()) // End of paragraph, or maybe an image
|
||||
if (text.empty()) // End of paragraph, or maybe an image
|
||||
return wxMax(-1, i - 1);
|
||||
else if (text == wxT(" ") || text.IsEmpty())
|
||||
else if (text == wxT(" ") || text.empty())
|
||||
i += direction;
|
||||
else
|
||||
{
|
||||
@@ -1241,9 +1241,9 @@ long wxRichTextCtrl::FindNextWordPosition(int direction) const
|
||||
{
|
||||
// i is in character, not caret positions
|
||||
wxString text = GetBuffer().GetTextForRange(wxRichTextRange(i, i));
|
||||
if (text.IsEmpty()) // End of paragraph, or maybe an image
|
||||
if (text.empty()) // End of paragraph, or maybe an image
|
||||
break;
|
||||
else if (text == wxT(" ") || text.IsEmpty())
|
||||
else if (text == wxT(" ") || text.empty())
|
||||
i += direction;
|
||||
else
|
||||
break;
|
||||
@@ -1253,12 +1253,11 @@ long wxRichTextCtrl::FindNextWordPosition(int direction) const
|
||||
{
|
||||
// i is in character, not caret positions
|
||||
wxString text = GetBuffer().GetTextForRange(wxRichTextRange(i, i));
|
||||
if (text != wxT(" ") /* && !text.IsEmpty() */)
|
||||
if (text != wxT(" ") /* && !text.empty() */)
|
||||
i += direction;
|
||||
else
|
||||
{
|
||||
return i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i < -1)
|
||||
@@ -1367,7 +1366,7 @@ void wxRichTextCtrl::PaintBackground(wxDC& dc)
|
||||
// Clear the background
|
||||
dc.SetBrush(wxBrush(backgroundColour));
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
wxRect windowRect(wxPoint(0, 0), GetClientSize());
|
||||
wxRect windowRect(GetClientSize());
|
||||
windowRect.x -= 2; windowRect.y -= 2;
|
||||
windowRect.width += 4; windowRect.height += 4;
|
||||
|
||||
@@ -2205,7 +2204,7 @@ bool wxRichTextCtrl::MoveCaret(long pos, bool showAtLineStart)
|
||||
/// setting the caret position.
|
||||
bool wxRichTextCtrl::Layout()
|
||||
{
|
||||
wxRect availableSpace(wxPoint(0, 0), GetClientSize());
|
||||
wxRect availableSpace(GetClientSize());
|
||||
if (availableSpace.width == 0)
|
||||
availableSpace.width = 10;
|
||||
if (availableSpace.height == 0)
|
||||
|
@@ -1,10 +1,10 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: richtextxml.cpp
|
||||
// Name: richtext/richtextxml.cpp
|
||||
// Purpose: XML and HTML I/O for wxRichTextCtrl
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 2005-09-30
|
||||
// RCS-ID:
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -37,7 +37,7 @@
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxRichTextXMLHandler, wxRichTextFileHandler)
|
||||
|
||||
#if wxUSE_STREAMS
|
||||
bool wxRichTextXMLHandler::LoadFile(wxRichTextBuffer *buffer, wxInputStream& stream)
|
||||
bool wxRichTextXMLHandler::DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& stream)
|
||||
{
|
||||
if (!stream.IsOk())
|
||||
return false;
|
||||
@@ -145,7 +145,7 @@ bool wxRichTextXMLHandler::ImportXML(wxRichTextBuffer* buffer, wxXmlNode* node)
|
||||
{
|
||||
int imageType = wxBITMAP_TYPE_PNG;
|
||||
wxString value = node->GetPropVal(wxT("imagetype"), wxEmptyString);
|
||||
if (!value.IsEmpty())
|
||||
if (!value.empty())
|
||||
imageType = wxAtoi(value);
|
||||
|
||||
wxString data;
|
||||
@@ -168,7 +168,7 @@ bool wxRichTextXMLHandler::ImportXML(wxRichTextBuffer* buffer, wxXmlNode* node)
|
||||
imageChild = imageChild->GetNext();
|
||||
}
|
||||
|
||||
if (!data.IsEmpty())
|
||||
if (!data.empty())
|
||||
{
|
||||
wxRichTextImage* imageObj = new wxRichTextImage(para);
|
||||
para->AppendChild(imageObj);
|
||||
@@ -242,7 +242,7 @@ wxString wxRichTextXMLHandler::GetNodeContent(wxXmlNode *node)
|
||||
|
||||
wxString wxRichTextXMLHandler::GetParamValue(wxXmlNode *node, const wxString& param)
|
||||
{
|
||||
if (param.IsEmpty())
|
||||
if (param.empty())
|
||||
return GetNodeContent(node);
|
||||
else
|
||||
return GetNodeContent(GetParamNode(node, param));
|
||||
@@ -259,9 +259,9 @@ wxString wxRichTextXMLHandler::GetText(wxXmlNode *node, const wxString& param, b
|
||||
|
||||
// write string to output:
|
||||
inline static void OutputString(wxOutputStream& stream, const wxString& str,
|
||||
wxMBConv *convMem = NULL, wxMBConv *convFile = NULL)
|
||||
wxMBConv *WXUNUSED_IN_UNICODE(convMem) = NULL, wxMBConv *convFile = NULL)
|
||||
{
|
||||
if (str.IsEmpty()) return;
|
||||
if (str.empty()) return;
|
||||
#if wxUSE_UNICODE
|
||||
const wxWX2MBbuf buf(str.mb_str(convFile ? *convFile : wxConvUTF8));
|
||||
stream.Write((const char*)buf, strlen((const char*)buf));
|
||||
@@ -359,17 +359,14 @@ static wxString ColourToHexString(const wxColour& col)
|
||||
// Convert 6-digit hex string to a colour
|
||||
wxColour HexStringToColour(const wxString& hex)
|
||||
{
|
||||
unsigned int r = 0;
|
||||
unsigned int g = 0;
|
||||
unsigned int b = 0;
|
||||
r = wxHexToDec(hex.Mid(0, 2));
|
||||
g = wxHexToDec(hex.Mid(2, 2));
|
||||
b = wxHexToDec(hex.Mid(4, 2));
|
||||
unsigned char r = (unsigned char)wxHexToDec(hex.Mid(0, 2));
|
||||
unsigned char g = (unsigned char)wxHexToDec(hex.Mid(2, 2));
|
||||
unsigned char b = (unsigned char)wxHexToDec(hex.Mid(4, 2));
|
||||
|
||||
return wxColour(r, g, b);
|
||||
}
|
||||
|
||||
bool wxRichTextXMLHandler::SaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream)
|
||||
bool wxRichTextXMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream)
|
||||
{
|
||||
if (!stream.IsOk())
|
||||
return false;
|
||||
@@ -527,7 +524,7 @@ wxString wxRichTextXMLHandler::CreateStyle(const wxTextAttrEx& attr, bool isPara
|
||||
str << wxT(" fontface=\"") << attr.GetFont().GetFaceName() << wxT("\"");
|
||||
}
|
||||
|
||||
if (!attr.GetCharacterStyleName().IsEmpty())
|
||||
if (!attr.GetCharacterStyleName().empty())
|
||||
str << wxT(" charactertyle=\"") << wxString(attr.GetCharacterStyleName()) << wxT("\"");
|
||||
|
||||
if (isPara)
|
||||
@@ -543,7 +540,7 @@ wxString wxRichTextXMLHandler::CreateStyle(const wxTextAttrEx& attr, bool isPara
|
||||
str << wxT(" bulletnumber=\"") << (int) attr.GetBulletNumber() << wxT("\"");
|
||||
str << wxT(" bulletsymbol=\"") << wxString(attr.GetBulletSymbol()) << wxT("\"");
|
||||
|
||||
if (!attr.GetParagraphStyleName().IsEmpty())
|
||||
if (!attr.GetParagraphStyleName().empty())
|
||||
str << wxT(" parstyle=\"") << wxString(attr.GetParagraphStyleName()) << wxT("\"");
|
||||
}
|
||||
|
||||
@@ -563,29 +560,29 @@ bool wxRichTextXMLHandler::GetStyle(wxTextAttrEx& attr, wxXmlNode* node, bool is
|
||||
fontFacename = node->GetPropVal(wxT("fontface"), wxEmptyString);
|
||||
|
||||
wxString value = node->GetPropVal(wxT("fontfamily"), wxEmptyString);
|
||||
if (!value.IsEmpty())
|
||||
if (!value.empty())
|
||||
fontFamily = wxAtoi(value);
|
||||
|
||||
value = node->GetPropVal(wxT("fontstyle"), wxEmptyString);
|
||||
if (!value.IsEmpty())
|
||||
if (!value.empty())
|
||||
fontStyle = wxAtoi(value);
|
||||
|
||||
value = node->GetPropVal(wxT("fontsize"), wxEmptyString);
|
||||
if (!value.IsEmpty())
|
||||
if (!value.empty())
|
||||
fontSize = wxAtoi(value);
|
||||
|
||||
value = node->GetPropVal(wxT("fontweight"), wxEmptyString);
|
||||
if (!value.IsEmpty())
|
||||
if (!value.empty())
|
||||
fontWeight = wxAtoi(value);
|
||||
|
||||
value = node->GetPropVal(wxT("fontunderlined"), wxEmptyString);
|
||||
if (!value.IsEmpty())
|
||||
if (!value.empty())
|
||||
fontUnderlined = wxAtoi(value) != 0;
|
||||
|
||||
attr.SetFont(* wxTheFontList->FindOrCreateFont(fontSize, fontFamily, fontStyle, fontWeight, fontUnderlined, fontFacename));
|
||||
|
||||
value = node->GetPropVal(wxT("textcolor"), wxEmptyString);
|
||||
if (!value.IsEmpty())
|
||||
if (!value.empty())
|
||||
{
|
||||
if (value[0] == wxT('#'))
|
||||
attr.SetTextColour(HexStringToColour(value.Mid(1)));
|
||||
@@ -594,7 +591,7 @@ bool wxRichTextXMLHandler::GetStyle(wxTextAttrEx& attr, wxXmlNode* node, bool is
|
||||
}
|
||||
|
||||
value = node->GetPropVal(wxT("backgroundcolor"), wxEmptyString);
|
||||
if (!value.IsEmpty())
|
||||
if (!value.empty())
|
||||
{
|
||||
if (value[0] == wxT('#'))
|
||||
attr.SetBackgroundColour(HexStringToColour(value.Mid(1)));
|
||||
@@ -603,56 +600,56 @@ bool wxRichTextXMLHandler::GetStyle(wxTextAttrEx& attr, wxXmlNode* node, bool is
|
||||
}
|
||||
|
||||
value = node->GetPropVal(wxT("characterstyle"), wxEmptyString);
|
||||
if (!value.IsEmpty())
|
||||
if (!value.empty())
|
||||
attr.SetCharacterStyleName(value);
|
||||
|
||||
// Set paragraph attributes
|
||||
if (isPara)
|
||||
{
|
||||
value = node->GetPropVal(wxT("alignment"), wxEmptyString);
|
||||
if (!value.IsEmpty())
|
||||
if (!value.empty())
|
||||
attr.SetAlignment((wxTextAttrAlignment) wxAtoi(value));
|
||||
|
||||
int leftSubIndent = 0;
|
||||
int leftIndent = 0;
|
||||
value = node->GetPropVal(wxT("leftindent"), wxEmptyString);
|
||||
if (!value.IsEmpty())
|
||||
if (!value.empty())
|
||||
leftIndent = wxAtoi(value);
|
||||
value = node->GetPropVal(wxT("leftsubindent"), wxEmptyString);
|
||||
if (!value.IsEmpty())
|
||||
if (!value.empty())
|
||||
leftSubIndent = wxAtoi(value);
|
||||
attr.SetLeftIndent(leftIndent, leftSubIndent);
|
||||
|
||||
value = node->GetPropVal(wxT("rightindent"), wxEmptyString);
|
||||
if (!value.IsEmpty())
|
||||
if (!value.empty())
|
||||
attr.SetRightIndent(wxAtoi(value));
|
||||
|
||||
value = node->GetPropVal(wxT("parspacingbefore"), wxEmptyString);
|
||||
if (!value.IsEmpty())
|
||||
if (!value.empty())
|
||||
attr.SetParagraphSpacingBefore(wxAtoi(value));
|
||||
|
||||
value = node->GetPropVal(wxT("parspacingafter"), wxEmptyString);
|
||||
if (!value.IsEmpty())
|
||||
if (!value.empty())
|
||||
attr.SetParagraphSpacingAfter(wxAtoi(value));
|
||||
|
||||
value = node->GetPropVal(wxT("linespacing"), wxEmptyString);
|
||||
if (!value.IsEmpty())
|
||||
if (!value.empty())
|
||||
attr.SetLineSpacing(wxAtoi(value));
|
||||
|
||||
value = node->GetPropVal(wxT("bulletstyle"), wxEmptyString);
|
||||
if (!value.IsEmpty())
|
||||
if (!value.empty())
|
||||
attr.SetBulletStyle(wxAtoi(value));
|
||||
|
||||
value = node->GetPropVal(wxT("bulletnumber"), wxEmptyString);
|
||||
if (!value.IsEmpty())
|
||||
if (!value.empty())
|
||||
attr.SetBulletNumber(wxAtoi(value));
|
||||
|
||||
value = node->GetPropVal(wxT("bulletsymbol"), wxEmptyString);
|
||||
if (!value.IsEmpty())
|
||||
if (!value.empty())
|
||||
attr.SetBulletSymbol(value[0]);
|
||||
|
||||
value = node->GetPropVal(wxT("parstyle"), wxEmptyString);
|
||||
if (!value.IsEmpty())
|
||||
if (!value.empty())
|
||||
attr.SetParagraphStyleName(value);
|
||||
}
|
||||
|
||||
@@ -674,7 +671,7 @@ bool wxRichTextHTMLHandler::CanHandle(const wxString& filename) const
|
||||
|
||||
|
||||
#if wxUSE_STREAMS
|
||||
bool wxRichTextHTMLHandler::LoadFile(wxRichTextBuffer *WXUNUSED(buffer), wxInputStream& WXUNUSED(stream))
|
||||
bool wxRichTextHTMLHandler::DoLoadFile(wxRichTextBuffer *WXUNUSED(buffer), wxInputStream& WXUNUSED(stream))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -683,7 +680,7 @@ bool wxRichTextHTMLHandler::LoadFile(wxRichTextBuffer *WXUNUSED(buffer), wxInput
|
||||
* We need to output only _changes_ in character formatting.
|
||||
*/
|
||||
|
||||
bool wxRichTextHTMLHandler::SaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream)
|
||||
bool wxRichTextHTMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream)
|
||||
{
|
||||
buffer->Defragment();
|
||||
|
||||
@@ -805,4 +802,3 @@ void wxRichTextHTMLHandler::OutputParagraphFormatting(const wxTextAttrEx& WXUNUS
|
||||
|
||||
#endif
|
||||
// wxUSE_RICHTEXT
|
||||
|
||||
|
Reference in New Issue
Block a user