home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Archives / Timing / EngClock96.lha / EngClock96 / Source / oct.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-01  |  5.4 KB  |  237 lines

  1. /*
  2.  *  Source machine generated by GadToolsBox V2.0
  3.  *  which is (c) Copyright 1991-1993 Jaba Development
  4.  *
  5.  *  GUI Designed by : -- Unnamed --
  6.  */
  7.  
  8. #include <exec/types.h>
  9. #include <intuition/intuition.h>
  10. #include <intuition/classes.h>
  11. #include <intuition/classusr.h>
  12. #include <intuition/imageclass.h>
  13. #include <intuition/gadgetclass.h>
  14. #include <libraries/gadtools.h>
  15. #include <graphics/displayinfo.h>
  16. #include <graphics/gfxbase.h>
  17. //#include <proto/exec.h>
  18. //#include <proto/intuition.h>
  19. //#include <proto/gadtools.h>
  20. //#include <proto/graphics.h>
  21. //#include <proto/utility.h>
  22. #include <string.h>
  23. #include <stdio.h>
  24. #include <stdlib.h>
  25.  
  26. #include <clib/exec_protos.h>
  27. #include <clib/intuition_protos.h>
  28. #include <clib/gadtools_protos.h>
  29. #include <clib/utility_protos.h>
  30. #include <clib/graphics_protos.h>
  31.  
  32. #include "oct.h"
  33.  
  34. extern struct IntuitionBase *IntuitionBase;
  35. extern struct GfxBase *GfxBase;
  36. extern struct Library *UtilityBase;
  37. extern struct Library *GadToolsBase;
  38. extern struct Library *DiskfontBase;
  39. extern struct Library *AslBase;
  40. extern struct Library *IFFParseBase;
  41. extern struct Library *DOSBase;
  42.  
  43. int oct=0;
  44.  
  45. extern struct Screen         *pubscreen;
  46.  
  47. APTR                   VisualInfo4 = NULL;
  48. struct Window         *Project0Wnd4 = NULL;
  49. struct Gadget         *Project0GList4 = NULL;
  50. struct Gadget         *Project0Gadgets4[2];
  51. UWORD                  Project0Left4 = 232;
  52. UWORD                  Project0Top4 = 50;
  53. UWORD                  Project0Width4 = 295;
  54. UWORD                  Project0Height4 = 76;
  55. UBYTE                 *Project0Wdt4 = (UBYTE *)"Sample settings";
  56.  
  57. struct TextAttr topaz84 = {
  58.     ( STRPTR )"topaz.font", 8, 0x00, 0x01 };
  59.  
  60. struct IntuiText Project0IText4[] = {
  61.     1, 0, JAM1,62, 6, &topaz84, (UBYTE *)"File is an instrument!", NULL };
  62.  
  63. UWORD Project0GTypes4[] = {
  64.     INTEGER_KIND,
  65.     BUTTON_KIND
  66. };
  67.  
  68. struct NewGadget Project0NGad4[] = {
  69.     99, 36, 100, 14, (UBYTE *)"Enter an octave value (0-)", NULL, GD_Oct, PLACETEXT_ABOVE, NULL, NULL,
  70.     6, 57, 276, 14, (UBYTE *)"Ok", NULL, GD_Ok, PLACETEXT_IN, NULL, NULL
  71. };
  72.  
  73. ULONG Project0GTags4[] = {
  74.     (GTIN_Number), 0, (GTIN_MaxChars), 10, (TAG_DONE),
  75.     (TAG_DONE)
  76. };
  77.  
  78. int SetupScreen4( void )
  79. {
  80.  
  81.     if ( ! ( VisualInfo4 = GetVisualInfo( pubscreen, TAG_DONE )))
  82.         return( 2L );
  83.  
  84.     return( 0L );
  85. }
  86.  
  87. void CloseDownScreen4( void )
  88. {
  89.     if ( VisualInfo4 ) {
  90.         FreeVisualInfo( VisualInfo4 );
  91.         VisualInfo4 = NULL;
  92.     }
  93.  
  94. }
  95.  
  96. void Project0Render4( void )
  97. {
  98.     UWORD        offx, offy;
  99.  
  100.     offx = Project0Wnd4->BorderLeft;
  101.     offy = Project0Wnd4->BorderTop;
  102.  
  103.     PrintIText( Project0Wnd4->RPort, Project0IText4, offx, offy );
  104. }
  105.  
  106. int OpenProject0Window4( void )
  107. {
  108.     struct NewGadget    ng;
  109.     struct Gadget    *g;
  110.     UWORD        lc, tc;
  111.     UWORD        offx = pubscreen->WBorLeft, offy = pubscreen->WBorTop + pubscreen->RastPort.TxHeight + 1;
  112.  
  113.     if ( ! ( g = CreateContext( &Project0GList4 )))
  114.         return( 1L );
  115.  
  116.     for( lc = 0, tc = 0; lc < Project0_CNT; lc++ ) {
  117.  
  118.         CopyMem((char * )&Project0NGad4[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
  119.  
  120.         ng.ng_VisualInfo = VisualInfo4;
  121.         ng.ng_TextAttr   = &topaz84;
  122.         ng.ng_LeftEdge  += offx;
  123.         ng.ng_TopEdge   += offy;
  124.  
  125.         Project0Gadgets4[ lc ] = g = CreateGadgetA((ULONG)Project0GTypes4[ lc ], g, &ng, ( struct TagItem * )&Project0GTags4[ tc ] );
  126.  
  127.         while( Project0GTags4[ tc ] ) tc += 2;
  128.         tc++;
  129.  
  130.         if ( NOT g )
  131.             return( 2L );
  132.     }
  133.  
  134.     if ( ! ( Project0Wnd4 = OpenWindowTags( NULL,
  135.                 WA_Left,    Project0Left4,
  136.                 WA_Top,        Project0Top4,
  137.                 WA_Width,    Project0Width4,
  138.                 WA_Height,    Project0Height4 + offy,
  139.                 WA_IDCMP,    INTEGERIDCMP|BUTTONIDCMP|IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW,
  140.                 WA_Flags,    WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
  141.                 WA_Gadgets,    Project0GList4,
  142.                 WA_Title,    Project0Wdt4,
  143.                 WA_ScreenTitle,    "EngClock Prefs",
  144.                 WA_PubScreen,    pubscreen,
  145.                 TAG_DONE )))
  146.     return( 4L );
  147.  
  148.     GT_RefreshWindow( Project0Wnd4, NULL );
  149.  
  150.     Project0Render4();
  151.  
  152.     return( 0L );
  153. }
  154.  
  155. void CloseProject0Window4( void )
  156. {
  157.     if ( Project0Wnd4        ) {
  158.         CloseWindow( Project0Wnd4 );
  159.         Project0Wnd4 = NULL;
  160.     }
  161.  
  162.     if ( Project0GList4      ) {
  163.         FreeGadgets( Project0GList4 );
  164.         Project0GList4 = NULL;
  165.     }
  166. }
  167.  
  168. int getoct(int max) {
  169.     struct IntuiMessage *msg;
  170.     ULONG class,code,iaddress;
  171.     char text[100], tmp[10];
  172.  
  173.     strcpy(text,"Enter an octave value (0-");
  174.     sprintf(tmp,"%d",max);
  175.     strcat(text,tmp);
  176.     strcat(text,")");
  177.  
  178.     Project0NGad4[0].ng_GadgetText=text;
  179.  
  180.     SetupScreen4();
  181.     OpenProject0Window4();
  182.  
  183.     GT_SetGadgetAttrs(Project0Gadgets4[GD_Oct],Project0Wnd4,NULL,GTIN_MaxChars,strlen(tmp),TAG_END);
  184.     GT_RefreshWindow(Project0Wnd4,NULL);
  185.  
  186.     while(1) {
  187.         Wait(1<<Project0Wnd4->UserPort->mp_SigBit);
  188.         msg=(struct IntuiMessage *)GT_GetIMsg(Project0Wnd4->UserPort);        
  189.         code=msg->Code; class=msg->Class; iaddress=(ULONG)msg->IAddress;
  190.         GT_ReplyIMsg(msg);
  191.  
  192.         switch(class) {
  193.             case CLOSEWINDOW:
  194.                 CloseProject0Window4();
  195.                 CloseDownScreen4();
  196.                 return(0);
  197.             break;
  198.             case GADGETUP:
  199.             case GADGETDOWN:
  200.                 if(gad(iaddress, max)) {
  201.                     CloseProject0Window4();
  202.                     CloseDownScreen4();
  203.                     return(oct);
  204.                 }
  205.             break;
  206.  
  207.         }
  208.     }
  209. }
  210.  
  211. BOOL gad(ULONG iaddress, int max) {
  212.     struct Gadget *gad2;
  213.     struct StringInfo *si;
  214.  
  215.     gad2=(struct Gadget *)iaddress;
  216.     si=(struct StringInfo *)gad2->SpecialInfo;
  217.  
  218.     switch(gad2->GadgetID) {
  219.         case GD_Oct:
  220.             if(si->LongInt > max || si->LongInt < 0) {
  221.                 DisplayBeep(NULL);
  222.                 GT_SetGadgetAttrs(Project0Gadgets4[GD_Oct],Project0Wnd4,NULL,GTIN_Number,oct,TAG_END);
  223.             } else
  224.                 oct=si->LongInt;
  225.         break;
  226.         case GD_Ok:
  227.             return(1);
  228.         break;
  229.         default:
  230.         break;
  231.     }
  232.     return(0);        
  233.  
  234. }
  235.  
  236.  
  237.