home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 13 / AACD13.ISO / AACD / Programming / Atmel / INCCT_Programmer / Src / progress.c < prev    next >
C/C++ Source or Header  |  2000-08-02  |  2KB  |  91 lines

  1. #include <exec/types.h>
  2. #include <intuition/intuition.h>
  3. #include <graphics/gfx.h>
  4.  
  5. #include <clib/exec_protos.h>
  6. #include <clib/graphics_protos.h>
  7. #include <clib/intuition_protos.h>
  8. #include <clib/gadtools_protos.h>
  9.  
  10. #include <stdio.h>
  11. #include "progress.h"
  12.  
  13. struct Screen   *PR_Mysc=NULL;
  14. struct Window   *PR_Mywin=NULL;
  15. UWORD           PR_Topborder;
  16. BYTE ProgressHere=0;
  17.  
  18. int OpenMyWindow(void);
  19. int CloseMyWindow(void);
  20.  
  21. int Progress(int Got, int OutOf)
  22. {
  23.   switch(ProgressHere)
  24.   {
  25.     case 0:   
  26.           if(OpenMyWindow())
  27.           {
  28.             ProgressHere=1;
  29.           }
  30.           else
  31.           {
  32.             ProgressHere=2;
  33.           }
  34.          break; 
  35.     case 1:
  36.           RectFill(PR_Mywin->RPort,PR_Mywin->BorderLeft,PR_Topborder,(int)((float)Got/OutOf*195),(PR_Topborder<<1)-1);
  37.  
  38.           break;
  39.  
  40.     default:
  41.            break;
  42.   }
  43.           
  44.   return 1;
  45. }
  46.  
  47. int OpenMyWindow(void)
  48. {
  49.   void            *vi;
  50.  
  51.   if ( (PR_Mysc = LockPubScreen(NULL)) )
  52.   {
  53.     if ( (vi = GetVisualInfo(PR_Mysc, TAG_END)) )
  54.     {
  55.       PR_Topborder = PR_Mysc->WBorTop + (PR_Mysc->Font->ta_YSize + 1);
  56.       if ((PR_Mywin = OpenWindowTags(NULL,
  57.                       WA_Title,     "Progress",
  58.                       WA_AutoAdjust,    TRUE,
  59.                       WA_Width,       200,      WA_MinWidth,        50,
  60.                       WA_InnerHeight, PR_Topborder,  WA_MinHeight,       6,
  61.                       WA_DragBar,    TRUE,      WA_DepthGadget,   TRUE,
  62.                       WA_Activate,   TRUE,      WA_CloseGadget,   FALSE,
  63.                       WA_SizeGadget, FALSE,      WA_SimpleRefresh, FALSE,
  64.                       WA_IDCMP, 0,
  65.                       WA_PubScreen, PR_Mysc,
  66.                       TAG_END)))
  67.       {
  68.         return 1;   /*did it*/
  69.       }
  70.     }
  71.   }
  72.   return 0; /*failed*/
  73. }
  74.  
  75. int FinishProgress(void)
  76. {
  77.   CloseMyWindow();
  78.   ProgressHere=0;
  79.   return 1;
  80. }
  81.  
  82. int CloseMyWindow(void)
  83. {
  84.   if(PR_Mysc) UnlockPubScreen(NULL, PR_Mysc);
  85.   if(PR_Mywin) CloseWindow(PR_Mywin);
  86.   PR_Mysc=NULL;
  87.   PR_Mywin=NULL;
  88.   return 1;
  89. }
  90.  
  91.