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