%! % % $Header: menubar.ps,v 1.7 88/12/02 11:36:56 bvs Exp $ % Copyright (C) 1988 by Sun Microsystems. All rights reserved. % systemdict begin systemdict /Item known not { (NeWS/liteitem.ps) run } if systemdict /SimpleScrollbar known not { (NeWS/liteitem.ps) run } if end /BarMenu DefaultMenu [] classbegin /CenterItems? false def classend def /MenuBar Object dictbegin /X null def /Y null def /Gap null def /MenuBarCanvas null def /Items [] def /ItemMgr null def dictend classbegin /new { % x y gap canvas -> - /new super send begin /MenuBarCanvas exch def /Gap exch def /Y exch def /X exch def %% (new: % % % %\n) [ MenuBarCanvas Gap Y X ] dbgprintf currentdict end } def /addmenu { % menu name proc -> - %% (addmenu: % % % %\n) [ MenuBarCanvas Gap Y X ] dbgprintf MenuBarCanvas 0 0 /new MenuItem send % item dup Items 999 3 -1 roll arrayinsert /Items exch def dup X Y /move 4 -1 roll send % item dup /bbox exch send pop % x y width X add Gap add /X exch def pop pop } def /activate { /ItemMgr Items forkitems def } def /paint { Items paintitems } def classend def /MenuItem ButtonItem [ /Menu null def ] classbegin /new { /new super send begin /Menu exch def % disgusting hack!! not my fault! blame ButtonItem!! /ItemRadius 6 def /ItemFrame 1 def /ItemBorder 1 def /ItemGap 2 def currentdict end } def /ItemButton [ RightMouseButton ] def /ClientDown { %% (client down\n) [] dbgprintf true SetButtonValue framebuffer setcanvas ItemCanvas getcanvaslocation /showat Menu send } def /ClientUp { %% (client up\n) [] dbgprintf pause % let the menu die! false SetButtonValue /ItemValue null store StopItem } def /ClientEnter { %% (client enter\n) [] dbgprintf } def /ClientExit { %% (client exit\n) [] dbgprintf } def /setmenu { % menu => - /Menu exch def } def /getmenu { % menu => - Menu } def classend def /MenuBarWindow DefaultWindow dictbegin /MenuBarItem null def dictend classbegin /MenuBarSize 30 def /ShapeClientCanvas { % - => - ([Re]set client canvas' shape) ClientCanvas null ne { gsave FrameCanvas setcanvas BorderLeft BorderBottom translate 0 0 ClientWidth ClientHeight MenuBarSize sub ClientPath ClientCanvas reshapecanvas grestore } if } def /PaintFrameBorder { % - => - (Paint frame border areas) FrameFillColor fillcanvas FrameBorderColor strokecanvas BorderLeft .5 sub BorderBottom .5 sub FrameWidth BorderLeft BorderRight add sub 1 add FrameHeight BorderBottom BorderTop add sub 1 add FramePath stroke BorderLeft .5 sub BorderBottom .5 sub FrameWidth BorderLeft BorderRight add sub 1 add FrameHeight BorderBottom BorderTop add sub 1 add MenuBarSize sub FramePath stroke /paint MenuBarItem send } def /activate { /MenuBarItem BorderLeft 5 add FrameHeight BorderTop sub MenuBarSize sub 5 add 5 % gap! FrameCanvas /new MenuBar send def [ (About NewsDraw...) { currentcursorlocation [ ( NewsDraw consists of about 500 lines of NeWS and about 2000 lines of C. ) ( NewsDraw is intended as a demonstration of the proper way to spit a NeWS) ( application into client and server sections. NewsDraw also demonstrates) ( how the PostScript imaging model allows text and graphics to be treated) ( with equal ease.) () ( Bruce V. Schwartz) ( bvs@sun.com ) ( \(c\) 1988 Sun Microsystems) ] popmsg } ] /new BarMenu send (Info ) {} /addmenu MenuBarItem send [ (Open NewsDraw "file.nd") { PROP_TAG tagprint READ_KEY typedprint } (Save NewsDraw "file.nd") { PROP_TAG tagprint WRITE_KEY typedprint } (Save PostScript "newsdraw.ps") { PROP_TAG tagprint PRINT_KEY typedprint } ] /new BarMenu send (File) {} /addmenu MenuBarItem send [ (Move) { TOOL_TAG tagprint STRETCH_MODE typedprint } (Rotate) { TOOL_TAG tagprint ROTATE_MODE typedprint } (Brush) { TOOL_TAG tagprint BRUSH_MODE typedprint } (Line) { TOOL_TAG tagprint LINE_MODE typedprint } (Box) { TOOL_TAG tagprint RECT_MODE typedprint } (Oval) { TOOL_TAG tagprint OVAL_MODE typedprint } (Circle){ TOOL_TAG tagprint CIRC_MODE typedprint } (Polygon) { TOOL_TAG tagprint POLY_MODE typedprint } (Text) { TOOL_TAG tagprint TEXT_MODE typedprint } ] /new BarMenu send (Mode) {} /addmenu MenuBarItem send [ (To Top) { PROP_TAG tagprint TOTOP_KEY typedprint } (To Bottom) { PROP_TAG tagprint TOBOT_KEY typedprint } (Redraw) { PROP_TAG tagprint REDRAW_KEY typedprint } ] /new BarMenu send (Misc) {} /addmenu MenuBarItem send [ (1) { PROP_TAG tagprint WIDTH_KEY typedprint 1 typedprint } (2) { PROP_TAG tagprint WIDTH_KEY typedprint 2 typedprint } (3) { PROP_TAG tagprint WIDTH_KEY typedprint 3 typedprint } (4) { PROP_TAG tagprint WIDTH_KEY typedprint 4 typedprint } (5) { PROP_TAG tagprint WIDTH_KEY typedprint 5 typedprint } (6) { PROP_TAG tagprint WIDTH_KEY typedprint 6 typedprint } (7) { PROP_TAG tagprint WIDTH_KEY typedprint 7 typedprint } (8) { PROP_TAG tagprint WIDTH_KEY typedprint 8 typedprint } (9) { PROP_TAG tagprint WIDTH_KEY typedprint 9 typedprint } (10) { PROP_TAG tagprint WIDTH_KEY typedprint 10 typedprint } ] /new BarMenu send (Line Width) {} /addmenu MenuBarItem send [ (none) { PROP_TAG tagprint STROKE_KEY typedprint -1.0 typedprint } (white) { PROP_TAG tagprint STROKE_KEY typedprint 1.0 typedprint } (light gray) { PROP_TAG tagprint STROKE_KEY typedprint .75 typedprint } (medium gray) { PROP_TAG tagprint STROKE_KEY typedprint .50 typedprint } (dark gray) { PROP_TAG tagprint STROKE_KEY typedprint .25 typedprint } (black) { PROP_TAG tagprint STROKE_KEY typedprint 0.0 typedprint } ] /new BarMenu send (Outline) {} /addmenu MenuBarItem send [ (none) { PROP_TAG tagprint FILL_KEY typedprint -1.0 typedprint } (white) { PROP_TAG tagprint FILL_KEY typedprint 1.0 typedprint } (light gray) { PROP_TAG tagprint FILL_KEY typedprint .75 typedprint } (medium gray) { PROP_TAG tagprint FILL_KEY typedprint .50 typedprint } (dark gray) { PROP_TAG tagprint FILL_KEY typedprint .25 typedprint } (black) { PROP_TAG tagprint FILL_KEY typedprint 0.0 typedprint } ] /new BarMenu send (Fill) {} /addmenu MenuBarItem send [ (white) { PROP_TAG tagprint TEXT_KEY typedprint 1.0 typedprint } (light gray) { PROP_TAG tagprint TEXT_KEY typedprint .75 typedprint } (medium gray) { PROP_TAG tagprint TEXT_KEY typedprint .50 typedprint } (dark gray) { PROP_TAG tagprint TEXT_KEY typedprint .25 typedprint } (black) { PROP_TAG tagprint TEXT_KEY typedprint 0.0 typedprint } ] /new BarMenu send (Text) {} /addmenu MenuBarItem send /activate MenuBarItem send { createevent begin /Canvas ClientCanvas def /Name [ /LeftMouseButton /MiddleMouseButton ] def currentdict end expressinterest { clear awaitevent begin end } loop } fork pop } def classend def /DefaultWindow MenuBarWindow def %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%