home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Atlanta_1990 / Atlanta-Devcon.1 / Libraries / Commodities / Blank / app.c next >
Encoding:
C/C++ Source or Header  |  1992-08-26  |  4.5 KB  |  177 lines

  1.  
  2.    /***********************************************************************
  3.    *                                                                      *
  4.    *                            COPYRIGHTS                                *
  5.    *                                                                      *
  6.    *   Copyright (c) 1990  Commodore-Amiga, Inc.  All Rights Reserved.    *
  7.    *                                                                      *
  8.    ***********************************************************************/
  9.  
  10. /* app.c This file contains the custom code for a commodity */
  11. /* you should be able to write a new commodity by changing only */
  12. /* app.c and app.h */
  13.  
  14. #include "app.h"
  15.  
  16. #if WINDOW
  17.  
  18. #define V(x) ((VOID *)x)
  19.  
  20. struct TextAttr mydesiredfont =
  21.    {
  22.       "topaz.font",  /*  Name */
  23.       8,             /*  YSize */
  24.       0,             /*  Style */
  25.       0,             /*  Flags */
  26.    };
  27.  
  28. VOID setupCustomGadgets(gad)
  29. struct Gadget **gad;
  30. {
  31.    struct NewGadget ng;
  32.  
  33.    ng.ng_VisualInfo=vi;
  34.  
  35.    ng.ng_TopEdge    = topborder+0;
  36.    ng.ng_LeftEdge   = 10;
  37.    ng.ng_Width      = 40;
  38.    ng.ng_Height     = 12;
  39.    ng.ng_GadgetText = "Hide";
  40.    ng.ng_TextAttr   = &mydesiredfont;
  41.    ng.ng_GadgetID   = GAD_HIDE;
  42.    ng.ng_Flags      = NULL;
  43.    ng.ng_VisualInfo = vi;
  44.    *gad = CreateGadget(BUTTON_KIND,*gad, &ng,TAG_DONE);
  45.  
  46.    ng.ng_TopEdge    = topborder+15;
  47.    ng.ng_LeftEdge   = 10;
  48.    ng.ng_Width      = 40;
  49.    ng.ng_Height     = 12;
  50.    ng.ng_GadgetText = "Quit";
  51.    ng.ng_TextAttr   = &mydesiredfont;
  52.    ng.ng_GadgetID   = GAD_DIE;
  53.    ng.ng_Flags      = NULL;
  54.    ng.ng_VisualInfo = vi;
  55.    *gad = CreateGadget(BUTTON_KIND,*gad, &ng,TAG_DONE);
  56. }
  57. VOID HandleGadget(gad,code)
  58. ULONG gad,code;
  59. {
  60.    D( kprintf("app: HandleGadget(%lx)\n",gad); )
  61.    switch(gad)
  62.    {
  63.       case GAD_HIDE:
  64.             D( kprintf("app: HandleGadget() GAD_HIDE\n"); )
  65.             shutdownWindow();
  66.             break;
  67.       case GAD_DIE:
  68.             D( kprintf("app: HandleGadget() GAD_DIE\n"); )
  69.             terminate();
  70.    }
  71. }
  72. VOID setupCustomMenu()
  73. {
  74.    struct NewMenu mynewmenu [] =
  75.       {
  76.          {  NM_TITLE,   "Project",  0,    0, 0, 0,             },
  77.          {   NM_ITEM,   "Hide",     "H",  0, 0, V(MENU_HIDE),   },
  78.          {   NM_ITEM,   "Quit",     "Q",  0, 0, V(MENU_DIE),    },
  79.          {  NM_END,     0,          0,    0, 0, 0              },
  80.       };
  81.  
  82.    menu=CreateMenus(mynewmenu,TAG_DONE);
  83.    D( kprintf("app: CreateMenus returns menu =  %lx\n",menu); )
  84. }
  85. VOID handleCustomMenu(code)
  86. UWORD code;
  87. {
  88.    struct MenuItem *item;
  89.    BOOL terminated=FALSE;
  90.  
  91.    D( kprintf("app: handleCustomMenu(code=%lx)\n",code); )
  92.    while((code!=MENUNULL)&&(!terminated))
  93.    {
  94.       item=ItemAddress(menu,code);
  95.       switch((int)MENU_USERDATA(item))
  96.       {
  97.          case MENU_HIDE:
  98.                shutdownWindow();
  99.                terminated=TRUE; /* since window is gone NextSelect is invalid so...*/
  100.                break;
  101.          case MENU_DIE:
  102.                terminate();
  103.                break;
  104.          default:
  105.                break;
  106.       }
  107.       code=item->NextSelect;
  108.       D( kprintf("app: handleCustomMenu next code=%lx\n",code); )
  109.    }
  110.    D( kprintf("app: handleCustomMenu exits"); )
  111. }
  112. VOID refreshWindow()
  113. {
  114.    if(window)
  115.    {
  116.       if(IDCMPRefresh)
  117.          GT_BeginRefresh( window );
  118.  
  119.       SetAPen(window->RPort,(UBYTE)mydi->dri_Pens[hifilltextPen]);
  120.       SetBPen(window->RPort,(UBYTE)mydi->dri_Pens[hifillPen]);
  121.       SetDrMd(window->RPort,JAM2);
  122.       SetFont(window->RPort,font);
  123.       Move(window->RPort,90,(WORD)(topborder+40));
  124.       Text(window->RPort,"Your Imagery Here",17);
  125.  
  126.       SetAPen(window->RPort,(UBYTE)mydi->dri_Pens[hilighttextPen]);
  127.       SetBPen(window->RPort,(UBYTE)mydi->dri_Pens[backgroundPen]);
  128.       Move(window->RPort,10,(WORD)(topborder+40));
  129.       Text(window->RPort,"Hilight:",8);
  130.  
  131.       if(IDCMPRefresh)
  132.          GT_EndRefresh( window, 1L );
  133.  
  134.       /* It is possible that the user has selected a font so large */
  135.       /* that our imagery will fall off the bottom of the window   */
  136.       /* we RefreshWindowFrame here in case our borders were overwritten */
  137.       if((topborder+WINDOW_INNERHEIGHT) > window->Height)
  138.          RefreshWindowFrame(window);
  139.    }
  140.    return;
  141. }
  142.  
  143. #endif /* WINDOW */
  144.  
  145. BOOL setupCustomCX()
  146. {
  147.    return(1);
  148. }
  149. VOID shutdownCustomCX()
  150. {
  151. }
  152. VOID handleCustomCXMsg(id)
  153. ULONG id;
  154. {
  155.    switch(id)
  156.    {
  157.       case 0:
  158.       default:
  159.             break;
  160.    }
  161. }
  162. VOID handleCustomCXCommand(id)
  163. ULONG id;
  164. {
  165.    switch(id)
  166.    {
  167.       case 0:
  168.       default:
  169.             break;
  170.    }
  171. }
  172. #if CSIGNAL
  173. VOID handleCustomSignal(VOID)
  174. {
  175. }
  176. #endif
  177.