home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / languages / obrn-a_1.5_lib.lha / oberon-a / source1.lha / source / amiga / Commodities.mod < prev    next >
Encoding:
Text File  |  1995-01-26  |  12.0 KB  |  433 lines

  1. (***************************************************************************
  2.  
  3.      $RCSfile: Commodities.mod $
  4.   Description: Interface to commodities.library
  5.  
  6.    Created by: fjc (Frank Copeland)
  7.     $Revision: 3.7 $
  8.       $Author: fjc $
  9.         $Date: 1995/01/26 02:39:55 $
  10.  
  11.   Includes Release 40.15
  12.  
  13.   (C) Copyright 1985-1993 Commodore-Amiga, Inc.
  14.       All Rights Reserved
  15.  
  16.   Oberon-A interface Copyright © 1994-1995, Frank Copeland.
  17.   This file is part of the Oberon-A Interface.
  18.   See Oberon-A.doc for conditions of use and distribution.
  19.  
  20. ***************************************************************************)
  21.  
  22. <* STANDARD- *> <* INITIALISE- *> <* MAIN- *>
  23. <*$ CaseChk-  IndexChk- LongVars+ NilChk-  *>
  24. <*$ RangeChk- StackChk- TypeChk-  OvflChk- *>
  25.  
  26. MODULE [2] Commodities;
  27.  
  28. IMPORT
  29.   SYS := SYSTEM, Kernel, e := Exec, Ie := InputEvent, Km := KeyMap,
  30.   s := Sets;
  31.  
  32. (**-- Pointer declarations ---------------------------------------------*)
  33.  
  34. TYPE
  35.  
  36.   NewBrokerPtr *      = POINTER TO NewBroker;
  37.   InputXpressionPtr * = POINTER TO InputXpression;
  38.   IXPtr *             = POINTER TO IX;
  39.   CxObjPtr *          = POINTER TO CxObj;
  40.   CxMsgPtr *          = POINTER TO CxMsg;
  41.  
  42. (*
  43. **      $VER: commodities.h 38.4 (24.2.93)
  44. **
  45. **      Commodities definitions.
  46. *)
  47.  
  48. (*****************************************************************************)
  49.  
  50. CONST
  51.  
  52. (* Sizes for various buffers *)
  53.   nameLen * = 24;
  54.   titleLen * = 40;
  55.   descrLen * = 40;
  56.  
  57. TYPE
  58.  
  59.   NameStr * = ARRAY nameLen OF CHAR;
  60.   TitleStr * = ARRAY titleLen OF CHAR;
  61.   DescrStr * = ARRAY descrLen OF CHAR;
  62.  
  63.   NewBroker * = RECORD
  64.     version * :  SHORTINT;        (* Must be set to NB_VERSION *)
  65.     name *    :  POINTER TO NameStr;
  66.     title *   :  POINTER TO TitleStr;
  67.     descr *   :  POINTER TO DescrStr;
  68.     unique *  :  s.SET16;
  69.     flags *   :  s.SET16;
  70.     pri *     :  SHORTINT;
  71.     port *    :  e.MsgPortPtr;
  72.     reservedChannel * :  INTEGER;
  73.   END;
  74.  
  75. CONST
  76.  
  77. (* constant for NewBroker.version *)
  78.   nbVersion * = 5;          (* Version of NewBroker structure *)
  79.  
  80. (* Flags for NewBroker.unique *)
  81.   duplicate * = 0;
  82.   unique * = 1;             (* will not allow duplicates           *)
  83.   notify * = 2;             (* sends cxmUnique to existing broker *)
  84.  
  85. (* Flags for NewBroker.flags *)
  86.   showHide * = 4;
  87.  
  88.  
  89. (*****************************************************************************)
  90.  
  91. TYPE
  92.  
  93. (* Fake data types for system private objects *)
  94.   CxObj = RECORD END;
  95.   CxMsg = RECORD END;
  96.  
  97. (* Pointer to a function returning a LONG *)
  98.   PFL = PROCEDURE () : LONGINT;
  99.  
  100.  
  101. (*****************************************************************************)
  102.  
  103. CONST
  104.  
  105. (* Commodities object types *)
  106.   invalid *    = 0;  (* not a valid object (probably null) *)
  107.   filter *     = 1;  (* input event messages only          *)
  108.   typeFilter * = 2;  (* obsolete, do not use               *)
  109.   send *       = 3;  (* sends a message                    *)
  110.   signal *     = 4;  (* sends a signal                     *)
  111.   translate *  = 5;  (* translates input event into chain  *)
  112.   broker *     = 6;  (* application representative         *)
  113.   debug *      = 7;  (* dumps info to serial port          *)
  114.   custom *     = 8;  (* application provides function      *)
  115.   zero *       = 9;  (* system terminator node             *)
  116.  
  117.  
  118. (*****************************************************************************)
  119.  
  120. CONST
  121.  
  122. (* Commodities message types *)
  123.   cxmIEvent * = 32;
  124.   cxmCommand * = 64;
  125.  
  126. (* Only mIEvent messages are passed through the input network. Other types
  127.  * of messages are sent to an optional port in your broker. This means that
  128.  * you must test the message type in your message handling, if input messages
  129.  * and command messages come to the same port.
  130.  *
  131.  * cxmIEvent:  Messages of this type rattle around the Commodities input
  132.  *             network. They are sent to you by a Sender object, and passed
  133.  *             to you as a synchronous function call by a Custom object.
  134.  *
  135.  *             The message port or function entry point is stored in the
  136.  *             object, and the ID field of the message will be set to what
  137.  *             you arrange issuing object.
  138.  *
  139.  *             The data section of the message will point to the input event
  140.  *             triggering the message.
  141.  *
  142.  * cxmCommand: These messages are sent to a port attached to your Broker.
  143.  *             They are sent to you when the controller program wants your
  144.  *             program to do something. The ID value identifies the command.
  145.  *)
  146.  
  147. CONST
  148.  
  149. (* ID values associated with a message of type mCommand *)
  150.   cmdDisable * = 15;        (* please disable yourself         *)
  151.   cmdEnable * = 17;         (* please enable yourself  *)
  152.   cmdAppear * = 19;         (* open your window, if you can    *)
  153.   cmdDisappear * = 21;      (* go dormant                      *)
  154.   cmdKill * = 23;           (* go away for good                *)
  155.   cmdListChg * = 27;        (* Someone changed the broker list *)
  156.   cmdUnique * = 25;         (* someone tried to create a broker
  157.                              * with your name. Suggest you appear.
  158.                              *)
  159.  
  160.  
  161. (*****************************************************************************)
  162.  
  163. TYPE
  164.  
  165.   InputXpression * = RECORD
  166.     version *   :  SHORTINT; (* must be set to ixVersion *)
  167.     class *     :  SHORTINT; (* class must match exactly  *)
  168.  
  169.     code *      :  s.SET16;  (* Bits that we want *)
  170.     codeMask *  :  INTEGER;  (* Set bits here to indicate which bits in code
  171.                               * are don't care bits.
  172.                               *)
  173.     qualifier * :  s.SET16;  (* Bits that we want *)
  174.     qualMask *  :  s.SET16;  (* Set bits here to indicate which bits in
  175.                               * qualifier are don't care bits
  176.                               *)
  177.     qualSame *  :  s.SET16;  (* synonyms in qualifier *)
  178.   END;
  179.  
  180.   IX * = InputXpression;
  181.  
  182. CONST
  183.  
  184. (* constant for InputXpression.version *)
  185.   ixVersion * = 2;
  186.  
  187. (* constants for InputXpression.qualSame *)
  188.   ixSymShift * = 0;     (* left- and right- shift are equivalent     *)
  189.   ixSymCaps * = 1;      (* either shift or caps lock are equivalent  *)
  190.   ixSymAlt * = 2;       (* left- and right- alt are equivalent       *)
  191.  
  192.   ixSymShiftMask * = {Ie.lShift, Ie.rShift};
  193.   ixSymCapsMask * = ixSymShiftMask + {Ie.capsLock};
  194.   ixSymAltMask * = {Ie.lAlt, Ie.rAlt};
  195.  
  196. (* constant for InputXpression.qualMask *)
  197.   ixNormalQuals * = -{Ie.relativeMouse};     (* avoid RELATIVEMOUSE *)
  198.  
  199.  
  200. (*****************************************************************************)
  201.  
  202. CONST
  203.  
  204. (* Error returns from CxBroker() *)
  205.   errOk * = 0;          (* No error                               *)
  206.   errSysErr * = 1;      (* System error, no memory, etc           *)
  207.   errDup * = 2;         (* uniqueness violation                   *)
  208.   errVersion * = 3;     (* didn't understand NewBroker.nb_Version *)
  209.  
  210.  
  211. (*****************************************************************************)
  212.  
  213. CONST
  214.  
  215. (* Return values from CxObjError() *)
  216.   coErrIsNull * = 0;           (* you called CxObjError(NULL)        *)
  217.   coErrNullAttach * = 1;       (* someone attached NULL to my list   *)
  218.   coErrBadFilter * = 2;        (* a bad filter description was given *)
  219.   coErrBadType * = 3;          (* unmatched type-specific operation  *)
  220.  
  221.  
  222. (*****************************************************************************)
  223.  
  224. TYPE
  225.   LONGBOOL * = e.LONGBOOL;
  226.  
  227. CONST
  228.   LTRUE * = e.LTRUE;
  229.   LFALSE * = e.LFALSE;
  230.  
  231.  
  232. (**-- Library Base variable --------------------------------------------*)
  233.  
  234. CONST
  235.  
  236.   commoditiesName * = "commodities.library";
  237.  
  238. VAR
  239.  
  240.   base * : e.LibraryPtr;
  241.  
  242.  
  243. (**-- Library Functions ------------------------------------------------*)
  244.  
  245. (*
  246. **      $VER: commodities_protos.h 38.4 (27.2.92)
  247. *)
  248.  
  249. TYPE
  250.   CustomProcType * = PROCEDURE ( obj : CxObjPtr; msg : CxMsgPtr );
  251.  
  252. (* --- functions in V36 or higher (distributed as Release 2.0) ---*)
  253.  
  254. (*  OBJECT UTILITIES *)
  255.  
  256. PROCEDURE CreateCxObj* [base,-30]
  257.   ( type [0] : e.ULONG;
  258.     arg1 [8] : SYS.LONGWORD;
  259.     arg2 [9] : SYS.LONGWORD )
  260.   : CxObjPtr;
  261. PROCEDURE CxBroker* [base,-36]
  262.   ( VAR nb    [8] : NewBroker;
  263.     VAR error [0] : LONGINT )
  264.   : CxObjPtr;
  265. PROCEDURE ActivateCxObj* [base,-42]
  266.   ( co   [8] : CxObjPtr;
  267.     true [0] : LONGBOOL )
  268.   : LONGBOOL;
  269. PROCEDURE DeleteCxObj* [base,-48]
  270.   ( co [8] : CxObjPtr );
  271. PROCEDURE DeleteCxObjAll* [base,-54]
  272.   ( co [8] : CxObjPtr );
  273. PROCEDURE CxObjType* [base,-60]
  274.   ( co [8] : CxObjPtr )
  275.   : e.ULONG;
  276. PROCEDURE CxObjError* [base,-66]
  277.   ( co [8] : CxObjPtr )
  278.   : s.SET32;
  279. PROCEDURE ClearCxObjError* [base,-72]
  280.   ( co [8] : CxObjPtr );
  281. PROCEDURE SetCxObjPri* [base,-78]
  282.   ( co  [8] : CxObjPtr;
  283.     pri [0] : LONGINT )
  284.   : LONGINT;
  285.  
  286. (*  OBJECT ATTACHMENT *)
  287.  
  288. PROCEDURE AttachCxObj* [base,-84]
  289.   ( headObj [8] : CxObjPtr;
  290.     co      [9] : CxObjPtr );
  291. PROCEDURE EnqueueCxObj* [base,-90]
  292.   ( headObj [8] : CxObjPtr;
  293.     co      [9] : CxObjPtr );
  294. PROCEDURE InsertCxObj* [base,-96]
  295.   ( headObj [8] : CxObjPtr;
  296.     co      [9] : CxObjPtr;
  297.     pred   [10] : CxObjPtr );
  298. PROCEDURE RemoveCxObj* [base,-102]
  299.   ( co [8] : CxObjPtr );
  300.  
  301. (*  TYPE SPECIFIC *)
  302.  
  303. PROCEDURE SetTranslate* [base,-114]
  304.   ( translator [8] : CxObjPtr;
  305.     VAR events [9] : Ie.InputEvent );
  306. PROCEDURE SetFilter* [base,-120]
  307.   ( filter [8] : CxObjPtr;
  308.     text   [9] : ARRAY OF CHAR );
  309. PROCEDURE SetFilterIX* [base,-126]
  310.   ( filter [8] : CxObjPtr;
  311.     VAR ix [9] : IX );
  312. PROCEDURE ParseIX* [base,-132]
  313.   ( description [8] : ARRAY OF CHAR;
  314.     VAR ix      [9] : IX )
  315.   : LONGINT;
  316.  
  317. (*  COMMON MESSAGE *)
  318.  
  319. PROCEDURE CxMsgType* [base,-138]
  320.   ( cxm [8] : CxMsgPtr )
  321.   : s.SET32;
  322. PROCEDURE CxMsgData* [base,-144]
  323.   ( cxm [8] : CxMsgPtr )
  324.   : e.APTR;
  325. PROCEDURE CxMsgID* [base,-150]
  326.   ( cxm [8] : CxMsgPtr )
  327.   : LONGINT;
  328.  
  329. (*  MESSAGE ROUTING *)
  330.  
  331. PROCEDURE DivertCxMsg* [base,-156]
  332.   ( cxm     [8] : CxMsgPtr;
  333.     headobj [9] : CxObjPtr;
  334.     ret    [10] : CxObjPtr );
  335. PROCEDURE RouteCxMsg* [base,-162]
  336.   ( cxm [8] : CxMsgPtr;
  337.     co  [9] : CxObjPtr );
  338. PROCEDURE DisposeCxMsg* [base,-168]
  339.   ( cxm [8] : CxMsgPtr );
  340.  
  341. (*  INPUT EVENT HANDLING *)
  342.  
  343. PROCEDURE InvertKeyMap* [base,-174]
  344.   ( ansicode [0] : e.ULONG;
  345.     event    [8] : Ie.InputEventDummyPtr;
  346.     km       [9] : Km.KeyMapPtr )
  347.   : BOOLEAN;
  348. PROCEDURE AddIEvents* [base,-180]
  349.   ( events [8] : Ie.InputEventDummyPtr );
  350.  
  351. (*--- functions in V38 or higher (Release 2.1) ---*)
  352.  
  353. (*  MORE INPUT EVENT HANDLING *)
  354.  
  355. PROCEDURE MatchIX* [base,-204]
  356.   ( event [8] : Ie.InputEventDummyPtr;
  357.     ix    [9] : IXPtr )
  358.   : BOOLEAN;
  359.  
  360. (**-- C Macros defined as procedures -----------------------------------*)
  361.  
  362. <*$LongVars+*>
  363.  
  364. (*************************
  365.  * object creation macros
  366.  *************************)
  367.  
  368. (**-----------------------------------*)
  369. PROCEDURE [0] CxFilter * (d : e.APTR)
  370.   : CxObjPtr;
  371. BEGIN (* CxFilter *)
  372.   RETURN CreateCxObj (filter, d, NIL)
  373. END CxFilter;
  374.  
  375. (**-----------------------------------*)
  376. PROCEDURE [0] CxTypeFilter * (type : e.APTR)
  377.   : CxObjPtr;
  378. BEGIN (* CxTypeFilter *)
  379.   RETURN CreateCxObj (typeFilter, type, NIL)
  380. END CxTypeFilter;
  381.  
  382. (**-----------------------------------*)
  383. PROCEDURE [0] CxSender * (port : e.MsgPortPtr; id : e.APTR)
  384.   : CxObjPtr;
  385. BEGIN (* CxSender *)
  386.   RETURN CreateCxObj (send, port, id)
  387. END CxSender;
  388.  
  389. (**-----------------------------------*)
  390. PROCEDURE [0] CxSignal * (task : e.TaskPtr; sig : INTEGER)
  391.   : CxObjPtr;
  392. BEGIN (* CxSignal *)
  393.   RETURN CreateCxObj (signal, task, sig)
  394. END CxSignal;
  395.  
  396. (**-----------------------------------*)
  397. PROCEDURE [0] CxTranslate * (ie : Ie.InputEventDummyPtr)
  398.   : CxObjPtr;
  399. BEGIN (* CxTranslate *)
  400.   RETURN CreateCxObj (translate, ie, NIL)
  401. END CxTranslate;
  402.  
  403. (**-----------------------------------*)
  404. PROCEDURE [0] CxDebug * (id : e.APTR)
  405.   : CxObjPtr;
  406. BEGIN (* CxDebug *)
  407.   RETURN CreateCxObj (debug, id, NIL)
  408. END CxDebug;
  409.  
  410. (**-----------------------------------*)
  411. PROCEDURE [0] CxCustom * (action : CustomProcType; id : e.APTR)
  412.   : CxObjPtr;
  413. BEGIN (* CxCustom *)
  414.   RETURN CreateCxObj (custom, action, id)
  415. END CxCustom;
  416.  
  417.  
  418. (**-- Library Base variable --------------------------------------------*)
  419.  
  420. <*$LongVars-*>
  421.  
  422. (**-----------------------------------*)
  423. PROCEDURE* [0] CloseLib (VAR rc : LONGINT);
  424.  
  425. BEGIN (* CloseLib *)
  426.   IF base # NIL THEN e.CloseLibrary (base) END;
  427. END CloseLib;
  428.  
  429. BEGIN
  430.   base := e.OpenLibrary (commoditiesName, e.libraryMinimum);
  431.   IF base # NIL THEN Kernel.SetCleanup (CloseLib) END
  432. END Commodities.
  433.