diff --git a/include/wx/richtext/richtextbuffer.h b/include/wx/richtext/richtextbuffer.h
index 45e8af0445..bc3b2b7a27 100644
--- a/include/wx/richtext/richtextbuffer.h
+++ b/include/wx/richtext/richtextbuffer.h
@@ -2746,6 +2746,16 @@ public:
*/
bool IsShown() const { return m_show; }
+ /**
+ Returns the object's unique identifier, if any.
+ */
+ const wxString& GetId() const { return m_id; }
+
+ /**
+ Sets the object's unique identifier.
+ */
+ void SetId(const wxString& id) { m_id = id; }
+
// Operations
/**
@@ -2844,6 +2854,7 @@ protected:
int m_descent; // Descent for this object (if any)
int m_refCount;
bool m_show;
+ wxString m_id;
wxRichTextObject* m_parent;
// The range of this object (start position to end position)
@@ -5690,13 +5701,25 @@ public:
// Accessors
- int GetColSpan() const;
+ /**
+ Returns the column span. The default is 1.
+ */
+ int GetColSpan() const { return m_colSpan; }
- void SetColSpan(long span) { GetProperties().SetProperty(wxT("colspan"), span); }
+ /**
+ Sets the column span.
+ */
+ void SetColSpan(int span);
- int GetRowSpan() const;
+ /**
+ Returns the row span. The default is 1.
+ */
+ int GetRowSpan() const { return m_rowSpan; }
- void SetRowSpan(long span) { GetProperties().SetProperty(wxT("rowspan"), span); }
+ /**
+ Sets the row span.
+ */
+ void SetRowSpan(int span);
// Operations
@@ -5705,6 +5728,8 @@ public:
void Copy(const wxRichTextCell& obj);
protected:
+ int m_colSpan;
+ int m_rowSpan;
};
/**
diff --git a/interface/wx/richtext/richtextbuffer.h b/interface/wx/richtext/richtextbuffer.h
index 38834746fa..ea5107e0ab 100644
--- a/interface/wx/richtext/richtextbuffer.h
+++ b/interface/wx/richtext/richtextbuffer.h
@@ -2588,6 +2588,16 @@ public:
*/
bool IsShown() const;
+ /**
+ Returns the object's unique identifier, if any.
+ */
+ const wxString& GetId() const;
+
+ /**
+ Sets the object's unique identifier.
+ */
+ void SetId(const wxString& id);
+
// Operations
/**
diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp
index 264598de4a..5ec84b74f2 100644
--- a/src/richtext/richtextbuffer.cpp
+++ b/src/richtext/richtextbuffer.cpp
@@ -531,6 +531,7 @@ void wxRichTextObject::Copy(const wxRichTextObject& obj)
m_properties = obj.m_properties;
m_descent = obj.m_descent;
m_show = obj.m_show;
+ m_id = obj.m_id;
}
// Get/set the top-level container of this object.
@@ -9389,6 +9390,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxRichTextCell, wxRichTextBox)
wxRichTextCell::wxRichTextCell(wxRichTextObject* parent):
wxRichTextBox(parent)
{
+ m_colSpan = 1;
+ m_rowSpan = 1;
}
/// Draw the item
@@ -9561,6 +9564,23 @@ bool wxRichTextCell::AdjustAttributes(wxRichTextAttr& attr, wxRichTextDrawingCon
void wxRichTextCell::Copy(const wxRichTextCell& obj)
{
wxRichTextBox::Copy(obj);
+
+ m_colSpan = obj.m_colSpan;
+ m_rowSpan = obj.m_rowSpan;
+}
+
+void wxRichTextCell::SetColSpan(int span)
+{
+ wxASSERT(span >= 1);
+ if (span >= 1)
+ m_colSpan = span;
+}
+
+void wxRichTextCell::SetRowSpan(int span)
+{
+ wxASSERT(span >= 1);
+ if (span >= 1)
+ m_rowSpan = span;
}
// Edit properties via a GUI
@@ -9643,29 +9663,6 @@ bool wxRichTextCell::EditProperties(wxWindow* parent, wxRichTextBuffer* buffer)
return false;
}
-// The next 2 methods return span values. Note that the default is 1, not 0
-int wxRichTextCell::GetColSpan() const
-{
- int span = 1;
- if (GetProperties().HasProperty(wxT("colspan")))
- {
- span = GetProperties().GetPropertyLong(wxT("colspan"));
- }
-
- return span;
-}
-
-int wxRichTextCell::GetRowSpan() const
-{
- int span = 1;
- if (GetProperties().HasProperty(wxT("rowspan")))
- {
- span = GetProperties().GetPropertyLong(wxT("rowspan"));
- }
-
- return span;
-}
-
WX_DEFINE_OBJARRAY(wxRichTextObjectPtrArrayArray)
IMPLEMENT_DYNAMIC_CLASS(wxRichTextTable, wxRichTextBox)
@@ -11574,21 +11571,29 @@ bool wxRichTextAction::Do()
// The plan is to swap the current object with the stored, previous-state, clone
// We can't get 'node' from the containing buffer (as it doesn't directly store objects)
// so use the parent paragraph
- wxRichTextParagraph* para = wxDynamicCast(obj->GetParent(), wxRichTextParagraph);
- wxCHECK_MSG(para, false, "Invalid parent paragraph");
+ wxRichTextCompositeObject* parent = wxDynamicCast(obj->GetParent(), wxRichTextCompositeObject);
+ wxCHECK_MSG(parent, false, wxT("Invalid parent"));
- // The stored object, m_object, may have a stale parent paragraph. This would cause
- // a crash during layout, so use obj's parent para, which should be the correct one.
+ // Check that at least one is a paragraph, but not both.
+ wxCHECK_MSG((!obj->IsKindOf(CLASSINFO(wxRichTextParagraph)) && parent->IsKindOf(CLASSINFO(wxRichTextParagraph))) ||
+ (obj->IsKindOf(CLASSINFO(wxRichTextParagraph)) && !parent->IsKindOf(CLASSINFO(wxRichTextParagraph)))
+ , false, wxT("Either the object or the parent must be a paragraph"));
+
+ // The stored object, m_object, may have a stale parent. This would cause
+ // a crash during layout, so use obj's parent, which should be the correct one.
// (An alternative would be to return the parent too from m_objectAddress.GetObject(),
// or to set obj's parent there before returning)
- m_object->SetParent(para);
-
- wxRichTextObjectList::compatibility_iterator node = para->GetChildren().Find(obj);
- if (node)
+ m_object->SetParent(parent);
+ if (parent)
{
- wxRichTextObject* obj = node->GetData();
- node->SetData(m_object);
- m_object = obj;
+ wxRichTextObjectList::compatibility_iterator node = parent->GetChildren().Find(obj);
+ if (node)
+ {
+ wxRichTextObject* obj = node->GetData();
+ node->SetData(m_object);
+ m_object = obj;
+ m_object->SetParent(NULL);
+ }
}
}
diff --git a/src/richtext/richtextdialogs.pjd b/src/richtext/richtextdialogs.pjd
index 788deac8c3..27a55a4a3c 100644
--- a/src/richtext/richtextdialogs.pjd
+++ b/src/richtext/richtextdialogs.pjd
@@ -474,7 +474,7 @@
0
"2/10/2006"
"wbTextCtrlProxy"
- "wxEVT_COMMAND_TEXT_UPDATED|OnFaceTextCtrlUpdated"
+ "wxEVT_COMMAND_TEXT_UPDATED|OnFaceTextCtrlUpdated|||wxRichTextFontPage"
"ID_RICHTEXTFONTPAGE_FACETEXTCTRL"
10001
""
@@ -7306,11 +7306,11 @@
0
"25/10/2006"
"wbSpinCtrlProxy"
- "wxEVT_COMMAND_SPINCTRL_UPDATED|OnNumberctrlUpdated"
- "wxEVT_SCROLL_LINEUP|OnNumberctrlUp"
- "wxEVT_SCROLL_LINEDOWN|OnNumberctrlDown"
- "wxEVT_COMMAND_TEXT_UPDATED|OnNumberctrlTextUpdated"
- "wxEVT_UPDATE_UI|OnNumberctrlUpdate"
+ "wxEVT_COMMAND_SPINCTRL_UPDATED|OnNumberctrlUpdated|||wxRichTextBulletsPage"
+ "wxEVT_SCROLL_LINEUP|OnNumberctrlUp|||"
+ "wxEVT_SCROLL_LINEDOWN|OnNumberctrlDown|||"
+ "wxEVT_COMMAND_TEXT_UPDATED|OnNumberctrlTextUpdated|||"
+ "wxEVT_UPDATE_UI|OnNumberctrlUpdate|||"
"ID_RICHTEXTBULLETSPAGE_NUMBERCTRL"
10310
""
diff --git a/src/richtext/richtextxml.cpp b/src/richtext/richtextxml.cpp
index 65898c558b..6c94051466 100644
--- a/src/richtext/richtextxml.cpp
+++ b/src/richtext/richtextxml.cpp
@@ -352,6 +352,7 @@ bool wxRichTextObject::ImportFromXML(wxRichTextBuffer* WXUNUSED(buffer), wxXmlNo
wxString value = node->GetAttribute(wxT("show"), wxEmptyString);
if (!value.IsEmpty())
Show(value == wxT("1"));
+ SetId(node->GetAttribute(wxT("id"), wxEmptyString));
*recurse = true;
@@ -368,6 +369,8 @@ bool wxRichTextObject::ExportXML(wxOutputStream& stream, int indent, wxRichTextX
wxString style = handler->GetHelper().AddAttributes(GetAttributes(), true);
if (!IsShown())
style << wxT(" show=\"0\"");
+ if (!GetId().IsEmpty())
+ style << wxT(" id=\"") << handler->GetHelper().AttributeToXML(GetId()) << wxT("\"");
handler->GetHelper().OutputString(stream, style + wxT(">"));
@@ -403,6 +406,8 @@ bool wxRichTextObject::ExportXML(wxXmlNode* parent, wxRichTextXMLHandler* handle
handler->GetHelper().WriteProperties(elementNode, GetProperties());
if (!IsShown())
elementNode->AddAttribute(wxT("show"), wxT("0"));
+ if (!GetId().IsEmpty())
+ elementNode->AddAttribute(wxT("id"), GetId());
wxRichTextCompositeObject* composite = wxDynamicCast(this, wxRichTextCompositeObject);
if (composite)
@@ -840,6 +845,15 @@ bool wxRichTextParagraphLayoutBox::ImportFromXML(wxRichTextBuffer* buffer, wxXml
if (partial == wxT("true"))
SetPartialParagraph(true);
+ wxRichTextCell* cell = wxDynamicCast(this, wxRichTextCell);
+ if (cell)
+ {
+ if (node->HasAttribute(wxT("colspan")))
+ cell->SetColSpan(wxAtoi(node->GetAttribute(wxT("colspan"), wxEmptyString)));
+ if (node->HasAttribute(wxT("rowspan")))
+ cell->SetRowSpan(wxAtoi(node->GetAttribute(wxT("rowspan"), wxEmptyString)));
+ }
+
wxXmlNode* child = handler->GetHelper().FindNode(node, wxT("stylesheet"));
if (child && (handler->GetFlags() & wxRICHTEXT_HANDLER_INCLUDE_STYLESHEET))
{
@@ -880,6 +894,13 @@ bool wxRichTextParagraphLayoutBox::ExportXML(wxOutputStream& stream, int indent,
if (GetPartialParagraph())
style << wxT(" partialparagraph=\"true\"");
+ wxRichTextCell* cell = wxDynamicCast(this, wxRichTextCell);
+ if (cell)
+ {
+ style << wxT(" colspan=\"") << wxString::Format(wxT("%d"), cell->GetColSpan()) << wxT("\"");
+ style << wxT(" rowspan=\"") << wxString::Format(wxT("%d"), cell->GetRowSpan()) << wxT("\"");
+ }
+
handler->GetHelper().OutputString(stream, style + wxT(">"));
if (GetProperties().GetCount() > 0)
@@ -912,6 +933,13 @@ bool wxRichTextParagraphLayoutBox::ExportXML(wxXmlNode* parent, wxRichTextXMLHan
if (GetPartialParagraph())
elementNode->AddAttribute(wxT("partialparagraph"), wxT("true"));
+ wxRichTextCell* cell = wxDynamicCast(this, wxRichTextCell);
+ if (cell)
+ {
+ elementNode->AddAttribute(wxT("colspan"), wxString::Format(wxT("%d"), cell->GetColSpan()));
+ elementNode->AddAttribute(wxT("rowspan"), wxString::Format(wxT("%d"), cell->GetRowSpan()));
+ }
+
size_t i;
for (i = 0; i < GetChildCount(); i++)
{