chiark / gitweb /
Bug fix
[clg] / gtk / alien / glue.c
CommitLineData
3350ea74 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
ec0dd9ca 19/* $Id: glue.c,v 1.3 2004-12-20 00:45:24 espen Exp $ */
3350ea74 20
21
22#include <gtk/gtk.h>
23
24
25/*
26 *
27 * Gtk helper functions
28 *
29 */
30
31void
32gtk_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
3350ea74 40/* Widget */
41
42GdkWindow*
43gtk_widget_get_window (GtkWidget *widget)
44{
45 return widget->window;
46}
47
48GtkStateType
49gtk_widget_get_state (GtkWidget *widget)
50{
51 return widget->state;
52}
53
54gboolean
55gtk_widget_mapped_p (GtkWidget *widget)
56{
57 return GTK_WIDGET_MAPPED (widget);
58}
59
60void
61gtk_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
70GtkWidget*
71gtk_container_get_focus_child (GtkContainer *container)
72{
73 return container->focus_child;
74}
75
76
77/* Dialog */
78
79GtkWidget*
80gtk_dialog_get_vbox (GtkDialog *dialog)
81{
82 return dialog->vbox;
83}
84
85GtkWidget*
86gtk_dialog_get_action_area (GtkDialog *dialog)
87{
88 return dialog->action_area;
89}
90
91
92
3350ea74 93/* Window */
94
95GtkWidget*
96gtk_window_get_default (GtkWindow *window)
97{
98 return window->default_widget;
99}
100
101
3350ea74 102/* Paned */
103
104GtkWidget*
105gtk_paned_child1 (GtkPaned *paned, guint *resize, guint *shrink)
106{
107 *resize = paned->child1_resize;
108 *shrink = paned->child1_shrink;
109
110 return paned->child1;
111}
112
113
114GtkWidget*
115gtk_paned_child2 (GtkPaned *paned, guint *resize, guint *shrink)
116{
117 *resize = paned->child2_resize;
118 *shrink = paned->child2_shrink;
119
120 return paned->child2;
121}
122
123
124/* Layout */
125
126GdkWindow*
127gtk_layout_get_bin_window (GtkLayout *layout)
128{
129 return layout->bin_window;
130}
131
132
3350ea74 133/* Drawing area */
134
135void
136gtk_drawing_area_get_size (GtkDrawingArea *darea, gint *width, gint *height)
137{
138 GtkWidget *widget;
139
140 widget = GTK_WIDGET (darea);
141 *width = widget->allocation.width;
142 *height = widget->allocation.height;
143}
144
145
3350ea74 146/* GtkStyle accessor functions */
147
148typedef enum {
149 GTK_COLOR_FG,
150 GTK_COLOR_BG,
151 GTK_COLOR_LIGHT,
152 GTK_COLOR_DARK,
153 GTK_COLOR_MID,
154 GTK_COLOR_TEXT,
155 GTK_COLOR_BASE,
ec0dd9ca 156 GTK_COLOR_TEXT_AA,
3350ea74 157 GTK_COLOR_WHITE,
158 GTK_COLOR_BLACK
159} GtkColorType;
160
161GdkColor*
162gtk_style_get_color (GtkStyle *style, GtkColorType color_type,
163 GtkStateType state)
164{
165 switch (color_type)
166 {
167 case GTK_COLOR_WHITE:
168 return &style->white;
169 case GTK_COLOR_BLACK:
170 return &style->black;
171 case GTK_COLOR_FG:
172 return &style->fg[state];
173 case GTK_COLOR_BG:
174 return &style->bg[state];
175 case GTK_COLOR_LIGHT:
176 return &style->light[state];
177 case GTK_COLOR_DARK:
178 return &style->dark[state];
179 case GTK_COLOR_MID:
180 return &style->mid[state];
181 case GTK_COLOR_TEXT:
182 return &style->text[state];
183 case GTK_COLOR_BASE:
184 return &style->base[state];
ec0dd9ca 185 case GTK_COLOR_TEXT_AA:
186 return &style->text_aa[state];
3350ea74 187 }
188}
189
190
ec0dd9ca 191void
3350ea74 192gtk_style_set_color (GtkStyle *style, GtkColorType color_type,
193 GtkStateType state, GdkColor *color)
194{
195 switch (color_type)
196 {
197 case GTK_COLOR_WHITE:
198 style->white = *color; break;
199 case GTK_COLOR_BLACK:
200 style->black = *color; break;
201 case GTK_COLOR_FG:
202 style->fg[state] = *color; break;
203 case GTK_COLOR_BG:
204 style->bg[state] = *color; break;
205 case GTK_COLOR_LIGHT:
206 style->light[state] = *color; break;
207 case GTK_COLOR_DARK:
208 style->dark[state] = *color; break;
209 case GTK_COLOR_MID:
210 style->mid[state] = *color; break;
211 case GTK_COLOR_TEXT:
212 style->text[state] = *color; break;
213 case GTK_COLOR_BASE:
214 style->base[state] = *color; break;
ec0dd9ca 215 case GTK_COLOR_TEXT_AA:
216 style->text_aa[state] = *color; break;
3350ea74 217 }
3350ea74 218}
219
3350ea74 220
221GdkGC*
222gtk_style_get_gc (GtkStyle *style, GtkColorType color_type, GtkStateType state)
223{
224 switch (color_type)
225 {
226 case GTK_COLOR_WHITE:
227 return style->white_gc;
228 case GTK_COLOR_BLACK:
229 return style->black_gc;
230 case GTK_COLOR_FG:
231 return style->fg_gc[state];
232 case GTK_COLOR_BG:
233 return style->bg_gc[state];
234 case GTK_COLOR_LIGHT:
235 return style->light_gc[state];
236 case GTK_COLOR_DARK:
237 return style->dark_gc[state];
238 case GTK_COLOR_MID:
239 return style->mid_gc[state];
240 case GTK_COLOR_TEXT:
241 return style->text_gc[state];
242 case GTK_COLOR_BASE:
243 return style->base_gc[state];
ec0dd9ca 244 case GTK_COLOR_TEXT_AA:
245 return style->text_aa_gc[state];
3350ea74 246 }
247}
ec0dd9ca 248
249int
250gtk_style_font_desc_offset ()
251{
252 GtkStyle style;
253
254 return (int)&style.font_desc - (int)&style;
255}
256