Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 23dbe49bc2fbd86096de282a461e6c66 > files > 389

gtk2-devel-docs-2.24.7-3.fc15.i686.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>Common Range Functions</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="GTK+ 2.0 Tutorial"
HREF="book1.html"><LINK
REL="UP"
TITLE="Range Widgets"
HREF="c633.html"><LINK
REL="PREVIOUS"
TITLE="Scale Widgets"
HREF="x645.html"><LINK
REL="NEXT"
TITLE="Key and Mouse bindings"
HREF="x725.html"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>GTK+ 2.0 Tutorial</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="x645.html"
ACCESSKEY="P"
>&#60;&#60;&#60; Previous</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Range Widgets</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="x725.html"
ACCESSKEY="N"
>Next &#62;&#62;&#62;</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="SEC-COMMONRANGEFUNCTIONS"
>Common Range Functions</A
></H1
><P
>The Range widget class is fairly complicated internally, but, like
all the "base class" widgets, most of its complexity is only
interesting if you want to hack on it. Also, almost all of the
functions and signals it defines are only really used in writing
derived widgets. There are, however, a few useful functions that are
defined in <TT
CLASS="LITERAL"
>&#60;gtk/gtkrange.h&#62;</TT
> and will work on all range
widgets.</P
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN688"
>Setting the Update Policy</A
></H2
><P
>The "update policy" of a range widget defines at what points during
user interaction it will change the <TT
CLASS="LITERAL"
>value</TT
> field of its
Adjustment and emit the "value_changed" signal on this
Adjustment. The update policies, defined in
<TT
CLASS="LITERAL"
>&#60;gtk/gtkenums.h&#62;</TT
> as type <TT
CLASS="LITERAL"
>enum GtkUpdateType</TT
>,
are:</P
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="LITERAL"
>GTK_UPDATE_CONTINUOUS</TT
></DT
><DD
><P
>This is the default. The
"value_changed" signal is emitted continuously, i.e., whenever the
slider is moved by even the tiniest amount.</P
></DD
><DT
><TT
CLASS="LITERAL"
>GTK_UPDATE_DISCONTINUOUS</TT
></DT
><DD
><P
>The "value_changed" signal is
only emitted once the slider has stopped moving and the user has
released the mouse button.</P
></DD
><DT
><TT
CLASS="LITERAL"
>GTK_UPDATE_DELAYED</TT
></DT
><DD
><P
>The "value_changed" signal is emitted
when the user releases the mouse button, or if the slider stops moving
for a short period of time.</P
></DD
></DL
></DIV
><P
>The update policy of a range widget can be set by casting it using the
<TT
CLASS="LITERAL"
>GTK_RANGE(widget)</TT
> macro and passing it to this function:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>void gtk_range_set_update_policy( GtkRange      *range,
	                          GtkUpdateType  policy);</PRE
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN713"
>Getting and Setting Adjustments</A
></H2
><P
>Getting and setting the adjustment for a range widget "on the fly" is
done, predictably, with:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>GtkAdjustment* gtk_range_get_adjustment( GtkRange *range );

void gtk_range_set_adjustment( GtkRange      *range,
                               GtkAdjustment *adjustment );</PRE
></TD
></TR
></TABLE
><P
><TT
CLASS="LITERAL"
>gtk_range_get_adjustment()</TT
> returns a pointer to the adjustment to
which <TT
CLASS="LITERAL"
>range</TT
> is connected.</P
><P
><TT
CLASS="LITERAL"
>gtk_range_set_adjustment()</TT
> does absolutely nothing if you pass it
the adjustment that <TT
CLASS="LITERAL"
>range</TT
> is already using, regardless of whether
you changed any of its fields or not. If you pass it a new
Adjustment, it will unreference the old one if it exists (possibly
destroying it), connect the appropriate signals to the new one, and
call the private function <TT
CLASS="LITERAL"
>gtk_range_adjustment_changed()</TT
>, which
will (or at least, is supposed to...) recalculate the size and/or
position of the slider and redraw if necessary. As mentioned in the
section on adjustments, if you wish to reuse the same Adjustment,
when you modify its values directly, you should emit the "changed"
signal on it, like this:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>g_signal_emit_by_name (adjustment, "changed");</PRE
></TD
></TR
></TABLE
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="x645.html"
ACCESSKEY="P"
>&#60;&#60;&#60; Previous</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="book1.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="x725.html"
ACCESSKEY="N"
>Next &#62;&#62;&#62;</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Scale Widgets</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="c633.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Key and Mouse bindings</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>