1 | /* |
---|
2 | * Copyright (C) 1997, 1998, 1999 Marius Vollmer |
---|
3 | * |
---|
4 | * This program is free software; you can redistribute it and/or modify |
---|
5 | * it under the terms of the GNU General Public License as published by |
---|
6 | * the Free Software Foundation; either version 2, or (at your option) |
---|
7 | * any later version. |
---|
8 | * |
---|
9 | * This program is distributed in the hope that it will be useful, |
---|
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
12 | * GNU General Public License for more details. |
---|
13 | * |
---|
14 | * You should have received a copy of the GNU General Public License |
---|
15 | * along with this software; see the file COPYING. If not, write to |
---|
16 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
17 | */ |
---|
18 | |
---|
19 | #include "rep-gtk.h" |
---|
20 | #include <string.h> |
---|
21 | #include <gdk/gdkx.h> |
---|
22 | |
---|
23 | /* It is not strictly correct to have Gdk support functions here. But |
---|
24 | as long as we do not want to have some SCM_PROCs for the (gdk gdk) |
---|
25 | module, we are safe. */ |
---|
26 | |
---|
27 | |
---|
28 | |
---|
29 | GdkColor * |
---|
30 | gdk_color_intern (GdkColor *color) |
---|
31 | { |
---|
32 | return color; |
---|
33 | } |
---|
34 | |
---|
35 | GdkFont * |
---|
36 | gdk_font_intern (GdkFont *font) |
---|
37 | { |
---|
38 | return font; |
---|
39 | } |
---|
40 | |
---|
41 | GdkGC * |
---|
42 | gtk_style_fg_gc (GtkStyle *style, GtkStateType state) |
---|
43 | { |
---|
44 | if (style == NULL || state < 0 || state >= 5) |
---|
45 | return NULL; |
---|
46 | |
---|
47 | return style->fg_gc[state]; |
---|
48 | } |
---|
49 | |
---|
50 | GdkGC * |
---|
51 | gtk_style_bg_gc (GtkStyle *style, GtkStateType state) |
---|
52 | { |
---|
53 | if (style == NULL || state < 0 || state >= 5) |
---|
54 | return NULL; |
---|
55 | |
---|
56 | return style->bg_gc[state]; |
---|
57 | } |
---|
58 | |
---|
59 | /* Event destructuring */ |
---|
60 | |
---|
61 | GdkEventType |
---|
62 | gdk_event_type (GdkEvent *event) |
---|
63 | { |
---|
64 | return event->any.type; |
---|
65 | } |
---|
66 | |
---|
67 | GdkWindow * |
---|
68 | gdk_event_window (GdkEvent *event) |
---|
69 | { |
---|
70 | return event->any.window; |
---|
71 | } |
---|
72 | |
---|
73 | gboolean |
---|
74 | gdk_event_send_event (GdkEvent *event) |
---|
75 | { |
---|
76 | return event->any.send_event; |
---|
77 | } |
---|
78 | |
---|
79 | GdkRectangle * |
---|
80 | gdk_event_area (GdkEvent *event) |
---|
81 | { |
---|
82 | switch (event->any.type) |
---|
83 | { |
---|
84 | case GDK_EXPOSE: |
---|
85 | return &event->expose.area; |
---|
86 | default: |
---|
87 | return NULL; |
---|
88 | } |
---|
89 | } |
---|
90 | |
---|
91 | GdkVisibilityState |
---|
92 | gdk_event_visibility_state (GdkEvent *event) |
---|
93 | { |
---|
94 | switch (event->any.type) |
---|
95 | { |
---|
96 | case GDK_VISIBILITY_NOTIFY: |
---|
97 | return event->visibility.state; |
---|
98 | default: |
---|
99 | return GDK_VISIBILITY_UNOBSCURED; /* XXX */ |
---|
100 | } |
---|
101 | } |
---|
102 | |
---|
103 | guint32 |
---|
104 | gdk_event_time (GdkEvent *event) |
---|
105 | { |
---|
106 | switch (event->any.type) |
---|
107 | { |
---|
108 | case GDK_MOTION_NOTIFY: |
---|
109 | return event->motion.time; |
---|
110 | case GDK_BUTTON_PRESS: |
---|
111 | case GDK_BUTTON_RELEASE: |
---|
112 | return event->button.time; |
---|
113 | case GDK_KEY_PRESS: |
---|
114 | case GDK_KEY_RELEASE: |
---|
115 | return event->key.time; |
---|
116 | return event->key.time; |
---|
117 | case GDK_PROPERTY_NOTIFY: |
---|
118 | return event->property.time; |
---|
119 | case GDK_SELECTION_CLEAR: |
---|
120 | case GDK_SELECTION_REQUEST: |
---|
121 | case GDK_SELECTION_NOTIFY: |
---|
122 | return event->selection.time; |
---|
123 | case GDK_PROXIMITY_IN: |
---|
124 | case GDK_PROXIMITY_OUT: |
---|
125 | return event->proximity.time; |
---|
126 | default: |
---|
127 | return 0; |
---|
128 | } |
---|
129 | } |
---|
130 | |
---|
131 | gdouble |
---|
132 | gdk_event_x (GdkEvent *event) |
---|
133 | { |
---|
134 | switch (event->any.type) |
---|
135 | { |
---|
136 | case GDK_MOTION_NOTIFY: |
---|
137 | return event->motion.x; |
---|
138 | case GDK_BUTTON_PRESS: |
---|
139 | case GDK_BUTTON_RELEASE: |
---|
140 | return event->button.x; |
---|
141 | default: |
---|
142 | return 0; |
---|
143 | } |
---|
144 | } |
---|
145 | |
---|
146 | gdouble |
---|
147 | gdk_event_y (GdkEvent *event) |
---|
148 | { |
---|
149 | switch (event->any.type) |
---|
150 | { |
---|
151 | case GDK_MOTION_NOTIFY: |
---|
152 | return event->motion.y; |
---|
153 | case GDK_BUTTON_PRESS: |
---|
154 | case GDK_BUTTON_RELEASE: |
---|
155 | return event->button.y; |
---|
156 | default: |
---|
157 | return 0; |
---|
158 | } |
---|
159 | } |
---|
160 | |
---|
161 | gdouble |
---|
162 | gdk_event_pressure (GdkEvent *event) |
---|
163 | { |
---|
164 | #ifdef XXX |
---|
165 | switch (event->any.type) |
---|
166 | { |
---|
167 | case GDK_MOTION_NOTIFY: |
---|
168 | return event->motion.pressure; |
---|
169 | case GDK_BUTTON_PRESS: |
---|
170 | case GDK_BUTTON_RELEASE: |
---|
171 | return event->button.pressure; |
---|
172 | default: |
---|
173 | return 0; |
---|
174 | } |
---|
175 | #else |
---|
176 | return 0; |
---|
177 | #endif |
---|
178 | } |
---|
179 | |
---|
180 | gdouble |
---|
181 | gdk_event_xtilt (GdkEvent *event) |
---|
182 | { |
---|
183 | #ifdef XXX |
---|
184 | switch (event->any.type) |
---|
185 | { |
---|
186 | case GDK_MOTION_NOTIFY: |
---|
187 | return event->motion.xtilt; |
---|
188 | case GDK_BUTTON_PRESS: |
---|
189 | case GDK_BUTTON_RELEASE: |
---|
190 | return event->button.xtilt; |
---|
191 | default: |
---|
192 | return 0; |
---|
193 | } |
---|
194 | #else |
---|
195 | return 0; |
---|
196 | #endif |
---|
197 | } |
---|
198 | |
---|
199 | gdouble |
---|
200 | gdk_event_ytilt (GdkEvent *event) |
---|
201 | { |
---|
202 | #ifdef XXX |
---|
203 | switch (event->any.type) |
---|
204 | { |
---|
205 | case GDK_MOTION_NOTIFY: |
---|
206 | return event->motion.ytilt; |
---|
207 | case GDK_BUTTON_PRESS: |
---|
208 | case GDK_BUTTON_RELEASE: |
---|
209 | return event->button.ytilt; |
---|
210 | default: |
---|
211 | return 0; |
---|
212 | } |
---|
213 | #else |
---|
214 | return 0; |
---|
215 | #endif |
---|
216 | } |
---|
217 | |
---|
218 | gint |
---|
219 | gdk_event_button (GdkEvent *event) |
---|
220 | { |
---|
221 | switch (event->any.type) |
---|
222 | { |
---|
223 | case GDK_BUTTON_PRESS: |
---|
224 | case GDK_BUTTON_RELEASE: |
---|
225 | return event->button.button; |
---|
226 | default: |
---|
227 | return 0; |
---|
228 | } |
---|
229 | } |
---|
230 | |
---|
231 | gboolean |
---|
232 | gdk_event_button_state (GdkEvent *event) |
---|
233 | { |
---|
234 | switch (event->any.type) |
---|
235 | { |
---|
236 | case GDK_MOTION_NOTIFY: |
---|
237 | return event->motion.state; |
---|
238 | case GDK_BUTTON_PRESS: |
---|
239 | case GDK_BUTTON_RELEASE: |
---|
240 | return event->button.state; |
---|
241 | default: |
---|
242 | return 0; |
---|
243 | } |
---|
244 | } |
---|
245 | |
---|
246 | gboolean |
---|
247 | gdk_event_is_hint (GdkEvent *event) |
---|
248 | { |
---|
249 | switch (event->any.type) |
---|
250 | { |
---|
251 | case GDK_MOTION_NOTIFY: |
---|
252 | return event->motion.is_hint; |
---|
253 | default: |
---|
254 | return 0; |
---|
255 | } |
---|
256 | } |
---|
257 | |
---|
258 | GdkInputSource |
---|
259 | gdk_event_source (GdkEvent *event) |
---|
260 | { |
---|
261 | #ifdef XXX |
---|
262 | switch (event->any.type) |
---|
263 | { |
---|
264 | case GDK_MOTION_NOTIFY: |
---|
265 | return event->motion.source; |
---|
266 | case GDK_BUTTON_PRESS: |
---|
267 | case GDK_BUTTON_RELEASE: |
---|
268 | return event->button.source; |
---|
269 | default: |
---|
270 | return GDK_SOURCE_MOUSE; /* XXX */ |
---|
271 | } |
---|
272 | #else |
---|
273 | return GDK_SOURCE_MOUSE; |
---|
274 | #endif |
---|
275 | } |
---|
276 | |
---|
277 | guint32 |
---|
278 | gdk_event_deviceid (GdkEvent *event) |
---|
279 | { |
---|
280 | #ifdef XXX |
---|
281 | switch (event->any.type) |
---|
282 | { |
---|
283 | case GDK_MOTION_NOTIFY: |
---|
284 | return event->motion.deviceid; |
---|
285 | case GDK_BUTTON_PRESS: |
---|
286 | case GDK_BUTTON_RELEASE: |
---|
287 | return event->button.deviceid; |
---|
288 | default: |
---|
289 | return 0; |
---|
290 | } |
---|
291 | #else |
---|
292 | return 0; |
---|
293 | #endif |
---|
294 | } |
---|
295 | |
---|
296 | gdouble |
---|
297 | gdk_event_x_root (GdkEvent *event) |
---|
298 | { |
---|
299 | switch (event->any.type) |
---|
300 | { |
---|
301 | case GDK_MOTION_NOTIFY: |
---|
302 | return event->motion.x_root; |
---|
303 | case GDK_BUTTON_PRESS: |
---|
304 | case GDK_BUTTON_RELEASE: |
---|
305 | return event->button.x_root; |
---|
306 | default: |
---|
307 | return 0; |
---|
308 | } |
---|
309 | } |
---|
310 | |
---|
311 | gdouble |
---|
312 | gdk_event_y_root (GdkEvent *event) |
---|
313 | { |
---|
314 | switch (event->any.type) |
---|
315 | { |
---|
316 | case GDK_MOTION_NOTIFY: |
---|
317 | return event->motion.y_root; |
---|
318 | case GDK_BUTTON_PRESS: |
---|
319 | case GDK_BUTTON_RELEASE: |
---|
320 | return event->button.y_root; |
---|
321 | default: |
---|
322 | return 0; |
---|
323 | } |
---|
324 | } |
---|
325 | |
---|
326 | gboolean |
---|
327 | gdk_event_key_state (GdkEvent *event) |
---|
328 | { |
---|
329 | switch (event->any.type) |
---|
330 | { |
---|
331 | case GDK_KEY_PRESS: |
---|
332 | case GDK_KEY_RELEASE: |
---|
333 | return event->key.state; |
---|
334 | default: |
---|
335 | return 0; |
---|
336 | } |
---|
337 | } |
---|
338 | |
---|
339 | guint |
---|
340 | gdk_event_keyval (GdkEvent *event) |
---|
341 | { |
---|
342 | switch (event->any.type) |
---|
343 | { |
---|
344 | case GDK_KEY_PRESS: |
---|
345 | case GDK_KEY_RELEASE: |
---|
346 | return event->key.keyval; |
---|
347 | default: |
---|
348 | return 0; |
---|
349 | } |
---|
350 | } |
---|
351 | |
---|
352 | gchar * |
---|
353 | gdk_event_string (GdkEvent *event) |
---|
354 | { |
---|
355 | switch (event->any.type) |
---|
356 | { |
---|
357 | case GDK_KEY_PRESS: |
---|
358 | case GDK_KEY_RELEASE: |
---|
359 | { |
---|
360 | gchar *str = g_malloc (event->key.length+1); |
---|
361 | strncpy (str, event->key.string, event->key.length); |
---|
362 | str[event->key.length] = '\0'; |
---|
363 | return str; |
---|
364 | } |
---|
365 | default: |
---|
366 | return NULL; |
---|
367 | } |
---|
368 | } |
---|
369 | |
---|
370 | GdkWindow * |
---|
371 | gdk_event_subwindow (GdkEvent *event) |
---|
372 | { |
---|
373 | switch (event->any.type) |
---|
374 | { |
---|
375 | case GDK_ENTER_NOTIFY: |
---|
376 | case GDK_LEAVE_NOTIFY: |
---|
377 | return event->crossing.subwindow; |
---|
378 | default: |
---|
379 | return 0; |
---|
380 | } |
---|
381 | } |
---|
382 | |
---|
383 | GdkNotifyType |
---|
384 | gdk_event_notify_detail (GdkEvent *event) |
---|
385 | { |
---|
386 | switch (event->any.type) |
---|
387 | { |
---|
388 | case GDK_ENTER_NOTIFY: |
---|
389 | case GDK_LEAVE_NOTIFY: |
---|
390 | return event->crossing.detail; |
---|
391 | default: |
---|
392 | return 0; |
---|
393 | } |
---|
394 | } |
---|
395 | |
---|
396 | gboolean |
---|
397 | gdk_event_in (GdkEvent *event) |
---|
398 | { |
---|
399 | switch (event->any.type) |
---|
400 | { |
---|
401 | case GDK_FOCUS_CHANGE: |
---|
402 | return event->focus_change.in; |
---|
403 | default: |
---|
404 | return 0; |
---|
405 | } |
---|
406 | } |
---|
407 | |
---|
408 | gint16 |
---|
409 | gdk_event_configure_x (GdkEvent *event) |
---|
410 | { |
---|
411 | switch (event->any.type) |
---|
412 | { |
---|
413 | case GDK_CONFIGURE: |
---|
414 | return event->configure.x; |
---|
415 | default: |
---|
416 | return 0; |
---|
417 | } |
---|
418 | } |
---|
419 | |
---|
420 | gint16 |
---|
421 | gdk_event_configure_y (GdkEvent *event) |
---|
422 | { |
---|
423 | switch (event->any.type) |
---|
424 | { |
---|
425 | case GDK_CONFIGURE: |
---|
426 | return event->configure.y; |
---|
427 | default: |
---|
428 | return 0; |
---|
429 | } |
---|
430 | } |
---|
431 | |
---|
432 | gint16 |
---|
433 | gdk_event_configure_width (GdkEvent *event) |
---|
434 | { |
---|
435 | switch (event->any.type) |
---|
436 | { |
---|
437 | case GDK_CONFIGURE: |
---|
438 | return event->configure.width; |
---|
439 | default: |
---|
440 | return 0; |
---|
441 | } |
---|
442 | } |
---|
443 | |
---|
444 | guint32 |
---|
445 | gdk_get_leader_window_id () |
---|
446 | { |
---|
447 | #ifdef XXX |
---|
448 | return (guint32) gdk_leader_window; |
---|
449 | #else |
---|
450 | return 0; |
---|
451 | #endif |
---|
452 | } |
---|
453 | |
---|
454 | gint16 |
---|
455 | gdk_event_configure_height (GdkEvent *event) |
---|
456 | { |
---|
457 | switch (event->any.type) |
---|
458 | { |
---|
459 | case GDK_CONFIGURE: |
---|
460 | return event->configure.height; |
---|
461 | default: |
---|
462 | return 0; |
---|
463 | } |
---|
464 | } |
---|
465 | |
---|
466 | guint32 |
---|
467 | gdk_window_xid (GdkWindow *win) |
---|
468 | { |
---|
469 | return GDK_WINDOW_XID (win); |
---|
470 | } |
---|
471 | |
---|
472 | GtkTextIter * |
---|
473 | gtk_text_iter_new (void) |
---|
474 | { |
---|
475 | GtkTextIter foo = {0}; |
---|
476 | return gtk_text_iter_copy (&foo); |
---|
477 | } |
---|
478 | |
---|
479 | |
---|
480 | |
---|
481 | |
---|
482 | repv |
---|
483 | sgtk_gtk_widget_get_allocation (GtkWidget *w) |
---|
484 | { |
---|
485 | return Fcons (Fcons (rep_MAKE_INT (w->allocation.x), |
---|
486 | rep_MAKE_INT (w->allocation.y)), |
---|
487 | Fcons (rep_MAKE_INT (w->allocation.width), |
---|
488 | rep_MAKE_INT (w->allocation.height))); |
---|
489 | } |
---|