chiark / gitweb /
Changed to MIT license
[clg] / gtk / alien / glue.c
CommitLineData
112ac1d3 1/* Common Lisp bindings for GTK+ v2.x
2 * Copyright 1999-2005 Espen S. Johnsen <espen@users.sf.net>
3350ea74 3 *
112ac1d3 4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sublicense, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
3350ea74 11 *
112ac1d3 12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
3350ea74 14 *
112ac1d3 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3350ea74 22 */
23
112ac1d3 24/* $Id: glue.c,v 1.8 2005-04-23 16:48:52 espen Exp $ */
3350ea74 25
26
27#include <gtk/gtk.h>
28
29
30/*
31 *
32 * Gtk helper functions
33 *
34 */
35
36void
37gtk_query_version (guint *major, guint *minor, guint *micro)
38{
39 *major = gtk_major_version;
40 *minor = gtk_minor_version;
41 *micro = gtk_micro_version;
42}
43
44
3350ea74 45/* Widget */
46
47GdkWindow*
48gtk_widget_get_window (GtkWidget *widget)
49{
50 return widget->window;
51}
52
53GtkStateType
54gtk_widget_get_state (GtkWidget *widget)
55{
56 return widget->state;
57}
58
59gboolean
60gtk_widget_mapped_p (GtkWidget *widget)
61{
62 return GTK_WIDGET_MAPPED (widget);
63}
64
65void
66gtk_widget_get_size_allocation (GtkWidget *widget, int *width, int *height)
67{
68 *width = widget->allocation.width;
69 *height = widget->allocation.height;
70}
71
72
73/* Container */
74
75GtkWidget*
76gtk_container_get_focus_child (GtkContainer *container)
77{
78 return container->focus_child;
79}
80
d76e9fca 81gboolean
82gtk_container_get_reallocate_redraws (GtkContainer *container)
83{
84 return container->reallocate_redraws;
85}
86
3350ea74 87
88/* Dialog */
89
90GtkWidget*
91gtk_dialog_get_vbox (GtkDialog *dialog)
92{
93 return dialog->vbox;
94}
95
96GtkWidget*
97gtk_dialog_get_action_area (GtkDialog *dialog)
98{
99 return dialog->action_area;
100}
101
102
103
3350ea74 104/* Window */
105
106GtkWidget*
107gtk_window_get_default (GtkWindow *window)
108{
109 return window->default_widget;
110}
111
4d16221f 112GtkWindowGroup*
113gtk_window_get_group (GtkWindow *window)
114{
115 return window->group;
116}
117
118
3350ea74 119
f6fc1365 120/* Menu */
3350ea74 121
d76e9fca 122GdkScreen*
123gtk_menu_get_screen (GtkMenu *menu)
3350ea74 124{
d76e9fca 125 return (GdkScreen*)g_object_get_data (G_OBJECT (menu), "gtk-menu-explicit-screen");
3350ea74 126}
127
128
3350ea74 129
f6fc1365 130/* Toolbar */
131
132GtkTooltips*
133gtk_toolbar_get_tooltips_object (GtkToolbar *toolbar)
134{
135 return toolbar->tooltips;
136}
137
138
139
140/* Tooltips */
141
142gint
143gtk_tooltips_get_enabled (GtkTooltips *tooltips)
144{
145 return tooltips->enabled;
146}
147
148
d76e9fca 149/* Layout */
3350ea74 150
d76e9fca 151GdkWindow*
152gtk_layout_get_bin_window (GtkLayout *layout)
153{
154 return layout->bin_window;
3350ea74 155}
156
157
3350ea74 158/* GtkStyle accessor functions */
159
160typedef enum {
161 GTK_COLOR_FG,
162 GTK_COLOR_BG,
163 GTK_COLOR_LIGHT,
164 GTK_COLOR_DARK,
165 GTK_COLOR_MID,
166 GTK_COLOR_TEXT,
167 GTK_COLOR_BASE,
ec0dd9ca 168 GTK_COLOR_TEXT_AA,
3350ea74 169 GTK_COLOR_WHITE,
170 GTK_COLOR_BLACK
171} GtkColorType;
172
173GdkColor*
174gtk_style_get_color (GtkStyle *style, GtkColorType color_type,
175 GtkStateType state)
176{
177 switch (color_type)
178 {
179 case GTK_COLOR_WHITE:
180 return &style->white;
181 case GTK_COLOR_BLACK:
182 return &style->black;
183 case GTK_COLOR_FG:
184 return &style->fg[state];
185 case GTK_COLOR_BG:
186 return &style->bg[state];
187 case GTK_COLOR_LIGHT:
188 return &style->light[state];
189 case GTK_COLOR_DARK:
190 return &style->dark[state];
191 case GTK_COLOR_MID:
192 return &style->mid[state];
193 case GTK_COLOR_TEXT:
194 return &style->text[state];
195 case GTK_COLOR_BASE:
196 return &style->base[state];
ec0dd9ca 197 case GTK_COLOR_TEXT_AA:
198 return &style->text_aa[state];
3350ea74 199 }
200}
201
202
ec0dd9ca 203void
3350ea74 204gtk_style_set_color (GtkStyle *style, GtkColorType color_type,
205 GtkStateType state, GdkColor *color)
206{
207 switch (color_type)
208 {
209 case GTK_COLOR_WHITE:
210 style->white = *color; break;
211 case GTK_COLOR_BLACK:
212 style->black = *color; break;
213 case GTK_COLOR_FG:
214 style->fg[state] = *color; break;
215 case GTK_COLOR_BG:
216 style->bg[state] = *color; break;
217 case GTK_COLOR_LIGHT:
218 style->light[state] = *color; break;
219 case GTK_COLOR_DARK:
220 style->dark[state] = *color; break;
221 case GTK_COLOR_MID:
222 style->mid[state] = *color; break;
223 case GTK_COLOR_TEXT:
224 style->text[state] = *color; break;
225 case GTK_COLOR_BASE:
226 style->base[state] = *color; break;
ec0dd9ca 227 case GTK_COLOR_TEXT_AA:
228 style->text_aa[state] = *color; break;
3350ea74 229 }
3350ea74 230}
231
3350ea74 232
233GdkGC*
234gtk_style_get_gc (GtkStyle *style, GtkColorType color_type, GtkStateType state)
235{
236 switch (color_type)
237 {
238 case GTK_COLOR_WHITE:
239 return style->white_gc;
240 case GTK_COLOR_BLACK:
241 return style->black_gc;
242 case GTK_COLOR_FG:
243 return style->fg_gc[state];
244 case GTK_COLOR_BG:
245 return style->bg_gc[state];
246 case GTK_COLOR_LIGHT:
247 return style->light_gc[state];
248 case GTK_COLOR_DARK:
249 return style->dark_gc[state];
250 case GTK_COLOR_MID:
251 return style->mid_gc[state];
252 case GTK_COLOR_TEXT:
253 return style->text_gc[state];
254 case GTK_COLOR_BASE:
255 return style->base_gc[state];
ec0dd9ca 256 case GTK_COLOR_TEXT_AA:
257 return style->text_aa_gc[state];
3350ea74 258 }
259}
ec0dd9ca 260
261int
262gtk_style_font_desc_offset ()
263{
264 GtkStyle style;
265
266 return (int)&style.font_desc - (int)&style;
267}
268