home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 5 / amigaformatcd05.iso / mui / developer / oberon / txt / boopsidoor.mod next >
Text File  |  1996-08-13  |  5KB  |  137 lines

  1. (*
  2. ** This program needs at least V39 interface files !
  3. ** It is possible that OpenLibrary call in Gadgets.mod
  4. ** do not an OpenLibrary ( "gadgets/colorwheel.gadget", 39 ).
  5. ** But only with this the Programm works, you MUST change this.
  6. *)
  7. MODULE BoopsiDoor;
  8.  
  9. IMPORT  I := Intuition,
  10.         G := Gadgets,
  11.         Mui,
  12.         Dos,
  13.         mb := MuiBasics,
  14.         Exec,
  15.         y := SYSTEM,
  16.         u := Utility;
  17.  
  18.  
  19.  
  20. (*
  21. ** Gauge object macro to display colorwheels
  22. ** hue and saturation values.
  23. *)
  24.  
  25.   PROCEDURE InfoGauge():Mui.Object;
  26.     BEGIN
  27.       mb.GaugeObject;
  28.         mb.GaugeFrame;
  29.         mb.Tags( Mui.aBackground  , Mui.iBACKGROUND,
  30.                  Mui.aGaugeMax   , 16384,
  31.                  Mui.aGaugeDivide, 262144,
  32.                  Mui.aGaugeHoriz , Exec.true,
  33.                  u.end );
  34.       RETURN mb.End();
  35.     END InfoGauge;
  36.  
  37.   PROCEDURE fail( obj : Mui.Object; s : ARRAY OF CHAR );
  38.     BEGIN
  39.       IF obj # NIL THEN
  40.         Mui.DisposeObject( obj );
  41.       END;
  42.       IF Dos.PutStr( s ) = 0 THEN END;
  43.       HALT( 20 );
  44.     END fail;
  45.  
  46. VAR App, Window, Wheel, Hue, Sat : Mui.Object;
  47.     signal : LONGSET;
  48.  
  49. BEGIN
  50.   IF G.cwBase = NIL THEN
  51.     fail( NIL, "colorwheel boopsi gadget not available\n" );
  52.   END;
  53.  
  54.   mb.ApplicationObject( Mui.aApplicationTitle      , y.ADR( "Oberon BoopsiDoor" ),
  55.                         Mui.aApplicationVersion    , y.ADR( "$VER: Oberon BoopsiDoor 1.0 (25.08.93)" ),
  56.                         Mui.aApplicationCopyright  , y.ADR( "©1992/93, Stefan Stuntz/Albert Weinert" ),
  57.                         Mui.aApplicationAuthor     , y.ADR( "Stefan Stuntz/Albert Weinert" ),
  58.                         Mui.aApplicationDescription, y.ADR( "Show a boopsi colorwheel with MUI." ),
  59.                         Mui.aApplicationBase       , y.ADR( "BOOPSIDOOR" ),
  60.                         u.end );
  61.     mb.SubWindow; mb.WindowObject( Mui.aWindowTitle, y.ADR( "BoopsiDoor" ),
  62.                                    Mui.aWindowID   , y.VAL( LONGINT, 'BOOP' ),
  63.                                    u.end );
  64.  
  65.                     mb.WindowContents; mb.VGroup;
  66.  
  67.                       mb.Child; mb.ColGroup( 2 );
  68.                                   mb.Child; mb.label("Hue:"       ); mb.Child; Hue := InfoGauge();
  69.                                   mb.Child; mb.label("Saturation:"); mb.Child; Sat := InfoGauge();
  70.                                   mb.Child; mb.RectangleObject( Mui.aWeight, 0, u.end); mb.end; mb.Child; mb.ScaleObject; mb.end;
  71.                                 mb.end;
  72.  
  73.                        mb.Child; mb.BoopsiObject; (* MUI and Boopsi tags mixed *)
  74.  
  75.                                    mb.GroupFrame;
  76.  
  77.                                    mb.Tags( Mui.aBoopsiClassID  , y.ADR( G.colorWheelName ),
  78.  
  79.                                             Mui.aBoopsiMinWidth , 30, (* boopsi objects don't know *)
  80.                                             Mui.aBoopsiMinHeight, 30, (* their sizes, so we help   *)
  81.           
  82.                                             Mui.aBoopsiRemember , G.wheelSaturation, (* keep important values *)
  83.                                             Mui.aBoopsiRemember , G.wheelHue,        (* during window resize  *)
  84.           
  85.                                             Mui.aBoopsiTagScreen, G.wheelScreen, (* this magic fills in *)
  86.                                             G.wheelScreen       , NIL,         (* the screen pointer  *)
  87.           
  88.                                             I.gaLeft     , 0,
  89.                                             I.gaTop      , 0, (* MUI will automatically     *)
  90.                                             I.gaWidth    , 0, (* fill in the correct values *)
  91.                                             I.gaHeight   , 0,
  92.           
  93.                                             I.icaTarget  , I.icTargetIDCMP, (* needed for notification *)
  94.           
  95.                                             G.wheelSaturation, 0, (* start in the center *)
  96.                                             u.end );
  97.                                   Wheel := mb.End();
  98.                           mb.end;
  99.                   Window := mb.End();
  100.   App := mb.End();
  101.  
  102.   IF App = NIL THEN
  103.     fail( App, "Failed to create Application.\n" );
  104.   END;
  105.  
  106. (*
  107. ** you can react on every boopsi notification
  108. ** event as on any other MUI attribute.
  109. *)
  110.  
  111.   Mui.DoMethod(Wheel,Mui.mNotify,G.wheelHue       ,Mui.vEveryTime,Hue,4,Mui.mSet,Mui.aGaugeCurrent,Mui.vTriggerValue);
  112.   Mui.DoMethod(Wheel,Mui.mNotify,G.wheelSaturation,Mui.vEveryTime,Sat,4,Mui.mSet,Mui.aGaugeCurrent,Mui.vTriggerValue);
  113.  
  114.  
  115. (*
  116. ** Simplest possible MUI main loop.
  117. *)
  118.  
  119.         Mui.DoMethod(Window,Mui.mNotify,Mui.aWindowCloseRequest,Exec.true,App,2,Mui.mApplicationReturnID,Mui.vApplicationReturnIDQuit);
  120.         mb.Set(Window,Mui.aWindowOpen, Exec.true);
  121.  
  122.         WHILE (Mui.DOMethod(App,Mui.mApplicationInput, y.ADR( signal) ) # Mui.vApplicationReturnIDQuit) DO
  123.                 IF signal # LONGSET{} THEN
  124.                    y.SETREG( 0, Exec.Wait(signal) );
  125.                 END;
  126.         END;
  127.  
  128.         mb.Set(Window,Mui.aWindowOpen, Exec.false);
  129.  
  130.  
  131. (*
  132. ** shut down.
  133. *)
  134.  
  135.         fail(App, "");
  136. END BoopsiDoor.
  137.