home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / amiga / gui / mui / mui14-dv.lha / MUI / Developer / Modula / Demo / MuiTest.mod < prev    next >
Encoding:
Text File  |  1993-10-27  |  6.8 KB  |  205 lines

  1. MODULE MuiTest;
  2.  
  3. (*$ LargeVars:=FALSE *)
  4.  
  5. (*
  6. ** This is just a little demo Prg. to show how to use MUI in Modula
  7. ** It has no functions, it just looks good (who cares.... ;-)
  8. ** Please note : There was a little bugfix in this version.
  9. **               Look where the WindowID gets defined - you have
  10. **               to write MakeID("....") instead of ADR("....")
  11. **               then MUI will store your window position!!
  12. **
  13. ** Version : 13.10.1993
  14. *)
  15.  
  16. IMPORT MD:MuiD;
  17. IMPORT ML:MuiL;
  18. IMPORT MM:MuiMacros;
  19. FROM   MuiMacros IMPORT set,get,MakeID;
  20. FROM   MuiSupport IMPORT DOMethod, DoMethod, APTR, fail;
  21. FROM   SYSTEM IMPORT TAG, ADR, LONGSET, CAST;
  22. FROM   ExecL IMPORT Wait;
  23. FROM   UtilityD IMPORT tagEnd;
  24.  
  25. TYPE
  26.     ShortString = ARRAY[0..3] OF CHAR;
  27.  
  28. CONST
  29.     True  = 1;      (* These are for the set-Macro *)
  30.     False = 0;      (* because set excepts just LONGINT as argument *)
  31.     IDbut1= 1;      (* The IDs for the Buttons *)
  32.     IDbut2= 2;
  33.     IDbut3= 3;
  34.     IDbut4= 4;
  35.     IDbut5= 5;
  36.     IDbut6= 6;
  37.  
  38. VAR app,window,bt1,bt2,bt3,bt4,bt5,bt6,Dirs  : APTR;
  39.     signals                                  : LONGSET;
  40.     running                                  : BOOLEAN;
  41.     buffer                                   : ARRAY[0..30] OF LONGINT;
  42.     buffer1                                  : ARRAY[0..30] OF LONGINT;
  43.     buffer2                                  : ARRAY[0..30] OF LONGINT;
  44.     buffer3                                  : ARRAY[0..30] OF LONGINT;
  45.  
  46. BEGIN
  47.  
  48.     running := TRUE;
  49.  
  50.     (* Set up the buttons *)
  51.  
  52.     bt1 := MM.Simplebutton("Button 1");
  53.     bt2 := MM.Keybutton("Button 2",'u');
  54.     bt3 := MM.Keybutton("Button 3",'t');
  55.     bt4 := MM.Keybutton("Button 4",'o');
  56.     bt5 := MM.Keybutton("Button 5",'n');
  57.     bt6 := MM.Keybutton("Cancel",'c');
  58.  
  59.     (* Set up the Volumelist *)
  60.  
  61.     Dirs:= MM.ListviewObject(TAG(buffer1,
  62.                 MD.maListviewList,  MM.VolumelistObject(TAG(buffer2,
  63.                                         MD.maFrame,         MD.mvFrameInputList,
  64.                                         MD.maFrameTitle,    ADR("Magic Volumes"),
  65.                                         MD.maListFormat,    ADR("COL=0"),
  66.                                         tagEnd)),
  67.                 tagEnd));
  68.  
  69.     (* Set up the window *)
  70.  
  71.     window := MM.WindowObject(TAG(buffer,
  72.                     MD.maWindowTitle   , ADR("MUI-Test :-)"),
  73.                     MD.maWindowID      , MakeID("MAIN"),
  74.  
  75.                     MM.WindowContents,
  76.  
  77.                         (* Create an array of Buttons *)
  78.  
  79.                         MM.VGroup(TAG(buffer3,
  80.                             MM.Child, MM.HGroup(TAG(buffer1,
  81.                                     MD.maFrame,         MD.mvFrameGroup,
  82.                                     MD.maFrameTitle,    ADR("Magic Buttons"),
  83.                                     MM.Child, MM.VGroup(TAG(buffer2,MD.maWeight, 20,
  84.                                             MM.Child, bt1,
  85.                                             MM.Child, bt2,
  86.                                             MM.Child, bt3,
  87.                                             tagEnd)),
  88.                                     MM.Child, MM.VGroup(TAG(buffer2,MD.maWeight, 20,
  89.                                             MM.Child, bt4,
  90.                                             MM.Child, bt5,
  91.                                             MM.Child, bt6, (* cancel *)
  92.                                             tagEnd)),
  93.                                     tagEnd)),
  94.  
  95.                             (* Put the Volumelist below them *)
  96.  
  97.                             MM.Child, Dirs,
  98.                             tagEnd)),
  99.                 tagEnd));
  100.  
  101.     (* set up the application object *)
  102.  
  103.     app:=MM.ApplicationObject(TAG(buffer,
  104.                     MD.maApplicationTitle      , ADR("MUITest"),
  105.                     MD.maApplicationVersion    , ADR("V1.0▀"),
  106.                     MD.maApplicationCopyright  , ADR("⌐1993 by Christian Scholz"),
  107.                     MD.maApplicationAuthor     , ADR("Tochkopf"),
  108.                     MD.maApplicationDescription, ADR("Test the MUI-Magic :-)"),
  109.                     MD.maApplicationBase       , ADR("MUITest"),
  110.  
  111.                     MM.SubWindow, window,
  112.  
  113.             tagEnd));
  114.  
  115.     IF app=NIL THEN fail(app, "failed to create Application !!"); END;
  116.  
  117. (* Set up the notification *)
  118.  
  119.             DoMethod(window,TAG(buffer,
  120.                         MD.mmNotify,MD.maWindowCloseRequest,TRUE,
  121.                         app,2,MD.mmApplicationReturnID,IDbut6
  122.                         ));
  123.  
  124.             DoMethod(bt1,TAG(buffer,
  125.                         MD.mmNotify,MD.maPressed,FALSE,
  126.                         app,2,MD.mmApplicationReturnID,IDbut1
  127.                         ));
  128.  
  129.             DoMethod(bt2,TAG(buffer,
  130.                         MD.mmNotify,MD.maPressed,FALSE,
  131.                         app,2,MD.mmApplicationReturnID,IDbut2
  132.                         ));
  133.  
  134.             DoMethod(bt3,TAG(buffer,
  135.                         MD.mmNotify,MD.maPressed,FALSE,
  136.                         app,2,MD.mmApplicationReturnID,IDbut3
  137.                         ));
  138.  
  139.             DoMethod(bt4,TAG(buffer,
  140.                         MD.mmNotify,MD.maPressed,FALSE,
  141.                         app,2,MD.mmApplicationReturnID,IDbut4
  142.                         ));
  143.  
  144.             DoMethod(bt5,TAG(buffer,
  145.                         MD.mmNotify,MD.maPressed,FALSE,
  146.                         app,2,MD.mmApplicationReturnID,IDbut5
  147.                         ));
  148.  
  149.             DoMethod(bt6,TAG(buffer,
  150.                         MD.mmNotify,MD.maPressed,FALSE,
  151.                         app,2,MD.mmApplicationReturnID,IDbut6
  152.                         ));
  153.  
  154. (* Cycle Chain for Keyboard *)
  155.  
  156.             DoMethod(window,TAG(buffer,
  157.                         MD.mmWindowSetCycleChain,
  158.                         bt1, bt2, bt3, bt4, bt5, bt6, Dirs, 0
  159.                         ));
  160.  
  161. (* Main Loop *)
  162.  
  163.             (* Open the window and set first active object
  164.                Here is also shown, how to use True and False in set *)
  165.  
  166.             set(window,MD.maWindowOpen, True);
  167.             set(window,MD.maWindowActiveObject, Dirs);
  168.  
  169.             (* Event Loop *)
  170.  
  171.             WHILE running DO
  172.  
  173.                         CASE DOMethod(app,TAG(buffer,
  174.                                       MD.mmApplicationInput,ADR(signals))) OF
  175.  
  176.                         |   MD.mvApplicationReturnIDQuit,IDbut6:
  177.                                     running:=FALSE;
  178.                         |   IDbut1,IDbut2,IDbut3,IDbut4, IDbut5:
  179.                                     fail(app, "Application failed of no reason");
  180.                         ELSE
  181.  
  182.                         END;
  183.  
  184.  
  185.                         IF running AND (signals <> LONGSET{} ) THEN signals:=Wait(signals);
  186.                                                    END;
  187.             END; (* While *)
  188.  
  189.             (* Close window *)
  190.  
  191.             set(window,MD.maWindowOpen, False);
  192.  
  193. (* Shut up *)
  194.  
  195.         fail(app,"");
  196.  
  197. END MuiTest.
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.