It appears to be enough to edit wxVListBoxComboPopup, merging some necessary drawing codes from wxOwnerDrawnComboBox.
Anyway, I've effectively completed my custom popup. It feels good and works well.
Which files I need to modify to customize wxOwnerDrawnComboBox? Topic is solved
Re: Which files I need to modify to customize wxOwnerDrawnComboBox?
Congrats then. What did you end up using as a combo box class then? I was rather annoyed noticing that wxComboCtrl does not support keyboard navigation on its own, all the code necessary is added in the wxOwnerDrawnComboBox.
Re: Which files I need to modify to customize wxOwnerDrawnComboBox?
Here are my combo popup codes:
SharedComboPopup.h
SharedComboPopup.cpp
This is my combo box class stripped down:
I hope this helps anyone looking for a virtual combo box in wx.
SharedComboPopup.h
SharedComboPopup.cpp
This is my combo box class stripped down:
Code: Select all
class AGEComboBox: public wxComboCtrl
{
public:
AGEComboBox(wxWindow *parent, wxArrayString *choices, int width):
wxComboCtrl(parent, wxID_ANY, "", wxDefaultPosition, wxSize(width, -1), wxTE_PROCESS_ENTER)
{
popup = new SharedComboPopup();
SetPopupControl(popup);
popup->Imbue(choices);
Bind(wxEVT_MOUSEWHEEL, [=](wxMouseEvent &event){GetParent()->GetEventHandler()->ProcessEvent(event);});
}
unsigned int GetCount() const {return popup->GetCount();}
void SetSelection(int n)
{
wxString str;
if(GetCount())
{
popup->SetSelection(n);
if(n >= 0)
{
str = popup->GetString(n);
}
}
// Refresh text portion in control
if(m_text)
m_text->ChangeValue(str);
else
m_valueString = str;
Refresh();
}
int GetSelection() const {return popup->GetSelection();}
void Flash() {popup->Flash();}
void SwapList(wxArrayString *choices) {popup->Imbue(choices);}
protected:
SharedComboPopup *popup;
};