Which files I need to modify to customize wxOwnerDrawnComboBox?  [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: 144
Joined: Tue Dec 06, 2011 5:52 pm
Location: Helsinki

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

Postby Tapsa » Fri Oct 07, 2016 8:42 pm

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: 1678
Joined: Sun Jan 03, 2010 5:45 pm

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

Postby PB » Fri Oct 07, 2016 9:40 pm

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: 144
Joined: Tue Dec 06, 2011 5:52 pm
Location: Helsinki

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

Postby Tapsa » Sat Oct 08, 2016 6:57 am

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.


Return to “Component Writing”

Who is online

Users browsing this forum: No registered users and 1 guest