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-2021 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/bitmap.h>
28 #include <wx/panel.h>
29 
30 class wxStaticBitmap;
31 
36 class INDICATOR_ICON : public wxPanel
37 {
38 public:
39 
46  using ICON_ID = int;
47 
53  {
54  public:
55 
56  virtual ~ICON_PROVIDER() {};
57 
64  virtual const wxBitmap& GetIndicatorIcon( ICON_ID aIconId ) const = 0;
65  };
66 
74  static ICON_PROVIDER& GetDefaultRowIconProvider( bool aAlternative );
75 
84  INDICATOR_ICON( wxWindow* aParent, ICON_PROVIDER& aIconProvider,
85  ICON_ID aInitialIcon, int aID );
86 
92  void SetIndicatorState( ICON_ID aIconId );
93 
94 
98  ICON_ID GetIndicatorState() const;
99 
100 private:
101 
105 
107  wxStaticBitmap* m_bitmap;
108 
111 };
112 
113 
118 {
119 public:
120 
122  enum STATE
123  {
124  OFF,
126  ON,
127  UP,
129  };
130 
135  ROW_ICON_PROVIDER( int aSize );
136 
138  const wxBitmap& GetIndicatorIcon( INDICATOR_ICON::ICON_ID aIconId ) const override;
139 
140 private:
141  wxBitmap m_blankBitmap;
143  wxBitmap m_upArrowBitmap;
145  wxBitmap m_dotBitmap;
146 };
147 
148 
149 #endif // ROW_INDICATOR__H_
void SetIndicatorState(ICON_ID aIconId)
Set the row indicator to the given state.
virtual const wxBitmap & GetIndicatorIcon(ICON_ID aIconId) const =0
Get 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
Is the icon currently "on".
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_PROVIDER & m_iconProvider
< An class that delivers icons for the indicator (currently just uses a default implementation).
representing a row indicator icon for use in places like the layer widget
const wxBitmap & GetIndicatorIcon(INDICATOR_ICON::ICON_ID aIconId) const override
Get a reference to the row icon in the given mode.
static ICON_PROVIDER & GetDefaultRowIconProvider(bool aAlternative)
Accessor for the default icon providers, which take true and false for IDs, meaning on/off.
A simple object that can provide fixed bitmaps for use as row indicators.
Row below design alpha.
Row "on" or "selected".
ROW_ICON_PROVIDER(int aSize)
Get a reference to the row icon in the given mode.
ICON_ID GetIndicatorState() const
wxBitmap m_rightArrowBitmap
STATE
< State constants to select the right icons
Row "off" or "deselected".
Row above design alpha.