source: trunk/third/rep-gtk/gtk-support.c @ 15286

Revision 15286, 8.2 KB checked in by ghudson, 24 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r15285, which included commits to RCS files with non-trunk default branches.
Line 
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/gdkprivate.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
29GdkColor *
30gdk_color_intern (GdkColor *color)
31{
32  return color;
33}
34
35GdkFont *
36gdk_font_intern (GdkFont *font)
37{
38  return font;
39}
40
41GdkGC *
42gtk_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
50GdkGC *
51gtk_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
61GdkEventType
62gdk_event_type (GdkEvent *event)
63{
64  return event->any.type;
65}
66
67GdkWindow *
68gdk_event_window (GdkEvent *event)
69{
70  return event->any.window;
71}
72
73gboolean
74gdk_event_send_event (GdkEvent *event)
75{
76  return event->any.send_event;
77}
78
79GdkRectangle *
80gdk_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
91GdkVisibilityState
92gdk_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
103guint32
104gdk_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
131gdouble
132gdk_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
146gdouble
147gdk_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
161gdouble
162gdk_event_pressure (GdkEvent *event)
163{
164  switch (event->any.type)
165    {
166    case GDK_MOTION_NOTIFY:
167      return event->motion.pressure;
168    case GDK_BUTTON_PRESS:
169    case GDK_BUTTON_RELEASE:
170      return event->button.pressure;
171    default:
172      return 0;
173    }
174}
175
176gdouble
177gdk_event_xtilt (GdkEvent *event)
178{
179  switch (event->any.type)
180    {
181    case GDK_MOTION_NOTIFY:
182      return event->motion.xtilt;
183    case GDK_BUTTON_PRESS:
184    case GDK_BUTTON_RELEASE:
185      return event->button.xtilt;
186    default:
187      return 0;
188    }
189}
190
191gdouble
192gdk_event_ytilt (GdkEvent *event)
193{
194  switch (event->any.type)
195    {
196    case GDK_MOTION_NOTIFY:
197      return event->motion.ytilt;
198    case GDK_BUTTON_PRESS:
199    case GDK_BUTTON_RELEASE:
200      return event->button.ytilt;
201    default:
202      return 0;
203    }
204}
205
206gint
207gdk_event_button (GdkEvent *event)
208{
209  switch (event->any.type)
210    {
211    case GDK_BUTTON_PRESS:
212    case GDK_BUTTON_RELEASE:
213      return event->button.button;
214    default:
215      return 0;
216    }
217}
218
219gboolean
220gdk_event_button_state (GdkEvent *event)
221{
222  switch (event->any.type)
223    {
224    case GDK_MOTION_NOTIFY:
225      return event->motion.state;
226    case GDK_BUTTON_PRESS:
227    case GDK_BUTTON_RELEASE:
228      return event->button.state;
229    default:
230      return 0;
231    }
232}
233
234gboolean
235gdk_event_is_hint (GdkEvent *event)
236{
237  switch (event->any.type)
238    {
239    case GDK_MOTION_NOTIFY:
240      return event->motion.is_hint;
241    default:
242      return 0;
243    }
244}
245
246GdkInputSource
247gdk_event_source (GdkEvent *event)
248{
249  switch (event->any.type)
250    {
251    case GDK_MOTION_NOTIFY:
252      return event->motion.source;
253    case GDK_BUTTON_PRESS:
254    case GDK_BUTTON_RELEASE:
255      return event->button.source;
256    default:
257      return GDK_SOURCE_MOUSE; /* XXX */
258    }
259}
260
261guint32
262gdk_event_deviceid (GdkEvent *event)
263{
264  switch (event->any.type)
265    {
266    case GDK_MOTION_NOTIFY:
267      return event->motion.deviceid;
268    case GDK_BUTTON_PRESS:
269    case GDK_BUTTON_RELEASE:
270      return event->button.deviceid;
271    default:
272      return 0;
273    }
274}
275
276gdouble
277gdk_event_x_root (GdkEvent *event)
278{
279  switch (event->any.type)
280    {
281    case GDK_MOTION_NOTIFY:
282      return event->motion.x_root;
283    case GDK_BUTTON_PRESS:
284    case GDK_BUTTON_RELEASE:
285      return event->button.x_root;
286    default:
287      return 0;
288    }
289}
290
291gdouble
292gdk_event_y_root (GdkEvent *event)
293{
294  switch (event->any.type)
295    {
296    case GDK_MOTION_NOTIFY:
297      return event->motion.y_root;
298    case GDK_BUTTON_PRESS:
299    case GDK_BUTTON_RELEASE:
300      return event->button.y_root;
301    default:
302      return 0;
303    }
304}
305
306gboolean
307gdk_event_key_state (GdkEvent *event)
308{
309  switch (event->any.type)
310    {
311    case GDK_KEY_PRESS:
312    case GDK_KEY_RELEASE:
313      return event->key.state;
314    default:
315      return 0;
316    }
317}
318
319guint
320gdk_event_keyval (GdkEvent *event)
321{
322  switch (event->any.type)
323    {
324    case GDK_KEY_PRESS:
325    case GDK_KEY_RELEASE:
326      return event->key.keyval;
327    default:
328      return 0;
329    }
330}
331
332gchar *
333gdk_event_string (GdkEvent *event)
334{
335  switch (event->any.type)
336    {
337    case GDK_KEY_PRESS:
338    case GDK_KEY_RELEASE:
339      {
340        gchar *str = g_malloc (event->key.length+1);
341        strncpy (str, event->key.string, event->key.length);
342        str[event->key.length] = '\0';
343        return str;
344      }
345    default:
346      return NULL;
347    }
348}
349
350GdkWindow *
351gdk_event_subwindow (GdkEvent *event)
352{
353  switch (event->any.type)
354    {
355    case GDK_ENTER_NOTIFY:
356    case GDK_LEAVE_NOTIFY:
357      return event->crossing.subwindow;
358    default:
359      return 0;
360    }
361}
362
363GdkNotifyType
364gdk_event_notify_detail (GdkEvent *event)
365{
366  switch (event->any.type)
367    {
368    case GDK_ENTER_NOTIFY:
369    case GDK_LEAVE_NOTIFY:
370      return event->crossing.detail;
371    default:
372      return 0;
373    }
374}
375
376gboolean
377gdk_event_in (GdkEvent *event)
378{
379  switch (event->any.type)
380    {
381    case GDK_FOCUS_CHANGE:
382      return event->focus_change.in;
383    default:
384      return 0;
385    }
386}
387
388gint16
389gdk_event_configure_x (GdkEvent *event)
390{
391  switch (event->any.type)
392    {
393    case GDK_CONFIGURE:
394      return event->configure.x;
395    default:
396      return 0;
397    }
398}
399
400gint16
401gdk_event_configure_y (GdkEvent *event)
402{
403  switch (event->any.type)
404    {
405    case GDK_CONFIGURE:
406      return event->configure.y;
407    default:
408      return 0;
409    }
410}
411
412gint16
413gdk_event_configure_width (GdkEvent *event)
414{
415  switch (event->any.type)
416    {
417    case GDK_CONFIGURE:
418      return event->configure.width;
419    default:
420      return 0;
421    }
422}
423
424guint32
425gdk_get_leader_window_id ()
426{
427  return (guint32) gdk_leader_window;
428}
429
430gint16
431gdk_event_configure_height (GdkEvent *event)
432{
433  switch (event->any.type)
434    {
435    case GDK_CONFIGURE:
436      return event->configure.height;
437    default:
438      return 0;
439    }
440}
441
442guint32
443gdk_window_xid (GdkWindow *win)
444{
445    GdkWindowPrivate *pri = (GdkWindowPrivate *)win;
446    return pri->xwindow;
447}
448
449
450
451repv
452sgtk_gtk_widget_get_allocation (GtkWidget *w)
453{
454    return Fcons (Fcons (rep_MAKE_INT (w->allocation.x),
455                         rep_MAKE_INT (w->allocation.y)),
456                  Fcons (rep_MAKE_INT (w->allocation.width),
457                         rep_MAKE_INT (w->allocation.height)));
458}
Note: See TracBrowser for help on using the repository browser.