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

📄 z166.html

📁 gtk_text program sample&eg
💻 HTML
📖 第 1 页 / 共 2 页
字号:
  nvis_children = 0;  nexpand_children = 0;  children = box-&gt;children;  while (children)    {      child = children-&gt;data;      children = children-&gt;next;      if (GTK_WIDGET_VISIBLE (child-&gt;widget))        {          nvis_children += 1;          if (child-&gt;expand)            nexpand_children += 1;        }    }  if (nvis_children &gt; 0)    {      if (box-&gt;homogeneous)        {          height = (allocation-&gt;height -                   GTK_CONTAINER (box)-&gt;border_width * 2 -                   (nvis_children - 1) * box-&gt;spacing);          extra = height / nvis_children;        }      else if (nexpand_children &gt; 0)        {          height = (gint) allocation-&gt;height - (gint) widget-&gt;requisition.height;          extra = height / nexpand_children;        }      else        {          height = 0;          extra = 0;        }      y = allocation-&gt;y + GTK_CONTAINER (box)-&gt;border_width;      child_allocation.x = allocation-&gt;x + GTK_CONTAINER (box)-&gt;border_width;      child_allocation.width = MAX (1, (gint) allocation-&gt;width - (gint) GTK_CONTAINER (box)-&gt;border_width * 2);      children = box-&gt;children;      while (children)        {          child = children-&gt;data;          children = children-&gt;next;          if ((child-&gt;pack == GTK_PACK_START) &amp;&amp; GTK_WIDGET_VISIBLE (child-&gt;widget))            {              if (box-&gt;homogeneous)                {                  if (nvis_children == 1)                    child_height = height;                  else                    child_height = extra;                  nvis_children -= 1;                  height -= extra;                }              else                {                  GtkRequisition child_requisition;                  gtk_widget_get_child_requisition (child-&gt;widget, &amp;child_requisition);                  child_height = child_requisition.height + child-&gt;padding * 2;                  if (child-&gt;expand)                    {                      if (nexpand_children == 1)                        child_height += height;                      else                        child_height += extra;                      nexpand_children -= 1;                      height -= extra;                    }                }              if (child-&gt;fill)                {                  child_allocation.height = MAX (1, child_height - (gint)child-&gt;padding * 2);                  child_allocation.y = y + child-&gt;padding;                }              else                {                  GtkRequisition child_requisition;                  gtk_widget_get_child_requisition (child-&gt;widget, &amp;child_requisition);                  child_allocation.height = child_requisition.height;                  child_allocation.y = y + (child_height - child_allocation.height) / 2;                }              gtk_widget_size_allocate (child-&gt;widget, &amp;child_allocation);              y += child_height + box-&gt;spacing;            }        }      y = allocation-&gt;y + allocation-&gt;height - GTK_CONTAINER (box)-&gt;border_width;      children = box-&gt;children;      while (children)        {          child = children-&gt;data;          children = children-&gt;next;          if ((child-&gt;pack == GTK_PACK_END) &amp;&amp; GTK_WIDGET_VISIBLE (child-&gt;widget))            {              GtkRequisition child_requisition;              gtk_widget_get_child_requisition (child-&gt;widget, &amp;child_requisition);              if (box-&gt;homogeneous)                {                  if (nvis_children == 1)                    child_height = height;                  else                    child_height = extra;                  nvis_children -= 1;                  height -= extra;                }              else                {                  child_height = child_requisition.height + child-&gt;padding * 2;                  if (child-&gt;expand)                    {                      if (nexpand_children == 1)                        child_height += height;                      else                        child_height += extra;                      nexpand_children -= 1;                      height -= extra;                    }                }              if (child-&gt;fill)                {                  child_allocation.height = MAX (1, child_height - (gint)child-&gt;padding * 2);                  child_allocation.y = y + child-&gt;padding - child_height;                }              else                {                  child_allocation.height = child_requisition.height;                  child_allocation.y = y + (child_height - child_allocation.height) / 2 - child_height;                }              gtk_widget_size_allocate (child-&gt;widget, &amp;child_allocation);              y -= (child_height + box-&gt;spacing);            }        }    }}      </pre>            </td>          </tr>        </table>      </div>      <div class="SECT2">        <h2 class="SECT2">          <a name="Z169">Child Arguments</a>        </h2>        <p>          <tt class="CLASSNAME">GtkBox</tt> implements <i class=           "FIRSTTERM">child arguments</i>, which were briefly          described in <a href="hc-objectargs.html#SEC-GETSETARG">          the section called <i>Using Object Arguments in Your Own          <span class="STRUCTNAME">GtkObject</span> Subclass</i> in          the chapter called <i>The GTK+ Object and Type          System</i></a>. Child arguments represent a property of a          pair of objects. In this case, the box-packing flags for          each child can be read and written using the object          argument system.        </p>        <p>          Here's how <tt class="CLASSNAME">GtkBox</tt> registers          its child arguments, in <tt class="FUNCTION">          gtk_box_class_init()</tt>:        </p>        <table border="0" bgcolor="#E0E0E0" width="100%">          <tr>            <td><pre class="PROGRAMLISTING">&#13;  gtk_container_add_child_arg_type ("GtkBox::expand", GTK_TYPE_BOOL, GTK_ARG_READWRITE, CHILD_ARG_EXPAND);  gtk_container_add_child_arg_type ("GtkBox::fill", GTK_TYPE_BOOL, GTK_ARG_READWRITE, CHILD_ARG_FILL);  gtk_container_add_child_arg_type ("GtkBox::padding", GTK_TYPE_ULONG, GTK_ARG_READWRITE, CHILD_ARG_PADDING);  gtk_container_add_child_arg_type ("GtkBox::pack_type", GTK_TYPE_PACK_TYPE, GTK_ARG_READWRITE, CHILD_ARG_PACK_TYPE);  gtk_container_add_child_arg_type ("GtkBox::position", GTK_TYPE_LONG, GTK_ARG_READWRITE, CHILD_ARG_POSITION);      </pre>            </td>          </tr>        </table>        <p>          <tt class="CLASSNAME">GtkBox</tt> then implements the          <span class="STRUCTNAME">get_child_arg</span> and <span          class="STRUCTNAME">set_child_arg</span> methods from          <span class="STRUCTNAME">GtkContainerClass</span>. Here's          <tt class="FUNCTION">gtk_box_get_child_arg()</tt>; the          <tt class="FUNCTION">gtk_box_set_child_arg()</tt> is          analagous.        </p>        <table border="0" bgcolor="#E0E0E0" width="100%">          <tr>            <td><pre class="PROGRAMLISTING">&#13;static voidgtk_box_get_child_arg (GtkContainer   *container,                       GtkWidget      *child,                       GtkArg         *arg,                       guint           arg_id){  gboolean expand = 0;  gboolean fill = 0;  guint padding = 0;  GtkPackType pack_type = 0;  GList *list;  if (arg_id != CHILD_ARG_POSITION)    gtk_box_query_child_packing (GTK_BOX (container),                                 child,                                 &amp;expand,                                 &amp;fill,                                 &amp;padding,                                 &amp;pack_type);    switch (arg_id)    {    case CHILD_ARG_EXPAND:      GTK_VALUE_BOOL (*arg) = expand;      break;    case CHILD_ARG_FILL:      GTK_VALUE_BOOL (*arg) = fill;      break;    case CHILD_ARG_PADDING:      GTK_VALUE_ULONG (*arg) = padding;      break;    case CHILD_ARG_PACK_TYPE:      GTK_VALUE_ENUM (*arg) = pack_type;      break;    case CHILD_ARG_POSITION:      GTK_VALUE_LONG (*arg) = 0;      for (list = GTK_BOX (container)-&gt;children; list; list = list-&gt;next)        {          GtkBoxChild *child_entry;          child_entry = list-&gt;data;          if (child_entry-&gt;widget == child)            break;          GTK_VALUE_LONG (*arg)++;        }      if (!list)        GTK_VALUE_LONG (*arg) = -1;      break;    default:      arg-&gt;type = GTK_TYPE_INVALID;      break;    }}      </pre>            </td>          </tr>        </table>      </div>    </div>    <div class="NAVFOOTER">      <br>      <br>      <table width="100%" border="0" bgcolor="#ffffff" cellpadding=       "1" cellspacing="0">        <tr>          <td width="25%" bgcolor="#ffffff" align="left">            <a href="sec-widgetindetail.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="z170.html"><font color="#0000ff" size="2"><b>            Next &gt;&gt;&gt;</b></font></a>          </td>        </tr>        <tr>          <td colspan="2" align="left">            <font color="#000000" size="2"><b><tt class=            "CLASSNAME">GtkWidget</tt> In Detail</b></font>          </td>          <td colspan="2" align="right">            <font color="#000000" size="2"><b><tt class=            "CLASSNAME">GnomeAppBar</tt>: A Trivial Composite            Widget</b></font>          </td>        </tr>      </table>    </div>  </body></html>

⌨️ 快捷键说明

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