chiark / gitweb /
New function to create radio buttons of any type
[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
d76e9fca 19/* $Id: glue.c,v 1.6 2004-12-29 21:17:37 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
d76e9fca 76gboolean
77gtk_container_get_reallocate_redraws (GtkContainer *container)
78{
79 return container->reallocate_redraws;
80}
81
3350ea74 82
83/* Dialog */
84
85GtkWidget*
86gtk_dialog_get_vbox (GtkDialog *dialog)
87{
88 return dialog->vbox;
89}
90
91GtkWidget*
92gtk_dialog_get_action_area (GtkDialog *dialog)
93{
94 return dialog->action_area;
95}
96
97
98
3350ea74 99/* Window */
100
101GtkWidget*
102gtk_window_get_default (GtkWindow *window)
103{
104 return window->default_widget;
105}
106
4d16221f 107GtkWindowGroup*
108gtk_window_get_group (GtkWindow *window)
109{
110 return window->group;
111}
112
113
3350ea74 114
d76e9fca 115/* Window */
3350ea74 116
d76e9fca 117GdkScreen*
118gtk_menu_get_screen (GtkMenu *menu)
3350ea74 119{
d76e9fca 120 return (GdkScreen*)g_object_get_data (G_OBJECT (menu), "gtk-menu-explicit-screen");
3350ea74 121}
122
123
3350ea74 124
d76e9fca 125/* Layout */
3350ea74 126
d76e9fca 127GdkWindow*
128gtk_layout_get_bin_window (GtkLayout *layout)
129{
130 return layout->bin_window;
3350ea74 131}
132
133
3350ea74 134/* GtkStyle accessor functions */
135
136typedef enum {
137 GTK_COLOR_FG,
138 GTK_COLOR_BG,
139 GTK_COLOR_LIGHT,
140 GTK_COLOR_DARK,
141 GTK_COLOR_MID,
142 GTK_COLOR_TEXT,
143 GTK_COLOR_BASE,
ec0dd9ca 144 GTK_COLOR_TEXT_AA,
3350ea74 145 GTK_COLOR_WHITE,
146 GTK_COLOR_BLACK
147} GtkColorType;
148
149GdkColor*
150gtk_style_get_color (GtkStyle *style, GtkColorType color_type,
151 GtkStateType state)
152{
153 switch (color_type)
154 {
155 case GTK_COLOR_WHITE:
156 return &style->white;
157 case GTK_COLOR_BLACK:
158 return &style->black;
159 case GTK_COLOR_FG:
160 return &style->fg[state];
161 case GTK_COLOR_BG:
162 return &style->bg[state];
163 case GTK_COLOR_LIGHT:
164 return &style->light[state];
165 case GTK_COLOR_DARK:
166 return &style->dark[state];
167 case GTK_COLOR_MID:
168 return &style->mid[state];
169 case GTK_COLOR_TEXT:
170 return &style->text[state];
171 case GTK_COLOR_BASE:
172 return &style->base[state];
ec0dd9ca 173 case GTK_COLOR_TEXT_AA:
174 return &style->text_aa[state];
3350ea74 175 }
176}
177
178
ec0dd9ca 179void
3350ea74 180gtk_style_set_color (GtkStyle *style, GtkColorType color_type,
181 GtkStateType state, GdkColor *color)
182{
183 switch (color_type)
184 {
185 case GTK_COLOR_WHITE:
186 style->white = *color; break;
187 case GTK_COLOR_BLACK:
188 style->black = *color; break;
189 case GTK_COLOR_FG:
190 style->fg[state] = *color; break;
191 case GTK_COLOR_BG:
192 style->bg[state] = *color; break;
193 case GTK_COLOR_LIGHT:
194 style->light[state] = *color; break;
195 case GTK_COLOR_DARK:
196 style->dark[state] = *color; break;
197 case GTK_COLOR_MID:
198 style->mid[state] = *color; break;
199 case GTK_COLOR_TEXT:
200 style->text[state] = *color; break;
201 case GTK_COLOR_BASE:
202 style->base[state] = *color; break;
ec0dd9ca 203 case GTK_COLOR_TEXT_AA:
204 style->text_aa[state] = *color; break;
3350ea74 205 }
3350ea74 206}
207
3350ea74 208
209GdkGC*
210gtk_style_get_gc (GtkStyle *style, GtkColorType color_type, GtkStateType state)
211{
212 switch (color_type)
213 {
214 case GTK_COLOR_WHITE:
215 return style->white_gc;
216 case GTK_COLOR_BLACK:
217 return style->black_gc;
218 case GTK_COLOR_FG:
219 return style->fg_gc[state];
220 case GTK_COLOR_BG:
221 return style->bg_gc[state];
222 case GTK_COLOR_LIGHT:
223 return style->light_gc[state];
224 case GTK_COLOR_DARK:
225 return style->dark_gc[state];
226 case GTK_COLOR_MID:
227 return style->mid_gc[state];
228 case GTK_COLOR_TEXT:
229 return style->text_gc[state];
230 case GTK_COLOR_BASE:
231 return style->base_gc[state];
ec0dd9ca 232 case GTK_COLOR_TEXT_AA:
233 return style->text_aa_gc[state];
3350ea74 234 }
235}
ec0dd9ca 236
237int
238gtk_style_font_desc_offset ()
239{
240 GtkStyle style;
241
242 return (int)&style.font_desc - (int)&style;
243}
244