Version 3 of Themes

Updated 2002-05-23 12:00:51

[Explain what themes are.]

[People often think of them in terms of Qt and/or Gtk+ implementations.]

[Explain how BLT supports themes now]


FB -- Quick glossary (in no special order):

Skin
custom image covering whole or part of a graphical interface (ie a whole widget hierarchy below the same toplevel window).
Tile
image pattern usually repeated horizontaly and verticaly over the background of a widget.
Element
part of a widget (eg a checkbox mark or a scrollbar arrow), usually active.
Icon
small picture associated with a given action or widget.
Style
the visual appearance of a widget. May include colors, skins, tiles, border drawing style (Windows, Motif...), element pictures.
Theme
a collection of graphical elements giving a consistent appearance to a whole widget hierarchy, application, or desktop. A theme is usually made of icons, colors, fonts, widget style, or even desktop background and sounds.

Whatever happened to the 'theme' TIP#48 ? Is that in limbo or actually going to happen?


FB -- Qt [L1 ] and GTK+ [L2 ] both support styles in their current versions. Styles seem to be implemented in a similar fashion by both toolkits: they define a set of common elements (arrows, checkmarks...) and associate each with one or several API calls.

Qt defines a generic QStyle class [L3 ] which is the base class for all styles (Windows, Motif...). QStyle-derived classes implement a number of virtual member methods, each being used to draw or compute the geometry of the many elements. Thanks to polymorphism, widgets can then use any style derived from this base class.

GTK+ seems to work in a similar fashion, if I understand clearly their so-called online documentation ([L4 ] for GTK+ 1.2 and [L5 ] for GTK+ 2.0). IMHO it seems incredibly poor for such a widely used toolkit. A bare collection of uncommented forward declarations. If I were in a bad mood I'd say it sucks so much it could lift steel plates, but I digress ;-) (If I've missed the real doc, someone please point me to the right place)

Contrary to the C++ -based Qt that defines a class gathering all style-related methods, GTK+ is C-based and defines individual procedures (eg. gtk_draw_slider). But overall, both use the same model: a predefined (albeit potentially extensible) set of elements, and associated overloadable methods/procs.


FB -- My feeling is that themes support is implemented in a very monolithic way by both Qt and GTK+. Only predefined elements can be themed, and widgets can't define their own new elements. Furthermore, any change to the core (eg. adding a new element) implies:

  • For QT, adding new member method to the QStyle class and thus a complete recompilation of all applications.
  • For GTK+, adding new API procedures. Recompilation may be needed, but not in a pathological way, as procedures need not be defined and/or implemented in a single place (a C+++ class).

Anyway, both methods aren't easily extensible without a break in binary compatibility, let alone dynamic script-level extensibility.

So we have two options here for extending Tk. Either we follow the Qt and GTK+ path and implement a monolithic system with predefined elements, or we define a novel, modular system that allows for new elements to be implemented (and even dynamically by loadable extensions).

The first option would be quite fast (and even easy) to implement, and may be sufficient. After all new widgets aren't implemented every day. And it seems to work fine for Qt and GTK, but I'm not sure it would fit the Tcl/Tk model.

Second option would take more time & effort, but IMHO better follows The Tcl Way better. Plus, it could make writing new widgets easier, and we know Tk is often criticized for the amount of effort needed to implement new widgets, and the lack of many widgets thereof. Most Tclers are convinced that the right way to build complex GUIs and widgets is at the script level, but that's not an excuse for making it harder at the C level ;-) Besides, we still don't have a good built-in megawidget framework.


 What: grdb
 Where: <URL: http://missoula.bigsky.net/shunter/grdb.html >
 Description: Tries to apply your gtk theme colors to Xt/Motif/Tk applications
        by setting variables based on the current them and piping them along
        with some other default files into an xrdb -merge command.
        Currently at version 0.2.4.
 Updated: 02/2000
 Contact: <URL: mailto:[email protected] >




 What: Oroborus Theme Changer
 Where: <URL: http://freshmeat.net/projects/otc/?topic_id=55 >
 Description: Tcl/Tk app for changing themes in the Oroborus window manager.
        Currently at version 1.2.
 Updated: 05/2002
 Contact: <URL: mailto:[email protected] >

 What: themeleme
 Where: <URL: http://mitglied.tripod.de/loppo/ >
 Description: Shell script for WindowMaker theme makers that eases the
        packaging of themes.  Now comes with a Tcl/Tk GUI.
 Updated: 09/1999
 Contact: <URL: mailto:[email protected] >