Mercurial > dwindows
annotate gtk/dw.c @ 36:cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
some GTK fixes.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 17 Sep 2001 09:15:40 +0000 |
parents | b03b24bb95f8 |
children | 360bc6a5f1c9 |
rev | line source |
---|---|
3 | 1 /* |
2 * Dynamic Windows: | |
3 * A GTK like implementation of the PM GUI | |
4 * GTK forwarder module for portabilty. | |
5 * | |
6 * (C) 2000,2001 Brian Smith <dbsoft@technologist.com> | |
7 * | |
8 */ | |
9 #include "dw.h" | |
10 #include <string.h> | |
11 #include <stdlib.h> | |
12 #include <sys/utsname.h> | |
13 #include <stdarg.h> | |
14 #include <stdio.h> | |
15 #include <unistd.h> | |
16 #include <errno.h> | |
17 #include <sys/time.h> | |
18 #include "config.h" | |
19 #ifdef USE_IMLIB | |
20 #include <gdk_imlib.h> | |
21 #endif | |
22 | |
23 /* These are used for resource management */ | |
24 #if defined(DW_RESOURCES) && !defined(BUILD_DLL) | |
25 extern DWResources _resources; | |
26 #endif | |
27 | |
28 char monthlist[][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", | |
29 "Sep", "Oct", "Nov", "Dec" }; | |
30 GdkColor _colors[] = | |
31 { | |
32 { 0, 0x0000, 0x0000, 0x0000 }, /* 0 black */ | |
33 { 0, 0xbbbb, 0x0000, 0x0000 }, /* 1 red */ | |
34 { 0, 0x0000, 0xbbbb, 0x0000 }, /* 2 green */ | |
35 { 0, 0xaaaa, 0xaaaa, 0x0000 }, /* 3 yellow */ | |
36 { 0, 0x0000, 0x0000, 0xcccc }, /* 4 blue */ | |
37 { 0, 0xbbbb, 0x0000, 0xbbbb }, /* 5 magenta */ | |
38 { 0, 0x0000, 0xbbbb, 0xbbbb }, /* 6 cyan */ | |
39 { 0, 0xaaaa, 0xaaaa, 0xaaaa }, /* 7 white */ | |
40 { 0, 0x7777, 0x7777, 0x7777 }, /* 8 grey */ | |
41 { 0, 0xffff, 0x0000, 0x0000 }, /* 9 bright red */ | |
42 { 0, 0x0000, 0xffff, 0x0000 }, /* 10 bright green */ | |
43 { 0, 0xeeee, 0xeeee, 0x0000 }, /* 11 bright yellow */ | |
44 { 0, 0x0000, 0x0000, 0xffff }, /* 12 bright blue */ | |
45 { 0, 0xffff, 0x0000, 0xffff }, /* 13 bright magenta */ | |
46 { 0, 0x0000, 0xeeee, 0xeeee }, /* 14 bright cyan */ | |
47 { 0, 0xffff, 0xffff, 0xffff }, /* 15 bright white */ | |
48 }; | |
49 | |
50 GdkColor _foreground = { 0, 0x0000, 0x0000, 0x0000 }; | |
51 GdkColor _background = { 0, 0xaaaa, 0xaaaa, 0xaaaa }; | |
52 | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
53 int _dw_file_active = 0, _dw_ignore_click = 0; |
3 | 54 pthread_t _dw_thread = (pthread_t)-1; |
55 int _dw_mutex_locked = FALSE; | |
56 | |
57 #define DW_MUTEX_LOCK { if(pthread_self() != _dw_thread && _dw_mutex_locked == FALSE) { gdk_threads_enter(); _dw_mutex_locked = TRUE; _locked_by_me = TRUE; } } | |
58 #define DW_MUTEX_UNLOCK { if(pthread_self() != _dw_thread && _locked_by_me == TRUE) { gdk_threads_leave(); _dw_mutex_locked = FALSE; _locked_by_me = FALSE; } } | |
59 | |
60 /* Currently the non Imlib method does not work */ | |
61 #ifndef USE_IMLIB | |
62 #define USE_IMLIB | |
63 #endif | |
64 | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
65 #define DEFAULT_SIZE_WIDTH 12 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
66 #define DEFAULT_SIZE_HEIGHT 6 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
67 #define DEFAULT_TITLEBAR_HEIGHT 22 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
68 |
3 | 69 GdkColormap *_dw_cmap = NULL; |
70 | |
71 /* Signal forwarder prototypes */ | |
72 gint _button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data); | |
73 gint _button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer data); | |
74 gint _motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer data); | |
75 gint _delete_event(GtkWidget *widget, GdkEvent *event, gpointer data); | |
76 gint _key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data); | |
77 gint _generic_event(GtkWidget *widget, gpointer data); | |
78 gint _configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data); | |
79 void _activate_event(GtkWidget *widget, gpointer data); | |
80 void _container_select_event(GtkWidget *widget, GdkEventButton *event, gpointer data); | |
81 void _container_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data); | |
82 void _item_select_event(GtkWidget *widget, GtkWidget *child, gpointer data); | |
83 void _expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data); | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
84 void _set_focus_event(GtkWindow *window, GtkWidget *widget, gpointer data); |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
85 void _tree_select_event(GtkTree *tree, GtkWidget *child, gpointer data); |
3 | 86 |
87 typedef struct | |
88 { | |
89 void *func; | |
90 char name[30]; | |
91 | |
92 } SignalList; | |
93 | |
94 typedef struct | |
95 { | |
96 HWND window; | |
97 void *func; | |
98 gpointer data; | |
99 | |
100 } SignalHandler; | |
101 | |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
102 #define SIGNALMAX 14 |
3 | 103 |
104 /* A list of signal forwarders, to account for paramater differences. */ | |
105 SignalList SignalTranslate[SIGNALMAX] = { | |
106 { _configure_event, "configure_event" }, | |
107 { _key_press_event, "key_press_event" }, | |
108 { _button_press_event, "button_press_event" }, | |
109 { _button_release_event, "button_release_event" }, | |
110 { _motion_notify_event, "motion_notify_event" }, | |
111 { _delete_event, "delete_event" }, | |
112 { _expose_event, "expose_event" }, | |
113 { _activate_event, "activate" }, | |
114 { _generic_event, "clicked" }, | |
115 { _container_select_event, "container-select" }, | |
116 { _container_context_event, "container-context" }, | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
117 { _item_select_event, "item-select" }, |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
118 { _tree_select_event, "tree-select" }, |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
119 { _set_focus_event, "set-focus" } |
3 | 120 }; |
121 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
122 /* Alignment flags */ |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
123 #define DW_CENTER 0.5f |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
124 #define DW_LEFT 0.0f |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
125 #define DW_RIGHT 1.0f |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
126 |
3 | 127 /* Finds the translation function for a given signal name */ |
128 void *_findsigfunc(char *signame) | |
129 { | |
130 int z; | |
131 | |
132 for(z=0;z<SIGNALMAX;z++) | |
133 { | |
134 if(strcasecmp(signame, SignalTranslate[z].name) == 0) | |
135 return SignalTranslate[z].func; | |
136 } | |
137 return NULL; | |
138 } | |
139 | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
140 void _set_focus_event(GtkWindow *window, GtkWidget *widget, gpointer data) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
141 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
142 SignalHandler *work = (SignalHandler *)data; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
143 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
144 if(work) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
145 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
146 int (*setfocusfunc)(HWND, void *) = work->func; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
147 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
148 setfocusfunc((HWND)window, work->data); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
149 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
150 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
151 |
3 | 152 gint _button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data) |
153 { | |
154 SignalHandler *work = (SignalHandler *)data; | |
155 | |
156 if(work) | |
157 { | |
158 int (*buttonfunc)(HWND, int, int, int, void *) = work->func; | |
159 int mybutton = event->button; | |
160 | |
161 if(event->button == 3) | |
162 mybutton = 2; | |
163 else if(event->button == 2) | |
164 mybutton = 3; | |
165 | |
166 buttonfunc(widget, event->x, event->y, mybutton, work->data); | |
167 } | |
168 return TRUE; | |
169 } | |
170 | |
171 gint _button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer data) | |
172 { | |
173 SignalHandler *work = (SignalHandler *)data; | |
174 | |
175 if(work) | |
176 { | |
177 int (*buttonfunc)(HWND, int, int, int, void *) = work->func; | |
178 int mybutton = event->button; | |
179 | |
180 if(event->button == 3) | |
181 mybutton = 2; | |
182 else if(event->button == 2) | |
183 mybutton = 3; | |
184 | |
185 buttonfunc(widget, event->x, event->y, mybutton, work->data); | |
186 } | |
187 return TRUE; | |
188 } | |
189 | |
190 gint _motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer data) | |
191 { | |
192 SignalHandler *work = (SignalHandler *)data; | |
193 | |
194 if(work) | |
195 { | |
196 int (*motionfunc)(HWND, int, int, int, void *) = work->func; | |
197 int keys = 0, x, y; | |
198 GdkModifierType state; | |
199 | |
200 if (event->is_hint) | |
201 gdk_window_get_pointer (event->window, &x, &y, &state); | |
202 else | |
203 { | |
204 x = event->x; | |
205 y = event->y; | |
206 state = event->state; | |
207 } | |
208 | |
209 if (state & GDK_BUTTON1_MASK) | |
210 keys = DW_BUTTON1_MASK; | |
211 if (state & GDK_BUTTON3_MASK) | |
212 keys |= DW_BUTTON2_MASK; | |
213 if (state & GDK_BUTTON2_MASK) | |
214 keys |= DW_BUTTON3_MASK; | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
215 |
3 | 216 motionfunc(widget, x, y, keys, work->data); |
217 } | |
218 return TRUE; | |
219 } | |
220 | |
221 gint _delete_event(GtkWidget *widget, GdkEvent *event, gpointer data) | |
222 { | |
223 SignalHandler *work = (SignalHandler *)data; | |
224 | |
225 if(work) | |
226 { | |
227 int (*closefunc)(HWND, void *) = work->func; | |
228 | |
229 closefunc(widget, data); | |
230 } | |
231 return TRUE; | |
232 } | |
233 | |
234 gint _key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data) | |
235 { | |
236 SignalHandler *work = (SignalHandler *)data; | |
237 | |
238 if(work) | |
239 { | |
240 int (*keypressfunc)(HWND, int, void *) = work->func; | |
241 | |
242 keypressfunc(widget, *event->string, work->data); | |
243 } | |
244 return TRUE; | |
245 } | |
246 | |
247 gint _generic_event(GtkWidget *widget, gpointer data) | |
248 { | |
249 SignalHandler *work = (SignalHandler *)data; | |
250 | |
251 if(work) | |
252 { | |
253 int (*genericfunc)(HWND, void *) = work->func; | |
254 | |
255 genericfunc(widget, work->data); | |
256 } | |
257 return TRUE; | |
258 } | |
259 | |
260 void _activate_event(GtkWidget *widget, gpointer data) | |
261 { | |
262 SignalHandler *work = (SignalHandler *)data; | |
263 | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
264 if(work && !_dw_ignore_click) |
3 | 265 { |
266 void (*activatefunc)(HWND, void *) = work->func; | |
267 | |
268 activatefunc(work->window, work->data); | |
269 } | |
270 return; | |
271 } | |
272 | |
273 gint _configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data) | |
274 { | |
275 SignalHandler *work = (SignalHandler *)data; | |
276 | |
277 if(work) | |
278 { | |
279 int (*sizefunc)(HWND, int, int, void *) = work->func; | |
280 | |
281 sizefunc(widget, event->width, event->height, work->data); | |
282 } | |
283 return TRUE; | |
284 } | |
285 | |
286 void _expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data) | |
287 { | |
288 SignalHandler *work = (SignalHandler *)data; | |
289 | |
290 if(work) | |
291 { | |
292 DWExpose exp; | |
293 int (*exposefunc)(HWND, DWExpose *, void *) = work->func; | |
294 | |
295 exp.x = event->area.x; | |
296 exp.y = event->area.y; | |
297 exp.width = event->area.width; | |
298 exp.height = event->area.height; | |
299 exposefunc(widget, &exp, work->data); | |
300 } | |
301 } | |
302 | |
303 void _item_select_event(GtkWidget *widget, GtkWidget *child, gpointer data) | |
304 { | |
305 SignalHandler *work = (SignalHandler *)data; | |
306 | |
307 if(work) | |
308 { | |
309 int (*selectfunc)(HWND, int, void *) = work->func; | |
310 GList *list; | |
311 int item = 0; | |
312 | |
313 if(GTK_IS_COMBO(work->window)) | |
314 list = GTK_LIST(GTK_COMBO(work->window)->list)->children; | |
315 else if(GTK_IS_LIST(widget)) | |
316 list = GTK_LIST(widget)->children; | |
317 else | |
318 return; | |
319 | |
320 while(list) | |
321 { | |
322 if(list->data == (gpointer)child) | |
323 { | |
324 gtk_object_set_data(GTK_OBJECT(work->window), "item", (gpointer)item); | |
325 selectfunc(work->window, item, work->data); | |
326 break; | |
327 } | |
328 item++; | |
329 list = list->next; | |
330 } | |
331 } | |
332 } | |
333 | |
334 void _container_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data) | |
335 { | |
336 SignalHandler *work = (SignalHandler *)data; | |
337 | |
338 if(work) | |
339 { | |
340 if(event->button == 3) | |
341 { | |
342 void (*contextfunc)(HWND, char *, int, int, void *) = work->func; | |
343 char *text; | |
344 int row, col; | |
345 | |
346 gtk_clist_get_selection_info(GTK_CLIST(widget), event->x, event->y, &row, &col); | |
347 | |
348 text = (char *)gtk_clist_get_row_data(GTK_CLIST(widget), row); | |
349 contextfunc(work->window, text, event->x, event->y, work->data); | |
350 } | |
351 } | |
352 } | |
353 | |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
354 void _tree_select_event(GtkTree *tree, GtkWidget *child, gpointer data) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
355 { |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
356 SignalHandler *work = (SignalHandler *)data; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
357 |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
358 if(work) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
359 { |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
360 void (*treeselectfunc)(HWND, HWND, char *, void *) = work->func; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
361 char *text = (char *)gtk_object_get_data(GTK_OBJECT(child), "text"); |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
362 |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
363 treeselectfunc(work->window, child, text, work->data); |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
364 } |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
365 } |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
366 |
3 | 367 void _container_select_event(GtkWidget *widget, GdkEventButton *event, gpointer data) |
368 { | |
369 SignalHandler *work = (SignalHandler *)data; | |
370 | |
371 if(work) | |
372 { | |
373 if(event->button == 1 && event->type == GDK_2BUTTON_PRESS) | |
374 { | |
375 void (*contextfunc)(HWND, char *, void *) = work->func; | |
376 char *text; | |
377 int row, col; | |
378 | |
379 gtk_clist_get_selection_info(GTK_CLIST(widget), event->x, event->y, &row, &col); | |
380 | |
381 text = (char *)gtk_clist_get_row_data(GTK_CLIST(widget), row); | |
382 contextfunc(work->window, text, work->data); | |
383 } | |
384 } | |
385 } | |
386 | |
387 void _select_row(GtkWidget *widget, gint row, gint column, GdkEventButton *event, gpointer data) | |
388 { | |
389 GList *tmp = (GList *)gtk_object_get_data(GTK_OBJECT(widget), "selectlist"); | |
390 char *rowdata = gtk_clist_get_row_data(GTK_CLIST(widget), row); | |
391 | |
392 if(rowdata) | |
393 { | |
394 tmp = g_list_append(tmp, rowdata); | |
395 gtk_object_set_data(GTK_OBJECT(widget), "selectlist", tmp); | |
396 } | |
397 | |
398 } | |
399 | |
400 void _unselect_row(GtkWidget *widget, gint row, gint column, GdkEventButton *event, gpointer data) | |
401 { | |
402 GList *tmp = (GList *)gtk_object_get_data(GTK_OBJECT(widget), "selectlist"); | |
403 char *rowdata = gtk_clist_get_row_data(GTK_CLIST(widget), row); | |
404 | |
405 if(rowdata) | |
406 { | |
407 g_list_remove(tmp, rowdata); | |
408 gtk_object_set_data(GTK_OBJECT(widget), "selectlist", tmp); | |
409 } | |
410 } | |
411 | |
412 GdkPixmap *_find_pixmap(GdkBitmap **bitmap, long id, HWND handle) | |
413 { | |
414 char *data = NULL; | |
415 int z; | |
416 | |
417 for(z=0;z<_resources.resource_max;z++) | |
418 { | |
419 if(_resources.resource_id[z] == id) | |
420 { | |
421 data = _resources.resource_data[z]; | |
422 break; | |
423 } | |
424 } | |
425 | |
426 if(data) | |
427 { | |
428 GdkPixmap *icon_pixmap = NULL; | |
429 #ifndef USE_IMLIB | |
430 GtkStyle *iconstyle; | |
431 | |
432 /* hmmm why do we need the handle here? */ | |
433 iconstyle = gtk_widget_get_style(handle); | |
434 if (!icon_pixmap) | |
435 icon_pixmap = gdk_pixmap_create_from_xpm_d(handle->window, bitmap, &iconstyle->bg[GTK_STATE_NORMAL], &data); | |
436 #else | |
437 gdk_imlib_data_to_pixmap((char **)data, &icon_pixmap, bitmap); | |
438 #endif | |
439 return icon_pixmap; | |
440 } | |
441 return NULL; | |
442 } | |
443 | |
444 void _size_allocate(GtkWindow *window) | |
445 { | |
446 XSizeHints sizehints; | |
447 | |
448 sizehints.base_width = 1; | |
449 sizehints.base_height = 1; | |
450 sizehints.width_inc = 1; | |
451 sizehints.height_inc = 1; | |
452 sizehints.min_width = 8; | |
453 sizehints.min_height = 8; | |
454 | |
455 sizehints.flags = (PBaseSize|PMinSize|PResizeInc); | |
456 | |
457 XSetWMNormalHints (GDK_DISPLAY(), | |
458 GDK_WINDOW_XWINDOW (GTK_WIDGET (window)->window), | |
459 &sizehints); | |
460 gdk_flush (); | |
461 } | |
462 | |
463 /* | |
464 * Initializes the Dynamic Windows engine. | |
465 * Parameters: | |
466 * newthread: True if this is the only thread. | |
467 * False if there is already a message loop running. | |
468 */ | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
469 int dw_int_init(DWResources *res, int newthread, int argc, char *argv[]) |
3 | 470 { |
471 int z; | |
472 | |
473 if(res) | |
474 { | |
475 _resources.resource_max = res->resource_max; | |
476 _resources.resource_id = res->resource_id; | |
477 _resources.resource_data = res->resource_data; | |
478 } | |
479 gtk_set_locale(); | |
480 g_thread_init(NULL); | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
481 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
482 gtk_init(&argc, &argv); |
3 | 483 #ifdef USE_IMLIB |
484 gdk_imlib_init(); | |
485 #endif | |
486 /* Add colors to the system colormap */ | |
487 _dw_cmap = gdk_colormap_get_system(); | |
488 for(z=0;z<16;z++) | |
489 gdk_color_alloc(_dw_cmap, &_colors[z]); | |
490 return TRUE; | |
491 } | |
492 | |
493 /* | |
494 * Runs a message loop for Dynamic Windows. | |
495 * Parameters: | |
496 * currenthab: The handle to the current anchor block | |
497 * or NULL if this DW is handling the message loop. | |
498 * func: Function pointer to the message filter function. | |
499 */ | |
500 void dw_main(HAB currenthab, void *func) | |
501 { | |
502 _dw_thread = pthread_self(); | |
503 gdk_threads_enter(); | |
504 gtk_main(); | |
505 gdk_threads_leave(); | |
506 } | |
507 | |
508 /* | |
509 * Free's memory allocated by dynamic windows. | |
510 * Parameters: | |
511 * ptr: Pointer to dynamic windows allocated | |
512 * memory to be free()'d. | |
513 */ | |
514 void dw_free(void *ptr) | |
515 { | |
516 free(ptr); | |
517 } | |
518 | |
519 /* | |
520 * Allocates and initializes a dialog struct. | |
521 * Parameters: | |
522 * data: User defined data to be passed to functions. | |
523 */ | |
524 DWDialog *dw_dialog_new(void *data) | |
525 { | |
526 DWDialog *tmp = malloc(sizeof(DWDialog)); | |
527 | |
528 tmp->eve = dw_event_new(); | |
529 dw_event_reset(tmp->eve); | |
530 tmp->data = data; | |
531 tmp->done = FALSE; | |
532 tmp->result = NULL; | |
533 | |
534 return tmp; | |
535 } | |
536 | |
537 /* | |
538 * Accepts a dialog struct and returns the given data to the | |
539 * initial called of dw_dialog_wait(). | |
540 * Parameters: | |
541 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). | |
542 * result: Data to be returned by dw_dialog_wait(). | |
543 */ | |
544 int dw_dialog_dismiss(DWDialog *dialog, void *result) | |
545 { | |
546 dialog->result = result; | |
547 if(pthread_self() == _dw_thread) | |
548 gtk_main_quit(); | |
549 else | |
550 dw_event_post(dialog->eve); | |
551 dialog->done = TRUE; | |
552 return 0; | |
553 } | |
554 | |
555 /* | |
556 * Accepts a dialog struct waits for dw_dialog_dismiss() to be | |
557 * called by a signal handler with the given dialog struct. | |
558 * Parameters: | |
559 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). | |
560 */ | |
561 void *dw_dialog_wait(DWDialog *dialog) | |
562 { | |
563 void *tmp; | |
564 | |
565 if(pthread_self() == _dw_thread) | |
566 gtk_main(); | |
567 else | |
568 dw_event_wait(dialog->eve, -1); | |
569 | |
570 dw_event_close(&dialog->eve); | |
571 tmp = dialog->result; | |
572 free(dialog); | |
573 return tmp; | |
574 } | |
575 | |
576 void _delete(GtkWidget *widget, GtkWidget *event, gpointer param) | |
577 { | |
578 gtk_widget_destroy(GTK_WIDGET(param)); | |
579 } | |
580 | |
581 void _delete2(GtkWidget *widget, gpointer param) | |
582 { | |
583 gtk_widget_destroy(GTK_WIDGET(param)); | |
584 } | |
585 | |
586 | |
587 /* | |
588 * Displays a Message Box with given text and title.. | |
589 * Parameters: | |
590 * title: The title of the message box. | |
591 * format: printf style format string. | |
592 * ...: Additional variables for use in the format. | |
593 */ | |
594 int dw_messagebox(char *title, char *format, ...) | |
595 { | |
596 va_list args; | |
597 char outbuf[256]; | |
598 GtkWidget *dialog, | |
599 *button, | |
600 *label; | |
601 int _locked_by_me = FALSE; | |
602 | |
603 DW_MUTEX_LOCK; | |
604 va_start(args, format); | |
605 vsprintf(outbuf, format, args); | |
606 va_end(args); | |
607 | |
608 dialog = gtk_dialog_new(); | |
609 | |
610 gtk_window_set_title(GTK_WINDOW(dialog), title); | |
611 | |
612 button = gtk_button_new_with_label("Ok"); | |
613 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), button, TRUE, TRUE, 0); | |
614 gtk_widget_show(button); | |
615 | |
616 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(_delete2), (gpointer)dialog); | |
617 gtk_signal_connect(GTK_OBJECT(dialog), "delete_event", GTK_SIGNAL_FUNC(_delete), (gpointer)dialog); | |
618 | |
619 label = gtk_label_new(outbuf); | |
620 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), 20); | |
621 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), label, TRUE, TRUE, 0); | |
622 gtk_widget_show(label); | |
623 | |
624 gtk_widget_show(dialog); | |
625 | |
626 DW_MUTEX_UNLOCK; | |
627 | |
628 return strlen(outbuf); | |
629 } | |
630 | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
631 void _dw_yes_func(HWND window, void *data) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
632 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
633 DWDialog *dwwait = (DWDialog *)data; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
634 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
635 if(!dwwait) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
636 return; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
637 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
638 dw_window_destroy((HWND)dwwait->data); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
639 dw_dialog_dismiss((DWDialog *)data, (void *)1); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
640 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
641 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
642 void _dw_no_func(HWND window, void *data) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
643 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
644 DWDialog *dwwait = (DWDialog *)data; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
645 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
646 if(!dwwait) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
647 return; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
648 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
649 dw_window_destroy((HWND)dwwait->data); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
650 dw_dialog_dismiss((DWDialog *)data, (void *)0); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
651 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
652 |
3 | 653 /* |
654 * Displays a Message Box with given text and title.. | |
655 * Parameters: | |
656 * title: The title of the message box. | |
657 * text: The text to display in the box. | |
658 * Returns: | |
659 * True if YES False of NO. | |
660 */ | |
661 int dw_yesno(char *title, char *text) | |
662 { | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
663 HWND entrywindow, mainbox, nobutton, yesbutton, buttonbox, stext; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
664 ULONG flStyle = DW_FCF_TITLEBAR | DW_FCF_SHELLPOSITION | DW_FCF_DLGBORDER; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
665 DWDialog *dwwait; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
666 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
667 entrywindow = dw_window_new(HWND_DESKTOP, title, flStyle); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
668 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
669 mainbox = dw_box_new(BOXVERT, 10); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
670 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
671 dw_box_pack_start(entrywindow, mainbox, 0, 0, TRUE, TRUE, 0); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
672 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
673 /* Archive Name */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
674 stext = dw_text_new(text, 0); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
675 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
676 dw_box_pack_start(mainbox, stext, 130, 20, TRUE, TRUE, 2); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
677 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
678 /* Buttons */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
679 buttonbox = dw_box_new(BOXHORZ, 10); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
680 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
681 dw_box_pack_start(mainbox, buttonbox, 0, 0, TRUE, TRUE, 0); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
682 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
683 yesbutton = dw_button_new("Yes", 1001L); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
684 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
685 dw_box_pack_start(buttonbox, yesbutton, 130, 30, TRUE, TRUE, 2); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
686 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
687 nobutton = dw_button_new("No", 1002L); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
688 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
689 dw_box_pack_start(buttonbox, nobutton, 130, 30, TRUE, TRUE, 2); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
690 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
691 dwwait = dw_dialog_new((void *)entrywindow); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
692 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
693 dw_signal_connect(yesbutton, "clicked", DW_SIGNAL_FUNC(_dw_yes_func), (void *)dwwait); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
694 dw_signal_connect(nobutton, "clicked", DW_SIGNAL_FUNC(_dw_no_func), (void *)dwwait); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
695 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
696 dw_window_set_usize(entrywindow, 340, 150); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
697 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
698 dw_window_show(entrywindow); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
699 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
700 return (int)dw_dialog_wait(dwwait);; |
3 | 701 } |
702 | |
703 /* | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
704 * Minimizes or Iconifies a top-level window. |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
705 * Parameters: |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
706 * handle: The window handle to minimize. |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
707 */ |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
708 int dw_window_minimize(HWND handle) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
709 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
710 int _locked_by_me = FALSE; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
711 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
712 if(!handle) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
713 return 0; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
714 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
715 DW_MUTEX_LOCK; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
716 XIconifyWindow(GDK_WINDOW_XDISPLAY(GTK_WIDGET(handle)->window), |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
717 GDK_WINDOW_XWINDOW(GTK_WIDGET(handle)->window), |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
718 DefaultScreen (GDK_DISPLAY ())); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
719 DW_MUTEX_UNLOCK; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
720 return 0; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
721 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
722 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
723 /* |
3 | 724 * Makes the window visible. |
725 * Parameters: | |
726 * handle: The window handle to make visible. | |
727 */ | |
728 int dw_window_show(HWND handle) | |
729 { | |
730 int _locked_by_me = FALSE; | |
34
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
731 GtkWidget *defaultitem; |
3 | 732 |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
733 if(!handle) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
734 return 0; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
735 |
3 | 736 DW_MUTEX_LOCK; |
737 gtk_widget_show(handle); | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
738 gdk_window_raise(GTK_WIDGET(handle)->window); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
739 gdk_flush(); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
740 gdk_window_show(GTK_WIDGET(handle)->window); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
741 gdk_flush(); |
34
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
742 defaultitem = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "defaultitem"); |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
743 if(defaultitem) |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
744 gtk_widget_grab_focus(defaultitem); |
3 | 745 DW_MUTEX_UNLOCK; |
746 return 0; | |
747 } | |
748 | |
749 /* | |
750 * Makes the window invisible. | |
751 * Parameters: | |
752 * handle: The window handle to make visible. | |
753 */ | |
754 int dw_window_hide(HWND handle) | |
755 { | |
756 int _locked_by_me = FALSE; | |
757 | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
758 if(!handle) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
759 return 0; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
760 |
3 | 761 DW_MUTEX_LOCK; |
762 gtk_widget_hide(handle); | |
763 DW_MUTEX_UNLOCK; | |
764 return 0; | |
765 } | |
766 | |
767 /* | |
768 * Destroys a window and all of it's children. | |
769 * Parameters: | |
770 * handle: The window handle to destroy. | |
771 */ | |
772 int dw_window_destroy(HWND handle) | |
773 { | |
774 int _locked_by_me = FALSE; | |
775 | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
776 if(!handle) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
777 return 0; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
778 |
3 | 779 DW_MUTEX_LOCK; |
17
f26eced21a30
Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
15
diff
changeset
|
780 if(GTK_IS_WIDGET(handle)) |
f26eced21a30
Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
15
diff
changeset
|
781 gtk_widget_destroy(handle); |
3 | 782 DW_MUTEX_UNLOCK; |
783 return 0; | |
784 } | |
785 | |
786 /* | |
787 * Changes a window's parent to newparent. | |
788 * Parameters: | |
789 * handle: The window handle to destroy. | |
790 * newparent: The window's new parent window. | |
791 */ | |
792 void dw_window_reparent(HWND handle, HWND newparent) | |
793 { | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
794 int _locked_by_me = FALSE; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
795 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
796 DW_MUTEX_LOCK; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
797 gdk_window_reparent(GTK_WIDGET(handle)->window, newparent ? GTK_WIDGET(newparent)->window : GDK_ROOT_PARENT(), 0, 0); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
798 DW_MUTEX_UNLOCK; |
3 | 799 } |
800 | |
801 int _set_font(HWND handle, char *fontname) | |
802 { | |
803 GtkStyle *style; | |
804 GdkFont *font = NULL; | |
805 int retval = FALSE; | |
806 | |
807 font = gdk_font_load(fontname); | |
808 | |
809 if(font) | |
810 { | |
811 style = gtk_widget_get_style(handle); | |
812 style->font = font; | |
813 gtk_widget_set_style(handle, style); | |
814 retval = TRUE; | |
815 } | |
816 return retval; | |
817 } | |
818 | |
819 /* | |
820 * Sets the font used by a specified window (widget) handle. | |
821 * Parameters: | |
822 * handle: The window (widget) handle. | |
823 * fontname: Name and size of the font in the form "size.fontname" | |
824 */ | |
825 int dw_window_set_font(HWND handle, char *fontname) | |
826 { | |
827 GtkWidget *handle2 = handle; | |
828 char *font; | |
829 int _locked_by_me = FALSE; | |
830 gpointer data; | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
831 GdkFont *gdkfont; |
3 | 832 |
833 DW_MUTEX_LOCK; | |
834 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
835 { | |
836 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
837 if(tmp) | |
838 handle2 = tmp; | |
839 } | |
840 font = strdup(fontname); | |
841 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
842 /* Free old font if it exists */ |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
843 gdkfont = (GdkFont *)gtk_object_get_data(GTK_OBJECT(handle2), "gdkfont"); |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
844 if(gdkfont) |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
845 gdk_font_unref(gdkfont); |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
846 gdkfont = gdk_font_load(fontname); |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
847 gtk_object_set_data(GTK_OBJECT(handle2), "gdkfont", (gpointer)gdkfont); |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
848 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
849 /* Free old font name if one is allocated */ |
3 | 850 data = gtk_object_get_data(GTK_OBJECT(handle2), "fontname"); |
851 if(data) | |
852 free(data); | |
853 | |
854 if(font) | |
855 gtk_object_set_data(GTK_OBJECT(handle2), "fontname", (gpointer)font); | |
856 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
857 |
3 | 858 DW_MUTEX_UNLOCK; |
859 return TRUE; | |
860 } | |
861 | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
862 void _free_gdk_colors(HWND handle) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
863 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
864 GdkColor *old = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle), "foregdk"); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
865 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
866 if(old) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
867 free(old); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
868 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
869 old = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle), "backgdk"); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
870 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
871 if(old) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
872 free(old); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
873 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
874 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
875 /* Free old color pointers and allocate new ones */ |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
876 void _save_gdk_colors(HWND handle, GdkColor fore, GdkColor back) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
877 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
878 GdkColor *foregdk = malloc(sizeof(GdkColor)); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
879 GdkColor *backgdk = malloc(sizeof(GdkColor)); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
880 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
881 _free_gdk_colors(handle); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
882 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
883 *foregdk = fore; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
884 *backgdk = back; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
885 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
886 gtk_object_set_data(GTK_OBJECT(handle), "foregdk", (gpointer)foregdk); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
887 gtk_object_set_data(GTK_OBJECT(handle), "backgdk", (gpointer)backgdk); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
888 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
889 |
3 | 890 int _set_color(HWND handle, unsigned long fore, unsigned long back) |
891 { | |
892 GtkStyle *style; | |
893 | |
894 if(fore & DW_RGB_COLOR || back & DW_RGB_COLOR) | |
895 { | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
896 /* Remember that each color component in X11 use 16 bit no matter |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
897 * what the destination display supports. (and thus GDK) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
898 */ |
3 | 899 GdkColor forecolor = { 0, DW_RED_VALUE(fore) << 8, DW_GREEN_VALUE(fore) << 8, DW_BLUE_VALUE(fore) << 8 }; |
900 GdkColor backcolor = { 0, DW_RED_VALUE(back) << 8, DW_GREEN_VALUE(back) << 8, DW_BLUE_VALUE(back) << 8 }; | |
901 | |
902 gdk_color_alloc(_dw_cmap, &forecolor); | |
903 gdk_color_alloc(_dw_cmap, &backcolor); | |
904 | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
905 style = gtk_style_copy(gtk_widget_get_style(handle)); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
906 style->text[0] = style->text[1] = style->fg[0] = style->fg[1] = forecolor; |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
907 style->base[0] = style->base[1] = style->bg[0] = style->bg[1] = backcolor; |
3 | 908 gtk_widget_set_style(handle, style); |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
909 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
910 _save_gdk_colors(handle, forecolor, backcolor); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
911 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
912 if(GTK_IS_CLIST(handle)) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
913 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
914 int z, rowcount = (int)gtk_object_get_data(GTK_OBJECT(handle), "rowcount"); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
915 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
916 for(z=0;z<rowcount;z++) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
917 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
918 gtk_clist_set_foreground(GTK_CLIST(handle), z, &forecolor); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
919 gtk_clist_set_background(GTK_CLIST(handle), z, &backcolor); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
920 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
921 } |
3 | 922 } |
923 else | |
924 { | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
925 style = gtk_style_copy(gtk_widget_get_style(handle)); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
926 style->text[0] = style->text[1] = style->fg[0] = style->fg[1] = _colors[fore]; |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
927 style->base[0] = style->base[1] = style->bg[0] = style->bg[1] = _colors[back]; |
3 | 928 gtk_widget_set_style(handle, style); |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
929 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
930 _save_gdk_colors(handle, _colors[fore], _colors[back]); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
931 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
932 if(GTK_IS_CLIST(handle)) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
933 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
934 int z, rowcount = (int)gtk_object_get_data(GTK_OBJECT(handle), "rowcount"); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
935 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
936 for(z=0;z<rowcount;z++) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
937 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
938 gtk_clist_set_foreground(GTK_CLIST(handle), z, &_colors[fore]); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
939 gtk_clist_set_background(GTK_CLIST(handle), z, &_colors[back]); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
940 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
941 } |
3 | 942 } |
943 | |
944 return TRUE; | |
945 } | |
946 /* | |
947 * Sets the colors used by a specified window (widget) handle. | |
948 * Parameters: | |
949 * handle: The window (widget) handle. | |
950 * fore: Foreground color in RGB format. | |
951 * back: Background color in RGB format. | |
952 */ | |
953 int dw_window_set_color(HWND handle, unsigned long fore, unsigned long back) | |
954 { | |
955 GtkWidget *handle2 = handle; | |
956 int _locked_by_me = FALSE; | |
957 | |
958 DW_MUTEX_LOCK; | |
959 | |
960 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
961 { | |
962 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
963 if(tmp) | |
964 handle2 = tmp; | |
965 } | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
966 else if(GTK_IS_BOX(handle)) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
967 { |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
968 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
969 if(tmp) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
970 handle2 = tmp; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
971 } |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
972 |
3 | 973 _set_color(handle2, fore, back); |
974 | |
975 DW_MUTEX_UNLOCK; | |
976 return TRUE; | |
977 } | |
978 | |
979 /* | |
980 * Sets the font used by a specified window (widget) handle. | |
981 * Parameters: | |
982 * handle: The window (widget) handle. | |
983 * border: Size of the window border in pixels. | |
984 */ | |
985 int dw_window_set_border(HWND handle, int border) | |
986 { | |
987 /* TODO */ | |
988 return 0; | |
989 } | |
990 | |
991 /* | |
992 * Captures the mouse input to this window. | |
993 * Parameters: | |
994 * handle: Handle to receive mouse input. | |
995 */ | |
996 void dw_window_capture(HWND handle) | |
997 { | |
998 int _locked_by_me = FALSE; | |
999 | |
1000 DW_MUTEX_LOCK; | |
1001 gdk_pointer_grab(handle->window, TRUE, GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK, NULL, NULL, GDK_CURRENT_TIME); | |
1002 DW_MUTEX_UNLOCK; | |
1003 } | |
1004 | |
1005 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1006 * Changes the appearance of the mouse pointer. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1007 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1008 * handle: Handle to widget for which to change. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1009 * cursortype: ID of the pointer you want. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1010 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1011 void dw_window_pointer(HWND handle, int pointertype) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1012 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1013 GdkCursor *cursor = gdk_cursor_new(pointertype); |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
1014 if(handle && handle->window) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
1015 gdk_window_set_cursor(handle->window, cursor); |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1016 gdk_cursor_destroy(cursor); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1017 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1018 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1019 /* |
3 | 1020 * Releases previous mouse capture. |
1021 */ | |
1022 void dw_window_release(void) | |
1023 { | |
1024 int _locked_by_me = FALSE; | |
1025 | |
1026 DW_MUTEX_LOCK; | |
1027 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
1028 DW_MUTEX_UNLOCK; | |
1029 } | |
1030 | |
1031 /* | |
1032 * Create a new Window Frame. | |
1033 * Parameters: | |
1034 * owner: The Owner's window handle or HWND_DESKTOP. | |
1035 * title: The Window title. | |
1036 * flStyle: Style flags, see the PM reference. | |
1037 */ | |
1038 HWND dw_window_new(HWND hwndOwner, char *title, unsigned long flStyle) | |
1039 { | |
1040 GtkWidget *tmp; | |
1041 int _locked_by_me = FALSE; | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1042 int flags = 0; |
3 | 1043 |
1044 DW_MUTEX_LOCK; | |
1045 tmp = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
1046 | |
1047 gtk_window_set_title(GTK_WINDOW(tmp), title); | |
1048 if(!(flStyle & DW_FCF_SIZEBORDER)) | |
1049 gtk_window_set_policy(GTK_WINDOW(tmp), FALSE, FALSE, TRUE); | |
1050 | |
1051 gtk_widget_realize(tmp); | |
1052 | |
1053 if(flStyle & DW_FCF_TITLEBAR) | |
1054 flags |= GDK_DECOR_TITLE; | |
1055 | |
1056 if(flStyle & DW_FCF_MINMAX) | |
1057 flags |= GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE; | |
1058 | |
1059 if(flStyle & DW_FCF_SIZEBORDER) | |
1060 flags |= GDK_DECOR_RESIZEH; | |
1061 | |
1062 if(flStyle & DW_FCF_BORDER) | |
1063 flags |= GDK_DECOR_BORDER; | |
1064 | |
1065 gdk_window_set_decorations(tmp->window, flags); | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1066 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1067 if(hwndOwner) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1068 gdk_window_reparent(GTK_WIDGET(tmp)->window, GTK_WIDGET(hwndOwner)->window, 0, 0); |
3 | 1069 |
1070 DW_MUTEX_UNLOCK; | |
1071 return tmp; | |
1072 } | |
1073 | |
1074 /* | |
1075 * Create a new Box to be packed. | |
1076 * Parameters: | |
1077 * type: Either BOXVERT (vertical) or BOXHORZ (horizontal). | |
1078 * pad: Number of pixels to pad around the box. | |
1079 */ | |
1080 HWND dw_box_new(int type, int pad) | |
1081 { | |
1082 GtkWidget *tmp; | |
1083 int _locked_by_me = FALSE; | |
1084 | |
1085 DW_MUTEX_LOCK; | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1086 tmp = gtk_table_new(1, 1, FALSE); |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1087 gtk_object_set_data(GTK_OBJECT(tmp), "boxtype", (gpointer)type); |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1088 gtk_object_set_data(GTK_OBJECT(tmp), "boxpad", (gpointer)pad); |
3 | 1089 gtk_widget_show(tmp); |
1090 DW_MUTEX_UNLOCK; | |
1091 return tmp; | |
1092 } | |
1093 | |
1094 /* | |
1095 * Create a new Group Box to be packed. | |
1096 * Parameters: | |
1097 * type: Either BOXVERT (vertical) or BOXHORZ (horizontal). | |
1098 * pad: Number of pixels to pad around the box. | |
1099 * title: Text to be displayined in the group outline. | |
1100 */ | |
1101 HWND dw_groupbox_new(int type, int pad, char *title) | |
1102 { | |
1103 return dw_box_new(type, pad); | |
1104 } | |
1105 | |
1106 /* | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1107 * Create a new MDI Frame to be packed. |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1108 * Parameters: |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1109 * id: An ID to be used with dw_window_from_id or 0L. |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1110 */ |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1111 HWND dw_mdi_new(unsigned long id) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1112 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1113 return gtk_vbox_new(FALSE, 0); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1114 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1115 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1116 /* |
3 | 1117 * Create a bitmap object to be packed. |
1118 * Parameters: | |
1119 * id: An ID to be used with WinWindowFromID() or 0L. | |
1120 */ | |
1121 HWND dw_bitmap_new(unsigned long id) | |
1122 { | |
1123 GdkPixmap *pixmap= NULL; | |
1124 GdkBitmap *bitmap; | |
1125 GtkWidget *tmp; | |
1126 char * test_xpm[] = { | |
1127 "1 1 1 1", | |
1128 " c None", | |
1129 " "}; | |
1130 int _locked_by_me = FALSE; | |
1131 | |
1132 DW_MUTEX_LOCK; | |
1133 #ifndef USE_IMLIB | |
1134 GtkStyle *iconstyle; | |
1135 | |
1136 /* hmmm why do we need the handle here? */ | |
1137 iconstyle = gtk_widget_get_style(handle); | |
1138 if (!pixmap) | |
1139 pixmap = gdk_pixmap_create_from_xpm_d(handle->window, &bitmap, &iconstyle->bg[GTK_STATE_NORMAL], &test_xpm); | |
1140 #else | |
1141 gdk_imlib_data_to_pixmap(test_xpm, &pixmap, &bitmap); | |
1142 #endif | |
1143 tmp = gtk_pixmap_new(pixmap, bitmap); | |
1144 gtk_widget_show(tmp); | |
1145 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
1146 DW_MUTEX_UNLOCK; | |
1147 return tmp; | |
1148 } | |
1149 | |
1150 /* | |
1151 * Create a notebook object to be packed. | |
1152 * Parameters: | |
1153 * id: An ID to be used for getting the resource from the | |
1154 * resource file. | |
1155 */ | |
1156 HWND dw_notebook_new(unsigned long id, int top) | |
1157 { | |
1158 GtkWidget *tmp; | |
1159 int _locked_by_me = FALSE; | |
1160 | |
1161 DW_MUTEX_LOCK; | |
1162 tmp = gtk_notebook_new(); | |
1163 if(top) | |
1164 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tmp), GTK_POS_TOP); | |
1165 else | |
1166 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tmp), GTK_POS_BOTTOM); | |
1167 gtk_widget_show(tmp); | |
1168 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
1169 DW_MUTEX_UNLOCK; | |
1170 return tmp; | |
1171 } | |
1172 | |
1173 /* | |
1174 * Create a menu object to be popped up. | |
1175 * Parameters: | |
1176 * id: An ID to be used for getting the resource from the | |
1177 * resource file. | |
1178 */ | |
1179 HMENUI dw_menu_new(unsigned long id) | |
1180 { | |
1181 int _locked_by_me = FALSE; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1182 HMENUI tmp = malloc(sizeof(struct _hmenui)); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1183 GtkAccelGroup *accel_group; |
3 | 1184 |
1185 if(!tmp) | |
1186 return NULL; | |
1187 | |
1188 DW_MUTEX_LOCK; | |
1189 tmp->menu = gtk_menu_new(); | |
1190 gtk_widget_show(tmp->menu); | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1191 accel_group = gtk_accel_group_new(); |
3 | 1192 gtk_object_set_data(GTK_OBJECT(tmp->menu), "id", (gpointer)id); |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1193 gtk_object_set_data(GTK_OBJECT(tmp->menu), "accel", (gpointer)accel_group); |
3 | 1194 DW_MUTEX_UNLOCK; |
1195 return tmp; | |
1196 } | |
1197 | |
1198 /* | |
1199 * Create a menubar on a window. | |
1200 * Parameters: | |
1201 * location: Handle of a window frame to be attached to. | |
1202 */ | |
1203 HMENUI dw_menubar_new(HWND location) | |
1204 { | |
1205 GtkWidget *box; | |
1206 int _locked_by_me = FALSE; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1207 HMENUI tmp = malloc(sizeof(struct _hmenui)); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1208 GtkAccelGroup *accel_group; |
3 | 1209 |
1210 if(!tmp) | |
1211 return NULL; | |
1212 | |
1213 DW_MUTEX_LOCK; | |
1214 tmp->menu = gtk_menu_bar_new(); | |
1215 box = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(location)); | |
1216 gtk_widget_show(tmp->menu); | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1217 accel_group = gtk_accel_group_new(); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1218 gtk_object_set_data(GTK_OBJECT(tmp->menu), "accel", (gpointer)accel_group); |
3 | 1219 |
1220 if(box) | |
1221 gtk_box_pack_end(GTK_BOX(box), tmp->menu, FALSE, FALSE, 0); | |
1222 | |
1223 DW_MUTEX_UNLOCK; | |
1224 return tmp; | |
1225 } | |
1226 | |
1227 /* | |
1228 * Destroys a menu created with dw_menubar_new or dw_menu_new. | |
1229 * Parameters: | |
1230 * menu: Handle of a menu. | |
1231 */ | |
1232 void dw_menu_destroy(HMENUI *menu) | |
1233 { | |
1234 if(menu && *menu) | |
1235 { | |
1236 int _locked_by_me = FALSE; | |
1237 | |
1238 DW_MUTEX_LOCK; | |
1239 gtk_widget_destroy((*menu)->menu); | |
1240 free(*menu); | |
1241 *menu = NULL; | |
1242 DW_MUTEX_UNLOCK; | |
1243 } | |
1244 } | |
1245 | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1246 char _removetilde(char *dest, char *src) |
3 | 1247 { |
1248 int z, cur=0; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1249 char accel = '\0'; |
3 | 1250 |
1251 for(z=0;z<strlen(src);z++) | |
1252 { | |
1253 if(src[z] != '~') | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1254 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1255 dest[cur] = src[z]; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1256 cur++; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1257 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1258 else |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1259 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1260 dest[cur] = '_'; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1261 accel = src[z+1]; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1262 cur++; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1263 } |
3 | 1264 } |
1265 dest[cur] = 0; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1266 return accel; |
3 | 1267 } |
1268 | |
1269 /* | |
1270 * Adds a menuitem or submenu to an existing menu. | |
1271 * Parameters: | |
1272 * menu: The handle the the existing menu. | |
1273 * title: The title text on the menu item to be added. | |
1274 * id: An ID to be used for message passing. | |
1275 * flags: Extended attributes to set on the menu. | |
1276 * end: If TRUE memu is positioned at the end of the menu. | |
1277 * check: If TRUE menu is "check"able. | |
1278 * submenu: Handle to an existing menu to be a submenu or NULL. | |
1279 */ | |
1280 HWND dw_menu_append_item(HMENUI menu, char *title, unsigned long id, unsigned long flags, int end, int check, HMENUI submenu) | |
1281 { | |
1282 GtkWidget *tmphandle; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1283 char accel, *tempbuf = malloc(strlen(title)+1); |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1284 int _locked_by_me = FALSE, submenucount; |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1285 guint tmp_key; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1286 GtkAccelGroup *accel_group; |
3 | 1287 |
1288 if(!menu || !menu->menu) | |
1289 { | |
1290 free(tempbuf); | |
1291 return NULL; | |
1292 } | |
1293 | |
1294 DW_MUTEX_LOCK; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1295 accel = _removetilde(tempbuf, title); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1296 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1297 accel_group = (GtkAccelGroup *)gtk_object_get_data(GTK_OBJECT(menu->menu), "accel"); |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1298 submenucount = (int)gtk_object_get_data(GTK_OBJECT(menu->menu), "submenucount"); |
3 | 1299 |
1300 if(strlen(tempbuf) == 0) | |
1301 tmphandle=gtk_menu_item_new(); | |
1302 else | |
1303 { | |
1304 if(check) | |
1305 { | |
1306 char numbuf[10]; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1307 if(accel && accel_group) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1308 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1309 tmphandle=gtk_check_menu_item_new_with_label(""); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1310 tmp_key = gtk_label_parse_uline(GTK_LABEL(GTK_BIN(tmphandle)->child), tempbuf); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1311 gtk_widget_add_accelerator(tmphandle, "activate_item", accel_group, tmp_key, GDK_MOD1_MASK, 0); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1312 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1313 else |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1314 tmphandle=gtk_check_menu_item_new_with_label(tempbuf); |
3 | 1315 gtk_check_menu_item_set_show_toggle(GTK_CHECK_MENU_ITEM(tmphandle), TRUE); |
1316 sprintf(numbuf, "%lu", id); | |
1317 gtk_object_set_data(GTK_OBJECT(menu->menu), numbuf, (gpointer)tmphandle); | |
1318 } | |
1319 else | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1320 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1321 if(accel && accel_group) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1322 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1323 tmphandle=gtk_menu_item_new_with_label(""); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1324 tmp_key = gtk_label_parse_uline(GTK_LABEL(GTK_BIN(tmphandle)->child), tempbuf); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1325 gtk_widget_add_accelerator(tmphandle, "activate_item", accel_group, tmp_key, GDK_MOD1_MASK, 0); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1326 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1327 else |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1328 tmphandle=gtk_menu_item_new_with_label(tempbuf); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1329 } |
3 | 1330 } |
1331 | |
1332 gtk_widget_show(tmphandle); | |
1333 | |
1334 if(submenu) | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1335 { |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1336 char tempbuf[100]; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1337 |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1338 sprintf(tempbuf, "submenu%d", submenucount); |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1339 submenucount++; |
3 | 1340 gtk_menu_item_set_submenu(GTK_MENU_ITEM(tmphandle), submenu->menu); |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1341 gtk_object_set_data(GTK_OBJECT(menu->menu), tempbuf, (gpointer)submenu->menu); |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1342 gtk_object_set_data(GTK_OBJECT(menu->menu), "submenucount", (gpointer)submenucount); |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1343 } |
3 | 1344 |
1345 if(GTK_IS_MENU_BAR(menu->menu)) | |
1346 gtk_menu_bar_append(GTK_MENU_BAR(menu->menu), tmphandle); | |
1347 else | |
1348 gtk_menu_append(GTK_MENU(menu->menu), tmphandle); | |
1349 | |
1350 gtk_object_set_data(GTK_OBJECT(tmphandle), "id", (gpointer)id); | |
1351 free(tempbuf); | |
1352 DW_MUTEX_UNLOCK; | |
1353 return tmphandle; | |
1354 } | |
1355 | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1356 GtkWidget *_find_submenu_id(GtkWidget *start, char *name) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1357 { |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1358 GtkWidget *tmp; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1359 int z, submenucount = (int)gtk_object_get_data(GTK_OBJECT(start), "submenucount"); |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1360 |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1361 if((tmp = gtk_object_get_data(GTK_OBJECT(start), name))) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1362 return tmp; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1363 |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1364 for(z=0;z<submenucount;z++) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1365 { |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1366 char tempbuf[100]; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1367 GtkWidget *submenu, *menuitem; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1368 |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1369 sprintf(tempbuf, "submenu%d", z); |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1370 |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1371 if((submenu = gtk_object_get_data(GTK_OBJECT(start), tempbuf))) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1372 { |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1373 if((menuitem = _find_submenu_id(submenu, name))) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1374 return menuitem; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1375 } |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1376 } |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1377 return NULL; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1378 } |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1379 |
3 | 1380 /* |
1381 * Sets the state of a menu item check. | |
1382 * Parameters: | |
1383 * menu: The handle the the existing menu. | |
1384 * id: Menuitem id. | |
1385 * check: TRUE for checked FALSE for not checked. | |
1386 */ | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1387 void dw_menu_item_set_check(HMENUI menu, unsigned long id, int check) |
3 | 1388 { |
1389 char numbuf[10]; | |
1390 GtkWidget *tmphandle; | |
1391 int _locked_by_me = FALSE; | |
1392 | |
1393 if(!menu || !menu->menu) | |
1394 return; | |
1395 | |
1396 DW_MUTEX_LOCK; | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1397 sprintf(numbuf, "%lu", id); |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1398 tmphandle = _find_submenu_id(menu->menu, numbuf); |
3 | 1399 |
1400 if(tmphandle) | |
1401 { | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1402 _dw_ignore_click = 1; |
3 | 1403 if(GTK_CHECK_MENU_ITEM(tmphandle)->active != check) |
1404 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(tmphandle), check); | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1405 _dw_ignore_click = 0; |
3 | 1406 } |
1407 DW_MUTEX_UNLOCK; | |
1408 } | |
1409 | |
1410 /* | |
1411 * Pops up a context menu at given x and y coordinates. | |
1412 * Parameters: | |
1413 * menu: The handle the the existing menu. | |
1414 * parent: Handle to the window initiating the popup. | |
1415 * x: X coordinate. | |
1416 * y: Y coordinate. | |
1417 */ | |
1418 void dw_menu_popup(HMENUI *menu, HWND parent, int x, int y) | |
1419 { | |
1420 int _locked_by_me = FALSE; | |
1421 | |
1422 if(!menu || !*menu) | |
1423 return; | |
1424 | |
1425 DW_MUTEX_LOCK; | |
1426 gtk_menu_popup(GTK_MENU((*menu)->menu), NULL, NULL, NULL, NULL, x, y); | |
1427 free(*menu); | |
1428 *menu = NULL; | |
1429 DW_MUTEX_UNLOCK; | |
1430 } | |
1431 | |
1432 | |
1433 /* | |
1434 * Returns the current X and Y coordinates of the mouse pointer. | |
1435 * Parameters: | |
1436 * x: Pointer to variable to store X coordinate. | |
1437 * y: Pointer to variable to store Y coordinate. | |
1438 */ | |
1439 void dw_pointer_query_pos(long *x, long *y) | |
1440 { | |
1441 GdkModifierType state; | |
1442 int gx, gy; | |
1443 | |
1444 gdk_window_get_pointer (GDK_ROOT_PARENT(), &gx, &gy, &state); | |
1445 *x = gx; | |
1446 *y = gy; | |
1447 } | |
1448 | |
1449 /* | |
1450 * Sets the X and Y coordinates of the mouse pointer. | |
1451 * Parameters: | |
1452 * x: X coordinate. | |
1453 * y: Y coordinate. | |
1454 */ | |
1455 void dw_pointer_set_pos(long x, long y) | |
1456 { | |
1457 XWarpPointer(GDK_DISPLAY(), None, GDK_ROOT_WINDOW(), 0,0,0,0, x, y); | |
1458 } | |
1459 | |
1460 /* | |
1461 * Create a container object to be packed. | |
1462 * Parameters: | |
1463 * id: An ID to be used for getting the resource from the | |
1464 * resource file. | |
1465 */ | |
1466 HWND dw_container_new(unsigned long id) | |
1467 { | |
1468 GtkWidget *tmp; | |
1469 int _locked_by_me = FALSE; | |
1470 | |
1471 DW_MUTEX_LOCK; | |
1472 tmp = gtk_scrolled_window_new (NULL, NULL); | |
1473 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (tmp), | |
1474 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
1475 | |
1476 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
1477 gtk_widget_show(tmp); | |
1478 | |
1479 DW_MUTEX_UNLOCK; | |
1480 return tmp; | |
1481 } | |
1482 | |
1483 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1484 * Create a tree object to be packed. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1485 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1486 * id: An ID to be used for getting the resource from the |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1487 * resource file. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1488 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1489 HWND dw_tree_new(ULONG id) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1490 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1491 GtkWidget *tmp, *tree; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1492 int _locked_by_me = FALSE; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1493 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1494 DW_MUTEX_LOCK; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1495 tmp = gtk_scrolled_window_new(NULL, NULL); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1496 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (tmp), |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1497 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1498 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1499 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1500 gtk_widget_show(tmp); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1501 tree = gtk_tree_new(); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1502 if(!tree) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1503 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1504 gtk_widget_destroy(tmp); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1505 DW_MUTEX_UNLOCK; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1506 return FALSE; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1507 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1508 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(tmp), tree); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1509 /* Set the selection mode */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1510 gtk_tree_set_selection_mode (GTK_TREE(tree), GTK_SELECTION_SINGLE); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1511 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1512 gtk_object_set_user_data(GTK_OBJECT(tmp), (gpointer)tree); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1513 gtk_widget_show(tree); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1514 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1515 DW_MUTEX_UNLOCK; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1516 return tmp; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1517 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1518 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1519 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1520 /* |
3 | 1521 * Create a new static text window (widget) to be packed. |
1522 * Parameters: | |
1523 * text: The text to be display by the static text widget. | |
1524 * id: An ID to be used with WinWindowFromID() or 0L. | |
1525 */ | |
1526 HWND dw_text_new(char *text, unsigned long id) | |
1527 { | |
1528 GtkWidget *tmp; | |
1529 int _locked_by_me = FALSE; | |
1530 | |
1531 DW_MUTEX_LOCK; | |
1532 tmp = gtk_label_new(text); | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1533 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1534 /* Left and centered */ |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1535 gtk_misc_set_alignment(GTK_MISC(tmp), 0.0f, 0.5f); |
3 | 1536 gtk_widget_show(tmp); |
1537 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
1538 DW_MUTEX_UNLOCK; | |
1539 return tmp; | |
1540 } | |
1541 | |
1542 /* | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1543 * Create a new status text window (widget) to be packed. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1544 * Parameters: |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1545 * text: The text to be display by the static text widget. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1546 * id: An ID to be used with WinWindowFromID() or 0L. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1547 */ |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1548 HWND dw_status_text_new(char *text, ULONG id) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1549 { |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1550 GtkWidget *tmp, *frame; |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1551 int _locked_by_me = FALSE; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1552 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1553 DW_MUTEX_LOCK; |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1554 frame = gtk_frame_new(NULL); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1555 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN); |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1556 tmp = gtk_label_new(text); |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1557 gtk_container_add(GTK_CONTAINER(frame), tmp); |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1558 gtk_widget_show(tmp); |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1559 gtk_widget_show(frame); |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1560 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1561 /* Left and centered */ |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1562 gtk_misc_set_alignment(GTK_MISC(tmp), 0.0f, 0.5f); |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1563 gtk_object_set_data(GTK_OBJECT(frame), "id", (gpointer)id); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1564 gtk_object_set_data(GTK_OBJECT(frame), "label", (gpointer)tmp); |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1565 DW_MUTEX_UNLOCK; |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1566 return frame; |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1567 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1568 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1569 /* |
3 | 1570 * Create a new Multiline Editbox window (widget) to be packed. |
1571 * Parameters: | |
1572 * id: An ID to be used with WinWindowFromID() or 0L. | |
1573 */ | |
1574 HWND dw_mle_new(unsigned long id) | |
1575 { | |
1576 GtkWidget *tmp, *tmpbox, *scroller; | |
1577 int _locked_by_me = FALSE; | |
1578 | |
1579 DW_MUTEX_LOCK; | |
1580 tmpbox = gtk_hbox_new(FALSE, 0); | |
1581 tmp = gtk_text_new(NULL, NULL); | |
1582 gtk_text_set_word_wrap(GTK_TEXT(tmp), FALSE); | |
1583 gtk_text_set_line_wrap(GTK_TEXT(tmp), FALSE); | |
1584 scroller = gtk_vscrollbar_new(GTK_TEXT(tmp)->vadj); | |
1585 GTK_WIDGET_UNSET_FLAGS(scroller, GTK_CAN_FOCUS); | |
1586 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
1587 gtk_object_set_data(GTK_OBJECT(tmpbox), "mle", (gpointer)tmp); | |
1588 gtk_box_pack_start(GTK_BOX(tmpbox), tmp, TRUE, TRUE, 0); | |
1589 gtk_box_pack_start(GTK_BOX(tmpbox), scroller, FALSE, TRUE, 0); | |
1590 gtk_widget_show(tmp); | |
1591 gtk_widget_show(scroller); | |
1592 gtk_widget_show(tmpbox); | |
1593 DW_MUTEX_UNLOCK; | |
1594 return tmpbox; | |
1595 } | |
1596 | |
1597 /* | |
1598 * Create a new Entryfield window (widget) to be packed. | |
1599 * Parameters: | |
1600 * text: The default text to be in the entryfield widget. | |
1601 * id: An ID to be used with WinWindowFromID() or 0L. | |
1602 */ | |
1603 HWND dw_entryfield_new(char *text, unsigned long id) | |
1604 { | |
1605 GtkWidget *tmp; | |
1606 int _locked_by_me = FALSE; | |
1607 | |
1608 DW_MUTEX_LOCK; | |
1609 tmp = gtk_entry_new(); | |
1610 | |
1611 gtk_entry_set_text(GTK_ENTRY(tmp), text); | |
1612 | |
1613 gtk_widget_show(tmp); | |
1614 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
1615 | |
1616 DW_MUTEX_UNLOCK; | |
1617 return tmp; | |
1618 } | |
1619 | |
1620 /* | |
1621 * Create a new Entryfield (password) window (widget) to be packed. | |
1622 * Parameters: | |
1623 * text: The default text to be in the entryfield widget. | |
1624 * id: An ID to be used with WinWindowFromID() or 0L. | |
1625 */ | |
1626 HWND dw_entryfield_password_new(char *text, ULONG id) | |
1627 { | |
1628 GtkWidget *tmp; | |
1629 int _locked_by_me = FALSE; | |
1630 | |
1631 DW_MUTEX_LOCK; | |
1632 tmp = gtk_entry_new(); | |
1633 | |
1634 gtk_entry_set_visibility(GTK_ENTRY(tmp), FALSE); | |
1635 gtk_entry_set_text(GTK_ENTRY(tmp), text); | |
1636 | |
1637 gtk_widget_show(tmp); | |
1638 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
1639 | |
1640 DW_MUTEX_UNLOCK; | |
1641 return tmp; | |
1642 } | |
1643 | |
1644 /* | |
1645 * Create a new Combobox window (widget) to be packed. | |
1646 * Parameters: | |
1647 * text: The default text to be in the combpbox widget. | |
1648 * id: An ID to be used with WinWindowFromID() or 0L. | |
1649 */ | |
1650 HWND dw_combobox_new(char *text, unsigned long id) | |
1651 { | |
1652 GtkWidget *tmp; | |
1653 int _locked_by_me = FALSE; | |
1654 | |
1655 DW_MUTEX_LOCK; | |
1656 tmp = gtk_combo_new(); | |
1657 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(tmp)->entry), text); | |
1658 gtk_combo_set_use_arrows(GTK_COMBO(tmp), TRUE); | |
1659 gtk_object_set_user_data(GTK_OBJECT(tmp), NULL); | |
1660 gtk_widget_show(tmp); | |
1661 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
1662 DW_MUTEX_UNLOCK; | |
1663 return tmp; | |
1664 } | |
1665 | |
1666 /* | |
1667 * Create a new button window (widget) to be packed. | |
1668 * Parameters: | |
1669 * text: The text to be display by the static text widget. | |
1670 * id: An ID to be used with WinWindowFromID() or 0L. | |
1671 */ | |
1672 HWND dw_button_new(char *text, unsigned long id) | |
1673 { | |
1674 GtkWidget *tmp; | |
1675 int _locked_by_me = FALSE; | |
1676 | |
1677 DW_MUTEX_LOCK; | |
1678 tmp = gtk_button_new_with_label(text); | |
1679 gtk_widget_show(tmp); | |
1680 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
1681 DW_MUTEX_UNLOCK; | |
1682 return tmp; | |
1683 } | |
1684 | |
1685 /* | |
1686 * Create a new bitmap button window (widget) to be packed. | |
1687 * Parameters: | |
1688 * text: Bubble help text to be displayed. | |
1689 * id: An ID of a bitmap in the resource file. | |
1690 */ | |
1691 HWND dw_bitmapbutton_new(char *text, unsigned long id) | |
1692 { | |
1693 GtkWidget *tmp; | |
1694 GtkWidget *bitmap; | |
1695 GtkTooltips *tooltips; | |
1696 int _locked_by_me = FALSE; | |
1697 | |
1698 DW_MUTEX_LOCK; | |
1699 tmp = gtk_button_new(); | |
1700 bitmap = dw_bitmap_new(id); | |
1701 | |
1702 if(bitmap) | |
1703 { | |
1704 dw_window_set_bitmap(bitmap, id); | |
1705 gtk_container_add (GTK_CONTAINER(tmp), bitmap); | |
1706 } | |
1707 gtk_widget_show(tmp); | |
1708 if(text) | |
1709 { | |
1710 tooltips = gtk_tooltips_new(); | |
1711 gtk_tooltips_set_colors(tooltips, &_colors[DW_CLR_BLACK], &_colors[DW_CLR_YELLOW]); | |
1712 gtk_tooltips_set_tip(tooltips, tmp, text, NULL); | |
1713 gtk_object_set_data(GTK_OBJECT(tmp), "tooltip", (gpointer)tooltips); | |
1714 } | |
1715 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
1716 DW_MUTEX_UNLOCK; | |
1717 return tmp; | |
1718 } | |
1719 | |
1720 /* | |
1721 * Create a new spinbutton window (widget) to be packed. | |
1722 * Parameters: | |
1723 * text: The text to be display by the static text widget. | |
1724 * id: An ID to be used with WinWindowFromID() or 0L. | |
1725 */ | |
1726 HWND dw_spinbutton_new(char *text, unsigned long id) | |
1727 { | |
1728 GtkAdjustment *adj; | |
1729 GtkWidget *tmp; | |
1730 int _locked_by_me = FALSE; | |
1731 | |
1732 DW_MUTEX_LOCK; | |
1733 adj = (GtkAdjustment *)gtk_adjustment_new (1.0, 0.0, 100.0, 1.0, 5.0, 0.0); | |
1734 tmp = gtk_spin_button_new (adj, 0, 0); | |
1735 gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(tmp), TRUE); | |
1736 gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(tmp), TRUE); | |
1737 gtk_widget_show(tmp); | |
1738 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
1739 DW_MUTEX_UNLOCK; | |
1740 return tmp; | |
1741 } | |
1742 | |
1743 /* | |
1744 * Create a new radiobutton window (widget) to be packed. | |
1745 * Parameters: | |
1746 * text: The text to be display by the static text widget. | |
1747 * id: An ID to be used with WinWindowFromID() or 0L. | |
1748 */ | |
1749 HWND dw_radiobutton_new(char *text, ULONG id) | |
1750 { | |
1751 /* This will have to be fixed in the future. */ | |
1752 GtkWidget *tmp; | |
1753 int _locked_by_me = FALSE; | |
1754 | |
1755 DW_MUTEX_LOCK; | |
1756 tmp = gtk_radio_button_new_with_label(NULL, text); | |
1757 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
1758 gtk_widget_show(tmp); | |
1759 | |
1760 DW_MUTEX_UNLOCK; | |
1761 return tmp; | |
1762 } | |
1763 | |
1764 /* | |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
1765 * Create a new percent bar window (widget) to be packed. |
3 | 1766 * Parameters: |
1767 * id: An ID to be used with WinWindowFromID() or 0L. | |
1768 */ | |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
1769 HWND dw_percent_new(unsigned long id) |
3 | 1770 { |
1771 GtkWidget *tmp; | |
1772 int _locked_by_me = FALSE; | |
1773 | |
1774 DW_MUTEX_LOCK; | |
1775 tmp = gtk_progress_bar_new(); | |
1776 gtk_widget_show(tmp); | |
1777 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
1778 DW_MUTEX_UNLOCK; | |
1779 return tmp; | |
1780 } | |
1781 | |
1782 /* | |
1783 * Create a new checkbox window (widget) to be packed. | |
1784 * Parameters: | |
1785 * text: The text to be display by the static text widget. | |
1786 * id: An ID to be used with WinWindowFromID() or 0L. | |
1787 */ | |
1788 HWND dw_checkbox_new(char *text, unsigned long id) | |
1789 { | |
1790 GtkWidget *tmp; | |
1791 int _locked_by_me = FALSE; | |
1792 | |
1793 DW_MUTEX_LOCK; | |
1794 tmp = gtk_check_button_new_with_label(text); | |
1795 gtk_widget_show(tmp); | |
1796 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
1797 DW_MUTEX_UNLOCK; | |
1798 return tmp; | |
1799 } | |
1800 | |
1801 /* | |
1802 * Create a new listbox window (widget) to be packed. | |
1803 * Parameters: | |
1804 * id: An ID to be used with WinWindowFromID() or 0L. | |
1805 * multi: Multiple select TRUE or FALSE. | |
1806 */ | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1807 HWND dw_listbox_new(unsigned long id, int multi) |
3 | 1808 { |
1809 GtkWidget *tmp, *list; | |
1810 int _locked_by_me = FALSE; | |
1811 | |
1812 DW_MUTEX_LOCK; | |
1813 tmp = gtk_scrolled_window_new(NULL, NULL); | |
1814 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (tmp), | |
1815 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
1816 | |
1817 list = gtk_list_new(); | |
1818 gtk_list_set_selection_mode(GTK_LIST(list), multi ? GTK_SELECTION_MULTIPLE : GTK_SELECTION_SINGLE); | |
1819 | |
1820 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(tmp), | |
1821 list); | |
1822 gtk_object_set_user_data(GTK_OBJECT(tmp), list); | |
1823 gtk_widget_show(list); | |
1824 gtk_widget_show(tmp); | |
1825 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
1826 | |
1827 DW_MUTEX_UNLOCK; | |
1828 return tmp; | |
1829 } | |
1830 | |
1831 /* | |
1832 * Sets the icon used for a given window. | |
1833 * Parameters: | |
1834 * handle: Handle to the window. | |
1835 * id: An ID to be used to specify the icon. | |
1836 */ | |
1837 void dw_window_set_icon(HWND handle, unsigned long id) | |
1838 { | |
1839 GdkBitmap *bitmap; | |
1840 GdkPixmap *icon_pixmap; | |
1841 int _locked_by_me = FALSE; | |
1842 | |
1843 DW_MUTEX_LOCK; | |
1844 icon_pixmap = _find_pixmap(&bitmap, id, handle); | |
1845 | |
1846 if(handle->window && icon_pixmap) | |
1847 gdk_window_set_icon(handle->window, NULL, icon_pixmap, bitmap); | |
1848 | |
1849 DW_MUTEX_UNLOCK; | |
1850 } | |
1851 | |
1852 /* | |
1853 * Sets the bitmap used for a given static window. | |
1854 * Parameters: | |
1855 * handle: Handle to the window. | |
1856 * id: An ID to be used to specify the icon. | |
1857 */ | |
1858 void dw_window_set_bitmap(HWND handle, unsigned long id) | |
1859 { | |
1860 GdkBitmap *bitmap; | |
1861 GdkPixmap *tmp; | |
1862 int _locked_by_me = FALSE; | |
1863 | |
1864 DW_MUTEX_LOCK; | |
1865 tmp = _find_pixmap(&bitmap, id, handle); | |
1866 if(tmp) | |
1867 gtk_pixmap_set(GTK_PIXMAP(handle), tmp, bitmap); | |
1868 DW_MUTEX_UNLOCK; | |
1869 } | |
1870 | |
1871 /* | |
1872 * Sets the text used for a given window. | |
1873 * Parameters: | |
1874 * handle: Handle to the window. | |
1875 * text: The text associsated with a given window. | |
1876 */ | |
1877 void dw_window_set_text(HWND handle, char *text) | |
1878 { | |
1879 int _locked_by_me = FALSE; | |
1880 | |
1881 DW_MUTEX_LOCK; | |
1882 if(GTK_IS_ENTRY(handle)) | |
1883 gtk_entry_set_text(GTK_ENTRY(handle), text); | |
1884 else if(GTK_IS_COMBO(handle)) | |
1885 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(handle)->entry), text); | |
1886 else if(GTK_IS_LABEL(handle)) | |
1887 gtk_label_set_text(GTK_LABEL(handle), text); | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1888 else if(GTK_IS_FRAME(handle)) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1889 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1890 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "label"); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1891 if(tmp && GTK_IS_LABEL(tmp)) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1892 gtk_label_set_text(GTK_LABEL(tmp), text); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1893 } |
3 | 1894 DW_MUTEX_UNLOCK; |
1895 } | |
1896 | |
1897 /* | |
1898 * Gets the text used for a given window. | |
1899 * Parameters: | |
1900 * handle: Handle to the window. | |
1901 * Returns: | |
1902 * text: The text associsated with a given window. | |
1903 */ | |
1904 char *dw_window_get_text(HWND handle) | |
1905 { | |
1906 char *possible = ""; | |
1907 int _locked_by_me = FALSE; | |
1908 | |
1909 DW_MUTEX_LOCK; | |
1910 if(GTK_IS_ENTRY(handle)) | |
1911 possible = gtk_entry_get_text(GTK_ENTRY(handle)); | |
1912 else if(GTK_IS_COMBO(handle)) | |
1913 possible = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(handle)->entry)); | |
1914 | |
1915 DW_MUTEX_UNLOCK; | |
1916 return strdup(possible); | |
1917 } | |
1918 | |
1919 /* | |
1920 * Disables given window (widget). | |
1921 * Parameters: | |
1922 * handle: Handle to the window. | |
1923 */ | |
1924 void dw_window_disable(HWND handle) | |
1925 { | |
1926 int _locked_by_me = FALSE; | |
1927 | |
1928 DW_MUTEX_LOCK; | |
1929 gtk_widget_set_sensitive(handle, FALSE); | |
1930 DW_MUTEX_UNLOCK; | |
1931 } | |
1932 | |
1933 /* | |
1934 * Enables given window (widget). | |
1935 * Parameters: | |
1936 * handle: Handle to the window. | |
1937 */ | |
1938 void dw_window_enable(HWND handle) | |
1939 { | |
1940 int _locked_by_me = FALSE; | |
1941 | |
1942 DW_MUTEX_LOCK; | |
1943 gtk_widget_set_sensitive(handle, TRUE); | |
1944 DW_MUTEX_UNLOCK; | |
1945 } | |
1946 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1947 void _strip_cr(char *dest, char *src) |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1948 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1949 int z, x = 0; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1950 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1951 for(z=0;z<strlen(src);z++) |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1952 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1953 if(src[z] != '\r') |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1954 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1955 dest[x] = src[z]; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1956 x++; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1957 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1958 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1959 dest[x] = 0; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1960 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1961 |
3 | 1962 /* |
1963 * Adds text to an MLE box and returns the current point. | |
1964 * Parameters: | |
1965 * handle: Handle to the MLE to be queried. | |
1966 * buffer: Text buffer to be imported. | |
1967 * startpoint: Point to start entering text. | |
1968 */ | |
1969 unsigned int dw_mle_import(HWND handle, char *buffer, int startpoint) | |
1970 { | |
1971 unsigned int tmppoint = startpoint; | |
1972 int _locked_by_me = FALSE; | |
1973 | |
1974 DW_MUTEX_LOCK; | |
1975 if(GTK_IS_BOX(handle)) | |
1976 { | |
1977 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1978 GdkFont *font = (GdkFont *)gtk_object_get_data(GTK_OBJECT(handle), "gdkfont"); |
3 | 1979 |
1980 if(tmp && GTK_IS_TEXT(tmp)) | |
1981 { | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1982 GdkColor *fore = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle), "foregdk"); |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1983 GdkColor *back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle), "backgdk"); |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1984 char *impbuf = malloc(strlen(buffer)+1); |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1985 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1986 _strip_cr(impbuf, buffer); |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1987 |
3 | 1988 gtk_text_set_point(GTK_TEXT(tmp), startpoint < 0 ? 0 : startpoint); |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1989 gtk_text_insert(GTK_TEXT(tmp), font, fore, back, impbuf, -1); |
3 | 1990 tmppoint = gtk_text_get_point(GTK_TEXT(tmp)); |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1991 free(impbuf); |
3 | 1992 } |
1993 } | |
1994 DW_MUTEX_UNLOCK; | |
1995 return tmppoint; | |
1996 } | |
1997 | |
1998 /* | |
1999 * Grabs text from an MLE box. | |
2000 * Parameters: | |
2001 * handle: Handle to the MLE to be queried. | |
2002 * buffer: Text buffer to be exported. | |
2003 * startpoint: Point to start grabbing text. | |
2004 * length: Amount of text to be grabbed. | |
2005 */ | |
2006 void dw_mle_export(HWND handle, char *buffer, int startpoint, int length) | |
2007 { | |
2008 int _locked_by_me = FALSE; | |
2009 gchar *text; | |
2010 | |
2011 DW_MUTEX_LOCK; | |
2012 if(GTK_IS_BOX(handle)) | |
2013 { | |
2014 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); | |
2015 | |
2016 if(tmp && GTK_IS_TEXT(tmp)) | |
2017 { | |
2018 text = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), startpoint, startpoint + length); | |
2019 if(text) | |
2020 { | |
2021 strcpy(buffer, text); | |
2022 g_free(text); | |
2023 } | |
2024 } | |
2025 } | |
2026 DW_MUTEX_UNLOCK; | |
2027 } | |
2028 | |
2029 /* | |
2030 * Obtains information about an MLE box. | |
2031 * Parameters: | |
2032 * handle: Handle to the MLE to be queried. | |
2033 * bytes: A pointer to a variable to return the total bytes. | |
2034 * lines: A pointer to a variable to return the number of lines. | |
2035 */ | |
2036 void dw_mle_query(HWND handle, unsigned long *bytes, unsigned long *lines) | |
2037 { | |
2038 int _locked_by_me = FALSE; | |
2039 | |
2040 if(bytes) | |
2041 *bytes = 0; | |
2042 if(lines) | |
2043 *lines = 0; | |
2044 | |
2045 DW_MUTEX_LOCK; | |
2046 if(GTK_IS_BOX(handle)) | |
2047 { | |
2048 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); | |
2049 | |
2050 if(tmp && GTK_IS_TEXT(tmp)) | |
2051 { | |
2052 if(bytes) | |
2053 *bytes = gtk_text_get_length(GTK_TEXT(tmp)); | |
2054 if(lines) | |
2055 { | |
2056 gchar *text; | |
2057 | |
2058 *lines = 0; | |
2059 text = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), 0, bytes ? *bytes : gtk_text_get_length(GTK_TEXT(tmp))); | |
2060 | |
2061 if(text) | |
2062 { | |
2063 int z, len = strlen(text); | |
2064 | |
2065 for(z=0;z<len;z++) | |
2066 { | |
2067 if(text[z] == '\n') | |
2068 (*lines)++; | |
2069 } | |
2070 g_free(text); | |
2071 } | |
2072 } | |
2073 } | |
2074 } | |
2075 DW_MUTEX_UNLOCK; | |
2076 } | |
2077 | |
2078 /* | |
2079 * Deletes text from an MLE box. | |
2080 * Parameters: | |
2081 * handle: Handle to the MLE to be deleted from. | |
2082 * startpoint: Point to start deleting text. | |
2083 * length: Amount of text to be deleted. | |
2084 */ | |
2085 void dw_mle_delete(HWND handle, int startpoint, int length) | |
2086 { | |
2087 int _locked_by_me = FALSE; | |
2088 | |
2089 DW_MUTEX_LOCK; | |
2090 if(GTK_IS_BOX(handle)) | |
2091 { | |
2092 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); | |
2093 | |
2094 if(tmp && GTK_IS_TEXT(tmp)) | |
2095 { | |
2096 gtk_text_set_point(GTK_TEXT(tmp), startpoint); | |
2097 gtk_text_forward_delete(GTK_TEXT(tmp), length); | |
2098 } | |
2099 } | |
2100 DW_MUTEX_UNLOCK; | |
2101 } | |
2102 | |
2103 /* | |
2104 * Clears all text from an MLE box. | |
2105 * Parameters: | |
2106 * handle: Handle to the MLE to be cleared. | |
2107 */ | |
2108 void dw_mle_clear(HWND handle) | |
2109 { | |
2110 int length, _locked_by_me = FALSE; | |
2111 | |
2112 DW_MUTEX_LOCK; | |
2113 if(GTK_IS_BOX(handle)) | |
2114 { | |
2115 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); | |
2116 | |
2117 if(tmp && GTK_IS_TEXT(tmp)) | |
2118 { | |
2119 length = gtk_text_get_length(GTK_TEXT(tmp)); | |
2120 gtk_text_set_point(GTK_TEXT(tmp), 0); | |
2121 gtk_text_forward_delete(GTK_TEXT(tmp), length); | |
2122 } | |
2123 } | |
2124 DW_MUTEX_UNLOCK; | |
2125 } | |
2126 | |
2127 /* | |
2128 * Sets the visible line of an MLE box. | |
2129 * Parameters: | |
2130 * handle: Handle to the MLE. | |
2131 * line: Line to be visible. | |
2132 */ | |
2133 void dw_mle_set_visible(HWND handle, int line) | |
2134 { | |
2135 int _locked_by_me = FALSE; | |
2136 | |
2137 DW_MUTEX_LOCK; | |
2138 if(GTK_IS_BOX(handle)) | |
2139 { | |
2140 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); | |
2141 | |
2142 if(tmp && GTK_IS_TEXT(tmp)) | |
2143 { | |
2144 unsigned long lines; | |
2145 float pos, ratio; | |
2146 | |
2147 dw_mle_query(handle, NULL, &lines); | |
2148 | |
2149 if(lines) | |
2150 { | |
2151 ratio = (float)line/(float)lines; | |
2152 | |
2153 pos = (ratio * (float)(GTK_TEXT(tmp)->vadj->upper - GTK_TEXT(tmp)->vadj->lower)) + GTK_TEXT(tmp)->vadj->lower; | |
2154 | |
2155 gtk_adjustment_set_value(GTK_TEXT(tmp)->vadj, pos); | |
2156 } | |
2157 } | |
2158 } | |
2159 DW_MUTEX_UNLOCK; | |
2160 } | |
2161 | |
2162 /* | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2163 * Sets the editablity of an MLE box. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2164 * Parameters: |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2165 * handle: Handle to the MLE. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2166 * state: TRUE if it can be edited, FALSE for readonly. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2167 */ |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2168 void dw_mle_set_editable(HWND handle, int state) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2169 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2170 int _locked_by_me = FALSE; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2171 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2172 DW_MUTEX_LOCK; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2173 if(GTK_IS_BOX(handle)) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2174 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2175 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2176 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2177 if(tmp && GTK_IS_TEXT(tmp)) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2178 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2179 gtk_text_set_editable(GTK_TEXT(tmp), state); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2180 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2181 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2182 DW_MUTEX_UNLOCK; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2183 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2184 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2185 /* |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2186 * Sets the word wrap state of an MLE box. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2187 * Parameters: |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2188 * handle: Handle to the MLE. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2189 * state: TRUE if it wraps, FALSE if it doesn't. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2190 */ |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2191 void dw_mle_set_word_wrap(HWND handle, int state) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2192 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2193 int _locked_by_me = FALSE; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2194 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2195 DW_MUTEX_LOCK; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2196 if(GTK_IS_BOX(handle)) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2197 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2198 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2199 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2200 if(tmp && GTK_IS_TEXT(tmp)) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2201 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2202 gtk_text_set_word_wrap(GTK_TEXT(tmp), state); |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2203 gtk_text_set_line_wrap(GTK_TEXT(tmp), state); |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2204 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2205 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2206 DW_MUTEX_UNLOCK; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2207 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2208 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2209 /* |
3 | 2210 * Sets the current cursor position of an MLE box. |
2211 * Parameters: | |
2212 * handle: Handle to the MLE to be positioned. | |
2213 * point: Point to position cursor. | |
2214 */ | |
2215 void dw_mle_set(HWND handle, int point) | |
2216 { | |
2217 int _locked_by_me = FALSE; | |
2218 | |
2219 DW_MUTEX_LOCK; | |
2220 if(GTK_IS_BOX(handle)) | |
2221 { | |
2222 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); | |
2223 | |
2224 if(tmp && GTK_IS_TEXT(tmp)) | |
2225 { | |
2226 gtk_text_set_point(GTK_TEXT(tmp), point); | |
2227 } | |
2228 } | |
2229 DW_MUTEX_UNLOCK; | |
2230 } | |
2231 | |
2232 /* | |
2233 * Finds text in an MLE box. | |
2234 * Parameters: | |
2235 * handle: Handle to the MLE to be cleared. | |
2236 * text: Text to search for. | |
2237 * point: Start point of search. | |
2238 * flags: Search specific flags. | |
2239 */ | |
2240 int dw_mle_search(HWND handle, char *text, int point, unsigned long flags) | |
2241 { | |
2242 int _locked_by_me = FALSE, retval = 0; | |
2243 | |
2244 DW_MUTEX_LOCK; | |
2245 if(GTK_IS_BOX(handle)) | |
2246 { | |
2247 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); | |
2248 | |
2249 if(tmp && GTK_IS_TEXT(tmp)) | |
2250 { | |
2251 int len = gtk_text_get_length(GTK_TEXT(tmp)); | |
2252 gchar *tmpbuf; | |
2253 | |
2254 tmpbuf = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), 0, len); | |
2255 if(tmpbuf) | |
2256 { | |
2257 int z, textlen; | |
2258 | |
2259 textlen = strlen(text); | |
2260 | |
2261 if(flags & DW_MLE_CASESENSITIVE) | |
2262 { | |
2263 for(z=point;z<(len-textlen) && !retval;z++) | |
2264 { | |
2265 if(strncmp(&tmpbuf[z], text, textlen) == 0) | |
2266 retval = z + textlen; | |
2267 } | |
2268 } | |
2269 else | |
2270 { | |
2271 for(z=point;z<(len-textlen) && !retval;z++) | |
2272 { | |
2273 if(strncasecmp(&tmpbuf[z], text, textlen) == 0) | |
2274 retval = z + textlen; | |
2275 } | |
2276 } | |
2277 | |
2278 if(retval) | |
2279 { | |
2280 gtk_text_set_point(GTK_TEXT(tmp), retval - textlen); | |
2281 gtk_editable_select_region(&(GTK_TEXT(tmp)->editable), retval - textlen, retval); | |
2282 } | |
2283 | |
2284 g_free(tmpbuf); | |
2285 } | |
2286 } | |
2287 } | |
2288 | |
2289 DW_MUTEX_UNLOCK; | |
2290 return retval; | |
2291 } | |
2292 | |
2293 /* | |
2294 * Stops redrawing of an MLE box. | |
2295 * Parameters: | |
2296 * handle: Handle to the MLE to freeze. | |
2297 */ | |
2298 void dw_mle_freeze(HWND handle) | |
2299 { | |
2300 int _locked_by_me = FALSE; | |
2301 | |
2302 DW_MUTEX_LOCK; | |
2303 if(GTK_IS_BOX(handle)) | |
2304 { | |
2305 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); | |
2306 | |
2307 if(tmp && GTK_IS_TEXT(tmp)) | |
2308 { | |
2309 gtk_text_freeze(GTK_TEXT(tmp)); | |
2310 } | |
2311 } | |
2312 DW_MUTEX_UNLOCK; | |
2313 } | |
2314 | |
2315 /* | |
2316 * Resumes redrawing of an MLE box. | |
2317 * Parameters: | |
2318 * handle: Handle to the MLE to thaw. | |
2319 */ | |
2320 void dw_mle_thaw(HWND handle) | |
2321 { | |
2322 int _locked_by_me = FALSE; | |
2323 | |
2324 DW_MUTEX_LOCK; | |
2325 if(GTK_IS_BOX(handle)) | |
2326 { | |
2327 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); | |
2328 | |
2329 if(tmp && GTK_IS_TEXT(tmp)) | |
2330 { | |
2331 gtk_text_thaw(GTK_TEXT(tmp)); | |
2332 } | |
2333 } | |
2334 DW_MUTEX_UNLOCK; | |
2335 } | |
2336 | |
2337 /* | |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
2338 * Returns the range of the percent bar. |
3 | 2339 * Parameters: |
2340 * handle: Handle to the slider to be queried. | |
2341 */ | |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
2342 unsigned int dw_percent_query_range(HWND handle) |
3 | 2343 { |
2344 return 100; | |
2345 } | |
2346 | |
2347 /* | |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
2348 * Sets the percent bar position. |
3 | 2349 * Parameters: |
2350 * handle: Handle to the slider to be set. | |
2351 * position: Position of the slider withing the range. | |
2352 */ | |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
2353 void dw_percent_set_pos(HWND handle, unsigned int position) |
3 | 2354 { |
2355 int _locked_by_me = FALSE; | |
2356 | |
2357 DW_MUTEX_LOCK; | |
2358 gtk_progress_bar_update(GTK_PROGRESS_BAR(handle), (gfloat)position/100); | |
2359 DW_MUTEX_UNLOCK; | |
2360 } | |
2361 | |
2362 /* | |
2363 * Sets the spinbutton value. | |
2364 * Parameters: | |
2365 * handle: Handle to the spinbutton to be set. | |
2366 * position: Current value of the spinbutton. | |
2367 */ | |
2368 void dw_spinbutton_set_pos(HWND handle, long position) | |
2369 { | |
2370 int _locked_by_me = FALSE; | |
2371 | |
2372 DW_MUTEX_LOCK; | |
2373 gtk_spin_button_set_value(GTK_SPIN_BUTTON(handle), (gfloat)position); | |
2374 DW_MUTEX_UNLOCK; | |
2375 } | |
2376 | |
2377 /* | |
2378 * Sets the spinbutton limits. | |
2379 * Parameters: | |
2380 * handle: Handle to the spinbutton to be set. | |
2381 * position: Current value of the spinbutton. | |
2382 * position: Current value of the spinbutton. | |
2383 */ | |
2384 void dw_spinbutton_set_limits(HWND handle, long upper, long lower) | |
2385 { | |
2386 long curval; | |
2387 GtkAdjustment *adj; | |
2388 int _locked_by_me = FALSE; | |
2389 | |
2390 curval = dw_spinbutton_query(handle); | |
2391 DW_MUTEX_LOCK; | |
2392 adj = (GtkAdjustment *)gtk_adjustment_new((gfloat)curval, (gfloat)lower, (gfloat)upper, 1.0, 5.0, 0.0); | |
2393 DW_MUTEX_UNLOCK; | |
2394 } | |
2395 | |
2396 /* | |
2397 * Sets the entryfield character limit. | |
2398 * Parameters: | |
2399 * handle: Handle to the spinbutton to be set. | |
2400 * limit: Number of characters the entryfield will take. | |
2401 */ | |
2402 void dw_entryfield_set_limit(HWND handle, ULONG limit) | |
2403 { | |
2404 /* TODO: can this be done after the fact? */ | |
2405 } | |
2406 | |
2407 /* | |
2408 * Returns the current value of the spinbutton. | |
2409 * Parameters: | |
2410 * handle: Handle to the spinbutton to be queried. | |
2411 */ | |
2412 long dw_spinbutton_query(HWND handle) | |
2413 { | |
2414 long retval; | |
2415 int _locked_by_me = FALSE; | |
2416 | |
2417 DW_MUTEX_LOCK; | |
2418 retval = (long)gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(handle)); | |
2419 DW_MUTEX_UNLOCK; | |
2420 | |
2421 return retval; | |
2422 } | |
2423 | |
2424 /* | |
2425 * Returns the state of the checkbox. | |
2426 * Parameters: | |
2427 * handle: Handle to the checkbox to be queried. | |
2428 */ | |
2429 int dw_checkbox_query(HWND handle) | |
2430 { | |
2431 int retval; | |
2432 int _locked_by_me = FALSE; | |
2433 | |
2434 DW_MUTEX_LOCK; | |
2435 retval = GTK_TOGGLE_BUTTON(handle)->active; | |
2436 DW_MUTEX_UNLOCK; | |
2437 | |
2438 return retval; | |
2439 } | |
2440 | |
2441 /* | |
2442 * Sets the state of the checkbox. | |
2443 * Parameters: | |
2444 * handle: Handle to the checkbox to be queried. | |
2445 * value: TRUE for checked, FALSE for unchecked. | |
2446 */ | |
2447 void dw_checkbox_set(HWND handle, int value) | |
2448 { | |
2449 int _locked_by_me = FALSE; | |
2450 | |
2451 DW_MUTEX_LOCK; | |
2452 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(handle), value); | |
2453 DW_MUTEX_UNLOCK; | |
2454 } | |
2455 | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2456 /* |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2457 * Inserts an item into a tree window (widget). |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2458 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2459 * handle: Handle to the tree to be inserted. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2460 * title: The text title of the entry. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2461 * icon: Handle to coresponding icon. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2462 * parent: Parent handle or 0 if root. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2463 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2464 HWND dw_tree_insert(HWND handle, char *title, unsigned long icon, HWND parent) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2465 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2466 GtkWidget *item, *tree, *subtree, *label, *hbox, *pixmap; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2467 GdkPixmap *gdkpix; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2468 GdkBitmap *gdkbmp; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2469 int _locked_by_me = FALSE; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2470 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2471 DW_MUTEX_LOCK; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2472 tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2473 if(!tree || !GTK_IS_TREE(tree)) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2474 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2475 DW_MUTEX_UNLOCK; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2476 return NULL; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2477 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2478 item = gtk_tree_item_new(); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2479 label = gtk_label_new(title); |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2480 gtk_object_set_data(GTK_OBJECT(item), "text", (gpointer)strdup(title)); |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2481 hbox = gtk_hbox_new(FALSE, 2); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2482 gdkpix = _find_pixmap(&gdkbmp, icon, hbox); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2483 pixmap = gtk_pixmap_new(gdkpix, gdkbmp); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2484 gtk_container_add(GTK_CONTAINER(item), hbox); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2485 gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, TRUE, 0); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2486 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, TRUE, 0); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2487 gtk_widget_show(label); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2488 gtk_widget_show(pixmap); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2489 gtk_widget_show(hbox); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2490 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2491 if(parent) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2492 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2493 subtree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(parent)); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2494 if(!subtree) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2495 { |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2496 void *thisfunc = (void *)gtk_object_get_data(GTK_OBJECT(tree), "select-child-func"); |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2497 void *work = (void *)gtk_object_get_data(GTK_OBJECT(tree), "select-child-data"); |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2498 |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2499 subtree = gtk_tree_new(); |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2500 |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2501 if(thisfunc && work) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2502 gtk_signal_connect(GTK_OBJECT(subtree), "select-child", GTK_SIGNAL_FUNC(thisfunc), work); |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2503 |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2504 gtk_object_set_user_data(GTK_OBJECT(parent), subtree); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2505 gtk_tree_set_selection_mode(GTK_TREE(subtree), GTK_SELECTION_SINGLE); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2506 gtk_tree_set_view_mode(GTK_TREE(subtree), GTK_TREE_VIEW_ITEM); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2507 gtk_tree_item_set_subtree(GTK_TREE_ITEM(parent), subtree); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2508 gtk_widget_show(subtree); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2509 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2510 gtk_tree_append(GTK_TREE(subtree), item); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2511 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2512 else |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2513 gtk_tree_append(GTK_TREE(tree), item); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2514 gtk_widget_show(item); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2515 DW_MUTEX_UNLOCK; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2516 return item; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2517 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2518 |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2519 /* |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2520 * Removes all nodes from a tree. |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2521 * Parameters: |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2522 * handle: Handle to the window (widget) to be cleared. |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2523 */ |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2524 void dw_tree_clear(HWND handle) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2525 { |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2526 GtkWidget *tree; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2527 int _locked_by_me = FALSE; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2528 |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2529 DW_MUTEX_LOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2530 tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2531 if(!tree || !GTK_IS_TREE(tree)) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2532 { |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2533 DW_MUTEX_UNLOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2534 return; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2535 } |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2536 gtk_tree_clear_items(GTK_TREE(tree), 0, 1000000); |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2537 DW_MUTEX_UNLOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2538 } |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2539 |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2540 /* |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2541 * Removes a node from a tree. |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2542 * Parameters: |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2543 * handle: Handle to the window (widget) to be cleared. |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2544 * item: Handle to node to be deleted. |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2545 */ |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2546 void dw_tree_delete(HWND handle, HWND item) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2547 { |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2548 GtkWidget *tree; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2549 int _locked_by_me = FALSE; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2550 |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2551 DW_MUTEX_LOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2552 tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2553 if(!tree || !GTK_IS_TREE(tree)) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2554 { |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2555 DW_MUTEX_UNLOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2556 return; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2557 } |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2558 gtk_tree_remove_item(GTK_TREE(tree), item); |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2559 DW_MUTEX_UNLOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2560 } |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
2561 |
3 | 2562 int _dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator, int extra) |
2563 { | |
2564 GtkWidget *clist; | |
2565 char numbuf[10]; | |
2566 int z; | |
2567 int _locked_by_me = FALSE; | |
2568 | |
2569 DW_MUTEX_LOCK; | |
2570 clist = gtk_clist_new_with_titles(count, (gchar **)titles); | |
2571 if(!clist) | |
2572 { | |
2573 DW_MUTEX_UNLOCK; | |
2574 return FALSE; | |
2575 } | |
2576 | |
2577 gtk_signal_connect(GTK_OBJECT(clist), "select_row", GTK_SIGNAL_FUNC(_select_row), NULL); | |
2578 gtk_signal_connect(GTK_OBJECT(clist), "unselect_row", GTK_SIGNAL_FUNC(_unselect_row), NULL); | |
2579 | |
2580 gtk_clist_set_column_auto_resize(GTK_CLIST(clist), 0, TRUE); | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2581 gtk_clist_set_selection_mode(GTK_CLIST(clist), GTK_SELECTION_SINGLE); |
3 | 2582 gtk_container_add(GTK_CONTAINER(handle), clist); |
2583 gtk_object_set_user_data(GTK_OBJECT(handle), (gpointer)clist); | |
2584 gtk_widget_show(clist); | |
2585 gtk_object_set_data(GTK_OBJECT(clist), "colcount", (gpointer)count); | |
2586 | |
2587 if(extra) | |
2588 gtk_clist_set_column_width(GTK_CLIST(clist), 1, 120); | |
2589 | |
2590 for(z=0;z<count;z++) | |
2591 { | |
2592 if(!extra || z > 1) | |
2593 gtk_clist_set_column_width(GTK_CLIST(clist), z, 50); | |
2594 sprintf(numbuf, "%d", z); | |
2595 gtk_object_set_data(GTK_OBJECT(clist), numbuf, (gpointer)flags[z]); | |
2596 } | |
2597 | |
2598 DW_MUTEX_UNLOCK; | |
2599 return TRUE; | |
2600 } | |
2601 | |
2602 /* | |
2603 * Sets up the container columns. | |
2604 * Parameters: | |
2605 * handle: Handle to the container to be configured. | |
2606 * flags: An array of unsigned longs with column flags. | |
2607 * titles: An array of strings with column text titles. | |
2608 * count: The number of columns (this should match the arrays). | |
2609 * separator: The column number that contains the main separator. | |
2610 * (this item may only be used in OS/2) | |
2611 */ | |
2612 int dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator) | |
2613 { | |
2614 return _dw_container_setup(handle, flags, titles, count, separator, 0); | |
2615 } | |
2616 | |
2617 /* | |
2618 * Sets up the filesystem columns, note: filesystem always has an icon/filename field. | |
2619 * Parameters: | |
2620 * handle: Handle to the container to be configured. | |
2621 * flags: An array of unsigned longs with column flags. | |
2622 * titles: An array of strings with column text titles. | |
2623 * count: The number of columns (this should match the arrays). | |
2624 */ | |
2625 int dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count) | |
2626 { | |
2627 char **newtitles = malloc(sizeof(char *) * (count + 2)); | |
2628 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 2)); | |
2629 | |
2630 newtitles[0] = "Icon"; | |
2631 newtitles[1] = "Filename"; | |
2632 | |
2633 newflags[0] = DW_CFA_BITMAPORICON | DW_CFA_CENTER | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR; | |
2634 newflags[1] = DW_CFA_STRING | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR; | |
2635 | |
2636 memcpy(&newtitles[2], titles, sizeof(char *) * count); | |
2637 memcpy(&newflags[2], flags, sizeof(unsigned long) * count); | |
2638 | |
2639 _dw_container_setup(handle, newflags, newtitles, count + 2, 2, 1); | |
2640 | |
2641 free(newtitles); | |
2642 free(newflags); | |
2643 return TRUE; | |
2644 } | |
2645 | |
2646 /* | |
2647 * Obtains an icon from a module (or header in GTK). | |
2648 * Parameters: | |
2649 * module: Handle to module (DLL) in OS/2 and Windows. | |
2650 * id: A unsigned long id int the resources on OS/2 and | |
2651 * Windows, on GTK this is converted to a pointer | |
2652 * to an embedded XPM. | |
2653 */ | |
2654 unsigned long dw_icon_load(unsigned long module, unsigned long id) | |
2655 { | |
2656 return id; | |
2657 } | |
2658 | |
2659 /* | |
2660 * Frees a loaded resource in OS/2 and Windows. | |
2661 * Parameters: | |
2662 * handle: Handle to icon returned by dw_icon_load(). | |
2663 */ | |
2664 void dw_icon_free(unsigned long handle) | |
2665 { | |
2666 } | |
2667 | |
2668 /* | |
2669 * Allocates memory used to populate a container. | |
2670 * Parameters: | |
2671 * handle: Handle to the container window (widget). | |
2672 * rowcount: The number of items to be populated. | |
2673 */ | |
2674 void *dw_container_alloc(HWND handle, int rowcount) | |
2675 { | |
2676 int z, count = 0; | |
2677 GtkWidget *clist; | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2678 GdkColor *fore, *back; |
3 | 2679 char **blah; |
2680 int _locked_by_me = FALSE; | |
2681 | |
2682 DW_MUTEX_LOCK; | |
2683 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
2684 if(!clist) | |
2685 { | |
2686 DW_MUTEX_UNLOCK; | |
2687 return NULL; | |
2688 } | |
2689 | |
2690 count = (int)gtk_object_get_data(GTK_OBJECT(clist), "colcount"); | |
2691 | |
2692 if(!count) | |
2693 { | |
2694 DW_MUTEX_UNLOCK; | |
2695 return NULL; | |
2696 } | |
2697 | |
2698 blah = malloc(sizeof(char *) * count); | |
2699 memset(blah, 0, sizeof(char *) * count); | |
2700 | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2701 fore = (GdkColor *)gtk_object_get_data(GTK_OBJECT(clist), "foregdk"); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2702 back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(clist), "backgdk"); |
3 | 2703 gtk_clist_freeze(GTK_CLIST(clist)); |
2704 for(z=0;z<rowcount;z++) | |
2705 { | |
2706 gtk_clist_append(GTK_CLIST(clist), blah); | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2707 if(fore) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2708 gtk_clist_set_foreground(GTK_CLIST(clist), z, fore); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2709 if(back) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2710 gtk_clist_set_background(GTK_CLIST(clist), z, back); |
3 | 2711 } |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2712 gtk_object_set_data(GTK_OBJECT(clist), "rowcount", (gpointer)rowcount); |
3 | 2713 free(blah); |
2714 DW_MUTEX_UNLOCK; | |
2715 return (void *)handle; | |
2716 } | |
2717 | |
2718 /* | |
2719 * Sets an item in specified row and column to the given data. | |
2720 * Parameters: | |
2721 * handle: Handle to the container window (widget). | |
2722 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
2723 * column: Zero based column of data being set. | |
2724 * row: Zero based row of data being set. | |
2725 * data: Pointer to the data to be added. | |
2726 */ | |
2727 void dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data) | |
2728 { | |
2729 char numbuf[10], textbuffer[100]; | |
2730 int flag = 0; | |
2731 GtkWidget *clist; | |
2732 int _locked_by_me = FALSE; | |
2733 | |
2734 DW_MUTEX_LOCK; | |
2735 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
2736 if(!clist) | |
2737 { | |
2738 DW_MUTEX_UNLOCK; | |
2739 return; | |
2740 } | |
2741 | |
2742 sprintf(numbuf, "%d", column); | |
2743 flag = (int)gtk_object_get_data(GTK_OBJECT(clist), numbuf); | |
2744 | |
2745 if(flag & DW_CFA_BITMAPORICON) | |
2746 { | |
2747 long hicon = *((long *)data); | |
2748 GdkBitmap *bitmap; | |
2749 GdkPixmap *pixmap = _find_pixmap(&bitmap, hicon, clist); | |
2750 | |
2751 if(pixmap) | |
2752 gtk_clist_set_pixmap(GTK_CLIST(clist), row, column, pixmap, bitmap); | |
2753 } | |
2754 else if(flag & DW_CFA_STRING) | |
2755 { | |
2756 char *tmp = *((char **)data); | |
2757 gtk_clist_set_text(GTK_CLIST(clist), row, column, tmp); | |
2758 } | |
2759 else if(flag & DW_CFA_ULONG) | |
2760 { | |
2761 ULONG tmp = *((ULONG *)data); | |
2762 | |
2763 sprintf(textbuffer, "%lu", tmp); | |
2764 | |
2765 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer); | |
2766 } | |
2767 else if(flag & DW_CFA_DATE) | |
2768 { | |
2769 CDATE fdate = *((CDATE *)data); | |
2770 | |
2771 sprintf(textbuffer, "%s %d, %d", monthlist[fdate.month], fdate.day, fdate.year); | |
2772 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer); | |
2773 } | |
2774 else if(flag & DW_CFA_TIME) | |
2775 { | |
2776 CTIME ftime = *((CTIME *)data); | |
2777 | |
2778 if(ftime.hours > 12) | |
2779 sprintf(textbuffer, "%d:%s%dpm", ftime.hours - 12, (ftime.minutes < 10) ? "0" : "", ftime.minutes); | |
2780 else | |
2781 sprintf(textbuffer, "%d:%s%dam", ftime.hours ? ftime.hours : 12, (ftime.minutes < 10) ? "0" : "", ftime.minutes); | |
2782 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer); | |
2783 } | |
2784 DW_MUTEX_UNLOCK; | |
2785 } | |
2786 | |
2787 /* | |
2788 * Sets an item in specified row and column to the given data. | |
2789 * Parameters: | |
2790 * handle: Handle to the container window (widget). | |
2791 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
2792 * column: Zero based column of data being set. | |
2793 * row: Zero based row of data being set. | |
2794 * data: Pointer to the data to be added. | |
2795 */ | |
2796 void dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, unsigned long icon) | |
2797 { | |
2798 dw_container_set_item(handle, pointer, 0, row, (void *)&icon); | |
2799 dw_container_set_item(handle, pointer, 1, row, (void *)&filename); | |
2800 } | |
2801 | |
2802 /* | |
2803 * Sets an item in specified row and column to the given data. | |
2804 * Parameters: | |
2805 * handle: Handle to the container window (widget). | |
2806 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
2807 * column: Zero based column of data being set. | |
2808 * row: Zero based row of data being set. | |
2809 * data: Pointer to the data to be added. | |
2810 */ | |
2811 void dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data) | |
2812 { | |
2813 dw_container_set_item(handle, pointer, column + 2, row, data); | |
2814 } | |
2815 | |
2816 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2817 * Sets the width of a column in the container. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2818 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2819 * handle: Handle to window (widget) of container. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2820 * column: Zero based column of width being set. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2821 * width: Width of column in pixels. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2822 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2823 void dw_container_set_column_width(HWND handle, int column, int width) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2824 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2825 GtkWidget *clist; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2826 int _locked_by_me = FALSE; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2827 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2828 DW_MUTEX_LOCK; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2829 clist = gtk_object_get_user_data(GTK_OBJECT(handle)); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2830 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2831 if(clist && GTK_IS_CLIST(clist)) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2832 gtk_clist_set_column_width(GTK_CLIST(clist), column, width); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2833 DW_MUTEX_UNLOCK; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2834 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2835 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2836 /* |
3 | 2837 * Sets the title of a row in the container. |
2838 * Parameters: | |
2839 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
2840 * row: Zero based row of data being set. | |
2841 * title: String title of the item. | |
2842 */ | |
2843 void dw_container_set_row_title(void *pointer, int row, char *title) | |
2844 { | |
2845 GtkWidget *clist; | |
2846 int _locked_by_me = FALSE; | |
2847 | |
2848 DW_MUTEX_LOCK; | |
2849 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(pointer)); | |
2850 | |
2851 if(clist) | |
2852 gtk_clist_set_row_data(GTK_CLIST(clist), row, (gpointer)title); | |
2853 DW_MUTEX_UNLOCK; | |
2854 } | |
2855 | |
2856 /* | |
2857 * Sets the title of a row in the container. | |
2858 * Parameters: | |
2859 * handle: Handle to the container window (widget). | |
2860 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
2861 * rowcount: The number of rows to be inserted. | |
2862 */ | |
2863 void dw_container_insert(HWND handle, void *pointer, int rowcount) | |
2864 { | |
2865 GtkWidget *clist; | |
2866 int _locked_by_me = FALSE; | |
2867 | |
2868 DW_MUTEX_LOCK; | |
2869 clist = gtk_object_get_user_data(GTK_OBJECT(handle)); | |
2870 | |
2871 if(clist && GTK_IS_CLIST(clist)) | |
2872 gtk_clist_thaw(GTK_CLIST(clist)); | |
2873 DW_MUTEX_UNLOCK; | |
2874 } | |
2875 | |
2876 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2877 * Removes the first x rows from a container. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2878 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2879 * handle: Handle to the window (widget) to be deleted from. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2880 * rowcount: The number of rows to be deleted. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2881 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2882 void dw_container_delete(HWND handle, int rowcount) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2883 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2884 GtkWidget *clist; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2885 GList *list; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2886 int _locked_by_me = FALSE; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2887 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2888 DW_MUTEX_LOCK; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2889 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle)); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2890 if(clist && GTK_IS_CLIST(clist)) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2891 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2892 int rows, z; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2893 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2894 list = (GList *)gtk_object_get_data(GTK_OBJECT(clist), "selectlist"); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2895 rows = (int)gtk_object_get_data(GTK_OBJECT(clist), "rowcount"); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2896 g_list_free(list); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2897 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2898 for(z=0;z<rowcount;z++) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2899 gtk_clist_remove(GTK_CLIST(clist), 0); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2900 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2901 if(rows - rowcount < 0) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2902 rows = 0; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2903 else |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2904 rows -= rowcount; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2905 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2906 gtk_object_set_data(GTK_OBJECT(clist), "selectlist", NULL); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2907 gtk_object_set_data(GTK_OBJECT(clist), "rowcount", (gpointer)rows); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2908 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2909 DW_MUTEX_UNLOCK; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2910 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2911 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2912 /* |
3 | 2913 * Removes all rows from a container. |
2914 * Parameters: | |
2915 * handle: Handle to the window (widget) to be cleared. | |
2916 */ | |
2917 void dw_container_clear(HWND handle) | |
2918 { | |
2919 GtkWidget *clist; | |
2920 GList *list; | |
2921 int _locked_by_me = FALSE; | |
2922 | |
2923 DW_MUTEX_LOCK; | |
2924 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
2925 if(clist && GTK_IS_CLIST(clist)) | |
2926 { | |
2927 list = (GList *)gtk_object_get_data(GTK_OBJECT(clist), "selectlist"); | |
2928 g_list_free(list); | |
2929 gtk_object_set_data(GTK_OBJECT(clist), "selectlist", NULL); | |
2930 gtk_clist_clear(GTK_CLIST(clist)); | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2931 gtk_object_set_data(GTK_OBJECT(clist), "rowcount", (gpointer)0); |
3 | 2932 } |
2933 DW_MUTEX_UNLOCK; | |
2934 } | |
2935 | |
2936 /* | |
2937 * Removes all rows from a container. | |
2938 * Parameters: | |
2939 * handle: Handle to the window (widget) to be cleared. | |
2940 */ | |
2941 void dw_container_set_view(HWND handle, unsigned long flags, int iconwidth, int iconheight) | |
2942 { | |
2943 } | |
2944 | |
2945 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2946 * Scrolls container up or down. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2947 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2948 * handle: Handle to the window (widget) to be scrolled. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2949 * direction: DW_SCROLL_UP, DW_SCROLL_DOWN, DW_SCROLL_TOP or |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2950 * DW_SCROLL_BOTTOM. (rows is ignored for last two) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2951 * rows: The number of rows to be scrolled. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2952 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2953 void dw_container_scroll(HWND handle, int direction, long rows) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2954 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2955 GtkAdjustment *adj; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2956 GtkWidget *clist; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2957 int _locked_by_me = FALSE; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2958 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2959 DW_MUTEX_LOCK; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2960 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle)); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2961 if(clist && GTK_IS_CLIST(clist)) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2962 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2963 adj = gtk_clist_get_vadjustment(GTK_CLIST(clist)); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2964 if(adj) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2965 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2966 switch(direction) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2967 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2968 case DW_SCROLL_TOP: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2969 adj->value = adj->lower; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2970 break; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2971 case DW_SCROLL_BOTTOM: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2972 adj->value = adj->upper; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2973 break; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2974 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2975 gtk_clist_set_vadjustment(GTK_CLIST(clist), adj); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2976 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2977 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2978 DW_MUTEX_UNLOCK; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2979 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2980 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2981 /* |
3 | 2982 * Starts a new query of a container. |
2983 * Parameters: | |
2984 * handle: Handle to the window (widget) to be queried. | |
2985 * flags: If this parameter is DW_CRA_SELECTED it will only | |
2986 * return items that are currently selected. Otherwise | |
2987 * it will return all records in the container. | |
2988 */ | |
2989 char *dw_container_query_start(HWND handle, unsigned long flags) | |
2990 { | |
2991 GtkWidget *clist; | |
2992 GList *list; | |
2993 char *retval = NULL; | |
2994 int _locked_by_me = FALSE; | |
2995 | |
2996 DW_MUTEX_LOCK; | |
2997 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
2998 | |
2999 if(!clist) | |
3000 { | |
3001 DW_MUTEX_UNLOCK; | |
3002 return NULL; | |
3003 } | |
3004 | |
3005 /* If there is an old query list, free it */ | |
3006 list = (GList *)gtk_object_get_data(GTK_OBJECT(clist), "querylist"); | |
3007 if(list) | |
3008 g_list_free(list); | |
3009 | |
3010 /* Move the current selection list to the query list, and remove the | |
3011 * current selection list. | |
3012 */ | |
3013 list = (GList *)gtk_object_get_data(GTK_OBJECT(clist), "selectlist"); | |
3014 gtk_object_set_data(GTK_OBJECT(clist), "selectlist", NULL); | |
3015 gtk_object_set_data(GTK_OBJECT(clist), "querylist", (gpointer)list); | |
3016 gtk_clist_unselect_all(GTK_CLIST(clist)); | |
3017 | |
3018 if(list) | |
3019 { | |
3020 gtk_object_set_data(GTK_OBJECT(clist), "querypos", (gpointer)1); | |
3021 if(list->data) | |
3022 retval = list->data; | |
3023 else | |
3024 retval = ""; | |
3025 } | |
3026 DW_MUTEX_UNLOCK; | |
3027 return retval; | |
3028 } | |
3029 | |
3030 /* | |
3031 * Continues an existing query of a container. | |
3032 * Parameters: | |
3033 * handle: Handle to the window (widget) to be queried. | |
3034 * flags: If this parameter is DW_CRA_SELECTED it will only | |
3035 * return items that are currently selected. Otherwise | |
3036 * it will return all records in the container. | |
3037 */ | |
3038 char *dw_container_query_next(HWND handle, unsigned long flags) | |
3039 { | |
3040 GtkWidget *clist; | |
3041 GList *list; | |
3042 char *retval = NULL; | |
3043 int _locked_by_me = FALSE; | |
3044 | |
3045 DW_MUTEX_LOCK; | |
3046 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
3047 | |
3048 if(!clist) | |
3049 { | |
3050 DW_MUTEX_UNLOCK; | |
3051 return NULL; | |
3052 } | |
3053 | |
3054 list = (GList *)gtk_object_get_data(GTK_OBJECT(clist), "querylist"); | |
3055 | |
3056 if(list) | |
3057 { | |
3058 int counter = 0, pos = (int)gtk_object_get_data(GTK_OBJECT(clist), "querypos"); | |
3059 gtk_object_set_data(GTK_OBJECT(clist), "querypos", (gpointer)pos+1); | |
3060 | |
3061 while(list && counter < pos) | |
3062 { | |
3063 list = list->next; | |
3064 counter++; | |
3065 } | |
3066 | |
3067 if(list && list->data) | |
3068 retval = list->data; | |
3069 else if(list && !list->data) | |
3070 retval = ""; | |
3071 } | |
3072 DW_MUTEX_UNLOCK; | |
3073 return retval; | |
3074 } | |
3075 | |
3076 /* | |
3077 * Creates a rendering context widget (window) to be packed. | |
3078 * Parameters: | |
3079 * id: An id to be used with dw_window_from_id. | |
3080 * Returns: | |
3081 * A handle to the widget or NULL on failure. | |
3082 */ | |
3083 HWND dw_render_new(unsigned long id) | |
3084 { | |
3085 int _locked_by_me = FALSE; | |
3086 GtkWidget *tmp; | |
3087 | |
3088 DW_MUTEX_LOCK; | |
3089 tmp = gtk_drawing_area_new(); | |
3090 gtk_widget_set_events(tmp, GDK_EXPOSURE_MASK | |
3091 | GDK_LEAVE_NOTIFY_MASK | |
3092 | GDK_BUTTON_PRESS_MASK | |
3093 | GDK_POINTER_MOTION_MASK | |
3094 | GDK_POINTER_MOTION_HINT_MASK); | |
3095 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
3096 gtk_widget_show(tmp); | |
3097 DW_MUTEX_UNLOCK; | |
3098 return tmp; | |
3099 } | |
3100 | |
3101 /* Sets the current foreground drawing color. | |
3102 * Parameters: | |
3103 * red: red value. | |
3104 * green: green value. | |
3105 * blue: blue value. | |
3106 */ | |
3107 void dw_color_foreground_set(unsigned long value) | |
3108 { | |
3109 int _locked_by_me = FALSE; | |
3110 GdkColor color = { 0, DW_RED_VALUE(value) << 8, DW_GREEN_VALUE(value) << 8, DW_BLUE_VALUE(value) << 8 }; | |
3111 | |
3112 DW_MUTEX_LOCK; | |
3113 gdk_color_alloc(_dw_cmap, &color); | |
3114 _foreground = color; | |
3115 DW_MUTEX_UNLOCK; | |
3116 } | |
3117 | |
3118 /* Sets the current background drawing color. | |
3119 * Parameters: | |
3120 * red: red value. | |
3121 * green: green value. | |
3122 * blue: blue value. | |
3123 */ | |
3124 void dw_color_background_set(unsigned long value) | |
3125 { | |
3126 int _locked_by_me = FALSE; | |
3127 GdkColor color = { 0, DW_RED_VALUE(value) << 8, DW_GREEN_VALUE(value) << 8, DW_BLUE_VALUE(value) << 8 }; | |
3128 | |
3129 DW_MUTEX_LOCK; | |
3130 gdk_color_alloc(_dw_cmap, &color); | |
3131 _background = color; | |
3132 DW_MUTEX_UNLOCK; | |
3133 } | |
3134 | |
3135 GdkGC *_set_colors(GdkWindow *window) | |
3136 { | |
3137 GdkGC *gc; | |
3138 if(!window) | |
3139 return NULL; | |
3140 gc = gdk_gc_new(window); | |
3141 if(gc) | |
3142 { | |
3143 gdk_gc_set_foreground(gc, &_foreground); | |
3144 gdk_gc_set_background(gc, &_background); | |
3145 } | |
3146 return gc; | |
3147 } | |
3148 | |
3149 /* Draw a point on a window (preferably a render window). | |
3150 * Parameters: | |
3151 * handle: Handle to the window. | |
3152 * pixmap: Handle to the pixmap. (choose only one of these) | |
3153 * x: X coordinate. | |
3154 * y: Y coordinate. | |
3155 */ | |
3156 void dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y) | |
3157 { | |
3158 int _locked_by_me = FALSE; | |
3159 GdkGC *gc = NULL; | |
3160 | |
3161 DW_MUTEX_LOCK; | |
3162 if(handle) | |
3163 gc = _set_colors(handle->window); | |
3164 else if(pixmap) | |
3165 gc = _set_colors(pixmap->pixmap); | |
3166 if(gc) | |
3167 { | |
3168 gdk_draw_point(handle ? handle->window : pixmap->pixmap, gc, x, y); | |
3169 gdk_gc_unref(gc); | |
3170 } | |
3171 DW_MUTEX_UNLOCK; | |
3172 } | |
3173 | |
3174 /* Draw a line on a window (preferably a render window). | |
3175 * Parameters: | |
3176 * handle: Handle to the window. | |
3177 * pixmap: Handle to the pixmap. (choose only one of these) | |
3178 * x1: First X coordinate. | |
3179 * y1: First Y coordinate. | |
3180 * x2: Second X coordinate. | |
3181 * y2: Second Y coordinate. | |
3182 */ | |
3183 void dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2) | |
3184 { | |
3185 int _locked_by_me = FALSE; | |
3186 GdkGC *gc = NULL; | |
3187 | |
3188 DW_MUTEX_LOCK; | |
3189 if(handle) | |
3190 gc = _set_colors(handle->window); | |
3191 else if(pixmap) | |
3192 gc = _set_colors(pixmap->pixmap); | |
3193 if(gc) | |
3194 { | |
3195 gdk_draw_line(handle ? handle->window : pixmap->pixmap, gc, x1, y1, x2, y2); | |
3196 gdk_gc_unref(gc); | |
3197 } | |
3198 DW_MUTEX_UNLOCK; | |
3199 } | |
3200 | |
3201 /* Draw a rectangle on a window (preferably a render window). | |
3202 * Parameters: | |
3203 * handle: Handle to the window. | |
3204 * pixmap: Handle to the pixmap. (choose only one of these) | |
3205 * x: X coordinate. | |
3206 * y: Y coordinate. | |
3207 * width: Width of rectangle. | |
3208 * height: Height of rectangle. | |
3209 */ | |
3210 void dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height) | |
3211 { | |
3212 int _locked_by_me = FALSE; | |
3213 GdkGC *gc = NULL; | |
3214 | |
3215 DW_MUTEX_LOCK; | |
3216 if(handle) | |
3217 gc = _set_colors(handle->window); | |
3218 else if(pixmap) | |
3219 gc = _set_colors(pixmap->pixmap); | |
3220 if(gc) | |
3221 { | |
3222 gdk_draw_rectangle(handle ? handle->window : pixmap->pixmap, gc, fill, x, y, width, height); | |
3223 gdk_gc_unref(gc); | |
3224 } | |
3225 DW_MUTEX_UNLOCK; | |
3226 } | |
3227 | |
3228 /* Draw text on a window (preferably a render window). | |
3229 * Parameters: | |
3230 * handle: Handle to the window. | |
3231 * pixmap: Handle to the pixmap. (choose only one of these) | |
3232 * x: X coordinate. | |
3233 * y: Y coordinate. | |
3234 * text: Text to be displayed. | |
3235 */ | |
3236 void dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text) | |
3237 { | |
3238 int _locked_by_me = FALSE; | |
3239 GdkGC *gc = NULL; | |
3240 GdkFont *font; | |
3241 char *fontname = "fixed"; | |
3242 | |
3243 DW_MUTEX_LOCK; | |
3244 if(handle) | |
3245 { | |
3246 fontname = (char *)gtk_object_get_data(GTK_OBJECT(handle), "fontname"); | |
3247 gc = _set_colors(handle->window); | |
3248 } | |
3249 else if(pixmap) | |
3250 { | |
3251 fontname = (char *)gtk_object_get_data(GTK_OBJECT(pixmap->handle), "fontname"); | |
3252 gc = _set_colors(pixmap->pixmap); | |
3253 } | |
3254 if(gc) | |
3255 { | |
3256 font = gdk_font_load(fontname); | |
3257 if(font) | |
3258 { | |
3259 gint ascent; | |
3260 | |
3261 gdk_text_extents(font, text, strlen(text), NULL, NULL, NULL, &ascent, NULL); | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3262 gdk_draw_text(handle ? handle->window : pixmap->pixmap, font, gc, x, y + ascent + 2, text, strlen(text)); |
3 | 3263 gdk_gc_unref(gc); |
3264 gdk_font_unref(font); | |
3265 } | |
3266 } | |
3267 DW_MUTEX_UNLOCK; | |
3268 } | |
3269 | |
3270 /* | |
3271 * Creates a pixmap with given parameters. | |
3272 * Parameters: | |
3273 * handle: Window handle the pixmap is associated with. | |
3274 * width: Width of the pixmap in pixels. | |
3275 * height: Height of the pixmap in pixels. | |
3276 * depth: Color depth of the pixmap. | |
3277 * Returns: | |
3278 * A handle to a pixmap or NULL on failure. | |
3279 */ | |
3280 HPIXMAP dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth) | |
3281 { | |
3282 int _locked_by_me = FALSE; | |
3283 HPIXMAP pixmap; | |
3284 | |
3285 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) | |
3286 return NULL; | |
3287 | |
3288 if (!depth) | |
3289 depth = 24; | |
3290 | |
3291 pixmap->width = width; pixmap->height = height; | |
3292 | |
3293 | |
3294 DW_MUTEX_LOCK; | |
3295 pixmap->handle = handle; | |
3296 pixmap->pixmap = gdk_pixmap_new(handle->window, width, height, depth); | |
3297 DW_MUTEX_UNLOCK; | |
3298 return pixmap; | |
3299 } | |
3300 | |
3301 /* | |
3302 * Creates a pixmap from internal resource graphic specified by id. | |
3303 * Parameters: | |
3304 * handle: Window handle the pixmap is associated with. | |
3305 * id: Resource ID associated with requested pixmap. | |
3306 * Returns: | |
3307 * A handle to a pixmap or NULL on failure. | |
3308 */ | |
3309 HPIXMAP dw_pixmap_grab(HWND handle, ULONG id) | |
3310 { | |
3311 GdkBitmap *bitmap; | |
3312 HPIXMAP pixmap; | |
3313 int _locked_by_me = FALSE; | |
3314 | |
3315 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) | |
3316 return NULL; | |
3317 | |
3318 | |
3319 DW_MUTEX_LOCK; | |
3320 pixmap->pixmap = _find_pixmap(&bitmap, id, handle); | |
3321 if(pixmap->pixmap) | |
3322 { | |
3323 GdkPixmapPrivate *pvt = (GdkPixmapPrivate *)pixmap->pixmap; | |
3324 pixmap->width = pvt->width; pixmap->height = pvt->height; | |
3325 } | |
3326 DW_MUTEX_UNLOCK; | |
3327 return pixmap; | |
3328 } | |
3329 | |
3330 /* Call this after drawing to the screen to make sure | |
3331 * anything you have drawn is visible. | |
3332 */ | |
3333 void dw_flush(void) | |
3334 { | |
3335 int _locked_by_me = FALSE; | |
3336 | |
3337 DW_MUTEX_LOCK; | |
3338 gdk_flush(); | |
3339 DW_MUTEX_UNLOCK; | |
3340 } | |
3341 | |
3342 /* | |
3343 * Destroys an allocated pixmap. | |
3344 * Parameters: | |
3345 * pixmap: Handle to a pixmap returned by | |
3346 * dw_pixmap_new.. | |
3347 */ | |
3348 void dw_pixmap_destroy(HPIXMAP pixmap) | |
3349 { | |
3350 int _locked_by_me = FALSE; | |
3351 | |
3352 DW_MUTEX_LOCK; | |
3353 gdk_pixmap_unref(pixmap->pixmap); | |
3354 free(pixmap); | |
3355 DW_MUTEX_UNLOCK; | |
3356 } | |
3357 | |
3358 /* | |
3359 * Copies from one item to another. | |
3360 * Parameters: | |
3361 * dest: Destination window handle. | |
3362 * destp: Destination pixmap. (choose only one). | |
3363 * xdest: X coordinate of destination. | |
3364 * ydest: Y coordinate of destination. | |
3365 * width: Width of area to copy. | |
3366 * height: Height of area to copy. | |
3367 * src: Source window handle. | |
3368 * srcp: Source pixmap. (choose only one). | |
3369 * xsrc: X coordinate of source. | |
3370 * ysrc: Y coordinate of source. | |
3371 */ | |
3372 void dw_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc) | |
3373 { | |
3374 int _locked_by_me = FALSE; | |
3375 GdkGC *gc = NULL; | |
3376 | |
3377 if((!dest && !destp) || (!src && !srcp)) | |
3378 return; | |
3379 | |
3380 DW_MUTEX_LOCK; | |
3381 if(dest) | |
3382 gc = _set_colors(dest->window); | |
3383 else if(src) | |
3384 gc = _set_colors(src->window); | |
3385 else if(destp) | |
3386 gc = gdk_gc_new(destp->pixmap); | |
3387 else if(srcp) | |
3388 gc = gdk_gc_new(srcp->pixmap); | |
3389 | |
3390 if(gc) | |
3391 { | |
3392 gdk_draw_pixmap(dest ? dest->window : destp->pixmap, gc, src ? src->window : srcp->pixmap, xsrc, ysrc, xdest, ydest, width, height); | |
3393 gdk_gc_unref(gc); | |
3394 } | |
3395 DW_MUTEX_UNLOCK; | |
3396 } | |
3397 | |
3398 /* | |
3399 * Emits a beep. | |
3400 * Parameters: | |
3401 * freq: Frequency. | |
3402 * dur: Duration. | |
3403 */ | |
3404 void dw_beep(int freq, int dur) | |
3405 { | |
3406 int _locked_by_me = FALSE; | |
3407 | |
3408 DW_MUTEX_LOCK; | |
3409 gdk_beep(); | |
3410 DW_MUTEX_UNLOCK; | |
3411 } | |
3412 | |
3413 /* | |
3414 * Returns the handle to an unnamed mutex semaphore. | |
3415 */ | |
3416 HMTX dw_mutex_new(void) | |
3417 { | |
3418 HMTX mutex; | |
3419 | |
3420 pthread_mutex_init(&mutex, NULL); | |
3421 return mutex; | |
3422 } | |
3423 | |
3424 /* | |
3425 * Closes a semaphore created by dw_mutex_new(). | |
3426 * Parameters: | |
3427 * mutex: The handle to the mutex returned by dw_mutex_new(). | |
3428 */ | |
3429 void dw_mutex_close(HMTX mutex) | |
3430 { | |
3431 pthread_mutex_destroy(&mutex); | |
3432 } | |
3433 | |
3434 /* | |
3435 * Tries to gain access to the semaphore, if it can't it blocks. | |
3436 * Parameters: | |
3437 * mutex: The handle to the mutex returned by dw_mutex_new(). | |
3438 */ | |
3439 void dw_mutex_lock(HMTX mutex) | |
3440 { | |
3441 pthread_mutex_lock(&mutex); | |
3442 } | |
3443 | |
3444 /* | |
3445 * Reliquishes the access to the semaphore. | |
3446 * Parameters: | |
3447 * mutex: The handle to the mutex returned by dw_mutex_new(). | |
3448 */ | |
3449 void dw_mutex_unlock(HMTX mutex) | |
3450 { | |
3451 pthread_mutex_unlock(&mutex); | |
3452 } | |
3453 | |
3454 /* | |
3455 * Returns the handle to an unnamed event semaphore. | |
3456 */ | |
3457 HEV dw_event_new(void) | |
3458 { | |
3459 HEV eve = (HEV)malloc(sizeof(struct _dw_unix_event)); | |
3460 | |
3461 if(!eve) | |
3462 return NULL; | |
3463 | |
3464 /* We need to be careful here, mutexes on Linux are | |
3465 * FAST by default but are error checking on other | |
3466 * systems such as FreeBSD and OS/2, perhaps others. | |
3467 */ | |
3468 pthread_mutex_init (&(eve->mutex), NULL); | |
3469 pthread_mutex_lock (&(eve->mutex)); | |
3470 pthread_cond_init (&(eve->event), NULL); | |
3471 | |
3472 pthread_mutex_unlock (&(eve->mutex)); | |
3473 eve->alive = 1; | |
3474 eve->posted = 0; | |
3475 | |
3476 return eve; | |
3477 } | |
3478 | |
3479 /* | |
3480 * Resets a semaphore created by dw_event_new(). | |
3481 * Parameters: | |
3482 * eve: The handle to the event returned by dw_event_new(). | |
3483 */ | |
3484 int dw_event_reset (HEV eve) | |
3485 { | |
3486 if(!eve) | |
3487 return FALSE; | |
3488 | |
3489 pthread_mutex_lock (&(eve->mutex)); | |
3490 pthread_cond_broadcast (&(eve->event)); | |
3491 pthread_cond_init (&(eve->event), NULL); | |
3492 eve->posted = 0; | |
3493 pthread_mutex_unlock (&(eve->mutex)); | |
3494 return 0; | |
3495 } | |
3496 | |
3497 /* | |
3498 * Posts a semaphore created by dw_event_new(). Causing all threads | |
3499 * waiting on this event in dw_event_wait to continue. | |
3500 * Parameters: | |
3501 * eve: The handle to the event returned by dw_event_new(). | |
3502 */ | |
3503 int dw_event_post (HEV eve) | |
3504 { | |
3505 if(!eve) | |
3506 return FALSE; | |
3507 | |
3508 pthread_mutex_lock (&(eve->mutex)); | |
3509 pthread_cond_broadcast (&(eve->event)); | |
3510 eve->posted = 1; | |
3511 pthread_mutex_unlock (&(eve->mutex)); | |
3512 return 0; | |
3513 } | |
3514 | |
3515 /* | |
3516 * Waits on a semaphore created by dw_event_new(), until the | |
3517 * event gets posted or until the timeout expires. | |
3518 * Parameters: | |
3519 * eve: The handle to the event returned by dw_event_new(). | |
3520 */ | |
3521 int dw_event_wait(HEV eve, unsigned long timeout) | |
3522 { | |
3523 int rc; | |
3524 struct timeval now; | |
3525 struct timespec timeo; | |
3526 | |
3527 if(!eve) | |
3528 return FALSE; | |
3529 | |
3530 if(eve->posted) | |
3531 return 0; | |
3532 | |
3533 pthread_mutex_lock (&(eve->mutex)); | |
3534 gettimeofday(&now, 0); | |
3535 timeo.tv_sec = now.tv_sec + (timeout / 1000); | |
3536 timeo.tv_nsec = now.tv_usec * 1000; | |
3537 rc = pthread_cond_timedwait (&(eve->event), &(eve->mutex), &timeo); | |
3538 pthread_mutex_unlock (&(eve->mutex)); | |
3539 if(!rc) | |
3540 return 1; | |
3541 if(rc == ETIMEDOUT) | |
3542 return -1; | |
3543 return 0; | |
3544 } | |
3545 | |
3546 /* | |
3547 * Closes a semaphore created by dw_event_new(). | |
3548 * Parameters: | |
3549 * eve: The handle to the event returned by dw_event_new(). | |
3550 */ | |
3551 int dw_event_close(HEV *eve) | |
3552 { | |
3553 if(!eve || !(*eve)) | |
3554 return FALSE; | |
3555 | |
3556 pthread_mutex_lock (&((*eve)->mutex)); | |
3557 pthread_cond_destroy (&((*eve)->event)); | |
3558 pthread_mutex_unlock (&((*eve)->mutex)); | |
3559 pthread_mutex_destroy (&((*eve)->mutex)); | |
3560 free(*eve); | |
3561 *eve = NULL; | |
3562 | |
3563 return TRUE; | |
3564 } | |
3565 | |
3566 /* | |
3567 * Creates a new thread with a starting point of func. | |
3568 * Parameters: | |
3569 * func: Function which will be run in the new thread. | |
3570 * data: Parameter(s) passed to the function. | |
3571 * stack: Stack size of new thread (OS/2 and Windows only). | |
3572 */ | |
3573 DWTID dw_thread_new(void *func, void *data, int stack) | |
3574 { | |
3575 DWTID gtkthread; | |
3576 | |
3577 pthread_create(>kthread, NULL, func, data); | |
3578 return gtkthread; | |
3579 } | |
3580 | |
3581 /* | |
3582 * Ends execution of current thread immediately. | |
3583 */ | |
3584 void dw_thread_end(void) | |
3585 { | |
3586 pthread_exit(NULL); | |
3587 } | |
3588 | |
3589 /* | |
3590 * Cleanly terminates a DW session, should be signal handler safe. | |
3591 * Parameters: | |
3592 * exitcode: Exit code reported to the operating system. | |
3593 */ | |
3594 void dw_exit(int exitcode) | |
3595 { | |
3596 exit(exitcode); | |
3597 } | |
3598 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3599 #define DW_EXPAND (GTK_EXPAND | GTK_SHRINK | GTK_FILL) |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3600 |
3 | 3601 /* |
3602 * Pack windows (widgets) into a box from the end (or bottom). | |
3603 * Parameters: | |
3604 * box: Window handle of the box to be packed into. | |
3605 * item: Window handle of the item to be back. | |
3606 * width: Width in pixels of the item or -1 to be self determined. | |
3607 * height: Height in pixels of the item or -1 to be self determined. | |
3608 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. | |
3609 * vsize: TRUE if the window (widget) should expand vertically to fill space given. | |
3610 * pad: Number of pixels of padding around the item. | |
3611 */ | |
3612 void dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) | |
3613 { | |
3614 int _locked_by_me = FALSE; | |
3615 | |
3616 if(!box) | |
3617 return; | |
3618 | |
3619 DW_MUTEX_LOCK; | |
3620 | |
3621 if(!item) | |
3622 { | |
3623 item = gtk_label_new(""); | |
3624 gtk_widget_show(item); | |
3625 } | |
3626 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3627 if(GTK_IS_TABLE(box)) |
3 | 3628 { |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3629 int boxcount = (int)gtk_object_get_data(GTK_OBJECT(box), "boxcount"); |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3630 int boxtype = (int)gtk_object_get_data(GTK_OBJECT(box), "boxtype"); |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3631 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3632 /* If the item being packed is a box, then we use it's padding |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3633 * instead of the padding specified on the pack line, this is |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3634 * due to a bug in the OS/2 and Win32 renderer and a limitation |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3635 * of the GtkTable class. |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3636 */ |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3637 if(GTK_IS_TABLE(item)) |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3638 pad = (int)gtk_object_get_data(GTK_OBJECT(item), "boxpad"); |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3639 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3640 if(boxtype == BOXVERT) |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3641 gtk_table_resize(GTK_TABLE(box), boxcount + 1, 1); |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3642 else |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3643 gtk_table_resize(GTK_TABLE(box), 1, boxcount + 1); |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3644 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3645 gtk_table_attach(GTK_TABLE(box), item, 0, 1, 0, 1, hsize ? DW_EXPAND : 0, vsize ? DW_EXPAND : 0, pad, pad); |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3646 gtk_object_set_data(GTK_OBJECT(box), "boxcount", (gpointer)boxcount + 1); |
3 | 3647 gtk_widget_set_usize(item, width, height); |
3648 if(GTK_IS_RADIO_BUTTON(item)) | |
3649 { | |
3650 GSList *group; | |
3651 GtkWidget *groupstart = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(box), "group"); | |
3652 | |
3653 if(groupstart) | |
3654 { | |
3655 group = gtk_radio_button_group(GTK_RADIO_BUTTON(groupstart)); | |
3656 gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group); | |
3657 } | |
3658 else | |
3659 gtk_object_set_data(GTK_OBJECT(box), "group", (gpointer)item); | |
3660 } | |
3661 } | |
3662 else | |
3663 { | |
3664 GtkWidget *vbox = gtk_vbox_new(FALSE, 0); | |
3665 | |
3666 gtk_container_add(GTK_CONTAINER(box), vbox); | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3667 gtk_box_pack_end(GTK_BOX(vbox), item, TRUE, TRUE, 0); |
3 | 3668 gtk_widget_show(vbox); |
3669 | |
3670 gtk_widget_set_usize(item, width, height); | |
3671 gtk_object_set_user_data(GTK_OBJECT(box), vbox); | |
3672 } | |
3673 DW_MUTEX_UNLOCK; | |
3674 } | |
3675 | |
3676 /* | |
3677 * Sets the size of a given window (widget). | |
3678 * Parameters: | |
3679 * handle: Window (widget) handle. | |
3680 * width: New width in pixels. | |
3681 * height: New height in pixels. | |
3682 */ | |
3683 void dw_window_set_usize(HWND handle, unsigned long width, unsigned long height) | |
3684 { | |
3685 int _locked_by_me = FALSE; | |
3686 | |
3687 DW_MUTEX_LOCK; | |
3688 if(GTK_IS_WINDOW(handle)) | |
3689 _size_allocate(GTK_WINDOW(handle)); | |
3690 #if 0 | |
3691 gtk_window_set_default_size(GTK_WINDOW(handle), width, height); | |
3692 else | |
3693 #endif | |
3694 gtk_widget_set_usize(handle, width, height); | |
3695 DW_MUTEX_UNLOCK; | |
3696 } | |
3697 | |
3698 /* | |
3699 * Returns the width of the screen. | |
3700 */ | |
3701 int dw_screen_width(void) | |
3702 { | |
3703 int retval; | |
3704 int _locked_by_me = FALSE; | |
3705 | |
3706 DW_MUTEX_LOCK; | |
3707 retval = gdk_screen_width(); | |
3708 DW_MUTEX_UNLOCK; | |
3709 return retval; | |
3710 } | |
3711 | |
3712 /* | |
3713 * Returns the height of the screen. | |
3714 */ | |
3715 int dw_screen_height(void) | |
3716 { | |
3717 int retval; | |
3718 int _locked_by_me = FALSE; | |
3719 | |
3720 DW_MUTEX_UNLOCK; | |
3721 retval = gdk_screen_height(); | |
3722 DW_MUTEX_UNLOCK; | |
3723 return retval; | |
3724 } | |
3725 | |
3726 /* This should return the current color depth */ | |
3727 unsigned long dw_color_depth(void) | |
3728 { | |
3729 int retval; | |
3730 int _locked_by_me = FALSE; | |
3731 | |
3732 DW_MUTEX_UNLOCK; | |
3733 retval = gdk_colormap_get_system_size(); | |
3734 DW_MUTEX_UNLOCK; | |
3735 return retval; | |
3736 } | |
3737 | |
3738 /* | |
3739 * Sets the position of a given window (widget). | |
3740 * Parameters: | |
3741 * handle: Window (widget) handle. | |
3742 * x: X location from the bottom left. | |
3743 * y: Y location from the bottom left. | |
3744 */ | |
3745 void dw_window_set_pos(HWND handle, unsigned long x, unsigned long y) | |
3746 { | |
3747 int _locked_by_me = FALSE; | |
3748 | |
3749 DW_MUTEX_LOCK; | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
3750 if(handle && handle->window) |
3 | 3751 gdk_window_move(handle->window, x, y); |
3752 DW_MUTEX_UNLOCK; | |
3753 } | |
3754 | |
3755 /* | |
3756 * Sets the position and size of a given window (widget). | |
3757 * Parameters: | |
3758 * handle: Window (widget) handle. | |
3759 * x: X location from the bottom left. | |
3760 * y: Y location from the bottom left. | |
3761 * width: Width of the widget. | |
3762 * height: Height of the widget. | |
3763 */ | |
3764 void dw_window_set_pos_size(HWND handle, unsigned long x, unsigned long y, unsigned long width, unsigned long height) | |
3765 { | |
3766 int _locked_by_me = FALSE; | |
3767 | |
3768 DW_MUTEX_LOCK; | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
3769 if(handle && GTK_IS_WINDOW(handle)) |
3 | 3770 { |
3771 _size_allocate(GTK_WINDOW(handle)); | |
15
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
3772 |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
3773 gtk_widget_set_uposition(handle, x, y); |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3774 gtk_window_set_default_size(GTK_WINDOW(handle), width, height); |
3 | 3775 } |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
3776 else if(handle && handle->window) |
3 | 3777 { |
3778 gdk_window_resize(handle->window, width, height); | |
3779 gdk_window_move(handle->window, x, y); | |
3780 } | |
3781 DW_MUTEX_UNLOCK; | |
3782 } | |
3783 | |
3784 /* | |
3785 * Gets the position and size of a given window (widget). | |
3786 * Parameters: | |
3787 * handle: Window (widget) handle. | |
3788 * x: X location from the bottom left. | |
3789 * y: Y location from the bottom left. | |
3790 * width: Width of the widget. | |
3791 * height: Height of the widget. | |
3792 */ | |
3793 void dw_window_get_pos_size(HWND handle, ULONG *x, ULONG *y, ULONG *width, ULONG *height) | |
3794 { | |
3795 int _locked_by_me = FALSE; | |
3796 gint gx, gy, gwidth, gheight, gdepth; | |
3797 | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
3798 if(handle && handle->window) |
3 | 3799 { |
3800 DW_MUTEX_LOCK; | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
3801 |
3 | 3802 gdk_window_get_geometry(handle->window, &gx, &gy, &gwidth, &gheight, &gdepth); |
3803 gdk_window_get_root_origin(handle->window, &gx, &gy); | |
3804 if(x) | |
3805 *x = gx; | |
3806 if(y) | |
3807 *y = gy; | |
3808 if(width) | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3809 *width = gwidth; |
3 | 3810 if(height) |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3811 *height = gheight; |
3 | 3812 DW_MUTEX_UNLOCK; |
3813 } | |
3814 } | |
3815 | |
3816 /* | |
3817 * Sets the style of a given window (widget). | |
3818 * Parameters: | |
3819 * handle: Window (widget) handle. | |
3820 * width: New width in pixels. | |
3821 * height: New height in pixels. | |
3822 */ | |
3823 void dw_window_set_style(HWND handle, unsigned long style, unsigned long mask) | |
3824 { | |
3825 GtkWidget *handle2 = handle; | |
3826 int _locked_by_me = FALSE; | |
3827 | |
3828 DW_MUTEX_LOCK; | |
3829 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
3830 { | |
3831 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
3832 if(tmp) | |
3833 handle2 = tmp; | |
3834 } | |
3835 if(GTK_IS_CLIST(handle2)) | |
3836 { | |
3837 if(style & DW_CCS_EXTENDSEL) | |
3838 gtk_clist_set_selection_mode(GTK_CLIST(handle2), GTK_SELECTION_MULTIPLE); | |
3839 if(style & DW_CCS_SINGLESEL) | |
3840 gtk_clist_set_selection_mode(GTK_CLIST(handle2), GTK_SELECTION_SINGLE); | |
3841 } | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3842 if(GTK_IS_LABEL(handle2)) |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3843 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3844 gfloat x, y; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3845 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3846 x = y = DW_LEFT; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3847 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3848 if(style & DW_DT_CENTER) |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3849 x = DW_CENTER; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3850 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3851 if(style & DW_DT_VCENTER) |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3852 y = DW_CENTER; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3853 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3854 gtk_misc_set_alignment(GTK_MISC(handle2), x, y); |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3855 } |
3 | 3856 DW_MUTEX_UNLOCK; |
3857 } | |
3858 | |
3859 /* | |
3860 * Adds a new page to specified notebook. | |
3861 * Parameters: | |
3862 * handle: Window (widget) handle. | |
3863 * flags: Any additional page creation flags. | |
3864 * front: If TRUE page is added at the beginning. | |
3865 */ | |
3866 unsigned long dw_notebook_page_new(HWND handle, unsigned long flags, int front) | |
3867 { | |
3868 int z; | |
3869 int _locked_by_me = FALSE; | |
3870 | |
3871 DW_MUTEX_LOCK; | |
3872 for(z=0;z<256;z++) | |
15
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
3873 { |
3 | 3874 if(!gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), z)) |
3875 { | |
3876 DW_MUTEX_UNLOCK; | |
3877 return z; | |
3878 } | |
15
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
3879 } |
3 | 3880 |
3881 DW_MUTEX_UNLOCK; | |
3882 | |
3883 /* Hopefully this won't happen. */ | |
3884 return 256; | |
3885 } | |
3886 | |
3887 /* | |
3888 * Remove a page from a notebook. | |
3889 * Parameters: | |
3890 * handle: Handle to the notebook widget. | |
3891 * pageid: ID of the page to be destroyed. | |
3892 */ | |
3893 void dw_notebook_page_destroy(HWND handle, unsigned int pageid) | |
3894 { | |
3895 int _locked_by_me = FALSE; | |
3896 | |
3897 DW_MUTEX_LOCK; | |
3898 gtk_notebook_remove_page(GTK_NOTEBOOK(handle), pageid); | |
3899 DW_MUTEX_UNLOCK; | |
3900 } | |
3901 | |
3902 /* | |
3903 * Queries the currently visible page ID. | |
3904 * Parameters: | |
3905 * handle: Handle to the notebook widget. | |
3906 */ | |
3907 unsigned int dw_notebook_page_query(HWND handle) | |
3908 { | |
3909 int retval; | |
3910 int _locked_by_me = FALSE; | |
3911 | |
3912 DW_MUTEX_LOCK; | |
3913 retval = gtk_notebook_get_current_page(GTK_NOTEBOOK(handle)); | |
3914 DW_MUTEX_UNLOCK; | |
3915 return retval; | |
3916 } | |
3917 | |
3918 /* | |
3919 * Sets the currently visibale page ID. | |
3920 * Parameters: | |
3921 * handle: Handle to the notebook widget. | |
3922 * pageid: ID of the page to be made visible. | |
3923 */ | |
3924 void dw_notebook_page_set(HWND handle, unsigned int pageid) | |
3925 { | |
3926 int _locked_by_me = FALSE; | |
3927 | |
3928 DW_MUTEX_LOCK; | |
3929 gtk_notebook_set_page(GTK_NOTEBOOK(handle), pageid); | |
3930 DW_MUTEX_UNLOCK; | |
3931 } | |
3932 | |
3933 | |
3934 /* | |
3935 * Sets the text on the specified notebook tab. | |
3936 * Parameters: | |
3937 * handle: Notebook handle. | |
3938 * pageid: Page ID of the tab to set. | |
3939 * text: Pointer to the text to set. | |
3940 */ | |
3941 void dw_notebook_page_set_text(HWND handle, unsigned long pageid, char *text) | |
3942 { | |
3943 GtkWidget *child; | |
3944 int _locked_by_me = FALSE; | |
3945 | |
3946 DW_MUTEX_LOCK; | |
3947 child = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), pageid); | |
3948 if(child) | |
3949 gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(handle), child, text); | |
3950 DW_MUTEX_UNLOCK; | |
3951 } | |
3952 | |
3953 /* | |
3954 * Sets the text on the specified notebook tab status area. | |
3955 * Parameters: | |
3956 * handle: Notebook handle. | |
3957 * pageid: Page ID of the tab to set. | |
3958 * text: Pointer to the text to set. | |
3959 */ | |
3960 void dw_notebook_page_set_status_text(HWND handle, unsigned long pageid, char *text) | |
3961 { | |
3962 /* TODO (if possible) */ | |
3963 } | |
3964 | |
3965 /* | |
3966 * Packs the specified box into the notebook page. | |
3967 * Parameters: | |
3968 * handle: Handle to the notebook to be packed. | |
3969 * pageid: Page ID in the notebook which is being packed. | |
3970 * page: Box handle to be packed. | |
3971 */ | |
3972 void dw_notebook_pack(HWND handle, unsigned long pageid, HWND page) | |
3973 { | |
15
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
3974 GtkWidget *label, *child, *oldlabel; |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
3975 gchar *text = NULL; |
3 | 3976 int _locked_by_me = FALSE; |
3977 | |
3978 DW_MUTEX_LOCK; | |
15
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
3979 child = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), pageid); |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
3980 if(child) |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
3981 { |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
3982 oldlabel = gtk_notebook_get_tab_label(GTK_NOTEBOOK(handle), child); |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
3983 if(oldlabel) |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
3984 gtk_label_get(GTK_LABEL(oldlabel), &text); |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
3985 } |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
3986 |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
3987 label = gtk_label_new(text ? text : ""); |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
3988 |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
3989 gtk_notebook_insert_page(GTK_NOTEBOOK(handle), page, label, pageid); |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
3990 if(child) |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
3991 gtk_notebook_remove_page(GTK_NOTEBOOK(handle), pageid+1); |
3 | 3992 DW_MUTEX_UNLOCK; |
3993 } | |
3994 | |
3995 /* | |
3996 * Appends the specified text to the listbox's (or combobox) entry list. | |
3997 * Parameters: | |
3998 * handle: Handle to the listbox to be appended to. | |
3999 * text: Text to append into listbox. | |
4000 */ | |
4001 void dw_listbox_append(HWND handle, char *text) | |
4002 { | |
4003 GtkWidget *handle2 = handle; | |
4004 int _locked_by_me = FALSE; | |
4005 | |
4006 DW_MUTEX_LOCK; | |
4007 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
4008 { | |
4009 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
4010 if(tmp) | |
4011 handle2 = tmp; | |
4012 } | |
4013 if(GTK_IS_LIST(handle2)) | |
4014 { | |
4015 GtkWidget *list_item; | |
4016 GList *tmp; | |
4017 char *font = (char *)gtk_object_get_data(GTK_OBJECT(handle), "font"); | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
4018 GdkColor *fore = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle2), "foregdk"); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
4019 GdkColor *back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle2), "backgdk"); |
3 | 4020 |
4021 list_item=gtk_list_item_new_with_label(text); | |
4022 | |
4023 if(font) | |
4024 _set_font(GTK_LIST_ITEM(list_item)->item.bin.child, font); | |
4025 if(fore && back) | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
4026 _set_color(GTK_LIST_ITEM(list_item)->item.bin.child, |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
4027 DW_RGB(fore->red, fore->green, fore->blue), |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
4028 DW_RGB(back->red, back->green, back->blue)); |
3 | 4029 |
4030 tmp = g_list_append(NULL, list_item); | |
4031 gtk_widget_show(list_item); | |
4032 gtk_list_append_items(GTK_LIST(handle2),tmp); | |
4033 } | |
4034 else if(GTK_IS_COMBO(handle2)) | |
4035 { | |
4036 GList *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2)); | |
4037 char *addtext = strdup(text); | |
4038 | |
4039 if(addtext) | |
4040 { | |
4041 tmp = g_list_append(tmp, addtext); | |
4042 gtk_object_set_user_data(GTK_OBJECT(handle2), tmp); | |
4043 gtk_combo_set_popdown_strings(GTK_COMBO(handle2), tmp); | |
4044 } | |
4045 } | |
4046 DW_MUTEX_UNLOCK; | |
4047 } | |
4048 | |
4049 /* | |
4050 * Clears the listbox's (or combobox) list of all entries. | |
4051 * Parameters: | |
4052 * handle: Handle to the listbox to be cleared. | |
4053 */ | |
4054 void dw_listbox_clear(HWND handle) | |
4055 { | |
4056 GtkWidget *handle2 = handle; | |
4057 int _locked_by_me = FALSE; | |
4058 | |
4059 DW_MUTEX_LOCK; | |
4060 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
4061 { | |
4062 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
4063 if(tmp) | |
4064 handle2 = tmp; | |
4065 } | |
4066 if(GTK_IS_COMBO(handle2)) | |
4067 { | |
4068 GList *list, *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2)); | |
4069 | |
4070 if(tmp) | |
4071 { | |
4072 list = tmp; | |
4073 while(list) | |
4074 { | |
4075 if(list->data) | |
4076 free(list->data); | |
4077 list=list->next; | |
4078 } | |
4079 g_list_free(tmp); | |
4080 } | |
4081 gtk_object_set_user_data(GTK_OBJECT(handle2), NULL); | |
4082 } | |
4083 else if(GTK_IS_LIST(handle2)) | |
4084 { | |
4085 int count = dw_listbox_count(handle); | |
4086 | |
4087 gtk_list_clear_items(GTK_LIST(handle2), 0, count - 1); | |
4088 } | |
4089 DW_MUTEX_UNLOCK; | |
4090 } | |
4091 | |
4092 /* | |
4093 * Returns the listbox's item count. | |
4094 * Parameters: | |
4095 * handle: Handle to the listbox to be counted | |
4096 */ | |
4097 int dw_listbox_count(HWND handle) | |
4098 { | |
4099 GtkWidget *handle2 = handle; | |
4100 int retval = 0; | |
4101 int _locked_by_me = FALSE; | |
4102 | |
4103 DW_MUTEX_LOCK; | |
4104 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
4105 { | |
4106 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
4107 if(tmp) | |
4108 handle2 = tmp; | |
4109 } | |
4110 else if(GTK_IS_COMBO(handle)) | |
4111 { | |
4112 handle2 = GTK_COMBO(handle)->list; | |
4113 } | |
4114 if(GTK_IS_LIST(handle2)) | |
4115 { | |
4116 GList *list = GTK_LIST(handle2)->children; | |
4117 while(list) | |
4118 { | |
4119 list = list->next; | |
4120 retval++; | |
4121 } | |
4122 } | |
4123 DW_MUTEX_UNLOCK; | |
4124 return retval; | |
4125 } | |
4126 | |
4127 /* | |
4128 * Sets the topmost item in the viewport. | |
4129 * Parameters: | |
4130 * handle: Handle to the listbox to be cleared. | |
4131 * top: Index to the top item. | |
4132 */ | |
4133 void dw_listbox_set_top(HWND handle, int top) | |
4134 { | |
4135 GtkWidget *handle2 = handle; | |
4136 int _locked_by_me = FALSE; | |
4137 | |
4138 DW_MUTEX_LOCK; | |
4139 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
4140 { | |
4141 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
4142 if(tmp) | |
4143 handle2 = tmp; | |
4144 } | |
4145 if(GTK_IS_LIST(handle2)) | |
4146 { | |
4147 int count = dw_listbox_count(handle); | |
4148 GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(handle)); | |
4149 float pos, ratio; | |
4150 | |
4151 if(count) | |
4152 { | |
4153 ratio = (float)top/(float)count; | |
4154 | |
4155 pos = (ratio * (float)(adj->upper - adj->lower)) + adj->lower; | |
4156 | |
4157 gtk_adjustment_set_value(adj, pos); | |
4158 } | |
4159 } | |
4160 DW_MUTEX_UNLOCK; | |
4161 } | |
4162 | |
4163 /* | |
4164 * Copies the given index item's text into buffer. | |
4165 * Parameters: | |
4166 * handle: Handle to the listbox to be queried. | |
4167 * index: Index into the list to be queried. | |
4168 * buffer: Buffer where text will be copied. | |
4169 * length: Length of the buffer (including NULL). | |
4170 */ | |
4171 void dw_listbox_query_text(HWND handle, unsigned int index, char *buffer, unsigned int length) | |
4172 { | |
4173 GtkWidget *handle2 = handle; | |
4174 int _locked_by_me = FALSE; | |
4175 | |
4176 DW_MUTEX_LOCK; | |
4177 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
4178 { | |
4179 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
4180 if(tmp) | |
4181 handle2 = tmp; | |
4182 } | |
4183 else if(GTK_IS_COMBO(handle)) | |
4184 { | |
4185 handle2 = GTK_COMBO(handle)->list; | |
4186 } | |
4187 if(GTK_IS_LIST(handle2)) | |
4188 { | |
4189 int counter = 0; | |
4190 GList *list = GTK_LIST(handle2)->children; | |
4191 | |
4192 while(list) | |
4193 { | |
4194 if(counter == index) | |
4195 { | |
4196 gchar *text = ""; | |
4197 | |
4198 if(GTK_IS_LIST_ITEM(list->data)) | |
4199 { | |
4200 GtkListItem *li = GTK_LIST_ITEM(list->data); | |
4201 | |
4202 if(GTK_IS_ITEM(&(li->item))) | |
4203 { | |
4204 GtkItem *i = &(li->item); | |
4205 | |
4206 if(GTK_IS_BIN(&(i->bin))) | |
4207 { | |
4208 GtkBin *b = &(i->bin); | |
4209 | |
4210 if(GTK_IS_LABEL(b->child)) | |
4211 gtk_label_get(GTK_LABEL(b->child), &text); | |
4212 } | |
4213 } | |
4214 } | |
4215 else if(GTK_IS_COMBO(handle) && list->data) | |
4216 text = (gchar *)list->data; | |
4217 | |
4218 strncpy(buffer, (char *)text, length); | |
4219 break; | |
4220 } | |
4221 list = list->next; | |
4222 counter++; | |
4223 } | |
4224 } | |
4225 DW_MUTEX_UNLOCK; | |
4226 } | |
4227 | |
4228 /* | |
4229 * Sets the text of a given listbox entry. | |
4230 * Parameters: | |
4231 * handle: Handle to the listbox to be queried. | |
4232 * index: Index into the list to be queried. | |
4233 * buffer: Buffer where text will be copied. | |
4234 */ | |
4235 void dw_listbox_set_text(HWND handle, unsigned int index, char *buffer) | |
4236 { | |
4237 GtkWidget *handle2 = handle; | |
4238 int _locked_by_me = FALSE; | |
4239 | |
4240 DW_MUTEX_LOCK; | |
4241 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
4242 { | |
4243 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
4244 if(tmp) | |
4245 handle2 = tmp; | |
4246 } | |
4247 else if(GTK_IS_COMBO(handle)) | |
4248 { | |
4249 handle2 = GTK_COMBO(handle)->list; | |
4250 } | |
4251 if(GTK_IS_LIST(handle2)) | |
4252 { | |
4253 int counter = 0; | |
4254 GList *list = GTK_LIST(handle2)->children; | |
4255 | |
4256 while(list) | |
4257 { | |
4258 if(counter == index) | |
4259 { | |
4260 | |
4261 if(GTK_IS_LIST_ITEM(list->data)) | |
4262 { | |
4263 GtkListItem *li = GTK_LIST_ITEM(list->data); | |
4264 | |
4265 if(GTK_IS_ITEM(&(li->item))) | |
4266 { | |
4267 GtkItem *i = &(li->item); | |
4268 | |
4269 if(GTK_IS_BIN(&(i->bin))) | |
4270 { | |
4271 GtkBin *b = &(i->bin); | |
4272 | |
4273 if(GTK_IS_LABEL(b->child)) | |
4274 gtk_label_set_text(GTK_LABEL(b->child), buffer); | |
4275 } | |
4276 } | |
4277 } | |
4278 else if(GTK_IS_COMBO(handle)) | |
4279 { | |
4280 if(list->data) | |
4281 g_free(list->data); | |
4282 list->data = g_strdup(buffer); | |
4283 } | |
4284 break; | |
4285 } | |
4286 list = list->next; | |
4287 counter++; | |
4288 } | |
4289 } | |
4290 DW_MUTEX_UNLOCK; | |
4291 } | |
4292 | |
4293 /* | |
4294 * Returns the index to the item in the list currently selected. | |
4295 * Parameters: | |
4296 * handle: Handle to the listbox to be queried. | |
4297 */ | |
4298 unsigned int dw_listbox_selected(HWND handle) | |
4299 { | |
4300 GtkWidget *handle2 = handle; | |
4301 int retval = DW_LIT_NONE; | |
4302 int _locked_by_me = FALSE; | |
4303 | |
4304 DW_MUTEX_LOCK; | |
4305 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
4306 { | |
4307 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
4308 if(tmp) | |
4309 handle2 = tmp; | |
4310 } | |
4311 else if(GTK_IS_COMBO(handle)) | |
4312 { | |
4313 retval = (unsigned int)gtk_object_get_data(GTK_OBJECT(handle), "item"); | |
4314 DW_MUTEX_UNLOCK; | |
4315 return retval; | |
4316 } | |
4317 if(GTK_IS_LIST(handle2)) | |
4318 { | |
4319 int counter = 0; | |
4320 GList *list = GTK_LIST(handle2)->children; | |
4321 while(list) | |
4322 { | |
19
3e5bff3e55ff
Fixed a problem in dw_listbox_selected().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
17
diff
changeset
|
4323 if(list->data == GTK_LIST(handle2)->selection->data) |
3 | 4324 { |
4325 retval = counter; | |
4326 break; | |
4327 } | |
4328 | |
4329 list = list->next; | |
4330 counter++; | |
4331 } | |
4332 } | |
4333 DW_MUTEX_UNLOCK; | |
4334 return retval; | |
4335 } | |
4336 | |
4337 /* | |
4338 * Sets the selection state of a given index. | |
4339 * Parameters: | |
4340 * handle: Handle to the listbox to be set. | |
4341 * index: Item index. | |
4342 * state: TRUE if selected FALSE if unselected. | |
4343 */ | |
4344 void dw_listbox_select(HWND handle, int index, int state) | |
4345 { | |
4346 GtkWidget *handle2 = handle; | |
4347 int _locked_by_me = FALSE; | |
4348 | |
4349 DW_MUTEX_LOCK; | |
4350 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
4351 { | |
4352 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
4353 if(tmp) | |
4354 handle2 = tmp; | |
4355 } | |
4356 else if(GTK_IS_COMBO(handle)) | |
4357 { | |
4358 handle2 = GTK_COMBO(handle)->list; | |
4359 } | |
4360 if(GTK_IS_LIST(handle2)) | |
4361 { | |
4362 if(state) | |
4363 gtk_list_select_item(GTK_LIST(handle2), index); | |
4364 else | |
4365 gtk_list_unselect_item(GTK_LIST(handle2), index); | |
4366 } | |
4367 DW_MUTEX_UNLOCK; | |
4368 } | |
4369 | |
4370 /* | |
4371 * Deletes the item with given index from the list. | |
4372 * Parameters: | |
4373 * handle: Handle to the listbox to be set. | |
4374 * index: Item index. | |
4375 */ | |
4376 void dw_listbox_delete(HWND handle, int index) | |
4377 { | |
4378 GtkWidget *handle2 = handle; | |
4379 int _locked_by_me = FALSE; | |
4380 | |
4381 DW_MUTEX_LOCK; | |
4382 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
4383 { | |
4384 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
4385 if(tmp) | |
4386 handle2 = tmp; | |
4387 } | |
4388 else if(GTK_IS_COMBO(handle)) | |
4389 { | |
4390 handle2 = GTK_COMBO(handle)->list; | |
4391 } | |
4392 if(GTK_IS_LIST(handle2)) | |
4393 gtk_list_clear_items(GTK_LIST(handle2), index, index); | |
4394 DW_MUTEX_UNLOCK; | |
4395 } | |
4396 | |
4397 | |
4398 /* | |
4399 * Pack a splitbar (sizer) into the specified box from the start. | |
4400 * Parameters: | |
4401 * box: Window handle of the box to be packed into. | |
4402 */ | |
4403 void dw_box_pack_splitbar_start(HWND box) | |
4404 { | |
4405 /* TODO */ | |
4406 } | |
4407 | |
4408 /* | |
4409 * Pack a splitbar (sizer) into the specified box from the end. | |
4410 * Parameters: | |
4411 * box: Window handle of the box to be packed into. | |
4412 */ | |
4413 void dw_box_pack_splitbar_end(HWND box) | |
4414 { | |
4415 /* TODO */ | |
4416 } | |
4417 | |
4418 /* | |
4419 * Pack windows (widgets) into a box from the start (or top). | |
4420 * Parameters: | |
4421 * box: Window handle of the box to be packed into. | |
4422 * item: Window handle of the item to be back. | |
4423 * width: Width in pixels of the item or -1 to be self determined. | |
4424 * height: Height in pixels of the item or -1 to be self determined. | |
4425 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. | |
4426 * vsize: TRUE if the window (widget) should expand vertically to fill space given. | |
4427 * pad: Number of pixels of padding around the item. | |
4428 */ | |
4429 void dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) | |
4430 { | |
4431 int _locked_by_me = FALSE; | |
4432 | |
4433 if(!box) | |
4434 return; | |
4435 | |
4436 DW_MUTEX_LOCK; | |
4437 | |
4438 if(!item) | |
4439 { | |
4440 item = gtk_label_new(""); | |
4441 gtk_widget_show(item); | |
4442 } | |
4443 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4444 if(GTK_IS_TABLE(box)) |
3 | 4445 { |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4446 int boxcount = (int)gtk_object_get_data(GTK_OBJECT(box), "boxcount"); |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4447 int boxtype = (int)gtk_object_get_data(GTK_OBJECT(box), "boxtype"); |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4448 int x, y; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4449 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4450 /* If the item being packed is a box, then we use it's padding |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4451 * instead of the padding specified on the pack line, this is |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4452 * due to a bug in the OS/2 and Win32 renderer and a limitation |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4453 * of the GtkTable class. |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4454 */ |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4455 if(GTK_IS_TABLE(item)) |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4456 pad = (int)gtk_object_get_data(GTK_OBJECT(item), "boxpad"); |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4457 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4458 if(boxtype == BOXVERT) |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4459 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4460 x = 0; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4461 y = boxcount; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4462 gtk_table_resize(GTK_TABLE(box), boxcount + 1, 1); |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4463 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4464 else |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4465 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4466 x = boxcount; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4467 y = 0; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4468 gtk_table_resize(GTK_TABLE(box), 1, boxcount + 1); |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4469 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4470 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4471 gtk_table_attach(GTK_TABLE(box), item, x, x + 1, y, y + 1, hsize ? DW_EXPAND : 0, vsize ? DW_EXPAND : 0, pad, pad); |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4472 gtk_object_set_data(GTK_OBJECT(box), "boxcount", (gpointer)boxcount + 1); |
3 | 4473 gtk_widget_set_usize(item, width, height); |
4474 if(GTK_IS_RADIO_BUTTON(item)) | |
4475 { | |
4476 GSList *group; | |
4477 GtkWidget *groupstart = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(box), "group"); | |
4478 | |
4479 if(groupstart) | |
4480 { | |
4481 group = gtk_radio_button_group(GTK_RADIO_BUTTON(groupstart)); | |
4482 gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group); | |
4483 } | |
4484 else | |
4485 gtk_object_set_data(GTK_OBJECT(box), "group", (gpointer)item); | |
4486 } | |
4487 } | |
4488 else | |
4489 { | |
4490 GtkWidget *vbox = gtk_vbox_new(FALSE, 0); | |
4491 | |
4492 gtk_container_add(GTK_CONTAINER(box), vbox); | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4493 gtk_box_pack_end(GTK_BOX(vbox), item, TRUE, TRUE, 0); |
3 | 4494 gtk_widget_show(vbox); |
4495 | |
4496 gtk_widget_set_usize(item, width, height); | |
4497 gtk_object_set_user_data(GTK_OBJECT(box), vbox); | |
4498 } | |
4499 DW_MUTEX_UNLOCK; | |
4500 } | |
4501 | |
4502 /* | |
34
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
4503 * Sets the default focus item for a window/dialog. |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
4504 * Parameters: |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
4505 * window: Toplevel window or dialog. |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
4506 * defaultitem: Handle to the dialog item to be default. |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
4507 */ |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
4508 void dw_window_default(HWND window, HWND defaultitem) |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
4509 { |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
4510 int _locked_by_me = FALSE; |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
4511 |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
4512 if(!window) |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
4513 return; |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
4514 |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
4515 DW_MUTEX_LOCK; |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
4516 gtk_object_set_data(GTK_OBJECT(window), "defaultitem", (gpointer)defaultitem); |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
4517 DW_MUTEX_UNLOCK; |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
4518 } |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
4519 |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
4520 /* |
3 | 4521 * Returns some information about the current operating environment. |
4522 * Parameters: | |
4523 * env: Pointer to a DWEnv struct. | |
4524 */ | |
4525 void dw_environment_query(DWEnv *env) | |
4526 { | |
4527 struct utsname name; | |
4528 char tempbuf[100]; | |
4529 int len, z; | |
4530 | |
4531 uname(&name); | |
4532 strcpy(env->osName, name.sysname); | |
4533 strcpy(tempbuf, name.release); | |
4534 | |
4535 env->MajorBuild = env->MinorBuild = 0; | |
4536 | |
4537 len = strlen(tempbuf); | |
4538 | |
15
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
4539 strcpy(env->buildDate, __DATE__); |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
4540 strcpy(env->buildTime, __TIME__); |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
4541 env->DWMajorVersion = DW_MAJOR_VERSION; |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
4542 env->DWMinorVersion = DW_MINOR_VERSION; |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
4543 env->DWSubVersion = DW_SUB_VERSION; |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
4544 |
3 | 4545 for(z=1;z<len;z++) |
4546 { | |
4547 if(tempbuf[z] == '.') | |
4548 { | |
4549 tempbuf[z] = '\0'; | |
4550 env->MajorVersion = atoi(&tempbuf[z-1]); | |
4551 env->MinorVersion = atoi(&tempbuf[z+1]); | |
4552 return; | |
4553 } | |
4554 } | |
4555 env->MajorVersion = atoi(tempbuf); | |
4556 env->MinorVersion = 0; | |
4557 } | |
4558 | |
4559 /* Internal function to handle the file OK press */ | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4560 void _gtk_file_ok(GtkWidget *widget, DWDialog *dwwait) |
3 | 4561 { |
4562 char *tmp; | |
4563 | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4564 if(!dwwait) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4565 return; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4566 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4567 tmp = gtk_file_selection_get_filename(GTK_FILE_SELECTION(dwwait->data)); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4568 gtk_widget_destroy(GTK_WIDGET(dwwait->data)); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4569 _dw_file_active = 0; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4570 dw_dialog_dismiss(dwwait, (void *)(tmp ? strdup(tmp) : NULL)); |
3 | 4571 } |
4572 | |
4573 /* Internal function to handle the file Cancel press */ | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4574 void _gtk_file_cancel(GtkWidget *widget, DWDialog *dwwait) |
3 | 4575 { |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4576 if(!dwwait) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4577 return; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4578 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4579 gtk_widget_destroy(GTK_WIDGET(dwwait->data)); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4580 _dw_file_active = 0; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4581 dw_dialog_dismiss(dwwait, NULL); |
3 | 4582 } |
4583 | |
4584 /* | |
4585 * Opens a file dialog and queries user selection. | |
4586 * Parameters: | |
4587 * title: Title bar text for dialog. | |
4588 * defpath: The default path of the open dialog. | |
4589 * ext: Default file extention. | |
4590 * flags: DW_FILE_OPEN or DW_FILE_SAVE. | |
4591 * Returns: | |
4592 * NULL on error. A malloced buffer containing | |
4593 * the file path on success. | |
4594 * | |
4595 */ | |
4596 char *dw_file_browse(char *title, char *defpath, char *ext, int flags) | |
4597 { | |
4598 GtkWidget *filew; | |
4599 int _locked_by_me = FALSE; | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4600 DWDialog *dwwait; |
3 | 4601 |
4602 DW_MUTEX_LOCK; | |
4603 | |
4604 /* The DW mutex should be sufficient for | |
4605 * insuring no thread changes this unknowingly. | |
4606 */ | |
4607 if(_dw_file_active) | |
4608 { | |
4609 DW_MUTEX_UNLOCK; | |
4610 return NULL; | |
4611 } | |
4612 | |
4613 _dw_file_active = 1; | |
4614 | |
4615 filew = gtk_file_selection_new(title); | |
4616 | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4617 dwwait = dw_dialog_new((void *)filew); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4618 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4619 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filew)->ok_button), "clicked", (GtkSignalFunc) _gtk_file_ok, dwwait); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4620 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filew)->cancel_button), "clicked", (GtkSignalFunc) _gtk_file_cancel, dwwait); |
3 | 4621 |
4622 if(defpath) | |
4623 gtk_file_selection_set_filename(GTK_FILE_SELECTION(filew), defpath); | |
4624 | |
4625 gtk_widget_show(filew); | |
4626 | |
4627 DW_MUTEX_UNLOCK; | |
4628 | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4629 return (char *)dw_dialog_wait(dwwait); |
3 | 4630 } |
4631 | |
4632 | |
4633 /* | |
4634 * Execute and external program in a seperate session. | |
4635 * Parameters: | |
4636 * program: Program name with optional path. | |
4637 * type: Either DW_EXEC_CON or DW_EXEC_GUI. | |
4638 * params: An array of pointers to string arguements. | |
4639 * Returns: | |
4640 * -1 on error. | |
4641 */ | |
4642 int dw_exec(char *program, int type, char **params) | |
4643 { | |
4644 int ret = -1; | |
4645 | |
4646 if((ret = fork()) == 0) | |
4647 { | |
4648 int i; | |
4649 | |
4650 for (i = 3; i < 256; i++) | |
4651 close(i); | |
4652 setsid(); | |
4653 if(type == DW_EXEC_GUI) | |
4654 { | |
4655 execvp(program, params); | |
4656 } | |
4657 else if(type == DW_EXEC_CON) | |
4658 { | |
4659 char **tmpargs; | |
4660 | |
4661 if(!params) | |
4662 { | |
4663 tmpargs = malloc(sizeof(char *)); | |
4664 tmpargs[0] = NULL; | |
4665 } | |
4666 else | |
4667 { | |
4668 int z = 0; | |
4669 | |
4670 while(params[z]) | |
4671 { | |
4672 z++; | |
4673 } | |
4674 tmpargs = malloc(sizeof(char *)*(z+3)); | |
4675 z=0; | |
4676 tmpargs[0] = "xterm"; | |
4677 tmpargs[1] = "-e"; | |
4678 while(params[z]) | |
4679 { | |
4680 tmpargs[z+2] = params[z]; | |
4681 z++; | |
4682 } | |
4683 tmpargs[z+2] = NULL; | |
4684 } | |
4685 execvp("xterm", tmpargs); | |
4686 free(tmpargs); | |
4687 } | |
4688 /* If we got here exec failed */ | |
4689 _exit(-1); | |
4690 } | |
4691 return ret; | |
4692 } | |
4693 | |
4694 /* | |
4695 * Loads a web browser pointed at the given URL. | |
4696 * Parameters: | |
4697 * url: Uniform resource locator. | |
4698 */ | |
4699 int dw_browse(char *url) | |
4700 { | |
4701 /* Is there a way to find the webbrowser in Unix? */ | |
4702 char *execargs[3], *browser = "netscape"; | |
4703 | |
4704 execargs[0] = browser; | |
4705 execargs[1] = url; | |
4706 execargs[2] = NULL; | |
4707 | |
4708 return dw_exec(browser, DW_EXEC_GUI, execargs); | |
4709 } | |
4710 | |
4711 /* | |
4712 * Returns a pointer to a static buffer which containes the | |
4713 * current user directory. Or the root directory (C:\ on | |
4714 * OS/2 and Windows). | |
4715 */ | |
4716 char *dw_user_dir(void) | |
4717 { | |
4718 static char _user_dir[1024] = ""; | |
4719 | |
4720 if(!_user_dir[0]) | |
4721 { | |
4722 char *home = getenv("HOME"); | |
4723 | |
4724 if(home) | |
4725 strcpy(_user_dir, home); | |
4726 else | |
4727 strcpy(_user_dir, "/"); | |
4728 } | |
4729 return _user_dir; | |
4730 } | |
4731 | |
4732 /* | |
4733 * Call a function from the window (widget)'s context. | |
4734 * Parameters: | |
4735 * handle: Window handle of the widget. | |
4736 * function: Function pointer to be called. | |
4737 * data: Pointer to the data to be passed to the function. | |
4738 */ | |
4739 void dw_window_function(HWND handle, void *function, void *data) | |
4740 { | |
4741 /* TODO */ | |
4742 } | |
4743 | |
4744 #ifndef NO_SIGNALS | |
4745 /* | |
4746 * Add a callback to a window event. | |
4747 * Parameters: | |
4748 * window: Window handle of signal to be called back. | |
4749 * signame: A string pointer identifying which signal to be hooked. | |
4750 * sigfunc: The pointer to the function to be used as the callback. | |
4751 * data: User data to be passed to the handler function. | |
4752 */ | |
4753 void dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data) | |
4754 { | |
4755 SignalHandler *work = malloc(sizeof(SignalHandler)); | |
4756 void *thisfunc = _findsigfunc(signame); | |
4757 char *thisname = signame; | |
4758 HWND thiswindow = window; | |
4759 int _locked_by_me = FALSE; | |
4760 | |
4761 DW_MUTEX_LOCK; | |
4762 if(GTK_IS_SCROLLED_WINDOW(thiswindow)) | |
4763 { | |
4764 thiswindow = (HWND)gtk_object_get_user_data(GTK_OBJECT(window)); | |
4765 } | |
4766 | |
4767 if(GTK_IS_MENU_ITEM(thiswindow) && strcmp(signame, "clicked") == 0) | |
4768 { | |
4769 thisname = "activate"; | |
4770 thisfunc = _findsigfunc(thisname); | |
4771 } | |
4772 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, "container-context") == 0) | |
4773 { | |
4774 thisname = "button_press_event"; | |
4775 thisfunc = _findsigfunc("container-context"); | |
4776 } | |
4777 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, "container-select") == 0) | |
4778 { | |
4779 thisname = "button_press_event"; | |
4780 thisfunc = _findsigfunc("container-select"); | |
4781 } | |
4782 else if(GTK_IS_COMBO(thiswindow) && strcmp(signame, "item-select") == 0) | |
4783 { | |
4784 thisname = "select_child"; | |
4785 thiswindow = GTK_COMBO(thiswindow)->list; | |
4786 } | |
4787 else if(GTK_IS_LIST(thiswindow) && strcmp(signame, "item-select") == 0) | |
4788 { | |
4789 thisname = "select_child"; | |
4790 } | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
4791 else if(GTK_IS_WINDOW(thiswindow) && strcmp(signame, "set-focus") == 0) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
4792 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
4793 thisname = "focus-in-event"; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
4794 } |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4795 else if(GTK_IS_TREE(thiswindow) && strcmp(signame, "tree-select") == 0) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4796 { |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4797 if(thisfunc) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4798 { |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4799 gtk_object_set_data(GTK_OBJECT(thiswindow), "select-child-func", (gpointer)thisfunc); |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4800 gtk_object_set_data(GTK_OBJECT(thiswindow), "select-child-data", (gpointer)work); |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4801 } |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4802 thisname = "select-child"; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4803 } |
3 | 4804 |
4805 if(!thisfunc || !thiswindow) | |
4806 { | |
4807 free(work); | |
4808 DW_MUTEX_UNLOCK; | |
4809 return; | |
4810 } | |
4811 | |
4812 work->window = window; | |
4813 work->data = data; | |
4814 work->func = sigfunc; | |
4815 | |
4816 gtk_signal_connect(GTK_OBJECT(thiswindow), thisname, GTK_SIGNAL_FUNC(thisfunc), work); | |
4817 DW_MUTEX_UNLOCK; | |
4818 } | |
4819 | |
4820 /* | |
4821 * Removes callbacks for a given window with given name. | |
4822 * Parameters: | |
4823 * window: Window handle of callback to be removed. | |
4824 */ | |
4825 void dw_signal_disconnect_by_name(HWND window, char *signame) | |
4826 { | |
4827 #if 0 | |
4828 gtk_signal_disconnect_by_name(window, signame); | |
4829 #endif | |
4830 } | |
4831 | |
4832 /* | |
4833 * Removes all callbacks for a given window. | |
4834 * Parameters: | |
4835 * window: Window handle of callback to be removed. | |
4836 */ | |
4837 void dw_signal_disconnect_by_window(HWND window) | |
4838 { | |
4839 #if 0 | |
4840 gtk_signal_disconnect_by_window(window); | |
4841 #endif | |
4842 } | |
4843 | |
4844 /* | |
4845 * Removes all callbacks for a given window with specified data. | |
4846 * Parameters: | |
4847 * window: Window handle of callback to be removed. | |
4848 * data: Pointer to the data to be compared against. | |
4849 */ | |
4850 void dw_signal_disconnect_by_data(HWND window, void *data) | |
4851 { | |
4852 dw_signal_disconnect_by_data(window, data); | |
4853 } | |
4854 #endif | |
4855 | |
4856 #ifdef TEST | |
4857 HWND mainwindow, | |
4858 listbox, | |
4859 okbutton, | |
4860 cancelbutton, | |
4861 lbbox, | |
4862 stext, | |
4863 buttonbox, | |
4864 testwindow, | |
4865 testbox, | |
4866 testok, | |
4867 testcancel, | |
4868 testbox2, | |
4869 testok2, | |
4870 testcancel2, | |
4871 notebook; | |
4872 int count = 2; | |
4873 | |
4874 int test_callback(HWND window, void *data) | |
4875 { | |
4876 dw_window_destroy((HWND)data); | |
4877 /* Return -1 to allow the default handlers to return. */ | |
4878 count--; | |
4879 if(!count) | |
4880 exit(0); | |
4881 return -1; | |
4882 } | |
4883 | |
4884 /* | |
4885 * Let's demonstrate the functionality of this library. :) | |
4886 */ | |
4887 int main(void) | |
4888 { | |
4889 unsigned long flStyle = DW_FCF_SYSMENU | DW_FCF_TITLEBAR | | |
4890 DW_FCF_SHELLPOSITION | DW_FCF_TASKLIST | DW_FCF_DLGBORDER; | |
4891 int pageid; | |
4892 | |
4893 dw_init(TRUE); | |
4894 | |
4895 /* Try a little server dialog. :) */ | |
4896 mainwindow = dw_window_new(DW_DESKTOP, "Server", flStyle | DW_FCF_SIZEBORDER | DW_FCF_MINMAX); | |
4897 | |
4898 lbbox = dw_box_new(BOXVERT, 10); | |
4899 | |
4900 dw_box_pack_start(mainwindow, lbbox, 0, 0, TRUE, TRUE, 0); | |
4901 | |
4902 stext = dw_text_new("Choose a server:", 0); | |
4903 | |
4904 dw_window_set_style(stext, DW_DT_VCENTER, DW_DT_VCENTER); | |
4905 | |
4906 dw_box_pack_start(lbbox, stext, 130, 15, FALSE, FALSE, 10); | |
4907 | |
4908 listbox = dw_listbox_new(100L, FALSE); | |
4909 | |
4910 dw_box_pack_start(lbbox, listbox, 130, 200, TRUE, TRUE, 10); | |
4911 | |
4912 buttonbox = dw_box_new(BOXHORZ, 0); | |
4913 | |
4914 dw_box_pack_start(lbbox, buttonbox, 0, 0, TRUE, TRUE, 0); | |
4915 | |
4916 okbutton = dw_button_new("Ok", 1001L); | |
4917 | |
4918 dw_box_pack_start(buttonbox, okbutton, 50, 30, TRUE, TRUE, 5); | |
4919 | |
4920 cancelbutton = dw_button_new("Cancel", 1002L); | |
4921 | |
4922 dw_box_pack_start(buttonbox, cancelbutton, 50, 30, TRUE, TRUE, 5); | |
4923 | |
4924 /* Set some nice fonts and colors */ | |
4925 dw_window_set_color(lbbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); | |
4926 dw_window_set_color(buttonbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); | |
4927 dw_window_set_font(stext, "9.WarpSans"); | |
4928 dw_window_set_color(stext, DW_CLR_BLACK, DW_CLR_PALEGRAY); | |
4929 dw_window_set_font(listbox, "9.WarpSans"); | |
4930 dw_window_set_font(okbutton, "9.WarpSans"); | |
4931 dw_window_set_font(cancelbutton, "9.WarpSans"); | |
4932 | |
4933 dw_window_show(mainwindow); | |
4934 | |
4935 dw_window_set_usize(mainwindow, 170, 340); | |
4936 | |
4937 /* Another small example */ | |
4938 flStyle |= DW_FCF_MINMAX | DW_FCF_SIZEBORDER; | |
4939 | |
4940 testwindow = dw_window_new(DW_DESKTOP, "Wow a test dialog! :) yay!", flStyle); | |
4941 | |
4942 testbox = dw_box_new(BOXVERT, 0); | |
4943 | |
4944 dw_box_pack_start(testwindow, testbox, 0, 0, TRUE, TRUE, 0); | |
4945 | |
4946 notebook = dw_notebook_new(1010L, TRUE); | |
4947 | |
4948 dw_box_pack_start(testbox, notebook, 100, 100, TRUE, TRUE, 0); | |
4949 | |
4950 testbox = dw_box_new(BOXVERT, 10); | |
4951 | |
4952 pageid = dw_notebook_page_new(notebook, 0L, FALSE); | |
4953 | |
4954 dw_notebook_pack(notebook, pageid, testbox); | |
4955 | |
4956 dw_notebook_page_set_text(notebook, pageid, "Test page"); | |
4957 dw_notebook_page_set_status_text(notebook, pageid, "Test page"); | |
4958 | |
4959 testok = dw_button_new("Ok", 1003L); | |
4960 | |
4961 dw_box_pack_start(testbox, testok, 60, 40, TRUE, TRUE, 10); | |
4962 | |
4963 testcancel = dw_button_new("Cancel", 1004L); | |
4964 | |
4965 dw_box_pack_start(testbox, testcancel, 60, 40, TRUE, TRUE, 10); | |
4966 | |
4967 testbox2 = dw_box_new(BOXHORZ, 0); | |
4968 | |
4969 dw_box_pack_start(testbox, testbox2, 0, 0, TRUE, TRUE, 0); | |
4970 | |
4971 testok2 = dw_button_new("Ok", 1003L); | |
4972 | |
4973 dw_box_pack_start(testbox2, testok2, 60, 40, TRUE, TRUE, 10); | |
4974 | |
4975 dw_box_pack_splitbar_start(testbox2); | |
4976 | |
4977 testcancel2 = dw_button_new("Cancel", 1004L); | |
4978 | |
4979 dw_box_pack_start(testbox2, testcancel2, 60, 40, TRUE, TRUE, 10); | |
4980 | |
4981 /* Set some nice fonts and colors */ | |
4982 dw_window_set_color(testbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); | |
4983 dw_window_set_color(testbox2, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); | |
4984 dw_window_set_font(testok, "9.WarpSans"); | |
4985 dw_window_set_font(testcancel, "9.WarpSans"); | |
4986 dw_window_set_font(testok2, "9.WarpSans"); | |
4987 dw_window_set_font(testcancel2, "9.WarpSans"); | |
4988 | |
4989 dw_window_show(testwindow); | |
4990 | |
4991 /* Setup the function callbacks */ | |
4992 dw_signal_connect(okbutton, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); | |
4993 dw_signal_connect(cancelbutton, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); | |
4994 dw_signal_connect(testok, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); | |
4995 dw_signal_connect(testcancel, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); | |
4996 dw_signal_connect(testok2, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); | |
4997 dw_signal_connect(testcancel2, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); | |
4998 dw_signal_connect(mainwindow, "delete_event", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); | |
4999 dw_signal_connect(testwindow, "delete_event", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); | |
5000 | |
5001 dw_main(0L, NULL); | |
5002 | |
5003 return 0; | |
5004 } | |
5005 #endif |