⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gtkspinbutton.html

📁 该压缩包包含了GTK+的大量API函数
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<HTML><HEAD><TITLE>GtkSpinButton</TITLE><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.61"><LINKREL="HOME"TITLE="GTK+ Reference Manual"HREF="index.html"><LINKREL="UP"TITLE="GTK+ Widgets and Objects"HREF="gtkobjects.html"><LINKREL="PREVIOUS"TITLE="GtkSocket"HREF="gtksocket.html"><LINKREL="NEXT"TITLE="GtkStatusbar"HREF="gtkstatusbar.html"></HEAD><BODYCLASS="REFENTRY"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLEWIDTH="100%"BORDER="0"BGCOLOR="#000000"CELLPADDING="1"CELLSPACING="0"><TR><THCOLSPAN="4"ALIGN="center"><FONTCOLOR="#FFFFFF"SIZE="5">GTK+ Reference Manual</FONT></TH></TR><TR><TDWIDTH="25%"BGCOLOR="#C00000"ALIGN="left"><AHREF="gtksocket.html"><FONTCOLOR="#FFFFFF"SIZE="3"><B>&#60;&#60;&#60; Previous Page</B></FONT></A></TD><TDWIDTH="25%"BGCOLOR="#0000C0"ALIGN="center"><FONTCOLOR="#FFFFFF"SIZE="3"><B><AHREF="index.html"><FONTCOLOR="#FFFFFF"SIZE="3"><B>Home</B></FONT></A></B></FONT></TD><TDWIDTH="25%"BGCOLOR="#00C000"ALIGN="center"><FONTCOLOR="#FFFFFF"SIZE="3"><B><AHREF="gtkobjects.html"><FONTCOLOR="#FFFFFF"SIZE="3"><B>Up</B></FONT></A></B></FONT></TD><TDWIDTH="25%"BGCOLOR="#C00000"ALIGN="right"><AHREF="gtkstatusbar.html"><FONTCOLOR="#FFFFFF"SIZE="3"><B>Next Page &#62;&#62;&#62;</B></FONT></A></TD></TR></TABLE></DIV><H1><ANAME="GTKSPINBUTTON">GtkSpinButton</A></H1><DIVCLASS="REFNAMEDIV"><ANAME="AEN39127"></A><H2>Name</H2>GtkSpinButton&nbsp;--&nbsp;retrieve an integer or floating-point number from the user.</DIV><DIVCLASS="REFSYNOPSISDIV"><ANAME="AEN39130"></A><H2>Synopsis</H2><TABLEBORDER="0"BGCOLOR="#D6E8FF"WIDTH="100%"CELLPADDING="6"><TR><TD><PRECLASS="SYNOPSIS">&#13;#include &lt;gtk/gtk.h&gt;struct      <AHREF="gtkspinbutton.html#GTKSPINBUTTON-STRUCT">GtkSpinButton</A>;enum        <AHREF="gtkspinbutton.html#GTKSPINBUTTONUPDATEPOLICY">GtkSpinButtonUpdatePolicy</A>;enum        <AHREF="gtkspinbutton.html#GTKSPINTYPE">GtkSpinType</A>;void        <AHREF="gtkspinbutton.html#GTK-SPIN-BUTTON-CONFIGURE">gtk_spin_button_configure</A>       (<AHREF="gtkspinbutton.html">GtkSpinButton</A> *spin_button,                                             <AHREF="gtkadjustment.html">GtkAdjustment</A> *adjustment,                                             <AHREF=../glib/glib-basic-types.html#GFLOAT>gfloat</A> climb_rate,                                             <AHREF=../glib/glib-basic-types.html#GUINT>guint</A> digits);<AHREF="gtkwidget.html">GtkWidget</A>*  <AHREF="gtkspinbutton.html#GTK-SPIN-BUTTON-NEW">gtk_spin_button_new</A>             (<AHREF="gtkadjustment.html">GtkAdjustment</A> *adjustment,                                             <AHREF=../glib/glib-basic-types.html#GFLOAT>gfloat</A> climb_rate,                                             <AHREF=../glib/glib-basic-types.html#GUINT>guint</A> digits);void        <AHREF="gtkspinbutton.html#GTK-SPIN-BUTTON-SET-ADJUSTMENT">gtk_spin_button_set_adjustment</A>  (<AHREF="gtkspinbutton.html">GtkSpinButton</A> *spin_button,                                             <AHREF="gtkadjustment.html">GtkAdjustment</A> *adjustment);<AHREF="gtkadjustment.html">GtkAdjustment</A>* <AHREF="gtkspinbutton.html#GTK-SPIN-BUTTON-GET-ADJUSTMENT">gtk_spin_button_get_adjustment</A>                                            (<AHREF="gtkspinbutton.html">GtkSpinButton</A> *spin_button);void        <AHREF="gtkspinbutton.html#GTK-SPIN-BUTTON-SET-DIGITS">gtk_spin_button_set_digits</A>      (<AHREF="gtkspinbutton.html">GtkSpinButton</A> *spin_button,                                             <AHREF=../glib/glib-basic-types.html#GUINT>guint</A> digits);<AHREF=../glib/glib-basic-types.html#GFLOAT>gfloat</A>      <AHREF="gtkspinbutton.html#GTK-SPIN-BUTTON-GET-VALUE-AS-FLOAT">gtk_spin_button_get_value_as_float</A>                                            (<AHREF="gtkspinbutton.html">GtkSpinButton</A> *spin_button);<AHREF=../glib/glib-basic-types.html#GINT>gint</A>        <AHREF="gtkspinbutton.html#GTK-SPIN-BUTTON-GET-VALUE-AS-INT">gtk_spin_button_get_value_as_int</A>                                            (<AHREF="gtkspinbutton.html">GtkSpinButton</A> *spin_button);void        <AHREF="gtkspinbutton.html#GTK-SPIN-BUTTON-SET-VALUE">gtk_spin_button_set_value</A>       (<AHREF="gtkspinbutton.html">GtkSpinButton</A> *spin_button,                                             <AHREF=../glib/glib-basic-types.html#GFLOAT>gfloat</A> value);void        <AHREF="gtkspinbutton.html#GTK-SPIN-BUTTON-SET-UPDATE-POLICY">gtk_spin_button_set_update_policy</A>                                            (<AHREF="gtkspinbutton.html">GtkSpinButton</A> *spin_button,                                             <AHREF="gtkspinbutton.html#GTKSPINBUTTONUPDATEPOLICY">GtkSpinButtonUpdatePolicy</A> policy);void        <AHREF="gtkspinbutton.html#GTK-SPIN-BUTTON-SET-NUMERIC">gtk_spin_button_set_numeric</A>     (<AHREF="gtkspinbutton.html">GtkSpinButton</A> *spin_button,                                             <AHREF=../glib/glib-basic-types.html#GBOOLEAN>gboolean</A> numeric);void        <AHREF="gtkspinbutton.html#GTK-SPIN-BUTTON-SPIN">gtk_spin_button_spin</A>            (<AHREF="gtkspinbutton.html">GtkSpinButton</A> *spin_button,                                             <AHREF="gtkspinbutton.html#GTKSPINTYPE">GtkSpinType</A> direction,                                             <AHREF=../glib/glib-basic-types.html#GFLOAT>gfloat</A> increment);void        <AHREF="gtkspinbutton.html#GTK-SPIN-BUTTON-SET-WRAP">gtk_spin_button_set_wrap</A>        (<AHREF="gtkspinbutton.html">GtkSpinButton</A> *spin_button,                                             <AHREF=../glib/glib-basic-types.html#GBOOLEAN>gboolean</A> wrap);void        <AHREF="gtkspinbutton.html#GTK-SPIN-BUTTON-SET-SHADOW-TYPE">gtk_spin_button_set_shadow_type</A> (<AHREF="gtkspinbutton.html">GtkSpinButton</A> *spin_button,                                             <AHREF="gtk-standard-enumerations.html#GTKSHADOWTYPE">GtkShadowType</A> shadow_type);void        <AHREF="gtkspinbutton.html#GTK-SPIN-BUTTON-SET-SNAP-TO-TICKS">gtk_spin_button_set_snap_to_ticks</A>                                            (<AHREF="gtkspinbutton.html">GtkSpinButton</A> *spin_button,                                             <AHREF=../glib/glib-basic-types.html#GBOOLEAN>gboolean</A> snap_to_ticks);void        <AHREF="gtkspinbutton.html#GTK-SPIN-BUTTON-UPDATE">gtk_spin_button_update</A>          (<AHREF="gtkspinbutton.html">GtkSpinButton</A> *spin_button);&#13;</PRE></TD></TR></TABLE></DIV><DIVCLASS="REFSECT1"><ANAME="AEN39185"></A><H2>Object Hierarchy</H2><TABLEBORDER="0"BGCOLOR="#D6E8FF"WIDTH="100%"CELLPADDING="6"><TR><TD><PRECLASS="SYNOPSIS">&#13;  <AHREF="gtkobject.html">GtkObject</A>   +----<AHREF="gtkwidget.html">GtkWidget</A>         +----<AHREF="gtkeditable.html">GtkEditable</A>               +----<AHREF="gtkentry.html">GtkEntry</A>                     +----GtkSpinButton</PRE></TD></TR></TABLE></DIV><DIVCLASS="REFSECT1"><ANAME="AEN39192"></A><H2>Args</H2><TABLEBORDER="0"BGCOLOR="#D6E8FF"WIDTH="100%"CELLPADDING="6"><TR><TD><PRECLASS="SYNOPSIS">&#13;  &quot;<AHREF="gtkspinbutton.html#GTKSPINBUTTON--ADJUSTMENT">adjustment</A>&quot;           <AHREF="gtkadjustment.html">GtkAdjustment</A>        : Read / Write  &quot;<AHREF="gtkspinbutton.html#GTKSPINBUTTON--CLIMB-RATE">climb-rate</A>&quot;           <AHREF=../glib/glib-basic-types.html#GFLOAT>gfloat</A>               : Read / Write  &quot;<AHREF="gtkspinbutton.html#GTKSPINBUTTON--DIGITS">digits</A>&quot;               <AHREF=../glib/glib-basic-types.html#GUINT>guint</A>                : Read / Write  &quot;<AHREF="gtkspinbutton.html#GTKSPINBUTTON--SNAP-TO-TICKS">snap-to-ticks</A>&quot;        <AHREF=../glib/glib-basic-types.html#GBOOLEAN>gboolean</A>             : Read / Write  &quot;<AHREF="gtkspinbutton.html#GTKSPINBUTTON--NUMERIC">numeric</A>&quot;              <AHREF=../glib/glib-basic-types.html#GBOOLEAN>gboolean</A>             : Read / Write  &quot;<AHREF="gtkspinbutton.html#GTKSPINBUTTON--WRAP">wrap</A>&quot;                 <AHREF=../glib/glib-basic-types.html#GBOOLEAN>gboolean</A>             : Read / Write  &quot;<AHREF="gtkspinbutton.html#GTKSPINBUTTON--UPDATE-POLICY">update-policy</A>&quot;        <AHREF="gtkspinbutton.html#GTKSPINBUTTONUPDATEPOLICY">GtkSpinButtonUpdatePolicy</A> : Read / Write  &quot;<AHREF="gtkspinbutton.html#GTKSPINBUTTON--SHADOW-TYPE">shadow-type</A>&quot;          <AHREF="gtk-standard-enumerations.html#GTKSHADOWTYPE">GtkShadowType</A>        : Read / Write  &quot;<AHREF="gtkspinbutton.html#GTKSPINBUTTON--VALUE">value</A>&quot;                <AHREF=../glib/glib-basic-types.html#GFLOAT>gfloat</A>               : Read / Write</PRE></TD></TR></TABLE></DIV><DIVCLASS="REFSECT1"><ANAME="AEN39213"></A><H2>Description</H2><P>A <AHREF="gtkspinbutton.html">GtkSpinButton</A> is an ideal way to allow the user to set the value of some attribute. Rather than having to directly type a number into a <AHREF="gtkentry.html">GtkEntry</A>, <AHREF="gtkspinbutton.html">GtkSpinButton</A> allows the user to click on one of two arrows to increment or decrement the displayed value. A value can still be typed in, with the bonus that it can be checked to ensure it is in a given range.</P><P>The main properties of a <AHREF="gtkspinbutton.html">GtkSpinButton</A> are through a <AHREF="gtkadjustment.html">GtkAdjustment</A>. See the <AHREF="gtkadjustment.html">GtkAdjustment</A> section for more details about an adjustment's properties.</P><P><AHREF="gtkspinbutton.html">GtkSpinButton</A> widgets are created with a call to <AHREF="gtkspinbutton.html#GTK-SPIN-BUTTON-NEW">gtk_spin_button_new</A>().</P><P>The <AHREF="gtkadjustment.html">GtkAdjustment</A> of a spin button can be set or retrieved with a call to <AHREF="gtkspinbutton.html#GTK-SPIN-BUTTON-SET-ADJUSTMENT">gtk_spin_button_set_adjustment</A>() or <AHREF="gtkspinbutton.html#GTK-SPIN-BUTTON-GET-ADJUSTMENT">gtk_spin_button_get_adjustment</A>(), respectively.</P><P>The number of digits after the decimal point of a spin button can be altered with <AHREF="gtkspinbutton.html#GTK-SPIN-BUTTON-SET-DIGITS">gtk_spin_button_set_digits</A>().</P><P>To retrieve values from a spin button, use <AHREF="gtkspinbutton.html#GTK-SPIN-BUTTON-GET-VALUE-AS-FLOAT">gtk_spin_button_get_value_as_float</A>() if you require a floating point number, or <AHREF="gtkspinbutton.html#GTK-SPIN-BUTTON-GET-VALUE-AS-INT">gtk_spin_button_get_value_as_int</A>() if you require an integer.</P><P>To set the value of a <AHREF="gtkspinbutton.html">GtkSpinButton</A>, use <AHREF="gtkspinbutton.html#GTK-SPIN-BUTTON-SET-VALUE">gtk_spin_button_set_value</A>(). To change the update behaviour of a spin button, use <AHREF="gtkspinbutton.html#GTK-SPIN-BUTTON-SET-UPDATE-POLICY">gtk_spin_button_set_update_policy</A>().</P><P>When a spin button reaches it's upper or lower limit, it can either stop spinning, or wrap around and continue spinning from the opposite limit. For example, if five is the upper limit and the lower limit is zero, upon reaching the value five, the spin button can change it's value back to zero and continue spinning upwards.This behaviour is set with <AHREF="gtkspinbutton.html#GTK-SPIN-BUTTON-SET-WRAP">gtk_spin_button_set_wrap</A>().</P><P>A border around a spin button's arrows can be created using <AHREF="gtkspinbutton.html#GTK-SPIN-BUTTON-SET-SHADOW-TYPE">gtk_spin_button_set_shadow_type</A>().</P><P>A number may be entered that is invalid, given a spin button's range. An erroneous number can be corrected as soon as the spin button is 'activated' using gtk_spin_button_snap_to_ticks(), which will alter the current value to the nearest step increment. (See <AHREF="gtkadjustment.html">GtkAdjustment</A> for step increments).</P><P>Because a spin contains a <AHREF="gtkentry.html">GtkEntry</A>, alphabetic characters may be entered. These can be ignored by using <AHREF="gtkspinbutton.html#GTK-SPIN-BUTTON-SET-NUMERIC">gtk_spin_button_set_numeric</A>() with a value of TRUE. Then only numeric values, '-' and a decimal point will be accepted.</P><P>To manually increment or decrement the spin button, use <AHREF="gtkspinbutton.html#GTK-SPIN-BUTTON-SPIN">gtk_spin_button_spin</A>(), and to force an update (refresh), use <AHREF="gtkspinbutton.html#GTK-SPIN-BUTTON-UPDATE">gtk_spin_button_update</A>().</P><P><DIVCLASS="EXAMPLE"><ANAME="AEN39253"></A><P><B>Example 1. Using a GtkSpinButton to get an integer.</B></P><TABLEBORDER="0"BGCOLOR="#D8F8D8"WIDTH="100%"CELLPADDING="6"><TR><TD><PRECLASS="PROGRAMLISTING">&#13;/* Provides a function to retrieve an integer value from a GtkSpinButton * and creates a spin button to model percentage values. */gint grab_int_value (GtkSpinButton *a_spinner, gpointer user_data) {   return gtk_spin_button_get_value_as_int (a_spinner);}void create_integer_spin_button(void) {   GtkWidget *window, *spinner;   GtkAdjustment *spinner_adj;   spinner_adj = (GtkAdjustment *) gtk_adjustment_new(50.0, 0.0, 100.0, 1.0, 5.0, 5.0);      window = gtk_window_new(GTK_WINDOW_TOPLEVEL);   gtk_container_set_border_width (GTK_CONTAINER (window), 5);      /* creates the spinner, with no decimal places */   spinner = gtk_spin_button_new (spinner_adj, 1.0, 0);   gtk_container_add (GTK_CONTAINER(window), spinner);      gtk_widget_show_all (window);   return;}&#13;</PRE></TD></TR></TABLE></DIV></P><P><DIVCLASS="EXAMPLE"><ANAME="AEN39257"></A><P><B>Example 2. Using a GtkSpinButton to get a floating point value.</B></P><TABLEBORDER="0"BGCOLOR="#D8F8D8"WIDTH="100%"CELLPADDING="6"><TR><TD><PRECLASS="PROGRAMLISTING">&#13;/* Provides a function to retrieve a floating point value from a * GtkSpinButton, and creates a high precision spin button. */gfloat grab_int_value (GtkSpinButton *a_spinner, gpointer user_data) {   return gtk_spin_button_get_value_as_float (a_spinner);}void create_floating_spin_button(void) {   GtkWidget *window, *spinner;   GtkAdjustment *spinner_adj;   spinner_adj = (GtkAdjustment *) gtk_adjustment_new(2.500, 0.0, 5.0, 0.001, 0.1, 0.1);      window = gtk_window_new(GTK_WINDOW_TOPLEVEL);   gtk_container_set_border_width (GTK_CONTAINER (window), 5);      /* creates the spinner, with three decimal places */   spinner = gtk_spin_button_new (spinner_adj, 0.001, 3);   gtk_container_add (GTK_CONTAINER(window), spinner);      gtk_widget_show_all (window);   return;}&#13;</PRE></TD></TR></TABLE></DIV></P></DIV><DIVCLASS="REFSECT1"><ANAME="AEN39260"></A><H2>Details</H2><DIVCLASS="REFSECT2"><ANAME="AEN39262"></A><H3><ANAME="GTKSPINBUTTON-STRUCT"></A>struct GtkSpinButton</H3><TABLEBORDER="0"BGCOLOR="#D6E8FF"WIDTH="100%"CELLPADDING="6"><TR><TD><PRECLASS="PROGRAMLISTING">struct GtkSpinButton;</PRE></TD></TR></TABLE><P><TTCLASS="STRUCTFIELD"><I>entry</I></TT> is the <AHREF="gtkentry.html">GtkEntry</A> part of the <AHREF="gtkspinbutton.html">GtkSpinButton</A> widget, and can be used accordingly. All other fields contain private data and should only be modified using the functions below.</P></DIV><HR><DIVCLASS="REFSECT2"><ANAME="AEN39270"></A><H3><ANAME="GTKSPINBUTTONUPDATEPOLICY"></A>enum GtkSpinButtonUpdatePolicy</H3><TABLEBORDER="0"BGCOLOR="#D6E8FF"WIDTH="100%"CELLPADDING="6"><TR><TD><PRECLASS="PROGRAMLISTING">typedef enum{  GTK_UPDATE_ALWAYS,  GTK_UPDATE_IF_VALID} GtkSpinButtonUpdatePolicy;</PRE></TD></TR></TABLE><P>&#13;<DIVCLASS="INFORMALTABLE"><ANAME="AEN39275"></A><P></P><TABLEBORDER="0"WIDTH="100%"BGCOLOR="#F0F0D0"CELLSPACING="0"CELLPADDING="4"CLASS="CALSTABLE"><TBODY><TR><TDWIDTH="20%"ALIGN="LEFT"VALIGN="TOP">GTK_UPDATE_ALWAYS</TD><TDWIDTH="80%"ALIGN="LEFT"VALIGN="TOP">When refreshing your <AHREF="gtkspinbutton.html">GtkSpinButton</A>, the value is always displayed.</TD></TR><TR><TDWIDTH="20%"ALIGN="LEFT"VALIGN="TOP">GTK_UPDATE_IF_VALID</TD><TDWIDTH="80%"ALIGN="LEFT"VALIGN="TOP">When refreshing your <AHREF="gtkspinbutton.html">GtkSpinButton</A>, the value is only displayed if it is valid within the bounds of the spin button's <AHREF="gtkadjustment.html">GtkAdjustment</A>.</TD></TR></TBODY></TABLE><P></P></DIV></P></DIV><HR><DIVCLASS="REFSECT2"><ANAME="AEN39289"></A><H3><ANAME="GTKSPINTYPE"></A>enum GtkSpinType</H3><TABLEBORDER="0"BGCOLOR="#D6E8FF"WIDTH="100%"CELLPADDING="6"><TR><TD><PRECLASS="PROGRAMLISTING">typedef enum{  GTK_SPIN_STEP_FORWARD,  GTK_SPIN_STEP_BACKWARD,  GTK_SPIN_PAGE_FORWARD,  GTK_SPIN_PAGE_BACKWARD,  GTK_SPIN_HOME,  GTK_SPIN_END,  GTK_SPIN_USER_DEFINED} GtkSpinType;</PRE></TD></TR></TABLE><P>&#13;<DIVCLASS="INFORMALTABLE"><ANAME="AEN39294"></A><P></P><TABLEBORDER="0"WIDTH="100%"BGCOLOR="#FFF0D0"CELLSPACING="0"CELLPADDING="4"CLASS="CALSTABLE"><TBODY><TR><TDWIDTH="20%"ALIGN="LEFT"VALIGN="TOP">GTK_SPIN_STEP_FORWARD, GTK_SPIN_STEP_BACKWARD, GTK_SPIN_PAGE_FORWARD, GTK_SPIN_PAGE_BACKWARD</TD><TDWIDTH="80%"ALIGN="LEFT"VALIGN="TOP">These values spin a <AHREF="gtkspinbutton.html">GtkSpinButton</A> by the relevant values of the spin button's <AHREF="gtkadjustment.html">GtkAdjustment</A>.</TD></TR><TR><TDWIDTH="20%"ALIGN="LEFT"VALIGN="TOP">GTK_SPIN_HOME, GTK_SPIN_END</TD><TDWIDTH="80%"ALIGN="LEFT"VALIGN="TOP">These set the spin button's value to the minimum or maxmimum possible values, (set by it's <AHREF="gtkadjustment.html">GtkAdjustment</A>), respectively.</TD></TR><TR><TDWIDTH="20%"ALIGN="LEFT"VALIGN="TOP">GTK_SPIN_USER_DEFINED</TD><TDWIDTH="80%"ALIGN="LEFT"VALIGN="TOP">The programmer must specify the exact amount to spin the <AHREF="gtkspinbutton.html">GtkSpinButton</A>.</TD></TR></TBODY></TABLE><P></P></DIV></P></DIV><HR><DIV

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -