home *** CD-ROM | disk | FTP | other *** search
- (*************************************************************************
-
- $RCSfile: AppIcon.mod $
- Description: A port of appicon.c from the RKM:Libraries
-
- Created by: fjc (Frank Copeland)
- $Revision: 1.3 $
- $Author: fjc $
- $Date: 1994/08/08 16:59:51 $
-
- Copyright © 1994, Frank Copeland.
- This example program is part of Oberon-A.
- See Oberon-A.doc for conditions of use and distribution.
-
- Log entries are at the end of the file.
-
- *************************************************************************)
-
- MODULE AppIcon;
-
- (*
- ** $C= CaseChk $I= IndexChk $L= LongAdr $N= NilChk
- ** $P- PortableCode $R= RangeChk $S= StackChk $T= TypeChk
- ** $V= OvflChk $Z= ZeroVars
- *)
-
- IMPORT
- SYS := SYSTEM,
- e := Exec,
- u := Utility,
- i := Icon,
- wb := Workbench,
- IO := StdIO;
-
- CONST
- VersionTag = "\0$VER: AppIcon 1.0 (18.6.94)\r\n";
-
- VAR
- dobj : wb.DiskObjectPtr;
- myport : e.MsgPortPtr;
- appicon : wb.AppIconPtr;
- appmsg : wb.AppMessagePtr;
-
- dropcount : LONGINT;
- x : LONGINT;
- success : BOOLEAN;
-
-
- BEGIN (* AppIcon *)
- IF e.base.version >= 37 THEN
- dobj := NIL; myport := NIL; appicon := NIL; appmsg := NIL;
- dropcount := 0; x := 0; success := FALSE;
- i.OpenLib (FALSE);
- IF i.base.version >= 37 THEN
- wb.OpenLib (FALSE);
- IF wb.base.version >= 37 THEN
- (* This is the easy way to get some icon imagery *)
- (* Real applications should use custom imagery *)
- dobj := i.base.GetDefDiskObject (wb.disk);
- IF dobj # NIL THEN
- (* The type must be set to 0 for an appIcon *)
- dobj.type := 0;
-
- (* The CreateMsgPort() function is on Exec version 37+ *)
- myport := e.base.CreateMsgPort();
- IF myport # NIL THEN
- (* Put the AppIcon up on the Workbench window *)
- appicon := wb.base.AddAppIcon
- ( 0, 0, "TestAppIcon", myport, NIL, dobj, u.tagEnd );
- IF appicon # NIL THEN
- (* For the sake of this example, we allow the AppIcon *)
- (* to be activated only five times. *)
- IO.WriteStr ("Drop files on the Workbench AppIcon\n");
- IO.WriteStr ("Example exits after 5 drops\n");
-
- WHILE dropcount < 5 DO
- e.base.WaitPort (myport);
-
- (* Might be more than one message at the port... *)
- LOOP
- appmsg :=
- SYS.VAL (wb.AppMessagePtr, e.base.GetMsg (myport));
- IF appmsg = NIL THEN EXIT END;
- IF appmsg.numArgs = 0 THEN
- (* If numArgs is 0 the AppIcon was activated directly *)
- IO.WriteStr ("User activated the AppIcon.\n");
- IO.WriteStr
- ("A Help window for the user would be good here\n")
- ELSIF appmsg.numArgs > 0 THEN
- (* If numArgs is >0 the AppIcon was activated by *)
- (* having one or more Icons dropped on top of it *)
- IO.WriteF1
- ( "User dropped %ld icons on the AppIcon.\n",
- appmsg.numArgs );
- FOR x := 0 TO appmsg.numArgs - 1 DO
- IO.WriteF2
- ( "#%ld name ='%s'\n",
- x+1, appmsg.argList[x].name )
- END
- END;
- (* Let Workbench know we're done with the message *)
- e.base.ReplyMsg (appmsg)
- END;
- INC (dropcount)
- END;
- success := wb.base.RemoveAppIcon (appicon)
- END;
- (* Clear away any messages that arrived at the last moment *)
- LOOP
- appmsg :=
- SYS.VAL (wb.AppMessagePtr, e.base.GetMsg (myport));
- IF appmsg = NIL THEN EXIT END;
- e.base.ReplyMsg (appmsg)
- END;
- e.base.DeleteMsgPort (myport)
- END;
- i.base.FreeDiskObject (dobj)
- END
- END
- END
- END
- END AppIcon.
-
- (*************************************************************************
-
- $Log: AppIcon.mod $
- Revision 1.3 1994/08/08 16:59:51 fjc
- Release 1.4
-
- Revision 1.2 1994/07/03 15:17:44 fjc
- - Incorporated changes in 3.1 Interfaces
-
- Revision 1.1 1994/06/18 22:59:44 fjc
- Initial revision
-
- *************************************************************************)
-
-