mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-15 10:47:50 -06:00
Modified wxCheckListBoxComboPopup::GetAdjustedSize() and create_combochecklist() to size the combo control taking in account the items width
This commit is contained in:
parent
d8091b7ad7
commit
85676af171
2 changed files with 17 additions and 3 deletions
|
@ -271,9 +271,12 @@ void create_combochecklist(wxComboCtrl* comboCtrl, const std::string& text, cons
|
||||||
// On the other side, with this line the combo box popup cannot be closed by clicking on the combo button on Windows 10.
|
// On the other side, with this line the combo box popup cannot be closed by clicking on the combo button on Windows 10.
|
||||||
comboCtrl->UseAltPopupWindow();
|
comboCtrl->UseAltPopupWindow();
|
||||||
|
|
||||||
|
int max_width = 0;
|
||||||
|
|
||||||
comboCtrl->EnablePopupAnimation(false);
|
comboCtrl->EnablePopupAnimation(false);
|
||||||
comboCtrl->SetPopupControl(popup);
|
comboCtrl->SetPopupControl(popup);
|
||||||
wxString title = from_u8(text);
|
wxString title = from_u8(text);
|
||||||
|
max_width = std::max(max_width, 60 + comboCtrl->GetTextExtent(title).x);
|
||||||
popup->SetStringValue(title);
|
popup->SetStringValue(title);
|
||||||
popup->Bind(wxEVT_CHECKLISTBOX, [popup](wxCommandEvent& evt) { popup->OnCheckListBox(evt); });
|
popup->Bind(wxEVT_CHECKLISTBOX, [popup](wxCommandEvent& evt) { popup->OnCheckListBox(evt); });
|
||||||
popup->Bind(wxEVT_LISTBOX, [popup](wxCommandEvent& evt) { popup->OnListBoxSelection(evt); });
|
popup->Bind(wxEVT_LISTBOX, [popup](wxCommandEvent& evt) { popup->OnListBoxSelection(evt); });
|
||||||
|
@ -289,9 +292,12 @@ void create_combochecklist(wxComboCtrl* comboCtrl, const std::string& text, cons
|
||||||
for (size_t i = 0; i < items_str.size(); i += 2)
|
for (size_t i = 0; i < items_str.size(); i += 2)
|
||||||
{
|
{
|
||||||
wxString label = from_u8(items_str[i]);
|
wxString label = from_u8(items_str[i]);
|
||||||
|
max_width = std::max(max_width, 60 + popup->GetTextExtent(label).x);
|
||||||
popup->Append(label);
|
popup->Append(label);
|
||||||
popup->Check(i / 2, items_str[i + 1] == "1");
|
popup->Check(i / 2, items_str[i + 1] == "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
comboCtrl->SetMinClientSize(wxSize(max_width, -1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -197,8 +197,8 @@ wxString wxCheckListBoxComboPopup::GetStringValue() const
|
||||||
|
|
||||||
wxSize wxCheckListBoxComboPopup::GetAdjustedSize(int minWidth, int prefHeight, int maxHeight)
|
wxSize wxCheckListBoxComboPopup::GetAdjustedSize(int minWidth, int prefHeight, int maxHeight)
|
||||||
{
|
{
|
||||||
// matches owner wxComboCtrl's width
|
// set width dinamically in dependence of items text
|
||||||
// and sets height dinamically in dependence of contained items count
|
// and set height dinamically in dependence of items count
|
||||||
|
|
||||||
wxComboCtrl* cmb = GetComboCtrl();
|
wxComboCtrl* cmb = GetComboCtrl();
|
||||||
if (cmb != nullptr)
|
if (cmb != nullptr)
|
||||||
|
@ -207,7 +207,15 @@ wxSize wxCheckListBoxComboPopup::GetAdjustedSize(int minWidth, int prefHeight, i
|
||||||
|
|
||||||
unsigned int count = GetCount();
|
unsigned int count = GetCount();
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
size.SetHeight(count * DefaultItemHeight);
|
{
|
||||||
|
int max_width = size.x;
|
||||||
|
for (unsigned int i = 0; i < count; ++i)
|
||||||
|
{
|
||||||
|
max_width = std::max(max_width, 60 + GetTextExtent(GetString(i)).x);
|
||||||
|
}
|
||||||
|
size.SetWidth(max_width);
|
||||||
|
size.SetHeight(count * GetTextExtent(GetString(0)).y);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
size.SetHeight(DefaultHeight);
|
size.SetHeight(DefaultHeight);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue