Skip to content

Commit

Permalink
Merge pull request #130 from rmpowell77/dev/withoutStyle
Browse files Browse the repository at this point in the history
Issue #127: There should be withStyle and withoutStyle which sets and…
  • Loading branch information
rmpowell77 authored Jul 4, 2023
2 parents 5632379 + ed8aca8 commit e87e291
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
1 change: 1 addition & 0 deletions LATEST_RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ Bugs addressed in this release:
Other changes:

* [#123](../../issues/123) Allow binding to multiple events
* [#127](../../issues/127) There should be withStyle and withoutStyle which sets and clears the bitmaps

3 changes: 2 additions & 1 deletion docs/ProgrammersGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ The list of Methods supported by all controllers:

* `withPosition(wxPoint pos)` : Specifies the `pos` of the `wxControl`.
* `withSize(wxSize size)` : Specifies the `size` of the `wxControl`.
* `withStyle(long style)` : Specifies the `style` of the `wxControl`.
* `withStyle(long style)` : Adds the style flags for the `style` of the `wxControl`.
* `withoutStyle(long style)` : Removes the style flags for the `style` of the `wxControl`.

#### Bind

Expand Down
3 changes: 2 additions & 1 deletion docs/src/docs/ProgrammersGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ The list of Methods supported by all controllers:

* `withPosition(wxPoint pos)` : Specifies the `pos` of the `wxControl`.
* `withSize(wxSize size)` : Specifies the `size` of the `wxControl`.
* `withStyle(long style)` : Specifies the `style` of the `wxControl`.
* `withStyle(long style)` : Adds the style flags for the `style` of the `wxControl`.
* `withoutStyle(long style)` : Removes the style flags for the `style` of the `wxControl`.

#### Bind

Expand Down
8 changes: 7 additions & 1 deletion include/wxUI/Widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,13 @@ struct WidgetDetails {

auto withStyle(int64_t style_) -> ConcreteWidget&
{
style = style_;
style |= style_;
return static_cast<ConcreteWidget&>(*this);
}

auto withoutStyle(int64_t style_) -> ConcreteWidget&
{
style &= ~style_;
return static_cast<ConcreteWidget&>(*this);
}

Expand Down
12 changes: 10 additions & 2 deletions tests/wxUI_HyperlinkTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,17 @@ TEST_CASE("Hyperlink")
SECTION("style")
{
wxFrame frame { nullptr, wxID_ANY, "" };
auto uut = createUUT().withStyle(wxHL_ALIGN_LEFT | wxHL_CONTEXTMENU);
auto uut = createUUT();
auto* window = dynamic_cast<TypeUnderTest::underlying_t*>(uut.create(&frame));
CHECK((window->GetWindowStyle() & wxHL_DEFAULT_STYLE) == wxHL_DEFAULT_STYLE);
}

SECTION("withStyle")
{
wxFrame frame { nullptr, wxID_ANY, "" };
auto uut = createUUT().withoutStyle(wxHL_ALIGN_CENTRE).withStyle(wxHL_ALIGN_LEFT);
auto* window = dynamic_cast<TypeUnderTest::underlying_t*>(uut.create(&frame));
CHECK(window->GetWindowStyle() == (wxHL_ALIGN_LEFT | wxHL_CONTEXTMENU));
CHECK(window->GetWindowStyle() == (wxHL_CONTEXTMENU | wxNO_BORDER | wxHL_ALIGN_LEFT));
}

SECTION("pos")
Expand Down

0 comments on commit e87e291

Please sign in to comment.