1 /*
2  * (SLIK) SimpLIstic sKin functions
3  * (C) 2005 John Ellis
4  *
5  * Author: John Ellis
6  *
7  * This software is released under the GNU General Public License (GNU GPL).
8  * Please read the included file COPYING for more information.
9  * This software comes with no warranty of any kind, use at your own risk!
10  */
11 
12 #ifndef UI2_TYPEDEFS_H
13 #define UI2_TYPEDEFS_H
14 
15 
16 /*
17  *-------------------------------------
18  * SLIK defines
19  *-------------------------------------
20  */
21 
22 #define SLIK_VERSION "0.92.0"
23 
24 #define SKIN_SIZE_MIN 4
25 #define SKIN_SIZE_MAX 2000
26 
27 /*
28  *-------------------------------------
29  * SLIK data structures
30  *-------------------------------------
31  */
32 
33 typedef gint WidgetType;
34 
35 typedef struct _WidgetObjectData WidgetObjectData;
36 typedef struct _WidgetData WidgetData;
37 
38 typedef struct _UIData UIData;
39 typedef struct _RegisterData RegisterData;
40 typedef struct _SkinData SkinData;
41 
42 typedef struct _EditData EditData;
43 
44 
45 struct _WidgetObjectData
46 {
47 	WidgetType type;
48 	gchar *description;
49 
50 	gint is_visible;
51 
52 	gint priority;
53 
54 	/* general ui */
55 	void (*func_draw)(gpointer widget, const gchar *key, gint update, gint force, GdkPixbuf *pb, UIData *ui);
56 	void (*func_reset)(gpointer widget, const gchar *key, GdkPixbuf *pb, UIData *ui);
57 	gint (*func_press)(gpointer widget, const gchar *key, gint x, gint y, GdkPixbuf *pb, UIData *ui);
58 	void (*func_release)(gpointer widget, const gchar *key, gint x, gint y, GdkPixbuf *pb, UIData *ui);
59 	void (*func_motion)(gpointer widget, const gchar *key, gint x, gint y, GdkPixbuf *pb, UIData *ui);
60 	void (*func_back)(gpointer widget, GdkPixbuf *pb);
61 	void (*func_free)(gpointer widget);
62 
63 	gint (*func_get_geometry)(gpointer widget, gint *x, gint *y, gint *w, gint *h);
64 	void (*func_set_coord)(gpointer widget, gint x, gint y);
65 	void (*func_set_size)(gpointer widget, gint dev_w, gint dev_h);
66 
67 	/* focus stuff */
68 	gint (*func_focus_draw)(gpointer widget, const gchar *key,
69 				gint x, gint y, gint w, gint h, GdkPixbuf *pb, UIData *ui);
70 	gint (*func_focus_key_event)(gpointer widget, const gchar *key, GdkEventKey *event, GdkPixbuf *pb, UIData *ui);
71 
72 	/* loading */
73 	WidgetData *(*func_parse)(SkinData *skin, GList *list, const gchar *skin_dir, const gchar *key, gint edit);
74 
75 	/* internal widget init stuff */
76 	void (*func_init)(gpointer widget, const gchar *key, UIData *ui);
77 
78 	/* editor */
79 	GdkPixbuf *(*func_get_pixbuf)(gpointer widget);
80 
81 	void (*func_edit_write)(FILE *f, WidgetData *wd, SkinData *skin, const gchar *dir);
82 	gpointer (*func_edit_read)(UIData *ui, WidgetData *wd, GList *list);
83 	void (*func_edit_free)(gpointer data);
84 
85 	gpointer (*func_edit_props)(UIData *ui, WidgetData *wd, GtkWidget *vbox, gpointer detail);
86 	GtkWidget *(*func_edit_page_new)(EditData *ed);
87 	void (*func_edit_page_add)(GtkWidget *widget, gpointer data);
88 
89 	gint (*func_edit_removable)(gpointer widget);
90 };
91 
92 
93 struct _WidgetData
94 {
95 	WidgetType type;
96 	gchar *key;
97 	gchar *text_id;
98 	gpointer widget;
99 	GList *data_list;
100 
101 	const WidgetObjectData *od;
102 
103 	gint hidden;
104 	gint in_bounds;
105 
106 	gint anchor_right;
107 	gint anchor_bottom;
108 
109 	gint exclusive;
110 };
111 
112 
113 struct _RegisterData
114 {
115 	WidgetType type;
116 	gchar *key;
117 	gchar *tooltip;
118 	gpointer callbacks;	/* struct containing update functions */
119 	guint callbacks_l;	/* byte size of callback data (used for copying) */
120 	gint private;		/* signal is internal to skin widgets ? (cleared on every skin change) */
121 	gpointer private_widget;	/* pointer to widget that holds this key (only used on unreg) */
122 };
123 
124 
125 struct _SkinData
126 {
127 	GdkPixbuf *overlay;	/* background */
128 	GdkPixbuf *pixbuf;	/* pixbuf */
129 	GdkPixmap *buffer;	/* offscreen buffer */
130 	GdkPixbuf *mask;	/* shape mask */
131 	GdkBitmap *mask_buffer;	/* bitmap version of mask */
132 	gint width;
133 	gint height;
134 	gint transparent;
135 
136 	GdkPixbuf *real_overlay;	/* used to hold original image for borders / stretch / resize */
137 
138 	gint stretch;		/* stretch image to a size? (width, height) */
139 
140 	/* borders */
141 	gint has_border;
142 	gint border_left;
143 	gint border_right;
144 	gint border_top;
145 	gint border_bottom;
146 	gint border_left_stretch;
147 	gint border_right_stretch;
148 	gint border_top_stretch;
149 	gint border_bottom_stretch;
150 
151 	/* resizing */
152 	gint sizeable;
153 	gint width_def;
154 	gint width_min;
155 	gint width_max;
156 	gint width_inc;
157 	gint height_def;
158 	gint height_min;
159 	gint height_max;
160 	gint height_inc;
161 
162 	/* focus */
163 	GdkPixbuf *focus_overlay;
164 	gint focus_stretch;
165 	gint focus_has_border;
166 	gint focus_border_left;
167 	gint focus_border_right;
168 	gint focus_border_top;
169 	gint focus_border_bottom;
170 	gint focus_anchor_right;
171 	gint focus_anchor_bottom;
172 
173 	gint focus_box_filled;
174 	guint8 focus_box_alpha;
175 	guint8 focus_box_r;
176 	guint8 focus_box_g;
177 	guint8 focus_box_b;
178 
179 	GList *data_list;	/* stores key/value pairs data for use by apps */
180 
181 	GList *widget_list;	/* widget list of WidgetData structs */
182 
183 	UIData *ui;		/* ui attached to */
184 
185 	gchar *background_filename;		/* used by editor */
186 	gchar *background_mask_filename;	/* " */
187 	gchar *focus_filename;
188 
189 	/* used by widgets that need extra offscreen scratch areas to work in */
190 	GdkPixbuf *scratch_pixbuf;
191 	GdkPixmap *scratch_pixmap;
192 
193 	/* delayed idle resize */
194 	gint resize_idle_id;
195 	gint resize_idle_width;
196 	gint resize_idle_height;
197 };
198 
199 
200 struct _UIData
201 {
202 	GtkWidget *window;
203 	GtkWidget *display;
204 
205 	gchar *key;		/* key to reference ui */
206 	gchar *class;		/* window class */
207 
208 	GList *register_list;	/* list of registered functions */
209 	SkinData *skin;
210 	gchar *skin_path;	/* location of skin, NULL for default? */
211 	gchar *skin_mode_key;	/* filename of skindata equivelent, NULL for default */
212 
213 	gint decorations;	/* show decorations */
214 	gint allow_move;	/* move by dragging mouse */
215 	gint focus_enable;	/* force keyboard focus on, usually only for menus */
216 	gint tooltips_enable;	/* enable display of tooltips */
217 
218 	gint sticky;		/* sticky */
219 
220 	/* called for click on a button greater than 2 (3, 4, 5, etc.) */
221 	void (*click_func)(UIData *ui, gint button, guint32 time, gpointer data);
222 	gpointer click_data;
223 
224 	/* default skin handler (used as last resort backup) */
225 	SkinData *(*skin_func)(UIData *ui, const gchar *key, gpointer data);
226 	gpointer skin_data;
227 
228 	/* called to request a background update, return TRUE if you set it */
229 	gint (*back_func)(UIData *ui, GdkPixbuf *pixbuf, gpointer data);
230 	gpointer back_data;
231 
232 	/* called when a new child window has opened */
233 	void (*new_window_func)(UIData *ui, const gchar *key, gpointer data);
234 	gpointer new_window_data;
235 
236 	/* called just before skin is set */
237 	void (*new_skin_func)(UIData *ui, SkinData *skin, gint initialized, gpointer data);
238 	gpointer new_skin_data;
239 
240 	WidgetData *active_widget;	/* widget with the mouse grab */
241 	gint in_press;
242 	gint in_move;
243 
244 	gint press_x;
245 	gint press_y;
246 	gint press_root_x;
247 	gint press_root_y;
248 
249 	WidgetData *focus_widget;
250 
251 	gint frozen;
252 
253 	gint root_win_idle;
254 
255 	/* groups */
256 	UIData *parent;
257 	GList *children;
258 
259 	UIData *edit;
260 
261 	gint destroyed;
262 };
263 
264 
265 struct _EditData
266 {
267 	GtkWidget *window;
268 	GtkWidget *table;
269 	UIData *ui;
270 	UIData *parent;	/* UI being edited */
271 
272 	/* the rest is private (and should be made that way) */
273 
274 	WidgetData *active_widget;
275 	gint in_press;
276 	gint in_move;
277 
278 	gint press_widget_x;
279 	gint press_widget_y;
280 	gint press_x;
281 	gint press_y;
282 
283 	WidgetData *info_widget;
284 
285 	GtkWidget *widget_list;
286 	GtkWidget *spin_x;
287 	GtkWidget *spin_y;
288 	GtkWidget *description;
289 	GtkWidget *key_combo_entry;
290 	GtkWidget *data_entry;
291 	GtkWidget *text_id_entry;
292 	GtkWidget *image_entry;
293 	GtkWidget *widget_image;
294 	GtkWidget *clip_mask_entry;
295 
296 	GtkWidget *anchor_right_button;
297 	GtkWidget *anchor_bottom_button;
298 	GtkWidget *exclusive_button;
299 
300 	GtkWidget *detail_vbox;
301 	GtkWidget *details;
302 	gpointer detail_data;
303 	WidgetType detail_type;
304 
305 	gint click_to_focus;
306 
307 	GtkWidget *save_path_entry;
308 	GtkWidget *save_key_entry;
309 
310 	/* widget addition dialog */
311 	GtkWidget *widget_window;
312 	GtkWidget *notebook;
313 
314 	GtkWidget *import_path_entry;
315 
316 	GList *widget_id_list;		/* list of 'widget type' data pointers */
317 
318 	GList *main_list;		/* list of 'add' backgrounds */
319 	GList *focus_list;
320 	gpointer main_page;		/* pointer to background page 'add' data */
321 
322 	/* help dialog */
323 	GtkWidget *help_window;
324 	gint help_follow;
325 
326 	gchar *help_path;
327 
328 	/* comments */
329 	GtkWidget *comment_window;
330 	GtkWidget *comment_title_entry;
331 	GtkWidget *comment_version_entry;
332 	GtkWidget *comment_author_entry;
333 	GtkWidget *comment_email_entry;
334 	GtkWidget *comment_url_entry;
335 	GtkWidget *comment_license_entry;
336 	GtkWidget *comment_misc_entry;
337 	GtkWidget *comment_build_spin;
338 	GtkWidget *comment_stamp_label;
339 
340 	gchar *comment_title;
341 	gchar *comment_version;
342 	gchar *comment_author;
343 	gchar *comment_email;
344 	gchar *comment_url;
345 	gchar *comment_license;
346 	gchar *comment_misc;
347 	gint comment_build;
348 	gchar *comment_stamp;
349 };
350 
351 
352 /*
353  *-------------------------------------
354  * SLIK globals
355  *-------------------------------------
356  */
357 
358 extern gint slik_smart_placement;
359 extern gint slik_remember_position;
360 
361 extern gint slik_focus_enable;
362 
363 extern gint slik_double_size;
364 
365 extern gint slik_scale;			/* set this before calling skin_parse to auto-scale a skin */
366 extern gfloat slik_scale_value;		/* be carefull with value, some skins may crash when scaled */
367 extern gint slik_allow_shapes;		/* set FALSE to disallow setting of shaped windows */
368 
369 extern gint slik_colorshift_r;
370 extern gint slik_colorshift_g;
371 extern gint slik_colorshift_b;
372 extern gint slik_colorshift_a;
373 extern gint slik_colorshift_on;
374 
375 extern gint slik_transparency_force;
376 extern gint slik_transparency_force_a;
377 
378 extern gint debug_mode;
379 extern gint debug_skin;
380 
381 
382 #endif
383 
384 
385 
386 
387