Mercurial > dwindows
comparison dwtest.c @ 1460:da9cd5da3440
Test dw_window_get_preferred_size by using it to get the size of the scrollbars.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 15 Dec 2011 23:14:28 +0000 |
parents | 6bf5dc7da45d |
children | 09323eb9dc32 |
comparison
equal
deleted
inserted
replaced
1459:98de42fc664d | 1460:da9cd5da3440 |
---|---|
24 #define FIXEDFONT "fixed" | 24 #define FIXEDFONT "fixed" |
25 #define FOLDER_ICON_NAME "gtk/folder" | 25 #define FOLDER_ICON_NAME "gtk/folder" |
26 #define FILE_ICON_NAME "gtk/file" | 26 #define FILE_ICON_NAME "gtk/file" |
27 #endif | 27 #endif |
28 | 28 |
29 #define SCROLLBARWIDTH 14 | |
30 #define MAX_WIDGETS 20 | 29 #define MAX_WIDGETS 20 |
31 | 30 |
32 unsigned long flStyle = DW_FCF_SYSMENU | DW_FCF_TITLEBAR | | 31 unsigned long flStyle = DW_FCF_SYSMENU | DW_FCF_TITLEBAR | |
33 DW_FCF_SHELLPOSITION | DW_FCF_TASKLIST | DW_FCF_DLGBORDER; | 32 DW_FCF_SHELLPOSITION | DW_FCF_TASKLIST | DW_FCF_DLGBORDER; |
34 | 33 |
390 /* If we aren't drawing direct do a bitblt */ | 389 /* If we aren't drawing direct do a bitblt */ |
391 if(!direct && !hpma) | 390 if(!direct && !hpma) |
392 { | 391 { |
393 text_expose( textbox2, NULL, NULL); | 392 text_expose( textbox2, NULL, NULL); |
394 } | 393 } |
394 /* Make sure the side area is cleared too */ | |
395 dw_color_foreground_set(DW_CLR_BLACK); | |
396 dw_draw_rect(textbox1, 0, DW_DRAW_FILL, 0, 0, DW_PIXMAP_WIDTH(text1pm), DW_PIXMAP_HEIGHT(text1pm)); | |
395 } | 397 } |
396 | 398 |
397 void update_render(void) | 399 void update_render(void) |
398 { | 400 { |
399 switch(render_type) | 401 switch(render_type) |
928 | 930 |
929 void text_add(void) | 931 void text_add(void) |
930 { | 932 { |
931 unsigned long depth = dw_color_depth_get(); | 933 unsigned long depth = dw_color_depth_get(); |
932 HWND vscrollbox, hbox, button1, button2, label; | 934 HWND vscrollbox, hbox, button1, button2, label; |
935 int vscrollbarwidth, hscrollbarheight; | |
933 | 936 |
934 /* create a box to pack into the notebook page */ | 937 /* create a box to pack into the notebook page */ |
935 pagebox = dw_box_new(BOXHORZ, 2); | 938 pagebox = dw_box_new(BOXHORZ, 2); |
936 dw_box_pack_start( notebookbox2, pagebox, 0, 0, TRUE, TRUE, 0); | 939 dw_box_pack_start( notebookbox2, pagebox, 0, 0, TRUE, TRUE, 0); |
937 /* now a status area under this box */ | 940 /* now a status area under this box */ |
969 button1 = dw_button_new( "Refresh", 1223L ); | 972 button1 = dw_button_new( "Refresh", 1223L ); |
970 dw_box_pack_start( hbox, button1, 100, 25, FALSE, FALSE, 0); | 973 dw_box_pack_start( hbox, button1, 100, 25, FALSE, FALSE, 0); |
971 button2 = dw_button_new( "Print", 1224L ); | 974 button2 = dw_button_new( "Print", 1224L ); |
972 dw_box_pack_start( hbox, button2, 100, 25, FALSE, FALSE, 0); | 975 dw_box_pack_start( hbox, button2, 100, 25, FALSE, FALSE, 0); |
973 | 976 |
977 /* Pre-create the scrollbars so we can query their sizes */ | |
978 vscrollbar = dw_scrollbar_new(DW_VERT, 50); | |
979 hscrollbar = dw_scrollbar_new(DW_HORZ, 50); | |
980 dw_window_get_preferred_size(vscrollbar, &vscrollbarwidth, NULL); | |
981 dw_window_get_preferred_size(hscrollbar, NULL, &hscrollbarheight); | |
982 | |
974 /* create render box for number pixmap */ | 983 /* create render box for number pixmap */ |
975 textbox1 = dw_render_new( 100 ); | 984 textbox1 = dw_render_new( 100 ); |
976 dw_window_set_font(textbox1, FIXEDFONT); | 985 dw_window_set_font(textbox1, FIXEDFONT); |
977 dw_font_text_extents_get(textbox1, NULL, "(g", &font_width, &font_height); | 986 dw_font_text_extents_get(textbox1, NULL, "(g", &font_width, &font_height); |
978 font_width = font_width / 2; | 987 font_width = font_width / 2; |
979 vscrollbox = dw_box_new(BOXVERT, 0); | 988 vscrollbox = dw_box_new(BOXVERT, 0); |
980 dw_box_pack_start(vscrollbox, textbox1, font_width*width1, font_height*rows, FALSE, TRUE, 0); | 989 dw_box_pack_start(vscrollbox, textbox1, font_width*width1, font_height*rows, FALSE, TRUE, 0); |
981 dw_box_pack_start(vscrollbox, 0, (font_width*(width1+1)), SCROLLBARWIDTH, FALSE, FALSE, 0); | 990 dw_box_pack_start(vscrollbox, 0, (font_width*(width1+1)), hscrollbarheight, FALSE, FALSE, 0); |
982 dw_box_pack_start(pagebox, vscrollbox, 0, 0, FALSE, TRUE, 0); | 991 dw_box_pack_start(pagebox, vscrollbox, 0, 0, FALSE, TRUE, 0); |
983 | 992 |
984 /* pack empty space 1 character wide */ | 993 /* pack empty space 1 character wide */ |
985 dw_box_pack_start(pagebox, 0, font_width, 0, FALSE, TRUE, 0); | 994 dw_box_pack_start(pagebox, 0, font_width, 0, FALSE, TRUE, 0); |
986 | 995 |
991 /* create render box for filecontents pixmap */ | 1000 /* create render box for filecontents pixmap */ |
992 textbox2 = dw_render_new( 101 ); | 1001 textbox2 = dw_render_new( 101 ); |
993 dw_box_pack_start( textboxA, textbox2, 10, 10, TRUE, TRUE, 0); | 1002 dw_box_pack_start( textboxA, textbox2, 10, 10, TRUE, TRUE, 0); |
994 dw_window_set_font(textbox2, FIXEDFONT); | 1003 dw_window_set_font(textbox2, FIXEDFONT); |
995 /* create horizonal scrollbar */ | 1004 /* create horizonal scrollbar */ |
996 hscrollbar = dw_scrollbar_new(FALSE, 50); | 1005 dw_box_pack_start( textboxA, hscrollbar, -1, -1, TRUE, FALSE, 0); |
997 dw_box_pack_start( textboxA, hscrollbar, 100, SCROLLBARWIDTH, TRUE, FALSE, 0); | |
998 | 1006 |
999 /* create vertical scrollbar */ | 1007 /* create vertical scrollbar */ |
1000 vscrollbox = dw_box_new(BOXVERT, 0); | 1008 vscrollbox = dw_box_new(BOXVERT, 0); |
1001 vscrollbar = dw_scrollbar_new(TRUE, 50); | 1009 dw_box_pack_start(vscrollbox, vscrollbar, -1, -1, FALSE, TRUE, 0); |
1002 dw_box_pack_start(vscrollbox, vscrollbar, SCROLLBARWIDTH, 100, FALSE, TRUE, 0); | |
1003 /* Pack an area of empty space 14x14 pixels */ | 1010 /* Pack an area of empty space 14x14 pixels */ |
1004 dw_box_pack_start(vscrollbox, 0, SCROLLBARWIDTH, SCROLLBARWIDTH, FALSE, FALSE, 0); | 1011 dw_box_pack_start(vscrollbox, 0, vscrollbarwidth, hscrollbarheight, FALSE, FALSE, 0); |
1005 dw_box_pack_start(pagebox, vscrollbox, 0, 0, FALSE, TRUE, 0); | 1012 dw_box_pack_start(pagebox, vscrollbox, 0, 0, FALSE, TRUE, 0); |
1006 | 1013 |
1007 text1pm = dw_pixmap_new( textbox1, font_width*width1, font_height*rows, (int)depth ); | 1014 text1pm = dw_pixmap_new( textbox1, font_width*width1, font_height*rows, (int)depth ); |
1008 text2pm = dw_pixmap_new( textbox2, font_width*cols, font_height*rows, (int)depth ); | 1015 text2pm = dw_pixmap_new( textbox2, font_width*cols, font_height*rows, (int)depth ); |
1009 image = dw_pixmap_new_from_file(textbox2, "image/test"); | 1016 image = dw_pixmap_new_from_file(textbox2, "image/test"); |