Debian Codegraph @

gtk/src/scale.hg

raw
1 /* Copyright (C) 1998-2002 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/range.h>
18 _DEFS(gtkmm,gtk)
19
20 _PINCLUDE(gtkmm/private/range_p.h)
21
22 namespace Gtk
23 {
24
25 /** A slider widget for selecting a value from a range.
26 *
27 * A Gtk::Scale is a slider control used to select a numeric value. To use it,
28 * you'll probably want to investigate the methods on its base class,
29 * Gtk::Range, in addition to the methods for Gtk::Scale itself. To set the
30 * value of a scale, you would normally use set_value(). To detect
31 * changes to the value, you would normally use signal_value_changed().
32 *
33 * Note that using the same upper and lower bounds for the Scale (through
34 * the Range methods) will hide the slider itself. This is useful for
35 * applications that want to show an undeterminate value on the scale, without
36 * changing the layout of the application (such as movie or music players).
37 *
38 * @ingroup Widgets
39 */
40 class GTKMM_API Scale : public Range
41 {
42 _CLASS_GTKOBJECT(Scale,GtkScale,GTK_SCALE,Gtk::Range,GtkRange,,,GTKMM_API)
43 public:
44
45 _CTOR_DEFAULT()
46
47 /**
48 * @newin{3,2}
49 */
50 explicit Scale(Orientation orientation);
51
52 //Note that we try to use the same default parameter value as the default property value.
53 explicit Scale(const Glib::RefPtr<Adjustment>& adjustment, Orientation orientation = ORIENTATION_HORIZONTAL);
54 _IGNORE(gtk_scale_new)
55
56 /** Set the number of decimal digits.
57 *
58 * This also causes the adjustment to be rounded off so the retrieved value
59 * matches the value the user sees. Setting digits to 1 gives for example
60 * 1.0, 2 gives 1.00, etc.
61 */
62 _WRAP_METHOD(void set_digits(int digits), gtk_scale_set_digits)
63
64 /** Get the number of decimal digits.
65 */
66 _WRAP_METHOD(int get_digits() const, gtk_scale_get_digits)
67
68 /** Set whether the current value is displayed as a string next to the slider.
69 */
70 _WRAP_METHOD(void set_draw_value(bool draw_value = true), gtk_scale_set_draw_value)
71
72 /** Get whether the current value is displayed as a string next to the slider.
73 */
74 _WRAP_METHOD(bool get_draw_value() const, gtk_scale_get_draw_value)
75
76
77 /** Set the position in which the value is displayed.
78 */
79 _WRAP_METHOD(void set_value_pos(PositionType pos), gtk_scale_set_value_pos)
80
81 /** Get the position in which the value is displayed.
82 */
83 _WRAP_METHOD(PositionType get_value_pos() const, gtk_scale_get_value_pos)
84
85
86 _WRAP_METHOD(void set_has_origin(bool has_origin = true), gtk_scale_set_has_origin)
87 _WRAP_METHOD(bool get_has_origin() const, gtk_scale_get_has_origin)
88
89 _WRAP_METHOD(Glib::RefPtr<Pango::Layout> get_layout(), gtk_scale_get_layout, refreturn)
90 _WRAP_METHOD(Glib::RefPtr<const Pango::Layout> get_layout() const, gtk_scale_get_layout, refreturn, constversion)
91 _WRAP_METHOD(void get_layout_offsets(int& x, int& y) const, gtk_scale_get_layout_offsets)
92
93 _WRAP_METHOD(void add_mark(double value, PositionType position, const Glib::ustring& markup), gtk_scale_add_mark)
94 _WRAP_METHOD(void clear_marks(), gtk_scale_clear_marks)
95
96 #m4 dnl// The ::format_value signal handler should return a newly allocated string.
97 #m4 dnl// (which is obviously not a const gchar*)
98 #m4 dnl// Also, ensure that format_value never returns an empty char[],
99 #m4 dnl// because that could be caused by an intermediate empty ustring from an initial null char*,
100 #m4 dnl//See bug http://bugzilla.gnome.org/show_bug.cgi?id=168747.
101 #m4 _CONVERSION(`Glib::ustring',`gchar*',`(strlen($3.c_str()) ? g_strdup($3.c_str()) : nullptr)')
102 #m4 _CONVERSION(`gchar*',`Glib::ustring',`Glib::convert_return_gchar_ptr_to_ustring($3)')
103
104 _WRAP_SIGNAL(Glib::ustring format_value(double value), "format_value")
105
106 /** Number of displayed decimal digits.
107 */
108 _WRAP_PROPERTY("digits", int)
109
110 /** Whether to draw the value as a string next to slider.
111 */
112 _WRAP_PROPERTY("draw-value", bool)
113
114 /** The position in which the value is displayed.
115 */
116 _WRAP_PROPERTY("value-pos", PositionType)
117
118 _WRAP_PROPERTY("has-origin", bool)
119
120 protected:
121
122 _WRAP_VFUNC(void draw_value(), draw_value)
123
124 virtual int calc_digits_(double step) const;
125 };
126
127 } //namespace Gtk
128
129 #ifndef GTKMM_DISABLE_DEPRECATED
130 //Include the deprecated header,
131 //whose classes were previously in this header,
132 //to preserve the "API" of the includes.
133 #include <gtkmm/hvscale.h>
134 #endif // GTKMM_DISABLE_DEPRECATED