The Figure 11.7, “Global Filters” , presents a customization dialog dedicated to the Inspector. Global Filters are categorized according to the Inspector sections.
Sections
Properties, of Items, Styles, Gradients, Images and Windows.
Geometry, size, position and coordinates of Items and Windows.
Published, the interface definition; these section contains the same entries as »Properties«.
Global Filters are disabled for event handlers. It does not make sense to use global filters for events.
The filter entries are regular expressions. The filter entry »Button (.*)ground« matches all properties ending with »ground« for the window class »Button«. The Gistbox in the left matches entries for any class.
Global Filters features a less frequent used section hidden in the bottom. The entries in the hidden part renders properties in the Inspector read-only. See also Figure 4.6, “Read-only Properties”.
Entries, in the global filters, are excluded from the Inspector, the entries are out-filtered. The filter has a negative working mechanism.
A filtered property can be simultaneously disabled globally, disabled for a window class, read-only globally and read-only for a window class.
Any Inspector window may have its own filter set. This filter set is called a »Local Filter«. Local Filters have a positive working mechanism. Any entry in a local filter appears inside the Inspector, everything else is out-filtered. See also Figure 9.3, “Local Filter”.
Normally both local and the section called “Global Filters” are used at the same time. Here the local filter is applied after the the section called “Global Filters”. This behavior can be changed through the Inspector context menu to the right side of the tabset. Where the menu entry »Disable Global Filters« disables the the section called “Global Filters” for this Inspector. After which the local filter is the sole used filter.
Each Inspector section uses its own local filter! Re-calling »Customize Local Filter« after selecting another section, actualizes the local filter dialog. In addition, the new section is listed in the dialog’s title bar.
The Tcl-Script tcledit.tcl
defines
the context menus for properties. There are two
types of context entries: »default« and »history«.
A set of default entries is a fixed, no other entry
is ever being added to this context set.
A set of history entries will expand while
working with the Inspector.
Example 11.7. Scale Default Set in tcledit.tcl
Scale { -orient {horizontal vertical} -showvalue {1 0} -sliderrelief {raised sunken flat groove ridge} }
Example 11.7, “Scale Default Set in tcledit.tcl” displays the fixed entries for certain »scale« properties. No other values are permitted for these properties.
Example 11.8. History Set in tcledit.tcl
-fillcolor { {=axial 90|red;45|black;100} {=axial -45|gold;100|white;100} {=radial 0 0|red;45|blue;100} {=radial 10 50|black;50|white;50} {seagreen;50} {red;20} {white;20} }
Example 11.8, “History Set in tcledit.tcl” displays a series of »-fillcolor« values for a TkZinc 3.3.4 object. A history set is open and expands whenever a new entry is specified inside the Inspector.
History and default and are active inside the shell. »$w history -background« will report the history values for the »background« property. »$w default -relief« reports the default entries for the »relief« property.
Sub Editors are accessible through the ellipsis »...« button to the right of the active property.
Sub Editor Types:
For flow-text, such as captions, text, commands and Event Handlers.
Colour editor, for colour properties. The colour editor varies on different platforms. The best of its kind is the AQUA® standard colour dialog.
File browsers for photo and bitmap selection.
Font selection and creation dialog, registered on font properties.
There is a special DocBook paragraph editor, which appears when an previously undocumented property gets created inside current interface. A screen-shot is presented in Figure 9.4, “Interface DocBook Editor”.
Every property inside the Inspector features a sub editor. The fall-back sub editor simply repeats the the section called “Property Context Menus”.
Example 11.9. The Default Sub Editor
proc useDefault { w def } { set attribute [$w cget -name]; set project [set [$w cget -intvar]]; set window [lindex [set [$w cget -widvar]] 0]; set l {}; # Query for the default values: set l [$project eval \ [list do $window default \ -$attribute]]; if ![string compare {} $l] { # Query for the history: set l [$project eval \ [list do $window history \ -$attribute]]; } # Nothing, bypass the sub editor: if ![string compare {} $l] { return $def; } # Display either history or default values: return [sublist $w.subeditor $def $l]; }
Conditions are script evaluated for a given property and category. There are two ways to assign a condition for a property: Directly for the property, and as a regular expression.
There is currently no Graphical User Interface for customizing conditions. Conditions are assigned via the global settings.
Example 11.10. Transparent Colour Condition
proc condColor { base value } { if { 2 == [llength $value] } { rtl::seteach { color opaque } $value set window \ [lindex [set [$base get-widvar]] 0] # Retrieve parent window: set p \ [[$base getInterp] eval \ winfo parent $window] # Parent color: set background \ [[$base getInterp] eval \ $p cget -background] # Mix parent color and »color«. $base set-option \ [rtl::mixColors $color \ $opaque $background] } }
The condition, presented in Example 11.10, “Transparent Colour Condition” expects two terms as a colour definition in »value«; the first term is the colour. The second term is the opacity of said colour. The condition queries for the parent window’s »background« colour and mixes both colours according to the opacity value. The entry inside the Inspector is then altered and the calculated colour applied.
The Example 11.10, “Transparent Colour Condition” is registered for »(.*)ground$« and »(.*)color$« inside the »Configure« category. Example 11.11, “Transparent Colour Registration” explains how the condition is registered.
Example 11.11. Transparent Colour Registration
set inspector "settings,Appearance,Inspector" set conditions "$inspector,Conditions" set category "$conditions,Configure" foreach expression { (.*)ground$ (.*)color$ } { set ::rat($category,$expression) \ {condColor %s {%s}} }
Another condition is registered for images. The image condition test whether a specified Tk image does already exist, and opens a file browser if it does not yet exist.