<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE TIP SYSTEM "http://www.tcl.tk/cgi-bin/tct/tip/tipxml.dtd">
<!-- Converted at Sat May 25 16:02:45 GMT 2013 -->
<!-- TIP AutoGenerator - written by Donal K. Fellows -->

<TIP number='186'>
<header><title>Expose the Type and Modified-State of Widget Options</title><author address="mailto:pmacdona@pdqi.com">Peter MacDonald</author><author address="mailto:peter@pdqi.com">Peter MacDonald</author><status type='project' state='draft' tclversion="8.7" vote='prior'>$Revision: 1.4 $</status><history></history><created day='16' month='apr' year='2004' /><keyword>Tk</keyword></header>
<abstract>This TIP adds a 6th (and 7th element) to each option in the output of [<emph style="italic">path</emph> <emph style="bold">configure</emph>] for Tk widgets, indicating the type and modified status of each option respectively.</abstract>
<body><section title="Rationale">
<para>The configure subcommand of Tk widgets provides a powerful method for introspection of widget state information. Unfortunately, two important pieces of information are currently unavailable. Namely, the type Tk is expecting for an option and the whether a user has explicitly assigned a value.</para>
<para>The type field is valuable in automating interfaces for editing the contents of widgets.</para>
<para>The modified field is useful in changing styles (such as in <emph style="bold">tk_setPalette</emph>) where we update all widgets that are currently using default values.</para>
</section>
<section title="Specification">
<para>The configure subcommand for Tk widgets, when invoked with no arguments, currently dumps out all options as a list with 5 elements per-option: optName, dbName, dbClass, defValue, optValue. This TIP proposes adding up to 2 additional values: <emph style="bold">optType</emph> and <emph style="bold">optModified</emph>.</para>
<itemize><item.i><para>A 6th element, <emph style="bold">optType</emph>, is a string representation of the type field of <emph style="bold">Tk_ConfigSpec</emph> and <emph style="bold">Tk_OptionSpec</emph>.</para></item.i><item.i><para>For widgets using the new <emph style="bold">Tk_OptionSpec</emph>, a 7th appended element indicates whether an option has been set by the user.</para></item.i></itemize>
</section>
<section title="Notes">
<para>Perhaps <emph style="bold">optModified</emph> should be specified as an enumeration. For example:</para>
<itemize><item.i><para>1 = <emph style="bold">USER_MODIFIED</emph></para></item.i><item.i><para>2 = <emph style="bold">OPTION_DATABASE</emph></para></item.i><item.i><para>3 = <emph style="bold">SYSTEM_DEFAULT</emph></para></item.i><item.i><para>4 = <emph style="bold">TABLE_DEFAULT</emph></para></item.i></itemize>
<para>In addition, as much of the Tk core is still using <emph style="bold">Tk_ConfigSpec</emph>, would some form of compatibility interface make sense whereby a <emph style="bold">Tk_ConfigSpec</emph> could be used to dynamically produce a <emph style="bold">Tk_OptionSpec</emph>? (This last is out of the scope of this TIP.)</para>
<para>Probably also need a way to change options such that the <emph style="bold">USER_MODIFIED</emph> flag does not get set. (eg. <emph style="bold">tk_setPalette</emph>)</para>
</section>
<section title="Changes">
<para>Threre are a couple of small changes to <emph style="italic">tkConfig.c</emph> and <emph style="italic">tkOldConfig.c</emph>, plus a #define of <emph style="bold">TK_OPTION_VALUE_SET</emph> in <emph style="italic">tk.h</emph></para>
</section>
<section title="Overhead/Impact">
<para>Scripts currently exploiting introspection and depending upon a list length of 5 may break.</para>
</section>
<section title="Reference Implementation">
<para>There is a simple implementation of the above available as a patch against Tk 8.4.2[<url ref="http://pdqi.com/configure.diff.gz"/>]. It does not implement a enumerated flag for <emph style="bold">optModified</emph>, and the type string lookup is rather crude.</para>
</section>
<section title="Copyright">
<para>This document has been placed in the public domain.</para>
</section>
</body></TIP>
