⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch21_09.htm

📁 by Randal L. Schwartz and Tom Phoenix ISBN 0-596-00132-0 Third Edition, published July 2001. (See
💻 HTM
字号:
<html><head><title>The Scrollbar Widget (Perl in a Nutshell, 2nd Edition)</title><link rel="stylesheet" type="text/css" href="../style/style1.css" /><meta name="DC.Creator" content="Stephen Spainhour" /><meta name="DC.Format" content="text/xml" scheme="MIME" /><meta name="DC.Language" content="en-US" /><meta name="DC.Publisher" content="O'Reilly &amp; Associates, Inc." /><meta name="DC.Source" scheme="ISBN" content="0596002416L" /><meta name="DC.Subject.Keyword" content="stuff" /><meta name="DC.Title" content="Perl in a Nutshell, 2nd Edition" /><meta name="DC.Type" content="Text.Monograph" /></head><body bgcolor="#ffffff"><img src="gifs/smbanner.gif" usemap="#banner-map" border="0" alt="Book Home" /><map name="banner-map"><area shape="rect" coords="1,-2,616,66" href="index.htm" alt="Java and XSLT" /><area shape="rect" coords="629,-11,726,25" href="jobjects/fsearch.htm" alt="Search this book" /></map><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch21_08.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0" /></a></td><td align="center" valign="top" width="228" /><td align="right" valign="top" width="228"><a href="ch21_10.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr></table></div><h2 class="sect1">21.9. The Scrollbar Widget</h2><p><a name="INDEX-2907" /><a name="INDEX-2908" /><a name="INDEX-2909" />Create a scrollbar with the<tt class="literal">Scrollbar</tt> method:</p><blockquote><pre class="code">$parentwidget-&gt;Scrollbar (<em class="replaceable"><tt>options</tt></em>)</pre></blockquote><p>The standard configuration options that apply to<tt class="literal">Scrollbar</tt> are:<tt class="literal">-ac</tt>-<tt class="literal">tivebackground</tt>,<tt class="literal">-background</tt>, <tt class="literal">-bg</tt>,<tt class="literal">-borderwidth</tt>, <tt class="literal">-bd</tt>,<tt class="literal">-cursor</tt>,<tt class="literal">-highlightback</tt>-<tt class="literal">ground</tt>,<tt class="literal">-highlightcolor</tt>,<tt class="literal">-highlightthickness</tt>, <tt class="literal">-relief</tt>,<tt class="literal">-takefocus</tt>, and <tt class="literal">-width</tt>.</p><p>Other options are:</p><dl><dt><b><tt class="literal">-activerelief =&gt;</tt> <em class="replaceable">type</em></b></dt><dd><a name="INDEX-2910" />Changes how active elements(<tt class="literal">arrow1</tt>, <tt class="literal">arrow2</tt>, and<tt class="literal">slider</tt>) in the scrollbar are drawn. Values for<em class="replaceable"><tt>type</tt></em> are <tt class="literal">flat</tt>,<tt class="literal">groove</tt>, <tt class="literal">raised</tt>,<tt class="literal">ridge</tt>, and <tt class="literal">sunken</tt>. The defaultis <tt class="literal">raised</tt>.</p></dd><dt><b><tt class="literal">-command =&gt;</tt> <em class="replaceable">callback</em></b></dt><dd><a name="INDEX-2911" />Pointer to a function that will becalled when the scrollbar is clicked on.</p></dd><dt><b><tt class="literal">-elementborderwidth =&gt;</tt> <em class="replaceable">amount</em></b></dt><dd><a name="INDEX-2912" />The width of the borders of the<tt class="literal">arrow1</tt>, <tt class="literal">arrow2</tt>, and<tt class="literal">slider</tt> elements.</p></dd><dt><b><tt class="literal">-jump =&gt;</tt> <em class="replaceable">boolean</em></b></dt><dd><a name="INDEX-2913" />Determines whether the scrollbarwill jump scroll. Default is <tt class="literal">0</tt> (jump scrolldisabled).</p></dd><dt><b><tt class="literal">-orient =&gt;</tt> <em class="replaceable">orientation</em></b></dt><dd><a name="INDEX-2914" />Determines the orientation of thescrollbar. Possible <em class="replaceable"><tt>orientation</tt></em>s are<tt class="literal">horizontal</tt> and <tt class="literal">vertical</tt>(default).</p></dd><dt><b><tt class="literal">-repeatdelay =&gt;</tt> <em class="replaceable">milliseconds</em></b></dt><dd><a name="INDEX-2915" />Determines the number of millisecondsto hold down an arrow before it will auto-repeat. Default is<tt class="literal">300</tt>. </p></dd><dt><b><tt class="literal">-repeatinterval =&gt;</tt> <em class="replaceable">milliseconds</em></b></dt><dd><a name="INDEX-2916" />Determines the number of millisecondsbetween auto-repeats once it is started. Default is<tt class="literal">100</tt>. </p></dd><dt><b><tt class="literal">-troughcolor =&gt;</tt> <em class="replaceable">color</em></b></dt><dd><a name="INDEX-2917" />Changes the color of the trough.</p></dd></dl><a name="perlnut2-CHP-21-SECT-9.1" /><div class="sect2"><h3 class="sect2">21.9.1. Scrollbar Methods</h3><p>In addition to <tt class="literal">configure</tt> and<tt class="literal">cget</tt>, the following methods are supported by theScrollbar widget:</p><dl><dt><b><tt class="literal">set</tt></b></dt><dd><a name="INDEX-2918" />Changes the viewable portion of thedata, with the two arguments being numbers between 0 and 1representing the portions of the data that will be visible.</p><blockquote><pre class="code">$scrollbar-&gt;set(0.2,0.6);</pre></blockquote></dd><dt><b><tt class="literal">get</tt></b></dt><dd><a name="INDEX-2919" />Returns the latest arguments to<tt class="literal">set</tt>.</p></dd><dt><b><tt class="literal">activate</tt></b></dt><dd><a name="INDEX-2920" />With no arguments, returns the name ofthe current active element. With an argument of<tt class="literal">arrow1</tt>, <tt class="literal">arrow2</tt>, or<tt class="literal">slider</tt>, changes the color of the specified elementto the active foreground color and relief type.</p></dd><dt><b><tt class="literal">delta</tt></b></dt><dd><a name="INDEX-2921" />Given a number of pixels in thefirst argument, returns the fractional change needed to move theslider that amount.</p></dd><dt><b><tt class="literal">fraction</tt></b></dt><dd><a name="INDEX-2922" />Given an x,y coordinate as the firstand second arguments, returns a number between 0 and 1 representingthe fraction of the scrollbar that the coordinate would fall under.</p></dd><dt><b><tt class="literal">identify</tt></b></dt><dd><a name="INDEX-2923" />Given an x,y coordinate as the firstand second arguments, returns the name of the element at thosecoordinates.</p></dd></dl></div><hr width="684" align="left" /><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch21_08.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0" /></a></td><td align="center" valign="top" width="228"><a href="index.htm"><img src="../gifs/txthome.gif" alt="Home" border="0" /></a></td><td align="right" valign="top" width="228"><a href="ch21_10.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr><tr><td align="left" valign="top" width="228">21.8. The Entry Widget</td><td align="center" valign="top" width="228"><a href="index/index.htm"><img src="../gifs/index.gif" alt="Book Index" border="0" /></a></td><td align="right" valign="top" width="228">21.10. The Listbox Widget</td></tr></table></div><hr width="684" align="left" /><img src="../gifs/navbar.gif" usemap="#library-map" border="0" alt="Library Navigation Links" /><p><p><font size="-1"><a href="copyrght.htm">Copyright &copy; 2002</a> O'Reilly &amp; Associates. All rights reserved.</font></p><map name="library-map"><area shape="rect" coords="1,0,85,94" href="../index.htm"><area shape="rect" coords="86,1,178,103" href="../lwp/index.htm"><area shape="rect" coords="180,0,265,103" href="../lperl/index.htm"><area shape="rect" coords="267,0,353,105" href="../perlnut/index.htm"><area shape="rect" coords="354,1,446,115" href="../prog/index.htm"><area shape="rect" coords="448,0,526,132" href="../tk/index.htm"><area shape="rect" coords="528,1,615,119" href="../cookbook/index.htm"><area shape="rect" coords="617,0,690,135" href="../pxml/index.htm"></map></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -