Reference Manual

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# spinbutton.h

Go to the documentation of this file.

    00001 /*  Inti: Integrated Foundation Classes
    00002  *  Copyright (C) 2002-2003 The Inti Development Team.
    00003  *  Copyright (C) 2000 Red Hat, Inc.
    00004  *
    00005  *  This program is free software; you can redistribute it and/or modify
    00006  *  it under the terms of the GNU General Public License as published by
    00007  *  the Free Software Foundation; either version 2 of the License, or
    00008  *  (at your option) any later version.
    00009  *
    00010  *  This program is distributed in the hope that it will be useful,
    00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00013  *  GNU Library General Public License for more details.
    00014  *
    00015  *  You should have received a copy of the GNU Library General Public License
    00016  *  along with this program; if not, write to the Free Software
    00017  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    00018  */
    00019
    00024
    00025 #ifndef INTI_GTK_SPIN_BUTTON_H
    00026 #define INTI_GTK_SPIN_BUTTON_H
    00027
    00028 #ifndef INTI_GTK_ENTRY_H
    00029 #include <inti/gtk/entry.h>
    00030 #endif
    00031
    00032 #ifndef __GTK_SPIN_BUTTON_H__
    00033 #include <gtk/gtkspinbutton.h>
    00034 #endif
    00035
    00036 namespace Inti {
    00037
    00038 namespace Gtk {
    00039
    00040 class SpinButtonClass;
    00041
    00045
    00046 enum SpinType
    00047 {
    00048         SPIN_STEP_FORWARD = GTK_SPIN_STEP_FORWARD,
    00049         SPIN_STEP_BACKWARD = GTK_SPIN_STEP_BACKWARD,
    00050         SPIN_PAGE_FORWARD = GTK_SPIN_PAGE_FORWARD,
    00051         SPIN_PAGE_BACKWARD = GTK_SPIN_PAGE_BACKWARD,
    00052         SPIN_HOME = GTK_SPIN_HOME,
    00053         SPIN_END = GTK_SPIN_END,
    00054         SPIN_USER_DEFINED = GTK_SPIN_USER_DEFINED
    00055 };
    00056
    00059
    00060 enum SpinButtonUpdatePolicy
    00061 {
    00062         UPDATE_ALWAYS = GTK_UPDATE_ALWAYS,
    00064
    00065         UPDATE_IF_VALID = GTK_UPDATE_IF_VALID
    00068 };
    00069
    00175
    00176 class SpinButton : public Entry
    00177 {
    00178         friend class G::Object;
    00179         friend class SpinButtonClass;
    00180
    00181         SpinButton(const SpinButton&);
    00182         SpinButton& operator=(const SpinButton&);
    00183
    00184 protected:
    00187
    00188         explicit SpinButton(GtkSpinButton *spin_button, bool reference = false);
    00195
    00199
    00200         virtual int on_input(double *new_value);
    00204
    00205         virtual int on_output();
    00208
    00209         virtual void on_value_changed();
    00211
    00213 //  Properties
    00214
    00215         typedef G::Property<Adjustment*, G::Object*> AdjustmentPropertyType;
    00216         typedef G::PropertyProxy<G::Object, AdjustmentPropertyType> AdjustmentPropertyProxy;
    00217         static const AdjustmentPropertyType adjustment_property;
    00218
    00219         typedef G::Property<double> ClimbRatePropertyType;
    00220         typedef G::PropertyProxy<G::Object, ClimbRatePropertyType> ClimbRatePropertyProxy;
    00221         static const ClimbRatePropertyType climb_rate_property;
    00222
    00223         typedef G::Property<unsigned int> DigitsPropertyType;
    00224         typedef G::PropertyProxy<G::Object, DigitsPropertyType> DigitsPropertyProxy;
    00225         static const DigitsPropertyType digits_property;
    00226
    00227         typedef G::Property<bool> SnapToTicksPropertyType;
    00228         typedef G::PropertyProxy<G::Object, SnapToTicksPropertyType> SnapToTicksPropertyProxy;
    00229         static const SnapToTicksPropertyType snap_to_ticks_property;
    00230
    00231         typedef G::Property<bool> NumericPropertyType;
    00232         typedef G::PropertyProxy<G::Object, NumericPropertyType> NumericPropertyProxy;
    00233         static const NumericPropertyType numeric_property;
    00234
    00235         typedef G::Property<bool> WrapPropertyType;
    00236         typedef G::PropertyProxy<G::Object, WrapPropertyType> WrapPropertyProxy;
    00237         static const WrapPropertyType wrap_property;
    00238
    00239         typedef G::Property<SpinButtonUpdatePolicy, int> UpdatePolicyPropertyType;
    00240         typedef G::PropertyProxy<G::Object, UpdatePolicyPropertyType> UpdatePolicyPropertyProxy;
    00241         static const UpdatePolicyPropertyType update_policy_property;
    00242
    00243         typedef G::Property<double> ValuePropertyType;
    00244         typedef G::PropertyProxy<G::Object, ValuePropertyType> ValuePropertyProxy;
    00245         static const ValuePropertyType value_property;
    00246
    00247 //  Signals
    00248
    00249         typedef G::Signal1<int, double*> InputSignalType;
    00250         typedef G::SignalProxy<TypeInstance, InputSignalType> InputSignalProxy;
    00251         static const InputSignalType input_signal;
    00252
    00253         typedef G::Signal0<int> OutputSignalType;
    00254         typedef G::SignalProxy<TypeInstance, OutputSignalType> OutputSignalProxy;
    00255         static const OutputSignalType output_signal;
    00256
    00257         typedef G::Signal0<void> ValueChangedSignalType;
    00258         typedef G::SignalProxy<TypeInstance, ValueChangedSignalType> ValueChangedSignalProxy;
    00259         static const ValueChangedSignalType value_changed_signal;
    00260
    00261 public:
    00264
    00265         SpinButton();
    00267
    00268         SpinButton(Adjustment *adjustment, double climb_rate, unsigned int digits);
    00273
    00274         SpinButton(double min, double max, double step = 1.0);
    00284
    00285         virtual ~SpinButton();
    00287
    00291
    00292         GtkSpinButton* gtk_spin_button() const { return (GtkSpinButton*)instance; }
    00294
    00295         GtkSpinButtonClass* gtk_spin_button_class() const;
    00297
    00298         operator GtkSpinButton* () const;
    00300
    00301         Adjustment* get_adjustment() const;
    00303
    00304         unsigned int get_digits() const;
    00307
    00308         void get_increments(double *step, double *page) const;
    00312
    00313         void get_range(double *min, double *max) const;
    00317
    00318         double get_value() const;
    00320
    00321         int get_value_as_int() const;
    00324
    00325         SpinButtonUpdatePolicy get_update_policy() const;
    00328
    00329         bool get_numeric() const;
    00332
    00333         bool get_wrap() const;
    00337
    00338         bool get_snap_to_ticks() const;
    00341
    00345
    00346         void configure(Adjustment *adjustment, double climb_rate, unsigned int digits);
    00354
    00355         void set_adjustment(Adjustment *adjustment);
    00358
    00359         void set_digits(unsigned int digits);
    00364
    00365         void set_increments(double step, double page);
    00371
    00372         void set_range(double min, double max);
    00376
    00377         void set_value(double value);
    00380
    00381         void set_update_policy(SpinButtonUpdatePolicy policy);
    00386
    00387         void set_numeric(bool numeric);
    00390
    00391         void spin(SpinType direction, double increment);
    00395
    00396         void set_wrap(bool wrap);
    00400
    00401         void set_snap_to_ticks(bool snap_to_ticks);
    00405
    00406         void update();
    00408
    00412
    00413         const AdjustmentPropertyProxy prop_adjustment()
    00414         {
    00415                 return AdjustmentPropertyProxy(this, &adjustment_property);
    00416         }
    00418
    00419         const ClimbRatePropertyProxy prop_climb_rate()
    00420         {
    00421                 return ClimbRatePropertyProxy(this, &climb_rate_property);
    00422         }
    00424
    00425         const DigitsPropertyProxy prop_digits()
    00426         {
    00427                 return DigitsPropertyProxy(this, &digits_property);
    00428         }
    00430
    00431         const SnapToTicksPropertyProxy prop_snap_to_ticks()
    00432         {
    00433                 return SnapToTicksPropertyProxy(this, &snap_to_ticks_property);
    00434         }
    00437
    00438         const NumericPropertyProxy prop_numeric()
    00439         {
    00440                 return NumericPropertyProxy(this, &numeric_property);
    00441         }
    00443
    00444         const WrapPropertyProxy prop_wrap()
    00445         {
    00446                 return WrapPropertyProxy(this, &wrap_property);
    00447         }
    00449
    00450         const UpdatePolicyPropertyProxy prop_update_policy()
    00451         {
    00452                 return UpdatePolicyPropertyProxy(this, &update_policy_property);
    00453         }
    00456
    00457         const ValuePropertyProxy prop_value()
    00458         {
    00459                 return ValuePropertyProxy(this, &value_property);
    00460         }
    00462
    00466
    00467         const InputSignalProxy sig_input()
    00468         {
    00469                 return InputSignalProxy(this, &input_signal);
    00470         }
    00472
    00473         const OutputSignalProxy sig_output()
    00474         {
    00475                 return OutputSignalProxy(this, &output_signal);
    00476         }
    00478
    00479         const ValueChangedSignalProxy sig_value_changed()
    00480         {
    00481                 return ValueChangedSignalProxy(this, &value_changed_signal);
    00482         }
    00484
    00486 };
    00487
    00488 } // namespace Gtk
    00489
    00490 } // namespace Inti
    00491
    00492 #endif // INTI_GTK_SPIN_BUTTON_H
    00493

Main Page - Footer