NetSurf
|
Window themes implementation. More...
#include <alloca.h>
#include <assert.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include "oslib/dragasprite.h"
#include "oslib/os.h"
#include "oslib/osgbpb.h"
#include "oslib/osfile.h"
#include "oslib/osfind.h"
#include "oslib/osspriteop.h"
#include "oslib/wimpspriteop.h"
#include "oslib/squash.h"
#include "oslib/wimp.h"
#include "oslib/wimpextend.h"
#include "utils/nsoption.h"
#include "utils/log.h"
#include "riscos/cookies.h"
#include "riscos/dialog.h"
#include "riscos/global_history.h"
#include "riscos/gui.h"
#include "riscos/hotlist.h"
#include "riscos/menus.h"
#include "riscos/theme.h"
#include "riscos/toolbar.h"
#include "riscos/wimp.h"
#include "riscos/wimp_event.h"
#include "riscos/wimputils.h"
Go to the source code of this file.
Functions | |
static bool | ro_gui_theme_add_descriptor (const char *folder, const char *leafname) |
Checks a theme is valid and adds it to the current list. More... | |
static void | ro_gui_theme_get_available_in_dir (const char *directory) |
Adds the themes in a directory to the global cache. More... | |
static void | ro_gui_theme_free (struct theme_descriptor *descriptor) |
Frees any unused theme descriptors. More... | |
void | ro_gui_theme_initialise (void) |
Initialise the theme handler. More... | |
void | ro_gui_theme_finalise (void) |
Finalise the theme handler. More... | |
struct theme_descriptor * | ro_gui_theme_find (const char *leafname) |
Finds a theme from the cached values. More... | |
struct theme_descriptor * | ro_gui_theme_get_available (void) |
Reads and caches the currently available themes. More... | |
struct theme_descriptor * | ro_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... | |
Variables | |
static struct theme_descriptor * | theme_current = NULL |
static struct theme_descriptor * | theme_descriptors = NULL |
Window themes implementation.
Definition in file theme.c.
|
static |
Checks a theme is valid and adds it to the current list.
folder | the theme folder |
leafname | the theme leafname |
Definition at line 357 of file theme.c.
References theme_descriptor::filename, theme_descriptor::leafname, theme_descriptor::name, theme_descriptor::next, NSLOG, theme_descriptor::previous, ro_gui_theme_read_file_header(), ro_warn_user(), and theme_descriptors.
Referenced by ro_gui_theme_get_available(), and ro_gui_theme_get_available_in_dir().
bool ro_gui_theme_apply | ( | struct theme_descriptor * | descriptor | ) |
Applies the theme to all current windows and subsequent ones.
descriptor | the theme_descriptor to open |
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().
void ro_gui_theme_close | ( | struct theme_descriptor * | descriptor, |
bool | list | ||
) |
Closes a theme after use.
descriptor | the theme_descriptor to close |
list | whether to open all themes in the list |
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().
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.
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().
leafname | the filename of the theme_descriptor to return |
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().
|
static |
Frees any unused theme descriptors.
descriptor | the theme_descriptor to free |
Definition at line 727 of file theme.c.
References theme_descriptor::filename, theme_descriptor::next, theme_descriptor::previous, theme_descriptor::theme, and theme_descriptors.
Referenced by ro_gui_theme_finalise(), and ro_gui_theme_get_available().
struct theme_descriptor * ro_gui_theme_get_available | ( | void | ) |
Reads and caches the currently available themes.
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().
|
static |
Adds the themes in a directory to the global cache.
directory | the directory to scan |
Definition at line 172 of file theme.c.
References NSLOG, ro_gui_theme_add_descriptor(), and ro_warn_user().
Referenced by ro_gui_theme_get_available().
struct theme_descriptor * ro_gui_theme_get_current | ( | void | ) |
Returns the current theme handle, or NULL if none is set.
Definition at line 207 of file theme.c.
References theme_current.
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.
*descriptor | The theme to use, or NULL for the current. |
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().
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.
*descriptor | The theme to use, or NULL for the current. |
style | The style to use. |
element | The style element to return. |
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().
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.
*descriptor | The theme of interest (NULL for current). |
*frames | Return the number of animation frames. |
*width | Return the throbber width. |
*height | Return the throbber height. |
*right | Return the 'locate on right' flag. |
*redraw | Return the 'forcible redraw' flag. |
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().
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().
bool ro_gui_theme_open | ( | struct theme_descriptor * | descriptor, |
bool | list | ||
) |
Opens a theme ready for use.
descriptor | the theme_descriptor to open |
list | whether to open all themes in the list |
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().
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.
descriptor | the descriptor to set up |
file_header | the header to read from |
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().
|
static |
Definition at line 58 of file theme.c.
Referenced by ro_gui_theme_apply(), ro_gui_theme_finalise(), ro_gui_theme_get_current(), ro_gui_theme_get_sprites(), ro_gui_theme_get_style_element(), and ro_gui_theme_get_throbber_data().
|
static |
Definition at line 59 of file theme.c.
Referenced by ro_gui_theme_add_descriptor(), ro_gui_theme_finalise(), ro_gui_theme_find(), ro_gui_theme_free(), ro_gui_theme_get_available(), and ro_gui_theme_initialise().