home *** CD-ROM | disk | FTP | other *** search
- (*
- This module can be used to display an error on top
- of a screen. All you have to do to use it is to
- pass an error string and a Screen pointer.
-
- Created: 9/17/87 by Richie Bielak
-
- Modified:
-
- Copyright © 1987 by Richie Bielak
-
- This program maybe freely copied, but please leave my
- name in. Thanks.....Richie
-
-
- *)
- IMPLEMENTATION MODULE ShowError;
-
- FROM SYSTEM IMPORT ADR;
- FROM SimpleWindows IMPORT CreateWindow;
- FROM Intuition IMPORT WindowPtr, GadgetPtr, CloseWindow, IDCMPFlagsSet,
- IDCMPFlags, WindowFlagsSet, WindowFlags,
- IntuiMessagePtr, ScreenPtr;
- FROM SimpleGadgets IMPORT BeginGadgetList, EndGadgetList, FreeGadgetList,
- AddGadgetTextButton;
- FROM Ports IMPORT WaitPort, ReplyMsg, GetMsg, MessagePtr;
- FROM Drawing IMPORT SetAPen, Move;
- FROM Text IMPORT Text;
-
- CONST
- MinWidth = 100;
-
- (* ++++++++++++++++++++++++++++++ *)
- PROCEDURE SetUpGadget (w : CARDINAL) : GadgetPtr;
- BEGIN
- BeginGadgetList ();
- AddGadgetTextButton ((w DIV 2) - 40, 25, ADR("Continue"));
- RETURN EndGadgetList ()
- END SetUpGadget;
-
- (* $D- *)
- (* ++++++++++++++++++++++++++++++ *)
- PROCEDURE Error (sp : ScreenPtr; text : ARRAY OF CHAR);
- VAR
- wp : WindowPtr;
- gp : GadgetPtr;
- msgp : IntuiMessagePtr;
- width : CARDINAL;
- BEGIN
- (* Figure out the width of the window based *)
- (* on the length of text. *)
- width := 20 + (HIGH(text)+1) * 9;
- IF width < MinWidth THEN width := MinWidth; END;
- (* Make one gadget *)
- gp := SetUpGadget (width);
- wp := CreateWindow (10, 20, width, 40,
- IDCMPFlagsSet {GadgetUp, GadgetDown},
- WindowFlagsSet {Activate, WindowDrag}, gp, sp,
- ADR ("Error..."));
- SetAPen (wp^.RPort^, 1);
- Move (wp^.RPort^, 20, 20);
- Text (wp^.RPort^, ADR(text), HIGH(text));
- (* Wait for gadget messages *)
- msgp := WaitPort (wp^.UserPort^);
- LOOP
- msgp := GetMsg (wp^.UserPort^);
- IF msgp = NIL THEN EXIT END;
- ReplyMsg (MessagePtr (msgp));
- END;
- CloseWindow (wp^);
- FreeGadgetList (gp^);
- END Error;
- (* $D+ *)
-
- END ShowError.
-