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

📄 gtkimage.html

📁 最新gtk中文资料集
💻 HTML
📖 第 1 页 / 共 5 页
字号:
   +----<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>                     +----<a class="link" href="GtkMisc.html" title="GtkMisc">GtkMisc</a>                           +----GtkImage</pre></div><div class="refsect1" lang="en"><a name="id3440081"></a><h2>Implemented Interfaces</h2><p>GtkImage implements AtkImplementorIface and  <a class="link" href="gtk-gtkbuildable.html#GtkBuildable">GtkBuildable</a>.</p></div><div class="refsect1" lang="en"><a name="id3440111"></a><h2>Properties</h2><pre class="synopsis">  "<a class="link" href="GtkImage.html#GtkImage--file">file</a>"                     <ahref="/usr/share/gtk-doc/html/gobject/gobject-Standard-Parameter-and-Value-Types.html#gchararray">gchararray</a>            : Read / Write  "<a class="link" href="GtkImage.html#GtkImage--icon-name">icon-name</a>"                <ahref="/usr/share/gtk-doc/html/gobject/gobject-Standard-Parameter-and-Value-Types.html#gchararray">gchararray</a>            : Read / Write  "<a class="link" href="GtkImage.html#GtkImage--icon-set">icon-set</a>"                 <a class="link" href="gtk-Themeable-Stock-Images.html#GtkIconSet">GtkIconSet</a>            : Read / Write  "<a class="link" href="GtkImage.html#GtkImage--icon-size">icon-size</a>"                <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a>                  : Read / Write  "<a class="link" href="GtkImage.html#GtkImage--image">image</a>"                    <ahref="/usr/share/gtk-doc/html/gdk/gdk-Images.html#GdkImage">GdkImage</a>              : Read / Write  "<a class="link" href="GtkImage.html#GtkImage--mask">mask</a>"                     <ahref="/usr/share/gtk-doc/html/gdk/gdk-Bitmaps-and-Pixmaps.html#GdkPixmap">GdkPixmap</a>             : Read / Write  "<a class="link" href="GtkImage.html#GtkImage--pixbuf">pixbuf</a>"                   <ahref="/usr/share/gtk-doc/html/gdk-pixbuf/gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf">GdkPixbuf</a>             : Read / Write  "<a class="link" href="GtkImage.html#GtkImage--pixbuf-animation">pixbuf-animation</a>"         <ahref="/usr/share/gtk-doc/html/gdk-pixbuf/gdk-pixbuf-animation.html#GdkPixbufAnimation">GdkPixbufAnimation</a>    : Read / Write  "<a class="link" href="GtkImage.html#GtkImage--pixel-size">pixel-size</a>"               <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a>                  : Read / Write  "<a class="link" href="GtkImage.html#GtkImage--pixmap">pixmap</a>"                   <ahref="/usr/share/gtk-doc/html/gdk/gdk-Bitmaps-and-Pixmaps.html#GdkPixmap">GdkPixmap</a>             : Read / Write  "<a class="link" href="GtkImage.html#GtkImage--stock">stock</a>"                    <ahref="/usr/share/gtk-doc/html/gobject/gobject-Standard-Parameter-and-Value-Types.html#gchararray">gchararray</a>            : Read / Write  "<a class="link" href="GtkImage.html#GtkImage--storage-type">storage-type</a>"             <a class="link" href="GtkImage.html#GtkImageType">GtkImageType</a>          : Read</pre></div><div class="refsect1" lang="en"><a name="id3440331"></a><h2>Description</h2><p>The <a class="link" href="GtkImage.html" title="GtkImage"><span class="type">GtkImage</span></a> widget displays an image. Various kinds of object can be displayed as an image; most typically, you would load a <ahref="/usr/share/gtk-doc/html/gdk-pixbuf/gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> ("pixel buffer") from a file, and then display that. There's a convenience function to do this, <a class="link" href="GtkImage.html#gtk-image-new-from-file"><code class="function">gtk_image_new_from_file()</code></a>,used as follows:</p><div class="informalexample"><pre class="programlisting">  GtkWidget *image;  image = gtk_image_new_from_file ("myfile.png");</pre></div><p>If the file isn't loaded successfully, the image will contain a"broken image" icon similar to that used in many web browsers.If you want to handle errors in loading the file yourself, for example by displaying an error message, then load the image with<ahref="/usr/share/gtk-doc/html/gdk-pixbuf/gdk-pixbuf-file-loading.html#gdk-pixbuf-new-from-file"><code class="function">gdk_pixbuf_new_from_file()</code></a>, then create the <a class="link" href="GtkImage.html" title="GtkImage"><span class="type">GtkImage</span></a> with <a class="link" href="GtkImage.html#gtk-image-new-from-pixbuf"><code class="function">gtk_image_new_from_pixbuf()</code></a>.</p><p>The image file may contain an animation, if so the <a class="link" href="GtkImage.html" title="GtkImage"><span class="type">GtkImage</span></a> will display an animation (<ahref="/usr/share/gtk-doc/html/gdk-pixbuf/gdk-pixbuf-animation.html#GdkPixbufAnimation"><span class="type">GdkPixbufAnimation</span></a>) instead of a static image.</p><p><a class="link" href="GtkImage.html" title="GtkImage"><span class="type">GtkImage</span></a> is a subclass of <a class="link" href="GtkMisc.html" title="GtkMisc"><span class="type">GtkMisc</span></a>, which implies that you can align it (center, left, right) and add padding to it, using <a class="link" href="GtkMisc.html" title="GtkMisc"><span class="type">GtkMisc</span></a> methods.</p><p><a class="link" href="GtkImage.html" title="GtkImage"><span class="type">GtkImage</span></a> is a "no window" widget (has no <ahref="/usr/share/gtk-doc/html/gdk/gdk-Windows.html#GdkWindow"><span class="type">GdkWindow</span></a> of its own), so by default does not receive events. If you want to receive eventson the image, such as button clicks, place the image inside a <a class="link" href="GtkEventBox.html" title="GtkEventBox"><span class="type">GtkEventBox</span></a>, then connect to the event signals on the event box.</p><div class="example"><a name="id3440497"></a><p class="title"><b>Example&#160;9.&#160;Handling button press events on a <span class="structname">GtkImage</span>.</b></p><div class="example-contents"><pre class="programlisting">  static gboolean  button_press_callback (GtkWidget      *event_box,                          GdkEventButton *event,                         gpointer        data)  {    g_print ("Event box clicked at coordinates %f,%f\n",              event-&gt;x, event-&gt;y);    /* Returning TRUE means we handled the event, so the signal      * emission should be stopped (don't call any further      * callbacks that may be connected). Return FALSE     * to continue invoking callbacks.     */    return TRUE;  }  static GtkWidget*  create_image (void)  {    GtkWidget *image;    GtkWidget *event_box;    image = gtk_image_new_from_file ("myfile.png");    event_box = gtk_event_box_new ();    gtk_container_add (GTK_CONTAINER (event_box), image);    g_signal_connect (G_OBJECT (event_box),                       "button_press_event",                      G_CALLBACK (button_press_callback),                      image);    return image;  }</pre></div></div><p><br class="example-break"></p><p>When handling events on the event box, keep in mind that coordinatesin the image may be different from event box coordinates due to the alignment and padding settings on the image (see <a class="link" href="GtkMisc.html" title="GtkMisc"><span class="type">GtkMisc</span></a>). The simplest way to solve this is to set the alignment to 0.0(left/top), and set the padding to zero. Then the origin of the image will be the same as the origin of the event box.</p><p>Sometimes an application will want to avoid depending on external datafiles, such as image files. GTK+ comes with a program to avoid this,called <span class="application">gdk-pixbuf-csource</span>. This programallows you to convert an image into a C variable declaration, whichcan then be loaded into a <ahref="/usr/share/gtk-doc/html/gdk-pixbuf/gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> using<ahref="/usr/share/gtk-doc/html/gdk-pixbuf/gdk-pixbuf-creating.html#gdk-pixbuf-new-from-inline"><code class="function">gdk_pixbuf_new_from_inline()</code></a>.</p></div><div class="refsect1" lang="en"><a name="id3440584"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id3440595"></a><h3><a name="GtkImage-struct"></a>GtkImage</h3><a class="indexterm" name="id3440607"></a><pre class="programlisting">typedef struct _GtkImage GtkImage;</pre><p>This struct contain private data only and should be accessed by the functionsbelow.</p></div><hr><div class="refsect2" lang="en"><a name="id3440623"></a><h3><a name="GtkImageType"></a>enum GtkImageType</h3><a class="indexterm" name="id3440636"></a><pre class="programlisting">typedef enum{  GTK_IMAGE_EMPTY,  GTK_IMAGE_PIXMAP,  GTK_IMAGE_IMAGE,  GTK_IMAGE_PIXBUF,  GTK_IMAGE_STOCK,  GTK_IMAGE_ICON_SET,  GTK_IMAGE_ANIMATION,  GTK_IMAGE_ICON_NAME} GtkImageType;</pre><p>Describes the image data representation used by a <a class="link" href="GtkImage.html" title="GtkImage"><span class="type">GtkImage</span></a>. If youwant to get the image from the widget, you can only get thecurrently-stored representation. e.g.  if the<a class="link" href="GtkImage.html#gtk-image-get-storage-type"><code class="function">gtk_image_get_storage_type()</code></a> returns <a class="link" href="GtkImage.html#GTK-IMAGE-PIXBUF:CAPS"><span class="type">GTK_IMAGE_PIXBUF</span></a>, then you cancall <a class="link" href="GtkImage.html#gtk-image-get-pixbuf"><code class="function">gtk_image_get_pixbuf()</code></a> but not <a class="link" href="GtkImage.html#gtk-image-get-stock"><code class="function">gtk_image_get_stock()</code></a>.  For emptyimages, you can request any storage type (call any of the "get"functions), but they will all return <ahref="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL:CAPS"><code class="literal">NULL</code></a> values.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><a name="GTK-IMAGE-EMPTY:CAPS"></a><code class="literal">GTK_IMAGE_EMPTY</code></span></p></td><td>there is no image displayed by the widget</td></tr><tr><td><p><span class="term"><a name="GTK-IMAGE-PIXMAP:CAPS"></a><code class="literal">GTK_IMAGE_PIXMAP</code></span></p></td><td>the widget contains a <ahref="/usr/share/gtk-doc/html/gdk/gdk-Bitmaps-and-Pixmaps.html#GdkPixmap"><span class="type">GdkPixmap</span></a></td></tr><tr><td><p><span class="term"><a name="GTK-IMAGE-IMAGE:CAPS"></a><code class="literal">GTK_IMAGE_IMAGE</code></span></p></td><td>the widget contains a <ahref="/usr/share/gtk-doc/html/gdk/gdk-Images.html#GdkImage"><span class="type">GdkImage</span></a></td></tr><tr><td><p><span class="term"><a name="GTK-IMAGE-PIXBUF:CAPS"></a><code class="literal">GTK_IMAGE_PIXBUF</code></span></p></td><td>the widget contains a <ahref="/usr/share/gtk-doc/html/gdk-pixbuf/gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a></td></tr><tr><td><p><span class="term"><a name="GTK-IMAGE-STOCK:CAPS"></a><code class="literal">GTK_IMAGE_STOCK</code></span></p></td><td>the widget contains a stock icon name (see <a class="xref" href="gtk-Stock-Items.html" title="Stock Items"><a name="id3208400"></a><span class="refentrytitle">Stock Items</span>(3)</a>)</td></tr><tr><td><p><span class="term"><a name="GTK-IMAGE-ICON-SET:CAPS"></a><code class="literal">GTK_IMAGE_ICON_SET</code></span></p></td><td>the widget contains a <a class="link" href="gtk-Themeable-Stock-Images.html#GtkIconSet"><span class="type">GtkIconSet</span></a></td></tr>

⌨️ 快捷键说明

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