home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 357.lha / intuisup_v1.15 / examples / list / test.c < prev    next >
C/C++ Source or Header  |  1990-03-10  |  3KB  |  100 lines

  1. #include <intuition/intuisup.h>
  2. #include <intuition/intuitionbase.h>
  3.  
  4.  
  5. struct IntuitionBase *IntuitionBase;
  6. struct GfxBase       *GfxBase;
  7.  
  8. #ifdef ISUP_RUNTIME
  9. struct   Library  *iSupBase;
  10. #else
  11. struct   Device   *ConsoleDevice;
  12. struct   IOStdReq  ConsoleMsg;
  13. #endif
  14.  
  15.  
  16. VOID main(argc, argv)
  17. LONG argc;
  18. char **argv;
  19. {
  20.    extern struct IntuiMessage *GetMsg();
  21.    extern struct Window       *OpenStdWindow();
  22.  
  23.    BOOL     mainswitch, ioswitch;
  24.    LONG     class;
  25.    SHORT    pick;
  26.    struct   IntuiMessage *message;
  27.    struct   ListSupport *list1, *list2;
  28.    struct   Window   *window;
  29.    struct   Screen   *s;
  30.  
  31.    if (  !(GfxBase       = (struct GfxBase *)OpenLibrary("graphics.library", 0))
  32.       || !(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 0))
  33. #ifdef ISUP_RUNTIME
  34.       || !(iSupBase      = (struct Library *)OpenLibrary("isup.library", 0))
  35. #else
  36.       || !(!OpenDevice("console.device", -1, &ConsoleMsg, 0) && (ConsoleDevice=ConsoleMsg.io_Device))
  37. #endif
  38.       ) goto MAIN_DONE;
  39.  
  40.    s = IntuitionBase->FirstScreen;
  41.  
  42.    if (!(window=OpenStdWindow("List Requester Example", 0x1B, 15, 65, 350, 70, NULL))) goto MAIN_DONE;
  43.    list1 = GetListSupport((LONG)s, (LONG)&s->NextScreen, (LONG)&s->Title);
  44.    list2 = GetListSupport((LONG)s, (LONG)&s->NextScreen, (LONG)&s->Title);
  45.  
  46.    if ((window == NULL) || (list1 == NULL) || (list2 == NULL)) goto MAIN_DONE;
  47.    Emit(window, "Click here for a List requester",  42, 40, 2);
  48.  
  49.    list2->ReqTitle   = (UBYTE *)"Select a Screen";
  50.    list2->MaxChars   = 21;
  51.    list2->MaxLines   = 10;
  52.    SetFlag(list1->Flags, LR_DRAG_BAR_OFF | LR_AUTO_CENTER );
  53.    SetFlag(list2->Flags, LR_AUTO_CENTER);
  54.  
  55.    mainswitch = TRUE;
  56.    pick = 0;
  57.    while (mainswitch)
  58.          {
  59.          WaitPort(window->UserPort);
  60.  
  61.          ioswitch = FALSE;
  62.          while (message = GetMsg(window->UserPort))
  63.                {
  64.                class = message->Class;
  65.                ReplyMsg(message);
  66.  
  67.                switch(class)
  68.                      {
  69.                      case CLOSEWINDOW: mainswitch=FALSE; break;
  70.  
  71.                      default:
  72.                      /* If any other event occurs, bring up that old requester! */
  73.                      ioswitch = TRUE;
  74.                      break;
  75.                      }
  76.                }
  77.  
  78.          if (ioswitch)
  79.             {
  80.             if (pick == 0) GetListName(list1, window, 6, 15);
  81.             else GetListName(list2, window, 6, 15);
  82.             pick = 1 - pick;
  83.             }
  84.          }
  85.  
  86.    MAIN_DONE:
  87.         if (list1)         ReleaseList(list1);
  88.         if (list2)         ReleaseList(list2);
  89.         if (window)        CloseStdWindow(window);
  90.  
  91. #ifdef ISUP_RUNTIME
  92.       if (iSupBase)      CloseLibrary(iSupBase);
  93. #else
  94.       if (ConsoleDevice) CloseDevice(&ConsoleMsg);
  95. #endif
  96.         if (IntuitionBase) CloseLibrary(IntuitionBase);
  97.         if (GfxBase)       CloseLibrary(GfxBase);
  98. }
  99.  
  100.