From 4101665b7c26438385e58bfa1b1bf9b15a075d86 Mon Sep 17 00:00:00 2001 From: Randalphwa <38287198+Randalphwa@users.noreply.github.com> Date: Tue, 16 Jan 2024 08:59:40 -0800 Subject: [PATCH 1/7] Add label to XRC for ribbonButton --- src/generate/gen_ribbon_button.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/generate/gen_ribbon_button.cpp b/src/generate/gen_ribbon_button.cpp index 9b84c7a3c..d9a5e0ddc 100644 --- a/src/generate/gen_ribbon_button.cpp +++ b/src/generate/gen_ribbon_button.cpp @@ -88,6 +88,7 @@ int RibbonButtonGenerator::GenXrcObject(Node* node, pugi::xml_node& object, size { auto item = InitializeXrcObject(node, object); GenXrcObjectAttributes(node, item, "button"); + ADD_ITEM_PROP(prop_label, "label") if (!node->hasValue(prop_bitmap)) { From 07bc7f660b1071917679d9efae0cdf5379ddac69 Mon Sep 17 00:00:00 2001 From: Randalphwa <38287198+Randalphwa@users.noreply.github.com> Date: Tue, 16 Jan 2024 09:00:17 -0800 Subject: [PATCH 2/7] Fix importing ribbonButton/ribbonGalleryItem --- src/import/import_xml.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/import/import_xml.cpp b/src/import/import_xml.cpp index 465e8341e..a2158a795 100644 --- a/src/import/import_xml.cpp +++ b/src/import/import_xml.cpp @@ -1183,13 +1183,21 @@ NodeSharedPtr ImportXML::CreateXrcNode(pugi::xml_node& xml_obj, Node* parent, No is_generic_version = true; getGenName = gen_wxAnimationCtrl; } + else if (object_name == "button" && (parent->isGen(gen_wxRibbonButtonBar))) + { + getGenName = gen_ribbonButton; + } + else if (object_name == "item" && (parent->isGen(gen_wxRibbonGallery))) + { + getGenName = gen_ribbonGalleryItem; + } else { #if defined(INTERNAL_TESTING) - if (parent && parent->getForm()) + if (parent) { MSG_INFO(tt_string() << "Unrecognized object: " << object_name << " in " - << parent->getForm()->as_string(prop_class_name)); + << map_GenNames.at(parent->getGenName())); } else { From 352fb6bb720d629bc0ea37a08f33e3164669c82f Mon Sep 17 00:00:00 2001 From: Randalphwa <38287198+Randalphwa@users.noreply.github.com> Date: Tue, 16 Jan 2024 09:21:00 -0800 Subject: [PATCH 3/7] Remove conditional blocking wxDialog comparison I no longer remember why this was conditionalized, but it prevented side-by-side comparisons of C++/XRC dialogs. --- src/generate/gen_xrc.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/generate/gen_xrc.cpp b/src/generate/gen_xrc.cpp index cc09af8bc..456d4a34c 100644 --- a/src/generate/gen_xrc.cpp +++ b/src/generate/gen_xrc.cpp @@ -208,7 +208,6 @@ std::string GenerateXrcStr(Node* node_start, size_t xrc_flags) GenXrcObject(node_start, object, xrc_flags); } -#if 0 else if ((xrc_flags & xrc::previewing) && node_start->isGen(gen_wxDialog)) { auto object = root.append_child("object"); @@ -217,7 +216,6 @@ std::string GenerateXrcStr(Node* node_start, size_t xrc_flags) object = object.append_child("object"); GenXrcObject(node_start->getChild(0), object, xrc_flags); } -#endif else { auto object = root.append_child("object"); From ef15db84e2dc569ae75aa2f0131db9105a170cf0 Mon Sep 17 00:00:00 2001 From: Randalphwa <38287198+Randalphwa@users.noreply.github.com> Date: Fri, 19 Jan 2024 05:19:02 -0800 Subject: [PATCH 4/7] Fix xrc gen and import for wxPropertySheetDialog This adds the required propertysheetpage to XRC generation and imports it back as a bookpage --- src/generate/gen_book_page.cpp | 2 ++ src/import/import_xml.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/generate/gen_book_page.cpp b/src/generate/gen_book_page.cpp index 17aff3dc2..131550c0b 100644 --- a/src/generate/gen_book_page.cpp +++ b/src/generate/gen_book_page.cpp @@ -366,6 +366,8 @@ int BookPageGenerator::GenXrcObject(Node* node, pugi::xml_node& object, size_t x page_type = "treebookpage"; else if (node->getParent()->isGen(gen_BookPage)) page_type = "treebookpage"; + else if (node->getParent()->isGen(gen_wxPropertySheetDialog)) + page_type = "propertysheetpage"; else FAIL_MSG("BookPageGenerator needs to know what to call the pages to pass to the XRC handler.") diff --git a/src/import/import_xml.cpp b/src/import/import_xml.cpp index a2158a795..ab3029ae7 100644 --- a/src/import/import_xml.cpp +++ b/src/import/import_xml.cpp @@ -1174,7 +1174,7 @@ NodeSharedPtr ImportXML::CreateXrcNode(pugi::xml_node& xml_obj, Node* parent, No auto getGenName = ConvertToGenName(object_name, parent); if (getGenName == gen_unknown) { - if (object_name.ends_with("bookpage")) + if (object_name.ends_with("bookpage") || object_name == "propertysheetpage") { getGenName = gen_BookPage; } From f27258af041ec2c7893fa2dc1b460e0b321d1b4b Mon Sep 17 00:00:00 2001 From: Randalphwa <38287198+Randalphwa@users.noreply.github.com> Date: Fri, 19 Jan 2024 06:52:21 -0800 Subject: [PATCH 5/7] Add form class name to MSG_INFO When converting an entire project, it's easier to know which form contains the control with a problem. --- src/import/import_xml.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/import/import_xml.cpp b/src/import/import_xml.cpp index ab3029ae7..df68f8e55 100644 --- a/src/import/import_xml.cpp +++ b/src/import/import_xml.cpp @@ -1196,8 +1196,18 @@ NodeSharedPtr ImportXML::CreateXrcNode(pugi::xml_node& xml_obj, Node* parent, No #if defined(INTERNAL_TESTING) if (parent) { - MSG_INFO(tt_string() << "Unrecognized object: " << object_name << " in " - << map_GenNames.at(parent->getGenName())); + auto form = parent->getForm(); + if (form && form->hasValue(prop_class_name)) + { + MSG_INFO(tt_string() << "Unrecognized object: " << object_name << " in " + << map_GenNames.at(parent->getGenName()) << " (" << form->as_string(prop_class_name) + << ')'); + } + else + { + MSG_INFO(tt_string() << "Unrecognized object: " << object_name << " in " + << map_GenNames.at(parent->getGenName())); + } } else { From 06cd401f1e597d041e881d4baa97ae21ff582bcd Mon Sep 17 00:00:00 2001 From: Randalphwa <38287198+Randalphwa@users.noreply.github.com> Date: Fri, 19 Jan 2024 06:54:24 -0800 Subject: [PATCH 6/7] Initial support for listcol property This property is used to set the column headers for a wxListView control. --- src/import/import_xml.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/import/import_xml.cpp b/src/import/import_xml.cpp index df68f8e55..da193c751 100644 --- a/src/import/import_xml.cpp +++ b/src/import/import_xml.cpp @@ -626,6 +626,21 @@ void ImportXML::ProcessProperties(const pugi::xml_node& xml_obj, Node* node, Nod { if (iter.name() == "object") { + if (node->isGen(gen_wxListView)) + { + if (auto class_name = iter.attribute("class").value(); class_name.size()) + { + if (auto col_node = iter.child("text"); col_node) + { + auto col_name = col_node.text().as_string(); + std::string cur_col_names = node->as_string(prop_column_labels); + if (cur_col_names.size()) + cur_col_names += ";"; + cur_col_names += col_name; + node->set_value(prop_column_labels, cur_col_names); + } + } + } continue; } @@ -1191,6 +1206,10 @@ NodeSharedPtr ImportXML::CreateXrcNode(pugi::xml_node& xml_obj, Node* parent, No { getGenName = gen_ribbonGalleryItem; } + else if (object_name == "listcol" && parent->isGen(gen_wxListView)) + { + return NodeSharedPtr(); + } else { #if defined(INTERNAL_TESTING) From 199b47d0aa9e87aff79ba34c0dc5fb752b7772bc Mon Sep 17 00:00:00 2001 From: Randalphwa <38287198+Randalphwa@users.noreply.github.com> Date: Fri, 19 Jan 2024 06:58:17 -0800 Subject: [PATCH 7/7] Reformat comments Not sure how it happened, but clang-format reformatted most of the comments, and I normally use a shorter line length to improve readability. So, I reformatted most of the comments. --- src/import/import_xml.cpp | 51 +++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/src/import/import_xml.cpp b/src/import/import_xml.cpp index da193c751..00e5d573d 100644 --- a/src/import/import_xml.cpp +++ b/src/import/import_xml.cpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // Purpose: Base class for XML importing // Author: Ralph Walden -// Copyright: Copyright (c) 2021-2023 KeyWorks Software (Ralph Walden) +// Copyright: Copyright (c) 2021-2024 KeyWorks Software (Ralph Walden) // License: Apache License -- see ../../LICENSE ///////////////////////////////////////////////////////////////////////////// @@ -241,9 +241,9 @@ void ImportXML::HandleSizerItemProperty(const pugi::xml_node& xml_prop, Node* no align_value << "wxALIGN_CENTER_HORIZONTAL"; } - // Because we use contains(), all we know is that a CENTER flag was used, but not which one. - // If we get here and no CENTER flag has been added, then assume that "wxALIGN_CENTER" or - // "wxALIGN_CENTRE" was specified. + // Because we use contains(), all we know is that a CENTER flag was used, but not which + // one. If we get here and no CENTER flag has been added, then assume that + // "wxALIGN_CENTER" or "wxALIGN_CENTRE" was specified. if (!align_value.contains("wxALIGN_CENTER")) { @@ -300,8 +300,8 @@ void ImportXML::ProcessStyle(pugi::xml_node& xml_prop, Node* node, NodeProperty* { if (node->isGen(gen_wxListBox) || node->isGen(gen_wxCheckListBox)) { - // A list box selection type can only be single, multiple, or extended, so wxUiEditor stores this setting in a - // type property so that the user can only choose one. + // A list box selection type can only be single, multiple, or extended, so wxUiEditor + // stores this setting in a type property so that the user can only choose one. tt_string style(xml_prop.text().as_string()); if (style.contains("wxLB_SINGLE")) @@ -345,8 +345,8 @@ void ImportXML::ProcessStyle(pugi::xml_node& xml_prop, Node* node, NodeProperty* } else if (node->isGen(gen_wxGauge)) { - // A list box selection type can only be single, multiple, or extended, so wxUiEditor stores this setting in a - // type property so that the user can only choose one. + // A list box selection type can only be single, multiple, or extended, so wxUiEditor + // stores this setting in a type property so that the user can only choose one. tt_string style(xml_prop.text().as_string()); if (style.contains("wxGA_VERTICAL")) @@ -378,8 +378,8 @@ void ImportXML::ProcessStyle(pugi::xml_node& xml_prop, Node* node, NodeProperty* } else if (node->isGen(gen_wxSlider)) { - // A list box selection type can only be single, multiple, or extended, so wxUiEditor stores this setting in a - // type property so that the user can only choose one. + // A list box selection type can only be single, multiple, or extended, so wxUiEditor + // stores this setting in a type property so that the user can only choose one. tt_string style(xml_prop.text().as_string()); if (style.contains("wxSL_HORIZONTAL")) @@ -661,7 +661,8 @@ void ImportXML::ProcessProperties(const pugi::xml_node& xml_obj, Node* node, Nod continue; } - // Start by processing names that wxUiEditor might use but that need special processing when importing. + // Start by processing names that wxUiEditor might use but that need special processing + // when importing. if (wxue_prop == prop_bitmap) { @@ -1015,9 +1016,10 @@ void ImportXML::ProcessUnknownProperty(const pugi::xml_node& xml_obj, Node* node { if (value.contains(";")) { - // wxFormBuilder breaks this into three fields: class, header, forward_declare. Or at least it is - // supposed to. In version 3.10, it doesn't properly handle an empty class name, so the header file - // can appear first. + // wxFormBuilder breaks this into three fields: class, header, + // forward_declare. Or at least it is supposed to. In version 3.10, it + // doesn't properly handle an empty class name, so the header file can + // appear first. tt_string_vector parts(value, ';', tt::TRIM::both); if (parts.size() > 0) { @@ -1143,8 +1145,8 @@ void ImportXML::ProcessBitmap(const pugi::xml_node& xml_obj, Node* node, GenEnum { tt_string bitmap("Embed;"); - // wxGlade doubles the backslash after the drive letter on Windows, and that causes the conversion to a relative - // path to be incorrect + // wxGlade doubles the backslash after the drive letter on Windows, and that causes + // the conversion to a relative path to be incorrect file.Replace(":\\\\", ":\\"); tt_string relative(file.make_wxString()); @@ -1307,16 +1309,18 @@ NodeSharedPtr ImportXML::CreateXrcNode(pugi::xml_node& xml_obj, Node* parent, No msg << object_name; if (parent) { - // We can't use the class name because that won't necessarily be the wxWidgets class name. E.g., PanelForm might - // be the class name, but what we want to display to the user is wxPanel. GetHelpText() will give us something - // that makes sense to the user. + // We can't use the class name because that won't necessarily be the wxWidgets + // class name. E.g., PanelForm might be the class name, but what we want to display + // to the user is wxPanel. GetHelpText() will give us something that makes sense to + // the user. auto name = parent->getGenerator()->GetHelpText(parent); if (name.size() && name != "wxWidgets") { #if defined(_DEBUG) - // Currently, Debug builds also include the filename that gets passed to the browser if Help is requested. - // That's not useful in a message box, so we remove it. + // Currently, Debug builds also include the filename that gets passed to the + // browser if Help is requested. That's not useful in a message box, so we + // remove it. name.erase_from('('); #endif // _DEBUG @@ -1425,8 +1429,9 @@ NodeSharedPtr ImportXML::CreateXrcNode(pugi::xml_node& xml_obj, Node* parent, No new_node->set_value(prop_rows, 0); } - // Various designers allow the users to create settings that will generate an assert if compiled on a debug version of - // wxWidgets. We fix some of the more common invalid settings here. + // Various designers allow the users to create settings that will generate an assert if + // compiled on a debug version of wxWidgets. We fix some of the more common invalid + // settings here. if (new_node->hasValue(prop_flags) && new_node->as_string(prop_flags).contains("wxEXPAND")) {