home *** CD-ROM | disk | FTP | other *** search
- (*---------------------------------------------------------------------------
- :Program. CxSupportTest
- :Author. Thomas Igracki
- :Address. Obstallee 45, 1000 Berlin 20, W-Germany
- :E-Mail. T.IGRACKI@BAMP.ZER
- :Version. V1.0
- :Date. Aug 1992
- :Copyright. Me
- :Language. Oberon
- :Translator. Amiga Oberon 2.14d
- :Contents. Testprogramm für das CxSupportModul
- :Usage. CxSupportTest
- :Remark. OS2.0 Only!
- ---------------------------------------------------------------------------*)
- MODULE CxSupportTest;
- IMPORT
- s: SYSTEM, e: Exec, d: Dos,
- c: Commodities, ie: InputEvent, OberonLib, cs: CxSupport;
- CONST
- alt1ID = 0; cxFuncID = 1; hotFuncID = 2;
- VAR
- hotFuncSig,
- hotKeySig,
- brokerSig : SHORTINT;
- ls : LONGSET;
- show, hide, kill : BOOLEAN;
- toggle : BOOLEAN;
-
- (* $CopyArrays- *)
- PROCEDURE Halt (txt: ARRAY OF CHAR); BEGIN d.PrintF("%s\n",s.ADR(txt)); HALT(d.warn) END Halt;
-
- (* $StackChk- $SaveRegs+ $ClearVars- $DeallocPars- *)
- PROCEDURE *LeftyMouse (co: c.CxObjPtr; cxm: c.CxMsgPtr);
- VAR ev: ie.InputEventPtr; newQuals: SET; upPref: INTEGER;
- BEGIN
- ev := c.CxMsgData(cxm);
-
- (* change left & right mouse button *)
- IF ev.class = ie.rawmouse THEN
- newQuals := ev.qualifier;
- (* first check the qualifiers *)
- IF ie.rightButton IN ev.qualifier THEN
- EXCL (newQuals,ie.rightButton); INCL (newQuals,ie.leftButton);
- END;
- IF ie.leftButton IN ev.qualifier THEN
- EXCL (newQuals,ie.leftButton); INCL (newQuals,ie.rightButton);
- END;
- ev.qualifier := newQuals;
- (* now check the code field *)
- IF ev.code >= ie.upPrefix THEN upPref := ie.upPrefix; DEC (ev.code,ie.upPrefix)
- ELSE upPref := 0
- END;
- IF ev.code = ie.rButton THEN ev.code := ie.lButton+upPref
- ELSIF ev.code = ie.lButton THEN ev.code := ie.rButton+upPref
- END;
-
- IF ev.code = ie.mButton THEN cs.InformBroker (co,cxm) END;
-
- END;
- END LeftyMouse; (* $StackChk= $ClearVars= *)
-
- PROCEDURE PowerLED* (onOff{0}: BOOLEAN);
- VAR ciaapra [0BFE001H]: SHORTSET;
- BEGIN IF onOff THEN EXCL(ciaapra,1) ELSE INCL(ciaapra,1) END
- END PowerLED;
-
- (* $StackChk- $SaveAllRegs+ $ClearVars- $DeallocPars- *)
- PROCEDURE *HotFunc (co: c.CxObjPtr; cxm: c.CxMsgPtr);
- BEGIN
- PowerLED (toggle); toggle := ~toggle;
- IF toggle THEN e.Signal (OberonLib.Me,LONGSET{hotFuncSig}) END;
- END HotFunc; (* $StackChk= $ClearVars= *)
-
- BEGIN
- (* $IF SmallData *) Bitte ohne -d compilieren und linken (* $END *)
-
- hotKeySig := e.AllocSignal(-1); IF hotKeySig = -1 THEN Halt ('No HotKeySig!') END;
- hotFuncSig := e.AllocSignal(-1); IF hotFuncSig = -1 THEN Halt ('No HotFuncSig!') END;
-
- brokerSig := cs.InitBroker ('CxSupportTest','This is a test of my CxSupport-Modul','for the commodities.library',TRUE);
- IF brokerSig = -1 THEN Halt('No Broker!') END;
-
- cs.HotKeyID ("alt 1",alt1ID);
- cs.HotKeySig ("alt 2",hotKeySig);
- cs.HotFunc ("alt 3",HotFunc);
- cs.CxFuncID (LeftyMouse,cxFuncID);
-
- cs.Activate (TRUE);
- d.PrintF ('CxSupportTestModul activated:\n');
- d.PrintF (' - The left & right mouse Buttons are changed (for lefthanders)!\n');
- d.PrintF (' - Two hotkeys are installed (alt 1 and alt 2).\n');
- d.PrintF (' - A hotfunction (alt 3).\n');
- d.PrintF ('\nQuit with Ctrl-C or with the ExChange program.\n\n');
-
- LOOP
- ls := e.Wait (LONGSET{d.ctrlC,hotKeySig,hotFuncSig,brokerSig,cs.ExChSig});
- IF d.ctrlC IN ls THEN Halt ('Break detected!') END;
- IF hotKeySig IN ls THEN d.PrintF ('Alt 2 pressed!\n') END;
- IF hotFuncSig IN ls THEN d.PrintF ('Hotfunc signalled us!\n') END;
-
- IF brokerSig IN ls THEN
- (* get the id of the hotkey or custom function *)
- CASE cs.GetID() OF
- |alt1ID : d.PrintF ('Alt 1 pressed!\n')
- |cxFuncID : d.PrintF ('LeftyMouse signalled us!\n')
- ELSE
- END;
- END;
-
- IF cs.ExChSig IN ls THEN
- cs.HandleExCh (show,hide,kill);
- IF show THEN d.PrintF ('Now you should show your Interface.\n') END;
- IF hide THEN d.PrintF ('And now hide your Interface.\n') END;
- IF kill THEN d.PrintF ("Ciao!!!\n"); HALT(d.ok) END;
- END;
- END
- CLOSE
- e.FreeSignal (hotKeySig); e.FreeSignal (hotFuncSig);
- END CxSupportTest.
-