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