gtkmm  3.4.0
Public Member Functions | Protected Member Functions | Related Functions
Gtk::Scale Class Reference

A slider widget for selecting a value from a range. More...

Inheritance diagram for Gtk::Scale:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual ~Scale ()
GtkScale* gobj ()
 Provides access to the underlying C GtkObject.
const GtkScale* gobj () const
 Provides access to the underlying C GtkObject.
 Scale ()
 Scale (Orientation orientation=ORIENTATION_HORIZONTAL)
 Scale (const Glib::RefPtr< Adjustment >& adjustment, Orientation orientation=ORIENTATION_HORIZONTAL)
void set_digits (int digits)
 Set the number of decimal digits.
int get_digits () const
 Get the number of decimal digits.
void set_draw_value (bool draw_value=true)
 Set whether the current value is displayed as a string next to the slider.
bool get_draw_value () const
 Get whether the current value is displayed as a string next to the slider.
void set_value_pos (PositionType pos)
 Set the position in which the value is displayed.
PositionType get_value_pos () const
 Get the position in which the value is displayed.
void set_has_origin (bool has_origin=true)
 If has_origin is set to true (the default), the scale will highlight the part of the scale between the origin (bottom or left side) of the scale and the current value.
bool get_has_origin () const
 Returns whether the scale has an origin.
Glib::RefPtr< Pango::Layoutget_layout ()
 Gets the Pango::Layout used to display the scale.
Glib::RefPtr< const Pango::Layoutget_layout () const
 Gets the Pango::Layout used to display the scale.
void get_layout_offsets (int& x, int& y) const
 Obtains the coordinates where the scale will draw the Pango::Layout representing the text in the scale.
void add_mark (double value, PositionType position, const Glib::ustring& markup)
 Adds a mark at value.
void clear_marks ()
 Removes any marks that have been added with add_mark().
Glib::SignalProxy1
< Glib::ustring, double > 
signal_format_value ()
Glib::PropertyProxy< int > property_digits ()
 Number of displayed decimal digits.
Glib::PropertyProxy_ReadOnly< int > property_digits () const
 The number of decimal places that are displayed in the value.
Glib::PropertyProxy< bool > property_draw_value ()
 Whether to draw the value as a string next to slider.
Glib::PropertyProxy_ReadOnly
< bool > 
property_draw_value () const
 Whether the current value is displayed as a string next to the slider.
Glib::PropertyProxy< PositionTypeproperty_value_pos ()
 The position in which the value is displayed.
Glib::PropertyProxy_ReadOnly
< PositionType
property_value_pos () const
 The position in which the current value is displayed.
Glib::PropertyProxy< bool > property_has_origin ()
 Whether the scale has an origin.
Glib::PropertyProxy_ReadOnly
< bool > 
property_has_origin () const
 Whether the scale has an origin.

Protected Member Functions

virtual Glib::ustring on_format_value (double value)
 This is a default handler for the signal signal_format_value().
virtual void draw_value_vfunc ()
virtual int calc_digits_ (double step) const

Related Functions

(Note that these are not member functions.)

Gtk::Scalewrap (GtkScale* object, bool take_copy=false)
 A Glib::wrap() method for this object.

Detailed Description

A slider widget for selecting a value from a range.

A Gtk::Scale is a slider control used to select a numeric value. To use it, you'll probably want to investigate the methods on its base class, Gtk::Range, in addition to the methods for Gtk::Scale itself. To set the value of a scale, you would normally use set_value(). To detect changes to the value, you would normally use signal_value_changed().

Note that using the same upper and lower bounds for the Scale (through the Range methods) will hide the slider itself. This is useful for applications that want to show an undeterminate value on the scale, without changing the layout of the application (such as movie or music players).


Constructor & Destructor Documentation

virtual Gtk::Scale::~Scale ( ) [virtual]
Gtk::Scale::Scale ( Orientation  orientation = ORIENTATION_HORIZONTAL) [explicit]
Gtk::Scale::Scale ( const Glib::RefPtr< Adjustment >&  adjustment,
Orientation  orientation = ORIENTATION_HORIZONTAL 
) [explicit]

Member Function Documentation

void Gtk::Scale::add_mark ( double  value,
PositionType  position,
const Glib::ustring markup 
)

Adds a mark at value.

A mark is indicated visually by drawing a tick mark next to the scale, and GTK+ makes it easy for the user to position the scale exactly at the marks value.

If markup is not 0, text is shown next to the tick mark.

To remove marks from a scale, use clear_marks().

Since gtkmm 2.16:
Parameters:
valueThe value at which the mark is placed, must be between the lower and upper limits of the scales' adjustment.
positionWhere to draw the mark. For a horizontal scale, Gtk::POS_TOP and Gtk::POS_LEFT are drawn above the scale, anything else below. For a vertical scale, Gtk::POS_LEFT and Gtk::POS_TOP are drawn to the left of the scale, anything else to the right.
markupText to be shown at the mark, using Pango markup, or 0.
virtual int Gtk::Scale::calc_digits_ ( double  step) const [protected, virtual]

Removes any marks that have been added with add_mark().

Since gtkmm 2.16:
virtual void Gtk::Scale::draw_value_vfunc ( ) [protected, virtual]
int Gtk::Scale::get_digits ( ) const

Get the number of decimal digits.

Get whether the current value is displayed as a string next to the slider.

Returns whether the scale has an origin.

Since gtkmm 3.4:
Returns:
true if the scale has an origin.

Gets the Pango::Layout used to display the scale.

The returned object is owned by the scale so does not need to be freed by the caller.

Since gtkmm 2.4:
Returns:
The Pango::Layout for this scale, or 0 if the Gtk::Scale::property_draw_value() property is false.

Gets the Pango::Layout used to display the scale.

The returned object is owned by the scale so does not need to be freed by the caller.

Since gtkmm 2.4:
Returns:
The Pango::Layout for this scale, or 0 if the Gtk::Scale::property_draw_value() property is false.
void Gtk::Scale::get_layout_offsets ( int &  x,
int &  y 
) const

Obtains the coordinates where the scale will draw the Pango::Layout representing the text in the scale.

Remember when using the Pango::Layout function you need to convert to and from pixels using PANGO_PIXELS() or Pango::SCALE.

If the Gtk::Scale::property_draw_value() property is false, the return values are undefined.

Since gtkmm 2.4:
Parameters:
xLocation to store X offset of layout, or 0.
yLocation to store Y offset of layout, or 0.

Get the position in which the value is displayed.

GtkScale* Gtk::Scale::gobj ( ) [inline]

Provides access to the underlying C GtkObject.

Reimplemented from Gtk::Range.

Reimplemented in Gtk::HScale, and Gtk::VScale.

const GtkScale* Gtk::Scale::gobj ( ) const [inline]

Provides access to the underlying C GtkObject.

Reimplemented from Gtk::Range.

Reimplemented in Gtk::HScale, and Gtk::VScale.

virtual Glib::ustring Gtk::Scale::on_format_value ( double  value) [protected, virtual]

This is a default handler for the signal signal_format_value().

Number of displayed decimal digits.

The number of decimal places that are displayed in the value.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

The number of decimal places that are displayed in the value.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Whether to draw the value as a string next to slider.

Whether the current value is displayed as a string next to the slider.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Whether the current value is displayed as a string next to the slider.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Whether the scale has an origin.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Whether the scale has an origin.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

The position in which the value is displayed.

The position in which the current value is displayed.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

The position in which the current value is displayed.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
void Gtk::Scale::set_digits ( int  digits)

Set the number of decimal digits.

This also causes the adjustment to be rounded off so the retrieved value matches the value the user sees. Setting digits to 1 gives for example 1.0, 2 gives 1.00, etc.

void Gtk::Scale::set_draw_value ( bool  draw_value = true)

Set whether the current value is displayed as a string next to the slider.

void Gtk::Scale::set_has_origin ( bool  has_origin = true)

If has_origin is set to true (the default), the scale will highlight the part of the scale between the origin (bottom or left side) of the scale and the current value.

Since gtkmm 3.4:
Parameters:
has_origintrue if the scale has an origin.

Set the position in which the value is displayed.

Slot Prototype:
Glib::ustring on_my_format_value(double value)

Signal which allows you to change how the scale value is displayed. Connect a signal handler which returns an allocated string representing value. That string will then be used to display the scale's value.

Here's an example signal handler which displays a value 1.0 as with "-->1.0<--".

[C example ellipted]

Parameters:
valueThe value to format.
Returns:
Allocated string representing value.

Friends And Related Function Documentation

Gtk::Scale* wrap ( GtkScale *  object,
bool  take_copy = false 
) [related]

A Glib::wrap() method for this object.

Parameters:
objectThe C instance.
take_copyFalse if the result should take ownership of the C instance. True if it should take a new copy or ref.
Returns:
A C++ instance that wraps this C instance.

The documentation for this class was generated from the following file: