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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
<title>GTK+ Foundation Classes</title>
<link href="gfc.css" rel="stylesheet" type="text/css">
<meta content="The GFC Development Team" name="author">
<meta content="Core Library Reference Manual" name="description">
</head>
<body style="color: rgb(0, 0, 0); background-color: rgb(243, 244, 248);"
alink="#000099" link="#000099" vlink="#990099">
<table style="text-align: left; width: 1227px; height: 117px;"
border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td
style="text-align: center; background-color: rgb(255, 255, 255); width: 220px; vertical-align: top;"><img
alt="GFC Logo" src="../images/gfc.png"
style="width: 207px; height: 92px;"></td>
<td
style="text-align: center; background-color: rgb(87, 107, 152); vertical-align: middle;"><img
alt="GFC Title Logo" src="../images/gfc-title.png"
style="width: 418px; height: 76px;"><br>
</td>
</tr>
<tr>
<td
style="text-align: center; background-color: rgb(65, 77, 104); vertical-align: middle;"><big><span
style="color: rgb(255, 255, 153); font-weight: bold;">Reference Manual</span></big><br>
</td>
<td
style="text-align: center; background-color: rgb(148, 164, 200); vertical-align: middle;"><small
style="font-family: helvetica,arial,sans-serif;"><a
href="../html/index.html">Main Page</a> | <a
href="../html/namespaces.html">Namespace List</a> | <a
href="classes.html">Alphabetical List</a> | <a
href="../html/annotated.html">Class List</a> | <a
href="../html/files.html">File List</a></small><br>
</td>
</tr>
</tbody>
</table>
<small> </small>
</body>
</html>
<!-- Generated by Doxygen 1.3.8 -->
<h1>GFC::Gtk::DrawingArea Class Reference</h1>A GtkDrawingArea C++ wrapper class.
<a href="#_details">More...</a>
<p>
<code>#include <<a class="el" href="drawingarea_8hh-source.html">gfc/gtk/drawingarea.hh</a>></code>
<p>
<p>Inheritance diagram for GFC::Gtk::DrawingArea:
<p><center><img src="classGFC_1_1Gtk_1_1DrawingArea.png" usemap="#GFC::Gtk::DrawingArea_map" border="0" alt=""></center>
<map name="GFC::Gtk::DrawingArea_map">
<area href="classGFC_1_1Gtk_1_1Widget.html" alt="GFC::Gtk::Widget" shape="rect" coords="76,224,219,248">
<area href="classGFC_1_1Gtk_1_1Object.html" alt="GFC::Gtk::Object" shape="rect" coords="0,168,143,192">
<area href="classGFC_1_1Atk_1_1Implementor.html" alt="GFC::Atk::Implementor" shape="rect" coords="153,168,296,192">
<area doxygen="gfccore.tag:" href="classGFC_1_1G_1_1Object.html" alt="GFC::G::Object" shape="rect" coords="0,112,143,136">
<area doxygen="gfccore.tag:" href="classGFC_1_1G_1_1TypeInterface.html" alt="GFC::G::TypeInterface" shape="rect" coords="153,112,296,136">
<area doxygen="gfccore.tag:" href="classGFC_1_1G_1_1TypeInstance.html" alt="GFC::G::TypeInstance" shape="rect" coords="0,56,143,80">
<area doxygen="gfccore.tag:" href="classGFC_1_1G_1_1TypeInstance.html" alt="GFC::G::TypeInstance" shape="rect" coords="153,56,296,80">
<area doxygen="gfccore.tag:" href="classGFC_1_1Trackable.html" alt="GFC::Trackable" shape="rect" coords="0,0,143,24">
<area doxygen="gfccore.tag:" href="classGFC_1_1Trackable.html" alt="GFC::Trackable" shape="rect" coords="153,0,296,24">
<area href="classGFC_1_1Gtk_1_1Curve.html" alt="GFC::Gtk::Curve" shape="rect" coords="76,336,219,360">
</map>
<a href="classGFC_1_1Gtk_1_1DrawingArea-members.html">List of all members.</a><h2>Public Member Functions</h2>
<tr><td colspan="2"><div class="groupHeader">Constructors</div></td></tr>
<ul>
<li><a class="anchor" name="z487_0" doxytag="GFC::Gtk::DrawingArea::DrawingArea" ></a>
<a class="el" href="classGFC_1_1Gtk_1_1DrawingArea.html#z487_0">DrawingArea</a> ()
<dl class="el"><dd class="mdescRight">Construct a new <a class="el" href="classGFC_1_1Gtk_1_1DrawingArea.html">DrawingArea</a>. <br></dl><li><a class="el" href="classGFC_1_1Gtk_1_1DrawingArea.html#z487_1">DrawingArea</a> (int width, int height)
<dl class="el"><dd class="mdescRight">Construct a new <a class="el" href="classGFC_1_1Gtk_1_1DrawingArea.html">DrawingArea</a> with the specified width and height. <a href="#z487_1"></a><br></dl><li><a class="anchor" name="z487_2" doxytag="GFC::Gtk::DrawingArea::~DrawingArea" ></a>
virtual <a class="el" href="classGFC_1_1Gtk_1_1DrawingArea.html#z487_2">~DrawingArea</a> ()
<dl class="el"><dd class="mdescRight">Destructor. <br></dl></ul>
<tr><td colspan="2"><div class="groupHeader">Accessors</div></td></tr>
<ul>
<li><a class="anchor" name="z488_0" doxytag="GFC::Gtk::DrawingArea::gtk_drawing_area" ></a>
GtkDrawingArea * <a class="el" href="classGFC_1_1Gtk_1_1DrawingArea.html#z488_0">gtk_drawing_area</a> () const
<dl class="el"><dd class="mdescRight">Get a pointer to the GtkDrawingArea structure. <br></dl><li><a class="anchor" name="z488_1" doxytag="GFC::Gtk::DrawingArea::operator GtkDrawingArea *" ></a>
<a class="el" href="classGFC_1_1Gtk_1_1DrawingArea.html#z488_1">operator GtkDrawingArea *</a> () const
<dl class="el"><dd class="mdescRight">Conversion operator; safely converts a <a class="el" href="classGFC_1_1Gtk_1_1DrawingArea.html">DrawingArea</a> to a GtkDrawingArea pointer. <br></dl></ul>
<h2>Protected Member Functions</h2>
<tr><td colspan="2"><div class="groupHeader">Constructors</div></td></tr>
<ul>
<li><a class="el" href="classGFC_1_1Gtk_1_1DrawingArea.html#z486_0">DrawingArea</a> (GtkDrawingArea *drawing_area, bool <a class="elRef" doxygen="gfccore.tag:" href="classGFC_1_1Trackable.html#z143_1">owns_reference</a>=false)
<dl class="el"><dd class="mdescRight">Construct a new <a class="el" href="classGFC_1_1Gtk_1_1DrawingArea.html">DrawingArea</a> from an existing GtkDrawingArea. <a href="#z486_0"></a><br></dl></ul>
<hr><a name="_details"></a><h2>Detailed Description</h2>
A GtkDrawingArea C++ wrapper class.
<p>
The <a class="el" href="classGFC_1_1Gtk_1_1DrawingArea.html">DrawingArea</a> widget is used for creating custom user interface elements. It's essentially a blank widget you can draw on. After creating a drawing area, the application may want to connect to mouse and button press signals to respond to input from the user. Use <a class="el" href="classGFC_1_1Gtk_1_1Widget.html#z1053_58">Gtk::Widget::add_events()</a> to enable events you wish to receive. Connect to the "realize" signal to take any necessary actions when the widget is instantiated on a particular display. (Create GDK resources in response to this signal.) Connect to the "configure_event" signal to take any necessary actions when the widget changes size. Connect to the "expose_event" signal to handle redrawing the contents of the widget.<p>
The following code portion demonstrates using a drawing area to display a circle in the normal widget foreground color. Note that GDK automatically clears the exposed area to the background color before sending the expose event, and that drawing is implicitly clipped to the exposed area.<p>
<b>Example:</b> Simple <a class="el" href="classGFC_1_1Gtk_1_1DrawingArea.html">DrawingArea</a> usage. <div class="fragment"><pre><span class="preprocessor"> #include <gfc/main.h></span>
<span class="preprocessor"> #include <gfc/gtk/drawingarea.h></span>
<span class="preprocessor"> #include <gfc/gtk/style.h></span>
<span class="preprocessor"> #include <gfc/gtk/window.h></span>
<span class="preprocessor"> #include <gfc/gdk/window.h></span>
<span class="keyword">using</span> <span class="keyword">namespace </span>GFC;
<span class="keyword">class </span>Window : <span class="keyword">public</span> Gtk::Window
{
Gtk::DrawingArea *area;
<span class="keyword">protected</span>:
<span class="keywordtype">bool</span> on_area_expose_event(GdkEventExpose *event);
<span class="keyword">public</span>:
Window();
};
Window::Window()
{
area = <span class="keyword">new</span> Gtk::DrawingArea(100, 100);
area->sig_expose_event().connect(slot(<span class="keyword">this</span>, &Window::on_area_expose_event));
add(*area);
area->show();
}
<span class="keywordtype">bool</span>
Window::on_area_expose_event(GdkEventExpose *event)
{
area->get_window()->draw_arc(*area->get_style()->fg_gc(area->get_state()), <span class="comment">// context</span>
0, 0, <span class="comment">// x, y,</span>
area->get_allocation().width, <span class="comment">// width</span>
area->get_allocation().height, <span class="comment">// height</span>
0, 64 * 360); <span class="comment">// angle1, angle2</span>
<span class="keywordflow">return</span> <span class="keyword">true</span>;
}
<span class="keywordtype">int</span> main (<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])
{
<span class="keyword">using</span> <span class="keyword">namespace </span>Main;
<a class="code" href="namespaceGFC_1_1Main.html#a2">init</a>(&argc, &argv);
Window window;
window.sig_destroy().connect(slot(&GFC::Main::quit));
window->show();
<a class="code" href="namespaceGFC_1_1Main.html#a11">run</a>();
<span class="keywordflow">return</span> 0;
}
</pre></div><p>
Expose events are normally delivered when a drawing area first comes onscreen, or when it's covered by another window and then uncovered (exposed). You can also force an expose event by adding to the "damage region" of the drawing area's window; <a class="el" href="classGFC_1_1Gtk_1_1Widget.html#z1053_15">Gtk::Widget::queue_draw_area()</a> and Gdk::Window::invalidate_rect() are equally good ways to do this. You'll then get an expose event for the invalid region. (See also Gdk::Pixbuf::render_to_drawable() for drawing a <a class="el" href="classGFC_1_1Gdk_1_1Pixbuf.html">Gdk::Pixbuf</a>.)<p>
To receive mouse events on a drawing area, you will need to enable them with <a class="el" href="classGFC_1_1Gtk_1_1Widget.html#z1053_58">Gtk::Widget::add_events()</a>. To receive keyboard events, you will need to set the CAN_FOCUS flag on the drawing area, and should probably draw some user-visible indication that the drawing area is focused. Use <a class="el" href="classGFC_1_1Gtk_1_1Widget.html#z1052_12">Gtk::Widget::has_focus()</a> in your expose event handler to decide whether to draw the focus indicator. (See <a class="el" href="classGFC_1_1Gtk_1_1Style.html#z850_20">Gtk::Style::draw_focus()</a> for one way to draw the focus.)
<p>
<hr><h2>Constructor & Destructor Documentation</h2>
<a class="anchor" name="z486_0" doxytag="GFC::Gtk::DrawingArea::DrawingArea" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> GFC::Gtk::DrawingArea::DrawingArea </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">GtkDrawingArea * </td>
<td class="mdname" nowrap> <em>drawing_area</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>bool </td>
<td class="mdname" nowrap> <em>owns_reference</em> = <code>false</code></td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"><code> [explicit, protected]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Construct a new <a class="el" href="classGFC_1_1Gtk_1_1DrawingArea.html">DrawingArea</a> from an existing GtkDrawingArea.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td></td><td valign=top><em>drawing_area</em> </td><td>A pointer to a GtkDrawingArea. </td></tr>
<tr><td></td><td valign=top><em>owns_reference</em> </td><td>Set false if the initial reference count is floating, set true if it's not.</td></tr>
</table>
</dl>
<br>
The <em>drawing_area</em> can be a newly created GtkDrawingArea or an existing GtkDrawingArea (see <a class="elRef" doxygen="gfccore.tag:" href="classGFC_1_1G_1_1Object.html#z68_0">G::Object::Object</a>). </td>
</tr>
</table>
<a class="anchor" name="z487_1" doxytag="GFC::Gtk::DrawingArea::DrawingArea" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> GFC::Gtk::DrawingArea::DrawingArea </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">int </td>
<td class="mdname" nowrap> <em>width</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>int </td>
<td class="mdname" nowrap> <em>height</em></td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Construct a new <a class="el" href="classGFC_1_1Gtk_1_1DrawingArea.html">DrawingArea</a> with the specified width and height.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td></td><td valign=top><em>width</em> </td><td>The width to request. </td></tr>
<tr><td></td><td valign=top><em>height</em> </td><td>The height to request. </td></tr>
</table>
</dl>
</td>
</tr>
</table>
<hr>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="drawingarea_8hh-source.html">drawingarea.hh</a></ul>
<hr size="1"><address style="align: right;"><small>Generated on Tue Aug 24 00:34:39 2004 for GFC-UI by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 ></a> 1.3.8 </small></address>
</body>
</html>
|