home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
229.lha
/
Calc_v1.01
/
sources
/
CalcDisplay.mod
< prev
next >
Wrap
Text File
|
1989-04-04
|
3KB
|
136 lines
IMPLEMENTATION MODULE CalcDisplay;
FROM SYSTEM IMPORT ADR, TERMPROC;
FROM Intuition IMPORT CloseWindow, IDCMPFlags, IDCMPFlagSet,
WindowFlags, WindowFlagSet,
SmartRefresh, ClearMenuStrip;
FROM Pens IMPORT RectFill, SetAPen, SetBPen, SetDrMd, Move;
FROM Text IMPORT Text, FontStyles, FontStyleSet, FontFlags,
FontFlagSet, TextFontPtr, OpenFont, CloseFont,
SetFont;
FROM Rasters IMPORT RastPortPtr, DrawingModeSet, Complement, Jam2;
FROM Ports IMPORT WaitPort, MessagePtr;
FROM Conversions IMPORT ConvNumToStr;
FROM Strings IMPORT LengthStr;
FROM EasyWindows IMPORT CreateWindow;
FROM CalcGadgets IMPORT Base, base;
FROM CalcMenus IMPORT signed;
FROM CalcBrains IMPORT EnterOperation, OpType, value;
CONST
LCDTop = 16;
LCDLeft = 18;
LCDWidth = 165;
LCDHeight = 11;
VAR
rp : RastPortPtr;
textFont : TextFontPtr;
PROCEDURE PrepareDisplay(): BOOLEAN;
BEGIN
IF textFont # NIL THEN
window:=CreateWindow(180,40,280,120,"Calc",
IDCMPFlagSet{CloseWindowFlag,GadgetUp,GadgetDown,
MenuPick,VanillaKey},
WindowFlagSet{WindowClose,WindowDrag,WindowDepth,
Activate,NoCareRefresh}+SmartRefresh,
NIL,NIL);
IF window # NIL THEN
rp:=window^.RPort;
SetFont(rp,textFont);
SetAPen(rp,1);
RectFill(rp,4,11,window^.Width-5,window^.Height-3);
SetAPen(rp,0);
RectFill(rp,LCDLeft,LCDTop,LCDLeft+LCDWidth,LCDTop+LCDHeight);
DoLCD;
RETURN TRUE;
END;
END;
RETURN FALSE;
END PrepareDisplay;
PROCEDURE KillDisplay;
BEGIN
ClearMenuStrip(window);
CloseWindow(window);
END KillDisplay;
PROCEDURE DoLCD;
VAR
numBase : LONGCARD;
bool : BOOLEAN;
str : ARRAY [0..35] OF CHAR;
BEGIN
bool:=FALSE;
CASE base OF
|BINA: numBase:=2;
|OCTA: numBase:=8;
|DECI: numBase:=10;
bool:=signed;
|HEXA: numBase:=16;
END;
SetAPen(rp,1);
SetBPen(rp,0);
SetDrMd(rp,Jam2);
bool:=ConvNumToStr(str,value,numBase,bool,33," ");
Move(rp,LCDLeft+3,LCDTop+8);
Text(rp,ADR(str[13]),20);
END DoLCD;
(*$S-*)
PROCEDURE DoLCDStr(str:ARRAY OF CHAR);
VAR
len : CARDINAL;
msg : MessagePtr;
BEGIN
SetAPen(rp,0);
RectFill(rp,LCDLeft,LCDTop,LCDLeft+LCDWidth,LCDTop+LCDHeight);
SetAPen(rp,1);
SetBPen(rp,0);
SetDrMd(rp,Jam2);
len:=LengthStr(str);
Move(rp,(LCDWidth-len*8)+LCDLeft+1,LCDTop+8);
Text(rp,ADR(str),len);
EnterOperation(OpClearAll);
msg:=WaitPort(window^.UserPort);
END DoLCDStr;
PROCEDURE TerminateCalcDisplay;
BEGIN
IF textFont # NIL THEN
CloseFont(textFont);
END;
END TerminateCalcDisplay;
BEGIN
WITH textAttr DO
taName := ADR("topaz.font");
taYSize := 8;
taStyle := FontStyleSet{};
taFlags := FontFlagSet{ROMFont};
END;
textFont:=OpenFont(ADR(textAttr));
TERMPROC(TerminateCalcDisplay);
END CalcDisplay.