Mercurial > dwindows
annotate gtk/dw.c @ 112:cf0115e38ef0
On multi-widget windows, set the data on all components.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 23 Sep 2002 13:34:03 +0000 |
parents | cd0e5cf92f6a |
children | 39932767ef46 |
rev | line source |
---|---|
3 | 1 /* |
2 * Dynamic Windows: | |
3 * A GTK like implementation of the PM GUI | |
4 * GTK forwarder module for portabilty. | |
5 * | |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
6 * (C) 2000-2002 Brian Smith <dbsoft@technologist.com> |
3 | 7 * |
8 */ | |
9 #include "dw.h" | |
10 #include <string.h> | |
11 #include <stdlib.h> | |
12 #include <sys/utsname.h> | |
13 #include <stdarg.h> | |
14 #include <stdio.h> | |
15 #include <unistd.h> | |
16 #include <errno.h> | |
17 #include <sys/time.h> | |
18 #include "config.h" | |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
19 #include <gdk/gdkkeysyms.h> |
3 | 20 #ifdef USE_IMLIB |
21 #include <gdk_imlib.h> | |
47
997e9ed670ef
Fixes for box alignment problem on OS/2, crash in dw_bitmap_new() on unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
46
diff
changeset
|
22 #elif defined(USE_PIXBUF) |
997e9ed670ef
Fixes for box alignment problem on OS/2, crash in dw_bitmap_new() on unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
46
diff
changeset
|
23 #include <gdk-pixbuf/gdk-pixbuf.h> |
997e9ed670ef
Fixes for box alignment problem on OS/2, crash in dw_bitmap_new() on unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
46
diff
changeset
|
24 #include <gdk-pixbuf/gdk-pixbuf-xlibrgb.h> |
997e9ed670ef
Fixes for box alignment problem on OS/2, crash in dw_bitmap_new() on unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
46
diff
changeset
|
25 #include <gdk-pixbuf/gdk-pixbuf-xlib.h> |
3 | 26 #endif |
27 | |
28 /* These are used for resource management */ | |
29 #if defined(DW_RESOURCES) && !defined(BUILD_DLL) | |
30 extern DWResources _resources; | |
31 #endif | |
32 | |
33 char monthlist[][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", | |
34 "Sep", "Oct", "Nov", "Dec" }; | |
35 GdkColor _colors[] = | |
36 { | |
37 { 0, 0x0000, 0x0000, 0x0000 }, /* 0 black */ | |
38 { 0, 0xbbbb, 0x0000, 0x0000 }, /* 1 red */ | |
39 { 0, 0x0000, 0xbbbb, 0x0000 }, /* 2 green */ | |
40 { 0, 0xaaaa, 0xaaaa, 0x0000 }, /* 3 yellow */ | |
41 { 0, 0x0000, 0x0000, 0xcccc }, /* 4 blue */ | |
42 { 0, 0xbbbb, 0x0000, 0xbbbb }, /* 5 magenta */ | |
43 { 0, 0x0000, 0xbbbb, 0xbbbb }, /* 6 cyan */ | |
44 { 0, 0xaaaa, 0xaaaa, 0xaaaa }, /* 7 white */ | |
45 { 0, 0x7777, 0x7777, 0x7777 }, /* 8 grey */ | |
46 { 0, 0xffff, 0x0000, 0x0000 }, /* 9 bright red */ | |
47 { 0, 0x0000, 0xffff, 0x0000 }, /* 10 bright green */ | |
48 { 0, 0xeeee, 0xeeee, 0x0000 }, /* 11 bright yellow */ | |
49 { 0, 0x0000, 0x0000, 0xffff }, /* 12 bright blue */ | |
50 { 0, 0xffff, 0x0000, 0xffff }, /* 13 bright magenta */ | |
51 { 0, 0x0000, 0xeeee, 0xeeee }, /* 14 bright cyan */ | |
52 { 0, 0xffff, 0xffff, 0xffff }, /* 15 bright white */ | |
53 }; | |
54 | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
55 #define DW_THREAD_LIMIT 50 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
56 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
57 DWTID _dw_thread_list[DW_THREAD_LIMIT]; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
58 GdkColor _foreground[DW_THREAD_LIMIT]; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
59 GdkColor _background[DW_THREAD_LIMIT]; |
3 | 60 |
93
98cce029a611
Changed handling of menu item click events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
92
diff
changeset
|
61 GtkWidget *last_window = NULL, *popup = 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
|
62 |
75
c629838d9805
Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
72
diff
changeset
|
63 int _dw_file_active = 0, _dw_ignore_click = 0, _dw_unselecting = 0; |
3 | 64 pthread_t _dw_thread = (pthread_t)-1; |
75
c629838d9805
Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
72
diff
changeset
|
65 int _dw_mutex_locked[DW_THREAD_LIMIT]; |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
66 /* Use default border size for the default enlightenment theme */ |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
67 int _dw_border_width = 12, _dw_border_height = 28; |
3 | 68 |
75
c629838d9805
Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
72
diff
changeset
|
69 #define DW_MUTEX_LOCK { int index = _find_thread_index(dw_thread_id()); if(pthread_self() != _dw_thread && _dw_mutex_locked[index] == FALSE) { gdk_threads_enter(); _dw_mutex_locked[index] = TRUE; _locked_by_me = TRUE; } } |
c629838d9805
Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
72
diff
changeset
|
70 #define DW_MUTEX_UNLOCK { if(pthread_self() != _dw_thread && _locked_by_me == TRUE) { gdk_threads_leave(); _dw_mutex_locked[_find_thread_index(dw_thread_id())] = FALSE; _locked_by_me = FALSE; } } |
3 | 71 |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
72 #define DEFAULT_SIZE_WIDTH 12 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
73 #define DEFAULT_SIZE_HEIGHT 6 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
74 #define DEFAULT_TITLEBAR_HEIGHT 22 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
75 |
3 | 76 GdkColormap *_dw_cmap = NULL; |
77 | |
78 /* Signal forwarder prototypes */ | |
79 gint _button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data); | |
80 gint _button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer data); | |
81 gint _motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer data); | |
82 gint _delete_event(GtkWidget *widget, GdkEvent *event, gpointer data); | |
83 gint _key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data); | |
84 gint _generic_event(GtkWidget *widget, gpointer data); | |
85 gint _configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data); | |
86 void _activate_event(GtkWidget *widget, gpointer data); | |
87 void _container_select_event(GtkWidget *widget, GdkEventButton *event, gpointer data); | |
88 void _container_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data); | |
89 void _item_select_event(GtkWidget *widget, GtkWidget *child, gpointer data); | |
90 void _expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data); | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
91 void _set_focus_event(GtkWindow *window, GtkWidget *widget, gpointer data); |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
92 void _tree_select_event(GtkTree *tree, GtkWidget *child, gpointer data); |
54
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
93 void _tree_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data); |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
94 void _value_changed_event(GtkAdjustment *adjustment, gpointer user_data); |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
95 |
3 | 96 |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
97 void msleep(long period); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
98 |
3 | 99 typedef struct |
100 { | |
101 void *func; | |
102 char name[30]; | |
103 | |
104 } SignalList; | |
105 | |
106 typedef struct | |
107 { | |
108 HWND window; | |
109 void *func; | |
110 gpointer data; | |
111 | |
112 } SignalHandler; | |
113 | |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
114 #define SIGNALMAX 16 |
3 | 115 |
116 /* A list of signal forwarders, to account for paramater differences. */ | |
117 SignalList SignalTranslate[SIGNALMAX] = { | |
118 { _configure_event, "configure_event" }, | |
119 { _key_press_event, "key_press_event" }, | |
120 { _button_press_event, "button_press_event" }, | |
121 { _button_release_event, "button_release_event" }, | |
122 { _motion_notify_event, "motion_notify_event" }, | |
123 { _delete_event, "delete_event" }, | |
124 { _expose_event, "expose_event" }, | |
125 { _activate_event, "activate" }, | |
126 { _generic_event, "clicked" }, | |
127 { _container_select_event, "container-select" }, | |
128 { _container_context_event, "container-context" }, | |
54
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
129 { _tree_context_event, "tree-context" }, |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
130 { _item_select_event, "item-select" }, |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
131 { _tree_select_event, "tree-select" }, |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
132 { _set_focus_event, "set-focus" }, |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
133 { _value_changed_event, "value_changed" } |
3 | 134 }; |
135 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
136 /* Alignment flags */ |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
137 #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
|
138 #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
|
139 #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
|
140 |
3 | 141 /* Finds the translation function for a given signal name */ |
142 void *_findsigfunc(char *signame) | |
143 { | |
144 int z; | |
145 | |
146 for(z=0;z<SIGNALMAX;z++) | |
147 { | |
148 if(strcasecmp(signame, SignalTranslate[z].name) == 0) | |
149 return SignalTranslate[z].func; | |
150 } | |
151 return NULL; | |
152 } | |
153 | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
154 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
|
155 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
156 SignalHandler *work = (SignalHandler *)data; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
157 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
158 if(work) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
159 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
160 int (*setfocusfunc)(HWND, void *) = work->func; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
161 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
162 setfocusfunc((HWND)window, work->data); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
163 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
164 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
165 |
3 | 166 gint _button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data) |
167 { | |
168 SignalHandler *work = (SignalHandler *)data; | |
169 | |
170 if(work) | |
171 { | |
172 int (*buttonfunc)(HWND, int, int, int, void *) = work->func; | |
173 int mybutton = event->button; | |
174 | |
175 if(event->button == 3) | |
176 mybutton = 2; | |
177 else if(event->button == 2) | |
178 mybutton = 3; | |
179 | |
180 buttonfunc(widget, event->x, event->y, mybutton, work->data); | |
181 } | |
182 return TRUE; | |
183 } | |
184 | |
185 gint _button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer data) | |
186 { | |
187 SignalHandler *work = (SignalHandler *)data; | |
188 | |
189 if(work) | |
190 { | |
191 int (*buttonfunc)(HWND, int, int, int, void *) = work->func; | |
192 int mybutton = event->button; | |
193 | |
194 if(event->button == 3) | |
195 mybutton = 2; | |
196 else if(event->button == 2) | |
197 mybutton = 3; | |
198 | |
199 buttonfunc(widget, event->x, event->y, mybutton, work->data); | |
200 } | |
201 return TRUE; | |
202 } | |
203 | |
204 gint _motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer data) | |
205 { | |
206 SignalHandler *work = (SignalHandler *)data; | |
207 | |
208 if(work) | |
209 { | |
210 int (*motionfunc)(HWND, int, int, int, void *) = work->func; | |
211 int keys = 0, x, y; | |
212 GdkModifierType state; | |
213 | |
214 if (event->is_hint) | |
215 gdk_window_get_pointer (event->window, &x, &y, &state); | |
216 else | |
217 { | |
218 x = event->x; | |
219 y = event->y; | |
220 state = event->state; | |
221 } | |
222 | |
223 if (state & GDK_BUTTON1_MASK) | |
224 keys = DW_BUTTON1_MASK; | |
225 if (state & GDK_BUTTON3_MASK) | |
226 keys |= DW_BUTTON2_MASK; | |
227 if (state & GDK_BUTTON2_MASK) | |
228 keys |= DW_BUTTON3_MASK; | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
229 |
3 | 230 motionfunc(widget, x, y, keys, work->data); |
231 } | |
232 return TRUE; | |
233 } | |
234 | |
235 gint _delete_event(GtkWidget *widget, GdkEvent *event, gpointer data) | |
236 { | |
237 SignalHandler *work = (SignalHandler *)data; | |
238 | |
239 if(work) | |
240 { | |
241 int (*closefunc)(HWND, void *) = work->func; | |
242 | |
54
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
243 closefunc(widget, work->data); |
3 | 244 } |
245 return TRUE; | |
246 } | |
247 | |
248 gint _key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data) | |
249 { | |
250 SignalHandler *work = (SignalHandler *)data; | |
251 | |
252 if(work) | |
253 { | |
254 int (*keypressfunc)(HWND, int, void *) = work->func; | |
255 | |
256 keypressfunc(widget, *event->string, work->data); | |
257 } | |
258 return TRUE; | |
259 } | |
260 | |
261 gint _generic_event(GtkWidget *widget, gpointer data) | |
262 { | |
263 SignalHandler *work = (SignalHandler *)data; | |
264 | |
265 if(work) | |
266 { | |
267 int (*genericfunc)(HWND, void *) = work->func; | |
268 | |
94
7c3eef54c98c
Popup menu handler fix for GTK, and fixed sliders/percent widgets not
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
93
diff
changeset
|
269 genericfunc(widget, work->data); |
3 | 270 } |
271 return TRUE; | |
272 } | |
273 | |
274 void _activate_event(GtkWidget *widget, gpointer data) | |
275 { | |
276 SignalHandler *work = (SignalHandler *)data; | |
277 | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
278 if(work && !_dw_ignore_click) |
3 | 279 { |
280 void (*activatefunc)(HWND, void *) = work->func; | |
281 | |
94
7c3eef54c98c
Popup menu handler fix for GTK, and fixed sliders/percent widgets not
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
93
diff
changeset
|
282 activatefunc(popup ? popup : work->window, work->data); |
3 | 283 } |
284 return; | |
285 } | |
286 | |
287 gint _configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data) | |
288 { | |
289 SignalHandler *work = (SignalHandler *)data; | |
290 | |
291 if(work) | |
292 { | |
293 int (*sizefunc)(HWND, int, int, void *) = work->func; | |
294 | |
295 sizefunc(widget, event->width, event->height, work->data); | |
296 } | |
297 return TRUE; | |
298 } | |
299 | |
300 void _expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data) | |
301 { | |
302 SignalHandler *work = (SignalHandler *)data; | |
303 | |
304 if(work) | |
305 { | |
306 DWExpose exp; | |
307 int (*exposefunc)(HWND, DWExpose *, void *) = work->func; | |
308 | |
309 exp.x = event->area.x; | |
310 exp.y = event->area.y; | |
311 exp.width = event->area.width; | |
312 exp.height = event->area.height; | |
313 exposefunc(widget, &exp, work->data); | |
314 } | |
315 } | |
316 | |
317 void _item_select_event(GtkWidget *widget, GtkWidget *child, gpointer data) | |
318 { | |
319 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
|
320 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
|
321 |
3aa9ef0b3996
Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
37
diff
changeset
|
322 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
|
323 return; |
3 | 324 |
325 if(work) | |
326 { | |
327 int (*selectfunc)(HWND, int, void *) = work->func; | |
328 GList *list; | |
329 int item = 0; | |
330 | |
39
3aa9ef0b3996
Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
37
diff
changeset
|
331 _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
|
332 |
3 | 333 if(GTK_IS_COMBO(work->window)) |
334 list = GTK_LIST(GTK_COMBO(work->window)->list)->children; | |
335 else if(GTK_IS_LIST(widget)) | |
336 list = GTK_LIST(widget)->children; | |
337 else | |
338 return; | |
339 | |
340 while(list) | |
341 { | |
342 if(list->data == (gpointer)child) | |
343 { | |
344 gtk_object_set_data(GTK_OBJECT(work->window), "item", (gpointer)item); | |
345 selectfunc(work->window, item, work->data); | |
346 break; | |
347 } | |
348 item++; | |
349 list = list->next; | |
350 } | |
39
3aa9ef0b3996
Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
37
diff
changeset
|
351 _dw_recursing = 0; |
3 | 352 } |
353 } | |
354 | |
355 void _container_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data) | |
356 { | |
357 SignalHandler *work = (SignalHandler *)data; | |
358 | |
359 if(work) | |
360 { | |
361 if(event->button == 3) | |
362 { | |
363 void (*contextfunc)(HWND, char *, int, int, void *) = work->func; | |
364 char *text; | |
365 int row, col; | |
366 | |
367 gtk_clist_get_selection_info(GTK_CLIST(widget), event->x, event->y, &row, &col); | |
368 | |
369 text = (char *)gtk_clist_get_row_data(GTK_CLIST(widget), row); | |
370 contextfunc(work->window, text, event->x, event->y, work->data); | |
371 } | |
372 } | |
373 } | |
374 | |
54
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
375 void _tree_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data) |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
376 { |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
377 SignalHandler *work = (SignalHandler *)data; |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
378 |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
379 if(work) |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
380 { |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
381 if(event->button == 3) |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
382 { |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
383 void (*contextfunc)(HWND, char *, int, int, void *, void *) = work->func; |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
384 char *text = (char *)gtk_object_get_data(GTK_OBJECT(widget), "text"); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
385 void *itemdata = (void *)gtk_object_get_data(GTK_OBJECT(widget), "itemdata"); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
386 |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
387 if(widget != work->window) |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
388 { |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
389 GtkWidget *tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(work->window)); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
390 |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
391 if(tree && GTK_IS_TREE(tree)) |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
392 { |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
393 GtkWidget *lastselect = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(tree), "lastselect"); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
394 |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
395 if(lastselect && GTK_IS_TREE_ITEM(lastselect)) |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
396 { |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
397 text = (char *)gtk_object_get_data(GTK_OBJECT(lastselect), "text"); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
398 itemdata = (void *)gtk_object_get_data(GTK_OBJECT(lastselect), "itemdata"); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
399 } |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
400 } |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
401 } |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
402 |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
403 contextfunc(work->window, text, event->x, event->y, work->data, itemdata); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
404 } |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
405 } |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
406 } |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
407 |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
408 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
|
409 { |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
410 SignalHandler *work = (SignalHandler *)data; |
107
cd0e5cf92f6a
Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
96
diff
changeset
|
411 GtkWidget *treeroot = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(child), "tree"); |
cd0e5cf92f6a
Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
96
diff
changeset
|
412 |
cd0e5cf92f6a
Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
96
diff
changeset
|
413 if(treeroot && GTK_IS_TREE(treeroot)) |
cd0e5cf92f6a
Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
96
diff
changeset
|
414 { |
cd0e5cf92f6a
Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
96
diff
changeset
|
415 GtkWidget *lastselect = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(treeroot), "lastselect"); |
cd0e5cf92f6a
Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
96
diff
changeset
|
416 if(lastselect && GTK_IS_TREE_ITEM(lastselect)) |
cd0e5cf92f6a
Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
96
diff
changeset
|
417 gtk_tree_item_deselect(GTK_TREE_ITEM(lastselect)); |
cd0e5cf92f6a
Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
96
diff
changeset
|
418 gtk_object_set_data(GTK_OBJECT(treeroot), "lastselect", (gpointer)child); |
cd0e5cf92f6a
Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
96
diff
changeset
|
419 } |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
420 |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
421 if(work) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
422 { |
54
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
423 void (*treeselectfunc)(HWND, HWND, char *, void *, void *) = work->func; |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
424 char *text = (char *)gtk_object_get_data(GTK_OBJECT(child), "text"); |
54
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
425 void *itemdata = (char *)gtk_object_get_data(GTK_OBJECT(child), "itemdata"); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
426 treeselectfunc(work->window, child, text, itemdata, work->data); |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
427 } |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
428 } |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
429 |
3 | 430 void _container_select_event(GtkWidget *widget, GdkEventButton *event, gpointer data) |
431 { | |
432 SignalHandler *work = (SignalHandler *)data; | |
433 | |
434 if(work) | |
435 { | |
436 if(event->button == 1 && event->type == GDK_2BUTTON_PRESS) | |
437 { | |
438 void (*contextfunc)(HWND, char *, void *) = work->func; | |
439 char *text; | |
440 int row, col; | |
441 | |
442 gtk_clist_get_selection_info(GTK_CLIST(widget), event->x, event->y, &row, &col); | |
443 | |
444 text = (char *)gtk_clist_get_row_data(GTK_CLIST(widget), row); | |
445 contextfunc(work->window, text, work->data); | |
446 } | |
447 } | |
448 } | |
449 | |
450 void _select_row(GtkWidget *widget, gint row, gint column, GdkEventButton *event, gpointer data) | |
451 { | |
452 GList *tmp = (GList *)gtk_object_get_data(GTK_OBJECT(widget), "selectlist"); | |
453 char *rowdata = gtk_clist_get_row_data(GTK_CLIST(widget), row); | |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
454 int multi = (int)gtk_object_get_data(GTK_OBJECT(widget), "multi"); |
3 | 455 |
456 if(rowdata) | |
457 { | |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
458 if(!multi) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
459 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
460 g_list_free(tmp); |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
461 tmp = NULL; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
462 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
463 |
3 | 464 tmp = g_list_append(tmp, rowdata); |
465 gtk_object_set_data(GTK_OBJECT(widget), "selectlist", tmp); | |
466 } | |
467 | |
468 } | |
469 | |
470 void _unselect_row(GtkWidget *widget, gint row, gint column, GdkEventButton *event, gpointer data) | |
471 { | |
75
c629838d9805
Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
72
diff
changeset
|
472 GList *tmp; |
c629838d9805
Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
72
diff
changeset
|
473 char *rowdata; |
c629838d9805
Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
72
diff
changeset
|
474 |
c629838d9805
Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
72
diff
changeset
|
475 if(_dw_unselecting) |
c629838d9805
Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
72
diff
changeset
|
476 return; |
c629838d9805
Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
72
diff
changeset
|
477 |
c629838d9805
Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
72
diff
changeset
|
478 tmp = (GList *)gtk_object_get_data(GTK_OBJECT(widget), "selectlist"); |
c629838d9805
Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
72
diff
changeset
|
479 rowdata = gtk_clist_get_row_data(GTK_CLIST(widget), row); |
3 | 480 |
76
ce0f5528bab0
Fixed clist crashing problems on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
75
diff
changeset
|
481 if(rowdata && tmp) |
3 | 482 { |
76
ce0f5528bab0
Fixed clist crashing problems on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
75
diff
changeset
|
483 tmp = g_list_remove(tmp, rowdata); |
3 | 484 gtk_object_set_data(GTK_OBJECT(widget), "selectlist", tmp); |
485 } | |
486 } | |
487 | |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
488 int _round_value(gfloat val) |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
489 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
490 int newval = (int)val; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
491 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
492 if(val >= 0.5 + (gfloat)newval) |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
493 newval++; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
494 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
495 return newval; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
496 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
497 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
498 void _value_changed_event(GtkAdjustment *adjustment, gpointer data) |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
499 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
500 GtkWidget *slider = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(adjustment), "slider"); |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
501 SignalHandler *work = (SignalHandler *)data; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
502 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
503 if(slider && work) |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
504 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
505 int (*valuechangedfunc)(HWND, int, void *) = work->func; |
67
ab9b0fa6c66e
Focus fixes and removal of several hack in the OS/2 code base.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
66
diff
changeset
|
506 int max = _round_value(adjustment->upper); |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
507 int val = _round_value(adjustment->value); |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
508 static int lastval = -1; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
509 static GtkWidget *lastwidget = 0; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
510 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
511 if(lastval != val || lastwidget != slider) |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
512 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
513 if(GTK_IS_VSCALE(slider)) |
67
ab9b0fa6c66e
Focus fixes and removal of several hack in the OS/2 code base.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
66
diff
changeset
|
514 valuechangedfunc(work->window, (max - val) - 1, work->data); |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
515 else |
85
f5c651a36085
Fixed a bug in the value_changed callback when using a horizontal slider.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
84
diff
changeset
|
516 valuechangedfunc(work->window, val, work->data); |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
517 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
518 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
519 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
520 |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
521 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
|
522 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
523 GtkWidget *next = (GtkWidget *)data; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
524 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
525 if(next) |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
526 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
527 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
|
528 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
529 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
|
530 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
|
531 else |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
532 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
|
533 } |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
534 } |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
535 return TRUE; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
536 } |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
537 |
3 | 538 GdkPixmap *_find_pixmap(GdkBitmap **bitmap, long id, HWND handle) |
539 { | |
540 char *data = NULL; | |
541 int z; | |
542 | |
543 for(z=0;z<_resources.resource_max;z++) | |
544 { | |
545 if(_resources.resource_id[z] == id) | |
546 { | |
547 data = _resources.resource_data[z]; | |
548 break; | |
549 } | |
550 } | |
551 | |
552 if(data) | |
553 { | |
554 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
|
555 #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
|
556 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
|
557 #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
|
558 icon_pixmap = (GdkPixmap *)gdk_pixbuf_new_from_xpm_data((const char **)data); |
3 | 559 #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
|
560 icon_pixmap = gdk_pixmap_create_from_xpm_d(handle->window, bitmap, &_colors[DW_CLR_PALEGRAY], &data); |
3 | 561 #endif |
562 return icon_pixmap; | |
563 } | |
564 return NULL; | |
565 } | |
566 | |
567 void _size_allocate(GtkWindow *window) | |
568 { | |
569 XSizeHints sizehints; | |
570 | |
571 sizehints.base_width = 1; | |
572 sizehints.base_height = 1; | |
573 sizehints.width_inc = 1; | |
574 sizehints.height_inc = 1; | |
575 sizehints.min_width = 8; | |
576 sizehints.min_height = 8; | |
577 | |
578 sizehints.flags = (PBaseSize|PMinSize|PResizeInc); | |
579 | |
580 XSetWMNormalHints (GDK_DISPLAY(), | |
581 GDK_WINDOW_XWINDOW (GTK_WIDGET (window)->window), | |
582 &sizehints); | |
583 gdk_flush (); | |
584 } | |
585 | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
586 /* Find the index of a given thread */ |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
587 int _find_thread_index(DWTID tid) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
588 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
589 int z; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
590 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
591 for(z=0;z<DW_THREAD_LIMIT;z++) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
592 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
593 if(_dw_thread_list[z] == tid) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
594 return z; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
595 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
596 return 0; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
597 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
598 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
599 /* Add a thread id to the thread list */ |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
600 void _dw_thread_add(DWTID tid) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
601 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
602 int z; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
603 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
604 for(z=0;z<DW_THREAD_LIMIT;z++) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
605 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
606 if(_dw_thread_list[z] == (DWTID)-1) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
607 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
608 _dw_thread_list[z] = tid; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
609 _foreground[z].pixel = _foreground[z].red =_foreground[z].green = _foreground[z].blue = 0; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
610 _background[z].pixel = 0; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
611 _background[z].red = 0xaaaa; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
612 _background[z].green = 0xaaaa; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
613 _background[z].blue = 0xaaaa; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
614 return; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
615 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
616 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
617 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
618 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
619 /* Remove a thread id to the thread list */ |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
620 void _dw_thread_remove(DWTID tid) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
621 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
622 int z; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
623 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
624 for(z=0;z<DW_THREAD_LIMIT;z++) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
625 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
626 if(_dw_thread_list[z] == (DWTID)tid) |
51
d97de82f0b6e
Fix warning on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
49
diff
changeset
|
627 _dw_thread_list[z] = (DWTID)-1; |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
628 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
629 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
630 |
3 | 631 /* |
632 * Initializes the Dynamic Windows engine. | |
633 * Parameters: | |
634 * newthread: True if this is the only thread. | |
635 * False if there is already a message loop running. | |
636 */ | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
637 int dw_int_init(DWResources *res, int newthread, int argc, char *argv[]) |
3 | 638 { |
639 int z; | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
640 char *tmp; |
3 | 641 |
642 if(res) | |
643 { | |
644 _resources.resource_max = res->resource_max; | |
645 _resources.resource_id = res->resource_id; | |
646 _resources.resource_data = res->resource_data; | |
647 } | |
648 gtk_set_locale(); | |
649 g_thread_init(NULL); | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
650 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
651 gtk_init(&argc, &argv); |
3 | 652 #ifdef USE_IMLIB |
653 gdk_imlib_init(); | |
654 #endif | |
655 /* Add colors to the system colormap */ | |
656 _dw_cmap = gdk_colormap_get_system(); | |
657 for(z=0;z<16;z++) | |
658 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
|
659 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
660 tmp = getenv("DW_BORDER_WIDTH"); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
661 if(tmp) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
662 _dw_border_width = atoi(tmp); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
663 tmp = getenv("DW_BORDER_HEIGHT"); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
664 if(tmp) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
665 _dw_border_height = atoi(tmp); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
666 |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
667 for(z=0;z<DW_THREAD_LIMIT;z++) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
668 _dw_thread_list[z] = (DWTID)-1; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
669 |
77
002da4d18ac6
Set tooltip background color to yellow.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
76
diff
changeset
|
670 gtk_rc_parse_string("style \"gtk-tooltips-style\" { bg[NORMAL] = \"#eeee00\" } widget \"gtk-tooltips\" style \"gtk-tooltips-style\""); |
002da4d18ac6
Set tooltip background color to yellow.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
76
diff
changeset
|
671 |
3 | 672 return TRUE; |
673 } | |
674 | |
675 /* | |
676 * Runs a message loop for Dynamic Windows. | |
677 * Parameters: | |
678 * currenthab: The handle to the current anchor block | |
679 * or NULL if this DW is handling the message loop. | |
680 * func: Function pointer to the message filter function. | |
681 */ | |
682 void dw_main(HAB currenthab, void *func) | |
683 { | |
684 _dw_thread = pthread_self(); | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
685 _dw_thread_add(_dw_thread); |
3 | 686 gdk_threads_enter(); |
687 gtk_main(); | |
688 gdk_threads_leave(); | |
689 } | |
690 | |
691 /* | |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
692 * Runs a message loop for Dynamic Windows, for a period of milliseconds. |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
693 * Parameters: |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
694 * milliseconds: Number of milliseconds to run the loop for. |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
695 */ |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
696 void dw_main_sleep(int milliseconds) |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
697 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
698 struct timeval tv, start; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
699 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
700 gettimeofday(&start, NULL); |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
701 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
702 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
|
703 { |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
704 gettimeofday(&tv, NULL); |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
705 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
706 while(((tv.tv_sec - start.tv_sec)*1000) + ((tv.tv_usec - start.tv_usec)/1000) <= milliseconds) |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
707 { |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
708 gdk_threads_enter(); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
709 if(gtk_events_pending()) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
710 gtk_main_iteration(); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
711 else |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
712 msleep(1); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
713 gdk_threads_leave(); |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
714 gettimeofday(&tv, NULL); |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
715 } |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
716 } |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
717 else |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
718 msleep(milliseconds); |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
719 } |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
720 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
721 /* |
3 | 722 * Free's memory allocated by dynamic windows. |
723 * Parameters: | |
724 * ptr: Pointer to dynamic windows allocated | |
725 * memory to be free()'d. | |
726 */ | |
727 void dw_free(void *ptr) | |
728 { | |
729 free(ptr); | |
730 } | |
731 | |
732 /* | |
733 * Allocates and initializes a dialog struct. | |
734 * Parameters: | |
735 * data: User defined data to be passed to functions. | |
736 */ | |
737 DWDialog *dw_dialog_new(void *data) | |
738 { | |
739 DWDialog *tmp = malloc(sizeof(DWDialog)); | |
740 | |
741 tmp->eve = dw_event_new(); | |
742 dw_event_reset(tmp->eve); | |
743 tmp->data = data; | |
744 tmp->done = FALSE; | |
745 tmp->result = NULL; | |
746 | |
747 return tmp; | |
748 } | |
749 | |
750 /* | |
751 * Accepts a dialog struct and returns the given data to the | |
752 * initial called of dw_dialog_wait(). | |
753 * Parameters: | |
754 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). | |
755 * result: Data to be returned by dw_dialog_wait(). | |
756 */ | |
757 int dw_dialog_dismiss(DWDialog *dialog, void *result) | |
758 { | |
759 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
|
760 if(pthread_self() == _dw_thread || _dw_thread == (pthread_t)-1) |
3 | 761 gtk_main_quit(); |
762 else | |
763 dw_event_post(dialog->eve); | |
764 dialog->done = TRUE; | |
765 return 0; | |
766 } | |
767 | |
768 /* | |
769 * Accepts a dialog struct waits for dw_dialog_dismiss() to be | |
770 * called by a signal handler with the given dialog struct. | |
771 * Parameters: | |
772 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). | |
773 */ | |
774 void *dw_dialog_wait(DWDialog *dialog) | |
775 { | |
776 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
|
777 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
|
778 |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
779 /* _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
|
780 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
|
781 { |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
782 _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
|
783 newprocess = 1; |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
784 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
|
785 } |
3 | 786 |
787 if(pthread_self() == _dw_thread) | |
788 gtk_main(); | |
789 else | |
790 dw_event_wait(dialog->eve, -1); | |
791 | |
41
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
792 if(newprocess) |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
793 { |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
794 _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
|
795 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
|
796 } |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
797 |
3 | 798 dw_event_close(&dialog->eve); |
799 tmp = dialog->result; | |
800 free(dialog); | |
801 return tmp; | |
802 } | |
803 | |
804 void _delete(GtkWidget *widget, GtkWidget *event, gpointer param) | |
805 { | |
806 gtk_widget_destroy(GTK_WIDGET(param)); | |
807 } | |
808 | |
809 void _delete2(GtkWidget *widget, gpointer param) | |
810 { | |
811 gtk_widget_destroy(GTK_WIDGET(param)); | |
812 } | |
813 | |
814 | |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
815 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
|
816 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
817 DWDialog *dwwait = (DWDialog *)data; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
818 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
819 if(!dwwait) |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
820 return; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
821 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
822 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
|
823 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
|
824 } |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
825 |
3 | 826 /* |
827 * Displays a Message Box with given text and title.. | |
828 * Parameters: | |
829 * title: The title of the message box. | |
830 * format: printf style format string. | |
831 * ...: Additional variables for use in the format. | |
832 */ | |
833 int dw_messagebox(char *title, char *format, ...) | |
834 { | |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
835 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
|
836 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
|
837 DWDialog *dwwait; |
3 | 838 va_list args; |
839 char outbuf[256]; | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
840 int x, y; |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
841 |
3 | 842 va_start(args, format); |
843 vsprintf(outbuf, format, args); | |
844 va_end(args); | |
845 | |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
846 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
|
847 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
|
848 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
|
849 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
850 /* Archive Name */ |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
851 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
|
852 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
|
853 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
854 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
|
855 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
856 /* Buttons */ |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
857 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
|
858 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
859 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
|
860 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
861 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
|
862 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
863 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
|
864 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
865 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
|
866 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
867 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
|
868 |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
869 x = (dw_screen_width() - 220)/2; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
870 y = (dw_screen_height() - 110)/2; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
871 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
872 dw_window_set_pos_size(entrywindow, x, y, 220, 110); |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
873 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
874 dw_window_show(entrywindow); |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
875 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
876 dw_dialog_wait(dwwait); |
3 | 877 |
878 return strlen(outbuf); | |
879 } | |
880 | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
881 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
|
882 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
883 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
|
884 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
885 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
|
886 return; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
887 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
888 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
|
889 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
|
890 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
891 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
892 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
|
893 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
894 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
|
895 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
896 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
|
897 return; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
898 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
899 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
|
900 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
|
901 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
902 |
3 | 903 /* |
904 * Displays a Message Box with given text and title.. | |
905 * Parameters: | |
906 * title: The title of the message box. | |
907 * text: The text to display in the box. | |
908 * Returns: | |
909 * True if YES False of NO. | |
910 */ | |
911 int dw_yesno(char *title, char *text) | |
912 { | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
913 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
|
914 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
|
915 DWDialog *dwwait; |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
916 int x, y; |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
917 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
918 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
|
919 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
920 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
|
921 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
922 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
|
923 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
924 /* 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
|
925 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
|
926 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
|
927 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
928 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
|
929 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
930 /* Buttons */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
931 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
|
932 |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
933 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
|
934 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
935 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
|
936 |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
937 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
|
938 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
939 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
|
940 |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
941 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
|
942 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
943 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
|
944 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
945 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
|
946 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
|
947 |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
948 x = (dw_screen_width() - 220)/2; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
949 y = (dw_screen_height() - 110)/2; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
950 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
951 dw_window_set_pos_size(entrywindow, x, y, 220, 110); |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
952 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
953 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
|
954 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
955 return (int)dw_dialog_wait(dwwait);; |
3 | 956 } |
957 | |
958 /* | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
959 * 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
|
960 * Parameters: |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
961 * handle: The window handle to minimize. |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
962 */ |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
963 int dw_window_minimize(HWND handle) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
964 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
965 int _locked_by_me = FALSE; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
966 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
967 if(!handle) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
968 return 0; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
969 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
970 DW_MUTEX_LOCK; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
971 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
|
972 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
|
973 DefaultScreen (GDK_DISPLAY ())); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
974 DW_MUTEX_UNLOCK; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
975 return 0; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
976 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
977 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
978 /* |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
979 * Makes the window topmost. |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
980 * Parameters: |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
981 * 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
|
982 */ |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
983 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
|
984 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
985 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
|
986 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
987 if(!handle) |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
988 return 0; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
989 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
990 DW_MUTEX_LOCK; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
991 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
|
992 DW_MUTEX_UNLOCK; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
993 return 0; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
994 } |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
995 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
996 /* |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
997 * Makes the window bottommost. |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
998 * Parameters: |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
999 * 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
|
1000 */ |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1001 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
|
1002 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1003 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
|
1004 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1005 if(!handle) |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1006 return 0; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1007 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1008 DW_MUTEX_LOCK; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1009 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
|
1010 DW_MUTEX_UNLOCK; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1011 return 0; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1012 } |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1013 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1014 /* |
3 | 1015 * Makes the window visible. |
1016 * Parameters: | |
1017 * handle: The window handle to make visible. | |
1018 */ | |
1019 int dw_window_show(HWND handle) | |
1020 { | |
1021 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
|
1022 GtkWidget *defaultitem; |
3 | 1023 |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1024 if(!handle) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1025 return 0; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1026 |
3 | 1027 DW_MUTEX_LOCK; |
1028 gtk_widget_show(handle); | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1029 if(GTK_WIDGET(handle)->window) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1030 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1031 gdk_window_raise(GTK_WIDGET(handle)->window); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1032 gdk_flush(); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1033 gdk_window_show(GTK_WIDGET(handle)->window); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1034 gdk_flush(); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1035 } |
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
|
1036 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
|
1037 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
|
1038 gtk_widget_grab_focus(defaultitem); |
3 | 1039 DW_MUTEX_UNLOCK; |
1040 return 0; | |
1041 } | |
1042 | |
1043 /* | |
1044 * Makes the window invisible. | |
1045 * Parameters: | |
1046 * handle: The window handle to make visible. | |
1047 */ | |
1048 int dw_window_hide(HWND handle) | |
1049 { | |
1050 int _locked_by_me = FALSE; | |
1051 | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1052 if(!handle) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1053 return 0; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1054 |
3 | 1055 DW_MUTEX_LOCK; |
1056 gtk_widget_hide(handle); | |
1057 DW_MUTEX_UNLOCK; | |
1058 return 0; | |
1059 } | |
1060 | |
1061 /* | |
1062 * Destroys a window and all of it's children. | |
1063 * Parameters: | |
1064 * handle: The window handle to destroy. | |
1065 */ | |
1066 int dw_window_destroy(HWND handle) | |
1067 { | |
1068 int _locked_by_me = FALSE; | |
1069 | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1070 if(!handle) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1071 return 0; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1072 |
3 | 1073 DW_MUTEX_LOCK; |
17
f26eced21a30
Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
15
diff
changeset
|
1074 if(GTK_IS_WIDGET(handle)) |
f26eced21a30
Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
15
diff
changeset
|
1075 gtk_widget_destroy(handle); |
3 | 1076 DW_MUTEX_UNLOCK; |
1077 return 0; | |
1078 } | |
1079 | |
54
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
1080 /* Causes entire window to be invalidated and redrawn. |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
1081 * Parameters: |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
1082 * handle: Toplevel window handle to be redrawn. |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
1083 */ |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
1084 void dw_window_redraw(HWND handle) |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
1085 { |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
1086 } |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
1087 |
3 | 1088 /* |
1089 * Changes a window's parent to newparent. | |
1090 * Parameters: | |
1091 * handle: The window handle to destroy. | |
1092 * newparent: The window's new parent window. | |
1093 */ | |
1094 void dw_window_reparent(HWND handle, HWND newparent) | |
1095 { | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1096 int _locked_by_me = FALSE; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1097 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1098 DW_MUTEX_LOCK; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1099 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
|
1100 DW_MUTEX_UNLOCK; |
3 | 1101 } |
1102 | |
1103 int _set_font(HWND handle, char *fontname) | |
1104 { | |
1105 GtkStyle *style; | |
1106 GdkFont *font = NULL; | |
1107 int retval = FALSE; | |
1108 | |
1109 font = gdk_font_load(fontname); | |
1110 | |
1111 if(font) | |
1112 { | |
1113 style = gtk_widget_get_style(handle); | |
1114 style->font = font; | |
1115 gtk_widget_set_style(handle, style); | |
1116 retval = TRUE; | |
1117 } | |
1118 return retval; | |
1119 } | |
1120 | |
1121 /* | |
1122 * Sets the font used by a specified window (widget) handle. | |
1123 * Parameters: | |
1124 * handle: The window (widget) handle. | |
1125 * fontname: Name and size of the font in the form "size.fontname" | |
1126 */ | |
1127 int dw_window_set_font(HWND handle, char *fontname) | |
1128 { | |
1129 GtkWidget *handle2 = handle; | |
1130 char *font; | |
1131 int _locked_by_me = FALSE; | |
1132 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
|
1133 GdkFont *gdkfont; |
3 | 1134 |
1135 DW_MUTEX_LOCK; | |
1136 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
1137 { | |
1138 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
1139 if(tmp) | |
1140 handle2 = tmp; | |
1141 } | |
1142 font = strdup(fontname); | |
1143 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1144 /* 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
|
1145 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
|
1146 if(gdkfont) |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1147 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
|
1148 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
|
1149 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
|
1150 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1151 /* Free old font name if one is allocated */ |
3 | 1152 data = gtk_object_get_data(GTK_OBJECT(handle2), "fontname"); |
1153 if(data) | |
1154 free(data); | |
1155 | |
1156 if(font) | |
1157 gtk_object_set_data(GTK_OBJECT(handle2), "fontname", (gpointer)font); | |
1158 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1159 |
3 | 1160 DW_MUTEX_UNLOCK; |
1161 return TRUE; | |
1162 } | |
1163 | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1164 void _free_gdk_colors(HWND handle) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1165 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1166 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
|
1167 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1168 if(old) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1169 free(old); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1170 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1171 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
|
1172 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1173 if(old) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1174 free(old); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1175 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1176 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1177 /* 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
|
1178 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
|
1179 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1180 GdkColor *foregdk = malloc(sizeof(GdkColor)); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1181 GdkColor *backgdk = malloc(sizeof(GdkColor)); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1182 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1183 _free_gdk_colors(handle); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1184 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1185 *foregdk = fore; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1186 *backgdk = back; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1187 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1188 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
|
1189 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
|
1190 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1191 |
3 | 1192 int _set_color(HWND handle, unsigned long fore, unsigned long back) |
1193 { | |
1194 GtkStyle *style; | |
1195 | |
1196 if(fore & DW_RGB_COLOR || back & DW_RGB_COLOR) | |
1197 { | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1198 /* 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
|
1199 * 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
|
1200 */ |
3 | 1201 GdkColor forecolor = { 0, DW_RED_VALUE(fore) << 8, DW_GREEN_VALUE(fore) << 8, DW_BLUE_VALUE(fore) << 8 }; |
1202 GdkColor backcolor = { 0, DW_RED_VALUE(back) << 8, DW_GREEN_VALUE(back) << 8, DW_BLUE_VALUE(back) << 8 }; | |
1203 | |
1204 gdk_color_alloc(_dw_cmap, &forecolor); | |
1205 gdk_color_alloc(_dw_cmap, &backcolor); | |
1206 | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1207 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
|
1208 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
|
1209 style->base[0] = style->base[1] = style->bg[0] = style->bg[1] = backcolor; |
3 | 1210 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
|
1211 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1212 _save_gdk_colors(handle, forecolor, backcolor); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1213 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1214 if(GTK_IS_CLIST(handle)) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1215 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1216 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
|
1217 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1218 for(z=0;z<rowcount;z++) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1219 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1220 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
|
1221 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
|
1222 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1223 } |
3 | 1224 } |
1225 else | |
1226 { | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1227 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
|
1228 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
|
1229 style->base[0] = style->base[1] = style->bg[0] = style->bg[1] = _colors[back]; |
3 | 1230 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
|
1231 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1232 _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
|
1233 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1234 if(GTK_IS_CLIST(handle)) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1235 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1236 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
|
1237 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1238 for(z=0;z<rowcount;z++) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1239 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1240 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
|
1241 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
|
1242 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1243 } |
3 | 1244 } |
1245 | |
1246 return TRUE; | |
1247 } | |
1248 /* | |
1249 * Sets the colors used by a specified window (widget) handle. | |
1250 * Parameters: | |
1251 * handle: The window (widget) handle. | |
1252 * fore: Foreground color in RGB format. | |
1253 * back: Background color in RGB format. | |
1254 */ | |
1255 int dw_window_set_color(HWND handle, unsigned long fore, unsigned long back) | |
1256 { | |
1257 GtkWidget *handle2 = handle; | |
1258 int _locked_by_me = FALSE; | |
1259 | |
1260 DW_MUTEX_LOCK; | |
1261 | |
1262 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
1263 { | |
1264 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
1265 if(tmp) | |
1266 handle2 = tmp; | |
1267 } | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1268 else if(GTK_IS_BOX(handle)) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1269 { |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1270 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
|
1271 if(tmp) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1272 handle2 = tmp; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1273 } |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1274 else if(GTK_IS_TABLE(handle)) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1275 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1276 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "eventbox"); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1277 if(tmp) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1278 handle2 = tmp; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1279 } |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1280 |
3 | 1281 _set_color(handle2, fore, back); |
1282 | |
1283 DW_MUTEX_UNLOCK; | |
1284 return TRUE; | |
1285 } | |
1286 | |
1287 /* | |
1288 * Sets the font used by a specified window (widget) handle. | |
1289 * Parameters: | |
1290 * handle: The window (widget) handle. | |
1291 * border: Size of the window border in pixels. | |
1292 */ | |
1293 int dw_window_set_border(HWND handle, int border) | |
1294 { | |
1295 /* TODO */ | |
1296 return 0; | |
1297 } | |
1298 | |
1299 /* | |
1300 * Captures the mouse input to this window. | |
1301 * Parameters: | |
1302 * handle: Handle to receive mouse input. | |
1303 */ | |
1304 void dw_window_capture(HWND handle) | |
1305 { | |
1306 int _locked_by_me = FALSE; | |
1307 | |
1308 DW_MUTEX_LOCK; | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1309 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 | 1310 DW_MUTEX_UNLOCK; |
1311 } | |
1312 | |
1313 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1314 * 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
|
1315 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1316 * 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
|
1317 * 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
|
1318 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1319 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
|
1320 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1321 GdkCursor *cursor = gdk_cursor_new(pointertype); |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
1322 if(handle && handle->window) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
1323 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
|
1324 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
|
1325 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1326 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1327 /* |
3 | 1328 * Releases previous mouse capture. |
1329 */ | |
1330 void dw_window_release(void) | |
1331 { | |
1332 int _locked_by_me = FALSE; | |
1333 | |
1334 DW_MUTEX_LOCK; | |
1335 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
1336 DW_MUTEX_UNLOCK; | |
1337 } | |
1338 | |
1339 /* | |
1340 * Create a new Window Frame. | |
1341 * Parameters: | |
1342 * owner: The Owner's window handle or HWND_DESKTOP. | |
1343 * title: The Window title. | |
1344 * flStyle: Style flags, see the PM reference. | |
1345 */ | |
1346 HWND dw_window_new(HWND hwndOwner, char *title, unsigned long flStyle) | |
1347 { | |
1348 GtkWidget *tmp; | |
1349 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
|
1350 int flags = 0; |
3 | 1351 |
1352 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
|
1353 last_window = tmp = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
3 | 1354 |
1355 gtk_window_set_title(GTK_WINDOW(tmp), title); | |
1356 if(!(flStyle & DW_FCF_SIZEBORDER)) | |
1357 gtk_window_set_policy(GTK_WINDOW(tmp), FALSE, FALSE, TRUE); | |
1358 | |
1359 gtk_widget_realize(tmp); | |
1360 | |
1361 if(flStyle & DW_FCF_TITLEBAR) | |
1362 flags |= GDK_DECOR_TITLE; | |
1363 | |
1364 if(flStyle & DW_FCF_MINMAX) | |
1365 flags |= GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE; | |
1366 | |
1367 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
|
1368 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
|
1369 |
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
|
1370 if(flStyle & DW_FCF_BORDER || flStyle & DW_FCF_DLGBORDER) |
3 | 1371 flags |= GDK_DECOR_BORDER; |
1372 | |
1373 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
|
1374 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1375 if(hwndOwner) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1376 gdk_window_reparent(GTK_WIDGET(tmp)->window, GTK_WIDGET(hwndOwner)->window, 0, 0); |
3 | 1377 |
1378 DW_MUTEX_UNLOCK; | |
1379 return tmp; | |
1380 } | |
1381 | |
1382 /* | |
1383 * Create a new Box to be packed. | |
1384 * Parameters: | |
1385 * type: Either BOXVERT (vertical) or BOXHORZ (horizontal). | |
1386 * pad: Number of pixels to pad around the box. | |
1387 */ | |
1388 HWND dw_box_new(int type, int pad) | |
1389 { | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1390 GtkWidget *tmp, *eventbox; |
3 | 1391 int _locked_by_me = FALSE; |
1392 | |
1393 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
|
1394 tmp = gtk_table_new(1, 1, FALSE); |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1395 eventbox = gtk_event_box_new(); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1396 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1397 gtk_widget_show(eventbox); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1398 gtk_object_set_data(GTK_OBJECT(tmp), "eventbox", (gpointer)eventbox); |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1399 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
|
1400 gtk_object_set_data(GTK_OBJECT(tmp), "boxpad", (gpointer)pad); |
3 | 1401 gtk_widget_show(tmp); |
1402 DW_MUTEX_UNLOCK; | |
1403 return tmp; | |
1404 } | |
1405 | |
1406 /* | |
1407 * Create a new Group Box to be packed. | |
1408 * Parameters: | |
1409 * type: Either BOXVERT (vertical) or BOXHORZ (horizontal). | |
1410 * pad: Number of pixels to pad around the box. | |
1411 * title: Text to be displayined in the group outline. | |
1412 */ | |
1413 HWND dw_groupbox_new(int type, int pad, char *title) | |
1414 { | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1415 GtkWidget *tmp, *frame; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1416 int _locked_by_me = FALSE; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1417 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1418 DW_MUTEX_LOCK; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1419 frame = gtk_frame_new(NULL); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1420 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
|
1421 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
|
1422 tmp = gtk_table_new(1, 1, FALSE); |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1423 gtk_container_border_width(GTK_CONTAINER(tmp), pad); |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1424 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
|
1425 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
|
1426 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
|
1427 gtk_container_add(GTK_CONTAINER(frame), tmp); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1428 gtk_widget_show(tmp); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1429 gtk_widget_show(frame); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1430 DW_MUTEX_UNLOCK; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1431 return frame; |
3 | 1432 } |
1433 | |
1434 /* | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1435 * 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
|
1436 * Parameters: |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1437 * 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
|
1438 */ |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1439 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
|
1440 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1441 return gtk_vbox_new(FALSE, 0); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1442 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1443 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1444 /* |
3 | 1445 * Create a bitmap object to be packed. |
1446 * Parameters: | |
1447 * id: An ID to be used with WinWindowFromID() or 0L. | |
1448 */ | |
1449 HWND dw_bitmap_new(unsigned long id) | |
1450 { | |
1451 GdkPixmap *pixmap= NULL; | |
1452 GdkBitmap *bitmap; | |
1453 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
|
1454 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
|
1455 "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
|
1456 " 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
|
1457 ". 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
|
1458 "."}; |
3 | 1459 int _locked_by_me = FALSE; |
1460 | |
1461 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
|
1462 #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
|
1463 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
|
1464 #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
|
1465 pixmap = (GdkPixmap *)gdk_pixbuf_new_from_xpm_data((const char **)test_xpm); |
3 | 1466 #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
|
1467 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
|
1468 |
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
|
1469 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
|
1470 pixmap = gdk_pixmap_create_from_xpm_d(last_window->window, &bitmap, &_colors[DW_CLR_PALEGRAY], test_xpm); |
3 | 1471 #endif |
1472 tmp = gtk_pixmap_new(pixmap, bitmap); | |
1473 gtk_widget_show(tmp); | |
1474 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
1475 DW_MUTEX_UNLOCK; | |
1476 return tmp; | |
1477 } | |
1478 | |
1479 /* | |
1480 * Create a notebook object to be packed. | |
1481 * Parameters: | |
1482 * id: An ID to be used for getting the resource from the | |
1483 * resource file. | |
1484 */ | |
1485 HWND dw_notebook_new(unsigned long id, int top) | |
1486 { | |
1487 GtkWidget *tmp; | |
1488 int _locked_by_me = FALSE; | |
1489 | |
1490 DW_MUTEX_LOCK; | |
1491 tmp = gtk_notebook_new(); | |
1492 if(top) | |
1493 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tmp), GTK_POS_TOP); | |
1494 else | |
1495 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tmp), GTK_POS_BOTTOM); | |
83
1062b0409938
Set notebook scrollable and enable popup so it will act like OS/2. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
77
diff
changeset
|
1496 gtk_notebook_set_scrollable(GTK_NOTEBOOK(tmp), TRUE); |
84
510c28aace3c
Ok the popup menu acted a bit funny so I am disabling it for now.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
83
diff
changeset
|
1497 #if 0 |
83
1062b0409938
Set notebook scrollable and enable popup so it will act like OS/2. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
77
diff
changeset
|
1498 gtk_notebook_popup_enable(GTK_NOTEBOOK(tmp)); |
84
510c28aace3c
Ok the popup menu acted a bit funny so I am disabling it for now.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
83
diff
changeset
|
1499 #endif |
3 | 1500 gtk_widget_show(tmp); |
1501 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
1502 DW_MUTEX_UNLOCK; | |
1503 return tmp; | |
1504 } | |
1505 | |
1506 /* | |
1507 * Create a menu object to be popped up. | |
1508 * Parameters: | |
1509 * id: An ID to be used for getting the resource from the | |
1510 * resource file. | |
1511 */ | |
1512 HMENUI dw_menu_new(unsigned long id) | |
1513 { | |
1514 int _locked_by_me = FALSE; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1515 HMENUI tmp = malloc(sizeof(struct _hmenui)); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1516 GtkAccelGroup *accel_group; |
3 | 1517 |
1518 if(!tmp) | |
1519 return NULL; | |
1520 | |
1521 DW_MUTEX_LOCK; | |
1522 tmp->menu = gtk_menu_new(); | |
1523 gtk_widget_show(tmp->menu); | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1524 accel_group = gtk_accel_group_new(); |
3 | 1525 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
|
1526 gtk_object_set_data(GTK_OBJECT(tmp->menu), "accel", (gpointer)accel_group); |
3 | 1527 DW_MUTEX_UNLOCK; |
1528 return tmp; | |
1529 } | |
1530 | |
1531 /* | |
1532 * Create a menubar on a window. | |
1533 * Parameters: | |
1534 * location: Handle of a window frame to be attached to. | |
1535 */ | |
1536 HMENUI dw_menubar_new(HWND location) | |
1537 { | |
1538 GtkWidget *box; | |
1539 int _locked_by_me = FALSE; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1540 HMENUI tmp = malloc(sizeof(struct _hmenui)); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1541 GtkAccelGroup *accel_group; |
3 | 1542 |
1543 if(!tmp) | |
1544 return NULL; | |
1545 | |
1546 DW_MUTEX_LOCK; | |
1547 tmp->menu = gtk_menu_bar_new(); | |
1548 box = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(location)); | |
1549 gtk_widget_show(tmp->menu); | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1550 accel_group = gtk_accel_group_new(); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1551 gtk_object_set_data(GTK_OBJECT(tmp->menu), "accel", (gpointer)accel_group); |
3 | 1552 |
1553 if(box) | |
1554 gtk_box_pack_end(GTK_BOX(box), tmp->menu, FALSE, FALSE, 0); | |
1555 | |
1556 DW_MUTEX_UNLOCK; | |
1557 return tmp; | |
1558 } | |
1559 | |
1560 /* | |
1561 * Destroys a menu created with dw_menubar_new or dw_menu_new. | |
1562 * Parameters: | |
1563 * menu: Handle of a menu. | |
1564 */ | |
1565 void dw_menu_destroy(HMENUI *menu) | |
1566 { | |
1567 if(menu && *menu) | |
1568 { | |
1569 int _locked_by_me = FALSE; | |
1570 | |
1571 DW_MUTEX_LOCK; | |
1572 gtk_widget_destroy((*menu)->menu); | |
1573 free(*menu); | |
1574 *menu = NULL; | |
1575 DW_MUTEX_UNLOCK; | |
1576 } | |
1577 } | |
1578 | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1579 char _removetilde(char *dest, char *src) |
3 | 1580 { |
1581 int z, cur=0; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1582 char accel = '\0'; |
3 | 1583 |
1584 for(z=0;z<strlen(src);z++) | |
1585 { | |
1586 if(src[z] != '~') | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1587 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1588 dest[cur] = src[z]; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1589 cur++; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1590 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1591 else |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1592 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1593 dest[cur] = '_'; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1594 accel = src[z+1]; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1595 cur++; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1596 } |
3 | 1597 } |
1598 dest[cur] = 0; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1599 return accel; |
3 | 1600 } |
1601 | |
1602 /* | |
1603 * Adds a menuitem or submenu to an existing menu. | |
1604 * Parameters: | |
1605 * menu: The handle the the existing menu. | |
1606 * title: The title text on the menu item to be added. | |
1607 * id: An ID to be used for message passing. | |
1608 * flags: Extended attributes to set on the menu. | |
1609 * end: If TRUE memu is positioned at the end of the menu. | |
1610 * check: If TRUE menu is "check"able. | |
1611 * submenu: Handle to an existing menu to be a submenu or NULL. | |
1612 */ | |
1613 HWND dw_menu_append_item(HMENUI menu, char *title, unsigned long id, unsigned long flags, int end, int check, HMENUI submenu) | |
1614 { | |
1615 GtkWidget *tmphandle; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1616 char accel, *tempbuf = malloc(strlen(title)+1); |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1617 int _locked_by_me = FALSE, submenucount; |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1618 guint tmp_key; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1619 GtkAccelGroup *accel_group; |
3 | 1620 |
1621 if(!menu || !menu->menu) | |
1622 { | |
1623 free(tempbuf); | |
1624 return NULL; | |
1625 } | |
1626 | |
1627 DW_MUTEX_LOCK; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1628 accel = _removetilde(tempbuf, title); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1629 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1630 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
|
1631 submenucount = (int)gtk_object_get_data(GTK_OBJECT(menu->menu), "submenucount"); |
3 | 1632 |
1633 if(strlen(tempbuf) == 0) | |
1634 tmphandle=gtk_menu_item_new(); | |
1635 else | |
1636 { | |
1637 if(check) | |
1638 { | |
1639 char numbuf[10]; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1640 if(accel && accel_group) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1641 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1642 tmphandle=gtk_check_menu_item_new_with_label(""); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1643 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
|
1644 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
|
1645 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1646 else |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1647 tmphandle=gtk_check_menu_item_new_with_label(tempbuf); |
3 | 1648 gtk_check_menu_item_set_show_toggle(GTK_CHECK_MENU_ITEM(tmphandle), TRUE); |
1649 sprintf(numbuf, "%lu", id); | |
1650 gtk_object_set_data(GTK_OBJECT(menu->menu), numbuf, (gpointer)tmphandle); | |
1651 } | |
1652 else | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1653 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1654 if(accel && accel_group) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1655 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1656 tmphandle=gtk_menu_item_new_with_label(""); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1657 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
|
1658 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
|
1659 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1660 else |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1661 tmphandle=gtk_menu_item_new_with_label(tempbuf); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1662 } |
3 | 1663 } |
1664 | |
1665 gtk_widget_show(tmphandle); | |
1666 | |
1667 if(submenu) | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1668 { |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1669 char tempbuf[100]; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1670 |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1671 sprintf(tempbuf, "submenu%d", submenucount); |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1672 submenucount++; |
3 | 1673 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
|
1674 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
|
1675 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
|
1676 } |
3 | 1677 |
1678 if(GTK_IS_MENU_BAR(menu->menu)) | |
1679 gtk_menu_bar_append(GTK_MENU_BAR(menu->menu), tmphandle); | |
1680 else | |
1681 gtk_menu_append(GTK_MENU(menu->menu), tmphandle); | |
1682 | |
1683 gtk_object_set_data(GTK_OBJECT(tmphandle), "id", (gpointer)id); | |
1684 free(tempbuf); | |
1685 DW_MUTEX_UNLOCK; | |
1686 return tmphandle; | |
1687 } | |
1688 | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1689 GtkWidget *_find_submenu_id(GtkWidget *start, char *name) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1690 { |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1691 GtkWidget *tmp; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1692 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
|
1693 |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1694 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
|
1695 return tmp; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1696 |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1697 for(z=0;z<submenucount;z++) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1698 { |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1699 char tempbuf[100]; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1700 GtkWidget *submenu, *menuitem; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1701 |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1702 sprintf(tempbuf, "submenu%d", z); |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1703 |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1704 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
|
1705 { |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1706 if((menuitem = _find_submenu_id(submenu, name))) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1707 return menuitem; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1708 } |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1709 } |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1710 return NULL; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1711 } |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1712 |
3 | 1713 /* |
1714 * Sets the state of a menu item check. | |
1715 * Parameters: | |
1716 * menu: The handle the the existing menu. | |
1717 * id: Menuitem id. | |
1718 * check: TRUE for checked FALSE for not checked. | |
1719 */ | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1720 void dw_menu_item_set_check(HMENUI menu, unsigned long id, int check) |
3 | 1721 { |
1722 char numbuf[10]; | |
1723 GtkWidget *tmphandle; | |
1724 int _locked_by_me = FALSE; | |
1725 | |
1726 if(!menu || !menu->menu) | |
1727 return; | |
1728 | |
1729 DW_MUTEX_LOCK; | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1730 sprintf(numbuf, "%lu", id); |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1731 tmphandle = _find_submenu_id(menu->menu, numbuf); |
3 | 1732 |
1733 if(tmphandle) | |
1734 { | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1735 _dw_ignore_click = 1; |
3 | 1736 if(GTK_CHECK_MENU_ITEM(tmphandle)->active != check) |
1737 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
|
1738 _dw_ignore_click = 0; |
3 | 1739 } |
1740 DW_MUTEX_UNLOCK; | |
1741 } | |
1742 | |
1743 /* | |
1744 * Pops up a context menu at given x and y coordinates. | |
1745 * Parameters: | |
1746 * menu: The handle the the existing menu. | |
1747 * parent: Handle to the window initiating the popup. | |
1748 * x: X coordinate. | |
1749 * y: Y coordinate. | |
1750 */ | |
1751 void dw_menu_popup(HMENUI *menu, HWND parent, int x, int y) | |
1752 { | |
1753 int _locked_by_me = FALSE; | |
1754 | |
1755 if(!menu || !*menu) | |
1756 return; | |
1757 | |
93
98cce029a611
Changed handling of menu item click events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
92
diff
changeset
|
1758 popup = parent; |
98cce029a611
Changed handling of menu item click events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
92
diff
changeset
|
1759 |
3 | 1760 DW_MUTEX_LOCK; |
1761 gtk_menu_popup(GTK_MENU((*menu)->menu), NULL, NULL, NULL, NULL, x, y); | |
1762 free(*menu); | |
1763 *menu = NULL; | |
1764 DW_MUTEX_UNLOCK; | |
1765 } | |
1766 | |
1767 | |
1768 /* | |
1769 * Returns the current X and Y coordinates of the mouse pointer. | |
1770 * Parameters: | |
1771 * x: Pointer to variable to store X coordinate. | |
1772 * y: Pointer to variable to store Y coordinate. | |
1773 */ | |
1774 void dw_pointer_query_pos(long *x, long *y) | |
1775 { | |
1776 GdkModifierType state; | |
1777 int gx, gy; | |
57
1ed95c8ec2ff
Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
55
diff
changeset
|
1778 int _locked_by_me = FALSE; |
1ed95c8ec2ff
Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
55
diff
changeset
|
1779 |
1ed95c8ec2ff
Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
55
diff
changeset
|
1780 DW_MUTEX_LOCK; |
3 | 1781 gdk_window_get_pointer (GDK_ROOT_PARENT(), &gx, &gy, &state); |
1782 *x = gx; | |
1783 *y = gy; | |
57
1ed95c8ec2ff
Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
55
diff
changeset
|
1784 DW_MUTEX_UNLOCK; |
3 | 1785 } |
1786 | |
1787 /* | |
1788 * Sets the X and Y coordinates of the mouse pointer. | |
1789 * Parameters: | |
1790 * x: X coordinate. | |
1791 * y: Y coordinate. | |
1792 */ | |
1793 void dw_pointer_set_pos(long x, long y) | |
1794 { | |
57
1ed95c8ec2ff
Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
55
diff
changeset
|
1795 int _locked_by_me = FALSE; |
1ed95c8ec2ff
Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
55
diff
changeset
|
1796 |
1ed95c8ec2ff
Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
55
diff
changeset
|
1797 DW_MUTEX_LOCK; |
3 | 1798 XWarpPointer(GDK_DISPLAY(), None, GDK_ROOT_WINDOW(), 0,0,0,0, x, y); |
57
1ed95c8ec2ff
Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
55
diff
changeset
|
1799 DW_MUTEX_UNLOCK; |
3 | 1800 } |
1801 | |
1802 /* | |
1803 * Create a container object to be packed. | |
1804 * Parameters: | |
1805 * id: An ID to be used for getting the resource from the | |
1806 * resource file. | |
1807 */ | |
1808 HWND dw_container_new(unsigned long id) | |
1809 { | |
1810 GtkWidget *tmp; | |
1811 int _locked_by_me = FALSE; | |
1812 | |
1813 DW_MUTEX_LOCK; | |
1814 tmp = gtk_scrolled_window_new (NULL, NULL); | |
1815 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (tmp), | |
1816 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
1817 | |
1818 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
1819 gtk_widget_show(tmp); | |
1820 | |
1821 DW_MUTEX_UNLOCK; | |
1822 return tmp; | |
1823 } | |
1824 | |
1825 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1826 * 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
|
1827 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1828 * 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
|
1829 * 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
|
1830 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1831 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
|
1832 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1833 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
|
1834 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
|
1835 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1836 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
|
1837 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
|
1838 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
|
1839 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
|
1840 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1841 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
|
1842 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
|
1843 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
|
1844 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
|
1845 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1846 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
|
1847 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
|
1848 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
|
1849 } |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1850 gtk_tree_set_view_mode(GTK_TREE(tree), GTK_TREE_VIEW_ITEM); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1851 gtk_tree_set_selection_mode(GTK_TREE(tree), GTK_SELECTION_SINGLE); |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1852 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
|
1853 /* 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
|
1854 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
|
1855 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1856 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
|
1857 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
|
1858 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1859 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
|
1860 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
|
1861 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1862 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1863 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1864 /* |
3 | 1865 * Create a new static text window (widget) to be packed. |
1866 * Parameters: | |
1867 * text: The text to be display by the static text widget. | |
1868 * id: An ID to be used with WinWindowFromID() or 0L. | |
1869 */ | |
1870 HWND dw_text_new(char *text, unsigned long id) | |
1871 { | |
1872 GtkWidget *tmp; | |
1873 int _locked_by_me = FALSE; | |
1874 | |
1875 DW_MUTEX_LOCK; | |
1876 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
|
1877 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1878 /* 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
|
1879 gtk_misc_set_alignment(GTK_MISC(tmp), 0.0f, 0.5f); |
3 | 1880 gtk_widget_show(tmp); |
1881 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
|
1882 gtk_misc_set_alignment(GTK_MISC(tmp), DW_LEFT, DW_LEFT); |
3 | 1883 DW_MUTEX_UNLOCK; |
1884 return tmp; | |
1885 } | |
1886 | |
1887 /* | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1888 * 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
|
1889 * Parameters: |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1890 * 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
|
1891 * 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
|
1892 */ |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1893 HWND dw_status_text_new(char *text, ULONG id) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1894 { |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1895 GtkWidget *tmp, *frame; |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1896 int _locked_by_me = FALSE; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1897 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1898 DW_MUTEX_LOCK; |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1899 frame = gtk_frame_new(NULL); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1900 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
|
1901 tmp = gtk_label_new(text); |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1902 gtk_container_add(GTK_CONTAINER(frame), tmp); |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1903 gtk_widget_show(tmp); |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1904 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
|
1905 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1906 /* 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
|
1907 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
|
1908 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
|
1909 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
|
1910 DW_MUTEX_UNLOCK; |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1911 return frame; |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1912 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1913 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1914 /* |
3 | 1915 * Create a new Multiline Editbox window (widget) to be packed. |
1916 * Parameters: | |
1917 * id: An ID to be used with WinWindowFromID() or 0L. | |
1918 */ | |
1919 HWND dw_mle_new(unsigned long id) | |
1920 { | |
1921 GtkWidget *tmp, *tmpbox, *scroller; | |
1922 int _locked_by_me = FALSE; | |
1923 | |
1924 DW_MUTEX_LOCK; | |
1925 tmpbox = gtk_hbox_new(FALSE, 0); | |
1926 tmp = gtk_text_new(NULL, NULL); | |
1927 gtk_text_set_word_wrap(GTK_TEXT(tmp), FALSE); | |
1928 gtk_text_set_line_wrap(GTK_TEXT(tmp), FALSE); | |
1929 scroller = gtk_vscrollbar_new(GTK_TEXT(tmp)->vadj); | |
1930 GTK_WIDGET_UNSET_FLAGS(scroller, GTK_CAN_FOCUS); | |
1931 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
1932 gtk_object_set_data(GTK_OBJECT(tmpbox), "mle", (gpointer)tmp); | |
1933 gtk_box_pack_start(GTK_BOX(tmpbox), tmp, TRUE, TRUE, 0); | |
1934 gtk_box_pack_start(GTK_BOX(tmpbox), scroller, FALSE, TRUE, 0); | |
1935 gtk_widget_show(tmp); | |
1936 gtk_widget_show(scroller); | |
1937 gtk_widget_show(tmpbox); | |
1938 DW_MUTEX_UNLOCK; | |
1939 return tmpbox; | |
1940 } | |
1941 | |
1942 /* | |
1943 * Create a new Entryfield window (widget) to be packed. | |
1944 * Parameters: | |
1945 * text: The default text to be in the entryfield widget. | |
1946 * id: An ID to be used with WinWindowFromID() or 0L. | |
1947 */ | |
1948 HWND dw_entryfield_new(char *text, unsigned long id) | |
1949 { | |
1950 GtkWidget *tmp; | |
1951 int _locked_by_me = FALSE; | |
1952 | |
1953 DW_MUTEX_LOCK; | |
1954 tmp = gtk_entry_new(); | |
1955 | |
1956 gtk_entry_set_text(GTK_ENTRY(tmp), text); | |
1957 | |
1958 gtk_widget_show(tmp); | |
1959 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
1960 | |
1961 DW_MUTEX_UNLOCK; | |
1962 return tmp; | |
1963 } | |
1964 | |
1965 /* | |
1966 * Create a new Entryfield (password) window (widget) to be packed. | |
1967 * Parameters: | |
1968 * text: The default text to be in the entryfield widget. | |
1969 * id: An ID to be used with WinWindowFromID() or 0L. | |
1970 */ | |
1971 HWND dw_entryfield_password_new(char *text, ULONG id) | |
1972 { | |
1973 GtkWidget *tmp; | |
1974 int _locked_by_me = FALSE; | |
1975 | |
1976 DW_MUTEX_LOCK; | |
1977 tmp = gtk_entry_new(); | |
1978 | |
1979 gtk_entry_set_visibility(GTK_ENTRY(tmp), FALSE); | |
1980 gtk_entry_set_text(GTK_ENTRY(tmp), text); | |
1981 | |
1982 gtk_widget_show(tmp); | |
1983 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
1984 | |
1985 DW_MUTEX_UNLOCK; | |
1986 return tmp; | |
1987 } | |
1988 | |
1989 /* | |
1990 * Create a new Combobox window (widget) to be packed. | |
1991 * Parameters: | |
1992 * text: The default text to be in the combpbox widget. | |
1993 * id: An ID to be used with WinWindowFromID() or 0L. | |
1994 */ | |
1995 HWND dw_combobox_new(char *text, unsigned long id) | |
1996 { | |
1997 GtkWidget *tmp; | |
1998 int _locked_by_me = FALSE; | |
1999 | |
2000 DW_MUTEX_LOCK; | |
2001 tmp = gtk_combo_new(); | |
2002 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(tmp)->entry), text); | |
2003 gtk_combo_set_use_arrows(GTK_COMBO(tmp), TRUE); | |
2004 gtk_object_set_user_data(GTK_OBJECT(tmp), NULL); | |
2005 gtk_widget_show(tmp); | |
2006 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
2007 DW_MUTEX_UNLOCK; | |
2008 return tmp; | |
2009 } | |
2010 | |
2011 /* | |
2012 * Create a new button window (widget) to be packed. | |
2013 * Parameters: | |
2014 * text: The text to be display by the static text widget. | |
2015 * id: An ID to be used with WinWindowFromID() or 0L. | |
2016 */ | |
2017 HWND dw_button_new(char *text, unsigned long id) | |
2018 { | |
2019 GtkWidget *tmp; | |
2020 int _locked_by_me = FALSE; | |
2021 | |
2022 DW_MUTEX_LOCK; | |
2023 tmp = gtk_button_new_with_label(text); | |
2024 gtk_widget_show(tmp); | |
2025 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
2026 DW_MUTEX_UNLOCK; | |
2027 return tmp; | |
2028 } | |
2029 | |
2030 /* | |
2031 * Create a new bitmap button window (widget) to be packed. | |
2032 * Parameters: | |
2033 * text: Bubble help text to be displayed. | |
2034 * id: An ID of a bitmap in the resource file. | |
2035 */ | |
2036 HWND dw_bitmapbutton_new(char *text, unsigned long id) | |
2037 { | |
2038 GtkWidget *tmp; | |
2039 GtkWidget *bitmap; | |
2040 GtkTooltips *tooltips; | |
2041 int _locked_by_me = FALSE; | |
2042 | |
2043 DW_MUTEX_LOCK; | |
2044 tmp = gtk_button_new(); | |
2045 bitmap = dw_bitmap_new(id); | |
2046 | |
2047 if(bitmap) | |
2048 { | |
2049 dw_window_set_bitmap(bitmap, id); | |
2050 gtk_container_add (GTK_CONTAINER(tmp), bitmap); | |
2051 } | |
2052 gtk_widget_show(tmp); | |
2053 if(text) | |
2054 { | |
2055 tooltips = gtk_tooltips_new(); | |
2056 gtk_tooltips_set_tip(tooltips, tmp, text, NULL); | |
2057 gtk_object_set_data(GTK_OBJECT(tmp), "tooltip", (gpointer)tooltips); | |
2058 } | |
2059 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
2060 DW_MUTEX_UNLOCK; | |
2061 return tmp; | |
2062 } | |
2063 | |
2064 /* | |
2065 * Create a new spinbutton window (widget) to be packed. | |
2066 * Parameters: | |
2067 * text: The text to be display by the static text widget. | |
2068 * id: An ID to be used with WinWindowFromID() or 0L. | |
2069 */ | |
2070 HWND dw_spinbutton_new(char *text, unsigned long id) | |
2071 { | |
2072 GtkAdjustment *adj; | |
2073 GtkWidget *tmp; | |
2074 int _locked_by_me = FALSE; | |
2075 | |
2076 DW_MUTEX_LOCK; | |
2077 adj = (GtkAdjustment *)gtk_adjustment_new (1.0, 0.0, 100.0, 1.0, 5.0, 0.0); | |
2078 tmp = gtk_spin_button_new (adj, 0, 0); | |
2079 gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(tmp), TRUE); | |
2080 gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(tmp), TRUE); | |
2081 gtk_widget_show(tmp); | |
2082 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
2083 DW_MUTEX_UNLOCK; | |
2084 return tmp; | |
2085 } | |
2086 | |
2087 /* | |
2088 * Create a new radiobutton window (widget) to be packed. | |
2089 * Parameters: | |
2090 * text: The text to be display by the static text widget. | |
2091 * id: An ID to be used with WinWindowFromID() or 0L. | |
2092 */ | |
2093 HWND dw_radiobutton_new(char *text, ULONG id) | |
2094 { | |
2095 /* This will have to be fixed in the future. */ | |
2096 GtkWidget *tmp; | |
2097 int _locked_by_me = FALSE; | |
2098 | |
2099 DW_MUTEX_LOCK; | |
2100 tmp = gtk_radio_button_new_with_label(NULL, text); | |
2101 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
2102 gtk_widget_show(tmp); | |
2103 | |
2104 DW_MUTEX_UNLOCK; | |
2105 return tmp; | |
2106 } | |
2107 | |
2108 /* | |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2109 * Create a new slider window (widget) to be packed. |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2110 * Parameters: |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2111 * vertical: TRUE or FALSE if slider is vertical. |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2112 * increments: Number of increments available. |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2113 * id: An ID to be used with WinWindowFromID() or 0L. |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2114 */ |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2115 HWND dw_slider_new(int vertical, int increments, ULONG id) |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2116 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2117 GtkWidget *tmp; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2118 GtkAdjustment *adjustment; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2119 int _locked_by_me = FALSE; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2120 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2121 DW_MUTEX_LOCK; |
67
ab9b0fa6c66e
Focus fixes and removal of several hack in the OS/2 code base.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
66
diff
changeset
|
2122 adjustment = (GtkAdjustment *)gtk_adjustment_new(0, 0, (gfloat)increments, 1, 1, 1); |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2123 if(vertical) |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2124 tmp = gtk_vscale_new(adjustment); |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2125 else |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2126 tmp = gtk_hscale_new(adjustment); |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2127 gtk_widget_show(tmp); |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2128 gtk_scale_set_draw_value(GTK_SCALE(tmp), 0); |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2129 gtk_scale_set_digits(GTK_SCALE(tmp), 0); |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2130 gtk_object_set_data(GTK_OBJECT(tmp), "adjustment", (gpointer)adjustment); |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2131 gtk_object_set_data(GTK_OBJECT(adjustment), "slider", (gpointer)tmp); |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2132 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2133 DW_MUTEX_UNLOCK; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2134 return tmp; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2135 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2136 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2137 /* |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
2138 * Create a new percent bar window (widget) to be packed. |
3 | 2139 * Parameters: |
2140 * id: An ID to be used with WinWindowFromID() or 0L. | |
2141 */ | |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
2142 HWND dw_percent_new(unsigned long id) |
3 | 2143 { |
2144 GtkWidget *tmp; | |
2145 int _locked_by_me = FALSE; | |
2146 | |
2147 DW_MUTEX_LOCK; | |
2148 tmp = gtk_progress_bar_new(); | |
2149 gtk_widget_show(tmp); | |
2150 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
2151 DW_MUTEX_UNLOCK; | |
2152 return tmp; | |
2153 } | |
2154 | |
2155 /* | |
2156 * Create a new checkbox window (widget) to be packed. | |
2157 * Parameters: | |
2158 * text: The text to be display by the static text widget. | |
2159 * id: An ID to be used with WinWindowFromID() or 0L. | |
2160 */ | |
2161 HWND dw_checkbox_new(char *text, unsigned long id) | |
2162 { | |
2163 GtkWidget *tmp; | |
2164 int _locked_by_me = FALSE; | |
2165 | |
2166 DW_MUTEX_LOCK; | |
2167 tmp = gtk_check_button_new_with_label(text); | |
2168 gtk_widget_show(tmp); | |
2169 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
2170 DW_MUTEX_UNLOCK; | |
2171 return tmp; | |
2172 } | |
2173 | |
2174 /* | |
2175 * Create a new listbox window (widget) to be packed. | |
2176 * Parameters: | |
2177 * id: An ID to be used with WinWindowFromID() or 0L. | |
2178 * multi: Multiple select TRUE or FALSE. | |
2179 */ | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2180 HWND dw_listbox_new(unsigned long id, int multi) |
3 | 2181 { |
2182 GtkWidget *tmp, *list; | |
2183 int _locked_by_me = FALSE; | |
2184 | |
2185 DW_MUTEX_LOCK; | |
2186 tmp = gtk_scrolled_window_new(NULL, NULL); | |
2187 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (tmp), | |
2188 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
2189 | |
2190 list = gtk_list_new(); | |
2191 gtk_list_set_selection_mode(GTK_LIST(list), multi ? GTK_SELECTION_MULTIPLE : GTK_SELECTION_SINGLE); | |
2192 | |
2193 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(tmp), | |
2194 list); | |
2195 gtk_object_set_user_data(GTK_OBJECT(tmp), list); | |
2196 gtk_widget_show(list); | |
2197 gtk_widget_show(tmp); | |
2198 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
2199 | |
2200 DW_MUTEX_UNLOCK; | |
2201 return tmp; | |
2202 } | |
2203 | |
2204 /* | |
2205 * Sets the icon used for a given window. | |
2206 * Parameters: | |
2207 * handle: Handle to the window. | |
2208 * id: An ID to be used to specify the icon. | |
2209 */ | |
2210 void dw_window_set_icon(HWND handle, unsigned long id) | |
2211 { | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2212 GdkBitmap *bitmap = NULL; |
3 | 2213 GdkPixmap *icon_pixmap; |
2214 int _locked_by_me = FALSE; | |
2215 | |
2216 DW_MUTEX_LOCK; | |
2217 icon_pixmap = _find_pixmap(&bitmap, id, handle); | |
2218 | |
2219 if(handle->window && icon_pixmap) | |
2220 gdk_window_set_icon(handle->window, NULL, icon_pixmap, bitmap); | |
2221 | |
2222 DW_MUTEX_UNLOCK; | |
2223 } | |
2224 | |
2225 /* | |
2226 * Sets the bitmap used for a given static window. | |
2227 * Parameters: | |
2228 * handle: Handle to the window. | |
2229 * id: An ID to be used to specify the icon. | |
2230 */ | |
2231 void dw_window_set_bitmap(HWND handle, unsigned long id) | |
2232 { | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2233 GdkBitmap *bitmap = NULL; |
3 | 2234 GdkPixmap *tmp; |
2235 int _locked_by_me = FALSE; | |
2236 | |
2237 DW_MUTEX_LOCK; | |
2238 tmp = _find_pixmap(&bitmap, id, handle); | |
2239 if(tmp) | |
2240 gtk_pixmap_set(GTK_PIXMAP(handle), tmp, bitmap); | |
2241 DW_MUTEX_UNLOCK; | |
2242 } | |
2243 | |
2244 /* | |
2245 * Sets the text used for a given window. | |
2246 * Parameters: | |
2247 * handle: Handle to the window. | |
2248 * text: The text associsated with a given window. | |
2249 */ | |
2250 void dw_window_set_text(HWND handle, char *text) | |
2251 { | |
2252 int _locked_by_me = FALSE; | |
2253 | |
2254 DW_MUTEX_LOCK; | |
2255 if(GTK_IS_ENTRY(handle)) | |
2256 gtk_entry_set_text(GTK_ENTRY(handle), text); | |
2257 else if(GTK_IS_COMBO(handle)) | |
2258 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(handle)->entry), text); | |
2259 else if(GTK_IS_LABEL(handle)) | |
2260 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
|
2261 else if(GTK_IS_FRAME(handle)) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2262 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2263 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
|
2264 if(tmp && GTK_IS_LABEL(tmp)) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2265 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
|
2266 } |
3 | 2267 DW_MUTEX_UNLOCK; |
2268 } | |
2269 | |
2270 /* | |
2271 * Gets the text used for a given window. | |
2272 * Parameters: | |
2273 * handle: Handle to the window. | |
2274 * Returns: | |
2275 * text: The text associsated with a given window. | |
2276 */ | |
2277 char *dw_window_get_text(HWND handle) | |
2278 { | |
2279 char *possible = ""; | |
2280 int _locked_by_me = FALSE; | |
2281 | |
2282 DW_MUTEX_LOCK; | |
2283 if(GTK_IS_ENTRY(handle)) | |
2284 possible = gtk_entry_get_text(GTK_ENTRY(handle)); | |
2285 else if(GTK_IS_COMBO(handle)) | |
2286 possible = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(handle)->entry)); | |
2287 | |
2288 DW_MUTEX_UNLOCK; | |
2289 return strdup(possible); | |
2290 } | |
2291 | |
2292 /* | |
2293 * Disables given window (widget). | |
2294 * Parameters: | |
2295 * handle: Handle to the window. | |
2296 */ | |
2297 void dw_window_disable(HWND handle) | |
2298 { | |
2299 int _locked_by_me = FALSE; | |
2300 | |
2301 DW_MUTEX_LOCK; | |
2302 gtk_widget_set_sensitive(handle, FALSE); | |
2303 DW_MUTEX_UNLOCK; | |
2304 } | |
2305 | |
2306 /* | |
2307 * Enables given window (widget). | |
2308 * Parameters: | |
2309 * handle: Handle to the window. | |
2310 */ | |
2311 void dw_window_enable(HWND handle) | |
2312 { | |
2313 int _locked_by_me = FALSE; | |
2314 | |
2315 DW_MUTEX_LOCK; | |
2316 gtk_widget_set_sensitive(handle, TRUE); | |
2317 DW_MUTEX_UNLOCK; | |
2318 } | |
2319 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2320 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
|
2321 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2322 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
|
2323 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2324 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
|
2325 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2326 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
|
2327 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2328 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
|
2329 x++; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2330 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2331 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2332 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
|
2333 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2334 |
3 | 2335 /* |
2336 * Adds text to an MLE box and returns the current point. | |
2337 * Parameters: | |
2338 * handle: Handle to the MLE to be queried. | |
2339 * buffer: Text buffer to be imported. | |
2340 * startpoint: Point to start entering text. | |
2341 */ | |
2342 unsigned int dw_mle_import(HWND handle, char *buffer, int startpoint) | |
2343 { | |
2344 unsigned int tmppoint = startpoint; | |
2345 int _locked_by_me = FALSE; | |
2346 | |
2347 DW_MUTEX_LOCK; | |
2348 if(GTK_IS_BOX(handle)) | |
2349 { | |
2350 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
|
2351 GdkFont *font = (GdkFont *)gtk_object_get_data(GTK_OBJECT(handle), "gdkfont"); |
3 | 2352 |
2353 if(tmp && GTK_IS_TEXT(tmp)) | |
2354 { | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2355 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
|
2356 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
|
2357 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
|
2358 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2359 _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
|
2360 |
3 | 2361 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
|
2362 gtk_text_insert(GTK_TEXT(tmp), font, fore, back, impbuf, -1); |
3 | 2363 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
|
2364 free(impbuf); |
3 | 2365 } |
2366 } | |
2367 DW_MUTEX_UNLOCK; | |
2368 return tmppoint; | |
2369 } | |
2370 | |
2371 /* | |
2372 * Grabs text from an MLE box. | |
2373 * Parameters: | |
2374 * handle: Handle to the MLE to be queried. | |
2375 * buffer: Text buffer to be exported. | |
2376 * startpoint: Point to start grabbing text. | |
2377 * length: Amount of text to be grabbed. | |
2378 */ | |
2379 void dw_mle_export(HWND handle, char *buffer, int startpoint, int length) | |
2380 { | |
2381 int _locked_by_me = FALSE; | |
2382 gchar *text; | |
2383 | |
2384 DW_MUTEX_LOCK; | |
2385 if(GTK_IS_BOX(handle)) | |
2386 { | |
2387 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); | |
2388 | |
2389 if(tmp && GTK_IS_TEXT(tmp)) | |
2390 { | |
2391 text = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), startpoint, startpoint + length); | |
2392 if(text) | |
2393 { | |
2394 strcpy(buffer, text); | |
2395 g_free(text); | |
2396 } | |
2397 } | |
2398 } | |
2399 DW_MUTEX_UNLOCK; | |
2400 } | |
2401 | |
2402 /* | |
2403 * Obtains information about an MLE box. | |
2404 * Parameters: | |
2405 * handle: Handle to the MLE to be queried. | |
2406 * bytes: A pointer to a variable to return the total bytes. | |
2407 * lines: A pointer to a variable to return the number of lines. | |
2408 */ | |
2409 void dw_mle_query(HWND handle, unsigned long *bytes, unsigned long *lines) | |
2410 { | |
2411 int _locked_by_me = FALSE; | |
2412 | |
2413 if(bytes) | |
2414 *bytes = 0; | |
2415 if(lines) | |
2416 *lines = 0; | |
2417 | |
2418 DW_MUTEX_LOCK; | |
2419 if(GTK_IS_BOX(handle)) | |
2420 { | |
2421 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); | |
2422 | |
2423 if(tmp && GTK_IS_TEXT(tmp)) | |
2424 { | |
2425 if(bytes) | |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
2426 *bytes = gtk_text_get_length(GTK_TEXT(tmp)) + 1; |
3 | 2427 if(lines) |
2428 { | |
2429 gchar *text; | |
2430 | |
2431 *lines = 0; | |
2432 text = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), 0, bytes ? *bytes : gtk_text_get_length(GTK_TEXT(tmp))); | |
2433 | |
2434 if(text) | |
2435 { | |
2436 int z, len = strlen(text); | |
2437 | |
2438 for(z=0;z<len;z++) | |
2439 { | |
2440 if(text[z] == '\n') | |
2441 (*lines)++; | |
2442 } | |
2443 g_free(text); | |
2444 } | |
2445 } | |
2446 } | |
2447 } | |
2448 DW_MUTEX_UNLOCK; | |
2449 } | |
2450 | |
2451 /* | |
2452 * Deletes text from an MLE box. | |
2453 * Parameters: | |
2454 * handle: Handle to the MLE to be deleted from. | |
2455 * startpoint: Point to start deleting text. | |
2456 * length: Amount of text to be deleted. | |
2457 */ | |
2458 void dw_mle_delete(HWND handle, int startpoint, int length) | |
2459 { | |
2460 int _locked_by_me = FALSE; | |
2461 | |
2462 DW_MUTEX_LOCK; | |
2463 if(GTK_IS_BOX(handle)) | |
2464 { | |
2465 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); | |
2466 | |
2467 if(tmp && GTK_IS_TEXT(tmp)) | |
2468 { | |
2469 gtk_text_set_point(GTK_TEXT(tmp), startpoint); | |
2470 gtk_text_forward_delete(GTK_TEXT(tmp), length); | |
2471 } | |
2472 } | |
2473 DW_MUTEX_UNLOCK; | |
2474 } | |
2475 | |
2476 /* | |
2477 * Clears all text from an MLE box. | |
2478 * Parameters: | |
2479 * handle: Handle to the MLE to be cleared. | |
2480 */ | |
2481 void dw_mle_clear(HWND handle) | |
2482 { | |
2483 int length, _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 length = gtk_text_get_length(GTK_TEXT(tmp)); | |
2493 gtk_text_set_point(GTK_TEXT(tmp), 0); | |
2494 gtk_text_forward_delete(GTK_TEXT(tmp), length); | |
2495 } | |
2496 } | |
2497 DW_MUTEX_UNLOCK; | |
2498 } | |
2499 | |
2500 /* | |
2501 * Sets the visible line of an MLE box. | |
2502 * Parameters: | |
2503 * handle: Handle to the MLE. | |
2504 * line: Line to be visible. | |
2505 */ | |
2506 void dw_mle_set_visible(HWND handle, int line) | |
2507 { | |
2508 int _locked_by_me = FALSE; | |
2509 | |
2510 DW_MUTEX_LOCK; | |
2511 if(GTK_IS_BOX(handle)) | |
2512 { | |
2513 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); | |
2514 | |
2515 if(tmp && GTK_IS_TEXT(tmp)) | |
2516 { | |
2517 unsigned long lines; | |
2518 float pos, ratio; | |
2519 | |
2520 dw_mle_query(handle, NULL, &lines); | |
2521 | |
2522 if(lines) | |
2523 { | |
2524 ratio = (float)line/(float)lines; | |
2525 | |
2526 pos = (ratio * (float)(GTK_TEXT(tmp)->vadj->upper - GTK_TEXT(tmp)->vadj->lower)) + GTK_TEXT(tmp)->vadj->lower; | |
2527 | |
2528 gtk_adjustment_set_value(GTK_TEXT(tmp)->vadj, pos); | |
2529 } | |
2530 } | |
2531 } | |
2532 DW_MUTEX_UNLOCK; | |
2533 } | |
2534 | |
2535 /* | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2536 * Sets the editablity of an MLE box. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2537 * Parameters: |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2538 * handle: Handle to the MLE. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2539 * 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
|
2540 */ |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2541 void dw_mle_set_editable(HWND handle, int state) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2542 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2543 int _locked_by_me = FALSE; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2544 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2545 DW_MUTEX_LOCK; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2546 if(GTK_IS_BOX(handle)) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2547 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2548 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
|
2549 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2550 if(tmp && GTK_IS_TEXT(tmp)) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2551 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2552 gtk_text_set_editable(GTK_TEXT(tmp), state); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2553 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2554 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2555 DW_MUTEX_UNLOCK; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2556 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2557 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2558 /* |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2559 * Sets the word wrap state of an MLE box. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2560 * Parameters: |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2561 * handle: Handle to the MLE. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2562 * 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
|
2563 */ |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2564 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
|
2565 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2566 int _locked_by_me = FALSE; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2567 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2568 DW_MUTEX_LOCK; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2569 if(GTK_IS_BOX(handle)) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2570 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2571 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
|
2572 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2573 if(tmp && GTK_IS_TEXT(tmp)) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2574 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2575 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
|
2576 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
|
2577 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2578 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2579 DW_MUTEX_UNLOCK; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2580 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2581 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2582 /* |
3 | 2583 * Sets the current cursor position of an MLE box. |
2584 * Parameters: | |
2585 * handle: Handle to the MLE to be positioned. | |
2586 * point: Point to position cursor. | |
2587 */ | |
2588 void dw_mle_set(HWND handle, int point) | |
2589 { | |
2590 int _locked_by_me = FALSE; | |
2591 | |
2592 DW_MUTEX_LOCK; | |
2593 if(GTK_IS_BOX(handle)) | |
2594 { | |
2595 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); | |
2596 | |
2597 if(tmp && GTK_IS_TEXT(tmp)) | |
2598 { | |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
2599 unsigned long chars; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
2600 float pos, ratio; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
2601 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
2602 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
|
2603 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
2604 if(chars) |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
2605 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
2606 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
|
2607 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
2608 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
|
2609 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
2610 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
|
2611 } |
3 | 2612 gtk_text_set_point(GTK_TEXT(tmp), point); |
2613 } | |
2614 } | |
2615 DW_MUTEX_UNLOCK; | |
2616 } | |
2617 | |
2618 /* | |
2619 * Finds text in an MLE box. | |
2620 * Parameters: | |
2621 * handle: Handle to the MLE to be cleared. | |
2622 * text: Text to search for. | |
2623 * point: Start point of search. | |
2624 * flags: Search specific flags. | |
2625 */ | |
2626 int dw_mle_search(HWND handle, char *text, int point, unsigned long flags) | |
2627 { | |
2628 int _locked_by_me = FALSE, retval = 0; | |
2629 | |
2630 DW_MUTEX_LOCK; | |
2631 if(GTK_IS_BOX(handle)) | |
2632 { | |
2633 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); | |
2634 | |
2635 if(tmp && GTK_IS_TEXT(tmp)) | |
2636 { | |
2637 int len = gtk_text_get_length(GTK_TEXT(tmp)); | |
2638 gchar *tmpbuf; | |
2639 | |
2640 tmpbuf = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), 0, len); | |
2641 if(tmpbuf) | |
2642 { | |
2643 int z, textlen; | |
2644 | |
2645 textlen = strlen(text); | |
2646 | |
2647 if(flags & DW_MLE_CASESENSITIVE) | |
2648 { | |
2649 for(z=point;z<(len-textlen) && !retval;z++) | |
2650 { | |
2651 if(strncmp(&tmpbuf[z], text, textlen) == 0) | |
2652 retval = z + textlen; | |
2653 } | |
2654 } | |
2655 else | |
2656 { | |
2657 for(z=point;z<(len-textlen) && !retval;z++) | |
2658 { | |
2659 if(strncasecmp(&tmpbuf[z], text, textlen) == 0) | |
2660 retval = z + textlen; | |
2661 } | |
2662 } | |
2663 | |
2664 if(retval) | |
2665 { | |
2666 gtk_text_set_point(GTK_TEXT(tmp), retval - textlen); | |
2667 gtk_editable_select_region(&(GTK_TEXT(tmp)->editable), retval - textlen, retval); | |
2668 } | |
2669 | |
2670 g_free(tmpbuf); | |
2671 } | |
2672 } | |
2673 } | |
2674 | |
2675 DW_MUTEX_UNLOCK; | |
2676 return retval; | |
2677 } | |
2678 | |
2679 /* | |
2680 * Stops redrawing of an MLE box. | |
2681 * Parameters: | |
2682 * handle: Handle to the MLE to freeze. | |
2683 */ | |
2684 void dw_mle_freeze(HWND handle) | |
2685 { | |
2686 int _locked_by_me = FALSE; | |
2687 | |
2688 DW_MUTEX_LOCK; | |
2689 if(GTK_IS_BOX(handle)) | |
2690 { | |
2691 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); | |
2692 | |
2693 if(tmp && GTK_IS_TEXT(tmp)) | |
2694 { | |
2695 gtk_text_freeze(GTK_TEXT(tmp)); | |
2696 } | |
2697 } | |
2698 DW_MUTEX_UNLOCK; | |
2699 } | |
2700 | |
2701 /* | |
2702 * Resumes redrawing of an MLE box. | |
2703 * Parameters: | |
2704 * handle: Handle to the MLE to thaw. | |
2705 */ | |
2706 void dw_mle_thaw(HWND handle) | |
2707 { | |
2708 int _locked_by_me = FALSE; | |
2709 | |
2710 DW_MUTEX_LOCK; | |
2711 if(GTK_IS_BOX(handle)) | |
2712 { | |
2713 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); | |
2714 | |
2715 if(tmp && GTK_IS_TEXT(tmp)) | |
2716 { | |
2717 gtk_text_thaw(GTK_TEXT(tmp)); | |
2718 } | |
2719 } | |
2720 DW_MUTEX_UNLOCK; | |
2721 } | |
2722 | |
2723 /* | |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
2724 * Returns the range of the percent bar. |
3 | 2725 * Parameters: |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2726 * handle: Handle to the percent bar to be queried. |
3 | 2727 */ |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
2728 unsigned int dw_percent_query_range(HWND handle) |
3 | 2729 { |
2730 return 100; | |
2731 } | |
2732 | |
2733 /* | |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
2734 * Sets the percent bar position. |
3 | 2735 * Parameters: |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2736 * handle: Handle to the percent bar to be set. |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2737 * position: Position of the percent bar withing the range. |
3 | 2738 */ |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
2739 void dw_percent_set_pos(HWND handle, unsigned int position) |
3 | 2740 { |
2741 int _locked_by_me = FALSE; | |
2742 | |
2743 DW_MUTEX_LOCK; | |
2744 gtk_progress_bar_update(GTK_PROGRESS_BAR(handle), (gfloat)position/100); | |
2745 DW_MUTEX_UNLOCK; | |
2746 } | |
2747 | |
2748 /* | |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2749 * Returns the position of the slider. |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2750 * Parameters: |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2751 * handle: Handle to the slider to be queried. |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2752 */ |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2753 unsigned int dw_slider_query_pos(HWND handle) |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2754 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2755 int val = 0, _locked_by_me = FALSE; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2756 GtkAdjustment *adjustment; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2757 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2758 if(!handle) |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2759 return 0; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2760 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2761 DW_MUTEX_LOCK; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2762 adjustment = (GtkAdjustment *)gtk_object_get_data(GTK_OBJECT(handle), "adjustment"); |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2763 if(adjustment) |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2764 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2765 int max = _round_value(adjustment->upper) - 1; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2766 int thisval = _round_value(adjustment->value); |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2767 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2768 if(GTK_IS_VSCALE(handle)) |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2769 val = max - thisval; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2770 else |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2771 val = thisval; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2772 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2773 DW_MUTEX_UNLOCK; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2774 return val; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2775 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2776 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2777 /* |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2778 * Sets the slider position. |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2779 * Parameters: |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2780 * handle: Handle to the slider to be set. |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2781 * position: Position of the slider withing the range. |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2782 */ |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2783 void dw_slider_set_pos(HWND handle, unsigned int position) |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2784 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2785 int _locked_by_me = FALSE; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2786 GtkAdjustment *adjustment; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2787 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2788 if(!handle) |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2789 return; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2790 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2791 DW_MUTEX_LOCK; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2792 adjustment = (GtkAdjustment *)gtk_object_get_data(GTK_OBJECT(handle), "adjustment"); |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2793 if(adjustment) |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2794 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2795 int max = _round_value(adjustment->upper) - 1; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2796 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2797 if(GTK_IS_VSCALE(handle)) |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2798 gtk_adjustment_set_value(adjustment, (gfloat)(max - position)); |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2799 else |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2800 gtk_adjustment_set_value(adjustment, (gfloat)position); |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2801 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2802 DW_MUTEX_UNLOCK; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2803 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2804 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2805 /* |
3 | 2806 * Sets the spinbutton value. |
2807 * Parameters: | |
2808 * handle: Handle to the spinbutton to be set. | |
2809 * position: Current value of the spinbutton. | |
2810 */ | |
2811 void dw_spinbutton_set_pos(HWND handle, long position) | |
2812 { | |
2813 int _locked_by_me = FALSE; | |
2814 | |
2815 DW_MUTEX_LOCK; | |
2816 gtk_spin_button_set_value(GTK_SPIN_BUTTON(handle), (gfloat)position); | |
2817 DW_MUTEX_UNLOCK; | |
2818 } | |
2819 | |
2820 /* | |
2821 * Sets the spinbutton limits. | |
2822 * Parameters: | |
2823 * handle: Handle to the spinbutton to be set. | |
2824 * position: Current value of the spinbutton. | |
2825 * position: Current value of the spinbutton. | |
2826 */ | |
2827 void dw_spinbutton_set_limits(HWND handle, long upper, long lower) | |
2828 { | |
2829 long curval; | |
2830 GtkAdjustment *adj; | |
2831 int _locked_by_me = FALSE; | |
2832 | |
2833 curval = dw_spinbutton_query(handle); | |
2834 DW_MUTEX_LOCK; | |
2835 adj = (GtkAdjustment *)gtk_adjustment_new((gfloat)curval, (gfloat)lower, (gfloat)upper, 1.0, 5.0, 0.0); | |
2836 DW_MUTEX_UNLOCK; | |
2837 } | |
2838 | |
2839 /* | |
2840 * Sets the entryfield character limit. | |
2841 * Parameters: | |
2842 * handle: Handle to the spinbutton to be set. | |
2843 * limit: Number of characters the entryfield will take. | |
2844 */ | |
2845 void dw_entryfield_set_limit(HWND handle, ULONG limit) | |
2846 { | |
2847 /* TODO: can this be done after the fact? */ | |
2848 } | |
2849 | |
2850 /* | |
2851 * Returns the current value of the spinbutton. | |
2852 * Parameters: | |
2853 * handle: Handle to the spinbutton to be queried. | |
2854 */ | |
2855 long dw_spinbutton_query(HWND handle) | |
2856 { | |
2857 long retval; | |
2858 int _locked_by_me = FALSE; | |
2859 | |
2860 DW_MUTEX_LOCK; | |
2861 retval = (long)gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(handle)); | |
2862 DW_MUTEX_UNLOCK; | |
2863 | |
2864 return retval; | |
2865 } | |
2866 | |
2867 /* | |
2868 * Returns the state of the checkbox. | |
2869 * Parameters: | |
2870 * handle: Handle to the checkbox to be queried. | |
2871 */ | |
2872 int dw_checkbox_query(HWND handle) | |
2873 { | |
2874 int retval; | |
2875 int _locked_by_me = FALSE; | |
2876 | |
2877 DW_MUTEX_LOCK; | |
2878 retval = GTK_TOGGLE_BUTTON(handle)->active; | |
2879 DW_MUTEX_UNLOCK; | |
2880 | |
2881 return retval; | |
2882 } | |
2883 | |
2884 /* | |
2885 * Sets the state of the checkbox. | |
2886 * Parameters: | |
2887 * handle: Handle to the checkbox to be queried. | |
2888 * value: TRUE for checked, FALSE for unchecked. | |
2889 */ | |
2890 void dw_checkbox_set(HWND handle, int value) | |
2891 { | |
2892 int _locked_by_me = FALSE; | |
2893 | |
2894 DW_MUTEX_LOCK; | |
2895 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(handle), value); | |
2896 DW_MUTEX_UNLOCK; | |
2897 } | |
2898 | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2899 /* |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2900 * Inserts an item into a tree window (widget) after another item. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2901 * Parameters: |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2902 * handle: Handle to the tree to be inserted. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2903 * item: Handle to the item to be positioned after. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2904 * title: The text title of the entry. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2905 * icon: Handle to coresponding icon. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2906 * parent: Parent handle or 0 if root. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2907 * itemdata: Item specific data. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2908 */ |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2909 HWND dw_tree_insert_after(HWND handle, HWND item, char *title, unsigned long icon, HWND parent, void *itemdata) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2910 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2911 GtkWidget *newitem, *tree, *subtree, *label, *hbox, *pixmap; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2912 GdkPixmap *gdkpix; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2913 GdkBitmap *gdkbmp = NULL; |
107
cd0e5cf92f6a
Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
96
diff
changeset
|
2914 int position = -1; |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2915 int _locked_by_me = FALSE; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2916 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2917 if(!handle) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2918 return NULL; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2919 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2920 DW_MUTEX_LOCK; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2921 tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2922 if(!tree || !GTK_IS_TREE(tree)) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2923 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2924 DW_MUTEX_UNLOCK; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2925 return NULL; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2926 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2927 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2928 if(item && GTK_IS_TREE_ITEM(item)) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2929 position = gtk_tree_child_position(GTK_TREE(tree), item); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2930 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2931 position++; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2932 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2933 newitem = gtk_tree_item_new(); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2934 label = gtk_label_new(title); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2935 gtk_object_set_data(GTK_OBJECT(newitem), "text", (gpointer)strdup(title)); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2936 gtk_object_set_data(GTK_OBJECT(newitem), "itemdata", (gpointer)itemdata); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2937 gtk_object_set_data(GTK_OBJECT(newitem), "tree", (gpointer)tree); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2938 hbox = gtk_hbox_new(FALSE, 2); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2939 gtk_object_set_data(GTK_OBJECT(newitem), "hbox", (gpointer)hbox); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2940 gdkpix = _find_pixmap(&gdkbmp, icon, hbox); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2941 pixmap = gtk_pixmap_new(gdkpix, gdkbmp); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2942 gtk_container_add(GTK_CONTAINER(newitem), hbox); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2943 gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, TRUE, 0); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2944 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, TRUE, 0); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2945 gtk_widget_show(label); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2946 gtk_widget_show(pixmap); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2947 gtk_widget_show(hbox); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2948 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2949 if(parent) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2950 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2951 subtree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(parent)); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2952 if(!subtree) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2953 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2954 void *thisfunc = (void *)gtk_object_get_data(GTK_OBJECT(tree), "select-child-func"); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2955 void *work = (void *)gtk_object_get_data(GTK_OBJECT(tree), "select-child-data"); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2956 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2957 subtree = gtk_tree_new(); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2958 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2959 if(thisfunc && work) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2960 gtk_signal_connect(GTK_OBJECT(subtree), "select-child", GTK_SIGNAL_FUNC(thisfunc), work); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2961 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2962 thisfunc = (void *)gtk_object_get_data(GTK_OBJECT(tree), "container-context-func"); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2963 work = (void *)gtk_object_get_data(GTK_OBJECT(tree), "container-context-data"); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2964 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2965 if(thisfunc && work) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2966 gtk_signal_connect(GTK_OBJECT(subtree), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), work); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2967 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2968 gtk_object_set_user_data(GTK_OBJECT(parent), subtree); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2969 gtk_tree_set_selection_mode(GTK_TREE(subtree), GTK_SELECTION_SINGLE); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2970 gtk_tree_set_view_mode(GTK_TREE(subtree), GTK_TREE_VIEW_ITEM); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2971 gtk_tree_item_set_subtree(GTK_TREE_ITEM(parent), subtree); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2972 gtk_tree_item_collapse(GTK_TREE_ITEM(parent)); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2973 gtk_widget_show(subtree); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2974 gtk_tree_item_expand(GTK_TREE_ITEM(parent)); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2975 gtk_tree_item_collapse(GTK_TREE_ITEM(parent)); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2976 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2977 gtk_object_set_data(GTK_OBJECT(newitem), "parenttree", (gpointer)subtree); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2978 gtk_tree_insert(GTK_TREE(subtree), newitem, position); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2979 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2980 else |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2981 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2982 gtk_object_set_data(GTK_OBJECT(newitem), "parenttree", (gpointer)tree); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2983 gtk_tree_insert(GTK_TREE(tree), newitem, position); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2984 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2985 gtk_tree_item_expand(GTK_TREE_ITEM(newitem)); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2986 gtk_tree_item_collapse(GTK_TREE_ITEM(newitem)); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2987 gtk_widget_show(newitem); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2988 DW_MUTEX_UNLOCK; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2989 return newitem; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2990 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2991 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2992 /* |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2993 * 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
|
2994 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2995 * 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
|
2996 * 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
|
2997 * 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
|
2998 * parent: Parent handle or 0 if root. |
54
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
2999 * itemdata: Item specific data. |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3000 */ |
54
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3001 HWND dw_tree_insert(HWND handle, char *title, unsigned long icon, HWND parent, void *itemdata) |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3002 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3003 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
|
3004 GdkPixmap *gdkpix; |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3005 GdkBitmap *gdkbmp = NULL; |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3006 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
|
3007 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3008 if(!handle) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3009 return NULL; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3010 |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3011 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
|
3012 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
|
3013 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
|
3014 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3015 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
|
3016 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
|
3017 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3018 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
|
3019 label = gtk_label_new(title); |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3020 gtk_object_set_data(GTK_OBJECT(item), "text", (gpointer)strdup(title)); |
54
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3021 gtk_object_set_data(GTK_OBJECT(item), "itemdata", (gpointer)itemdata); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3022 gtk_object_set_data(GTK_OBJECT(item), "tree", (gpointer)tree); |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3023 hbox = gtk_hbox_new(FALSE, 2); |
54
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3024 gtk_object_set_data(GTK_OBJECT(item), "hbox", (gpointer)hbox); |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3025 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
|
3026 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
|
3027 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
|
3028 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
|
3029 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
|
3030 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
|
3031 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
|
3032 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
|
3033 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3034 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
|
3035 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3036 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
|
3037 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
|
3038 { |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3039 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
|
3040 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
|
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 subtree = gtk_tree_new(); |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3043 |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3044 if(thisfunc && work) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3045 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
|
3046 |
54
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3047 thisfunc = (void *)gtk_object_get_data(GTK_OBJECT(tree), "container-context-func"); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3048 work = (void *)gtk_object_get_data(GTK_OBJECT(tree), "container-context-data"); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3049 |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3050 if(thisfunc && work) |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3051 gtk_signal_connect(GTK_OBJECT(subtree), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), work); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3052 |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3053 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
|
3054 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
|
3055 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
|
3056 gtk_tree_item_set_subtree(GTK_TREE_ITEM(parent), subtree); |
54
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3057 gtk_tree_item_collapse(GTK_TREE_ITEM(parent)); |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3058 gtk_widget_show(subtree); |
54
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3059 gtk_tree_item_expand(GTK_TREE_ITEM(parent)); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3060 gtk_tree_item_collapse(GTK_TREE_ITEM(parent)); |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3061 } |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3062 gtk_object_set_data(GTK_OBJECT(item), "parenttree", (gpointer)subtree); |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3063 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
|
3064 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3065 else |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3066 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3067 gtk_object_set_data(GTK_OBJECT(item), "parenttree", (gpointer)tree); |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3068 gtk_tree_append(GTK_TREE(tree), item); |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3069 } |
54
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3070 gtk_tree_item_expand(GTK_TREE_ITEM(item)); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3071 gtk_tree_item_collapse(GTK_TREE_ITEM(item)); |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3072 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
|
3073 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
|
3074 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
|
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 |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3077 /* |
54
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3078 * Sets the text and icon of an item in a tree window (widget). |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3079 * Parameters: |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3080 * handle: Handle to the tree containing the item. |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3081 * item: Handle of the item to be modified. |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3082 * title: The text title of the entry. |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3083 * icon: Handle to coresponding icon. |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3084 */ |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3085 void dw_tree_set(HWND handle, HWND item, char *title, unsigned long icon) |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3086 { |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3087 GtkWidget *label, *hbox, *pixmap; |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3088 GdkPixmap *gdkpix; |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3089 GdkBitmap *gdkbmp = NULL; |
54
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3090 char *oldtext; |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3091 int _locked_by_me = FALSE; |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3092 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3093 if(!handle || !item) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3094 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3095 |
54
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3096 DW_MUTEX_LOCK; |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3097 oldtext = (char *)gtk_object_get_data(GTK_OBJECT(item), "text"); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3098 if(oldtext) |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3099 free(oldtext); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3100 label = gtk_label_new(title); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3101 gtk_object_set_data(GTK_OBJECT(item), "text", (gpointer)strdup(title)); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3102 hbox = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "hbox"); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3103 gtk_widget_destroy(hbox); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3104 hbox = gtk_hbox_new(FALSE, 2); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3105 gtk_object_set_data(GTK_OBJECT(item), "hbox", (gpointer)hbox); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3106 gdkpix = _find_pixmap(&gdkbmp, icon, hbox); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3107 pixmap = gtk_pixmap_new(gdkpix, gdkbmp); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3108 gtk_container_add(GTK_CONTAINER(item), hbox); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3109 gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, TRUE, 0); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3110 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, TRUE, 0); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3111 gtk_widget_show(label); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3112 gtk_widget_show(pixmap); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3113 gtk_widget_show(hbox); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3114 DW_MUTEX_UNLOCK; |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3115 } |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3116 |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3117 /* |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3118 * Sets the item data of a tree item. |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3119 * Parameters: |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3120 * handle: Handle to the tree containing the item. |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3121 * item: Handle of the item to be modified. |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3122 * itemdata: User defined data to be associated with item. |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3123 */ |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3124 void dw_tree_set_data(HWND handle, HWND item, void *itemdata) |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3125 { |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3126 int _locked_by_me = FALSE; |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3127 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3128 if(!handle || !item) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3129 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3130 |
54
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3131 DW_MUTEX_LOCK; |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3132 gtk_object_set_data(GTK_OBJECT(item), "itemdata", (gpointer)itemdata); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3133 DW_MUTEX_UNLOCK; |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3134 } |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3135 |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3136 /* |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3137 * Sets this item as the active selection. |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3138 * Parameters: |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3139 * handle: Handle to the tree window (widget) to be selected. |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3140 * item: Handle to the item to be selected. |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3141 */ |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3142 void dw_tree_item_select(HWND handle, HWND item) |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3143 { |
107
cd0e5cf92f6a
Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
96
diff
changeset
|
3144 GtkWidget *lastselect, *tree; |
54
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3145 int _locked_by_me = FALSE; |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3146 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3147 if(!handle || !item) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3148 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3149 |
54
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3150 DW_MUTEX_LOCK; |
107
cd0e5cf92f6a
Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
96
diff
changeset
|
3151 tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
cd0e5cf92f6a
Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
96
diff
changeset
|
3152 lastselect = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(tree), "lastselect"); |
54
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3153 if(lastselect && GTK_IS_TREE_ITEM(lastselect)) |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3154 gtk_tree_item_deselect(GTK_TREE_ITEM(lastselect)); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3155 gtk_tree_item_select(GTK_TREE_ITEM(item)); |
107
cd0e5cf92f6a
Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
96
diff
changeset
|
3156 gtk_object_set_data(GTK_OBJECT(tree), "lastselect", (gpointer)item); |
54
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3157 DW_MUTEX_UNLOCK; |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3158 } |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3159 |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3160 /* |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3161 * Removes all nodes from a tree. |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3162 * Parameters: |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3163 * 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
|
3164 */ |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3165 void dw_tree_clear(HWND handle) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3166 { |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3167 GtkWidget *tree; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3168 int _locked_by_me = FALSE; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3169 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3170 if(!handle) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3171 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3172 |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3173 DW_MUTEX_LOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3174 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
|
3175 if(!tree || !GTK_IS_TREE(tree)) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3176 { |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3177 DW_MUTEX_UNLOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3178 return; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3179 } |
107
cd0e5cf92f6a
Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
96
diff
changeset
|
3180 gtk_object_set_data(GTK_OBJECT(tree), "lastselect", NULL); |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3181 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
|
3182 DW_MUTEX_UNLOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3183 } |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3184 |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3185 /* |
54
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3186 * Expands a node on a tree. |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3187 * Parameters: |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3188 * handle: Handle to the tree window (widget). |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3189 * item: Handle to node to be expanded. |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3190 */ |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3191 void dw_tree_expand(HWND handle, HWND item) |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3192 { |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3193 int _locked_by_me = FALSE; |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3194 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3195 if(!handle || !item) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3196 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3197 |
54
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3198 DW_MUTEX_LOCK; |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3199 if(GTK_IS_TREE_ITEM(item)) |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3200 gtk_tree_item_expand(GTK_TREE_ITEM(item)); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3201 DW_MUTEX_UNLOCK; |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3202 } |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3203 |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3204 /* |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3205 * Collapses a node on a tree. |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3206 * Parameters: |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3207 * handle: Handle to the tree window (widget). |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3208 * item: Handle to node to be collapsed. |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3209 */ |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3210 void dw_tree_collapse(HWND handle, HWND item) |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3211 { |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3212 int _locked_by_me = FALSE; |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3213 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3214 if(!handle || !item) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3215 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3216 |
54
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3217 DW_MUTEX_LOCK; |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3218 if(GTK_IS_TREE_ITEM(item)) |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3219 gtk_tree_item_collapse(GTK_TREE_ITEM(item)); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3220 DW_MUTEX_UNLOCK; |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3221 } |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3222 |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3223 /* |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3224 * Removes a node from a tree. |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3225 * Parameters: |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3226 * 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
|
3227 * item: Handle to node to be deleted. |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3228 */ |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3229 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
|
3230 { |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3231 GtkWidget *tree, *lastselect, *parenttree; |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3232 int _locked_by_me = FALSE; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3233 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3234 if(!handle || !item || !GTK_IS_WIDGET(handle) || !GTK_IS_WIDGET(item)) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3235 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3236 |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3237 DW_MUTEX_LOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3238 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
|
3239 if(!tree || !GTK_IS_TREE(tree)) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3240 { |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3241 DW_MUTEX_UNLOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3242 return; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3243 } |
54
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3244 |
107
cd0e5cf92f6a
Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
96
diff
changeset
|
3245 lastselect = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(tree), "lastselect"); |
cd0e5cf92f6a
Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
96
diff
changeset
|
3246 |
cd0e5cf92f6a
Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
96
diff
changeset
|
3247 parenttree = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "parenttree"); |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3248 |
54
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3249 if(lastselect == item) |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3250 { |
107
cd0e5cf92f6a
Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
96
diff
changeset
|
3251 gtk_tree_item_deselect(GTK_TREE_ITEM(lastselect)); |
cd0e5cf92f6a
Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
96
diff
changeset
|
3252 gtk_object_set_data(GTK_OBJECT(tree), "lastselect", NULL); |
cd0e5cf92f6a
Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
96
diff
changeset
|
3253 } |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3254 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3255 if(parenttree && GTK_IS_WIDGET(parenttree)) |
107
cd0e5cf92f6a
Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
96
diff
changeset
|
3256 gtk_container_remove(GTK_CONTAINER(parenttree), item); |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3257 DW_MUTEX_UNLOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3258 } |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3259 |
3 | 3260 int _dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator, int extra) |
3261 { | |
3262 GtkWidget *clist; | |
3263 char numbuf[10]; | |
3264 int z; | |
3265 int _locked_by_me = FALSE; | |
3266 | |
3267 DW_MUTEX_LOCK; | |
3268 clist = gtk_clist_new_with_titles(count, (gchar **)titles); | |
3269 if(!clist) | |
3270 { | |
3271 DW_MUTEX_UNLOCK; | |
3272 return FALSE; | |
3273 } | |
3274 | |
3275 gtk_signal_connect(GTK_OBJECT(clist), "select_row", GTK_SIGNAL_FUNC(_select_row), NULL); | |
3276 gtk_signal_connect(GTK_OBJECT(clist), "unselect_row", GTK_SIGNAL_FUNC(_unselect_row), NULL); | |
3277 | |
3278 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
|
3279 gtk_clist_set_selection_mode(GTK_CLIST(clist), GTK_SELECTION_SINGLE); |
3 | 3280 gtk_container_add(GTK_CONTAINER(handle), clist); |
72
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
3281 gtk_object_set_data(GTK_OBJECT(clist), "multi", (gpointer)0); |
3 | 3282 gtk_object_set_user_data(GTK_OBJECT(handle), (gpointer)clist); |
3283 gtk_widget_show(clist); | |
3284 gtk_object_set_data(GTK_OBJECT(clist), "colcount", (gpointer)count); | |
3285 | |
3286 if(extra) | |
3287 gtk_clist_set_column_width(GTK_CLIST(clist), 1, 120); | |
3288 | |
3289 for(z=0;z<count;z++) | |
3290 { | |
3291 if(!extra || z > 1) | |
3292 gtk_clist_set_column_width(GTK_CLIST(clist), z, 50); | |
3293 sprintf(numbuf, "%d", z); | |
3294 gtk_object_set_data(GTK_OBJECT(clist), numbuf, (gpointer)flags[z]); | |
3295 } | |
3296 | |
3297 DW_MUTEX_UNLOCK; | |
3298 return TRUE; | |
3299 } | |
3300 | |
3301 /* | |
3302 * Sets up the container columns. | |
3303 * Parameters: | |
3304 * handle: Handle to the container to be configured. | |
3305 * flags: An array of unsigned longs with column flags. | |
3306 * titles: An array of strings with column text titles. | |
3307 * count: The number of columns (this should match the arrays). | |
3308 * separator: The column number that contains the main separator. | |
3309 * (this item may only be used in OS/2) | |
3310 */ | |
3311 int dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator) | |
3312 { | |
3313 return _dw_container_setup(handle, flags, titles, count, separator, 0); | |
3314 } | |
3315 | |
3316 /* | |
3317 * Sets up the filesystem columns, note: filesystem always has an icon/filename field. | |
3318 * Parameters: | |
3319 * handle: Handle to the container to be configured. | |
3320 * flags: An array of unsigned longs with column flags. | |
3321 * titles: An array of strings with column text titles. | |
3322 * count: The number of columns (this should match the arrays). | |
3323 */ | |
3324 int dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count) | |
3325 { | |
3326 char **newtitles = malloc(sizeof(char *) * (count + 2)); | |
3327 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 2)); | |
3328 | |
3329 newtitles[0] = "Icon"; | |
3330 newtitles[1] = "Filename"; | |
3331 | |
3332 newflags[0] = DW_CFA_BITMAPORICON | DW_CFA_CENTER | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR; | |
3333 newflags[1] = DW_CFA_STRING | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR; | |
3334 | |
3335 memcpy(&newtitles[2], titles, sizeof(char *) * count); | |
3336 memcpy(&newflags[2], flags, sizeof(unsigned long) * count); | |
3337 | |
3338 _dw_container_setup(handle, newflags, newtitles, count + 2, 2, 1); | |
3339 | |
3340 free(newtitles); | |
3341 free(newflags); | |
3342 return TRUE; | |
3343 } | |
3344 | |
3345 /* | |
3346 * Obtains an icon from a module (or header in GTK). | |
3347 * Parameters: | |
3348 * module: Handle to module (DLL) in OS/2 and Windows. | |
3349 * id: A unsigned long id int the resources on OS/2 and | |
3350 * Windows, on GTK this is converted to a pointer | |
3351 * to an embedded XPM. | |
3352 */ | |
3353 unsigned long dw_icon_load(unsigned long module, unsigned long id) | |
3354 { | |
3355 return id; | |
3356 } | |
3357 | |
3358 /* | |
3359 * Frees a loaded resource in OS/2 and Windows. | |
3360 * Parameters: | |
3361 * handle: Handle to icon returned by dw_icon_load(). | |
3362 */ | |
3363 void dw_icon_free(unsigned long handle) | |
3364 { | |
3365 } | |
3366 | |
72
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
3367 /* Clears a CList selection and associated selection list */ |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
3368 void _dw_unselect(GtkWidget *clist) |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
3369 { |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
3370 GList *list = (GList *)gtk_object_get_data(GTK_OBJECT(clist), "selectlist"); |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
3371 |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
3372 if(list) |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
3373 g_list_free(list); |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
3374 |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
3375 gtk_object_set_data(GTK_OBJECT(clist), "selectlist", NULL); |
75
c629838d9805
Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
72
diff
changeset
|
3376 |
c629838d9805
Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
72
diff
changeset
|
3377 _dw_unselecting = 1; |
72
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
3378 gtk_clist_unselect_all(GTK_CLIST(clist)); |
75
c629838d9805
Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
72
diff
changeset
|
3379 _dw_unselecting = 0; |
72
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
3380 } |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
3381 |
3 | 3382 /* |
3383 * Allocates memory used to populate a container. | |
3384 * Parameters: | |
3385 * handle: Handle to the container window (widget). | |
3386 * rowcount: The number of items to be populated. | |
3387 */ | |
3388 void *dw_container_alloc(HWND handle, int rowcount) | |
3389 { | |
3390 int z, count = 0; | |
3391 GtkWidget *clist; | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
3392 GdkColor *fore, *back; |
3 | 3393 char **blah; |
3394 int _locked_by_me = FALSE; | |
3395 | |
3396 DW_MUTEX_LOCK; | |
3397 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
3398 if(!clist) | |
3399 { | |
3400 DW_MUTEX_UNLOCK; | |
3401 return NULL; | |
3402 } | |
3403 | |
3404 count = (int)gtk_object_get_data(GTK_OBJECT(clist), "colcount"); | |
3405 | |
3406 if(!count) | |
3407 { | |
3408 DW_MUTEX_UNLOCK; | |
3409 return NULL; | |
3410 } | |
3411 | |
3412 blah = malloc(sizeof(char *) * count); | |
3413 memset(blah, 0, sizeof(char *) * count); | |
3414 | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
3415 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
|
3416 back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(clist), "backgdk"); |
3 | 3417 gtk_clist_freeze(GTK_CLIST(clist)); |
3418 for(z=0;z<rowcount;z++) | |
3419 { | |
3420 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
|
3421 if(fore) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
3422 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
|
3423 if(back) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
3424 gtk_clist_set_background(GTK_CLIST(clist), z, back); |
3 | 3425 } |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
3426 gtk_object_set_data(GTK_OBJECT(clist), "rowcount", (gpointer)rowcount); |
3 | 3427 free(blah); |
3428 DW_MUTEX_UNLOCK; | |
3429 return (void *)handle; | |
3430 } | |
3431 | |
3432 /* | |
3433 * Sets an item in specified row and column to the given data. | |
3434 * Parameters: | |
3435 * handle: Handle to the container window (widget). | |
3436 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
3437 * column: Zero based column of data being set. | |
3438 * row: Zero based row of data being set. | |
3439 * data: Pointer to the data to be added. | |
3440 */ | |
3441 void dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data) | |
3442 { | |
3443 char numbuf[10], textbuffer[100]; | |
3444 int flag = 0; | |
3445 GtkWidget *clist; | |
3446 int _locked_by_me = FALSE; | |
3447 | |
3448 DW_MUTEX_LOCK; | |
3449 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
3450 if(!clist) | |
3451 { | |
3452 DW_MUTEX_UNLOCK; | |
3453 return; | |
3454 } | |
3455 | |
3456 sprintf(numbuf, "%d", column); | |
3457 flag = (int)gtk_object_get_data(GTK_OBJECT(clist), numbuf); | |
3458 | |
3459 if(flag & DW_CFA_BITMAPORICON) | |
3460 { | |
3461 long hicon = *((long *)data); | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3462 GdkBitmap *bitmap = NULL; |
3 | 3463 GdkPixmap *pixmap = _find_pixmap(&bitmap, hicon, clist); |
3464 | |
3465 if(pixmap) | |
3466 gtk_clist_set_pixmap(GTK_CLIST(clist), row, column, pixmap, bitmap); | |
3467 } | |
3468 else if(flag & DW_CFA_STRING) | |
3469 { | |
3470 char *tmp = *((char **)data); | |
3471 gtk_clist_set_text(GTK_CLIST(clist), row, column, tmp); | |
3472 } | |
3473 else if(flag & DW_CFA_ULONG) | |
3474 { | |
3475 ULONG tmp = *((ULONG *)data); | |
3476 | |
3477 sprintf(textbuffer, "%lu", tmp); | |
3478 | |
3479 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer); | |
3480 } | |
3481 else if(flag & DW_CFA_DATE) | |
3482 { | |
3483 CDATE fdate = *((CDATE *)data); | |
3484 | |
92
0a085f295e81
A couple more minor changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
91
diff
changeset
|
3485 if(/*fdate.month > -1 &&*/ fdate.month < 12 && fdate.day > 0 && fdate.year > 0) |
87
1eb72c0e8c79
Fixed a problem with the date type in the containers... month should be
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
86
diff
changeset
|
3486 sprintf(textbuffer, "%s %d, %d", monthlist[fdate.month], fdate.day, fdate.year); |
46
30d091bc7899
Fixed an error in the container date code on Windows and Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
41
diff
changeset
|
3487 else |
30d091bc7899
Fixed an error in the container date code on Windows and Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
41
diff
changeset
|
3488 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
|
3489 |
3 | 3490 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer); |
3491 } | |
3492 else if(flag & DW_CFA_TIME) | |
3493 { | |
3494 CTIME ftime = *((CTIME *)data); | |
3495 | |
3496 if(ftime.hours > 12) | |
3497 sprintf(textbuffer, "%d:%s%dpm", ftime.hours - 12, (ftime.minutes < 10) ? "0" : "", ftime.minutes); | |
3498 else | |
3499 sprintf(textbuffer, "%d:%s%dam", ftime.hours ? ftime.hours : 12, (ftime.minutes < 10) ? "0" : "", ftime.minutes); | |
3500 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer); | |
3501 } | |
3502 DW_MUTEX_UNLOCK; | |
3503 } | |
3504 | |
3505 /* | |
3506 * Sets an item in specified row and column to the given data. | |
3507 * Parameters: | |
3508 * handle: Handle to the container window (widget). | |
3509 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
3510 * column: Zero based column of data being set. | |
3511 * row: Zero based row of data being set. | |
3512 * data: Pointer to the data to be added. | |
3513 */ | |
3514 void dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, unsigned long icon) | |
3515 { | |
3516 dw_container_set_item(handle, pointer, 0, row, (void *)&icon); | |
3517 dw_container_set_item(handle, pointer, 1, row, (void *)&filename); | |
3518 } | |
3519 | |
3520 /* | |
3521 * Sets an item in specified row and column to the given data. | |
3522 * Parameters: | |
3523 * handle: Handle to the container window (widget). | |
3524 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
3525 * column: Zero based column of data being set. | |
3526 * row: Zero based row of data being set. | |
3527 * data: Pointer to the data to be added. | |
3528 */ | |
3529 void dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data) | |
3530 { | |
3531 dw_container_set_item(handle, pointer, column + 2, row, data); | |
3532 } | |
3533 | |
3534 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3535 * 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
|
3536 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3537 * 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
|
3538 * 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
|
3539 * 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
|
3540 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3541 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
|
3542 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3543 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
|
3544 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
|
3545 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3546 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
|
3547 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
|
3548 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3549 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
|
3550 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
|
3551 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
|
3552 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3553 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3554 /* |
3 | 3555 * Sets the title of a row in the container. |
3556 * Parameters: | |
3557 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
3558 * row: Zero based row of data being set. | |
3559 * title: String title of the item. | |
3560 */ | |
3561 void dw_container_set_row_title(void *pointer, int row, char *title) | |
3562 { | |
3563 GtkWidget *clist; | |
3564 int _locked_by_me = FALSE; | |
3565 | |
3566 DW_MUTEX_LOCK; | |
3567 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(pointer)); | |
3568 | |
3569 if(clist) | |
3570 gtk_clist_set_row_data(GTK_CLIST(clist), row, (gpointer)title); | |
3571 DW_MUTEX_UNLOCK; | |
3572 } | |
3573 | |
3574 /* | |
3575 * Sets the title of a row in the container. | |
3576 * Parameters: | |
3577 * handle: Handle to the container window (widget). | |
3578 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
3579 * rowcount: The number of rows to be inserted. | |
3580 */ | |
3581 void dw_container_insert(HWND handle, void *pointer, int rowcount) | |
3582 { | |
3583 GtkWidget *clist; | |
3584 int _locked_by_me = FALSE; | |
3585 | |
3586 DW_MUTEX_LOCK; | |
3587 clist = gtk_object_get_user_data(GTK_OBJECT(handle)); | |
3588 | |
3589 if(clist && GTK_IS_CLIST(clist)) | |
3590 gtk_clist_thaw(GTK_CLIST(clist)); | |
3591 DW_MUTEX_UNLOCK; | |
3592 } | |
3593 | |
3594 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3595 * 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
|
3596 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3597 * 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
|
3598 * 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
|
3599 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3600 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
|
3601 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3602 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
|
3603 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
|
3604 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3605 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
|
3606 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
|
3607 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
|
3608 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3609 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
|
3610 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3611 rows = (int)gtk_object_get_data(GTK_OBJECT(clist), "rowcount"); |
72
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
3612 |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
3613 _dw_unselect(clist); |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3614 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3615 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
|
3616 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
|
3617 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3618 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
|
3619 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
|
3620 else |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3621 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
|
3622 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3623 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
|
3624 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3625 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
|
3626 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3627 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3628 /* |
3 | 3629 * Removes all rows from a container. |
3630 * Parameters: | |
3631 * handle: Handle to the window (widget) to be cleared. | |
52
0804483f6320
Added a redraw parameter to dw_container_clear().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
51
diff
changeset
|
3632 * redraw: TRUE to cause the container to redraw immediately. |
3 | 3633 */ |
52
0804483f6320
Added a redraw parameter to dw_container_clear().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
51
diff
changeset
|
3634 void dw_container_clear(HWND handle, int redraw) |
3 | 3635 { |
3636 GtkWidget *clist; | |
3637 int _locked_by_me = FALSE; | |
3638 | |
3639 DW_MUTEX_LOCK; | |
3640 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
3641 if(clist && GTK_IS_CLIST(clist)) | |
3642 { | |
72
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
3643 _dw_unselect(clist); |
3 | 3644 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
|
3645 gtk_object_set_data(GTK_OBJECT(clist), "rowcount", (gpointer)0); |
3 | 3646 } |
3647 DW_MUTEX_UNLOCK; | |
3648 } | |
3649 | |
3650 /* | |
3651 * Removes all rows from a container. | |
3652 * Parameters: | |
3653 * handle: Handle to the window (widget) to be cleared. | |
3654 */ | |
3655 void dw_container_set_view(HWND handle, unsigned long flags, int iconwidth, int iconheight) | |
3656 { | |
3657 } | |
3658 | |
3659 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3660 * 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
|
3661 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3662 * 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
|
3663 * 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
|
3664 * 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
|
3665 * 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
|
3666 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3667 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
|
3668 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3669 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
|
3670 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
|
3671 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
|
3672 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3673 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
|
3674 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
|
3675 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
|
3676 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3677 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
|
3678 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
|
3679 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3680 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
|
3681 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3682 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
|
3683 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
|
3684 break; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3685 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
|
3686 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
|
3687 break; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3688 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3689 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
|
3690 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3691 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3692 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
|
3693 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3694 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3695 /* |
3 | 3696 * Starts a new query of a container. |
3697 * Parameters: | |
3698 * handle: Handle to the window (widget) to be queried. | |
3699 * flags: If this parameter is DW_CRA_SELECTED it will only | |
3700 * return items that are currently selected. Otherwise | |
3701 * it will return all records in the container. | |
3702 */ | |
3703 char *dw_container_query_start(HWND handle, unsigned long flags) | |
3704 { | |
3705 GtkWidget *clist; | |
3706 GList *list; | |
3707 char *retval = NULL; | |
3708 int _locked_by_me = FALSE; | |
3709 | |
3710 DW_MUTEX_LOCK; | |
3711 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
3712 | |
3713 if(!clist) | |
3714 { | |
3715 DW_MUTEX_UNLOCK; | |
3716 return NULL; | |
3717 } | |
3718 | |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3719 /* These should be separate but right now this will work */ |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3720 if(flags & DW_CRA_SELECTED || flags & DW_CRA_CURSORED) |
3 | 3721 { |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3722 /* If there is an old query list, free it */ |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3723 list = (GList *)gtk_object_get_data(GTK_OBJECT(clist), "querylist"); |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3724 if(list) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3725 g_list_free(list); |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3726 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3727 /* Move the current selection list to the query list, and remove the |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3728 * current selection list. |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3729 */ |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3730 list = (GList *)gtk_object_get_data(GTK_OBJECT(clist), "selectlist"); |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3731 gtk_object_set_data(GTK_OBJECT(clist), "selectlist", NULL); |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3732 gtk_object_set_data(GTK_OBJECT(clist), "querylist", (gpointer)list); |
75
c629838d9805
Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
72
diff
changeset
|
3733 _dw_unselect(clist); |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3734 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3735 if(list) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3736 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3737 gtk_object_set_data(GTK_OBJECT(clist), "querypos", (gpointer)1); |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3738 if(list->data) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3739 retval = list->data; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3740 else |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3741 retval = ""; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3742 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3743 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3744 else |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3745 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3746 retval = (char *)gtk_clist_get_row_data(GTK_CLIST(clist), 0); |
3 | 3747 gtk_object_set_data(GTK_OBJECT(clist), "querypos", (gpointer)1); |
3748 } | |
3749 DW_MUTEX_UNLOCK; | |
3750 return retval; | |
3751 } | |
3752 | |
3753 /* | |
3754 * Continues an existing query of a container. | |
3755 * Parameters: | |
3756 * handle: Handle to the window (widget) to be queried. | |
3757 * flags: If this parameter is DW_CRA_SELECTED it will only | |
3758 * return items that are currently selected. Otherwise | |
3759 * it will return all records in the container. | |
3760 */ | |
3761 char *dw_container_query_next(HWND handle, unsigned long flags) | |
3762 { | |
3763 GtkWidget *clist; | |
3764 GList *list; | |
3765 char *retval = NULL; | |
3766 int _locked_by_me = FALSE; | |
3767 | |
3768 DW_MUTEX_LOCK; | |
3769 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
3770 | |
3771 if(!clist) | |
3772 { | |
3773 DW_MUTEX_UNLOCK; | |
3774 return NULL; | |
3775 } | |
3776 | |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3777 /* These should be separate but right now this will work */ |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3778 if(flags & DW_CRA_SELECTED || flags & DW_CRA_CURSORED) |
3 | 3779 { |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3780 list = (GList *)gtk_object_get_data(GTK_OBJECT(clist), "querylist"); |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3781 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3782 if(list) |
3 | 3783 { |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3784 int counter = 0, pos = (int)gtk_object_get_data(GTK_OBJECT(clist), "querypos"); |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3785 gtk_object_set_data(GTK_OBJECT(clist), "querypos", (gpointer)pos+1); |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3786 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3787 while(list && counter < pos) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3788 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3789 list = list->next; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3790 counter++; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3791 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3792 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3793 if(list && list->data) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3794 retval = list->data; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3795 else if(list && !list->data) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3796 retval = ""; |
3 | 3797 } |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3798 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3799 else |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3800 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3801 int pos = (int)gtk_object_get_data(GTK_OBJECT(clist), "querypos"); |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3802 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3803 retval = (char *)gtk_clist_get_row_data(GTK_CLIST(clist), pos); |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3804 gtk_object_set_data(GTK_OBJECT(clist), "querypos", (gpointer)pos+1); |
3 | 3805 } |
3806 DW_MUTEX_UNLOCK; | |
3807 return retval; | |
3808 } | |
3809 | |
3810 /* | |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3811 * Cursors the item with the text speficied, and scrolls to that item. |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3812 * Parameters: |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3813 * handle: Handle to the window (widget) to be queried. |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3814 * text: Text usually returned by dw_container_query(). |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3815 */ |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3816 void dw_container_cursor(HWND handle, char *text) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3817 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3818 int _locked_by_me = FALSE; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3819 GtkWidget *clist; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3820 int rowcount, z; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3821 char *rowdata; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3822 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3823 DW_MUTEX_LOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3824 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle)); |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3825 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3826 if(!clist) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3827 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3828 DW_MUTEX_UNLOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3829 return; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3830 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3831 rowcount = (int)gtk_object_get_data(GTK_OBJECT(clist), "rowcount"); |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3832 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3833 for(z=0;z<rowcount;z++) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3834 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3835 rowdata = gtk_clist_get_row_data(GTK_CLIST(clist), z); |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3836 if(rowdata == text) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3837 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3838 gfloat pos; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3839 GtkAdjustment *adj = gtk_clist_get_vadjustment(GTK_CLIST(clist)); |
72
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
3840 |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
3841 _dw_unselect(clist); |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
3842 |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3843 gtk_clist_select_row(GTK_CLIST(clist), z, 0); |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3844 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3845 pos = ((adj->upper - adj->lower) * ((gfloat)z/(gfloat)rowcount)) + adj->lower; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3846 gtk_adjustment_set_value(adj, pos); |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3847 DW_MUTEX_UNLOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3848 return; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3849 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3850 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3851 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3852 DW_MUTEX_UNLOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3853 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3854 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3855 /* |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3856 * Optimizes the column widths so that all data is visible. |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3857 * Parameters: |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3858 * handle: Handle to the window (widget) to be optimized. |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3859 */ |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3860 void dw_container_optimize(HWND handle) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3861 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3862 int _locked_by_me = FALSE; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3863 GtkWidget *clist; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3864 int colcount, z; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3865 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3866 DW_MUTEX_LOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3867 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle)); |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3868 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3869 if(!clist) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3870 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3871 DW_MUTEX_UNLOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3872 return; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3873 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3874 colcount = (int)gtk_object_get_data(GTK_OBJECT(clist), "colcount"); |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3875 for(z=0;z<colcount;z++) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3876 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3877 int width = gtk_clist_optimal_column_width(GTK_CLIST(clist), z); |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3878 gtk_clist_set_column_width(GTK_CLIST(clist), z, width); |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3879 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3880 DW_MUTEX_UNLOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3881 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3882 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3883 /* |
3 | 3884 * Creates a rendering context widget (window) to be packed. |
3885 * Parameters: | |
3886 * id: An id to be used with dw_window_from_id. | |
3887 * Returns: | |
3888 * A handle to the widget or NULL on failure. | |
3889 */ | |
3890 HWND dw_render_new(unsigned long id) | |
3891 { | |
3892 int _locked_by_me = FALSE; | |
3893 GtkWidget *tmp; | |
3894 | |
3895 DW_MUTEX_LOCK; | |
3896 tmp = gtk_drawing_area_new(); | |
3897 gtk_widget_set_events(tmp, GDK_EXPOSURE_MASK | |
3898 | GDK_LEAVE_NOTIFY_MASK | |
3899 | GDK_BUTTON_PRESS_MASK | |
3900 | GDK_POINTER_MOTION_MASK | |
3901 | GDK_POINTER_MOTION_HINT_MASK); | |
3902 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
3903 gtk_widget_show(tmp); | |
3904 DW_MUTEX_UNLOCK; | |
3905 return tmp; | |
3906 } | |
3907 | |
3908 /* Sets the current foreground drawing color. | |
3909 * Parameters: | |
3910 * red: red value. | |
3911 * green: green value. | |
3912 * blue: blue value. | |
3913 */ | |
3914 void dw_color_foreground_set(unsigned long value) | |
3915 { | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
3916 int _locked_by_me = FALSE, index = _find_thread_index(dw_thread_id()); |
3 | 3917 GdkColor color = { 0, DW_RED_VALUE(value) << 8, DW_GREEN_VALUE(value) << 8, DW_BLUE_VALUE(value) << 8 }; |
3918 | |
3919 DW_MUTEX_LOCK; | |
3920 gdk_color_alloc(_dw_cmap, &color); | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
3921 _foreground[index] = color; |
3 | 3922 DW_MUTEX_UNLOCK; |
3923 } | |
3924 | |
3925 /* Sets the current background drawing color. | |
3926 * Parameters: | |
3927 * red: red value. | |
3928 * green: green value. | |
3929 * blue: blue value. | |
3930 */ | |
3931 void dw_color_background_set(unsigned long value) | |
3932 { | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
3933 int _locked_by_me = FALSE, index = _find_thread_index(dw_thread_id()); |
3 | 3934 GdkColor color = { 0, DW_RED_VALUE(value) << 8, DW_GREEN_VALUE(value) << 8, DW_BLUE_VALUE(value) << 8 }; |
3935 | |
3936 DW_MUTEX_LOCK; | |
3937 gdk_color_alloc(_dw_cmap, &color); | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
3938 _background[index] = color; |
3 | 3939 DW_MUTEX_UNLOCK; |
3940 } | |
3941 | |
3942 GdkGC *_set_colors(GdkWindow *window) | |
3943 { | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3944 GdkGC *gc = NULL; |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
3945 int index = _find_thread_index(dw_thread_id()); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
3946 |
3 | 3947 if(!window) |
3948 return NULL; | |
3949 gc = gdk_gc_new(window); | |
3950 if(gc) | |
3951 { | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
3952 gdk_gc_set_foreground(gc, &_foreground[index]); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
3953 gdk_gc_set_background(gc, &_background[index]); |
3 | 3954 } |
3955 return gc; | |
3956 } | |
3957 | |
3958 /* Draw a point on a window (preferably a render window). | |
3959 * Parameters: | |
3960 * handle: Handle to the window. | |
3961 * pixmap: Handle to the pixmap. (choose only one of these) | |
3962 * x: X coordinate. | |
3963 * y: Y coordinate. | |
3964 */ | |
3965 void dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y) | |
3966 { | |
3967 int _locked_by_me = FALSE; | |
3968 GdkGC *gc = NULL; | |
3969 | |
3970 DW_MUTEX_LOCK; | |
3971 if(handle) | |
3972 gc = _set_colors(handle->window); | |
3973 else if(pixmap) | |
3974 gc = _set_colors(pixmap->pixmap); | |
3975 if(gc) | |
3976 { | |
3977 gdk_draw_point(handle ? handle->window : pixmap->pixmap, gc, x, y); | |
3978 gdk_gc_unref(gc); | |
3979 } | |
3980 DW_MUTEX_UNLOCK; | |
3981 } | |
3982 | |
3983 /* Draw a line on a window (preferably a render window). | |
3984 * Parameters: | |
3985 * handle: Handle to the window. | |
3986 * pixmap: Handle to the pixmap. (choose only one of these) | |
3987 * x1: First X coordinate. | |
3988 * y1: First Y coordinate. | |
3989 * x2: Second X coordinate. | |
3990 * y2: Second Y coordinate. | |
3991 */ | |
3992 void dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2) | |
3993 { | |
3994 int _locked_by_me = FALSE; | |
3995 GdkGC *gc = NULL; | |
3996 | |
3997 DW_MUTEX_LOCK; | |
3998 if(handle) | |
3999 gc = _set_colors(handle->window); | |
4000 else if(pixmap) | |
4001 gc = _set_colors(pixmap->pixmap); | |
4002 if(gc) | |
4003 { | |
4004 gdk_draw_line(handle ? handle->window : pixmap->pixmap, gc, x1, y1, x2, y2); | |
4005 gdk_gc_unref(gc); | |
4006 } | |
4007 DW_MUTEX_UNLOCK; | |
4008 } | |
4009 | |
4010 /* Draw a rectangle on a window (preferably a render window). | |
4011 * Parameters: | |
4012 * handle: Handle to the window. | |
4013 * pixmap: Handle to the pixmap. (choose only one of these) | |
4014 * x: X coordinate. | |
4015 * y: Y coordinate. | |
4016 * width: Width of rectangle. | |
4017 * height: Height of rectangle. | |
4018 */ | |
4019 void dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height) | |
4020 { | |
4021 int _locked_by_me = FALSE; | |
4022 GdkGC *gc = NULL; | |
4023 | |
4024 DW_MUTEX_LOCK; | |
4025 if(handle) | |
4026 gc = _set_colors(handle->window); | |
4027 else if(pixmap) | |
4028 gc = _set_colors(pixmap->pixmap); | |
4029 if(gc) | |
4030 { | |
4031 gdk_draw_rectangle(handle ? handle->window : pixmap->pixmap, gc, fill, x, y, width, height); | |
4032 gdk_gc_unref(gc); | |
4033 } | |
4034 DW_MUTEX_UNLOCK; | |
4035 } | |
4036 | |
4037 /* Draw text on a window (preferably a render window). | |
4038 * Parameters: | |
4039 * handle: Handle to the window. | |
4040 * pixmap: Handle to the pixmap. (choose only one of these) | |
4041 * x: X coordinate. | |
4042 * y: Y coordinate. | |
4043 * text: Text to be displayed. | |
4044 */ | |
4045 void dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text) | |
4046 { | |
4047 int _locked_by_me = FALSE; | |
4048 GdkGC *gc = NULL; | |
4049 GdkFont *font; | |
4050 char *fontname = "fixed"; | |
4051 | |
49
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4052 if(!text) |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4053 return; |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4054 |
3 | 4055 DW_MUTEX_LOCK; |
4056 if(handle) | |
4057 { | |
4058 fontname = (char *)gtk_object_get_data(GTK_OBJECT(handle), "fontname"); | |
4059 gc = _set_colors(handle->window); | |
4060 } | |
4061 else if(pixmap) | |
4062 { | |
4063 fontname = (char *)gtk_object_get_data(GTK_OBJECT(pixmap->handle), "fontname"); | |
4064 gc = _set_colors(pixmap->pixmap); | |
4065 } | |
4066 if(gc) | |
4067 { | |
4068 font = gdk_font_load(fontname); | |
4069 if(font) | |
4070 { | |
4071 gint ascent; | |
4072 | |
4073 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
|
4074 gdk_draw_text(handle ? handle->window : pixmap->pixmap, font, gc, x, y + ascent + 2, text, strlen(text)); |
3 | 4075 gdk_gc_unref(gc); |
4076 gdk_font_unref(font); | |
4077 } | |
4078 } | |
4079 DW_MUTEX_UNLOCK; | |
4080 } | |
4081 | |
49
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4082 /* Query the width and height of a text string. |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4083 * Parameters: |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4084 * handle: Handle to the window. |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4085 * pixmap: Handle to the pixmap. (choose only one of these) |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4086 * text: Text to be queried. |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4087 * width: Pointer to a variable to be filled in with the width. |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4088 * height Pointer to a variable to be filled in with the height. |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4089 */ |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4090 void dw_font_text_extents(HWND handle, HPIXMAP pixmap, char *text, int *width, int *height) |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4091 { |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4092 int _locked_by_me = FALSE; |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4093 GdkFont *font; |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4094 char *fontname = NULL; |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4095 |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4096 if(!text) |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4097 return; |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4098 |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4099 DW_MUTEX_LOCK; |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4100 if(handle) |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4101 fontname = (char *)gtk_object_get_data(GTK_OBJECT(handle), "fontname"); |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4102 else if(pixmap) |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4103 fontname = (char *)gtk_object_get_data(GTK_OBJECT(pixmap->handle), "fontname"); |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4104 |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4105 font = gdk_font_load(fontname ? fontname : "fixed"); |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4106 if(font) |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4107 { |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4108 if(width) |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4109 *width = gdk_string_width(font, text); |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4110 if(height) |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4111 *height = gdk_string_height(font, text); |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4112 gdk_font_unref(font); |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4113 } |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4114 DW_MUTEX_UNLOCK; |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4115 } |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
4116 |
3 | 4117 /* |
4118 * Creates a pixmap with given parameters. | |
4119 * Parameters: | |
4120 * handle: Window handle the pixmap is associated with. | |
4121 * width: Width of the pixmap in pixels. | |
4122 * height: Height of the pixmap in pixels. | |
4123 * depth: Color depth of the pixmap. | |
4124 * Returns: | |
4125 * A handle to a pixmap or NULL on failure. | |
4126 */ | |
4127 HPIXMAP dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth) | |
4128 { | |
4129 int _locked_by_me = FALSE; | |
4130 HPIXMAP pixmap; | |
4131 | |
4132 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) | |
4133 return NULL; | |
4134 | |
4135 if (!depth) | |
66
664a274a46a6
Fixed color depth problem when creating a new pixmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
63
diff
changeset
|
4136 depth = -1; |
3 | 4137 |
4138 pixmap->width = width; pixmap->height = height; | |
4139 | |
4140 | |
4141 DW_MUTEX_LOCK; | |
4142 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
|
4143 #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
|
4144 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
|
4145 #else |
3 | 4146 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
|
4147 #endif |
3 | 4148 DW_MUTEX_UNLOCK; |
4149 return pixmap; | |
4150 } | |
4151 | |
4152 /* | |
4153 * Creates a pixmap from internal resource graphic specified by id. | |
4154 * Parameters: | |
4155 * handle: Window handle the pixmap is associated with. | |
4156 * id: Resource ID associated with requested pixmap. | |
4157 * Returns: | |
4158 * A handle to a pixmap or NULL on failure. | |
4159 */ | |
4160 HPIXMAP dw_pixmap_grab(HWND handle, ULONG id) | |
4161 { | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4162 GdkBitmap *bitmap = NULL; |
3 | 4163 HPIXMAP pixmap; |
4164 int _locked_by_me = FALSE; | |
4165 | |
4166 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) | |
4167 return NULL; | |
4168 | |
4169 | |
4170 DW_MUTEX_LOCK; | |
4171 pixmap->pixmap = _find_pixmap(&bitmap, id, handle); | |
4172 if(pixmap->pixmap) | |
4173 { | |
4174 GdkPixmapPrivate *pvt = (GdkPixmapPrivate *)pixmap->pixmap; | |
4175 pixmap->width = pvt->width; pixmap->height = pvt->height; | |
4176 } | |
4177 DW_MUTEX_UNLOCK; | |
4178 return pixmap; | |
4179 } | |
4180 | |
4181 /* Call this after drawing to the screen to make sure | |
4182 * anything you have drawn is visible. | |
4183 */ | |
4184 void dw_flush(void) | |
4185 { | |
4186 int _locked_by_me = FALSE; | |
4187 | |
4188 DW_MUTEX_LOCK; | |
4189 gdk_flush(); | |
4190 DW_MUTEX_UNLOCK; | |
4191 } | |
4192 | |
4193 /* | |
4194 * Destroys an allocated pixmap. | |
4195 * Parameters: | |
4196 * pixmap: Handle to a pixmap returned by | |
4197 * dw_pixmap_new.. | |
4198 */ | |
4199 void dw_pixmap_destroy(HPIXMAP pixmap) | |
4200 { | |
4201 int _locked_by_me = FALSE; | |
4202 | |
4203 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
|
4204 #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
|
4205 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
|
4206 #else |
3 | 4207 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
|
4208 #endif |
3 | 4209 free(pixmap); |
4210 DW_MUTEX_UNLOCK; | |
4211 } | |
4212 | |
4213 /* | |
4214 * Copies from one item to another. | |
4215 * Parameters: | |
4216 * dest: Destination window handle. | |
4217 * destp: Destination pixmap. (choose only one). | |
4218 * xdest: X coordinate of destination. | |
4219 * ydest: Y coordinate of destination. | |
4220 * width: Width of area to copy. | |
4221 * height: Height of area to copy. | |
4222 * src: Source window handle. | |
4223 * srcp: Source pixmap. (choose only one). | |
4224 * xsrc: X coordinate of source. | |
4225 * ysrc: Y coordinate of source. | |
4226 */ | |
4227 void dw_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc) | |
4228 { | |
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
|
4229 /* 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
|
4230 * 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
|
4231 * 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
|
4232 * 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
|
4233 */ |
3 | 4234 int _locked_by_me = FALSE; |
4235 GdkGC *gc = NULL; | |
4236 | |
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
|
4237 if((!dest && (!destp || !destp->pixmap)) || (!src && (!srcp || !srcp->pixmap))) |
3 | 4238 return; |
4239 | |
4240 DW_MUTEX_LOCK; | |
4241 if(dest) | |
4242 gc = _set_colors(dest->window); | |
4243 else if(src) | |
4244 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
|
4245 #ifndef USE_PIXBUF |
3 | 4246 else if(destp) |
4247 gc = gdk_gc_new(destp->pixmap); | |
4248 else if(srcp) | |
4249 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
|
4250 #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
|
4251 |
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
|
4252 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
|
4253 #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
|
4254 || (!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
|
4255 #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
|
4256 ) |
3 | 4257 { |
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
|
4258 #ifndef USE_PIXBUF |
3 | 4259 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
|
4260 #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
|
4261 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
|
4262 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
|
4263 |
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
|
4264 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
|
4265 #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
|
4266 gdk_gc_unref(gc); |
3 | 4267 } |
4268 DW_MUTEX_UNLOCK; | |
4269 } | |
4270 | |
4271 /* | |
4272 * Emits a beep. | |
4273 * Parameters: | |
4274 * freq: Frequency. | |
4275 * dur: Duration. | |
4276 */ | |
4277 void dw_beep(int freq, int dur) | |
4278 { | |
4279 int _locked_by_me = FALSE; | |
4280 | |
4281 DW_MUTEX_LOCK; | |
4282 gdk_beep(); | |
4283 DW_MUTEX_UNLOCK; | |
4284 } | |
4285 | |
4286 /* | |
4287 * Returns the handle to an unnamed mutex semaphore. | |
4288 */ | |
4289 HMTX dw_mutex_new(void) | |
4290 { | |
4291 HMTX mutex; | |
4292 | |
4293 pthread_mutex_init(&mutex, NULL); | |
4294 return mutex; | |
4295 } | |
4296 | |
4297 /* | |
4298 * Closes a semaphore created by dw_mutex_new(). | |
4299 * Parameters: | |
4300 * mutex: The handle to the mutex returned by dw_mutex_new(). | |
4301 */ | |
4302 void dw_mutex_close(HMTX mutex) | |
4303 { | |
4304 pthread_mutex_destroy(&mutex); | |
4305 } | |
4306 | |
4307 /* | |
4308 * Tries to gain access to the semaphore, if it can't it blocks. | |
4309 * Parameters: | |
4310 * mutex: The handle to the mutex returned by dw_mutex_new(). | |
4311 */ | |
4312 void dw_mutex_lock(HMTX mutex) | |
4313 { | |
96
baaf4b04d284
Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
94
diff
changeset
|
4314 /* If we are being called from an event handler we must release |
baaf4b04d284
Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
94
diff
changeset
|
4315 * the GTK mutex so we don't deadlock. |
baaf4b04d284
Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
94
diff
changeset
|
4316 */ |
baaf4b04d284
Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
94
diff
changeset
|
4317 if(pthread_self() == _dw_thread) |
baaf4b04d284
Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
94
diff
changeset
|
4318 gdk_threads_leave(); |
baaf4b04d284
Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
94
diff
changeset
|
4319 |
3 | 4320 pthread_mutex_lock(&mutex); |
96
baaf4b04d284
Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
94
diff
changeset
|
4321 |
baaf4b04d284
Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
94
diff
changeset
|
4322 /* And of course relock it when we have acquired the mutext */ |
baaf4b04d284
Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
94
diff
changeset
|
4323 if(pthread_self() == _dw_thread) |
baaf4b04d284
Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
94
diff
changeset
|
4324 gdk_threads_enter(); |
3 | 4325 } |
4326 | |
4327 /* | |
4328 * Reliquishes the access to the semaphore. | |
4329 * Parameters: | |
4330 * mutex: The handle to the mutex returned by dw_mutex_new(). | |
4331 */ | |
4332 void dw_mutex_unlock(HMTX mutex) | |
4333 { | |
4334 pthread_mutex_unlock(&mutex); | |
4335 } | |
4336 | |
4337 /* | |
4338 * Returns the handle to an unnamed event semaphore. | |
4339 */ | |
4340 HEV dw_event_new(void) | |
4341 { | |
4342 HEV eve = (HEV)malloc(sizeof(struct _dw_unix_event)); | |
4343 | |
4344 if(!eve) | |
4345 return NULL; | |
4346 | |
4347 /* We need to be careful here, mutexes on Linux are | |
4348 * FAST by default but are error checking on other | |
4349 * systems such as FreeBSD and OS/2, perhaps others. | |
4350 */ | |
4351 pthread_mutex_init (&(eve->mutex), NULL); | |
4352 pthread_mutex_lock (&(eve->mutex)); | |
4353 pthread_cond_init (&(eve->event), NULL); | |
4354 | |
4355 pthread_mutex_unlock (&(eve->mutex)); | |
4356 eve->alive = 1; | |
4357 eve->posted = 0; | |
4358 | |
4359 return eve; | |
4360 } | |
4361 | |
4362 /* | |
4363 * Resets a semaphore created by dw_event_new(). | |
4364 * Parameters: | |
4365 * eve: The handle to the event returned by dw_event_new(). | |
4366 */ | |
4367 int dw_event_reset (HEV eve) | |
4368 { | |
4369 if(!eve) | |
4370 return FALSE; | |
4371 | |
4372 pthread_mutex_lock (&(eve->mutex)); | |
4373 pthread_cond_broadcast (&(eve->event)); | |
4374 pthread_cond_init (&(eve->event), NULL); | |
4375 eve->posted = 0; | |
4376 pthread_mutex_unlock (&(eve->mutex)); | |
4377 return 0; | |
4378 } | |
4379 | |
4380 /* | |
4381 * Posts a semaphore created by dw_event_new(). Causing all threads | |
4382 * waiting on this event in dw_event_wait to continue. | |
4383 * Parameters: | |
4384 * eve: The handle to the event returned by dw_event_new(). | |
4385 */ | |
4386 int dw_event_post (HEV eve) | |
4387 { | |
4388 if(!eve) | |
4389 return FALSE; | |
4390 | |
4391 pthread_mutex_lock (&(eve->mutex)); | |
4392 pthread_cond_broadcast (&(eve->event)); | |
4393 eve->posted = 1; | |
4394 pthread_mutex_unlock (&(eve->mutex)); | |
4395 return 0; | |
4396 } | |
4397 | |
4398 /* | |
4399 * Waits on a semaphore created by dw_event_new(), until the | |
4400 * event gets posted or until the timeout expires. | |
4401 * Parameters: | |
4402 * eve: The handle to the event returned by dw_event_new(). | |
4403 */ | |
4404 int dw_event_wait(HEV eve, unsigned long timeout) | |
4405 { | |
4406 int rc; | |
4407 struct timeval now; | |
4408 struct timespec timeo; | |
4409 | |
4410 if(!eve) | |
4411 return FALSE; | |
4412 | |
4413 if(eve->posted) | |
4414 return 0; | |
4415 | |
4416 pthread_mutex_lock (&(eve->mutex)); | |
4417 gettimeofday(&now, 0); | |
4418 timeo.tv_sec = now.tv_sec + (timeout / 1000); | |
4419 timeo.tv_nsec = now.tv_usec * 1000; | |
4420 rc = pthread_cond_timedwait (&(eve->event), &(eve->mutex), &timeo); | |
4421 pthread_mutex_unlock (&(eve->mutex)); | |
4422 if(!rc) | |
4423 return 1; | |
4424 if(rc == ETIMEDOUT) | |
4425 return -1; | |
4426 return 0; | |
4427 } | |
4428 | |
4429 /* | |
4430 * Closes a semaphore created by dw_event_new(). | |
4431 * Parameters: | |
4432 * eve: The handle to the event returned by dw_event_new(). | |
4433 */ | |
4434 int dw_event_close(HEV *eve) | |
4435 { | |
4436 if(!eve || !(*eve)) | |
4437 return FALSE; | |
4438 | |
4439 pthread_mutex_lock (&((*eve)->mutex)); | |
4440 pthread_cond_destroy (&((*eve)->event)); | |
4441 pthread_mutex_unlock (&((*eve)->mutex)); | |
4442 pthread_mutex_destroy (&((*eve)->mutex)); | |
4443 free(*eve); | |
4444 *eve = NULL; | |
4445 | |
4446 return TRUE; | |
4447 } | |
4448 | |
4449 /* | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4450 * Setup thread independent color sets. |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4451 */ |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4452 void _dwthreadstart(void *data) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4453 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4454 void (*threadfunc)(void *) = NULL; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4455 void **tmp = (void **)data; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4456 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4457 threadfunc = (void (*)(void *))tmp[0]; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4458 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4459 _dw_thread_add(dw_thread_id()); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4460 threadfunc(tmp[1]); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4461 _dw_thread_remove(dw_thread_id()); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4462 free(tmp); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4463 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4464 /* |
3 | 4465 * Creates a new thread with a starting point of func. |
4466 * Parameters: | |
4467 * func: Function which will be run in the new thread. | |
4468 * data: Parameter(s) passed to the function. | |
4469 * stack: Stack size of new thread (OS/2 and Windows only). | |
4470 */ | |
4471 DWTID dw_thread_new(void *func, void *data, int stack) | |
4472 { | |
4473 DWTID gtkthread; | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4474 void **tmp = malloc(sizeof(void *) * 2); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4475 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4476 tmp[0] = func; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4477 tmp[1] = data; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4478 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4479 pthread_create(>kthread, NULL, (void *)_dwthreadstart, (void *)tmp); |
3 | 4480 return gtkthread; |
4481 } | |
4482 | |
4483 /* | |
4484 * Ends execution of current thread immediately. | |
4485 */ | |
4486 void dw_thread_end(void) | |
4487 { | |
4488 pthread_exit(NULL); | |
4489 } | |
4490 | |
4491 /* | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4492 * Returns the current thread's ID. |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4493 */ |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4494 DWTID dw_thread_id(void) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4495 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4496 return (DWTID)pthread_self(); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4497 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4498 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4499 /* |
3 | 4500 * Cleanly terminates a DW session, should be signal handler safe. |
4501 * Parameters: | |
4502 * exitcode: Exit code reported to the operating system. | |
4503 */ | |
4504 void dw_exit(int exitcode) | |
4505 { | |
4506 exit(exitcode); | |
4507 } | |
4508 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4509 #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
|
4510 |
3 | 4511 /* |
4512 * Pack windows (widgets) into a box from the end (or bottom). | |
4513 * Parameters: | |
4514 * box: Window handle of the box to be packed into. | |
4515 * item: Window handle of the item to be back. | |
4516 * width: Width in pixels of the item or -1 to be self determined. | |
4517 * height: Height in pixels of the item or -1 to be self determined. | |
4518 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. | |
4519 * vsize: TRUE if the window (widget) should expand vertically to fill space given. | |
4520 * pad: Number of pixels of padding around the item. | |
4521 */ | |
4522 void dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) | |
4523 { | |
4524 int _locked_by_me = FALSE; | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4525 GtkWidget *tmp; |
3 | 4526 |
4527 if(!box) | |
4528 return; | |
4529 | |
4530 DW_MUTEX_LOCK; | |
4531 | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4532 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
|
4533 box = tmp; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4534 |
3 | 4535 if(!item) |
4536 { | |
4537 item = gtk_label_new(""); | |
4538 gtk_widget_show(item); | |
4539 } | |
4540 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4541 if(GTK_IS_TABLE(box)) |
3 | 4542 { |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4543 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
|
4544 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
|
4545 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4546 /* 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
|
4547 * 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
|
4548 * 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
|
4549 * 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
|
4550 */ |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4551 if(GTK_IS_TABLE(item)) |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4552 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4553 GtkWidget *eventbox = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "eventbox"); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4554 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4555 if(eventbox) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4556 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4557 gtk_container_add(GTK_CONTAINER(eventbox), item); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4558 pad = (int)gtk_object_get_data(GTK_OBJECT(item), "boxpad"); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4559 item = eventbox; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4560 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4561 } |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4562 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4563 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
|
4564 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
|
4565 else |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4566 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
|
4567 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4568 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
|
4569 gtk_object_set_data(GTK_OBJECT(box), "boxcount", (gpointer)boxcount + 1); |
3 | 4570 gtk_widget_set_usize(item, width, height); |
4571 if(GTK_IS_RADIO_BUTTON(item)) | |
4572 { | |
4573 GSList *group; | |
4574 GtkWidget *groupstart = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(box), "group"); | |
4575 | |
4576 if(groupstart) | |
4577 { | |
4578 group = gtk_radio_button_group(GTK_RADIO_BUTTON(groupstart)); | |
4579 gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group); | |
4580 } | |
4581 else | |
4582 gtk_object_set_data(GTK_OBJECT(box), "group", (gpointer)item); | |
4583 } | |
4584 } | |
4585 else | |
4586 { | |
4587 GtkWidget *vbox = gtk_vbox_new(FALSE, 0); | |
4588 | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4589 if(GTK_IS_TABLE(item)) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4590 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4591 GtkWidget *eventbox = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "eventbox"); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4592 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4593 if(eventbox) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4594 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4595 gtk_container_add(GTK_CONTAINER(eventbox), item); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4596 pad = (int)gtk_object_get_data(GTK_OBJECT(item), "boxpad"); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4597 item = eventbox; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4598 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4599 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4600 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4601 gtk_container_border_width(GTK_CONTAINER(box), pad); |
3 | 4602 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
|
4603 gtk_box_pack_end(GTK_BOX(vbox), item, TRUE, TRUE, 0); |
3 | 4604 gtk_widget_show(vbox); |
4605 | |
4606 gtk_widget_set_usize(item, width, height); | |
4607 gtk_object_set_user_data(GTK_OBJECT(box), vbox); | |
4608 } | |
4609 DW_MUTEX_UNLOCK; | |
4610 } | |
4611 | |
4612 /* | |
4613 * Sets the size of a given window (widget). | |
4614 * Parameters: | |
4615 * handle: Window (widget) handle. | |
4616 * width: New width in pixels. | |
4617 * height: New height in pixels. | |
4618 */ | |
4619 void dw_window_set_usize(HWND handle, unsigned long width, unsigned long height) | |
4620 { | |
4621 int _locked_by_me = FALSE; | |
4622 | |
4623 DW_MUTEX_LOCK; | |
4624 if(GTK_IS_WINDOW(handle)) | |
4625 _size_allocate(GTK_WINDOW(handle)); | |
4626 #if 0 | |
4627 gtk_window_set_default_size(GTK_WINDOW(handle), width, height); | |
4628 else | |
4629 #endif | |
4630 gtk_widget_set_usize(handle, width, height); | |
4631 DW_MUTEX_UNLOCK; | |
4632 } | |
4633 | |
4634 /* | |
4635 * Returns the width of the screen. | |
4636 */ | |
4637 int dw_screen_width(void) | |
4638 { | |
4639 int retval; | |
4640 int _locked_by_me = FALSE; | |
4641 | |
4642 DW_MUTEX_LOCK; | |
4643 retval = gdk_screen_width(); | |
4644 DW_MUTEX_UNLOCK; | |
4645 return retval; | |
4646 } | |
4647 | |
4648 /* | |
4649 * Returns the height of the screen. | |
4650 */ | |
4651 int dw_screen_height(void) | |
4652 { | |
4653 int retval; | |
4654 int _locked_by_me = FALSE; | |
4655 | |
4656 DW_MUTEX_UNLOCK; | |
4657 retval = gdk_screen_height(); | |
4658 DW_MUTEX_UNLOCK; | |
4659 return retval; | |
4660 } | |
4661 | |
4662 /* This should return the current color depth */ | |
4663 unsigned long dw_color_depth(void) | |
4664 { | |
4665 int retval; | |
4666 int _locked_by_me = FALSE; | |
4667 | |
4668 DW_MUTEX_UNLOCK; | |
86
a2b13e127d25
Make dw_color_depth() return the correct value on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
85
diff
changeset
|
4669 retval = gdk_visual_get_best_depth(); |
3 | 4670 DW_MUTEX_UNLOCK; |
4671 return retval; | |
4672 } | |
4673 | |
4674 /* | |
4675 * Sets the position of a given window (widget). | |
4676 * Parameters: | |
4677 * handle: Window (widget) handle. | |
4678 * x: X location from the bottom left. | |
4679 * y: Y location from the bottom left. | |
4680 */ | |
4681 void dw_window_set_pos(HWND handle, unsigned long x, unsigned long y) | |
4682 { | |
4683 int _locked_by_me = FALSE; | |
4684 | |
4685 DW_MUTEX_LOCK; | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
4686 if(handle && handle->window) |
3 | 4687 gdk_window_move(handle->window, x, y); |
4688 DW_MUTEX_UNLOCK; | |
4689 } | |
4690 | |
4691 /* | |
4692 * Sets the position and size of a given window (widget). | |
4693 * Parameters: | |
4694 * handle: Window (widget) handle. | |
4695 * x: X location from the bottom left. | |
4696 * y: Y location from the bottom left. | |
4697 * width: Width of the widget. | |
4698 * height: Height of the widget. | |
4699 */ | |
4700 void dw_window_set_pos_size(HWND handle, unsigned long x, unsigned long y, unsigned long width, unsigned long height) | |
4701 { | |
4702 int _locked_by_me = FALSE; | |
4703 | |
4704 DW_MUTEX_LOCK; | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
4705 if(handle && GTK_IS_WINDOW(handle)) |
3 | 4706 { |
4707 _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
|
4708 |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
4709 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
|
4710 gtk_window_set_default_size(GTK_WINDOW(handle), width - _dw_border_width, height - _dw_border_height); |
3 | 4711 } |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
4712 else if(handle && handle->window) |
3 | 4713 { |
4714 gdk_window_resize(handle->window, width, height); | |
4715 gdk_window_move(handle->window, x, y); | |
4716 } | |
4717 DW_MUTEX_UNLOCK; | |
4718 } | |
4719 | |
4720 /* | |
4721 * Gets the position and size of a given window (widget). | |
4722 * Parameters: | |
4723 * handle: Window (widget) handle. | |
4724 * x: X location from the bottom left. | |
4725 * y: Y location from the bottom left. | |
4726 * width: Width of the widget. | |
4727 * height: Height of the widget. | |
4728 */ | |
4729 void dw_window_get_pos_size(HWND handle, ULONG *x, ULONG *y, ULONG *width, ULONG *height) | |
4730 { | |
4731 int _locked_by_me = FALSE; | |
4732 gint gx, gy, gwidth, gheight, gdepth; | |
4733 | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
4734 if(handle && handle->window) |
3 | 4735 { |
4736 DW_MUTEX_LOCK; | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
4737 |
3 | 4738 gdk_window_get_geometry(handle->window, &gx, &gy, &gwidth, &gheight, &gdepth); |
4739 gdk_window_get_root_origin(handle->window, &gx, &gy); | |
4740 if(x) | |
4741 *x = gx; | |
4742 if(y) | |
4743 *y = gy; | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4744 if(GTK_IS_WINDOW(handle)) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4745 { |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4746 if(width) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4747 *width = gwidth + _dw_border_width; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4748 if(height) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4749 *height = gheight + _dw_border_height; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4750 } |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4751 else |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4752 { |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4753 if(width) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4754 *width = gwidth; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4755 if(height) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4756 *height = gheight; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4757 } |
3 | 4758 DW_MUTEX_UNLOCK; |
4759 } | |
4760 } | |
4761 | |
4762 /* | |
4763 * Sets the style of a given window (widget). | |
4764 * Parameters: | |
4765 * handle: Window (widget) handle. | |
4766 * width: New width in pixels. | |
4767 * height: New height in pixels. | |
4768 */ | |
4769 void dw_window_set_style(HWND handle, unsigned long style, unsigned long mask) | |
4770 { | |
4771 GtkWidget *handle2 = handle; | |
4772 int _locked_by_me = FALSE; | |
4773 | |
4774 DW_MUTEX_LOCK; | |
4775 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
4776 { | |
4777 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
4778 if(tmp) | |
4779 handle2 = tmp; | |
4780 } | |
4781 if(GTK_IS_CLIST(handle2)) | |
4782 { | |
4783 if(style & DW_CCS_EXTENDSEL) | |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4784 { |
75
c629838d9805
Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
72
diff
changeset
|
4785 gtk_clist_set_selection_mode(GTK_CLIST(handle2), GTK_SELECTION_EXTENDED); |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4786 gtk_object_set_data(GTK_OBJECT(handle2), "multi", (gpointer)1); |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4787 } |
3 | 4788 if(style & DW_CCS_SINGLESEL) |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4789 { |
3 | 4790 gtk_clist_set_selection_mode(GTK_CLIST(handle2), GTK_SELECTION_SINGLE); |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4791 gtk_object_set_data(GTK_OBJECT(handle2), "multi", (gpointer)0); |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4792 } |
3 | 4793 } |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4794 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
|
4795 { |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4796 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
|
4797 { |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4798 gfloat x, y; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4799 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4800 x = y = DW_LEFT; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4801 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4802 if(style & DW_DT_CENTER) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4803 x = DW_CENTER; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4804 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4805 if(style & DW_DT_VCENTER) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4806 y = DW_CENTER; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4807 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4808 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
|
4809 } |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4810 if(style & DW_DT_WORDBREAK) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4811 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
|
4812 } |
3 | 4813 DW_MUTEX_UNLOCK; |
4814 } | |
4815 | |
4816 /* | |
4817 * Adds a new page to specified notebook. | |
4818 * Parameters: | |
4819 * handle: Window (widget) handle. | |
4820 * flags: Any additional page creation flags. | |
4821 * front: If TRUE page is added at the beginning. | |
4822 */ | |
4823 unsigned long dw_notebook_page_new(HWND handle, unsigned long flags, int front) | |
4824 { | |
4825 int z; | |
4826 int _locked_by_me = FALSE; | |
4827 | |
4828 DW_MUTEX_LOCK; | |
4829 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
|
4830 { |
3 | 4831 if(!gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), z)) |
4832 { | |
4833 DW_MUTEX_UNLOCK; | |
4834 return z; | |
4835 } | |
15
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
4836 } |
3 | 4837 |
4838 DW_MUTEX_UNLOCK; | |
4839 | |
4840 /* Hopefully this won't happen. */ | |
4841 return 256; | |
4842 } | |
4843 | |
4844 /* | |
4845 * Remove a page from a notebook. | |
4846 * Parameters: | |
4847 * handle: Handle to the notebook widget. | |
4848 * pageid: ID of the page to be destroyed. | |
4849 */ | |
4850 void dw_notebook_page_destroy(HWND handle, unsigned int pageid) | |
4851 { | |
4852 int _locked_by_me = FALSE; | |
4853 | |
4854 DW_MUTEX_LOCK; | |
4855 gtk_notebook_remove_page(GTK_NOTEBOOK(handle), pageid); | |
4856 DW_MUTEX_UNLOCK; | |
4857 } | |
4858 | |
4859 /* | |
4860 * Queries the currently visible page ID. | |
4861 * Parameters: | |
4862 * handle: Handle to the notebook widget. | |
4863 */ | |
4864 unsigned int dw_notebook_page_query(HWND handle) | |
4865 { | |
4866 int retval; | |
4867 int _locked_by_me = FALSE; | |
4868 | |
4869 DW_MUTEX_LOCK; | |
4870 retval = gtk_notebook_get_current_page(GTK_NOTEBOOK(handle)); | |
4871 DW_MUTEX_UNLOCK; | |
4872 return retval; | |
4873 } | |
4874 | |
4875 /* | |
4876 * Sets the currently visibale page ID. | |
4877 * Parameters: | |
4878 * handle: Handle to the notebook widget. | |
4879 * pageid: ID of the page to be made visible. | |
4880 */ | |
4881 void dw_notebook_page_set(HWND handle, unsigned int pageid) | |
4882 { | |
4883 int _locked_by_me = FALSE; | |
4884 | |
4885 DW_MUTEX_LOCK; | |
4886 gtk_notebook_set_page(GTK_NOTEBOOK(handle), pageid); | |
4887 DW_MUTEX_UNLOCK; | |
4888 } | |
4889 | |
4890 | |
4891 /* | |
4892 * Sets the text on the specified notebook tab. | |
4893 * Parameters: | |
4894 * handle: Notebook handle. | |
4895 * pageid: Page ID of the tab to set. | |
4896 * text: Pointer to the text to set. | |
4897 */ | |
4898 void dw_notebook_page_set_text(HWND handle, unsigned long pageid, char *text) | |
4899 { | |
4900 GtkWidget *child; | |
4901 int _locked_by_me = FALSE; | |
4902 | |
4903 DW_MUTEX_LOCK; | |
4904 child = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), pageid); | |
4905 if(child) | |
4906 gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(handle), child, text); | |
4907 DW_MUTEX_UNLOCK; | |
4908 } | |
4909 | |
4910 /* | |
4911 * Sets the text on the specified notebook tab status area. | |
4912 * Parameters: | |
4913 * handle: Notebook handle. | |
4914 * pageid: Page ID of the tab to set. | |
4915 * text: Pointer to the text to set. | |
4916 */ | |
4917 void dw_notebook_page_set_status_text(HWND handle, unsigned long pageid, char *text) | |
4918 { | |
4919 /* TODO (if possible) */ | |
4920 } | |
4921 | |
4922 /* | |
4923 * Packs the specified box into the notebook page. | |
4924 * Parameters: | |
4925 * handle: Handle to the notebook to be packed. | |
4926 * pageid: Page ID in the notebook which is being packed. | |
4927 * page: Box handle to be packed. | |
4928 */ | |
4929 void dw_notebook_pack(HWND handle, unsigned long pageid, HWND page) | |
4930 { | |
15
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
4931 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
|
4932 gchar *text = NULL; |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4933 int pad, _locked_by_me = FALSE; |
3 | 4934 |
4935 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
|
4936 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
|
4937 if(child) |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
4938 { |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
4939 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
|
4940 if(oldlabel) |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
4941 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
|
4942 } |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
4943 |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
4944 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
|
4945 |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4946 if(GTK_IS_TABLE(page)) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4947 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4948 pad = (int)gtk_object_get_data(GTK_OBJECT(page), "boxpad"); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4949 gtk_container_border_width(GTK_CONTAINER(page), pad); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4950 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4951 |
15
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
4952 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
|
4953 if(child) |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
4954 gtk_notebook_remove_page(GTK_NOTEBOOK(handle), pageid+1); |
3 | 4955 DW_MUTEX_UNLOCK; |
4956 } | |
4957 | |
4958 /* | |
4959 * Appends the specified text to the listbox's (or combobox) entry list. | |
4960 * Parameters: | |
4961 * handle: Handle to the listbox to be appended to. | |
4962 * text: Text to append into listbox. | |
4963 */ | |
4964 void dw_listbox_append(HWND handle, char *text) | |
4965 { | |
4966 GtkWidget *handle2 = handle; | |
4967 int _locked_by_me = FALSE; | |
4968 | |
4969 DW_MUTEX_LOCK; | |
4970 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
4971 { | |
4972 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
4973 if(tmp) | |
4974 handle2 = tmp; | |
4975 } | |
4976 if(GTK_IS_LIST(handle2)) | |
4977 { | |
4978 GtkWidget *list_item; | |
4979 GList *tmp; | |
4980 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
|
4981 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
|
4982 GdkColor *back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle2), "backgdk"); |
3 | 4983 |
4984 list_item=gtk_list_item_new_with_label(text); | |
4985 | |
4986 if(font) | |
4987 _set_font(GTK_LIST_ITEM(list_item)->item.bin.child, font); | |
4988 if(fore && back) | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
4989 _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
|
4990 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
|
4991 DW_RGB(back->red, back->green, back->blue)); |
3 | 4992 |
4993 tmp = g_list_append(NULL, list_item); | |
4994 gtk_widget_show(list_item); | |
4995 gtk_list_append_items(GTK_LIST(handle2),tmp); | |
4996 } | |
4997 else if(GTK_IS_COMBO(handle2)) | |
4998 { | |
4999 GList *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2)); | |
5000 char *addtext = strdup(text); | |
5001 | |
5002 if(addtext) | |
5003 { | |
5004 tmp = g_list_append(tmp, addtext); | |
5005 gtk_object_set_user_data(GTK_OBJECT(handle2), tmp); | |
5006 gtk_combo_set_popdown_strings(GTK_COMBO(handle2), tmp); | |
5007 } | |
5008 } | |
5009 DW_MUTEX_UNLOCK; | |
5010 } | |
5011 | |
5012 /* | |
5013 * Clears the listbox's (or combobox) list of all entries. | |
5014 * Parameters: | |
5015 * handle: Handle to the listbox to be cleared. | |
5016 */ | |
5017 void dw_listbox_clear(HWND handle) | |
5018 { | |
5019 GtkWidget *handle2 = handle; | |
5020 int _locked_by_me = FALSE; | |
5021 | |
5022 DW_MUTEX_LOCK; | |
5023 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
5024 { | |
5025 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
5026 if(tmp) | |
5027 handle2 = tmp; | |
5028 } | |
5029 if(GTK_IS_COMBO(handle2)) | |
5030 { | |
5031 GList *list, *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2)); | |
5032 | |
5033 if(tmp) | |
5034 { | |
5035 list = tmp; | |
5036 while(list) | |
5037 { | |
5038 if(list->data) | |
5039 free(list->data); | |
5040 list=list->next; | |
5041 } | |
5042 g_list_free(tmp); | |
5043 } | |
5044 gtk_object_set_user_data(GTK_OBJECT(handle2), NULL); | |
5045 } | |
5046 else if(GTK_IS_LIST(handle2)) | |
5047 { | |
5048 int count = dw_listbox_count(handle); | |
5049 | |
5050 gtk_list_clear_items(GTK_LIST(handle2), 0, count - 1); | |
5051 } | |
5052 DW_MUTEX_UNLOCK; | |
5053 } | |
5054 | |
5055 /* | |
5056 * Returns the listbox's item count. | |
5057 * Parameters: | |
5058 * handle: Handle to the listbox to be counted | |
5059 */ | |
5060 int dw_listbox_count(HWND handle) | |
5061 { | |
5062 GtkWidget *handle2 = handle; | |
5063 int retval = 0; | |
5064 int _locked_by_me = FALSE; | |
5065 | |
5066 DW_MUTEX_LOCK; | |
5067 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
5068 { | |
5069 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
5070 if(tmp) | |
5071 handle2 = tmp; | |
5072 } | |
5073 else if(GTK_IS_COMBO(handle)) | |
5074 { | |
5075 handle2 = GTK_COMBO(handle)->list; | |
5076 } | |
5077 if(GTK_IS_LIST(handle2)) | |
5078 { | |
5079 GList *list = GTK_LIST(handle2)->children; | |
5080 while(list) | |
5081 { | |
5082 list = list->next; | |
5083 retval++; | |
5084 } | |
5085 } | |
5086 DW_MUTEX_UNLOCK; | |
5087 return retval; | |
5088 } | |
5089 | |
5090 /* | |
5091 * Sets the topmost item in the viewport. | |
5092 * Parameters: | |
5093 * handle: Handle to the listbox to be cleared. | |
5094 * top: Index to the top item. | |
5095 */ | |
5096 void dw_listbox_set_top(HWND handle, int top) | |
5097 { | |
5098 GtkWidget *handle2 = handle; | |
5099 int _locked_by_me = FALSE; | |
5100 | |
5101 DW_MUTEX_LOCK; | |
5102 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
5103 { | |
5104 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
5105 if(tmp) | |
5106 handle2 = tmp; | |
5107 } | |
5108 if(GTK_IS_LIST(handle2)) | |
5109 { | |
5110 int count = dw_listbox_count(handle); | |
5111 GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(handle)); | |
5112 float pos, ratio; | |
5113 | |
5114 if(count) | |
5115 { | |
5116 ratio = (float)top/(float)count; | |
5117 | |
5118 pos = (ratio * (float)(adj->upper - adj->lower)) + adj->lower; | |
5119 | |
5120 gtk_adjustment_set_value(adj, pos); | |
5121 } | |
5122 } | |
5123 DW_MUTEX_UNLOCK; | |
5124 } | |
5125 | |
5126 /* | |
5127 * Copies the given index item's text into buffer. | |
5128 * Parameters: | |
5129 * handle: Handle to the listbox to be queried. | |
5130 * index: Index into the list to be queried. | |
5131 * buffer: Buffer where text will be copied. | |
5132 * length: Length of the buffer (including NULL). | |
5133 */ | |
5134 void dw_listbox_query_text(HWND handle, unsigned int index, char *buffer, unsigned int length) | |
5135 { | |
5136 GtkWidget *handle2 = handle; | |
5137 int _locked_by_me = FALSE; | |
5138 | |
5139 DW_MUTEX_LOCK; | |
5140 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
5141 { | |
5142 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
5143 if(tmp) | |
5144 handle2 = tmp; | |
5145 } | |
5146 else if(GTK_IS_COMBO(handle)) | |
5147 { | |
5148 handle2 = GTK_COMBO(handle)->list; | |
5149 } | |
5150 if(GTK_IS_LIST(handle2)) | |
5151 { | |
5152 int counter = 0; | |
5153 GList *list = GTK_LIST(handle2)->children; | |
5154 | |
5155 while(list) | |
5156 { | |
5157 if(counter == index) | |
5158 { | |
5159 gchar *text = ""; | |
5160 | |
5161 if(GTK_IS_LIST_ITEM(list->data)) | |
5162 { | |
5163 GtkListItem *li = GTK_LIST_ITEM(list->data); | |
5164 | |
5165 if(GTK_IS_ITEM(&(li->item))) | |
5166 { | |
5167 GtkItem *i = &(li->item); | |
5168 | |
5169 if(GTK_IS_BIN(&(i->bin))) | |
5170 { | |
5171 GtkBin *b = &(i->bin); | |
5172 | |
5173 if(GTK_IS_LABEL(b->child)) | |
5174 gtk_label_get(GTK_LABEL(b->child), &text); | |
5175 } | |
5176 } | |
5177 } | |
5178 else if(GTK_IS_COMBO(handle) && list->data) | |
5179 text = (gchar *)list->data; | |
5180 | |
5181 strncpy(buffer, (char *)text, length); | |
5182 break; | |
5183 } | |
5184 list = list->next; | |
5185 counter++; | |
5186 } | |
5187 } | |
5188 DW_MUTEX_UNLOCK; | |
5189 } | |
5190 | |
5191 /* | |
5192 * Sets the text of a given listbox entry. | |
5193 * Parameters: | |
5194 * handle: Handle to the listbox to be queried. | |
5195 * index: Index into the list to be queried. | |
5196 * buffer: Buffer where text will be copied. | |
5197 */ | |
5198 void dw_listbox_set_text(HWND handle, unsigned int index, char *buffer) | |
5199 { | |
5200 GtkWidget *handle2 = handle; | |
5201 int _locked_by_me = FALSE; | |
5202 | |
5203 DW_MUTEX_LOCK; | |
5204 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
5205 { | |
5206 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
5207 if(tmp) | |
5208 handle2 = tmp; | |
5209 } | |
5210 else if(GTK_IS_COMBO(handle)) | |
5211 { | |
5212 handle2 = GTK_COMBO(handle)->list; | |
5213 } | |
5214 if(GTK_IS_LIST(handle2)) | |
5215 { | |
5216 int counter = 0; | |
5217 GList *list = GTK_LIST(handle2)->children; | |
5218 | |
5219 while(list) | |
5220 { | |
5221 if(counter == index) | |
5222 { | |
5223 | |
5224 if(GTK_IS_LIST_ITEM(list->data)) | |
5225 { | |
5226 GtkListItem *li = GTK_LIST_ITEM(list->data); | |
5227 | |
5228 if(GTK_IS_ITEM(&(li->item))) | |
5229 { | |
5230 GtkItem *i = &(li->item); | |
5231 | |
5232 if(GTK_IS_BIN(&(i->bin))) | |
5233 { | |
5234 GtkBin *b = &(i->bin); | |
5235 | |
5236 if(GTK_IS_LABEL(b->child)) | |
5237 gtk_label_set_text(GTK_LABEL(b->child), buffer); | |
5238 } | |
5239 } | |
5240 } | |
5241 else if(GTK_IS_COMBO(handle)) | |
5242 { | |
5243 if(list->data) | |
5244 g_free(list->data); | |
5245 list->data = g_strdup(buffer); | |
5246 } | |
5247 break; | |
5248 } | |
5249 list = list->next; | |
5250 counter++; | |
5251 } | |
5252 } | |
5253 DW_MUTEX_UNLOCK; | |
5254 } | |
5255 | |
5256 /* | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5257 * Returns the index to the current selected item or -1 when done. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5258 * Parameters: |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5259 * handle: Handle to the listbox to be queried. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5260 * where: Either the previous return or -1 to restart. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5261 */ |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5262 int dw_listbox_selected_multi(HWND handle, int where) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5263 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5264 GtkWidget *handle2 = handle; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5265 int retval = DW_LIT_NONE; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5266 int _locked_by_me = FALSE; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5267 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5268 DW_MUTEX_LOCK; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5269 if(GTK_IS_SCROLLED_WINDOW(handle)) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5270 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5271 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5272 if(tmp) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5273 handle2 = tmp; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5274 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5275 if(GTK_IS_LIST(handle2)) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5276 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5277 int counter = 0; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5278 GList *list = GTK_LIST(handle2)->selection; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5279 while(list) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5280 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5281 if(counter > where) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5282 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5283 retval = counter; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5284 break; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5285 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5286 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5287 list = list->next; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5288 counter++; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5289 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5290 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5291 DW_MUTEX_UNLOCK; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5292 return retval; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5293 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5294 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5295 /* |
3 | 5296 * Returns the index to the item in the list currently selected. |
5297 * Parameters: | |
5298 * handle: Handle to the listbox to be queried. | |
5299 */ | |
5300 unsigned int dw_listbox_selected(HWND handle) | |
5301 { | |
5302 GtkWidget *handle2 = handle; | |
5303 int retval = DW_LIT_NONE; | |
5304 int _locked_by_me = FALSE; | |
5305 | |
5306 DW_MUTEX_LOCK; | |
5307 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
5308 { | |
5309 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
5310 if(tmp) | |
5311 handle2 = tmp; | |
5312 } | |
5313 else if(GTK_IS_COMBO(handle)) | |
5314 { | |
5315 retval = (unsigned int)gtk_object_get_data(GTK_OBJECT(handle), "item"); | |
5316 DW_MUTEX_UNLOCK; | |
5317 return retval; | |
5318 } | |
5319 if(GTK_IS_LIST(handle2)) | |
5320 { | |
5321 int counter = 0; | |
5322 GList *list = GTK_LIST(handle2)->children; | |
5323 while(list) | |
5324 { | |
19
3e5bff3e55ff
Fixed a problem in dw_listbox_selected().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
17
diff
changeset
|
5325 if(list->data == GTK_LIST(handle2)->selection->data) |
3 | 5326 { |
5327 retval = counter; | |
5328 break; | |
5329 } | |
5330 | |
5331 list = list->next; | |
5332 counter++; | |
5333 } | |
5334 } | |
5335 DW_MUTEX_UNLOCK; | |
5336 return retval; | |
5337 } | |
5338 | |
5339 /* | |
5340 * Sets the selection state of a given index. | |
5341 * Parameters: | |
5342 * handle: Handle to the listbox to be set. | |
5343 * index: Item index. | |
5344 * state: TRUE if selected FALSE if unselected. | |
5345 */ | |
5346 void dw_listbox_select(HWND handle, int index, int state) | |
5347 { | |
5348 GtkWidget *handle2 = handle; | |
5349 int _locked_by_me = FALSE; | |
5350 | |
5351 DW_MUTEX_LOCK; | |
5352 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
5353 { | |
5354 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
5355 if(tmp) | |
5356 handle2 = tmp; | |
5357 } | |
5358 else if(GTK_IS_COMBO(handle)) | |
5359 { | |
5360 handle2 = GTK_COMBO(handle)->list; | |
5361 } | |
5362 if(GTK_IS_LIST(handle2)) | |
5363 { | |
5364 if(state) | |
5365 gtk_list_select_item(GTK_LIST(handle2), index); | |
5366 else | |
5367 gtk_list_unselect_item(GTK_LIST(handle2), index); | |
5368 } | |
5369 DW_MUTEX_UNLOCK; | |
5370 } | |
5371 | |
5372 /* | |
5373 * Deletes the item with given index from the list. | |
5374 * Parameters: | |
5375 * handle: Handle to the listbox to be set. | |
5376 * index: Item index. | |
5377 */ | |
5378 void dw_listbox_delete(HWND handle, int index) | |
5379 { | |
5380 GtkWidget *handle2 = handle; | |
5381 int _locked_by_me = FALSE; | |
5382 | |
5383 DW_MUTEX_LOCK; | |
5384 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
5385 { | |
5386 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
5387 if(tmp) | |
5388 handle2 = tmp; | |
5389 } | |
5390 else if(GTK_IS_COMBO(handle)) | |
5391 { | |
5392 handle2 = GTK_COMBO(handle)->list; | |
5393 } | |
5394 if(GTK_IS_LIST(handle2)) | |
5395 gtk_list_clear_items(GTK_LIST(handle2), index, index); | |
5396 DW_MUTEX_UNLOCK; | |
5397 } | |
5398 | |
5399 | |
5400 /* | |
5401 * Pack a splitbar (sizer) into the specified box from the start. | |
5402 * Parameters: | |
5403 * box: Window handle of the box to be packed into. | |
5404 */ | |
5405 void dw_box_pack_splitbar_start(HWND box) | |
5406 { | |
5407 /* TODO */ | |
5408 } | |
5409 | |
5410 /* | |
5411 * Pack a splitbar (sizer) into the specified box from the end. | |
5412 * Parameters: | |
5413 * box: Window handle of the box to be packed into. | |
5414 */ | |
5415 void dw_box_pack_splitbar_end(HWND box) | |
5416 { | |
5417 /* TODO */ | |
5418 } | |
5419 | |
5420 /* | |
5421 * Pack windows (widgets) into a box from the start (or top). | |
5422 * Parameters: | |
5423 * box: Window handle of the box to be packed into. | |
5424 * item: Window handle of the item to be back. | |
5425 * width: Width in pixels of the item or -1 to be self determined. | |
5426 * height: Height in pixels of the item or -1 to be self determined. | |
5427 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. | |
5428 * vsize: TRUE if the window (widget) should expand vertically to fill space given. | |
5429 * pad: Number of pixels of padding around the item. | |
5430 */ | |
5431 void dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) | |
5432 { | |
5433 int _locked_by_me = FALSE; | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
5434 GtkWidget *tmp; |
3 | 5435 |
5436 if(!box) | |
5437 return; | |
5438 | |
5439 DW_MUTEX_LOCK; | |
5440 | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
5441 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
|
5442 box = tmp; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
5443 |
3 | 5444 if(!item) |
5445 { | |
5446 item = gtk_label_new(""); | |
5447 gtk_widget_show(item); | |
5448 } | |
5449 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5450 if(GTK_IS_TABLE(box)) |
3 | 5451 { |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5452 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
|
5453 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
|
5454 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
|
5455 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5456 /* 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
|
5457 * 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
|
5458 * 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
|
5459 * 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
|
5460 */ |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5461 if(GTK_IS_TABLE(item)) |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5462 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5463 GtkWidget *eventbox = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "eventbox"); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5464 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5465 if(eventbox) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5466 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5467 gtk_container_add(GTK_CONTAINER(eventbox), item); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5468 pad = (int)gtk_object_get_data(GTK_OBJECT(item), "boxpad"); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5469 item = eventbox; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5470 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5471 } |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5472 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5473 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
|
5474 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5475 x = 0; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5476 y = boxcount; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5477 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
|
5478 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5479 else |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5480 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5481 x = boxcount; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5482 y = 0; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5483 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
|
5484 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5485 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5486 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
|
5487 gtk_object_set_data(GTK_OBJECT(box), "boxcount", (gpointer)boxcount + 1); |
3 | 5488 gtk_widget_set_usize(item, width, height); |
5489 if(GTK_IS_RADIO_BUTTON(item)) | |
5490 { | |
5491 GSList *group; | |
5492 GtkWidget *groupstart = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(box), "group"); | |
5493 | |
5494 if(groupstart) | |
5495 { | |
5496 group = gtk_radio_button_group(GTK_RADIO_BUTTON(groupstart)); | |
5497 gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group); | |
5498 } | |
5499 else | |
5500 gtk_object_set_data(GTK_OBJECT(box), "group", (gpointer)item); | |
5501 } | |
5502 } | |
5503 else | |
5504 { | |
5505 GtkWidget *vbox = gtk_vbox_new(FALSE, 0); | |
5506 | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5507 if(GTK_IS_TABLE(item)) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5508 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5509 GtkWidget *eventbox = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "eventbox"); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5510 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5511 if(eventbox) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5512 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5513 gtk_container_add(GTK_CONTAINER(eventbox), item); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5514 pad = (int)gtk_object_get_data(GTK_OBJECT(item), "boxpad"); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5515 item = eventbox; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5516 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5517 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5518 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5519 gtk_container_border_width(GTK_CONTAINER(box), pad); |
3 | 5520 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
|
5521 gtk_box_pack_end(GTK_BOX(vbox), item, TRUE, TRUE, 0); |
3 | 5522 gtk_widget_show(vbox); |
5523 | |
5524 gtk_widget_set_usize(item, width, height); | |
5525 gtk_object_set_user_data(GTK_OBJECT(box), vbox); | |
5526 } | |
5527 DW_MUTEX_UNLOCK; | |
5528 } | |
5529 | |
5530 /* | |
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
|
5531 * 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
|
5532 * 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
|
5533 * 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
|
5534 * 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
|
5535 */ |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
5536 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
|
5537 { |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
5538 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
|
5539 |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
5540 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
|
5541 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
|
5542 |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
5543 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
|
5544 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
|
5545 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
|
5546 } |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
5547 |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
5548 /* |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
5549 * 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
|
5550 * Parameters: |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
5551 * 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
|
5552 * 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
|
5553 */ |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
5554 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
|
5555 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
5556 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
|
5557 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
5558 if(!window) |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
5559 return; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
5560 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
5561 DW_MUTEX_LOCK; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
5562 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
|
5563 DW_MUTEX_UNLOCK; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
5564 } |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
5565 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
5566 /* |
3 | 5567 * Returns some information about the current operating environment. |
5568 * Parameters: | |
5569 * env: Pointer to a DWEnv struct. | |
5570 */ | |
5571 void dw_environment_query(DWEnv *env) | |
5572 { | |
5573 struct utsname name; | |
5574 char tempbuf[100]; | |
5575 int len, z; | |
5576 | |
5577 uname(&name); | |
5578 strcpy(env->osName, name.sysname); | |
5579 strcpy(tempbuf, name.release); | |
5580 | |
5581 env->MajorBuild = env->MinorBuild = 0; | |
5582 | |
5583 len = strlen(tempbuf); | |
5584 | |
15
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
5585 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
|
5586 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
|
5587 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
|
5588 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
|
5589 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
|
5590 |
3 | 5591 for(z=1;z<len;z++) |
5592 { | |
5593 if(tempbuf[z] == '.') | |
5594 { | |
5595 tempbuf[z] = '\0'; | |
5596 env->MajorVersion = atoi(&tempbuf[z-1]); | |
5597 env->MinorVersion = atoi(&tempbuf[z+1]); | |
5598 return; | |
5599 } | |
5600 } | |
5601 env->MajorVersion = atoi(tempbuf); | |
5602 env->MinorVersion = 0; | |
5603 } | |
5604 | |
5605 /* 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
|
5606 void _gtk_file_ok(GtkWidget *widget, DWDialog *dwwait) |
3 | 5607 { |
5608 char *tmp; | |
5609 | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5610 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
|
5611 return; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5612 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5613 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
|
5614 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
|
5615 _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
|
5616 dw_dialog_dismiss(dwwait, (void *)(tmp ? strdup(tmp) : NULL)); |
3 | 5617 } |
5618 | |
5619 /* 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
|
5620 void _gtk_file_cancel(GtkWidget *widget, DWDialog *dwwait) |
3 | 5621 { |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5622 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
|
5623 return; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5624 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5625 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
|
5626 _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
|
5627 dw_dialog_dismiss(dwwait, NULL); |
3 | 5628 } |
5629 | |
5630 /* | |
5631 * Opens a file dialog and queries user selection. | |
5632 * Parameters: | |
5633 * title: Title bar text for dialog. | |
5634 * defpath: The default path of the open dialog. | |
5635 * ext: Default file extention. | |
5636 * flags: DW_FILE_OPEN or DW_FILE_SAVE. | |
5637 * Returns: | |
5638 * NULL on error. A malloced buffer containing | |
5639 * the file path on success. | |
5640 * | |
5641 */ | |
5642 char *dw_file_browse(char *title, char *defpath, char *ext, int flags) | |
5643 { | |
5644 GtkWidget *filew; | |
5645 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
|
5646 DWDialog *dwwait; |
3 | 5647 |
5648 DW_MUTEX_LOCK; | |
5649 | |
5650 /* The DW mutex should be sufficient for | |
5651 * insuring no thread changes this unknowingly. | |
5652 */ | |
5653 if(_dw_file_active) | |
5654 { | |
5655 DW_MUTEX_UNLOCK; | |
5656 return NULL; | |
5657 } | |
5658 | |
5659 _dw_file_active = 1; | |
5660 | |
5661 filew = gtk_file_selection_new(title); | |
5662 | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5663 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
|
5664 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5665 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
|
5666 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filew)->cancel_button), "clicked", (GtkSignalFunc) _gtk_file_cancel, dwwait); |
3 | 5667 |
5668 if(defpath) | |
5669 gtk_file_selection_set_filename(GTK_FILE_SELECTION(filew), defpath); | |
5670 | |
5671 gtk_widget_show(filew); | |
5672 | |
5673 DW_MUTEX_UNLOCK; | |
5674 | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5675 return (char *)dw_dialog_wait(dwwait); |
3 | 5676 } |
5677 | |
5678 | |
5679 /* | |
5680 * Execute and external program in a seperate session. | |
5681 * Parameters: | |
5682 * program: Program name with optional path. | |
5683 * type: Either DW_EXEC_CON or DW_EXEC_GUI. | |
5684 * params: An array of pointers to string arguements. | |
5685 * Returns: | |
5686 * -1 on error. | |
5687 */ | |
5688 int dw_exec(char *program, int type, char **params) | |
5689 { | |
5690 int ret = -1; | |
5691 | |
5692 if((ret = fork()) == 0) | |
5693 { | |
5694 int i; | |
5695 | |
5696 for (i = 3; i < 256; i++) | |
5697 close(i); | |
5698 setsid(); | |
5699 if(type == DW_EXEC_GUI) | |
5700 { | |
5701 execvp(program, params); | |
5702 } | |
5703 else if(type == DW_EXEC_CON) | |
5704 { | |
5705 char **tmpargs; | |
5706 | |
5707 if(!params) | |
5708 { | |
5709 tmpargs = malloc(sizeof(char *)); | |
5710 tmpargs[0] = NULL; | |
5711 } | |
5712 else | |
5713 { | |
5714 int z = 0; | |
5715 | |
5716 while(params[z]) | |
5717 { | |
5718 z++; | |
5719 } | |
5720 tmpargs = malloc(sizeof(char *)*(z+3)); | |
5721 z=0; | |
5722 tmpargs[0] = "xterm"; | |
5723 tmpargs[1] = "-e"; | |
5724 while(params[z]) | |
5725 { | |
5726 tmpargs[z+2] = params[z]; | |
5727 z++; | |
5728 } | |
5729 tmpargs[z+2] = NULL; | |
5730 } | |
5731 execvp("xterm", tmpargs); | |
5732 free(tmpargs); | |
5733 } | |
5734 /* If we got here exec failed */ | |
5735 _exit(-1); | |
5736 } | |
5737 return ret; | |
5738 } | |
5739 | |
5740 /* | |
5741 * Loads a web browser pointed at the given URL. | |
5742 * Parameters: | |
5743 * url: Uniform resource locator. | |
5744 */ | |
5745 int dw_browse(char *url) | |
5746 { | |
5747 /* Is there a way to find the webbrowser in Unix? */ | |
5748 char *execargs[3], *browser = "netscape"; | |
5749 | |
5750 execargs[0] = browser; | |
5751 execargs[1] = url; | |
5752 execargs[2] = NULL; | |
5753 | |
5754 return dw_exec(browser, DW_EXEC_GUI, execargs); | |
5755 } | |
5756 | |
5757 /* | |
5758 * Returns a pointer to a static buffer which containes the | |
5759 * current user directory. Or the root directory (C:\ on | |
5760 * OS/2 and Windows). | |
5761 */ | |
5762 char *dw_user_dir(void) | |
5763 { | |
5764 static char _user_dir[1024] = ""; | |
5765 | |
5766 if(!_user_dir[0]) | |
5767 { | |
5768 char *home = getenv("HOME"); | |
5769 | |
5770 if(home) | |
5771 strcpy(_user_dir, home); | |
5772 else | |
5773 strcpy(_user_dir, "/"); | |
5774 } | |
5775 return _user_dir; | |
5776 } | |
5777 | |
5778 /* | |
5779 * Call a function from the window (widget)'s context. | |
5780 * Parameters: | |
5781 * handle: Window handle of the widget. | |
5782 * function: Function pointer to be called. | |
5783 * data: Pointer to the data to be passed to the function. | |
5784 */ | |
5785 void dw_window_function(HWND handle, void *function, void *data) | |
5786 { | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
5787 void (* windowfunc)(void *); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
5788 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
5789 windowfunc = function; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
5790 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
5791 if(windowfunc) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
5792 windowfunc(data); |
3 | 5793 } |
5794 | |
90
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5795 /* |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5796 * Add a named user data item to a window handle. |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5797 * Parameters: |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5798 * window: Window handle of signal to be called back. |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5799 * dataname: A string pointer identifying which signal to be hooked. |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5800 * data: User data to be passed to the handler function. |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5801 */ |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5802 void dw_window_set_data(HWND window, char *dataname, void *data) |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5803 { |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5804 int _locked_by_me = FALSE; |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5805 |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5806 if(!window) |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5807 return; |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5808 |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5809 DW_MUTEX_LOCK; |
112
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
5810 if(GTK_IS_OBJECT(window)) |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
5811 { |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
5812 if(GTK_IS_SCROLLED_WINDOW(window)) |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
5813 { |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
5814 HWND thiswindow = (HWND)gtk_object_get_user_data(GTK_OBJECT(window)); |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
5815 |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
5816 if(thiswindow && GTK_IS_OBJECT(thiswindow)) |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
5817 gtk_object_set_data(GTK_OBJECT(thiswindow), dataname, (gpointer)data); |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
5818 } |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
5819 if(GTK_IS_COMBO(window)) |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
5820 gtk_object_set_data(GTK_OBJECT(GTK_COMBO(window)->entry), dataname, (gpointer)data); |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
5821 gtk_object_set_data(GTK_OBJECT(window), dataname, (gpointer)data); |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
5822 } |
90
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5823 DW_MUTEX_UNLOCK; |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5824 } |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5825 |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5826 /* |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5827 * Gets a named user data item to a window handle. |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5828 * Parameters: |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5829 * window: Window handle of signal to be called back. |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5830 * dataname: A string pointer identifying which signal to be hooked. |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5831 * data: User data to be passed to the handler function. |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5832 */ |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5833 void *dw_window_get_data(HWND window, char *dataname) |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5834 { |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5835 int _locked_by_me = FALSE; |
112
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
5836 void *ret = NULL; |
90
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5837 |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5838 if(!window) |
92
0a085f295e81
A couple more minor changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
91
diff
changeset
|
5839 return NULL; |
90
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5840 |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5841 DW_MUTEX_LOCK; |
112
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
5842 if(GTK_IS_OBJECT(window)) |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
5843 ret = (void *)gtk_object_get_data(GTK_OBJECT(window), dataname); |
90
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5844 DW_MUTEX_UNLOCK; |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5845 return ret; |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5846 } |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
5847 |
3 | 5848 #ifndef NO_SIGNALS |
5849 /* | |
5850 * Add a callback to a window event. | |
5851 * Parameters: | |
5852 * window: Window handle of signal to be called back. | |
5853 * signame: A string pointer identifying which signal to be hooked. | |
5854 * sigfunc: The pointer to the function to be used as the callback. | |
5855 * data: User data to be passed to the handler function. | |
5856 */ | |
5857 void dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data) | |
5858 { | |
5859 SignalHandler *work = malloc(sizeof(SignalHandler)); | |
5860 void *thisfunc = _findsigfunc(signame); | |
5861 char *thisname = signame; | |
5862 HWND thiswindow = window; | |
5863 int _locked_by_me = FALSE; | |
5864 | |
5865 DW_MUTEX_LOCK; | |
5866 if(GTK_IS_SCROLLED_WINDOW(thiswindow)) | |
5867 { | |
5868 thiswindow = (HWND)gtk_object_get_user_data(GTK_OBJECT(window)); | |
5869 } | |
5870 | |
5871 if(GTK_IS_MENU_ITEM(thiswindow) && strcmp(signame, "clicked") == 0) | |
5872 { | |
5873 thisname = "activate"; | |
5874 thisfunc = _findsigfunc(thisname); | |
5875 } | |
5876 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, "container-context") == 0) | |
5877 { | |
5878 thisname = "button_press_event"; | |
5879 thisfunc = _findsigfunc("container-context"); | |
5880 } | |
54
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
5881 else if(GTK_IS_TREE(thiswindow) && strcmp(signame, "container-context") == 0) |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
5882 { |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
5883 thisfunc = _findsigfunc("tree-context"); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
5884 |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
5885 work->window = window; |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
5886 work->data = data; |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
5887 work->func = sigfunc; |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
5888 |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
5889 gtk_object_set_data(GTK_OBJECT(thiswindow), "container-context-func", (gpointer)thisfunc); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
5890 gtk_object_set_data(GTK_OBJECT(thiswindow), "container-context-data", (gpointer)work); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
5891 gtk_signal_connect(GTK_OBJECT(thiswindow), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), work); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
5892 gtk_signal_connect(GTK_OBJECT(window), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), work); |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
5893 DW_MUTEX_UNLOCK; |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
5894 return; |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
5895 } |
3 | 5896 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, "container-select") == 0) |
5897 { | |
5898 thisname = "button_press_event"; | |
5899 thisfunc = _findsigfunc("container-select"); | |
5900 } | |
5901 else if(GTK_IS_COMBO(thiswindow) && strcmp(signame, "item-select") == 0) | |
5902 { | |
5903 thisname = "select_child"; | |
5904 thiswindow = GTK_COMBO(thiswindow)->list; | |
5905 } | |
5906 else if(GTK_IS_LIST(thiswindow) && strcmp(signame, "item-select") == 0) | |
5907 { | |
5908 thisname = "select_child"; | |
5909 } | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
5910 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
|
5911 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
5912 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
|
5913 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
|
5914 thiswindow = GTK_COMBO(thiswindow)->entry; |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
5915 } |
55
b6948eac375a
Sync with the latest dynamic windows, tree fixes, and other miscellaneous
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
54
diff
changeset
|
5916 else if(strcmp(signame, "lose-focus") == 0) |
b6948eac375a
Sync with the latest dynamic windows, tree fixes, and other miscellaneous
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
54
diff
changeset
|
5917 { |
b6948eac375a
Sync with the latest dynamic windows, tree fixes, and other miscellaneous
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
54
diff
changeset
|
5918 thisname = "focus-out-event"; |
b6948eac375a
Sync with the latest dynamic windows, tree fixes, and other miscellaneous
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
54
diff
changeset
|
5919 if(GTK_IS_COMBO(thiswindow)) |
b6948eac375a
Sync with the latest dynamic windows, tree fixes, and other miscellaneous
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
54
diff
changeset
|
5920 thiswindow = GTK_COMBO(thiswindow)->entry; |
b6948eac375a
Sync with the latest dynamic windows, tree fixes, and other miscellaneous
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
54
diff
changeset
|
5921 } |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
5922 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
|
5923 { |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
5924 if(thisfunc) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
5925 { |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
5926 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
|
5927 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
|
5928 } |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
5929 thisname = "select-child"; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
5930 } |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
5931 else if(GTK_IS_VSCALE(thiswindow) || GTK_IS_HSCALE(thiswindow)) |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
5932 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
5933 thiswindow = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(thiswindow), "adjustment"); |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
5934 } |
3 | 5935 |
5936 if(!thisfunc || !thiswindow) | |
5937 { | |
5938 free(work); | |
5939 DW_MUTEX_UNLOCK; | |
5940 return; | |
5941 } | |
5942 | |
5943 work->window = window; | |
5944 work->data = data; | |
5945 work->func = sigfunc; | |
5946 | |
5947 gtk_signal_connect(GTK_OBJECT(thiswindow), thisname, GTK_SIGNAL_FUNC(thisfunc), work); | |
5948 DW_MUTEX_UNLOCK; | |
5949 } | |
5950 | |
5951 /* | |
5952 * Removes callbacks for a given window with given name. | |
5953 * Parameters: | |
5954 * window: Window handle of callback to be removed. | |
5955 */ | |
5956 void dw_signal_disconnect_by_name(HWND window, char *signame) | |
5957 { | |
5958 #if 0 | |
5959 gtk_signal_disconnect_by_name(window, signame); | |
5960 #endif | |
5961 } | |
5962 | |
5963 /* | |
5964 * Removes all callbacks for a given window. | |
5965 * Parameters: | |
5966 * window: Window handle of callback to be removed. | |
5967 */ | |
5968 void dw_signal_disconnect_by_window(HWND window) | |
5969 { | |
5970 #if 0 | |
5971 gtk_signal_disconnect_by_window(window); | |
5972 #endif | |
5973 } | |
5974 | |
5975 /* | |
5976 * Removes all callbacks for a given window with specified data. | |
5977 * Parameters: | |
5978 * window: Window handle of callback to be removed. | |
5979 * data: Pointer to the data to be compared against. | |
5980 */ | |
5981 void dw_signal_disconnect_by_data(HWND window, void *data) | |
5982 { | |
5983 dw_signal_disconnect_by_data(window, data); | |
5984 } | |
5985 #endif | |
5986 | |
5987 #ifdef TEST | |
5988 HWND mainwindow, | |
5989 listbox, | |
5990 okbutton, | |
5991 cancelbutton, | |
5992 lbbox, | |
5993 stext, | |
5994 buttonbox, | |
5995 testwindow, | |
5996 testbox, | |
5997 testok, | |
5998 testcancel, | |
5999 testbox2, | |
6000 testok2, | |
6001 testcancel2, | |
6002 notebook; | |
6003 int count = 2; | |
6004 | |
6005 int test_callback(HWND window, void *data) | |
6006 { | |
6007 dw_window_destroy((HWND)data); | |
6008 /* Return -1 to allow the default handlers to return. */ | |
6009 count--; | |
6010 if(!count) | |
6011 exit(0); | |
6012 return -1; | |
6013 } | |
6014 | |
6015 /* | |
6016 * Let's demonstrate the functionality of this library. :) | |
6017 */ | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6018 int main(int argc, char *argv[]) |
3 | 6019 { |
6020 unsigned long flStyle = DW_FCF_SYSMENU | DW_FCF_TITLEBAR | | |
6021 DW_FCF_SHELLPOSITION | DW_FCF_TASKLIST | DW_FCF_DLGBORDER; | |
6022 int pageid; | |
6023 | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6024 dw_init(TRUE, argc, argv); |
3 | 6025 |
6026 /* Try a little server dialog. :) */ | |
6027 mainwindow = dw_window_new(DW_DESKTOP, "Server", flStyle | DW_FCF_SIZEBORDER | DW_FCF_MINMAX); | |
6028 | |
6029 lbbox = dw_box_new(BOXVERT, 10); | |
6030 | |
6031 dw_box_pack_start(mainwindow, lbbox, 0, 0, TRUE, TRUE, 0); | |
6032 | |
6033 stext = dw_text_new("Choose a server:", 0); | |
6034 | |
6035 dw_window_set_style(stext, DW_DT_VCENTER, DW_DT_VCENTER); | |
6036 | |
6037 dw_box_pack_start(lbbox, stext, 130, 15, FALSE, FALSE, 10); | |
6038 | |
6039 listbox = dw_listbox_new(100L, FALSE); | |
6040 | |
6041 dw_box_pack_start(lbbox, listbox, 130, 200, TRUE, TRUE, 10); | |
6042 | |
6043 buttonbox = dw_box_new(BOXHORZ, 0); | |
6044 | |
6045 dw_box_pack_start(lbbox, buttonbox, 0, 0, TRUE, TRUE, 0); | |
6046 | |
6047 okbutton = dw_button_new("Ok", 1001L); | |
6048 | |
6049 dw_box_pack_start(buttonbox, okbutton, 50, 30, TRUE, TRUE, 5); | |
6050 | |
6051 cancelbutton = dw_button_new("Cancel", 1002L); | |
6052 | |
6053 dw_box_pack_start(buttonbox, cancelbutton, 50, 30, TRUE, TRUE, 5); | |
6054 | |
6055 /* Set some nice fonts and colors */ | |
6056 dw_window_set_color(lbbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); | |
6057 dw_window_set_color(buttonbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); | |
6058 dw_window_set_font(stext, "9.WarpSans"); | |
6059 dw_window_set_color(stext, DW_CLR_BLACK, DW_CLR_PALEGRAY); | |
6060 dw_window_set_font(listbox, "9.WarpSans"); | |
6061 dw_window_set_font(okbutton, "9.WarpSans"); | |
6062 dw_window_set_font(cancelbutton, "9.WarpSans"); | |
6063 | |
6064 dw_window_show(mainwindow); | |
6065 | |
6066 dw_window_set_usize(mainwindow, 170, 340); | |
6067 | |
6068 /* Another small example */ | |
6069 flStyle |= DW_FCF_MINMAX | DW_FCF_SIZEBORDER; | |
6070 | |
6071 testwindow = dw_window_new(DW_DESKTOP, "Wow a test dialog! :) yay!", flStyle); | |
6072 | |
6073 testbox = dw_box_new(BOXVERT, 0); | |
6074 | |
6075 dw_box_pack_start(testwindow, testbox, 0, 0, TRUE, TRUE, 0); | |
6076 | |
6077 notebook = dw_notebook_new(1010L, TRUE); | |
6078 | |
6079 dw_box_pack_start(testbox, notebook, 100, 100, TRUE, TRUE, 0); | |
6080 | |
6081 testbox = dw_box_new(BOXVERT, 10); | |
6082 | |
6083 pageid = dw_notebook_page_new(notebook, 0L, FALSE); | |
6084 | |
6085 dw_notebook_pack(notebook, pageid, testbox); | |
6086 | |
6087 dw_notebook_page_set_text(notebook, pageid, "Test page"); | |
6088 dw_notebook_page_set_status_text(notebook, pageid, "Test page"); | |
6089 | |
6090 testok = dw_button_new("Ok", 1003L); | |
6091 | |
6092 dw_box_pack_start(testbox, testok, 60, 40, TRUE, TRUE, 10); | |
6093 | |
6094 testcancel = dw_button_new("Cancel", 1004L); | |
6095 | |
6096 dw_box_pack_start(testbox, testcancel, 60, 40, TRUE, TRUE, 10); | |
6097 | |
6098 testbox2 = dw_box_new(BOXHORZ, 0); | |
6099 | |
6100 dw_box_pack_start(testbox, testbox2, 0, 0, TRUE, TRUE, 0); | |
6101 | |
6102 testok2 = dw_button_new("Ok", 1003L); | |
6103 | |
6104 dw_box_pack_start(testbox2, testok2, 60, 40, TRUE, TRUE, 10); | |
6105 | |
6106 dw_box_pack_splitbar_start(testbox2); | |
6107 | |
6108 testcancel2 = dw_button_new("Cancel", 1004L); | |
6109 | |
6110 dw_box_pack_start(testbox2, testcancel2, 60, 40, TRUE, TRUE, 10); | |
6111 | |
6112 /* Set some nice fonts and colors */ | |
6113 dw_window_set_color(testbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); | |
6114 dw_window_set_color(testbox2, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); | |
6115 dw_window_set_font(testok, "9.WarpSans"); | |
6116 dw_window_set_font(testcancel, "9.WarpSans"); | |
6117 dw_window_set_font(testok2, "9.WarpSans"); | |
6118 dw_window_set_font(testcancel2, "9.WarpSans"); | |
6119 | |
6120 dw_window_show(testwindow); | |
6121 | |
6122 /* Setup the function callbacks */ | |
6123 dw_signal_connect(okbutton, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); | |
6124 dw_signal_connect(cancelbutton, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); | |
6125 dw_signal_connect(testok, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); | |
6126 dw_signal_connect(testcancel, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); | |
6127 dw_signal_connect(testok2, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); | |
6128 dw_signal_connect(testcancel2, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); | |
6129 dw_signal_connect(mainwindow, "delete_event", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); | |
6130 dw_signal_connect(testwindow, "delete_event", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); | |
6131 | |
6132 dw_main(0L, NULL); | |
6133 | |
6134 return 0; | |
6135 } | |
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
|
6136 #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
|
6137 |