comparison dwtest.c @ 1137:e24e5a13ff2c

Added code to test the new print functions in dwtest. GTK3 code mostly works except the for the text. Added stub print functions to all platforms besides GTK3. Need to decide what to do about GTK2; the GTK3 code will work in GTK 2.10 and later, but will require switching to cairo. Mac/Win/OS2 code coming soon. :)
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 09 Sep 2011 09:17:09 +0000
parents 404b639f096b
children 88cc189b5e56
comparison
equal deleted inserted replaced
1136:1a5b0908659b 1137:e24e5a13ff2c
331 text_expose( textbox1, NULL, NULL); 331 text_expose( textbox1, NULL, NULL);
332 text_expose( textbox2, NULL, NULL); 332 text_expose( textbox2, NULL, NULL);
333 } 333 }
334 } 334 }
335 335
336 void draw_shapes(int direct) 336 void draw_shapes(int direct, HPIXMAP hpma)
337 { 337 {
338 int width = (int)DW_PIXMAP_WIDTH(text2pm), height = (int)DW_PIXMAP_HEIGHT(text2pm); 338 HPIXMAP hpm = hpma ? hpma : text2pm;
339 HPIXMAP pixmap = direct ? NULL : text2pm; 339 int width = (int)DW_PIXMAP_WIDTH(hpm), height = (int)DW_PIXMAP_HEIGHT(hpm);
340 HPIXMAP pixmap = direct ? NULL : hpm;
340 HWND window = direct ? textbox2 : 0; 341 HWND window = direct ? textbox2 : 0;
341 342
342 image_x = (int)dw_spinbutton_get_pos(imagexspin); 343 image_x = (int)dw_spinbutton_get_pos(imagexspin);
343 image_y = (int)dw_spinbutton_get_pos(imageyspin); 344 image_y = (int)dw_spinbutton_get_pos(imageyspin);
344 345
353 { 354 {
354 dw_pixmap_bitblt(window, pixmap, image_x, image_y, (int)DW_PIXMAP_WIDTH(image), (int)DW_PIXMAP_HEIGHT(image), 0, image, 0, 0); 355 dw_pixmap_bitblt(window, pixmap, image_x, image_y, (int)DW_PIXMAP_WIDTH(image), (int)DW_PIXMAP_HEIGHT(image), 0, image, 0, 0);
355 } 356 }
356 357
357 /* If we aren't drawing direct do a bitblt */ 358 /* If we aren't drawing direct do a bitblt */
358 if(!direct) 359 if(!direct && !hpma)
359 { 360 {
360 text_expose( textbox2, NULL, NULL); 361 text_expose( textbox2, NULL, NULL);
361 } 362 }
362 } 363 }
363 364
364 void update_render(void) 365 void update_render(void)
365 { 366 {
366 switch(render_type) 367 switch(render_type)
367 { 368 {
368 case 0: 369 case 0:
369 draw_shapes(FALSE); 370 draw_shapes(FALSE, NULL);
370 break; 371 break;
371 case 1: 372 case 1:
372 draw_shapes(TRUE); 373 draw_shapes(TRUE, NULL);
373 break; 374 break;
374 case 2: 375 case 2:
375 draw_file(current_row, current_col); 376 draw_file(current_row, current_col);
376 break; 377 break;
377 } 378 }
379 }
380
381 int DWSIGNAL draw_page(HPRINT print, HPIXMAP pixmap, int page_num, void *data)
382 {
383 draw_shapes(FALSE, pixmap);
384 return TRUE;
385 }
386
387 int DWSIGNAL print_callback(HWND window, void *data)
388 {
389 HPRINT print = dw_print_new(0, 1, DW_SIGNAL_FUNC(draw_page), NULL);
390 dw_print_run(print, 0);
391 return FALSE;
378 } 392 }
379 393
380 int DWSIGNAL refresh_callback(HWND window, void *data) 394 int DWSIGNAL refresh_callback(HWND window, void *data)
381 { 395 {
382 update_render(); 396 update_render();
841 } 855 }
842 856
843 void text_add(void) 857 void text_add(void)
844 { 858 {
845 unsigned long depth = dw_color_depth_get(); 859 unsigned long depth = dw_color_depth_get();
846 HWND vscrollbox, hbox, button1, label; 860 HWND vscrollbox, hbox, button1, button2, label;
847 861
848 /* create a box to pack into the notebook page */ 862 /* create a box to pack into the notebook page */
849 pagebox = dw_box_new(BOXHORZ, 2); 863 pagebox = dw_box_new(BOXHORZ, 2);
850 dw_box_pack_start( notebookbox2, pagebox, 0, 0, TRUE, TRUE, 0); 864 dw_box_pack_start( notebookbox2, pagebox, 0, 0, TRUE, TRUE, 0);
851 /* now a status area under this box */ 865 /* now a status area under this box */
878 dw_spinbutton_set_pos(imagexspin, 20); 892 dw_spinbutton_set_pos(imagexspin, 20);
879 dw_spinbutton_set_pos(imageyspin, 20); 893 dw_spinbutton_set_pos(imageyspin, 20);
880 894
881 button1 = dw_button_new( "Refresh", 1223L ); 895 button1 = dw_button_new( "Refresh", 1223L );
882 dw_box_pack_start( hbox, button1, 50, 25, TRUE, FALSE, 0); 896 dw_box_pack_start( hbox, button1, 50, 25, TRUE, FALSE, 0);
897 button2 = dw_button_new( "Print", 1224L );
898 dw_box_pack_start( hbox, button2, 50, 25, TRUE, FALSE, 0);
883 899
884 /* create render box for number pixmap */ 900 /* create render box for number pixmap */
885 textbox1 = dw_render_new( 100 ); 901 textbox1 = dw_render_new( 100 );
886 dw_window_set_font(textbox1, FIXEDFONT); 902 dw_window_set_font(textbox1, FIXEDFONT);
887 dw_font_text_extents_get(textbox1, NULL, "(g", &font_width, &font_height); 903 dw_font_text_extents_get(textbox1, NULL, "(g", &font_width, &font_height);
931 dw_signal_connect(textbox2, DW_SIGNAL_MOTION_NOTIFY, DW_SIGNAL_FUNC(motion_notify_event), (void *)1); 947 dw_signal_connect(textbox2, DW_SIGNAL_MOTION_NOTIFY, DW_SIGNAL_FUNC(motion_notify_event), (void *)1);
932 dw_signal_connect(textbox2, DW_SIGNAL_BUTTON_PRESS, DW_SIGNAL_FUNC(motion_notify_event), (void *)0); 948 dw_signal_connect(textbox2, DW_SIGNAL_BUTTON_PRESS, DW_SIGNAL_FUNC(motion_notify_event), (void *)0);
933 dw_signal_connect(hscrollbar, DW_SIGNAL_VALUE_CHANGED, DW_SIGNAL_FUNC(scrollbar_valuechanged_callback), (void *)status1); 949 dw_signal_connect(hscrollbar, DW_SIGNAL_VALUE_CHANGED, DW_SIGNAL_FUNC(scrollbar_valuechanged_callback), (void *)status1);
934 dw_signal_connect(vscrollbar, DW_SIGNAL_VALUE_CHANGED, DW_SIGNAL_FUNC(scrollbar_valuechanged_callback), (void *)status1); 950 dw_signal_connect(vscrollbar, DW_SIGNAL_VALUE_CHANGED, DW_SIGNAL_FUNC(scrollbar_valuechanged_callback), (void *)status1);
935 dw_signal_connect(button1, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(refresh_callback), NULL); 951 dw_signal_connect(button1, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(refresh_callback), NULL);
952 dw_signal_connect(button2, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(print_callback), NULL);
936 dw_signal_connect(rendcombo, DW_SIGNAL_LIST_SELECT, DW_SIGNAL_FUNC(render_select_event_callback), NULL ); 953 dw_signal_connect(rendcombo, DW_SIGNAL_LIST_SELECT, DW_SIGNAL_FUNC(render_select_event_callback), NULL );
937 dw_signal_connect(mainwindow, DW_SIGNAL_KEY_PRESS, DW_SIGNAL_FUNC(keypress_callback), NULL); 954 dw_signal_connect(mainwindow, DW_SIGNAL_KEY_PRESS, DW_SIGNAL_FUNC(keypress_callback), NULL);
938 } 955 }
939 956
940 void tree_add(void) 957 void tree_add(void)