mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 09:17:52 -06:00
84 lines
2.2 KiB
C++
84 lines
2.2 KiB
C++
#include "wxExtensions.hpp"
|
|
|
|
const unsigned int wxCheckListBoxComboPopup::DefaultWidth = 200;
|
|
const unsigned int wxCheckListBoxComboPopup::DefaultHeight = 200;
|
|
const unsigned int wxCheckListBoxComboPopup::DefaultItemHeight = 18;
|
|
|
|
bool wxCheckListBoxComboPopup::Create(wxWindow* parent)
|
|
{
|
|
return wxCheckListBox::Create(parent, wxID_HIGHEST + 1, wxPoint(0, 0));
|
|
}
|
|
|
|
wxWindow* wxCheckListBoxComboPopup::GetControl()
|
|
{
|
|
return this;
|
|
}
|
|
|
|
void wxCheckListBoxComboPopup::SetStringValue(const wxString& value)
|
|
{
|
|
m_text = value;
|
|
}
|
|
|
|
wxString wxCheckListBoxComboPopup::GetStringValue() const
|
|
{
|
|
return m_text;
|
|
}
|
|
|
|
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();
|
|
|
|
unsigned int count = GetCount();
|
|
if (count > 0)
|
|
size.SetHeight(count * DefaultItemHeight);
|
|
else
|
|
size.SetHeight(DefaultHeight);
|
|
|
|
return size;
|
|
}
|
|
else
|
|
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)
|
|
{
|
|
// forwards the checklistbox event to the owner wxComboCtrl
|
|
|
|
wxComboCtrl* cmb = GetComboCtrl();
|
|
if (cmb != nullptr)
|
|
{
|
|
wxCommandEvent event(wxEVT_CHECKLISTBOX, cmb->GetId());
|
|
event.SetEventObject(cmb);
|
|
cmb->ProcessWindowEvent(event);
|
|
}
|
|
|
|
evt.Skip();
|
|
}
|
|
|
|
void wxCheckListBoxComboPopup::OnListBoxSelection(wxCommandEvent& evt)
|
|
{
|
|
// transforms list box item selection event into checklistbox item toggle event
|
|
|
|
int selId = GetSelection();
|
|
if (selId != wxNOT_FOUND)
|
|
{
|
|
Check((unsigned int)selId, !IsChecked((unsigned int)selId));
|
|
SetSelection(wxNOT_FOUND);
|
|
|
|
wxCommandEvent event(wxEVT_CHECKLISTBOX, GetId());
|
|
event.SetInt(selId);
|
|
event.SetEventObject(this);
|
|
ProcessEvent(event);
|
|
}
|
|
}
|