Adjustment Internals
| Chapter 14. Adjustments |

## Adjustment Internals

OK, you say, that's nice, but what if I want to create my own handlers to respond when the user adjusts a `Range` widget or a `SpinButton`. To access the value of a `Gtk::Adjustment`, you can use the `get_value()` and `set_value()` methods:

As mentioned earlier, `Gtk::Adjustment` can emit signals. This is, of course, how updates happen automatically when you share an `Adjustment` object between a `Scrollbar` and another adjustable widget; all adjustable widgets connect signal handlers to their adjustment's `value_changed` signal, as can your program.

So, for example, if you have a `Scale` widget, and you want to change the rotation of a picture whenever its value changes, you would create a signal handler like this:

    void cb_rotate_picture (Gtk::Widget *picture)
    {
      picture->set_rotation (adj->value);
    ...

and connect it to the scale widget's adjustment like this:

    adj.value_changed.connect(sigc::bind<Widget*>(sigc::mem_fun(*this,
        &cb_rotate_picture), picture));

What if a widget reconfigures the `upper` or `lower` fields of its `Adjustment`, such as when a user adds more text to a text widget? In this case, it emits the `changed` signal.

`Range` widgets typically connect a handler to this signal, which changes their appearance to reflect the change - for example, the size of the slider in a scrollbar will grow or shrink in inverse proportion to the difference between the `lower` and `upper` values of its `Adjustment`.

You probably won't ever need to attach a handler to this signal, unless you're writing a new type of range widget.

    adjustment->changed();

Using Adjustments the Easy Way |  | Chapter 15. Widgets Without X-Windows