home *** CD-ROM | disk | FTP | other *** search
/ MACD 4 / MACD4.iso / cdity / cxsupport.lha / CxSupport / CxSupportTest.mod < prev    next >
Encoding:
Text File  |  1992-09-07  |  4.4 KB  |  120 lines

  1. (*---------------------------------------------------------------------------
  2.   :Program.    CxSupportTest
  3.   :Author.     Thomas Igracki
  4.   :Address.    Obstallee 45, 1000 Berlin 20, W-Germany
  5.   :E-Mail.     T.IGRACKI@BAMP.ZER
  6.   :Version.    V1.0
  7.   :Date.       Aug 1992
  8.   :Copyright.  Me
  9.   :Language.   Oberon
  10.   :Translator. Amiga Oberon 2.14d
  11.   :Contents.   Testprogramm für das CxSupportModul
  12.   :Usage.      CxSupportTest
  13.   :Remark.     OS2.0 Only!
  14. ---------------------------------------------------------------------------*)
  15. MODULE CxSupportTest;
  16. IMPORT
  17.    s: SYSTEM, e: Exec, d: Dos,
  18.    c: Commodities, ie: InputEvent, OberonLib, cs: CxSupport;
  19. CONST
  20.    alt1ID = 0; cxFuncID = 1; hotFuncID = 2;
  21. VAR
  22.    hotFuncSig,
  23.    hotKeySig,
  24.    brokerSig        : SHORTINT;
  25.    ls               : LONGSET;
  26.    show, hide, kill : BOOLEAN;
  27.    toggle           : BOOLEAN;
  28.  
  29. (* $CopyArrays- *)
  30. PROCEDURE Halt (txt: ARRAY OF CHAR); BEGIN d.PrintF("%s\n",s.ADR(txt)); HALT(d.warn) END Halt;
  31.  
  32. (* $StackChk- $SaveRegs+ $ClearVars- $DeallocPars- *)
  33. PROCEDURE *LeftyMouse (co: c.CxObjPtr; cxm: c.CxMsgPtr);
  34. VAR ev: ie.InputEventPtr; newQuals: SET; upPref: INTEGER;
  35. BEGIN
  36.      ev := c.CxMsgData(cxm);
  37.  
  38.      (* change left & right mouse button *)
  39.      IF ev.class = ie.rawmouse THEN
  40.         newQuals := ev.qualifier;
  41.         (* first check the qualifiers *)
  42.         IF ie.rightButton IN ev.qualifier THEN
  43.            EXCL (newQuals,ie.rightButton); INCL (newQuals,ie.leftButton);
  44.         END;
  45.         IF ie.leftButton IN ev.qualifier THEN
  46.            EXCL (newQuals,ie.leftButton); INCL (newQuals,ie.rightButton);
  47.         END;
  48.         ev.qualifier := newQuals;
  49.         (* now check the code field *)
  50.         IF ev.code >= ie.upPrefix THEN upPref := ie.upPrefix; DEC (ev.code,ie.upPrefix)
  51.                                   ELSE upPref := 0
  52.         END;
  53.         IF    ev.code = ie.rButton THEN ev.code := ie.lButton+upPref
  54.         ELSIF ev.code = ie.lButton THEN ev.code := ie.rButton+upPref
  55.         END;
  56.  
  57.         IF ev.code = ie.mButton THEN cs.InformBroker (co,cxm) END;
  58.  
  59.      END;
  60. END LeftyMouse; (* $StackChk= $ClearVars= *)
  61.  
  62. PROCEDURE PowerLED* (onOff{0}: BOOLEAN);
  63. VAR ciaapra [0BFE001H]: SHORTSET;
  64. BEGIN   IF onOff THEN EXCL(ciaapra,1) ELSE INCL(ciaapra,1) END
  65. END PowerLED;
  66.  
  67. (* $StackChk- $SaveAllRegs+ $ClearVars- $DeallocPars- *)
  68. PROCEDURE *HotFunc (co: c.CxObjPtr; cxm: c.CxMsgPtr);
  69. BEGIN
  70.      PowerLED (toggle); toggle := ~toggle;
  71.      IF toggle THEN e.Signal (OberonLib.Me,LONGSET{hotFuncSig}) END;
  72. END HotFunc; (* $StackChk= $ClearVars= *)
  73.  
  74. BEGIN
  75.      (* $IF SmallData *) Bitte ohne -d compilieren und linken (* $END *)
  76.  
  77.      hotKeySig  := e.AllocSignal(-1); IF hotKeySig  = -1 THEN Halt ('No HotKeySig!') END;
  78.      hotFuncSig := e.AllocSignal(-1); IF hotFuncSig = -1 THEN Halt ('No HotFuncSig!') END;
  79.  
  80.      brokerSig := cs.InitBroker ('CxSupportTest','This is a test of my CxSupport-Modul','for the commodities.library',TRUE);
  81.      IF brokerSig = -1 THEN Halt('No Broker!') END;
  82.  
  83.      cs.HotKeyID ("alt 1",alt1ID);
  84.      cs.HotKeySig ("alt 2",hotKeySig);
  85.      cs.HotFunc ("alt 3",HotFunc);
  86.      cs.CxFuncID (LeftyMouse,cxFuncID);
  87.  
  88.      cs.Activate (TRUE);
  89.      d.PrintF ('CxSupportTestModul activated:\n');
  90.      d.PrintF ('  - The left & right mouse Buttons are changed (for lefthanders)!\n');
  91.      d.PrintF ('  - Two hotkeys are installed (alt 1 and alt 2).\n');
  92.      d.PrintF ('  - A hotfunction (alt 3).\n');
  93.      d.PrintF ('\nQuit with Ctrl-C or with the ExChange program.\n\n');
  94.  
  95.      LOOP
  96.         ls := e.Wait (LONGSET{d.ctrlC,hotKeySig,hotFuncSig,brokerSig,cs.ExChSig});
  97.         IF d.ctrlC    IN ls THEN Halt ('Break detected!') END;
  98.         IF hotKeySig  IN ls THEN d.PrintF ('Alt 2 pressed!\n') END;
  99.         IF hotFuncSig IN ls THEN d.PrintF ('Hotfunc signalled us!\n') END;
  100.  
  101.         IF brokerSig IN ls THEN
  102.             (* get the id of the hotkey or custom function *)
  103.             CASE cs.GetID() OF
  104.                |alt1ID   : d.PrintF ('Alt 1 pressed!\n')
  105.                |cxFuncID : d.PrintF ('LeftyMouse signalled us!\n')
  106.             ELSE
  107.             END;
  108.         END;
  109.  
  110.         IF cs.ExChSig IN ls THEN
  111.            cs.HandleExCh (show,hide,kill);
  112.            IF show  THEN d.PrintF ('Now you should show your Interface.\n') END;
  113.            IF hide  THEN d.PrintF ('And now hide your Interface.\n') END;
  114.            IF kill  THEN d.PrintF ("Ciao!!!\n"); HALT(d.ok) END;
  115.         END;
  116.      END
  117. CLOSE
  118.     e.FreeSignal (hotKeySig); e.FreeSignal (hotFuncSig);
  119. END CxSupportTest.
  120.