home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 324.lha / Gone / gone.cp < prev    next >
Text File  |  1989-12-12  |  2KB  |  77 lines

  1. #include "exec/types.h"
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <intuition/intuition.h>
  5. #include <graphics/gfxmacros.h>
  6. #include <devices/input.h>
  7. #include <devices/inputevent.h>
  8.  
  9. // this routine provided by the programmer
  10. void displayroutine(struct RastPort *DRrastport,struct ListNode *list,short y)
  11. {
  12. struct Window *DRwindow;
  13. DRwindow = (struct Window *)list;
  14.     if (DRwindow->Title) 
  15.       {
  16.       SetAPen(DRrastport,2);
  17.       Move(DRrastport,2,y+6);
  18.       Text(DRrastport,DRwindow->Title,strlen(DRwindow->Title));
  19.       }
  20. }
  21.  
  22. #include "poplist.hxx"    // header file
  23. #include "poplist.h"       // methods
  24. #include "gone.h"          // window defines 
  25. // see comments for C++ in file poplist.h
  26. BOOL Debug = 0;  // set to 1 to print debug # to stdio
  27. main()
  28.    
  29. /*      The main program.  Open an Intuition window in Workbench
  30.         with two gadgets, one to send a window to the front, the
  31.         second to send it to the back.
  32.  
  33.         When a gadget is clicked on, call ScrollingPopUpMenu() and
  34.         pass it the list of Workbench windows.  If the user selects
  35.         one of the windows, either call WindowToFront(window) or
  36.         WindowToBack(window), depending on which gadget was clicked.
  37. */
  38. {
  39.     PopUpList popup_list;  
  40.      if (popup_list.openflag == 0)
  41.         {
  42.         Gripe("Unable to open list manager.");
  43.         exit(20);
  44.         }
  45.         
  46.     struct IntuiMessage *message;
  47.     struct Window *window;
  48.     struct Window *selectwindow;
  49.     long miclass;  /* code*/
  50.     struct Gadget *gadget;
  51.     window =(struct Window *) OpenWindow(&wNewWindowStructure1);
  52.     if (window) {
  53.         for (;;) {
  54.             message = 0;
  55.             while (!message) {
  56.                 WaitPort(window->UserPort);
  57.                 message = (struct IntuiMessage *) GetMsg(window->UserPort);
  58.             }
  59.             miclass = message->Class;
  60.             gadget = (struct Gadget *) message->IAddress;
  61.             ReplyMsg(message);
  62.             if (miclass == CLOSEWINDOW) break;
  63.             selectwindow = (struct Window *)popup_list.ScrollingPopUpMenu(window->WScreen,(struct ListNode *)window->WScreen->FirstWindow,(WORD)8,(WORD)100,(WORD)4);
  64.             if (miclass == GADGETDOWN) {
  65.                 if (gadget->GadgetID == 1) {
  66.                     if (selectwindow) WindowToFront(selectwindow);
  67.                 }
  68.             else if (gadget->GadgetID == 2) {
  69.                if (selectwindow) WindowToBack(selectwindow);
  70.                 }
  71.             }
  72.         }
  73.         CloseWindow(window);
  74.     }
  75. exit(20);
  76. }
  77.