home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 5
/
FreshFish_July-August1994.bin
/
bbs
/
os20
/
devicelock-1.2.lha
/
DeviceLock-1.2
/
txt
/
DeviceLock.mod
< prev
next >
Wrap
Text File
|
1994-03-21
|
18KB
|
564 lines
(*---------------------------------------------------------------------------
:Program. DeviceLock.mod
:Author. Thomas Wagner
:Address. Mühlenweg 7, 90602 Pyrbaum, Germany
:Address. E-Mail: tom@oberon.nbg.sub.org
:Copyright. © 1994 by Thomas Wagner [tom], see DeviceLock.guide
:Language. Oberon
:Translator. Amiga Oberon Compiler V3.11d
:Import. HotKey.mod V2.0 Thomas Igracki, [tom] (on this disk)
:Import. MoreIntuition.mod V1.3 [mick] (Amok 78)
:Import. WBReadArgs.mod V1.0 [hG] (Amok 83)
:Import. PrintF.mod V1.4 Volker Rudolph, [hG] (Amok 82)
:Contents. Lock with Intuition-Interface (2.04 or higher ONLY!)
---------------------------------------------------------------------------*)
MODULE DeviceLock;
(*-------------------------------------------------------------------------*)
IMPORT c := Conversions,
d := Dos,
DLd:= DLdrives,
DLr:= DLrequester,
DLs:= DLstrings,
DLp:= DLprefs,
e := Exec,
g := Graphics,
gt := GadTools,
hot:= HotKey,
I := Intuition,
MI := MoreIntuition,
ol := OberonLib,
s := Strings,
sys:= SYSTEM,
t := Timer,
u := Utility;
(*-------------------------------------------------------------------------*)
CONST
comName *= "DeviceLock\o$VER: DeviceLock 1.2 (17.3.94)";
comTitle *= "DeviceLock, 1.2 © 1994 [tom]";
comDescr *= "Intuition-Interface for CLI-Lock";
scrtitle = "DeviceLock, 1.2 - © 1994 by Thomas Wagner. All Rights reserved.";
about = "DeviceLock 1.2\n\n"
"© 1994 by Thomas Wagner, Pyrbaum [tom].\n"
"%s";
topadd = 5 ;
checkscal = 2421;
(*-------------------------------------------------------------------------*)
TYPE
NewMenus = ARRAY 10 OF gt.NewMenu;
(*-------------------------------------------------------------------------*)
CONST
menuLock = 1;
menuUnlock = 2;
menuNorm = 3;
menuAbout = 4;
menuHide = 5;
menuQuit = 6;
myNewMenuConst = NewMenus(
gt.title, NIL, NIL, {}, LONGSET{}, NIL,
gt.item , NIL, sys.ADR("L"), {}, LONGSET{}, menuLock,
gt.item , NIL, sys.ADR("U"), {}, LONGSET{}, menuUnlock,
gt.item , NIL, sys.ADR("U"), {}, LONGSET{}, menuNorm,
gt.item , gt.barLabel, NIL, {}, LONGSET{}, NIL,
gt.item , NIL, sys.ADR("?"), {}, LONGSET{}, menuAbout,
gt.item , gt.barLabel, NIL, {}, LONGSET{}, NIL,
gt.item , NIL, sys.ADR("H"), {}, LONGSET{}, menuHide,
gt.item , NIL, sys.ADR("Q"), {}, LONGSET{}, menuQuit,
gt.end , NIL, NIL, {}, LONGSET{}, NIL);
(*-------------------------------------------------------------------------*)
VAR
font : g.TextFontPtr;
ng : gt.NewGadget;
glist : I.GadgetPtr;
gad : I.GadgetPtr;
vi : e.APTR;
terminated : BOOLEAN;
imsg : I.IntuiMessagePtr;
imsgClass : LONGSET;
imsgCode : INTEGER;
count : INTEGER;
TimerPort : e.MsgPortPtr;
TimeReq : t.TimeRequestPtr;
OpenDev : SHORTINT;
signals : LONGSET;
allock : BOOLEAN;
allunlock : BOOLEAN;
quickquit : BOOLEAN;
keepquit : BOOLEAN;
gheight : INTEGER;
wheight : INTEGER;
wwidth : INTEGER;
windowopen : BOOLEAN;
HotSig : SHORTINT;
HotType : LONGSET;
HotID : LONGINT;
closewin : BOOLEAN;
myNewMenu : NewMenus;
menu : I.MenuPtr;
topborder : INTEGER;
zoom : ARRAY 4 OF INTEGER;
force : BOOLEAN;
(*------ Append one Gadget to Gadget-List ---------------------------------*)
PROCEDURE * MakeGad(VAR n: DLp.driveT);
BEGIN
ng.topEdge := topborder + topadd + 2 + (count)*gheight;
ng.gadgetText := sys.ADR(n.PrintName);
ng.gadgetID := count;
gad := gt.CreateGadget(gt.checkBoxKind, gad, ng,
I.gaDisabled, sys.VAL(SHORTINT,n.disabled),
gt.cbChecked, sys.VAL(SHORTINT,n.locked),
gt.cbScaled, I.LTRUE,
u.done);
n.GadPtr:=gad;
END MakeGad;
(*------ Prepare and Send IO ----------------------------------------------*)
PROCEDURE psIO();
BEGIN
TimeReq.time.secs := DLp.Prefs.CheckTime;
TimeReq.time.micro := 0;
e.SendIO(TimeReq);
END psIO;
(*------ Do something on response to a pressed Gadget ---------------------*)
PROCEDURE HandleGadgetEvent(gad: I.GadgetPtr; code: INTEGER);
BEGIN
IF gad.gadgetID = 0 THEN
DLd.LockAll(FALSE);
ELSE
IF gad.gadgetID<=DLp.Prefs.DriveNum THEN
IF I.selected IN gad.flags THEN
DLd.LckOne(DLp.drive[gad.gadgetID-1])
ELSE
DLd.UnLckOne(DLp.drive[gad.gadgetID-1])
END;
END;
force := FALSE;
END;
END HandleGadgetEvent;
(*------ Response to Menu-select ------------------------------------------*)
PROCEDURE HandleMenuEvent(code: INTEGER);
VAR
item: I.MenuItemPtr;
BEGIN
WHILE (code # I.menuNull) AND ~ terminated DO
item := I.ItemAddress(menu^, code);
CASE sys.VAL(LONGINT,gt.MenuItemUserData(item)) OF
menuLock : DLd.LockAll(FALSE); |
menuUnlock : DLd.UnlockAll(FALSE); |
menuNorm : DLd.NormAll(); |
menuAbout : DLr.RequestNotify(DLs.GetString(DLs.MsgAbout),
sys.ADR(about),
DLs.GetString(DLs.MsgAllRightsReserved)); |
menuHide : closewin := TRUE; |
menuQuit : terminated := TRUE; quickquit := FALSE |
ELSE END;
code := item.nextSelect;
END;
END HandleMenuEvent;
(*------ Lock all window-specific resources and open window ---------------*)
PROCEDURE OpenWindow(hijackfront: BOOLEAN);
VAR twidth : INTEGER;
mysc : I.ScreenPtr;
gadwidth: LONGINT;
(*------ Starts Gadget-List and calls MakeGadget --------------------------*)
PROCEDURE CreateAllGadgets(VAR glist: I.GadgetPtr;
vi: e.APTR;
topborder: INTEGER;
mysc: I.ScreenPtr): BOOLEAN;
BEGIN
gad := gt.CreateContext(glist);
ng.textAttr := mysc.font;
ng.leftEdge := 8;
ng.topEdge := topadd + topborder;
ng.width := wwidth-15;
ng.height := gheight + 2;
ng.gadgetText := DLs.GetString(DLs.GadLockAll);
ng.flags := LONGSET{};
ng.gadgetID := 0;
ng.visualInfo := vi;
gad := gt.CreateGadget(gt.buttonKind, gad, ng, u.done);
ng.flags := LONGSET{gt.placeTextRight};
ng.height := gheight;
ng.width := SHORT(gadwidth);
FOR count := 1 TO DLp.Prefs.DriveNum DO
MakeGad(DLp.drive[count-1]);
END;
RETURN gad#NIL;
END CreateAllGadgets;
(*---- Check and FailOut if FALSE + Unlock PubScreen! ----------------*)
PROCEDURE CheckAndFail(test: BOOLEAN; error: ARRAY OF CHAR); (* $CopyArrays- *)
BEGIN
IF ~test THEN
(* Save to call with mysc=NIL ! *) I.UnlockPubScreen(NIL,mysc);
DLr.FailOut(error);
END;
END CheckAndFail;
(*---- Swaps two INTEGER's ----------------------------------------------*)
PROCEDURE SwapInt(VAR x,y: INTEGER);
VAR s: INTEGER;
BEGIN
s := x;
x := y;
y := s;
END SwapInt;
(*---- Max of two INTEGER's ---------------------------------------------*)
PROCEDURE Max(x,y: INTEGER):INTEGER;
BEGIN
IF x > y THEN RETURN(x) ELSE RETURN(y) END;
END Max;
(*---- Min of two INTEGER's ---------------------------------------------*)
PROCEDURE Min(x,y: INTEGER):INTEGER;
BEGIN
IF x < y THEN RETURN(x) ELSE RETURN(y) END;
END Min;
BEGIN
IF hijackfront THEN
DLp.Buffer1 := "\o";
mysc := MI.LockFrontPubScr(DLp.Buffer1);
ELSE
mysc := I.LockPubScreen(DLp.Prefs.PubScreen);
END;
IF mysc=NIL THEN mysc := I.LockPubScreen(NIL) END;
CheckAndFail(mysc#NIL,"LockPubScreen()");
font := g.OpenFont(mysc.font^);
CheckAndFail(font#NIL,"OpenFont()");
zoom[0] := DLp.Prefs.LeftEdgeZoomed;
zoom[1] := DLp.Prefs.TopEdgeZoomed;
gheight := mysc.font.ySize;
IF gheight <