Sophie

Sophie

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

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
>Scale Widgets</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="Range Widgets"
HREF="c633.html"><LINK
REL="NEXT"
TITLE="Common Range Functions"
HREF="x684.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="c633.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="x684.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-SCALEWIDGETS"
>Scale Widgets</A
></H1
><P
>Scale widgets are used to allow the user to visually select and
manipulate a value within a specific range. You might want to use a
scale widget, for example, to adjust the magnification level on a
zoomed preview of a picture, or to control the brightness of a color,
or to specify the number of minutes of inactivity before a screensaver
takes over the screen.</P
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN648"
>Creating a Scale Widget</A
></H2
><P
>As with scrollbars, there are separate widget types for horizontal and
vertical scale widgets. (Most programmers seem to favour horizontal
scale widgets.) Since they work essentially the same way, there's no
need to treat them separately here. The following functions create vertical and 
horizontal scale widgets, respectively:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>GtkWidget *gtk_vscale_new( GtkAdjustment *adjustment );

GtkWidget *gtk_vscale_new_with_range( gdouble min,
                                      gdouble max,
                                      gdouble step );

GtkWidget *gtk_hscale_new( GtkAdjustment *adjustment );

GtkWidget *gtk_hscale_new_with_range( gdouble min,
                                      gdouble max,
                                      gdouble step );</PRE
></TD
></TR
></TABLE
><P
>The <TT
CLASS="LITERAL"
>adjustment</TT
> argument can either be an adjustment which has
already been created with gtk_adjustment_new(), or NULL, in
which case, an anonymous Adjustment is created with all of its
values set to <TT
CLASS="LITERAL"
>0.0</TT
> (which isn't very useful in this case). 
In order to avoid confusing yourself, you probably want to create your
adjustment with a <TT
CLASS="LITERAL"
>page_size</TT
> of <TT
CLASS="LITERAL"
>0.0</TT
> so 
that its <TT
CLASS="LITERAL"
>upper</TT
> value actually corresponds to the highest 
value the user can select. The _new_with_range()�variants take care of creating
a suitable adjustment. (If you're <I
CLASS="EMPHASIS"
>already</I
> thoroughly
confused, read the section on <A
HREF="c563.html"
>Adjustments</A
> 
again for an explanation of what exactly adjustments do and how to create and 
manipulate them.)</P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN660"
>Functions and Signals (well, functions, at least)</A
></H2
><P
>Scale widgets can display their current value as a number beside the
trough. The default behaviour is to show the value, but you can change
this with this function:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>void gtk_scale_set_draw_value( GtkScale *scale,
                               gboolean draw_value );</PRE
></TD
></TR
></TABLE
><P
>As you might have guessed, <TT
CLASS="LITERAL"
>draw_value</TT
> is either <TT
CLASS="LITERAL"
>TRUE</TT
> or
<TT
CLASS="LITERAL"
>FALSE</TT
>, with predictable consequences for either one.</P
><P
>The value displayed by a scale widget is rounded to one decimal point
by default, as is the <TT
CLASS="LITERAL"
>value</TT
> field in its Adjustment. You can
change this with:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>void gtk_scale_set_digits( GtkScale *scale,
                            gint     digits );</PRE
></TD
></TR
></TABLE
><P
>where <TT
CLASS="LITERAL"
>digits</TT
> is the number of decimal places you want. You can
set <TT
CLASS="LITERAL"
>digits</TT
> to anything you like, but no more than 13 decimal
places will actually be drawn on screen.</P
><P
>Finally, the value can be drawn in different positions
relative to the trough:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>void gtk_scale_set_value_pos( GtkScale        *scale,
                              GtkPositionType  pos );</PRE
></TD
></TR
></TABLE
><P
>The argument <TT
CLASS="LITERAL"
>pos</TT
> is of type <TT
CLASS="LITERAL"
>GtkPositionType</TT
>,
which can take one of the following values:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>  GTK_POS_LEFT
  GTK_POS_RIGHT
  GTK_POS_TOP
  GTK_POS_BOTTOM</PRE
></TD
></TR
></TABLE
><P
>If you position the value on the "side" of the trough (e.g., on the
top or bottom of a horizontal scale widget), then it will follow the
slider up and down the trough.</P
><P
>All the preceding functions are defined in
<TT
CLASS="LITERAL"
>&#60;gtk/gtkscale.h&#62;</TT
>. The header files for all GTK widgets
are automatically included when you include
<TT
CLASS="LITERAL"
>&#60;gtk/gtk.h&#62;</TT
>. But you should look over the header files
of all widgets that interest you, in order to learn more about their functions
and features.</P
></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="c633.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="x684.html"
ACCESSKEY="N"
>Next &#62;&#62;&#62;</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Range 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"
>Common Range Functions</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>