Themes


Typedefs

typedef bool(* fltk::Theme )()

Functions

bool fltk_theme ()
void fltk::load_theme ()
void fltk::reload_theme ()
bool fltk::reset_theme ()
void fltk::theme (Theme f)
Theme fltk::theme ()

Variables

Theme theme_

Typedef Documentation

Theme
 

A Theme is a function called by fltk just before it shows the first window, and also whenever it receives a signal from the operating system that the user's preferences have changed.

The Theme's job is to set all the NamedStyle structures to the correct values for the appearance selected by the user and operating system.

The return value is ignored but you should return true for future compatability.

This pointer is declared as a "C" function to make it easier to load the correct function by name from a plugin, if you would like to write a scheme where the appearance is controlled by plugins. Fltk provides a convienence function to portably load plugins called fltk::load_plugin() that you may want to use if you are writing such a system.


Function Documentation

theme  )  [inline]
 

Returns the current Theme function. By default this points at fltk_theme().

theme Theme  f  )  [inline]
 

Change what function fltk should call to set the appearance. If you change this after any windows may have been shown, you should call reload_theme().

void load_theme  ) 
 

Call the theme() function if it has not already been called. Normally FLTK calls this just before the first Window::show() is done. You need to call this earlier to execute code such as measuring labels that may depend on the theme.

void reload_theme  ) 
 

Does nothing if load_theme() has not been called yet. If load_theme() has been called, this calls the theme() function again and then call redraw(). If the theme function is written correctly, this should change the display to the new theme. You should call this if you change the theme() or if external information changes such that the result of your theme() function changes.

FLTK will call this automatically when it gets a message from the system indicating the user's preferences have changed.

bool reset_theme  ) 
 

Change the theme to the compiled-in default by calling the revert function of all NamedStyle structures. A theme() function may want to call this to clear the previous settings.

bool fltk_theme  ) 
 

This is the default value of fltk::theme().

This is declared as a "C" function to allow it to be replaced with a function from a loaded plugin. If you are statically linking fltk you can also override this by declaring a fltk_theme() function in your own code (some Unix systems, but not Linux, will do this even if fltk is a shared library).

Unix/Linux/X11:

This attempts to read information from the KDE files "~/.kde/share/config/kdeglobals" and "/usr/share/config/kdeglobals". If these exist it also installs an event handler to listen for KDE style-change events and call fltk::reload_theme() on them. Fltk does not even bother trying to look at the xrdb databases, nobody seems to use that any more.

Windows:

On Windows it will read colors and fonts using GetSysColor() and SystemParametersInfo(). FLTK will call fltk::reload_theme() when a WM_SYSCOLORCHANGE, WM_DISPLAYCHANGE, or WM_SETTINGCHANGE event happens, even if you replace fltk_theme(), so your replacement should be prepared for this.


Sun May 8 21:48:57 2005. FLTK ©2004 Bill Spitzak and others. See Main Page for details.