Skip to content

Commit

Permalink
Merge pull request #1554 from KeyWorksRW/xrc_unavailable
Browse files Browse the repository at this point in the history
Change how unsupported XRC widget can have a comment to that effect
  • Loading branch information
Randalphwa authored Dec 24, 2024
2 parents 27341b5 + 33dd268 commit 41d4104
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 11 deletions.
25 changes: 21 additions & 4 deletions src/generate/gen_ctx_help_btn.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//////////////////////////////////////////////////////////////////////////
// Purpose: wxContextHelpButton generator
// Author: Ralph Walden
// Copyright: Copyright (c) 2023 KeyWorks Software (Ralph Walden)
// Copyright: Copyright (c) 2023-2024 KeyWorks Software (Ralph Walden)
// License: Apache License -- see ../../LICENSE
/////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -68,9 +68,26 @@ bool CtxHelpButtonGenerator::GetIncludes(Node* node, std::set<std::string>& set_
return true;
}

int CtxHelpButtonGenerator::GenXrcObject(Node* node, pugi::xml_node& object, size_t /* xrc_flags */)
int CtxHelpButtonGenerator::GenXrcObject(Node* /* node */, pugi::xml_node& /* object */, size_t /* xrc_flags */)
{
auto item = InitializeXrcObject(node, object);
ADD_ITEM_COMMENT(" XRC does not support wxContextHelpButton ")
return BaseGenerator::xrc_not_supported;
}

std::optional<tt_string> CtxHelpButtonGenerator::GetWarning(Node* node, GenLang language)
{
switch (language)
{
case GEN_LANG_XRC:
{
tt_string msg;
if (auto form = node->getForm(); form && form->hasValue(prop_class_name))
{
msg << form->as_string(prop_class_name) << ": ";
}
msg << " XRC currently does not support wxContextHelpButton ";
return msg;
}
default:
return {};
}
}
3 changes: 2 additions & 1 deletion src/generate/gen_ctx_help_btn.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//////////////////////////////////////////////////////////////////////////
// Purpose: wxContextHelpButton generator
// Author: Ralph Walden
// Copyright: Copyright (c) 2023 KeyWorks Software (Ralph Walden)
// Copyright: Copyright (c) 2023-2024 KeyWorks Software (Ralph Walden)
// License: Apache License -- see ../../LICENSE
/////////////////////////////////////////////////////////////////////////////

Expand All @@ -21,4 +21,5 @@ class CtxHelpButtonGenerator : public BaseGenerator
GenLang /* language */) override;

int GenXrcObject(Node*, pugi::xml_node& /* object */, size_t /* xrc_flags */) override;
std::optional<tt_string> GetWarning(Node* node, GenLang language) override;
};
19 changes: 19 additions & 0 deletions src/generate/gen_ribbon_tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,25 @@ int RibbonToolBarGenerator::GenXrcObject(Node* /* node */, pugi::xml_node& /* ob
return BaseGenerator::xrc_not_supported;
}

std::optional<tt_string> RibbonToolBarGenerator::GetWarning(Node* node, GenLang language)
{
switch (language)
{
case GEN_LANG_XRC:
{
tt_string msg;
if (auto form = node->getForm(); form && form->hasValue(prop_class_name))
{
msg << form->as_string(prop_class_name) << ": ";
}
msg << " XRC currently does not support wxRibbonToolBar ";
return msg;
}
default:
return {};
}
}

////////////////////////////////////////// RibbonToolGenerator //////////////////////////////////////////

bool RibbonToolGenerator::ConstructionCode(Code& code)
Expand Down
1 change: 1 addition & 0 deletions src/generate/gen_ribbon_tool.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class RibbonToolBarGenerator : public BaseGenerator
GenLang /* language */) override;

int GenXrcObject(Node*, pugi::xml_node& /* object */, size_t /* xrc_flags */) override;
std::optional<tt_string> GetWarning(Node* node, GenLang language) override;
};

class RibbonToolGenerator : public BaseGenerator
Expand Down
21 changes: 19 additions & 2 deletions src/generate/gen_xrc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,26 @@ int GenXrcObject(Node* node, pugi::xml_node& object, size_t xrc_flags)
{
auto generator = node->getNodeDeclaration()->getGenerator();
auto result = generator->GenXrcObject(node, object, xrc_flags);
if (result == BaseGenerator::xrc_not_supported && node->isGen(gen_Project))
if (result == BaseGenerator::xrc_not_supported)
{
result = BaseGenerator::xrc_updated;
if (node->isGen(gen_Project))
{
result = BaseGenerator::xrc_updated;
}
else
{
auto item = InitializeXrcObject(node, object);
auto comment = generator->GetWarning(node, GEN_LANG_XRC);
if (comment)
{
// We need a dummy item to hold the comment but which will not show up in the UI
GenXrcObjectAttributes(node, item, "wxBoxSizer");

object.append_child(pugi::node_comment).set_value(comment->c_str());
}

return BaseGenerator::xrc_form_not_supported;
}
}

if (result == BaseGenerator::xrc_sizer_item_created)
Expand Down
25 changes: 21 additions & 4 deletions src/generate/window_widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,28 @@ bool ScrolledCanvasGenerator::GetIncludes(Node* node, std::set<std::string>& set
return true;
}

int ScrolledCanvasGenerator::GenXrcObject(Node* node, pugi::xml_node& object, size_t /* xrc_flags */)
int ScrolledCanvasGenerator::GenXrcObject(Node* /* node */, pugi::xml_node& /* object */, size_t /* xrc_flags */)
{
auto item = InitializeXrcObject(node, object);
ADD_ITEM_COMMENT(" XRC does not support wxScrolledCanvas (wxScrolled<wxWindow>) ")
return BaseGenerator::xrc_updated;
return xrc_not_supported;
}

std::optional<tt_string> ScrolledCanvasGenerator::GetWarning(Node* node, GenLang language)
{
switch (language)
{
case GEN_LANG_XRC:
{
tt_string msg;
if (auto form = node->getForm(); form && form->hasValue(prop_class_name))
{
msg << form->as_string(prop_class_name) << ": ";
}
msg << " XRC currently does not support wxScrolledCanvas ";
return msg;
}
default:
return {};
}
}

////////////////////////////////////////// ScrolledWindowGenerator //////////////////////////////////////////
Expand Down
1 change: 1 addition & 0 deletions src/generate/window_widgets.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class ScrolledCanvasGenerator : public BaseGenerator
int GenXrcObject(Node*, pugi::xml_node& /* object */, size_t /* xrc_flags */) override;

tt_string GetHelpURL(Node*) override { return tt_string("group__group__class__miscwnd.html"); };
std::optional<tt_string> GetWarning(Node* node, GenLang language) override;
};

class ScrolledWindowGenerator : public BaseGenerator
Expand Down

0 comments on commit 41d4104

Please # to comment.