Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!math.lsa.umich.edu!math.lsa.umich.edu!emv From: grunwald@foobar.colorado.edu (Dirk Grunwald) Newsgroups: comp.archives Subject: [xpert] Re: Cascading SimpleMenuWidgets Message-ID: <1990May30.041610.29503@math.lsa.umich.edu> Date: 30 May 90 04:16:10 GMT Sender: emv@math.lsa.umich.edu (Edward Vielmetti) Reply-To: grunwald@foobar.colorado.edu Followup-To: comp.windows.x Organization: University of Michigan, Department of Mathematics Lines: 88 Approved: emv@math.lsa.umich.edu (Edward Vielmetti) X-Original-Newsgroups: comp.windows.x Archive-name: ezmenu/30-May-90 Original-posting-by: grunwald@foobar.colorado.edu (Dirk Grunwald) Original-subject: Re: Cascading SimpleMenuWidgets Archive-site: foobar.colorado.edu [128.138.243.105] Archive-directory: pub Reposted-by: emv@math.lsa.umich.edu (Edward Vielmetti) CP> > I would like to know if it is possible to cascade several CP> > SimpleMenuWidgets. CP> CP> Has anyone sucessfully done this? I have yet to hear of a working CP> implementation. -- I have a simple implementation, but you're right, it's kind of gross. I subclassed the simple menu widget to build the ``EzMenu'' widget and I subclasses Sme to make ``EzME''. The EzMenu widget actually constructs EzME's on the fly, using a menu specified by a string (see example below). All ``callbacks'' are implemented by action routines, because I was sick of maintaining two diff interfaces to my code (action routines & callbacks). The EzME object enforces one of two translations on the parent widget (which had better be an EzMenu) -- one is used if you have a submenu (i.e. cascaded) and one is used if you don't. Popups occur on the normal Highlight action, and popdowns on Notify & LeaveWindow. The code for all of this (sans example) is available via anon. ftp from foobar.colorado.edu in pub/EzMenu.shar.Z. There's no magic in making an EzMenu, you just XtCreateManageWidget -- the hard part is the .menu resource specification, which provides the menu layout and associated action. There's a little unorthogonality to the design, e.g. for submenus, the menu label is specified by the ``(menu "
"...'' string, while for the top level menu, you must use the ``label'' resource. It works O.K, about as well as the menus in TWM -- the only added functionality I'd like is to see is a ``hot spot'' that you have to move into to cause a submenu to popup -- that & it'd be nice to have the parsing for the actions to be done via the routines in Xt, but I couldn't figure out a way to use them. A sample menu specification used in xtex follows: *.xtex-page*.menu.label: XTeX Menu *.xtex-page*.menu*.RowHeight: 16 *.xtex-page*.menu.menu:\ (line)\ (item "Forward" (action "xtex-page-foreward()"))\ (item "...10 pages" (action "xtex-page-number(1) xtex-page-number(0) xtex-page-foreward() xtex-page-number-reset()"))\ (item "Backward" (action "xtex-page-backward()"))\ (item "...10 pages" (action "xtex-page-number(1) xtex-page-number(0) xtex-page-backward() xtex-page-number-reset()"))\ (item "Goto..." (action "xtex-page-goto-popup()"))\ (blank)\ (item "Overview" (action "xtex-page-magnify(small)"))\ (item "Detail View" (action "xtex-page-magnify(large)"))\ (blank)\ (item "Mark" (action "xtex-mark-page(set)"))\ (item "Unmark" (action "xtex-mark-page(clear)"))\ (blank)\ (item "Reopen" (action "xtex-file(reopen) xtex-page-number-reset()"))\ (blank)\ (menu "Print..." \ (line)\ (item "This Page" \ (action "xtex-mark-push() xtex-mark-page(set) xtex-print-using(set) xtex-mark-pop()"))\ (item "All Pages" (action "xtex-print-using(all)"))\ (item "All Marked Pages" (action "xtex-print-using(set)"))\ (item "All Unmarked Pages" (action "xtex-print-using(clear)"))\ )\ (blank)\ (menu "Ruler Units..."\ (line)\ (item "Inches" (action "dvi-line-units(in)"))\ (item "Points" (action "dvi-line-units(pt)"))\ (item "Centimeters" (action "dvi-line-units(cm)"))\ (item "Millimeters" (action "dvi-line-units(mm)"))\ (item "Scaled Points" (action "dvi-line-units(sp)"))\ (item "Picas" (action "dvi-line-units(pc)"))\ (item "Big Points" (action "dvi-line-units(bp)"))\ (item "Didot" (action "dvi-line-units(dd)"))\ (item "Cicero" (action "dvi-line-units(cc)"))\ )\ (blank)\ (item "Quit Page" (action "xtex-page-quit()"))\ (item "Quit XTeX" (action "xtex-quit()"))