#include "wx/wxprec.h"
#ifdef __BORLANDC__
- #pragma hdrstop
+ #pragma hdrstop
#endif
#if wxUSE_RICHTEXT
#include "wx/richtext/richtextstyles.h"
#ifndef WX_PRECOMP
- #include "wx/dcclient.h"
- #include "wx/module.h"
+ #include "wx/wx.h"
#endif
#include "wx/filename.h"
IMPLEMENT_CLASS(wxRichTextCharacterStyleDefinition, wxRichTextStyleDefinition)
IMPLEMENT_CLASS(wxRichTextParagraphStyleDefinition, wxRichTextStyleDefinition)
+/*!
+ * A definition
+ */
+
+void wxRichTextStyleDefinition::Copy(const wxRichTextStyleDefinition& def)
+{
+ m_name = def.m_name;
+ m_baseStyle = def.m_baseStyle;
+ m_style = def.m_style;
+}
+
+bool wxRichTextStyleDefinition::Eq(const wxRichTextStyleDefinition& def) const
+{
+ return (m_name == def.m_name && m_baseStyle == def.m_baseStyle && m_style == def.m_style);
+}
+
+/*!
+ * Paragraph style definition
+ */
+
+void wxRichTextParagraphStyleDefinition::Copy(const wxRichTextParagraphStyleDefinition& def)
+{
+ wxRichTextStyleDefinition::Copy(def);
+
+ m_nextStyle = def.m_nextStyle;
+}
+
+bool wxRichTextParagraphStyleDefinition::operator ==(const wxRichTextParagraphStyleDefinition& def) const
+{
+ return (Eq(def) && m_nextStyle == def.m_nextStyle);
+}
+
/*!
* The style manager
*/
WX_CLEAR_LIST(wxList, m_paragraphStyleDefinitions);
}
+/// Add a definition to the character style list
+bool wxRichTextStyleSheet::AddCharacterStyle(wxRichTextCharacterStyleDefinition* def)
+{
+ def->GetStyle().SetCharacterStyleName(def->GetName());
+ return AddStyle(m_characterStyleDefinitions, def);
+}
+
+/// Add a definition to the paragraph style list
+bool wxRichTextStyleSheet::AddParagraphStyle(wxRichTextParagraphStyleDefinition* def)
+{
+ def->GetStyle().SetParagraphStyleName(def->GetName());
+ return AddStyle(m_paragraphStyleDefinitions, def);
+}
+
+/// Copy
+void wxRichTextStyleSheet::Copy(const wxRichTextStyleSheet& sheet)
+{
+ DeleteStyles();
+
+ wxList::compatibility_iterator node;
+
+ for (node = sheet.m_characterStyleDefinitions.GetFirst(); node; node = node->GetNext())
+ {
+ wxRichTextCharacterStyleDefinition* def = (wxRichTextCharacterStyleDefinition*) node->GetData();
+ AddCharacterStyle(new wxRichTextCharacterStyleDefinition(*def));
+ }
+
+ for (node = sheet.m_paragraphStyleDefinitions.GetFirst(); node; node = node->GetNext())
+ {
+ wxRichTextParagraphStyleDefinition* def = (wxRichTextParagraphStyleDefinition*) node->GetData();
+ AddParagraphStyle(new wxRichTextParagraphStyleDefinition(*def));
+ }
+}
+
+/// Equality
+bool wxRichTextStyleSheet::operator==(const wxRichTextStyleSheet& WXUNUSED(sheet)) const
+{
+ // TODO
+ return false;
+}
+
+
#if wxUSE_HTML
/*!
* wxRichTextStyleListBox class declaration
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
{
if (CanAutoSetSelection() && GetRichTextCtrl())
{
- wxRichTextParagraph* para = GetRichTextCtrl()->GetBuffer().GetParagraphAtPosition(GetRichTextCtrl()->GetCaretPosition());
- wxRichTextObject* obj = GetRichTextCtrl()->GetBuffer().GetLeafObjectAtPosition(GetRichTextCtrl()->GetCaretPosition());
+ int adjustedCaretPos = GetRichTextCtrl()->GetAdjustedCaretPosition(GetRichTextCtrl()->GetCaretPosition());
+
+ wxRichTextParagraph* para = GetRichTextCtrl()->GetBuffer().GetParagraphAtPosition(adjustedCaretPos);
+ wxRichTextObject* obj = GetRichTextCtrl()->GetBuffer().GetLeafObjectAtPosition(adjustedCaretPos);
wxString styleName;
}
/// 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);
}
/*!
{
if (GetRichTextCtrl() && !IsPopupShown())
{
- wxRichTextParagraph* para = GetRichTextCtrl()->GetBuffer().GetParagraphAtPosition(GetRichTextCtrl()->GetCaretPosition());
- wxRichTextObject* obj = GetRichTextCtrl()->GetBuffer().GetLeafObjectAtPosition(GetRichTextCtrl()->GetCaretPosition());
+ int adjustedCaretPos = GetRichTextCtrl()->GetAdjustedCaretPosition(GetRichTextCtrl()->GetCaretPosition());
+
+ wxRichTextParagraph* para = GetRichTextCtrl()->GetBuffer().GetParagraphAtPosition(adjustedCaretPos);
+ wxRichTextObject* obj = GetRichTextCtrl()->GetBuffer().GetLeafObjectAtPosition(adjustedCaretPos);
wxString styleName;