1 /* $Id: spinbutton.hg,v 1.4 2006/07/19 15:35:02 murrayc Exp $ */
3 /* Copyright (C) 1998-2002 The gtkmm Development Team
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the Free
17 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <gtkmm/entry.h>
21 #include <gtkmm/editable.h>
24 _PINCLUDE(gtkmm/private/entry_p.h)
30 _CC_INCLUDE(gtk/gtktypebuiltins.h)
31 _WRAP_ENUM(SpinButtonUpdatePolicy, GtkSpinButtonUpdatePolicy)
32 _WRAP_ENUM(SpinType, GtkSpinType)
34 /** @ingroup gtkmmEnums */
35 enum { INPUT_ERROR = -1 };
39 /** numeric Entry with up/down buttons
40 * Slightly misnamed, this should be called a SpinEntry.
44 class SpinButton : public Entry
46 _CLASS_GTKOBJECT(SpinButton,GtkSpinButton,GTK_SPIN_BUTTON,Gtk::Entry,GtkEntry)
47 _IMPLEMENTS_INTERFACE(Editable)
51 // adjustment: see Gtk::Adjustment
53 // digits: number of decimal digits (has to be < 6)
54 SpinButton(double climb_rate = 0.0, guint digits = 0);
55 _WRAP_CTOR(SpinButton(Adjustment& adjustment, double climb_rate = 0.0, guint digits = 0), gtk_spin_button_new)
58 _WRAP_METHOD(void configure(Adjustment& adjustment, double climb_rate, guint digits), gtk_spin_button_configure)
60 _WRAP_METHOD(void set_adjustment(Adjustment& adjustment), gtk_spin_button_set_adjustment)
61 void unset_adjustment();
62 _WRAP_METHOD(Gtk::Adjustment* get_adjustment(), gtk_spin_button_get_adjustment)
63 _WRAP_METHOD(const Gtk::Adjustment* get_adjustment() const, gtk_spin_button_get_adjustment, constversion)
65 _WRAP_METHOD(void set_digits(guint digits), gtk_spin_button_set_digits)
66 _WRAP_METHOD(guint get_digits() const, gtk_spin_button_get_digits)
68 _WRAP_METHOD(void set_increments(double step, double page), gtk_spin_button_set_increments)
69 _WRAP_METHOD(void get_increments(double& step, double& page) const, gtk_spin_button_get_increments)
71 _WRAP_METHOD(void set_range(double min, double max), gtk_spin_button_set_range)
72 _WRAP_METHOD(void get_range(double& min, double& max) const, gtk_spin_button_get_range)
74 _WRAP_METHOD(double get_value() const, gtk_spin_button_get_value)
75 _WRAP_METHOD(int get_value_as_int() const, gtk_spin_button_get_value_as_int)
76 _WRAP_METHOD(void set_value(double value), gtk_spin_button_set_value)
78 _WRAP_METHOD(void set_update_policy(SpinButtonUpdatePolicy policy), gtk_spin_button_set_update_policy)
79 _WRAP_METHOD(SpinButtonUpdatePolicy get_update_policy() const, gtk_spin_button_get_update_policy)
81 _WRAP_METHOD(void set_numeric(bool numeric = true), gtk_spin_button_set_numeric)
82 _WRAP_METHOD(bool get_numeric() const, gtk_spin_button_get_numeric)
84 _WRAP_METHOD(void spin(SpinType direction, double increment), gtk_spin_button_spin)
86 _WRAP_METHOD(void set_wrap(bool wrap = true), gtk_spin_button_set_wrap)
87 _WRAP_METHOD(bool get_wrap() const, gtk_spin_button_get_wrap)
89 _WRAP_METHOD(void set_snap_to_ticks(bool snap_to_ticks = true), gtk_spin_button_set_snap_to_ticks)
90 _WRAP_METHOD(bool get_snap_to_ticks() const, gtk_spin_button_get_snap_to_ticks)
92 _WRAP_METHOD(void update(), gtk_spin_button_update)
94 /** Convert the Entry text to a number.
95 * The computed number should be written to <tt>*new_value</tt>.
97 * @li <tt>false</tt>: No conversion done, continue with default handler.
98 * @li <tt>true</tt>: Conversion successful, don't call default handler.
99 * @li <tt>Gtk::INPUT_ERROR</tt>: Conversion failed, don't call default handler.
101 _WRAP_SIGNAL(int input(double* new_value), "input")
103 /** Convert the Adjustment position to text.
104 * The computed text should be written via Gtk::Entry::set_text().
106 * @li <tt>false</tt>: No conversion done, continue with default handler.
107 * @li <tt>true</tt>: Conversion successful, don't call default handler.
109 _WRAP_SIGNAL(bool output(), "output")
111 _WRAP_SIGNAL(bool wrapped(), "wrapped", no_default_handler)
113 _WRAP_SIGNAL(void value_changed(), "value_changed")
115 //Keybinding signals:
116 _IGNORE_SIGNAL("change_value")
118 _WRAP_PROPERTY("adjustment", Gtk::Adjustment*)
119 _WRAP_PROPERTY("climb-rate", double)
120 _WRAP_PROPERTY("digits", guint)
121 _WRAP_PROPERTY("snap-to-ticks", bool)
122 _WRAP_PROPERTY("numeric", bool)
123 _WRAP_PROPERTY("wrap", bool)
124 _WRAP_PROPERTY("update-policy", SpinButtonUpdatePolicy)
125 _WRAP_PROPERTY("value", double)