comparison dwtest.c @ 957:beed3e7f9d4b

Fixes to flip pixmaps when loading from file or data on Mac. Also added bitblt test to the test program.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 02 May 2011 04:45:38 +0000
parents 8b73a45ae424
children 5320a168cc0d
comparison
equal deleted inserted replaced
956:a3e4cebf3c99 957:beed3e7f9d4b
28 28
29 #define SCROLLBARWIDTH 14 29 #define SCROLLBARWIDTH 14
30 #define MAX_WIDGETS 20 30 #define MAX_WIDGETS 20
31 31
32 unsigned long flStyle = DW_FCF_SYSMENU | DW_FCF_TITLEBAR | 32 unsigned long flStyle = DW_FCF_SYSMENU | DW_FCF_TITLEBAR |
33 DW_FCF_SHELLPOSITION | DW_FCF_TASKLIST | DW_FCF_DLGBORDER; 33 DW_FCF_SHELLPOSITION | DW_FCF_TASKLIST | DW_FCF_DLGBORDER;
34 34
35 unsigned long current_color = DW_RGB(100,100,100); 35 unsigned long current_color = DW_RGB(100,100,100);
36 36
37 int iteration = 0; 37 int iteration = 0;
38 void create_button( int); 38 void create_button( int);
66 vscrollbar, 66 vscrollbar,
67 hscrollbar, 67 hscrollbar,
68 status1, 68 status1,
69 status2, 69 status2,
70 rendcombo, 70 rendcombo,
71 imagexspin,
72 imageyspin,
71 container_status, 73 container_status,
72 tree_status, 74 tree_status,
73 stext, 75 stext,
74 tree, 76 tree,
75 container, 77 container,
95 void *containerinfo; 97 void *containerinfo;
96 98
97 99
98 int menu_enabled = 1; 100 int menu_enabled = 1;
99 101
100 HPIXMAP text1pm,text2pm; 102 HPIXMAP text1pm,text2pm,image;
101 HICN fileicon,foldericon; 103 HICN fileicon,foldericon;
102 int mle_point=-1; 104 int mle_point=-1;
105 int image_x = 20, image_y = 20;
103 106
104 int font_width = 8; 107 int font_width = 8;
105 int font_height=12; 108 int font_height=12;
106 int rows=100,width1=6,cols=80; 109 int rows=100,width1=6,cols=80;
107 char *current_file = NULL; 110 char *current_file = NULL;
310 { 313 {
311 int width = (int)DW_PIXMAP_WIDTH(text2pm), height = (int)DW_PIXMAP_HEIGHT(text2pm); 314 int width = (int)DW_PIXMAP_WIDTH(text2pm), height = (int)DW_PIXMAP_HEIGHT(text2pm);
312 HPIXMAP pixmap = direct ? NULL : text2pm; 315 HPIXMAP pixmap = direct ? NULL : text2pm;
313 HWND window = direct ? textbox2 : 0; 316 HWND window = direct ? textbox2 : 0;
314 317
318 image_x = (int)dw_spinbutton_get_pos(imagexspin);
319 image_y = (int)dw_spinbutton_get_pos(imageyspin);
320
315 dw_color_foreground_set(DW_CLR_WHITE); 321 dw_color_foreground_set(DW_CLR_WHITE);
316 dw_draw_rect(window, pixmap, TRUE, 0, 0, width, height); 322 dw_draw_rect(window, pixmap, TRUE, 0, 0, width, height);
317 dw_color_foreground_set(DW_CLR_DARKPINK); 323 dw_color_foreground_set(DW_CLR_DARKPINK);
318 dw_draw_rect(window, pixmap, TRUE, 10, 10, width - 20, height - 20); 324 dw_draw_rect(window, pixmap, TRUE, 10, 10, width - 20, height - 20);
319 dw_color_foreground_set(DW_CLR_GREEN); 325 dw_color_foreground_set(DW_CLR_GREEN);
320 dw_color_background_set(DW_CLR_DARKRED); 326 dw_color_background_set(DW_CLR_DARKRED);
321 dw_draw_text(window, pixmap, 10, 10, "This should be aligned with the edges."); 327 dw_draw_text(window, pixmap, 10, 10, "This should be aligned with the edges.");
328 if(image)
329 {
330 dw_pixmap_bitblt(window, pixmap, image_x, image_y, DW_PIXMAP_WIDTH(image), DW_PIXMAP_HEIGHT(image), 0, image, 0, 0);
331 }
322 332
323 /* If we aren't drawing direct do a bitblt */ 333 /* If we aren't drawing direct do a bitblt */
324 if(!direct) 334 if(!direct)
325 { 335 {
326 text_expose( textbox2, NULL, NULL); 336 text_expose( textbox2, NULL, NULL);
797 } 807 }
798 808
799 void text_add(void) 809 void text_add(void)
800 { 810 {
801 unsigned long depth = dw_color_depth_get(); 811 unsigned long depth = dw_color_depth_get();
802 HWND vscrollbox, hbox, button1; 812 HWND vscrollbox, hbox, button1, label;
803 813
804 /* create a box to pack into the notebook page */ 814 /* create a box to pack into the notebook page */
805 pagebox = dw_box_new(BOXHORZ, 2); 815 pagebox = dw_box_new(BOXHORZ, 2);
806 dw_box_pack_start( notebookbox2, pagebox, 0, 0, TRUE, TRUE, 0); 816 dw_box_pack_start( notebookbox2, pagebox, 0, 0, TRUE, TRUE, 0);
807 /* now a status area under this box */ 817 /* now a status area under this box */
817 rendcombo = dw_combobox_new( "Shapes Double Buffered", 0 ); 827 rendcombo = dw_combobox_new( "Shapes Double Buffered", 0 );
818 dw_box_pack_start( hbox, rendcombo, 100, 25, TRUE, FALSE, 0); 828 dw_box_pack_start( hbox, rendcombo, 100, 25, TRUE, FALSE, 0);
819 dw_listbox_append(rendcombo, "Shapes Double Buffered"); 829 dw_listbox_append(rendcombo, "Shapes Double Buffered");
820 dw_listbox_append(rendcombo, "Shapes Direct"); 830 dw_listbox_append(rendcombo, "Shapes Direct");
821 dw_listbox_append(rendcombo, "File Display"); 831 dw_listbox_append(rendcombo, "File Display");
832 label = dw_text_new("Image X:", 100);
833 dw_window_set_style(label, DW_DT_VCENTER, DW_DT_VCENTER);
834 dw_box_pack_start( hbox, label, 55, 25, FALSE, FALSE, 0);
835 imagexspin = dw_spinbutton_new("20", 1021);
836 dw_box_pack_start( hbox, imagexspin, 20, 25, TRUE, FALSE, 0);
837 label = dw_text_new("Y:", 100);
838 dw_window_set_style(label, DW_DT_VCENTER, DW_DT_VCENTER);
839 dw_box_pack_start( hbox, label, 20, 25, FALSE, FALSE, 0);
840 imageyspin = dw_spinbutton_new("20", 1021);
841 dw_box_pack_start( hbox, imageyspin, 20, 25, TRUE, FALSE, 0);
842 dw_spinbutton_set_limits(imagexspin, 2000, 0);
843 dw_spinbutton_set_limits(imageyspin, 2000, 0);
844 dw_spinbutton_set_pos(imagexspin, 20);
845 dw_spinbutton_set_pos(imageyspin, 20);
846
822 button1 = dw_button_new( "Refresh", 1223L ); 847 button1 = dw_button_new( "Refresh", 1223L );
823 dw_box_pack_start( hbox, button1, 50, 25, TRUE, FALSE, 0); 848 dw_box_pack_start( hbox, button1, 50, 25, TRUE, FALSE, 0);
824 849
825 /* create render box for number pixmap */ 850 /* create render box for number pixmap */
826 textbox1 = dw_render_new( 100 ); 851 textbox1 = dw_render_new( 100 );
855 dw_box_pack_start(vscrollbox, 0, SCROLLBARWIDTH, SCROLLBARWIDTH, FALSE, FALSE, 0); 880 dw_box_pack_start(vscrollbox, 0, SCROLLBARWIDTH, SCROLLBARWIDTH, FALSE, FALSE, 0);
856 dw_box_pack_start(pagebox, vscrollbox, 0, 0, FALSE, TRUE, 0); 881 dw_box_pack_start(pagebox, vscrollbox, 0, 0, FALSE, TRUE, 0);
857 882
858 text1pm = dw_pixmap_new( textbox1, font_width*width1, font_height*rows, (int)depth ); 883 text1pm = dw_pixmap_new( textbox1, font_width*width1, font_height*rows, (int)depth );
859 text2pm = dw_pixmap_new( textbox2, font_width*cols, font_height*rows, (int)depth ); 884 text2pm = dw_pixmap_new( textbox2, font_width*cols, font_height*rows, (int)depth );
885 image = dw_pixmap_new_from_file(textbox2, "mac/folder.png");
886 if(!image)
887 image = dw_pixmap_new_from_file(textbox2, "~/folder.png");
888
860 889
861 dw_messagebox("DWTest", DW_MB_OK|DW_MB_INFORMATION, "Width: %d Height: %d\n", font_width, font_height); 890 dw_messagebox("DWTest", DW_MB_OK|DW_MB_INFORMATION, "Width: %d Height: %d\n", font_width, font_height);
862 dw_draw_rect(0, text1pm, TRUE, 0, 0, font_width*width1, font_height*rows); 891 dw_draw_rect(0, text1pm, TRUE, 0, 0, font_width*width1, font_height*rows);
863 dw_draw_rect(0, text2pm, TRUE, 0, 0, font_width*cols, font_height*rows); 892 dw_draw_rect(0, text2pm, TRUE, 0, 0, font_width*cols, font_height*rows);
864 dw_signal_connect(textbox1, DW_SIGNAL_EXPOSE, DW_SIGNAL_FUNC(text_expose), NULL); 893 dw_signal_connect(textbox1, DW_SIGNAL_EXPOSE, DW_SIGNAL_FUNC(text_expose), NULL);