📄 gtkcontainer.html
字号:
>gchar</a> *property_name);void <a class="link" href="GtkContainer.html#gtk-container-class-install-child-property">gtk_container_class_install_child_property</a> (GtkContainerClass *cclass, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> property_id, <ahref="/usr/share/gtk-doc/html/gobject/gobject-GParamSpec.html#GParamSpec">GParamSpec</a> *pspec);<ahref="/usr/share/gtk-doc/html/gobject/gobject-GParamSpec.html#GParamSpec">GParamSpec</a>** <a class="link" href="GtkContainer.html#gtk-container-class-list-child-properties">gtk_container_class_list_child_properties</a> (<ahref="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GObjectClass">GObjectClass</a> *cclass, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> *n_properties);</pre></div><div class="refsect1" lang="en"><a name="id4253102"></a><h2>Object Hierarchy</h2><pre class="synopsis"> <ahref="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GObject">GObject</a> +----<ahref="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GInitiallyUnowned">GInitiallyUnowned</a> +----<a class="link" href="GtkObject.html" title="GtkObject">GtkObject</a> +----<a class="link" href="GtkWidget.html" title="GtkWidget">GtkWidget</a> +----GtkContainer +----<a class="link" href="GtkBin.html" title="GtkBin">GtkBin</a> +----<a class="link" href="GtkBox.html" title="GtkBox">GtkBox</a> +----<a class="link" href="GtkCList.html" title="GtkCList">GtkCList</a> +----<a class="link" href="GtkFixed.html" title="GtkFixed">GtkFixed</a> +----<a class="link" href="GtkPaned.html" title="GtkPaned">GtkPaned</a> +----<a class="link" href="GtkIconView.html" title="GtkIconView">GtkIconView</a> +----<a class="link" href="GtkLayout.html" title="GtkLayout">GtkLayout</a> +----<a class="link" href="GtkList.html" title="GtkList">GtkList</a> +----<a class="link" href="GtkMenuShell.html" title="GtkMenuShell">GtkMenuShell</a> +----<a class="link" href="GtkNotebook.html" title="GtkNotebook">GtkNotebook</a> +----<a class="link" href="GtkSocket.html" title="GtkSocket">GtkSocket</a> +----<a class="link" href="GtkTable.html" title="GtkTable">GtkTable</a> +----<a class="link" href="GtkTextView.html" title="GtkTextView">GtkTextView</a> +----<a class="link" href="GtkToolbar.html" title="GtkToolbar">GtkToolbar</a> +----<a class="link" href="GtkTree.html" title="GtkTree">GtkTree</a> +----<a class="link" href="GtkTreeView.html" title="GtkTreeView">GtkTreeView</a></pre></div><div class="refsect1" lang="en"><a name="id4253266"></a><h2>Implemented Interfaces</h2><p>GtkContainer implements AtkImplementorIface and <a class="link" href="gtk-gtkbuildable.html#GtkBuildable">GtkBuildable</a>.</p></div><div class="refsect1" lang="en"><a name="id4253296"></a><h2>Properties</h2><pre class="synopsis"> "<a class="link" href="GtkContainer.html#GtkContainer--border-width">border-width</a>" <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> : Read / Write "<a class="link" href="GtkContainer.html#GtkContainer--child">child</a>" <a class="link" href="GtkWidget.html" title="GtkWidget">GtkWidget</a> : Write "<a class="link" href="GtkContainer.html#GtkContainer--resize-mode">resize-mode</a>" <a class="link" href="gtk-Standard-Enumerations.html#GtkResizeMode">GtkResizeMode</a> : Read / Write</pre></div><div class="refsect1" lang="en"><a name="id4253364"></a><h2>Signals</h2><pre class="synopsis"> "<a class="link" href="GtkContainer.html#GtkContainer-add">add</a>" : Run First "<a class="link" href="GtkContainer.html#GtkContainer-check-resize">check-resize</a>" : Run Last "<a class="link" href="GtkContainer.html#GtkContainer-remove">remove</a>" : Run First "<a class="link" href="GtkContainer.html#GtkContainer-set-focus-child">set-focus-child</a>" : Run First</pre></div><div class="refsect1" lang="en"><a name="id4253424"></a><h2>Description</h2><p>A GTK+ user interface is constructed by nesting widgets inside widgets. Container widgets are the inner nodes in the resulting tree of widgets: they contain other widgets. So, for example, you might have a <a class="link" href="GtkWindow.html" title="GtkWindow"><span class="type">GtkWindow</span></a> containing a <a class="link" href="GtkFrame.html" title="GtkFrame"><span class="type">GtkFrame</span></a> containing a GtkLabel. If you wanted an image instead of a textual label inside the frame, you might replace the <a class="link" href="GtkLabel.html" title="GtkLabel"><span class="type">GtkLabel</span></a> widget with a <a class="link" href="GtkImage.html" title="GtkImage"><span class="type">GtkImage</span></a> widget.</p><p>There are two major kinds of container widgets in GTK+. Both are subclasses of the abstract <a class="link" href="GtkContainer.html" title="GtkContainer"><span class="type">GtkContainer</span></a> base class.</p><p>The first type of container widget has a single child widget and derives from <a class="link" href="GtkBin.html" title="GtkBin"><span class="type">GtkBin</span></a>. These containers are <em class="firstterm">decorators</em>, which add some kind of functionality to the child. For example, a <a class="link" href="GtkButton.html" title="GtkButton"><span class="type">GtkButton</span></a> makes its child into a clickable button; a <a class="link" href="GtkFrame.html" title="GtkFrame"><span class="type">GtkFrame</span></a> draws a frame around its child and a <a class="link" href="GtkWindow.html" title="GtkWindow"><span class="type">GtkWindow</span></a> places its child widget inside a top-level window.</p><p>The second type of container can have more than one child; its purpose is to manage <em class="firstterm">layout</em>. This means that these containers assign sizes and positions to their children. For example, a <a class="link" href="GtkHBox.html" title="GtkHBox"><span class="type">GtkHBox</span></a> arranges its children in a horizontal row, and a <a class="link" href="GtkTable.html" title="GtkTable"><span class="type">GtkTable</span></a> arranges the widgets it contains in a two-dimensional grid. </p><p>To fulfill its task, a layout container must negotiate the size requirements with its parent and its children. This negotiation is carried out in two phases, <em class="firstterm">size requisition</em> and <em class="firstterm">size allocation</em>. </p><div class="refsect2" lang="en"><a name="size-requisition"></a><h3>Size Requisition</h3><p>The size requisition of a widget is it's desired width and height. This is represented by a <a class="link" href="GtkWidget.html#GtkRequisition"><span class="type">GtkRequisition</span></a>.</p><p>How a widget determines its desired size depends on the widget. A <a class="link" href="GtkLabel.html" title="GtkLabel"><span class="type">GtkLabel</span></a>, for example, requests enough space to display all its text. Container widgets generally base their size request on the requisitions of their children. </p><p>The size requisition phase of the widget layout process operates top-down. It starts at a top-level widget, typically a <a class="link" href="GtkWindow.html" title="GtkWindow"><span class="type">GtkWindow</span></a>. The top-level widget asks its child for its size requisition by calling <a class="link" href="GtkWidget.html#gtk-widget-size-request"><code class="function">gtk_widget_size_request()</code></a>. To determine its requisition, the child asks its own children for their requisitions and so on. Finally, the top-level widget will get a requisition back from its child. </p></div><hr><div class="refsect2" lang="en"><a name="size-allocation"></a><h3>Size Allocation</h3><p>When the top-level widget has determined how much space its child would like to have, the second phase of the size negotiation, size allocation, begins. Depending on its configuration (see <a class="link" href="GtkWindow.html#gtk-window-set-resizable"><code class="function">gtk_window_set_resizable()</code></a>), the top-level widget may be able to expand in order to satisfy the size request or it may have to ignore the size request and keep its fixed size. It then tells its child widget how much space it gets by calling <a class="link" href="GtkWidget.html#gtk-widget-size-allocate"><code class="function">gtk_widget_size_allocate()</code></a>. The child widget divides the space among its children and tells each child how much space it got, and so on. Under normal circumstances, a <a class="link" href="GtkWindow.html" title="GtkWindow"><span class="type">GtkWindow</span></a> will always give its child the amount of space the child requested.</p><p>A child's size allocation is represented by a <a class="link" href="GtkWidget.html#GtkAllocation"><span class="type">GtkAllocation</span></a>. This struct contains not only a width and height, but also a position (i.e. X and Y coordinates), so that containers can tell their children not only how muchspace they have gotten, but also where they are positioned inside the space available to the container. </p><p>Widgets are required to honor the size allocation they receive; a size request is only a request, and widgets must be able to cope with any size.</p></div><hr><div class="refsect2" lang="en"><a name="child-properties"></a><h3>Child properties</h3><p><span class="structname">GtkContainer</span> introduces <em class="firstterm">child properties</em> - these are object properties that are not specificto either the container or the contained widget, but rather to their relation.Typical examples of child properties are the position or pack-type of a widgetwhich is contained in a <a class="link" href="GtkBox.html" title="GtkBox"><span class="type">GtkBox</span></a>.</p><p>Use <a class="link" href="GtkContainer.html#gtk-container-class-install-child-property"><code class="function">gtk_container_class_install_child_property()</code></a> to install child properties for a container class and <a class="link" href="GtkContainer.html#gtk-container-class-find-child-property"><code class="function">gtk_container_class_find_child_property()</code></a> or<a class="link" href="GtkContainer.html#gtk-container-class-list-child-properties"><code class="function">gtk_container_class_list_child_properties()</code></a> to get information about existingchild properties.</p><p>To set the value of a child property, use <a class="link" href="GtkContainer.html#gtk-container-child-set-property"><code class="function">gtk_container_child_set_property()</code></a>, <a class="link" href="GtkContainer.html#gtk-container-child-set"><code class="function">gtk_container_child_set()</code></a> or <a class="link" href="GtkContainer.html#gtk-container-child-set-valist"><code class="function">gtk_container_child_set_valist()</code></a>. To obtain the value of a child property, use <a class="link" href="GtkContainer.html#gtk-container-child-get-property"><code class="function">gtk_container_child_get_property()</code></a>, <a class="link" href="GtkContainer.html#gtk-container-child-get"><code class="function">gtk_container_child_get()</code></a> or<a class="link" href="GtkContainer.html#gtk-container-child-get-valist"><code class="function">gtk_container_child_get_valist()</code></a>. To emit notification about child property changes, use <a class="link" href="GtkWidget.html#gtk-widget-child-notify"><code class="function">gtk_widget_child_notify()</code></a>.</p></div><hr><div class="refsect2" lang="en"><a name="GtkContainer-BUILDER-UI"></a><h3>GtkContainer as GtkBuildable</h3><p>The GtkContainer implementation of the GtkBuildable interface supports a <packing> element for children, which cancontain multiple <property> elements that specifychild properties for the child.</p><div class="example"><a name="id4253898"></a><p class="title"><b>Example 45. Child properties in UI definitions</b></p><div class="example-contents"><pre class="programlisting"><object class="GtkVBox"> <child> <object class="GtkLabel"/> <packing> <property name="pack-type">start</property> </packing> </child></object></pre></div></div><br class="example-break"></div></div><div class="refsect1" lang="en"><a name="id4253916"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id4253926"></a><h3><a name="GtkContainer-struct"></a>GtkContainer</h3><a class="indexterm" name="id4253938"></a><pre class="programlisting">typedef struct _GtkContainer GtkContainer;</pre><p></p></div><hr><div class="refsect2" lang="en"><a name="id4253954"></a><h3><a name="GTK-IS-RESIZE-CONTAINER:CAPS"></a>GTK_IS_RESIZE_CONTAINER()</h3><a class="indexterm" name="id4253968"></a><pre class="programlisting">#define GTK_IS_RESIZE_CONTAINER(widget) (GTK_IS_CONTAINER (widget) && ((GtkContainer*) (widget))->resize_mode != GTK_RESIZE_PARENT)</pre><p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -