home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / gui / guienv376.lha / GUIEnvironment / M2Amiga / Examples / RequesterExample.mod < prev    next >
Encoding:
Text File  |  1994-12-16  |  5.2 KB  |  138 lines

  1. (****************************************************************************
  2.  
  3. $RCSfile: RequesterExample.mod $
  4.  
  5. $Revision: 1.8 $
  6.     $Date: 1994/12/16 16:33:57 $
  7.  
  8.     GUIEnvironment example: Requester
  9.  
  10.     M2Amiga Modula-2 Compiler V4.3
  11.  
  12.   Copyright © 1994, Carsten Ziegeler
  13.                     Augustin-Wibbelt-Str.7, 33106 Paderborn, Germany
  14.  
  15. ****************************************************************************)
  16. MODULE RequesterExample;
  17.  
  18. (* This example shows all available requesters using ReqTools if available *)
  19.  
  20. (* RequesterExample uses the following catalog strings 201.. : texts
  21.                                                        240.. : gadgets
  22.                                                        250   : END     *)
  23.  
  24.   FROM SYSTEM     IMPORT ADR, ADDRESS, TAG;
  25.   FROM GadToolsD  IMPORT GtTags, textKind;
  26.   FROM IntuitionD IMPORT WindowPtr, WindowFlagSet, WindowFlags, IDCMPFlagSet,
  27.                          IDCMPFlags;
  28. IMPORT D : GUIEnvD,
  29.        L : GUIEnvL,
  30.        GS: GUIEnvSupport;
  31.  
  32. CONST version = ADR("$VER: RequesterExample 37.6 (14.12.94)\n");
  33.  
  34. VAR win : WindowPtr;
  35.     gui : D.GUIInfoPtr;
  36.  
  37.     choose : LONGINT;
  38.     file, dir : ARRAY[0..255] OF CHAR;
  39.     tagbuf : ARRAY[0..19] OF LONGCARD;
  40.     args : ARRAY[0..4] OF ADDRESS; (* for the arguments *)
  41.  
  42. BEGIN
  43.  
  44.   win := L.OpenGUIWindowA( 50, 50, 300, 100, ADR("GUIEnvironment - RequesterExample"),
  45.                           IDCMPFlagSet{closeWindow, refreshWindow},
  46.                           WindowFlagSet{activate, windowDepth, windowClose,
  47.                                         windowDrag}, NIL, NIL);
  48.   IF win # NIL THEN
  49.  
  50.     gui := L.CreateGUIInfoA(win, TAG(tagbuf,
  51.                             D.guiTextFont, GS.TopazAttr(),
  52.                             D.guiCatalogFile, ADR("GUIEnvExamples.catalog"),
  53.                             D.guiGadgetCatalogOffset, 240, NIL));
  54.     IF gui # NIL THEN
  55.  
  56.       L.CreateGUIGadgetA(gui, 10, 40, 280, 20, textKind,
  57.                          TAG(tagbuf, gttxText, L.GetCatStr(gui, 240, ADR("Use requesters")),
  58.                                      gttxBorder, TRUE, NIL));
  59.  
  60.       IF L.DrawGUIA(gui, NIL) = D.geDone THEN
  61.  
  62.         (* Return value not needed, ok requester *)
  63.         IGNORE L.GUIRequestA(gui, ADR("This is the requester demo !\nEnjoy it !"),
  64.                              D.gerRTOKKind,
  65.                              TAG(tagbuf, D.gerLocaleID, 201, NIL));
  66.  
  67.         (* doitReqKind *)
  68.         WHILE L.GUIRequestA(gui, ADR("Do you want to see this requester again ?"),
  69.                             D.gerRTDoItKind,
  70.                             TAG(tagbuf, D.gerLocaleID, 202, NIL)) = D.gerYes DO
  71.         END;
  72.  
  73.         (* Yes/no/cancel  requester *)
  74.         choose := L.GUIRequestA(gui, ADR("Do you want to see some asl requesters ?"),
  75.                                 D.gerRTYNCKind,
  76.                                 TAG(tagbuf, D.gerLocaleID, 203, NIL));
  77.         IF choose = D.gerYes THEN
  78.  
  79.           (* And now the asl requesters supported by GUIEnvironment *)
  80.  
  81.           file := "guienv.library";
  82.           dir  := "sys:libs";
  83.  
  84.           (* First a requester to choose the best library ! *)
  85.           IF L.GUIRequestA(gui, ADR("Choose the best library"),
  86.                            D.gerRTFileKind, TAG(tagbuf,
  87.                            D.gerPattern, ADR("#?.library"),
  88.                            D.gerFileBuffer, ADR(file),
  89.                            D.gerDirBuffer, ADR(dir),
  90.                            D.gerLocaleID, 204, NIL)) = D.gerYes THEN
  91.             args[0] := ADR(dir);
  92.             args[1] := ADR(file);
  93.             IGNORE L.GUIRequestA(gui, ADR("You choice was:\ndir : %s\nfile: %s"),
  94.                                  D.gerRTOKKind, TAG(tagbuf,
  95.                                  D.gerArgs, ADR(args),
  96.                                  D.gerLocaleID, 205, NIL));
  97.           ELSE
  98.             IGNORE L.GUIRequestA(gui, ADR("You cancelled it ! (Sniff..)"),
  99.                                  D.gerRTOKKind,
  100.                                  TAG(tagbuf, D.gerLocaleID, 206, NIL));
  101.           END;
  102.  
  103.           (* And now a save dir requester with no pattern gadget *)
  104.           dir := "ram:t";
  105.           IF L.GUIRequestA(gui, ADR("Choose directory to save something..."),
  106.                            D.gerRTDirKind, TAG(tagbuf,
  107.                            D.gerNameBuffer, ADR(dir),
  108.                            D.gerPattern, NIL,
  109.                            D.gerSave, TRUE,
  110.                            D.gerLocaleID, 207, NIL)) = D.gerYes THEN
  111.  
  112.             args[0] := ADR(dir);
  113.             IGNORE L.GUIRequestA(gui, ADR("You selected directory:\n%s"),
  114.                                  D.gerRTOKKind, TAG(tagbuf,
  115.                                  D.gerArgs, ADR(args),
  116.                                  D.gerLocaleID, 208, NIL));
  117.           ELSE
  118.             IGNORE L.GUIRequestA(gui, ADR("You cancelled it ! (Snuff..)"),
  119.                                  D.gerRTOKKind,
  120.                                  TAG(tagbuf, D.gerLocaleID, 209, NIL));
  121.           END;
  122.  
  123.         ELSIF choose = D.gerNo  THEN
  124.           IGNORE L.GUIRequestA(gui, ADR("Click OK to quit !"), D.gerRTOKKind,
  125.                                TAG(tagbuf, D.gerLocaleID, 210, NIL));
  126.         END;
  127.  
  128.       END;
  129.     END;
  130.   END;
  131.  
  132. CLOSE
  133.   IF win # NIL THEN
  134.     L.CloseGUIWindow(win);
  135.     win := NIL;
  136.   END;
  137. END RequesterExample.
  138.