home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / screen / shdwmstr.lha / source / config / no-config.c < prev    next >
C/C++ Source or Header  |  1991-12-29  |  4KB  |  116 lines

  1. /*
  2.  * Config program for use by savers that don't need configuration. Just
  3.  * report that to the user.
  4.  *
  5.  * Copyright (c) 1991, Mike Meyer
  6.  * All Rights Reserved
  7.  *
  8.  * See the file "ShadowMaster:Distribution"  for information on distribution.
  9.  *
  10.  * ===build instructions
  11.  * % lc no-config ; output= no-config.o input= no-config.c
  12.  * % blink no-config.o lib lib:amiga.lib to no-config SC SD ; output= no-config input= no-config.o
  13.  * % copy no-config //config
  14.  * ===endbuild
  15.  */
  16.  
  17. #include <exec/types.h>
  18. #include <utility/tagitem.h>
  19. #include <dos/dos.h>
  20. #include <intuition/intuition.h>
  21. #include <libraries/gadtools.h>
  22. #include <proto/exec.h>
  23. #include <proto/dos.h>
  24. #include <proto/intuition.h>
  25. #include <proto/gadtools.h>
  26.  
  27. struct ExecBase        *SysBase = NULL ;
  28. struct DosLibrary    *DOSBase = NULL ;
  29. struct IntuitionBase    *IntuitionBase = NULL ;
  30. struct Library        *GadToolsBase = NULL ;
  31.  
  32. struct TextAttr        topaz_8 = { "topaz", 8, 0, 0 } ;/* Blame this on GadTools */
  33. struct IntuiText    Message[2] = {
  34.             {   1, 0, JAM2, 0, 0, &topaz_8,
  35.                 "No config needed for saver:" , &Message[1]
  36.                 } ,
  37.             {   1, 0, JAM2, 0, 16, &topaz_8, NULL, NULL }
  38.             } ;
  39.  
  40.  
  41. struct NewGadget no_good = {
  42.     0, 0,    /* Must fill out later, gadtools to stupid to do it right */
  43.     45, 12, "Okay", &topaz_8, 0, 0, NULL, NULL
  44.     } ;
  45.  
  46. #define done(x)    do { status = x; goto out; } while (0) ;
  47. int __saveds
  48. start(void) {
  49.     struct Window        *window = NULL ;
  50.     int            status ;
  51.     struct RDArgs        *args = NULL ;
  52.     struct IntuiMessage    *bounce, in ;
  53.     struct Gadget        *gadget_crap = NULL, *gadtools_turd ;
  54.     
  55.  
  56.     SysBase = *((struct ExecBase **) 4);
  57.     if (!(DOSBase = (struct DosLibrary *) OpenLibrary("dos.library", 37)))
  58.         done(RETURN_FAIL) ;
  59.     if (!(IntuitionBase = (struct IntuitionBase *)
  60.         OpenLibrary("intuition.library", 37)))
  61.             done(RETURN_FAIL) ;
  62.     if (!(GadToolsBase = OpenLibrary("gadtools.library", 37)))
  63.         done(RETURN_FAIL) ;
  64.  
  65.     if (!(args = ReadArgs("NAME/A", (LONG *) &(Message[1].IText), NULL)))
  66.         done(RETURN_ERROR) ;
  67.  
  68.     if (!(window = OpenWindowTags(NULL,
  69.             WA_Left, 0, WA_InnerWidth, IntuiTextLength(&Message[0]) + 20,
  70.             WA_Top, 11, WA_InnerHeight, 55, WA_AutoAdjust, 1,
  71.             WA_Title, "Shadow Master Configuration:",
  72.             WA_DragBar, 1, WA_IDCMP, IDCMP_GADGETUP,
  73.             TAG_DONE, 0)))
  74.         done(RETURN_FAIL) ;
  75.  
  76.     if (!(no_good.ng_VisualInfo = GetVisualInfoA(window->WScreen, NULL)))
  77.         done(RETURN_FAIL) ;
  78.     if (!(gadtools_turd = CreateContext(&gadget_crap))) done(RETURN_FAIL) ;
  79.     no_good.ng_TopEdge = window->Height - 17 ;
  80.     no_good.ng_LeftEdge = window->Width - 65 ;
  81.     if (!(CreateGadgetA(BUTTON_KIND, gadtools_turd, &no_good, NULL)))
  82.         done(RETURN_FAIL) ;
  83.     AddGList(window, gadget_crap, -1, -1, NULL) ;
  84.     RefreshGList(gadget_crap, window, NULL, -1) ;
  85.     GT_RefreshWindow(window, NULL) ;
  86.  
  87.     Message[0].LeftEdge = (window->Width - IntuiTextLength(&Message[0])) / 2;
  88.     Message[1].LeftEdge = (window->Width - IntuiTextLength(&Message[1])) / 2;
  89.     PrintIText(window->RPort, &Message[0], 0, 20) ;
  90.  
  91.     FOREVER {
  92.         WaitPort(window->UserPort) ;
  93.         while (bounce = GT_GetIMsg(window->UserPort)) {
  94.             in = *bounce ;
  95.             GT_ReplyIMsg(bounce) ;
  96.             switch (in.Class) {
  97.                 case IDCMP_GADGETUP: done(RETURN_OK) ;
  98.                 case IDCMP_REFRESHWINDOW:
  99.                     GT_BeginRefresh(window);
  100.                     GT_EndRefresh(window, TRUE);
  101.                     break ;
  102.                 }
  103.             }
  104.         }
  105.  
  106. out:
  107.     if (window) CloseWindow(window) ;
  108.     if (gadget_crap) FreeGadgets(gadget_crap) ;
  109.     if (no_good.ng_VisualInfo) FreeVisualInfo(no_good.ng_VisualInfo) ;
  110.     FreeArgs(args) ;
  111.     if (GadToolsBase) CloseLibrary(GadToolsBase) ;
  112.     if (IntuitionBase) CloseLibrary((struct Library *) IntuitionBase) ;
  113.     if (DOSBase) CloseLibrary((struct Library *) DOSBase) ;
  114.     return status ;
  115.     }
  116.