bool Eq(const wxRichTextStyleDefinition& def) const;
void operator =(const wxRichTextStyleDefinition& def) { Copy(def); }
bool operator ==(const wxRichTextStyleDefinition& def) const { return Eq(def); }
+ virtual wxRichTextStyleDefinition* Clone() const = 0;
/// The name of the style.
void SetName(const wxString& name) { m_name = name; }
wxRichTextStyleDefinition(name) {}
virtual ~wxRichTextCharacterStyleDefinition() {}
+ virtual wxRichTextStyleDefinition* Clone() const { return new wxRichTextCharacterStyleDefinition(*this); }
+
protected:
};
void operator =(const wxRichTextParagraphStyleDefinition& def) { Copy(def); }
bool operator ==(const wxRichTextParagraphStyleDefinition& def) const;
+ virtual wxRichTextStyleDefinition* Clone() const { return new wxRichTextParagraphStyleDefinition(*this); }
+
protected:
/// The next style to use when adding a paragraph after this style.
{
m_styleSheet = NULL;
m_richTextCtrl = NULL;
+ m_applyOnSelection = true;
}
bool Create(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
/// Updates the list
void UpdateStyles();
- /// Do selection
- void DoSelection(int i);
+ /// Apply the style
+ void ApplyStyle(int i);
/// React to selection
void OnSelect(wxCommandEvent& event);
/// Need to override this if being used in a combobox popup
virtual bool CanAutoSetSelection() { return true; }
+ /// Set whether the style should be applied as soon as the item is selected (the default)
+ void SetApplyOnSelection(bool applyOnSel) { m_applyOnSelection = applyOnSel; }
+ bool GetApplyOnSelection() const { return m_applyOnSelection; }
+
protected:
/// Returns the HTML for this item
virtual wxString OnGetItem(size_t n) const;
wxRichTextStyleSheet* m_styleSheet;
wxRichTextCtrl* m_richTextCtrl;
+ bool m_applyOnSelection; // if true, applies style on selection
};
#if wxUSE_COMBOCTRL
wxVListBox::OnLeftDown(event);
int item = HitTest(event.GetPosition());
- if (item != wxNOT_FOUND)
- DoSelection(item);
+ if (item != wxNOT_FOUND && GetApplyOnSelection())
+ ApplyStyle(item);
}
/// Auto-select from style under caret in idle time
}
/// Do selection
-void wxRichTextStyleListBox::DoSelection(int item)
+void wxRichTextStyleListBox::ApplyStyle(int item)
{
if ( item != wxNOT_FOUND )
{
m_value = m_itemHere;
// Ordering is important, so we don't dismiss this popup accidentally
- // by setting the focus elsewhere e.g. in DoSelection
+ // by setting the focus elsewhere e.g. in ApplyStyle
Dismiss();
if (m_itemHere >= 0)
- wxRichTextStyleListBox::DoSelection(m_itemHere);
+ wxRichTextStyleListBox::ApplyStyle(m_itemHere);
}
/*!