2017-02-22 12:34:23 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2021-01-25 12:42:36 +00:00
|
|
|
* Copyright (C) 2017-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2017-02-22 12:34:23 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ROW_INDICATOR__H_
|
|
|
|
#define ROW_INDICATOR__H_
|
|
|
|
|
|
|
|
#include <wx/wx.h>
|
|
|
|
|
|
|
|
/**
|
2020-01-10 14:31:00 +00:00
|
|
|
* representing a row indicator icon for use in
|
2017-02-22 12:34:23 +00:00
|
|
|
* places like the layer widget
|
|
|
|
*/
|
|
|
|
class INDICATOR_ICON: public wxPanel
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An id that refers to a certain icon state.
|
|
|
|
*
|
|
|
|
* Exactly what that state might mean in terms of icons is up
|
|
|
|
* to the icon provider.
|
|
|
|
*/
|
|
|
|
using ICON_ID = int;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A simple object that can provide fixed bitmaps for use as row
|
|
|
|
* indicators
|
|
|
|
*/
|
|
|
|
class ICON_PROVIDER
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
virtual ~ICON_PROVIDER() {};
|
|
|
|
|
|
|
|
/**
|
2021-01-25 12:42:36 +00:00
|
|
|
* Get a reference to the row icon in the given mode.
|
2017-02-22 12:34:23 +00:00
|
|
|
*
|
|
|
|
* @param aIconId the id of the icon to get (depends on the
|
|
|
|
* provider).
|
|
|
|
*/
|
|
|
|
virtual const wxBitmap& GetIndicatorIcon( ICON_ID aIconId ) const = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Accessor for the default icon providers, which take
|
2021-01-25 12:42:36 +00:00
|
|
|
* true and false for IDs, meaning on/off.
|
2017-02-22 12:34:23 +00:00
|
|
|
*
|
|
|
|
* @param aAlternative false for blue arrow/blank, true for the
|
|
|
|
* green diamond
|
|
|
|
*/
|
|
|
|
static ICON_PROVIDER& GetDefaultRowIconProvider( bool aAlternative );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param aParent the owning window
|
|
|
|
* @param aIconProvider the icon provider to get icons from
|
2017-06-16 07:14:28 +00:00
|
|
|
* @param aInitialIcon is the initial state of the icon (the meaning
|
|
|
|
* depends on what is the purpose of the icon)
|
2017-02-22 12:34:23 +00:00
|
|
|
* @param aID the ID to use for the widgets - events will have
|
|
|
|
* this ID.
|
|
|
|
*/
|
2018-02-21 16:29:24 +00:00
|
|
|
INDICATOR_ICON( wxWindow* aParent, ICON_PROVIDER& aIconProvider,
|
2017-02-22 12:34:23 +00:00
|
|
|
ICON_ID aInitialIcon, int aID );
|
|
|
|
|
|
|
|
/**
|
2021-01-25 12:42:36 +00:00
|
|
|
* Set the row indicator to the given state.
|
2017-02-22 12:34:23 +00:00
|
|
|
*
|
|
|
|
* @param aIconId the icon ID to pass to the provider.
|
|
|
|
*/
|
|
|
|
void SetIndicatorState( ICON_ID aIconId );
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the current state of the indicator
|
|
|
|
*/
|
|
|
|
ICON_ID GetIndicatorState() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2021-01-25 12:42:36 +00:00
|
|
|
///< An class that delivers icons for the indicator (currently just
|
|
|
|
///< uses a default implementation).
|
2017-02-22 12:34:23 +00:00
|
|
|
ICON_PROVIDER& m_iconProvider;
|
|
|
|
|
2021-01-25 12:42:36 +00:00
|
|
|
///< Handle on the bitmap widget
|
2017-02-22 12:34:23 +00:00
|
|
|
wxStaticBitmap* m_bitmap;
|
|
|
|
|
2021-01-25 12:42:36 +00:00
|
|
|
///< Is the icon currently "on"
|
2017-02-22 12:34:23 +00:00
|
|
|
ICON_ID m_currentId;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-01-25 12:42:36 +00:00
|
|
|
* Icon provider for the "standard" row indicators, for example in layer selection lists
|
2017-02-22 12:34:23 +00:00
|
|
|
*/
|
|
|
|
class ROW_ICON_PROVIDER: public INDICATOR_ICON::ICON_PROVIDER
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2021-01-25 12:42:36 +00:00
|
|
|
///< State constants to select the right icons
|
2017-02-22 12:34:23 +00:00
|
|
|
enum STATE
|
|
|
|
{
|
2021-01-25 12:42:36 +00:00
|
|
|
OFF, ///< Row "off" or "deselected"
|
|
|
|
DIMMED, ///< Row "dimmed"
|
|
|
|
ON, ///< Row "on" or "selected"
|
|
|
|
UP, ///< Row above design alpha
|
|
|
|
DOWN, ///< Row below design alpha
|
2017-02-22 12:34:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param aAlt false: normal icons (blue arrow/blank), true:
|
|
|
|
* alternative icons (blue arrow/green diamond)
|
|
|
|
*/
|
2018-02-21 16:29:24 +00:00
|
|
|
ROW_ICON_PROVIDER( int aSize );
|
2017-02-22 12:34:23 +00:00
|
|
|
|
2021-01-25 12:42:36 +00:00
|
|
|
///< @copydoc INDICATOR_ICON::ICON_PROVIDER::GetIndicatorIcon()
|
2017-02-22 12:34:23 +00:00
|
|
|
const wxBitmap& GetIndicatorIcon( INDICATOR_ICON::ICON_ID aIconId ) const override;
|
|
|
|
|
|
|
|
private:
|
2018-02-21 16:29:24 +00:00
|
|
|
wxBitmap m_blankBitmap;
|
|
|
|
wxBitmap m_rightArrowBitmap;
|
|
|
|
wxBitmap m_upArrowBitmap;
|
|
|
|
wxBitmap m_downArrowBitmap;
|
|
|
|
wxBitmap m_dotBitmap;
|
2017-02-22 12:34:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // ROW_INDICATOR__H_
|