#include "wx/dataobj.h"
#endif
-// Experimental dynamic styles to avoid user-specific character styles from being
-// overwritten by paragraph styles.
-#define wxRICHTEXT_USE_DYNAMIC_STYLES 1
-
/*!
* File types
*/
virtual bool GetStyle(long position, wxTextAttrEx& style);
virtual bool GetStyle(long position, wxRichTextAttr& style);
-/*
// get the common set of styles for the range
- bool GetStyleForRange(const wxRichTextRange& range, wxRichTextAttr& style);
- bool GetStyleForRange(const wxRichTextRange& range, wxTextAttrEx& style);
-*/
+ virtual bool GetStyleForRange(const wxRichTextRange& range, wxRichTextAttr& style);
+ virtual bool GetStyleForRange(const wxRichTextRange& range, wxTextAttrEx& style);
+
// extended style setting operation with flags including:
// wxRICHTEXT_SETSTYLE_WITH_UNDO, wxRICHTEXT_SETSTYLE_OPTIMIZE, wxRICHTEXT_SETSTYLE_PARAGRAPHS_ONLY, wxRICHTEXT_SETSTYLE_CHARACTERS_ONLY
// see richtextbuffer.h for more details.
public:
wxRichTextEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
: wxNotifyEvent(commandType, winid),
- m_itemIndex(-1), m_flags(0), m_oldStyleSheet(NULL), m_newStyleSheet(NULL)
+ m_flags(0), m_position(-1), m_oldStyleSheet(NULL), m_newStyleSheet(NULL),
+ m_char((wxChar) 0)
{ }
wxRichTextEvent(const wxRichTextEvent& event)
: wxNotifyEvent(event),
- m_itemIndex(event.m_itemIndex), m_flags(event.m_flags),
- m_oldStyleSheet(event.m_oldStyleSheet), m_newStyleSheet(event.m_newStyleSheet)
+ m_flags(event.m_flags), m_position(-1),
+ m_oldStyleSheet(event.m_oldStyleSheet), m_newStyleSheet(event.m_newStyleSheet),
+ m_char((wxChar) 0)
{ }
- int GetIndex() const { return m_itemIndex; }
- void SetIndex(int n) { m_itemIndex = n; }
+ long GetPosition() const { return m_position; }
+ void SetPosition(long pos) { m_position = pos; }
int GetFlags() const { return m_flags; }
void SetFlags(int flags) { m_flags = flags; }
wxRichTextStyleSheet* GetNewStyleSheet() const { return m_newStyleSheet; }
void SetNewStyleSheet(wxRichTextStyleSheet* sheet) { m_newStyleSheet = sheet; }
+ const wxRichTextRange& GetRange() const { return m_range; }
+ void SetRange(const wxRichTextRange& range) { m_range = range; }
+
+ wxChar GetCharacter() const { return m_char; }
+ void SetCharacter(wxChar ch) { m_char = ch; }
+
virtual wxEvent *Clone() const { return new wxRichTextEvent(*this); }
protected:
- int m_itemIndex;
int m_flags;
+ long m_position;
wxRichTextStyleSheet* m_oldStyleSheet;
wxRichTextStyleSheet* m_newStyleSheet;
+ wxRichTextRange m_range;
+ wxChar m_char;
private:
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRichTextEvent)
*/
BEGIN_DECLARE_EVENT_TYPES()
- DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_ITEM_SELECTED, 2600)
- DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_ITEM_DESELECTED, 2601)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_LEFT_CLICK, 2602)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_RIGHT_CLICK, 2603)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_MIDDLE_CLICK, 2604)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_LEFT_DCLICK, 2605)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_RETURN, 2606)
-
- DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING, 2607)
- DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGED, 2608)
- DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACING, 2609)
- DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACED, 2610)
+ DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_CHARACTER, 2607)
+ DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_DELETE, 2608)
+
+ DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING, 2609)
+ DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGED, 2610)
+ DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACING, 2611)
+ DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACED, 2612)
+
+ DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_CONTENT_INSERTED, 2613)
+ DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_CONTENT_DELETED, 2614)
+ DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_STYLE_CHANGED, 2615)
+ DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_SELECTION_CHANGED, 2616)
END_DECLARE_EVENT_TYPES()
typedef void (wxEvtHandler::*wxRichTextEventFunction)(wxRichTextEvent&);
-#define EVT_RICHTEXT_ITEM_SELECTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_ITEM_SELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ),
-#define EVT_RICHTEXT_ITEM_DESELECTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_ITEM_DESELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ),
#define EVT_RICHTEXT_LEFT_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_LEFT_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ),
#define EVT_RICHTEXT_RIGHT_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_RIGHT_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ),
#define EVT_RICHTEXT_MIDDLE_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_MIDDLE_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ),
#define EVT_RICHTEXT_LEFT_DCLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_LEFT_DCLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ),
#define EVT_RICHTEXT_RETURN(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_RETURN, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ),
+#define EVT_RICHTEXT_CHARACTER(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_CHARACTER, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ),
+#define EVT_RICHTEXT_DELETE(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_DELETE, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ),
#define EVT_RICHTEXT_STYLESHEET_CHANGING(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ),
#define EVT_RICHTEXT_STYLESHEET_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ),
#define EVT_RICHTEXT_STYLESHEET_REPLACING(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACING, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ),
#define EVT_RICHTEXT_STYLESHEET_REPLACED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACED, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ),
+#define EVT_RICHTEXT_CONTENT_INSERTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_CONTENT_INSERTED, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ),
+#define EVT_RICHTEXT_CONTENT_DELETED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_CONTENT_DELETED, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ),
+#define EVT_RICHTEXT_STYLE_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_STYLE_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ),
+#define EVT_RICHTEXT_SELECTION_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_SELECTION_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ),
+
#endif
// wxUSE_RICHTEXT
m_range = obj.m_range;
m_attributes = obj.m_attributes;
m_descent = obj.m_descent;
-/*
- if (!m_attributes.GetFont().Ok())
- wxLogDebug(wxT("No font!"));
- if (!obj.m_attributes.GetFont().Ok())
- wxLogDebug(wxT("Parent has no font!"));
-*/
}
void wxRichTextObject::SetMargins(int margin)
/// Convenience function to add a paragraph of text
wxRichTextRange wxRichTextParagraphLayoutBox::AddParagraph(const wxString& text, wxTextAttrEx* paraStyle)
{
-#if wxRICHTEXT_USE_DYNAMIC_STYLES
// Don't use the base style, just the default style, and the base style will
// be combined at display time.
// Divide into paragraph and character styles.
wxTextAttrEx defaultCharStyle;
wxTextAttrEx defaultParaStyle;
- wxRichTextSplitParaCharStyles(GetDefaultStyle(), defaultParaStyle, defaultCharStyle);
-#else
- wxTextAttrEx style(GetAttributes());
-
- // Apply default style. If the style has no attributes set,
- // then the attributes will remain the 'basic style' (i.e. the
- // layout box's style).
- wxRichTextApplyStyle(style, GetDefaultStyle());
- wxTextAttrEx defaultCharStyle = style;
- wxTextAttrEx defaultParaStyle = style;
-#endif
+ wxRichTextSplitParaCharStyles(GetDefaultStyle(), defaultParaStyle, defaultCharStyle);
wxTextAttrEx* pStyle = paraStyle ? paraStyle : (wxTextAttrEx*) & defaultParaStyle;
wxTextAttrEx* cStyle = & defaultCharStyle;
/// Adds multiple paragraphs, based on newlines.
wxRichTextRange wxRichTextParagraphLayoutBox::AddParagraphs(const wxString& text, wxTextAttrEx* paraStyle)
{
-#if wxRICHTEXT_USE_DYNAMIC_STYLES
// Don't use the base style, just the default style, and the base style will
// be combined at display time.
// Divide into paragraph and character styles.
wxTextAttrEx defaultCharStyle;
wxTextAttrEx defaultParaStyle;
wxRichTextSplitParaCharStyles(GetDefaultStyle(), defaultParaStyle, defaultCharStyle);
-#else
- wxTextAttrEx style(GetAttributes());
-
- // Apply default style. If the style has no attributes set,
- // then the attributes will remain the 'basic style' (i.e. the
- // layout box's style).
- wxRichTextApplyStyle(style, GetDefaultStyle());
-
- wxTextAttrEx defaultCharStyle = style;
- wxTextAttrEx defaultParaStyle = style;
-#endif
wxTextAttrEx* pStyle = paraStyle ? paraStyle : (wxTextAttrEx*) & defaultParaStyle;
wxTextAttrEx* cStyle = & defaultCharStyle;
/// Convenience function to add an image
wxRichTextRange wxRichTextParagraphLayoutBox::AddImage(const wxImage& image, wxTextAttrEx* paraStyle)
{
-#if wxRICHTEXT_USE_DYNAMIC_STYLES
// Don't use the base style, just the default style, and the base style will
// be combined at display time.
// Divide into paragraph and character styles.
wxTextAttrEx defaultCharStyle;
wxTextAttrEx defaultParaStyle;
wxRichTextSplitParaCharStyles(GetDefaultStyle(), defaultParaStyle, defaultCharStyle);
-#else
- wxTextAttrEx style(GetAttributes());
-
- // Apply default style. If the style has no attributes set,
- // then the attributes will remain the 'basic style' (i.e. the
- // layout box's style).
- wxRichTextApplyStyle(style, GetDefaultStyle());
-
- wxTextAttrEx defaultCharStyle = style;
- wxTextAttrEx defaultParaStyle = style;
-#endif
wxTextAttrEx* pStyle = paraStyle ? paraStyle : (wxTextAttrEx*) & defaultParaStyle;
wxTextAttrEx* cStyle = & defaultCharStyle;
}
}
-#if wxRICHTEXT_USE_DYNAMIC_STYLES
- // If applying paragraph styles dynamically, don't change the text objects' attributes
+ // When applying paragraph styles dynamically, don't change the text objects' attributes
// since they will computed as needed. Only apply the character styling if it's _only_
// character styling. This policy is subject to change and might be put under user control.
// if (!paragraphStyle && characterStyle && range.GetStart() != newPara->GetRange().GetEnd())
if (!parasOnly && characterStyle && range.GetStart() != newPara->GetRange().GetEnd())
-#else
- if (characterStyle && range.GetStart() != newPara->GetRange().GetEnd())
-#endif
{
wxRichTextRange childRange(range);
childRange.LimitTo(newPara->GetRange());
obj = GetParagraphAtPosition(position);
if (obj)
{
-#if wxRICHTEXT_USE_DYNAMIC_STYLES
if (combineStyles)
{
// Start with the base style
}
else
style = obj->GetAttributes();
-#else
- style = obj->GetAttributes();
-#endif
+
return true;
}
}
obj = GetLeafObjectAtPosition(position);
if (obj)
{
-#if wxRICHTEXT_USE_DYNAMIC_STYLES
if (combineStyles)
{
wxRichTextParagraph* para = wxDynamicCast(obj->GetParent(), wxRichTextParagraph);
}
else
style = obj->GetAttributes();
-#else
- style = obj->GetAttributes();
-#endif
+
return true;
}
}
if (!child->GetRange().IsOutside(range) && child->IsKindOf(CLASSINFO(wxRichTextPlainText)))
{
foundCount ++;
-#if wxRICHTEXT_USE_DYNAMIC_STYLES
wxTextAttrEx textAttr = para->GetCombinedAttributes(child->GetAttributes());
-#else
- const wxTextAttrEx& textAttr = child->GetAttributes();
-#endif
+
if (wxTextAttrEqPartial(textAttr, style, style.GetFlags()))
matchingCount ++;
}
if (!para->GetRange().IsOutside(range))
{
-#if wxRICHTEXT_USE_DYNAMIC_STYLES
wxTextAttrEx textAttr = GetAttributes();
// Apply the paragraph style
wxRichTextApplyStyle(textAttr, para->GetAttributes());
-#else
- const wxTextAttrEx& textAttr = para->GetAttributes();
-#endif
foundCount ++;
if (wxTextAttrEqPartial(textAttr, style, style.GetFlags()))
matchingCount ++;
/// Draw the item
bool wxRichTextParagraph::Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& WXUNUSED(rect), int WXUNUSED(descent), int style)
{
-#if wxRICHTEXT_USE_DYNAMIC_STYLES
wxTextAttrEx attr = GetCombinedAttributes();
-#else
- const wxTextAttrEx& attr = GetAttributes();
-#endif
// Draw the bullet, if any
if (attr.GetBulletStyle() != wxTEXT_ATTR_BULLET_STYLE_NONE)
/// Lay the item out
bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, int style)
{
-#if wxRICHTEXT_USE_DYNAMIC_STYLES
wxTextAttrEx attr = GetCombinedAttributes();
-#else
- const wxTextAttrEx& attr = GetAttributes();
-#endif
// ClearLines();
/// Draw the item
bool wxRichTextPlainText::Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& rect, int descent, int WXUNUSED(style))
{
-#if wxRICHTEXT_USE_DYNAMIC_STYLES
wxRichTextParagraph* para = wxDynamicCast(GetParent(), wxRichTextParagraph);
wxASSERT (para != NULL);
wxTextAttrEx textAttr(para ? para->GetCombinedAttributes(GetAttributes()) : GetAttributes());
-#else
- wxTextAttrEx textAttr(GetAttributes());
-#endif
int offset = GetRange().GetStart();
/// Lay the item out
bool wxRichTextPlainText::Layout(wxDC& dc, const wxRect& WXUNUSED(rect), int WXUNUSED(style))
{
-#if wxRICHTEXT_USE_DYNAMIC_STYLES
wxRichTextParagraph* para = wxDynamicCast(GetParent(), wxRichTextParagraph);
wxASSERT (para != NULL);
wxTextAttrEx textAttr(para ? para->GetCombinedAttributes(GetAttributes()) : GetAttributes());
-#else
- wxTextAttrEx textAttr(GetAttributes());
-#endif
if (textAttr.GetFont().Ok())
dc.SetFont(textAttr.GetFont());
if (!range.IsWithin(GetRange()))
return false;
-#if wxRICHTEXT_USE_DYNAMIC_STYLES
wxRichTextParagraph* para = wxDynamicCast(GetParent(), wxRichTextParagraph);
wxASSERT (para != NULL);
wxTextAttrEx textAttr(para ? para->GetCombinedAttributes(GetAttributes()) : GetAttributes());
-#else
- wxTextAttrEx textAttr(GetAttributes());
-#endif
// Always assume unformatted text, since at this level we have no knowledge
// of line breaks - and we don't need it, since we'll calculate size within
{
wxRichTextAction* action = new wxRichTextAction(NULL, _("Insert Text"), wxRICHTEXT_INSERT, this, ctrl, false);
-#if wxRICHTEXT_USE_DYNAMIC_STYLES
wxTextAttrEx attr(GetDefaultStyle());
-#else
- wxTextAttrEx attr(GetBasicStyle());
- wxRichTextApplyStyle(attr, GetDefaultStyle());
-#endif
wxTextAttrEx* p = NULL;
wxTextAttrEx paraAttr;
p = & paraAttr;
}
-#if wxRICHTEXT_USE_DYNAMIC_STYLES
wxTextAttrEx attr(GetDefaultStyle());
-#else
- wxTextAttrEx attr(GetBasicStyle());
- wxRichTextApplyStyle(attr, GetDefaultStyle());
-#endif
wxRichTextParagraph* newPara = new wxRichTextParagraph(wxEmptyString, this, & attr);
action->GetNewParagraphs().AppendChild(newPara);
p = & paraAttr;
}
-#if wxRICHTEXT_USE_DYNAMIC_STYLES
wxTextAttrEx attr(GetDefaultStyle());
-#else
- wxTextAttrEx attr(GetBasicStyle());
- wxRichTextApplyStyle(attr, GetDefaultStyle());
-#endif
wxRichTextParagraph* newPara = new wxRichTextParagraph(this, & attr);
if (p)
if (m_newParagraphs.GetPartialParagraph())
newCaretPosition --;
- newCaretPosition = wxMin(newCaretPosition, (m_buffer->GetRange().GetEnd()-1));
-
+ newCaretPosition = wxMin(newCaretPosition, (m_buffer->GetRange().GetEnd()-1));
if (optimizationLineCharPositions.GetCount() > 0)
UpdateAppearance(newCaretPosition, true /* send update event */, & optimizationLineCharPositions, & optimizationLineYPositions);
else
UpdateAppearance(newCaretPosition, true /* send update event */);
+
+ wxRichTextEvent cmdEvent(
+ wxEVT_COMMAND_RICHTEXT_CONTENT_INSERTED,
+ m_ctrl ? m_ctrl->GetId() : -1);
+ cmdEvent.SetEventObject(m_ctrl ? (wxObject*) m_ctrl : (wxObject*) m_buffer);
+ cmdEvent.SetRange(GetRange());
+ cmdEvent.SetPosition(GetRange().GetStart());
+
+ m_buffer->SendEvent(cmdEvent);
break;
}
UpdateAppearance(GetRange().GetStart()-1, true /* send update event */);
+ wxRichTextEvent cmdEvent(
+ wxEVT_COMMAND_RICHTEXT_CONTENT_DELETED,
+ m_ctrl ? m_ctrl->GetId() : -1);
+ cmdEvent.SetEventObject(m_ctrl ? (wxObject*) m_ctrl : (wxObject*) m_buffer);
+ cmdEvent.SetRange(GetRange());
+ cmdEvent.SetPosition(GetRange().GetStart());
+
+ m_buffer->SendEvent(cmdEvent);
+
break;
}
case wxRICHTEXT_CHANGE_STYLE:
UpdateAppearance(GetPosition());
+ wxRichTextEvent cmdEvent(
+ wxEVT_COMMAND_RICHTEXT_STYLE_CHANGED,
+ m_ctrl ? m_ctrl->GetId() : -1);
+ cmdEvent.SetEventObject(m_ctrl ? (wxObject*) m_ctrl : (wxObject*) m_buffer);
+ cmdEvent.SetRange(GetRange());
+ cmdEvent.SetPosition(GetRange().GetStart());
+
+ m_buffer->SendEvent(cmdEvent);
+
break;
}
default:
m_buffer->Invalidate(wxRichTextRange(GetRange().GetStart(), GetRange().GetStart()));
long newCaretPosition = GetPosition() - 1;
- // if (m_newParagraphs.GetPartialParagraph())
- // newCaretPosition --;
UpdateAppearance(newCaretPosition, true /* send update event */);
+ wxRichTextEvent cmdEvent(
+ wxEVT_COMMAND_RICHTEXT_CONTENT_DELETED,
+ m_ctrl ? m_ctrl->GetId() : -1);
+ cmdEvent.SetEventObject(m_ctrl ? (wxObject*) m_ctrl : (wxObject*) m_buffer);
+ cmdEvent.SetRange(GetRange());
+ cmdEvent.SetPosition(GetRange().GetStart());
+
+ m_buffer->SendEvent(cmdEvent);
+
break;
}
case wxRICHTEXT_DELETE:
UpdateAppearance(GetPosition(), true /* send update event */);
+ wxRichTextEvent cmdEvent(
+ wxEVT_COMMAND_RICHTEXT_CONTENT_INSERTED,
+ m_ctrl ? m_ctrl->GetId() : -1);
+ cmdEvent.SetEventObject(m_ctrl ? (wxObject*) m_ctrl : (wxObject*) m_buffer);
+ cmdEvent.SetRange(GetRange());
+ cmdEvent.SetPosition(GetRange().GetStart());
+
+ m_buffer->SendEvent(cmdEvent);
+
break;
}
case wxRICHTEXT_CHANGE_STYLE:
UpdateAppearance(GetPosition());
+ wxRichTextEvent cmdEvent(
+ wxEVT_COMMAND_RICHTEXT_STYLE_CHANGED,
+ m_ctrl ? m_ctrl->GetId() : -1);
+ cmdEvent.SetEventObject(m_ctrl ? (wxObject*) m_ctrl : (wxObject*) m_buffer);
+ cmdEvent.SetRange(GetRange());
+ cmdEvent.SetPosition(GetRange().GetStart());
+
+ m_buffer->SendEvent(cmdEvent);
+
break;
}
default:
#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)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_MIDDLE_CLICK)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_RIGHT_CLICK)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_LEFT_DCLICK)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_RETURN)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_CHARACTER)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_DELETE)
+
DEFINE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACING)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACED)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGED)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_CONTENT_INSERTED)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_CONTENT_DELETED)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_STYLE_CHANGED)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_SELECTION_CHANGED)
+
IMPLEMENT_CLASS( wxRichTextCtrl, wxControl )
IMPLEMENT_CLASS( wxRichTextEvent, wxNotifyEvent )
GetId());
cmdEvent.SetEventObject(this);
cmdEvent.SetFlags(flags);
+ cmdEvent.SetPosition(newPos+1);
+
if (!GetEventHandler()->ProcessEvent(cmdEvent))
{
// Generate conventional event
else if (event.GetKeyCode() == WXK_BACK)
{
BeginBatchUndo(_("Delete Text"));
-
+
// Submit range in character positions, which are greater than caret positions,
// so subtract 1 for deleted character and add 1 for conversion to character position.
if (m_caretPosition > -1 && !HasSelection())
}
ScrollIntoView(m_caretPosition, WXK_LEFT);
+
+ wxRichTextEvent cmdEvent(
+ wxEVT_COMMAND_RICHTEXT_DELETE,
+ GetId());
+ cmdEvent.SetEventObject(this);
+ cmdEvent.SetFlags(flags);
+ cmdEvent.SetPosition(m_caretPosition+1);
+ GetEventHandler()->ProcessEvent(cmdEvent);
+
Update();
}
else if (event.GetKeyCode() == WXK_DELETE)
PositionCaret();
SetDefaultStyleToCursorStyle();
}
+
+ wxRichTextEvent cmdEvent(
+ wxEVT_COMMAND_RICHTEXT_DELETE,
+ GetId());
+ cmdEvent.SetEventObject(this);
+ cmdEvent.SetFlags(flags);
+ cmdEvent.SetPosition(m_caretPosition+1);
+ GetEventHandler()->ProcessEvent(cmdEvent);
+
Update();
}
else
return;
}
+ wxRichTextEvent cmdEvent(
+ wxEVT_COMMAND_RICHTEXT_CHARACTER,
+ GetId());
+ cmdEvent.SetEventObject(this);
+ cmdEvent.SetFlags(flags);
+ cmdEvent.SetCharacter((wxChar) keycode);
+ cmdEvent.SetPosition(m_caretPosition+1);
+
if (keycode == wxT('\t'))
{
// See if we need to promote or demote the selection or paragraph at the cursor
PromoteList(promoteBy, range, NULL);
+ GetEventHandler()->ProcessEvent(cmdEvent);
+
return;
}
}
SetDefaultStyleToCursorStyle();
ScrollIntoView(m_caretPosition, WXK_RIGHT);
+
+ GetEventHandler()->ProcessEvent(cmdEvent);
+
Update();
}
}
return GetBuffer().GetStyle(position, style);
}
-/*
// get the common set of styles for the range
bool wxRichTextCtrl::GetStyleForRange(const wxRichTextRange& range, wxRichTextAttr& style)
{
{
return GetBuffer().GetStyleForRange(range.ToInternal(), style);
}
-*/
/// Get the content (uncombined) attributes for this position.
// If at the start of a paragraph, use the next position.
long pos = GetAdjustedCaretPosition(GetCaretPosition());
-#if wxRICHTEXT_USE_DYNAMIC_STYLES
if (GetUncombinedStyle(pos, attr))
-#else
- if (GetStyle(pos, attr))
-#endif
{
SetDefaultStyle(attr);
return true;