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

📄 sec-rangewidgetsexample.html

📁 gtk的教材和问答集
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<HTML><HEAD><TITLE>Example</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="Key and Mouse bindings"HREF="sec-keyandmousebindings.html"><LINKREL="NEXT"TITLE="Miscellaneous Widgets"HREF="ch-miscwidgets.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-keyandmousebindings.html">&#60;&#60;&#60; Previous</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom">Chapter 8. Range Widgets</TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="ch-miscwidgets.html">Next &#62;&#62;&#62;</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="SEC-RANGEWIDGETSEXAMPLE">8.5. Example</A></H1><P>This example is a somewhat modified version of the "range controls"test from <TTCLASS="LITERAL">testgtk.c</TT>. It basically puts up a window with threerange widgets all connected to the same adjustment, and a couple ofcontrols for adjusting some of the parameters mentioned above and inthe section on adjustments, so you can see how they affect the waythese widgets work for the user.</P><TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="100%"><TR><TD><PRECLASS="PROGRAMLISTING">/* example-start rangewidgets rangewidgets.c */#include &#60;gtk/gtk.h&#62;GtkWidget *hscale, *vscale;void cb_pos_menu_select( GtkWidget       *item,                         GtkPositionType  pos ){    /* Set the value position on both scale widgets */    gtk_scale_set_value_pos (GTK_SCALE (hscale), pos);    gtk_scale_set_value_pos (GTK_SCALE (vscale), pos);}void cb_update_menu_select( GtkWidget     *item,                            GtkUpdateType  policy ){    /* Set the update policy for both scale widgets */    gtk_range_set_update_policy (GTK_RANGE (hscale), policy);    gtk_range_set_update_policy (GTK_RANGE (vscale), policy);}void cb_digits_scale( GtkAdjustment *adj ){    /* Set the number of decimal places to which adj-&#62;value is rounded */    gtk_scale_set_digits (GTK_SCALE (hscale), (gint) adj-&#62;value);    gtk_scale_set_digits (GTK_SCALE (vscale), (gint) adj-&#62;value);}void cb_page_size( GtkAdjustment *get,                   GtkAdjustment *set ){    /* Set the page size and page increment size of the sample     * adjustment to the value specified by the "Page Size" scale */    set-&#62;page_size = get-&#62;value;    set-&#62;page_increment = get-&#62;value;    /* Now emit the "changed" signal to reconfigure all the widgets that     * are attached to this adjustment */    gtk_signal_emit_by_name (GTK_OBJECT (set), "changed");}void cb_draw_value( GtkToggleButton *button ){    /* Turn the value display on the scale widgets off or on depending     *  on the state of the checkbutton */    gtk_scale_set_draw_value (GTK_SCALE (hscale), button-&#62;active);    gtk_scale_set_draw_value (GTK_SCALE (vscale), button-&#62;active);  }/* Convenience functions */GtkWidget *make_menu_item( gchar         *name,                           GtkSignalFunc  callback,			   gpointer       data ){    GtkWidget *item;      item = gtk_menu_item_new_with_label (name);    gtk_signal_connect (GTK_OBJECT (item), "activate",                        callback, data);    gtk_widget_show (item);    return(item);}void scale_set_default_values( GtkScale *scale ){    gtk_range_set_update_policy (GTK_RANGE (scale),                                 GTK_UPDATE_CONTINUOUS);

⌨️ 快捷键说明

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