lumiera_/src/gui/widget/mini-button.hpp

86 lines
2.4 KiB
C++
Raw Normal View History

2009-03-14 13:17:21 +01:00
/*
MINI-BUTTON.hpp - a tool button-like widget
2010-12-17 23:28:49 +01:00
2009-03-14 13:17:21 +01:00
Copyright (C) Lumiera.org
2009, Joel Holdsworth <joel@airwebreathe.org.uk>
2010-12-17 23:28:49 +01:00
2009-03-14 13:17:21 +01:00
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
2010-12-17 23:28:49 +01:00
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
2009-03-14 13:17:21 +01:00
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.
2010-12-17 23:28:49 +01:00
2009-03-14 13:17:21 +01:00
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
2010-12-17 23:28:49 +01:00
2009-03-14 13:17:21 +01:00
*/
#ifndef GUI_WIDGET_MINI_BUTTON_H
#define GUI_WIDGET_MINI_BUTTON_H
2009-03-14 13:17:21 +01:00
#include "gui/gtk-base.hpp"
2009-03-14 13:17:21 +01:00
namespace gui {
namespace widget {
2009-03-14 13:17:21 +01:00
/**
* A wrapper for ToolButton-like Button widgets
*/
template<class T>
class MiniWrapper
: public T
{
/** image widget for the button. */
Gtk::Image image_;
public:
/**
* Creates a new Button containing the image and text from a stock item.
* @param stock_id The stock_id of the image.
* @param icon_size The size of the image to show.
* @remarks Stock IDs have identifiers like \c Gtk::Stock::OK and \c Gtk::Stock::APPLY.
*/
MiniWrapper (Gtk::StockID const& stock_id
,const Gtk::IconSize icon_size = Gtk::ICON_SIZE_LARGE_TOOLBAR)
: image_(stock_id, icon_size)
{
T::add (image_);
T::set_relief (Gtk::RELIEF_NONE);
T::set_focus_on_click (false);
}
/**
* Sets a new image from a stock-id for this button.
* @param stock_id The stock_id of the image.
* @param icon_size The size of the image to show.
*/
void
setStockID (Gtk::StockID const& stock_id
,const Gtk::IconSize icon_size = Gtk::ICON_SIZE_LARGE_TOOLBAR)
{
image_.set (stock_id, icon_size);
}
};
2009-03-14 15:25:39 +01:00
2009-03-14 13:17:21 +01:00
/** A ToolButton-like widget */
using MiniButton = MiniWrapper<Gtk::Button>;
/** A ToggleToolButton-like widget */
using MiniToggleButton = MiniWrapper<Gtk::ToggleButton>;
}}// gui::widget
#endif /*GUI_WIDGET_MINI_BUTTON_H*/