Skip to content

Commit

Permalink
Issue #70: Widget::style() is odd, it should be withStyle()
Browse files Browse the repository at this point in the history
  • Loading branch information
rmpowell77 committed Feb 1, 2023
1 parent 79e2b51 commit 2a17f16
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 22 deletions.
5 changes: 5 additions & 0 deletions LATEST_RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Bugs addressed in this release:

Other changes:

* [#55](../../issues/55) Layout::Generic should take wxWindow also
* [#56](../../issues/56) Need Line
* [#57](../../issues/56) Need Slider
* [#58](../../issues/58) Need SpinCtrl Controller
* [#59](../../issues/59) need BitmapToggleButton
* [#65](../../issues/65) Custom controller should take a coroutine that generates wxWindows to be added to the sizer
* [#70](../../issues/70) Widget::style() is odd, it should be withStyle()

10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ ExampleDialog::ExampleDialog(wxWindow* parent)
"Text examples",
Text { "Example of Text in wxUI" },
TextCtrl { "Single line of text" }
.style(wxALIGN_LEFT),
.withStyle(wxALIGN_LEFT),
TextCtrl {
"Several lines of text.\n"
"With wxUI the code reflects\n"
"what the UI looks like." }
.style(wxTE_MULTILINE)
.withStyle(wxTE_MULTILINE)
.withSize(wxSize(200, 100))
},
RadioBox { "&Log Levels:", { "&Information", "&Warning", "&Error", "&None", "&Custom" } }
.style(wxRA_SPECIFY_ROWS)
.withStyle(wxRA_SPECIFY_ROWS)
.majorDim(1)
.withSelection(1),

Expand All @@ -42,7 +42,7 @@ ExampleDialog::ExampleDialog(wxWindow* parent)
CheckBox { "Show" },
Choice { { "Less", "More" } },
TextCtrl { wxSizerFlags(1).Expand().Border(), "Fill in the blank" }
.style(wxALIGN_LEFT),
.withStyle(wxALIGN_LEFT),
},

HStack {
Expand Down Expand Up @@ -109,7 +109,7 @@ ExampleDialog::ExampleDialog(wxWindow* parent)
"Text examples",
Text { "Example of Text in wxUI" },
TextCtrl { "Single line of text" }
.style(wxALIGN_LEFT),
.withStyle(wxALIGN_LEFT),
// ...
},
// ...
Expand Down
2 changes: 1 addition & 1 deletion docs/ProgrammersGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ One special type of "Layout" is `Generic`. There are cases where you may have a
CheckBox { "Show" },
Choice { { "Less", "More" } },
TextCtrl { wxSizerFlags(1).Expand().Border(), "Fill in the blank" }
.style(wxALIGN_LEFT),
.withStyle(wxALIGN_LEFT),
},
```

Expand Down
8 changes: 4 additions & 4 deletions examples/HelloWorld/HelloWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,19 +240,19 @@ ExampleDialog::ExampleDialog(wxWindow* parent)
// endsnippet wxUILayoutBasic
Text { "Example of Text in wxUI" },
TextCtrl { "Single line of text" }
.style(wxALIGN_LEFT),
.withStyle(wxALIGN_LEFT),
// endsnippet withwxUI
TextCtrl {
"Several lines of text.\n"
"With wxUI the code reflects\n"
"what the UI looks like." }
.style(wxTE_MULTILINE)
.withStyle(wxTE_MULTILINE)
.withSize(wxSize(200, 100))
// snippet withwxUI
},
// endsnippet withwxUI
RadioBox { "&Log Levels:", { "&Information", "&Warning", "&Error", "&None", "&Custom" } }
.style(wxRA_SPECIFY_ROWS)
.withStyle(wxRA_SPECIFY_ROWS)
.majorDim(1)
.withSelection(1),

Expand All @@ -262,7 +262,7 @@ ExampleDialog::ExampleDialog(wxWindow* parent)
CheckBox { "Show" },
Choice { { "Less", "More" } },
TextCtrl { wxSizerFlags(1).Expand().Border(), "Fill in the blank" }
.style(wxALIGN_LEFT),
.withStyle(wxALIGN_LEFT),
},
// endsnippet wxUIController

Expand Down
4 changes: 2 additions & 2 deletions include/wxUI/Line.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ struct Line : public details::WidgetDetails<Line, wxStaticLine> {

inline auto HLine() -> Line
{
return Line(wxSizerFlags {}.Border(wxALL, 2).Proportion(1).Expand()).style(wxLI_HORIZONTAL);
return Line(wxSizerFlags {}.Border(wxALL, 2).Proportion(1).Expand()).withStyle(wxLI_HORIZONTAL);
}

inline auto VLine() -> Line
{
return Line(wxSizerFlags {}.Border(wxALL, 2).Proportion(1).Expand()).style(wxLI_VERTICAL);
return Line(wxSizerFlags {}.Border(wxALL, 2).Proportion(1).Expand()).withStyle(wxLI_VERTICAL);
}

static_assert(details::Widget<Line>);
Expand Down
2 changes: 1 addition & 1 deletion include/wxUI/Widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ struct WidgetDetails {
return static_cast<ConcreteWidget&>(*this);
}

auto style(int64_t style) -> ConcreteWidget&
auto withStyle(int64_t style) -> ConcreteWidget&
{
usingStyle = style;
return static_cast<ConcreteWidget&>(*this);
Expand Down
2 changes: 1 addition & 1 deletion tests/wxUI_BitmapButtonTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ TEST_CASE("BitmapButton")
SECTION("style")
{
wxFrame frame { nullptr, wxID_ANY, "" };
auto uut = TypeUnderTest { wxBitmap {} }.style(wxBU_LEFT);
auto uut = TypeUnderTest { wxBitmap {} }.withStyle(wxBU_LEFT);
auto* window = dynamic_cast<TypeUnderTest::underlying_t*>(uut.create(&frame));
CHECK(window->GetWindowStyle() == (wxBU_LEFT | wxBU_EXACTFIT | wxBU_NOTEXT));
}
Expand Down
2 changes: 1 addition & 1 deletion tests/wxUI_ButtonTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ TEST_CASE("Button")
SECTION("style")
{
wxFrame frame { nullptr, wxID_ANY, "" };
auto uut = TypeUnderTest {}.style(wxBU_LEFT);
auto uut = TypeUnderTest {}.withStyle(wxBU_LEFT);
auto* window = dynamic_cast<TypeUnderTest::underlying_t*>(uut.create(&frame));
CHECK(window->GetWindowStyle() == wxBU_LEFT);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/wxUI_CheckBoxTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ TEST_CASE("CheckBox")
SECTION("style")
{
wxFrame frame { nullptr, wxID_ANY, "" };
auto uut = TypeUnderTest {}.style(wxCHK_3STATE);
auto uut = TypeUnderTest {}.withStyle(wxCHK_3STATE);
auto* window = dynamic_cast<TypeUnderTest::underlying_t*>(uut.create(&frame));
CHECK(window->GetWindowStyle() == wxCHK_3STATE);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/wxUI_ChoiceTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ TEST_CASE("Choice")
SECTION("style")
{
wxFrame frame { nullptr, wxID_ANY, "" };
auto uut = TypeUnderTest {}.style(wxCB_SORT);
auto uut = TypeUnderTest {}.withStyle(wxCB_SORT);
auto* window = dynamic_cast<TypeUnderTest::underlying_t*>(uut.create(&frame));
CHECK(window->GetWindowStyle() == wxCB_SORT);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/wxUI_ListBoxTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ TEST_CASE("ListBox")
SECTION("style")
{
wxFrame frame { nullptr, wxID_ANY, "" };
auto uut = TypeUnderTest {}.style(wxLB_MULTIPLE);
auto uut = TypeUnderTest {}.withStyle(wxLB_MULTIPLE);
auto* window = dynamic_cast<TypeUnderTest::underlying_t*>(uut.create(&frame));
CHECK(window->GetWindowStyle() == (wxBORDER_SUNKEN | wxLB_MULTIPLE));
}
Expand Down
2 changes: 1 addition & 1 deletion tests/wxUI_RadioBoxTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ TEST_CASE("RadioBox")
SECTION("style")
{
wxFrame frame { nullptr, wxID_ANY, "" };
auto uut = TypeUnderTest { std::vector<wxString> { "Hello", "Goodbye" } }.style(wxRA_SPECIFY_COLS);
auto uut = TypeUnderTest { std::vector<wxString> { "Hello", "Goodbye" } }.withStyle(wxRA_SPECIFY_COLS);
auto* window = dynamic_cast<TypeUnderTest::underlying_t*>(uut.create(&frame));
CHECK(window->GetWindowStyle() == (wxRA_SPECIFY_COLS | wxTAB_TRAVERSAL));
}
Expand Down
2 changes: 1 addition & 1 deletion tests/wxUI_SpinCtrlTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ TEST_CASE("SpinCtrl")
SECTION("style")
{
wxFrame frame { nullptr, wxID_ANY, "" };
auto uut = TypeUnderTest {}.style(wxTE_PROCESS_ENTER);
auto uut = TypeUnderTest {}.withStyle(wxTE_PROCESS_ENTER);
auto* window = dynamic_cast<TypeUnderTest::underlying_t*>(uut.create(&frame));
CHECK(window->GetWindowStyle() == (wxTE_PROCESS_ENTER | wxTAB_TRAVERSAL | 0x200000));
}
Expand Down
2 changes: 1 addition & 1 deletion tests/wxUI_Text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ TEST_CASE("Text")
SECTION("style")
{
wxFrame frame { nullptr, wxID_ANY, "" };
auto uut = TypeUnderTest {}.style(wxST_ELLIPSIZE_MIDDLE);
auto uut = TypeUnderTest {}.withStyle(wxST_ELLIPSIZE_MIDDLE);
auto* window = dynamic_cast<TypeUnderTest::underlying_t*>(uut.create(&frame));
CHECK(window->GetWindowStyle() == wxST_ELLIPSIZE_MIDDLE);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/wxUI_TextCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ TEST_CASE("TextCtrl")
SECTION("style")
{
wxFrame frame { nullptr, wxID_ANY, "" };
auto uut = TypeUnderTest {}.style(wxTE_PROCESS_ENTER);
auto uut = TypeUnderTest {}.withStyle(wxTE_PROCESS_ENTER);
auto* window = dynamic_cast<TypeUnderTest::underlying_t*>(uut.create(&frame));
CHECK(window->GetWindowStyle() == (wxBORDER_SUNKEN | wxTE_PROCESS_ENTER));
}
Expand Down

0 comments on commit 2a17f16

Please sign in to comment.