From 46efa354ee1a95fdd0d7ca74d1c037f03d3767a0 Mon Sep 17 00:00:00 2001 From: Steffen Olszewski Date: Fri, 16 Feb 2024 22:42:39 +0100 Subject: [PATCH 1/8] Add XRC filter type Passthrough This filter type passes values between XRC and XFB unmodified as text. This is useful for properties that use the exact same representation in both formats. Current code usually uses the type Text and relies on the fact that the properties don't use values that require escaping. The type Passthrough never uses escaping and makes semantically clear that values get passed unmodified. --- sdk/plugin_interface/xrcconv.cpp | 6 ++++++ sdk/plugin_interface/xrcconv.h | 1 + 2 files changed, 7 insertions(+) diff --git a/sdk/plugin_interface/xrcconv.cpp b/sdk/plugin_interface/xrcconv.cpp index 70111872..7276b6ac 100644 --- a/sdk/plugin_interface/xrcconv.cpp +++ b/sdk/plugin_interface/xrcconv.cpp @@ -209,6 +209,9 @@ void ObjectToXrcFilter::AddProperty(Type propType, const wxString& objPropName, } break; } + case Type::Passthrough: + SetText(propertyElement, m_obj->GetPropertyAsString(objPropName), false); + break; } } @@ -466,6 +469,9 @@ void XrcToXfbFilter::AddProperty(Type propType, const wxString& xrcPropName, con case Type::Bitmap: SetBitmapProperty(propertyElement, xrcPropName); break; + case Type::Passthrough: + SetTextProperty(propertyElement, xrcPropName, false); + break; } } diff --git a/sdk/plugin_interface/xrcconv.h b/sdk/plugin_interface/xrcconv.h index 691300ae..c2e90f66 100644 --- a/sdk/plugin_interface/xrcconv.h +++ b/sdk/plugin_interface/xrcconv.h @@ -57,6 +57,7 @@ class XrcFilter Font, BitList, StringList, + Passthrough, }; protected: From 035bb9f3f5b0acb074bd33a15a7425b5a9ce6bad Mon Sep 17 00:00:00 2001 From: Steffen Olszewski Date: Fri, 16 Feb 2024 23:19:30 +0100 Subject: [PATCH 2/8] Reorder case labels to match the enum symbol oder better No functional changes, just to improve clarity. --- sdk/plugin_interface/xrcconv.cpp | 54 ++++++++++++++++---------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/sdk/plugin_interface/xrcconv.cpp b/sdk/plugin_interface/xrcconv.cpp index 7276b6ac..a48878fe 100644 --- a/sdk/plugin_interface/xrcconv.cpp +++ b/sdk/plugin_interface/xrcconv.cpp @@ -159,15 +159,6 @@ void ObjectToXrcFilter::AddProperty(Type propType, const wxString& objPropName, { auto* propertyElement = m_xrcElement->InsertNewChildElement(!xrcPropName.empty() ? xrcPropName.utf8_str() : objPropName.utf8_str()); switch (propType) { - case Type::Size: - case Type::Point: - case Type::BitList: - SetText(propertyElement, m_obj->GetPropertyAsString(objPropName)); - break; - case Type::Text: - // The text must be converted to XRC format - SetText(propertyElement, m_obj->GetPropertyAsString(objPropName), true); - break; case Type::Bool: case Type::Integer: SetInteger(propertyElement, m_obj->GetPropertyAsInteger(objPropName)); @@ -175,14 +166,14 @@ void ObjectToXrcFilter::AddProperty(Type propType, const wxString& objPropName, case Type::Float: SetFloat(propertyElement, m_obj->GetPropertyAsFloat(objPropName)); break; - case Type::Colour: - SetColour(propertyElement, m_obj->GetPropertyAsColour(objPropName)); - break; - case Type::Font: - SetFont(propertyElement, m_obj->GetPropertyAsFont(objPropName)); + case Type::Text: + // The text must be converted to XRC format + SetText(propertyElement, m_obj->GetPropertyAsString(objPropName), true); break; - case Type::StringList: - SetStringList(propertyElement, m_obj->GetPropertyAsArrayString(objPropName)); + case Type::Point: + case Type::Size: + case Type::BitList: + SetText(propertyElement, m_obj->GetPropertyAsString(objPropName), false); break; case Type::Bitmap: { auto bitmapProp = m_obj->GetPropertyAsString(objPropName); @@ -209,6 +200,15 @@ void ObjectToXrcFilter::AddProperty(Type propType, const wxString& objPropName, } break; } + case Type::Colour: + SetColour(propertyElement, m_obj->GetPropertyAsColour(objPropName)); + break; + case Type::Font: + SetFont(propertyElement, m_obj->GetPropertyAsFont(objPropName)); + break; + case Type::StringList: + SetStringList(propertyElement, m_obj->GetPropertyAsArrayString(objPropName)); + break; case Type::Passthrough: SetText(propertyElement, m_obj->GetPropertyAsString(objPropName), false); break; @@ -440,13 +440,10 @@ void XrcToXfbFilter::AddProperty(Type propType, const wxString& xrcPropName, con auto* propertyElement = m_xfbElement->InsertNewChildElement("property"); XMLUtils::SetAttribute(propertyElement, "name", !xfbPropName.empty() ? xfbPropName : xrcPropName); switch (propType) { - case Type::Size: - case Type::Point: case Type::Bool: - SetTextProperty(propertyElement, xrcPropName); - break; - case Type::Text: - SetTextProperty(propertyElement, xrcPropName, true); + case Type::Point: + case Type::Size: + SetTextProperty(propertyElement, xrcPropName, false); break; case Type::Integer: SetIntegerProperty(propertyElement, xrcPropName); @@ -454,8 +451,11 @@ void XrcToXfbFilter::AddProperty(Type propType, const wxString& xrcPropName, con case Type::Float: SetFloatProperty(propertyElement, xrcPropName); break; - case Type::BitList: - SetBitlistProperty(propertyElement, xrcPropName); + case Type::Text: + SetTextProperty(propertyElement, xrcPropName, true); + break; + case Type::Bitmap: + SetBitmapProperty(propertyElement, xrcPropName); break; case Type::Colour: SetColourProperty(propertyElement, xrcPropName); @@ -463,12 +463,12 @@ void XrcToXfbFilter::AddProperty(Type propType, const wxString& xrcPropName, con case Type::Font: SetFontProperty(propertyElement, xrcPropName); break; + case Type::BitList: + SetBitlistProperty(propertyElement, xrcPropName); + break; case Type::StringList: SetStringListProperty(propertyElement, xrcPropName, true); break; - case Type::Bitmap: - SetBitmapProperty(propertyElement, xrcPropName); - break; case Type::Passthrough: SetTextProperty(propertyElement, xrcPropName, false); break; From a6df062222854e9e3fdde4ea7e3c0c17d952ab1c Mon Sep 17 00:00:00 2001 From: Steffen Olszewski Date: Fri, 16 Feb 2024 23:30:51 +0100 Subject: [PATCH 3/8] Add XRC filter type Option This filter type is the single value variant of BitList. Current code does use the type Text for macro-like properties but the Text type does not perform synonymous translation on import. --- sdk/plugin_interface/xrcconv.cpp | 16 ++++++++++++++++ sdk/plugin_interface/xrcconv.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/sdk/plugin_interface/xrcconv.cpp b/sdk/plugin_interface/xrcconv.cpp index a48878fe..12696aae 100644 --- a/sdk/plugin_interface/xrcconv.cpp +++ b/sdk/plugin_interface/xrcconv.cpp @@ -172,6 +172,7 @@ void ObjectToXrcFilter::AddProperty(Type propType, const wxString& objPropName, break; case Type::Point: case Type::Size: + case Type::Option: case Type::BitList: SetText(propertyElement, m_obj->GetPropertyAsString(objPropName), false); break; @@ -463,6 +464,9 @@ void XrcToXfbFilter::AddProperty(Type propType, const wxString& xrcPropName, con case Type::Font: SetFontProperty(propertyElement, xrcPropName); break; + case Type::Option: + SetOptionProperty(propertyElement, xrcPropName); + break; case Type::BitList: SetBitlistProperty(propertyElement, xrcPropName); break; @@ -678,6 +682,18 @@ void XrcToXfbFilter::SetFontProperty(tinyxml2::XMLElement* element, const wxStri )); } +void XrcToXfbFilter::SetOptionProperty(tinyxml2::XMLElement* element, const wxString& name) const +{ + const auto* propertyElement = m_xrcElement->FirstChildElement(name.utf8_str()); + if (!propertyElement) { + return; + } + + auto option = XMLUtils::GetText(propertyElement); + option = m_lib->ReplaceSynonymous(option); + XMLUtils::SetText(element, option); +} + void XrcToXfbFilter::SetBitlistProperty(tinyxml2::XMLElement* element, const wxString& name) const { const auto* propertyElement = m_xrcElement->FirstChildElement(name.utf8_str()); diff --git a/sdk/plugin_interface/xrcconv.h b/sdk/plugin_interface/xrcconv.h index c2e90f66..b9368f9a 100644 --- a/sdk/plugin_interface/xrcconv.h +++ b/sdk/plugin_interface/xrcconv.h @@ -55,6 +55,7 @@ class XrcFilter Bitmap, Colour, Font, + Option, BitList, StringList, Passthrough, @@ -220,6 +221,7 @@ class XrcToXfbFilter : public XrcFilter void SetBitmapProperty(tinyxml2::XMLElement* element, const wxString& name) const; void SetColourProperty(tinyxml2::XMLElement* element, const wxString& name) const; void SetFontProperty(tinyxml2::XMLElement* element, const wxString& name) const; + void SetOptionProperty(tinyxml2::XMLElement* element, const wxString& name) const; void SetBitlistProperty(tinyxml2::XMLElement* element, const wxString& name) const; void SetStringListProperty(tinyxml2::XMLElement* element, const wxString& name, bool xrcFormat = false) const; From d599e59608f846e9aba9a2ea344545e35222d2ea Mon Sep 17 00:00:00 2001 From: Steffen Olszewski Date: Fri, 16 Feb 2024 23:55:15 +0100 Subject: [PATCH 4/8] Rename XRC filter type Passthrough to String The XRC File Format specification uses this datatype for text-like properties that don't perform XRC text escapes, it makes more sense to use that name as well. --- sdk/plugin_interface/xrcconv.cpp | 16 ++++++---------- sdk/plugin_interface/xrcconv.h | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/sdk/plugin_interface/xrcconv.cpp b/sdk/plugin_interface/xrcconv.cpp index 12696aae..fa0c8d8a 100644 --- a/sdk/plugin_interface/xrcconv.cpp +++ b/sdk/plugin_interface/xrcconv.cpp @@ -166,16 +166,17 @@ void ObjectToXrcFilter::AddProperty(Type propType, const wxString& objPropName, case Type::Float: SetFloat(propertyElement, m_obj->GetPropertyAsFloat(objPropName)); break; - case Type::Text: - // The text must be converted to XRC format - SetText(propertyElement, m_obj->GetPropertyAsString(objPropName), true); - break; + case Type::String: case Type::Point: case Type::Size: case Type::Option: case Type::BitList: SetText(propertyElement, m_obj->GetPropertyAsString(objPropName), false); break; + case Type::Text: + // The text must be converted to XRC format + SetText(propertyElement, m_obj->GetPropertyAsString(objPropName), true); + break; case Type::Bitmap: { auto bitmapProp = m_obj->GetPropertyAsString(objPropName); if (bitmapProp.empty()) { @@ -210,9 +211,6 @@ void ObjectToXrcFilter::AddProperty(Type propType, const wxString& objPropName, case Type::StringList: SetStringList(propertyElement, m_obj->GetPropertyAsArrayString(objPropName)); break; - case Type::Passthrough: - SetText(propertyElement, m_obj->GetPropertyAsString(objPropName), false); - break; } } @@ -442,6 +440,7 @@ void XrcToXfbFilter::AddProperty(Type propType, const wxString& xrcPropName, con XMLUtils::SetAttribute(propertyElement, "name", !xfbPropName.empty() ? xfbPropName : xrcPropName); switch (propType) { case Type::Bool: + case Type::String: case Type::Point: case Type::Size: SetTextProperty(propertyElement, xrcPropName, false); @@ -473,9 +472,6 @@ void XrcToXfbFilter::AddProperty(Type propType, const wxString& xrcPropName, con case Type::StringList: SetStringListProperty(propertyElement, xrcPropName, true); break; - case Type::Passthrough: - SetTextProperty(propertyElement, xrcPropName, false); - break; } } diff --git a/sdk/plugin_interface/xrcconv.h b/sdk/plugin_interface/xrcconv.h index b9368f9a..8eb4969f 100644 --- a/sdk/plugin_interface/xrcconv.h +++ b/sdk/plugin_interface/xrcconv.h @@ -49,6 +49,7 @@ class XrcFilter Bool = 0, Integer, Float, + String, Text, Point, Size, @@ -58,7 +59,6 @@ class XrcFilter Option, BitList, StringList, - Passthrough, }; protected: From 584848e9938d8a42c993dedd72ea7ff0084011b5 Mon Sep 17 00:00:00 2001 From: Steffen Olszewski Date: Sat, 17 Feb 2024 00:02:20 +0100 Subject: [PATCH 5/8] Rename XRC filter type StringList to TextList Reflect the fact that this datatype does XRC text escaping. --- plugins/additional/additional.cpp | 4 ++-- plugins/common/common.cpp | 20 ++++++++++---------- sdk/plugin_interface/xrcconv.cpp | 4 ++-- sdk/plugin_interface/xrcconv.h | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/plugins/additional/additional.cpp b/plugins/additional/additional.cpp index c5d57089..264cd1d1 100644 --- a/plugins/additional/additional.cpp +++ b/plugins/additional/additional.cpp @@ -992,7 +992,7 @@ class CheckListBoxComponent : public ComponentBase { ObjectToXrcFilter filter(xrc, GetLibrary(), obj); filter.AddWindowProperties(); - filter.AddProperty(XrcFilter::Type::StringList, "choices", "content"); + filter.AddProperty(XrcFilter::Type::TextList, "choices", "content"); return xrc; } @@ -1000,7 +1000,7 @@ class CheckListBoxComponent : public ComponentBase { XrcToXfbFilter filter(xfb, GetLibrary(), xrc); filter.AddWindowProperties(); - filter.AddProperty(XrcFilter::Type::StringList, "content", "choices"); + filter.AddProperty(XrcFilter::Type::TextList, "content", "choices"); return xfb; } }; diff --git a/plugins/common/common.cpp b/plugins/common/common.cpp index 11e50452..6269681a 100644 --- a/plugins/common/common.cpp +++ b/plugins/common/common.cpp @@ -664,7 +664,7 @@ class ComboBoxComponent : public ComponentBase ObjectToXrcFilter filter(xrc, GetLibrary(), obj); filter.AddWindowProperties(); filter.AddProperty(XrcFilter::Type::Text, "value"); - filter.AddProperty(XrcFilter::Type::StringList, "choices", "content"); + filter.AddProperty(XrcFilter::Type::TextList, "choices", "content"); return xrc; } @@ -673,7 +673,7 @@ class ComboBoxComponent : public ComponentBase XrcToXfbFilter filter(xfb, GetLibrary(), xrc); filter.AddWindowProperties(); filter.AddProperty(XrcFilter::Type::Text, "value"); - filter.AddProperty(XrcFilter::Type::StringList, "content", "choices"); + filter.AddProperty(XrcFilter::Type::TextList, "content", "choices"); return xfb; } }; @@ -717,7 +717,7 @@ class BitmapComboBoxComponent : public ComponentBase ObjectToXrcFilter filter(xrc, GetLibrary(), obj); filter.AddWindowProperties(); filter.AddProperty(XrcFilter::Type::Text, "value"); - filter.AddProperty(XrcFilter::Type::StringList, "choices", "content"); + filter.AddProperty(XrcFilter::Type::TextList, "choices", "content"); return xrc; } @@ -726,7 +726,7 @@ class BitmapComboBoxComponent : public ComponentBase XrcToXfbFilter filter(xfb, GetLibrary(), xrc); filter.AddWindowProperties(); filter.AddProperty(XrcFilter::Type::Text, "value"); - filter.AddProperty(XrcFilter::Type::StringList, "content", "choices"); + filter.AddProperty(XrcFilter::Type::TextList, "content", "choices"); return xfb; } }; @@ -900,7 +900,7 @@ class ListBoxComponent : public ComponentBase { ObjectToXrcFilter filter(xrc, GetLibrary(), obj); filter.AddWindowProperties(); - filter.AddProperty(XrcFilter::Type::StringList, "choices", "content"); + filter.AddProperty(XrcFilter::Type::TextList, "choices", "content"); return xrc; } @@ -908,7 +908,7 @@ class ListBoxComponent : public ComponentBase { XrcToXfbFilter filter(xfb, GetLibrary(), xrc); filter.AddWindowProperties(); - filter.AddProperty(XrcFilter::Type::StringList, "content", "choices"); + filter.AddProperty(XrcFilter::Type::TextList, "content", "choices"); return xfb; } }; @@ -976,7 +976,7 @@ class RadioBoxComponent : public ComponentBase, public wxEvtHandler filter.AddWindowProperties(); filter.AddProperty(XrcFilter::Type::Text, "label"); filter.AddProperty(XrcFilter::Type::Integer, "selection"); - filter.AddProperty(XrcFilter::Type::StringList, "choices", "content"); + filter.AddProperty(XrcFilter::Type::TextList, "choices", "content"); filter.AddProperty(XrcFilter::Type::Integer, "majorDimension", "dimension"); return xrc; } @@ -987,7 +987,7 @@ class RadioBoxComponent : public ComponentBase, public wxEvtHandler filter.AddWindowProperties(); filter.AddProperty(XrcFilter::Type::Text, "label"); filter.AddProperty(XrcFilter::Type::Integer, "selection"); - filter.AddProperty(XrcFilter::Type::StringList, "content", "choices"); + filter.AddProperty(XrcFilter::Type::TextList, "content", "choices"); filter.AddProperty(XrcFilter::Type::Integer, "dimension", "majorDimension"); return xfb; } @@ -1463,7 +1463,7 @@ class ChoiceComponent : public ComponentBase ObjectToXrcFilter filter(xrc, GetLibrary(), obj); filter.AddWindowProperties(); filter.AddProperty(XrcFilter::Type::Integer, "selection"); - filter.AddProperty(XrcFilter::Type::StringList, "choices", "content"); + filter.AddProperty(XrcFilter::Type::TextList, "choices", "content"); return xrc; } @@ -1472,7 +1472,7 @@ class ChoiceComponent : public ComponentBase XrcToXfbFilter filter(xfb, GetLibrary(), xrc); filter.AddWindowProperties(); filter.AddProperty(XrcFilter::Type::Integer, "selection"); - filter.AddProperty(XrcFilter::Type::StringList, "content", "choices"); + filter.AddProperty(XrcFilter::Type::TextList, "content", "choices"); return xfb; } }; diff --git a/sdk/plugin_interface/xrcconv.cpp b/sdk/plugin_interface/xrcconv.cpp index fa0c8d8a..afd81c21 100644 --- a/sdk/plugin_interface/xrcconv.cpp +++ b/sdk/plugin_interface/xrcconv.cpp @@ -208,7 +208,7 @@ void ObjectToXrcFilter::AddProperty(Type propType, const wxString& objPropName, case Type::Font: SetFont(propertyElement, m_obj->GetPropertyAsFont(objPropName)); break; - case Type::StringList: + case Type::TextList: SetStringList(propertyElement, m_obj->GetPropertyAsArrayString(objPropName)); break; } @@ -469,7 +469,7 @@ void XrcToXfbFilter::AddProperty(Type propType, const wxString& xrcPropName, con case Type::BitList: SetBitlistProperty(propertyElement, xrcPropName); break; - case Type::StringList: + case Type::TextList: SetStringListProperty(propertyElement, xrcPropName, true); break; } diff --git a/sdk/plugin_interface/xrcconv.h b/sdk/plugin_interface/xrcconv.h index 8eb4969f..351b4fef 100644 --- a/sdk/plugin_interface/xrcconv.h +++ b/sdk/plugin_interface/xrcconv.h @@ -58,7 +58,7 @@ class XrcFilter Font, Option, BitList, - StringList, + TextList, }; protected: From afd2c025b010b72f4c607e6758c42cebf07a8d0f Mon Sep 17 00:00:00 2001 From: Steffen Olszewski Date: Fri, 16 Feb 2024 23:46:11 +0100 Subject: [PATCH 6/8] Use XRC filter type Option instead of Text --- plugins/additional/additional.cpp | 8 ++++---- plugins/common/common.cpp | 16 ++++++++-------- plugins/layout/layout.cpp | 12 ++++++------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/plugins/additional/additional.cpp b/plugins/additional/additional.cpp index 264cd1d1..a2cbdcdd 100644 --- a/plugins/additional/additional.cpp +++ b/plugins/additional/additional.cpp @@ -617,7 +617,7 @@ class ToggleButtonComponent : public ComponentBase, public wxEvtHandler filter.AddProperty(XrcFilter::Type::Bitmap, "current"); } if (!obj->IsPropertyNull("position")) { - filter.AddProperty(XrcFilter::Type::Text, "position", "bitmapposition"); + filter.AddProperty(XrcFilter::Type::Option, "position", "bitmapposition"); } if (!obj->IsPropertyNull("margins")) { filter.AddProperty(XrcFilter::Type::Size, "margins"); @@ -637,7 +637,7 @@ class ToggleButtonComponent : public ComponentBase, public wxEvtHandler filter.AddProperty(XrcFilter::Type::Bitmap, "pressed"); filter.AddProperty(XrcFilter::Type::Bitmap, "focus"); filter.AddProperty(XrcFilter::Type::Bitmap, "current"); - filter.AddProperty(XrcFilter::Type::Text, "bitmapposition", "position"); + filter.AddProperty(XrcFilter::Type::Option, "bitmapposition", "position"); filter.AddProperty(XrcFilter::Type::Size, "margins"); filter.AddProperty(XrcFilter::Type::Bool, "checked", "value"); return xfb; @@ -719,7 +719,7 @@ class BitmapToggleButtonComponent : public ComponentBase, public wxEvtHandler filter.AddProperty(XrcFilter::Type::Bitmap, "current"); } if (!obj->IsPropertyNull("position")) { - filter.AddProperty(XrcFilter::Type::Text, "position", "bitmapposition"); + filter.AddProperty(XrcFilter::Type::Option, "position", "bitmapposition"); } if (!obj->IsPropertyNull("margins")) { filter.AddProperty(XrcFilter::Type::Size, "margins"); @@ -737,7 +737,7 @@ class BitmapToggleButtonComponent : public ComponentBase, public wxEvtHandler filter.AddProperty(XrcFilter::Type::Bitmap, "pressed"); filter.AddProperty(XrcFilter::Type::Bitmap, "focus"); filter.AddProperty(XrcFilter::Type::Bitmap, "current"); - filter.AddProperty(XrcFilter::Type::Text, "bitmapposition", "position"); + filter.AddProperty(XrcFilter::Type::Option, "bitmapposition", "position"); filter.AddProperty(XrcFilter::Type::Size, "margins"); filter.AddProperty(XrcFilter::Type::Bool, "checked", "value"); return xfb; diff --git a/plugins/common/common.cpp b/plugins/common/common.cpp index 6269681a..6a5122c0 100644 --- a/plugins/common/common.cpp +++ b/plugins/common/common.cpp @@ -420,7 +420,7 @@ class ButtonComponent : public ComponentBase filter.AddProperty(XrcFilter::Type::Bitmap, "current"); } if (!obj->IsPropertyNull("position")) { - filter.AddProperty(XrcFilter::Type::Text, "position", "bitmapposition"); + filter.AddProperty(XrcFilter::Type::Option, "position", "bitmapposition"); } if (!obj->IsPropertyNull("margins")) { filter.AddProperty(XrcFilter::Type::Size, "margins"); @@ -441,7 +441,7 @@ class ButtonComponent : public ComponentBase filter.AddProperty(XrcFilter::Type::Bitmap, "pressed"); filter.AddProperty(XrcFilter::Type::Bitmap, "focus"); filter.AddProperty(XrcFilter::Type::Bitmap, "current"); - filter.AddProperty(XrcFilter::Type::Text, "bitmapposition", "position"); + filter.AddProperty(XrcFilter::Type::Option, "bitmapposition", "position"); filter.AddProperty(XrcFilter::Type::Size, "margins"); return xfb; } @@ -517,7 +517,7 @@ class BitmapButtonComponent : public ComponentBase filter.AddProperty(XrcFilter::Type::Bitmap, "current"); } if (!obj->IsPropertyNull("position")) { - filter.AddProperty(XrcFilter::Type::Text, "position", "bitmapposition"); + filter.AddProperty(XrcFilter::Type::Option, "position", "bitmapposition"); } if (!obj->IsPropertyNull("margins")) { filter.AddProperty(XrcFilter::Type::Size, "margins"); @@ -536,7 +536,7 @@ class BitmapButtonComponent : public ComponentBase filter.AddProperty(XrcFilter::Type::Bitmap, "pressed"); filter.AddProperty(XrcFilter::Type::Bitmap, "focus"); filter.AddProperty(XrcFilter::Type::Bitmap, "current"); - filter.AddProperty(XrcFilter::Type::Text, "bitmapposition", "position"); + filter.AddProperty(XrcFilter::Type::Option, "bitmapposition", "position"); filter.AddProperty(XrcFilter::Type::Size, "margins"); return xfb; } @@ -1630,8 +1630,8 @@ class InfoBarComponent : public ComponentBase { ObjectToXrcFilter filter(xrc, GetLibrary(), obj); filter.AddWindowProperties(); - filter.AddProperty(XrcFilter::Type::Text, "show_effect", "showeffect"); - filter.AddProperty(XrcFilter::Type::Text, "hide_effect", "hideeffect"); + filter.AddProperty(XrcFilter::Type::Option, "show_effect", "showeffect"); + filter.AddProperty(XrcFilter::Type::Option, "hide_effect", "hideeffect"); filter.AddProperty(XrcFilter::Type::Integer, "duration", "effectduration"); // FIXME: button is currently not part of the data model return xrc; @@ -1641,8 +1641,8 @@ class InfoBarComponent : public ComponentBase { XrcToXfbFilter filter(xfb, GetLibrary(), xrc); filter.AddWindowProperties(); - filter.AddProperty(XrcFilter::Type::Text, "showeffect", "show_effect"); - filter.AddProperty(XrcFilter::Type::Text, "hideeffect", "hide_effect"); + filter.AddProperty(XrcFilter::Type::Option, "showeffect", "show_effect"); + filter.AddProperty(XrcFilter::Type::Option, "hideeffect", "hide_effect"); filter.AddProperty(XrcFilter::Type::Integer, "effectduration", "duration"); // FIXME: button is currently not part of the data model return xfb; diff --git a/plugins/layout/layout.cpp b/plugins/layout/layout.cpp index 42c1816c..63171163 100644 --- a/plugins/layout/layout.cpp +++ b/plugins/layout/layout.cpp @@ -174,7 +174,7 @@ class BoxSizerComponent : public ComponentBase if (obj->GetPropertyAsSize("minimum_size") != wxDefaultSize) { filter.AddProperty(XrcFilter::Type::Size, "minimum_size", "minsize"); } - filter.AddProperty(XrcFilter::Type::Text, "orient"); + filter.AddProperty(XrcFilter::Type::Option, "orient"); return xrc; } @@ -182,7 +182,7 @@ class BoxSizerComponent : public ComponentBase { XrcToXfbFilter filter(xfb, GetLibrary(), xrc); filter.AddProperty(XrcFilter::Type::Size, "minsize", "minimum_size"); - filter.AddProperty(XrcFilter::Type::Text, "orient"); + filter.AddProperty(XrcFilter::Type::Option, "orient"); return xfb; } }; @@ -204,7 +204,7 @@ class WrapSizerComponent : public ComponentBase if (obj->GetPropertyAsSize("minimum_size") != wxDefaultSize) { filter.AddProperty(XrcFilter::Type::Size, "minimum_size", "minsize"); } - filter.AddProperty(XrcFilter::Type::Text, "orient"); + filter.AddProperty(XrcFilter::Type::Option, "orient"); filter.AddProperty(XrcFilter::Type::BitList, "flags"); return xrc; } @@ -213,7 +213,7 @@ class WrapSizerComponent : public ComponentBase { XrcToXfbFilter filter(xfb, GetLibrary(), xrc); filter.AddProperty(XrcFilter::Type::Size, "minsize", "minimum_size"); - filter.AddProperty(XrcFilter::Type::Text, "orient"); + filter.AddProperty(XrcFilter::Type::Option, "orient"); filter.AddProperty(XrcFilter::Type::BitList, "flags"); return xfb; } @@ -242,7 +242,7 @@ class StaticBoxSizerComponent : public ComponentBase if (obj->GetPropertyAsSize("minimum_size") != wxDefaultSize) { filter.AddProperty(XrcFilter::Type::Size, "minimum_size", "minsize"); } - filter.AddProperty(XrcFilter::Type::Text, "orient"); + filter.AddProperty(XrcFilter::Type::Option, "orient"); filter.AddProperty(XrcFilter::Type::Text, "label"); return xrc; } @@ -251,7 +251,7 @@ class StaticBoxSizerComponent : public ComponentBase { XrcToXfbFilter filter(xfb, GetLibrary(), xrc); filter.AddProperty(XrcFilter::Type::Size, "minsize", "minimum_size"); - filter.AddProperty(XrcFilter::Type::Text, "orient"); + filter.AddProperty(XrcFilter::Type::Option, "orient"); filter.AddProperty(XrcFilter::Type::Text, "label"); return xfb; } From c20e5fa90175204b9770ea218f511064ca197a72 Mon Sep 17 00:00:00 2001 From: Steffen Olszewski Date: Sat, 17 Feb 2024 00:26:03 +0100 Subject: [PATCH 7/8] Use XRC filter type String instead of Text --- plugins/additional/additional.cpp | 18 ++++++++---------- plugins/common/common.cpp | 4 ++-- plugins/layout/layout.cpp | 8 ++++---- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/plugins/additional/additional.cpp b/plugins/additional/additional.cpp index a2cbdcdd..159e8d50 100644 --- a/plugins/additional/additional.cpp +++ b/plugins/additional/additional.cpp @@ -1287,7 +1287,7 @@ class FilePickerComponent : public PickerComponentBase { ObjectToXrcFilter filter(xrc, GetLibrary(), obj); filter.AddWindowProperties(); - filter.AddProperty(XrcFilter::Type::Text, "value"); + filter.AddProperty(XrcFilter::Type::String, "value"); filter.AddProperty(XrcFilter::Type::Text, "message"); filter.AddProperty(XrcFilter::Type::Text, "wildcard"); return xrc; @@ -1297,7 +1297,7 @@ class FilePickerComponent : public PickerComponentBase { XrcToXfbFilter filter(xfb, GetLibrary(), xrc); filter.AddWindowProperties(); - filter.AddProperty(XrcFilter::Type::Text, "value"); + filter.AddProperty(XrcFilter::Type::String, "value"); filter.AddProperty(XrcFilter::Type::Text, "message"); filter.AddProperty(XrcFilter::Type::Text, "wildcard"); return xfb; @@ -1330,7 +1330,7 @@ class DirPickerComponent : public PickerComponentBase { ObjectToXrcFilter filter(xrc, GetLibrary(), obj); filter.AddWindowProperties(); - filter.AddProperty(XrcFilter::Type::Text, "value"); + filter.AddProperty(XrcFilter::Type::String, "value"); filter.AddProperty(XrcFilter::Type::Text, "message"); return xrc; } @@ -1339,7 +1339,7 @@ class DirPickerComponent : public PickerComponentBase { XrcToXfbFilter filter(xfb, GetLibrary(), xrc); filter.AddWindowProperties(); - filter.AddProperty(XrcFilter::Type::Text, "value"); + filter.AddProperty(XrcFilter::Type::String, "value"); filter.AddProperty(XrcFilter::Type::Text, "message"); return xfb; } @@ -1373,7 +1373,7 @@ class HyperlinkComponent : public ComponentBase ObjectToXrcFilter filter(xrc, GetLibrary(), obj); filter.AddWindowProperties(); filter.AddProperty(XrcFilter::Type::Text, "label"); - filter.AddPropertyValue("url", obj->GetPropertyAsString("url")); + filter.AddProperty(XrcFilter::Type::String, "url"); return xrc; } @@ -1382,9 +1382,7 @@ class HyperlinkComponent : public ComponentBase XrcToXfbFilter filter(xfb, GetLibrary(), xrc); filter.AddWindowProperties(); filter.AddProperty(XrcFilter::Type::Text, "label"); - if (const auto* urlElement = xrc->FirstChildElement("url")) { - filter.AddPropertyValue("url", XMLUtils::GetText(urlElement)); - } + filter.AddProperty(XrcFilter::Type::String, "url"); return xfb; } }; @@ -1417,7 +1415,7 @@ class GenericDirCtrlComponent : public ComponentBase { ObjectToXrcFilter filter(xrc, GetLibrary(), obj); filter.AddWindowProperties(); - filter.AddProperty(XrcFilter::Type::Text, "defaultfolder"); + filter.AddProperty(XrcFilter::Type::String, "defaultfolder"); filter.AddProperty(XrcFilter::Type::Text, "filter"); filter.AddProperty(XrcFilter::Type::Integer, "defaultfilter"); return xrc; @@ -1427,7 +1425,7 @@ class GenericDirCtrlComponent : public ComponentBase { XrcToXfbFilter filter(xfb, GetLibrary(), xrc); filter.AddWindowProperties(); - filter.AddProperty(XrcFilter::Type::Text, "defaultfolder"); + filter.AddProperty(XrcFilter::Type::String, "defaultfolder"); filter.AddProperty(XrcFilter::Type::Text, "filter"); filter.AddProperty(XrcFilter::Type::Integer, "defaultfilter"); return xfb; diff --git a/plugins/common/common.cpp b/plugins/common/common.cpp index 6a5122c0..eb8313e0 100644 --- a/plugins/common/common.cpp +++ b/plugins/common/common.cpp @@ -1587,7 +1587,7 @@ class AnimCtrlComponent : public ComponentBase { ObjectToXrcFilter filter(xrc, GetLibrary(), obj); filter.AddWindowProperties(); - filter.AddProperty(XrcFilter::Type::Text, "animation"); + filter.AddProperty(XrcFilter::Type::String, "animation"); return xrc; } @@ -1595,7 +1595,7 @@ class AnimCtrlComponent : public ComponentBase { XrcToXfbFilter filter(xfb, GetLibrary(), xrc); filter.AddWindowProperties(); - filter.AddProperty(XrcFilter::Type::Text, "animation"); + filter.AddProperty(XrcFilter::Type::String, "animation"); return xfb; } }; diff --git a/plugins/layout/layout.cpp b/plugins/layout/layout.cpp index 63171163..e5b4d9ef 100644 --- a/plugins/layout/layout.cpp +++ b/plugins/layout/layout.cpp @@ -320,8 +320,8 @@ class FlexGridSizerBase : public ComponentBase } filter.AddProperty(XrcFilter::Type::Integer, "vgap"); filter.AddProperty(XrcFilter::Type::Integer, "hgap"); - filter.AddProperty(XrcFilter::Type::Text, "growablerows"); - filter.AddProperty(XrcFilter::Type::Text, "growablecols"); + filter.AddProperty(XrcFilter::Type::String, "growablerows"); + filter.AddProperty(XrcFilter::Type::String, "growablecols"); return xrc; } @@ -331,8 +331,8 @@ class FlexGridSizerBase : public ComponentBase filter.AddProperty(XrcFilter::Type::Size, "minsize", "minimum_size"); filter.AddProperty(XrcFilter::Type::Integer, "vgap"); filter.AddProperty(XrcFilter::Type::Integer, "hgap"); - filter.AddProperty(XrcFilter::Type::Text, "growablerows"); - filter.AddProperty(XrcFilter::Type::Text, "growablecols"); + filter.AddProperty(XrcFilter::Type::String, "growablerows"); + filter.AddProperty(XrcFilter::Type::String, "growablecols"); return xfb; } }; From 2dade96b944fc3287bac17ed664f76a53f05bd8f Mon Sep 17 00:00:00 2001 From: Steffen Olszewski Date: Mon, 19 Feb 2024 22:16:41 +0100 Subject: [PATCH 8/8] Fix data types of wxSpinButton based controls --- plugins/additional/additional.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/additional/additional.cpp b/plugins/additional/additional.cpp index 159e8d50..2a78556e 100644 --- a/plugins/additional/additional.cpp +++ b/plugins/additional/additional.cpp @@ -864,7 +864,7 @@ class SpinCtrlComponent : public ComponentBase, public wxEvtHandler { ObjectToXrcFilter filter(xrc, GetLibrary(), obj); filter.AddWindowProperties(); - filter.AddProperty(XrcFilter::Type::Text, "initial", "value"); + filter.AddProperty(XrcFilter::Type::Integer, "initial", "value"); filter.AddProperty(XrcFilter::Type::Integer, "min"); filter.AddProperty(XrcFilter::Type::Integer, "max"); return xrc; @@ -874,9 +874,9 @@ class SpinCtrlComponent : public ComponentBase, public wxEvtHandler { XrcToXfbFilter filter(xfb, GetLibrary(), xrc); filter.AddWindowProperties(); - // FIXME: Why is value filtered twice? What effect does this have? - filter.AddProperty(XrcFilter::Type::Text, "value"); - filter.AddProperty(XrcFilter::Type::Text, "value", "initial"); + // TODO: XRC only supports the integral initial value, filter it twice to initialize the string initial value as well + filter.AddProperty(XrcFilter::Type::String, "value"); + filter.AddProperty(XrcFilter::Type::Integer, "value", "initial"); filter.AddProperty(XrcFilter::Type::Integer, "min"); filter.AddProperty(XrcFilter::Type::Integer, "max"); return xfb; @@ -927,7 +927,7 @@ class SpinCtrlDoubleComponent : public ComponentBase, public wxEvtHandler { ObjectToXrcFilter filter(xrc, GetLibrary(), obj); filter.AddWindowProperties(); - filter.AddProperty(XrcFilter::Type::Text, "initial", "value"); + filter.AddProperty(XrcFilter::Type::Float, "initial", "value"); filter.AddProperty(XrcFilter::Type::Float, "min"); filter.AddProperty(XrcFilter::Type::Float, "max"); filter.AddProperty(XrcFilter::Type::Float, "inc"); @@ -939,9 +939,9 @@ class SpinCtrlDoubleComponent : public ComponentBase, public wxEvtHandler { XrcToXfbFilter filter(xfb, GetLibrary(), xrc); filter.AddWindowProperties(); - // FIXME: Why is value filtered twice? What effect does this have? - filter.AddProperty(XrcFilter::Type::Text, "value"); - filter.AddProperty(XrcFilter::Type::Text, "value", "initial"); + // TODO: XRC only supports the float initial value, filter it twice to initialize the string initial value as well + filter.AddProperty(XrcFilter::Type::String, "value"); + filter.AddProperty(XrcFilter::Type::Float, "value", "initial"); filter.AddProperty(XrcFilter::Type::Float, "min"); filter.AddProperty(XrcFilter::Type::Float, "max"); filter.AddProperty(XrcFilter::Type::Float, "inc");