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 >
Text File  |  1989-04-04  |  3KB  |  136 lines

  1. IMPLEMENTATION MODULE CalcDisplay;
  2.  
  3.  
  4. FROM SYSTEM        IMPORT ADR, TERMPROC;
  5. FROM Intuition        IMPORT CloseWindow, IDCMPFlags, IDCMPFlagSet,
  6.                    WindowFlags, WindowFlagSet,
  7.                    SmartRefresh, ClearMenuStrip;
  8. FROM Pens        IMPORT RectFill, SetAPen, SetBPen, SetDrMd, Move;
  9. FROM Text        IMPORT Text, FontStyles, FontStyleSet, FontFlags,
  10.                    FontFlagSet, TextFontPtr, OpenFont, CloseFont,
  11.                    SetFont;
  12. FROM Rasters        IMPORT RastPortPtr, DrawingModeSet, Complement, Jam2;
  13. FROM Ports        IMPORT WaitPort, MessagePtr;
  14. FROM Conversions    IMPORT ConvNumToStr;
  15. FROM Strings        IMPORT LengthStr;
  16. FROM EasyWindows    IMPORT CreateWindow;
  17. FROM CalcGadgets    IMPORT Base, base;
  18. FROM CalcMenus        IMPORT signed;
  19. FROM CalcBrains        IMPORT EnterOperation, OpType, value;
  20.  
  21.  
  22. CONST
  23.   LCDTop    = 16;
  24.   LCDLeft   = 18;
  25.   LCDWidth  = 165;
  26.   LCDHeight = 11;
  27.  
  28.  
  29. VAR
  30.   rp       : RastPortPtr;
  31.   textFont : TextFontPtr;
  32.  
  33.  
  34. PROCEDURE PrepareDisplay(): BOOLEAN;
  35. BEGIN
  36.   IF textFont # NIL THEN
  37.     window:=CreateWindow(180,40,280,120,"Calc",
  38.                          IDCMPFlagSet{CloseWindowFlag,GadgetUp,GadgetDown,
  39.                                       MenuPick,VanillaKey},
  40.                          WindowFlagSet{WindowClose,WindowDrag,WindowDepth,
  41.                                        Activate,NoCareRefresh}+SmartRefresh,
  42.                          NIL,NIL);
  43.     IF window # NIL THEN
  44.       rp:=window^.RPort;
  45.       SetFont(rp,textFont);
  46.       SetAPen(rp,1);
  47.       RectFill(rp,4,11,window^.Width-5,window^.Height-3);
  48.       SetAPen(rp,0);
  49.       RectFill(rp,LCDLeft,LCDTop,LCDLeft+LCDWidth,LCDTop+LCDHeight);
  50.     
  51.       DoLCD;
  52.   
  53.       RETURN TRUE;
  54.     END;
  55.   END;
  56.  
  57.   RETURN FALSE;
  58. END PrepareDisplay;
  59.  
  60.  
  61. PROCEDURE KillDisplay;
  62. BEGIN
  63.   ClearMenuStrip(window);
  64.   CloseWindow(window);
  65. END KillDisplay;
  66.  
  67.  
  68. PROCEDURE DoLCD;
  69. VAR
  70.   numBase : LONGCARD;
  71.   bool    : BOOLEAN;
  72.   str     : ARRAY [0..35] OF CHAR;
  73. BEGIN
  74.   bool:=FALSE;
  75.   CASE base OF
  76.     |BINA: numBase:=2;
  77.     |OCTA: numBase:=8;
  78.     |DECI: numBase:=10;
  79.        bool:=signed;
  80.     |HEXA: numBase:=16;
  81.   END;
  82.  
  83.   SetAPen(rp,1);
  84.   SetBPen(rp,0);
  85.   SetDrMd(rp,Jam2);
  86.  
  87.   bool:=ConvNumToStr(str,value,numBase,bool,33," ");
  88.  
  89.   Move(rp,LCDLeft+3,LCDTop+8);
  90.   Text(rp,ADR(str[13]),20);
  91. END DoLCD;
  92.  
  93.  
  94. (*$S-*)
  95. PROCEDURE DoLCDStr(str:ARRAY OF CHAR);
  96. VAR
  97.   len : CARDINAL;
  98.   msg : MessagePtr;
  99. BEGIN
  100.   SetAPen(rp,0);
  101.   RectFill(rp,LCDLeft,LCDTop,LCDLeft+LCDWidth,LCDTop+LCDHeight);
  102.  
  103.   SetAPen(rp,1);
  104.   SetBPen(rp,0);
  105.   SetDrMd(rp,Jam2);
  106.  
  107.   len:=LengthStr(str);
  108.  
  109.   Move(rp,(LCDWidth-len*8)+LCDLeft+1,LCDTop+8);
  110.   Text(rp,ADR(str),len);
  111.  
  112.   EnterOperation(OpClearAll);
  113.   msg:=WaitPort(window^.UserPort);
  114. END DoLCDStr;
  115.  
  116.  
  117. PROCEDURE TerminateCalcDisplay;
  118. BEGIN
  119.   IF textFont # NIL THEN
  120.     CloseFont(textFont);
  121.   END;
  122. END TerminateCalcDisplay;
  123.  
  124.  
  125. BEGIN
  126.   WITH textAttr DO
  127.     taName     := ADR("topaz.font");
  128.     taYSize    := 8;
  129.     taStyle    := FontStyleSet{};
  130.     taFlags    := FontFlagSet{ROMFont};
  131.   END;
  132.  
  133.   textFont:=OpenFont(ADR(textAttr));
  134.   TERMPROC(TerminateCalcDisplay);
  135. END CalcDisplay.
  136.