home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 5 / amigaformatcd05.iso / mui / developer / oberon / examples / settings.mod < prev    next >
Text File  |  1996-08-13  |  6KB  |  179 lines

  1. MODULE  Settings;
  2.  
  3. IMPORT
  4.   Mui,
  5.   mb := MuiBasics,
  6.   Exec,
  7.   Utility,
  8.   y := SYSTEM,
  9.   I := Intuition,
  10.   Dos;
  11.  
  12.  
  13. VAR window, app, str1, str2, str3, str4, cy1, sl1 : Mui.Object;
  14.     btsave, btuse, btcancel : Mui.Object;
  15.     dum : Mui.Object;
  16.     signals : LONGSET;
  17.     running : BOOLEAN;
  18.  
  19. TYPE  SA2 = ARRAY 3 OF Exec.STRPTR;
  20.  
  21. CONST sex = SA2( y.ADR( "male" ), y.ADR( "female" ), NIL );
  22.  
  23.   idCancel = 1;
  24.   idSave   = 2;
  25.   idUse    = 3;
  26.  
  27.   PROCEDURE fail( obj : Mui.Object; s : ARRAY OF CHAR );
  28.     BEGIN
  29.       IF obj # NIL THEN
  30.         Mui.DisposeObject( obj );
  31.       END;
  32.       IF Dos.PutStr( s ) = 0 THEN END;
  33.       HALT( 20 );
  34.     END fail;
  35.  
  36. BEGIN
  37.   mb.ApplicationObject( Mui.aApplicationTitle      , y.ADR("Oberon Settings"),
  38.                         Mui.aApplicationVersion    , y.ADR("$VER: Oberon Settings 1.0 (25.08.93)"),
  39.                         Mui.aApplicationCopyright  , y.ADR("© 1992/93, Stefan Stuntz/Albert Weinert"),
  40.                         Mui.aApplicationAuthor     , y.ADR("Stefan Stzung/Albert Weinert"),
  41.                         Mui.aApplicationDescription, y.ADR("Show Saving and loading of settings"),
  42.                         Mui.aApplicationBase       , y.ADR("SETTINGS"),
  43.                         Utility.end );
  44.     mb.SubWindow;
  45.     mb.WindowObject( Mui.aWindowTitle, y.ADR("Settings"),
  46.                      Mui.aWindowID   , y.VAL( LONGINT, "SETT" ),
  47.                      Utility.end );
  48.  
  49.       mb.WindowContents;
  50.       mb.VGroup;
  51.         mb.Child; mb.ColGroup( 2 );
  52.           mb.GroupFrameT( "User Identification" );
  53.             mb.Child; mb.label2(  "Name:"  );
  54.             mb.Child; mb.StringObject;
  55.                          mb.StringFrame;
  56.                            mb.TagItem( Mui.aExportID, 1 );
  57.                        str1 := mb.End();
  58.  
  59.             mb.Child; mb.label2( "Street:" );
  60.             mb.Child; mb.StringObject;
  61.                         mb.StringFrame;
  62.                           mb.TagItem( Mui.aExportID, 2 );
  63.                       str2 := mb.End();
  64.  
  65.             mb.Child; mb.label2( "City:" );
  66.             mb.Child; mb.StringObject;
  67.                         mb.StringFrame;
  68.                          mb.TagItem( Mui.aExportID, 3 );
  69.                       str3 := mb.End();
  70.  
  71.             mb.Child; mb.label2( "Password:" );
  72.             mb.Child; mb.StringObject;
  73.                         mb.StringFrame;
  74.                           mb.TagItem2( Mui.aExportID, 4,
  75.                                        Mui.aStringSecret, Exec.true );
  76.  
  77.                       str4 := mb.End();
  78.  
  79.             mb.Child; mb.label1( "Sex:" );
  80.             mb.Child; mb.CycleObject( Mui.aCycleEntries, y.ADR( sex ),
  81.                                         Mui.aExportID, 6,
  82.                                         Utility.end );
  83.                       cy1 := mb.End();
  84.  
  85.             mb.Child; mb.label( "Age:" );
  86.             mb.Child; mb.SliderObject( Mui.aExportID, 5,
  87.                                          Mui.aSliderMin, 9,
  88.                                          Mui.aSliderMax, 99,
  89.                                          Utility.end );
  90.                       sl1 := mb.End();
  91.         mb.end;
  92.  
  93.         mb.Child; mb.VSpace( 2 );
  94.  
  95.         mb.Child; mb.HGroup;
  96.                     mb.TagItem( Mui.aGroupSameSize, Exec.true );
  97.                     mb.Child; btsave := mb.KeyButton( "Save", "s" );
  98.                     mb.Child; mb.HSpace( 0 );
  99.                     mb.Child; btuse := mb.KeyButton( "Use", "u" );
  100.                     mb.Child; mb.HSpace( 0 );
  101.                     mb.Child; btcancel := mb.KeyButton( "Cancel" , "c" );
  102.                   mb.end;
  103.  
  104.       mb.end;
  105.     window := mb.End();
  106.   app := mb.End();
  107.  
  108.   IF app = NIL THEN fail( window, "Failed to create Application\n" ) END;
  109.  
  110. (*
  111.  *  Install notification events...
  112.  *)
  113.  
  114.   Mui.DoMethod( window, Mui.mNotify, Mui.aWindowCloseRequest, Exec.true,
  115.                         app, 2, Mui.mApplicationReturnID, idCancel );
  116.  
  117.   Mui.DoMethod( btcancel, Mui.mNotify, Mui.aPressed, Exec.false,
  118.                           app, 2, Mui.mApplicationReturnID, idCancel );
  119.  
  120.   Mui.DoMethod( btsave, Mui.mNotify, Mui.aPressed, Exec.false,
  121.                         app, 2, Mui.mApplicationReturnID, idSave );
  122.  
  123.   Mui.DoMethod( btuse, Mui.mNotify, Mui.aPressed, Exec.false,
  124.                        app, 2, Mui.mApplicationReturnID, idUse );
  125.  
  126. (*
  127.  *  Cycle chain for keyboard control
  128.  *)
  129.  
  130.   Mui.DoMethod( window, Mui.mWindowSetCycleChain,
  131.                 str1, str2, str3, str4, cy1, sl1, btsave, btuse, btcancel, NIL );
  132.  
  133. (*
  134.  *  Concatenate string, <return> will activate the next one
  135.  *)
  136.  
  137.   Mui.DoMethod( str1, Mui.mNotify, Mui.aStringAcknowledge, Mui.vEveryTime,
  138.                 window, 3, Mui.mSet, Mui.aWindowActiveObject, str2);
  139.  
  140.   Mui.DoMethod( str2, Mui.mNotify, Mui.aStringAcknowledge, Mui.vEveryTime,
  141.                 window, 3, Mui.mSet, Mui.aWindowActiveObject, str3);
  142.  
  143.   Mui.DoMethod( str3, Mui.mNotify, Mui.aStringAcknowledge, Mui.vEveryTime,
  144.                 window, 3, Mui.mSet, Mui.aWindowActiveObject, str4);
  145.  
  146.   Mui.DoMethod( str4, Mui.mNotify, Mui.aStringAcknowledge, Mui.vEveryTime,
  147.                 window, 3, Mui.mSet, Mui.aWindowActiveObject, btuse);
  148.  
  149.   Mui.DoMethod( app, Mui.mApplicationLoad, Mui.vApplicationLoadENV );
  150.  
  151.   mb.Set( window, Mui.aWindowOpen, Exec.true );
  152.   mb.Set( window, Mui.aWindowActiveObject, str1 );
  153.  
  154.   running := TRUE;
  155.   WHILE running DO
  156.     CASE Mui.DOMethod( app, Mui.mApplicationInput, y.ADR(signals), Utility.end ) OF
  157.       | Mui.vApplicationReturnIDQuit, idCancel :
  158.           running := FALSE;
  159.       | idSave :
  160.           Mui.DoMethod( app, Mui.mApplicationSave, Mui.vApplicationSaveENVARC );
  161.       | idUse :
  162.           Mui.DoMethod( app, Mui.mApplicationSave, Mui.vApplicationSaveENV );
  163.           running := FALSE;
  164.     ELSE END;
  165.     IF (running) & (signals # LONGSET{}) THEN y.SETREG( 0, Exec.Wait(signals) ) END;
  166.   END;
  167.  
  168.   mb.Set(window, Mui.aWindowOpen, Exec.LFALSE );
  169.  
  170. CLOSE
  171.   IF app # NIL THEN
  172.     Mui.DisposeObject( app );
  173.   ELSE
  174.     IF window # NIL THEN
  175.       Mui.DisposeObject( window );
  176.     END;
  177.   END;
  178. END Settings.
  179.