TIP #48 [http://purl.org/tcl/tip/48] provides an API to support alternative styles for Tk widgets. This TIP was implemented in March 2002 (which means that the functionality is in Tk 8.4.?), but there is very little other than the TIP itself to document how this might be used and what further work is required. ''([DKF] - Further work required includes documentation, application to existing widgets, and plenty of tests...)'' [[Various community members have mentioned that, with one example showing how this functionality is supposed to be used, they would work on extending the functionality through the toolkit.]] [JE] For an example of how the style engine can be used, see the Tile widget -- now hosted on sourceforge under the tktable project. Actually this uses a (now quite severely) modified version of the TIP 48 style engine; I've made some changes to the API based on experience using it. Changes to be detailed in a forthcoming TIP. To get the source cvs -d:pserver:anonymous@cvs.tktable.sf.net:/cvsroot/tktable co tile [PT]: Some screenshots of current ''tile'' project results are available at http://tktable.sourceforge.net/tile/ (last updated: 11-Jan-2004) For instance: [http://tktable.sourceforge.net/tile/demo-classic-50.jpg] [http://tktable.sourceforge.net/tile/demo-xp-blue-50.jpg] Note that this package supports some additional widgets -- notably a notebook and a progress bar. It would be awesome if this could also be used as the basis for a GTK/QT (Gnome/KDE) port of Tk and to improve Aqua port : Theme engine support API for GTK+ [http://www.gtk.org/~otaylor/gtk/2.0/theme-engines.html] ---- '''This section needs re-writing in the context of the tile code''' The basis of the Tk style API is to break down the Tk widgets into '''elements'''. Elements abstract objects for which an implementation may be registered with a given style engine. A style name can be used to select a set of element implementations and thus provide an alternative look to the Tk widgets. As the Tk code stands for 8.5a0, we have this styling API (in generic/tkStyle.c) but no elements. This makes the API pretty useless for now, so the first job is to implement a set of elements and rewrite the Tk widgets to do their drawing using elements. Once this is done, then it becomes simple to replace an element dynamically because of the design of the element search algorithm. To illustrate we can take the Tk [frame] widget. We can decompose this into a ''highlight'' and a ''frame'' element. Now what we actually register is an element called 'highlight'. However, what we try to use is an element called 'Frame.highlight'. If this can't be found, then the element search algorithm trims off the first word and tries again until it runs out of bits. This permits us to provide a generic implementation, and then override it for specific widgets. So it seems to me that we can create a ''generic/tkElements.c'' file which contains all the elements we need for the core widgets. Then we can add a ''win/tkElementsXP.c'' which provides an alternative implementation that uses the XP theming API (uxtheme.dll) to do the drawing. Then selecting the proper default style should permit switching between Tk and XP styles at wish. The same should be possible for Gtk or KDE too. ---- [category gui]