home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 1 / Amiga Tools.iso / egs-tools / egs_dev-disk / egsdemos / moreexamples / example1 / example1.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-06  |  3.0 KB  |  91 lines

  1.                            /*  Example 1.c
  2.                                This code follows the overview of gadgets doc
  3.                                included with this developer disk.
  4.  
  5.                                Patrick Hager, Great Valley Products Inc.
  6.                                October 30, 1993
  7.                            */
  8. #include <stdio.h>
  9. #include "/global/userwindow.h"
  10. #include "/global/egslibraries.h"
  11.  
  12. #include <egs/egsintui.h>
  13. #include <egs/clib/egsintui_protos.h>
  14. #include <egs/pragmas/egsintui_pragmas.h>
  15. #include <egs/egsgadbox.h>
  16. #include <egs/clib/egsgadbox_protos.h>
  17. #include <egs/pragmas/egsgadbox_pragmas.h>
  18.  
  19.  
  20. #define TESTING_ID 200
  21.  
  22.  
  23. struct UserInputWindow Example_Request;
  24.  
  25. EB_GadBoxPtr Create_Example (UserInputWindowPtr UserWindow);
  26. void GadgetDown_Example (UserInputWindowPtr UserWindow, EI_GadgetPtr iaddress);
  27.  
  28. void main (void) {
  29.  
  30.   if (OpenEGSLibraries ()) {
  31.     Init_UserWindow (&Example_Request, "Example Window",WINDOW_MODAL,NULL,
  32.                      NULL);
  33.     Example_Request.Create = Create_Example;
  34.     Example_Request.GadgetDown = GadgetDown_Example;
  35.     Example_Request.IDCMPFlags = EI_iCLOSEWINDOW | EI_iSIZEVERIFY |
  36.                                  EI_iNEWSIZE | EI_iGADGETDOWN;
  37.     Example_Request.Flags =      EI_SIZEBBOTTOM| EI_SIMPLE_REFRESH |
  38.                                  EI_GIMMEZEROZERO;
  39.     Example_Request.SysGadgets = (EI_WINDOWCLOSE)|(EI_WINDOWSIZE)|EI_WINDOWDRAG;
  40.  
  41.     if (Open_UserWindow (&Example_Request,-1,-1)) {
  42.       Close_UserWindow (&Example_Request);
  43.     }
  44.     else
  45.       printf ("Couldn't open my window!\n");
  46.   }
  47.   CloseEGSLibraries ();  // after the bracket cause what if I opened 3 but
  48.                          // couldn't find the rest, still need to close the 3.
  49. }
  50.  
  51. /*************************************
  52.    PRIVATE:  Create_Example.
  53.              This routine is called by the UserWindow routines.
  54.              It passes back a GadBoxPtr to the gadgets wanted.
  55. *************************************/
  56. EB_GadBoxPtr Create_Example (UserInputWindowPtr UserWindow) {
  57.   EB_GadBoxPtr root;
  58.   EB_GadContext gadcon;
  59.  
  60.   gadcon = UserWindow->GadCon;
  61.  
  62.   root = EB_CreateVertiBox (gadcon);
  63.   EB_AddLastSon (root,EB_CreateTextAction (gadcon,"Gadget 1",TESTING_ID,EB_FILL_ALL));
  64.   EB_AddLastSon (root,EB_CreateTextAction (gadcon,"Gadget 2",TESTING_ID+1,EB_FILL_ALL));
  65.   EB_AddLastSon (root,EB_CreateTextAction (gadcon,"Gadget 3",TESTING_ID+2,EB_FILL_ALL));
  66.  
  67.  
  68.   EB_AddLastSon (root,EB_CreateVertiFill (gadcon,0,0));
  69.   return root;
  70. }
  71.  
  72. /**************************************
  73.     PRIVATE:  GadgetDown_Example.
  74.               This routine handles the gadget down events passed to the
  75.               Example Control Window.
  76. **************************************/
  77. void GadgetDown_Example (UserInputWindowPtr UserWindow, EI_GadgetPtr iaddress) {
  78.  
  79.  
  80.   switch (iaddress->GadgetID) {
  81.     case TESTING_ID:
  82.       printf ("You hit Top Gadget!\n");
  83.     break;
  84.     case TESTING_ID+1:
  85.       printf ("You hit Middle Gadget!\n");
  86.     break;
  87.     case TESTING_ID+2:
  88.       printf ("You hit Bottom Gadget!\n");
  89.     break;
  90.   }
  91. }