comparison dwtest.c @ 257:9ea4ac9a097f

Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix to be filled in shortly.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 20 Feb 2003 20:19:09 +0000
parents 42332e598d55
children 5c5bee286d0e
comparison
equal deleted inserted replaced
256:63d68387d924 257:9ea4ac9a097f
11 #elif GTK_MAJOR_VERSION > 1 11 #elif GTK_MAJOR_VERSION > 1
12 #define FIXEDFONT "monospace 10" 12 #define FIXEDFONT "monospace 10"
13 #else 13 #else
14 #define FIXEDFONT "fixed" 14 #define FIXEDFONT "fixed"
15 #endif 15 #endif
16
17 #define SCROLLBARWIDTH 14
16 18
17 unsigned long flStyle = DW_FCF_SYSMENU | DW_FCF_TITLEBAR | 19 unsigned long flStyle = DW_FCF_SYSMENU | DW_FCF_TITLEBAR |
18 DW_FCF_SHELLPOSITION | DW_FCF_TASKLIST | DW_FCF_DLGBORDER; 20 DW_FCF_SHELLPOSITION | DW_FCF_TASKLIST | DW_FCF_DLGBORDER;
19 21
20 HWND mainwindow, 22 HWND mainwindow,
32 status, 34 status,
33 stext, 35 stext,
34 tree, 36 tree,
35 pagebox, 37 pagebox,
36 treebox, 38 treebox,
37 textbox1, textbox2, textboxA, textbox3, 39 textbox1, textbox2, textboxA,
38 gap_box, 40 gap_box,
39 buttonbox; 41 buttonbox;
40 42
41 HPIXMAP text1pm,text2pm,text3pm; 43 HPIXMAP text1pm,text2pm;
42 44
43 int font_width = 8; 45 int font_width = 8;
44 int font_height=12; 46 int font_height=12;
45 int font_gap = 2; 47 int font_gap = 2;
46 int rows=100,width1=6,cols=80; 48 int rows=100,width1=6,cols=80;
61 63
62 if ( hwnd == textbox1 ) 64 if ( hwnd == textbox1 )
63 hpm = text1pm; 65 hpm = text1pm;
64 else if ( hwnd == textbox2 ) 66 else if ( hwnd == textbox2 )
65 hpm = text2pm; 67 hpm = text2pm;
66 else if ( hwnd == textbox3 )
67 hpm = text3pm;
68 68
69 width = DW_PIXMAP_WIDTH(hpm); 69 width = DW_PIXMAP_WIDTH(hpm);
70 height = DW_PIXMAP_HEIGHT(hpm); 70 height = DW_PIXMAP_HEIGHT(hpm);
71 71
72 dw_pixmap_bitblt(hwnd, NULL, 0, 0, width, height, NULL, hpm, 0, 0 ); 72 dw_pixmap_bitblt(hwnd, NULL, 0, 0, width, height, NULL, hpm, 0, 0 );
118 sprintf( buf, "%6.6d", i+row ); 118 sprintf( buf, "%6.6d", i+row );
119 dw_draw_text( NULL, text1pm, 0, y, buf); 119 dw_draw_text( NULL, text1pm, 0, y, buf);
120 pLine = lp[i+row]; 120 pLine = lp[i+row];
121 dw_draw_text( NULL, text2pm, 0, y, pLine+col ); 121 dw_draw_text( NULL, text2pm, 0, y, pLine+col );
122 } 122 }
123 dw_color_foreground_set(DW_CLR_DEFAULT);
124 dw_draw_rect(0, text3pm, TRUE, 0, 0, DW_PIXMAP_WIDTH(text3pm), DW_PIXMAP_HEIGHT(text3pm));
125 text_expose( textbox1, NULL, NULL); 123 text_expose( textbox1, NULL, NULL);
126 text_expose( textbox2, NULL, NULL); 124 text_expose( textbox2, NULL, NULL);
127 text_expose( textbox3, NULL, NULL);
128 } 125 }
129 } 126 }
130 127
131 int DWSIGNAL beep_callback(HWND window, void *data) 128 int DWSIGNAL beep_callback(HWND window, void *data)
132 { 129 {
196 } 193 }
197 194
198 /* Handle size change of the main render window */ 195 /* Handle size change of the main render window */
199 int DWSIGNAL configure_event(HWND hwnd, int width, int height, void *data) 196 int DWSIGNAL configure_event(HWND hwnd, int width, int height, void *data)
200 { 197 {
201 HPIXMAP old1 = text1pm, old2 = text2pm, old3 = text3pm; 198 HPIXMAP old1 = text1pm, old2 = text2pm;
202 unsigned long height1;
203 int depth = dw_color_depth(); 199 int depth = dw_color_depth();
204 200
205 rows = height / (font_height+font_gap); 201 rows = height / (font_height+font_gap);
206 cols = width / font_width; 202 cols = width / font_width;
207 203
208 dw_window_get_pos_size(textbox1, NULL, NULL, NULL, &height1);
209
210 /* Create new pixmaps with the current sizes */ 204 /* Create new pixmaps with the current sizes */
211 text1pm = dw_pixmap_new(textbox1, (font_width*width1)+2, height, depth); /* was height1 */ 205 text1pm = dw_pixmap_new(textbox1, (font_width*(width1+1)), height+1, depth);
212 text2pm = dw_pixmap_new(textbox2, width, height, depth); 206 text2pm = dw_pixmap_new(textbox2, width, height, depth);
213 text3pm = dw_pixmap_new(textbox3, width, height, depth);
214 207
215 /* Destroy the old pixmaps */ 208 /* Destroy the old pixmaps */
216 dw_pixmap_destroy(old1); 209 dw_pixmap_destroy(old1);
217 dw_pixmap_destroy(old2); 210 dw_pixmap_destroy(old2);
218 dw_pixmap_destroy(old3);
219 211
220 /* Update scrollbar ranges with new values */ 212 /* Update scrollbar ranges with new values */
221 dw_scrollbar_set_range(hscrollbar, max_linewidth, cols); 213 dw_scrollbar_set_range(hscrollbar, max_linewidth, cols);
222 dw_scrollbar_set_range(vscrollbar, num_lines, rows); 214 dw_scrollbar_set_range(vscrollbar, num_lines, rows);
223 215
294 286
295 /* create render box for number pixmap */ 287 /* create render box for number pixmap */
296 textbox1 = dw_render_new( 100 ); 288 textbox1 = dw_render_new( 100 );
297 dw_window_set_font(textbox1, FIXEDFONT); 289 dw_window_set_font(textbox1, FIXEDFONT);
298 dw_font_text_extents(textbox1, NULL, "O", &font_width, &font_height); 290 dw_font_text_extents(textbox1, NULL, "O", &font_width, &font_height);
299 dw_box_pack_start(pagebox, textbox1, (font_width*width1), font_height*rows, FALSE, TRUE, 0); 291 vscrollbox = dw_box_new(BOXVERT, 0);
292 dw_box_pack_start(vscrollbox, textbox1, (font_width*(width1+1)), font_height*rows, FALSE, TRUE, 0);
293 dw_box_pack_start(vscrollbox, 0, (font_width*(width1+1)), SCROLLBARWIDTH, FALSE, FALSE, 0);
294 dw_box_pack_start(pagebox, vscrollbox, 0, 0, FALSE, TRUE, 0);
300 295
301 /* create render box for gap pixmap */ 296 /* create render box for gap pixmap */
302 textbox3 = dw_render_new( 102 );
303 dw_window_set_font(textbox3, FIXEDFONT);
304 dw_font_text_extents(textbox3, NULL, "O", &font_width, &font_height);
305 dw_box_pack_start(pagebox, textbox3, (font_width), font_height*rows, FALSE, TRUE, 0);
306
307 /* create box for filecontents and horz scrollbar */ 297 /* create box for filecontents and horz scrollbar */
308 textboxA = dw_box_new( BOXVERT,0 ); 298 textboxA = dw_box_new( BOXVERT,0 );
309 dw_box_pack_start( pagebox, textboxA, 0, 0, TRUE, TRUE, 0); 299 dw_box_pack_start( pagebox, textboxA, 0, 0, TRUE, TRUE, 0);
310 300
311 /* create render box for filecontents pixmap */ 301 /* create render box for filecontents pixmap */
312 textbox2 = dw_render_new( 101 ); 302 textbox2 = dw_render_new( 101 );
313 dw_box_pack_start( textboxA, textbox2, 10, 10, TRUE, TRUE, 0); 303 dw_box_pack_start( textboxA, textbox2, 10, 10, TRUE, TRUE, 0);
314 dw_window_set_font(textbox2, FIXEDFONT); 304 dw_window_set_font(textbox2, FIXEDFONT);
315 /* create horizonal scrollbar */ 305 /* create horizonal scrollbar */
316 hscrollbar = dw_scrollbar_new(FALSE, 100, 50); 306 hscrollbar = dw_scrollbar_new(FALSE, 100, 50);
317 dw_box_pack_start( textboxA, hscrollbar, 100, 14, TRUE, FALSE, 0); 307 dw_box_pack_start( textboxA, hscrollbar, 100, SCROLLBARWIDTH, TRUE, FALSE, 0);
318 308
319 /* create vertical scrollbar */ 309 /* create vertical scrollbar */
320 vscrollbox = dw_box_new(BOXVERT, 0); 310 vscrollbox = dw_box_new(BOXVERT, 0);
321 vscrollbar = dw_scrollbar_new(TRUE, 100, 50); 311 vscrollbar = dw_scrollbar_new(TRUE, 100, 50);
322 dw_box_pack_start(vscrollbox, vscrollbar, 14, 100, FALSE, TRUE, 0); 312 dw_box_pack_start(vscrollbox, vscrollbar, SCROLLBARWIDTH, 100, FALSE, TRUE, 0);
323 /* Pack an area of empty space 14x14 pixels */ 313 /* Pack an area of empty space 14x14 pixels */
324 dw_box_pack_start(vscrollbox, 0, 14, 14, FALSE, FALSE, 0); 314 dw_box_pack_start(vscrollbox, 0, SCROLLBARWIDTH, SCROLLBARWIDTH, FALSE, FALSE, 0);
325 dw_box_pack_start(pagebox, vscrollbox, 0, 0, FALSE, TRUE, 0); 315 dw_box_pack_start(pagebox, vscrollbox, 0, 0, FALSE, TRUE, 0);
326 316
327 text1pm = dw_pixmap_new( textbox1, (font_width*width1)+2, font_height*rows, depth ); 317 text1pm = dw_pixmap_new( textbox1, (font_width*(width1+1)), font_height*rows, depth );
328 text2pm = dw_pixmap_new( textbox2, font_width*cols, font_height*rows, depth ); 318 text2pm = dw_pixmap_new( textbox2, font_width*cols, font_height*rows, depth );
329 text3pm = dw_pixmap_new( textbox3, font_width, font_height*rows, depth );
330 319
331 dw_messagebox("DWTest", "Width: %d Height: %d\n", font_width, font_height); 320 dw_messagebox("DWTest", "Width: %d Height: %d\n", font_width, font_height);
332 dw_draw_rect(0, text1pm, TRUE, 0, 0, font_width*width1, font_height*rows); 321 dw_draw_rect(0, text1pm, TRUE, 0, 0, font_width*width1, font_height*rows);
333 dw_draw_rect(0, text2pm, TRUE, 0, 0, font_width*cols, font_height*rows); 322 dw_draw_rect(0, text2pm, TRUE, 0, 0, font_width*cols, font_height*rows);
334 dw_signal_connect(textbox1, "expose_event", DW_SIGNAL_FUNC(text_expose), NULL); 323 dw_signal_connect(textbox1, "expose_event", DW_SIGNAL_FUNC(text_expose), NULL);
335 dw_signal_connect(textbox2, "expose_event", DW_SIGNAL_FUNC(text_expose), NULL); 324 dw_signal_connect(textbox2, "expose_event", DW_SIGNAL_FUNC(text_expose), NULL);
336 dw_signal_connect(textbox3, "expose_event", DW_SIGNAL_FUNC(text_expose), NULL);
337 dw_signal_connect(textbox2, "configure_event", DW_SIGNAL_FUNC(configure_event), text2pm); 325 dw_signal_connect(textbox2, "configure_event", DW_SIGNAL_FUNC(configure_event), text2pm);
338 dw_signal_connect(hscrollbar, "value_changed", DW_SIGNAL_FUNC(scrollbar_valuechanged), (void *)status); 326 dw_signal_connect(hscrollbar, "value_changed", DW_SIGNAL_FUNC(scrollbar_valuechanged), (void *)status);
339 dw_signal_connect(vscrollbar, "value_changed", DW_SIGNAL_FUNC(scrollbar_valuechanged), (void *)status); 327 dw_signal_connect(vscrollbar, "value_changed", DW_SIGNAL_FUNC(scrollbar_valuechanged), (void *)status);
340 dw_signal_connect(textbox1, "key_press_event", DW_SIGNAL_FUNC(keypress_callback), text1pm); 328 dw_signal_connect(textbox1, "key_press_event", DW_SIGNAL_FUNC(keypress_callback), text1pm);
341 dw_signal_connect(textbox2, "key_press_event", DW_SIGNAL_FUNC(keypress_callback), text2pm); 329 dw_signal_connect(textbox2, "key_press_event", DW_SIGNAL_FUNC(keypress_callback), text2pm);