mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
Refactoring:
1. Use C++ style cast instead of C style 2. Deleted unused code from Search
This commit is contained in:
parent
d9be78d4cb
commit
7f22ce63f6
18 changed files with 110 additions and 256 deletions
|
@ -335,81 +335,6 @@ void OptionsSearcher::add_key(const std::string& opt_key, const wxString& group,
|
|||
}
|
||||
|
||||
|
||||
//------------------------------------------
|
||||
// SearchComboPopup
|
||||
//------------------------------------------
|
||||
|
||||
|
||||
void SearchComboPopup::Init()
|
||||
{
|
||||
this->Bind(wxEVT_MOTION, &SearchComboPopup::OnMouseMove, this);
|
||||
this->Bind(wxEVT_LEFT_UP, &SearchComboPopup::OnMouseClick, this);
|
||||
this->Bind(wxEVT_KEY_DOWN, &SearchComboPopup::OnKeyDown, this);
|
||||
}
|
||||
|
||||
bool SearchComboPopup::Create(wxWindow* parent)
|
||||
{
|
||||
return wxListBox::Create(parent, 1, wxPoint(0, 0), wxDefaultSize);
|
||||
}
|
||||
|
||||
void SearchComboPopup::SetStringValue(const wxString& s)
|
||||
{
|
||||
int n = wxListBox::FindString(s);
|
||||
if (n >= 0 && n < int(wxListBox::GetCount()))
|
||||
wxListBox::Select(n);
|
||||
|
||||
// save a combo control's string
|
||||
m_input_string = s;
|
||||
}
|
||||
|
||||
void SearchComboPopup::ProcessSelection(int selection)
|
||||
{
|
||||
wxCommandEvent event(wxEVT_LISTBOX, GetId());
|
||||
event.SetInt(selection);
|
||||
event.SetEventObject(this);
|
||||
ProcessEvent(event);
|
||||
|
||||
Dismiss();
|
||||
}
|
||||
|
||||
void SearchComboPopup::OnMouseMove(wxMouseEvent& event)
|
||||
{
|
||||
wxPoint pt = wxGetMousePosition() - this->GetScreenPosition();
|
||||
int selection = this->HitTest(pt);
|
||||
wxListBox::Select(selection);
|
||||
}
|
||||
|
||||
void SearchComboPopup::OnMouseClick(wxMouseEvent&)
|
||||
{
|
||||
int selection = wxListBox::GetSelection();
|
||||
SetSelection(wxNOT_FOUND);
|
||||
ProcessSelection(selection);
|
||||
}
|
||||
|
||||
void SearchComboPopup::OnKeyDown(wxKeyEvent& event)
|
||||
{
|
||||
int key = event.GetKeyCode();
|
||||
|
||||
// change selected item in the list
|
||||
if (key == WXK_UP || key == WXK_DOWN)
|
||||
{
|
||||
int selection = wxListBox::GetSelection();
|
||||
|
||||
if (key == WXK_UP && selection > 0)
|
||||
selection--;
|
||||
if (key == WXK_DOWN && selection < int(wxListBox::GetCount() - 1))
|
||||
selection++;
|
||||
|
||||
wxListBox::Select(selection);
|
||||
}
|
||||
// send wxEVT_LISTBOX event if "Enter" was pushed
|
||||
else if (key == WXK_NUMPAD_ENTER || key == WXK_RETURN)
|
||||
ProcessSelection(wxListBox::GetSelection());
|
||||
else
|
||||
event.Skip(); // !Needed to have EVT_CHAR generated as well
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------
|
||||
// SearchDialog
|
||||
//------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue