home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / pufferfish / source / buttonclass / test.c < prev   
C/C++ Source or Header  |  1994-03-26  |  5KB  |  207 lines

  1. #include "headers.h"
  2.  
  3. #include "buttonclass.h"
  4.  
  5.  
  6. LONG StartUpCode(void)
  7. {
  8.   struct Library *SysBase;
  9.   struct Library *IntuitionBase, *UtilityBase, *GfxBase, *DOSBase;
  10.   struct Window *w;
  11.   Class *buttonCl;
  12.   Class *progressCl;
  13.   struct IntuiMessage *msg;
  14.   struct Gadget *glist=NULL;
  15.   struct DrawInfo *drinfo;
  16.   ULONG done=FALSE;
  17.   struct Gadget *pro;
  18.   ULONG get;
  19.  
  20.  
  21.     SysBase=*((void **)4L);
  22.     if(DOSBase=OpenLibrary("dos.library",37))
  23.         {
  24.         if(IntuitionBase=OpenLibrary("intuition.library",37))
  25.             {
  26.             if(UtilityBase=OpenLibrary("utility.library",37))
  27.                 {
  28.                 if(GfxBase=OpenLibrary("graphics.library",37))
  29.                     {
  30.                     if(w=OpenWindowTags(NULL,
  31.                                 WA_Flags,    WFLG_DEPTHGADGET | WFLG_DRAGBAR |
  32.                                             WFLG_CLOSEGADGET | WFLG_SIZEGADGET,
  33.                                 WA_IDCMP,    IDCMP_CLOSEWINDOW | IDCMP_GADGETUP | IDCMP_GADGETDOWN | IDCMP_MOUSEBUTTONS | IDCMP_RAWKEY,
  34.                                 WA_Top,        15,
  35.                                 WA_Left,    150,
  36.                                 WA_Width,    300,
  37.                                 WA_Height,    300,
  38.                                 WA_MinWidth,100,
  39.                                 WA_MinHeight,50,
  40.                                 WA_MaxWidth,~0,
  41.                                 WA_MaxHeight,~0,
  42.                                 WA_Activate,TRUE,
  43.                                 TAG_END) )
  44.                         {
  45.                         if( drinfo=GetScreenDrawInfo(w->WScreen) )
  46.                             {
  47.                             if(buttonCl = initButtonGadgetClass(IntuitionBase, UtilityBase, GfxBase))
  48.                                 {
  49.                             if(progressCl = initProgressGadgetClass(IntuitionBase, UtilityBase, GfxBase))
  50.                                 {
  51.                                 struct Gadget *tmpgad,*gad;
  52.                                 WORD i;
  53.  
  54.                                 tmpgad= (struct Gadget *)&glist;
  55.                                 for(i=0;i<16;i++)
  56.                                     {
  57.                                     NewObject(buttonCl, NULL,
  58.                                             GA_ID,            1L,
  59.                                             GA_Top,            w->BorderTop + 2 + i*13,
  60.                                             GA_Left,        20,
  61.                                             GA_Width,        100,
  62.                                             GA_Height,        11,
  63.                                             GA_Immediate,    TRUE,
  64.                                             GA_RelVerify,    TRUE,
  65.                                             GA_Previous,    tmpgad,
  66.                                             BUT_Text,        "All",
  67.                                             BUT_Color,        (i<8?(i==1?0:1):i%8),
  68.                                             BUT_BackColor,    (i<8?i%8:~0),
  69.                                             TAG_DONE);
  70.                                     }
  71.                                 NewObject(buttonCl, NULL,
  72.                                         GA_ID,            1L,
  73.                                         GA_Top,            w->BorderTop + 2 + i*13,
  74.                                         GA_Left,        20,
  75.                                         GA_Width,        150,
  76.                                         GA_Height,        12,
  77.                                         GA_Immediate,    TRUE,
  78.                                         GA_RelVerify,    TRUE,
  79.                                         GA_Previous,    tmpgad,
  80.                                         //GA_Disabled,    TRUE,
  81.                                         BUT_Text,        "_Press a Key",
  82.                                         TAG_DONE);
  83.                                 pro=NewObject(progressCl, NULL,
  84.                                         GA_ID,            1L,
  85.                                         GA_Top,            w->BorderTop + 2 + ++i*13,
  86.                                         GA_Left,        20,
  87.                                         GA_Width,        200,
  88.                                         GA_Height,        12,
  89.                                         GA_Previous,    tmpgad,
  90.                                         PRO_Min,        100,
  91.                                         PRO_Max,        200,
  92.                                         PRO_ShowPercent,TRUE,
  93.                                         TAG_DONE);
  94.  
  95.                                 NewObject(buttonCl, NULL,
  96.                                         GA_ID,            1L,
  97.                                         GA_Top,            w->BorderTop + 5 + ++i*13,
  98.                                         GA_Left,        20,
  99.                                         GA_Width,        20,
  100.                                         GA_Height,        14,
  101.                                         GA_Immediate,    TRUE,
  102.                                         GA_RelVerify,    TRUE,
  103.                                         GA_Previous,    tmpgad,
  104.                                         BUT_Drawer,        TRUE,
  105.                                         TAG_DONE);
  106.  
  107.  
  108.                                 AddGList(w, glist, -1, -1, NULL);
  109.                                 RefreshGList(glist, w, NULL, -1);
  110.  
  111.                                 for( i=100; i<=200; i++ )
  112.                                     {
  113.                                     SetGadgetAttrs(pro, w, NULL,
  114.                                         PRO_Current, i,
  115.                                         TAG_DONE);
  116.                                     Delay(2);
  117.                                     }
  118.                                 if( GetAttr(PRO_Current, pro, &get) )
  119.                                     {
  120.                                     kprintf("current: %ld\n", get);
  121.                                     }
  122.                                 if( GetAttr(PRO_ShowPercent, pro, &get) )
  123.                                     {
  124.                                     kprintf("showpercent: %ld\n", get);
  125.                                     }
  126.                                 SetGadgetAttrs(pro, w, NULL,
  127.                                     PRO_ShowPercent, FALSE,
  128.                                     TAG_DONE);
  129.                                 if( GetAttr(PRO_ShowPercent, pro, &get) )
  130.                                     {
  131.                                     kprintf("showpercent: %ld\n", get);
  132.                                     }
  133.                                 for( i=200; i>=100; i-- )
  134.                                     {
  135.                                     SetGadgetAttrs(pro, w, NULL,
  136.                                         PRO_Current, i,
  137.                                         TAG_DONE);
  138.                                     Delay(2);
  139.                                     }
  140.  
  141.                                 while(done==FALSE)
  142.                                     {
  143.                                     WaitPort(w->UserPort);
  144.                                     while(msg=(struct IntuiMessage *)GetMsg(w->UserPort))
  145.                                         {
  146.                                         switch( msg->Class )
  147.                                             {
  148.                                             case IDCMP_GADGETDOWN:
  149.                                                 kprintf("Gadget down\n");
  150.                                                 break;
  151.                                             case IDCMP_GADGETUP:
  152.                                                 kprintf("Gadget up\n");
  153.                                                 break;
  154.                                             case IDCMP_MOUSEBUTTONS:
  155.                                                 kprintf("Mouse buttons\n");
  156.                                                 break;
  157.                                             case IDCMP_CLOSEWINDOW:
  158.                                                 done=TRUE;
  159.                                                 break;
  160.                                             case IDCMP_RAWKEY:
  161.                                                 if( msg->Code & IECODE_UP_PREFIX )
  162.                                                     {
  163.                                                     SetGadgetAttrs(glist, w, NULL,
  164.                                                         GA_Selected,    FALSE,
  165.                                                         TAG_DONE);
  166.                                                     }
  167.                                                 else if( !(msg->Qualifier & IEQUALIFIER_REPEAT) )
  168.                                                     {
  169.                                                     SetGadgetAttrs(glist, w, NULL,
  170.                                                         GA_Selected,    TRUE,
  171.                                                         TAG_DONE);
  172.                                                     }
  173.                                                 break;
  174.                                             }
  175.                                         ReplyMsg(msg);
  176.                                         }
  177.                                     }
  178.  
  179.                                 RemoveGList(w, glist, -1);
  180.  
  181.                                 gad=glist;
  182.                                 while(gad)
  183.                                     {
  184.                                     tmpgad= gad->NextGadget;
  185.                                     DisposeObject(gad);
  186.                                     gad= tmpgad;
  187.                                     }
  188.  
  189.                                 freeProgressGadgetClass(progressCl);
  190.                                 }
  191.                                 freeButtonGadgetClass(buttonCl);
  192.                                 }
  193.                             FreeScreenDrawInfo(w->WScreen,drinfo);
  194.                             }
  195.                         CloseWindow(w);
  196.                         }
  197.                     CloseLibrary(GfxBase);
  198.                     }
  199.                 CloseLibrary(UtilityBase);
  200.                 }
  201.             CloseLibrary(IntuitionBase);
  202.             }
  203.         CloseLibrary(DOSBase);
  204.         }
  205.     return( 0 );
  206. }
  207.