% news.ps % % These are the NeWS dependent graphics routines used by calctool. % % Copyright (c) Rich Burridge - May 1988. % Sun Microsystems, Australia - All rights reserved. % % Version 2.2. % % No responsibility is taken for any errors or inaccuracies inherent % either to the comments or the code of this program, but if % reported to me then an attempt will be made to fix them. % /edef { exch def } def /PSClearCanvas % color canvas => - { 2 dict begin /Canvas edef /Index edef gsave Canvas setcanvas ColorTable Index get fillcanvas grestore end } def /PSCloseFrame % - => - { /flipiconic CFrame send /unmap RFrame send } def /PSDrawBox % x y width height => - { /BoxHeight edef /BoxWidth edef /BoxY edef /BoxX edef KC setcanvas /BoxY KCHeight BoxY sub 5 sub def gsave newpath BoxX BoxY moveto BoxX BoxWidth add BoxY lineto BoxX BoxWidth add BoxY BoxHeight sub lineto BoxX BoxY BoxHeight sub lineto closepath 0 setgray stroke grestore } def /PSDrawRegs { /map RFrame send } def /PSFillBox % x y canvas canvasheight width height boundry color => - { 8 dict begin /ColorIndex edef /BoxBoundry edef /BoxHeight edef /BoxWidth edef /BoxCanvasHeight edef /BoxCanvas edef /BoxY edef /BoxX edef BoxCanvas setcanvas /BoxY BoxCanvasHeight BoxY sub 5 sub def gsave BoxBoundry 1 eq { BoxX BoxY BoxHeight sub 1 sub BoxWidth 1 add BoxHeight 1 add rectpath 1 setgray fill BoxX 1 add BoxY BoxHeight sub BoxWidth 1 sub BoxHeight 1 sub rectpath ColorTable ColorIndex get setcolor fill } { BoxX BoxY BoxHeight sub 1 sub BoxWidth 1 add BoxHeight 1 add rectpath ColorTable ColorIndex get setcolor fill } ifelse grestore end } def /PSInitFonts % - => - { /SFont /Courier findfont 7 scalefont def /NFont /Courier-Bold findfont 14 scalefont def /BFont /Courier-Bold findfont 18 scalefont def } def /PSInitialise % - => - { /CFRAME_REPAINT_EVENT 100 def /RFRAME_REPAINT_EVENT 101 def /LEFT_DOWN_EVENT 102 def /LEFT_UP_EVENT 103 def /MIDDLE_DOWN_EVENT 104 def /MIDDLE_UP_EVENT 105 def /KEYBOARD_EVENT 106 def } def /PSIsColor % - => iscolorscreen { /Color? framebuffer /Color get def Color? {1} {0} ifelse typedprint } def /PSLoadColor % red green blue index => - { /ColorIndex edef /BlueValue edef /GreenValue edef /RedValue edef /CColor RedValue 255 div GreenValue 255 div BlueValue 255 div rgbcolor def ColorTable ColorIndex CColor put } def /PSMakeColorTable % size => - { /TableSize edef /ColorTable TableSize array def } def /PSMakeFrames % x y width height => - { /CFrameHeight edef /CFrameWidth edef /CFrameY edef /CFrameX edef clippath pathbbox /ScreenHeight edef pop pop pop /CFrame framebuffer /new DefaultWindow send def { /PaintClient { CFRAME_REPAINT_EVENT typedprint } def /PaintIcon { gsave IconCanvas setcanvas clippath pathbbox scale pop pop 0 setgray fill 1 1 1 setrgbcolor false CalctoolIcon imagemaskcanvas grestore } def } CFrame send CFrame /BorderLeft 5 put CFrame /BorderBottom 5 put CFrame /BorderRight 5 put CFrame /BorderTop 5 put CFrame /ControlSize 0 put CFrameX ScreenHeight CFrameHeight sub CFrameY sub CFrameWidth 10 add CFrameHeight /reshape CFrame send /map CFrame send /RFrame framebuffer /new DefaultWindow send def { /PaintClient { RFRAME_REPAINT_EVENT typedprint } def /PaintIcon { gsave IconCanvas setcanvas 1 fillcanvas 0 strokecanvas NFont setfont 5 40 moveto (Memory) show 10 20 moveto (Regs.) show grestore } def } RFrame send RFrame /BorderLeft 5 put RFrame /BorderBottom 5 put RFrame /BorderRight 5 put RFrame /BorderTop 5 put RFrame /ControlSize 0 put CFrameX CFrameWidth add 25 add ScreenHeight 200 sub CFrameY sub CFrameWidth 200 /reshape RFrame send } def /PSMakeIcons % - => - { /CalctoolIcon 42 64 1 { } { < 1555 5555 5540 2AAA AAAA AA80 5555 5555 5540 FFFF FFFF FE80 8000 0000 0340 BFFF FFFF FA80 A000 0000 0B40 A000 0000 0A80 A003 0030 CB40 A004 8049 2A80 A005 8059 6B40 A006 8069 AA80 A004 8449 2B40 A003 0430 CA80 A000 0000 0B40 A000 0000 0A80 BFFF FFFF FB40 8000 0000 0280 8000 0000 0340 BFDF EFF7 FA80 A050 2814 0B40 AF53 2994 0A80 A154 AA55 1340 A253 2A54 AA80 A254 A9D4 4B40 A454 A854 AA80 A453 2995 1B40 A050 2814 0A80 BFDF EFF7 FB40 8000 0000 0280 BFDF EFF7 FB40 A050 2814 0A80 A257 A994 2B40 A654 2A14 4A80 AA57 2B94 4B40 AF50 AA54 8A80 A254 AA54 8B40 A253 2995 0A80 A050 2814 0B40 BFDF EFF7 FA80 8000 0000 0340 BFDF EFF7 FA80 A050 2814 0B40 A253 2994 0A80 A654 AA54 0B40 A250 A895 EA80 A253 2854 0B40 A254 2A54 0A80 A757 A994 0B40 A050 2814 0A80 BFDF EFF7 FB40 8000 0000 0280 BFDF EFF7 FB40 A050 2814 0A80 A650 2814 0B40 A950 2814 4A80 AB50 2BD4 4B40 AD50 2815 FA80 A951 2BD4 4B40 A651 2814 4A80 A050 2814 0B40 BFDF EFF7 FA80 8000 0000 0300 FFFF FFFF FE00 > } buildimage def } def /PSMakePanel % x y width height => - { /PCHeight edef /PCWidth edef /PCX edef /PCY edef gsave CCanvas setcanvas /PC currentcanvas newcanvas def PC begin /Transparent false def /Mapped true def /Retained true def end PC 0 CFrameHeight PCHeight sub translate PCX PCY moveto PCWidth PCHeight rect reshapecanvas PC setcanvas 1 fillcanvas 0 strokecanvas grestore } def /PSMakeSubCanvas % x y width height => - { /KCHeight edef /KCWidth edef /KCY edef /KCX edef gsave CCanvas setcanvas /KC currentcanvas newcanvas def KC begin /Transparent false def /Mapped true def /Retained true def end KC 0 0 moveto KCWidth KCHeight rect reshapecanvas grestore } def /PSMakeSubframes % panelheight => - { /PCHeight edef /CCanvas CFrame /ClientCanvas get def /RC RFrame /ClientCanvas get def 0 0 CFrameWidth PCHeight PSMakePanel 0 PCHeight 10 sub CFrameWidth CFrameHeight PCHeight sub 10 sub PSMakeSubCanvas /RCHeight 200 def /RCWidth CFrameWidth def /SendEvent { KC setcanvas typedprint currentcursorlocation KCHeight exch sub exch typedprint typedprint } def /KbdEvent { begin Action /DownTransition eq { KEYBOARD_EVENT typedprint Name SendEvent } if end } def /EventMgrKbdInterest { [3 1 roll] { MakeEventMgrKbdInterest} append cvx } def /MakeEventMgrKbdInterest { addkbdinterests { /ClientData 10 dict dup /CallBack 5 index put put } forall pop } def /DownEventInterest {/DownTransition KC eventmgrinterest} def /UpEventInterest {/UpTransition KC eventmgrinterest} def /EventMgr [ LeftMouseButton {LEFT_DOWN_EVENT SendEvent} DownEventInterest MiddleMouseButton {MIDDLE_DOWN_EVENT SendEvent} DownEventInterest LeftMouseButton {LEFT_UP_EVENT SendEvent} UpEventInterest MiddleMouseButton {MIDDLE_UP_EVENT SendEvent} UpEventInterest { KbdEvent } KC EventMgrKbdInterest ] forkeventmgr def } def /PSMakeText % canvas canvasheight font x y color string => - { /TextString edef /TextColor edef /TextY edef /TextX edef /TextFont edef /TextCanvasHeight edef /TextCanvas edef /TextFontHeight TextFont fontheight def /Y TextCanvasHeight TextY sub 5 sub def TextCanvas setcanvas TextFont setfont ColorTable TextColor get setcolor TextX Y moveto TextString show } def /PSSetCursor % type => - { } def /PSToggleRegCanvas % state => - { /RState edef RState 1 eq {/map RFrame send} {/unmap RFrame send} ifelse } def