📄 ch-adjustments.html
字号:
<HTML><HEAD><TITLE>Adjustments</TITLE><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.49"><LINKREL="HOME"TITLE="GTK+ 1.2 Tutorial"HREF="gtk-tut.html"><LINKREL="PREVIOUS"TITLE="Radio Buttons"HREF="sec-radiobuttons.html"><LINKREL="NEXT"TITLE="Using Adjustments the Easy Way"HREF="sec-usingadjustments.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="CHAPTER"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-radiobuttons.html"><<< Previous</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom"></TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="sec-usingadjustments.html">Next >>></A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="CHAPTER"><H1><ANAME="CH-ADJUSTMENTS">Chapter 7. Adjustments</A></H1><DIVCLASS="TOC"><DL><DT><B>Table of Contents</B></DT><DT>7.1. <AHREF="ch-adjustments.html#SEC-CREATINGANADJUSTMENT">Creating an Adjustment</A></DT><DT>7.2. <AHREF="sec-usingadjustments.html">Using Adjustments the Easy Way</A></DT><DT>7.3. <AHREF="sec-adjustmentinternals.html">Adjustment Internals</A></DT></DL></DIV><P>GTK has various widgets that can be visually adjusted by the userusing the mouse or the keyboard, such as the range widgets, describedin the <AHREF="ch-rangewidgets.html">Range Widgets</A>section. There are also a few widgets that display some adjustableportion of a larger area of data, such as the text widget and theviewport widget.</P><P>Obviously, an application needs to be able to react to changes theuser makes in range widgets. One way to do this would be to have eachwidget emit its own type of signal when its adjustment changes, andeither pass the new value to the signal handler, or require it to lookinside the widget's data structure in order to ascertain the value.But you may also want to connect the adjustments of several widgetstogether, so that adjusting one adjusts the others. The most obviousexample of this is connecting a scrollbar to a panning viewport or ascrolling text area. If each widget has its own way of setting orgetting the adjustment value, then the programmer may have to writetheir own signal handlers to translate between the output of onewidget's signal and the "input" of another's adjustment settingfunction.</P><P>GTK solves this problem using the Adjustment object, which is not awidget but a way for widgets to store and pass adjustment informationin an abstract and flexible form. The most obvious use of Adjustmentis to store the configuration parameters and values of range widgets,such as scrollbars and scale controls. However, since Adjustments arederived from Object, they have some special powers beyond those ofnormal data structures. Most importantly, they can emit signals, justlike widgets, and these signals can be used not only to allow yourprogram to react to user input on adjustable widgets, but also topropagate adjustment values transparently between adjustable widgets.</P><P>You will see how adjustments fit in when you see the other widgetsthat incorporate them:<AHREF="sec-progressbars.html">Progress Bars</A>,<AHREF="sec-viewports.html">Viewports</A>,<AHREF="sec-scrolledwindows.html">Scrolled Windows</A>, and others.</P><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="SEC-CREATINGANADJUSTMENT">7.1. Creating an Adjustment</A></H1><P>Many of the widgets which use adjustment objects do so automatically,but some cases will be shown in later examples where you may need tocreate one yourself. You create an adjustment using:</P><TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="100%"><TR><TD><PRECLASS="PROGRAMLISTING">GtkObject *gtk_adjustment_new( gfloat value, gfloat lower, gfloat upper, gfloat step_increment, gfloat page_increment, gfloat page_size );</PRE></TD></TR></TABLE><P>The <TTCLASS="LITERAL">value</TT> argument is the initial value you want to give to theadjustment, usually corresponding to the topmost or leftmost positionof an adjustable widget. The <TTCLASS="LITERAL">lower</TT> argument specifies the lowestvalue which the adjustment can hold. The <TTCLASS="LITERAL">step_increment</TT> argumentspecifies the "smaller" of the two increments by which the user canchange the value, while the <TTCLASS="LITERAL">page_increment</TT> is the "larger" one.The <TTCLASS="LITERAL">page_size</TT> argument usually corresponds somehow to the visiblearea of a panning widget. The <TTCLASS="LITERAL">upper</TT> argument is used to representthe bottom most or right most coordinate in a panning widget'schild. Therefore it is <ICLASS="EMPHASIS">not</I> always the largest number that<TTCLASS="LITERAL">value</TT> can take, since the <TTCLASS="LITERAL">page_size</TT> of such widgets isusually non-zero.</P></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-radiobuttons.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-usingadjustments.html">Next >>></A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Radio Buttons</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"> </TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Using Adjustments the Easy Way</TD></TR></TABLE></DIV> </td> </tr></table> </td> </tr></table></body></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -