📄 sec-commonrangefunctions.html
字号:
<HTML><HEAD><TITLE>Common Range Functions</TITLE><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.49"><LINKREL="HOME"TITLE="GTK+ 1.2 Tutorial"HREF="gtk-tut.html"><LINKREL="UP"TITLE="Range Widgets"HREF="ch-rangewidgets.html"><LINKREL="PREVIOUS"TITLE="Scale Widgets"HREF="sec-scalewidgets.html"><LINKREL="NEXT"TITLE="Key and Mouse bindings"HREF="sec-keyandmousebindings.html"></HEAD></head><body bgcolor="#FFFFFF" marginheight=0 marginwidth=0 width="100%"><table cellspacing=6 border=0 cellpadding=0 width="100%"> <tr> <td bgcolor="#FFFFFF" valign=top nowrap> <centeR><A HREF="/"><img src="/images/gtk-logo-rgb.gif" width=107 height=140 border=0></A> <font face="helvetica,lucidia" color="#000000"><BR><BR><b>GTK+<BR>The GIMP Toolkit</b></center><BR><table width=100% cellspacing=0 cellpadding=2 border=0><tr><td bgcolor="#000000"><table width=100% cellspacing=0 cellpadding=4 border=0><tr><td bgcolor="#AAAAEE" nowrap><B>General</B></td></tr><tr><td bgcolor="#FFFFFF" nowrap><A HREF="/">Introduction</A><BR><A HREF="/screenshots/">Screenshots</A><br><A HREF="/download/">Download</A><br><A HREF="/mailinglists.html">Mailing Lists</A><BR><A HREF="/bindings.html">Language Bindings</A><BR><A HREF="http://gtk.themes.org/">Themes</A><BR><A HREF="/bugs.html">Bug Tracker</A><BR></td></tr></table></td></tr></table><BR> <table width=100% cellspacing=0 cellpadding=2 border=0><tr><td bgcolor="#000000"><table width=100% cellspacing=0 cellpadding=4 border=0><tr><td bgcolor="#AAAAEE" nowrap><B>Documentation</B></td></tr><tr><td bgcolor="#FFFFFF" nowrap><A HREF="/faq/">FAQ</A><br><A HREF="/tutorial/">Tutorial</A><BR><A HREF="/api/">API Reference</A><br><A HREF="/books.html">Published Books</A><BR></td></tr></table></td></tr></table><BR> <table width=100% cellspacing=0 cellpadding=2 border=0><tr><td bgcolor="#000000"><table width=100% cellspacing=0 cellpadding=4 border=0><tr><td bgcolor="#AAAAEE" nowrap><B>Projects</B></td></tr><tr><td bgcolor="#FFFFFF" nowrap><A HREF="http://www.pango.org/">Pango</A><BR><A HREF="http://sources.redhat.com/inti/">Inti</A><BR><A HREF="http://www.gnome.org/">GNOME</A><BR><A HREF="http://user.sgic.fi/~tml/gimp/win32/">GTK+ for Win32</A><br><A HREF="http://people.redhat.com/sopwith/gtkfb/">GtkFB (Framebuffer)</A><br><A HREF="http://www.directfb.org/gtk.xml">GTK+ on DirectFB</A><BR><A HREF="/beos/">GTK+ for BeOS</A></td></tr></table></td></tr></table><BR> <table width=100% cellspacing=0 cellpadding=2 border=0><tr><td bgcolor="#000000"><table width=100% cellspacing=0 cellpadding=4 border=0><tr><td bgcolor="#AAAAEE" nowrap><B><B>Applications</B></B></td></tr><tr><td bgcolor="#FFFFFF" nowrap><A HREF="http://www.gimp.org/">GIMP</A><BR><A HREF="http://www.abiword.org/">Abiword</A><BR><A HREF="http://www.lysator.liu.se/~alla/dia/dia.html">Dia</A><BR><A HREF="http://glade.pn.org/">Glade</A><BR><A HREF="http://www.gnucash.org/">GnuCash</A><BR><A HREF="http://www.gnome.org/projects/gnumeric/">Gnumeric</A><BR><BR><A HREF="http://www.gnome.org/applist/">GNOME Software Map</A><br></td></tr></table></td></tr></table><BR> </td> <td bgcolor="#ffffff" valign=top width="99%"><font face="lucida,helvetica"><BODYCLASS="SECT1"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLEWIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">GTK+ 1.2 Tutorial</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="sec-scalewidgets.html"><<< Previous</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom">Chapter 8. Range Widgets</TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="sec-keyandmousebindings.html">Next >>></A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="SEC-COMMONRANGEFUNCTIONS">8.3. Common Range Functions</A></H1><P>The Range widget class is fairly complicated internally, but, likeall the "base class" widgets, most of its complexity is onlyinteresting if you want to hack on it. Also, almost all of thefunctions and signals it defines are only really used in writingderived widgets. There are, however, a few useful functions that aredefined in <TTCLASS="LITERAL"><gtk/gtkrange.h></TT> and will work on all rangewidgets.</P><DIVCLASS="SECT2"><H2CLASS="SECT2"><ANAME="AEN637">8.3.1. Setting the Update Policy</A></H2><P>The "update policy" of a range widget defines at what points duringuser interaction it will change the <TTCLASS="LITERAL">value</TT> field of itsAdjustment and emit the "value_changed" signal on thisAdjustment. The update policies, defined in<TTCLASS="LITERAL"><gtk/gtkenums.h></TT> as type <TTCLASS="LITERAL">enum GtkUpdateType</TT>,are:</P><P></P><UL><LI><P>GTK_UPDATE_CONTINUOUS - This is the default. The"value_changed" signal is emitted continuously, i.e., whenever theslider is moved by even the tiniest amount.</P></LI><LI><P>GTK_UPDATE_DISCONTINUOUS - The "value_changed" signal isonly emitted once the slider has stopped moving and the user hasreleased the mouse button.</P></LI><LI><P>GTK_UPDATE_DELAYED - The "value_changed" signal is emittedwhen the user releases the mouse button, or if the slider stops movingfor a short period of time.</P></LI></UL><P>The update policy of a range widget can be set by casting it using the<TTCLASS="LITERAL">GTK_RANGE (Widget)</TT> macro and passing it to this function:</P><TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="100%"><TR><TD><PRECLASS="PROGRAMLISTING">void gtk_range_set_update_policy( GtkRange *range, GtkUpdateType policy);</PRE></TD></TR></TABLE></DIV><DIVCLASS="SECT2"><H2CLASS="SECT2"><ANAME="AEN653">8.3.2. Getting and Setting Adjustments</A></H2><P>Getting and setting the adjustment for a range widget "on the fly" isdone, predictably, with:</P><TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="100%"><TR><TD><PRECLASS="PROGRAMLISTING">GtkAdjustment* gtk_range_get_adjustment( GtkRange *range );void gtk_range_set_adjustment( GtkRange *range, GtkAdjustment *adjustment );</PRE></TD></TR></TABLE><P><TTCLASS="LITERAL">gtk_range_get_adjustment()</TT> returns a pointer to the adjustment towhich <TTCLASS="LITERAL">range</TT> is connected.</P><P><TTCLASS="LITERAL">gtk_range_set_adjustment()</TT> does absolutely nothing if you pass itthe adjustment that <TTCLASS="LITERAL">range</TT> is already using, regardless of whetheryou changed any of its fields or not. If you pass it a newAdjustment, it will unreference the old one if it exists (possiblydestroying it), connect the appropriate signals to the new one, andcall the private function <TTCLASS="LITERAL">gtk_range_adjustment_changed()</TT>, whichwill (or at least, is supposed to...) recalculate the size and/orposition of the slider and redraw if necessary. As mentioned in thesection 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><TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="100%"><TR><TD><PRECLASS="PROGRAMLISTING">gtk_signal_emit_by_name (GTK_OBJECT (adjustment), "changed");</PRE></TD></TR></TABLE></DIV></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLEWIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="sec-scalewidgets.html"><<< Previous</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="gtk-tut.html">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="sec-keyandmousebindings.html">Next >>></A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Scale Widgets</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="ch-rangewidgets.html">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Key and Mouse bindings</TD></TR></TABLE></DIV> </td> </tr></table> </td> </tr></table></body></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -