55212af1 |
1 | /* Common Lisp bindings for GTK+ v2.x |
2 | * Copyright 1999-2005 Espen S. Johnsen <espen@users.sf.net> |
4641cb32 |
3 | * |
55212af1 |
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: |
4641cb32 |
11 | * |
55212af1 |
12 | * The above copyright notice and this permission notice shall be |
13 | * included in all copies or substantial portions of the Software. |
4641cb32 |
14 | * |
55212af1 |
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. |
4641cb32 |
22 | */ |
23 | |
55212af1 |
24 | /* $Id: glue.c,v 1.8 2005/04/23 16:48:52 espen Exp $ */ |
4641cb32 |
25 | |
26 | |
27 | #include <gtk/gtk.h> |
28 | |
29 | |
30 | /* |
31 | * |
32 | * Gtk helper functions |
33 | * |
34 | */ |
35 | |
36 | void |
37 | gtk_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 | |
4641cb32 |
45 | /* Widget */ |
46 | |
47 | GdkWindow* |
48 | gtk_widget_get_window (GtkWidget *widget) |
49 | { |
50 | return widget->window; |
51 | } |
52 | |
53 | GtkStateType |
54 | gtk_widget_get_state (GtkWidget *widget) |
55 | { |
56 | return widget->state; |
57 | } |
58 | |
59 | gboolean |
60 | gtk_widget_mapped_p (GtkWidget *widget) |
61 | { |
62 | return GTK_WIDGET_MAPPED (widget); |
63 | } |
64 | |
65 | void |
66 | gtk_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 | |
75 | GtkWidget* |
76 | gtk_container_get_focus_child (GtkContainer *container) |
77 | { |
78 | return container->focus_child; |
79 | } |
80 | |
14eaa563 |
81 | gboolean |
82 | gtk_container_get_reallocate_redraws (GtkContainer *container) |
83 | { |
84 | return container->reallocate_redraws; |
85 | } |
86 | |
4641cb32 |
87 | |
88 | /* Dialog */ |
89 | |
90 | GtkWidget* |
91 | gtk_dialog_get_vbox (GtkDialog *dialog) |
92 | { |
93 | return dialog->vbox; |
94 | } |
95 | |
96 | GtkWidget* |
97 | gtk_dialog_get_action_area (GtkDialog *dialog) |
98 | { |
99 | return dialog->action_area; |
100 | } |
101 | |
102 | |
103 | |
4641cb32 |
104 | /* Window */ |
105 | |
106 | GtkWidget* |
107 | gtk_window_get_default (GtkWindow *window) |
108 | { |
109 | return window->default_widget; |
110 | } |
111 | |
4eed43f1 |
112 | GtkWindowGroup* |
113 | gtk_window_get_group (GtkWindow *window) |
114 | { |
115 | return window->group; |
116 | } |
117 | |
118 | |
4641cb32 |
119 | |
d155cc82 |
120 | /* Menu */ |
4641cb32 |
121 | |
14eaa563 |
122 | GdkScreen* |
123 | gtk_menu_get_screen (GtkMenu *menu) |
4641cb32 |
124 | { |
14eaa563 |
125 | return (GdkScreen*)g_object_get_data (G_OBJECT (menu), "gtk-menu-explicit-screen"); |
4641cb32 |
126 | } |
127 | |
128 | |
4641cb32 |
129 | |
d155cc82 |
130 | /* Toolbar */ |
131 | |
132 | GtkTooltips* |
133 | gtk_toolbar_get_tooltips_object (GtkToolbar *toolbar) |
134 | { |
135 | return toolbar->tooltips; |
136 | } |
137 | |
138 | |
139 | |
140 | /* Tooltips */ |
141 | |
142 | gint |
143 | gtk_tooltips_get_enabled (GtkTooltips *tooltips) |
144 | { |
145 | return tooltips->enabled; |
146 | } |
147 | |
148 | |
14eaa563 |
149 | /* Layout */ |
4641cb32 |
150 | |
14eaa563 |
151 | GdkWindow* |
152 | gtk_layout_get_bin_window (GtkLayout *layout) |
153 | { |
154 | return layout->bin_window; |
4641cb32 |
155 | } |
156 | |
157 | |
4641cb32 |
158 | /* GtkStyle accessor functions */ |
159 | |
160 | typedef 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, |
ce844863 |
168 | GTK_COLOR_TEXT_AA, |
4641cb32 |
169 | GTK_COLOR_WHITE, |
170 | GTK_COLOR_BLACK |
171 | } GtkColorType; |
172 | |
173 | GdkColor* |
174 | gtk_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]; |
ce844863 |
197 | case GTK_COLOR_TEXT_AA: |
198 | return &style->text_aa[state]; |
4641cb32 |
199 | } |
200 | } |
201 | |
202 | |
ce844863 |
203 | void |
4641cb32 |
204 | gtk_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; |
ce844863 |
227 | case GTK_COLOR_TEXT_AA: |
228 | style->text_aa[state] = *color; break; |
4641cb32 |
229 | } |
4641cb32 |
230 | } |
231 | |
4641cb32 |
232 | |
233 | GdkGC* |
234 | gtk_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]; |
ce844863 |
256 | case GTK_COLOR_TEXT_AA: |
257 | return style->text_aa_gc[state]; |
4641cb32 |
258 | } |
259 | } |
ce844863 |
260 | |
261 | int |
262 | gtk_style_font_desc_offset () |
263 | { |
264 | GtkStyle style; |
265 | |
266 | return (int)&style.font_desc - (int)&style; |
267 | } |
268 | |