home *** CD-ROM | disk | FTP | other *** search
-
- <HTML>
- <HEAD>
- <TITLE>Tk::Scrollbar - Create and manipulate Scrollbar widgets</TITLE>
- <LINK REL="stylesheet" HREF="../../../Active.css" TYPE="text/css">
- <LINK REV="made" HREF="mailto:">
- </HEAD>
-
- <BODY>
- <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
- <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
- <STRONG><P CLASS=block> Tk::Scrollbar - Create and manipulate Scrollbar widgets</P></STRONG>
- </TD></TR>
- </TABLE>
-
- <A NAME="__index__"></A>
- <!-- INDEX BEGIN -->
-
- <UL>
-
- <LI><A HREF="#name">NAME</A></LI><LI><A HREF="#supportedplatforms">SUPPORTED PLATFORMS</A></LI>
-
- <LI><A HREF="#synopsis">SYNOPSIS</A></LI>
- <LI><A HREF="#standard options">STANDARD OPTIONS</A></LI>
- <LI><A HREF="#widgetspecific options">WIDGET-SPECIFIC OPTIONS</A></LI>
- <LI><A HREF="#description">DESCRIPTION</A></LI>
- <LI><A HREF="#elements">ELEMENTS</A></LI>
- <LI><A HREF="#widget methods">WIDGET METHODS</A></LI>
- <LI><A HREF="#scrolling commands">SCROLLING COMMANDS</A></LI>
- <LI><A HREF="#old command syntax">OLD COMMAND SYNTAX</A></LI>
- <LI><A HREF="#bindings">BINDINGS</A></LI>
- <LI><A HREF="#see also">SEE ALSO</A></LI>
- <LI><A HREF="#keywords">KEYWORDS</A></LI>
- </UL>
- <!-- INDEX END -->
-
- <HR>
- <P>
- <H1><A NAME="name">NAME</A></H1>
- <P>Tk::Scrollbar - Create and manipulate Scrollbar widgets</P>
- <P>
- <HR>
- <H1><A NAME="supportedplatforms">SUPPORTED PLATFORMS</A></H1>
- <UL>
- <LI>Linux</LI>
- <LI>Solaris</LI>
- <LI>Windows</LI>
- </UL>
- <HR>
- <H1><A NAME="synopsis">SYNOPSIS</A></H1>
- <P><EM>$scrollbar</EM> = <EM>$parent</EM>-><STRONG>Scrollbar</STRONG>(?<EM>options</EM>?);</P>
- <P>
- <HR>
- <H1><A NAME="standard options">STANDARD OPTIONS</A></H1>
- <P><TABLE CELLSPACING=0 CELLPADDING=0><TR><TD><STRONG>-activebackground</STRONG><TD><STRONG>-highlightbackground</STRONG><TD><STRONG>-orient</STRONG><TD><STRONG>-takefocus</STRONG>
- <TR><TD><STRONG>-background</STRONG><TD><STRONG>-highlightcolor</STRONG><TD><STRONG>-relief</STRONG><TD><STRONG>-troughcolor</STRONG>
- <TR><TD><STRONG>-borderwidth</STRONG><TD><STRONG>-highlightthickness</STRONG><TD><STRONG>-repeatdelay</STRONG>
- <TR><TD><STRONG>-cursor</STRONG><TD><STRONG>-jump</STRONG><TD><STRONG>-repeatinterval</STRONG></TABLE></P>
- <P>See <A HREF="../../../site/lib/Tk/options.html">the Tk::options manpage</A> for details of the standard options.</P>
- <P>
- <HR>
- <H1><A NAME="widgetspecific options">WIDGET-SPECIFIC OPTIONS</A></H1>
- <DL>
- <DT><STRONG><A NAME="item_Name%3A_activeRelief">Name: <STRONG>activeRelief</STRONG></A></STRONG><BR>
- <DD>
- <DT><STRONG><A NAME="item_Class%3A_ActiveRelief">Class: <STRONG>ActiveRelief</STRONG></A></STRONG><BR>
- <DD>
- <DT><STRONG><A NAME="item_Switch%3A_%2Dactiverelief">Switch: <STRONG>-activerelief</STRONG></A></STRONG><BR>
- <DD>
- Specifies the relief to use when displaying the element that is
- active, if any.
- Elements other than the active element are always displayed with
- a raised relief.
- <P></P>
- <DT><STRONG><A NAME="item_Name%3A_command">Name: <STRONG>command</STRONG></A></STRONG><BR>
- <DD>
- <DT><STRONG><A NAME="item_Class%3A_Command">Class: <STRONG>Command</STRONG></A></STRONG><BR>
- <DD>
- <DT><STRONG><A NAME="item_Switch%3A_%2Dcommand">Switch: <STRONG>-command</STRONG></A></STRONG><BR>
- <DD>
- Specifies a callback to invoke to change the view
- in the widget associated with the scrollbar. When a user requests
- a view change by manipulating the scrollbar, the callback is
- invoked. The callback is passed
- additional arguments as described later. This option almost always has
- a value such as <STRONG>[xview => $widget]</STRONG> or <STRONG>[yview => $widget]</STRONG>, consisting of the
- a widget object and either <STRONG>xview</STRONG> (if the scrollbar is for
- horizontal scrolling) or <STRONG>yview</STRONG> (for vertical scrolling).
- All scrollable widgets have <STRONG>xview</STRONG> and <STRONG>yview</STRONG> methods
- that take exactly the additional arguments appended by the scrollbar
- as described in <A HREF="#scrolling commands">SCROLLING COMMANDS</A> below.
- <P></P>
- <DT><STRONG><A NAME="item_Name%3A_elementBorderWidth">Name: <STRONG>elementBorderWidth</STRONG></A></STRONG><BR>
- <DD>
- <DT><STRONG><A NAME="item_Class%3A_BorderWidth">Class: <STRONG>BorderWidth</STRONG></A></STRONG><BR>
- <DD>
- <DT><STRONG><A NAME="item_Switch%3A_%2Delementborderwidth">Switch: <STRONG>-elementborderwidth</STRONG></A></STRONG><BR>
- <DD>
- Specifies the width of borders drawn around the internal elements
- of the scrollbar (the two arrows and the slider). The value may
- have any of the forms acceptable to <STRONG>Tk_GetPixels</STRONG>.
- If this value is less than zero, the value of the <STRONG>borderWidth</STRONG>
- option is used in its place.
- <P></P>
- <DT><STRONG><A NAME="item_Name%3A_width">Name: <STRONG>width</STRONG></A></STRONG><BR>
- <DD>
- <DT><STRONG><A NAME="item_Class%3A_Width">Class: <STRONG>Width</STRONG></A></STRONG><BR>
- <DD>
- <DT><STRONG><A NAME="item_Switch%3A_%2Dwidth">Switch: <STRONG>-width</STRONG></A></STRONG><BR>
- <DD>
- Specifies the desired narrow dimension of the scrollbar window,
- not including 3-D border, if any. For vertical
- scrollbars this will be the width and for horizontal scrollbars
- this will be the height.
- The value may have any of the forms acceptable to <STRONG>Tk_GetPixels</STRONG>.
- <P></P></DL>
- <P>
- <HR>
- <H1><A NAME="description">DESCRIPTION</A></H1>
- <P>The <STRONG>Scrollbar</STRONG> method creates a new window (given by the
- $widget argument) and makes it into a scrollbar widget.
- Additional options, described above, may be specified on the command
- line or in the option database to configure aspects of the scrollbar
- such as its colors, orientation, and relief.
- The <STRONG>scrollbar</STRONG> command returns its $widget argument.
- At the time this command is invoked, there must not exist a window
- named $widget, but $widget's parent must exist.</P>
- <P>A scrollbar is a widget that displays two arrows, one at each end of
- the scrollbar, and a <EM>slider</EM> in the middle portion of the
- scrollbar.
- It provides information about what is visible in an <EM>associated window</EM>
- that displays an document of some sort (such as a file being edited or
- a drawing).
- The position and size of the slider indicate which portion of the
- document is visible in the associated window. For example, if the
- slider in a vertical scrollbar covers the top third of the area
- between the two arrows, it means that the associated window displays
- the top third of its document.</P>
- <P>Scrollbars can be used to adjust the view in the associated window
- by clicking or dragging with the mouse.
- See <A HREF="#bindings">BINDINGS</A> below for details.</P>
- <P>
- <HR>
- <H1><A NAME="elements">ELEMENTS</A></H1>
- <P>A scrollbar displays five elements, which are referred to in the
- methods for the scrollbar:</P>
- <DL>
- <DT><STRONG><A NAME="item_arrow1"><STRONG>arrow1</STRONG></A></STRONG><BR>
- <DD>
- The top or left arrow in the scrollbar.
- <P></P>
- <DT><STRONG><A NAME="item_trough1"><STRONG>trough1</STRONG></A></STRONG><BR>
- <DD>
- The region between the slider and <STRONG>arrow1</STRONG>.
- <P></P>
- <DT><STRONG><A NAME="item_slider"><STRONG>slider</STRONG></A></STRONG><BR>
- <DD>
- The rectangle that indicates what is visible in the associated widget.
- <P></P>
- <DT><STRONG><A NAME="item_trough2"><STRONG>trough2</STRONG></A></STRONG><BR>
- <DD>
- The region between the slider and <STRONG>arrow2</STRONG>.
- <P></P>
- <DT><STRONG><A NAME="item_arrow2"><STRONG>arrow2</STRONG></A></STRONG><BR>
- <DD>
- The bottom or right arrow in the scrollbar.
- <P></P></DL>
- <P>
- <HR>
- <H1><A NAME="widget methods">WIDGET METHODS</A></H1>
- <P>The <STRONG>Scrollbar</STRONG> method creates a widget object.
- This object supports the <STRONG>configure</STRONG> and <STRONG>cget</STRONG> methods
- described in <A HREF="../../../site/lib/Tk/options.html">the Tk::options manpage</A> which can be used to enquire and
- modify the options described above.
- The widget also inherits all the methods provided by the generic
- <A HREF="../../../site/lib/Tk/Widget.html">Tk::Widget</A> class.</P>
- <P>The following additional methods are available for scrollbar widgets:</P>
- <DL>
- <DT><STRONG><A NAME="item_activate"><EM>$scrollbar</EM>-><STRONG>activate</STRONG>(?<EM>element</EM>?)</A></STRONG><BR>
- <DD>
- Marks the element indicated by <EM>element</EM> as active, which
- causes it to be displayed as specified by the <STRONG>activeBackground</STRONG>
- and <STRONG>activeRelief</STRONG> options.
- The only element values understood by this command are <STRONG>arrow1</STRONG>,
- <STRONG>slider</STRONG>, or <STRONG>arrow2</STRONG>.
- If any other value is specified then no element of the scrollbar
- will be active.
- If <EM>element</EM> is not specified, the command returns
- the name of the element that is currently active, or an empty string
- if no element is active.
- <P></P>
- <DT><STRONG><A NAME="item_delta"><EM>$scrollbar</EM>-><STRONG>delta</STRONG>(<EM>deltaX, deltaY</EM>)</A></STRONG><BR>
- <DD>
- Returns a real number indicating the fractional change in
- the scrollbar setting that corresponds to a given change
- in slider position. For example, if the scrollbar is horizontal,
- the result indicates how much the scrollbar setting must change
- to move the slider <EM>deltaX</EM> pixels to the right (<EM>deltaY</EM> is
- ignored in this case).
- If the scrollbar is vertical, the result indicates how much the
- scrollbar setting must change to move the slider <EM>deltaY</EM> pixels
- down. The arguments and the result may be zero or negative.
- <P></P>
- <DT><STRONG><A NAME="item_fraction"><EM>$scrollbar</EM>-><STRONG>fraction</STRONG>(<EM>x, y</EM>)</A></STRONG><BR>
- <DD>
- Returns a real number between 0 and 1 indicating where the point
- given by <EM>x</EM> and <EM>y</EM> lies in the trough area of the scrollbar.
- The value 0 corresponds to the top or left of the trough, the
- value 1 corresponds to the bottom or right, 0.5 corresponds to
- the middle, and so on.
- <EM>X</EM> and <EM>y</EM> must be pixel coordinates relative to the scrollbar
- widget.
- If <EM>x</EM> and <EM>y</EM> refer to a point outside the trough, the closest
- point in the trough is used.
- <P></P>
- <DT><STRONG><A NAME="item_get"><EM>$scrollbar</EM>-><STRONG>get</STRONG></A></STRONG><BR>
- <DD>
- Returns the scrollbar settings in the form of a list whose
- elements are the arguments to the most recent <STRONG>set</STRONG> method.
- <P></P>
- <DT><STRONG><A NAME="item_identify"><EM>$scrollbar</EM>-><STRONG>identify</STRONG>(<EM>x, y</EM>)</A></STRONG><BR>
- <DD>
- Returns the name of the element under the point given by <EM>x</EM> and
- <EM>y</EM> (such as <STRONG>arrow1</STRONG>), or an empty string if the point does
- not lie in any element of the scrollbar.
- <EM>X</EM> and <EM>y</EM> must be pixel coordinates relative to the scrollbar
- widget.
- <P></P>
- <DT><STRONG><A NAME="item_set"><EM>$scrollbar</EM>-><STRONG>set</STRONG>(<EM>first, last</EM>)</A></STRONG><BR>
- <DD>
- This command is invoked by the scrollbar's associated widget to
- tell the scrollbar about the current view in the widget.
- The command takes two arguments, each of which is a real fraction
- between 0 and 1.
- The fractions describe the range of the document that is visible in
- the associated widget.
- For example, if <EM>first</EM> is 0.2 and <EM>last</EM> is 0.4, it means
- that the first part of the document visible in the window is 20%
- of the way through the document, and the last visible part is 40%
- of the way through.
- <P></P></DL>
- <P>
- <HR>
- <H1><A NAME="scrolling commands">SCROLLING COMMANDS</A></H1>
- <P>When the user interacts with the scrollbar, for example by dragging
- the slider, the scrollbar notifies the associated widget that it
- must change its view.
- The scrollbar makes the notification by evaluating a callback
- specified as the scrollbar's <STRONG>-command</STRONG> option.
- The callback may take several forms.
- In each case, the intial arguments passed are those
- specified in the <STRONG>-command</STRONG> callback itself,
- which usually has a form like [<STRONG>yview</STRONG> => <EM>$widget</EM>].
- (Which will invoke <EM>$widget</EM>-><STRONG>yview</STRONG>(...) where
- the ... part is as below. See <A HREF="../../../site/lib/Tk/callbacks.html">the Tk::callbacks manpage</A> for details.)
- The callback is passed additional arguments as follows:</P>
- <DL>
- <DT><STRONG><A NAME="item_moveto%2Cfraction"><STRONG>moveto</STRONG>,<EM>fraction</EM></A></STRONG><BR>
- <DD>
- <EM>Fraction</EM> is a real number between 0 and 1.
- The widget should adjust its view so that the point given
- by <EM>fraction</EM> appears at the beginning of the widget.
- If <EM>fraction</EM> is 0 it refers to the beginning of the
- document. 1.0 refers to the end of the document, 0.333
- refers to a point one-third of the way through the document,
- and so on.
- <P></P>
- <DT><STRONG><A NAME="item_scroll%2Cnumber%2Cunits"><STRONG>scroll,</STRONG><EM>number,</EM><STRONG>units</STRONG></A></STRONG><BR>
- <DD>
- The widget should adjust its view by <EM>number</EM> units.
- The units are defined in whatever way makes sense for the widget,
- such as characters or lines in a text widget.
- <EM>Number</EM> is either 1, which means one unit should scroll off
- the top or left of the window, or -1, which means that one unit
- should scroll off the bottom or right of the window.
- <P></P>
- <DT><STRONG><A NAME="item_scroll%2Cnumber%2Cpage"><STRONG>scroll</STRONG>,<EM>number</EM>,<STRONG>page</STRONG></A></STRONG><BR>
- <DD>
- The widget should adjust its view by <EM>number</EM> pages.
- It is up to the widget to define the meaning of a page; typically
- it is slightly less than what fits in the window, so that there
- is a slight overlap between the old and new views.
- <EM>Number</EM> is either 1, which means the next page should
- become visible, or -1, which means that the previous page should
- become visible.
- <P></P></DL>
- <P>
- <HR>
- <H1><A NAME="old command syntax">OLD COMMAND SYNTAX</A></H1>
- <P>In versions of Tk before 4.0, the <STRONG>set</STRONG> and <STRONG>get</STRONG> widget
- commands used a different form.
- This form is still supported for backward compatibility, but it
- is deprecated.
- In the old command syntax, the <STRONG>set</STRONG> method has the
- following form:</P>
- <DL>
- <DT><STRONG><EM>$scrollbar</EM>-><STRONG>set</STRONG>(<EM>totalUnits, windowUnits, firstUnit, lastUnit</EM>)</STRONG><BR>
- <DD>
- In this form the arguments are all integers.
- <EM>TotalUnits</EM> gives the total size of the object being displayed in the
- associated widget. The meaning of one unit depends on the associated
- widget; for example, in a text editor widget units might
- correspond to lines of
- text. <EM>WindowUnits</EM> indicates the total number of units that
- can fit in the associated window at one time. <EM>FirstUnit</EM>
- and <EM>lastUnit</EM> give the indices of the first and last units
- currently visible in the associated window (zero corresponds to the
- first unit of the object).
- <P></P></DL>
- <P>Under the old syntax the <STRONG>get</STRONG> method returns a list
- of four integers, consisting of the <EM>totalUnits</EM>, <EM>windowUnits</EM>,
- <EM>firstUnit</EM>, and <EM>lastUnit</EM> values from the last <STRONG>set</STRONG>
- method.</P>
- <P>The callbacks generated by scrollbars also have a different form
- when the old syntax is being used, the callback is passed a single argument:</P>
- <DL>
- <DT><STRONG><A NAME="item_unit"><EM>unit</EM></A></STRONG><BR>
- <DD>
- <EM>Unit</EM> is an integer that indicates what should appear at
- the top or left of the associated widget's window.
- It has the same meaning as the <EM>firstUnit</EM> and <EM>lastUnit</EM>
- arguments to the <STRONG>set</STRONG> method.
- <P></P></DL>
- <P>The most recent <STRONG>set</STRONG> method determines whether or not
- to use the old syntax.
- If it is given two real arguments then the new syntax will be
- used in the future, and if it is given four integer arguments then
- the old syntax will be used.</P>
- <P>
- <HR>
- <H1><A NAME="bindings">BINDINGS</A></H1>
- <P>Tk automatically creates class bindings for scrollbars that give them
- the following default behavior.
- If the behavior is different for vertical and horizontal scrollbars,
- the horizontal behavior is described in parentheses.</P>
- <DL>
- <DT><STRONG><A NAME="item_%5B1%5D">[1]</A></STRONG><BR>
- <DD>
- Pressing button 1 over <STRONG>arrow1</STRONG> causes the view in the
- associated widget to shift up (left) by one unit so that the
- document appears to move down (right) one unit.
- If the button is held down, the action auto-repeats.
- <P></P>
- <DT><STRONG><A NAME="item_%5B2%5D">[2]</A></STRONG><BR>
- <DD>
- Pressing button 1 over <STRONG>trough1</STRONG> causes the view in the
- associated widget to shift up (left) by one screenful so that the
- document appears to move down (right) one screenful.
- If the button is held down, the action auto-repeats.
- <P></P>
- <DT><STRONG><A NAME="item_%5B3%5D">[3]</A></STRONG><BR>
- <DD>
- Pressing button 1 over the slider and dragging causes the view
- to drag with the slider.
- If the <STRONG>jump</STRONG> option is true, then the view doesn't drag along
- with the slider; it changes only when the mouse button is released.
- <P></P>
- <DT><STRONG><A NAME="item_%5B4%5D">[4]</A></STRONG><BR>
- <DD>
- Pressing button 1 over <STRONG>trough2</STRONG> causes the view in the
- associated widget to shift down (right) by one screenful so that the
- document appears to move up (left) one screenful.
- If the button is held down, the action auto-repeats.
- <P></P>
- <DT><STRONG><A NAME="item_%5B5%5D">[5]</A></STRONG><BR>
- <DD>
- Pressing button 1 over <STRONG>arrow2</STRONG> causes the view in the
- associated widget to shift down (right) by one unit so that the
- document appears to move up (left) one unit.
- If the button is held down, the action auto-repeats.
- <P></P>
- <DT><STRONG><A NAME="item_%5B6%5D">[6]</A></STRONG><BR>
- <DD>
- If button 2 is pressed over the trough or the slider, it sets
- the view to correspond to the mouse position; dragging the
- mouse with button 2 down causes the view to drag with the mouse.
- If button 2 is pressed over one of the arrows, it causes the
- same behavior as pressing button 1.
- <P></P>
- <DT><STRONG><A NAME="item_%5B7%5D">[7]</A></STRONG><BR>
- <DD>
- If button 1 is pressed with the Control key down, then if the
- mouse is over <STRONG>arrow1</STRONG> or <STRONG>trough1</STRONG> the view changes
- to the very top (left) of the document; if the mouse is over
- <STRONG>arrow2</STRONG> or <STRONG>trough2</STRONG> the view changes
- to the very bottom (right) of the document; if the mouse is
- anywhere else then the button press has no effect.
- <P></P>
- <DT><STRONG><A NAME="item_%5B8%5D">[8]</A></STRONG><BR>
- <DD>
- In vertical scrollbars the Up and Down keys have the same behavior
- as mouse clicks over <STRONG>arrow1</STRONG> and <STRONG>arrow2</STRONG>, respectively.
- In horizontal scrollbars these keys have no effect.
- <P></P>
- <DT><STRONG><A NAME="item_%5B9%5D">[9]</A></STRONG><BR>
- <DD>
- In vertical scrollbars Control-Up and Control-Down have the same
- behavior as mouse clicks over <STRONG>trough1</STRONG> and <STRONG>trough2</STRONG>, respectively.
- In horizontal scrollbars these keys have no effect.
- <P></P>
- <DT><STRONG><A NAME="item_%5B10%5D">[10]</A></STRONG><BR>
- <DD>
- In horizontal scrollbars the Up and Down keys have the same behavior
- as mouse clicks over <STRONG>arrow1</STRONG> and <STRONG>arrow2</STRONG>, respectively.
- In vertical scrollbars these keys have no effect.
- <P></P>
- <DT><STRONG><A NAME="item_%5B11%5D">[11]</A></STRONG><BR>
- <DD>
- In horizontal scrollbars Control-Up and Control-Down have the same
- behavior as mouse clicks over <STRONG>trough1</STRONG> and <STRONG>trough2</STRONG>, respectively.
- In vertical scrollbars these keys have no effect.
- <P></P>
- <DT><STRONG><A NAME="item_%5B12%5D">[12]</A></STRONG><BR>
- <DD>
- The Prior and Next keys have the same behavior
- as mouse clicks over <STRONG>trough1</STRONG> and <STRONG>trough2</STRONG>, respectively.
- <P></P>
- <DT><STRONG><A NAME="item_%5B13%5D">[13]</A></STRONG><BR>
- <DD>
- The Home key adjusts the view to the top (left edge) of the document.
- <P></P>
- <DT><STRONG><A NAME="item_%5B14%5D">[14]</A></STRONG><BR>
- <DD>
- The End key adjusts the view to the bottom (right edge) of the document.
- <P></P></DL>
- <P>
- <HR>
- <H1><A NAME="see also">SEE ALSO</A></H1>
- <P><A HREF="../../../site/lib/Tk/callbacks.html">Tk::callbacks</A>
- <A HREF="../../../site/lib/Tk/Scrolled.html">Tk::Scrolled</A></P>
- <P>
- <HR>
- <H1><A NAME="keywords">KEYWORDS</A></H1>
- <P>scrollbar, widget</P>
- <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
- <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
- <STRONG><P CLASS=block> Tk::Scrollbar - Create and manipulate Scrollbar widgets</P></STRONG>
- </TD></TR>
- </TABLE>
-
- </BODY>
-
- </HTML>
-