Install ardour as a binary, a script and a set of shared
[ardour.git] / libs / gtkmm2 / gtk / gtkmm / spinbutton.h
1 // -*- c++ -*-
2 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #ifndef _GTKMM_SPINBUTTON_H
4 #define _GTKMM_SPINBUTTON_H
5
6 #include <glibmm.h>
7
8 /* $Id$ */
9
10 /* Copyright (C) 1998-2002 The gtkmm Development Team
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Library General Public
14  * License as published by the Free Software Foundation; either
15  * version 2 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * Library General Public License for more details.
21  *
22  * You should have received a copy of the GNU Library General Public
23  * License along with this library; if not, write to the Free
24  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25  */
26
27 #include <gtkmm/entry.h>
28 #include <gtkmm/editable.h>
29
30
31 #ifndef DOXYGEN_SHOULD_SKIP_THIS
32 typedef struct _GtkSpinButton GtkSpinButton;
33 typedef struct _GtkSpinButtonClass GtkSpinButtonClass;
34 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
35
36
37 namespace Gtk
38 { class SpinButton_Class; } // namespace Gtk
39 namespace Gtk
40 {
41
42
43 /** @addtogroup gtkmmEnums Enums and Flags */
44
45 /**
46  * @ingroup gtkmmEnums
47  */
48 enum SpinButtonUpdatePolicy
49 {
50   UPDATE_ALWAYS,
51   UPDATE_IF_VALID
52 };
53
54 } // namespace Gtk
55
56
57 #ifndef DOXYGEN_SHOULD_SKIP_THIS
58 namespace Glib
59 {
60
61 template <>
62 class Value<Gtk::SpinButtonUpdatePolicy> : public Glib::Value_Enum<Gtk::SpinButtonUpdatePolicy>
63 {
64 public:
65   static GType value_type() G_GNUC_CONST;
66 };
67
68 } // namespace Glib
69 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
70
71
72 namespace Gtk
73 {
74
75 /**
76  * @ingroup gtkmmEnums
77  */
78 enum SpinType
79 {
80   SPIN_STEP_FORWARD,
81   SPIN_STEP_BACKWARD,
82   SPIN_PAGE_FORWARD,
83   SPIN_PAGE_BACKWARD,
84   SPIN_HOME,
85   SPIN_END,
86   SPIN_USER_DEFINED
87 };
88
89 } // namespace Gtk
90
91
92 #ifndef DOXYGEN_SHOULD_SKIP_THIS
93 namespace Glib
94 {
95
96 template <>
97 class Value<Gtk::SpinType> : public Glib::Value_Enum<Gtk::SpinType>
98 {
99 public:
100   static GType value_type() G_GNUC_CONST;
101 };
102
103 } // namespace Glib
104 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
105
106
107 namespace Gtk
108 {
109
110
111 /** @ingroup gtkmmEnums */
112 enum { INPUT_ERROR = -1 };
113
114 class Adjustment;
115
116 /** numeric Entry with up/down buttons
117  * Slightly misnamed, this should be called a SpinEntry.
118  *
119  * @ingroup Widgets
120  */
121
122 class SpinButton : public Entry
123 {
124   public:
125 #ifndef DOXYGEN_SHOULD_SKIP_THIS
126   typedef SpinButton CppObjectType;
127   typedef SpinButton_Class CppClassType;
128   typedef GtkSpinButton BaseObjectType;
129   typedef GtkSpinButtonClass BaseClassType;
130 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
131
132   virtual ~SpinButton();
133
134 #ifndef DOXYGEN_SHOULD_SKIP_THIS
135
136 private:
137   friend class SpinButton_Class;
138   static CppClassType spinbutton_class_;
139
140   // noncopyable
141   SpinButton(const SpinButton&);
142   SpinButton& operator=(const SpinButton&);
143
144 protected:
145   explicit SpinButton(const Glib::ConstructParams& construct_params);
146   explicit SpinButton(GtkSpinButton* castitem);
147
148 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
149
150 public:
151 #ifndef DOXYGEN_SHOULD_SKIP_THIS
152   static GType get_type()      G_GNUC_CONST;
153   static GType get_base_type() G_GNUC_CONST;
154 #endif
155
156   ///Provides access to the underlying C GtkObject.
157   GtkSpinButton*       gobj()       { return reinterpret_cast<GtkSpinButton*>(gobject_); }
158
159   ///Provides access to the underlying C GtkObject.
160   const GtkSpinButton* gobj() const { return reinterpret_cast<GtkSpinButton*>(gobject_); }
161
162
163 public:
164   //C++ methods used to invoke GTK+ virtual functions:
165
166 protected:
167   //GTK+ Virtual Functions (override these to change behaviour):
168
169   //Default Signal Handlers::
170   virtual int on_input(double* new_value);
171   virtual bool on_output();
172   virtual void on_value_changed();
173
174
175 private:
176
177   
178 public:
179
180   //: create instance
181   // adjustment: see Gtk::Adjustment
182   // climb_rate:
183   // digits: number of decimal digits (has to be < 6)
184   SpinButton(double climb_rate = 0.0, guint digits = 0);
185   explicit SpinButton(Adjustment& adjustment, double climb_rate = 0.0, guint digits = 0);
186
187
188   void configure(Adjustment& adjustment, double climb_rate, guint digits);
189
190   
191   /** Replaces the Gtk::Adjustment associated with @a spin_button .
192    * @param adjustment A Gtk::Adjustment to replace the existing adjustment.
193    */
194   void set_adjustment(Adjustment& adjustment);
195   void unset_adjustment();
196   
197   /** Get the adjustment associated with a Gtk::SpinButton
198    * @return The Gtk::Adjustment of @a spin_button .
199    */
200   Gtk::Adjustment* get_adjustment();
201   
202   /** Get the adjustment associated with a Gtk::SpinButton
203    * @return The Gtk::Adjustment of @a spin_button .
204    */
205   const Gtk::Adjustment* get_adjustment() const;
206
207   
208   /** Set the precision to be displayed by @a spin_button . Up to 20 digit precision
209    * is allowed.
210    * @param digits The number of digits after the decimal point to be displayed for the spin button's value.
211    */
212   void set_digits(guint digits);
213   
214   /** Fetches the precision of @a spin_button . See set_digits().
215    * @return The current precision.
216    */
217   guint get_digits() const;
218
219   
220   /** Sets the step and page increments for spin_button.  This affects how 
221    * quickly the value changes when the spin button's arrows are activated.
222    * @param step Increment applied for a button 1 press.
223    * @param page Increment applied for a button 2 press.
224    */
225   void set_increments(double step, double page);
226   
227   /** Gets the current step and page the increments used by @a spin_button . See
228    * set_increments().
229    * @param step Location to store step increment, or <tt>0</tt>.
230    * @param page Location to store page increment, or <tt>0</tt>.
231    */
232   void get_increments(double& step, double& page) const;
233
234   
235   /** Sets the minimum and maximum allowable values for @a spin_button 
236    * @param min Minimum allowable value.
237    * @param max Maximum allowable value.
238    */
239   void set_range(double min, double max);
240   
241   /** Gets the range allowed for @a spin_button . See
242    * set_range().
243    * @param min Location to store minimum allowed value, or <tt>0</tt>.
244    * @param max Location to store maximum allowed value, or <tt>0</tt>.
245    */
246   void get_range(double& min, double& max) const;
247
248   
249   /** Get the value in the @a spin_button .
250    * @return The value of @a spin_button .
251    */
252   double get_value() const;
253   
254   /** Get the value @a spin_button  represented as an integer.
255    * @return The value of @a spin_button .
256    */
257   int get_value_as_int() const;
258   
259   /** Set the value of @a spin_button .
260    * @param value The new value.
261    */
262   void set_value(double value);
263
264   
265   /** Sets the update behavior of a spin button. This determines whether the
266    * spin button is always updated or only when a valid value is set.
267    * @param policy A Gtk::SpinButtonUpdatePolicy value.
268    */
269   void set_update_policy(SpinButtonUpdatePolicy policy);
270   
271   /** Gets the update behavior of a spin button. See
272    * set_update_policy().
273    * @return The current update policy.
274    */
275   SpinButtonUpdatePolicy get_update_policy() const;
276
277   
278   /** Sets the flag that determines if non-numeric text can be typed into
279    * the spin button.
280    * @param numeric Flag indicating if only numeric entry is allowed.
281    */
282   void set_numeric(bool numeric = true);
283   
284   /** Returns whether non-numeric text can be typed into the spin button.
285    * See set_numeric().
286    * @return <tt>true</tt> if only numeric text can be entered.
287    */
288   bool get_numeric() const;
289
290   
291   /** Increment or decrement a spin button's value in a specified direction
292    * by a specified amount.
293    * @param direction A Gtk::SpinType indicating the direction to spin.
294    * @param increment Step increment to apply in the specified direction.
295    */
296   void spin(SpinType direction, double increment);
297
298   
299   /** Sets the flag that determines if a spin button value wraps around to the
300    * opposite limit when the upper or lower limit of the range is exceeded.
301    * @param wrap A flag indicating if wrapping behavior is performed.
302    */
303   void set_wrap(bool wrap = true);
304   
305   /** Returns whether the spin button's value wraps around to the
306    * opposite limit when the upper or lower limit of the range is
307    * exceeded. See set_wrap().
308    * @return <tt>true</tt> if the spin button wraps around.
309    */
310   bool get_wrap() const;
311
312   
313   /** Sets the policy as to whether values are corrected to the nearest step 
314    * increment when a spin button is activated after providing an invalid value.
315    * @param snap_to_ticks A flag indicating if invalid values should be corrected.
316    */
317   void set_snap_to_ticks(bool snap_to_ticks = true);
318   
319   /** Returns whether the values are corrected to the nearest step. See
320    * set_snap_to_ticks().
321    * @return <tt>true</tt> if values are snapped to the nearest step.
322    */
323   bool get_snap_to_ticks() const;
324
325   
326   /** Manually force an update of the spin button.
327    */
328   void update();
329
330   /** Convert the Entry text to a number.
331    * The computed number should be written to <tt>*new_value</tt>.
332    * @return
333    * @li <tt>false</tt>: No conversion done, continue with default handler.
334    * @li <tt>true</tt>: Conversion successful, don't call default handler.
335    * @li <tt>Gtk::INPUT_ERROR</tt>: Conversion failed, don't call default handler.
336    */
337   
338
339   Glib::SignalProxy1< int,double* > signal_input();
340
341
342   /** Convert the Adjustment position to text.
343    * The computed text should be written via Gtk::Entry::set_text().
344    * @return
345    * @li <tt>false</tt>: No conversion done, continue with default handler.
346    * @li <tt>true</tt>: Conversion successful, don't call default handler.
347    */
348   
349
350   Glib::SignalProxy0< bool > signal_output();
351
352
353   Glib::SignalProxy0< void > signal_value_changed();
354
355
356   //Keybinding signals:
357   
358
359   /** The adjustment that holds the value of the spinbutton.
360    *
361    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
362    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
363    * the value of the property changes.
364    */
365   Glib::PropertyProxy<Gtk::Adjustment*> property_adjustment() ;
366
367 /** The adjustment that holds the value of the spinbutton.
368    *
369    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
370    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
371    * the value of the property changes.
372    */
373   Glib::PropertyProxy_ReadOnly<Gtk::Adjustment*> property_adjustment() const;
374
375   /** The acceleration rate when you hold down a button.
376    *
377    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
378    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
379    * the value of the property changes.
380    */
381   Glib::PropertyProxy<double> property_climb_rate() ;
382
383 /** The acceleration rate when you hold down a button.
384    *
385    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
386    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
387    * the value of the property changes.
388    */
389   Glib::PropertyProxy_ReadOnly<double> property_climb_rate() const;
390
391   /** The number of decimal places to display.
392    *
393    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
394    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
395    * the value of the property changes.
396    */
397   Glib::PropertyProxy<guint> property_digits() ;
398
399 /** The number of decimal places to display.
400    *
401    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
402    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
403    * the value of the property changes.
404    */
405   Glib::PropertyProxy_ReadOnly<guint> property_digits() const;
406
407   /** Whether erroneous values are automatically changed to a spin button's nearest step increment.
408    *
409    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
410    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
411    * the value of the property changes.
412    */
413   Glib::PropertyProxy<bool> property_snap_to_ticks() ;
414
415 /** Whether erroneous values are automatically changed to a spin button's nearest step increment.
416    *
417    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
418    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
419    * the value of the property changes.
420    */
421   Glib::PropertyProxy_ReadOnly<bool> property_snap_to_ticks() const;
422
423   /** Whether non-numeric characters should be ignored.
424    *
425    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
426    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
427    * the value of the property changes.
428    */
429   Glib::PropertyProxy<bool> property_numeric() ;
430
431 /** Whether non-numeric characters should be ignored.
432    *
433    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
434    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
435    * the value of the property changes.
436    */
437   Glib::PropertyProxy_ReadOnly<bool> property_numeric() const;
438
439   /** Whether a spin button should wrap upon reaching its limits.
440    *
441    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
442    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
443    * the value of the property changes.
444    */
445   Glib::PropertyProxy<bool> property_wrap() ;
446
447 /** Whether a spin button should wrap upon reaching its limits.
448    *
449    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
450    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
451    * the value of the property changes.
452    */
453   Glib::PropertyProxy_ReadOnly<bool> property_wrap() const;
454
455   /** Whether the spin button should update always
456    *
457    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
458    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
459    * the value of the property changes.
460    */
461   Glib::PropertyProxy<SpinButtonUpdatePolicy> property_update_policy() ;
462
463 /** Whether the spin button should update always
464    *
465    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
466    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
467    * the value of the property changes.
468    */
469   Glib::PropertyProxy_ReadOnly<SpinButtonUpdatePolicy> property_update_policy() const;
470
471   /** Reads the current value
472    *
473    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
474    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
475    * the value of the property changes.
476    */
477   Glib::PropertyProxy<double> property_value() ;
478
479 /** Reads the current value
480    *
481    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
482    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
483    * the value of the property changes.
484    */
485   Glib::PropertyProxy_ReadOnly<double> property_value() const;
486
487
488 };
489
490 } // namespace Gtk
491
492
493 namespace Glib
494 {
495   /** @relates Gtk::SpinButton
496    * @param object The C instance
497    * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
498    * @result A C++ instance that wraps this C instance.
499    */
500   Gtk::SpinButton* wrap(GtkSpinButton* object, bool take_copy = false);
501 }
502 #endif /* _GTKMM_SPINBUTTON_H */
503