home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / gui / gauge.lha / test.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-26  |  1.6 KB  |  96 lines

  1. /*
  2. **    $VER: Test.c 1.1 (26.1.97)
  3. **
  4. **    Test.c -- Test for an implementation of a progress requester as
  5. **              per the Amiga User Interface Style Guide.
  6. **
  7. **    Copyright © 1997 by Olaf `Olsen' Barthel <olsen@sourcery.han.de>
  8. **        Freely Distributable
  9. */
  10.  
  11. #include <dos/dos.h>
  12.  
  13. #include <clib/exec_protos.h>
  14. #include <clib/dos_protos.h>
  15.  
  16. #include "gauge.h"
  17.  
  18. struct Library *IntuitionBase,*GfxBase,*UtilityBase;
  19.  
  20. int
  21. main()
  22. {
  23.     IntuitionBase    = OpenLibrary("intuition.library",37);
  24.     GfxBase        = OpenLibrary("graphics.library",37);
  25.     UtilityBase    = OpenLibrary("utility.library",37);
  26.  
  27.     if(IntuitionBase && GfxBase && UtilityBase)
  28.     {
  29.         struct Gauge *g;
  30.  
  31.         /* Just open the gauge and wait for a response.
  32.          * Then close the display
  33.          */
  34.         if(g = NewGauge(
  35.             GAUGE_Title,    "Rendering \"Boing.Ball\"",
  36.             GAUGE_Fill,    50,
  37.         TAG_DONE))
  38.         {
  39.             struct MsgPort *port;
  40.  
  41.             GetGauge(g,GAUGE_MsgPort,&port,TAG_DONE);
  42.  
  43.             WaitPort(port);
  44.  
  45.             DisposeGauge(g);
  46.         }
  47.  
  48.         if(g = NewGauge(
  49.             GAUGE_ButtonLabel,    "Stop the test",
  50.             GAUGE_Title,        "Testing the fill bar",
  51.         TAG_DONE))
  52.         {
  53.             LONG percent;
  54.             LONG increment;
  55.             LONG stop;
  56.  
  57.             percent = 0;
  58.             increment = 1;
  59.  
  60.             do
  61.             {
  62.                 percent += increment;
  63.  
  64.                 SetGauge(g,
  65.                     GAUGE_Fill,percent,
  66.                 TAG_DONE);
  67.  
  68.                 if(percent == 100 || percent == 0)
  69.                     increment = -increment;
  70.  
  71.                 Delay(TICKS_PER_SECOND / 10);
  72.  
  73.                 stop = FALSE;
  74.  
  75.                 GetGauge(g,
  76.                     GAUGE_Hit,&stop,
  77.                 TAG_DONE);
  78.             }
  79.             while(stop == FALSE);
  80.  
  81.             DisposeGauge(g);
  82.         }
  83.     }
  84.  
  85.     if(IntuitionBase)
  86.         CloseLibrary(IntuitionBase);
  87.  
  88.     if(GfxBase)
  89.         CloseLibrary(GfxBase);
  90.  
  91.     if(UtilityBase)
  92.         CloseLibrary(UtilityBase);
  93.  
  94.     return(0);
  95. }
  96.