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

📄 z144.html

📁 GTK+_ Gnome Application Development
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html>  <head>    <title>      The GtkWidget Base Class    </title>    <meta name="GENERATOR" content=    "Modular DocBook HTML Stylesheet Version 1.45">    <link rel="HOME" title="GTK+ / Gnome Application Development"    href="ggad.html">    <link rel="UP" title="Writing a GtkWidget" href=    "cha-widget.html">    <link rel="PREVIOUS" title="Writing a GtkWidget" href=     "cha-widget.html">    <link rel="NEXT" title="An Example: The GtkEv Widget" href=     "z147.html">  </head>  <body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink=   "#840084" alink="#0000FF">    <div class="NAVHEADER">      <table width="100%" border="0" bgcolor="#ffffff" cellpadding=       "1" cellspacing="0">        <tr>          <th colspan="4" align="center">            <font color="#000000" size="2">GTK+ / Gnome Application            Development</font>          </th>        </tr>        <tr>          <td width="25%" bgcolor="#ffffff" align="left">            <a href="cha-widget.html"><font color="#0000ff" size=            "2"><b>&lt;&lt;&lt; Previous</b></font></a>          </td>          <td width="25%" colspan="2" bgcolor="#ffffff" align=           "center">            <font color="#0000ff" size="2"><b><a href="ggad.html">            <font color="#0000ff" size="2"><b>            Home</b></font></a></b></font>          </td>          <td width="25%" bgcolor="#ffffff" align="right">            <a href="z147.html"><font color="#0000ff" size="2"><b>            Next &gt;&gt;&gt;</b></font></a>          </td>        </tr>      </table>    </div>    <div class="SECT1">      <h1 class="SECT1">        <a name="Z144">The <tt class="CLASSNAME">GtkWidget</tt>        Base Class</a>      </h1>      <p>        Obviously, to subclass <tt class="CLASSNAME">        GtkWidget</tt>, you will have to be familiar with the base        class. This section offers a brief tour of the <tt class=         "CLASSNAME">GtkWidget</tt> class and instance structs, and        some important GTK+ routines that aren't very common in        everyday programming.      </p>      <div class="SECT2">        <h2 class="SECT2">          <a name="Z145">The <tt class="CLASSNAME">GtkWidget</tt>          Instance Struct</a>        </h2>        <p>          A <tt class="CLASSNAME">GtkWidget</tt> instance looks          like this:        </p>        <table border="0" bgcolor="#E0E0E0" width="100%">          <tr>            <td><pre class="PROGRAMLISTING">&#13;typedef struct _GtkWidget GtkWidget;struct _GtkWidget{  GtkObject object;  guint16 private_flags;    guint8 state;  guint8 saved_state;    gchar *name;  GtkStyle *style;    GtkRequisition requisition;  GtkAllocation allocation;    GdkWindow *window;  GtkWidget *parent;};      </pre>            </td>          </tr>        </table>        <p>          The <span class="STRUCTNAME">private_flags</span>, <span          class="STRUCTNAME">state</span>, and <span class=           "STRUCTNAME">saved_state</span> fields should all be          accessed with macros, if at all. Some of these macros          will come up as we discuss widget implementations. The          <span class="STRUCTNAME">state</span> field stores the          widget's state as described in <a href=           "z57.html#SEC-WIDGETSTATES">the section called <i>Widget          States</i> in the chapter called <i>GTK+ Basics</i></a>.          <span class="STRUCTNAME">saved_state</span> is used to          save the widget's previous state when the current state          is <span class="STRUCTNAME">GTK_STATE_INSENSITIVE</span>;          when the widget is re-sensitized, its original state is          restored. As <a href="z57.html#SEC-WIDGETSTATES">the          section called <i>Widget States</i> in the chapter called          <i>GTK+ Basics</i></a> explains, the current state can be          accessed with the <tt class="FUNCTION">          GTK_WIDGET_STATE()</tt> macro.        </p>        <p>          The <span class="STRUCTNAME">name</span> of a widget is          used in a <tt class="FILENAME">gtkrc</tt> file to group          widgets together for customization purposes. By default,          the name of a widget is the type name registered with the          object system (in GTK+, this type name is always the name          of the instance struct, such as <span class="STRUCTNAME">          "GtkLabel"</span>). Particular widgets can be given a          different name with <tt class="FUNCTION">          gtk_widget_set_name()</tt>; for example, if you want a          particular label to appear in a different font, you can          give it a name like "FunkyFontLabel" and then specify a          different font for that name in a <tt class="FILENAME">          gtkrc</tt> shipped with your application.        </p>        <p>          The <span class="STRUCTNAME">requisition</span> and <span          class="STRUCTNAME">allocation</span> fields store the          last requested and allocated size of the widget,          respectively. <a href=          "sec-widgetindetail.html#SEC-SIZENEG">the section called          <i>Size Negotiation</i></a> will have more to say about          this.        </p>        <p>          The <span class="STRUCTNAME">window</span> field stores          the widget's <span class="STRUCTNAME">GdkWindow</span>,          or the widget's parent's <span class="STRUCTNAME">          GdkWindow</span> if the widget has none. The <span class=           "STRUCTNAME">parent</span> field is a pointer to the          widget's parent container; it will be <span class=           "STRUCTNAME">NULL</span> if the widget is not inside a          container.        </p>      </div>      <div class="SECT2">        <h2 class="SECT2">          <a name="Z146">The <tt class="CLASSNAME">GtkWidget</tt>          Class Struct</a>        </h2>        <p>          There are a truly huge number of class functions in <span          class="STRUCTNAME">GtkWidgetClass</span>. Thankfully, in          most cases you only have to override a few of them. Here          is the code:        </p>        <table border="0" bgcolor="#E0E0E0" width="100%">          <tr>            <td><pre class="PROGRAMLISTING">&#13;typedef struct _GtkWidgetClass GtkWidgetClass;struct _GtkWidgetClass{  GtkObjectClass parent_class;    guint activate_signal;  guint set_scroll_adjustments_signal;    /* Basics */  void (* show)                (GtkWidget      *widget);  void (* show_all)            (GtkWidget      *widget);  void (* hide)                (GtkWidget      *widget);  void (* hide_all)            (GtkWidget      *widget);  void (* map)                 (GtkWidget      *widget);  void (* unmap)               (GtkWidget      *widget);  void (* realize)             (GtkWidget      *widget);  void (* unrealize)           (GtkWidget      *widget);  void (* draw)                (GtkWidget      *widget,                                GdkRectangle   *area);  void (* draw_focus)          (GtkWidget      *widget);  void (* draw_default)        (GtkWidget      *widget);  void (* size_request)        (GtkWidget      *widget,                                GtkRequisition *requisition);  void (* size_allocate)       (GtkWidget      *widget,                                GtkAllocation  *allocation);  void (* state_changed)       (GtkWidget      *widget,                                GtkStateType    previous_state);  void (* parent_set)          (GtkWidget      *widget,                                GtkWidget      *previous_parent);  void (* style_set)           (GtkWidget      *widget,                                GtkStyle       *previous_style);    /* Accelerators */  gint (* add_accelerator)     (GtkWidget      *widget,                                guint           accel_signal_id,                                GtkAccelGroup  *accel_group,                                guint           accel_key,                                GdkModifierType accel_mods,                                GtkAccelFlags   accel_flags);  void (* remove_accelerator)  (GtkWidget      *widget,                                GtkAccelGroup  *accel_group,                                guint           accel_key,

⌨️ 快捷键说明

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