24#include <wx/settings.h>
27#define SEPARATOR wxT( "---" )
31 const wxSize& aSize,
int n,
const wxString choices[],
long style ) :
32 wxOwnerDrawnComboBox( aParent, aId, aValue, aPos, aSize, n, choices, style ),
45 using namespace std::placeholders;
46 wxOwnerDrawnComboBox::DoSetPopupControl( aPopup );
67 wxPen pen( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ), 1 );
70 aDC.DrawLine( aRect.x, aRect.y + aRect.height / 2, aRect.x + aRect.width,
71 aRect.y + aRect.height / 2 );
77 if( aFlags & wxODCB_PAINTING_CONTROL )
79 x = aRect.x + GetMargins().x;
80 y = ( aRect.height - aDC.GetCharHeight() ) / 2 + aRect.y;
88 aDC.DrawText(
text, x, y );
95 return wxOwnerDrawnComboBox::GetCharHeight() + 2;
104 return wxOwnerDrawnComboBox::OnMeasureItem( aItem );
111 return GetTextRect().GetWidth() - 2;
113 return wxOwnerDrawnComboBox::OnMeasureItemWidth( aItem );
119 int item = GetVListBoxComboPopup()->VirtualHitTest( aEvent.GetPosition().y );
130 if( sel >= 0 && sel < (
int) GetCount() )
149 if( !aMenuText.IsEmpty() )
152 wxOwnerDrawnComboBox::Append( aText );
160 else if( aItem >= 0 && aItem < (
int) GetCount() )
161 return GetVListBoxComboPopup()->GetString( aItem );
163 return wxEmptyString;
170 return GetVListBoxComboPopup()->wxVListBox::GetSelection();
172 return GetSelection();
178 if( aSel >= 0 && aSel < (
int) GetCount() )
181 return GetVListBoxComboPopup()->wxVListBox::SetSelection( aSel );
183 return SetSelection( aSel );
virtual wxCoord OnMeasureItemWidth(size_t aItem) const override
void Append(const wxString &aText, const wxString &aMenuText=wxEmptyString)
WX_COMBOBOX(wxWindow *aParent, int aId=wxID_ANY, const wxString &aValue=wxEmptyString, const wxPoint &aPos=wxDefaultPosition, const wxSize &aSize=wxDefaultSize, int n=0, const wxString choices[]=nullptr, long style=0)
virtual void DoSetPopupControl(wxComboPopup *aPopup) override
void TryVetoSelect(wxCommandEvent &aEvent, bool aInner)
Veto a select event for the separator.
void SetSelectionEither(bool aInner, int aSel)
Safely set selection for either the outer (combo box) or inner (popup) list, doing nothing for invali...
virtual wxCoord OnMeasureItem(size_t aItem) const override
std::map< int, wxString > m_menuText
void TryVetoMouse(wxMouseEvent &aEvent)
Veto a mouseover event if in the separator.
int GetSelectionEither(bool aInner) const
Get selection from either the outer (combo box) or inner (popup) list.
wxString GetMenuText(int aItem) const
Safely get a string for an item, returning wxEmptyString if the item doesn't exist.
virtual void OnDrawItem(wxDC &aDC, const wxRect &aRect, int aItem, int aFlags) const override
int GetCharHeight() const override