4641cb32 |
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 | |
41a559d2 |
19 | /* $Id: glue.c,v 1.4 2004/12/20 20:00:46 espen Exp $ */ |
4641cb32 |
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 | |
4641cb32 |
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 | |
4641cb32 |
93 | /* Window */ |
94 | |
95 | GtkWidget* |
96 | gtk_window_get_default (GtkWindow *window) |
97 | { |
98 | return window->default_widget; |
99 | } |
100 | |
101 | |
4641cb32 |
102 | /* Layout */ |
103 | |
104 | GdkWindow* |
105 | gtk_layout_get_bin_window (GtkLayout *layout) |
106 | { |
107 | return layout->bin_window; |
108 | } |
109 | |
110 | |
4641cb32 |
111 | /* Drawing area */ |
112 | |
113 | void |
114 | gtk_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 | |
4641cb32 |
124 | /* GtkStyle accessor functions */ |
125 | |
126 | typedef 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, |
ce844863 |
134 | GTK_COLOR_TEXT_AA, |
4641cb32 |
135 | GTK_COLOR_WHITE, |
136 | GTK_COLOR_BLACK |
137 | } GtkColorType; |
138 | |
139 | GdkColor* |
140 | gtk_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]; |
ce844863 |
163 | case GTK_COLOR_TEXT_AA: |
164 | return &style->text_aa[state]; |
4641cb32 |
165 | } |
166 | } |
167 | |
168 | |
ce844863 |
169 | void |
4641cb32 |
170 | gtk_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; |
ce844863 |
193 | case GTK_COLOR_TEXT_AA: |
194 | style->text_aa[state] = *color; break; |
4641cb32 |
195 | } |
4641cb32 |
196 | } |
197 | |
4641cb32 |
198 | |
199 | GdkGC* |
200 | gtk_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]; |
ce844863 |
222 | case GTK_COLOR_TEXT_AA: |
223 | return style->text_aa_gc[state]; |
4641cb32 |
224 | } |
225 | } |
ce844863 |
226 | |
227 | int |
228 | gtk_style_font_desc_offset () |
229 | { |
230 | GtkStyle style; |
231 | |
232 | return (int)&style.font_desc - (int)&style; |
233 | } |
234 | |