2nd attempt to fix JIRA SPE-26 (Feature types on MAC)

This commit is contained in:
Enrico Turri 2018-02-20 14:25:40 +01:00
parent a569de44b6
commit 26409cbade
3 changed files with 26 additions and 4 deletions

View file

@ -491,6 +491,8 @@ void create_combochecklist(wxComboCtrl* comboCtrl, std::string text, std::string
popup->SetStringValue(text);
popup->Bind(wxEVT_CHECKLISTBOX, [popup](wxCommandEvent& evt) { popup->OnCheckListBox(evt); });
popup->Bind(wxEVT_LISTBOX, [popup](wxCommandEvent& evt) { popup->OnListBoxSelection(evt); });
popup->Bind(wxEVT_KEY_DOWN, [popup](wxKeyEvent& evt) { popup->OnKeyEvent(evt); });
popup->Bind(wxEVT_KEY_UP, [popup](wxKeyEvent& evt) { popup->OnKeyEvent(evt); });
std::vector<std::string> items_str;
boost::split(items_str, items, boost::is_any_of("|"), boost::token_compress_off);

View file

@ -1,6 +1,7 @@
#include "wxExtensions.hpp"
const unsigned int wxCheckListBoxComboPopup::Height = 210;
const unsigned int wxCheckListBoxComboPopup::DefaultWidth = 200;
const unsigned int wxCheckListBoxComboPopup::DefaultHeight = 200;
bool wxCheckListBoxComboPopup::Create(wxWindow* parent)
{
@ -25,16 +26,32 @@ wxString wxCheckListBoxComboPopup::GetStringValue() const
wxSize wxCheckListBoxComboPopup::GetAdjustedSize(int minWidth, int prefHeight, int maxHeight)
{
// matches owner wxComboCtrl's width
// and sets height dinamically in dependence of contained items count
wxComboCtrl* cmb = GetComboCtrl();
if (cmb != nullptr)
{
wxSize size = GetComboCtrl()->GetSize();
size.SetHeight(Height);
unsigned int count = GetCount();
if (count > 0)
{
wxRect first_rect;
GetItemRect(0, first_rect);
size.SetHeight((1 + count) * first_rect.GetHeight());
}
else
size.SetHeight(DefaultHeight);
return size;
}
else
return wxSize(200, Height);
return wxSize(DefaultWidth, DefaultHeight);
}
void wxCheckListBoxComboPopup::OnKeyEvent(wxKeyEvent& evt)
{
// do nothing, but prevents navigation in the list using arrows keys (which is not working properly)
}
void wxCheckListBoxComboPopup::OnCheckListBox(wxCommandEvent& evt)

View file

@ -6,7 +6,8 @@
class wxCheckListBoxComboPopup : public wxCheckListBox, public wxComboPopup
{
static const unsigned int Height;
static const unsigned int DefaultWidth;
static const unsigned int DefaultHeight;
wxString m_text;
@ -17,6 +18,8 @@ public:
virtual wxString GetStringValue() const;
virtual wxSize GetAdjustedSize(int minWidth, int prefHeight, int maxHeight);
virtual void OnKeyEvent(wxKeyEvent& evt);
void OnCheckListBox(wxCommandEvent& evt);
void OnListBoxSelection(wxCommandEvent& evt);
};