KiCad PCB EDA Suite
Loading...
Searching...
No Matches
wx_combobox.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef WX_COMBOBOX_H
21#define WX_COMBOBOX_H
22
23#include <map>
24#include <wx/odcombo.h>
25
32class WX_COMBOBOX : public wxOwnerDrawnComboBox
33{
34public:
35 WX_COMBOBOX( wxWindow* aParent, int aId = wxID_ANY, const wxString& aValue = wxEmptyString,
36 const wxPoint& aPos = wxDefaultPosition, const wxSize& aSize = wxDefaultSize,
37 int n = 0, const wxString choices[] = nullptr, long style = 0 );
38
39 virtual ~WX_COMBOBOX();
40
41 void Append( const wxString& aText, const wxString& aMenuText = wxEmptyString );
42
43 int GetCharHeight() const override;
44
45protected:
46 virtual void DoSetPopupControl( wxComboPopup* aPopup ) override;
47 virtual void OnDrawItem( wxDC& aDC, const wxRect& aRect, int aItem, int aFlags ) const override;
48 virtual wxCoord OnMeasureItem( size_t aItem ) const override;
49 virtual wxCoord OnMeasureItemWidth( size_t aItem ) const override;
50
52 void TryVetoMouse( wxMouseEvent& aEvent );
53
60 void TryVetoSelect( wxCommandEvent& aEvent, bool aInner );
61
65 wxString GetMenuText( int aItem ) const;
66
70 int GetSelectionEither( bool aInner ) const;
71
76 void SetSelectionEither( bool aInner, int aSel );
77
78private:
79 std::map<int, wxString> m_menuText;
81};
82
83#endif // WX_COMBOBOX_H
Fix some issues with wxCombobox:
Definition: wx_combobox.h:33
virtual wxCoord OnMeasureItemWidth(size_t aItem) const override
void Append(const wxString &aText, const wxString &aMenuText=wxEmptyString)
virtual void DoSetPopupControl(wxComboPopup *aPopup) override
Definition: wx_combobox.cpp:43
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...
int m_lastSelection
Definition: wx_combobox.h:80
virtual ~WX_COMBOBOX()
Definition: wx_combobox.cpp:38
virtual wxCoord OnMeasureItem(size_t aItem) const override
Definition: wx_combobox.cpp:99
std::map< int, wxString > m_menuText
Definition: wx_combobox.h:79
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
Definition: wx_combobox.cpp:61
int GetCharHeight() const override
Definition: wx_combobox.cpp:93