KiCad PCB EDA Suite
indicator_icon.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-2018 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 #ifndef ROW_INDICATOR__H_
25 #define ROW_INDICATOR__H_
26 
27 #include <wx/wx.h>
28 
33 class INDICATOR_ICON: public wxPanel
34 {
35 public:
36 
43  using ICON_ID = int;
44 
50  {
51  public:
52 
53  virtual ~ICON_PROVIDER() {};
54 
61  virtual const wxBitmap& GetIndicatorIcon( ICON_ID aIconId ) const = 0;
62  };
63 
71  static ICON_PROVIDER& GetDefaultRowIconProvider( bool aAlternative );
72 
81  INDICATOR_ICON( wxWindow* aParent, ICON_PROVIDER& aIconProvider,
82  ICON_ID aInitialIcon, int aID );
83 
89  void SetIndicatorState( ICON_ID aIconId );
90 
91 
95  ICON_ID GetIndicatorState() const;
96 
97 private:
98 
102 
104  wxStaticBitmap* m_bitmap;
105 
108 };
109 
110 
116 {
117 public:
118 
120  enum STATE
121  {
122  OFF,
124  ON,
125  UP,
127  };
128 
133  ROW_ICON_PROVIDER( int aSize );
134 
136  const wxBitmap& GetIndicatorIcon( INDICATOR_ICON::ICON_ID aIconId ) const override;
137 
138 private:
139  wxBitmap m_blankBitmap;
141  wxBitmap m_upArrowBitmap;
143  wxBitmap m_dotBitmap;
144 };
145 
146 
147 
148 #endif // ROW_INDICATOR__H_
void SetIndicatorState(ICON_ID aIconId)
Sets the row indiciator to the given state.
virtual const wxBitmap & GetIndicatorIcon(ICON_ID aIconId) const =0
Gets a reference to the row icon in the given mode.
Icon provider for the "standard" row indicators, for example in layer selection lists.
wxStaticBitmap * m_bitmap
Handle on the bitmap widget
int ICON_ID
An id that refers to a certain icon state.
wxBitmap m_upArrowBitmap
wxBitmap m_downArrowBitmap
INDICATOR_ICON(wxWindow *aParent, ICON_PROVIDER &aIconProvider, ICON_ID aInitialIcon, int aID)
ICON_ID GetIndicatorState() const
ICON_PROVIDER & m_iconProvider
An class that delivers icons for the indictor (currently just uses a default implementation).
Class representing a row indicator icon for use in places like the layer widget.
Row "off" or "deselected"
static ICON_PROVIDER & GetDefaultRowIconProvider(bool aAlternative)
Accessor for the default icon providers, which take true and false for IDs, meaining on/off...
A simple object that can provide fixed bitmaps for use as row indicators.
Row above design alpha
ICON_ID m_currentId
Is the icon currently "on"
wxBitmap m_rightArrowBitmap
STATE
State constants to select the right icons
Row "on" or "selected"