home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / M2V11-1.LHA / modula / amiga / Commodities.def < prev    next >
Encoding:
Text File  |  1993-11-10  |  8.2 KB  |  241 lines

  1. DEFINITION FOR LIBRARY MODULE Commodities ;
  2.  
  3. FROM SYSTEM    IMPORT STRING, ADDRESS, SHORTSET, LONGSET, LONGWORD ;
  4. FROM Exec    IMPORT MsgPortPtr, TaskPtr, LibraryPtr ;
  5. FROM InputEvent IMPORT InputEventPtr, IEQUALIFIER_LSHIFT, IEQUALIFIER_RSHIFT,
  6.                IEQUALIFIER_CAPSLOCK, IEQUALIFIER_LALT, IEQUALIFIER_RALT;
  7.  
  8. FROM KeyMap    IMPORT KeyMapPtr ;
  9.  
  10. (*============================================================================*)
  11.  
  12. TYPE
  13.   NewBroker = RECORD
  14.     nb_Version        : SHORTINT ;   (* Must be set to NB_VERSION *)
  15.     nb_Name        : STRING ;
  16.     nb_Title        : STRING ;
  17.     nb_Descr        : STRING ;
  18.     nb_Unique        : INTEGER ;
  19.     nb_Flags        : BITSET ;
  20.     nb_Pri        : SHORTINT ;
  21.     nb_Port        : MsgPortPtr ;
  22.     nb_ReservedChannel    : INTEGER ;
  23.   END ;
  24.   NewBrokerPtr = POINTER TO NewBroker ;
  25.  
  26. (* constant for NewBroker.nb_Version *)
  27. CONST
  28.   NB_VERSION    = 5 ;        (* Version of NewBroker structure *)
  29.  
  30. (* Sizes for various buffers *)
  31.   CBD_NAMELEN      = 24 ;
  32.   CBD_TITLELEN     = 40 ;
  33.   CBD_DESCRLEN     = 40 ;
  34.  
  35. (* Flags for NewBroker.nb_Unique *)
  36.   NBU_DUPLICATE = 0 ;
  37.   NBU_UNIQUE    = 1 ; (* will not allow duplicates         *)
  38.   NBU_NOTIFY    = 2 ; (* sends CXM_UNIQUE to existing broker *)
  39.  
  40. (* Flags for NewBroker.nb_Flags *)
  41.   COF_SHOW_HIDE = 4 ;
  42.  
  43. (*============================================================================*)
  44.  
  45. (* Fake data types for system private objects *)
  46.  
  47. TYPE
  48.   CxObj        = LONGINT ;
  49.   CxMsg        = LONGINT ;
  50.   CxObjPtr    = POINTER TO CxObj ;
  51.   CxMsgPtr    = POINTER TO CxMsg ;
  52.  
  53. (* Pointer to a function returning a LONG *)
  54.  
  55.   PFL        = PROCEDURE( ) : LONGINT ;
  56.  
  57. (*============================================================================*)
  58.  
  59. (* Commodities object types *)
  60. CONST
  61.   CX_INVALID    = 0 ;     (* not a valid object (probably null) *)
  62.   CX_FILTER    = 1 ;     (* input event messages only        *)
  63.   CX_TYPEFILTER    = 2 ;     (* obsolete, do not use        *)
  64.   CX_SEND    = 3 ;     (* sends a message            *)
  65.   CX_SIGNAL    = 4 ;     (* sends a signal            *)
  66.   CX_TRANSLATE    = 5 ;     (* translates input event into chain  *)
  67.   CX_BROKER    = 6 ;     (* application representative        *)
  68.   CX_DEBUG    = 7 ;     (* dumps info to serial port        *)
  69.   CX_CUSTOM    = 8 ;     (* application provides function    *)
  70.   CX_ZERO    = 9 ;      (* system terminator node        *)
  71.  
  72. (*============================================================================*)
  73.  
  74. (* Commodities message types *)
  75. CONST
  76.   CXM_IEVENT  = {5} ;
  77.   CXM_COMMAND = {6} ;
  78.  
  79. (* Only CXM_IEVENT messages are passed through the input network. Other types
  80.  * of messages are sent to an optional port in your broker. This means that
  81.  * you must test the message type in your message handling, if input messages
  82.  * and command messages come to the same port.
  83.  *
  84.  * CXM_IEVENT: Messages of this type rattle around the Commodities input
  85.  *           network. They are sent to you by a Sender object, and passed
  86.  *           to you as a synchronous function call by a Custom object.
  87.  *
  88.  *           The message port or function entry point is stored in the
  89.  *           object, and the ID field of the message will be set to what
  90.  *           you arrange issuing object.
  91.  *
  92.  *           The data section of the message will point to the input event
  93.  *           triggering the message.
  94.  *
  95.  * CXM_COMMAND: These messages are sent to a port attached to your Broker.
  96.  *        They are sent to you when the controller program wants your
  97.  *        program to do something. The ID value identifies the command.
  98.  *)
  99.  
  100. (* ID values associated with a message of type CXM_COMMAND    *)
  101.   CXCMD_DISABLE      = 15 ; (* please disable yourself        *)
  102.   CXCMD_ENABLE      = 17 ; (* please enable yourself        *)
  103.   CXCMD_APPEAR      = 19 ; (* open your window, if you can    *)
  104.   CXCMD_DISAPPEAR = 21 ; (* go dormant                *)
  105.   CXCMD_KILL      = 23 ; (* go away for good            *)
  106.   CXCMD_LIST_CHG  = 27 ; (* Someone changed the broker list    *)
  107.   CXCMD_UNIQUE      = 25 ; (* someone tried to create a broker    *)
  108.              (* with your name. Suggest you appear. *)
  109.  
  110. (*============================================================================*)
  111.  
  112. TYPE
  113.   InputXpression = RECORD
  114.     ix_Version   : SHORTINT ; (* must be set to IX_VERSION *)
  115.     ix_Class     : SHORTINT ; (* class must match exactly  *)
  116.  
  117.     ix_Code      : BITSET ;(* Bits that we want                      *)
  118.     ix_CodeMask  : BITSET ;(* Set bits here to indicate which bits in ix_Code *)
  119.                (* are don't care bits.                  *)
  120.  
  121.     ix_Qualifier : BITSET ;(* Bits that we want                *)
  122.     ix_QualMask  : BITSET ;(* Set bits here to indicate which bits in   *)
  123.                (* ix_Qualifier are don't care bits        *)
  124.  
  125.     ix_QualSame  : BITSET ;(* synonyms in qualifier *)
  126.   END ;
  127.   IX = InputXpression ;
  128.  
  129.   InputXpressionPtr = POINTER TO InputXpression ;
  130.   IXPtr            = POINTER TO InputXpressionPtr ;
  131.  
  132. (* constant for InputXpression.ix_Version *)
  133. CONST
  134.   IX_VERSION    = 2 ;
  135.  
  136. (* constants for InputXpression.ix_QualSame *)
  137.   IXSYM_SHIFT = {0} ;    (* left- and right- shift are equivalent     *)
  138.   IXSYM_CAPS  = {1} ;    (* either shift or caps lock are equivalent  *)
  139.   IXSYM_ALT   = {2} ;    (* left- and right- alt are equivalent         *)
  140.  
  141.   IXSYM_SHIFTMASK = IEQUALIFIER_LSHIFT + IEQUALIFIER_RSHIFT ;
  142.   IXSYM_CAPSMASK  = IXSYM_SHIFTMASK + IEQUALIFIER_CAPSLOCK ;
  143.   IXSYM_ALTMASK      = IEQUALIFIER_LALT + IEQUALIFIER_RALT ;
  144.  
  145. (* constant for InputXpression.ix_QualMask *)
  146.   IX_NORMALQUALS = BITSET( 07FFFH ) ;     (* avoid RELATIVEMOUSE *)
  147.  
  148.  
  149. (* matches nothing *)
  150.  
  151.   PROCEDURE NULL_IX( ix : LONGINT ) : BOOLEAN ; (* ix->ix_Class==IECLASS_NULL *)
  152.  
  153. (*============================================================================*)
  154.  
  155. (* Error returns from CxBroker() *)
  156. CONST
  157.   CBERR_OK      = 0 ;  (* No error                 *)
  158.   CBERR_SYSERR  = 1 ;  (* System error, no memory, etc         *)
  159.   CBERR_DUP     = 2 ;  (* uniqueness violation             *)
  160.   CBERR_VERSION = 3 ;  (* didn't understand NewBroker.nb_Version *)
  161.  
  162. (*============================================================================*)
  163.  
  164. (* Return values from CxObjError() *)
  165.  
  166.   COERR_ISNULL        = 1 ; (* you called CxObjError(NULL)        *)
  167.   COERR_NULLATTACH    = 2 ; (* someone attached NULL to my list   *)
  168.   COERR_BADFILTER     = 4 ; (* a bad filter description was given *)
  169.   COERR_BADTYPE        = 8 ; (* unmatched type-specific operation  *)
  170.  
  171.  
  172. (*============================================================================*)
  173.  
  174. VAR
  175.   CxBase : LibraryPtr ;
  176.  
  177. (* object creation macros *)
  178.  
  179. PROCEDURE CxCustom( func : PROC (* cast it *) ; id : LONGINT ) : CxObjPtr ;
  180. PROCEDURE CxDebug ( id : LONGINT ) : CxObjPtr ;
  181. PROCEDURE CxFilter( description : STRING ) : CxObjPtr ;
  182. PROCEDURE CxSender( port : MsgPortPtr ; id : LONGINT ) : CxObjPtr ;
  183. PROCEDURE CxSignal( task : TaskPtr ; signal : LONGSET ) : CxObjPtr ;
  184. PROCEDURE CxTranslate( ie : InputEventPtr ) : CxObjPtr ;
  185.  
  186. (*--- functions in V36 or higher (Release 2.0) ---*)
  187.  
  188. (* OBJECT UTILITIES *)
  189.  
  190. PROCEDURE CreateCxObj( type : LONGINT ; arg1, arg2 : LONGWORD ) : CxObjPtr ;
  191. PROCEDURE CxBroker( nb : NewBrokerPtr ; error : ADDRESS ) : CxObjPtr ;
  192. PROCEDURE ActivateCxObj( co : CxObjPtr ; true : LONGINT ) : LONGINT ;
  193. PROCEDURE DeleteCxObj( co : CxObjPtr );
  194. PROCEDURE DeleteCxObjAll( co : CxObjPtr ) ;
  195. PROCEDURE CxObjType( co : CxObjPtr ) : LONGINT ;
  196. PROCEDURE CxObjError( co : CxObjPtr ) : LONGINT ;
  197. PROCEDURE ClearCxObjError( co : CxObjPtr );
  198. PROCEDURE SetCxObjPri( co : CxObjPtr ; pri : LONGINT ) : LONGINT ;
  199.  
  200. (* OBJECT ATTACHMENT *)
  201.  
  202. PROCEDURE AttachCxObj( headObj, co : CxObjPtr );
  203. PROCEDURE EnqueueCxObj( headObj, co : CxObjPtr );
  204. PROCEDURE InsertCxObj( headObj , co , pred : CxObjPtr );
  205. PROCEDURE RemoveCxObj( co : CxObjPtr );
  206.  
  207. (* TYPE SPECIFIC *)
  208.  
  209. PROCEDURE SetTranslate( translator : CxObjPtr ; events : InputEventPtr ) ;
  210. PROCEDURE SetFilter( filter : CxObjPtr ; text : STRING ) ;
  211. PROCEDURE SetFilterIX( filter : CxObjPtr ; ix : IXPtr ) ;
  212. PROCEDURE ParseIX( description : STRING ; ix : IXPtr ) : LONGINT ;
  213.  
  214. (* COMMON MESSAGE *)
  215.  
  216. PROCEDURE CxMsgType( cxm : CxMsgPtr ) : LONGINT ;
  217. PROCEDURE CxMsgData( cxm : CxMsgPtr ) : ADDRESS ;
  218. PROCEDURE CxMsgID( cxm : CxMsgPtr ) : LONGINT ;
  219.  
  220. (* MESSAGE ROUTING *)
  221.  
  222. PROCEDURE DivertCxMsg( cxm : CxMsgPtr ; headObj , returnObj : CxObjPtr  ) ;
  223. PROCEDURE RouteCxMsg( cxm : CxMsgPtr ; co : CxObjPtr ) ;
  224. PROCEDURE DisposeCxMsg( cxm : CxMsgPtr ) ;
  225.  
  226. (* INPUT EVENT HANDLING *)
  227.  
  228. PROCEDURE InvertKeyMap( ansiCode : LONGINT ;
  229.             event     : InputEventPtr ;
  230.             km     : KeyMapPtr ) : BOOLEAN ;
  231.  
  232. PROCEDURE AddIEvents( events : InputEventPtr ) ;
  233.  
  234. (*--- functions in V38 or higher (Release 2.1) ---*)
  235.  
  236. (* MORE INPUT EVENT HANDLING *)
  237.  
  238. PROCEDURE MatchIX( event : InputEventPtr ; ix : IXPtr ) : BOOLEAN ;
  239.  
  240. END Commodities.
  241.