Added a box style definition name to the box attribute.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70233 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart 2012-01-02 21:18:05 +00:00
parent 3e14a8d3d7
commit 2f987d8309
4 changed files with 85 additions and 2 deletions

View File

@ -273,7 +273,8 @@ enum wxTextBoxAttrFlags
wxTEXT_BOX_ATTR_FLOAT = 0x00000001, wxTEXT_BOX_ATTR_FLOAT = 0x00000001,
wxTEXT_BOX_ATTR_CLEAR = 0x00000002, wxTEXT_BOX_ATTR_CLEAR = 0x00000002,
wxTEXT_BOX_ATTR_COLLAPSE_BORDERS = 0x00000004, wxTEXT_BOX_ATTR_COLLAPSE_BORDERS = 0x00000004,
wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT = 0x00000008 wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT = 0x00000008,
wxTEXT_BOX_ATTR_BOX_STYLE_NAME = 0x00000010
}; };
/** /**
@ -1332,6 +1333,21 @@ public:
wxTextAttrDimension& GetHeight() { return m_size.m_height; } wxTextAttrDimension& GetHeight() { return m_size.m_height; }
const wxTextAttrDimension& GetHeight() const { return m_size.m_height; } const wxTextAttrDimension& GetHeight() const { return m_size.m_height; }
/**
Returns the box style name.
*/
const wxString& GetBoxStyleName() const { return m_boxStyleName; }
/**
Sets the box style name.
*/
void SetBoxStyleName(const wxString& name) { m_boxStyleName = name; AddFlag(wxTEXT_BOX_ATTR_BOX_STYLE_NAME); }
/**
Returns @true if the box style name is present.
*/
bool HasBoxStyleName() const { return HasFlag(wxTEXT_BOX_ATTR_BOX_STYLE_NAME); }
public: public:
int m_flags; int m_flags;
@ -1349,6 +1365,7 @@ public:
wxTextBoxAttrClearStyle m_clearMode; wxTextBoxAttrClearStyle m_clearMode;
wxTextBoxAttrCollapseMode m_collapseMode; wxTextBoxAttrCollapseMode m_collapseMode;
wxTextBoxAttrVerticalAlignment m_verticalAlignment; wxTextBoxAttrVerticalAlignment m_verticalAlignment;
wxString m_boxStyleName;
}; };
/** /**

View File

@ -1217,6 +1217,21 @@ public:
wxTextAttrDimension& GetHeight() { return m_size.m_height; } wxTextAttrDimension& GetHeight() { return m_size.m_height; }
const wxTextAttrDimension& GetHeight() const { return m_size.m_height; } const wxTextAttrDimension& GetHeight() const { return m_size.m_height; }
/**
Returns the box style name.
*/
const wxString& GetBoxStyleName() const { return m_boxStyleName; }
/**
Sets the box style name.
*/
void SetBoxStyleName(const wxString& name) { m_boxStyleName = name; AddFlag(wxTEXT_BOX_ATTR_BOX_STYLE_NAME); }
/**
Returns @true if the box style name is present.
*/
bool HasBoxStyleName() const { return HasFlag(wxTEXT_BOX_ATTR_BOX_STYLE_NAME); }
public: public:
int m_flags; int m_flags;
@ -1234,6 +1249,7 @@ public:
wxTextBoxAttrClearStyle m_clearMode; wxTextBoxAttrClearStyle m_clearMode;
wxTextBoxAttrCollapseMode m_collapseMode; wxTextBoxAttrCollapseMode m_collapseMode;
wxTextBoxAttrVerticalAlignment m_verticalAlignment; wxTextBoxAttrVerticalAlignment m_verticalAlignment;
wxString m_boxStyleName;
}; };
/** /**

View File

@ -10746,6 +10746,7 @@ void wxTextBoxAttr::Reset()
m_clearMode = wxTEXT_BOX_ATTR_CLEAR_NONE; m_clearMode = wxTEXT_BOX_ATTR_CLEAR_NONE;
m_collapseMode = wxTEXT_BOX_ATTR_COLLAPSE_NONE; m_collapseMode = wxTEXT_BOX_ATTR_COLLAPSE_NONE;
m_verticalAlignment = wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_NONE; m_verticalAlignment = wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_NONE;
m_boxStyleName = wxEmptyString;
m_margins.Reset(); m_margins.Reset();
m_padding.Reset(); m_padding.Reset();
@ -10774,7 +10775,9 @@ bool wxTextBoxAttr::operator== (const wxTextBoxAttr& attr) const
m_size == attr.m_size && m_size == attr.m_size &&
m_border == attr.m_border && m_border == attr.m_border &&
m_outline == attr.m_outline m_outline == attr.m_outline &&
m_boxStyleName == attr.m_boxStyleName
); );
} }
@ -10793,6 +10796,9 @@ bool wxTextBoxAttr::EqPartial(const wxTextBoxAttr& attr) const
if (attr.HasVerticalAlignment() && HasVerticalAlignment() && (attr.GetVerticalAlignment() != GetVerticalAlignment())) if (attr.HasVerticalAlignment() && HasVerticalAlignment() && (attr.GetVerticalAlignment() != GetVerticalAlignment()))
return false; return false;
if (attr.HasBoxStyleName() && HasBoxStyleName() && (attr.GetBoxStyleName() != GetBoxStyleName()))
return false;
// Position // Position
if (!m_position.EqPartial(attr.m_position)) if (!m_position.EqPartial(attr.m_position))
@ -10850,6 +10856,12 @@ bool wxTextBoxAttr::Apply(const wxTextBoxAttr& attr, const wxTextBoxAttr* compar
SetVerticalAlignment(attr.GetVerticalAlignment()); SetVerticalAlignment(attr.GetVerticalAlignment());
} }
if (attr.HasBoxStyleName())
{
if (!(compareWith && compareWith->HasBoxStyleName() && compareWith->GetBoxStyleName() == attr.GetBoxStyleName()))
SetBoxStyleName(attr.GetBoxStyleName());
}
m_margins.Apply(attr.m_margins, compareWith ? (& attr.m_margins) : (const wxTextAttrDimensions*) NULL); m_margins.Apply(attr.m_margins, compareWith ? (& attr.m_margins) : (const wxTextAttrDimensions*) NULL);
m_padding.Apply(attr.m_padding, compareWith ? (& attr.m_padding) : (const wxTextAttrDimensions*) NULL); m_padding.Apply(attr.m_padding, compareWith ? (& attr.m_padding) : (const wxTextAttrDimensions*) NULL);
m_position.Apply(attr.m_position, compareWith ? (& attr.m_position) : (const wxTextAttrDimensions*) NULL); m_position.Apply(attr.m_position, compareWith ? (& attr.m_position) : (const wxTextAttrDimensions*) NULL);
@ -10877,6 +10889,12 @@ bool wxTextBoxAttr::RemoveStyle(const wxTextBoxAttr& attr)
if (attr.HasVerticalAlignment()) if (attr.HasVerticalAlignment())
RemoveFlag(wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT); RemoveFlag(wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT);
if (attr.HasBoxStyleName())
{
SetBoxStyleName(wxEmptyString);
RemoveFlag(wxTEXT_BOX_ATTR_BOX_STYLE_NAME);
}
m_margins.RemoveStyle(attr.m_margins); m_margins.RemoveStyle(attr.m_margins);
m_padding.RemoveStyle(attr.m_padding); m_padding.RemoveStyle(attr.m_padding);
m_position.RemoveStyle(attr.m_position); m_position.RemoveStyle(attr.m_position);
@ -10969,6 +10987,25 @@ void wxTextBoxAttr::CollectCommonAttributes(const wxTextBoxAttr& attr, wxTextBox
else else
absentAttr.AddFlag(wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT); absentAttr.AddFlag(wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT);
if (attr.HasBoxStyleName())
{
if (!clashingAttr.HasBoxStyleName() && !absentAttr.HasBoxStyleName())
{
if (HasBoxStyleName())
{
if (GetBoxStyleName() != attr.GetBoxStyleName())
{
clashingAttr.AddFlag(wxTEXT_BOX_ATTR_BOX_STYLE_NAME);
RemoveFlag(wxTEXT_BOX_ATTR_BOX_STYLE_NAME);
}
}
else
SetBoxStyleName(attr.GetBoxStyleName());
}
}
else
absentAttr.AddFlag(wxTEXT_BOX_ATTR_BOX_STYLE_NAME);
m_margins.CollectCommonAttributes(attr.m_margins, clashingAttr.m_margins, absentAttr.m_margins); m_margins.CollectCommonAttributes(attr.m_margins, clashingAttr.m_margins, absentAttr.m_margins);
m_padding.CollectCommonAttributes(attr.m_padding, clashingAttr.m_padding, absentAttr.m_padding); m_padding.CollectCommonAttributes(attr.m_padding, clashingAttr.m_padding, absentAttr.m_padding);
m_position.CollectCommonAttributes(attr.m_position, clashingAttr.m_position, absentAttr.m_position); m_position.CollectCommonAttributes(attr.m_position, clashingAttr.m_position, absentAttr.m_position);

View File

@ -1162,6 +1162,9 @@ wxString wxRichTextXMLHandler::AddAttributes(const wxRichTextAttr& attr, bool is
if (!attr.GetListStyleName().empty()) if (!attr.GetListStyleName().empty())
AddAttribute(str, wxT("liststyle"), AttributeToXML(attr.GetListStyleName())); AddAttribute(str, wxT("liststyle"), AttributeToXML(attr.GetListStyleName()));
if (!attr.GetTextBoxAttr().GetBoxStyleName().empty())
AddAttribute(str, wxT("boxstyle"), AttributeToXML(attr.GetTextBoxAttr().GetBoxStyleName()));
if (attr.HasTabs()) if (attr.HasTabs())
{ {
wxString strTabs; wxString strTabs;
@ -1451,6 +1454,9 @@ bool wxRichTextXMLHandler::AddAttributes(wxXmlNode* node, wxRichTextAttr& attr,
if (!attr.GetListStyleName().empty()) if (!attr.GetListStyleName().empty())
node->AddAttribute(wxT("liststyle"), attr.GetListStyleName()); node->AddAttribute(wxT("liststyle"), attr.GetListStyleName());
if (!attr.GetTextBoxAttr().GetBoxStyleName().empty())
node->AddAttribute(wxT("boxstyle"), attr.GetTextBoxAttr().GetBoxStyleName());
if (attr.HasTabs()) if (attr.HasTabs())
{ {
wxString tabs; wxString tabs;
@ -1804,6 +1810,13 @@ bool wxRichTextXMLHandler::ImportStyle(wxRichTextAttr& attr, wxXmlNode* node, bo
attr.SetListStyleName(value); attr.SetListStyleName(value);
} }
} }
else if (name == wxT("boxstyle"))
{
if (!value.empty())
{
attr.GetTextBoxAttr().SetBoxStyleName(value);
}
}
else if (name == wxT("tabs")) else if (name == wxT("tabs"))
{ {
if (!value.empty()) if (!value.empty())