Reference Manual
Inti Logo
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

Inti::Gtk::SpinButton Class Reference

A GtkSpinButton C++ wrapper class. More...

#include <inti/gtk/spinbutton.h>

Inheritance diagram for Inti::Gtk::SpinButton:

Inti::Gtk::Entry Inti::Gtk::Widget Inti::Gtk::Editable Inti::Gtk::CellEditable Inti::Gtk::Object Inti::Atk::Implementor Inti::G::TypeInterface Inti::G::TypeInterface Inti::G::Object Inti::G::TypeInterface Inti::G::TypeInstance Inti::G::TypeInstance Inti::G::TypeInstance Inti::MemoryHandler Inti::G::TypeInstance Inti::ReferencedBase Inti::ReferencedBase Inti::ReferencedBase Inti::ReferencedBase List of all members.

Public Member Functions

Constructors
Accessors
Methods
Property Proxies
Signal Proxies

Protected Member Functions

Constructors
Signal Handlers

Detailed Description

A GtkSpinButton C++ wrapper class.

A SpinButton is an ideal way to allow the user to set the value of some attribute. Rather than having to directly type a number into a Entry, SpinButton allows the user to click on one of two arrows to increment or decrement the displayed value. A value can still be typed in, with the bonus that it can be checked to ensure it is in a given range. The main properties of a SpinButton are through an Adjustment. See the Adjustment section for more details about an adjustment's properties.

Example 1: Using a SpinButton to get an integer.

    #include <inti/main.h>
    #include <inti/gtk/window.h>
    #include <inti/gtk/adjustment.h>
    #include <inti/gtk/spinbutton.h>
   
    using namespace Inti;
   
    class Window : public Gtk::Window
    {
        Gtk::SpinButton *spinner;
    public:
        Window();
        int grab_value() const;
    };
   
    Window::Window()
    {
        set_border_width(5);
        Gtk::Adjustment *spinner_adj = new Gtk::Adjustment(50.0, 0.0, 100.0, 1.0, 5.0, 5.0);
   
        // Creates the spinner, with no decimal places.
        spinner = new Gtk::SpinButton(spinner_adj, 1.0, 0);
        add(*spinner);
        show_all();
    }
   
    int
    Window::grab_value() const
    {
        return spinner->get_value_as_int();
    }
   
    int main (int argc, char *argv[])
    {
        using namespace Main;
   
        init(&argc, &argv);
   
        Window window;
        window.sig_destroy().connect(slot(&Inti::Main::quit));
   
        run();
        return 0;
    }

Example 2: Using a SpinButton to get a floating point value.

    #include <inti/main.h>
    #include <inti/gtk/window.h>
    #include <inti/gtk/adjustment.h>
    #include <inti/gtk/spinbutton.h>
   
    using namespace Inti;
   
    class Window : public Gtk::Window
    {
        Gtk::SpinButton *spinner;
    public:
        Window();
        double grab_value() const;
    };
   
    Window::Window()
    {
        set_border_width(5);
        Gtk::Adjustment *spinner_adj = new Gtk::Adjustment(2.500, 0.0, 5.0, 0.001, 0.1, 0.1);
   
        // Creates the spinner, with no decimal places.
        spinner = new Gtk::SpinButton(spinner_adj, 0.001, 3);
        add(*spinner);
        show_all();
    }
   
    double
    Window::grab_value() const
    {
        return spinner->get_value();
    }
   
    int main (int argc, char *argv[])
    {
        using namespace Main;
   
        init(&argc, &argv);
   
        Window window;
        window.sig_destroy().connect(slot(&Inti::Main::quit));
   
        run();
        return 0;
    }


Constructor & Destructor Documentation

Inti::Gtk::SpinButton::SpinButton GtkSpinButton *  spin_button,
bool  reference = false
[explicit, protected]
 

Construct a new SpinButton from an existing GtkSpinButton.

Parameters:
spin_button A pointer to a GtkSpinButton.
reference Set false if the initial reference count is floating, set true if it's not.

The spin_button can be a newly created GtkSpinButton or an existing GtkSpinButton (see G::Object::Object).

Inti::Gtk::SpinButton::SpinButton Adjustment adjustment,
double  climb_rate,
unsigned int  digits
 

Construct a new spin button with the specified Adjustment, climb_rate and digits.

Parameters:
adjustment The Adjustment object that this spin button should use.
climb_rate Specifies how much the spin button changes when an arrow is clicked on.
digits The number of decimal places to display.

Inti::Gtk::SpinButton::SpinButton double  min,
double  max,
double  step = 1.0
 

Construct a new spin button without specifying an Adjustment.

Parameters:
min The minimum allowable value.
max The maximum allowable value.
step The increment added or subtracted by spinning the widget.

This is a convenience constructor that allows creation of a numeric SpinButton without manually creating an adjustment. The value is initially set to the minimum value and a page increment of 10 * step is the default. The precision of the spinbutton is equivalent to the precision of step.


Member Function Documentation

void Inti::Gtk::SpinButton::configure Adjustment adjustment,
double  climb_rate,
unsigned int  digits
 

Changes the properties of an existing spin button.

Parameters:
adjustment The new Adjustment object this spin button should use.
climb_rate How much the spin button changes when an arrow is clicked on.
digits The number of decimal places to display in the spin button.

The adjustment, climb rate, and number of decimal places are all changed accordingly, after this function call.

unsigned int Inti::Gtk::SpinButton::get_digits  )  const
 

Fetches the precision of the spin button (see set_digits()).

Returns:
The current precision.

void Inti::Gtk::SpinButton::get_increments double *  step,
double *  page
const
 

Gets the current step and page the increments used by the spin button (see set_increments()).

Parameters:
step The location to store step increment, or null.
page The location to store page increment, or null.

bool Inti::Gtk::SpinButton::get_numeric  )  const
 

Returns whether non-numeric text can be typed into the spin button (see set_numeric()).

Returns:
true if only numeric text can be entered.

void Inti::Gtk::SpinButton::get_range double *  min,
double *  max
const
 

Gets the range allowed for the spin button (see set_range()).

Parameters:
min The location to store minimum allowed value, or null.
max The location to store maximum allowed value, or null.

bool Inti::Gtk::SpinButton::get_snap_to_ticks  )  const
 

Returns whether the values are corrected to the nearest step (see set_snap_to_ticks()).

Returns:
true if values are snapped to the nearest step.

SpinButtonUpdatePolicy Inti::Gtk::SpinButton::get_update_policy  )  const
 

Gets the update behavior of the spin button (see set_update_policy()).

Returns:
The current update policy.

int Inti::Gtk::SpinButton::get_value_as_int  )  const
 

Get the value of the spin button represented as an integer.

Returns:
The value of the spin button.

bool Inti::Gtk::SpinButton::get_wrap  )  const
 

Returns whether the spin button's value wraps around to the opposite limit when the upper or lower limit of the range is exceeded (see set_wrap()).

Returns:
true if the spin button wraps around.

virtual int Inti::Gtk::SpinButton::on_input double *  new_value  )  [protected, virtual]
 

Called when a new value is displayed in the spinbutton.

Parameters:
new_value The new value of the spin button.
Returns:
-1 if an error occurs, otherwise 0.

virtual int Inti::Gtk::SpinButton::on_output  )  [protected, virtual]
 

Called to display the new value in the spin button.

Returns:
Always zero.

void Inti::Gtk::SpinButton::set_adjustment Adjustment adjustment  ) 
 

Replaces the Adjustment associated with the spin button.

Parameters:
adjustment An Adjustment to replace the existing adjustment.

void Inti::Gtk::SpinButton::set_digits unsigned int  digits  ) 
 

Set the precision to be displayed by the spin button.

Parameters:
digits The number of digits to be displayed for the spin button's value.

Up to 20 digit precision is allowed.

void Inti::Gtk::SpinButton::set_increments double  step,
double  page
 

Sets the step and page increments for the spin button.

Parameters:
step The increment applied for a button 1 press.
page The increment applied for a button 2 press.

This affects how quickly the value changes when the spin button's arrows are activated.

void Inti::Gtk::SpinButton::set_numeric bool  numeric  ) 
 

Sets the flag that determines if non-numeric text can be typed into the spin button.

Parameters:
numeric true if only numeric entry is allowed.

void Inti::Gtk::SpinButton::set_range double  min,
double  max
 

Sets the minimum and maximum allowable values for the spin button.

Parameters:
min The minimum allowable value.
max The maximum allowable value.

void Inti::Gtk::SpinButton::set_snap_to_ticks bool  snap_to_ticks  ) 
 

Sets the policy as to whether values are corrected to the nearest step increment when a spin button is activated after providing an invalid value.

Parameters:
snap_to_ticks A flag indicating if invalid values should be corrected.

void Inti::Gtk::SpinButton::set_update_policy SpinButtonUpdatePolicy  policy  ) 
 

Sets the update behavior of the spin button.

Parameters:
policy A SpinButtonUpdatePolicy value.

This determines whether the spin button is always updated or only when a valid value is set.

void Inti::Gtk::SpinButton::set_value double  value  ) 
 

Set the value of the spin button.

Parameters:
value The new value.

void Inti::Gtk::SpinButton::set_wrap bool  wrap  ) 
 

Sets the flag that determines if a spin button value wraps around to the opposite limit when the upper or lower limit of the range is exceeded.

Parameters:
wrap true if wrapping behavior is performed.

void Inti::Gtk::SpinButton::spin SpinType  direction,
double  increment
 

Increment or decrement a spin button's value in a specified direction by a specified amount.

Parameters:
direction A SpinType indicating the direction to spin.
increment The step increment to apply in the specified direction.


The documentation for this class was generated from the following file: Main Page - Footer


Generated on Sun Sep 14 20:08:18 2003 for Inti by doxygen 1.3.2 written by Dimitri van Heesch, © 1997-2002