Which files I need to modify to customize wxOwnerDrawnComboBox? Topic is solved

Are you writing your own components and need help with how to set them up or have questions about the components you are deriving from ? Ask them here.
Tapsa
Earned some good credits
Earned some good credits
Posts: 147
Joined: Tue Dec 06, 2011 5:52 pm
Location: Helsinki

Re: Which files I need to modify to customize wxOwnerDrawnComboBox?

Post by Tapsa »

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.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: Which files I need to modify to customize wxOwnerDrawnComboBox?

Post by PB »

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.
Tapsa
Earned some good credits
Earned some good credits
Posts: 147
Joined: Tue Dec 06, 2011 5:52 pm
Location: Helsinki

Re: Which files I need to modify to customize wxOwnerDrawnComboBox?

Post by Tapsa »

Here are my combo popup codes:
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;
};
I hope this helps anyone looking for a virtual combo box in wx.
Post Reply