| 1 |
/* Copyright (C) 2012 The gtkmm Development Team |
| 2 |
* |
| 3 |
* This library is free software; you can redistribute it and/or |
| 4 |
* modify it under the terms of the GNU Lesser General Public |
| 5 |
* License as published by the Free Software Foundation; either |
| 6 |
* version 2.1 of the License, or (at your option) any later version. |
| 7 |
* |
| 8 |
* This library is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 |
* Lesser General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU Lesser General Public |
| 14 |
* License along with this library; if not, see <https://www.gnu.org/licenses/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
#include <gtkmm/widget.h> |
| 18 |
_DEFS(gtkmm,gtk) |
| 19 |
_PINCLUDE(gtkmm/private/widget_p.h) |
| 20 |
|
| 21 |
namespace Gtk |
| 22 |
{ |
| 23 |
|
| 24 |
_WRAP_ENUM(LevelBarMode, GtkLevelBarMode, decl_prefix GTKMM_API) |
| 25 |
|
| 26 |
//TODO: Derive/Implement from Gtk::Orientable (and remove our mention of that |
| 27 |
//in the class documentation when we can break ABI. |
| 28 |
|
| 29 |
/** A bar that can used as a level indicator |
| 30 |
* |
| 31 |
* Typical use cases are displaying the strength |
| 32 |
* of a password, or showing the charge level of a battery. |
| 33 |
* |
| 34 |
* Use set_value() to set the current value, and |
| 35 |
* add_offset_value() to set the value offsets at which |
| 36 |
* the bar will be considered in a different state. There will be two offsets |
| 37 |
* by default on the level bar: Gtk::LEVEL_BAR_OFFSET_LOW and |
| 38 |
* Gtk::LEVEL_BAR_OFFSET_HIGH, with values 0.25 and 0.75 respectively. |
| 39 |
* |
| 40 |
* The default interval of values is between zero and one, but it's possible to |
| 41 |
* modify the interval using set_min_value() and |
| 42 |
* set_max_value(). The value will be always drawn in proportion to |
| 43 |
* the admissible interval, i.e. a value of 15 with a specified interval between |
| 44 |
* 10 and 20 is equivalent to a value of 0.5 with an interval between 0 and 1. |
| 45 |
* When Gtk::LEVEL_BAR_MODE_DISCRETE is used, the bar level is rendered |
| 46 |
* as a finite and number of separated blocks instead of a single one. The number |
| 47 |
* of blocks that will be rendered is equal to the number of units specified by |
| 48 |
* the admissible interval. |
| 49 |
* For instance, to build a bar rendered with five blocks, it's sufficient to |
| 50 |
* set the minimum value to 0 and the maximum value to 5 after changing the indicator |
| 51 |
* mode to discrete. |
| 52 |
* |
| 53 |
* @ingroup Widgets |
| 54 |
* @newin{3,6} |
| 55 |
*/ |
| 56 |
class GTKMM_API LevelBar : public Widget |
| 57 |
{ |
| 58 |
_CLASS_GTKOBJECT(LevelBar, GtkLevelBar, GTK_LEVEL_BAR, Gtk::Widget, GtkWidget, , , GTKMM_API) |
| 59 |
public: |
| 60 |
|
| 61 |
_CTOR_DEFAULT() |
| 62 |
_IGNORE(gtk_level_bar_new) |
| 63 |
|
| 64 |
//TODO: Remove this when we can break ABI to derive from Orientable. |
| 65 |
/** Sets the orientation of the widget. |
| 66 |
* |
| 67 |
* @newin{3,18} |
| 68 |
* |
| 69 |
* @param orientation The widget’s new orientation. |
| 70 |
*/ |
| 71 |
void set_orientation(Orientation orientation); |
| 72 |
|
| 73 |
_WRAP_METHOD(void set_mode(LevelBarMode mode), gtk_level_bar_set_mode) |
| 74 |
_WRAP_METHOD(LevelBarMode get_mode() const, gtk_level_bar_get_mode) |
| 75 |
|
| 76 |
_WRAP_METHOD(void set_value(double value), gtk_level_bar_set_value) |
| 77 |
_WRAP_METHOD(double get_value() const, gtk_level_bar_get_value) |
| 78 |
|
| 79 |
_WRAP_METHOD(void set_min_value(double value), gtk_level_bar_set_min_value) |
| 80 |
_WRAP_METHOD(double get_min_value() const, gtk_level_bar_get_min_value) |
| 81 |
|
| 82 |
_WRAP_METHOD(void set_max_value(double value), gtk_level_bar_set_max_value) |
| 83 |
_WRAP_METHOD(double get_max_value() const, gtk_level_bar_get_max_value) |
| 84 |
|
| 85 |
_WRAP_METHOD(void set_inverted(bool inverted = true), gtk_level_bar_set_inverted) |
| 86 |
_WRAP_METHOD(bool get_inverted() const, gtk_level_bar_get_inverted) |
| 87 |
|
| 88 |
|
| 89 |
_WRAP_METHOD(void add_offset_value(const Glib::ustring& name, double value), gtk_level_bar_add_offset_value) |
| 90 |
_WRAP_METHOD(void remove_offset_value(const Glib::ustring& name), gtk_level_bar_remove_offset_value) |
| 91 |
_WRAP_METHOD(bool get_offset_value(const Glib::ustring& name, double& value) const, gtk_level_bar_get_offset_value) |
| 92 |
|
| 93 |
_WRAP_SIGNAL(void offset_changed(const Glib::ustring& name), offset_changed, |
| 94 |
detail_name offset_name, two_signal_methods) |
| 95 |
|
| 96 |
_WRAP_PROPERTY("value", double) |
| 97 |
_WRAP_PROPERTY("min-value", double) |
| 98 |
_WRAP_PROPERTY("max-value", double) |
| 99 |
_WRAP_PROPERTY("mode", LevelBarMode) |
| 100 |
_WRAP_PROPERTY("inverted", bool) |
| 101 |
}; |
| 102 |
|
| 103 |
} // namespace Gtk |