Mercurial > dwindows
comparison dwtest.c @ 620:9876b75d7115
Added menu tests, including checked and disabled menu items.
author | mhessling@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 06 Apr 2008 00:41:44 +0000 |
parents | df01183257a0 |
children | 46c261153aa4 |
comparison
equal
deleted
inserted
replaced
619:e0213b22fe5b | 620:9876b75d7115 |
---|---|
23 #endif | 23 #endif |
24 | 24 |
25 #define SCROLLBARWIDTH 14 | 25 #define SCROLLBARWIDTH 14 |
26 | 26 |
27 unsigned long flStyle = DW_FCF_SYSMENU | DW_FCF_TITLEBAR | | 27 unsigned long flStyle = DW_FCF_SYSMENU | DW_FCF_TITLEBAR | |
28 DW_FCF_SHELLPOSITION | DW_FCF_TASKLIST | DW_FCF_DLGBORDER; | 28 DW_FCF_SHELLPOSITION | DW_FCF_TASKLIST | DW_FCF_DLGBORDER; |
29 | 29 |
30 unsigned long current_color = DW_RGB(100,100,100); | 30 unsigned long current_color = DW_RGB(100,100,100); |
31 | 31 |
32 int iteration = 0; | 32 int iteration = 0; |
33 void create_button( int); | 33 void create_button( int); |
34 | 34 |
35 #ifdef __MAC__ | 35 #ifdef __MAC__ |
36 int main(int argc, char *argv[]) | 36 int main(int argc, char *argv[]) |
37 { | 37 { |
38 DWEnv env; | 38 DWEnv env; |
39 HWND window; | 39 HWND window; |
40 | 40 |
41 dw_init(TRUE, argc, argv); | 41 dw_init(TRUE, argc, argv); |
42 | 42 |
43 window = dw_window_new(HWND_DESKTOP, "Test Window", flStyle); | 43 window = dw_window_new(HWND_DESKTOP, "Test Window", flStyle); |
44 dw_window_set_pos_size(window, 100, 100, 300, 200); | 44 dw_window_set_pos_size(window, 100, 100, 300, 200); |
45 dw_window_show(window); | 45 dw_window_show(window); |
46 | 46 |
47 dw_environment_query(&env); | 47 dw_environment_query(&env); |
48 dw_messagebox("Title", DW_MB_OK | DW_MB_INFORMATION, "Operating System: %s %d.%d\nBuild: %d.%d\n", | 48 dw_messagebox("Title", DW_MB_OK | DW_MB_INFORMATION, "Operating System: %s %d.%d\nBuild: %d.%d\n", |
49 env.osName, env.MajorVersion, env.MinorVersion, env.MajorBuild, env.MinorBuild); | 49 env.osName, env.MajorVersion, env.MinorVersion, env.MajorBuild, env.MinorBuild); |
50 | 50 |
51 return 0; | 51 return 0; |
52 } | 52 } |
53 #else | 53 #else |
54 | 54 |
55 HWND mainwindow, | 55 HWND mainwindow, |
56 entryfield, | 56 entryfield, |
57 cursortogglebutton, | 57 checkable_menuitem, |
58 colorchoosebutton, | 58 noncheckable_menuitem, |
59 okbutton, | 59 cursortogglebutton, |
60 cancelbutton, | 60 colorchoosebutton, |
61 lbbox, | 61 okbutton, |
62 combox, | 62 cancelbutton, |
63 combobox1, | 63 lbbox, |
64 combobox2, | 64 combox, |
65 spinbutton, | 65 combobox1, |
66 notebookbox, | 66 combobox2, |
67 notebookbox1, | 67 spinbutton, |
68 notebookbox2, | 68 notebookbox, |
69 notebookbox3, | 69 notebookbox1, |
70 notebookbox4, | 70 notebookbox2, |
71 notebookbox5, | 71 notebookbox3, |
72 notebookbox6, | 72 notebookbox4, |
73 html, | 73 notebookbox5, |
74 notebook, | 74 notebookbox6, |
75 vscrollbar, | 75 notebookbox7, |
76 hscrollbar, | 76 html, |
77 status, status1, | 77 notebook, |
78 container_status, | 78 vscrollbar, |
79 tree_status, | 79 hscrollbar, |
80 stext, | 80 status, status1, |
81 tree, | 81 container_status, |
82 container, | 82 tree_status, |
83 container_mle, | 83 stext, |
84 pagebox, | 84 tree, |
85 treebox, | 85 container, |
86 containerbox, | 86 container_mle, |
87 textbox1, textbox2, textboxA, | 87 pagebox, |
88 gap_box, | 88 treebox, |
89 buttonbox, | 89 containerbox, |
90 buttonboxperm, | 90 textbox1, textbox2, textboxA, |
91 filetoolbarbox; | 91 gap_box, |
92 buttonbox, | |
93 buttonboxperm, | |
94 cal, | |
95 filetoolbarbox; | |
96 | |
97 HMENUI mainmenubar,changeable_menu; | |
98 #define CHECKABLE_MENUITEMID 2001 | |
99 #define NONCHECKABLE_MENUITEMID 2002 | |
92 | 100 |
93 void *containerinfo; | 101 void *containerinfo; |
102 | |
103 | |
104 int menu_enabled = 1; | |
94 | 105 |
95 HPIXMAP text1pm,text2pm; | 106 HPIXMAP text1pm,text2pm; |
96 unsigned long fileicon,foldericon,mle_point=-1; | 107 unsigned long fileicon,foldericon,mle_point=-1; |
97 | 108 |
98 int font_width = 8; | 109 int font_width = 8; |
108 FILE *fp=NULL; | 119 FILE *fp=NULL; |
109 char **lp; | 120 char **lp; |
110 | 121 |
111 char *resolve_keyname( int vk ) | 122 char *resolve_keyname( int vk ) |
112 { | 123 { |
113 char *keyname; | 124 char *keyname; |
114 switch(vk) | 125 switch(vk) |
115 { | 126 { |
116 case VK_LBUTTON : keyname = "VK_LBUTTON"; break; | 127 case VK_LBUTTON : keyname = "VK_LBUTTON"; break; |
117 case VK_RBUTTON : keyname = "VK_RBUTTON"; break; | 128 case VK_RBUTTON : keyname = "VK_RBUTTON"; break; |
118 case VK_CANCEL : keyname = "VK_CANCEL"; break; | 129 case VK_CANCEL : keyname = "VK_CANCEL"; break; |
119 case VK_MBUTTON : keyname = "VK_MBUTTON"; break; | 130 case VK_MBUTTON : keyname = "VK_MBUTTON"; break; |
120 /* case VK_BACK : keyname = "VK_BACK"; break;*/ | 131 /* case VK_BACK : keyname = "VK_BACK"; break;*/ |
121 case VK_TAB : keyname = "VK_TAB"; break; | 132 case VK_TAB : keyname = "VK_TAB"; break; |
122 case VK_CLEAR : keyname = "VK_CLEAR"; break; | 133 case VK_CLEAR : keyname = "VK_CLEAR"; break; |
123 case VK_RETURN : keyname = "VK_RETURN"; break; | 134 case VK_RETURN : keyname = "VK_RETURN"; break; |
124 /* case VK_MENU : keyname = "VK_MENU"; break;*/ | 135 /* case VK_MENU : keyname = "VK_MENU"; break;*/ |
125 case VK_PAUSE : keyname = "VK_PAUSE"; break; | 136 case VK_PAUSE : keyname = "VK_PAUSE"; break; |
126 case VK_CAPITAL : keyname = "VK_CAPITAL"; break; | 137 case VK_CAPITAL : keyname = "VK_CAPITAL"; break; |
127 case VK_ESCAPE : keyname = "VK_ESCAPE"; break; | 138 case VK_ESCAPE : keyname = "VK_ESCAPE"; break; |
128 case VK_SPACE : keyname = "VK_SPACE"; break; | 139 case VK_SPACE : keyname = "VK_SPACE"; break; |
129 case VK_PRIOR : keyname = "VK_PRIOR"; break; | 140 case VK_PRIOR : keyname = "VK_PRIOR"; break; |
130 case VK_NEXT : keyname = "VK_NEXT"; break; | 141 case VK_NEXT : keyname = "VK_NEXT"; break; |
131 case VK_END : keyname = "VK_END"; break; | 142 case VK_END : keyname = "VK_END"; break; |
132 case VK_HOME : keyname = "VK_HOME"; break; | 143 case VK_HOME : keyname = "VK_HOME"; break; |
133 case VK_LEFT : keyname = "VK_LEFT"; break; | 144 case VK_LEFT : keyname = "VK_LEFT"; break; |
134 case VK_UP : keyname = "VK_UP"; break; | 145 case VK_UP : keyname = "VK_UP"; break; |
135 case VK_RIGHT : keyname = "VK_RIGHT"; break; | 146 case VK_RIGHT : keyname = "VK_RIGHT"; break; |
136 case VK_DOWN : keyname = "VK_DOWN"; break; | 147 case VK_DOWN : keyname = "VK_DOWN"; break; |
137 case VK_SELECT : keyname = "VK_SELECT"; break; | 148 case VK_SELECT : keyname = "VK_SELECT"; break; |
138 case VK_PRINT : keyname = "VK_PRINT"; break; | 149 case VK_PRINT : keyname = "VK_PRINT"; break; |
139 case VK_EXECUTE : keyname = "VK_EXECUTE"; break; | 150 case VK_EXECUTE : keyname = "VK_EXECUTE"; break; |
140 case VK_SNAPSHOT: keyname = "VK_SNAPSHOT"; break; | 151 case VK_SNAPSHOT: keyname = "VK_SNAPSHOT"; break; |
141 case VK_INSERT : keyname = "VK_INSERT"; break; | 152 case VK_INSERT : keyname = "VK_INSERT"; break; |
142 case VK_DELETE : keyname = "VK_DELETE"; break; | 153 case VK_DELETE : keyname = "VK_DELETE"; break; |
143 case VK_HELP : keyname = "VK_HELP"; break; | 154 case VK_HELP : keyname = "VK_HELP"; break; |
144 case VK_LWIN : keyname = "VK_LWIN"; break; | 155 case VK_LWIN : keyname = "VK_LWIN"; break; |
145 case VK_RWIN : keyname = "VK_RWIN"; break; | 156 case VK_RWIN : keyname = "VK_RWIN"; break; |
146 case VK_NUMPAD0 : keyname = "VK_NUMPAD0"; break; | 157 case VK_NUMPAD0 : keyname = "VK_NUMPAD0"; break; |
147 case VK_NUMPAD1 : keyname = "VK_NUMPAD1"; break; | 158 case VK_NUMPAD1 : keyname = "VK_NUMPAD1"; break; |
148 case VK_NUMPAD2 : keyname = "VK_NUMPAD2"; break; | 159 case VK_NUMPAD2 : keyname = "VK_NUMPAD2"; break; |
149 case VK_NUMPAD3 : keyname = "VK_NUMPAD3"; break; | 160 case VK_NUMPAD3 : keyname = "VK_NUMPAD3"; break; |
150 case VK_NUMPAD4 : keyname = "VK_NUMPAD4"; break; | 161 case VK_NUMPAD4 : keyname = "VK_NUMPAD4"; break; |
151 case VK_NUMPAD5 : keyname = "VK_NUMPAD5"; break; | 162 case VK_NUMPAD5 : keyname = "VK_NUMPAD5"; break; |
152 case VK_NUMPAD6 : keyname = "VK_NUMPAD6"; break; | 163 case VK_NUMPAD6 : keyname = "VK_NUMPAD6"; break; |
153 case VK_NUMPAD7 : keyname = "VK_NUMPAD7"; break; | 164 case VK_NUMPAD7 : keyname = "VK_NUMPAD7"; break; |
154 case VK_NUMPAD8 : keyname = "VK_NUMPAD8"; break; | 165 case VK_NUMPAD8 : keyname = "VK_NUMPAD8"; break; |
155 case VK_NUMPAD9 : keyname = "VK_NUMPAD9"; break; | 166 case VK_NUMPAD9 : keyname = "VK_NUMPAD9"; break; |
156 case VK_MULTIPLY: keyname = "VK_MULTIPLY"; break; | 167 case VK_MULTIPLY: keyname = "VK_MULTIPLY"; break; |
157 case VK_ADD : keyname = "VK_ADD"; break; | 168 case VK_ADD : keyname = "VK_ADD"; break; |
158 case VK_SEPARATOR: keyname = "VK_SEPARATOR"; break; | 169 case VK_SEPARATOR: keyname = "VK_SEPARATOR"; break; |
159 case VK_SUBTRACT: keyname = "VK_SUBTRACT"; break; | 170 case VK_SUBTRACT: keyname = "VK_SUBTRACT"; break; |
160 case VK_DECIMAL : keyname = "VK_DECIMAL"; break; | 171 case VK_DECIMAL : keyname = "VK_DECIMAL"; break; |
161 case VK_DIVIDE : keyname = "VK_DIVIDE"; break; | 172 case VK_DIVIDE : keyname = "VK_DIVIDE"; break; |
162 case VK_F1 : keyname = "VK_F1"; break; | 173 case VK_F1 : keyname = "VK_F1"; break; |
163 case VK_F2 : keyname = "VK_F2"; break; | 174 case VK_F2 : keyname = "VK_F2"; break; |
164 case VK_F3 : keyname = "VK_F3"; break; | 175 case VK_F3 : keyname = "VK_F3"; break; |
165 case VK_F4 : keyname = "VK_F4"; break; | 176 case VK_F4 : keyname = "VK_F4"; break; |
166 case VK_F5 : keyname = "VK_F5"; break; | 177 case VK_F5 : keyname = "VK_F5"; break; |
167 case VK_F6 : keyname = "VK_F6"; break; | 178 case VK_F6 : keyname = "VK_F6"; break; |
168 case VK_F7 : keyname = "VK_F7"; break; | 179 case VK_F7 : keyname = "VK_F7"; break; |
169 case VK_F8 : keyname = "VK_F8"; break; | 180 case VK_F8 : keyname = "VK_F8"; break; |
170 case VK_F9 : keyname = "VK_F9"; break; | 181 case VK_F9 : keyname = "VK_F9"; break; |
171 case VK_F10 : keyname = "VK_F10"; break; | 182 case VK_F10 : keyname = "VK_F10"; break; |
172 case VK_F11 : keyname = "VK_F11"; break; | 183 case VK_F11 : keyname = "VK_F11"; break; |
173 case VK_F12 : keyname = "VK_F12"; break; | 184 case VK_F12 : keyname = "VK_F12"; break; |
174 case VK_F13 : keyname = "VK_F13"; break; | 185 case VK_F13 : keyname = "VK_F13"; break; |
175 case VK_F14 : keyname = "VK_F14"; break; | 186 case VK_F14 : keyname = "VK_F14"; break; |
176 case VK_F15 : keyname = "VK_F15"; break; | 187 case VK_F15 : keyname = "VK_F15"; break; |
177 case VK_F16 : keyname = "VK_F16"; break; | 188 case VK_F16 : keyname = "VK_F16"; break; |
178 case VK_F17 : keyname = "VK_F17"; break; | 189 case VK_F17 : keyname = "VK_F17"; break; |
179 case VK_F18 : keyname = "VK_F18"; break; | 190 case VK_F18 : keyname = "VK_F18"; break; |
180 case VK_F19 : keyname = "VK_F19"; break; | 191 case VK_F19 : keyname = "VK_F19"; break; |
181 case VK_F20 : keyname = "VK_F20"; break; | 192 case VK_F20 : keyname = "VK_F20"; break; |
182 case VK_F21 : keyname = "VK_F21"; break; | 193 case VK_F21 : keyname = "VK_F21"; break; |
183 case VK_F22 : keyname = "VK_F22"; break; | 194 case VK_F22 : keyname = "VK_F22"; break; |
184 case VK_F23 : keyname = "VK_F23"; break; | 195 case VK_F23 : keyname = "VK_F23"; break; |
185 case VK_F24 : keyname = "VK_F24"; break; | 196 case VK_F24 : keyname = "VK_F24"; break; |
186 case VK_NUMLOCK : keyname = "VK_NUMLOCK"; break; | 197 case VK_NUMLOCK : keyname = "VK_NUMLOCK"; break; |
187 case VK_SCROLL : keyname = "VK_SCROLL"; break; | 198 case VK_SCROLL : keyname = "VK_SCROLL"; break; |
188 case VK_LSHIFT : keyname = "VK_LSHIFT"; break; | 199 case VK_LSHIFT : keyname = "VK_LSHIFT"; break; |
189 case VK_RSHIFT : keyname = "VK_RSHIFT"; break; | 200 case VK_RSHIFT : keyname = "VK_RSHIFT"; break; |
190 case VK_LCONTROL: keyname = "VK_LCONTROL"; break; | 201 case VK_LCONTROL: keyname = "VK_LCONTROL"; break; |
191 case VK_RCONTROL: keyname = "VK_RCONTROL"; break; | 202 case VK_RCONTROL: keyname = "VK_RCONTROL"; break; |
192 /* case VK_LMENU : keyname = "VK_LMENU"; break; */ | 203 /* case VK_LMENU : keyname = "VK_LMENU"; break; */ |
193 /* case VK_RMENU : keyname = "VK_RMENU"; break;*/ | 204 /* case VK_RMENU : keyname = "VK_RMENU"; break;*/ |
194 default: keyname = "<unknown>"; break; | 205 default: keyname = "<unknown>"; break; |
195 } | 206 } |
196 return keyname; | 207 return keyname; |
197 } | 208 } |
198 | 209 |
199 char *resolve_keymodifiers( int mask ) | 210 char *resolve_keymodifiers( int mask ) |
200 { | 211 { |
201 if ( (mask & KC_CTRL) && (mask & KC_SHIFT) && (mask && KC_ALT) ) | 212 if ( (mask & KC_CTRL) && (mask & KC_SHIFT) && (mask && KC_ALT) ) |
202 return "KC_CTRL KC_SHIFT KC_ALT"; | 213 return "KC_CTRL KC_SHIFT KC_ALT"; |
203 else if ( (mask & KC_CTRL) && (mask & KC_SHIFT) ) | 214 else if ( (mask & KC_CTRL) && (mask & KC_SHIFT) ) |
204 return "KC_CTRL KC_SHIFT"; | 215 return "KC_CTRL KC_SHIFT"; |
205 else if ( (mask & KC_CTRL) && (mask & KC_ALT) ) | 216 else if ( (mask & KC_CTRL) && (mask & KC_ALT) ) |
206 return "KC_CTRL KC_ALT"; | 217 return "KC_CTRL KC_ALT"; |
207 else if ( (mask & KC_SHIFT) && (mask & KC_ALT) ) | 218 else if ( (mask & KC_SHIFT) && (mask & KC_ALT) ) |
208 return "KC_SHIFT KC_ALT"; | 219 return "KC_SHIFT KC_ALT"; |
209 else if ( (mask & KC_SHIFT) ) | 220 else if ( (mask & KC_SHIFT) ) |
210 return "KC_SHIFT"; | 221 return "KC_SHIFT"; |
211 else if ( (mask & KC_CTRL) ) | 222 else if ( (mask & KC_CTRL) ) |
212 return "KC_CTRL"; | 223 return "KC_CTRL"; |
213 else if ( (mask & KC_ALT) ) | 224 else if ( (mask & KC_ALT) ) |
214 return "KC_ALT"; | 225 return "KC_ALT"; |
215 else return "none"; | 226 else return "none"; |
216 } | 227 } |
217 | 228 |
218 /* This gets called when a part of the graph needs to be repainted. */ | 229 /* This gets called when a part of the graph needs to be repainted. */ |
219 int DWSIGNAL text_expose(HWND hwnd, DWExpose *exp, void *data) | 230 int DWSIGNAL text_expose(HWND hwnd, DWExpose *exp, void *data) |
220 { | 231 { |
221 HPIXMAP hpm; | 232 HPIXMAP hpm; |
222 int width,height; | 233 int width,height; |
223 | 234 |
224 if ( hwnd == textbox1 ) | 235 if ( hwnd == textbox1 ) |
225 hpm = text1pm; | 236 hpm = text1pm; |
226 else if ( hwnd == textbox2 ) | 237 else if ( hwnd == textbox2 ) |
227 hpm = text2pm; | 238 hpm = text2pm; |
228 else | 239 else |
229 return TRUE; | 240 return TRUE; |
230 | 241 |
231 width = DW_PIXMAP_WIDTH(hpm); | 242 width = DW_PIXMAP_WIDTH(hpm); |
232 height = DW_PIXMAP_HEIGHT(hpm); | 243 height = DW_PIXMAP_HEIGHT(hpm); |
233 | 244 |
234 dw_pixmap_bitblt(hwnd, NULL, 0, 0, width, height, 0, hpm, 0, 0 ); | 245 dw_pixmap_bitblt(hwnd, NULL, 0, 0, width, height, 0, hpm, 0, 0 ); |
235 dw_flush(); | 246 dw_flush(); |
236 return TRUE; | 247 return TRUE; |
237 } | 248 } |
238 | 249 |
239 void read_file( void ) | 250 void read_file( void ) |
240 { | 251 { |
241 int i,len; | 252 int i,len; |
242 fp = fopen( current_file, "r" ); | 253 fp = fopen( current_file, "r" ); |
243 lp = (char **)calloc( 1000,sizeof(char *)); | 254 lp = (char **)calloc( 1000,sizeof(char *)); |
244 /* should test for out of memory */ | 255 /* should test for out of memory */ |
245 max_linewidth=0; | 256 max_linewidth=0; |
246 for ( i = 0; i < 1000; i++ ) | 257 for ( i = 0; i < 1000; i++ ) |
247 { | 258 { |
248 lp[i] = (char *)calloc(1, 1025); | 259 lp[i] = (char *)calloc(1, 1025); |
249 if ( fgets( lp[i], 1024, fp ) == NULL ) | 260 if ( fgets( lp[i], 1024, fp ) == NULL ) |
250 break; | 261 break; |
251 len = strlen( lp[i] ); | 262 len = strlen( lp[i] ); |
252 if ( len > max_linewidth ) | 263 if ( len > max_linewidth ) |
253 max_linewidth = len; | 264 max_linewidth = len; |
254 if ( lp[i][len - 1] == '\n' ) | 265 if ( lp[i][len - 1] == '\n' ) |
255 lp[i][len - 1] = '\0'; | 266 lp[i][len - 1] = '\0'; |
256 } | 267 } |
257 num_lines = i; | 268 num_lines = i; |
258 fclose( fp ); | 269 fclose( fp ); |
259 dw_scrollbar_set_range(hscrollbar, max_linewidth, cols); | 270 dw_scrollbar_set_range(hscrollbar, max_linewidth, cols); |
260 dw_scrollbar_set_pos(hscrollbar, 0); | 271 dw_scrollbar_set_pos(hscrollbar, 0); |
261 dw_scrollbar_set_range(vscrollbar, num_lines, rows); | 272 dw_scrollbar_set_range(vscrollbar, num_lines, rows); |
262 dw_scrollbar_set_pos(vscrollbar, 0); | 273 dw_scrollbar_set_pos(vscrollbar, 0); |
263 } | 274 } |
264 | 275 |
265 void draw_file( int row, int col ) | 276 void draw_file( int row, int col ) |
266 { | 277 { |
267 char buf[10]; | 278 char buf[10]; |
268 int i,y,fileline; | 279 int i,y,fileline; |
269 char *pLine; | 280 char *pLine; |
270 | 281 |
271 if ( current_file ) | 282 if ( current_file ) |
272 { | 283 { |
273 dw_color_foreground_set(DW_CLR_WHITE); | 284 dw_color_foreground_set(DW_CLR_WHITE); |
274 dw_draw_rect(0, text1pm, TRUE, 0, 0, DW_PIXMAP_WIDTH(text1pm), DW_PIXMAP_HEIGHT(text1pm)); | 285 dw_draw_rect(0, text1pm, TRUE, 0, 0, DW_PIXMAP_WIDTH(text1pm), DW_PIXMAP_HEIGHT(text1pm)); |
275 dw_draw_rect(0, text2pm, TRUE, 0, 0, DW_PIXMAP_WIDTH(text2pm), DW_PIXMAP_HEIGHT(text2pm)); | 286 dw_draw_rect(0, text2pm, TRUE, 0, 0, DW_PIXMAP_WIDTH(text2pm), DW_PIXMAP_HEIGHT(text2pm)); |
276 | 287 |
277 for ( i = 0;(i < rows) && (i+row < num_lines); i++) | 288 for ( i = 0;(i < rows) && (i+row < num_lines); i++) |
278 { | 289 { |
279 fileline = i + row - 1; | 290 fileline = i + row - 1; |
280 y = i*font_height; | 291 y = i*font_height; |
281 dw_color_background_set( 1 + (fileline % 15) ); | 292 dw_color_background_set( 1 + (fileline % 15) ); |
282 dw_color_foreground_set( fileline % 16 ); | 293 dw_color_foreground_set( fileline % 16 ); |
283 sprintf( buf, "%6.6d", i+row ); | 294 sprintf( buf, "%6.6d", i+row ); |
284 dw_draw_text( 0, text1pm, 0, y, buf); | 295 dw_draw_text( 0, text1pm, 0, y, buf); |
285 pLine = lp[i+row]; | 296 pLine = lp[i+row]; |
286 dw_draw_text( 0, text2pm, 0, y, pLine+col ); | 297 dw_draw_text( 0, text2pm, 0, y, pLine+col ); |
287 } | 298 } |
288 text_expose( textbox1, NULL, NULL); | 299 text_expose( textbox1, NULL, NULL); |
289 text_expose( textbox2, NULL, NULL); | 300 text_expose( textbox2, NULL, NULL); |
290 } | 301 } |
291 } | 302 } |
292 | 303 |
293 | 304 |
294 int DWSIGNAL colorchoose_callback(HWND window, void *data) | 305 int DWSIGNAL colorchoose_callback(HWND window, void *data) |
295 { | 306 { |
296 current_color = dw_color_choose(current_color); | 307 current_color = dw_color_choose(current_color); |
297 return FALSE; | 308 return FALSE; |
298 } | 309 } |
299 | 310 |
300 int DWSIGNAL cursortoggle_callback(HWND window, void *data) | 311 int DWSIGNAL cursortoggle_callback(HWND window, void *data) |
301 { | 312 { |
302 | 313 if(cursor_arrow) |
303 if(cursor_arrow) | 314 { |
304 { | 315 dw_window_set_text((HWND)cursortogglebutton,"Set Cursor pointer - ARROW"); |
305 dw_window_set_text((HWND)cursortogglebutton,"Set Cursor pointer - ARROW"); | 316 dw_window_set_pointer((HWND)data,DW_POINTER_CLOCK); |
306 dw_window_set_pointer((HWND)data,DW_POINTER_CLOCK); | 317 cursor_arrow = 0; |
307 cursor_arrow = 0; | 318 } |
308 } | 319 else |
309 else | 320 { |
310 { | 321 dw_window_set_text((HWND)cursortogglebutton,"Set Cursor pointer - CLOCK"); |
311 dw_window_set_text((HWND)cursortogglebutton,"Set Cursor pointer - CLOCK"); | 322 dw_window_set_pointer((HWND)data,DW_POINTER_DEFAULT); |
312 dw_window_set_pointer((HWND)data,DW_POINTER_DEFAULT); | 323 cursor_arrow = 1; |
313 cursor_arrow = 1; | 324 } |
314 } | 325 return FALSE; |
315 return FALSE; | |
316 } | 326 } |
317 | 327 |
318 int DWSIGNAL beep_callback(HWND window, void *data) | 328 int DWSIGNAL beep_callback(HWND window, void *data) |
319 { | 329 { |
320 dw_timer_disconnect( timerid ); | 330 dw_timer_disconnect( timerid ); |
321 return TRUE; | 331 return TRUE; |
322 } | 332 } |
323 | 333 |
324 int DWSIGNAL keypress_callback(HWND window, char ch, int vk, int state, void *data) | 334 int DWSIGNAL keypress_callback(HWND window, char ch, int vk, int state, void *data) |
325 { | 335 { |
326 char tmpbuf[100]; | 336 char tmpbuf[100]; |
327 if ( ch ) | 337 if ( ch ) |
328 sprintf( tmpbuf, "Key: %c(%d) Modifiers: %s(%d)", ch, ch, resolve_keymodifiers(state), state ); | 338 sprintf( tmpbuf, "Key: %c(%d) Modifiers: %s(%d)", ch, ch, resolve_keymodifiers(state), state ); |
329 else | 339 else |
330 sprintf( tmpbuf, "Key: %s(%d) Modifiers: %s(%d)", resolve_keyname(vk), vk, resolve_keymodifiers(state), state ); | 340 sprintf( tmpbuf, "Key: %s(%d) Modifiers: %s(%d)", resolve_keyname(vk), vk, resolve_keymodifiers(state), state ); |
331 dw_window_set_text( status1, tmpbuf); | 341 dw_window_set_text( status1, tmpbuf); |
332 return 0; | 342 return 0; |
343 } | |
344 | |
345 int DWSIGNAL menu_callback(HWND window, void *data) | |
346 { | |
347 char buf[100]; | |
348 | |
349 sprintf( buf, "%s menu item selected", (char *)data ); | |
350 dw_messagebox( "Menu Item Callback", DW_MB_OK | DW_MB_INFORMATION, buf ); | |
351 return 0; | |
352 } | |
353 | |
354 int DWSIGNAL menutoggle_callback(HWND window, void *data) | |
355 { | |
356 if ( menu_enabled ) | |
357 { | |
358 dw_menu_item_set_state( changeable_menu, CHECKABLE_MENUITEMID, DW_MIS_DISABLED ); | |
359 dw_menu_item_set_state( changeable_menu, NONCHECKABLE_MENUITEMID, DW_MIS_DISABLED ); | |
360 menu_enabled = 0; | |
361 } | |
362 else | |
363 { | |
364 dw_menu_item_set_state( changeable_menu, CHECKABLE_MENUITEMID, DW_MIS_ENABLED ); | |
365 dw_menu_item_set_state( changeable_menu, NONCHECKABLE_MENUITEMID, DW_MIS_ENABLED ); | |
366 menu_enabled = 1; | |
367 } | |
368 return 0; | |
369 } | |
370 | |
371 int DWSIGNAL helpabout_callback(HWND window, void *data) | |
372 { | |
373 char buf[100]; | |
374 DWEnv env; | |
375 | |
376 dw_environment_query(&env); | |
377 sprintf( buf, "dwindows test\n\nOS: %s %s %s Version: %d.%d.%d.%d\n\ndwindows Version: %d.%d.%d", | |
378 env.osName, env.buildDate, env.buildTime, | |
379 env.MajorVersion, env.MinorVersion, env.MajorBuild, env.MinorBuild, | |
380 env.DWMajorVersion, env.DWMinorVersion, env.DWSubVersion ); | |
381 dw_messagebox( "About dwindows", DW_MB_OK | DW_MB_INFORMATION, buf ); | |
382 return 0; | |
333 } | 383 } |
334 | 384 |
335 int DWSIGNAL exit_callback(HWND window, void *data) | 385 int DWSIGNAL exit_callback(HWND window, void *data) |
336 { | 386 { |
337 dw_window_destroy((HWND)data); | 387 dw_window_destroy((HWND)data); |
338 exit(0); | 388 exit(0); |
339 return -1; | 389 return -1; |
340 } | 390 } |
341 | 391 |
342 int DWSIGNAL test_callback(HWND window, void *data) | 392 int DWSIGNAL test_callback(HWND window, void *data) |
343 { | 393 { |
344 dw_window_destroy((HWND)data); | 394 dw_window_destroy((HWND)data); |
345 if ( current_file ) | 395 if ( current_file ) |
346 dw_free( current_file ); | 396 dw_free( current_file ); |
347 exit(0); | 397 exit(0); |
348 return -1; | 398 return -1; |
349 } | 399 } |
350 | 400 |
351 int DWSIGNAL browse_callback(HWND window, void *data) | 401 int DWSIGNAL browse_callback(HWND window, void *data) |
352 { | 402 { |
353 char *tmp; | 403 char *tmp; |
354 tmp = dw_file_browse("test string", NULL, "c", DW_FILE_OPEN ); | 404 tmp = dw_file_browse("test string", NULL, "c", DW_FILE_OPEN ); |
355 if ( tmp ) | 405 if ( tmp ) |
356 { | 406 { |
357 if ( current_file ) | 407 if ( current_file ) |
358 { | 408 { |
359 dw_free( current_file ); | 409 dw_free( current_file ); |
360 } | 410 } |
361 current_file = tmp; | 411 current_file = tmp; |
362 dw_window_set_text( entryfield, current_file ); | 412 dw_window_set_text( entryfield, current_file ); |
363 read_file(); | 413 read_file(); |
364 draw_file(0,0); | 414 draw_file(0,0); |
365 } | 415 } |
366 return 0; | 416 return 0; |
367 } | 417 } |
368 | 418 |
369 int DWSIGNAL button_callback(HWND window, void *data) | 419 int DWSIGNAL button_callback(HWND window, void *data) |
370 { | 420 { |
371 return 0; | 421 unsigned int y,m,d; |
422 unsigned int idx; | |
423 int len; | |
424 long spvalue; | |
425 char buf1[100]; | |
426 char buf2[100]; | |
427 char buf3[500]; | |
428 | |
429 idx = dw_listbox_selected( combobox1 ); | |
430 dw_listbox_get_text( combobox1, idx, buf1, 99 ); | |
431 idx = dw_listbox_selected( combobox2 ); | |
432 dw_listbox_get_text( combobox2, idx, buf2, 99 ); | |
433 dw_calendar_get_date( cal, &y, &m, &d ); | |
434 spvalue = dw_spinbutton_get_pos( spinbutton ); | |
435 len = sprintf( buf3, "spinbutton: %ld\ncombobox1: \"%s\"\ncombobox2: \"%s\"\ncalendar: %d-%d-%d", | |
436 spvalue, | |
437 buf1, buf2, | |
438 y, m, d ); | |
439 dw_messagebox( "Values", DW_MB_OK | DW_MB_INFORMATION, buf3 ); | |
440 dw_clipboard_set_text( buf3, len ); | |
441 return 0; | |
372 } | 442 } |
373 | 443 |
374 int DWSIGNAL redraw_button_box_callback(HWND window, void *data) | 444 int DWSIGNAL redraw_button_box_callback(HWND window, void *data) |
375 { | 445 { |
376 #if 0 | 446 #if 0 |
377 dw_window_destroy( filetoolbarbox ); | 447 dw_window_destroy( filetoolbarbox ); |
378 create_button(1); | 448 create_button(1); |
379 #else | 449 #else |
380 dw_window_enable( window); | 450 dw_window_enable( window); |
381 #endif | 451 #endif |
382 return 0; | 452 return 0; |
383 } | 453 } |
384 | 454 |
385 /* Callback to handle user selection of the scrollbar position */ | 455 /* Callback to handle user selection of the scrollbar position */ |
386 void DWSIGNAL scrollbar_valuechanged(HWND hwnd, int value, void *data) | 456 void DWSIGNAL scrollbar_valuechanged_callback(HWND hwnd, int value, void *data) |
387 { | 457 { |
388 if(data) | 458 if(data) |
389 { | 459 { |
390 HWND stext = (HWND)data; | 460 HWND stext = (HWND)data; |
391 char tmpbuf[100]; | 461 char tmpbuf[100]; |
392 if ( hwnd == vscrollbar ) | 462 if ( hwnd == vscrollbar ) |
393 { | 463 { |
394 current_row = value; | 464 current_row = value; |
395 } | 465 } |
396 else | 466 else |
397 { | 467 { |
398 current_col = value; | 468 current_col = value; |
399 } | 469 } |
400 sprintf(tmpbuf, "Row:%d Col:%d Lines:%d Cols:%d", current_row,current_col,num_lines,max_linewidth); | 470 sprintf(tmpbuf, "Row:%d Col:%d Lines:%d Cols:%d", current_row,current_col,num_lines,max_linewidth); |
401 dw_window_set_text(stext, tmpbuf); | 471 dw_window_set_text(stext, tmpbuf); |
402 draw_file( current_row, current_col); | 472 draw_file( current_row, current_col); |
403 } | 473 } |
404 } | 474 } |
405 | 475 |
406 /* Callback to handle user selection of the spinbutton position */ | 476 /* Callback to handle user selection of the spinbutton position */ |
407 void DWSIGNAL spinbutton_valuechanged(HWND hwnd, int value, void *data) | 477 void DWSIGNAL spinbutton_valuechanged_callback(HWND hwnd, int value, void *data) |
408 { | 478 { |
409 dw_messagebox("DWTest", DW_MB_OK, "New value from spinbutton: %d\n", value); | 479 dw_messagebox("DWTest", DW_MB_OK, "New value from spinbutton: %d\n", value); |
410 } | 480 } |
411 | 481 |
412 /* Handle size change of the main render window */ | 482 /* Handle size change of the main render window */ |
413 int DWSIGNAL configure_event(HWND hwnd, int width, int height, void *data) | 483 int DWSIGNAL configure_event(HWND hwnd, int width, int height, void *data) |
414 { | 484 { |
415 HPIXMAP old1 = text1pm, old2 = text2pm; | 485 HPIXMAP old1 = text1pm, old2 = text2pm; |
416 int depth = dw_color_depth_get(); | 486 int depth = dw_color_depth_get(); |
417 | 487 |
418 rows = height / font_height; | 488 rows = height / font_height; |
419 cols = width / font_width; | 489 cols = width / font_width; |
420 | 490 |
421 /* Create new pixmaps with the current sizes */ | 491 /* Create new pixmaps with the current sizes */ |
422 text1pm = dw_pixmap_new(textbox1, (font_width*(width1)), height, depth); | 492 text1pm = dw_pixmap_new(textbox1, (font_width*(width1)), height, depth); |
423 text2pm = dw_pixmap_new(textbox2, width, height, depth); | 493 text2pm = dw_pixmap_new(textbox2, width, height, depth); |
424 | 494 |
425 /* Destroy the old pixmaps */ | 495 /* Destroy the old pixmaps */ |
426 dw_pixmap_destroy(old1); | 496 dw_pixmap_destroy(old1); |
427 dw_pixmap_destroy(old2); | 497 dw_pixmap_destroy(old2); |
428 | 498 |
429 /* Update scrollbar ranges with new values */ | 499 /* Update scrollbar ranges with new values */ |
430 dw_scrollbar_set_range(hscrollbar, max_linewidth, cols); | 500 dw_scrollbar_set_range(hscrollbar, max_linewidth, cols); |
431 dw_scrollbar_set_range(vscrollbar, num_lines, rows); | 501 dw_scrollbar_set_range(vscrollbar, num_lines, rows); |
432 | 502 |
433 /* Redraw the window */ | 503 /* Redraw the window */ |
434 draw_file( current_row, current_col); | 504 draw_file( current_row, current_col); |
435 return TRUE; | 505 return TRUE; |
436 } | 506 } |
437 | 507 |
438 int DWSIGNAL item_enter_cb( HWND window, char *text, void *data ) | 508 int DWSIGNAL item_enter_cb( HWND window, char *text, void *data ) |
439 { | 509 { |
440 char buf[200]; | 510 char buf[200]; |
441 HWND statline = (HWND)data; | 511 HWND statline = (HWND)data; |
442 | 512 |
443 sprintf(buf,"DW_SIGNAL_ITEM_ENTER: Window: %x Text: %s", (unsigned int)window, text ); | 513 sprintf(buf,"DW_SIGNAL_ITEM_ENTER: Window: %x Text: %s", (unsigned int)window, text ); |
444 dw_window_set_text( statline, buf); | 514 dw_window_set_text( statline, buf); |
445 return 0; | 515 return 0; |
446 } | 516 } |
447 | 517 |
448 int DWSIGNAL item_context_cb( HWND window, char *text, int x, int y, void *data, void *itemdata ) | 518 int DWSIGNAL item_context_cb( HWND window, char *text, int x, int y, void *data, void *itemdata ) |
449 { | 519 { |
450 char buf[200]; | 520 char buf[200]; |
451 HWND statline = (HWND)data; | 521 HWND statline = (HWND)data; |
452 | 522 |
453 sprintf(buf,"DW_SIGNAL_ITEM_CONTEXT: Window: %x Text: %s x: %d y: %d Itemdata: %x", (unsigned int)window, text, x, y, (unsigned int)itemdata ); | 523 sprintf(buf,"DW_SIGNAL_ITEM_CONTEXT: Window: %x Text: %s x: %d y: %d Itemdata: %x", (unsigned int)window, text, x, y, (unsigned int)itemdata ); |
454 dw_window_set_text( statline, buf); | 524 dw_window_set_text( statline, buf); |
455 return 0; | 525 return 0; |
456 } | 526 } |
457 | 527 |
458 int DWSIGNAL list_select_cb( HWND window, int item, void *data ) | 528 int DWSIGNAL list_select_cb( HWND window, int item, void *data ) |
459 { | 529 { |
460 char buf[200]; | 530 char buf[200]; |
461 HWND statline = (HWND)data; | 531 HWND statline = (HWND)data; |
462 | 532 |
463 sprintf(buf,"DW_SIGNAL_LIST_SELECT: Window: %d Item: %d", (unsigned int)window, item ); | 533 sprintf(buf,"DW_SIGNAL_LIST_SELECT: Window: %d Item: %d", (unsigned int)window, item ); |
464 dw_window_set_text( statline, buf); | 534 dw_window_set_text( statline, buf); |
465 return 0; | 535 return 0; |
466 } | 536 } |
467 | 537 |
468 int DWSIGNAL item_select_cb( HWND window, HTREEITEM item, char *text, void *data, void *itemdata ) | 538 int DWSIGNAL item_select_cb( HWND window, HTREEITEM item, char *text, void *data, void *itemdata ) |
469 { | 539 { |
470 char buf[200]; | 540 char buf[200]; |
471 HWND statline = (HWND)data; | 541 HWND statline = (HWND)data; |
472 | 542 |
473 sprintf(buf,"DW_SIGNAL_ITEM_SELECT: Window: %x Item: %x Text: %s Itemdata: %x", (unsigned int)window, (unsigned int)item, text, (unsigned int)itemdata ); | 543 sprintf(buf,"DW_SIGNAL_ITEM_SELECT: Window: %x Item: %x Text: %s Itemdata: %x", (unsigned int)window, (unsigned int)item, text, (unsigned int)itemdata ); |
474 dw_window_set_text( statline, buf); | 544 dw_window_set_text( statline, buf); |
475 return 0; | 545 return 0; |
476 } | 546 } |
477 | 547 |
478 int DWSIGNAL container_select_cb( HWND window, HTREEITEM item, char *text, void *data, void *itemdata ) | 548 int DWSIGNAL container_select_cb( HWND window, HTREEITEM item, char *text, void *data, void *itemdata ) |
479 { | 549 { |
480 char buf[200]; | 550 char buf[200]; |
481 char *str; | 551 char *str; |
482 HWND statline = (HWND)data; | 552 HWND statline = (HWND)data; |
483 unsigned long size; | 553 unsigned long size; |
484 | 554 |
485 sprintf(buf,"DW_SIGNAL_ITEM_SELECT: Window: %x Item: %x Text: %s Itemdata: %x", (unsigned int)window, (unsigned int)item, text, (unsigned int)itemdata ); | 555 sprintf(buf,"DW_SIGNAL_ITEM_SELECT: Window: %x Item: %x Text: %s Itemdata: %x", (unsigned int)window, (unsigned int)item, text, (unsigned int)itemdata ); |
486 dw_window_set_text( statline, buf); | 556 dw_window_set_text( statline, buf); |
487 sprintf(buf,"\r\nDW_SIGNAL_ITEM_SELECT: Window: %x Item: %x Text: %s Itemdata: %x\r\n", (unsigned int)window, (unsigned int)item, text, (unsigned int)itemdata ); | 557 sprintf(buf,"\r\nDW_SIGNAL_ITEM_SELECT: Window: %x Item: %x Text: %s Itemdata: %x\r\n", (unsigned int)window, (unsigned int)item, text, (unsigned int)itemdata ); |
488 mle_point = dw_mle_import( container_mle, buf, mle_point); | 558 mle_point = dw_mle_import( container_mle, buf, mle_point); |
489 str = dw_container_query_start(container, DW_CRA_SELECTED); | 559 str = dw_container_query_start(container, DW_CRA_SELECTED); |
490 while(str) | 560 while(str) |
491 { | 561 { |
492 sprintf(buf,"Selected: %s\r\n", str); | 562 sprintf(buf,"Selected: %s\r\n", str); |
493 mle_point = dw_mle_import( container_mle, buf, mle_point); | 563 mle_point = dw_mle_import( container_mle, buf, mle_point); |
494 str = dw_container_query_next(container, DW_CRA_SELECTED); | 564 str = dw_container_query_next(container, DW_CRA_SELECTED); |
495 } | 565 } |
496 /* Make the last inserted point the cursor location */ | 566 /* Make the last inserted point the cursor location */ |
497 dw_mle_set_cursor(container_mle, mle_point); | 567 dw_mle_set_cursor(container_mle, mle_point); |
498 /* set the details of item 0 to new data */ | 568 /* set the details of item 0 to new data */ |
499 fprintf(stderr,"In cb: container: %x containerinfo: %x icon: %x\n", (int)container, (int)containerinfo, (int)fileicon); | 569 fprintf(stderr,"In cb: container: %x containerinfo: %x icon: %x\n", (int)container, (int)containerinfo, (int)fileicon); |
500 dw_filesystem_change_file(container, 0, "new data", fileicon); | 570 dw_filesystem_change_file(container, 0, "new data", fileicon); |
501 size = 999; | 571 size = 999; |
502 fprintf(stderr,"In cb: container: %x containerinfo: %x icon: %x\n", (int)container, (int)containerinfo, (int)fileicon); | 572 fprintf(stderr,"In cb: container: %x containerinfo: %x icon: %x\n", (int)container, (int)containerinfo, (int)fileicon); |
503 dw_filesystem_change_item(container, 0, 0, &size); | 573 dw_filesystem_change_item(container, 0, 0, &size); |
504 return 0; | 574 return 0; |
505 } | 575 } |
506 | 576 |
507 int DWSIGNAL switch_page_cb( HWND window, unsigned long page_num, void *itemdata ) | 577 int DWSIGNAL switch_page_cb( HWND window, unsigned long page_num, void *itemdata ) |
508 { | 578 { |
509 FILE *fp=fopen("log","a"); | 579 FILE *fp=fopen("log","a"); |
510 fprintf(fp,"DW_SIGNAL_SWITCH_PAGE: Window: %x PageNum: %u Itemdata: %x\n", (unsigned int)window, (unsigned int)page_num, (unsigned int)itemdata ); | 580 fprintf(fp,"DW_SIGNAL_SWITCH_PAGE: Window: %x PageNum: %u Itemdata: %x\n", (unsigned int)window, (unsigned int)page_num, (unsigned int)itemdata ); |
511 fclose(fp); | 581 fclose(fp); |
512 return 0; | 582 return 0; |
513 } | 583 } |
514 | 584 |
515 int DWSIGNAL column_click_cb( HWND window, int column_num, void *data ) | 585 int DWSIGNAL column_click_cb( HWND window, int column_num, void *data ) |
516 { | 586 { |
517 char buf[200], buf1[100]; | 587 char buf[200], buf1[100]; |
518 HWND statline = (HWND)data; | 588 HWND statline = (HWND)data; |
519 int column_type; | 589 int column_type; |
520 | 590 |
521 if(column_num == 0) | 591 if(column_num == 0) |
522 strcpy(buf1,"Filename"); | 592 strcpy(buf1,"Filename"); |
523 else | 593 else |
524 { | 594 { |
525 column_type = dw_filesystem_get_column_type( window, column_num-1 ); | 595 column_type = dw_filesystem_get_column_type( window, column_num-1 ); |
526 if( column_type == DW_CFA_STRING) | 596 if( column_type == DW_CFA_STRING) |
527 strcpy(buf1,"String"); | 597 strcpy(buf1,"String"); |
528 else if( column_type == DW_CFA_ULONG) | 598 else if( column_type == DW_CFA_ULONG) |
529 strcpy(buf1,"ULong"); | 599 strcpy(buf1,"ULong"); |
530 else if( column_type == DW_CFA_DATE) | 600 else if( column_type == DW_CFA_DATE) |
531 strcpy(buf1,"Date"); | 601 strcpy(buf1,"Date"); |
532 else if( column_type == DW_CFA_TIME) | 602 else if( column_type == DW_CFA_TIME) |
533 strcpy(buf1,"Time"); | 603 strcpy(buf1,"Time"); |
534 else if( column_type == DW_CFA_BITMAPORICON) | 604 else if( column_type == DW_CFA_BITMAPORICON) |
535 strcpy(buf1,"BitmapOrIcon"); | 605 strcpy(buf1,"BitmapOrIcon"); |
536 else | 606 else |
537 strcpy(buf1,"Unknown"); | 607 strcpy(buf1,"Unknown"); |
538 } | 608 } |
539 sprintf(buf,"DW_SIGNAL_COLUMN_CLICK: Window: %x Column: %d Type: %s Itemdata: %x", (unsigned int)window, column_num, buf1, (unsigned int)data ); | 609 sprintf(buf,"DW_SIGNAL_COLUMN_CLICK: Window: %x Column: %d Type: %s Itemdata: %x", (unsigned int)window, column_num, buf1, (unsigned int)data ); |
540 dw_window_set_text( statline, buf); | 610 dw_window_set_text( statline, buf); |
541 return 0; | 611 return 0; |
542 } | 612 } |
543 | 613 |
544 int DWSIGNAL combobox_select_event_callback(HWND window, int index) | 614 int DWSIGNAL combobox_select_event_callback(HWND window, int index) |
545 { | 615 { |
546 fprintf(stderr,"got combobox_select_event for index: %d, iteration: %d\n", index, iteration++); | 616 fprintf(stderr,"got combobox_select_event for index: %d, iteration: %d\n", index, iteration++); |
547 return FALSE; | 617 return FALSE; |
548 } | 618 } |
549 | 619 |
550 void archive_add(void) | 620 void archive_add(void) |
551 { | 621 { |
552 HWND browsebutton, browsebox; | 622 HWND browsebutton, browsebox; |
553 | 623 |
554 lbbox = dw_box_new(BOXVERT, 10); | 624 lbbox = dw_box_new(BOXVERT, 10); |
555 | 625 |
556 dw_box_pack_start(notebookbox1, lbbox, 150, 70, TRUE, TRUE, 0); | 626 dw_box_pack_start(notebookbox1, lbbox, 150, 70, TRUE, TRUE, 0); |
557 | 627 |
558 /* Archive Name */ | 628 /* Archive Name */ |
559 stext = dw_text_new("File to browse", 0); | 629 stext = dw_text_new("File to browse", 0); |
560 | 630 |
561 dw_window_set_style(stext, DW_DT_VCENTER, DW_DT_VCENTER); | 631 dw_window_set_style(stext, DW_DT_VCENTER, DW_DT_VCENTER); |
562 | 632 |
563 dw_box_pack_start(lbbox, stext, 130, 15, TRUE, TRUE, 2); | 633 dw_box_pack_start(lbbox, stext, 130, 15, TRUE, TRUE, 2); |
564 | 634 |
565 browsebox = dw_box_new(BOXHORZ, 0); | 635 browsebox = dw_box_new(BOXHORZ, 0); |
566 | 636 |
567 dw_box_pack_start(lbbox, browsebox, 0, 0, TRUE, TRUE, 0); | 637 dw_box_pack_start(lbbox, browsebox, 0, 0, TRUE, TRUE, 0); |
568 | 638 |
569 entryfield = dw_entryfield_new("", 100L); | 639 entryfield = dw_entryfield_new("", 100L); |
570 | 640 |
571 dw_entryfield_set_limit(entryfield, 260); | 641 dw_entryfield_set_limit(entryfield, 260); |
572 | 642 |
573 dw_box_pack_start(browsebox, entryfield, 100, 15, TRUE, TRUE, 4); | 643 dw_box_pack_start(browsebox, entryfield, 100, 15, TRUE, TRUE, 4); |
574 | 644 |
575 browsebutton = dw_button_new("Browse", 1001L); | 645 browsebutton = dw_button_new("Browse", 1001L); |
576 | 646 |
577 dw_box_pack_start(browsebox, browsebutton, 30, 15, TRUE, TRUE, 0); | 647 dw_box_pack_start(browsebox, browsebutton, 30, 15, TRUE, TRUE, 0); |
578 | 648 |
579 dw_window_set_color(browsebox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); | 649 dw_window_set_color(browsebox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); |
580 dw_window_set_color(stext, DW_CLR_BLACK, DW_CLR_PALEGRAY); | 650 dw_window_set_color(stext, DW_CLR_BLACK, DW_CLR_PALEGRAY); |
581 | 651 |
582 /* Buttons */ | 652 /* Buttons */ |
583 buttonbox = dw_box_new(BOXHORZ, 10); | 653 buttonbox = dw_box_new(BOXHORZ, 10); |
584 | 654 |
585 dw_box_pack_start(lbbox, buttonbox, 0, 0, TRUE, TRUE, 0); | 655 dw_box_pack_start(lbbox, buttonbox, 0, 0, TRUE, TRUE, 0); |
586 | 656 |
587 cursortogglebutton = dw_button_new("Set Cursor pointer - CLOCK", 1003L); | 657 cursortogglebutton = dw_button_new("Set Cursor pointer - CLOCK", 1003L); |
588 dw_box_pack_start(buttonbox, cursortogglebutton, 130, 30, TRUE, TRUE, 2); | 658 dw_box_pack_start(buttonbox, cursortogglebutton, 130, 30, TRUE, TRUE, 2); |
589 | 659 |
590 colorchoosebutton = dw_button_new("Color Chooser Dialog", 1004L); | 660 colorchoosebutton = dw_button_new("Color Chooser Dialog", 1004L); |
591 dw_box_pack_start(buttonbox, colorchoosebutton, 130, 30, TRUE, TRUE, 2); | 661 dw_box_pack_start(buttonbox, colorchoosebutton, 130, 30, TRUE, TRUE, 2); |
592 | 662 |
593 okbutton = dw_button_new("Turn Off Annoying Beep!", 1001L); | 663 okbutton = dw_button_new("Turn Off Annoying Beep!", 1001L); |
594 dw_box_pack_start(buttonbox, okbutton, 130, 30, TRUE, TRUE, 2); | 664 dw_box_pack_start(buttonbox, okbutton, 130, 30, TRUE, TRUE, 2); |
595 | 665 |
596 cancelbutton = dw_button_new("Exit", 1002L); | 666 cancelbutton = dw_button_new("Exit", 1002L); |
597 dw_box_pack_start(buttonbox, cancelbutton, 130, 30, TRUE, TRUE, 2); | 667 dw_box_pack_start(buttonbox, cancelbutton, 130, 30, TRUE, TRUE, 2); |
598 | 668 dw_window_click_default( mainwindow, cancelbutton ); |
599 /* Set some nice fonts and colors */ | 669 |
600 dw_window_set_color(lbbox, DW_CLR_DARKCYAN, DW_CLR_PALEGRAY); | 670 /* Set some nice fonts and colors */ |
601 dw_window_set_color(buttonbox, DW_CLR_DARKCYAN, DW_CLR_PALEGRAY); | 671 dw_window_set_color(lbbox, DW_CLR_DARKCYAN, DW_CLR_PALEGRAY); |
602 dw_window_set_color(okbutton, DW_CLR_PALEGRAY, DW_CLR_DARKCYAN); | 672 dw_window_set_color(buttonbox, DW_CLR_DARKCYAN, DW_CLR_PALEGRAY); |
603 | 673 dw_window_set_color(okbutton, DW_CLR_PALEGRAY, DW_CLR_DARKCYAN); |
604 dw_signal_connect(browsebutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(browse_callback), (void *)notebookbox1); | 674 |
605 dw_signal_connect(okbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(beep_callback), (void *)notebookbox1); | 675 dw_signal_connect(browsebutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(browse_callback), (void *)notebookbox1); |
606 dw_signal_connect(cancelbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(exit_callback), (void *)mainwindow); | 676 dw_signal_connect(okbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(beep_callback), (void *)notebookbox1); |
607 dw_signal_connect(cursortogglebutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(cursortoggle_callback), (void *)mainwindow); | 677 dw_signal_connect(cancelbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(exit_callback), (void *)mainwindow); |
608 dw_signal_connect(colorchoosebutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(colorchoose_callback), (void *)mainwindow); | 678 dw_signal_connect(cursortogglebutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(cursortoggle_callback), (void *)mainwindow); |
679 dw_signal_connect(colorchoosebutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(colorchoose_callback), (void *)mainwindow); | |
609 } | 680 } |
610 | 681 |
611 | 682 |
612 void text_add(void) | 683 void text_add(void) |
613 { | 684 { |
614 int depth = dw_color_depth_get(); | 685 int depth = dw_color_depth_get(); |
615 HWND vscrollbox; | 686 HWND vscrollbox; |
616 | 687 |
617 /* create a box to pack into the notebook page */ | 688 /* create a box to pack into the notebook page */ |
618 pagebox = dw_box_new(BOXHORZ, 2); | 689 pagebox = dw_box_new(BOXHORZ, 2); |
619 dw_box_pack_start( notebookbox2, pagebox, 0, 0, TRUE, TRUE, 0); | 690 dw_box_pack_start( notebookbox2, pagebox, 0, 0, TRUE, TRUE, 0); |
620 /* now a status area under this box */ | 691 /* now a status area under this box */ |
621 status = dw_status_text_new("", 0); | 692 status = dw_status_text_new("", 0); |
622 dw_box_pack_start( notebookbox2, status, 100, 20, TRUE, FALSE, 1); | 693 dw_box_pack_start( notebookbox2, status, 100, 20, TRUE, FALSE, 1); |
623 /* and another one */ | 694 /* and another one */ |
624 status1 = dw_status_text_new("", 0); | 695 status1 = dw_status_text_new("", 0); |
625 dw_box_pack_start( notebookbox2, status1, 100, 20, TRUE, FALSE, 1); | 696 dw_box_pack_start( notebookbox2, status1, 100, 20, TRUE, FALSE, 1); |
626 | 697 |
627 /* create render box for number pixmap */ | 698 /* create render box for number pixmap */ |
628 textbox1 = dw_render_new( 100 ); | 699 textbox1 = dw_render_new( 100 ); |
629 dw_window_set_font(textbox1, FIXEDFONT); | 700 dw_window_set_font(textbox1, FIXEDFONT); |
630 dw_font_text_extents_get(textbox1, NULL, "(g", &font_width, &font_height); | 701 dw_font_text_extents_get(textbox1, NULL, "(g", &font_width, &font_height); |
631 font_width = font_width / 2; | 702 font_width = font_width / 2; |
632 vscrollbox = dw_box_new(BOXVERT, 0); | 703 vscrollbox = dw_box_new(BOXVERT, 0); |
633 dw_box_pack_start(vscrollbox, textbox1, font_width*width1, font_height*rows, FALSE, TRUE, 0); | 704 dw_box_pack_start(vscrollbox, textbox1, font_width*width1, font_height*rows, FALSE, TRUE, 0); |
634 dw_box_pack_start(vscrollbox, 0, (font_width*(width1+1)), SCROLLBARWIDTH, FALSE, FALSE, 0); | 705 dw_box_pack_start(vscrollbox, 0, (font_width*(width1+1)), SCROLLBARWIDTH, FALSE, FALSE, 0); |
635 dw_box_pack_start(pagebox, vscrollbox, 0, 0, FALSE, TRUE, 0); | 706 dw_box_pack_start(pagebox, vscrollbox, 0, 0, FALSE, TRUE, 0); |
636 | 707 |
637 /* pack empty space 1 character wide */ | 708 /* pack empty space 1 character wide */ |
638 dw_box_pack_start(pagebox, 0, font_width, 0, FALSE, TRUE, 0); | 709 dw_box_pack_start(pagebox, 0, font_width, 0, FALSE, TRUE, 0); |
639 | 710 |
640 /* create box for filecontents and horz scrollbar */ | 711 /* create box for filecontents and horz scrollbar */ |
641 textboxA = dw_box_new( BOXVERT,0 ); | 712 textboxA = dw_box_new( BOXVERT,0 ); |
642 dw_box_pack_start( pagebox, textboxA, 0, 0, TRUE, TRUE, 0); | 713 dw_box_pack_start( pagebox, textboxA, 0, 0, TRUE, TRUE, 0); |
643 | 714 |
644 /* create render box for filecontents pixmap */ | 715 /* create render box for filecontents pixmap */ |
645 textbox2 = dw_render_new( 101 ); | 716 textbox2 = dw_render_new( 101 ); |
646 dw_box_pack_start( textboxA, textbox2, 10, 10, TRUE, TRUE, 0); | 717 dw_box_pack_start( textboxA, textbox2, 10, 10, TRUE, TRUE, 0); |
647 dw_window_set_font(textbox2, FIXEDFONT); | 718 dw_window_set_font(textbox2, FIXEDFONT); |
648 /* create horizonal scrollbar */ | 719 /* create horizonal scrollbar */ |
649 hscrollbar = dw_scrollbar_new(FALSE, 50); | 720 hscrollbar = dw_scrollbar_new(FALSE, 50); |
650 dw_box_pack_start( textboxA, hscrollbar, 100, SCROLLBARWIDTH, TRUE, FALSE, 0); | 721 dw_box_pack_start( textboxA, hscrollbar, 100, SCROLLBARWIDTH, TRUE, FALSE, 0); |
651 | 722 |
652 /* create vertical scrollbar */ | 723 /* create vertical scrollbar */ |
653 vscrollbox = dw_box_new(BOXVERT, 0); | 724 vscrollbox = dw_box_new(BOXVERT, 0); |
654 vscrollbar = dw_scrollbar_new(TRUE, 50); | 725 vscrollbar = dw_scrollbar_new(TRUE, 50); |
655 dw_box_pack_start(vscrollbox, vscrollbar, SCROLLBARWIDTH, 100, FALSE, TRUE, 0); | 726 dw_box_pack_start(vscrollbox, vscrollbar, SCROLLBARWIDTH, 100, FALSE, TRUE, 0); |
656 /* Pack an area of empty space 14x14 pixels */ | 727 /* Pack an area of empty space 14x14 pixels */ |
657 dw_box_pack_start(vscrollbox, 0, SCROLLBARWIDTH, SCROLLBARWIDTH, FALSE, FALSE, 0); | 728 dw_box_pack_start(vscrollbox, 0, SCROLLBARWIDTH, SCROLLBARWIDTH, FALSE, FALSE, 0); |
658 dw_box_pack_start(pagebox, vscrollbox, 0, 0, FALSE, TRUE, 0); | 729 dw_box_pack_start(pagebox, vscrollbox, 0, 0, FALSE, TRUE, 0); |
659 | 730 |
660 text1pm = dw_pixmap_new( textbox1, font_width*width1, font_height*rows, depth ); | 731 text1pm = dw_pixmap_new( textbox1, font_width*width1, font_height*rows, depth ); |
661 text2pm = dw_pixmap_new( textbox2, font_width*cols, font_height*rows, depth ); | 732 text2pm = dw_pixmap_new( textbox2, font_width*cols, font_height*rows, depth ); |
662 | 733 |
663 dw_messagebox("DWTest", DW_MB_OK|DW_MB_INFORMATION, "Width: %d Height: %d\n", font_width, font_height); | 734 dw_messagebox("DWTest", DW_MB_OK|DW_MB_INFORMATION, "Width: %d Height: %d\n", font_width, font_height); |
664 dw_draw_rect(0, text1pm, TRUE, 0, 0, font_width*width1, font_height*rows); | 735 dw_draw_rect(0, text1pm, TRUE, 0, 0, font_width*width1, font_height*rows); |
665 dw_draw_rect(0, text2pm, TRUE, 0, 0, font_width*cols, font_height*rows); | 736 dw_draw_rect(0, text2pm, TRUE, 0, 0, font_width*cols, font_height*rows); |
666 dw_signal_connect(textbox1, DW_SIGNAL_EXPOSE, DW_SIGNAL_FUNC(text_expose), NULL); | 737 dw_signal_connect(textbox1, DW_SIGNAL_EXPOSE, DW_SIGNAL_FUNC(text_expose), NULL); |
667 dw_signal_connect(textbox2, DW_SIGNAL_EXPOSE, DW_SIGNAL_FUNC(text_expose), NULL); | 738 dw_signal_connect(textbox2, DW_SIGNAL_EXPOSE, DW_SIGNAL_FUNC(text_expose), NULL); |
668 dw_signal_connect(textbox2, DW_SIGNAL_CONFIGURE, DW_SIGNAL_FUNC(configure_event), text2pm); | 739 dw_signal_connect(textbox2, DW_SIGNAL_CONFIGURE, DW_SIGNAL_FUNC(configure_event), text2pm); |
669 dw_signal_connect(hscrollbar, DW_SIGNAL_VALUE_CHANGED, DW_SIGNAL_FUNC(scrollbar_valuechanged), (void *)status); | 740 dw_signal_connect(hscrollbar, DW_SIGNAL_VALUE_CHANGED, DW_SIGNAL_FUNC(scrollbar_valuechanged_callback), (void *)status); |
670 dw_signal_connect(vscrollbar, DW_SIGNAL_VALUE_CHANGED, DW_SIGNAL_FUNC(scrollbar_valuechanged), (void *)status); | 741 dw_signal_connect(vscrollbar, DW_SIGNAL_VALUE_CHANGED, DW_SIGNAL_FUNC(scrollbar_valuechanged_callback), (void *)status); |
671 | 742 |
672 dw_signal_connect(mainwindow, DW_SIGNAL_KEY_PRESS, DW_SIGNAL_FUNC(keypress_callback), NULL); | 743 dw_signal_connect(mainwindow, DW_SIGNAL_KEY_PRESS, DW_SIGNAL_FUNC(keypress_callback), NULL); |
673 } | 744 } |
674 | 745 |
675 void tree_add(void) | 746 void tree_add(void) |
676 { | 747 { |
677 HTREEITEM t1,t2,t3,t4,t5,t6; | 748 HTREEITEM t1,t2,t3,t4,t5,t6; |
678 | 749 |
679 /* create a box to pack into the notebook page */ | 750 /* create a box to pack into the notebook page */ |
680 treebox = dw_box_new(BOXHORZ, 2); | 751 treebox = dw_box_new(BOXHORZ, 2); |
681 dw_box_pack_start( notebookbox3, treebox, 500, 200, TRUE, TRUE, 0); | 752 dw_box_pack_start( notebookbox3, treebox, 500, 200, TRUE, TRUE, 0); |
682 | 753 |
683 /* now a tree area under this box */ | 754 /* now a tree area under this box */ |
684 tree = dw_tree_new(101); | 755 tree = dw_tree_new(101); |
685 dw_box_pack_start( notebookbox3, tree, 500, 200, TRUE, FALSE, 1); | 756 dw_box_pack_start( notebookbox3, tree, 500, 200, TRUE, FALSE, 1); |
686 | 757 |
687 /* and a status area to see whats going on */ | 758 /* and a status area to see whats going on */ |
688 tree_status = dw_status_text_new("", 0); | 759 tree_status = dw_status_text_new("", 0); |
689 dw_box_pack_start( notebookbox3, tree_status, 100, 20, TRUE, FALSE, 1); | 760 dw_box_pack_start( notebookbox3, tree_status, 100, 20, TRUE, FALSE, 1); |
690 | 761 |
691 foldericon = dw_icon_load_from_file( FOLDER_ICON_NAME ); | 762 foldericon = dw_icon_load_from_file( FOLDER_ICON_NAME ); |
692 fileicon = dw_icon_load_from_file( FILE_ICON_NAME ); | 763 fileicon = dw_icon_load_from_file( FILE_ICON_NAME ); |
693 | 764 |
694 /* set up our signal trappers... */ | 765 /* set up our signal trappers... */ |
695 dw_signal_connect(tree, DW_SIGNAL_ITEM_CONTEXT, DW_SIGNAL_FUNC(item_context_cb), (void *)tree_status); | 766 dw_signal_connect(tree, DW_SIGNAL_ITEM_CONTEXT, DW_SIGNAL_FUNC(item_context_cb), (void *)tree_status); |
696 dw_signal_connect(tree, DW_SIGNAL_ITEM_SELECT, DW_SIGNAL_FUNC(item_select_cb), (void *)tree_status); | 767 dw_signal_connect(tree, DW_SIGNAL_ITEM_SELECT, DW_SIGNAL_FUNC(item_select_cb), (void *)tree_status); |
697 | 768 |
698 t1 = dw_tree_insert(tree, "tree folder 1", foldericon, NULL, (void *)1 ); | 769 t1 = dw_tree_insert(tree, "tree folder 1", foldericon, NULL, (void *)1 ); |
699 t2 = dw_tree_insert(tree, "tree folder 2", foldericon, NULL, (void *)2 ); | 770 t2 = dw_tree_insert(tree, "tree folder 2", foldericon, NULL, (void *)2 ); |
700 t3 = dw_tree_insert(tree, "tree file 1", fileicon, t1, (void *)3 ); | 771 t3 = dw_tree_insert(tree, "tree file 1", fileicon, t1, (void *)3 ); |
701 t4 = dw_tree_insert(tree, "tree file 2", fileicon, t1, (void *)4 ); | 772 t4 = dw_tree_insert(tree, "tree file 2", fileicon, t1, (void *)4 ); |
702 t5 = dw_tree_insert(tree, "tree file 3", fileicon, t2, (void *)5 ); | 773 t5 = dw_tree_insert(tree, "tree file 3", fileicon, t2, (void *)5 ); |
703 t6 = dw_tree_insert(tree, "tree file 4", fileicon, t2, (void *)6 ); | 774 t6 = dw_tree_insert(tree, "tree file 4", fileicon, t2, (void *)6 ); |
704 /* set the folder name and icon again to show error with dw_tree_item_change under GTK 2.0 */ | 775 /* set the folder name and icon again to show error with dw_tree_item_change under GTK 2.0 */ |
705 dw_tree_item_change(tree, t1, "tree folder 1", foldericon ); | 776 dw_tree_item_change(tree, t1, "tree folder 1", foldericon ); |
706 dw_tree_item_change(tree, t2, "tree folder 2", foldericon ); | 777 dw_tree_item_change(tree, t2, "tree folder 2", foldericon ); |
707 } | 778 } |
708 | 779 |
709 void container_add(void) | 780 void container_add(void) |
710 { | 781 { |
711 char *titles[3]; | 782 char *titles[3]; |
712 char *names[3]; | 783 char *names[3]; |
713 char buffer[100]; | 784 char buffer[100]; |
714 unsigned long flags[3] = { DW_CFA_ULONG | DW_CFA_RIGHT | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR, | 785 unsigned long flags[3] = { DW_CFA_ULONG | DW_CFA_RIGHT | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR, |
715 DW_CFA_TIME | DW_CFA_CENTER | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR, | 786 DW_CFA_TIME | DW_CFA_CENTER | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR, |
716 DW_CFA_DATE | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR }; | 787 DW_CFA_DATE | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR }; |
717 int z; | 788 int z; |
718 CTIME time; | 789 CTIME time; |
719 CDATE date; | 790 CDATE date; |
720 unsigned long size, thisicon; | 791 unsigned long size, thisicon; |
721 | 792 |
722 /* create a box to pack into the notebook page */ | 793 /* create a box to pack into the notebook page */ |
723 containerbox = dw_box_new(BOXHORZ, 2); | 794 containerbox = dw_box_new(BOXHORZ, 2); |
724 dw_box_pack_start( notebookbox4, containerbox, 500, 200, TRUE, TRUE, 0); | 795 dw_box_pack_start( notebookbox4, containerbox, 500, 200, TRUE, TRUE, 0); |
725 | 796 |
726 /* now a container area under this box */ | 797 /* now a container area under this box */ |
727 container = dw_container_new(100, TRUE); | 798 container = dw_container_new(100, TRUE); |
728 dw_box_pack_start( notebookbox4, container, 500, 200, TRUE, FALSE, 1); | 799 dw_box_pack_start( notebookbox4, container, 500, 200, TRUE, FALSE, 1); |
729 | 800 |
730 /* and a status area to see whats going on */ | 801 /* and a status area to see whats going on */ |
731 container_status = dw_status_text_new("", 0); | 802 container_status = dw_status_text_new("", 0); |
732 dw_box_pack_start( notebookbox4, container_status, 100, 20, TRUE, FALSE, 1); | 803 dw_box_pack_start( notebookbox4, container_status, 100, 20, TRUE, FALSE, 1); |
733 | 804 |
734 titles[0] = "Size"; | 805 titles[0] = "Size"; |
735 titles[1] = "Time"; | 806 titles[1] = "Time"; |
736 titles[2] = "Date"; | 807 titles[2] = "Date"; |
737 | 808 |
738 dw_filesystem_setup(container, flags, titles, 3); | 809 dw_filesystem_setup(container, flags, titles, 3); |
739 containerinfo = dw_container_alloc(container, 3); | 810 containerinfo = dw_container_alloc(container, 3); |
740 | 811 |
741 for(z=0;z<3;z++) | 812 for(z=0;z<3;z++) |
742 { | 813 { |
743 names[z] = (char *)malloc( 100 ); | 814 names[z] = (char *)malloc( 100 ); |
744 /* yes, there is a memory leak here */ | 815 /* yes, there is a memory leak here */ |
745 sprintf(names[z],"Don't allocate from stack: Item: %d",z); | 816 sprintf(names[z],"Don't allocate from stack: Item: %d",z); |
746 size = z*100; | 817 size = z*100; |
747 sprintf(buffer, "Filename %d",z+1); | 818 sprintf(buffer, "Filename %d",z+1); |
748 if (z == 0 ) thisicon = foldericon; | 819 if (z == 0 ) thisicon = foldericon; |
749 else thisicon = fileicon; | 820 else thisicon = fileicon; |
750 fprintf(stderr,"Initial: container: %x containerinfo: %x icon: %x\n", (int)container, (int)containerinfo, (int)thisicon); | 821 fprintf(stderr,"Initial: container: %x containerinfo: %x icon: %x\n", (int)container, (int)containerinfo, (int)thisicon); |
751 dw_filesystem_set_file(container, containerinfo, z, buffer, thisicon); | 822 dw_filesystem_set_file(container, containerinfo, z, buffer, thisicon); |
752 dw_filesystem_set_item(container, containerinfo, 0, z, &size); | 823 dw_filesystem_set_item(container, containerinfo, 0, z, &size); |
753 | 824 |
754 time.seconds = z+10; | 825 time.seconds = z+10; |
755 time.minutes = z+10; | 826 time.minutes = z+10; |
756 time.hours = z+10; | 827 time.hours = z+10; |
757 dw_filesystem_set_item(container, containerinfo, 1, z, &time); | 828 dw_filesystem_set_item(container, containerinfo, 1, z, &time); |
758 | 829 |
759 date.day = z+10; | 830 date.day = z+10; |
760 date.month = z+10; | 831 date.month = z+10; |
761 date.year = z+2000; | 832 date.year = z+2000; |
762 dw_filesystem_set_item(container, containerinfo, 2, z, &date); | 833 dw_filesystem_set_item(container, containerinfo, 2, z, &date); |
763 | 834 |
764 dw_container_set_row_title(containerinfo, z, names[z]); | 835 dw_container_set_row_title(containerinfo, z, names[z]); |
765 } | 836 } |
766 | 837 |
767 dw_container_insert(container, containerinfo, 3); | 838 dw_container_insert(container, containerinfo, 3); |
768 dw_container_optimize(container); | 839 dw_container_optimize(container); |
769 | 840 |
770 container_mle = dw_mle_new( 111 ); | 841 container_mle = dw_mle_new( 111 ); |
771 dw_box_pack_start( containerbox, container_mle, 500, 200, TRUE, TRUE, 0); | 842 dw_box_pack_start( containerbox, container_mle, 500, 200, TRUE, TRUE, 0); |
772 | 843 |
773 /* connect our event trappers... */ | 844 /* connect our event trappers... */ |
774 dw_signal_connect(container, DW_SIGNAL_ITEM_ENTER, DW_SIGNAL_FUNC(item_enter_cb), (void *)container_status); | 845 dw_signal_connect(container, DW_SIGNAL_ITEM_ENTER, DW_SIGNAL_FUNC(item_enter_cb), (void *)container_status); |
775 dw_signal_connect(container, DW_SIGNAL_ITEM_CONTEXT, DW_SIGNAL_FUNC(item_context_cb), (void *)container_status); | 846 dw_signal_connect(container, DW_SIGNAL_ITEM_CONTEXT, DW_SIGNAL_FUNC(item_context_cb), (void *)container_status); |
776 dw_signal_connect(container, DW_SIGNAL_ITEM_SELECT, DW_SIGNAL_FUNC(container_select_cb), (void *)container_status); | 847 dw_signal_connect(container, DW_SIGNAL_ITEM_SELECT, DW_SIGNAL_FUNC(container_select_cb), (void *)container_status); |
777 dw_signal_connect(container, DW_SIGNAL_COLUMN_CLICK, DW_SIGNAL_FUNC(column_click_cb), (void *)container_status); | 848 dw_signal_connect(container, DW_SIGNAL_COLUMN_CLICK, DW_SIGNAL_FUNC(column_click_cb), (void *)container_status); |
778 } | 849 } |
779 | 850 |
780 /* Beep every second */ | 851 /* Beep every second */ |
781 int DWSIGNAL timer_callback(void *data) | 852 int DWSIGNAL timer_callback(void *data) |
782 { | 853 { |
783 dw_beep(200, 200); | 854 dw_beep(200, 200); |
784 | 855 |
785 /* Return TRUE so we get called again */ | 856 /* Return TRUE so we get called again */ |
786 return TRUE; | 857 return TRUE; |
787 } | 858 } |
788 | 859 |
789 | 860 |
790 void buttons_add(void) | 861 void buttons_add(void) |
791 { | 862 { |
792 HWND buttonsbox,abutton1,abutton2,cal,calbox; | 863 HWND buttonsbox,abutton1,abutton2,calbox,bw; |
793 int i; | 864 int i; |
794 char buf[20]; | 865 char buf[20]; |
795 char **text; | 866 char **text; |
796 | 867 |
797 /* create a box to pack into the notebook page */ | 868 /* create a box to pack into the notebook page */ |
798 buttonsbox = dw_box_new(BOXVERT, 2); | 869 buttonsbox = dw_box_new(BOXVERT, 2); |
799 dw_box_pack_start( notebookbox5, buttonsbox, 25, 200, TRUE, TRUE, 0); | 870 dw_box_pack_start( notebookbox5, buttonsbox, 25, 200, TRUE, TRUE, 0); |
800 dw_window_set_color(buttonsbox, DW_CLR_RED, DW_CLR_RED); | 871 dw_window_set_color(buttonsbox, DW_CLR_RED, DW_CLR_RED); |
801 | 872 |
802 calbox = dw_box_new(DW_HORZ, 0); | 873 calbox = dw_box_new(DW_HORZ, 0); |
803 dw_box_pack_start(notebookbox5, calbox, 500, 200, TRUE, TRUE, 1); | 874 dw_box_pack_start(notebookbox5, calbox, 500, 200, TRUE, TRUE, 1); |
804 cal = dw_calendar_new(100); | 875 cal = dw_calendar_new(100); |
805 dw_box_pack_start(calbox, cal, 180, 160, TRUE, TRUE, 0); | 876 dw_box_pack_start(calbox, cal, 180, 160, TRUE, TRUE, 0); |
806 dw_calendar_set_date(cal, 2001, 1, 1); | 877 /* |
878 dw_calendar_set_date(cal, 2001, 1, 1); | |
879 */ | |
807 /* | 880 /* |
808 * Create our file toolbar boxes... | 881 * Create our file toolbar boxes... |
809 */ | 882 */ |
810 buttonboxperm = dw_box_new( BOXVERT, 0 ); | 883 buttonboxperm = dw_box_new( BOXVERT, 0 ); |
811 dw_box_pack_start( buttonsbox, buttonboxperm, 25, 0, FALSE, TRUE, 2 ); | 884 dw_box_pack_start( buttonsbox, buttonboxperm, 25, 0, FALSE, TRUE, 2 ); |
812 dw_window_set_color(buttonboxperm, DW_CLR_WHITE, DW_CLR_WHITE); | 885 dw_window_set_color(buttonboxperm, DW_CLR_WHITE, DW_CLR_WHITE); |
813 abutton1 = dw_bitmapbutton_new_from_file( "Top", 0, FILE_ICON_NAME ); | 886 abutton1 = dw_bitmapbutton_new_from_file( "Top Button", 0, FILE_ICON_NAME ); |
814 dw_box_pack_start( buttonboxperm, abutton1, 25, 25, FALSE, FALSE, 0 ); | 887 dw_box_pack_start( buttonboxperm, abutton1, 100, 30, FALSE, FALSE, 0 ); |
815 dw_signal_connect( abutton1, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(button_callback), NULL ); | 888 dw_signal_connect( abutton1, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(button_callback), NULL ); |
816 dw_box_pack_start( buttonboxperm, 0, 25, 5, FALSE, FALSE, 0 ); | 889 dw_box_pack_start( buttonboxperm, 0, 25, 5, FALSE, FALSE, 0 ); |
817 abutton2 = dw_bitmapbutton_new_from_file( "Bottom", 0, FOLDER_ICON_NAME ); | 890 abutton2 = dw_bitmapbutton_new_from_file( "Bottom", 0, FOLDER_ICON_NAME ); |
818 dw_box_pack_start( buttonsbox, abutton2, 25, 25, FALSE, FALSE, 0 ); | 891 dw_box_pack_start( buttonsbox, abutton2, 25, 25, FALSE, FALSE, 0 ); |
819 dw_signal_connect( abutton2, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(button_callback), NULL ); | 892 dw_signal_connect( abutton2, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(button_callback), NULL ); |
820 | 893 |
821 create_button(0); | 894 create_button(0); |
822 /* make a combobox */ | 895 /* make a combobox */ |
823 combox = dw_box_new(BOXVERT, 2); | 896 combox = dw_box_new(BOXVERT, 2); |
824 dw_box_pack_start( notebookbox5, combox, 25, 200, TRUE, TRUE, 0); | 897 dw_box_pack_start( notebookbox5, combox, 25, 200, TRUE, TRUE, 0); |
825 combobox1 = dw_combobox_new( "fred", 0 ); /* no point in specifying an initial value */ | 898 combobox1 = dw_combobox_new( "fred", 0 ); /* no point in specifying an initial value */ |
826 dw_box_pack_start( combox, combobox1, 200, 20, TRUE, FALSE, 0); | 899 dw_listbox_append( combobox1, "fred" ); |
900 dw_box_pack_start( combox, combobox1, 200, 20, TRUE, FALSE, 0); | |
827 /* | 901 /* |
828 dw_window_set_text( combobox, "initial value"); | 902 dw_window_set_text( combobox, "initial value"); |
829 */ | 903 */ |
830 dw_signal_connect( combobox1, DW_SIGNAL_LIST_SELECT, DW_SIGNAL_FUNC(combobox_select_event_callback), NULL ); | 904 dw_signal_connect( combobox1, DW_SIGNAL_LIST_SELECT, DW_SIGNAL_FUNC(combobox_select_event_callback), NULL ); |
831 #if 0 | 905 #if 0 |
832 /* add LOTS of items */ | 906 /* add LOTS of items */ |
833 fprintf(stderr,"before appending 100 items to combobox using dw_listbox_append()\n"); | 907 fprintf(stderr,"before appending 100 items to combobox using dw_listbox_append()\n"); |
834 for( i = 0; i < 100; i++ ) | 908 for( i = 0; i < 100; i++ ) |
835 { | 909 { |
836 sprintf( buf, "item %d", i); | 910 sprintf( buf, "item %d", i); |
837 dw_listbox_append( combobox1, buf ); | 911 dw_listbox_append( combobox1, buf ); |
838 } | 912 } |
839 fprintf(stderr,"after appending 100 items to combobox\n"); | 913 fprintf(stderr,"after appending 100 items to combobox\n"); |
840 #endif | 914 #endif |
841 | 915 |
842 combobox2 = dw_combobox_new( "joe", 0 ); /* no point in specifying an initial value */ | 916 combobox2 = dw_combobox_new( "joe", 0 ); /* no point in specifying an initial value */ |
843 dw_box_pack_start( combox, combobox2, 200, 20, TRUE, FALSE, 0); | 917 dw_box_pack_start( combox, combobox2, 200, 20, TRUE, FALSE, 0); |
844 /* | 918 /* |
845 dw_window_set_text( combobox, "initial value"); | 919 dw_window_set_text( combobox, "initial value"); |
846 */ | 920 */ |
847 dw_signal_connect( combobox2, DW_SIGNAL_LIST_SELECT, DW_SIGNAL_FUNC(combobox_select_event_callback), NULL ); | 921 dw_signal_connect( combobox2, DW_SIGNAL_LIST_SELECT, DW_SIGNAL_FUNC(combobox_select_event_callback), NULL ); |
848 /* add LOTS of items */ | 922 /* add LOTS of items */ |
849 fprintf(stderr,"before appending 500 items to combobox using dw_listbox_list_append()\n"); | 923 fprintf(stderr,"before appending 500 items to combobox using dw_listbox_list_append()\n"); |
850 text = (char **)malloc(500*sizeof(char *)); | 924 text = (char **)malloc(500*sizeof(char *)); |
851 for( i = 0; i < 500; i++ ) | 925 for( i = 0; i < 500; i++ ) |
852 { | 926 { |
853 text[i] = (char *)malloc( 50 ); | 927 text[i] = (char *)malloc( 50 ); |
854 sprintf( text[i], "item %d", i); | 928 sprintf( text[i], "item %d", i); |
855 } | 929 } |
856 dw_listbox_list_append( combobox2, text, 500 ); | 930 dw_listbox_list_append( combobox2, text, 500 ); |
857 fprintf(stderr,"after appending 500 items to combobox\n"); | 931 fprintf(stderr,"after appending 500 items to combobox\n"); |
858 for( i = 0; i < 500; i++ ) | 932 for( i = 0; i < 500; i++ ) |
859 { | 933 { |
860 free(text[i]); | 934 free(text[i]); |
861 } | 935 } |
862 free(text); | 936 free(text); |
863 /* make a spinbutton */ | 937 /* make a spinbutton */ |
864 spinbutton = dw_spinbutton_new( "", 0 ); /* no point in specifying text */ | 938 spinbutton = dw_spinbutton_new( "", 0 ); /* no point in specifying text */ |
865 dw_box_pack_start( combox, spinbutton, 200, 20, TRUE, FALSE, 0); | 939 dw_box_pack_start( combox, spinbutton, 200, 20, TRUE, FALSE, 0); |
866 dw_spinbutton_set_limits( spinbutton, 100, 1 ); | 940 dw_spinbutton_set_limits( spinbutton, 100, 1 ); |
867 dw_spinbutton_set_pos( spinbutton, 30 ); | 941 dw_spinbutton_set_pos( spinbutton, 30 ); |
868 dw_signal_connect( spinbutton, DW_SIGNAL_VALUE_CHANGED, DW_SIGNAL_FUNC(spinbutton_valuechanged), NULL ); | 942 dw_signal_connect( spinbutton, DW_SIGNAL_VALUE_CHANGED, DW_SIGNAL_FUNC(spinbutton_valuechanged_callback), NULL ); |
869 } | 943 } |
870 | 944 |
871 void create_button( int redraw) | 945 void create_button( int redraw) |
872 { | 946 { |
873 HWND abutton1; | 947 HWND abutton1; |
874 filetoolbarbox = dw_box_new( BOXVERT, 0 ); | 948 filetoolbarbox = dw_box_new( BOXVERT, 0 ); |
875 dw_box_pack_start( buttonboxperm, filetoolbarbox, 0, 0, TRUE, TRUE, 0 ); | 949 dw_box_pack_start( buttonboxperm, filetoolbarbox, 0, 0, TRUE, TRUE, 0 ); |
876 | 950 |
877 abutton1 = dw_bitmapbutton_new_from_file( "Should be under Top button", 0, "junk" ); | 951 abutton1 = dw_bitmapbutton_new_from_file( "Should be under Top button", 0, "junk" ); |
878 dw_box_pack_start( filetoolbarbox, abutton1, 25, 25, FALSE, FALSE, 0); | 952 dw_box_pack_start( filetoolbarbox, abutton1, 25, 25, FALSE, FALSE, 0); |
879 dw_signal_connect( abutton1, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(redraw_button_box_callback), NULL ); | 953 dw_signal_connect( abutton1, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(redraw_button_box_callback), NULL ); |
880 dw_box_pack_start( filetoolbarbox, 0, 25, 5, FALSE, FALSE, 0 ); | 954 dw_box_pack_start( filetoolbarbox, 0, 25, 5, FALSE, FALSE, 0 ); |
881 | 955 |
882 abutton1 = dw_bitmapbutton_new_from_file( "Should be under Top button", 0, "junk" ); | 956 abutton1 = dw_bitmapbutton_new_from_file( "Should be under Top button", 0, "junk" ); |
883 dw_box_pack_start( filetoolbarbox, abutton1, 25, 25, FALSE, FALSE, 0); | 957 dw_box_pack_start( filetoolbarbox, abutton1, 25, 25, FALSE, FALSE, 0); |
884 dw_signal_connect( abutton1, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(redraw_button_box_callback), NULL ); | 958 dw_signal_connect( abutton1, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(redraw_button_box_callback), NULL ); |
885 dw_box_pack_start( filetoolbarbox, 0, 25, 5, FALSE, FALSE, 0 ); | 959 dw_box_pack_start( filetoolbarbox, 0, 25, 5, FALSE, FALSE, 0 ); |
886 | 960 |
887 abutton1 = dw_bitmapbutton_new_from_file( "Should be under Top button", 0, "junk" ); | 961 abutton1 = dw_bitmapbutton_new_from_file( "Should be under Top button", 0, "junk" ); |
888 dw_box_pack_start( filetoolbarbox, abutton1, 25, 25, FALSE, FALSE, 0); | 962 dw_box_pack_start( filetoolbarbox, abutton1, 25, 25, FALSE, FALSE, 0); |
889 dw_signal_connect( abutton1, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(redraw_button_box_callback), NULL ); | 963 dw_signal_connect( abutton1, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(redraw_button_box_callback), NULL ); |
890 dw_box_pack_start( filetoolbarbox, 0, 25, 5, FALSE, FALSE, 0 ); | 964 dw_box_pack_start( filetoolbarbox, 0, 25, 5, FALSE, FALSE, 0 ); |
891 if ( redraw ) | 965 if ( redraw ) |
892 { | 966 { |
893 dw_window_redraw( filetoolbarbox ); | 967 dw_window_redraw( filetoolbarbox ); |
894 dw_window_redraw( mainwindow ); | 968 dw_window_redraw( mainwindow ); |
895 } | 969 } |
896 } | 970 } |
897 | 971 |
898 void mdi_add(void) | 972 void mdi_add(void) |
899 { | 973 { |
900 HWND mdibox, mdi, mdi1w, mdi1box, ef, mdi2w, mdi2box, bb; | 974 HWND mdibox, mdi, mdi1w, mdi1box, ef, mdi2w, mdi2box, bb; |
901 | 975 |
902 /* create a box to pack into the notebook page */ | 976 /* create a box to pack into the notebook page */ |
903 mdibox = dw_box_new(DW_HORZ, 0); | 977 mdibox = dw_box_new(DW_HORZ, 0); |
904 | 978 |
905 dw_box_pack_start(notebookbox6, mdibox, 500, 200, TRUE, TRUE, 1); | 979 dw_box_pack_start(notebookbox6, mdibox, 500, 200, TRUE, TRUE, 1); |
906 | 980 |
907 /* now a mdi under this box */ | 981 /* now a mdi under this box */ |
908 mdi = dw_mdi_new(333); | 982 mdi = dw_mdi_new(333); |
909 dw_box_pack_start(mdibox, mdi, 500, 200, TRUE, TRUE, 2); | 983 dw_box_pack_start(mdibox, mdi, 500, 200, TRUE, TRUE, 2); |
910 | 984 |
911 mdi1w = dw_window_new(mdi, "MDI1", flStyle | DW_FCF_SIZEBORDER | DW_FCF_MINMAX); | 985 mdi1w = dw_window_new(mdi, "MDI1", flStyle | DW_FCF_SIZEBORDER | DW_FCF_MINMAX); |
912 mdi1box = dw_box_new(DW_HORZ, 0); | 986 mdi1box = dw_box_new(DW_HORZ, 0); |
913 dw_box_pack_start(mdi1w, mdi1box, 0, 0, TRUE, TRUE, 0); | 987 dw_box_pack_start(mdi1w, mdi1box, 0, 0, TRUE, TRUE, 0); |
914 ef = dw_entryfield_new("", 0); | 988 ef = dw_entryfield_new("", 0); |
915 dw_box_pack_start(mdi1box, ef, 100, 20, FALSE, FALSE, 4); | 989 dw_box_pack_start(mdi1box, ef, 100, 20, FALSE, FALSE, 4); |
916 dw_window_set_size(mdi1w, 200, 100); | 990 dw_window_set_size(mdi1w, 200, 100); |
917 dw_window_show(mdi1w); | 991 dw_window_show(mdi1w); |
918 | 992 |
919 mdi2w = dw_window_new(mdi, "MDI2", flStyle | DW_FCF_SIZEBORDER | DW_FCF_MINMAX); | 993 mdi2w = dw_window_new(mdi, "MDI2", flStyle | DW_FCF_SIZEBORDER | DW_FCF_MINMAX); |
920 mdi2box = dw_box_new(DW_HORZ, 0); | 994 mdi2box = dw_box_new(DW_HORZ, 0); |
921 dw_box_pack_start(mdi2w, mdi2box, 0, 0, TRUE, TRUE, 0); | 995 dw_box_pack_start(mdi2w, mdi2box, 0, 0, TRUE, TRUE, 0); |
922 ef = dw_entryfield_new( "", 0); | 996 ef = dw_entryfield_new( "", 0); |
923 dw_box_pack_start(mdi2box, ef, 150, 30, FALSE, FALSE, 4); | 997 dw_box_pack_start(mdi2box, ef, 150, 30, FALSE, FALSE, 4); |
924 bb = dw_button_new("Browse", 0); | 998 bb = dw_button_new("Browse", 0); |
925 dw_box_pack_start(mdi2box, bb, 60, 30, FALSE, FALSE, 4); | 999 dw_box_pack_start(mdi2box, bb, 60, 30, FALSE, FALSE, 4); |
926 dw_window_set_size(mdi2w, 200, 200); | 1000 dw_window_set_size(mdi2w, 200, 200); |
927 dw_window_show(mdi2w); | 1001 dw_window_show(mdi2w); |
1002 } | |
1003 | |
1004 void menu_add(void) | |
1005 { | |
1006 HMENUI menuitem,menu; | |
1007 | |
1008 mainmenubar = dw_menubar_new( mainwindow ); | |
1009 /* add menus to the menubar */ | |
1010 menu = dw_menu_new( 0 ); | |
1011 menuitem = dw_menu_append_item( menu, "~Quit", 1019, 0, TRUE, FALSE, NULL ); | |
1012 dw_signal_connect( menuitem, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(exit_callback), (void *)mainwindow); | |
1013 /* | |
1014 * Add the "File" menu to the menubar... | |
1015 */ | |
1016 dw_menu_append_item( mainmenubar, "~File", 1010, 0, TRUE, FALSE, menu ); | |
1017 | |
1018 changeable_menu = dw_menu_new( 0 ); | |
1019 checkable_menuitem = dw_menu_append_item( changeable_menu, "~Checkable Menu Item", CHECKABLE_MENUITEMID, 0, TRUE, TRUE, 0 ); | |
1020 dw_signal_connect( checkable_menuitem, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(menu_callback), (void *)"checkable"); | |
1021 noncheckable_menuitem = dw_menu_append_item( changeable_menu, "~Non-checkable Menu Item", NONCHECKABLE_MENUITEMID, 0, TRUE, FALSE, 0 ); | |
1022 dw_signal_connect( noncheckable_menuitem, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(menu_callback), (void *)"non-checkable"); | |
1023 menuitem = dw_menu_append_item( changeable_menu, "~Disabled menu Item", 2003, DW_MIS_DISABLED, TRUE, FALSE, 0 ); | |
1024 dw_signal_connect( noncheckable_menuitem, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(menu_callback), (void *)"non-checkable"); | |
1025 /* seperator */ | |
1026 dw_menu_append_item( changeable_menu, DW_MENU_SEPARATOR, 3999, 0, TRUE, FALSE, 0 ); | |
1027 menuitem = dw_menu_append_item( changeable_menu, "~Menu Items Disabled", 2009, 0, TRUE, TRUE, 0 ); | |
1028 dw_signal_connect( menuitem, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(menutoggle_callback), (void *)NULL); | |
1029 /* | |
1030 * Add the "Menu" menu to the menubar... | |
1031 */ | |
1032 dw_menu_append_item( mainmenubar, "~Menu", 1020, 0, TRUE, FALSE, changeable_menu ); | |
1033 | |
1034 menu = dw_menu_new( 0 ); | |
1035 menuitem = dw_menu_append_item( menu, "~About", 1091, 0, TRUE, FALSE, 0 ); | |
1036 dw_signal_connect( menuitem, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(helpabout_callback), (void *)mainwindow); | |
1037 /* | |
1038 * Add the "Help" menu to the menubar... | |
1039 */ | |
1040 dw_menu_append_item( mainmenubar, "~Help", 1090, 0, TRUE, FALSE, menu ); | |
928 } | 1041 } |
929 | 1042 |
930 /* | 1043 /* |
931 * Let's demonstrate the functionality of this library. :) | 1044 * Let's demonstrate the functionality of this library. :) |
932 */ | 1045 */ |
933 int main(int argc, char *argv[]) | 1046 int main(int argc, char *argv[]) |
934 { | 1047 { |
935 ULONG notebookpage1; | 1048 ULONG notebookpage1; |
936 ULONG notebookpage2; | 1049 ULONG notebookpage2; |
937 ULONG notebookpage3; | 1050 ULONG notebookpage3; |
938 ULONG notebookpage4; | 1051 ULONG notebookpage4; |
939 ULONG notebookpage5; | 1052 ULONG notebookpage5; |
940 ULONG notebookpage6; | 1053 ULONG notebookpage6; |
941 ULONG notebookpage7; | 1054 ULONG notebookpage7; |
942 | 1055 |
943 dw_init(TRUE, argc, argv); | 1056 dw_init(TRUE, argc, argv); |
944 | 1057 |
945 mainwindow = dw_window_new( HWND_DESKTOP, "dwindows test", flStyle | DW_FCF_SIZEBORDER | DW_FCF_MINMAX ); | 1058 mainwindow = dw_window_new( HWND_DESKTOP, "dwindows test", flStyle | DW_FCF_SIZEBORDER | DW_FCF_MINMAX); |
946 | 1059 dw_window_set_icon(mainwindow, fileicon); |
947 notebookbox = dw_box_new( BOXVERT, 5 ); | 1060 |
948 dw_box_pack_start( mainwindow, notebookbox, 0, 0, TRUE, TRUE, 0); | 1061 notebookbox = dw_box_new( BOXVERT, 5 ); |
949 | 1062 dw_box_pack_start( mainwindow, notebookbox, 0, 0, TRUE, TRUE, 0); |
950 notebook = dw_notebook_new( 1, TRUE ); | 1063 /* MUST pack a box into the mainwindow BEFORE adding menus */ |
951 dw_box_pack_start( notebookbox, notebook, 100, 100, TRUE, TRUE, 0); | 1064 menu_add(); |
952 dw_signal_connect(notebook, DW_SIGNAL_SWITCH_PAGE, DW_SIGNAL_FUNC(switch_page_cb), NULL); | 1065 |
953 | 1066 notebook = dw_notebook_new( 1, TRUE ); |
954 notebookbox1 = dw_box_new( BOXVERT, 5 ); | 1067 dw_box_pack_start( notebookbox, notebook, 100, 100, TRUE, TRUE, 0); |
955 notebookpage1 = dw_notebook_page_new( notebook, 0, TRUE ); | 1068 dw_signal_connect(notebook, DW_SIGNAL_SWITCH_PAGE, DW_SIGNAL_FUNC(switch_page_cb), NULL); |
956 dw_notebook_pack( notebook, notebookpage1, notebookbox1 ); | 1069 |
957 dw_notebook_page_set_text( notebook, notebookpage1, "buttons and entry"); | 1070 notebookbox1 = dw_box_new( BOXVERT, 5 ); |
958 archive_add(); | 1071 notebookpage1 = dw_notebook_page_new( notebook, 0, TRUE ); |
959 | 1072 dw_notebook_pack( notebook, notebookpage1, notebookbox1 ); |
960 notebookbox2 = dw_box_new( BOXVERT, 5 ); | 1073 dw_notebook_page_set_text( notebook, notebookpage1, "buttons and entry"); |
961 notebookpage2 = dw_notebook_page_new( notebook, 1, FALSE ); | 1074 archive_add(); |
962 dw_notebook_pack( notebook, notebookpage2, notebookbox2 ); | 1075 |
963 dw_notebook_page_set_text( notebook, notebookpage2, "render"); | 1076 notebookbox2 = dw_box_new( BOXVERT, 5 ); |
964 text_add(); | 1077 notebookpage2 = dw_notebook_page_new( notebook, 1, FALSE ); |
965 | 1078 dw_notebook_pack( notebook, notebookpage2, notebookbox2 ); |
966 notebookbox3 = dw_box_new( BOXVERT, 5 ); | 1079 dw_notebook_page_set_text( notebook, notebookpage2, "render"); |
967 notebookpage3 = dw_notebook_page_new( notebook, 1, FALSE ); | 1080 text_add(); |
968 dw_notebook_pack( notebook, notebookpage3, notebookbox3 ); | 1081 |
969 dw_notebook_page_set_text( notebook, notebookpage3, "tree"); | 1082 notebookbox3 = dw_box_new( BOXVERT, 5 ); |
970 tree_add(); | 1083 notebookpage3 = dw_notebook_page_new( notebook, 1, FALSE ); |
971 | 1084 dw_notebook_pack( notebook, notebookpage3, notebookbox3 ); |
972 notebookbox4 = dw_box_new( BOXVERT, 5 ); | 1085 dw_notebook_page_set_text( notebook, notebookpage3, "tree"); |
973 notebookpage4 = dw_notebook_page_new( notebook, 1, FALSE ); | 1086 tree_add(); |
974 dw_notebook_pack( notebook, notebookpage4, notebookbox4 ); | 1087 |
975 dw_notebook_page_set_text( notebook, notebookpage4, "container"); | 1088 notebookbox4 = dw_box_new( BOXVERT, 5 ); |
976 container_add(); | 1089 notebookpage4 = dw_notebook_page_new( notebook, 1, FALSE ); |
977 | 1090 dw_notebook_pack( notebook, notebookpage4, notebookbox4 ); |
978 notebookbox5 = dw_box_new( BOXVERT, 5 ); | 1091 dw_notebook_page_set_text( notebook, notebookpage4, "container"); |
979 notebookpage5 = dw_notebook_page_new( notebook, 1, FALSE ); | 1092 container_add(); |
980 dw_notebook_pack( notebook, notebookpage5, notebookbox5 ); | 1093 |
981 dw_notebook_page_set_text( notebook, notebookpage5, "buttons"); | 1094 notebookbox5 = dw_box_new( BOXVERT, 5 ); |
982 buttons_add(); | 1095 notebookpage5 = dw_notebook_page_new( notebook, 1, FALSE ); |
983 | 1096 dw_notebook_pack( notebook, notebookpage5, notebookbox5 ); |
984 notebookbox6 = dw_box_new( BOXVERT, 5 ); | 1097 dw_notebook_page_set_text( notebook, notebookpage5, "buttons"); |
985 notebookpage6 = dw_notebook_page_new( notebook, 1, FALSE ); | 1098 buttons_add(); |
986 dw_notebook_pack( notebook, notebookpage6, notebookbox6 ); | 1099 |
987 dw_notebook_page_set_text( notebook, notebookpage6, "mdi"); | 1100 notebookbox6 = dw_box_new( BOXVERT, 5 ); |
988 mdi_add(); | 1101 notebookpage6 = dw_notebook_page_new( notebook, 1, FALSE ); |
989 | 1102 dw_notebook_pack( notebook, notebookpage6, notebookbox6 ); |
990 html = dw_html_new(0); | 1103 dw_notebook_page_set_text( notebook, notebookpage6, "mdi"); |
991 notebookpage7 = dw_notebook_page_new( notebook, 1, FALSE ); | 1104 mdi_add(); |
992 dw_notebook_pack( notebook, notebookpage7, html ); | 1105 |
993 dw_notebook_page_set_text( notebook, notebookpage7, "html"); | 1106 notebookbox7 = dw_box_new( BOXVERT, 6 ); |
994 dw_html_url(html, "http://dwindows.netlabs.org"); | 1107 notebookpage7 = dw_notebook_page_new( notebook, 1, FALSE ); |
995 | 1108 dw_notebook_pack( notebook, notebookpage7, notebookbox7 ); |
996 dw_signal_connect(mainwindow, DW_SIGNAL_DELETE, DW_SIGNAL_FUNC(exit_callback), (void *)mainwindow); | 1109 dw_notebook_page_set_text( notebook, notebookpage7, "html"); |
997 timerid = dw_timer_connect(1000, DW_SIGNAL_FUNC(timer_callback), 0); | 1110 html = dw_html_new(1001); |
998 dw_window_set_icon(mainwindow, fileicon); | 1111 dw_box_pack_start( notebookbox7, html, 100, 100, TRUE, TRUE, 0); |
999 dw_window_set_size(mainwindow, 640, 480); | 1112 /* |
1000 dw_window_show(mainwindow); | 1113 * This originally had: |
1001 | 1114 dw_html_url(html, "http://dwindows.netlabs.org"); |
1002 dw_main(); | 1115 * but as the base file is XML, the Windows browser instance can't display it. |
1003 | 1116 * Instead a pure HTML based web page is displayed. MHES 5/4/2008 |
1004 return 0; | 1117 */ |
1118 dw_html_url(html, "http://www.rexx.org"); | |
1119 | |
1120 dw_signal_connect(mainwindow, DW_SIGNAL_DELETE, DW_SIGNAL_FUNC(exit_callback), (void *)mainwindow); | |
1121 timerid = dw_timer_connect(1000, DW_SIGNAL_FUNC(timer_callback), 0); | |
1122 dw_window_set_size(mainwindow, 640, 520); | |
1123 dw_window_show(mainwindow); | |
1124 | |
1125 dw_main(); | |
1126 | |
1127 return 0; | |
1005 } | 1128 } |
1006 #endif | 1129 #endif |