/usr/share/mozart/doc/wp/node44.html is in mozart-doc 1.4.0-8ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>8.3 Menubars</TITLE><LINK href="ozdoc.css" rel="stylesheet" type="text/css"></HEAD><BODY><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node43.html#section.tools.error"><< Prev</A></TD><TD><A href="node41.html">- Up -</A></TD><TD><A href="node45.html#section.tools.images">Next >></A></TD></TR></TABLE><DIV id="section.tools.menubars"><H2><A name="section.tools.menubars">8.3 Menubars</A></H2><DIV class="apropos"><P class="margin">keyboard accelerators</P><P> A menubar is a frame widget containing several menubutton widgets. To each of the menubutton widgets a menu is attached. The menu contains menuitems being either radiobutton entries, checkbutton entries, command entries (similar to button widgets), separator entries or cascade entries to which sub menus are attached. The menu entries can be equipped with <A name="label337"></A><EM>keyboard accelerators</EM> describing key event bindings that can be used to invoke the action of the menu entry. A keyboard accelerator must be added to the menu entry and the right event binding needs to be created. </P></DIV><P> Creating a menubar by hand has to follow this structure and is inconvenient due to the large numbers of different kinds of widgets and menu entries that are to be created. To ease the creation of a menubar, the <CODE>TkTools</CODE> module provides the procedure <CODE>TkTools<SPAN class="keyword">.</SPAN>menubar</CODE> that creates to a given specification a menubar and creates keyboard accelerators with the right event bindings. The specification of a menubar consists of messages used to initialize the necessary widgets and entries, where the label determines the kind of entry to be created. </P><P> <A href="node44.html#figure.tools.menubar">Figure 8.3</A> shows an example for menubar creation. The procedure <CODE>TkTools<SPAN class="keyword">.</SPAN>menubar</CODE> takes two widgets and two menubar specifications as input and returns a frame containing the widgets for the menubar. The widget given as first argument serves as parent for the menubar's frame, whereas the widget given as second argument receives the key bindings for the accelerators. The specification given as third (fourth) argument describe the left (right) part of the menubar. </P><P> </P><DIV id="figure.tools.menubar"><HR><P><A name="figure.tools.menubar"></A></P><P> </P><DIV align="center"><IMG alt="" src="menubar.gif"></DIV><P> <A name="label339"></A> </P><DL class="anonymous"><DD class="code"><CODE>V={New Tk<SPAN class="keyword">.</SPAN>variable tkInit(0)}<BR>B={TkTools<SPAN class="keyword">.</SPAN>menubar W W<BR> [menubutton(text:<SPAN class="string">'Test'</SPAN> underline:0<BR> menu: [command(label: <SPAN class="string">'About test'</SPAN> <BR> action: Browse<SPAN class="keyword">#</SPAN>about<BR> key: alt(a)<BR> feature: about)<BR> separator<BR> command(label: <SPAN class="string">'Quit'</SPAN> <BR> action: W<SPAN class="keyword">#</SPAN>tkClose<BR> key: ctrl(c)<BR> feature: quit)]<BR> feature: test)<BR> menubutton(text:<SPAN class="string">'Options'</SPAN> underline:0<BR> menu: [checkbutton(label: <SPAN class="string">'Incremental'</SPAN> <BR> var: {New Tk<SPAN class="keyword">.</SPAN>variable tkInit(<SPAN class="keyword">false</SPAN>)})<BR> separator<BR> cascade(label: <SPAN class="string">'Size'</SPAN> <BR> menu: [radiobutton(label:<SPAN class="string">'Small'</SPAN> <BR> var:V value:0)<BR> radiobutton(label:<SPAN class="string">'Middle'</SPAN> <BR> var:V value:1)<BR> radiobutton(label:<SPAN class="string">'Large'</SPAN> <BR> var:V value: 2)])])]<BR> nil}<BR>F={New Tk<SPAN class="keyword">.</SPAN>frame tkInit(parent:W width:10<SPAN class="keyword">#</SPAN>c height:5<SPAN class="keyword">#</SPAN>c bg:ivory)}<BR>{Tk<SPAN class="keyword">.</SPAN>send pack(B F fill:x)}</CODE></DD></DL><P> </P><P class="caption"><STRONG>Figure 8.3:</STRONG> A menubar.</P><HR></DIV><P> </P><P> A menubar specification consists of a list of <CODE>menubutton</CODE> messages. The valid options are those for the <CODE>tkInit</CODE> method of a menubutton widget object, where the parent field is not necessary, and the additional options <CODE>menu</CODE> and <CODE>feature</CODE>. The value for the <CODE>menu</CODE> option must be a list of specifications for the menu entries. The menu entries are specified similar to the menubuttons, the allow for the additional options <CODE>feature</CODE>, <CODE>key</CODE>, and <CODE>event</CODE>. </P><P> The value for the <CODE>key</CODE> describes the keyboard accelerator and event binding to be created. They can be used as follows: </P><TABLE align="center" bgcolor="#f0f0e0"><TR valign="top"><TH><P><CODE>key</CODE> option value</P></TH><TH><P>accelerator</P></TH><TH><P>event binding</P></TH></TR><TR valign="top"><TD><P><CODE>a</CODE></P></TD><TD><P><SPAN class="key">a</SPAN></P></TD><TD><P><CODE>a</CODE></P></TD></TR><TR valign="top"><TD><P><CODE>ctrl(a)</CODE></P></TD><TD><P><SPAN class="key">C-a</SPAN></P></TD><TD><P><CODE><Control-a></CODE></P></TD></TR><TR valign="top"><TD><P><CODE>alt(a)</CODE></P></TD><TD><P><SPAN class="key">A-a</SPAN></P></TD><TD><P><CODE><Alt-a></CODE></P></TD></TR><TR valign="top"><TD><P><CODE>alt(ctrl(a))</CODE></P></TD><TD><P><SPAN class="key">A-C-a</SPAN></P></TD><TD><P><CODE><Alt-Control-a></CODE></P></TD></TR><TR valign="top"><TD><P><CODE>ctrl(alt(a))</CODE></P></TD><TD><P><SPAN class="key">C-A-a</SPAN></P></TD><TD><P><CODE><Control-Alt-a></CODE></P></TD></TR></TABLE><P> </P><P> In case one wants to use different event bindings than those generated from the <CODE>key</CODE> option value, one can specify the event pattern as value for the option <CODE>event</CODE>. </P><P> The <CODE>feature</CODE> options for menubuttons and menu entries attach features to the created objects such that the object get accessible by these features. For instance, to disable the <SPAN class="menu">``About test''</SPAN> entry is possible with </P><DL class="anonymous"><DD class="code"><CODE>{B<SPAN class="keyword">.</SPAN>test<SPAN class="keyword">.</SPAN>about tk(entryconfigure state:disabled)}</CODE></DD></DL><P> </P><P> The menus attached to menubuttons or to cascade entries can be accessed under the feature <CODE>menu</CODE>. For instance the first tear off entry from the <SPAN class="menu">``Test''</SPAN> menu can be removed with </P><DL class="anonymous"><DD class="code"><CODE>{B<SPAN class="keyword">.</SPAN>test<SPAN class="keyword">.</SPAN>menu tk(configure tearoff:<SPAN class="keyword">false</SPAN>)}</CODE></DD></DL><P> </P><P> It is possible to extend a menubar created with <CODE>TkTools<SPAN class="keyword">.</SPAN>menubar</CODE> with further entries. The following statement adds a menu entry just before the <CODE>Quit</CODE> entry: <A name="label341"></A> </P><DL class="anonymous"><DD class="code"><CODE>A={New Tk<SPAN class="keyword">.</SPAN>menuentry<SPAN class="keyword">.</SPAN>command tkInit(parent:B<SPAN class="keyword">.</SPAN>test<SPAN class="keyword">.</SPAN>menu<BR> before:B<SPAN class="keyword">.</SPAN>test<SPAN class="keyword">.</SPAN>quit<BR> label: <SPAN class="string">'Exit'</SPAN>)}</CODE></DD></DL><P> which can be deleted and removed from the menu again by: </P><DL class="anonymous"><DD class="code"><CODE>{A tkClose}</CODE></DD></DL><P> </P></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node43.html#section.tools.error"><< Prev</A></TD><TD><A href="node41.html">- Up -</A></TD><TD><A href="node45.html#section.tools.images">Next >></A></TD></TR></TABLE><HR><ADDRESS><A href="http://www.ps.uni-sb.de/~schulte/">Christian Schulte</A><BR><SPAN class="version">Version 1.4.0 (20110908185330)</SPAN></ADDRESS></BODY></HTML>
|