Skip to content

Commit

Permalink
Standardize wxScrolled... code generation
Browse files Browse the repository at this point in the history
Fixes #1551
  • Loading branch information
Randalphwa committed Dec 23, 2024
1 parent b1fb6af commit 4408f67
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ All notable changes to this project will be documented in this file.
- Fixed code generation for Python and Ruby wxStdDialogButtonSizer events
- Ruby code generation no longer writes the class `end` line before the final generated comment block
- You can add a menubar or toolbar to a wxFrame that was created without them
- Fixed inconsistent generation of wxScrolledWindow versus wxScrolled<wxPanel> -- wxScrolledWindow is now always used.

## [Released (1.2.1)]

Expand Down
15 changes: 11 additions & 4 deletions src/generate/window_widgets.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/////////////////////////////////////////////////////////////////////////////
// Purpose: Scroll window component classes
// Author: Ralph Walden
// Copyright: Copyright (c) 2020-2023 KeyWorks Software (Ralph Walden)
// Copyright: Copyright (c) 2020-2024 KeyWorks Software (Ralph Walden)
// License: Apache License -- see ../../LICENSE
/////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -30,7 +30,7 @@ bool ScrolledCanvasGenerator::ConstructionCode(Code& code)
{
if (code.is_cpp())
{
code.AddAuto().NodeName().Str(" = new wxScrolled<wxWindow>(");
code.AddAuto().NodeName().Str(" = new wxScrolledCanvas(");
code.ValidParentName().Comma().as_string(prop_id);
code.PosSizeFlags();
}
Expand Down Expand Up @@ -62,11 +62,18 @@ 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 */)
{
auto item = InitializeXrcObject(node, object);
ADD_ITEM_COMMENT(" XRC does not support wxScrolledCanvas (wxScrolled<wxWindow>) ")
return BaseGenerator::xrc_updated;
}

////////////////////////////////////////// ScrolledWindowGenerator //////////////////////////////////////////

wxObject* ScrolledWindowGenerator::CreateMockup(Node* node, wxObject* parent)
{
auto widget = new wxScrolled<wxPanel>(wxStaticCast(parent, wxWindow), wxID_ANY, DlgPoint(node, prop_pos),
auto widget = new wxScrolledWindow(wxStaticCast(parent, wxWindow), wxID_ANY, DlgPoint(node, prop_pos),
DlgSize(node, prop_size), GetStyleInt(node));
widget->SetScrollRate(node->as_int(prop_scroll_rate_x), node->as_int(prop_scroll_rate_y));

Expand All @@ -79,7 +86,7 @@ bool ScrolledWindowGenerator::ConstructionCode(Code& code)
{
if (code.is_cpp())
{
code.AddAuto().NodeName().Str(" = new wxScrolled<wxPanel>(");
code.AddAuto().NodeName().Str(" = new wxScrolledWindow(");
code.ValidParentName().Comma().as_string(prop_id);
code.PosSizeFlags();
}
Expand Down
3 changes: 2 additions & 1 deletion src/generate/window_widgets.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/////////////////////////////////////////////////////////////////////////////
// Purpose: Scroll window component classes
// Author: Ralph Walden
// Copyright: Copyright (c) 2020-2023 KeyWorks Software (Ralph Walden)
// Copyright: Copyright (c) 2020-2024 KeyWorks Software (Ralph Walden)
// License: Apache License -- see ../../LICENSE
/////////////////////////////////////////////////////////////////////////////

Expand All @@ -19,6 +19,7 @@ class ScrolledCanvasGenerator : public BaseGenerator

bool GetIncludes(Node* node, std::set<std::string>& set_src, std::set<std::string>& set_hdr,
GenLang /* language */) override;
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"); };
};
Expand Down
4 changes: 2 additions & 2 deletions src/panels/ribbon_tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ void RibbonPanel::OnDropDown(wxRibbonToolBarEvent& event)
case NewScrolled:
{
wxMenu menu;
menu.Append(gen_wxScrolledWindow, "Insert wxScrolled<wxPanel> (wxScrolledWindow)");
menu.Append(gen_wxScrolledCanvas, "Insert wxScrolled<wxWindow> (wxScrolledCanvas)");
menu.Append(gen_wxScrolledWindow, "Insert wxScrolledWindow");
menu.Append(gen_wxScrolledCanvas, "Insert wxScrolledCanvas");

menu.Bind(wxEVT_MENU, &RibbonPanel::OnMenuEvent, this, wxID_ANY);
event.PopupMenu(&menu);
Expand Down

0 comments on commit 4408f67

Please # to comment.