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