home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / desklib / examples / DeskLib / Examples / !Dialog2EG / c / Main < prev   
Encoding:
Text File  |  1995-06-22  |  2.7 KB  |  121 lines

  1. #include "DeskLib:Dialog2.h"
  2. #include "DeskLib:Event.h"
  3. #include "DeskLib:Resource.h"
  4. #include "DeskLib:Template.h"
  5. #include "DeskLib:Icon.h"
  6. #include "DeskLib:Error.h"
  7. #include "DeskLib:Menu2.h"
  8. #include "DeskLib:Debug.h"
  9.  
  10.  
  11.  
  12. typedef struct    {
  13.  
  14.     struct    {
  15.         dialog2_block    *one, 
  16.                 *two, 
  17.                 *info;
  18.         }
  19.         dialogs;
  20.     
  21.     icon_handle    baricon;
  22.     menu2_handle    iconbarmenu;
  23.     }
  24.     app_block;
  25.     /* This holds all our application's global data.    */
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32. static menu2_handle    IconbarSubmenuHandler( int item, event_pollblock *event, void *reference)
  33. /* Called when a submenu is needed    */
  34. {
  35. app_block    *app = (app_block *) reference;
  36.  
  37. UNUSED( item);    /* It must be item 0    */
  38.  
  39. Dialog2_OpenDialogMenuLeaf( event, app->dialogs.info);
  40.     /* Could check which menuitem this menuwarn is for, and open    */
  41.     /* the apropriate dialog2 box.                    */
  42.  
  43. Debug_Printf( "Just opened the info window...\n");
  44.  
  45. return NULL;    /* We don't want a menu2_handle to be opened as    */
  46.         /* a submenu, so return NULL.            */
  47. }
  48.  
  49.  
  50.  
  51.  
  52. static void    IconbarMenuChoiceHandler( int item, void *reference)
  53. /* Called when a menu-choice is made.    */
  54. {
  55. app_block    *app = (app_block *) reference;
  56.  
  57. Debug_Printf( "Iconbar menu item '%i' has just been chosen\n", item);
  58.  
  59.      if ( item==1)    Dialog2_OpenDialogStatic(    app->dialogs.one, open_WHEREVER);
  60. else if ( item==2)    Dialog2_OpenDialogMenu(        app->dialogs.one, open_CENTERED);
  61. else if ( item==3)    Dialog2_OpenDialogStatic(    app->dialogs.two, open_WHEREVER);
  62. else if ( item==4)    Dialog2_OpenDialogMenu(        app->dialogs.two, open_CENTERED);
  63. else if ( item==5)    Event_CloseDown();
  64.  
  65. }
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73. static void    OpenFn( dialog2_block *dialog2)
  74. /* This is called whenever a dialog is opened.    */
  75. {
  76. UNUSED( dialog2);
  77.  
  78. Debug_Printf( "Dialog %p has just opened\n", dialog2);
  79. /*
  80. Could call Event_Claim( event_CLICK, dialog2->window, event_ANY, functionname, (void *) dialog2)
  81. to get clicks in this dialog window.
  82. */
  83. }
  84.  
  85.  
  86.  
  87.  
  88. int    main( void)
  89. {
  90. static app_block    app;
  91.  
  92. Event_Initialise( "Dialog2 example");
  93. Resource_Initialise( "Dialog2EG");
  94. Template_Initialise();
  95. Template_LoadFile( "Templates");
  96.  
  97.  
  98. app.dialogs.one        = Dialog2_CreateDialogBlock( "one", 0, 1, OpenFn, NULL, NULL);
  99. app.dialogs.two        = Dialog2_CreateDialogBlock( "two", 0, 1, OpenFn, NULL, NULL);
  100. app.dialogs.info    = Dialog2_CreateDialogBlock( "three", 0, 1, OpenFn, NULL, NULL);
  101.     /* Info window.    */
  102.  
  103. app.baricon = Icon_BarIcon( "switcher", iconbar_RIGHT);
  104.  
  105. app.iconbarmenu = Menu2_Create( 
  106.     "Test", 
  107.     ">Info,Open one static,Open one menu, Open two static, Open two menu ,Quit",
  108.     NULL,    /* Custom menu-maker    */
  109.     NULL,    /* Flags function    */
  110.     IconbarSubmenuHandler,
  111.     IconbarMenuChoiceHandler,
  112.     &app
  113.     );
  114.  
  115. Menu2_AttachMenu( window_ICONBAR, app.baricon, app.iconbarmenu, button_MENU);
  116.  
  117. for(;;)    Event_Poll();
  118.  
  119. return 0;
  120. }
  121.