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