<manpage cat="misc" id="tile-intro" title="intro" version="0.2">
<!-- This file was automatically generated.  DO NOT EDIT (yet)! -->
<!-- 
     Copyright (c) 2004 Joe English
 -->
<?TROFF.TH title="intro" section="n" date="0.2" source="tile" manual="Tile Widget Set" ?>
<namesection>
<name>tile_intro</name>
<desc>Introduction to the Tile theme engine</desc>
</namesection>
<section>
<title>OVERVIEW</title>
<p>The tile widget set is based on a revised and enhanced version
of the 
<ref href="http://purl.org/tcl/tip/48">TIP #48
</ref>style engine.
The main concepts are described below.
The basic idea is to separate, to the extent possible,
the code implementing a widget's behavior from
the code implementing its appearance.
Widget class bindings are primarily responsible for
maintaining the widget state and invoking callbacks;
all aspects of the widgets appearance is
</p>
</section>
<section>
<title>THEMES</title>
<p>A <i>theme</i> is a collection of elements and styles 
that determine the look and feel of the widget set.
Themes can be used to:
</p>
<ul>
<li>Isolate platform differences (X11 vs. classic Windows vs. XP vs. Aqua ...)
</li>
<li>Adapt to display limitations (low-color, grayscale, monochrome, tiny screens)
</li>
<li>Accessibility (high contrast, large type)
</li>
<li>Application suite branding
</li>
<li>Blend in with the rest of the desktop (Gnome, KDE, Java)
</li>
<li>And, of course: eye candy.
</li>
</ul>
</section>
<section>
<title>ELEMENTS</title>
<p>An <i>element</i> displays an individual part of a widget.
For example, a vertical scrollbar widget contains <b>uparrow</b>,
<b>downarrow</b>, <b>trough</b> and <b>slider</b> elements.
</p>
<p>Element names use a recursive dotted notation.
For example, <b>uparrow</b> identifies a generic arrow element,
and <b>Scrollbar.uparrow</b> and <b>Combobox.uparrow</b> identify 
widget-specific elements.
When looking for an element, the style engine looks for
the specific name first, and if an element of that name is
not found it looks for generic elements by stripping off
successive leading components of the element name.
</p>
<p>Like widgets, elements have <i>options</i> which
specify what to display and how to display it.
For example, the <b cat="AMBIGUOUS widget canvasitemtype cmd">text</b> element 
(which displays a text string) has
<b>-text</b>, <b>-font</b>, <b>-foreground</b>, <b>-background</b>, 
<b>-underline</b>, and <b>-width</b> options.
The value of an element option is taken from:
</p>
<ul>
<li>An option of the same name and type in the widget containing the element;
</li>
<li>A dynamic setting specified by <b>style map</b> and the current state;
</li>
<li>The default setting specified by <b>style configure</b>; or
</li>
<li>The element's built-in default value for the option.
</li>
</ul>
</section>
<section>
<title>LAYOUTS</title>
<p>A <i>layout</i> specifies which elements make up a widget
and how they are arranged.
The layout engine uses a simplified version of the <cmd>pack</cmd>
algorithm: starting with an initial cavity equal to the size
of the widget, elements are allocated a parcel within the cavity along
the side specified by the <b>-side</b> option,
and placed within the parcel according to the <b>-sticky</b>
option.
For example, the layout for a horizontal scrollbar 
</p>
<example>
ttk::style layout Horizontal.TScrollbar {
    Scrollbar.trough -children {
	Scrollbar.leftarrow -side left -sticky w
	Scrollbar.rightarrow -side right -sticky e
	Scrollbar.thumb -side left -expand true -sticky ew
    }
}
</example>
<p>By default, the layout for a widget is the same as its class name.
Some widgets may override this (for example, the <b>ttk::scrollbar</b>
widget chooses different layouts based on the <b>-orient</b> option).
</p>
</section>
<section>
<title>STATES</title>
<p>In standard Tk, many widgets have a <b>-state</b> option
which (in most cases) is either <b>normal</b> or <b>disabled</b>.
Some widgets support additional states, such
as the <b cat="AMBIGUOUS widget cmd">entry</b> widget which has a <b>readonly</b> state
and the various flavors of buttons which have <b>active</b> state.
</p>
<p>The Tile widget set generalizes this idea:
every widget has a bitmap of independent state flags.
Widget state flags include <b>active</b>, <b>disabled</b>,
<b>pressed</b>, <cmd>focus</cmd>, etc., 
(see <i>widget(n)</i> for the full list of state flags).
</p>
<p>Instead of a <b>-state</b> option, every widget now has 
a <b>state</b> widget command which is used to set or query
the state.
A <i>state specification</i> is a list of symbolic state names
indicating which bits are set, each optionally prefixed with an 
exclamation point indicating that the bit is cleared instead.
</p>
<p>For example, the class bindings for the <b>ttk::button</b>
widget are:
</p>
<example>
bind TButton &lt;Enter&gt;		{ %W state active }
bind TButton &lt;Leave&gt;		{ %W state !active }
bind TButton &lt;ButtonPress-1&gt;	{ %W state pressed }
bind TButton &lt;Button1-Leave&gt;	{ %W state !pressed }
bind TButton &lt;Button1-Enter&gt;	{ %W state pressed }
bind TButton &lt;ButtonRelease-1&gt;	\
    { %W instate {pressed} { %W state !pressed ; %W invoke } }
</example>
<p>This specifies that the widget becomes <b>active</b> when
the pointer enters the widget, and inactive when it leaves.
Similarly it becomes <b>pressed</b> when the mouse button is pressed,
and <b>!pressed</b> on the ButtonRelease event.
In addition, the button unpresses if 
pointer is dragged outside the widget while Button-1 is held down,
and represses if it's dragged back in.
Finally, when the mouse button is released, the widget's
<b>-command</b> is invoked, but only if the button is currently
in the <b>pressed</b> state.
(The actual bindings are a little more complicated than the above,
but not by much).
</p>
<p><i>Note to self: rewrite that paragraph.  It's horrible.</i>
</p>
</section>
<section>
<title>STYLES</title>
<p>Each widget is associated with a <i>style</i>, 
which specifies values for element options.
Style names use a recursive dotted notation like layouts and elements;
by default, widgets use the class name to look up a style in the current theme.
For example:
</p>
<example>
ttk::style configure TButton \
	-background #d9d9d9 \
	-foreground black \
	-relief raised \
	;
</example>
<p>Many elements are displayed differently depending on the widget state.  
For example, buttons have a different background when they are active,
a different foreground when disabled, and a different relief when pressed.
The <b>style map</b> command specifies dynamic option settings
for a particular style:
</p>
<example>
ttk::style map TButton \
	-background [list disabled #d9d9d9  active #ececec] \
	-foreground [list disabled #a3a3a3] \
	-relief [list {pressed !disabled} sunken] \
	;
</example>
</section>
<seealso>
<ref>widget(n)</ref>
<ref>style(n)</ref>
<ref></ref>
<ref href="http://purl.org/tcl/tip/48">TIP #48
</ref>
</seealso>
</manpage>
