Mercurial > dwindows
comparison dwtest.c @ 503:f3ed8dda02f8
Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
Also, added _fix_button_owner() to dw_window_redraw() on OS/2.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 18 Jan 2004 06:33:25 +0000 |
parents | d6e07d292145 |
children | 078a40ba2e41 |
comparison
equal
deleted
inserted
replaced
502:56ea525c1a24 | 503:f3ed8dda02f8 |
---|---|
25 #define SCROLLBARWIDTH 14 | 25 #define SCROLLBARWIDTH 14 |
26 | 26 |
27 unsigned long flStyle = DW_FCF_SYSMENU | DW_FCF_TITLEBAR | | 27 unsigned long flStyle = DW_FCF_SYSMENU | DW_FCF_TITLEBAR | |
28 DW_FCF_SHELLPOSITION | DW_FCF_TASKLIST | DW_FCF_DLGBORDER; | 28 DW_FCF_SHELLPOSITION | DW_FCF_TASKLIST | DW_FCF_DLGBORDER; |
29 | 29 |
30 void create_button( int); | |
31 | |
30 #ifdef __MAC__ | 32 #ifdef __MAC__ |
31 int main(int argc, char *argv[]) | 33 int main(int argc, char *argv[]) |
32 { | 34 { |
33 DWEnv env; | 35 DWEnv env; |
34 HWND window; | 36 HWND window; |
35 | 37 |
36 dw_init(TRUE, argc, argv); | 38 dw_init(TRUE, argc, argv); |
37 | 39 |
38 window = dw_window_new(HWND_DESKTOP, "Test Window", flStyle); | 40 window = dw_window_new(HWND_DESKTOP, "Test Window", flStyle); |
39 dw_window_set_pos_size(window, 100, 100, 300, 200); | 41 dw_window_set_pos_size(window, 100, 100, 300, 200); |
40 dw_window_show(window); | 42 dw_window_show(window); |
41 | 43 |
42 dw_environment_query(&env); | 44 dw_environment_query(&env); |
43 dw_messagebox("Title", DW_MB_OK | DW_MB_INFORMATION, "Operating System: %s %d.%d\nBuild: %d.%d\n", | 45 dw_messagebox("Title", DW_MB_OK | DW_MB_INFORMATION, "Operating System: %s %d.%d\nBuild: %d.%d\n", |
44 env.osName, env.MajorVersion, env.MinorVersion, env.MajorBuild, env.MinorBuild); | 46 env.osName, env.MajorVersion, env.MinorVersion, env.MajorBuild, env.MinorBuild); |
45 | 47 |
46 return 0; | 48 return 0; |
47 } | 49 } |
48 #else | 50 #else |
49 | 51 |
50 HWND mainwindow, | 52 HWND mainwindow, |
56 notebookbox, | 58 notebookbox, |
57 notebookbox1, | 59 notebookbox1, |
58 notebookbox2, | 60 notebookbox2, |
59 notebookbox3, | 61 notebookbox3, |
60 notebookbox4, | 62 notebookbox4, |
63 notebookbox5, | |
61 notebook, | 64 notebook, |
62 vscrollbar, | 65 vscrollbar, |
63 hscrollbar, | 66 hscrollbar, |
64 status, status1, | 67 status, status1, |
65 container_status, | 68 container_status, |
71 pagebox, | 74 pagebox, |
72 treebox, | 75 treebox, |
73 containerbox, | 76 containerbox, |
74 textbox1, textbox2, textboxA, | 77 textbox1, textbox2, textboxA, |
75 gap_box, | 78 gap_box, |
76 buttonbox; | 79 buttonbox, |
80 buttonboxperm, | |
81 filetoolbarbox; | |
82 | |
83 void *containerinfo; | |
77 | 84 |
78 HPIXMAP text1pm,text2pm; | 85 HPIXMAP text1pm,text2pm; |
79 unsigned long fileicon,foldericon,mle_point=-1; | 86 unsigned long fileicon,foldericon,mle_point=-1; |
80 | 87 |
81 int font_width = 8; | 88 int font_width = 8; |
324 } | 331 } |
325 | 332 |
326 int DWSIGNAL browse_callback(HWND window, void *data) | 333 int DWSIGNAL browse_callback(HWND window, void *data) |
327 { | 334 { |
328 char *tmp; | 335 char *tmp; |
329 tmp = dw_file_browse("test string", NULL, "c", DW_DIRECTORY_OPEN ); | 336 tmp = dw_file_browse("test string", NULL, "c", DW_FILE_OPEN ); |
330 if ( tmp ) | 337 if ( tmp ) |
331 { | 338 { |
332 if ( current_file ) | 339 if ( current_file ) |
333 { | 340 { |
334 dw_free( current_file ); | 341 dw_free( current_file ); |
336 current_file = tmp; | 343 current_file = tmp; |
337 dw_window_set_text( entryfield, current_file ); | 344 dw_window_set_text( entryfield, current_file ); |
338 read_file(); | 345 read_file(); |
339 draw_file(0,0); | 346 draw_file(0,0); |
340 } | 347 } |
348 return 0; | |
349 } | |
350 | |
351 int DWSIGNAL button_callback(HWND window, void *data) | |
352 { | |
353 return 0; | |
354 } | |
355 | |
356 int DWSIGNAL redraw_button_box_callback(HWND window, void *data) | |
357 { | |
358 #if 0 | |
359 dw_window_destroy( filetoolbarbox ); | |
360 create_button(1); | |
361 #else | |
362 dw_window_enable( window); | |
363 #endif | |
341 return 0; | 364 return 0; |
342 } | 365 } |
343 | 366 |
344 /* Callback to handle user selection of the scrollbar position */ | 367 /* Callback to handle user selection of the scrollbar position */ |
345 void DWSIGNAL scrollbar_valuechanged(HWND hwnd, int value, void *data) | 368 void DWSIGNAL scrollbar_valuechanged(HWND hwnd, int value, void *data) |
431 int DWSIGNAL container_select_cb( HWND window, HTREEITEM item, char *text, void *data, void *itemdata ) | 454 int DWSIGNAL container_select_cb( HWND window, HTREEITEM item, char *text, void *data, void *itemdata ) |
432 { | 455 { |
433 char buf[200]; | 456 char buf[200]; |
434 char *str; | 457 char *str; |
435 HWND statline = (HWND)data; | 458 HWND statline = (HWND)data; |
459 unsigned long size; | |
436 | 460 |
437 sprintf(buf,"DW_SIGNAL_ITEM_SELECT: Window: %x Item: %x Text: %s Itemdata: %x", (unsigned int)window, (unsigned int)item, text, (unsigned int)itemdata ); | 461 sprintf(buf,"DW_SIGNAL_ITEM_SELECT: Window: %x Item: %x Text: %s Itemdata: %x", (unsigned int)window, (unsigned int)item, text, (unsigned int)itemdata ); |
438 dw_window_set_text( statline, buf); | 462 dw_window_set_text( statline, buf); |
439 sprintf(buf,"\r\nDW_SIGNAL_ITEM_SELECT: Window: %x Item: %x Text: %s Itemdata: %x\r\n", (unsigned int)window, (unsigned int)item, text, (unsigned int)itemdata ); | 463 sprintf(buf,"\r\nDW_SIGNAL_ITEM_SELECT: Window: %x Item: %x Text: %s Itemdata: %x\r\n", (unsigned int)window, (unsigned int)item, text, (unsigned int)itemdata ); |
440 mle_point = dw_mle_import( container_mle, buf, mle_point); | 464 mle_point = dw_mle_import( container_mle, buf, mle_point); |
445 mle_point = dw_mle_import( container_mle, buf, mle_point); | 469 mle_point = dw_mle_import( container_mle, buf, mle_point); |
446 str = dw_container_query_next(container, DW_CRA_SELECTED); | 470 str = dw_container_query_next(container, DW_CRA_SELECTED); |
447 } | 471 } |
448 /* Make the last inserted point the cursor location */ | 472 /* Make the last inserted point the cursor location */ |
449 dw_mle_set(container_mle, mle_point); | 473 dw_mle_set(container_mle, mle_point); |
474 /* set the details of item 0 to new data */ | |
475 fprintf(stderr,"In cb: container: %x containerinfo: %x icon: %x\n", container, containerinfo, fileicon); | |
476 dw_filesystem_change_file(container, 0, "new data", fileicon); | |
477 size = 999; | |
478 fprintf(stderr,"In cb: container: %x containerinfo: %x icon: %x\n", container, containerinfo, fileicon); | |
479 dw_filesystem_change_item(container, 0, 0, &size); | |
450 return 0; | 480 return 0; |
451 } | 481 } |
452 | 482 |
453 int DWSIGNAL switch_page_cb( HWND window, unsigned long page_num, void *itemdata ) | 483 int DWSIGNAL switch_page_cb( HWND window, unsigned long page_num, void *itemdata ) |
454 { | 484 { |
632 char *names[3]; | 662 char *names[3]; |
633 char buffer[100]; | 663 char buffer[100]; |
634 unsigned long flags[3] = { DW_CFA_ULONG | DW_CFA_RIGHT | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR, | 664 unsigned long flags[3] = { DW_CFA_ULONG | DW_CFA_RIGHT | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR, |
635 DW_CFA_TIME | DW_CFA_CENTER | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR, | 665 DW_CFA_TIME | DW_CFA_CENTER | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR, |
636 DW_CFA_DATE | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR }; | 666 DW_CFA_DATE | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR }; |
637 void *containerinfo; | |
638 int z; | 667 int z; |
639 CTIME time; | 668 CTIME time; |
640 CDATE date; | 669 CDATE date; |
641 unsigned long size, thisicon; | 670 unsigned long size, thisicon; |
642 | 671 |
666 sprintf(names[z],"Don't allocate from stack: Item: %d",z); | 695 sprintf(names[z],"Don't allocate from stack: Item: %d",z); |
667 size = z*100; | 696 size = z*100; |
668 sprintf(buffer, "Filename %d",z+1); | 697 sprintf(buffer, "Filename %d",z+1); |
669 if (z == 0 ) thisicon = foldericon; | 698 if (z == 0 ) thisicon = foldericon; |
670 else thisicon = fileicon; | 699 else thisicon = fileicon; |
700 fprintf(stderr,"Initial: container: %x containerinfo: %x icon: %x\n", container, containerinfo, thisicon); | |
671 dw_filesystem_set_file(container, containerinfo, z, buffer, thisicon); | 701 dw_filesystem_set_file(container, containerinfo, z, buffer, thisicon); |
672 dw_filesystem_set_item(container, containerinfo, 0, z, &size); | 702 dw_filesystem_set_item(container, containerinfo, 0, z, &size); |
673 | 703 |
674 time.seconds = z+10; | 704 time.seconds = z+10; |
675 time.minutes = z+10; | 705 time.minutes = z+10; |
704 | 734 |
705 /* Return TRUE so we get called again */ | 735 /* Return TRUE so we get called again */ |
706 return TRUE; | 736 return TRUE; |
707 } | 737 } |
708 | 738 |
739 | |
740 void buttons_add(void) | |
741 { | |
742 HWND buttonsbox,abutton1,abutton2; | |
743 | |
744 /* create a box to pack into the notebook page */ | |
745 buttonsbox = dw_box_new(BOXVERT, 2); | |
746 dw_box_pack_start( notebookbox5, buttonsbox, 25, 200, TRUE, TRUE, 0); | |
747 dw_window_set_color(buttonsbox, DW_CLR_RED, DW_CLR_RED); | |
748 /* | |
749 * Create our file toolbar boxes... | |
750 */ | |
751 buttonboxperm = dw_box_new( BOXVERT, 0 ); | |
752 dw_box_pack_start( buttonsbox, buttonboxperm, 25, 0, FALSE, TRUE, 2 ); | |
753 dw_window_set_color(buttonboxperm, DW_CLR_WHITE, DW_CLR_WHITE); | |
754 abutton1 = dw_bitmapbutton_new_from_file( "Top", 0, "junk" ); | |
755 dw_box_pack_start( buttonboxperm, abutton1, 25, 25, FALSE, FALSE, 0 ); | |
756 dw_signal_connect( abutton1, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(button_callback), NULL ); | |
757 dw_box_pack_start( buttonboxperm, 0, 25, 5, FALSE, FALSE, 0 ); | |
758 abutton2 = dw_bitmapbutton_new_from_file( "Bottom", 0, "junk" ); | |
759 dw_box_pack_start( buttonsbox, abutton2, 25, 25, FALSE, FALSE, 0 ); | |
760 dw_signal_connect( abutton2, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(button_callback), NULL ); | |
761 | |
762 create_button(0); | |
763 } | |
764 | |
765 void create_button( int redraw) | |
766 { | |
767 HWND abutton1; | |
768 filetoolbarbox = dw_box_new( BOXVERT, 0 ); | |
769 dw_box_pack_start( buttonboxperm, filetoolbarbox, 0, 0, TRUE, TRUE, 0 ); | |
770 | |
771 abutton1 = dw_bitmapbutton_new_from_file( "Should be under Top button", 0, "junk" ); | |
772 dw_box_pack_start( filetoolbarbox, abutton1, 25, 25, FALSE, FALSE, 0); | |
773 dw_signal_connect( abutton1, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(redraw_button_box_callback), NULL ); | |
774 dw_box_pack_start( filetoolbarbox, 0, 25, 5, FALSE, FALSE, 0 ); | |
775 | |
776 abutton1 = dw_bitmapbutton_new_from_file( "Should be under Top button", 0, "junk" ); | |
777 dw_box_pack_start( filetoolbarbox, abutton1, 25, 25, FALSE, FALSE, 0); | |
778 dw_signal_connect( abutton1, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(redraw_button_box_callback), NULL ); | |
779 dw_box_pack_start( filetoolbarbox, 0, 25, 5, FALSE, FALSE, 0 ); | |
780 | |
781 abutton1 = dw_bitmapbutton_new_from_file( "Should be under Top button", 0, "junk" ); | |
782 dw_box_pack_start( filetoolbarbox, abutton1, 25, 25, FALSE, FALSE, 0); | |
783 dw_signal_connect( abutton1, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(redraw_button_box_callback), NULL ); | |
784 dw_box_pack_start( filetoolbarbox, 0, 25, 5, FALSE, FALSE, 0 ); | |
785 if ( redraw ) | |
786 { | |
787 dw_window_redraw( filetoolbarbox ); | |
788 dw_window_redraw( mainwindow ); | |
789 } | |
790 } | |
791 | |
709 /* | 792 /* |
710 * Let's demonstrate the functionality of this library. :) | 793 * Let's demonstrate the functionality of this library. :) |
711 */ | 794 */ |
712 int main(int argc, char *argv[]) | 795 int main(int argc, char *argv[]) |
713 { | 796 { |
714 ULONG notebookpage1; | 797 ULONG notebookpage1; |
715 ULONG notebookpage2; | 798 ULONG notebookpage2; |
716 ULONG notebookpage3; | 799 ULONG notebookpage3; |
717 ULONG notebookpage4; | 800 ULONG notebookpage4; |
801 ULONG notebookpage5; | |
718 | 802 |
719 dw_init(TRUE, argc, argv); | 803 dw_init(TRUE, argc, argv); |
720 | 804 |
721 mainwindow = dw_window_new( HWND_DESKTOP, "dwindows test", flStyle | DW_FCF_SIZEBORDER | DW_FCF_MINMAX ); | 805 mainwindow = dw_window_new( HWND_DESKTOP, "dwindows test", flStyle | DW_FCF_SIZEBORDER | DW_FCF_MINMAX ); |
722 | 806 |
749 notebookpage4 = dw_notebook_page_new( notebook, 1, FALSE ); | 833 notebookpage4 = dw_notebook_page_new( notebook, 1, FALSE ); |
750 dw_notebook_pack( notebook, notebookpage4, notebookbox4 ); | 834 dw_notebook_pack( notebook, notebookpage4, notebookbox4 ); |
751 dw_notebook_page_set_text( notebook, notebookpage4, "container"); | 835 dw_notebook_page_set_text( notebook, notebookpage4, "container"); |
752 container_add(); | 836 container_add(); |
753 | 837 |
838 notebookbox5 = dw_box_new( BOXVERT, 5 ); | |
839 notebookpage5 = dw_notebook_page_new( notebook, 1, FALSE ); | |
840 dw_notebook_pack( notebook, notebookpage5, notebookbox5 ); | |
841 dw_notebook_page_set_text( notebook, notebookpage5, "buttons"); | |
842 buttons_add(); | |
843 | |
754 dw_signal_connect(mainwindow, DW_SIGNAL_DELETE, DW_SIGNAL_FUNC(exit_callback), (void *)mainwindow); | 844 dw_signal_connect(mainwindow, DW_SIGNAL_DELETE, DW_SIGNAL_FUNC(exit_callback), (void *)mainwindow); |
755 timerid = dw_timer_connect(1000, DW_SIGNAL_FUNC(timer_callback), 0); | 845 timerid = dw_timer_connect(1000, DW_SIGNAL_FUNC(timer_callback), 0); |
756 dw_window_set_icon(mainwindow, fileicon); | 846 dw_window_set_icon(mainwindow, fileicon); |
757 dw_window_set_usize(mainwindow, 640, 480); | 847 dw_window_set_usize(mainwindow, 640, 480); |
758 dw_window_show(mainwindow); | 848 dw_window_show(mainwindow); |