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