chiark / gitweb /
Renamed CHILD-SLOTS to CHILD-PROPERTIES
[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
59792174 19/* $Id: glue.c,v 1.4 2004-12-20 20:00:46 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/* Layout */
103
104GdkWindow*
105gtk_layout_get_bin_window (GtkLayout *layout)
106{
107 return layout->bin_window;
108}
109
110
3350ea74 111/* Drawing area */
112
113void
114gtk_drawing_area_get_size (GtkDrawingArea *darea, gint *width, gint *height)
115{
116 GtkWidget *widget;
117
118 widget = GTK_WIDGET (darea);
119 *width = widget->allocation.width;
120 *height = widget->allocation.height;
121}
122
123
3350ea74 124/* GtkStyle accessor functions */
125
126typedef enum {
127 GTK_COLOR_FG,
128 GTK_COLOR_BG,
129 GTK_COLOR_LIGHT,
130 GTK_COLOR_DARK,
131 GTK_COLOR_MID,
132 GTK_COLOR_TEXT,
133 GTK_COLOR_BASE,
ec0dd9ca 134 GTK_COLOR_TEXT_AA,
3350ea74 135 GTK_COLOR_WHITE,
136 GTK_COLOR_BLACK
137} GtkColorType;
138
139GdkColor*
140gtk_style_get_color (GtkStyle *style, GtkColorType color_type,
141 GtkStateType state)
142{
143 switch (color_type)
144 {
145 case GTK_COLOR_WHITE:
146 return &style->white;
147 case GTK_COLOR_BLACK:
148 return &style->black;
149 case GTK_COLOR_FG:
150 return &style->fg[state];
151 case GTK_COLOR_BG:
152 return &style->bg[state];
153 case GTK_COLOR_LIGHT:
154 return &style->light[state];
155 case GTK_COLOR_DARK:
156 return &style->dark[state];
157 case GTK_COLOR_MID:
158 return &style->mid[state];
159 case GTK_COLOR_TEXT:
160 return &style->text[state];
161 case GTK_COLOR_BASE:
162 return &style->base[state];
ec0dd9ca 163 case GTK_COLOR_TEXT_AA:
164 return &style->text_aa[state];
3350ea74 165 }
166}
167
168
ec0dd9ca 169void
3350ea74 170gtk_style_set_color (GtkStyle *style, GtkColorType color_type,
171 GtkStateType state, GdkColor *color)
172{
173 switch (color_type)
174 {
175 case GTK_COLOR_WHITE:
176 style->white = *color; break;
177 case GTK_COLOR_BLACK:
178 style->black = *color; break;
179 case GTK_COLOR_FG:
180 style->fg[state] = *color; break;
181 case GTK_COLOR_BG:
182 style->bg[state] = *color; break;
183 case GTK_COLOR_LIGHT:
184 style->light[state] = *color; break;
185 case GTK_COLOR_DARK:
186 style->dark[state] = *color; break;
187 case GTK_COLOR_MID:
188 style->mid[state] = *color; break;
189 case GTK_COLOR_TEXT:
190 style->text[state] = *color; break;
191 case GTK_COLOR_BASE:
192 style->base[state] = *color; break;
ec0dd9ca 193 case GTK_COLOR_TEXT_AA:
194 style->text_aa[state] = *color; break;
3350ea74 195 }
3350ea74 196}
197
3350ea74 198
199GdkGC*
200gtk_style_get_gc (GtkStyle *style, GtkColorType color_type, GtkStateType state)
201{
202 switch (color_type)
203 {
204 case GTK_COLOR_WHITE:
205 return style->white_gc;
206 case GTK_COLOR_BLACK:
207 return style->black_gc;
208 case GTK_COLOR_FG:
209 return style->fg_gc[state];
210 case GTK_COLOR_BG:
211 return style->bg_gc[state];
212 case GTK_COLOR_LIGHT:
213 return style->light_gc[state];
214 case GTK_COLOR_DARK:
215 return style->dark_gc[state];
216 case GTK_COLOR_MID:
217 return style->mid_gc[state];
218 case GTK_COLOR_TEXT:
219 return style->text_gc[state];
220 case GTK_COLOR_BASE:
221 return style->base_gc[state];
ec0dd9ca 222 case GTK_COLOR_TEXT_AA:
223 return style->text_aa_gc[state];
3350ea74 224 }
225}
ec0dd9ca 226
227int
228gtk_style_font_desc_offset ()
229{
230 GtkStyle style;
231
232 return (int)&style.font_desc - (int)&style;
233}
234