/usr/share/mozart/doc/wp/node16.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>4.2 The Packer</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="node15.html#section.geometry.intro"><< Prev</A></TD><TD><A href="node14.html">- Up -</A></TD><TD><A href="node17.html#section.geometry.grid">Next >></A></TD></TR></TABLE><DIV id="section.geometry.pack"><H2><A name="section.geometry.pack">4.2 The Packer</A></H2><P> The packer supports simple arrangements of widgets in rows and columns. Arranging widgets nicely usually also means that some vertical and horizontal space has to be inserted, either designed to provide for additional space or to fill up space not occupied by the widget's original size. </P><P> The different ways how to affect the geometry we will study by means of examples. For this, let us assume we are dealing with three label widgets. The following function creates a toplevel widget with background color white for better visibility, and returns a list of three labels. </P><DL class="anonymous"><DD class="code"><CODE><SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">NewLabels</SPAN>}<BR> W={New Tk<SPAN class="keyword">.</SPAN>toplevel tkInit(background:white)}<BR><SPAN class="keyword">in</SPAN> <BR> {Map [<SPAN class="string">'label'</SPAN> <SPAN class="string">'Second label widget'</SPAN> <SPAN class="string">'3rd label'</SPAN>]<BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> A}<BR> {New Tk<SPAN class="keyword">.</SPAN>label tkInit(parent:W text:A)}<BR> <SPAN class="keyword">end</SPAN>}<BR><SPAN class="keyword">end</SPAN></CODE></DD></DL><P> </P><P> To display the labels in the toplevel widget, the packer can be invoked as follows: <A name="label142"></A> </P><DL class="anonymous"><DD class="code"><CODE>[L1 L2 L3] = {NewLabels}<BR>{Tk<SPAN class="keyword">.</SPAN>send pack(L1 L2 L3)}</CODE></DD></DL><P> </P><P id="para.geometry.batch"> This computes and displays a geometry for the toplevel widget as shown in <A href="node16.html#figure.geometry.pack-basic">Figure 4.1</A>. Rather than giving a tickle which contains each of the labels as field we can give a <A name="label143"></A><EM>batch tickle</EM>. A batch tickle is a tuple with label <CODE>b</CODE> where its single argument must be a list of tickles. By using a batch tickle, we can rewrite our example from above to </P><DL class="anonymous"><DD class="code"><CODE>{Tk<SPAN class="keyword">.</SPAN>send pack(b({NewLabels}))}</CODE></DD></DL><P> where the list of tickles is the list of labels as returned by the function <CODE>NewLabels</CODE>. </P><P> </P><DIV id="figure.geometry.pack-basic"><HR><P><A name="figure.geometry.pack-basic"></A></P><DIV align="center"><IMG alt="" src="packer-plain.gif"></DIV><P class="caption"><STRONG>Figure 4.1:</STRONG> Plain geometry computed by the packer.</P><HR></DIV><P> </P><H3><A name="label144">4.2.1 Side Options</A></H3><P> <A name="label146"></A> <A name="label148"></A> <A name="label150"></A> <A name="label152"></A> <A name="label154"></A> The label widgets in the previous examples were placed from the top to the bottom of the toplevel widget. The side where the widgets are packed against can be determined with the <CODE>side</CODE> option. The default value for this option is <CODE>top</CODE>. The examples in <A href="node16.html#figure.geometry.packer-side">Figure 4.2</A> show the geometry which is computed when <CODE>left</CODE> and <CODE>bottom</CODE> are given as values for the side option. Valid values for the side option are <CODE>top</CODE>, <CODE>bottom</CODE>, <CODE>left</CODE>, and <CODE>right</CODE>. </P><P> </P><DIV id="figure.geometry.packer-side"><HR><P><A name="figure.geometry.packer-side"></A></P><P> </P><DIV align="center"><IMG alt="" src="packer-left.gif"></DIV><P> </P><DL class="anonymous"><DD class="code"><CODE>{Tk<SPAN class="keyword">.</SPAN>send pack(b({NewLabels}) side:left)}</CODE></DD></DL><P> </P><DIV align="center"><IMG alt="" src="packer-bottom.gif"></DIV><P> </P><DL class="anonymous"><DD class="code"><CODE>{Tk<SPAN class="keyword">.</SPAN>send pack(b({NewLabels}) side:bottom)}</CODE></DD></DL><P> </P><P class="caption"><STRONG>Figure 4.2:</STRONG> Geometries computed by the packer according to <CODE>side</CODE> option.</P><HR></DIV><P> </P><H3><A name="label155">4.2.2 Padding</A></H3><P> <A name="label156"></A> <A name="label158"></A> <A name="label160"></A> <A name="label162"></A> <A name="label164"></A> The geometry computed for widgets by the packer can be given additional space in two different ways: either externally or internally. Additional external space can be specified with the options <CODE>padx</CODE> and <CODE>pady</CODE>. The values for these options must be valid screen distances (see <A href="node9.html#section.widgets-1.distances">Section 3.3.2</A>), specifying how much additional space should be provided by the master widget around the packed widgets. The internal space can be specified by the <CODE>ipadx</CODE> and <CODE>ipady</CODE> options, where the values must be screen distances as well. These values determine by how much space the packed widgets are expanded in each of their four borders. The examples in <A href="node16.html#figure.geometry.packer-pad">Figure 4.3</A> show the effects on the geometries computed by the packer for both internal and external padding. </P><DIV id="figure.geometry.packer-pad"><HR><P><A name="figure.geometry.packer-pad"></A></P><P> </P><DIV align="center"><IMG alt="" src="packer-pad.gif"></DIV><P> </P><DL class="anonymous"><DD class="code"><CODE>{Tk<SPAN class="keyword">.</SPAN>send pack(b({NewLabels}) padx:1<SPAN class="keyword">#</SPAN>m pady:1<SPAN class="keyword">#</SPAN>m)}</CODE></DD></DL><P> </P><DIV align="center"><IMG alt="" src="packer-ipad.gif"></DIV><P> </P><DL class="anonymous"><DD class="code"><CODE>{Tk<SPAN class="keyword">.</SPAN>send pack(b({NewLabels}) ipadx:2<SPAN class="keyword">#</SPAN>m ipady:2<SPAN class="keyword">#</SPAN>m)}</CODE></DD></DL><P> </P><P class="caption"><STRONG>Figure 4.3:</STRONG> Additional space provided by the packer.</P><HR></DIV><P> </P><DIV id="section.geometry.anchors"><H3><A name="section.geometry.anchors">4.2.3 Anchors</A></H3><P> <A name="label165"></A> <A name="label167"></A> With the <CODE>anchor</CODE> option it can be specified where in a widget's parcel the packer places the widget. If no <CODE>anchor</CODE> option is given, the packer places the widget in the center of its parcel. Otherwise, the widget is placed according to the option's value, which can be one of <CODE>center</CODE>, <CODE>n</CODE>, <CODE>s</CODE>, <CODE>w</CODE>, <CODE>e</CODE>, <CODE>nw</CODE>, <CODE>ne</CODE>, <CODE>sw</CODE>, and <CODE>se</CODE>. The <A href="node16.html#figure.geometry.packer-anchor">Figure 4.4</A> shows the geometry computed when <CODE>w</CODE> is used as anchor. </P><DIV id="figure.geometry.packer-anchor"><HR><P><A name="figure.geometry.packer-anchor"></A></P><P> </P><DIV align="center"><IMG alt="" src="packer-anchor.gif"></DIV><P> </P><DL class="anonymous"><DD class="code"><CODE>{Tk<SPAN class="keyword">.</SPAN>send pack(b({NewLabels}) anchor:w padx:1<SPAN class="keyword">#</SPAN>m pady:1<SPAN class="keyword">#</SPAN>m)}</CODE></DD></DL><P> </P><P class="caption"><STRONG>Figure 4.4:</STRONG> Using the <CODE>anchor</CODE> option for packing.</P><HR></DIV><P> </P><P> </P></DIV><H3><A name="label168">4.2.4 Filling and Expansion</A></H3><P> For pleasant overall geometry it is imported that widgets have similar geometries. The packer employs two different schemes how widgets can be arranged to have similar geometries. One is filling: the widget extends over its entire parcel. The other one is expansion: the widget's parcel is extended such that the parcels of all slaves in a master occupy the master's parcel entirely. </P><P> <A name="label170"></A> <A name="label172"></A> <A name="label174"></A> <A name="label176"></A> <A name="label178"></A> <A href="node16.html#figure.geometry.packer-fill">Figure 4.5</A> shows the geometry computed when the option <CODE>fill</CODE> with value <CODE>x</CODE> is used. Possible values for the <CODE>fill</CODE> option are <CODE>x</CODE>, <CODE>y</CODE>, <CODE>both</CODE>, and <CODE>none</CODE> (which is the default). </P><DIV id="figure.geometry.packer-fill"><HR><P><A name="figure.geometry.packer-fill"></A></P><P> </P><DIV align="center"><IMG alt="" src="packer-fill.gif"></DIV><P> </P><DL class="anonymous"><DD class="code"><CODE>{Tk<SPAN class="keyword">.</SPAN>send pack(b({NewLabels}) fill:x)}</CODE></DD></DL><P> </P><P class="caption"><STRONG>Figure 4.5:</STRONG> Using the <CODE>fill</CODE> option for packing.</P><HR></DIV><P> </P><P> <A name="label180"></A> Expansion is only significant when the parcels of the slave do not fill the master's parcel completely. In all our previous examples, the parcel of the master was computed by the packer to be just large enough to contain the slave's parcels. So there was no additional space in the master's parcel to be filled by expansion of slave parcels. </P><P> <A href="node16.html#figure.geometry.packer-resize">Figure 4.6</A> shows three toplevel widgets which have been resized manually by dragging with the mouse. The top most example shows that when the parcel of the toplevel widget grows, the remaining space is filled by the label widgets. In the example in the middle, only the parcels of the label widget's are expanded. At the bottom, the parcels are expanded and then filled up in both horizontal and vertical direction by the label widgets. </P><DIV id="figure.geometry.packer-resize"><HR><P><A name="figure.geometry.packer-resize"></A></P><P> </P><DIV align="center"><IMG alt="" src="packer-resize-fill.gif"></DIV><P> </P><DL class="anonymous"><DD class="code"><CODE>{Tk<SPAN class="keyword">.</SPAN>send pack(b({NewLabels}) fill:x)}</CODE></DD></DL><P> </P><DIV align="center"><IMG alt="" src="packer-resize-expand.gif"></DIV><P> </P><DL class="anonymous"><DD class="code"><CODE>{Tk<SPAN class="keyword">.</SPAN>send pack(b({NewLabels}) expand:<SPAN class="keyword">true</SPAN>)}</CODE></DD></DL><P> </P><DIV align="center"><IMG alt="" src="packer-resize-both.gif"></DIV><P> </P><DL class="anonymous"><DD class="code"><CODE>{Tk<SPAN class="keyword">.</SPAN>send pack(b({NewLabels}) fill:both expand:<SPAN class="keyword">true</SPAN>)}</CODE></DD></DL><P> </P><P class="caption"><STRONG>Figure 4.6:</STRONG> Resizing effects for filling and expansion.</P><HR></DIV><P> </P></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node15.html#section.geometry.intro"><< Prev</A></TD><TD><A href="node14.html">- Up -</A></TD><TD><A href="node17.html#section.geometry.grid">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>
|