comparison dwtest.c @ 1560:ee47bda26916

Added some comments and a couple more tests to dwtest.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 17 Jan 2012 16:33:21 +0000
parents bc3a11fe9a46
children 71e0a3ad07f7
comparison
equal deleted inserted replaced
1559:bc3a11fe9a46 1560:ee47bda26916
1 /*
2 * An example Dynamic Windows application and
3 * testing ground for Dynamic Windows features.
4 * By: Brian Smith and Mark Hessling
5 */
1 #include <stdlib.h> 6 #include <stdlib.h>
2 #include <string.h> 7 #include <string.h>
3 #include <stdio.h> 8 #include <stdio.h>
4 #include "dw.h" 9 #include "dw.h"
5 10
571 576
572 int DWSIGNAL exit_callback(HWND window, void *data) 577 int DWSIGNAL exit_callback(HWND window, void *data)
573 { 578 {
574 if(dw_messagebox("dwtest", DW_MB_YESNO | DW_MB_QUESTION, "Are you sure you want to exit?")) 579 if(dw_messagebox("dwtest", DW_MB_YESNO | DW_MB_QUESTION, "Are you sure you want to exit?"))
575 { 580 {
576 dw_taskbar_delete(textbox1, fileicon);
577 dw_window_destroy((HWND)data);
578 dw_main_quit(); 581 dw_main_quit();
579 } 582 }
580 return TRUE; 583 return TRUE;
581 } 584 }
582 585
903 sprintf(buf, "%s: %dx%d", data ? "motion_notify" : "button_press", x, y); 906 sprintf(buf, "%s: %dx%d", data ? "motion_notify" : "button_press", x, y);
904 dw_window_set_text(status2, buf); 907 dw_window_set_text(status2, buf);
905 return 0; 908 return 0;
906 } 909 }
907 910
911 int DWSIGNAL show_window_callback(HWND window, void *data)
912 {
913 HWND thiswindow = (HWND)data;
914 if(thiswindow)
915 {
916 dw_window_show(thiswindow);
917 dw_window_raise(thiswindow);
918 }
919 return TRUE;
920 }
921
908 int API context_menu_event(HWND window, int x, int y, int buttonmask, void *data) 922 int API context_menu_event(HWND window, int x, int y, int buttonmask, void *data)
909 { 923 {
910 HMENUI hwndMenu = dw_menu_new(0L); 924 HMENUI hwndMenu = dw_menu_new(0L);
911 HWND menuitem = dw_menu_append_item(hwndMenu, "~Quit", 1019, 0L, TRUE, FALSE, DW_NOMENU); 925 HWND menuitem = dw_menu_append_item(hwndMenu, "~Quit", DW_MENU_POPUP, 0L, TRUE, FALSE, DW_NOMENU);
912 long px, py; 926 long px, py;
913 927
914 dw_signal_connect(menuitem, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(exit_callback), (void *)mainwindow); 928 dw_signal_connect(menuitem, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(exit_callback), (void *)mainwindow);
929 dw_menu_append_item(hwndMenu, DW_MENU_SEPARATOR, DW_MENU_POPUP, 0L, TRUE, FALSE, DW_NOMENU);
930 menuitem = dw_menu_append_item(hwndMenu, "~Show Window", DW_MENU_POPUP, 0L, TRUE, FALSE, DW_NOMENU);
931 dw_signal_connect(menuitem, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(show_window_callback), (void *)mainwindow);
915 dw_pointer_query_pos(&px, &py); 932 dw_pointer_query_pos(&px, &py);
916 /* Use the toplevel window handle here.... because on the Mac.. 933 /* Use the toplevel window handle here.... because on the Mac..
917 * using the control itself, when a different tab is active 934 * using the control itself, when a different tab is active
918 * the control is removed from the window and can no longer 935 * the control is removed from the window and can no longer
919 * handle the messages. 936 * handle the messages.
1598 ULONG notebookpage6; 1615 ULONG notebookpage6;
1599 ULONG notebookpage7; 1616 ULONG notebookpage7;
1600 ULONG notebookpage8; 1617 ULONG notebookpage8;
1601 ULONG notebookpage9; 1618 ULONG notebookpage9;
1602 1619
1620 /* Initialize the Dynamic Windows engine */
1603 dw_init(TRUE, argc, argv); 1621 dw_init(TRUE, argc, argv);
1604 1622
1623 /* Create our window */
1605 mainwindow = dw_window_new( HWND_DESKTOP, "dwindows test", flStyle | DW_FCF_SIZEBORDER | DW_FCF_MINMAX); 1624 mainwindow = dw_window_new( HWND_DESKTOP, "dwindows test", flStyle | DW_FCF_SIZEBORDER | DW_FCF_MINMAX);
1606 dw_window_set_icon(mainwindow, fileicon); 1625 dw_window_set_icon(mainwindow, fileicon);
1607 1626
1608 menu_add(); 1627 menu_add();
1609 1628
1688 dw_signal_connect(mainwindow, DW_SIGNAL_DELETE, DW_SIGNAL_FUNC(exit_callback), (void *)mainwindow); 1707 dw_signal_connect(mainwindow, DW_SIGNAL_DELETE, DW_SIGNAL_FUNC(exit_callback), (void *)mainwindow);
1689 timerid = dw_timer_connect(2000, DW_SIGNAL_FUNC(timer_callback), 0); 1708 timerid = dw_timer_connect(2000, DW_SIGNAL_FUNC(timer_callback), 0);
1690 dw_window_set_size(mainwindow, 640, 520); 1709 dw_window_set_size(mainwindow, 640, 520);
1691 dw_window_show(mainwindow); 1710 dw_window_show(mainwindow);
1692 1711
1712 /* Now that the window is created and shown...
1713 * run the main loop until we get dw_main_quit()
1714 */
1693 dw_main(); 1715 dw_main();
1694 1716
1695 dw_debug("dwtest exiting..."); 1717 /* Now that the loop is done we can cleanup */
1718 dw_taskbar_delete(textbox1, fileicon);
1719 dw_window_destroy(mainwindow);
1720
1721 dw_debug("dwtest exiting...\n");
1722 /* Call dw_exit() to shutdown the Dynamic Windows engine */
1696 dw_exit(0); 1723 dw_exit(0);
1697 return 0; 1724 return 0;
1698 } 1725 }