Mercurial > dwindows
annotate gtk/dw.c @ 135:f57ef391f104
For GTK to be thread safe in 2.0 we must call gdk_threads_init().
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 21 Oct 2002 04:29:47 +0000 |
parents | caeb52bb5ef4 |
children | d22b50184e3b |
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> | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
22 #endif |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
23 #if GTK_MAJOR_VERSION > 1 |
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
|
24 #include <gdk-pixbuf/gdk-pixbuf.h> |
3 | 25 #endif |
26 | |
27 /* These are used for resource management */ | |
28 #if defined(DW_RESOURCES) && !defined(BUILD_DLL) | |
29 extern DWResources _resources; | |
30 #endif | |
31 | |
32 char monthlist[][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", | |
33 "Sep", "Oct", "Nov", "Dec" }; | |
34 GdkColor _colors[] = | |
35 { | |
36 { 0, 0x0000, 0x0000, 0x0000 }, /* 0 black */ | |
37 { 0, 0xbbbb, 0x0000, 0x0000 }, /* 1 red */ | |
38 { 0, 0x0000, 0xbbbb, 0x0000 }, /* 2 green */ | |
39 { 0, 0xaaaa, 0xaaaa, 0x0000 }, /* 3 yellow */ | |
40 { 0, 0x0000, 0x0000, 0xcccc }, /* 4 blue */ | |
41 { 0, 0xbbbb, 0x0000, 0xbbbb }, /* 5 magenta */ | |
42 { 0, 0x0000, 0xbbbb, 0xbbbb }, /* 6 cyan */ | |
43 { 0, 0xaaaa, 0xaaaa, 0xaaaa }, /* 7 white */ | |
44 { 0, 0x7777, 0x7777, 0x7777 }, /* 8 grey */ | |
45 { 0, 0xffff, 0x0000, 0x0000 }, /* 9 bright red */ | |
46 { 0, 0x0000, 0xffff, 0x0000 }, /* 10 bright green */ | |
47 { 0, 0xeeee, 0xeeee, 0x0000 }, /* 11 bright yellow */ | |
48 { 0, 0x0000, 0x0000, 0xffff }, /* 12 bright blue */ | |
49 { 0, 0xffff, 0x0000, 0xffff }, /* 13 bright magenta */ | |
50 { 0, 0x0000, 0xeeee, 0xeeee }, /* 14 bright cyan */ | |
51 { 0, 0xffff, 0xffff, 0xffff }, /* 15 bright white */ | |
52 }; | |
53 | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
54 #define DW_THREAD_LIMIT 50 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
55 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
56 DWTID _dw_thread_list[DW_THREAD_LIMIT]; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
57 GdkColor _foreground[DW_THREAD_LIMIT]; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
58 GdkColor _background[DW_THREAD_LIMIT]; |
3 | 59 |
93
98cce029a611
Changed handling of menu item click events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
92
diff
changeset
|
60 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
|
61 |
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
|
62 int _dw_file_active = 0, _dw_ignore_click = 0, _dw_unselecting = 0; |
3 | 63 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
|
64 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
|
65 /* 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
|
66 int _dw_border_width = 12, _dw_border_height = 28; |
3 | 67 |
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
|
68 #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
|
69 #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 | 70 |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
71 #define DEFAULT_SIZE_WIDTH 12 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
72 #define DEFAULT_SIZE_HEIGHT 6 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
73 #define DEFAULT_TITLEBAR_HEIGHT 22 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
74 |
3 | 75 GdkColormap *_dw_cmap = NULL; |
76 | |
77 /* Signal forwarder prototypes */ | |
78 gint _button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data); | |
79 gint _button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer data); | |
80 gint _motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer data); | |
81 gint _delete_event(GtkWidget *widget, GdkEvent *event, gpointer data); | |
82 gint _key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data); | |
83 gint _generic_event(GtkWidget *widget, gpointer data); | |
84 gint _configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data); | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
85 gint _activate_event(GtkWidget *widget, gpointer data); |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
86 gint _container_select_event(GtkWidget *widget, GdkEventButton *event, gpointer data); |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
87 gint _container_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data); |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
88 gint _item_select_event(GtkWidget *widget, GtkWidget *child, gpointer data); |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
89 gint _expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data); |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
90 gint _set_focus_event(GtkWindow *window, GtkWidget *widget, gpointer data); |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
91 gint _tree_select_event(GtkTree *tree, GtkWidget *child, gpointer data); |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
92 gint _tree_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data); |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
93 gint _value_changed_event(GtkAdjustment *adjustment, gpointer user_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 |
3 | 95 |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
96 void msleep(long period); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
97 |
3 | 98 typedef struct |
99 { | |
100 void *func; | |
101 char name[30]; | |
102 | |
103 } SignalList; | |
104 | |
105 typedef struct | |
106 { | |
107 HWND window; | |
108 void *func; | |
109 gpointer data; | |
110 | |
111 } SignalHandler; | |
112 | |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
113 #define SIGNALMAX 16 |
3 | 114 |
115 /* A list of signal forwarders, to account for paramater differences. */ | |
116 SignalList SignalTranslate[SIGNALMAX] = { | |
117 { _configure_event, "configure_event" }, | |
118 { _key_press_event, "key_press_event" }, | |
119 { _button_press_event, "button_press_event" }, | |
120 { _button_release_event, "button_release_event" }, | |
121 { _motion_notify_event, "motion_notify_event" }, | |
122 { _delete_event, "delete_event" }, | |
123 { _expose_event, "expose_event" }, | |
124 { _activate_event, "activate" }, | |
125 { _generic_event, "clicked" }, | |
126 { _container_select_event, "container-select" }, | |
127 { _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
|
128 { _tree_context_event, "tree-context" }, |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
129 { _item_select_event, "item-select" }, |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
130 { _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
|
131 { _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
|
132 { _value_changed_event, "value_changed" } |
3 | 133 }; |
134 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
135 /* Alignment flags */ |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
136 #define DW_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
|
137 #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
|
138 #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
|
139 |
3 | 140 /* Finds the translation function for a given signal name */ |
141 void *_findsigfunc(char *signame) | |
142 { | |
143 int z; | |
144 | |
145 for(z=0;z<SIGNALMAX;z++) | |
146 { | |
147 if(strcasecmp(signame, SignalTranslate[z].name) == 0) | |
148 return SignalTranslate[z].func; | |
149 } | |
150 return NULL; | |
151 } | |
152 | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
153 gint _set_focus_event(GtkWindow *window, GtkWidget *widget, gpointer data) |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
154 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
155 SignalHandler *work = (SignalHandler *)data; |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
156 int retval = FALSE; |
14
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 |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
162 retval = setfocusfunc((HWND)window, work->data); |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
163 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
164 return retval; |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
165 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
166 |
3 | 167 gint _button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data) |
168 { | |
169 SignalHandler *work = (SignalHandler *)data; | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
170 int retval = FALSE; |
3 | 171 |
172 if(work) | |
173 { | |
174 int (*buttonfunc)(HWND, int, int, int, void *) = work->func; | |
175 int mybutton = event->button; | |
176 | |
177 if(event->button == 3) | |
178 mybutton = 2; | |
179 else if(event->button == 2) | |
180 mybutton = 3; | |
181 | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
182 retval = buttonfunc(widget, event->x, event->y, mybutton, work->data); |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
183 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
184 return retval; |
3 | 185 } |
186 | |
187 gint _button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer data) | |
188 { | |
189 SignalHandler *work = (SignalHandler *)data; | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
190 int retval = FALSE; |
3 | 191 |
192 if(work) | |
193 { | |
194 int (*buttonfunc)(HWND, int, int, int, void *) = work->func; | |
195 int mybutton = event->button; | |
196 | |
197 if(event->button == 3) | |
198 mybutton = 2; | |
199 else if(event->button == 2) | |
200 mybutton = 3; | |
201 | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
202 retval = buttonfunc(widget, event->x, event->y, mybutton, work->data); |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
203 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
204 return retval; |
3 | 205 } |
206 | |
207 gint _motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer data) | |
208 { | |
209 SignalHandler *work = (SignalHandler *)data; | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
210 int retval = FALSE; |
3 | 211 |
212 if(work) | |
213 { | |
214 int (*motionfunc)(HWND, int, int, int, void *) = work->func; | |
215 int keys = 0, x, y; | |
216 GdkModifierType state; | |
217 | |
218 if (event->is_hint) | |
219 gdk_window_get_pointer (event->window, &x, &y, &state); | |
220 else | |
221 { | |
222 x = event->x; | |
223 y = event->y; | |
224 state = event->state; | |
225 } | |
226 | |
227 if (state & GDK_BUTTON1_MASK) | |
228 keys = DW_BUTTON1_MASK; | |
229 if (state & GDK_BUTTON3_MASK) | |
230 keys |= DW_BUTTON2_MASK; | |
231 if (state & GDK_BUTTON2_MASK) | |
232 keys |= DW_BUTTON3_MASK; | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
233 |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
234 retval = motionfunc(widget, x, y, keys, work->data); |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
235 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
236 return retval; |
3 | 237 } |
238 | |
239 gint _delete_event(GtkWidget *widget, GdkEvent *event, gpointer data) | |
240 { | |
241 SignalHandler *work = (SignalHandler *)data; | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
242 int retval = FALSE; |
3 | 243 |
244 if(work) | |
245 { | |
246 int (*closefunc)(HWND, void *) = work->func; | |
247 | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
248 retval = closefunc(widget, work->data); |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
249 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
250 return retval; |
3 | 251 } |
252 | |
253 gint _key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data) | |
254 { | |
255 SignalHandler *work = (SignalHandler *)data; | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
256 int retval = FALSE; |
3 | 257 |
258 if(work) | |
259 { | |
260 int (*keypressfunc)(HWND, int, void *) = work->func; | |
261 | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
262 retval = keypressfunc(widget, *event->string, work->data); |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
263 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
264 return retval; |
3 | 265 } |
266 | |
267 gint _generic_event(GtkWidget *widget, gpointer data) | |
268 { | |
269 SignalHandler *work = (SignalHandler *)data; | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
270 int retval = FALSE; |
3 | 271 |
272 if(work) | |
273 { | |
274 int (*genericfunc)(HWND, void *) = work->func; | |
275 | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
276 retval = genericfunc(widget, work->data); |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
277 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
278 return retval; |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
279 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
280 |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
281 gint _activate_event(GtkWidget *widget, gpointer data) |
3 | 282 { |
283 SignalHandler *work = (SignalHandler *)data; | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
284 int retval = FALSE; |
3 | 285 |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
286 if(work && !_dw_ignore_click) |
3 | 287 { |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
288 int (*activatefunc)(HWND, void *) = work->func; |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
289 |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
290 retval = activatefunc(popup ? popup : work->window, work->data); |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
291 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
292 return retval; |
3 | 293 } |
294 | |
295 gint _configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data) | |
296 { | |
297 SignalHandler *work = (SignalHandler *)data; | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
298 int retval = FALSE; |
3 | 299 |
300 if(work) | |
301 { | |
302 int (*sizefunc)(HWND, int, int, void *) = work->func; | |
303 | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
304 retval = sizefunc(widget, event->width, event->height, work->data); |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
305 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
306 return retval; |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
307 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
308 |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
309 gint _expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data) |
3 | 310 { |
311 SignalHandler *work = (SignalHandler *)data; | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
312 int retval = FALSE; |
3 | 313 |
314 if(work) | |
315 { | |
316 DWExpose exp; | |
317 int (*exposefunc)(HWND, DWExpose *, void *) = work->func; | |
318 | |
319 exp.x = event->area.x; | |
320 exp.y = event->area.y; | |
321 exp.width = event->area.width; | |
322 exp.height = event->area.height; | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
323 retval = exposefunc(widget, &exp, work->data); |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
324 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
325 return retval; |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
326 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
327 |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
328 gint _item_select_event(GtkWidget *widget, GtkWidget *child, gpointer data) |
3 | 329 { |
330 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
|
331 static int _dw_recursing = 0; |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
332 int retval = FALSE; |
39
3aa9ef0b3996
Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
37
diff
changeset
|
333 |
3aa9ef0b3996
Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
37
diff
changeset
|
334 if(_dw_recursing) |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
335 return FALSE; |
3 | 336 |
337 if(work) | |
338 { | |
339 int (*selectfunc)(HWND, int, void *) = work->func; | |
340 GList *list; | |
341 int item = 0; | |
342 | |
39
3aa9ef0b3996
Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
37
diff
changeset
|
343 _dw_recursing = 1; |
3aa9ef0b3996
Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
37
diff
changeset
|
344 |
3 | 345 if(GTK_IS_COMBO(work->window)) |
346 list = GTK_LIST(GTK_COMBO(work->window)->list)->children; | |
347 else if(GTK_IS_LIST(widget)) | |
348 list = GTK_LIST(widget)->children; | |
349 else | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
350 return FALSE; |
3 | 351 |
352 while(list) | |
353 { | |
354 if(list->data == (gpointer)child) | |
355 { | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
356 if(!gtk_object_get_data(GTK_OBJECT(work->window), "appending")) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
357 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
358 gtk_object_set_data(GTK_OBJECT(work->window), "item", (gpointer)item); |
115
2d121d4d90c0
Run the _item_select_event() handler on comboboxes even if a handler
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
114
diff
changeset
|
359 if(selectfunc) |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
360 retval = selectfunc(work->window, item, work->data); |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
361 } |
3 | 362 break; |
363 } | |
364 item++; | |
365 list = list->next; | |
366 } | |
39
3aa9ef0b3996
Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
37
diff
changeset
|
367 _dw_recursing = 0; |
3 | 368 } |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
369 return retval; |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
370 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
371 |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
372 gint _container_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data) |
3 | 373 { |
374 SignalHandler *work = (SignalHandler *)data; | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
375 int retval = FALSE; |
3 | 376 |
377 if(work) | |
378 { | |
379 if(event->button == 3) | |
380 { | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
381 int (*contextfunc)(HWND, char *, int, int, void *) = work->func; |
3 | 382 char *text; |
383 int row, col; | |
384 | |
385 gtk_clist_get_selection_info(GTK_CLIST(widget), event->x, event->y, &row, &col); | |
386 | |
387 text = (char *)gtk_clist_get_row_data(GTK_CLIST(widget), row); | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
388 retval = contextfunc(work->window, text, event->x, event->y, work->data); |
3 | 389 } |
390 } | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
391 return retval; |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
392 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
393 |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
394 gint _tree_context_event(GtkWidget *widget, GdkEventButton *event, 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
|
395 { |
c4e1139d9872
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 SignalHandler *work = (SignalHandler *)data; |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
397 int retval = FALSE; |
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
|
398 |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
399 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
|
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 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
|
402 { |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
403 int (*contextfunc)(HWND, char *, int, int, void *, void *) = work->func; |
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
|
404 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
|
405 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
|
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 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
|
408 { |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
409 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
|
410 |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
411 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
|
412 { |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
413 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
|
414 |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
415 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
|
416 { |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
417 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
|
418 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
|
419 } |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
420 } |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
421 } |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
422 |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
423 retval = contextfunc(work->window, text, event->x, event->y, work->data, itemdata); |
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
|
424 } |
c4e1139d9872
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 } |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
426 return retval; |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
427 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
428 |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
429 gint _tree_select_event(GtkTree *tree, GtkWidget *child, gpointer data) |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
430 { |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
431 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
|
432 GtkWidget *treeroot = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(child), "tree"); |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
433 int retval = FALSE; |
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
|
434 |
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
|
435 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
|
436 { |
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
|
437 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
|
438 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
|
439 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
|
440 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
|
441 } |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
442 |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
443 if(work) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
444 { |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
445 int (*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
|
446 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
|
447 void *itemdata = (char *)gtk_object_get_data(GTK_OBJECT(child), "itemdata"); |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
448 retval = treeselectfunc(work->window, child, text, itemdata, work->data); |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
449 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
450 return retval; |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
451 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
452 |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
453 gint _container_select_event(GtkWidget *widget, GdkEventButton *event, gpointer data) |
3 | 454 { |
455 SignalHandler *work = (SignalHandler *)data; | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
456 int retval = FALSE; |
3 | 457 |
458 if(work) | |
459 { | |
460 if(event->button == 1 && event->type == GDK_2BUTTON_PRESS) | |
461 { | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
462 int (*contextfunc)(HWND, char *, void *) = work->func; |
3 | 463 char *text; |
464 int row, col; | |
465 | |
466 gtk_clist_get_selection_info(GTK_CLIST(widget), event->x, event->y, &row, &col); | |
467 | |
468 text = (char *)gtk_clist_get_row_data(GTK_CLIST(widget), row); | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
469 retval = contextfunc(work->window, text, work->data); |
3 | 470 } |
471 } | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
472 return retval; |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
473 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
474 |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
475 gint _select_row(GtkWidget *widget, gint row, gint column, GdkEventButton *event, gpointer data) |
3 | 476 { |
477 GList *tmp = (GList *)gtk_object_get_data(GTK_OBJECT(widget), "selectlist"); | |
478 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
|
479 int multi = (int)gtk_object_get_data(GTK_OBJECT(widget), "multi"); |
3 | 480 |
481 if(rowdata) | |
482 { | |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
483 if(!multi) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
484 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
485 g_list_free(tmp); |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
486 tmp = NULL; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
487 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
488 |
3 | 489 tmp = g_list_append(tmp, rowdata); |
490 gtk_object_set_data(GTK_OBJECT(widget), "selectlist", tmp); | |
491 } | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
492 return FALSE; |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
493 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
494 |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
495 gint _unselect_row(GtkWidget *widget, gint row, gint column, GdkEventButton *event, gpointer data) |
3 | 496 { |
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
|
497 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
|
498 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
|
499 |
c629838d9805
Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
72
diff
changeset
|
500 if(_dw_unselecting) |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
501 return FALSE; |
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
|
502 |
c629838d9805
Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
72
diff
changeset
|
503 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
|
504 rowdata = gtk_clist_get_row_data(GTK_CLIST(widget), row); |
3 | 505 |
76
ce0f5528bab0
Fixed clist crashing problems on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
75
diff
changeset
|
506 if(rowdata && tmp) |
3 | 507 { |
76
ce0f5528bab0
Fixed clist crashing problems on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
75
diff
changeset
|
508 tmp = g_list_remove(tmp, rowdata); |
3 | 509 gtk_object_set_data(GTK_OBJECT(widget), "selectlist", tmp); |
510 } | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
511 return FALSE; |
3 | 512 } |
513 | |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
514 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
|
515 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
516 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
|
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 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
|
519 newval++; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
520 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
521 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
|
522 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
523 |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
524 gint _value_changed_event(GtkAdjustment *adjustment, 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
|
525 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
526 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
|
527 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
|
528 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
529 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
|
530 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
531 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
|
532 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
|
533 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
|
534 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
|
535 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
|
536 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
537 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
|
538 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
539 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
|
540 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
|
541 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
|
542 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
|
543 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
544 } |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
545 return FALSE; |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
546 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
547 |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
548 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
|
549 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
550 GtkWidget *next = (GtkWidget *)data; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
551 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
552 if(next) |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
553 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
554 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
|
555 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
556 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
|
557 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
|
558 else |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
559 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
|
560 } |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
561 } |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
562 return FALSE; |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
563 } |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
564 |
121
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
565 GdkPixmap *_find_pixmap(GdkBitmap **bitmap, long id, HWND handle, unsigned long *userwidth, unsigned long *userheight) |
3 | 566 { |
567 char *data = NULL; | |
568 int z; | |
569 | |
570 for(z=0;z<_resources.resource_max;z++) | |
571 { | |
572 if(_resources.resource_id[z] == id) | |
573 { | |
574 data = _resources.resource_data[z]; | |
575 break; | |
576 } | |
577 } | |
578 | |
579 if(data) | |
580 { | |
581 GdkPixmap *icon_pixmap = NULL; | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
582 #if GTK_MAJOR_VERSION > 1 |
121
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
583 GdkPixbuf *icon_pixbuf = gdk_pixbuf_new_from_xpm_data((const char **)data); |
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
584 |
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
585 if(userwidth) |
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
586 *userwidth = gdk_pixbuf_get_width(icon_pixbuf); |
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
587 if(userheight) |
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
588 *userheight = gdk_pixbuf_get_height(icon_pixbuf); |
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
589 |
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
590 gdk_pixbuf_render_pixmap_and_mask(icon_pixbuf, &icon_pixmap, bitmap, 1); |
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
591 g_object_unref(icon_pixbuf); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
592 #elif defined(USE_IMLIB) |
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
|
593 gdk_imlib_data_to_pixmap((char **)data, &icon_pixmap, bitmap); |
3 | 594 #else |
121
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
595 icon_pixmap = gdk_pixmap_create_from_xpm_d(handle->window, bitmap, &_colors[DW_CLR_PALEGRAY], (char **)data); |
3 | 596 #endif |
597 return icon_pixmap; | |
598 } | |
599 return NULL; | |
600 } | |
601 | |
602 void _size_allocate(GtkWindow *window) | |
603 { | |
604 XSizeHints sizehints; | |
605 | |
606 sizehints.base_width = 1; | |
607 sizehints.base_height = 1; | |
608 sizehints.width_inc = 1; | |
609 sizehints.height_inc = 1; | |
610 sizehints.min_width = 8; | |
611 sizehints.min_height = 8; | |
612 | |
613 sizehints.flags = (PBaseSize|PMinSize|PResizeInc); | |
614 | |
615 XSetWMNormalHints (GDK_DISPLAY(), | |
616 GDK_WINDOW_XWINDOW (GTK_WIDGET (window)->window), | |
617 &sizehints); | |
618 gdk_flush (); | |
619 } | |
620 | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
621 /* Find the index of a given thread */ |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
622 int _find_thread_index(DWTID tid) |
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 int 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 for(z=0;z<DW_THREAD_LIMIT;z++) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
627 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
628 if(_dw_thread_list[z] == tid) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
629 return z; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
630 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
631 return 0; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
632 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
633 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
634 /* Add a thread id to the thread list */ |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
635 void _dw_thread_add(DWTID tid) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
636 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
637 int z; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
638 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
639 for(z=0;z<DW_THREAD_LIMIT;z++) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
640 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
641 if(_dw_thread_list[z] == (DWTID)-1) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
642 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
643 _dw_thread_list[z] = tid; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
644 _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
|
645 _background[z].pixel = 0; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
646 _background[z].red = 0xaaaa; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
647 _background[z].green = 0xaaaa; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
648 _background[z].blue = 0xaaaa; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
649 return; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
650 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
651 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
652 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
653 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
654 /* Remove a thread id to the thread list */ |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
655 void _dw_thread_remove(DWTID tid) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
656 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
657 int z; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
658 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
659 for(z=0;z<DW_THREAD_LIMIT;z++) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
660 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
661 if(_dw_thread_list[z] == (DWTID)tid) |
51
d97de82f0b6e
Fix warning on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
49
diff
changeset
|
662 _dw_thread_list[z] = (DWTID)-1; |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
663 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
664 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
665 |
3 | 666 /* |
667 * Initializes the Dynamic Windows engine. | |
668 * Parameters: | |
669 * newthread: True if this is the only thread. | |
670 * False if there is already a message loop running. | |
671 */ | |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
672 int dw_int_init(DWResources *res, int newthread, int *argc, char **argv[]) |
3 | 673 { |
674 int z; | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
675 char *tmp; |
3 | 676 |
677 if(res) | |
678 { | |
679 _resources.resource_max = res->resource_max; | |
680 _resources.resource_id = res->resource_id; | |
681 _resources.resource_data = res->resource_data; | |
682 } | |
683 gtk_set_locale(); | |
684 g_thread_init(NULL); | |
135
f57ef391f104
For GTK to be thread safe in 2.0 we must call gdk_threads_init().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
134
diff
changeset
|
685 #if GTK_MAJOR_VERSION > 1 |
f57ef391f104
For GTK to be thread safe in 2.0 we must call gdk_threads_init().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
134
diff
changeset
|
686 gdk_threads_init(); |
f57ef391f104
For GTK to be thread safe in 2.0 we must call gdk_threads_init().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
134
diff
changeset
|
687 #endif |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
688 |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
689 gtk_init(argc, argv); |
3 | 690 #ifdef USE_IMLIB |
691 gdk_imlib_init(); | |
692 #endif | |
693 /* Add colors to the system colormap */ | |
694 _dw_cmap = gdk_colormap_get_system(); | |
695 for(z=0;z<16;z++) | |
696 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
|
697 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
698 tmp = getenv("DW_BORDER_WIDTH"); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
699 if(tmp) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
700 _dw_border_width = atoi(tmp); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
701 tmp = getenv("DW_BORDER_HEIGHT"); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
702 if(tmp) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
703 _dw_border_height = atoi(tmp); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
704 |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
705 for(z=0;z<DW_THREAD_LIMIT;z++) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
706 _dw_thread_list[z] = (DWTID)-1; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
707 |
77
002da4d18ac6
Set tooltip background color to yellow.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
76
diff
changeset
|
708 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
|
709 |
3 | 710 return TRUE; |
711 } | |
712 | |
713 /* | |
714 * Runs a message loop for Dynamic Windows. | |
715 * Parameters: | |
716 * currenthab: The handle to the current anchor block | |
717 * or NULL if this DW is handling the message loop. | |
718 * func: Function pointer to the message filter function. | |
719 */ | |
720 void dw_main(HAB currenthab, void *func) | |
721 { | |
722 _dw_thread = pthread_self(); | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
723 _dw_thread_add(_dw_thread); |
3 | 724 gdk_threads_enter(); |
725 gtk_main(); | |
726 gdk_threads_leave(); | |
727 } | |
728 | |
729 /* | |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
730 * 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
|
731 * 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
|
732 * 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
|
733 */ |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
734 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
|
735 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
736 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
|
737 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
738 gettimeofday(&start, NULL); |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
739 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
740 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
|
741 { |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
742 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
|
743 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
744 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
|
745 { |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
746 gdk_threads_enter(); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
747 if(gtk_events_pending()) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
748 gtk_main_iteration(); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
749 else |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
750 msleep(1); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
751 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
|
752 gettimeofday(&tv, NULL); |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
753 } |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
754 } |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
755 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
|
756 msleep(milliseconds); |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
757 } |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
758 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
759 /* |
3 | 760 * Free's memory allocated by dynamic windows. |
761 * Parameters: | |
762 * ptr: Pointer to dynamic windows allocated | |
763 * memory to be free()'d. | |
764 */ | |
765 void dw_free(void *ptr) | |
766 { | |
767 free(ptr); | |
768 } | |
769 | |
770 /* | |
771 * Allocates and initializes a dialog struct. | |
772 * Parameters: | |
773 * data: User defined data to be passed to functions. | |
774 */ | |
775 DWDialog *dw_dialog_new(void *data) | |
776 { | |
777 DWDialog *tmp = malloc(sizeof(DWDialog)); | |
778 | |
779 tmp->eve = dw_event_new(); | |
780 dw_event_reset(tmp->eve); | |
781 tmp->data = data; | |
782 tmp->done = FALSE; | |
783 tmp->result = NULL; | |
784 | |
785 return tmp; | |
786 } | |
787 | |
788 /* | |
789 * Accepts a dialog struct and returns the given data to the | |
790 * initial called of dw_dialog_wait(). | |
791 * Parameters: | |
792 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). | |
793 * result: Data to be returned by dw_dialog_wait(). | |
794 */ | |
795 int dw_dialog_dismiss(DWDialog *dialog, void *result) | |
796 { | |
797 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
|
798 if(pthread_self() == _dw_thread || _dw_thread == (pthread_t)-1) |
3 | 799 gtk_main_quit(); |
800 else | |
801 dw_event_post(dialog->eve); | |
802 dialog->done = TRUE; | |
803 return 0; | |
804 } | |
805 | |
806 /* | |
807 * Accepts a dialog struct waits for dw_dialog_dismiss() to be | |
808 * called by a signal handler with the given dialog struct. | |
809 * Parameters: | |
810 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). | |
811 */ | |
812 void *dw_dialog_wait(DWDialog *dialog) | |
813 { | |
814 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
|
815 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
|
816 |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
817 /* _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
|
818 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
|
819 { |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
820 _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
|
821 newprocess = 1; |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
822 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
|
823 } |
3 | 824 |
825 if(pthread_self() == _dw_thread) | |
826 gtk_main(); | |
827 else | |
828 dw_event_wait(dialog->eve, -1); | |
829 | |
41
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
830 if(newprocess) |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
831 { |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
832 _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
|
833 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
|
834 } |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
835 |
3 | 836 dw_event_close(&dialog->eve); |
837 tmp = dialog->result; | |
838 free(dialog); | |
839 return tmp; | |
840 } | |
841 | |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
842 int _delete(GtkWidget *widget, GtkWidget *event, gpointer param) |
3 | 843 { |
844 gtk_widget_destroy(GTK_WIDGET(param)); | |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
845 return FALSE; |
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
846 } |
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
847 |
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
848 int _delete2(GtkWidget *widget, gpointer param) |
3 | 849 { |
850 gtk_widget_destroy(GTK_WIDGET(param)); | |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
851 return FALSE; |
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
852 } |
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
853 |
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
854 |
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
855 int _dw_ok_func(HWND window, void *data) |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
856 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
857 DWDialog *dwwait = (DWDialog *)data; |
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 if(!dwwait) |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
860 return FALSE; |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
861 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
862 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
|
863 dw_dialog_dismiss((DWDialog *)data, (void *)0); |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
864 return FALSE; |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
865 } |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
866 |
3 | 867 /* |
868 * Displays a Message Box with given text and title.. | |
869 * Parameters: | |
870 * title: The title of the message box. | |
871 * format: printf style format string. | |
872 * ...: Additional variables for use in the format. | |
873 */ | |
874 int dw_messagebox(char *title, char *format, ...) | |
875 { | |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
876 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
|
877 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
|
878 DWDialog *dwwait; |
3 | 879 va_list args; |
880 char outbuf[256]; | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
881 int x, y; |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
882 |
3 | 883 va_start(args, format); |
884 vsprintf(outbuf, format, args); | |
885 va_end(args); | |
886 | |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
887 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
|
888 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
|
889 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
|
890 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
891 /* Archive Name */ |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
892 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
|
893 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
|
894 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
895 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
|
896 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
897 /* Buttons */ |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
898 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
|
899 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
900 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
|
901 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
902 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
|
903 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
904 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
|
905 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
906 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
|
907 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
908 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
|
909 |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
910 x = (dw_screen_width() - 220)/2; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
911 y = (dw_screen_height() - 110)/2; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
912 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
913 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
|
914 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
915 dw_window_show(entrywindow); |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
916 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
917 dw_dialog_wait(dwwait); |
3 | 918 |
919 return strlen(outbuf); | |
920 } | |
921 | |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
922 int _dw_yes_func(HWND window, void *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
|
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 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
|
925 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
926 if(!dwwait) |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
927 return 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
|
928 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
929 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
|
930 dw_dialog_dismiss((DWDialog *)data, (void *)1); |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
931 return FALSE; |
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
932 } |
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
933 |
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
934 int _dw_no_func(HWND window, void *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
|
935 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
936 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
|
937 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
938 if(!dwwait) |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
939 return 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
|
940 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
941 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
|
942 dw_dialog_dismiss((DWDialog *)data, (void *)0); |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
943 return 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
|
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 |
3 | 946 /* |
947 * Displays a Message Box with given text and title.. | |
948 * Parameters: | |
949 * title: The title of the message box. | |
950 * text: The text to display in the box. | |
951 * Returns: | |
952 * True if YES False of NO. | |
953 */ | |
954 int dw_yesno(char *title, char *text) | |
955 { | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
956 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
|
957 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
|
958 DWDialog *dwwait; |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
959 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
|
960 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
961 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
|
962 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
963 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
|
964 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
965 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
|
966 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
967 /* 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
|
968 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
|
969 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
|
970 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
971 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
|
972 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
973 /* Buttons */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
974 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
|
975 |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
976 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
|
977 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
978 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
|
979 |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
980 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
|
981 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
982 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
|
983 |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
984 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
|
985 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
986 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
|
987 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
988 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
|
989 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
|
990 |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
991 x = (dw_screen_width() - 220)/2; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
992 y = (dw_screen_height() - 110)/2; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
993 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
994 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
|
995 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
996 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
|
997 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
998 return (int)dw_dialog_wait(dwwait);; |
3 | 999 } |
1000 | |
1001 /* | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1002 * 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
|
1003 * Parameters: |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1004 * handle: The window handle to minimize. |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1005 */ |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1006 int dw_window_minimize(HWND handle) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1007 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1008 int _locked_by_me = FALSE; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1009 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1010 if(!handle) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1011 return 0; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1012 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1013 DW_MUTEX_LOCK; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1014 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
|
1015 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
|
1016 DefaultScreen (GDK_DISPLAY ())); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1017 DW_MUTEX_UNLOCK; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1018 return 0; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1019 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1020 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1021 /* |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1022 * Makes the window topmost. |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1023 * Parameters: |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1024 * 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
|
1025 */ |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1026 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
|
1027 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1028 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
|
1029 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1030 if(!handle) |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1031 return 0; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1032 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1033 DW_MUTEX_LOCK; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1034 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
|
1035 DW_MUTEX_UNLOCK; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1036 return 0; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1037 } |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1038 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1039 /* |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1040 * Makes the window bottommost. |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1041 * Parameters: |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1042 * 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
|
1043 */ |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1044 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
|
1045 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1046 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
|
1047 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1048 if(!handle) |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1049 return 0; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1050 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1051 DW_MUTEX_LOCK; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1052 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
|
1053 DW_MUTEX_UNLOCK; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1054 return 0; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1055 } |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1056 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1057 /* |
3 | 1058 * Makes the window visible. |
1059 * Parameters: | |
1060 * handle: The window handle to make visible. | |
1061 */ | |
1062 int dw_window_show(HWND handle) | |
1063 { | |
1064 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
|
1065 GtkWidget *defaultitem; |
3 | 1066 |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1067 if(!handle) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1068 return 0; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1069 |
3 | 1070 DW_MUTEX_LOCK; |
1071 gtk_widget_show(handle); | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1072 if(GTK_WIDGET(handle)->window) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1073 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1074 gdk_window_raise(GTK_WIDGET(handle)->window); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1075 gdk_flush(); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1076 gdk_window_show(GTK_WIDGET(handle)->window); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1077 gdk_flush(); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1078 } |
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
|
1079 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
|
1080 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
|
1081 gtk_widget_grab_focus(defaultitem); |
3 | 1082 DW_MUTEX_UNLOCK; |
1083 return 0; | |
1084 } | |
1085 | |
1086 /* | |
1087 * Makes the window invisible. | |
1088 * Parameters: | |
1089 * handle: The window handle to make visible. | |
1090 */ | |
1091 int dw_window_hide(HWND handle) | |
1092 { | |
1093 int _locked_by_me = FALSE; | |
1094 | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1095 if(!handle) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1096 return 0; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1097 |
3 | 1098 DW_MUTEX_LOCK; |
1099 gtk_widget_hide(handle); | |
1100 DW_MUTEX_UNLOCK; | |
1101 return 0; | |
1102 } | |
1103 | |
1104 /* | |
1105 * Destroys a window and all of it's children. | |
1106 * Parameters: | |
1107 * handle: The window handle to destroy. | |
1108 */ | |
1109 int dw_window_destroy(HWND handle) | |
1110 { | |
1111 int _locked_by_me = FALSE; | |
1112 | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1113 if(!handle) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1114 return 0; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1115 |
3 | 1116 DW_MUTEX_LOCK; |
17
f26eced21a30
Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
15
diff
changeset
|
1117 if(GTK_IS_WIDGET(handle)) |
f26eced21a30
Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
15
diff
changeset
|
1118 gtk_widget_destroy(handle); |
3 | 1119 DW_MUTEX_UNLOCK; |
1120 return 0; | |
1121 } | |
1122 | |
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
|
1123 /* 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
|
1124 * 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
|
1125 * 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
|
1126 */ |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
1127 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
|
1128 { |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
1129 } |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
1130 |
3 | 1131 /* |
1132 * Changes a window's parent to newparent. | |
1133 * Parameters: | |
1134 * handle: The window handle to destroy. | |
1135 * newparent: The window's new parent window. | |
1136 */ | |
1137 void dw_window_reparent(HWND handle, HWND newparent) | |
1138 { | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1139 int _locked_by_me = FALSE; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1140 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1141 DW_MUTEX_LOCK; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1142 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
|
1143 DW_MUTEX_UNLOCK; |
3 | 1144 } |
1145 | |
1146 int _set_font(HWND handle, char *fontname) | |
1147 { | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1148 int retval = FALSE; |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1149 #if GTK_MAJOR_VERSION < 2 |
3 | 1150 GtkStyle *style; |
1151 GdkFont *font = NULL; | |
1152 | |
1153 font = gdk_font_load(fontname); | |
1154 | |
1155 if(font) | |
1156 { | |
1157 style = gtk_widget_get_style(handle); | |
1158 style->font = font; | |
1159 gtk_widget_set_style(handle, style); | |
1160 retval = TRUE; | |
1161 } | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1162 #else |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1163 PangoFontDescription *font = pango_font_description_from_string(fontname); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1164 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1165 if(font) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1166 gtk_widget_modify_font(handle, font); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1167 pango_font_description_free(font); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1168 #endif |
3 | 1169 return retval; |
1170 } | |
1171 | |
1172 /* | |
1173 * Sets the font used by a specified window (widget) handle. | |
1174 * Parameters: | |
1175 * handle: The window (widget) handle. | |
1176 * fontname: Name and size of the font in the form "size.fontname" | |
1177 */ | |
1178 int dw_window_set_font(HWND handle, char *fontname) | |
1179 { | |
1180 GtkWidget *handle2 = handle; | |
1181 char *font; | |
1182 int _locked_by_me = FALSE; | |
1183 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
|
1184 GdkFont *gdkfont; |
3 | 1185 |
1186 DW_MUTEX_LOCK; | |
1187 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
1188 { | |
1189 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
1190 if(tmp) | |
1191 handle2 = tmp; | |
1192 } | |
1193 font = strdup(fontname); | |
1194 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1195 /* 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
|
1196 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
|
1197 if(gdkfont) |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1198 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
|
1199 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
|
1200 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
|
1201 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1202 /* Free old font name if one is allocated */ |
3 | 1203 data = gtk_object_get_data(GTK_OBJECT(handle2), "fontname"); |
1204 if(data) | |
1205 free(data); | |
1206 | |
1207 if(font) | |
1208 gtk_object_set_data(GTK_OBJECT(handle2), "fontname", (gpointer)font); | |
1209 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1210 |
3 | 1211 DW_MUTEX_UNLOCK; |
1212 return TRUE; | |
1213 } | |
1214 | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1215 void _free_gdk_colors(HWND handle) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1216 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1217 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
|
1218 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1219 if(old) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1220 free(old); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1221 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1222 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
|
1223 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1224 if(old) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1225 free(old); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1226 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1227 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1228 /* 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
|
1229 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
|
1230 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1231 GdkColor *foregdk = malloc(sizeof(GdkColor)); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1232 GdkColor *backgdk = malloc(sizeof(GdkColor)); |
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 _free_gdk_colors(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 *foregdk = fore; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1237 *backgdk = back; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1238 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1239 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
|
1240 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
|
1241 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1242 |
3 | 1243 int _set_color(HWND handle, unsigned long fore, unsigned long back) |
1244 { | |
1245 GtkStyle *style; | |
1246 | |
1247 if(fore & DW_RGB_COLOR || back & DW_RGB_COLOR) | |
1248 { | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1249 /* 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
|
1250 * 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
|
1251 */ |
3 | 1252 GdkColor forecolor = { 0, DW_RED_VALUE(fore) << 8, DW_GREEN_VALUE(fore) << 8, DW_BLUE_VALUE(fore) << 8 }; |
1253 GdkColor backcolor = { 0, DW_RED_VALUE(back) << 8, DW_GREEN_VALUE(back) << 8, DW_BLUE_VALUE(back) << 8 }; | |
1254 | |
1255 gdk_color_alloc(_dw_cmap, &forecolor); | |
1256 gdk_color_alloc(_dw_cmap, &backcolor); | |
1257 | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1258 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
|
1259 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
|
1260 style->base[0] = style->base[1] = style->bg[0] = style->bg[1] = backcolor; |
3 | 1261 gtk_widget_set_style(handle, style); |
122
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
1262 |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1263 _save_gdk_colors(handle, forecolor, backcolor); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1264 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1265 if(GTK_IS_CLIST(handle)) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1266 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1267 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
|
1268 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1269 for(z=0;z<rowcount;z++) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1270 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1271 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
|
1272 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
|
1273 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1274 } |
3 | 1275 } |
1276 else | |
1277 { | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1278 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
|
1279 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
|
1280 style->base[0] = style->base[1] = style->bg[0] = style->bg[1] = _colors[back]; |
3 | 1281 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
|
1282 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1283 _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
|
1284 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1285 if(GTK_IS_CLIST(handle)) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1286 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1287 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
|
1288 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1289 for(z=0;z<rowcount;z++) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1290 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1291 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
|
1292 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
|
1293 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1294 } |
3 | 1295 } |
1296 | |
1297 return TRUE; | |
1298 } | |
1299 /* | |
1300 * Sets the colors used by a specified window (widget) handle. | |
1301 * Parameters: | |
1302 * handle: The window (widget) handle. | |
1303 * fore: Foreground color in RGB format. | |
1304 * back: Background color in RGB format. | |
1305 */ | |
1306 int dw_window_set_color(HWND handle, unsigned long fore, unsigned long back) | |
1307 { | |
1308 GtkWidget *handle2 = handle; | |
1309 int _locked_by_me = FALSE; | |
1310 | |
1311 DW_MUTEX_LOCK; | |
1312 | |
1313 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
1314 { | |
1315 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
1316 if(tmp) | |
1317 handle2 = tmp; | |
1318 } | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1319 else if(GTK_IS_BOX(handle)) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1320 { |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1321 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
|
1322 if(tmp) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1323 handle2 = tmp; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1324 } |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1325 else if(GTK_IS_TABLE(handle)) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1326 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1327 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
|
1328 if(tmp) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1329 handle2 = tmp; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1330 } |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1331 |
3 | 1332 _set_color(handle2, fore, back); |
1333 | |
1334 DW_MUTEX_UNLOCK; | |
1335 return TRUE; | |
1336 } | |
1337 | |
1338 /* | |
1339 * Sets the font used by a specified window (widget) handle. | |
1340 * Parameters: | |
1341 * handle: The window (widget) handle. | |
1342 * border: Size of the window border in pixels. | |
1343 */ | |
1344 int dw_window_set_border(HWND handle, int border) | |
1345 { | |
1346 /* TODO */ | |
1347 return 0; | |
1348 } | |
1349 | |
1350 /* | |
1351 * Captures the mouse input to this window. | |
1352 * Parameters: | |
1353 * handle: Handle to receive mouse input. | |
1354 */ | |
1355 void dw_window_capture(HWND handle) | |
1356 { | |
1357 int _locked_by_me = FALSE; | |
1358 | |
1359 DW_MUTEX_LOCK; | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1360 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 | 1361 DW_MUTEX_UNLOCK; |
1362 } | |
1363 | |
1364 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1365 * 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
|
1366 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1367 * 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
|
1368 * 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
|
1369 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1370 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
|
1371 { |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1372 int _locked_by_me = FALSE; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1373 GdkCursor *cursor; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1374 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1375 DW_MUTEX_LOCK; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1376 cursor = gdk_cursor_new(pointertype); |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
1377 if(handle && handle->window) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
1378 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
|
1379 gdk_cursor_destroy(cursor); |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1380 DW_MUTEX_UNLOCK; |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1381 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1382 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1383 /* |
3 | 1384 * Releases previous mouse capture. |
1385 */ | |
1386 void dw_window_release(void) | |
1387 { | |
1388 int _locked_by_me = FALSE; | |
1389 | |
1390 DW_MUTEX_LOCK; | |
1391 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
1392 DW_MUTEX_UNLOCK; | |
1393 } | |
1394 | |
1395 /* | |
1396 * Create a new Window Frame. | |
1397 * Parameters: | |
1398 * owner: The Owner's window handle or HWND_DESKTOP. | |
1399 * title: The Window title. | |
1400 * flStyle: Style flags, see the PM reference. | |
1401 */ | |
1402 HWND dw_window_new(HWND hwndOwner, char *title, unsigned long flStyle) | |
1403 { | |
1404 GtkWidget *tmp; | |
1405 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
|
1406 int flags = 0; |
3 | 1407 |
1408 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
|
1409 last_window = tmp = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
3 | 1410 |
1411 gtk_window_set_title(GTK_WINDOW(tmp), title); | |
1412 if(!(flStyle & DW_FCF_SIZEBORDER)) | |
1413 gtk_window_set_policy(GTK_WINDOW(tmp), FALSE, FALSE, TRUE); | |
1414 | |
1415 gtk_widget_realize(tmp); | |
1416 | |
1417 if(flStyle & DW_FCF_TITLEBAR) | |
1418 flags |= GDK_DECOR_TITLE; | |
1419 | |
1420 if(flStyle & DW_FCF_MINMAX) | |
1421 flags |= GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE; | |
1422 | |
1423 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
|
1424 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
|
1425 |
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
|
1426 if(flStyle & DW_FCF_BORDER || flStyle & DW_FCF_DLGBORDER) |
3 | 1427 flags |= GDK_DECOR_BORDER; |
1428 | |
1429 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
|
1430 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1431 if(hwndOwner) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1432 gdk_window_reparent(GTK_WIDGET(tmp)->window, GTK_WIDGET(hwndOwner)->window, 0, 0); |
3 | 1433 |
1434 DW_MUTEX_UNLOCK; | |
1435 return tmp; | |
1436 } | |
1437 | |
1438 /* | |
1439 * Create a new Box to be packed. | |
1440 * Parameters: | |
1441 * type: Either BOXVERT (vertical) or BOXHORZ (horizontal). | |
1442 * pad: Number of pixels to pad around the box. | |
1443 */ | |
1444 HWND dw_box_new(int type, int pad) | |
1445 { | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1446 GtkWidget *tmp, *eventbox; |
3 | 1447 int _locked_by_me = FALSE; |
1448 | |
1449 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
|
1450 tmp = gtk_table_new(1, 1, FALSE); |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1451 eventbox = gtk_event_box_new(); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1452 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1453 gtk_widget_show(eventbox); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1454 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
|
1455 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
|
1456 gtk_object_set_data(GTK_OBJECT(tmp), "boxpad", (gpointer)pad); |
3 | 1457 gtk_widget_show(tmp); |
1458 DW_MUTEX_UNLOCK; | |
1459 return tmp; | |
1460 } | |
1461 | |
1462 /* | |
1463 * Create a new Group Box to be packed. | |
1464 * Parameters: | |
1465 * type: Either BOXVERT (vertical) or BOXHORZ (horizontal). | |
1466 * pad: Number of pixels to pad around the box. | |
1467 * title: Text to be displayined in the group outline. | |
1468 */ | |
1469 HWND dw_groupbox_new(int type, int pad, char *title) | |
1470 { | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1471 GtkWidget *tmp, *frame; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1472 int _locked_by_me = FALSE; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1473 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1474 DW_MUTEX_LOCK; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1475 frame = gtk_frame_new(NULL); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1476 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
|
1477 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
|
1478 tmp = gtk_table_new(1, 1, FALSE); |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1479 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
|
1480 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
|
1481 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
|
1482 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
|
1483 gtk_container_add(GTK_CONTAINER(frame), tmp); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1484 gtk_widget_show(tmp); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1485 gtk_widget_show(frame); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1486 DW_MUTEX_UNLOCK; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1487 return frame; |
3 | 1488 } |
1489 | |
1490 /* | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1491 * 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
|
1492 * Parameters: |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1493 * 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
|
1494 */ |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1495 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
|
1496 { |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1497 GtkWidget *tmp; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1498 int _locked_by_me = FALSE; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1499 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1500 DW_MUTEX_LOCK; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1501 tmp = gtk_vbox_new(FALSE, 0); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1502 DW_MUTEX_UNLOCK; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1503 return tmp; |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1504 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1505 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1506 /* |
3 | 1507 * Create a bitmap object to be packed. |
1508 * Parameters: | |
1509 * id: An ID to be used with WinWindowFromID() or 0L. | |
1510 */ | |
1511 HWND dw_bitmap_new(unsigned long id) | |
1512 { | |
121
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
1513 #if GTK_MAJOR_VERSION < 2 |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1514 GdkPixmap *pixmap = NULL; |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1515 GdkBitmap *bitmap = 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
|
1516 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
|
1517 "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
|
1518 " 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
|
1519 ". 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
|
1520 "."}; |
121
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
1521 #endif |
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
1522 GtkWidget *tmp; |
3 | 1523 int _locked_by_me = FALSE; |
1524 | |
1525 DW_MUTEX_LOCK; | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1526 #if GTK_MAJOR_VERSION > 1 |
121
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
1527 tmp = gtk_image_new(); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1528 #elif defined(USE_IMLIB) |
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
|
1529 gdk_imlib_data_to_pixmap(test_xpm, &pixmap, &bitmap); |
3 | 1530 #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
|
1531 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
|
1532 |
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
|
1533 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
|
1534 pixmap = gdk_pixmap_create_from_xpm_d(last_window->window, &bitmap, &_colors[DW_CLR_PALEGRAY], test_xpm); |
3 | 1535 #endif |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1536 #if GTK_MAJOR_VERSION < 2 |
3 | 1537 tmp = gtk_pixmap_new(pixmap, bitmap); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1538 #endif |
3 | 1539 gtk_widget_show(tmp); |
1540 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
1541 DW_MUTEX_UNLOCK; | |
1542 return tmp; | |
1543 } | |
1544 | |
1545 /* | |
1546 * Create a notebook object to be packed. | |
1547 * Parameters: | |
1548 * id: An ID to be used for getting the resource from the | |
1549 * resource file. | |
1550 */ | |
1551 HWND dw_notebook_new(unsigned long id, int top) | |
1552 { | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1553 GtkWidget *tmp, **pagearray = calloc(sizeof(GtkWidget *), 256); |
3 | 1554 int _locked_by_me = FALSE; |
1555 | |
1556 DW_MUTEX_LOCK; | |
1557 tmp = gtk_notebook_new(); | |
1558 if(top) | |
1559 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tmp), GTK_POS_TOP); | |
1560 else | |
1561 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
|
1562 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
|
1563 #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
|
1564 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
|
1565 #endif |
3 | 1566 gtk_widget_show(tmp); |
1567 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1568 gtk_object_set_data(GTK_OBJECT(tmp), "pagearray", (gpointer)pagearray); |
3 | 1569 DW_MUTEX_UNLOCK; |
1570 return tmp; | |
1571 } | |
1572 | |
1573 /* | |
1574 * Create a menu object to be popped up. | |
1575 * Parameters: | |
1576 * id: An ID to be used for getting the resource from the | |
1577 * resource file. | |
1578 */ | |
1579 HMENUI dw_menu_new(unsigned long id) | |
1580 { | |
1581 int _locked_by_me = FALSE; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1582 HMENUI tmp = malloc(sizeof(struct _hmenui)); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1583 GtkAccelGroup *accel_group; |
3 | 1584 |
1585 if(!tmp) | |
1586 return NULL; | |
1587 | |
1588 DW_MUTEX_LOCK; | |
1589 tmp->menu = gtk_menu_new(); | |
1590 gtk_widget_show(tmp->menu); | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1591 accel_group = gtk_accel_group_new(); |
3 | 1592 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
|
1593 gtk_object_set_data(GTK_OBJECT(tmp->menu), "accel", (gpointer)accel_group); |
3 | 1594 DW_MUTEX_UNLOCK; |
1595 return tmp; | |
1596 } | |
1597 | |
1598 /* | |
1599 * Create a menubar on a window. | |
1600 * Parameters: | |
1601 * location: Handle of a window frame to be attached to. | |
1602 */ | |
1603 HMENUI dw_menubar_new(HWND location) | |
1604 { | |
1605 GtkWidget *box; | |
1606 int _locked_by_me = FALSE; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1607 HMENUI tmp = malloc(sizeof(struct _hmenui)); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1608 GtkAccelGroup *accel_group; |
3 | 1609 |
1610 if(!tmp) | |
1611 return NULL; | |
1612 | |
1613 DW_MUTEX_LOCK; | |
1614 tmp->menu = gtk_menu_bar_new(); | |
1615 box = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(location)); | |
1616 gtk_widget_show(tmp->menu); | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1617 accel_group = gtk_accel_group_new(); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1618 gtk_object_set_data(GTK_OBJECT(tmp->menu), "accel", (gpointer)accel_group); |
3 | 1619 |
1620 if(box) | |
1621 gtk_box_pack_end(GTK_BOX(box), tmp->menu, FALSE, FALSE, 0); | |
1622 | |
1623 DW_MUTEX_UNLOCK; | |
1624 return tmp; | |
1625 } | |
1626 | |
1627 /* | |
1628 * Destroys a menu created with dw_menubar_new or dw_menu_new. | |
1629 * Parameters: | |
1630 * menu: Handle of a menu. | |
1631 */ | |
1632 void dw_menu_destroy(HMENUI *menu) | |
1633 { | |
1634 if(menu && *menu) | |
1635 { | |
1636 int _locked_by_me = FALSE; | |
1637 | |
1638 DW_MUTEX_LOCK; | |
1639 gtk_widget_destroy((*menu)->menu); | |
1640 free(*menu); | |
1641 *menu = NULL; | |
1642 DW_MUTEX_UNLOCK; | |
1643 } | |
1644 } | |
1645 | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1646 char _removetilde(char *dest, char *src) |
3 | 1647 { |
1648 int z, cur=0; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1649 char accel = '\0'; |
3 | 1650 |
1651 for(z=0;z<strlen(src);z++) | |
1652 { | |
1653 if(src[z] != '~') | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1654 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1655 dest[cur] = src[z]; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1656 cur++; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1657 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1658 else |
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 dest[cur] = '_'; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1661 accel = src[z+1]; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1662 cur++; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1663 } |
3 | 1664 } |
1665 dest[cur] = 0; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1666 return accel; |
3 | 1667 } |
1668 | |
1669 /* | |
1670 * Adds a menuitem or submenu to an existing menu. | |
1671 * Parameters: | |
1672 * menu: The handle the the existing menu. | |
1673 * title: The title text on the menu item to be added. | |
1674 * id: An ID to be used for message passing. | |
1675 * flags: Extended attributes to set on the menu. | |
1676 * end: If TRUE memu is positioned at the end of the menu. | |
1677 * check: If TRUE menu is "check"able. | |
1678 * submenu: Handle to an existing menu to be a submenu or NULL. | |
1679 */ | |
1680 HWND dw_menu_append_item(HMENUI menu, char *title, unsigned long id, unsigned long flags, int end, int check, HMENUI submenu) | |
1681 { | |
1682 GtkWidget *tmphandle; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1683 char accel, *tempbuf = malloc(strlen(title)+1); |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1684 int _locked_by_me = FALSE, submenucount; |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1685 guint tmp_key; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1686 GtkAccelGroup *accel_group; |
3 | 1687 |
1688 if(!menu || !menu->menu) | |
1689 { | |
1690 free(tempbuf); | |
1691 return NULL; | |
1692 } | |
1693 | |
1694 DW_MUTEX_LOCK; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1695 accel = _removetilde(tempbuf, title); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1696 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1697 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
|
1698 submenucount = (int)gtk_object_get_data(GTK_OBJECT(menu->menu), "submenucount"); |
3 | 1699 |
1700 if(strlen(tempbuf) == 0) | |
1701 tmphandle=gtk_menu_item_new(); | |
1702 else | |
1703 { | |
1704 if(check) | |
1705 { | |
1706 char numbuf[10]; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1707 if(accel && accel_group) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1708 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1709 tmphandle=gtk_check_menu_item_new_with_label(""); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1710 tmp_key = gtk_label_parse_uline(GTK_LABEL(GTK_BIN(tmphandle)->child), tempbuf); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1711 gtk_widget_add_accelerator(tmphandle, "activate", accel_group, tmp_key, GDK_MOD1_MASK, 0); |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1712 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1713 else |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1714 tmphandle=gtk_check_menu_item_new_with_label(tempbuf); |
3 | 1715 gtk_check_menu_item_set_show_toggle(GTK_CHECK_MENU_ITEM(tmphandle), TRUE); |
1716 sprintf(numbuf, "%lu", id); | |
1717 gtk_object_set_data(GTK_OBJECT(menu->menu), numbuf, (gpointer)tmphandle); | |
1718 } | |
1719 else | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1720 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1721 if(accel && accel_group) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1722 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1723 tmphandle=gtk_menu_item_new_with_label(""); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1724 tmp_key = gtk_label_parse_uline(GTK_LABEL(GTK_BIN(tmphandle)->child), tempbuf); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1725 gtk_widget_add_accelerator(tmphandle, "activate", accel_group, tmp_key, GDK_MOD1_MASK, 0); |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1726 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1727 else |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1728 tmphandle=gtk_menu_item_new_with_label(tempbuf); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1729 } |
3 | 1730 } |
1731 | |
1732 gtk_widget_show(tmphandle); | |
1733 | |
1734 if(submenu) | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1735 { |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1736 char tempbuf[100]; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1737 |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1738 sprintf(tempbuf, "submenu%d", submenucount); |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1739 submenucount++; |
3 | 1740 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
|
1741 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
|
1742 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
|
1743 } |
3 | 1744 |
1745 if(GTK_IS_MENU_BAR(menu->menu)) | |
1746 gtk_menu_bar_append(GTK_MENU_BAR(menu->menu), tmphandle); | |
1747 else | |
1748 gtk_menu_append(GTK_MENU(menu->menu), tmphandle); | |
1749 | |
1750 gtk_object_set_data(GTK_OBJECT(tmphandle), "id", (gpointer)id); | |
1751 free(tempbuf); | |
1752 DW_MUTEX_UNLOCK; | |
1753 return tmphandle; | |
1754 } | |
1755 | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1756 GtkWidget *_find_submenu_id(GtkWidget *start, char *name) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1757 { |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1758 GtkWidget *tmp; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1759 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
|
1760 |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1761 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
|
1762 return tmp; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1763 |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1764 for(z=0;z<submenucount;z++) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1765 { |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1766 char tempbuf[100]; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1767 GtkWidget *submenu, *menuitem; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1768 |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1769 sprintf(tempbuf, "submenu%d", z); |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1770 |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1771 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
|
1772 { |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1773 if((menuitem = _find_submenu_id(submenu, name))) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1774 return menuitem; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1775 } |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1776 } |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1777 return NULL; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1778 } |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1779 |
3 | 1780 /* |
1781 * Sets the state of a menu item check. | |
1782 * Parameters: | |
1783 * menu: The handle the the existing menu. | |
1784 * id: Menuitem id. | |
1785 * check: TRUE for checked FALSE for not checked. | |
1786 */ | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1787 void dw_menu_item_set_check(HMENUI menu, unsigned long id, int check) |
3 | 1788 { |
1789 char numbuf[10]; | |
1790 GtkWidget *tmphandle; | |
1791 int _locked_by_me = FALSE; | |
1792 | |
1793 if(!menu || !menu->menu) | |
1794 return; | |
1795 | |
1796 DW_MUTEX_LOCK; | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1797 sprintf(numbuf, "%lu", id); |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1798 tmphandle = _find_submenu_id(menu->menu, numbuf); |
3 | 1799 |
1800 if(tmphandle) | |
1801 { | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1802 _dw_ignore_click = 1; |
3 | 1803 if(GTK_CHECK_MENU_ITEM(tmphandle)->active != check) |
1804 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
|
1805 _dw_ignore_click = 0; |
3 | 1806 } |
1807 DW_MUTEX_UNLOCK; | |
1808 } | |
1809 | |
1810 /* | |
1811 * Pops up a context menu at given x and y coordinates. | |
1812 * Parameters: | |
1813 * menu: The handle the the existing menu. | |
1814 * parent: Handle to the window initiating the popup. | |
1815 * x: X coordinate. | |
1816 * y: Y coordinate. | |
1817 */ | |
1818 void dw_menu_popup(HMENUI *menu, HWND parent, int x, int y) | |
1819 { | |
1820 int _locked_by_me = FALSE; | |
1821 | |
1822 if(!menu || !*menu) | |
1823 return; | |
1824 | |
93
98cce029a611
Changed handling of menu item click events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
92
diff
changeset
|
1825 popup = parent; |
98cce029a611
Changed handling of menu item click events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
92
diff
changeset
|
1826 |
3 | 1827 DW_MUTEX_LOCK; |
132
6e37014ccbae
Fixed an error in the call to gtk_menu_popup() which was causing popup
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
131
diff
changeset
|
1828 gtk_menu_popup(GTK_MENU((*menu)->menu), NULL, NULL, NULL, NULL, 1, GDK_CURRENT_TIME); |
3 | 1829 free(*menu); |
1830 *menu = NULL; | |
1831 DW_MUTEX_UNLOCK; | |
1832 } | |
1833 | |
1834 | |
1835 /* | |
1836 * Returns the current X and Y coordinates of the mouse pointer. | |
1837 * Parameters: | |
1838 * x: Pointer to variable to store X coordinate. | |
1839 * y: Pointer to variable to store Y coordinate. | |
1840 */ | |
1841 void dw_pointer_query_pos(long *x, long *y) | |
1842 { | |
1843 GdkModifierType state; | |
1844 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
|
1845 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
|
1846 |
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
|
1847 DW_MUTEX_LOCK; |
3 | 1848 gdk_window_get_pointer (GDK_ROOT_PARENT(), &gx, &gy, &state); |
1849 *x = gx; | |
1850 *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
|
1851 DW_MUTEX_UNLOCK; |
3 | 1852 } |
1853 | |
1854 /* | |
1855 * Sets the X and Y coordinates of the mouse pointer. | |
1856 * Parameters: | |
1857 * x: X coordinate. | |
1858 * y: Y coordinate. | |
1859 */ | |
1860 void dw_pointer_set_pos(long x, long y) | |
1861 { | |
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
|
1862 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
|
1863 |
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
|
1864 DW_MUTEX_LOCK; |
3 | 1865 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
|
1866 DW_MUTEX_UNLOCK; |
3 | 1867 } |
1868 | |
1869 /* | |
1870 * Create a container object to be packed. | |
1871 * Parameters: | |
1872 * id: An ID to be used for getting the resource from the | |
1873 * resource file. | |
1874 */ | |
1875 HWND dw_container_new(unsigned long id) | |
1876 { | |
1877 GtkWidget *tmp; | |
1878 int _locked_by_me = FALSE; | |
1879 | |
1880 DW_MUTEX_LOCK; | |
1881 tmp = gtk_scrolled_window_new (NULL, NULL); | |
1882 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (tmp), | |
1883 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
1884 | |
1885 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
1886 gtk_widget_show(tmp); | |
1887 | |
1888 DW_MUTEX_UNLOCK; | |
1889 return tmp; | |
1890 } | |
1891 | |
1892 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1893 * 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
|
1894 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1895 * 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
|
1896 * 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
|
1897 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1898 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
|
1899 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1900 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
|
1901 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
|
1902 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1903 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
|
1904 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
|
1905 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
|
1906 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
|
1907 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1908 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
|
1909 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
|
1910 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
|
1911 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
|
1912 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1913 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
|
1914 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
|
1915 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
|
1916 } |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1917 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
|
1918 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
|
1919 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
|
1920 /* 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
|
1921 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
|
1922 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1923 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
|
1924 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
|
1925 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1926 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
|
1927 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
|
1928 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1929 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1930 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1931 /* |
3 | 1932 * Create a new static text window (widget) to be packed. |
1933 * Parameters: | |
1934 * text: The text to be display by the static text widget. | |
1935 * id: An ID to be used with WinWindowFromID() or 0L. | |
1936 */ | |
1937 HWND dw_text_new(char *text, unsigned long id) | |
1938 { | |
1939 GtkWidget *tmp; | |
1940 int _locked_by_me = FALSE; | |
1941 | |
1942 DW_MUTEX_LOCK; | |
1943 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
|
1944 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1945 /* 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
|
1946 gtk_misc_set_alignment(GTK_MISC(tmp), 0.0f, 0.5f); |
3 | 1947 gtk_widget_show(tmp); |
1948 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
|
1949 gtk_misc_set_alignment(GTK_MISC(tmp), DW_LEFT, DW_LEFT); |
3 | 1950 DW_MUTEX_UNLOCK; |
1951 return tmp; | |
1952 } | |
1953 | |
1954 /* | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1955 * 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
|
1956 * Parameters: |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1957 * 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
|
1958 * 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
|
1959 */ |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1960 HWND dw_status_text_new(char *text, ULONG id) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1961 { |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1962 GtkWidget *tmp, *frame; |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1963 int _locked_by_me = FALSE; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1964 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1965 DW_MUTEX_LOCK; |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1966 frame = gtk_frame_new(NULL); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1967 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
|
1968 tmp = gtk_label_new(text); |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1969 gtk_container_add(GTK_CONTAINER(frame), tmp); |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1970 gtk_widget_show(tmp); |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1971 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
|
1972 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1973 /* 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
|
1974 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
|
1975 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
|
1976 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
|
1977 DW_MUTEX_UNLOCK; |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1978 return frame; |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1979 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1980 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1981 /* |
3 | 1982 * Create a new Multiline Editbox window (widget) to be packed. |
1983 * Parameters: | |
1984 * id: An ID to be used with WinWindowFromID() or 0L. | |
1985 */ | |
1986 HWND dw_mle_new(unsigned long id) | |
1987 { | |
1988 GtkWidget *tmp, *tmpbox, *scroller; | |
1989 int _locked_by_me = FALSE; | |
1990 | |
1991 DW_MUTEX_LOCK; | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1992 #if GTK_MAJOR_VERSION > 1 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1993 tmpbox = gtk_scrolled_window_new (NULL, NULL); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1994 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (tmpbox), |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1995 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1996 tmp = gtk_text_view_new(); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1997 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(tmpbox), tmp); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1998 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(tmp), GTK_WRAP_NONE); |
122
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
1999 gtk_object_set_user_data(GTK_OBJECT(tmpbox), (gpointer)tmp); |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
2000 scroller = NULL; |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2001 #else |
3 | 2002 tmpbox = gtk_hbox_new(FALSE, 0); |
2003 tmp = gtk_text_new(NULL, NULL); | |
2004 gtk_text_set_word_wrap(GTK_TEXT(tmp), FALSE); | |
2005 gtk_text_set_line_wrap(GTK_TEXT(tmp), FALSE); | |
2006 scroller = gtk_vscrollbar_new(GTK_TEXT(tmp)->vadj); | |
2007 GTK_WIDGET_UNSET_FLAGS(scroller, GTK_CAN_FOCUS); | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2008 gtk_box_pack_start(GTK_BOX(tmpbox), tmp, TRUE, TRUE, 0); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2009 gtk_box_pack_start(GTK_BOX(tmpbox), scroller, FALSE, TRUE, 0); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2010 gtk_widget_show(scroller); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2011 #endif |
3 | 2012 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); |
2013 gtk_object_set_data(GTK_OBJECT(tmpbox), "mle", (gpointer)tmp); | |
2014 gtk_widget_show(tmp); | |
2015 gtk_widget_show(tmpbox); | |
2016 DW_MUTEX_UNLOCK; | |
2017 return tmpbox; | |
2018 } | |
2019 | |
2020 /* | |
2021 * Create a new Entryfield window (widget) to be packed. | |
2022 * Parameters: | |
2023 * text: The default text to be in the entryfield widget. | |
2024 * id: An ID to be used with WinWindowFromID() or 0L. | |
2025 */ | |
2026 HWND dw_entryfield_new(char *text, unsigned long id) | |
2027 { | |
2028 GtkWidget *tmp; | |
2029 int _locked_by_me = FALSE; | |
2030 | |
2031 DW_MUTEX_LOCK; | |
2032 tmp = gtk_entry_new(); | |
2033 | |
2034 gtk_entry_set_text(GTK_ENTRY(tmp), text); | |
2035 | |
2036 gtk_widget_show(tmp); | |
2037 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
2038 | |
2039 DW_MUTEX_UNLOCK; | |
2040 return tmp; | |
2041 } | |
2042 | |
2043 /* | |
2044 * Create a new Entryfield (password) window (widget) to be packed. | |
2045 * Parameters: | |
2046 * text: The default text to be in the entryfield widget. | |
2047 * id: An ID to be used with WinWindowFromID() or 0L. | |
2048 */ | |
2049 HWND dw_entryfield_password_new(char *text, ULONG id) | |
2050 { | |
2051 GtkWidget *tmp; | |
2052 int _locked_by_me = FALSE; | |
2053 | |
2054 DW_MUTEX_LOCK; | |
2055 tmp = gtk_entry_new(); | |
2056 | |
2057 gtk_entry_set_visibility(GTK_ENTRY(tmp), FALSE); | |
2058 gtk_entry_set_text(GTK_ENTRY(tmp), text); | |
2059 | |
2060 gtk_widget_show(tmp); | |
2061 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
2062 | |
2063 DW_MUTEX_UNLOCK; | |
2064 return tmp; | |
2065 } | |
2066 | |
2067 /* | |
2068 * Create a new Combobox window (widget) to be packed. | |
2069 * Parameters: | |
2070 * text: The default text to be in the combpbox widget. | |
2071 * id: An ID to be used with WinWindowFromID() or 0L. | |
2072 */ | |
2073 HWND dw_combobox_new(char *text, unsigned long id) | |
2074 { | |
2075 GtkWidget *tmp; | |
115
2d121d4d90c0
Run the _item_select_event() handler on comboboxes even if a handler
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
114
diff
changeset
|
2076 SignalHandler *work = malloc(sizeof(SignalHandler)); |
3 | 2077 int _locked_by_me = FALSE; |
2078 | |
2079 DW_MUTEX_LOCK; | |
2080 tmp = gtk_combo_new(); | |
2081 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(tmp)->entry), text); | |
2082 gtk_combo_set_use_arrows(GTK_COMBO(tmp), TRUE); | |
2083 gtk_object_set_user_data(GTK_OBJECT(tmp), NULL); | |
2084 gtk_widget_show(tmp); | |
2085 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
115
2d121d4d90c0
Run the _item_select_event() handler on comboboxes even if a handler
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
114
diff
changeset
|
2086 |
2d121d4d90c0
Run the _item_select_event() handler on comboboxes even if a handler
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
114
diff
changeset
|
2087 work->window = tmp; |
2d121d4d90c0
Run the _item_select_event() handler on comboboxes even if a handler
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
114
diff
changeset
|
2088 work->func = NULL; |
2d121d4d90c0
Run the _item_select_event() handler on comboboxes even if a handler
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
114
diff
changeset
|
2089 work->data = NULL; |
2d121d4d90c0
Run the _item_select_event() handler on comboboxes even if a handler
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
114
diff
changeset
|
2090 |
2d121d4d90c0
Run the _item_select_event() handler on comboboxes even if a handler
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
114
diff
changeset
|
2091 gtk_signal_connect(GTK_OBJECT(GTK_COMBO(tmp)->list), "select_child", GTK_SIGNAL_FUNC(_item_select_event), work); |
3 | 2092 DW_MUTEX_UNLOCK; |
2093 return tmp; | |
2094 } | |
2095 | |
2096 /* | |
2097 * Create a new button window (widget) to be packed. | |
2098 * Parameters: | |
2099 * text: The text to be display by the static text widget. | |
2100 * id: An ID to be used with WinWindowFromID() or 0L. | |
2101 */ | |
2102 HWND dw_button_new(char *text, unsigned long id) | |
2103 { | |
2104 GtkWidget *tmp; | |
2105 int _locked_by_me = FALSE; | |
2106 | |
2107 DW_MUTEX_LOCK; | |
2108 tmp = gtk_button_new_with_label(text); | |
2109 gtk_widget_show(tmp); | |
2110 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
2111 DW_MUTEX_UNLOCK; | |
2112 return tmp; | |
2113 } | |
2114 | |
2115 /* | |
2116 * Create a new bitmap button window (widget) to be packed. | |
2117 * Parameters: | |
2118 * text: Bubble help text to be displayed. | |
2119 * id: An ID of a bitmap in the resource file. | |
2120 */ | |
2121 HWND dw_bitmapbutton_new(char *text, unsigned long id) | |
2122 { | |
2123 GtkWidget *tmp; | |
2124 GtkWidget *bitmap; | |
2125 GtkTooltips *tooltips; | |
2126 int _locked_by_me = FALSE; | |
2127 | |
2128 DW_MUTEX_LOCK; | |
2129 tmp = gtk_button_new(); | |
2130 bitmap = dw_bitmap_new(id); | |
2131 | |
2132 if(bitmap) | |
2133 { | |
2134 dw_window_set_bitmap(bitmap, id); | |
2135 gtk_container_add (GTK_CONTAINER(tmp), bitmap); | |
2136 } | |
2137 gtk_widget_show(tmp); | |
2138 if(text) | |
2139 { | |
2140 tooltips = gtk_tooltips_new(); | |
2141 gtk_tooltips_set_tip(tooltips, tmp, text, NULL); | |
2142 gtk_object_set_data(GTK_OBJECT(tmp), "tooltip", (gpointer)tooltips); | |
2143 } | |
2144 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
2145 DW_MUTEX_UNLOCK; | |
2146 return tmp; | |
2147 } | |
2148 | |
2149 /* | |
2150 * Create a new spinbutton window (widget) to be packed. | |
2151 * Parameters: | |
2152 * text: The text to be display by the static text widget. | |
2153 * id: An ID to be used with WinWindowFromID() or 0L. | |
2154 */ | |
2155 HWND dw_spinbutton_new(char *text, unsigned long id) | |
2156 { | |
2157 GtkAdjustment *adj; | |
2158 GtkWidget *tmp; | |
2159 int _locked_by_me = FALSE; | |
2160 | |
2161 DW_MUTEX_LOCK; | |
2162 adj = (GtkAdjustment *)gtk_adjustment_new (1.0, 0.0, 100.0, 1.0, 5.0, 0.0); | |
2163 tmp = gtk_spin_button_new (adj, 0, 0); | |
2164 gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(tmp), TRUE); | |
2165 gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(tmp), TRUE); | |
2166 gtk_widget_show(tmp); | |
2167 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
2168 DW_MUTEX_UNLOCK; | |
2169 return tmp; | |
2170 } | |
2171 | |
2172 /* | |
2173 * Create a new radiobutton window (widget) to be packed. | |
2174 * Parameters: | |
2175 * text: The text to be display by the static text widget. | |
2176 * id: An ID to be used with WinWindowFromID() or 0L. | |
2177 */ | |
2178 HWND dw_radiobutton_new(char *text, ULONG id) | |
2179 { | |
2180 /* This will have to be fixed in the future. */ | |
2181 GtkWidget *tmp; | |
2182 int _locked_by_me = FALSE; | |
2183 | |
2184 DW_MUTEX_LOCK; | |
2185 tmp = gtk_radio_button_new_with_label(NULL, text); | |
2186 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
2187 gtk_widget_show(tmp); | |
2188 | |
2189 DW_MUTEX_UNLOCK; | |
2190 return tmp; | |
2191 } | |
2192 | |
2193 /* | |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2194 * 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
|
2195 * Parameters: |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2196 * 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
|
2197 * 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
|
2198 * 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
|
2199 */ |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2200 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
|
2201 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2202 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
|
2203 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
|
2204 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
|
2205 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2206 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
|
2207 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
|
2208 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
|
2209 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
|
2210 else |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2211 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
|
2212 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
|
2213 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
|
2214 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
|
2215 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
|
2216 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
|
2217 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
|
2218 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
|
2219 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
|
2220 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2221 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2222 /* |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
2223 * Create a new percent bar window (widget) to be packed. |
3 | 2224 * Parameters: |
2225 * id: An ID to be used with WinWindowFromID() or 0L. | |
2226 */ | |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
2227 HWND dw_percent_new(unsigned long id) |
3 | 2228 { |
2229 GtkWidget *tmp; | |
2230 int _locked_by_me = FALSE; | |
2231 | |
2232 DW_MUTEX_LOCK; | |
2233 tmp = gtk_progress_bar_new(); | |
2234 gtk_widget_show(tmp); | |
2235 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
2236 DW_MUTEX_UNLOCK; | |
2237 return tmp; | |
2238 } | |
2239 | |
2240 /* | |
2241 * Create a new checkbox window (widget) to be packed. | |
2242 * Parameters: | |
2243 * text: The text to be display by the static text widget. | |
2244 * id: An ID to be used with WinWindowFromID() or 0L. | |
2245 */ | |
2246 HWND dw_checkbox_new(char *text, unsigned long id) | |
2247 { | |
2248 GtkWidget *tmp; | |
2249 int _locked_by_me = FALSE; | |
2250 | |
2251 DW_MUTEX_LOCK; | |
2252 tmp = gtk_check_button_new_with_label(text); | |
2253 gtk_widget_show(tmp); | |
2254 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
2255 DW_MUTEX_UNLOCK; | |
2256 return tmp; | |
2257 } | |
2258 | |
2259 /* | |
2260 * Create a new listbox window (widget) to be packed. | |
2261 * Parameters: | |
2262 * id: An ID to be used with WinWindowFromID() or 0L. | |
2263 * multi: Multiple select TRUE or FALSE. | |
2264 */ | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2265 HWND dw_listbox_new(unsigned long id, int multi) |
3 | 2266 { |
2267 GtkWidget *tmp, *list; | |
2268 int _locked_by_me = FALSE; | |
2269 | |
2270 DW_MUTEX_LOCK; | |
2271 tmp = gtk_scrolled_window_new(NULL, NULL); | |
2272 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (tmp), | |
2273 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
2274 | |
2275 list = gtk_list_new(); | |
2276 gtk_list_set_selection_mode(GTK_LIST(list), multi ? GTK_SELECTION_MULTIPLE : GTK_SELECTION_SINGLE); | |
2277 | |
2278 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(tmp), | |
2279 list); | |
2280 gtk_object_set_user_data(GTK_OBJECT(tmp), list); | |
2281 gtk_widget_show(list); | |
2282 gtk_widget_show(tmp); | |
2283 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
2284 | |
2285 DW_MUTEX_UNLOCK; | |
2286 return tmp; | |
2287 } | |
2288 | |
2289 /* | |
2290 * Sets the icon used for a given window. | |
2291 * Parameters: | |
2292 * handle: Handle to the window. | |
2293 * id: An ID to be used to specify the icon. | |
2294 */ | |
2295 void dw_window_set_icon(HWND handle, unsigned long id) | |
2296 { | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2297 GdkBitmap *bitmap = NULL; |
3 | 2298 GdkPixmap *icon_pixmap; |
2299 int _locked_by_me = FALSE; | |
2300 | |
2301 DW_MUTEX_LOCK; | |
121
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
2302 icon_pixmap = _find_pixmap(&bitmap, id, handle, NULL, NULL); |
3 | 2303 |
2304 if(handle->window && icon_pixmap) | |
2305 gdk_window_set_icon(handle->window, NULL, icon_pixmap, bitmap); | |
2306 | |
2307 DW_MUTEX_UNLOCK; | |
2308 } | |
2309 | |
2310 /* | |
2311 * Sets the bitmap used for a given static window. | |
2312 * Parameters: | |
2313 * handle: Handle to the window. | |
2314 * id: An ID to be used to specify the icon. | |
2315 */ | |
2316 void dw_window_set_bitmap(HWND handle, unsigned long id) | |
2317 { | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2318 GdkBitmap *bitmap = NULL; |
3 | 2319 GdkPixmap *tmp; |
2320 int _locked_by_me = FALSE; | |
2321 | |
2322 DW_MUTEX_LOCK; | |
121
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
2323 tmp = _find_pixmap(&bitmap, id, handle, NULL, NULL); |
3 | 2324 if(tmp) |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2325 #if GTK_MAJOR_VERSION > 1 |
121
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
2326 gtk_image_set_from_pixmap(GTK_IMAGE(handle), tmp, bitmap); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2327 #else |
3 | 2328 gtk_pixmap_set(GTK_PIXMAP(handle), tmp, bitmap); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2329 #endif |
3 | 2330 DW_MUTEX_UNLOCK; |
2331 } | |
2332 | |
2333 /* | |
2334 * Sets the text used for a given window. | |
2335 * Parameters: | |
2336 * handle: Handle to the window. | |
2337 * text: The text associsated with a given window. | |
2338 */ | |
2339 void dw_window_set_text(HWND handle, char *text) | |
2340 { | |
2341 int _locked_by_me = FALSE; | |
2342 | |
2343 DW_MUTEX_LOCK; | |
2344 if(GTK_IS_ENTRY(handle)) | |
2345 gtk_entry_set_text(GTK_ENTRY(handle), text); | |
2346 else if(GTK_IS_COMBO(handle)) | |
2347 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(handle)->entry), text); | |
2348 else if(GTK_IS_LABEL(handle)) | |
2349 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
|
2350 else if(GTK_IS_FRAME(handle)) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2351 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2352 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
|
2353 if(tmp && GTK_IS_LABEL(tmp)) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2354 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
|
2355 } |
3 | 2356 DW_MUTEX_UNLOCK; |
2357 } | |
2358 | |
2359 /* | |
2360 * Gets the text used for a given window. | |
2361 * Parameters: | |
2362 * handle: Handle to the window. | |
2363 * Returns: | |
2364 * text: The text associsated with a given window. | |
2365 */ | |
2366 char *dw_window_get_text(HWND handle) | |
2367 { | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2368 #if GTK_MAJOR_VERSION > 1 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2369 const char *possible = ""; |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2370 #else |
3 | 2371 char *possible = ""; |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2372 #endif |
3 | 2373 int _locked_by_me = FALSE; |
2374 | |
2375 DW_MUTEX_LOCK; | |
2376 if(GTK_IS_ENTRY(handle)) | |
2377 possible = gtk_entry_get_text(GTK_ENTRY(handle)); | |
2378 else if(GTK_IS_COMBO(handle)) | |
2379 possible = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(handle)->entry)); | |
2380 | |
2381 DW_MUTEX_UNLOCK; | |
2382 return strdup(possible); | |
2383 } | |
2384 | |
2385 /* | |
2386 * Disables given window (widget). | |
2387 * Parameters: | |
2388 * handle: Handle to the window. | |
2389 */ | |
2390 void dw_window_disable(HWND handle) | |
2391 { | |
2392 int _locked_by_me = FALSE; | |
2393 | |
2394 DW_MUTEX_LOCK; | |
2395 gtk_widget_set_sensitive(handle, FALSE); | |
2396 DW_MUTEX_UNLOCK; | |
2397 } | |
2398 | |
2399 /* | |
2400 * Enables given window (widget). | |
2401 * Parameters: | |
2402 * handle: Handle to the window. | |
2403 */ | |
2404 void dw_window_enable(HWND handle) | |
2405 { | |
2406 int _locked_by_me = FALSE; | |
2407 | |
2408 DW_MUTEX_LOCK; | |
2409 gtk_widget_set_sensitive(handle, TRUE); | |
2410 DW_MUTEX_UNLOCK; | |
2411 } | |
2412 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2413 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
|
2414 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2415 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
|
2416 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2417 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
|
2418 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2419 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
|
2420 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2421 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
|
2422 x++; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2423 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2424 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2425 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
|
2426 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2427 |
3 | 2428 /* |
2429 * Adds text to an MLE box and returns the current point. | |
2430 * Parameters: | |
2431 * handle: Handle to the MLE to be queried. | |
2432 * buffer: Text buffer to be imported. | |
2433 * startpoint: Point to start entering text. | |
2434 */ | |
2435 unsigned int dw_mle_import(HWND handle, char *buffer, int startpoint) | |
2436 { | |
2437 unsigned int tmppoint = startpoint; | |
2438 int _locked_by_me = FALSE; | |
2439 | |
2440 DW_MUTEX_LOCK; | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2441 #if GTK_MAJOR_VERSION > 1 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2442 if(GTK_IS_SCROLLED_WINDOW(handle)) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2443 #else |
3 | 2444 if(GTK_IS_BOX(handle)) |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2445 #endif |
3 | 2446 { |
2447 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); | |
2448 | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2449 #if GTK_MAJOR_VERSION > 1 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2450 if(tmp && GTK_IS_TEXT_VIEW(tmp)) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2451 { |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2452 char *impbuf = malloc(strlen(buffer)+1); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2453 GtkTextBuffer *tbuffer; |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2454 GtkTextIter iter; |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2455 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2456 _strip_cr(impbuf, buffer); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2457 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2458 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp)); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2459 gtk_text_buffer_get_iter_at_offset(tbuffer, &iter, startpoint); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2460 gtk_text_buffer_place_cursor(tbuffer, &iter); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2461 gtk_text_buffer_insert_at_cursor(tbuffer, impbuf, -1); |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2462 tmppoint = startpoint + strlen(impbuf); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2463 free(impbuf); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2464 } |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2465 #else |
122
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
2466 GdkFont *font = (GdkFont *)gtk_object_get_data(GTK_OBJECT(handle), "gdkfont"); |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
2467 |
3 | 2468 if(tmp && GTK_IS_TEXT(tmp)) |
2469 { | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2470 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
|
2471 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
|
2472 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
|
2473 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2474 _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
|
2475 |
3 | 2476 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
|
2477 gtk_text_insert(GTK_TEXT(tmp), font, fore, back, impbuf, -1); |
3 | 2478 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
|
2479 free(impbuf); |
3 | 2480 } |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2481 #endif |
3 | 2482 } |
2483 DW_MUTEX_UNLOCK; | |
2484 return tmppoint; | |
2485 } | |
2486 | |
2487 /* | |
2488 * Grabs text from an MLE box. | |
2489 * Parameters: | |
2490 * handle: Handle to the MLE to be queried. | |
2491 * buffer: Text buffer to be exported. | |
2492 * startpoint: Point to start grabbing text. | |
2493 * length: Amount of text to be grabbed. | |
2494 */ | |
2495 void dw_mle_export(HWND handle, char *buffer, int startpoint, int length) | |
2496 { | |
2497 int _locked_by_me = FALSE; | |
2498 gchar *text; | |
2499 | |
2500 DW_MUTEX_LOCK; | |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2501 #if GTK_MAJOR_VERSION > 1 |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2502 if(GTK_IS_SCROLLED_WINDOW(handle)) |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2503 #else |
3 | 2504 if(GTK_IS_BOX(handle)) |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2505 #endif |
3 | 2506 { |
2507 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); | |
2508 | |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2509 #if GTK_MAJOR_VERSION > 1 |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2510 if(tmp && GTK_IS_TEXT_VIEW(tmp)) |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2511 { |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2512 GtkTextBuffer *tbuffer; |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2513 GtkTextIter start, end; |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2514 |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2515 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp)); |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2516 gtk_text_buffer_get_iter_at_offset(tbuffer, &start, startpoint); |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2517 gtk_text_buffer_get_iter_at_offset(tbuffer, &end, startpoint + length); |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2518 text = gtk_text_iter_get_text(&start, &end); |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2519 if(text) /* Should this get freed? */ |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2520 strcpy(buffer, text); |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2521 } |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2522 #else |
3 | 2523 if(tmp && GTK_IS_TEXT(tmp)) |
2524 { | |
2525 text = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), startpoint, startpoint + length); | |
2526 if(text) | |
2527 { | |
2528 strcpy(buffer, text); | |
2529 g_free(text); | |
2530 } | |
2531 } | |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2532 #endif |
3 | 2533 } |
2534 DW_MUTEX_UNLOCK; | |
2535 } | |
2536 | |
2537 /* | |
2538 * Obtains information about an MLE box. | |
2539 * Parameters: | |
2540 * handle: Handle to the MLE to be queried. | |
2541 * bytes: A pointer to a variable to return the total bytes. | |
2542 * lines: A pointer to a variable to return the number of lines. | |
2543 */ | |
2544 void dw_mle_query(HWND handle, unsigned long *bytes, unsigned long *lines) | |
2545 { | |
2546 int _locked_by_me = FALSE; | |
2547 | |
2548 if(bytes) | |
2549 *bytes = 0; | |
2550 if(lines) | |
2551 *lines = 0; | |
2552 | |
2553 DW_MUTEX_LOCK; | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2554 #if GTK_MAJOR_VERSION > 1 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2555 if(GTK_IS_SCROLLED_WINDOW(handle)) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2556 { |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2557 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2558 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2559 if(tmp && GTK_IS_TEXT_VIEW(tmp)) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2560 { |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2561 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tmp)); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2562 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2563 if(bytes) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2564 *bytes = gtk_text_buffer_get_char_count(buffer) + 1; |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2565 if(lines) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2566 *lines = gtk_text_buffer_get_line_count(buffer) + 1; |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2567 } |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2568 } |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2569 #else |
3 | 2570 if(GTK_IS_BOX(handle)) |
2571 { | |
2572 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); | |
2573 | |
2574 if(tmp && GTK_IS_TEXT(tmp)) | |
2575 { | |
2576 if(bytes) | |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
2577 *bytes = gtk_text_get_length(GTK_TEXT(tmp)) + 1; |
3 | 2578 if(lines) |
2579 { | |
2580 gchar *text; | |
2581 | |
2582 *lines = 0; | |
2583 text = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), 0, bytes ? *bytes : gtk_text_get_length(GTK_TEXT(tmp))); | |
2584 | |
2585 if(text) | |
2586 { | |
2587 int z, len = strlen(text); | |
2588 | |
2589 for(z=0;z<len;z++) | |
2590 { | |
2591 if(text[z] == '\n') | |
2592 (*lines)++; | |
2593 } | |
2594 g_free(text); | |
2595 } | |
2596 } | |
2597 } | |
2598 } | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2599 #endif |
3 | 2600 DW_MUTEX_UNLOCK; |
2601 } | |
2602 | |
2603 /* | |
2604 * Deletes text from an MLE box. | |
2605 * Parameters: | |
2606 * handle: Handle to the MLE to be deleted from. | |
2607 * startpoint: Point to start deleting text. | |
2608 * length: Amount of text to be deleted. | |
2609 */ | |
2610 void dw_mle_delete(HWND handle, int startpoint, int length) | |
2611 { | |
2612 int _locked_by_me = FALSE; | |
2613 | |
2614 DW_MUTEX_LOCK; | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2615 #if GTK_MAJOR_VERSION > 1 |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2616 if(GTK_IS_SCROLLED_WINDOW(handle)) |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2617 #else |
3 | 2618 if(GTK_IS_BOX(handle)) |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2619 #endif |
3 | 2620 { |
2621 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); | |
2622 | |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2623 #if GTK_MAJOR_VERSION > 1 |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2624 if(tmp && GTK_IS_TEXT_VIEW(tmp)) |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2625 { |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2626 GtkTextBuffer *tbuffer; |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2627 GtkTextIter start, end; |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2628 |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2629 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp)); |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2630 gtk_text_buffer_get_iter_at_offset(tbuffer, &start, startpoint); |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2631 gtk_text_buffer_get_iter_at_offset(tbuffer, &end, startpoint + length); |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2632 gtk_text_buffer_delete(tbuffer, &start, &end); |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2633 } |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2634 #else |
3 | 2635 if(tmp && GTK_IS_TEXT(tmp)) |
2636 { | |
2637 gtk_text_set_point(GTK_TEXT(tmp), startpoint); | |
2638 gtk_text_forward_delete(GTK_TEXT(tmp), length); | |
2639 } | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2640 #endif |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2641 } |
3 | 2642 DW_MUTEX_UNLOCK; |
2643 } | |
2644 | |
2645 /* | |
2646 * Clears all text from an MLE box. | |
2647 * Parameters: | |
2648 * handle: Handle to the MLE to be cleared. | |
2649 */ | |
2650 void dw_mle_clear(HWND handle) | |
2651 { | |
2652 int length, _locked_by_me = FALSE; | |
2653 | |
2654 DW_MUTEX_LOCK; | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2655 #if GTK_MAJOR_VERSION > 1 |
122
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
2656 if(GTK_IS_SCROLLED_WINDOW(handle)) |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
2657 { |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
2658 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
2659 |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
2660 if(tmp && GTK_IS_TEXT_VIEW(tmp)) |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
2661 { |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
2662 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tmp)); |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
2663 |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
2664 length = -1; |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
2665 gtk_text_buffer_set_text(buffer, "", length); |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
2666 } |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
2667 } |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2668 #else |
3 | 2669 if(GTK_IS_BOX(handle)) |
2670 { | |
2671 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); | |
2672 | |
2673 if(tmp && GTK_IS_TEXT(tmp)) | |
2674 { | |
2675 length = gtk_text_get_length(GTK_TEXT(tmp)); | |
2676 gtk_text_set_point(GTK_TEXT(tmp), 0); | |
2677 gtk_text_forward_delete(GTK_TEXT(tmp), length); | |
2678 } | |
2679 } | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2680 #endif |
3 | 2681 DW_MUTEX_UNLOCK; |
2682 } | |
2683 | |
2684 /* | |
2685 * Sets the visible line of an MLE box. | |
2686 * Parameters: | |
2687 * handle: Handle to the MLE. | |
2688 * line: Line to be visible. | |
2689 */ | |
2690 void dw_mle_set_visible(HWND handle, int line) | |
2691 { | |
2692 int _locked_by_me = FALSE; | |
2693 | |
2694 DW_MUTEX_LOCK; | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2695 #if GTK_MAJOR_VERSION > 1 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2696 #else |
3 | 2697 if(GTK_IS_BOX(handle)) |
2698 { | |
2699 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); | |
2700 | |
2701 if(tmp && GTK_IS_TEXT(tmp)) | |
2702 { | |
2703 unsigned long lines; | |
2704 float pos, ratio; | |
2705 | |
2706 dw_mle_query(handle, NULL, &lines); | |
2707 | |
2708 if(lines) | |
2709 { | |
2710 ratio = (float)line/(float)lines; | |
2711 | |
2712 pos = (ratio * (float)(GTK_TEXT(tmp)->vadj->upper - GTK_TEXT(tmp)->vadj->lower)) + GTK_TEXT(tmp)->vadj->lower; | |
2713 | |
2714 gtk_adjustment_set_value(GTK_TEXT(tmp)->vadj, pos); | |
2715 } | |
2716 } | |
2717 } | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2718 #endif |
3 | 2719 DW_MUTEX_UNLOCK; |
2720 } | |
2721 | |
2722 /* | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2723 * Sets the editablity of an MLE box. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2724 * Parameters: |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2725 * handle: Handle to the MLE. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2726 * 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
|
2727 */ |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2728 void dw_mle_set_editable(HWND handle, int state) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2729 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2730 int _locked_by_me = FALSE; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2731 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2732 DW_MUTEX_LOCK; |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2733 #if GTK_MAJOR_VERSION > 1 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2734 if(GTK_IS_SCROLLED_WINDOW(handle)) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2735 { |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2736 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2737 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2738 if(tmp && GTK_IS_TEXT_VIEW(tmp)) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2739 gtk_text_view_set_editable(GTK_TEXT_VIEW(tmp), state); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2740 } |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2741 #else |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2742 if(GTK_IS_BOX(handle)) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2743 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2744 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
|
2745 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2746 if(tmp && GTK_IS_TEXT(tmp)) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2747 gtk_text_set_editable(GTK_TEXT(tmp), state); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2748 } |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2749 #endif |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2750 DW_MUTEX_UNLOCK; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2751 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2752 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2753 /* |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2754 * Sets the word wrap state of an MLE box. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2755 * Parameters: |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2756 * handle: Handle to the MLE. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2757 * 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
|
2758 */ |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2759 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
|
2760 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2761 int _locked_by_me = FALSE; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2762 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2763 DW_MUTEX_LOCK; |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2764 #if GTK_MAJOR_VERSION > 1 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2765 if(GTK_IS_SCROLLED_WINDOW(handle)) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2766 { |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2767 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2768 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2769 if(tmp && GTK_IS_TEXT_VIEW(tmp)) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2770 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(tmp), GTK_WRAP_WORD); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2771 } |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2772 #else |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2773 if(GTK_IS_BOX(handle)) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2774 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2775 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
|
2776 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2777 if(tmp && GTK_IS_TEXT(tmp)) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2778 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2779 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
|
2780 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
|
2781 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2782 } |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2783 #endif |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2784 DW_MUTEX_UNLOCK; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2785 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2786 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2787 /* |
3 | 2788 * Sets the current cursor position of an MLE box. |
2789 * Parameters: | |
2790 * handle: Handle to the MLE to be positioned. | |
2791 * point: Point to position cursor. | |
2792 */ | |
2793 void dw_mle_set(HWND handle, int point) | |
2794 { | |
2795 int _locked_by_me = FALSE; | |
2796 | |
2797 DW_MUTEX_LOCK; | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2798 #if GTK_MAJOR_VERSION > 1 |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2799 if(GTK_IS_SCROLLED_WINDOW(handle)) |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2800 #else |
3 | 2801 if(GTK_IS_BOX(handle)) |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2802 #endif |
3 | 2803 { |
2804 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); | |
2805 | |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2806 #if GTK_MAJOR_VERSION > 1 |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2807 if(tmp && GTK_IS_TEXT_VIEW(tmp)) |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2808 { |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2809 GtkTextBuffer *tbuffer; |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2810 GtkTextIter iter; |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2811 |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2812 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp)); |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2813 gtk_text_buffer_get_iter_at_offset(tbuffer, &iter, point); |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2814 gtk_text_buffer_place_cursor(tbuffer, &iter); |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2815 } |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2816 #else |
3 | 2817 if(tmp && GTK_IS_TEXT(tmp)) |
2818 { | |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
2819 unsigned long chars; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
2820 float pos, ratio; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
2821 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
2822 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
|
2823 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
2824 if(chars) |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
2825 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
2826 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
|
2827 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
2828 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
|
2829 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
2830 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
|
2831 } |
3 | 2832 gtk_text_set_point(GTK_TEXT(tmp), point); |
2833 } | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2834 #endif |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2835 } |
3 | 2836 DW_MUTEX_UNLOCK; |
2837 } | |
2838 | |
2839 /* | |
2840 * Finds text in an MLE box. | |
2841 * Parameters: | |
2842 * handle: Handle to the MLE to be cleared. | |
2843 * text: Text to search for. | |
2844 * point: Start point of search. | |
2845 * flags: Search specific flags. | |
2846 */ | |
2847 int dw_mle_search(HWND handle, char *text, int point, unsigned long flags) | |
2848 { | |
2849 int _locked_by_me = FALSE, retval = 0; | |
2850 | |
2851 DW_MUTEX_LOCK; | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2852 #if GTK_MAJOR_VERSION > 1 |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2853 if(GTK_IS_SCROLLED_WINDOW(handle)) |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2854 #else |
3 | 2855 if(GTK_IS_BOX(handle)) |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2856 #endif |
3 | 2857 { |
2858 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); | |
2859 | |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2860 #if GTK_MAJOR_VERSION > 1 |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2861 if(tmp && GTK_IS_TEXT_VIEW(tmp)) |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2862 { |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2863 GtkTextBuffer *tbuffer; |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2864 GtkTextIter iter, found; |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2865 |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2866 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp)); |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2867 gtk_text_buffer_get_iter_at_offset(tbuffer, &iter, point); |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2868 gtk_text_iter_forward_search(&iter, text, GTK_TEXT_SEARCH_TEXT_ONLY, &found, NULL, NULL); |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2869 retval = gtk_text_iter_get_offset(&found); |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2870 } |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2871 #else |
3 | 2872 if(tmp && GTK_IS_TEXT(tmp)) |
2873 { | |
2874 int len = gtk_text_get_length(GTK_TEXT(tmp)); | |
2875 gchar *tmpbuf; | |
2876 | |
2877 tmpbuf = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), 0, len); | |
2878 if(tmpbuf) | |
2879 { | |
2880 int z, textlen; | |
2881 | |
2882 textlen = strlen(text); | |
2883 | |
2884 if(flags & DW_MLE_CASESENSITIVE) | |
2885 { | |
2886 for(z=point;z<(len-textlen) && !retval;z++) | |
2887 { | |
2888 if(strncmp(&tmpbuf[z], text, textlen) == 0) | |
2889 retval = z + textlen; | |
2890 } | |
2891 } | |
2892 else | |
2893 { | |
2894 for(z=point;z<(len-textlen) && !retval;z++) | |
2895 { | |
2896 if(strncasecmp(&tmpbuf[z], text, textlen) == 0) | |
2897 retval = z + textlen; | |
2898 } | |
2899 } | |
2900 | |
2901 if(retval) | |
2902 { | |
2903 gtk_text_set_point(GTK_TEXT(tmp), retval - textlen); | |
2904 gtk_editable_select_region(&(GTK_TEXT(tmp)->editable), retval - textlen, retval); | |
2905 } | |
2906 | |
2907 g_free(tmpbuf); | |
2908 } | |
2909 } | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2910 #endif |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2911 } |
3 | 2912 DW_MUTEX_UNLOCK; |
2913 return retval; | |
2914 } | |
2915 | |
2916 /* | |
2917 * Stops redrawing of an MLE box. | |
2918 * Parameters: | |
2919 * handle: Handle to the MLE to freeze. | |
2920 */ | |
2921 void dw_mle_freeze(HWND handle) | |
2922 { | |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2923 #if GTK_MAJOR_VERSION < 2 |
3 | 2924 int _locked_by_me = FALSE; |
2925 | |
2926 DW_MUTEX_LOCK; | |
2927 if(GTK_IS_BOX(handle)) | |
2928 { | |
2929 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); | |
2930 | |
2931 if(tmp && GTK_IS_TEXT(tmp)) | |
2932 { | |
2933 gtk_text_freeze(GTK_TEXT(tmp)); | |
2934 } | |
2935 } | |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2936 DW_MUTEX_UNLOCK; |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2937 #endif |
3 | 2938 } |
2939 | |
2940 /* | |
2941 * Resumes redrawing of an MLE box. | |
2942 * Parameters: | |
2943 * handle: Handle to the MLE to thaw. | |
2944 */ | |
2945 void dw_mle_thaw(HWND handle) | |
2946 { | |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2947 #if GTK_MAJOR_VERSION < 2 |
3 | 2948 int _locked_by_me = FALSE; |
2949 | |
2950 DW_MUTEX_LOCK; | |
2951 if(GTK_IS_BOX(handle)) | |
2952 { | |
2953 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); | |
2954 | |
2955 if(tmp && GTK_IS_TEXT(tmp)) | |
2956 { | |
2957 gtk_text_thaw(GTK_TEXT(tmp)); | |
2958 } | |
2959 } | |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
2960 DW_MUTEX_UNLOCK; |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2961 #endif |
3 | 2962 } |
2963 | |
2964 /* | |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
2965 * Returns the range of the percent bar. |
3 | 2966 * 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
|
2967 * handle: Handle to the percent bar to be queried. |
3 | 2968 */ |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
2969 unsigned int dw_percent_query_range(HWND handle) |
3 | 2970 { |
2971 return 100; | |
2972 } | |
2973 | |
2974 /* | |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
2975 * Sets the percent bar position. |
3 | 2976 * 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
|
2977 * 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
|
2978 * position: Position of the percent bar withing the range. |
3 | 2979 */ |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
2980 void dw_percent_set_pos(HWND handle, unsigned int position) |
3 | 2981 { |
2982 int _locked_by_me = FALSE; | |
2983 | |
2984 DW_MUTEX_LOCK; | |
2985 gtk_progress_bar_update(GTK_PROGRESS_BAR(handle), (gfloat)position/100); | |
2986 DW_MUTEX_UNLOCK; | |
2987 } | |
2988 | |
2989 /* | |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2990 * 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
|
2991 * Parameters: |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2992 * 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
|
2993 */ |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2994 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
|
2995 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2996 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
|
2997 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
|
2998 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2999 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
|
3000 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
|
3001 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3002 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
|
3003 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
|
3004 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
|
3005 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3006 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
|
3007 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
|
3008 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3009 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
|
3010 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
|
3011 else |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3012 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
|
3013 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3014 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
|
3015 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
|
3016 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3017 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3018 /* |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3019 * 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
|
3020 * Parameters: |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3021 * 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
|
3022 * 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
|
3023 */ |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3024 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
|
3025 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3026 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
|
3027 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
|
3028 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3029 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
|
3030 return; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3031 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3032 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
|
3033 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
|
3034 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
|
3035 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3036 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
|
3037 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3038 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
|
3039 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
|
3040 else |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3041 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
|
3042 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3043 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
|
3044 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3045 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3046 /* |
3 | 3047 * Sets the spinbutton value. |
3048 * Parameters: | |
3049 * handle: Handle to the spinbutton to be set. | |
3050 * position: Current value of the spinbutton. | |
3051 */ | |
3052 void dw_spinbutton_set_pos(HWND handle, long position) | |
3053 { | |
3054 int _locked_by_me = FALSE; | |
3055 | |
3056 DW_MUTEX_LOCK; | |
3057 gtk_spin_button_set_value(GTK_SPIN_BUTTON(handle), (gfloat)position); | |
3058 DW_MUTEX_UNLOCK; | |
3059 } | |
3060 | |
3061 /* | |
3062 * Sets the spinbutton limits. | |
3063 * Parameters: | |
3064 * handle: Handle to the spinbutton to be set. | |
3065 * position: Current value of the spinbutton. | |
3066 * position: Current value of the spinbutton. | |
3067 */ | |
3068 void dw_spinbutton_set_limits(HWND handle, long upper, long lower) | |
3069 { | |
3070 long curval; | |
3071 GtkAdjustment *adj; | |
3072 int _locked_by_me = FALSE; | |
3073 | |
3074 curval = dw_spinbutton_query(handle); | |
3075 DW_MUTEX_LOCK; | |
3076 adj = (GtkAdjustment *)gtk_adjustment_new((gfloat)curval, (gfloat)lower, (gfloat)upper, 1.0, 5.0, 0.0); | |
3077 DW_MUTEX_UNLOCK; | |
3078 } | |
3079 | |
3080 /* | |
3081 * Sets the entryfield character limit. | |
3082 * Parameters: | |
3083 * handle: Handle to the spinbutton to be set. | |
3084 * limit: Number of characters the entryfield will take. | |
3085 */ | |
3086 void dw_entryfield_set_limit(HWND handle, ULONG limit) | |
3087 { | |
3088 /* TODO: can this be done after the fact? */ | |
3089 } | |
3090 | |
3091 /* | |
3092 * Returns the current value of the spinbutton. | |
3093 * Parameters: | |
3094 * handle: Handle to the spinbutton to be queried. | |
3095 */ | |
3096 long dw_spinbutton_query(HWND handle) | |
3097 { | |
3098 long retval; | |
3099 int _locked_by_me = FALSE; | |
3100 | |
3101 DW_MUTEX_LOCK; | |
3102 retval = (long)gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(handle)); | |
3103 DW_MUTEX_UNLOCK; | |
3104 | |
3105 return retval; | |
3106 } | |
3107 | |
3108 /* | |
3109 * Returns the state of the checkbox. | |
3110 * Parameters: | |
3111 * handle: Handle to the checkbox to be queried. | |
3112 */ | |
3113 int dw_checkbox_query(HWND handle) | |
3114 { | |
3115 int retval; | |
3116 int _locked_by_me = FALSE; | |
3117 | |
3118 DW_MUTEX_LOCK; | |
3119 retval = GTK_TOGGLE_BUTTON(handle)->active; | |
3120 DW_MUTEX_UNLOCK; | |
3121 | |
3122 return retval; | |
3123 } | |
3124 | |
3125 /* | |
3126 * Sets the state of the checkbox. | |
3127 * Parameters: | |
3128 * handle: Handle to the checkbox to be queried. | |
3129 * value: TRUE for checked, FALSE for unchecked. | |
3130 */ | |
3131 void dw_checkbox_set(HWND handle, int value) | |
3132 { | |
3133 int _locked_by_me = FALSE; | |
3134 | |
3135 DW_MUTEX_LOCK; | |
3136 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(handle), value); | |
3137 DW_MUTEX_UNLOCK; | |
3138 } | |
3139 | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3140 /* |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3141 * 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
|
3142 * Parameters: |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3143 * 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
|
3144 * 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
|
3145 * title: The text title of the entry. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3146 * icon: Handle to coresponding icon. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3147 * parent: Parent handle or 0 if root. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3148 * itemdata: Item specific data. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3149 */ |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3150 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
|
3151 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3152 GtkWidget *newitem, *tree, *subtree, *label, *hbox, *pixmap; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3153 GdkPixmap *gdkpix; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3154 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
|
3155 int position = -1; |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3156 int _locked_by_me = FALSE; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3157 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3158 if(!handle) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3159 return NULL; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3160 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3161 DW_MUTEX_LOCK; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3162 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
|
3163 if(!tree || !GTK_IS_TREE(tree)) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3164 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3165 DW_MUTEX_UNLOCK; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3166 return NULL; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3167 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3168 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3169 if(item && GTK_IS_TREE_ITEM(item)) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3170 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
|
3171 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3172 position++; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3173 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3174 newitem = gtk_tree_item_new(); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3175 label = gtk_label_new(title); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3176 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
|
3177 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
|
3178 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
|
3179 hbox = gtk_hbox_new(FALSE, 2); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3180 gtk_object_set_data(GTK_OBJECT(newitem), "hbox", (gpointer)hbox); |
121
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
3181 gdkpix = _find_pixmap(&gdkbmp, icon, hbox, NULL, NULL); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3182 #if GTK_MAJOR_VERSION > 1 |
121
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
3183 pixmap = gtk_image_new_from_pixmap(gdkpix, gdkbmp); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3184 #else |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3185 pixmap = gtk_pixmap_new(gdkpix, gdkbmp); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3186 #endif |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3187 gtk_container_add(GTK_CONTAINER(newitem), hbox); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3188 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
|
3189 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
|
3190 gtk_widget_show(label); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3191 gtk_widget_show(pixmap); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3192 gtk_widget_show(hbox); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3193 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3194 if(parent) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3195 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3196 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
|
3197 if(!subtree) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3198 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3199 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
|
3200 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
|
3201 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3202 subtree = gtk_tree_new(); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3203 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3204 if(thisfunc && work) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3205 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
|
3206 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3207 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
|
3208 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
|
3209 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3210 if(thisfunc && work) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3211 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
|
3212 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3213 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
|
3214 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
|
3215 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
|
3216 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
|
3217 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
|
3218 gtk_widget_show(subtree); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3219 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
|
3220 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
|
3221 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3222 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
|
3223 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
|
3224 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3225 else |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3226 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3227 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
|
3228 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
|
3229 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3230 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
|
3231 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
|
3232 gtk_widget_show(newitem); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3233 DW_MUTEX_UNLOCK; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3234 return newitem; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3235 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3236 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3237 /* |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3238 * 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
|
3239 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3240 * 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
|
3241 * 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
|
3242 * 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
|
3243 * 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
|
3244 * 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
|
3245 */ |
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
|
3246 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
|
3247 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3248 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
|
3249 GdkPixmap *gdkpix; |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3250 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
|
3251 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
|
3252 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3253 if(!handle) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3254 return NULL; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3255 |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3256 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
|
3257 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
|
3258 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
|
3259 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3260 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
|
3261 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
|
3262 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3263 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
|
3264 label = gtk_label_new(title); |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3265 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
|
3266 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
|
3267 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
|
3268 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
|
3269 gtk_object_set_data(GTK_OBJECT(item), "hbox", (gpointer)hbox); |
121
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
3270 gdkpix = _find_pixmap(&gdkbmp, icon, hbox, NULL, NULL); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3271 #if GTK_MAJOR_VERSION > 1 |
121
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
3272 pixmap = gtk_image_new_from_pixmap(gdkpix, gdkbmp); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3273 #else |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3274 pixmap = gtk_pixmap_new(gdkpix, gdkbmp); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3275 #endif |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3276 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
|
3277 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
|
3278 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
|
3279 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
|
3280 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
|
3281 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
|
3282 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3283 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
|
3284 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3285 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
|
3286 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
|
3287 { |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3288 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
|
3289 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
|
3290 |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3291 subtree = gtk_tree_new(); |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3292 |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3293 if(thisfunc && work) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3294 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
|
3295 |
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
|
3296 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
|
3297 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
|
3298 |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3299 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
|
3300 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
|
3301 |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3302 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
|
3303 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
|
3304 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
|
3305 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
|
3306 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
|
3307 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
|
3308 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
|
3309 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
|
3310 } |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3311 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
|
3312 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
|
3313 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3314 else |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3315 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3316 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
|
3317 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
|
3318 } |
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
|
3319 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
|
3320 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
|
3321 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
|
3322 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
|
3323 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
|
3324 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3325 |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3326 /* |
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
|
3327 * 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
|
3328 * 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
|
3329 * 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
|
3330 * 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
|
3331 * 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
|
3332 * 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
|
3333 */ |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3334 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
|
3335 { |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3336 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
|
3337 GdkPixmap *gdkpix; |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3338 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
|
3339 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
|
3340 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
|
3341 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3342 if(!handle || !item) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3343 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3344 |
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
|
3345 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
|
3346 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
|
3347 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
|
3348 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
|
3349 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
|
3350 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
|
3351 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
|
3352 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
|
3353 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
|
3354 gtk_object_set_data(GTK_OBJECT(item), "hbox", (gpointer)hbox); |
121
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
3355 gdkpix = _find_pixmap(&gdkbmp, icon, hbox, NULL, NULL); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3356 #if GTK_MAJOR_VERSION > 1 |
121
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
3357 pixmap = gtk_image_new_from_pixmap(gdkpix, gdkbmp); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3358 #else |
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
|
3359 pixmap = gtk_pixmap_new(gdkpix, gdkbmp); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3360 #endif |
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
|
3361 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
|
3362 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
|
3363 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
|
3364 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
|
3365 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
|
3366 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
|
3367 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
|
3368 } |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3369 |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3370 /* |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3371 * 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
|
3372 * 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
|
3373 * 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
|
3374 * 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
|
3375 * 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
|
3376 */ |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3377 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
|
3378 { |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3379 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
|
3380 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3381 if(!handle || !item) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3382 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3383 |
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
|
3384 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
|
3385 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
|
3386 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
|
3387 } |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3388 |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3389 /* |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3390 * 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
|
3391 * 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
|
3392 * 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
|
3393 * 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
|
3394 */ |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3395 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
|
3396 { |
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
|
3397 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
|
3398 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
|
3399 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3400 if(!handle || !item) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3401 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3402 |
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
|
3403 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
|
3404 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
|
3405 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
|
3406 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
|
3407 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
|
3408 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
|
3409 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
|
3410 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
|
3411 } |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3412 |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3413 /* |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3414 * Removes all nodes from a tree. |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3415 * Parameters: |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3416 * 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
|
3417 */ |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3418 void dw_tree_clear(HWND handle) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3419 { |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3420 GtkWidget *tree; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3421 int _locked_by_me = FALSE; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3422 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3423 if(!handle) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3424 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3425 |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3426 DW_MUTEX_LOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3427 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
|
3428 if(!tree || !GTK_IS_TREE(tree)) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3429 { |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3430 DW_MUTEX_UNLOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3431 return; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3432 } |
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
|
3433 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
|
3434 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
|
3435 DW_MUTEX_UNLOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3436 } |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3437 |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3438 /* |
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
|
3439 * 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
|
3440 * 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
|
3441 * 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
|
3442 * 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
|
3443 */ |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3444 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
|
3445 { |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3446 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
|
3447 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3448 if(!handle || !item) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3449 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3450 |
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
|
3451 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
|
3452 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
|
3453 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
|
3454 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
|
3455 } |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3456 |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3457 /* |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3458 * 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
|
3459 * 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
|
3460 * 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
|
3461 * 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
|
3462 */ |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3463 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
|
3464 { |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3465 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
|
3466 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3467 if(!handle || !item) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3468 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3469 |
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
|
3470 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
|
3471 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
|
3472 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
|
3473 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
|
3474 } |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3475 |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
3476 /* |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3477 * Removes a node from a tree. |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3478 * Parameters: |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3479 * 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
|
3480 * item: Handle to node to be deleted. |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3481 */ |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3482 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
|
3483 { |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3484 GtkWidget *tree, *lastselect, *parenttree; |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3485 int _locked_by_me = FALSE; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3486 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3487 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
|
3488 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3489 |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3490 DW_MUTEX_LOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3491 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
|
3492 if(!tree || !GTK_IS_TREE(tree)) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3493 { |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3494 DW_MUTEX_UNLOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3495 return; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3496 } |
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
|
3497 |
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
|
3498 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
|
3499 |
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
|
3500 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
|
3501 |
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
|
3502 if(lastselect == item) |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3503 { |
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
|
3504 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
|
3505 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
|
3506 } |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3507 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3508 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
|
3509 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
|
3510 DW_MUTEX_UNLOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3511 } |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3512 |
3 | 3513 int _dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator, int extra) |
3514 { | |
3515 GtkWidget *clist; | |
3516 char numbuf[10]; | |
3517 int z; | |
3518 int _locked_by_me = FALSE; | |
3519 | |
3520 DW_MUTEX_LOCK; | |
3521 clist = gtk_clist_new_with_titles(count, (gchar **)titles); | |
3522 if(!clist) | |
3523 { | |
3524 DW_MUTEX_UNLOCK; | |
3525 return FALSE; | |
3526 } | |
3527 | |
3528 gtk_signal_connect(GTK_OBJECT(clist), "select_row", GTK_SIGNAL_FUNC(_select_row), NULL); | |
3529 gtk_signal_connect(GTK_OBJECT(clist), "unselect_row", GTK_SIGNAL_FUNC(_unselect_row), NULL); | |
3530 | |
3531 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
|
3532 gtk_clist_set_selection_mode(GTK_CLIST(clist), GTK_SELECTION_SINGLE); |
3 | 3533 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
|
3534 gtk_object_set_data(GTK_OBJECT(clist), "multi", (gpointer)0); |
3 | 3535 gtk_object_set_user_data(GTK_OBJECT(handle), (gpointer)clist); |
3536 gtk_widget_show(clist); | |
3537 gtk_object_set_data(GTK_OBJECT(clist), "colcount", (gpointer)count); | |
3538 | |
3539 if(extra) | |
3540 gtk_clist_set_column_width(GTK_CLIST(clist), 1, 120); | |
3541 | |
3542 for(z=0;z<count;z++) | |
3543 { | |
3544 if(!extra || z > 1) | |
3545 gtk_clist_set_column_width(GTK_CLIST(clist), z, 50); | |
3546 sprintf(numbuf, "%d", z); | |
3547 gtk_object_set_data(GTK_OBJECT(clist), numbuf, (gpointer)flags[z]); | |
3548 } | |
3549 | |
3550 DW_MUTEX_UNLOCK; | |
3551 return TRUE; | |
3552 } | |
3553 | |
3554 /* | |
3555 * Sets up the container columns. | |
3556 * Parameters: | |
3557 * handle: Handle to the container to be configured. | |
3558 * flags: An array of unsigned longs with column flags. | |
3559 * titles: An array of strings with column text titles. | |
3560 * count: The number of columns (this should match the arrays). | |
3561 * separator: The column number that contains the main separator. | |
3562 * (this item may only be used in OS/2) | |
3563 */ | |
3564 int dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator) | |
3565 { | |
3566 return _dw_container_setup(handle, flags, titles, count, separator, 0); | |
3567 } | |
3568 | |
3569 /* | |
3570 * Sets up the filesystem columns, note: filesystem always has an icon/filename field. | |
3571 * Parameters: | |
3572 * handle: Handle to the container to be configured. | |
3573 * flags: An array of unsigned longs with column flags. | |
3574 * titles: An array of strings with column text titles. | |
3575 * count: The number of columns (this should match the arrays). | |
3576 */ | |
3577 int dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count) | |
3578 { | |
3579 char **newtitles = malloc(sizeof(char *) * (count + 2)); | |
3580 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 2)); | |
3581 | |
3582 newtitles[0] = "Icon"; | |
3583 newtitles[1] = "Filename"; | |
3584 | |
3585 newflags[0] = DW_CFA_BITMAPORICON | DW_CFA_CENTER | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR; | |
3586 newflags[1] = DW_CFA_STRING | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR; | |
3587 | |
3588 memcpy(&newtitles[2], titles, sizeof(char *) * count); | |
3589 memcpy(&newflags[2], flags, sizeof(unsigned long) * count); | |
3590 | |
3591 _dw_container_setup(handle, newflags, newtitles, count + 2, 2, 1); | |
3592 | |
3593 free(newtitles); | |
3594 free(newflags); | |
3595 return TRUE; | |
3596 } | |
3597 | |
3598 /* | |
3599 * Obtains an icon from a module (or header in GTK). | |
3600 * Parameters: | |
3601 * module: Handle to module (DLL) in OS/2 and Windows. | |
3602 * id: A unsigned long id int the resources on OS/2 and | |
3603 * Windows, on GTK this is converted to a pointer | |
3604 * to an embedded XPM. | |
3605 */ | |
3606 unsigned long dw_icon_load(unsigned long module, unsigned long id) | |
3607 { | |
3608 return id; | |
3609 } | |
3610 | |
3611 /* | |
3612 * Frees a loaded resource in OS/2 and Windows. | |
3613 * Parameters: | |
3614 * handle: Handle to icon returned by dw_icon_load(). | |
3615 */ | |
3616 void dw_icon_free(unsigned long handle) | |
3617 { | |
3618 } | |
3619 | |
72
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
3620 /* 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
|
3621 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
|
3622 { |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
3623 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
|
3624 |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
3625 if(list) |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
3626 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
|
3627 |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
3628 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
|
3629 |
c629838d9805
Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
72
diff
changeset
|
3630 _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
|
3631 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
|
3632 _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
|
3633 } |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
3634 |
3 | 3635 /* |
3636 * Allocates memory used to populate a container. | |
3637 * Parameters: | |
3638 * handle: Handle to the container window (widget). | |
3639 * rowcount: The number of items to be populated. | |
3640 */ | |
3641 void *dw_container_alloc(HWND handle, int rowcount) | |
3642 { | |
3643 int z, count = 0; | |
3644 GtkWidget *clist; | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
3645 GdkColor *fore, *back; |
3 | 3646 char **blah; |
3647 int _locked_by_me = FALSE; | |
3648 | |
3649 DW_MUTEX_LOCK; | |
3650 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
3651 if(!clist) | |
3652 { | |
3653 DW_MUTEX_UNLOCK; | |
3654 return NULL; | |
3655 } | |
3656 | |
3657 count = (int)gtk_object_get_data(GTK_OBJECT(clist), "colcount"); | |
3658 | |
3659 if(!count) | |
3660 { | |
3661 DW_MUTEX_UNLOCK; | |
3662 return NULL; | |
3663 } | |
3664 | |
3665 blah = malloc(sizeof(char *) * count); | |
3666 memset(blah, 0, sizeof(char *) * count); | |
3667 | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
3668 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
|
3669 back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(clist), "backgdk"); |
3 | 3670 gtk_clist_freeze(GTK_CLIST(clist)); |
3671 for(z=0;z<rowcount;z++) | |
3672 { | |
3673 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
|
3674 if(fore) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
3675 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
|
3676 if(back) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
3677 gtk_clist_set_background(GTK_CLIST(clist), z, back); |
3 | 3678 } |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
3679 gtk_object_set_data(GTK_OBJECT(clist), "rowcount", (gpointer)rowcount); |
3 | 3680 free(blah); |
3681 DW_MUTEX_UNLOCK; | |
3682 return (void *)handle; | |
3683 } | |
3684 | |
3685 /* | |
3686 * Sets an item in specified row and column to the given data. | |
3687 * Parameters: | |
3688 * handle: Handle to the container window (widget). | |
3689 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
3690 * column: Zero based column of data being set. | |
3691 * row: Zero based row of data being set. | |
3692 * data: Pointer to the data to be added. | |
3693 */ | |
3694 void dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data) | |
3695 { | |
3696 char numbuf[10], textbuffer[100]; | |
3697 int flag = 0; | |
3698 GtkWidget *clist; | |
3699 int _locked_by_me = FALSE; | |
3700 | |
3701 DW_MUTEX_LOCK; | |
3702 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
3703 if(!clist) | |
3704 { | |
3705 DW_MUTEX_UNLOCK; | |
3706 return; | |
3707 } | |
3708 | |
3709 sprintf(numbuf, "%d", column); | |
3710 flag = (int)gtk_object_get_data(GTK_OBJECT(clist), numbuf); | |
3711 | |
3712 if(flag & DW_CFA_BITMAPORICON) | |
3713 { | |
3714 long hicon = *((long *)data); | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3715 GdkBitmap *bitmap = NULL; |
121
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
3716 GdkPixmap *pixmap = _find_pixmap(&bitmap, hicon, clist, NULL, NULL); |
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
3717 |
3 | 3718 if(pixmap) |
3719 gtk_clist_set_pixmap(GTK_CLIST(clist), row, column, pixmap, bitmap); | |
3720 } | |
3721 else if(flag & DW_CFA_STRING) | |
3722 { | |
3723 char *tmp = *((char **)data); | |
3724 gtk_clist_set_text(GTK_CLIST(clist), row, column, tmp); | |
3725 } | |
3726 else if(flag & DW_CFA_ULONG) | |
3727 { | |
3728 ULONG tmp = *((ULONG *)data); | |
3729 | |
3730 sprintf(textbuffer, "%lu", tmp); | |
3731 | |
3732 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer); | |
3733 } | |
3734 else if(flag & DW_CFA_DATE) | |
3735 { | |
3736 CDATE fdate = *((CDATE *)data); | |
3737 | |
92
0a085f295e81
A couple more minor changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
91
diff
changeset
|
3738 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
|
3739 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
|
3740 else |
30d091bc7899
Fixed an error in the container date code on Windows and Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
41
diff
changeset
|
3741 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
|
3742 |
3 | 3743 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer); |
3744 } | |
3745 else if(flag & DW_CFA_TIME) | |
3746 { | |
3747 CTIME ftime = *((CTIME *)data); | |
3748 | |
3749 if(ftime.hours > 12) | |
3750 sprintf(textbuffer, "%d:%s%dpm", ftime.hours - 12, (ftime.minutes < 10) ? "0" : "", ftime.minutes); | |
3751 else | |
3752 sprintf(textbuffer, "%d:%s%dam", ftime.hours ? ftime.hours : 12, (ftime.minutes < 10) ? "0" : "", ftime.minutes); | |
3753 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer); | |
3754 } | |
3755 DW_MUTEX_UNLOCK; | |
3756 } | |
3757 | |
3758 /* | |
3759 * Sets an item in specified row and column to the given data. | |
3760 * Parameters: | |
3761 * handle: Handle to the container window (widget). | |
3762 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
3763 * column: Zero based column of data being set. | |
3764 * row: Zero based row of data being set. | |
3765 * data: Pointer to the data to be added. | |
3766 */ | |
3767 void dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, unsigned long icon) | |
3768 { | |
3769 dw_container_set_item(handle, pointer, 0, row, (void *)&icon); | |
3770 dw_container_set_item(handle, pointer, 1, row, (void *)&filename); | |
3771 } | |
3772 | |
3773 /* | |
3774 * Sets an item in specified row and column to the given data. | |
3775 * Parameters: | |
3776 * handle: Handle to the container window (widget). | |
3777 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
3778 * column: Zero based column of data being set. | |
3779 * row: Zero based row of data being set. | |
3780 * data: Pointer to the data to be added. | |
3781 */ | |
3782 void dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data) | |
3783 { | |
3784 dw_container_set_item(handle, pointer, column + 2, row, data); | |
3785 } | |
3786 | |
3787 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3788 * 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
|
3789 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3790 * 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
|
3791 * 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
|
3792 * 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
|
3793 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3794 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
|
3795 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3796 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
|
3797 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
|
3798 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3799 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
|
3800 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
|
3801 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3802 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
|
3803 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
|
3804 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
|
3805 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3806 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3807 /* |
3 | 3808 * Sets the title of a row in the container. |
3809 * Parameters: | |
3810 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
3811 * row: Zero based row of data being set. | |
3812 * title: String title of the item. | |
3813 */ | |
3814 void dw_container_set_row_title(void *pointer, int row, char *title) | |
3815 { | |
3816 GtkWidget *clist; | |
3817 int _locked_by_me = FALSE; | |
3818 | |
3819 DW_MUTEX_LOCK; | |
3820 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(pointer)); | |
3821 | |
3822 if(clist) | |
3823 gtk_clist_set_row_data(GTK_CLIST(clist), row, (gpointer)title); | |
3824 DW_MUTEX_UNLOCK; | |
3825 } | |
3826 | |
3827 /* | |
3828 * Sets the title of a row in the container. | |
3829 * Parameters: | |
3830 * handle: Handle to the container window (widget). | |
3831 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
3832 * rowcount: The number of rows to be inserted. | |
3833 */ | |
3834 void dw_container_insert(HWND handle, void *pointer, int rowcount) | |
3835 { | |
3836 GtkWidget *clist; | |
3837 int _locked_by_me = FALSE; | |
3838 | |
3839 DW_MUTEX_LOCK; | |
3840 clist = gtk_object_get_user_data(GTK_OBJECT(handle)); | |
3841 | |
3842 if(clist && GTK_IS_CLIST(clist)) | |
3843 gtk_clist_thaw(GTK_CLIST(clist)); | |
3844 DW_MUTEX_UNLOCK; | |
3845 } | |
3846 | |
3847 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3848 * 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
|
3849 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3850 * 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
|
3851 * 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
|
3852 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3853 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
|
3854 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3855 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
|
3856 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
|
3857 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3858 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
|
3859 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
|
3860 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
|
3861 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3862 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
|
3863 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3864 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
|
3865 |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
3866 _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
|
3867 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3868 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
|
3869 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
|
3870 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3871 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
|
3872 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
|
3873 else |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3874 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
|
3875 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3876 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
|
3877 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3878 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
|
3879 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3880 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3881 /* |
3 | 3882 * Removes all rows from a container. |
3883 * Parameters: | |
3884 * 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
|
3885 * redraw: TRUE to cause the container to redraw immediately. |
3 | 3886 */ |
52
0804483f6320
Added a redraw parameter to dw_container_clear().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
51
diff
changeset
|
3887 void dw_container_clear(HWND handle, int redraw) |
3 | 3888 { |
3889 GtkWidget *clist; | |
3890 int _locked_by_me = FALSE; | |
3891 | |
3892 DW_MUTEX_LOCK; | |
3893 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
3894 if(clist && GTK_IS_CLIST(clist)) | |
3895 { | |
72
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
3896 _dw_unselect(clist); |
3 | 3897 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
|
3898 gtk_object_set_data(GTK_OBJECT(clist), "rowcount", (gpointer)0); |
3 | 3899 } |
3900 DW_MUTEX_UNLOCK; | |
3901 } | |
3902 | |
3903 /* | |
3904 * Removes all rows from a container. | |
3905 * Parameters: | |
3906 * handle: Handle to the window (widget) to be cleared. | |
3907 */ | |
3908 void dw_container_set_view(HWND handle, unsigned long flags, int iconwidth, int iconheight) | |
3909 { | |
3910 } | |
3911 | |
3912 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3913 * 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
|
3914 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3915 * 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
|
3916 * 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
|
3917 * 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
|
3918 * 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
|
3919 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3920 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
|
3921 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3922 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
|
3923 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
|
3924 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
|
3925 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3926 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
|
3927 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
|
3928 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
|
3929 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3930 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
|
3931 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
|
3932 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3933 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
|
3934 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3935 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
|
3936 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
|
3937 break; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3938 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
|
3939 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
|
3940 break; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3941 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3942 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
|
3943 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3944 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3945 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
|
3946 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3947 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3948 /* |
3 | 3949 * Starts a new query of a container. |
3950 * Parameters: | |
3951 * handle: Handle to the window (widget) to be queried. | |
3952 * flags: If this parameter is DW_CRA_SELECTED it will only | |
3953 * return items that are currently selected. Otherwise | |
3954 * it will return all records in the container. | |
3955 */ | |
3956 char *dw_container_query_start(HWND handle, unsigned long flags) | |
3957 { | |
3958 GtkWidget *clist; | |
3959 GList *list; | |
3960 char *retval = NULL; | |
3961 int _locked_by_me = FALSE; | |
3962 | |
3963 DW_MUTEX_LOCK; | |
3964 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
3965 | |
3966 if(!clist) | |
3967 { | |
3968 DW_MUTEX_UNLOCK; | |
3969 return NULL; | |
3970 } | |
3971 | |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3972 /* 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
|
3973 if(flags & DW_CRA_SELECTED || flags & DW_CRA_CURSORED) |
3 | 3974 { |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3975 /* 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
|
3976 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
|
3977 if(list) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3978 g_list_free(list); |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3979 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3980 /* 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
|
3981 * current selection list. |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3982 */ |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3983 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
|
3984 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
|
3985 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
|
3986 _dw_unselect(clist); |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3987 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3988 if(list) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3989 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3990 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
|
3991 if(list->data) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3992 retval = list->data; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3993 else |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3994 retval = ""; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3995 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3996 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3997 else |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3998 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
3999 retval = (char *)gtk_clist_get_row_data(GTK_CLIST(clist), 0); |
3 | 4000 gtk_object_set_data(GTK_OBJECT(clist), "querypos", (gpointer)1); |
4001 } | |
4002 DW_MUTEX_UNLOCK; | |
4003 return retval; | |
4004 } | |
4005 | |
4006 /* | |
4007 * Continues an existing query of a container. | |
4008 * Parameters: | |
4009 * handle: Handle to the window (widget) to be queried. | |
4010 * flags: If this parameter is DW_CRA_SELECTED it will only | |
4011 * return items that are currently selected. Otherwise | |
4012 * it will return all records in the container. | |
4013 */ | |
4014 char *dw_container_query_next(HWND handle, unsigned long flags) | |
4015 { | |
4016 GtkWidget *clist; | |
4017 GList *list; | |
4018 char *retval = NULL; | |
4019 int _locked_by_me = FALSE; | |
4020 | |
4021 DW_MUTEX_LOCK; | |
4022 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
4023 | |
4024 if(!clist) | |
4025 { | |
4026 DW_MUTEX_UNLOCK; | |
4027 return NULL; | |
4028 } | |
4029 | |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4030 /* 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
|
4031 if(flags & DW_CRA_SELECTED || flags & DW_CRA_CURSORED) |
3 | 4032 { |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4033 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
|
4034 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4035 if(list) |
3 | 4036 { |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4037 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
|
4038 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
|
4039 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4040 while(list && counter < pos) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4041 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4042 list = list->next; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4043 counter++; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4044 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4045 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4046 if(list && list->data) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4047 retval = list->data; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4048 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
|
4049 retval = ""; |
3 | 4050 } |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4051 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4052 else |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4053 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4054 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
|
4055 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4056 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
|
4057 gtk_object_set_data(GTK_OBJECT(clist), "querypos", (gpointer)pos+1); |
3 | 4058 } |
4059 DW_MUTEX_UNLOCK; | |
4060 return retval; | |
4061 } | |
4062 | |
4063 /* | |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4064 * 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
|
4065 * Parameters: |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4066 * 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
|
4067 * 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
|
4068 */ |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4069 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
|
4070 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4071 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
|
4072 GtkWidget *clist; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4073 int rowcount, z; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4074 char *rowdata; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4075 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4076 DW_MUTEX_LOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4077 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
|
4078 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4079 if(!clist) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4080 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4081 DW_MUTEX_UNLOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4082 return; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4083 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4084 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
|
4085 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4086 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
|
4087 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4088 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
|
4089 if(rowdata == text) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4090 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4091 gfloat pos; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4092 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
|
4093 |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
4094 _dw_unselect(clist); |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
4095 |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4096 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
|
4097 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4098 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
|
4099 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
|
4100 DW_MUTEX_UNLOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4101 return; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4102 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4103 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4104 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4105 DW_MUTEX_UNLOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4106 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4107 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4108 /* |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4109 * 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
|
4110 * Parameters: |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4111 * 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
|
4112 */ |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4113 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
|
4114 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4115 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
|
4116 GtkWidget *clist; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4117 int colcount, z; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4118 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4119 DW_MUTEX_LOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4120 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
|
4121 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4122 if(!clist) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4123 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4124 DW_MUTEX_UNLOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4125 return; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4126 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4127 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
|
4128 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
|
4129 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4130 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
|
4131 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
|
4132 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4133 DW_MUTEX_UNLOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4134 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4135 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4136 /* |
3 | 4137 * Creates a rendering context widget (window) to be packed. |
4138 * Parameters: | |
4139 * id: An id to be used with dw_window_from_id. | |
4140 * Returns: | |
4141 * A handle to the widget or NULL on failure. | |
4142 */ | |
4143 HWND dw_render_new(unsigned long id) | |
4144 { | |
4145 int _locked_by_me = FALSE; | |
4146 GtkWidget *tmp; | |
4147 | |
4148 DW_MUTEX_LOCK; | |
4149 tmp = gtk_drawing_area_new(); | |
4150 gtk_widget_set_events(tmp, GDK_EXPOSURE_MASK | |
4151 | GDK_LEAVE_NOTIFY_MASK | |
4152 | GDK_BUTTON_PRESS_MASK | |
4153 | GDK_POINTER_MOTION_MASK | |
4154 | GDK_POINTER_MOTION_HINT_MASK); | |
4155 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); | |
4156 gtk_widget_show(tmp); | |
4157 DW_MUTEX_UNLOCK; | |
4158 return tmp; | |
4159 } | |
4160 | |
4161 /* Sets the current foreground drawing color. | |
4162 * Parameters: | |
4163 * red: red value. | |
4164 * green: green value. | |
4165 * blue: blue value. | |
4166 */ | |
4167 void dw_color_foreground_set(unsigned long value) | |
4168 { | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4169 int _locked_by_me = FALSE, index = _find_thread_index(dw_thread_id()); |
3 | 4170 GdkColor color = { 0, DW_RED_VALUE(value) << 8, DW_GREEN_VALUE(value) << 8, DW_BLUE_VALUE(value) << 8 }; |
4171 | |
4172 DW_MUTEX_LOCK; | |
4173 gdk_color_alloc(_dw_cmap, &color); | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4174 _foreground[index] = color; |
3 | 4175 DW_MUTEX_UNLOCK; |
4176 } | |
4177 | |
4178 /* Sets the current background drawing color. | |
4179 * Parameters: | |
4180 * red: red value. | |
4181 * green: green value. | |
4182 * blue: blue value. | |
4183 */ | |
4184 void dw_color_background_set(unsigned long value) | |
4185 { | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4186 int _locked_by_me = FALSE, index = _find_thread_index(dw_thread_id()); |
3 | 4187 GdkColor color = { 0, DW_RED_VALUE(value) << 8, DW_GREEN_VALUE(value) << 8, DW_BLUE_VALUE(value) << 8 }; |
4188 | |
4189 DW_MUTEX_LOCK; | |
4190 gdk_color_alloc(_dw_cmap, &color); | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4191 _background[index] = color; |
3 | 4192 DW_MUTEX_UNLOCK; |
4193 } | |
4194 | |
4195 GdkGC *_set_colors(GdkWindow *window) | |
4196 { | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4197 GdkGC *gc = NULL; |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4198 int index = _find_thread_index(dw_thread_id()); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4199 |
3 | 4200 if(!window) |
4201 return NULL; | |
4202 gc = gdk_gc_new(window); | |
4203 if(gc) | |
4204 { | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4205 gdk_gc_set_foreground(gc, &_foreground[index]); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4206 gdk_gc_set_background(gc, &_background[index]); |
3 | 4207 } |
4208 return gc; | |
4209 } | |
4210 | |
4211 /* Draw a point on a window (preferably a render window). | |
4212 * Parameters: | |
4213 * handle: Handle to the window. | |
4214 * pixmap: Handle to the pixmap. (choose only one of these) | |
4215 * x: X coordinate. | |
4216 * y: Y coordinate. | |
4217 */ | |
4218 void dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y) | |
4219 { | |
4220 int _locked_by_me = FALSE; | |
4221 GdkGC *gc = NULL; | |
4222 | |
4223 DW_MUTEX_LOCK; | |
4224 if(handle) | |
4225 gc = _set_colors(handle->window); | |
4226 else if(pixmap) | |
4227 gc = _set_colors(pixmap->pixmap); | |
4228 if(gc) | |
4229 { | |
4230 gdk_draw_point(handle ? handle->window : pixmap->pixmap, gc, x, y); | |
4231 gdk_gc_unref(gc); | |
4232 } | |
4233 DW_MUTEX_UNLOCK; | |
4234 } | |
4235 | |
4236 /* Draw a line on a window (preferably a render window). | |
4237 * Parameters: | |
4238 * handle: Handle to the window. | |
4239 * pixmap: Handle to the pixmap. (choose only one of these) | |
4240 * x1: First X coordinate. | |
4241 * y1: First Y coordinate. | |
4242 * x2: Second X coordinate. | |
4243 * y2: Second Y coordinate. | |
4244 */ | |
4245 void dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2) | |
4246 { | |
4247 int _locked_by_me = FALSE; | |
4248 GdkGC *gc = NULL; | |
4249 | |
4250 DW_MUTEX_LOCK; | |
4251 if(handle) | |
4252 gc = _set_colors(handle->window); | |
4253 else if(pixmap) | |
4254 gc = _set_colors(pixmap->pixmap); | |
4255 if(gc) | |
4256 { | |
4257 gdk_draw_line(handle ? handle->window : pixmap->pixmap, gc, x1, y1, x2, y2); | |
4258 gdk_gc_unref(gc); | |
4259 } | |
4260 DW_MUTEX_UNLOCK; | |
4261 } | |
4262 | |
4263 /* Draw a rectangle on a window (preferably a render window). | |
4264 * Parameters: | |
4265 * handle: Handle to the window. | |
4266 * pixmap: Handle to the pixmap. (choose only one of these) | |
4267 * x: X coordinate. | |
4268 * y: Y coordinate. | |
4269 * width: Width of rectangle. | |
4270 * height: Height of rectangle. | |
4271 */ | |
4272 void dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height) | |
4273 { | |
4274 int _locked_by_me = FALSE; | |
4275 GdkGC *gc = NULL; | |
4276 | |
4277 DW_MUTEX_LOCK; | |
4278 if(handle) | |
4279 gc = _set_colors(handle->window); | |
4280 else if(pixmap) | |
4281 gc = _set_colors(pixmap->pixmap); | |
4282 if(gc) | |
4283 { | |
4284 gdk_draw_rectangle(handle ? handle->window : pixmap->pixmap, gc, fill, x, y, width, height); | |
4285 gdk_gc_unref(gc); | |
4286 } | |
4287 DW_MUTEX_UNLOCK; | |
4288 } | |
4289 | |
4290 /* Draw text on a window (preferably a render window). | |
4291 * Parameters: | |
4292 * handle: Handle to the window. | |
4293 * pixmap: Handle to the pixmap. (choose only one of these) | |
4294 * x: X coordinate. | |
4295 * y: Y coordinate. | |
4296 * text: Text to be displayed. | |
4297 */ | |
4298 void dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text) | |
4299 { | |
4300 int _locked_by_me = FALSE; | |
4301 GdkGC *gc = NULL; | |
4302 GdkFont *font; | |
4303 char *fontname = "fixed"; | |
4304 | |
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
|
4305 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
|
4306 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
|
4307 |
3 | 4308 DW_MUTEX_LOCK; |
4309 if(handle) | |
4310 { | |
4311 fontname = (char *)gtk_object_get_data(GTK_OBJECT(handle), "fontname"); | |
4312 gc = _set_colors(handle->window); | |
4313 } | |
4314 else if(pixmap) | |
4315 { | |
4316 fontname = (char *)gtk_object_get_data(GTK_OBJECT(pixmap->handle), "fontname"); | |
4317 gc = _set_colors(pixmap->pixmap); | |
4318 } | |
4319 if(gc) | |
4320 { | |
4321 font = gdk_font_load(fontname); | |
4322 if(font) | |
4323 { | |
4324 gint ascent; | |
4325 | |
4326 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
|
4327 gdk_draw_text(handle ? handle->window : pixmap->pixmap, font, gc, x, y + ascent + 2, text, strlen(text)); |
3 | 4328 gdk_gc_unref(gc); |
4329 gdk_font_unref(font); | |
4330 } | |
4331 } | |
4332 DW_MUTEX_UNLOCK; | |
4333 } | |
4334 | |
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
|
4335 /* 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
|
4336 * 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
|
4337 * 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
|
4338 * 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
|
4339 * 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
|
4340 * 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
|
4341 * 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
|
4342 */ |
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
|
4343 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
|
4344 { |
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
|
4345 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
|
4346 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
|
4347 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
|
4348 |
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
|
4349 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
|
4350 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
|
4351 |
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
|
4352 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
|
4353 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
|
4354 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
|
4355 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
|
4356 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
|
4357 |
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
|
4358 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
|
4359 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
|
4360 { |
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
|
4361 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
|
4362 *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
|
4363 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
|
4364 *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
|
4365 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
|
4366 } |
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
|
4367 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
|
4368 } |
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
|
4369 |
3 | 4370 /* |
4371 * Creates a pixmap with given parameters. | |
4372 * Parameters: | |
4373 * handle: Window handle the pixmap is associated with. | |
4374 * width: Width of the pixmap in pixels. | |
4375 * height: Height of the pixmap in pixels. | |
4376 * depth: Color depth of the pixmap. | |
4377 * Returns: | |
4378 * A handle to a pixmap or NULL on failure. | |
4379 */ | |
4380 HPIXMAP dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth) | |
4381 { | |
4382 int _locked_by_me = FALSE; | |
4383 HPIXMAP pixmap; | |
4384 | |
4385 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) | |
4386 return NULL; | |
4387 | |
4388 if (!depth) | |
66
664a274a46a6
Fixed color depth problem when creating a new pixmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
63
diff
changeset
|
4389 depth = -1; |
3 | 4390 |
4391 pixmap->width = width; pixmap->height = height; | |
4392 | |
4393 | |
4394 DW_MUTEX_LOCK; | |
4395 pixmap->handle = handle; | |
4396 pixmap->pixmap = gdk_pixmap_new(handle->window, width, height, depth); | |
4397 DW_MUTEX_UNLOCK; | |
4398 return pixmap; | |
4399 } | |
4400 | |
4401 /* | |
4402 * Creates a pixmap from internal resource graphic specified by id. | |
4403 * Parameters: | |
4404 * handle: Window handle the pixmap is associated with. | |
4405 * id: Resource ID associated with requested pixmap. | |
4406 * Returns: | |
4407 * A handle to a pixmap or NULL on failure. | |
4408 */ | |
4409 HPIXMAP dw_pixmap_grab(HWND handle, ULONG id) | |
4410 { | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4411 GdkBitmap *bitmap = NULL; |
3 | 4412 HPIXMAP pixmap; |
4413 int _locked_by_me = FALSE; | |
4414 | |
4415 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) | |
4416 return NULL; | |
4417 | |
4418 | |
4419 DW_MUTEX_LOCK; | |
121
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
4420 pixmap->pixmap = _find_pixmap(&bitmap, id, handle, &pixmap->width, &pixmap->height); |
3 | 4421 if(pixmap->pixmap) |
4422 { | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
4423 #if GTK_MAJOR_VERSION < 2 |
3 | 4424 GdkPixmapPrivate *pvt = (GdkPixmapPrivate *)pixmap->pixmap; |
4425 pixmap->width = pvt->width; pixmap->height = pvt->height; | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
4426 #endif |
3 | 4427 } |
4428 DW_MUTEX_UNLOCK; | |
4429 return pixmap; | |
4430 } | |
4431 | |
4432 /* Call this after drawing to the screen to make sure | |
4433 * anything you have drawn is visible. | |
4434 */ | |
4435 void dw_flush(void) | |
4436 { | |
133
85f8ba78736d
Don't call gdk_flush() in GTK 2.0. It doesn't seem to be necessary and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
132
diff
changeset
|
4437 #if GTK_MAJOR_VERSION < 2 |
3 | 4438 int _locked_by_me = FALSE; |
4439 | |
4440 DW_MUTEX_LOCK; | |
4441 gdk_flush(); | |
4442 DW_MUTEX_UNLOCK; | |
133
85f8ba78736d
Don't call gdk_flush() in GTK 2.0. It doesn't seem to be necessary and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
132
diff
changeset
|
4443 #endif |
3 | 4444 } |
4445 | |
4446 /* | |
4447 * Destroys an allocated pixmap. | |
4448 * Parameters: | |
4449 * pixmap: Handle to a pixmap returned by | |
4450 * dw_pixmap_new.. | |
4451 */ | |
4452 void dw_pixmap_destroy(HPIXMAP pixmap) | |
4453 { | |
4454 int _locked_by_me = FALSE; | |
4455 | |
4456 DW_MUTEX_LOCK; | |
4457 gdk_pixmap_unref(pixmap->pixmap); | |
4458 free(pixmap); | |
4459 DW_MUTEX_UNLOCK; | |
4460 } | |
4461 | |
4462 /* | |
4463 * Copies from one item to another. | |
4464 * Parameters: | |
4465 * dest: Destination window handle. | |
4466 * destp: Destination pixmap. (choose only one). | |
4467 * xdest: X coordinate of destination. | |
4468 * ydest: Y coordinate of destination. | |
4469 * width: Width of area to copy. | |
4470 * height: Height of area to copy. | |
4471 * src: Source window handle. | |
4472 * srcp: Source pixmap. (choose only one). | |
4473 * xsrc: X coordinate of source. | |
4474 * ysrc: Y coordinate of source. | |
4475 */ | |
4476 void dw_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc) | |
4477 { | |
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
|
4478 /* 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
|
4479 * 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
|
4480 * 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
|
4481 * 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
|
4482 */ |
3 | 4483 int _locked_by_me = FALSE; |
4484 GdkGC *gc = NULL; | |
4485 | |
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
|
4486 if((!dest && (!destp || !destp->pixmap)) || (!src && (!srcp || !srcp->pixmap))) |
3 | 4487 return; |
4488 | |
4489 DW_MUTEX_LOCK; | |
4490 if(dest) | |
4491 gc = _set_colors(dest->window); | |
4492 else if(src) | |
4493 gc = _set_colors(src->window); | |
4494 else if(destp) | |
4495 gc = gdk_gc_new(destp->pixmap); | |
4496 else if(srcp) | |
4497 gc = gdk_gc_new(srcp->pixmap); | |
122
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
4498 |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
4499 if(gc) |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
4500 { |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
4501 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
|
4502 gdk_gc_unref(gc); |
3 | 4503 } |
4504 DW_MUTEX_UNLOCK; | |
4505 } | |
4506 | |
4507 /* | |
4508 * Emits a beep. | |
4509 * Parameters: | |
4510 * freq: Frequency. | |
4511 * dur: Duration. | |
4512 */ | |
4513 void dw_beep(int freq, int dur) | |
4514 { | |
4515 int _locked_by_me = FALSE; | |
4516 | |
4517 DW_MUTEX_LOCK; | |
4518 gdk_beep(); | |
4519 DW_MUTEX_UNLOCK; | |
4520 } | |
4521 | |
4522 /* | |
4523 * Returns the handle to an unnamed mutex semaphore. | |
4524 */ | |
4525 HMTX dw_mutex_new(void) | |
4526 { | |
4527 HMTX mutex; | |
4528 | |
4529 pthread_mutex_init(&mutex, NULL); | |
4530 return mutex; | |
4531 } | |
4532 | |
4533 /* | |
4534 * Closes a semaphore created by dw_mutex_new(). | |
4535 * Parameters: | |
4536 * mutex: The handle to the mutex returned by dw_mutex_new(). | |
4537 */ | |
4538 void dw_mutex_close(HMTX mutex) | |
4539 { | |
4540 pthread_mutex_destroy(&mutex); | |
4541 } | |
4542 | |
4543 /* | |
4544 * Tries to gain access to the semaphore, if it can't it blocks. | |
4545 * Parameters: | |
4546 * mutex: The handle to the mutex returned by dw_mutex_new(). | |
4547 */ | |
4548 void dw_mutex_lock(HMTX mutex) | |
4549 { | |
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
|
4550 /* 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
|
4551 * 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
|
4552 */ |
baaf4b04d284
Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
94
diff
changeset
|
4553 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
|
4554 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
|
4555 |
3 | 4556 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
|
4557 |
baaf4b04d284
Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
94
diff
changeset
|
4558 /* 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
|
4559 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
|
4560 gdk_threads_enter(); |
3 | 4561 } |
4562 | |
4563 /* | |
4564 * Reliquishes the access to the semaphore. | |
4565 * Parameters: | |
4566 * mutex: The handle to the mutex returned by dw_mutex_new(). | |
4567 */ | |
4568 void dw_mutex_unlock(HMTX mutex) | |
4569 { | |
4570 pthread_mutex_unlock(&mutex); | |
4571 } | |
4572 | |
4573 /* | |
4574 * Returns the handle to an unnamed event semaphore. | |
4575 */ | |
4576 HEV dw_event_new(void) | |
4577 { | |
4578 HEV eve = (HEV)malloc(sizeof(struct _dw_unix_event)); | |
4579 | |
4580 if(!eve) | |
4581 return NULL; | |
4582 | |
4583 /* We need to be careful here, mutexes on Linux are | |
4584 * FAST by default but are error checking on other | |
4585 * systems such as FreeBSD and OS/2, perhaps others. | |
4586 */ | |
4587 pthread_mutex_init (&(eve->mutex), NULL); | |
4588 pthread_mutex_lock (&(eve->mutex)); | |
4589 pthread_cond_init (&(eve->event), NULL); | |
4590 | |
4591 pthread_mutex_unlock (&(eve->mutex)); | |
4592 eve->alive = 1; | |
4593 eve->posted = 0; | |
4594 | |
4595 return eve; | |
4596 } | |
4597 | |
4598 /* | |
4599 * Resets a semaphore created by dw_event_new(). | |
4600 * Parameters: | |
4601 * eve: The handle to the event returned by dw_event_new(). | |
4602 */ | |
4603 int dw_event_reset (HEV eve) | |
4604 { | |
4605 if(!eve) | |
4606 return FALSE; | |
4607 | |
4608 pthread_mutex_lock (&(eve->mutex)); | |
4609 pthread_cond_broadcast (&(eve->event)); | |
4610 pthread_cond_init (&(eve->event), NULL); | |
4611 eve->posted = 0; | |
4612 pthread_mutex_unlock (&(eve->mutex)); | |
4613 return 0; | |
4614 } | |
4615 | |
4616 /* | |
4617 * Posts a semaphore created by dw_event_new(). Causing all threads | |
4618 * waiting on this event in dw_event_wait to continue. | |
4619 * Parameters: | |
4620 * eve: The handle to the event returned by dw_event_new(). | |
4621 */ | |
4622 int dw_event_post (HEV eve) | |
4623 { | |
4624 if(!eve) | |
4625 return FALSE; | |
4626 | |
4627 pthread_mutex_lock (&(eve->mutex)); | |
4628 pthread_cond_broadcast (&(eve->event)); | |
4629 eve->posted = 1; | |
4630 pthread_mutex_unlock (&(eve->mutex)); | |
4631 return 0; | |
4632 } | |
4633 | |
4634 /* | |
4635 * Waits on a semaphore created by dw_event_new(), until the | |
4636 * event gets posted or until the timeout expires. | |
4637 * Parameters: | |
4638 * eve: The handle to the event returned by dw_event_new(). | |
4639 */ | |
4640 int dw_event_wait(HEV eve, unsigned long timeout) | |
4641 { | |
4642 int rc; | |
4643 struct timeval now; | |
4644 struct timespec timeo; | |
4645 | |
4646 if(!eve) | |
4647 return FALSE; | |
4648 | |
4649 if(eve->posted) | |
4650 return 0; | |
4651 | |
4652 pthread_mutex_lock (&(eve->mutex)); | |
4653 gettimeofday(&now, 0); | |
4654 timeo.tv_sec = now.tv_sec + (timeout / 1000); | |
4655 timeo.tv_nsec = now.tv_usec * 1000; | |
4656 rc = pthread_cond_timedwait (&(eve->event), &(eve->mutex), &timeo); | |
4657 pthread_mutex_unlock (&(eve->mutex)); | |
4658 if(!rc) | |
4659 return 1; | |
4660 if(rc == ETIMEDOUT) | |
4661 return -1; | |
4662 return 0; | |
4663 } | |
4664 | |
4665 /* | |
4666 * Closes a semaphore created by dw_event_new(). | |
4667 * Parameters: | |
4668 * eve: The handle to the event returned by dw_event_new(). | |
4669 */ | |
4670 int dw_event_close(HEV *eve) | |
4671 { | |
4672 if(!eve || !(*eve)) | |
4673 return FALSE; | |
4674 | |
4675 pthread_mutex_lock (&((*eve)->mutex)); | |
4676 pthread_cond_destroy (&((*eve)->event)); | |
4677 pthread_mutex_unlock (&((*eve)->mutex)); | |
4678 pthread_mutex_destroy (&((*eve)->mutex)); | |
4679 free(*eve); | |
4680 *eve = NULL; | |
4681 | |
4682 return TRUE; | |
4683 } | |
4684 | |
4685 /* | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4686 * Setup thread independent color sets. |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4687 */ |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4688 void _dwthreadstart(void *data) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4689 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4690 void (*threadfunc)(void *) = NULL; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4691 void **tmp = (void **)data; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4692 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4693 threadfunc = (void (*)(void *))tmp[0]; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4694 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4695 _dw_thread_add(dw_thread_id()); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4696 threadfunc(tmp[1]); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4697 _dw_thread_remove(dw_thread_id()); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4698 free(tmp); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4699 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4700 /* |
3 | 4701 * Creates a new thread with a starting point of func. |
4702 * Parameters: | |
4703 * func: Function which will be run in the new thread. | |
4704 * data: Parameter(s) passed to the function. | |
4705 * stack: Stack size of new thread (OS/2 and Windows only). | |
4706 */ | |
4707 DWTID dw_thread_new(void *func, void *data, int stack) | |
4708 { | |
4709 DWTID gtkthread; | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4710 void **tmp = malloc(sizeof(void *) * 2); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4711 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4712 tmp[0] = func; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4713 tmp[1] = data; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4714 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4715 pthread_create(>kthread, NULL, (void *)_dwthreadstart, (void *)tmp); |
3 | 4716 return gtkthread; |
4717 } | |
4718 | |
4719 /* | |
4720 * Ends execution of current thread immediately. | |
4721 */ | |
4722 void dw_thread_end(void) | |
4723 { | |
4724 pthread_exit(NULL); | |
4725 } | |
4726 | |
4727 /* | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4728 * Returns the current thread's ID. |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4729 */ |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4730 DWTID dw_thread_id(void) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4731 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4732 return (DWTID)pthread_self(); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4733 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4734 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4735 /* |
3 | 4736 * Cleanly terminates a DW session, should be signal handler safe. |
4737 * Parameters: | |
4738 * exitcode: Exit code reported to the operating system. | |
4739 */ | |
4740 void dw_exit(int exitcode) | |
4741 { | |
4742 exit(exitcode); | |
4743 } | |
4744 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4745 #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
|
4746 |
3 | 4747 /* |
4748 * Pack windows (widgets) into a box from the end (or bottom). | |
4749 * Parameters: | |
4750 * box: Window handle of the box to be packed into. | |
4751 * item: Window handle of the item to be back. | |
4752 * width: Width in pixels of the item or -1 to be self determined. | |
4753 * height: Height in pixels of the item or -1 to be self determined. | |
4754 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. | |
4755 * vsize: TRUE if the window (widget) should expand vertically to fill space given. | |
4756 * pad: Number of pixels of padding around the item. | |
4757 */ | |
4758 void dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) | |
4759 { | |
4760 int _locked_by_me = FALSE; | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4761 GtkWidget *tmp; |
3 | 4762 |
4763 if(!box) | |
4764 return; | |
4765 | |
4766 DW_MUTEX_LOCK; | |
4767 | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4768 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
|
4769 box = tmp; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4770 |
3 | 4771 if(!item) |
4772 { | |
4773 item = gtk_label_new(""); | |
4774 gtk_widget_show(item); | |
4775 } | |
4776 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4777 if(GTK_IS_TABLE(box)) |
3 | 4778 { |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4779 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
|
4780 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
|
4781 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4782 /* 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
|
4783 * 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
|
4784 * 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
|
4785 * 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
|
4786 */ |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4787 if(GTK_IS_TABLE(item)) |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4788 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4789 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
|
4790 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4791 if(eventbox) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4792 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4793 gtk_container_add(GTK_CONTAINER(eventbox), item); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4794 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
|
4795 item = eventbox; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4796 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4797 } |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4798 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4799 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
|
4800 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
|
4801 else |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4802 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
|
4803 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
4804 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
|
4805 gtk_object_set_data(GTK_OBJECT(box), "boxcount", (gpointer)boxcount + 1); |
3 | 4806 gtk_widget_set_usize(item, width, height); |
4807 if(GTK_IS_RADIO_BUTTON(item)) | |
4808 { | |
4809 GSList *group; | |
4810 GtkWidget *groupstart = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(box), "group"); | |
4811 | |
4812 if(groupstart) | |
4813 { | |
4814 group = gtk_radio_button_group(GTK_RADIO_BUTTON(groupstart)); | |
4815 gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group); | |
4816 } | |
4817 else | |
4818 gtk_object_set_data(GTK_OBJECT(box), "group", (gpointer)item); | |
4819 } | |
4820 } | |
4821 else | |
4822 { | |
4823 GtkWidget *vbox = gtk_vbox_new(FALSE, 0); | |
4824 | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4825 if(GTK_IS_TABLE(item)) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4826 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4827 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
|
4828 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4829 if(eventbox) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4830 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4831 gtk_container_add(GTK_CONTAINER(eventbox), item); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4832 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
|
4833 item = eventbox; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4834 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4835 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4836 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
4837 gtk_container_border_width(GTK_CONTAINER(box), pad); |
3 | 4838 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
|
4839 gtk_box_pack_end(GTK_BOX(vbox), item, TRUE, TRUE, 0); |
3 | 4840 gtk_widget_show(vbox); |
4841 | |
4842 gtk_widget_set_usize(item, width, height); | |
4843 gtk_object_set_user_data(GTK_OBJECT(box), vbox); | |
4844 } | |
4845 DW_MUTEX_UNLOCK; | |
4846 } | |
4847 | |
4848 /* | |
4849 * Sets the size of a given window (widget). | |
4850 * Parameters: | |
4851 * handle: Window (widget) handle. | |
4852 * width: New width in pixels. | |
4853 * height: New height in pixels. | |
4854 */ | |
4855 void dw_window_set_usize(HWND handle, unsigned long width, unsigned long height) | |
4856 { | |
4857 int _locked_by_me = FALSE; | |
4858 | |
4859 DW_MUTEX_LOCK; | |
4860 if(GTK_IS_WINDOW(handle)) | |
4861 _size_allocate(GTK_WINDOW(handle)); | |
4862 #if 0 | |
4863 gtk_window_set_default_size(GTK_WINDOW(handle), width, height); | |
4864 else | |
4865 #endif | |
4866 gtk_widget_set_usize(handle, width, height); | |
4867 DW_MUTEX_UNLOCK; | |
4868 } | |
4869 | |
4870 /* | |
4871 * Returns the width of the screen. | |
4872 */ | |
4873 int dw_screen_width(void) | |
4874 { | |
4875 int retval; | |
4876 int _locked_by_me = FALSE; | |
4877 | |
4878 DW_MUTEX_LOCK; | |
4879 retval = gdk_screen_width(); | |
4880 DW_MUTEX_UNLOCK; | |
4881 return retval; | |
4882 } | |
4883 | |
4884 /* | |
4885 * Returns the height of the screen. | |
4886 */ | |
4887 int dw_screen_height(void) | |
4888 { | |
4889 int retval; | |
4890 int _locked_by_me = FALSE; | |
4891 | |
4892 DW_MUTEX_UNLOCK; | |
4893 retval = gdk_screen_height(); | |
4894 DW_MUTEX_UNLOCK; | |
4895 return retval; | |
4896 } | |
4897 | |
4898 /* This should return the current color depth */ | |
4899 unsigned long dw_color_depth(void) | |
4900 { | |
4901 int retval; | |
4902 int _locked_by_me = FALSE; | |
4903 | |
4904 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
|
4905 retval = gdk_visual_get_best_depth(); |
3 | 4906 DW_MUTEX_UNLOCK; |
4907 return retval; | |
4908 } | |
4909 | |
4910 /* | |
4911 * Sets the position of a given window (widget). | |
4912 * Parameters: | |
4913 * handle: Window (widget) handle. | |
4914 * x: X location from the bottom left. | |
4915 * y: Y location from the bottom left. | |
4916 */ | |
4917 void dw_window_set_pos(HWND handle, unsigned long x, unsigned long y) | |
4918 { | |
4919 int _locked_by_me = FALSE; | |
4920 | |
4921 DW_MUTEX_LOCK; | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
4922 if(handle && handle->window) |
3 | 4923 gdk_window_move(handle->window, x, y); |
4924 DW_MUTEX_UNLOCK; | |
4925 } | |
4926 | |
4927 /* | |
4928 * Sets the position and size of a given window (widget). | |
4929 * Parameters: | |
4930 * handle: Window (widget) handle. | |
4931 * x: X location from the bottom left. | |
4932 * y: Y location from the bottom left. | |
4933 * width: Width of the widget. | |
4934 * height: Height of the widget. | |
4935 */ | |
4936 void dw_window_set_pos_size(HWND handle, unsigned long x, unsigned long y, unsigned long width, unsigned long height) | |
4937 { | |
4938 int _locked_by_me = FALSE; | |
4939 | |
4940 DW_MUTEX_LOCK; | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
4941 if(handle && GTK_IS_WINDOW(handle)) |
3 | 4942 { |
4943 _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
|
4944 |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
4945 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
|
4946 gtk_window_set_default_size(GTK_WINDOW(handle), width - _dw_border_width, height - _dw_border_height); |
3 | 4947 } |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
4948 else if(handle && handle->window) |
3 | 4949 { |
4950 gdk_window_resize(handle->window, width, height); | |
4951 gdk_window_move(handle->window, x, y); | |
4952 } | |
4953 DW_MUTEX_UNLOCK; | |
4954 } | |
4955 | |
4956 /* | |
4957 * Gets the position and size of a given window (widget). | |
4958 * Parameters: | |
4959 * handle: Window (widget) handle. | |
4960 * x: X location from the bottom left. | |
4961 * y: Y location from the bottom left. | |
4962 * width: Width of the widget. | |
4963 * height: Height of the widget. | |
4964 */ | |
4965 void dw_window_get_pos_size(HWND handle, ULONG *x, ULONG *y, ULONG *width, ULONG *height) | |
4966 { | |
4967 int _locked_by_me = FALSE; | |
4968 gint gx, gy, gwidth, gheight, gdepth; | |
4969 | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
4970 if(handle && handle->window) |
3 | 4971 { |
4972 DW_MUTEX_LOCK; | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
4973 |
3 | 4974 gdk_window_get_geometry(handle->window, &gx, &gy, &gwidth, &gheight, &gdepth); |
4975 gdk_window_get_root_origin(handle->window, &gx, &gy); | |
4976 if(x) | |
4977 *x = gx; | |
4978 if(y) | |
4979 *y = gy; | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4980 if(GTK_IS_WINDOW(handle)) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4981 { |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4982 if(width) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4983 *width = gwidth + _dw_border_width; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4984 if(height) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4985 *height = gheight + _dw_border_height; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4986 } |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4987 else |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4988 { |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4989 if(width) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4990 *width = gwidth; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4991 if(height) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4992 *height = gheight; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
4993 } |
3 | 4994 DW_MUTEX_UNLOCK; |
4995 } | |
4996 } | |
4997 | |
4998 /* | |
4999 * Sets the style of a given window (widget). | |
5000 * Parameters: | |
5001 * handle: Window (widget) handle. | |
5002 * width: New width in pixels. | |
5003 * height: New height in pixels. | |
5004 */ | |
5005 void dw_window_set_style(HWND handle, unsigned long style, unsigned long mask) | |
5006 { | |
5007 GtkWidget *handle2 = handle; | |
5008 int _locked_by_me = FALSE; | |
5009 | |
5010 DW_MUTEX_LOCK; | |
5011 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
5012 { | |
5013 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
5014 if(tmp) | |
5015 handle2 = tmp; | |
5016 } | |
5017 if(GTK_IS_CLIST(handle2)) | |
5018 { | |
5019 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
|
5020 { |
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
|
5021 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
|
5022 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
|
5023 } |
3 | 5024 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
|
5025 { |
3 | 5026 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
|
5027 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
|
5028 } |
3 | 5029 } |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5030 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
|
5031 { |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
5032 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
|
5033 { |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
5034 gfloat x, y; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
5035 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
5036 x = y = DW_LEFT; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
5037 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
5038 if(style & DW_DT_CENTER) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
5039 x = DW_CENTER; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
5040 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
5041 if(style & DW_DT_VCENTER) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
5042 y = DW_CENTER; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
5043 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
5044 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
|
5045 } |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
5046 if(style & DW_DT_WORDBREAK) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
5047 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
|
5048 } |
3 | 5049 DW_MUTEX_UNLOCK; |
5050 } | |
5051 | |
5052 /* | |
5053 * Adds a new page to specified notebook. | |
5054 * Parameters: | |
5055 * handle: Window (widget) handle. | |
5056 * flags: Any additional page creation flags. | |
5057 * front: If TRUE page is added at the beginning. | |
5058 */ | |
5059 unsigned long dw_notebook_page_new(HWND handle, unsigned long flags, int front) | |
5060 { | |
5061 int z; | |
5062 int _locked_by_me = FALSE; | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5063 GtkWidget **pagearray; |
3 | 5064 |
5065 DW_MUTEX_LOCK; | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5066 pagearray = (GtkWidget **)gtk_object_get_data(GTK_OBJECT(handle), "pagearray"); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5067 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5068 if(pagearray) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5069 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5070 for(z=0;z<256;z++) |
3 | 5071 { |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5072 if(!pagearray[z]) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5073 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5074 char text[100]; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5075 int num = z; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5076 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5077 if(front) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5078 num |= 1 << 16; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5079 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5080 sprintf(text, "page%d", z); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5081 /* Save the real id and the creation flags */ |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5082 gtk_object_set_data(GTK_OBJECT(handle), text, (gpointer)num); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5083 DW_MUTEX_UNLOCK; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5084 return z; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5085 } |
3 | 5086 } |
15
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
5087 } |
3 | 5088 DW_MUTEX_UNLOCK; |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5089 |
3 | 5090 /* Hopefully this won't happen. */ |
5091 return 256; | |
5092 } | |
5093 | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5094 /* Return the physical page id from the logical page id */ |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5095 int _get_physical_page(HWND handle, unsigned long pageid) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5096 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5097 int z; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5098 GtkWidget *thispage, **pagearray = gtk_object_get_data(GTK_OBJECT(handle), "pagearray"); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5099 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5100 if(pagearray) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5101 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5102 for(z=0;z<256;z++) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5103 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5104 if((thispage = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), z))) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5105 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5106 if(thispage == pagearray[pageid]) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5107 return z; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5108 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5109 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5110 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5111 return 256; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5112 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5113 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5114 /* Return the logical page id from the physical page id */ |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5115 int _get_logical_page(HWND handle, unsigned long pageid) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5116 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5117 int z; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5118 GtkWidget **pagearray = gtk_object_get_data(GTK_OBJECT(handle), "pagearray"); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5119 GtkWidget *thispage = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), pageid); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5120 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5121 if(pagearray && thispage) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5122 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5123 for(z=0;z<256;z++) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5124 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5125 if(thispage == pagearray[z]) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5126 return z; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5127 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5128 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5129 return 256; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5130 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5131 |
3 | 5132 /* |
5133 * Remove a page from a notebook. | |
5134 * Parameters: | |
5135 * handle: Handle to the notebook widget. | |
5136 * pageid: ID of the page to be destroyed. | |
5137 */ | |
5138 void dw_notebook_page_destroy(HWND handle, unsigned int pageid) | |
5139 { | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5140 int realpage, _locked_by_me = FALSE; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5141 GtkWidget **pagearray; |
3 | 5142 |
5143 DW_MUTEX_LOCK; | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5144 realpage = _get_physical_page(handle, pageid); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5145 if(realpage > -1 && realpage < 256) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5146 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5147 gtk_notebook_remove_page(GTK_NOTEBOOK(handle), realpage); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5148 if((pagearray = gtk_object_get_data(GTK_OBJECT(handle), "pagearray"))) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5149 pagearray[pageid] = NULL; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5150 } |
3 | 5151 DW_MUTEX_UNLOCK; |
5152 } | |
5153 | |
5154 /* | |
5155 * Queries the currently visible page ID. | |
5156 * Parameters: | |
5157 * handle: Handle to the notebook widget. | |
5158 */ | |
5159 unsigned int dw_notebook_page_query(HWND handle) | |
5160 { | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5161 int retval, phys; |
3 | 5162 int _locked_by_me = FALSE; |
5163 | |
5164 DW_MUTEX_LOCK; | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5165 phys = gtk_notebook_get_current_page(GTK_NOTEBOOK(handle)); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5166 retval = _get_logical_page(handle, phys); |
3 | 5167 DW_MUTEX_UNLOCK; |
5168 return retval; | |
5169 } | |
5170 | |
5171 /* | |
5172 * Sets the currently visibale page ID. | |
5173 * Parameters: | |
5174 * handle: Handle to the notebook widget. | |
5175 * pageid: ID of the page to be made visible. | |
5176 */ | |
5177 void dw_notebook_page_set(HWND handle, unsigned int pageid) | |
5178 { | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5179 int realpage, _locked_by_me = FALSE; |
3 | 5180 |
5181 DW_MUTEX_LOCK; | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5182 realpage = _get_physical_page(handle, pageid); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5183 if(realpage > -1 && realpage < 256) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5184 gtk_notebook_set_page(GTK_NOTEBOOK(handle), pageid); |
3 | 5185 DW_MUTEX_UNLOCK; |
5186 } | |
5187 | |
5188 | |
5189 /* | |
5190 * Sets the text on the specified notebook tab. | |
5191 * Parameters: | |
5192 * handle: Notebook handle. | |
5193 * pageid: Page ID of the tab to set. | |
5194 * text: Pointer to the text to set. | |
5195 */ | |
5196 void dw_notebook_page_set_text(HWND handle, unsigned long pageid, char *text) | |
5197 { | |
5198 GtkWidget *child; | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5199 int realpage, _locked_by_me = FALSE; |
3 | 5200 |
5201 DW_MUTEX_LOCK; | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5202 realpage = _get_physical_page(handle, pageid); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5203 if(realpage < 0 || realpage > 255) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5204 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5205 char ptext[100]; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5206 int num; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5207 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5208 sprintf(ptext, "page%d", (int)pageid); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5209 num = (int)gtk_object_get_data(GTK_OBJECT(handle), ptext); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5210 realpage = 0xFF & num; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5211 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5212 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5213 if(realpage > -1 && realpage < 256) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5214 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5215 child = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), realpage); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5216 if(child) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5217 gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(handle), child, text); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5218 } |
3 | 5219 DW_MUTEX_UNLOCK; |
5220 } | |
5221 | |
5222 /* | |
5223 * Sets the text on the specified notebook tab status area. | |
5224 * Parameters: | |
5225 * handle: Notebook handle. | |
5226 * pageid: Page ID of the tab to set. | |
5227 * text: Pointer to the text to set. | |
5228 */ | |
5229 void dw_notebook_page_set_status_text(HWND handle, unsigned long pageid, char *text) | |
5230 { | |
5231 /* TODO (if possible) */ | |
5232 } | |
5233 | |
5234 /* | |
5235 * Packs the specified box into the notebook page. | |
5236 * Parameters: | |
5237 * handle: Handle to the notebook to be packed. | |
5238 * pageid: Page ID in the notebook which is being packed. | |
5239 * page: Box handle to be packed. | |
5240 */ | |
5241 void dw_notebook_pack(HWND handle, unsigned long pageid, HWND page) | |
5242 { | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5243 GtkWidget *label, *child, *oldlabel, **pagearray; |
15
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
5244 gchar *text = NULL; |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5245 int num, z, realpage = -1, pad, _locked_by_me = FALSE; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5246 char ptext[100]; |
3 | 5247 |
5248 DW_MUTEX_LOCK; | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5249 sprintf(ptext, "page%d", (int)pageid); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5250 num = (int)gtk_object_get_data(GTK_OBJECT(handle), ptext); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5251 gtk_object_set_data(GTK_OBJECT(handle), ptext, NULL); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5252 pagearray = (GtkWidget **)gtk_object_get_data(GTK_OBJECT(handle), "pagearray"); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5253 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5254 if(!pagearray) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5255 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5256 DW_MUTEX_UNLOCK; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5257 return; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5258 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5259 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5260 /* The page already exists... so get it's current page */ |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5261 if(pagearray[pageid]) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5262 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5263 for(z=0;z<256;z++) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5264 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5265 child = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), z); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5266 if(child == pagearray[pageid]) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5267 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5268 oldlabel = gtk_notebook_get_tab_label(GTK_NOTEBOOK(handle), child); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5269 if(oldlabel) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5270 gtk_label_get(GTK_LABEL(oldlabel), &text); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5271 gtk_notebook_remove_page(GTK_NOTEBOOK(handle), z); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5272 realpage = z; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5273 break; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5274 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5275 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5276 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5277 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5278 pagearray[pageid] = page; |
15
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
5279 |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
5280 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
|
5281 |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5282 if(GTK_IS_TABLE(page)) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5283 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5284 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
|
5285 gtk_container_border_width(GTK_CONTAINER(page), pad); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5286 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5287 |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5288 if(realpage != -1) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5289 gtk_notebook_insert_page(GTK_NOTEBOOK(handle), page, label, realpage); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5290 else if(num & ~(0xFF)) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5291 gtk_notebook_insert_page(GTK_NOTEBOOK(handle), page, label, 0); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5292 else |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5293 gtk_notebook_insert_page(GTK_NOTEBOOK(handle), page, label, 256); |
3 | 5294 DW_MUTEX_UNLOCK; |
5295 } | |
5296 | |
5297 /* | |
5298 * Appends the specified text to the listbox's (or combobox) entry list. | |
5299 * Parameters: | |
5300 * handle: Handle to the listbox to be appended to. | |
5301 * text: Text to append into listbox. | |
5302 */ | |
5303 void dw_listbox_append(HWND handle, char *text) | |
5304 { | |
5305 GtkWidget *handle2 = handle; | |
5306 int _locked_by_me = FALSE; | |
5307 | |
5308 DW_MUTEX_LOCK; | |
5309 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
5310 { | |
5311 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
5312 if(tmp) | |
5313 handle2 = tmp; | |
5314 } | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5315 gtk_object_set_data(GTK_OBJECT(handle), "appending", (gpointer)1); |
3 | 5316 if(GTK_IS_LIST(handle2)) |
5317 { | |
5318 GtkWidget *list_item; | |
5319 GList *tmp; | |
5320 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
|
5321 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
|
5322 GdkColor *back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle2), "backgdk"); |
3 | 5323 |
5324 list_item=gtk_list_item_new_with_label(text); | |
5325 | |
5326 if(font) | |
5327 _set_font(GTK_LIST_ITEM(list_item)->item.bin.child, font); | |
5328 if(fore && back) | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
5329 _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
|
5330 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
|
5331 DW_RGB(back->red, back->green, back->blue)); |
3 | 5332 |
5333 tmp = g_list_append(NULL, list_item); | |
5334 gtk_widget_show(list_item); | |
5335 gtk_list_append_items(GTK_LIST(handle2),tmp); | |
5336 } | |
5337 else if(GTK_IS_COMBO(handle2)) | |
5338 { | |
5339 GList *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2)); | |
5340 char *addtext = strdup(text); | |
5341 | |
5342 if(addtext) | |
5343 { | |
5344 tmp = g_list_append(tmp, addtext); | |
5345 gtk_object_set_user_data(GTK_OBJECT(handle2), tmp); | |
5346 gtk_combo_set_popdown_strings(GTK_COMBO(handle2), tmp); | |
5347 } | |
5348 } | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
5349 gtk_object_set_data(GTK_OBJECT(handle), "appending", NULL); |
3 | 5350 DW_MUTEX_UNLOCK; |
5351 } | |
5352 | |
5353 /* | |
5354 * Clears the listbox's (or combobox) list of all entries. | |
5355 * Parameters: | |
5356 * handle: Handle to the listbox to be cleared. | |
5357 */ | |
5358 void dw_listbox_clear(HWND handle) | |
5359 { | |
5360 GtkWidget *handle2 = handle; | |
5361 int _locked_by_me = FALSE; | |
5362 | |
5363 DW_MUTEX_LOCK; | |
5364 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
5365 { | |
5366 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
5367 if(tmp) | |
5368 handle2 = tmp; | |
5369 } | |
5370 if(GTK_IS_COMBO(handle2)) | |
5371 { | |
5372 GList *list, *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2)); | |
5373 | |
5374 if(tmp) | |
5375 { | |
5376 list = tmp; | |
5377 while(list) | |
5378 { | |
5379 if(list->data) | |
5380 free(list->data); | |
5381 list=list->next; | |
5382 } | |
5383 g_list_free(tmp); | |
5384 } | |
5385 gtk_object_set_user_data(GTK_OBJECT(handle2), NULL); | |
5386 } | |
5387 else if(GTK_IS_LIST(handle2)) | |
5388 { | |
5389 int count = dw_listbox_count(handle); | |
5390 | |
5391 gtk_list_clear_items(GTK_LIST(handle2), 0, count - 1); | |
5392 } | |
5393 DW_MUTEX_UNLOCK; | |
5394 } | |
5395 | |
5396 /* | |
5397 * Returns the listbox's item count. | |
5398 * Parameters: | |
5399 * handle: Handle to the listbox to be counted | |
5400 */ | |
5401 int dw_listbox_count(HWND handle) | |
5402 { | |
5403 GtkWidget *handle2 = handle; | |
5404 int retval = 0; | |
5405 int _locked_by_me = FALSE; | |
5406 | |
5407 DW_MUTEX_LOCK; | |
5408 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
5409 { | |
5410 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
5411 if(tmp) | |
5412 handle2 = tmp; | |
5413 } | |
5414 else if(GTK_IS_COMBO(handle)) | |
5415 { | |
5416 handle2 = GTK_COMBO(handle)->list; | |
5417 } | |
5418 if(GTK_IS_LIST(handle2)) | |
5419 { | |
5420 GList *list = GTK_LIST(handle2)->children; | |
5421 while(list) | |
5422 { | |
5423 list = list->next; | |
5424 retval++; | |
5425 } | |
5426 } | |
5427 DW_MUTEX_UNLOCK; | |
5428 return retval; | |
5429 } | |
5430 | |
5431 /* | |
5432 * Sets the topmost item in the viewport. | |
5433 * Parameters: | |
5434 * handle: Handle to the listbox to be cleared. | |
5435 * top: Index to the top item. | |
5436 */ | |
5437 void dw_listbox_set_top(HWND handle, int top) | |
5438 { | |
5439 GtkWidget *handle2 = handle; | |
5440 int _locked_by_me = FALSE; | |
5441 | |
5442 DW_MUTEX_LOCK; | |
5443 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
5444 { | |
5445 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
5446 if(tmp) | |
5447 handle2 = tmp; | |
5448 } | |
5449 if(GTK_IS_LIST(handle2)) | |
5450 { | |
5451 int count = dw_listbox_count(handle); | |
5452 GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(handle)); | |
5453 float pos, ratio; | |
5454 | |
5455 if(count) | |
5456 { | |
5457 ratio = (float)top/(float)count; | |
5458 | |
5459 pos = (ratio * (float)(adj->upper - adj->lower)) + adj->lower; | |
5460 | |
5461 gtk_adjustment_set_value(adj, pos); | |
5462 } | |
5463 } | |
5464 DW_MUTEX_UNLOCK; | |
5465 } | |
5466 | |
5467 /* | |
5468 * Copies the given index item's text into buffer. | |
5469 * Parameters: | |
5470 * handle: Handle to the listbox to be queried. | |
5471 * index: Index into the list to be queried. | |
5472 * buffer: Buffer where text will be copied. | |
5473 * length: Length of the buffer (including NULL). | |
5474 */ | |
5475 void dw_listbox_query_text(HWND handle, unsigned int index, char *buffer, unsigned int length) | |
5476 { | |
5477 GtkWidget *handle2 = handle; | |
5478 int _locked_by_me = FALSE; | |
5479 | |
5480 DW_MUTEX_LOCK; | |
5481 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
5482 { | |
5483 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
5484 if(tmp) | |
5485 handle2 = tmp; | |
5486 } | |
5487 else if(GTK_IS_COMBO(handle)) | |
5488 { | |
5489 handle2 = GTK_COMBO(handle)->list; | |
5490 } | |
5491 if(GTK_IS_LIST(handle2)) | |
5492 { | |
5493 int counter = 0; | |
5494 GList *list = GTK_LIST(handle2)->children; | |
5495 | |
5496 while(list) | |
5497 { | |
5498 if(counter == index) | |
5499 { | |
5500 gchar *text = ""; | |
5501 | |
5502 if(GTK_IS_LIST_ITEM(list->data)) | |
5503 { | |
5504 GtkListItem *li = GTK_LIST_ITEM(list->data); | |
5505 | |
5506 if(GTK_IS_ITEM(&(li->item))) | |
5507 { | |
5508 GtkItem *i = &(li->item); | |
5509 | |
5510 if(GTK_IS_BIN(&(i->bin))) | |
5511 { | |
5512 GtkBin *b = &(i->bin); | |
5513 | |
5514 if(GTK_IS_LABEL(b->child)) | |
5515 gtk_label_get(GTK_LABEL(b->child), &text); | |
5516 } | |
5517 } | |
5518 } | |
5519 else if(GTK_IS_COMBO(handle) && list->data) | |
5520 text = (gchar *)list->data; | |
5521 | |
5522 strncpy(buffer, (char *)text, length); | |
5523 break; | |
5524 } | |
5525 list = list->next; | |
5526 counter++; | |
5527 } | |
5528 } | |
5529 DW_MUTEX_UNLOCK; | |
5530 } | |
5531 | |
5532 /* | |
5533 * Sets the text of a given listbox entry. | |
5534 * Parameters: | |
5535 * handle: Handle to the listbox to be queried. | |
5536 * index: Index into the list to be queried. | |
5537 * buffer: Buffer where text will be copied. | |
5538 */ | |
5539 void dw_listbox_set_text(HWND handle, unsigned int index, char *buffer) | |
5540 { | |
5541 GtkWidget *handle2 = handle; | |
5542 int _locked_by_me = FALSE; | |
5543 | |
5544 DW_MUTEX_LOCK; | |
5545 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
5546 { | |
5547 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
5548 if(tmp) | |
5549 handle2 = tmp; | |
5550 } | |
5551 else if(GTK_IS_COMBO(handle)) | |
5552 { | |
5553 handle2 = GTK_COMBO(handle)->list; | |
5554 } | |
5555 if(GTK_IS_LIST(handle2)) | |
5556 { | |
5557 int counter = 0; | |
5558 GList *list = GTK_LIST(handle2)->children; | |
5559 | |
5560 while(list) | |
5561 { | |
5562 if(counter == index) | |
5563 { | |
5564 | |
5565 if(GTK_IS_LIST_ITEM(list->data)) | |
5566 { | |
5567 GtkListItem *li = GTK_LIST_ITEM(list->data); | |
5568 | |
5569 if(GTK_IS_ITEM(&(li->item))) | |
5570 { | |
5571 GtkItem *i = &(li->item); | |
5572 | |
5573 if(GTK_IS_BIN(&(i->bin))) | |
5574 { | |
5575 GtkBin *b = &(i->bin); | |
5576 | |
5577 if(GTK_IS_LABEL(b->child)) | |
5578 gtk_label_set_text(GTK_LABEL(b->child), buffer); | |
5579 } | |
5580 } | |
5581 } | |
5582 else if(GTK_IS_COMBO(handle)) | |
5583 { | |
5584 if(list->data) | |
5585 g_free(list->data); | |
5586 list->data = g_strdup(buffer); | |
5587 } | |
5588 break; | |
5589 } | |
5590 list = list->next; | |
5591 counter++; | |
5592 } | |
5593 } | |
5594 DW_MUTEX_UNLOCK; | |
5595 } | |
5596 | |
5597 /* | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5598 * 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
|
5599 * Parameters: |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5600 * 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
|
5601 * 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
|
5602 */ |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5603 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
|
5604 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5605 GtkWidget *handle2 = handle; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5606 int retval = DW_LIT_NONE; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5607 int _locked_by_me = FALSE; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5608 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5609 DW_MUTEX_LOCK; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5610 if(GTK_IS_SCROLLED_WINDOW(handle)) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5611 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5612 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
|
5613 if(tmp) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5614 handle2 = tmp; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5615 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5616 if(GTK_IS_LIST(handle2)) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5617 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5618 int counter = 0; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5619 GList *list = GTK_LIST(handle2)->selection; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5620 while(list) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5621 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5622 if(counter > where) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5623 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5624 retval = counter; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5625 break; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5626 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5627 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5628 list = list->next; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5629 counter++; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5630 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5631 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5632 DW_MUTEX_UNLOCK; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5633 return retval; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5634 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5635 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5636 /* |
3 | 5637 * Returns the index to the item in the list currently selected. |
5638 * Parameters: | |
5639 * handle: Handle to the listbox to be queried. | |
5640 */ | |
5641 unsigned int dw_listbox_selected(HWND handle) | |
5642 { | |
5643 GtkWidget *handle2 = handle; | |
5644 int retval = DW_LIT_NONE; | |
5645 int _locked_by_me = FALSE; | |
5646 | |
5647 DW_MUTEX_LOCK; | |
5648 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
5649 { | |
5650 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
5651 if(tmp) | |
5652 handle2 = tmp; | |
5653 } | |
5654 else if(GTK_IS_COMBO(handle)) | |
5655 { | |
5656 retval = (unsigned int)gtk_object_get_data(GTK_OBJECT(handle), "item"); | |
5657 DW_MUTEX_UNLOCK; | |
5658 return retval; | |
5659 } | |
5660 if(GTK_IS_LIST(handle2)) | |
5661 { | |
5662 int counter = 0; | |
5663 GList *list = GTK_LIST(handle2)->children; | |
5664 while(list) | |
5665 { | |
19
3e5bff3e55ff
Fixed a problem in dw_listbox_selected().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
17
diff
changeset
|
5666 if(list->data == GTK_LIST(handle2)->selection->data) |
3 | 5667 { |
5668 retval = counter; | |
5669 break; | |
5670 } | |
5671 | |
5672 list = list->next; | |
5673 counter++; | |
5674 } | |
5675 } | |
5676 DW_MUTEX_UNLOCK; | |
5677 return retval; | |
5678 } | |
5679 | |
5680 /* | |
5681 * Sets the selection state of a given index. | |
5682 * Parameters: | |
5683 * handle: Handle to the listbox to be set. | |
5684 * index: Item index. | |
5685 * state: TRUE if selected FALSE if unselected. | |
5686 */ | |
5687 void dw_listbox_select(HWND handle, int index, int state) | |
5688 { | |
5689 GtkWidget *handle2 = handle; | |
5690 int _locked_by_me = FALSE; | |
5691 | |
5692 DW_MUTEX_LOCK; | |
5693 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
5694 { | |
5695 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
5696 if(tmp) | |
5697 handle2 = tmp; | |
5698 } | |
5699 else if(GTK_IS_COMBO(handle)) | |
5700 { | |
5701 handle2 = GTK_COMBO(handle)->list; | |
5702 } | |
5703 if(GTK_IS_LIST(handle2)) | |
5704 { | |
5705 if(state) | |
5706 gtk_list_select_item(GTK_LIST(handle2), index); | |
5707 else | |
5708 gtk_list_unselect_item(GTK_LIST(handle2), index); | |
5709 } | |
5710 DW_MUTEX_UNLOCK; | |
5711 } | |
5712 | |
5713 /* | |
5714 * Deletes the item with given index from the list. | |
5715 * Parameters: | |
5716 * handle: Handle to the listbox to be set. | |
5717 * index: Item index. | |
5718 */ | |
5719 void dw_listbox_delete(HWND handle, int index) | |
5720 { | |
5721 GtkWidget *handle2 = handle; | |
5722 int _locked_by_me = FALSE; | |
5723 | |
5724 DW_MUTEX_LOCK; | |
5725 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
5726 { | |
5727 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
5728 if(tmp) | |
5729 handle2 = tmp; | |
5730 } | |
5731 else if(GTK_IS_COMBO(handle)) | |
5732 { | |
5733 handle2 = GTK_COMBO(handle)->list; | |
5734 } | |
5735 if(GTK_IS_LIST(handle2)) | |
5736 gtk_list_clear_items(GTK_LIST(handle2), index, index); | |
5737 DW_MUTEX_UNLOCK; | |
5738 } | |
5739 | |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5740 /* Reposition the bar according to the percentage */ |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5741 gint _splitbar_size_allocate(GtkWidget *widget, GtkAllocation *event, gpointer data) |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5742 { |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5743 float *percent = (float *)gtk_object_get_data(GTK_OBJECT(widget), "_dw_percent"); |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5744 int lastwidth = (int)gtk_object_get_data(GTK_OBJECT(widget), "_dw_lastwidth"); |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5745 int lastheight = (int)gtk_object_get_data(GTK_OBJECT(widget), "_dw_lastheight"); |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5746 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5747 /* Prevent infinite recursion ;) */ |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5748 if(!percent || (lastwidth == event->width && lastheight == event->height)) |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
5749 return FALSE; |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5750 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5751 lastwidth = event->width; lastheight = event->height; |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5752 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5753 gtk_object_set_data(GTK_OBJECT(widget), "_dw_lastwidth", (gpointer)lastwidth); |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5754 gtk_object_set_data(GTK_OBJECT(widget), "_dw_lastheight", (gpointer)lastheight); |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5755 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5756 if(GTK_IS_HPANED(widget)) |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5757 gtk_paned_set_position(GTK_PANED(widget), (int)(event->width * (*percent / 100.0))); |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5758 if(GTK_IS_VPANED(widget)) |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5759 gtk_paned_set_position(GTK_PANED(widget), (int)(event->height * (*percent / 100.0))); |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
5760 return FALSE; |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5761 } |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5762 |
122
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
5763 #if GTK_MAJOR_VERSION > 1 |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5764 /* Figure out the new percentage */ |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5765 gint _splitbar_accept_position(GtkWidget *widget, gpointer data) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5766 { |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5767 float *percent = (float *)gtk_object_get_data(GTK_OBJECT(widget), "_dw_percent"); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5768 int size = 0, position = gtk_paned_get_position(GTK_PANED(widget)); |
122
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
5769 |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5770 if(!percent) |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
5771 return FALSE; |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5772 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5773 if(GTK_IS_VPANED(widget)) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5774 size = widget->allocation.height; |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5775 else if(GTK_IS_HPANED(widget)) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5776 size = widget->allocation.width; |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5777 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5778 if(size > 0) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5779 *percent = ((float)(position * 100) / (float)size); |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
5780 return FALSE; |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5781 } |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5782 #endif |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5783 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5784 /* |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5785 * Creates a splitbar window (widget) with given parameters. |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5786 * Parameters: |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5787 * type: Value can be BOXVERT or BOXHORZ. |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5788 * topleft: Handle to the window to be top or left. |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5789 * bottomright: Handle to the window to be bottom or right. |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5790 * Returns: |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5791 * A handle to a splitbar window or NULL on failure. |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5792 */ |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5793 HWND dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long id) |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5794 { |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5795 GtkWidget *tmp = NULL; |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5796 int _locked_by_me = FALSE; |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5797 float *percent = malloc(sizeof(float)); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5798 |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5799 DW_MUTEX_LOCK; |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5800 if(type == BOXHORZ) |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5801 tmp = gtk_hpaned_new(); |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5802 else |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5803 tmp = gtk_vpaned_new(); |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5804 gtk_paned_add1(GTK_PANED(tmp), topleft); |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5805 gtk_paned_add2(GTK_PANED(tmp), bottomright); |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5806 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5807 *percent = 50.0; |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5808 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_percent", (gpointer)percent); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5809 gtk_signal_connect(GTK_OBJECT(tmp), "size-allocate", GTK_SIGNAL_FUNC(_splitbar_size_allocate), NULL); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5810 #if GTK_MAJOR_VERSION > 1 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5811 gtk_signal_connect(GTK_OBJECT(tmp), "accept-position", GTK_SIGNAL_FUNC(_splitbar_accept_position), NULL); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5812 #else |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5813 gtk_paned_set_handle_size(GTK_PANED(tmp), 3); |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5814 #endif |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5815 gtk_widget_show(tmp); |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5816 DW_MUTEX_UNLOCK; |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5817 return tmp; |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5818 } |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5819 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5820 /* |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5821 * Sets the position of a splitbar (pecentage). |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5822 * Parameters: |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5823 * handle: The handle to the splitbar returned by dw_splitbar_new(). |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5824 */ |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5825 void dw_splitbar_set(HWND handle, float percent) |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5826 { |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5827 /* We probably need to force a redraw here */ |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5828 float *mypercent = (float *)dw_window_get_data(handle, "_dw_percent"); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5829 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5830 if(mypercent) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5831 *mypercent = percent; |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5832 } |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5833 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5834 /* |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5835 * Gets the position of a splitbar (pecentage). |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5836 * Parameters: |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5837 * handle: The handle to the splitbar returned by dw_splitbar_new(). |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
5838 */ |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5839 float dw_splitbar_get(HWND handle) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5840 { |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5841 float *percent = (float *)dw_window_get_data(handle, "_dw_percent"); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5842 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5843 if(percent) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5844 return *percent; |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5845 return 0.0; |
3 | 5846 } |
5847 | |
5848 /* | |
5849 * Pack windows (widgets) into a box from the start (or top). | |
5850 * Parameters: | |
5851 * box: Window handle of the box to be packed into. | |
5852 * item: Window handle of the item to be back. | |
5853 * width: Width in pixels of the item or -1 to be self determined. | |
5854 * height: Height in pixels of the item or -1 to be self determined. | |
5855 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. | |
5856 * vsize: TRUE if the window (widget) should expand vertically to fill space given. | |
5857 * pad: Number of pixels of padding around the item. | |
5858 */ | |
5859 void dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) | |
5860 { | |
5861 int _locked_by_me = FALSE; | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
5862 GtkWidget *tmp; |
3 | 5863 |
5864 if(!box) | |
5865 return; | |
5866 | |
5867 DW_MUTEX_LOCK; | |
5868 | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
5869 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
|
5870 box = tmp; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
5871 |
3 | 5872 if(!item) |
5873 { | |
5874 item = gtk_label_new(""); | |
5875 gtk_widget_show(item); | |
5876 } | |
5877 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5878 if(GTK_IS_TABLE(box)) |
3 | 5879 { |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5880 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
|
5881 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
|
5882 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
|
5883 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5884 /* 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
|
5885 * 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
|
5886 * 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
|
5887 * 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
|
5888 */ |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5889 if(GTK_IS_TABLE(item)) |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5890 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5891 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
|
5892 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5893 if(eventbox) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5894 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5895 gtk_container_add(GTK_CONTAINER(eventbox), item); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5896 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
|
5897 item = eventbox; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5898 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5899 } |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5900 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5901 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
|
5902 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5903 x = 0; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5904 y = boxcount; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5905 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
|
5906 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5907 else |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5908 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5909 x = boxcount; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5910 y = 0; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5911 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
|
5912 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5913 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5914 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
|
5915 gtk_object_set_data(GTK_OBJECT(box), "boxcount", (gpointer)boxcount + 1); |
3 | 5916 gtk_widget_set_usize(item, width, height); |
5917 if(GTK_IS_RADIO_BUTTON(item)) | |
5918 { | |
5919 GSList *group; | |
5920 GtkWidget *groupstart = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(box), "group"); | |
5921 | |
5922 if(groupstart) | |
5923 { | |
5924 group = gtk_radio_button_group(GTK_RADIO_BUTTON(groupstart)); | |
5925 gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group); | |
5926 } | |
5927 else | |
5928 gtk_object_set_data(GTK_OBJECT(box), "group", (gpointer)item); | |
5929 } | |
5930 } | |
5931 else | |
5932 { | |
5933 GtkWidget *vbox = gtk_vbox_new(FALSE, 0); | |
5934 | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5935 if(GTK_IS_TABLE(item)) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5936 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5937 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
|
5938 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5939 if(eventbox) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5940 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5941 gtk_container_add(GTK_CONTAINER(eventbox), item); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5942 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
|
5943 item = eventbox; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5944 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5945 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5946 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5947 gtk_container_border_width(GTK_CONTAINER(box), pad); |
3 | 5948 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
|
5949 gtk_box_pack_end(GTK_BOX(vbox), item, TRUE, TRUE, 0); |
3 | 5950 gtk_widget_show(vbox); |
5951 | |
5952 gtk_widget_set_usize(item, width, height); | |
5953 gtk_object_set_user_data(GTK_OBJECT(box), vbox); | |
5954 } | |
5955 DW_MUTEX_UNLOCK; | |
5956 } | |
5957 | |
5958 /* | |
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
|
5959 * 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
|
5960 * 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
|
5961 * 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
|
5962 * 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
|
5963 */ |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
5964 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
|
5965 { |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
5966 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
|
5967 |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
5968 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
|
5969 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
|
5970 |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
5971 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
|
5972 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
|
5973 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
|
5974 } |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
5975 |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
5976 /* |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
5977 * 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
|
5978 * Parameters: |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
5979 * 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
|
5980 * 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
|
5981 */ |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
5982 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
|
5983 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
5984 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
|
5985 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
5986 if(!window) |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
5987 return; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
5988 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
5989 DW_MUTEX_LOCK; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
5990 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
|
5991 DW_MUTEX_UNLOCK; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
5992 } |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
5993 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
5994 /* |
3 | 5995 * Returns some information about the current operating environment. |
5996 * Parameters: | |
5997 * env: Pointer to a DWEnv struct. | |
5998 */ | |
5999 void dw_environment_query(DWEnv *env) | |
6000 { | |
6001 struct utsname name; | |
6002 char tempbuf[100]; | |
6003 int len, z; | |
6004 | |
6005 uname(&name); | |
6006 strcpy(env->osName, name.sysname); | |
6007 strcpy(tempbuf, name.release); | |
6008 | |
6009 env->MajorBuild = env->MinorBuild = 0; | |
6010 | |
6011 len = strlen(tempbuf); | |
6012 | |
15
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
6013 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
|
6014 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
|
6015 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
|
6016 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
|
6017 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
|
6018 |
3 | 6019 for(z=1;z<len;z++) |
6020 { | |
6021 if(tempbuf[z] == '.') | |
6022 { | |
6023 tempbuf[z] = '\0'; | |
6024 env->MajorVersion = atoi(&tempbuf[z-1]); | |
6025 env->MinorVersion = atoi(&tempbuf[z+1]); | |
6026 return; | |
6027 } | |
6028 } | |
6029 env->MajorVersion = atoi(tempbuf); | |
6030 env->MinorVersion = 0; | |
6031 } | |
6032 | |
6033 /* Internal function to handle the file OK press */ | |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
6034 gint _gtk_file_ok(GtkWidget *widget, DWDialog *dwwait) |
3 | 6035 { |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
6036 #if GTK_MAJOR_VERSION > 1 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
6037 const char *tmp; |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
6038 #else |
3 | 6039 char *tmp; |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
6040 #endif |
3 | 6041 |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
6042 if(!dwwait) |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
6043 return 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
|
6044 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
6045 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
|
6046 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
|
6047 _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
|
6048 dw_dialog_dismiss(dwwait, (void *)(tmp ? strdup(tmp) : NULL)); |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
6049 return FALSE; |
3 | 6050 } |
6051 | |
6052 /* Internal function to handle the file Cancel press */ | |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
6053 gint _gtk_file_cancel(GtkWidget *widget, DWDialog *dwwait) |
3 | 6054 { |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
6055 if(!dwwait) |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
6056 return 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
|
6057 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
6058 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
|
6059 _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
|
6060 dw_dialog_dismiss(dwwait, NULL); |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
6061 return FALSE; |
3 | 6062 } |
6063 | |
6064 /* | |
6065 * Opens a file dialog and queries user selection. | |
6066 * Parameters: | |
6067 * title: Title bar text for dialog. | |
6068 * defpath: The default path of the open dialog. | |
6069 * ext: Default file extention. | |
6070 * flags: DW_FILE_OPEN or DW_FILE_SAVE. | |
6071 * Returns: | |
6072 * NULL on error. A malloced buffer containing | |
6073 * the file path on success. | |
6074 * | |
6075 */ | |
6076 char *dw_file_browse(char *title, char *defpath, char *ext, int flags) | |
6077 { | |
6078 GtkWidget *filew; | |
6079 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
|
6080 DWDialog *dwwait; |
3 | 6081 |
6082 DW_MUTEX_LOCK; | |
6083 | |
6084 /* The DW mutex should be sufficient for | |
6085 * insuring no thread changes this unknowingly. | |
6086 */ | |
6087 if(_dw_file_active) | |
6088 { | |
6089 DW_MUTEX_UNLOCK; | |
6090 return NULL; | |
6091 } | |
6092 | |
6093 _dw_file_active = 1; | |
6094 | |
6095 filew = gtk_file_selection_new(title); | |
6096 | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
6097 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
|
6098 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
6099 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
|
6100 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filew)->cancel_button), "clicked", (GtkSignalFunc) _gtk_file_cancel, dwwait); |
3 | 6101 |
6102 if(defpath) | |
6103 gtk_file_selection_set_filename(GTK_FILE_SELECTION(filew), defpath); | |
6104 | |
6105 gtk_widget_show(filew); | |
6106 | |
6107 DW_MUTEX_UNLOCK; | |
6108 | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
6109 return (char *)dw_dialog_wait(dwwait); |
3 | 6110 } |
6111 | |
6112 | |
6113 /* | |
6114 * Execute and external program in a seperate session. | |
6115 * Parameters: | |
6116 * program: Program name with optional path. | |
6117 * type: Either DW_EXEC_CON or DW_EXEC_GUI. | |
6118 * params: An array of pointers to string arguements. | |
6119 * Returns: | |
6120 * -1 on error. | |
6121 */ | |
6122 int dw_exec(char *program, int type, char **params) | |
6123 { | |
6124 int ret = -1; | |
6125 | |
6126 if((ret = fork()) == 0) | |
6127 { | |
6128 int i; | |
6129 | |
6130 for (i = 3; i < 256; i++) | |
6131 close(i); | |
6132 setsid(); | |
6133 if(type == DW_EXEC_GUI) | |
6134 { | |
6135 execvp(program, params); | |
6136 } | |
6137 else if(type == DW_EXEC_CON) | |
6138 { | |
6139 char **tmpargs; | |
6140 | |
6141 if(!params) | |
6142 { | |
6143 tmpargs = malloc(sizeof(char *)); | |
6144 tmpargs[0] = NULL; | |
6145 } | |
6146 else | |
6147 { | |
6148 int z = 0; | |
6149 | |
6150 while(params[z]) | |
6151 { | |
6152 z++; | |
6153 } | |
6154 tmpargs = malloc(sizeof(char *)*(z+3)); | |
6155 z=0; | |
6156 tmpargs[0] = "xterm"; | |
6157 tmpargs[1] = "-e"; | |
6158 while(params[z]) | |
6159 { | |
6160 tmpargs[z+2] = params[z]; | |
6161 z++; | |
6162 } | |
6163 tmpargs[z+2] = NULL; | |
6164 } | |
6165 execvp("xterm", tmpargs); | |
6166 free(tmpargs); | |
6167 } | |
6168 /* If we got here exec failed */ | |
6169 _exit(-1); | |
6170 } | |
6171 return ret; | |
6172 } | |
6173 | |
6174 /* | |
6175 * Loads a web browser pointed at the given URL. | |
6176 * Parameters: | |
6177 * url: Uniform resource locator. | |
6178 */ | |
6179 int dw_browse(char *url) | |
6180 { | |
6181 /* Is there a way to find the webbrowser in Unix? */ | |
6182 char *execargs[3], *browser = "netscape"; | |
6183 | |
6184 execargs[0] = browser; | |
6185 execargs[1] = url; | |
6186 execargs[2] = NULL; | |
6187 | |
6188 return dw_exec(browser, DW_EXEC_GUI, execargs); | |
6189 } | |
6190 | |
6191 /* | |
6192 * Returns a pointer to a static buffer which containes the | |
6193 * current user directory. Or the root directory (C:\ on | |
6194 * OS/2 and Windows). | |
6195 */ | |
6196 char *dw_user_dir(void) | |
6197 { | |
6198 static char _user_dir[1024] = ""; | |
6199 | |
6200 if(!_user_dir[0]) | |
6201 { | |
6202 char *home = getenv("HOME"); | |
6203 | |
6204 if(home) | |
6205 strcpy(_user_dir, home); | |
6206 else | |
6207 strcpy(_user_dir, "/"); | |
6208 } | |
6209 return _user_dir; | |
6210 } | |
6211 | |
6212 /* | |
6213 * Call a function from the window (widget)'s context. | |
6214 * Parameters: | |
6215 * handle: Window handle of the widget. | |
6216 * function: Function pointer to be called. | |
6217 * data: Pointer to the data to be passed to the function. | |
6218 */ | |
6219 void dw_window_function(HWND handle, void *function, void *data) | |
6220 { | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6221 void (* windowfunc)(void *); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6222 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6223 windowfunc = function; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6224 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6225 if(windowfunc) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6226 windowfunc(data); |
3 | 6227 } |
6228 | |
90
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
6229 /* |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
6230 * 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
|
6231 * Parameters: |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
6232 * 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
|
6233 * 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
|
6234 * 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
|
6235 */ |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
6236 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
|
6237 { |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
6238 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
|
6239 |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
6240 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
|
6241 return; |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
6242 |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
6243 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
|
6244 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
|
6245 { |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
6246 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
|
6247 { |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
6248 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
|
6249 |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
6250 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
|
6251 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
|
6252 } |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
6253 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
|
6254 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
|
6255 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
|
6256 } |
90
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
6257 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
|
6258 } |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
6259 |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
6260 /* |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
6261 * 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
|
6262 * Parameters: |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
6263 * 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
|
6264 * 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
|
6265 * 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
|
6266 */ |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
6267 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
|
6268 { |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
6269 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
|
6270 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
|
6271 |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
6272 if(!window) |
92
0a085f295e81
A couple more minor changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
91
diff
changeset
|
6273 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
|
6274 |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
6275 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
|
6276 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
|
6277 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
|
6278 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
|
6279 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
|
6280 } |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
6281 |
3 | 6282 #ifndef NO_SIGNALS |
6283 /* | |
6284 * Add a callback to a window event. | |
6285 * Parameters: | |
6286 * window: Window handle of signal to be called back. | |
6287 * signame: A string pointer identifying which signal to be hooked. | |
6288 * sigfunc: The pointer to the function to be used as the callback. | |
6289 * data: User data to be passed to the handler function. | |
6290 */ | |
6291 void dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data) | |
6292 { | |
6293 SignalHandler *work = malloc(sizeof(SignalHandler)); | |
6294 void *thisfunc = _findsigfunc(signame); | |
6295 char *thisname = signame; | |
6296 HWND thiswindow = window; | |
6297 int _locked_by_me = FALSE; | |
6298 | |
6299 DW_MUTEX_LOCK; | |
6300 if(GTK_IS_SCROLLED_WINDOW(thiswindow)) | |
6301 { | |
6302 thiswindow = (HWND)gtk_object_get_user_data(GTK_OBJECT(window)); | |
6303 } | |
6304 | |
6305 if(GTK_IS_MENU_ITEM(thiswindow) && strcmp(signame, "clicked") == 0) | |
6306 { | |
6307 thisname = "activate"; | |
6308 thisfunc = _findsigfunc(thisname); | |
6309 } | |
6310 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, "container-context") == 0) | |
6311 { | |
6312 thisname = "button_press_event"; | |
6313 thisfunc = _findsigfunc("container-context"); | |
6314 } | |
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
|
6315 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
|
6316 { |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
6317 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
|
6318 |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
6319 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
|
6320 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
|
6321 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
|
6322 |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
6323 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
|
6324 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
|
6325 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
|
6326 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
|
6327 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
|
6328 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
|
6329 } |
3 | 6330 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, "container-select") == 0) |
6331 { | |
6332 thisname = "button_press_event"; | |
6333 thisfunc = _findsigfunc("container-select"); | |
6334 } | |
6335 else if(GTK_IS_COMBO(thiswindow) && strcmp(signame, "item-select") == 0) | |
6336 { | |
6337 thisname = "select_child"; | |
6338 thiswindow = GTK_COMBO(thiswindow)->list; | |
6339 } | |
6340 else if(GTK_IS_LIST(thiswindow) && strcmp(signame, "item-select") == 0) | |
6341 { | |
6342 thisname = "select_child"; | |
6343 } | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6344 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
|
6345 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
6346 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
|
6347 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
|
6348 thiswindow = GTK_COMBO(thiswindow)->entry; |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
6349 } |
55
b6948eac375a
Sync with the latest dynamic windows, tree fixes, and other miscellaneous
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
54
diff
changeset
|
6350 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
|
6351 { |
b6948eac375a
Sync with the latest dynamic windows, tree fixes, and other miscellaneous
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
54
diff
changeset
|
6352 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
|
6353 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
|
6354 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
|
6355 } |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
6356 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
|
6357 { |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
6358 if(thisfunc) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
6359 { |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
6360 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
|
6361 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
|
6362 } |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
6363 thisname = "select-child"; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
6364 } |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
6365 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
|
6366 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
6367 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
|
6368 } |
3 | 6369 |
6370 if(!thisfunc || !thiswindow) | |
6371 { | |
6372 free(work); | |
6373 DW_MUTEX_UNLOCK; | |
6374 return; | |
6375 } | |
6376 | |
6377 work->window = window; | |
6378 work->data = data; | |
6379 work->func = sigfunc; | |
6380 | |
6381 gtk_signal_connect(GTK_OBJECT(thiswindow), thisname, GTK_SIGNAL_FUNC(thisfunc), work); | |
6382 DW_MUTEX_UNLOCK; | |
6383 } | |
6384 | |
6385 /* | |
6386 * Removes callbacks for a given window with given name. | |
6387 * Parameters: | |
6388 * window: Window handle of callback to be removed. | |
6389 */ | |
6390 void dw_signal_disconnect_by_name(HWND window, char *signame) | |
6391 { | |
6392 #if 0 | |
6393 gtk_signal_disconnect_by_name(window, signame); | |
6394 #endif | |
6395 } | |
6396 | |
6397 /* | |
6398 * Removes all callbacks for a given window. | |
6399 * Parameters: | |
6400 * window: Window handle of callback to be removed. | |
6401 */ | |
6402 void dw_signal_disconnect_by_window(HWND window) | |
6403 { | |
6404 #if 0 | |
6405 gtk_signal_disconnect_by_window(window); | |
6406 #endif | |
6407 } | |
6408 | |
6409 /* | |
6410 * Removes all callbacks for a given window with specified data. | |
6411 * Parameters: | |
6412 * window: Window handle of callback to be removed. | |
6413 * data: Pointer to the data to be compared against. | |
6414 */ | |
6415 void dw_signal_disconnect_by_data(HWND window, void *data) | |
6416 { | |
6417 dw_signal_disconnect_by_data(window, data); | |
6418 } | |
6419 #endif | |
6420 | |
6421 #ifdef TEST | |
6422 HWND mainwindow, | |
6423 listbox, | |
6424 okbutton, | |
6425 cancelbutton, | |
6426 lbbox, | |
6427 stext, | |
6428 buttonbox, | |
6429 testwindow, | |
6430 testbox, | |
6431 testok, | |
6432 testcancel, | |
6433 testbox2, | |
6434 testok2, | |
6435 testcancel2, | |
6436 notebook; | |
6437 int count = 2; | |
6438 | |
6439 int test_callback(HWND window, void *data) | |
6440 { | |
6441 dw_window_destroy((HWND)data); | |
6442 /* Return -1 to allow the default handlers to return. */ | |
6443 count--; | |
6444 if(!count) | |
6445 exit(0); | |
6446 return -1; | |
6447 } | |
6448 | |
6449 /* | |
6450 * Let's demonstrate the functionality of this library. :) | |
6451 */ | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6452 int main(int argc, char *argv[]) |
3 | 6453 { |
6454 unsigned long flStyle = DW_FCF_SYSMENU | DW_FCF_TITLEBAR | | |
6455 DW_FCF_SHELLPOSITION | DW_FCF_TASKLIST | DW_FCF_DLGBORDER; | |
6456 int pageid; | |
6457 | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6458 dw_init(TRUE, argc, argv); |
3 | 6459 |
6460 /* Try a little server dialog. :) */ | |
6461 mainwindow = dw_window_new(DW_DESKTOP, "Server", flStyle | DW_FCF_SIZEBORDER | DW_FCF_MINMAX); | |
6462 | |
6463 lbbox = dw_box_new(BOXVERT, 10); | |
6464 | |
6465 dw_box_pack_start(mainwindow, lbbox, 0, 0, TRUE, TRUE, 0); | |
6466 | |
6467 stext = dw_text_new("Choose a server:", 0); | |
6468 | |
6469 dw_window_set_style(stext, DW_DT_VCENTER, DW_DT_VCENTER); | |
6470 | |
6471 dw_box_pack_start(lbbox, stext, 130, 15, FALSE, FALSE, 10); | |
6472 | |
6473 listbox = dw_listbox_new(100L, FALSE); | |
6474 | |
6475 dw_box_pack_start(lbbox, listbox, 130, 200, TRUE, TRUE, 10); | |
6476 | |
6477 buttonbox = dw_box_new(BOXHORZ, 0); | |
6478 | |
6479 dw_box_pack_start(lbbox, buttonbox, 0, 0, TRUE, TRUE, 0); | |
6480 | |
6481 okbutton = dw_button_new("Ok", 1001L); | |
6482 | |
6483 dw_box_pack_start(buttonbox, okbutton, 50, 30, TRUE, TRUE, 5); | |
6484 | |
6485 cancelbutton = dw_button_new("Cancel", 1002L); | |
6486 | |
6487 dw_box_pack_start(buttonbox, cancelbutton, 50, 30, TRUE, TRUE, 5); | |
6488 | |
6489 /* Set some nice fonts and colors */ | |
6490 dw_window_set_color(lbbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); | |
6491 dw_window_set_color(buttonbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); | |
6492 dw_window_set_font(stext, "9.WarpSans"); | |
6493 dw_window_set_color(stext, DW_CLR_BLACK, DW_CLR_PALEGRAY); | |
6494 dw_window_set_font(listbox, "9.WarpSans"); | |
6495 dw_window_set_font(okbutton, "9.WarpSans"); | |
6496 dw_window_set_font(cancelbutton, "9.WarpSans"); | |
6497 | |
6498 dw_window_show(mainwindow); | |
6499 | |
6500 dw_window_set_usize(mainwindow, 170, 340); | |
6501 | |
6502 /* Another small example */ | |
6503 flStyle |= DW_FCF_MINMAX | DW_FCF_SIZEBORDER; | |
6504 | |
6505 testwindow = dw_window_new(DW_DESKTOP, "Wow a test dialog! :) yay!", flStyle); | |
6506 | |
6507 testbox = dw_box_new(BOXVERT, 0); | |
6508 | |
6509 dw_box_pack_start(testwindow, testbox, 0, 0, TRUE, TRUE, 0); | |
6510 | |
6511 notebook = dw_notebook_new(1010L, TRUE); | |
6512 | |
6513 dw_box_pack_start(testbox, notebook, 100, 100, TRUE, TRUE, 0); | |
6514 | |
6515 testbox = dw_box_new(BOXVERT, 10); | |
6516 | |
6517 pageid = dw_notebook_page_new(notebook, 0L, FALSE); | |
6518 | |
6519 dw_notebook_pack(notebook, pageid, testbox); | |
6520 | |
6521 dw_notebook_page_set_text(notebook, pageid, "Test page"); | |
6522 dw_notebook_page_set_status_text(notebook, pageid, "Test page"); | |
6523 | |
6524 testok = dw_button_new("Ok", 1003L); | |
6525 | |
6526 dw_box_pack_start(testbox, testok, 60, 40, TRUE, TRUE, 10); | |
6527 | |
6528 testcancel = dw_button_new("Cancel", 1004L); | |
6529 | |
6530 dw_box_pack_start(testbox, testcancel, 60, 40, TRUE, TRUE, 10); | |
6531 | |
6532 testbox2 = dw_box_new(BOXHORZ, 0); | |
6533 | |
6534 dw_box_pack_start(testbox, testbox2, 0, 0, TRUE, TRUE, 0); | |
6535 | |
6536 testok2 = dw_button_new("Ok", 1003L); | |
6537 | |
6538 dw_box_pack_start(testbox2, testok2, 60, 40, TRUE, TRUE, 10); | |
6539 | |
6540 dw_box_pack_splitbar_start(testbox2); | |
6541 | |
6542 testcancel2 = dw_button_new("Cancel", 1004L); | |
6543 | |
6544 dw_box_pack_start(testbox2, testcancel2, 60, 40, TRUE, TRUE, 10); | |
6545 | |
6546 /* Set some nice fonts and colors */ | |
6547 dw_window_set_color(testbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); | |
6548 dw_window_set_color(testbox2, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); | |
6549 dw_window_set_font(testok, "9.WarpSans"); | |
6550 dw_window_set_font(testcancel, "9.WarpSans"); | |
6551 dw_window_set_font(testok2, "9.WarpSans"); | |
6552 dw_window_set_font(testcancel2, "9.WarpSans"); | |
6553 | |
6554 dw_window_show(testwindow); | |
6555 | |
6556 /* Setup the function callbacks */ | |
6557 dw_signal_connect(okbutton, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); | |
6558 dw_signal_connect(cancelbutton, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); | |
6559 dw_signal_connect(testok, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); | |
6560 dw_signal_connect(testcancel, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); | |
6561 dw_signal_connect(testok2, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); | |
6562 dw_signal_connect(testcancel2, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); | |
6563 dw_signal_connect(mainwindow, "delete_event", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); | |
6564 dw_signal_connect(testwindow, "delete_event", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); | |
6565 | |
6566 dw_main(0L, NULL); | |
6567 | |
6568 return 0; | |
6569 } | |
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
|
6570 #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
|
6571 |