
   /***********************************************************************
   *                                                                      *
   *                            COPYRIGHTS                                *
   *                                                                      *
   *   Copyright (c) 1990  Commodore-Amiga, Inc.  All Rights Reserved.    *
   *                                                                      *
   ***********************************************************************/

/* custom.c This file contains the custom code for a commodity */
/* you should be able to write a new commodity by changing only */
/* custom.c and custom.h */

#include "app.h"

#if WINDOW

#define V(x) ((VOID *)x)

struct TextAttr mydesiredfont =
   {
      "topaz.font",  /*  Name */
      8,             /*  YSize */
      0,             /*  Style */
      0,             /*  Flags */
   };

VOID setupCustomGadgets(gad)
struct Gadget **gad;
{
   mysetupCustomGadgets(gad);
}
VOID HandleGadget(gad,code)
ULONG gad,code;
{
   myHandleGadget(gad,code);
}
VOID setupCustomMenu()
{
   struct NewMenu mynewmenu [] =
      {
         {  NM_TITLE,   "Project",  0,    0, 0, 0,             },
         {   NM_ITEM,   "Hide",     "H",  0, 0, V(MENU_HIDE),   },
         {   NM_ITEM,   "Quit",      "Q",  0, 0, V(MENU_DIE),    },
         {  NM_END,     0,          0,    0, 0, 0              },
      };

   menu=CreateMenus(mynewmenu,TAG_DONE);
   D( kprintf("custom: CreateMenus returns menu =  %lx\n",menu); )
}
VOID handleCustomMenu(code)
UWORD code;
{
   struct MenuItem *item;
   BOOL terminated=FALSE;

   D( kprintf("custom: handleCustomMenu(code=%lx)\n",code); )
   while((code!=MENUNULL)&&(!terminated))
   {
      item=ItemAddress(menu,code);
      switch((int)MENU_USERDATA(item))
      {
         case MENU_HIDE:
               shutdownWindow();
               terminated=TRUE; /* since window is gone NextSelect is invalid so...*/
               break;
         case MENU_DIE:
               terminate();
               break;
         default:
               break;
      }
      code=item->NextSelect;
      D( kprintf("custom: handleCustomMenu next code=%lx\n",code); )
   }
   D( kprintf("custom: handleCustomMenu exits"); )
}
VOID refreshWindow()
{
   if(window)
   {
      if(IDCMPRefresh)
         GT_BeginRefresh( window );

      SetAPen(window->RPort,2);
      SetDrMd(window->RPort,JAM1);
      SetFont(window->RPort,font);
      Move(window->RPort,160,topborder+8);
      Text(window->RPort,"Never Blank --",14);
      Move(window->RPort,190,topborder+18);
      Text(window->RPort,"Top Right",9);
      Move(window->RPort,160,topborder+28);
      Text(window->RPort,"Blank Now --",12);
      Move(window->RPort,190,topborder+38);
      Text(window->RPort,"Bottom Right",12);

      if(IDCMPRefresh)
         GT_EndRefresh( window, 1L );

      /* It is possible that the user has selected a font so large */
      /* that our imagery will fall off the bottom of the window   */
      /* we RefreshWindowFrame here incase our borders were overwritten */
      if((topborder+WINDOW_INNERHEIGHT) > window->Height)
         RefreshWindowFrame(window);
   }
   return;
}

#endif /* WINDOW */

BOOL setupCustomCX()
{
   return(setupBlanker());
}
VOID shutdownCustomCX()
{
}
VOID handleCustomCXMsg(id)
ULONG id;
{
   switch(id)
   {
      case 0:
      default:
            break;
   }
}
VOID handleCustomCXCommand(id)
ULONG id;
{
   switch(id)
   {
      case 0:
      default:
            break;
   }
}
#if CSIGNAL
VOID handleCustomSignal(VOID)
{
   MyHandleCustomSignal();
}
#endif
