public:
// ctors
wxTextAttrEx(const wxTextAttrEx& attr);
+ wxTextAttrEx(const wxTextAttr& attr) { Init(); (*this) = attr; }
wxTextAttrEx() { Init(); }
// Initialise this object.
// Constructors
wxRichTextCtrl( );
- wxRichTextCtrl( wxWindow* parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
+ wxRichTextCtrl( wxWindow* parent, wxWindowID id = -1, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxRE_MULTILINE );
~wxRichTextCtrl( );
// Operations
/// Creation
- bool Create( wxWindow* parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
+ bool Create( wxWindow* parent, wxWindowID id = -1, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxRE_MULTILINE );
/// Member initialisation
// text control under some platforms supports the text styles: these
// methods allow to apply the given text style to the given selection or to
// set/get the style which will be used for all appended text
+ virtual bool SetStyle(long start, long end, const wxTextAttr& style);
virtual bool SetStyle(long start, long end, const wxTextAttrEx& style);
virtual bool SetStyle(const wxRichTextRange& range, const wxRichTextAttr& style);
+ virtual bool GetStyle(long position, wxTextAttr& style) const;
virtual bool GetStyle(long position, wxTextAttrEx& style) const;
virtual bool GetStyle(long position, wxRichTextAttr& style) const;
virtual bool SetDefaultStyle(const wxTextAttrEx& style);
+ virtual bool SetDefaultStyle(const wxTextAttr& style);
// TODO: change to GetDefaultStyle if we merge wxTextAttr and wxTextAttrEx
virtual const wxTextAttrEx& GetDefaultStyleEx() const;
+ virtual const wxTextAttr& GetDefaultStyle() const;
// translate between the position (which is just an index in the text ctrl
// considering all its contents as a single strings) and (x, y) coordinates
m_styleSheet->AddParagraphStyle(indentedPara);
+ wxRichTextParagraphStyleDefinition* indentedPara2 = new wxRichTextParagraphStyleDefinition(wxT("Red Bold Indented"));
+ wxRichTextAttr indentedAttr2;
+ indentedAttr2.SetFontFaceName(romanFont.GetFaceName());
+ indentedAttr2.SetFontSize(12);
+ indentedAttr2.SetFontWeight(wxBOLD);
+ indentedAttr2.SetTextColour(*wxRED);
+ indentedAttr2.SetFontSize(12);
+ indentedAttr2.SetLeftIndent(100, 0);
+ // We want to affect indentation, font and text colour
+ indentedAttr2.SetFlags(wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_FONT|wxTEXT_ATTR_TEXT_COLOUR);
+ indentedPara2->SetStyle(indentedAttr2);
+
+ m_styleSheet->AddParagraphStyle(indentedPara2);
+
wxRichTextParagraphStyleDefinition* flIndentedPara = new wxRichTextParagraphStyleDefinition(wxT("First Line Indented"));
wxRichTextAttr flIndentedAttr;
flIndentedAttr.SetFontFaceName(swissFont.GetFaceName());
wxFont boldFont = wxFont(12, wxROMAN, wxNORMAL, wxBOLD);
wxFont italicFont = wxFont(12, wxROMAN, wxITALIC, wxNORMAL);
- m_richTextCtrl = new wxRichTextCtrl(splitter, wxID_ANY, wxDefaultPosition, wxSize(200, 200), wxVSCROLL|wxHSCROLL|wxNO_BORDER|wxWANTS_CHARS);
+ m_richTextCtrl = new wxRichTextCtrl(splitter, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(200, 200), wxVSCROLL|wxHSCROLL|wxNO_BORDER|wxWANTS_CHARS);
wxFont font(12, wxROMAN, wxNORMAL, wxNORMAL);
m_richTextCtrl->SetFont(font);
/// Get the paragraph by number
wxRichTextParagraph* wxRichTextParagraphLayoutBox::GetParagraphAtLine(long paragraphNumber) const
{
- if ((size_t) paragraphNumber <= GetChildCount())
+ if ((size_t) paragraphNumber >= GetChildCount())
return NULL;
return (wxRichTextParagraph*) GetChild((size_t) paragraphNumber);
#include "wx/dcbuffer.h"
#include "wx/arrimpl.cpp"
+// DLL options compatibility check:
+#include "wx/app.h"
+WX_CHECK_BUILD_OPTIONS("wxRichTextCtrl")
+
DEFINE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_ITEM_SELECTED)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_ITEM_DESELECTED)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_LEFT_CLICK)
Init();
}
-wxRichTextCtrl::wxRichTextCtrl( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
+wxRichTextCtrl::wxRichTextCtrl( wxWindow* parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style)
#if wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
: wxScrollHelper(this)
#endif
{
Init();
- Create(parent, id, pos, size, style);
+ Create(parent, id, value, pos, size, style);
}
/// Creation
-bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
+bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style)
{
#if wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
if (!wxTextCtrlBase::Create(parent, id, pos, size, style|wxFULL_REPAINT_ON_RESIZE
RecreateBuffer(size);
SetCursor(wxCursor(wxCURSOR_IBEAM));
+
+ if (!value.IsEmpty())
+ SetValue(value);
return true;
}
return GetBuffer().SetStyle(wxRichTextRange(start, end), style);
}
+bool wxRichTextCtrl::SetStyle(long start, long end, const wxTextAttr& style)
+{
+ return GetBuffer().SetStyle(wxRichTextRange(start, end), wxTextAttrEx(style));
+}
+
bool wxRichTextCtrl::SetStyle(const wxRichTextRange& range, const wxRichTextAttr& style)
{
return GetBuffer().SetStyle(range, style);
return GetBuffer().SetDefaultStyle(style);
}
+bool wxRichTextCtrl::SetDefaultStyle(const wxTextAttr& style)
+{
+ return GetBuffer().SetDefaultStyle(wxTextAttrEx(style));
+}
+
const wxTextAttrEx& wxRichTextCtrl::GetDefaultStyleEx() const
{
return GetBuffer().GetDefaultStyle();
}
+const wxTextAttr& wxRichTextCtrl::GetDefaultStyle() const
+{
+ return GetBuffer().GetDefaultStyle();
+}
+
+bool wxRichTextCtrl::GetStyle(long position, wxTextAttr& style) const
+{
+ wxTextAttrEx attr;
+ if (GetBuffer().GetStyle(position, attr))
+ {
+ style = attr;
+ return true;
+ }
+ else
+ return false;
+}
+
bool wxRichTextCtrl::GetStyle(long position, wxTextAttrEx& style) const
{
return GetBuffer().GetStyle(position, style);