KiCad PCB EDA Suite
footprint_choice.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) 2017 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 FOOTPRINT_CHOICE_H
21 #define FOOTPRINT_CHOICE_H
22 
23 #include <wx/odcombo.h>
24 
38 class FOOTPRINT_CHOICE : public wxOwnerDrawnComboBox
39 {
40 public:
41  FOOTPRINT_CHOICE( wxWindow* aParent, int aId );
42 
43  virtual ~FOOTPRINT_CHOICE();
44 
45 protected:
46  virtual void DoSetPopupControl( wxComboPopup* aPopup ) override;
47  virtual void OnDrawItem( wxDC& aDC, wxRect const& 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 
54  static wxCoord DrawTextFragment( wxDC& aDC, wxCoord x, wxCoord y, wxString const& aText );
55 
57  void TryVetoMouse( wxMouseEvent& aEvent );
58 
65  void TryVetoSelect( wxCommandEvent& aEvent, bool aInner );
66 
70  wxString SafeGetString( int aItem ) const;
71 
75  int GetSelectionEither( bool aInner ) const;
76 
81  void SetSelectionEither( bool aInner, int aSel );
82 
83  static wxColour m_grey;
84 
85 private:
87 };
88 
89 #endif // FOOTPRINT_CHOICE_H
virtual wxCoord OnMeasureItem(size_t aItem) const override
wxString SafeGetString(int aItem) const
Safely get a string for an item, returning wxEmptyString if the item doesn't exist.
virtual void DoSetPopupControl(wxComboPopup *aPopup) override
virtual ~FOOTPRINT_CHOICE()
FOOTPRINT_CHOICE(wxWindow *aParent, int aId)
void TryVetoMouse(wxMouseEvent &aEvent)
Veto a mouseover event if in the separator.
virtual wxCoord OnMeasureItemWidth(size_t aItem) const override
Customized combo box for footprint selection.
virtual void OnDrawItem(wxDC &aDC, wxRect const &aRect, int aItem, int aFlags) const override
void TryVetoSelect(wxCommandEvent &aEvent, bool aInner)
Veto a select event for the separator.
int GetSelectionEither(bool aInner) const
Get selection from either the outer (combo box) or inner (popup) list.
static wxCoord DrawTextFragment(wxDC &aDC, wxCoord x, wxCoord y, wxString const &aText)
Draw a fragment of text, then return the next x coordinate to continue drawing.
void SetSelectionEither(bool aInner, int aSel)
Safely set selection for either the outer (combo box) or inner (popup) list, doing nothing for invali...
static wxColour m_grey