Bindings for window and window-group completed
[clg] / gtk / alien / glue.c
1 /* Common Lisp bindings for GTK+ v2.0
2 * Copyright (C) 1999-2002 Espen S. Johnsen <espen@users.sourceforge.net>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library 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 GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19 /* $Id: glue.c,v 1.5 2004-12-26 11:51:21 espen Exp $ */
20
21
22 #include <gtk/gtk.h>
23
24
25 /*
26 *
27 * Gtk helper functions
28 *
29 */
30
31 void
32 gtk_query_version (guint *major, guint *minor, guint *micro)
33 {
34 *major = gtk_major_version;
35 *minor = gtk_minor_version;
36 *micro = gtk_micro_version;
37 }
38
39
40 /* Widget */
41
42 GdkWindow*
43 gtk_widget_get_window (GtkWidget *widget)
44 {
45 return widget->window;
46 }
47
48 GtkStateType
49 gtk_widget_get_state (GtkWidget *widget)
50 {
51 return widget->state;
52 }
53
54 gboolean
55 gtk_widget_mapped_p (GtkWidget *widget)
56 {
57 return GTK_WIDGET_MAPPED (widget);
58 }
59
60 void
61 gtk_widget_get_size_allocation (GtkWidget *widget, int *width, int *height)
62 {
63 *width = widget->allocation.width;
64 *height = widget->allocation.height;
65 }
66
67
68 /* Container */
69
70 GtkWidget*
71 gtk_container_get_focus_child (GtkContainer *container)
72 {
73 return container->focus_child;
74 }
75
76
77 /* Dialog */
78
79 GtkWidget*
80 gtk_dialog_get_vbox (GtkDialog *dialog)
81 {
82 return dialog->vbox;
83 }
84
85 GtkWidget*
86 gtk_dialog_get_action_area (GtkDialog *dialog)
87 {
88 return dialog->action_area;
89 }
90
91
92
93 /* Window */
94
95 GtkWidget*
96 gtk_window_get_default (GtkWindow *window)
97 {
98 return window->default_widget;
99 }
100
101 GtkWindowGroup*
102 gtk_window_get_group (GtkWindow *window)
103 {
104 return window->group;
105 }
106
107
108
109 /* Layout */
110
111 GdkWindow*
112 gtk_layout_get_bin_window (GtkLayout *layout)
113 {
114 return layout->bin_window;
115 }
116
117
118 /* Drawing area */
119
120 void
121 gtk_drawing_area_get_size (GtkDrawingArea *darea, gint *width, gint *height)
122 {
123 GtkWidget *widget;
124
125 widget = GTK_WIDGET (darea);
126 *width = widget->allocation.width;
127 *height = widget->allocation.height;
128 }
129
130
131 /* GtkStyle accessor functions */
132
133 typedef enum {
134 GTK_COLOR_FG,
135 GTK_COLOR_BG,
136 GTK_COLOR_LIGHT,
137 GTK_COLOR_DARK,
138 GTK_COLOR_MID,
139 GTK_COLOR_TEXT,
140 GTK_COLOR_BASE,
141 GTK_COLOR_TEXT_AA,
142 GTK_COLOR_WHITE,
143 GTK_COLOR_BLACK
144 } GtkColorType;
145
146 GdkColor*
147 gtk_style_get_color (GtkStyle *style, GtkColorType color_type,
148 GtkStateType state)
149 {
150 switch (color_type)
151 {
152 case GTK_COLOR_WHITE:
153 return &style->white;
154 case GTK_COLOR_BLACK:
155 return &style->black;
156 case GTK_COLOR_FG:
157 return &style->fg[state];
158 case GTK_COLOR_BG:
159 return &style->bg[state];
160 case GTK_COLOR_LIGHT:
161 return &style->light[state];
162 case GTK_COLOR_DARK:
163 return &style->dark[state];
164 case GTK_COLOR_MID:
165 return &style->mid[state];
166 case GTK_COLOR_TEXT:
167 return &style->text[state];
168 case GTK_COLOR_BASE:
169 return &style->base[state];
170 case GTK_COLOR_TEXT_AA:
171 return &style->text_aa[state];
172 }
173 }
174
175
176 void
177 gtk_style_set_color (GtkStyle *style, GtkColorType color_type,
178 GtkStateType state, GdkColor *color)
179 {
180 switch (color_type)
181 {
182 case GTK_COLOR_WHITE:
183 style->white = *color; break;
184 case GTK_COLOR_BLACK:
185 style->black = *color; break;
186 case GTK_COLOR_FG:
187 style->fg[state] = *color; break;
188 case GTK_COLOR_BG:
189 style->bg[state] = *color; break;
190 case GTK_COLOR_LIGHT:
191 style->light[state] = *color; break;
192 case GTK_COLOR_DARK:
193 style->dark[state] = *color; break;
194 case GTK_COLOR_MID:
195 style->mid[state] = *color; break;
196 case GTK_COLOR_TEXT:
197 style->text[state] = *color; break;
198 case GTK_COLOR_BASE:
199 style->base[state] = *color; break;
200 case GTK_COLOR_TEXT_AA:
201 style->text_aa[state] = *color; break;
202 }
203 }
204
205
206 GdkGC*
207 gtk_style_get_gc (GtkStyle *style, GtkColorType color_type, GtkStateType state)
208 {
209 switch (color_type)
210 {
211 case GTK_COLOR_WHITE:
212 return style->white_gc;
213 case GTK_COLOR_BLACK:
214 return style->black_gc;
215 case GTK_COLOR_FG:
216 return style->fg_gc[state];
217 case GTK_COLOR_BG:
218 return style->bg_gc[state];
219 case GTK_COLOR_LIGHT:
220 return style->light_gc[state];
221 case GTK_COLOR_DARK:
222 return style->dark_gc[state];
223 case GTK_COLOR_MID:
224 return style->mid_gc[state];
225 case GTK_COLOR_TEXT:
226 return style->text_gc[state];
227 case GTK_COLOR_BASE:
228 return style->base_gc[state];
229 case GTK_COLOR_TEXT_AA:
230 return style->text_aa_gc[state];
231 }
232 }
233
234 int
235 gtk_style_font_desc_offset ()
236 {
237 GtkStyle style;
238
239 return (int)&style.font_desc - (int)&style;
240 }
241