⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.10
Server IP:
157.245.101.34
Server:
Linux skvinfotech-website 5.4.0-131-generic #147-Ubuntu SMP Fri Oct 14 17:07:22 UTC 2022 x86_64
Server Software:
Apache/2.4.41 (Ubuntu)
PHP Version:
7.4.33
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
doc
/
libgtk-3-dev
/
gtk3
/
View File Name :
GtkDrawingArea.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>GtkDrawingArea: GTK+ 3 Reference Manual</title> <meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> <link rel="home" href="index.html" title="GTK+ 3 Reference Manual"> <link rel="up" href="MiscObjects.html" title="Miscellaneous"> <link rel="prev" href="GtkCalendar.html" title="GtkCalendar"> <link rel="next" href="GtkGLArea.html" title="GtkGLArea"> <meta name="generator" content="GTK-Doc V1.32 (XML mode)"> <link rel="stylesheet" href="style.css" type="text/css"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle"> <td width="100%" align="left" class="shortcuts"> <a href="#" class="shortcut">Top</a><span id="nav_description"> <span class="dim">|</span> <a href="#GtkDrawingArea.description" class="shortcut">Description</a></span><span id="nav_hierarchy"> <span class="dim">|</span> <a href="#GtkDrawingArea.object-hierarchy" class="shortcut">Object Hierarchy</a></span><span id="nav_interfaces"> <span class="dim">|</span> <a href="#GtkDrawingArea.implemented-interfaces" class="shortcut">Implemented Interfaces</a></span> </td> <td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td> <td><a accesskey="u" href="MiscObjects.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td> <td><a accesskey="p" href="GtkCalendar.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td> <td><a accesskey="n" href="GtkGLArea.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td> </tr></table> <div class="refentry"> <a name="GtkDrawingArea"></a><div class="titlepage"></div> <div class="refnamediv"><table width="100%"><tr> <td valign="top"> <h2><span class="refentrytitle"><a name="GtkDrawingArea.top_of_page"></a>GtkDrawingArea</span></h2> <p>GtkDrawingArea — A widget for custom user interface elements</p> </td> <td class="gallery_image" valign="top" align="right"></td> </tr></table></div> <div class="refsect1"> <a name="GtkDrawingArea.functions"></a><h2>Functions</h2> <div class="informaltable"><table class="informaltable" width="100%" border="0"> <colgroup> <col width="150px" class="functions_proto_type"> <col class="functions_proto_name"> </colgroup> <tbody><tr> <td class="function_type"> <a class="link" href="GtkWidget.html" title="GtkWidget"><span class="returnvalue">GtkWidget</span></a> * </td> <td class="function_name"> <a class="link" href="GtkDrawingArea.html#gtk-drawing-area-new" title="gtk_drawing_area_new ()">gtk_drawing_area_new</a> <span class="c_punctuation">()</span> </td> </tr></tbody> </table></div> </div> <div class="refsect1"> <a name="GtkDrawingArea.other"></a><h2>Types and Values</h2> <div class="informaltable"><table class="informaltable" width="100%" border="0"> <colgroup> <col width="150px" class="other_proto_type"> <col class="other_proto_name"> </colgroup> <tbody><tr> <td class="datatype_keyword">struct</td> <td class="function_name"><a class="link" href="GtkDrawingArea.html#GtkDrawingArea-struct" title="struct GtkDrawingArea">GtkDrawingArea</a></td> </tr></tbody> </table></div> </div> <div class="refsect1"> <a name="GtkDrawingArea.object-hierarchy"></a><h2>Object Hierarchy</h2> <pre class="screen"> <a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GObject-struct">GObject</a> <span class="lineart">╰──</span> <a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GInitiallyUnowned">GInitiallyUnowned</a> <span class="lineart">╰──</span> <a class="link" href="GtkWidget.html" title="GtkWidget">GtkWidget</a> <span class="lineart">╰──</span> GtkDrawingArea </pre> </div> <div class="refsect1"> <a name="GtkDrawingArea.implemented-interfaces"></a><h2>Implemented Interfaces</h2> <p> GtkDrawingArea implements AtkImplementorIface and <a class="link" href="GtkBuildable.html" title="GtkBuildable">GtkBuildable</a>.</p> </div> <div class="refsect1"> <a name="GtkDrawingArea.includes"></a><h2>Includes</h2> <pre class="synopsis">#include <gtk/gtk.h> </pre> </div> <div class="refsect1"> <a name="GtkDrawingArea.description"></a><h2>Description</h2> <p>The <a class="link" href="GtkDrawingArea.html" title="GtkDrawingArea"><span class="type">GtkDrawingArea</span></a> widget is used for creating custom user interface elements. It’s essentially a blank widget; you can draw on it. After creating a drawing area, the application may want to connect to:</p> <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"><p>Mouse and button press signals to respond to input from the user. (Use <a class="link" href="GtkWidget.html#gtk-widget-add-events" title="gtk_widget_add_events ()"><code class="function">gtk_widget_add_events()</code></a> to enable events you wish to receive.)</p></li> <li class="listitem"><p>The <a class="link" href="GtkWidget.html#GtkWidget-realize" title="The “realize” signal"><span class="type">“realize”</span></a> signal to take any necessary actions when the widget is instantiated on a particular display. (Create GDK resources in response to this signal.)</p></li> <li class="listitem"><p>The <a class="link" href="GtkWidget.html#GtkWidget-size-allocate" title="The “size-allocate” signal"><span class="type">“size-allocate”</span></a> signal to take any necessary actions when the widget changes size.</p></li> <li class="listitem"><p>The <a class="link" href="GtkWidget.html#GtkWidget-draw" title="The “draw” signal"><span class="type">“draw”</span></a> signal to handle redrawing the contents of the widget.</p></li> </ul></div> <p>The following code portion demonstrates using a drawing area to display a circle in the normal widget foreground color.</p> <p>Note that GDK automatically clears the exposed area before sending the expose event, and that drawing is implicitly clipped to the exposed area. If you want to have a theme-provided background, you need to call <a class="link" href="GtkStyleContext.html#gtk-render-background" title="gtk_render_background ()"><code class="function">gtk_render_background()</code></a> in your ::draw method.</p> <div class="refsect3"> <a name="id-1.3.19.4.8.6"></a><h4>Simple GtkDrawingArea usage</h4> <div class="informalexample"> <table class="listing_frame" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="listing_lines" align="right"><pre>1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33</pre></td> <td class="listing_code"><pre class="programlisting"><span class="n">gboolean</span> <span class="nf">draw_callback</span> <span class="p">(</span><span class="n">GtkWidget</span> <span class="o">*</span><span class="n">widget</span><span class="p">,</span> <span class="n">cairo_t</span> <span class="o">*</span><span class="n">cr</span><span class="p">,</span> <span class="n">gpointer</span> <span class="n">data</span><span class="p">)</span> <span class="p">{</span> <span class="n">guint</span> <span class="n">width</span><span class="p">,</span> <span class="n">height</span><span class="p">;</span> <span class="n">GdkRGBA</span> <span class="n">color</span><span class="p">;</span> <span class="n">GtkStyleContext</span> <span class="o">*</span><span class="n">context</span><span class="p">;</span> <span class="n">context</span> <span class="o">=</span> <span class="n">gtk_widget_get_style_context</span> <span class="p">(</span><span class="n">widget</span><span class="p">);</span> <span class="n">width</span> <span class="o">=</span> <span class="n">gtk_widget_get_allocated_width</span> <span class="p">(</span><span class="n">widget</span><span class="p">);</span> <span class="n">height</span> <span class="o">=</span> <span class="n">gtk_widget_get_allocated_height</span> <span class="p">(</span><span class="n">widget</span><span class="p">);</span> <span class="n">gtk_render_background</span> <span class="p">(</span><span class="n">context</span><span class="p">,</span> <span class="n">cr</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">width</span><span class="p">,</span> <span class="n">height</span><span class="p">);</span> <span class="n">cairo_arc</span> <span class="p">(</span><span class="n">cr</span><span class="p">,</span> <span class="n">width</span> <span class="o">/</span> <span class="mf">2.0</span><span class="p">,</span> <span class="n">height</span> <span class="o">/</span> <span class="mf">2.0</span><span class="p">,</span> <span class="n">MIN</span> <span class="p">(</span><span class="n">width</span><span class="p">,</span> <span class="n">height</span><span class="p">)</span> <span class="o">/</span> <span class="mf">2.0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span> <span class="o">*</span> <span class="n">G_PI</span><span class="p">);</span> <span class="n">gtk_style_context_get_color</span> <span class="p">(</span><span class="n">context</span><span class="p">,</span> <span class="n">gtk_style_context_get_state</span> <span class="p">(</span><span class="n">context</span><span class="p">),</span> <span class="o">&</span><span class="n">color</span><span class="p">);</span> <span class="n">gdk_cairo_set_source_rgba</span> <span class="p">(</span><span class="n">cr</span><span class="p">,</span> <span class="o">&</span><span class="n">color</span><span class="p">);</span> <span class="n">cairo_fill</span> <span class="p">(</span><span class="n">cr</span><span class="p">);</span> <span class="k">return</span> <span class="n">FALSE</span><span class="p">;</span> <span class="p">}</span> <span class="p">[...]</span> <span class="n">GtkWidget</span> <span class="o">*</span><span class="n">drawing_area</span> <span class="o">=</span> <span class="n">gtk_drawing_area_new</span> <span class="p">();</span> <span class="n">gtk_widget_set_size_request</span> <span class="p">(</span><span class="n">drawing_area</span><span class="p">,</span> <span class="mi">100</span><span class="p">,</span> <span class="mi">100</span><span class="p">);</span> <span class="n">g_signal_connect</span> <span class="p">(</span><span class="n">G_OBJECT</span> <span class="p">(</span><span class="n">drawing_area</span><span class="p">),</span> <span class="s">"draw"</span><span class="p">,</span> <span class="n">G_CALLBACK</span> <span class="p">(</span><span class="n">draw_callback</span><span class="p">),</span> <span class="nb">NULL</span><span class="p">);</span></pre></td> </tr> </tbody> </table> </div> <p></p> <p>Draw signals are normally delivered when a drawing area first comes onscreen, or when it’s covered by another window and then uncovered. You can also force an expose event by adding to the “damage region” of the drawing area’s window; <a class="link" href="GtkWidget.html#gtk-widget-queue-draw-area" title="gtk_widget_queue_draw_area ()"><code class="function">gtk_widget_queue_draw_area()</code></a> and <a href="../html/gdk3-Windows.html#gdk-window-invalidate-rect"><code class="function">gdk_window_invalidate_rect()</code></a> are equally good ways to do this. You’ll then get a draw signal for the invalid region.</p> <p>The available routines for drawing are documented on the GDK Drawing Primitives page and the cairo documentation.</p> <p>To receive mouse events on a drawing area, you will need to enable them with <a class="link" href="GtkWidget.html#gtk-widget-add-events" title="gtk_widget_add_events ()"><code class="function">gtk_widget_add_events()</code></a>. To receive keyboard events, you will need to set the “can-focus” property on the drawing area, and you should probably draw some user-visible indication that the drawing area is focused. Use <a class="link" href="GtkWidget.html#gtk-widget-has-focus" title="gtk_widget_has_focus ()"><code class="function">gtk_widget_has_focus()</code></a> in your expose event handler to decide whether to draw the focus indicator. See <a class="link" href="GtkStyleContext.html#gtk-render-focus" title="gtk_render_focus ()"><code class="function">gtk_render_focus()</code></a> for one way to draw focus.</p> </div> </div> <div class="refsect1"> <a name="GtkDrawingArea.functions_details"></a><h2>Functions</h2> <div class="refsect2"> <a name="gtk-drawing-area-new"></a><h3>gtk_drawing_area_new ()</h3> <pre class="programlisting"><a class="link" href="GtkWidget.html" title="GtkWidget"><span class="returnvalue">GtkWidget</span></a> * gtk_drawing_area_new (<em class="parameter"><code><span class="type">void</span></code></em>);</pre> <p>Creates a new drawing area.</p> <div class="refsect3"> <a name="gtk-drawing-area-new.returns"></a><h4>Returns</h4> <p> a new <a class="link" href="GtkDrawingArea.html" title="GtkDrawingArea"><span class="type">GtkDrawingArea</span></a></p> </div> </div> </div> <div class="refsect1"> <a name="GtkDrawingArea.other_details"></a><h2>Types and Values</h2> <div class="refsect2"> <a name="GtkDrawingArea-struct"></a><h3>struct GtkDrawingArea</h3> <pre class="programlisting">struct GtkDrawingArea;</pre> </div> </div> <div class="refsect1"> <a name="GtkDrawingArea.see-also"></a><h2>See Also</h2> <p><a class="link" href="GtkImage.html" title="GtkImage"><span class="type">GtkImage</span></a></p> </div> </div> <div class="footer"> <hr>Generated by GTK-Doc V1.32</div> </body> </html>