Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > bd5c3d824c3db63ffd9226c15941e6ad > files > 2386

mozart-1.4.0-1mdv2010.0.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>3.3 Frames</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="node8.html#section.widgets-1.tickles">&lt;&lt; Prev</A></TD><TD><A href="node6.html">- Up -</A></TD><TD><A href="node10.html#section.widgets-1.hierarchy">Next &gt;&gt;</A></TD></TR></TABLE><DIV id="section.widgets-1.frame"><H2><A name="section.widgets-1.frame">3.3 Frames</A></H2><P> <A name="label69"></A>Frame widgets are similar to toplevel widgets in that they serve as containers for other widgets. The difference is that a frame is used as container within other widgets, whereas a toplevel widget is the outermost container. The main purpose of frames is to determine geometrical layouts for the widgets they contain. More on geometry management we see in <A href="node14.html#chapter.geometry">Chapter&nbsp;4</A>. </P><DIV id="section.widgets-1.relief"><H3><A name="section.widgets-1.relief">3.3.1 Relief Options</A></H3><DIV class="apropos"><P class="margin">relief and border</P><P> Frames support the <A name="label71"></A><CODE>relief</CODE> and <A name="label73"></A><CODE>borderwidth</CODE> options. These options determine a three dimensional border to be drawn around a frame. The values for the <CODE>relief</CODE> option must be one of <A name="label75"></A><CODE>groove</CODE>, <A name="label77"></A><CODE>ridge</CODE>, <A name="label79"></A><CODE>flat</CODE>, <A name="label81"></A><CODE>sunken</CODE>, and <A name="label83"></A><CODE>raised</CODE>. The different styles of borders which correspond to theses values are shown in <A href="node9.html#figure.widgets-1.relief-frames">Figure&nbsp;3.2</A>. </P></DIV><P> </P><DIV id="figure.widgets-1.relief-frames"><HR><P><A name="figure.widgets-1.relief-frames"></A></P><P> </P><DIV align="center"><IMG alt="" src="relief-frames.gif"></DIV><P> <A name="label85"></A> <A name="label87"></A> </P><DL class="anonymous"><DD class="code"><CODE>Fs={Map&nbsp;[groove&nbsp;ridge&nbsp;flat&nbsp;sunken&nbsp;raised]<BR>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">fun</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">$</SPAN>&nbsp;R}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{New&nbsp;Tk<SPAN class="keyword">.</SPAN>frame&nbsp;tkInit(parent:W&nbsp;width:2<SPAN class="keyword">#</SPAN>c&nbsp;height:1<SPAN class="keyword">#</SPAN>c<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;relief:R&nbsp;borderwidth:4)}<BR>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">end</SPAN>}<BR>{{Nth&nbsp;Fs&nbsp;3}&nbsp;tk(configure&nbsp;background:black)}<BR>{Tk<SPAN class="keyword">.</SPAN>send&nbsp;pack(b(Fs)&nbsp;side:left&nbsp;padx:4&nbsp;pady:4)}</CODE></DD></DL><P> </P><P class="caption"><STRONG>Figure&nbsp;3.2:</STRONG> Frame widgets with different values for relief.</P><HR></DIV><P> </P><DIV class="apropos"><P class="margin">parent widgets</P><P> The <CODE>tkInit</CODE> message contains the option <CODE>parent</CODE> which links the frames into its parent, the toplevel widget&nbsp;<CODE>W</CODE>. All widgets but toplevels need a parent widget, this is discussed in <A href="node10.html#section.widgets-1.hierarchy">Section&nbsp;3.4</A>. </P></DIV><P> The program shown in <A href="node9.html#figure.widgets-1.relief-frames">Figure&nbsp;3.2</A> maps the list of relief option values to frame objects. To make the frame with the option <CODE>flat</CODE> visible, its background is configured to be black. </P><P> Note that we left out the code to create the toplevel widget. Here and in the following we assume that the variable&nbsp;<CODE>W</CODE> is bound to a toplevel widget. The <A href="WindowProgramming.oz">example file</A>, however, contains the code needed to create the toplevel widget. </P><P> The exact meaning of the <CODE>pack</CODE> command used in this example is explained in <A href="node16.html#section.geometry.pack">Section&nbsp;4.2</A>. </P></DIV><DIV id="section.widgets-1.distances"><H3><A name="section.widgets-1.distances">3.3.2 Screen Distance Options</A></H3><P> <A name="label88"></A>As value for the <CODE>borderwidth</CODE> option we used an integer in the example shown in <A href="node9.html#figure.widgets-1.relief-frames">Figure&nbsp;3.2</A>. Just giving a number specifies a distance in <A name="label89"></A><EM>screen pixels</EM>. If the number is followed by one of the letters <CODE>c</CODE>, <CODE>m</CODE>, <CODE>i</CODE>, and&nbsp;<CODE>p</CODE> the screen distance is given in centimeters, millimeters, inches (2.54 centimeters), or printers' points (1/72 inch). </P><P> A convenient way to specify screen distances that employ units is to use a virtual string that appends the unit letter to the number, as used in <A href="node9.html#figure.widgets-1.relief-frames">Figure&nbsp;3.2</A>. </P></DIV><DIV id="section.widgets-1.color"><H3><A name="section.widgets-1.color">3.3.3 Color Options</A></H3><P> <A name="label90"></A>To make the frame with the <CODE>relief</CODE> option <CODE>flat</CODE> visible, we configured the background color to be black. Color options can be given either symbolically or numerically. </P><DIV class="apropos"><P class="margin">symbolic color values</P><P> <A name="label91"></A>A symbolic color value can be given as virtual string like <CODE>black</CODE>, <CODE><SPAN class="string">&quot;red&quot;</SPAN></CODE>, or <CODE><SPAN class="string">&quot;dArK&quot;</SPAN><SPAN class="keyword">#</SPAN>blUe</CODE>, where the capitalization does not have any significance. </P></DIV><DIV class="apropos"><P class="margin">numerical color values</P><P> <A name="label92"></A>A numerical color value is determined by three integers between <CODE>0</CODE> and <CODE>255</CODE>. The three integers describe the red, green, and blue part of the color. A numerical color value in Oz can be specified by a ternary tuple with label&nbsp;<CODE>c</CODE>, where the three fields of the tuple are the three integers. For example, the base colors red, green, and blue are described by the tuples <CODE>c(255&nbsp;0&nbsp;0)</CODE>, <CODE>c(0&nbsp;255&nbsp;0)</CODE>, and <CODE>c(0&nbsp;0&nbsp;255)</CODE> respectively. </P></DIV><P> Two examples that make frequent use of color options can be found in <A href="node27.html#section.widgets-2.scale">Section&nbsp;5.8</A> and <A href="node28.html#section.widgets-2.listbox">Section&nbsp;5.9</A>. </P></DIV><H3><A name="label93">3.3.4 Abbreviations and Synonyms</A></H3><P> Some of the most common options have the following synonyms: </P><TABLE align="center" bgcolor="#f0f0e0"><TR valign="top"><TD><P><CODE>background</CODE> </P></TD><TD><P><CODE>bg</CODE> </P></TD></TR><TR valign="top"><TD><P><CODE>foreground</CODE> </P></TD><TD><P><CODE>fg</CODE> </P></TD></TR><TR valign="top"><TD><P><CODE>borderwidth</CODE> </P></TD><TD><P><CODE>bd</CODE> </P></TD></TR></TABLE><P> </P><DIV class="apropos"><P class="margin">option abbreviations</P><P> <A name="label94"></A>In addition to synonyms, it is also possible to abbreviate options provided that the abbreviation is unambiguous. For example, it is correct to abbreviate the <CODE>background</CODE> option by <CODE>ba</CODE> but not by <CODE>b</CODE> since <CODE>b</CODE> is also an abbreviation for <CODE>bitmap</CODE> and <CODE>borderwidth</CODE>. </P></DIV><H3><A name="label95">3.3.5 Additional Tk Information</A></H3><P> The full Tk-reference information for each widget is shipped with the Mozart distribution. For an example, see the reference information for <A href="../tcltk/TkCmd/frame.htm"><KBD>frame</KBD></A>. </P><P> Reference information on options that are supported by all widgets are explained in <A href="../tcltk/TkCmd/options.htm"><KBD>options</KBD></A>. </P></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node8.html#section.widgets-1.tickles">&lt;&lt; Prev</A></TD><TD><A href="node6.html">- Up -</A></TD><TD><A href="node10.html#section.widgets-1.hierarchy">Next &gt;&gt;</A></TD></TR></TABLE><HR><ADDRESS><A href="http://www.ps.uni-sb.de/~schulte/">Christian&nbsp;Schulte</A><BR><SPAN class="version">Version 1.4.0 (20090610)</SPAN></ADDRESS></BODY></HTML>