Mercurial > dwindows
diff 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 |
line wrap: on
line diff
--- a/dwtest.c Thu Feb 20 17:55:56 2003 +0000 +++ b/dwtest.c Thu Feb 20 20:19:09 2003 +0000 @@ -14,6 +14,8 @@ #define FIXEDFONT "fixed" #endif +#define SCROLLBARWIDTH 14 + unsigned long flStyle = DW_FCF_SYSMENU | DW_FCF_TITLEBAR | DW_FCF_SHELLPOSITION | DW_FCF_TASKLIST | DW_FCF_DLGBORDER; @@ -34,11 +36,11 @@ tree, pagebox, treebox, - textbox1, textbox2, textboxA, textbox3, + textbox1, textbox2, textboxA, gap_box, buttonbox; -HPIXMAP text1pm,text2pm,text3pm; +HPIXMAP text1pm,text2pm; int font_width = 8; int font_height=12; @@ -63,8 +65,6 @@ hpm = text1pm; else if ( hwnd == textbox2 ) hpm = text2pm; - else if ( hwnd == textbox3 ) - hpm = text3pm; width = DW_PIXMAP_WIDTH(hpm); height = DW_PIXMAP_HEIGHT(hpm); @@ -120,11 +120,8 @@ pLine = lp[i+row]; dw_draw_text( NULL, text2pm, 0, y, pLine+col ); } - dw_color_foreground_set(DW_CLR_DEFAULT); - dw_draw_rect(0, text3pm, TRUE, 0, 0, DW_PIXMAP_WIDTH(text3pm), DW_PIXMAP_HEIGHT(text3pm)); text_expose( textbox1, NULL, NULL); text_expose( textbox2, NULL, NULL); - text_expose( textbox3, NULL, NULL); } } @@ -198,24 +195,19 @@ /* Handle size change of the main render window */ int DWSIGNAL configure_event(HWND hwnd, int width, int height, void *data) { - HPIXMAP old1 = text1pm, old2 = text2pm, old3 = text3pm; - unsigned long height1; + HPIXMAP old1 = text1pm, old2 = text2pm; int depth = dw_color_depth(); rows = height / (font_height+font_gap); cols = width / font_width; - dw_window_get_pos_size(textbox1, NULL, NULL, NULL, &height1); - /* Create new pixmaps with the current sizes */ - text1pm = dw_pixmap_new(textbox1, (font_width*width1)+2, height, depth); /* was height1 */ + text1pm = dw_pixmap_new(textbox1, (font_width*(width1+1)), height+1, depth); text2pm = dw_pixmap_new(textbox2, width, height, depth); - text3pm = dw_pixmap_new(textbox3, width, height, depth); /* Destroy the old pixmaps */ dw_pixmap_destroy(old1); dw_pixmap_destroy(old2); - dw_pixmap_destroy(old3); /* Update scrollbar ranges with new values */ dw_scrollbar_set_range(hscrollbar, max_linewidth, cols); @@ -296,14 +288,12 @@ textbox1 = dw_render_new( 100 ); dw_window_set_font(textbox1, FIXEDFONT); dw_font_text_extents(textbox1, NULL, "O", &font_width, &font_height); - dw_box_pack_start(pagebox, textbox1, (font_width*width1), font_height*rows, FALSE, TRUE, 0); + vscrollbox = dw_box_new(BOXVERT, 0); + dw_box_pack_start(vscrollbox, textbox1, (font_width*(width1+1)), font_height*rows, FALSE, TRUE, 0); + dw_box_pack_start(vscrollbox, 0, (font_width*(width1+1)), SCROLLBARWIDTH, FALSE, FALSE, 0); + dw_box_pack_start(pagebox, vscrollbox, 0, 0, FALSE, TRUE, 0); /* create render box for gap pixmap */ - textbox3 = dw_render_new( 102 ); - dw_window_set_font(textbox3, FIXEDFONT); - dw_font_text_extents(textbox3, NULL, "O", &font_width, &font_height); - dw_box_pack_start(pagebox, textbox3, (font_width), font_height*rows, FALSE, TRUE, 0); - /* create box for filecontents and horz scrollbar */ textboxA = dw_box_new( BOXVERT,0 ); dw_box_pack_start( pagebox, textboxA, 0, 0, TRUE, TRUE, 0); @@ -314,26 +304,24 @@ dw_window_set_font(textbox2, FIXEDFONT); /* create horizonal scrollbar */ hscrollbar = dw_scrollbar_new(FALSE, 100, 50); - dw_box_pack_start( textboxA, hscrollbar, 100, 14, TRUE, FALSE, 0); + dw_box_pack_start( textboxA, hscrollbar, 100, SCROLLBARWIDTH, TRUE, FALSE, 0); /* create vertical scrollbar */ vscrollbox = dw_box_new(BOXVERT, 0); vscrollbar = dw_scrollbar_new(TRUE, 100, 50); - dw_box_pack_start(vscrollbox, vscrollbar, 14, 100, FALSE, TRUE, 0); + dw_box_pack_start(vscrollbox, vscrollbar, SCROLLBARWIDTH, 100, FALSE, TRUE, 0); /* Pack an area of empty space 14x14 pixels */ - dw_box_pack_start(vscrollbox, 0, 14, 14, FALSE, FALSE, 0); + dw_box_pack_start(vscrollbox, 0, SCROLLBARWIDTH, SCROLLBARWIDTH, FALSE, FALSE, 0); dw_box_pack_start(pagebox, vscrollbox, 0, 0, FALSE, TRUE, 0); - text1pm = dw_pixmap_new( textbox1, (font_width*width1)+2, font_height*rows, depth ); + text1pm = dw_pixmap_new( textbox1, (font_width*(width1+1)), font_height*rows, depth ); text2pm = dw_pixmap_new( textbox2, font_width*cols, font_height*rows, depth ); - text3pm = dw_pixmap_new( textbox3, font_width, font_height*rows, depth ); dw_messagebox("DWTest", "Width: %d Height: %d\n", font_width, font_height); dw_draw_rect(0, text1pm, TRUE, 0, 0, font_width*width1, font_height*rows); dw_draw_rect(0, text2pm, TRUE, 0, 0, font_width*cols, font_height*rows); dw_signal_connect(textbox1, "expose_event", DW_SIGNAL_FUNC(text_expose), NULL); dw_signal_connect(textbox2, "expose_event", DW_SIGNAL_FUNC(text_expose), NULL); - dw_signal_connect(textbox3, "expose_event", DW_SIGNAL_FUNC(text_expose), NULL); dw_signal_connect(textbox2, "configure_event", DW_SIGNAL_FUNC(configure_event), text2pm); dw_signal_connect(hscrollbar, "value_changed", DW_SIGNAL_FUNC(scrollbar_valuechanged), (void *)status); dw_signal_connect(vscrollbar, "value_changed", DW_SIGNAL_FUNC(scrollbar_valuechanged), (void *)status);