Skip to content

Commit

Permalink
Merge pull request #113 from rmpowell77/issue/85-ensureVisible
Browse files Browse the repository at this point in the history
Issue #85: Need a EnsureVisible for ListBox
  • Loading branch information
rmpowell77 authored Jun 6, 2023
2 parents 469aad8 + 3697e77 commit aa790b1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions LATEST_RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Other changes:
* [#76](../../issues/76) add wxBitmapComboBox
* [#79](../../issues/79) CheckBox has some unneeded member variables (that should be private)
* [#82](../../issues/82) wxCheckBox needs a setValue
* [#85](../../issues/85) Need a EnsureVisible for ListBox
* [#89](../../issues/89) Change stack to sizer
* [#92](../../issues/92) Need a Bitmap
* [#95](../../issues/95) Text needs to customize font
Expand Down
10 changes: 10 additions & 0 deletions include/wxUI/ListBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,19 @@ struct ListBox : public details::WidgetDetails<ListBox, wxListBox> {
return *this;
}

auto withEnsureVisible(int which) -> ListBox&
{
ensureVisible = which;
return *this;
}

auto create(wxWindow* parent) -> wxWindow* override
{
auto* widget = setProxy(new underlying_t(parent, getIdentity(), getPos(), getSize(), static_cast<int>(choices.size()), choices.data(), getStyle()));
widget->SetSelection(selection);
if (ensureVisible) {
widget->EnsureVisible(*ensureVisible);
}
return widget;
}

Expand Down Expand Up @@ -93,6 +102,7 @@ struct ListBox : public details::WidgetDetails<ListBox, wxListBox> {
private:
std::vector<wxString> choices {};
int selection = wxNOT_FOUND;
std::optional<int> ensureVisible {};
};

static_assert(details::Widget<ListBox>);
Expand Down

0 comments on commit aa790b1

Please sign in to comment.