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 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 
79  INDICATOR_ICON( wxWindow* aParent,
80  ICON_PROVIDER& aIconProvider,
81  ICON_ID aInitialIcon, int aID );
82 
88  void SetIndicatorState( ICON_ID aIconId );
89 
90 
94  ICON_ID GetIndicatorState() const;
95 
96 private:
97 
101 
103  wxStaticBitmap* m_bitmap;
104 
107 };
108 
109 
115 {
116 public:
117 
119  enum STATE
120  {
121  OFF,
122  ON,
123  };
124 
129  ROW_ICON_PROVIDER( bool aAlt );
130 
132  const wxBitmap& GetIndicatorIcon( INDICATOR_ICON::ICON_ID aIconId ) const override;
133 
134 private:
135  bool m_alt;
136 };
137 
138 
139 
140 #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.
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.
const wxBitmap & GetIndicatorIcon(INDICATOR_ICON::ICON_ID aIconId) const override
>
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 "off" or "deselected"
ICON_ID m_currentId
Is the icon currently "on"
STATE
State constants to select the right icons
ROW_ICON_PROVIDER(bool aAlt)