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
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>
GDK Basics
</title>
<meta name="GENERATOR" content=
"Modular DocBook HTML Stylesheet Version 1.45">
<link rel="HOME" title="GTK+ / Gnome Application Development"
href="ggad.html">
<link rel="UP" title="Advanced GTK+/Gnome Techniques" href=
"advanced.html">
<link rel="PREVIOUS" title="Attaching Data to Objects" href=
"sec-objectdata.html">
<link rel="NEXT" title="GdkWindow" href="sec-gdkwindow.html">
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink=
"#840084" alink="#0000FF">
<div class="NAVHEADER">
<table width="100%" border="0" bgcolor="#ffffff" cellpadding=
"1" cellspacing="0">
<tr>
<th colspan="4" align="center">
<font color="#000000" size="2">GTK+ / Gnome Application
Development</font>
</th>
</tr>
<tr>
<td width="25%" bgcolor="#ffffff" align="left">
<a href="sec-objectdata.html"><font color="#0000ff"
size="2"><b><<< 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="sec-gdkwindow.html"><font color="#0000ff"
size="2"><b>Next >>></b></font></a>
</td>
</tr>
</table>
</div>
<div class="CHAPTER">
<h1>
<a name="CHA-GDK">GDK Basics</a>
</h1>
<div class="TOC">
<dl>
<dt>
<b>Table of Contents</b>
</dt>
<dt>
<a href="cha-gdk.html#Z112">GDK and Xlib</a>
</dt>
<dt>
<a href="sec-gdkwindow.html"><span class="STRUCTNAME">
GdkWindow</span></a>
</dt>
<dt>
<a href="sec-gdkvisual.html">Visuals and Colormaps</a>
</dt>
<dt>
<a href="sec-gdkdrawable.html">Drawables and
Pixmaps</a>
</dt>
<dt>
<a href="sec-gdkevent.html">Events</a>
</dt>
<dt>
<a href="sec-gdkcursor.html">The Mouse Pointer</a>
</dt>
<dt>
<a href="sec-gdkfont.html">Fonts</a>
</dt>
<dt>
<a href="sec-gc.html">Graphics Contexts</a>
</dt>
<dt>
<a href="z132.html">Drawing</a>
</dt>
<dt>
<a href="sec-gdkresourcemgmt.html">GDK Resource
Management</a>
</dt>
<dt>
<a href="sec-style.html"><span class="STRUCTNAME">
GtkStyle</span> and Themes</a>
</dt>
</dl>
</div>
<p>
This chapter will discuss GDK, the underpinning of GTK+,
and some of the occasions you might have to use it. To
write custom widgets and canvas items, you will need to
understand a few of these low-level details. Like chapters
two and three, this chapter is a quick summary that doesn't
hold your hand; there is no way to cover all of GDK in a
single chapter. However, the chapter will try to cover the
important concepts and data types of GDK, and should be a
useful reference on certain topics. As details come up in
later chapters, you can use this background to understand
them. This chapter does not attempt to exhaustively catalog
GDK's API.
</p>
<div class="SECT1">
<h1 class="SECT1">
<a name="Z112">GDK and Xlib</a>
</h1>
<p>
The X Window System comes with a low-level and thoroughly
unpleasant library called Xlib. Almost every function in
GDK is a very thin wrapper around a corresponding Xlib
function; but some of the complexity (and functionality)
of Xlib is hidden, to simplify programming and to make
GDK easier to port to other windowing systems. (There is
a port of GDK to Windows available.) The concealed Xlib
functionality will rarely be of interest to application
programmers; for example, many features used only by
window managers are not exposed in GDK. If necessary, you
can use Xlib directly in your application by including
the special <tt class="FILENAME">gdk/gdkx.h</tt> header
file. (Check out the GDK source code to see how to
extract the low-level Xlib data structures from their GDK
wrappers.)
</p>
<p>
If you need excruciating details on a GDK function, you
can typically glance at the source to determine the Xlib
function it wraps, and then read the man page for the
Xlib function. For example, here is the implementation of
<tt class="FUNCTION">gdk_draw_point()</tt>:
</p>
<table border="0" bgcolor="#E0E0E0" width="100%">
<tr>
<td>
<pre class="PROGRAMLISTING">
void
gdk_draw_point (GdkDrawable *drawable,
GdkGC *gc,
gint x,
gint y)
{
GdkWindowPrivate *drawable_private;
GdkGCPrivate *gc_private;
g_return_if_fail (drawable != NULL);
g_return_if_fail (gc != NULL);
drawable_private = (GdkWindowPrivate*) drawable;
if (drawable_private->destroyed)
return;
gc_private = (GdkGCPrivate*) gc;
XDrawPoint (drawable_private->xdisplay, drawable_private->xwindow,
gc_private->xgc, x, y);
}
</pre>
</td>
</tr>
</table>
<p>
Each data structure is cast to its "private" version,
which contains information relating to the particular
window system GDK is being used on; this is to keep
window-system-specific declarations out of the <tt class=
"FILENAME">gdk/gdk.h</tt> header file. The private
version of each data structure contains a wrapped Xlib
data structure, which is passed to <tt class="FUNCTION">
XDrawPoint()</tt>. So the <tt class="FUNCTION">
XDrawPoint()</tt> documentation will also apply to <tt
class="FUNCTION">gdk_draw_point()</tt>.
</p>
</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-objectdata.html"><font color="#0000ff"
size="2"><b><<< 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="sec-gdkwindow.html"><font color="#0000ff"
size="2"><b>Next >>></b></font></a>
</td>
</tr>
<tr>
<td colspan="2" align="left">
<font color="#000000" size="2"><b>Attaching Data to
Objects</b></font>
</td>
<td colspan="2" align="right">
<font color="#000000" size="2"><b><span class=
"STRUCTNAME">GdkWindow</span></b></font>
</td>
</tr>
</table>
</div>
</body>
</html>
|