NetSurf
Data Structures | Enumerations | Functions
theme.h File Reference

Window themes(interface). More...

#include <stdbool.h>
#include "oslib/osspriteop.h"
Include dependency graph for theme.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  theme_file_header
 
struct  theme
 
struct  theme_descriptor
 

Enumerations

enum  theme_style {
  THEME_STYLE_NONE = 0 , THEME_STYLE_BROWSER_TOOLBAR , THEME_STYLE_HOTLIST_TOOLBAR , THEME_STYLE_COOKIES_TOOLBAR ,
  THEME_STYLE_GLOBAL_HISTORY_TOOLBAR , THEME_STYLE_STATUS_BAR
}
 Theme styles, collecting groups of attributes for different locations. More...
 
enum  theme_element { THEME_ELEMENT_FOREGROUND , THEME_ELEMENT_BACKGROUND }
 Theme elements, which belong to styles. More...
 

Functions

void ro_gui_theme_initialise (void)
 Initialise the theme handler. More...
 
void ro_gui_theme_finalise (void)
 Finalise the theme handler. More...
 
struct theme_descriptorro_gui_theme_find (const char *leafname)
 Finds a theme from the cached values. More...
 
struct theme_descriptorro_gui_theme_get_available (void)
 Reads and caches the currently available themes. More...
 
struct theme_descriptorro_gui_theme_get_current (void)
 Returns the current theme handle, or NULL if none is set. More...
 
osspriteop_area * ro_gui_theme_get_sprites (struct theme_descriptor *descriptor)
 Returns a sprite area for use with the given theme. More...
 
int ro_gui_theme_get_style_element (struct theme_descriptor *descriptor, theme_style style, theme_element element)
 Returns an interger element from the specified theme, or the current theme if the descriptor is NULL. More...
 
bool ro_gui_theme_get_throbber_data (struct theme_descriptor *descriptor, int *frames, int *width, int *height, bool *right, bool *redraw)
 Returns details of the throbber as defined in a theme. More...
 
bool ro_gui_theme_read_file_header (struct theme_descriptor *descriptor, struct theme_file_header *file_header)
 Fills in the basic details for a descriptor from a file header. More...
 
bool ro_gui_theme_open (struct theme_descriptor *descriptor, bool list)
 Opens a theme ready for use. More...
 
bool ro_gui_theme_apply (struct theme_descriptor *descriptor)
 Applies the theme to all current windows and subsequent ones. More...
 
void ro_gui_theme_close (struct theme_descriptor *descriptor, bool list)
 Closes a theme after use. More...
 

Detailed Description

Window themes(interface).

Definition in file theme.h.

Enumeration Type Documentation

◆ theme_element

Theme elements, which belong to styles.

Enumerator
THEME_ELEMENT_FOREGROUND 
THEME_ELEMENT_BACKGROUND 

Definition at line 42 of file theme.h.

◆ theme_style

Theme styles, collecting groups of attributes for different locations.

Enumerator
THEME_STYLE_NONE 
THEME_STYLE_BROWSER_TOOLBAR 
THEME_STYLE_HOTLIST_TOOLBAR 
THEME_STYLE_COOKIES_TOOLBAR 
THEME_STYLE_GLOBAL_HISTORY_TOOLBAR 
THEME_STYLE_STATUS_BAR 

Definition at line 31 of file theme.h.

Function Documentation

◆ ro_gui_theme_apply()

bool ro_gui_theme_apply ( struct theme_descriptor descriptor)

Applies the theme to all current windows and subsequent ones.

Parameters
descriptorthe theme_descriptor to open
Returns
whether the operation was successful

Definition at line 666 of file theme.c.

References ro_gui_theme_close(), ro_gui_theme_open(), ro_toolbar_theme_update(), and theme_current.

Referenced by ro_gui_options_theme_ok(), ro_gui_theme_initialise(), and ro_gui_theme_install_apply().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_gui_theme_close()

void ro_gui_theme_close ( struct theme_descriptor descriptor,
bool  list 
)

Closes a theme after use.

Parameters
descriptorthe theme_descriptor to close
listwhether to open all themes in the list
Returns
whether the operation was successful

Definition at line 695 of file theme.c.

References theme_descriptor::next, theme_descriptor::previous, theme::sprite_area, theme_descriptor::theme, and theme::users.

Referenced by ro_gui_options_theme_free(), ro_gui_theme_apply(), and ro_gui_theme_finalise().

Here is the caller graph for this function:

◆ ro_gui_theme_finalise()

void ro_gui_theme_finalise ( void  )

Finalise the theme handler.

Definition at line 83 of file theme.c.

References ro_gui_theme_close(), ro_gui_theme_free(), theme_current, and theme_descriptors.

Here is the call graph for this function:

◆ ro_gui_theme_find()

struct theme_descriptor * ro_gui_theme_find ( const char *  leafname)

Finds a theme from the cached values.

The returned theme is only guaranteed to be valid until the next call to ro_gui_theme_get_available() unless it has been opened using ro_gui_theme_open().

Parameters
leafnamethe filename of the theme_descriptor to return
Returns
the requested theme_descriptor, or NULL if not found

Definition at line 100 of file theme.c.

References theme_descriptor::leafname, theme_descriptor::next, and theme_descriptors.

Referenced by ro_gui_options_theme_click(), ro_gui_options_theme_initialise(), ro_gui_theme_initialise(), and ro_gui_theme_install_apply().

Here is the caller graph for this function:

◆ ro_gui_theme_get_available()

struct theme_descriptor * ro_gui_theme_get_available ( void  )

Reads and caches the currently available themes.

Returns
the requested theme_descriptor, or NULL if not found

Definition at line 125 of file theme.c.

References theme_descriptor::name, theme_descriptor::next, nsoption_charp, theme_descriptor::previous, ro_gui_theme_add_descriptor(), ro_gui_theme_free(), ro_gui_theme_get_available_in_dir(), and theme_descriptors.

Referenced by ro_gui_options_theme_load(), ro_gui_theme_initialise(), and ro_gui_theme_install_apply().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_gui_theme_get_current()

struct theme_descriptor * ro_gui_theme_get_current ( void  )

Returns the current theme handle, or NULL if none is set.

Returns
The theme descriptor handle, or NULL.

Definition at line 207 of file theme.c.

References theme_current.

◆ ro_gui_theme_get_sprites()

osspriteop_area * ro_gui_theme_get_sprites ( struct theme_descriptor descriptor)

Returns a sprite area for use with the given theme.

This may return a pointer to the wimp sprite pool if a theme area isn't available.

Parameters
*descriptorThe theme to use, or NULL for the current.
Returns
A pointer to the theme sprite area.

Definition at line 221 of file theme.c.

References theme::sprite_area, theme_descriptor::theme, and theme_current.

Referenced by ro_gui_button_bar_create(), ro_gui_button_bar_rebuild(), ro_gui_throbber_create(), ro_gui_throbber_rebuild(), ro_gui_url_bar_create(), and ro_toolbar_rebuild().

Here is the caller graph for this function:

◆ ro_gui_theme_get_style_element()

int ro_gui_theme_get_style_element ( struct theme_descriptor descriptor,
theme_style  style,
theme_element  element 
)

Returns an interger element from the specified theme, or the current theme if the descriptor is NULL.

This is an attempt to abstract the theme data from its clients: it should simplify the task of expanding the theme system in the future should this be necessary to include other parts of the RISC OS GUI in the theme system.

Parameters
*descriptorThe theme to use, or NULL for the current.
styleThe style to use.
elementThe style element to return.
Returns
The requested value, or 0.

Definition at line 251 of file theme.c.

References theme_descriptor::browser_background, theme_descriptor::hotlist_background, theme_descriptor::status_background, theme_descriptor::status_foreground, theme_current, THEME_ELEMENT_BACKGROUND, THEME_ELEMENT_FOREGROUND, THEME_STYLE_BROWSER_TOOLBAR, THEME_STYLE_COOKIES_TOOLBAR, THEME_STYLE_GLOBAL_HISTORY_TOOLBAR, THEME_STYLE_HOTLIST_TOOLBAR, THEME_STYLE_NONE, and THEME_STYLE_STATUS_BAR.

Referenced by ro_gui_button_bar_rebuild(), and ro_toolbar_rebuild().

Here is the caller graph for this function:

◆ ro_gui_theme_get_throbber_data()

bool ro_gui_theme_get_throbber_data ( struct theme_descriptor descriptor,
int *  frames,
int *  width,
int *  height,
bool *  right,
bool *  redraw 
)

Returns details of the throbber as defined in a theme.

Parameters
*descriptorThe theme of interest (NULL for current).
*framesReturn the number of animation frames.
*widthReturn the throbber width.
*heightReturn the throbber height.
*rightReturn the 'locate on right' flag.
*redrawReturn the 'forcible redraw' flag.
Returns
true if meaningful data has been returned; else false.

Definition at line 325 of file theme.c.

References height, theme_descriptor::theme, theme_current, theme::throbber_frames, theme::throbber_height, theme_descriptor::throbber_redraw, theme_descriptor::throbber_right, theme::throbber_width, and width.

Referenced by ro_gui_throbber_create(), ro_gui_throbber_rebuild(), and ro_toolbar_rebuild().

Here is the caller graph for this function:

◆ ro_gui_theme_initialise()

void ro_gui_theme_initialise ( void  )

Initialise the theme handler.

Definition at line 68 of file theme.c.

References nsoption_charp, ro_gui_theme_apply(), ro_gui_theme_find(), ro_gui_theme_get_available(), and theme_descriptors.

Referenced by gui_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_gui_theme_open()

bool ro_gui_theme_open ( struct theme_descriptor descriptor,
bool  list 
)

Opens a theme ready for use.

Parameters
descriptorthe theme_descriptor to open
listwhether to open all themes in the list
Returns
whether the operation was successful

Definition at line 488 of file theme.c.

References theme_descriptor::compressed_size, theme_descriptor::decompressed_size, theme_descriptor::filename, mode, theme_descriptor::name, theme_descriptor::next, NSLOG, theme_descriptor::previous, result, ro_convert_pixels_to_os_units(), ro_warn_user(), theme::sprite_area, theme_descriptor::theme, theme::throbber_frames, theme::throbber_height, theme::throbber_width, and theme::users.

Referenced by ro_gui_options_theme_load(), and ro_gui_theme_apply().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_gui_theme_read_file_header()

bool ro_gui_theme_read_file_header ( struct theme_descriptor descriptor,
struct theme_file_header file_header 
)

Fills in the basic details for a descriptor from a file header.

The filename string is not set.

Parameters
descriptorthe descriptor to set up
file_headerthe header to read from
Returns
false for a badly formed theme, true otherwise

Definition at line 452 of file theme.c.

References theme_file_header::author, theme_descriptor::author, theme_descriptor::browser_background, theme_file_header::browser_bg, theme_descriptor::compressed_size, theme_file_header::compressed_sprite_size, theme_descriptor::decompressed_size, theme_file_header::decompressed_sprite_size, theme_descriptor::hotlist_background, theme_file_header::hotlist_bg, theme_file_header::magic_value, theme_file_header::name, theme_descriptor::name, theme_file_header::parser_version, theme_descriptor::status_background, theme_file_header::status_bg, theme_file_header::status_fg, theme_descriptor::status_foreground, theme_file_header::theme_flags, theme_descriptor::throbber_redraw, and theme_descriptor::throbber_right.

Referenced by ro_gui_theme_add_descriptor(), and theme_install_read().

Here is the caller graph for this function: