]> Pileus Git - ~andy/gtk/blob - docs/gdk.texi
4e4b84f5d7bb23e5d0fbd13417c8b2c09cc60b0c
[~andy/gtk] / docs / gdk.texi
1 \input texinfo @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename gdk.info
4 @settitle GDK
5 @setchapternewpage odd
6 @c %**end of header
7
8 @set edition 1.0
9 @set update-date 16 May 1996
10 @set update-month May 1996
11
12 @ifinfo
13 This file documents GDK, the General Drawing Kit
14
15 Copyright (C) 1996 Peter Mattis
16
17 Permission is granted to make and distribute verbatim copies of this
18 manual provided the copyright notice and this permission notice are
19 preserved on all copies
20
21 @ignore
22 Permission is granted to process this file throught TeX and print the
23 results, provided the printed document carries copying permission notice
24 identical to this one except for the removal of this paragraph (this
25 paragraph not being relevant to the printed manual).
26
27 @end ignore
28 Permission is granted to copy and distribute modified versions of this
29 manual under the conditions for verbatim copying, provided that the
30 entire resulting derived work is distributed under the terms of a
31 permission notice identical to this one.
32
33 Permission is granted to copy and distribute translations of this manual
34 into another language, under the above conditions for modified versions,
35 except that this permission notice may be stated in a translation
36 approved by Peter Mattis.
37 @end ifinfo
38
39 @titlepage
40 @title The General Drawing Kit
41 @subtitle Version 1.0
42 @subtitle @value{update-month}
43 @author by Peter Mattis
44
45 @page
46 @vskip 0pt plus 1filll
47 Copyright @copyright{} 1996 Peter Mattis
48
49 Permission is granted to make and distribute verbatim copies of this
50 manual provided the copyright notice and this permission notice are
51 preserved on all copies.
52
53 Permission is granted to copy and distribute modified versions of this
54 manual under the conditions for verbatim copying, provided that the
55 entire resulting derived work is distributed under the terms of a
56 permission notice identical to this one.
57
58 Permission is granted to copy and distribute translations of this manual
59 into another language, under the above conditions for modified versions,
60 except that this permission notice may be stated in a translation
61 approved by Peter Mattis.
62 @end titlepage
63
64 @dircategory User Interface Toolkit
65 @direntry
66 * GDK: (gdk).           The General Drawing Kit
67 @end direntry
68
69 @node Top, Copying, (dir), (dir)
70 @top The General Drawing Kit
71 @ifinfo
72 This is edition @value{edition} of the GDK documentation,
73 @w{@value{update-date}}.
74 @end ifinfo
75
76 @menu
77 * Copying::                     Your rights.
78 * Overview::                    What is GDK?
79 * Initialization::              Initialization and exit.
80 * Events::                      Event handling.
81 * Visuals::                     Understanding and using visuals.
82 * Windows::                     Creating and using windows.
83 * Graphics Contexts::           Creating and modifying GCs.
84 * Pixmaps::                     Creating pixmaps.
85 * Images::                      Creating images.
86 * Color::                       Specifying color.
87 * Fonts::                       Creating fonts.
88 * Drawing::                     Drawing commands.
89 * XInput Support::              Using extended devices.
90 * Miscellany::                  Other stuff.
91 * Examples::                    Using GDK.
92 * Function Index::              Index of functions
93 * Concept Index::               Index of concepts
94 @end menu
95
96 @node Copying, Overview, Top, Top
97 @comment node-name, next, previous, up
98 @chapter Copying
99
100 GDK is @dfn{free}; this means that everyone is free to use it and free
101 to redestribute it on a free basis. GDK is not in the public domain; it
102 is copyrighted and there are restrictions on its distribution, but these
103 restrictions are designed to permit everything that a good cooperating
104 citizen would want to do. What is not allowed is to try to prevent
105 others from further sharing any version of GDK that they might get from
106 you.
107
108 Specifically, we want to make sure that you have the right to give away
109 copies of GDK, that you receive source code or else can get it if you
110 want it, that you can change GDK or use pieces of it in new free
111 programs, and that you know you can do these things.
112
113 To make sure that everyone has such rights, we have to forbid you to
114 deprive anyone else of these rights. For example, if you distribute
115 copies of GDK, you must give the recipients all the rights that you
116 have. You must make sure that they, too, receive or can get the source
117 code. And you must tell them their rights.
118
119 Also, for my own protection, we must make certain that everyone finds
120 out that there is no warranty for GDK. If GDK is modified by someone
121 else and passed on, we want their recipients to know that what they have
122 is not what we distributed, so that any problems introduced by others
123 will no reflect on our reputation.
124
125 The precise conditions of the licenses for GDK are found in the General
126 Public Licenses that accompanies it.
127
128
129 @node Overview, Initialization, Copying, Top
130 @comment node-name, next, previous, up
131 @chapter What is GDK?
132 @cindex Overview
133
134 GDK is designed as a wrapper library that lies on top of Xlib. It
135 performs many common and desired operations for a programmer instead
136 of the programmer having to explicitly ask for such functionality from
137 Xlib directly. For example, GDK provides a common interface to both
138 regular and shared memory XImage types. By doing so, an application
139 can nearly transparently use the fastest image type available. GDK
140 also provides routines for determining the best available color depth
141 and the best available visual which is not always the default visual
142 for a screen.
143
144 @node Initialization, Events, Overview, Top
145 @comment node-name, next, previous, up
146 @chapter Initialization and exit
147 @cindex Initialization
148 @cindex Exit
149
150 Initializing GDK is easy. Simply call @code{gdk_init} passing in the
151 @var{argc} and @var{argv} parameters. Exit is similarly easy. Just
152 call @code{gdk_exit}.
153
154 @deftypefun void gdk_init (int *@var{argc}, char ***@var{argv})
155 Initializes the GDK library. The arguments @var{argc} and @var{argv}
156 are scanned and any arguments that GDK recognizes are handled and
157 removed. The @var{argc} and @var{argv} parameters are the values
158 passed to @code{main} upon program invocation.
159 @end deftypefun
160
161 @deftypefun void gdk_exit (int @var{errorcode})
162 Exit GDK and perform any necessary cleanup. @code{gdk_exit} will call
163 the systems @code{exit} function passing @var{errorcode} as the
164 parameter.
165 @end deftypefun
166
167 @example
168 int
169 main (int argc, char *argv[])
170 @{
171   /* Initialize GDK. */
172   gdk_init (&argc, &argv);
173
174   /* Exit from GDK...this call will never return. */
175   gdk_exit (0);
176
177   /* Keep compiler from issuing a warning */
178   return 0;
179 @}
180 @end example
181
182
183 @node Events, Visuals, Initialization, Top
184 @comment node-name, next, previous, up
185 @chapter Event handling
186 @cindex Events
187
188 Events are the means by which GDK lets the programmer know of user
189 interaction. An event is normally a button or key press or some other
190 indirect user action, such as a the mouse cursor entering or leaving a
191 window.
192
193 There exist only a few functions for getting events and event
194 information. These are @code{gdk_events_pending},
195 @code{gdk_event_get}, @code{gdk_events_record} and
196 @code{gdk_events_playback}. The latter two functions are useful for
197 automatic testing of a software package and should normally not be
198 needed in a program.
199
200 @deftypefun gint gdk_events_pending (void)
201 Returns the number of events pending on the event queue.
202 @end deftypefun
203
204 @deftypefun gint gdk_event_get (GdkEvent *@var{event})
205 Return the next available event in the @var{event}
206 structure. @code{gdk_event_get} will return @code{TRUE} on success and
207 @code{FALSE} on failure. Success and failure is determined by whether
208 an event arrived before the timeout period expired.
209 @end deftypefun
210
211 @deftypefun void gdk_events_record (char *@var{filename})
212 Turn on recording of events. User events and certain system events will
213 be saved in the file named by the variable @var{filename}. This stream
214 of events can later be played back and ``should'' produce the same
215 results as when the original events were handled. However, the
216 programmer does need to be careful in that the state of the program must
217 be the same when @code{gdk_events_record} is called and when
218 @code{gdk_events_playback} is called. For this reason,
219 @code{gdk_events_record} is normally not called directly, but is instead
220 invoked indirectly by specifying the ``-record'' command line option.
221 @end deftypefun
222
223 @deftypefun void gdk_events_playback (char *@var{filename})
224 Start playback of events from a file. (See the above description of
225 @code{gdk_events_record}). Normally this function is not called directly
226 but is invoked by the ``-playback'' command line option.
227 @end deftypefun
228
229 @deftypefun void gdk_events_stop (void)
230 Stop recording and playback of events.
231 @end deftypefun
232
233 @example
234 void
235 handle_event ()
236 @{
237   GdkEvent event;
238
239   if (gdk_event_get (&event))
240     @{
241       switch (event.type)
242        @{
243          @dots{}
244        @}
245     @}
246 @}
247 @end example
248
249
250 @node Visuals, Windows, Events, Top
251 @comment node-name, next, previous, up
252 @chapter Understanding and using visuals
253 @cindex Visuals
254
255 @node Windows, Graphics Contexts, Visuals, Top
256 @comment node-name, next, previous, up
257 @chapter Creating and using windows
258 @cindex Windows
259
260 @node Graphics Contexts, Pixmaps, Windows, Top
261 @comment node-name, next, previous, up
262 @chapter Creating and modifying GCs
263 @cindex Graphics Contexts
264 @cindex GC
265
266 @node Pixmaps, Images, Graphics Contexts, Top
267 @comment node-name, next, previous, up
268 @chapter Creating pixmaps
269 @cindex Pixmaps
270
271 @node Images, Color, Pixmaps, Top
272 @comment node-name, next, previous, up
273 @chapter Creating images
274 @cindex Images
275
276 @node Color, Fonts, Images, Top
277 @comment node-name, next, previous, up
278 @chapter Specifying color
279 @cindex Color
280
281 @node Fonts, Drawing, Color, Top
282 @comment node-name, next, previous, up
283 @chapter Creating Fonts
284 @cindex Fonts
285
286 @node Drawing, XInput Support, Fonts, Top
287 @comment node-name, next, previous, up
288 @chapter Drawing Commands
289 @cindex Drawing
290
291 @node XInput Support, Miscellany, Drawing, Top
292 @comment node-name, next, previous, up
293 @chapter Using extended devices
294 @cindex Overview
295 @cindex Using extended device capabilities
296 @cindex Controlling extended devices
297
298 @node Miscellany, Examples, XInput Support, Top
299 @comment node-name, next, previous, up
300 @chapter Other stuff
301 @cindex Timers
302 @cindex Debugging
303 @cindex Miscellaneous
304
305
306 @node Examples, Function Index, Miscellany, Top
307 @comment node-name, next, previous, up
308 @chapter Using GDK
309 @cindex Examples
310
311
312 @node Function Index, Concept Index, Examples, Top
313 @comment node-name, next, previous, up
314 @unnumbered Variable Index
315
316 @printindex fn
317
318 @node Concept Index, , Function Index, Top
319 @comment node-name, next, previous, up
320 @unnumbered Concept Index
321
322 @printindex cp
323
324 @summarycontents
325 @contents
326 @bye
327
328
329
330
331
332
333
334