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