Copyright © 2008, 2009 Arndt Roger Schneider
Labels and message windows are the most obvious controls for hijacking. They are also the only controls under AQUA®, which require a textured background.
The hijacking, of labels and messages, does work with vanilla Tk (text is used). I do, however, recommend to install TkPath for Tk 8.4 under X Window System. TkPath will provide anti-aliasing under X Window System for labels.
Messages won’t be rendered through TkPath. They are usually multi-line text, which can’t be done right away with TkPath.
A label, intended for hijacking, shall not contain any carriage return or line feed characters whatsoever.
Hijacked windows must not contain multi-line text, unless it is explicit allowed. Messages, for example, will always accept multi-line text.
Example 6.3. Hijacking a Message
pack [message .toplevel.message \ -justify center \ -text { This is a typical message. Containing a paragraph.}] \ -side top -fill x ... # Here the message is hijacked. .toplevel.stripes hijackwindow \ .toplevel.message
Each window must be visible when hijacked. That is, each call to »hijackwindow« has to be performed in response to a »<Map>« event. This is also required to gain acceptable performance. The hijacking is thus broken in smaller chunks, which can be performed without slowing down the Graphical User Interface at all.
Example 6.4. Use The Map Event for hijacking
bind .toplevel <Map> { after idle { foreach child { .toplevel.message ... } { %W.stripes hijackwindow $child } bind %W <Configure> { after idle { foreach child { .toplevel.message ... } { %W.stripes hijackwindow \$child } } } } }
The Example 6.4, “Use The Map Event for hijacking” contains an additional binding for the configure event on the container window (in this example a toplevel). The configure event must be processed geometry changes.
The hijacking of labels is identical to messages.
Labels may feature multi-line text. The »justify« property will be used to align the successive lines. I recommend using »messages« for multi-line text. Labels should be used for descriptions and not to display verbose informations.
Gstripes ignores labels and messages, whenever their background colour differs from that of the »stripes« window. If a message or label contains an image it will be ignored, too. »Hijackwindow« then returns without doing anything at all.
The window is lowered behind the stripes–enslaved by its hijacker–, after hijacking. This disrupts the window Z-Order and thus the focus ring is in disarray.