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 
30 wxDECLARE_EVENT( EVT_INTERACTIVE_CHOICE, wxCommandEvent );
31 
32 
46 class FOOTPRINT_CHOICE : public wxOwnerDrawnComboBox
47 {
48 public:
49  FOOTPRINT_CHOICE( wxWindow* aParent, int aId );
50 
51  virtual ~FOOTPRINT_CHOICE();
52 
53 protected:
54  virtual void DoSetPopupControl( wxComboPopup* aPopup ) override;
55  virtual void OnDrawItem( wxDC& aDC, wxRect const& aRect, int aItem, int aFlags ) const override;
56  virtual wxCoord OnMeasureItem( size_t aItem ) const override;
57  virtual wxCoord OnMeasureItemWidth( size_t aItem ) const override;
58 
62  static wxCoord DrawTextFragment( wxDC& aDC, wxCoord x, wxCoord y, wxString const& aText );
63 
65  void TryVetoMouse( wxMouseEvent& aEvent );
66 
73  void TryVetoSelect( wxCommandEvent& aEvent, bool aInner );
74 
78  void OnMouseUp( wxMouseEvent& aEvent );
79 
83  void OnKeyUp( wxKeyEvent& aEvent );
84 
91  void TrySkipSeparator( wxKeyEvent& aEvent, bool aInner );
92 
96  wxString SafeGetString( int aItem ) const;
97 
101  int GetSelectionEither( bool aInner ) const;
102 
107  void SetSelectionEither( bool aInner, int aSel );
108 
109  static wxColour m_grey;
110 
111 private:
113 };
114 
115 #endif // FOOTPRINT_CHOICE_H
virtual wxCoord OnMeasureItem(size_t aItem) const override
void TrySkipSeparator(wxKeyEvent &aEvent, bool aInner)
For arrow key events, skip over separators.
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.
void OnMouseUp(wxMouseEvent &aEvent)
Mouse up on an item in the list.
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 OnKeyUp(wxKeyEvent &aEvent)
Key up on an item in the list.
wxDECLARE_EVENT(EVT_INTERACTIVE_CHOICE, wxCommandEvent)
Event thrown when an item is selected "interactively".
void SetSelectionEither(bool aInner, int aSel)
Safely set selection for either the outer (combo box) or inner (popup) list, doing nothing for invali...
wxString SafeGetString(int aItem) const
Safely get a string for an item, returning wxEmptyString if the item doesn't exist.
static wxColour m_grey