NetSurf
|
General RISC OS WIMP/OS library functions (implementation). More...
#include <assert.h>
#include <locale.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "oslib/colourtrans.h"
#include "oslib/os.h"
#include "oslib/osfile.h"
#include "oslib/wimp.h"
#include "oslib/wimpextend.h"
#include "oslib/wimpspriteop.h"
#include "utils/log.h"
#include "utils/utf8.h"
#include "riscos/gui.h"
#include "riscos/oslib_pre7.h"
#include "riscos/wimp.h"
#include "riscos/ucstables.h"
Go to the source code of this file.
Macros | |
#define | ro_gui_redraw_icon(w, i) xwimp_set_icon_state(w, i, 0, 0) |
Redraws an icon. More... | |
Functions | |
static void | ro_gui_wimp_cache_furniture_sizes (wimp_w w) |
Caches window furniture information. More... | |
static size_t | ro_gui_strlen (const char *str) |
RO GUI-specific strlen, for control character terminated strings. More... | |
static int | ro_gui_strncmp (const char *s1, const char *s2, size_t len) |
RO GUI-specific strncmp, for control character terminated strings. More... | |
int | ro_get_hscroll_height (wimp_w w) |
Gets the horizontal scrollbar height. More... | |
int | ro_get_vscroll_width (wimp_w w) |
Gets the vertical scrollbar width. More... | |
int | ro_get_title_height (wimp_w w) |
Gets the title bar height. More... | |
bool | ro_gui_wimp_read_eig_factors (os_mode mode, int *xeig, int *yeig) |
Reads a modes EIG factors. More... | |
void | ro_convert_os_units_to_pixels (os_coord *os_units, os_mode mode) |
Converts the supplied os_coord from OS units to pixels. More... | |
void | ro_convert_pixels_to_os_units (os_coord *pixels, os_mode mode) |
Converts the supplied os_coord from pixels to OS units. More... | |
void | ro_gui_force_redraw_icon (wimp_w w, wimp_i i) |
Forces an icon to be redrawn entirely (ie not just updated). More... | |
const char * | ro_gui_get_icon_string (wimp_w w, wimp_i i) |
Read the contents of a text or sprite icon. More... | |
void | ro_gui_set_icon_string (wimp_w w, wimp_i i, const char *text, bool is_utf8) |
Set the contents of a text or sprite icon to a string. More... | |
void | ro_gui_set_icon_integer (wimp_w w, wimp_i i, int value) |
Set the contents of an icon to a number. More... | |
void | ro_gui_set_icon_decimal (wimp_w w, wimp_i i, int value, int decimal_places) |
Set the contents of an icon to a number. More... | |
int | ro_gui_get_icon_decimal (wimp_w w, wimp_i i, int decimal_places) |
Get the contents of an icon as a number. More... | |
void | ro_gui_set_icon_selected_state (wimp_w w, wimp_i i, bool state) |
Set the selected state of an icon. More... | |
bool | ro_gui_get_icon_selected_state (wimp_w w, wimp_i i) |
Gets the selected state of an icon. More... | |
void | ro_gui_set_icon_shaded_state (wimp_w w, wimp_i i, bool state) |
Set the shaded state of an icon. More... | |
bool | ro_gui_get_icon_shaded_state (wimp_w w, wimp_i i) |
Gets the shaded state of an icon. More... | |
void | ro_gui_set_icon_deleted_state (wimp_w w, wimp_i i, bool state) |
Set the deleted state of an icon. More... | |
bool | ro_gui_get_icon_deleted_state (wimp_w w, wimp_i i) |
Gets the deleted state of an icon. More... | |
void | ro_gui_set_icon_button_type (wimp_w w, wimp_i i, int type) |
Set the button type of an icon. More... | |
void | ro_gui_set_icon_sprite (wimp_w w, wimp_i i, osspriteop_area *area, const char *name) |
Set an icon's sprite. More... | |
void | ro_gui_set_window_title (wimp_w w, const char *text) |
Set a window title. More... | |
bool | ro_gui_set_caret_first (wimp_w w) |
Places the caret in the first available icon. More... | |
osspriteop_area * | ro_gui_load_sprite_file (const char *pathname) |
Load a sprite file into memory. More... | |
bool | ro_gui_wimp_sprite_exists (const char *sprite) |
Check if a sprite is present in the Wimp sprite pool. More... | |
os_error * | ro_gui_wimp_get_sprite (const char *name, osspriteop_header **sprite) |
Locate a sprite in the Wimp sprite pool, returning a pointer to it. More... | |
bool | ro_gui_wimp_get_sprite_dimensions (osspriteop_area *area, char *sprite, int *width, int *height) |
Get the dimensions of a sprite. More... | |
void | ro_gui_user_redraw (wimp_draw *redraw, bool user_fill, os_colour user_colour) |
Performs simple user redraw for a window. More... | |
void | ro_gui_wimp_update_window_furniture (wimp_w w, wimp_window_flags bic_mask, wimp_window_flags xor_mask) |
Sets whether a piece of window furniture is present for a window. More... | |
bool | ro_gui_wimp_check_window_furniture (wimp_w w, wimp_window_flags mask) |
Checks whether a piece of window furniture is present for a window. More... | |
void | ro_gui_scroll (wimp_scroll *scroll) |
Generic window scroll event handler. More... | |
Variables | |
static wimpextend_furniture_sizes | furniture_sizes |
static wimp_w | furniture_window = NULL |
General RISC OS WIMP/OS library functions (implementation).
Definition in file wimp.c.
#define ro_gui_redraw_icon | ( | w, | |
i | |||
) | xwimp_set_icon_state(w, i, 0, 0) |
void ro_convert_os_units_to_pixels | ( | os_coord * | os_units, |
os_mode | mode | ||
) |
Converts the supplied os_coord from OS units to pixels.
os_units | values to convert |
mode | mode to use EIG factors for, or -1 for current |
Definition at line 151 of file wimp.c.
References mode, and ro_gui_wimp_read_eig_factors().
Referenced by ro_gui_buffer_open().
void ro_convert_pixels_to_os_units | ( | os_coord * | pixels, |
os_mode | mode | ||
) |
Converts the supplied os_coord from pixels to OS units.
pixels | values to convert |
mode | mode to use EIG factors for, or -1 for current |
Definition at line 167 of file wimp.c.
References mode, and ro_gui_wimp_read_eig_factors().
Referenced by ro_gui_theme_open(), ro_gui_url_bar_icon_resize(), ro_gui_wimp_get_sprite_dimensions(), ro_textarea_set_caret(), and ro_textarea_set_caret_xy().
int ro_get_hscroll_height | ( | wimp_w | w | ) |
Gets the horizontal scrollbar height.
w | the window to read (or NULL to read a cached value) |
Definition at line 58 of file wimp.c.
References furniture_sizes, and ro_gui_wimp_cache_furniture_sizes().
Referenced by gui_window_set_extent(), ro_gui_status_bar_resize(), ro_gui_window_open(), and ro_textarea_update().
int ro_get_title_height | ( | wimp_w | w | ) |
Gets the title bar height.
w | the window to read (or NULL to read a cached value) |
Definition at line 82 of file wimp.c.
References furniture_sizes, and ro_gui_wimp_cache_furniture_sizes().
Referenced by gui_window_set_extent().
int ro_get_vscroll_width | ( | wimp_w | w | ) |
Gets the vertical scrollbar width.
w | the window to read (or NULL to read a cached value) |
Definition at line 70 of file wimp.c.
References furniture_sizes, and ro_gui_wimp_cache_furniture_sizes().
Referenced by gui_window_create(), ro_gui_dialog_open_centre_parent(), ro_gui_dialog_open_top(), ro_gui_options_theme_initialise(), ro_gui_url_complete_resize(), ro_gui_window_open(), ro_textarea_reflow(), and ro_textarea_update().
void ro_gui_force_redraw_icon | ( | wimp_w | w, |
wimp_i | i | ||
) |
Forces an icon to be redrawn entirely (ie not just updated).
w | window handle |
i | icon handle |
Definition at line 193 of file wimp.c.
References NSLOG, and ro_warn_user().
Referenced by ro_gui_download_save(), ro_gui_throbber_animate(), and ro_gui_throbber_stop().
int ro_gui_get_icon_decimal | ( | wimp_w | w, |
wimp_i | i, | ||
int | decimal_places | ||
) |
Get the contents of an icon as a number.
w | window handle |
i | icon handle |
decimal_places | number of places to show. |
Definition at line 423 of file wimp.c.
References ro_gui_get_icon_string().
Referenced by ro_gui_options_cache_ok(), ro_gui_options_connection_ok(), ro_gui_options_fonts_ok(), ro_gui_options_security_ok(), ro_gui_wimp_event_mouse_click(), and ro_gui_wimp_event_validate().
bool ro_gui_get_icon_deleted_state | ( | wimp_w | w, |
wimp_i | i | ||
) |
Gets the deleted state of an icon.
w | window handle |
i | icon handle |
Definition at line 600 of file wimp.c.
Referenced by ro_gui_set_icon_deleted_state().
bool ro_gui_get_icon_selected_state | ( | wimp_w | w, |
wimp_i | i | ||
) |
Gets the selected state of an icon.
w | window handle |
i | icon handle |
Definition at line 463 of file wimp.c.
References NSLOG, and ro_warn_user().
Referenced by ro_gui_options_content_ok(), ro_gui_options_home_ok(), ro_gui_options_image_ok(), ro_gui_options_interface_click(), ro_gui_options_interface_ok(), ro_gui_options_security_ok(), ro_gui_options_theme_ok(), ro_gui_options_update_shading(), ro_gui_print_apply(), ro_gui_search_click(), ro_gui_search_keypress(), ro_gui_search_update_flags(), ro_gui_set_icon_selected_state(), and ro_gui_wimp_event_memorise().
bool ro_gui_get_icon_shaded_state | ( | wimp_w | w, |
wimp_i | i | ||
) |
Gets the shaded state of an icon.
w | window handle |
i | icon handle |
Definition at line 535 of file wimp.c.
Referenced by ro_gui_interactive_help_request(), ro_gui_set_icon_shaded_state(), ro_gui_wimp_event_memorise(), and ro_gui_wimp_event_ok_click().
const char * ro_gui_get_icon_string | ( | wimp_w | w, |
wimp_i | i | ||
) |
Read the contents of a text or sprite icon.
w | window handle |
i | icon handle |
If the icon contains direct text then the returned data will be invalidated by the next call to this function. Therefore, all client calls to this function must either copy the string or ensure that this function is not called again until they are finished with the string data returned.
Definition at line 235 of file wimp.c.
References NSLOG, ro_gui_strlen(), and ro_warn_user().
Referenced by ro_gui_dialog_openurl_apply(), ro_gui_dialog_zoom_apply(), ro_gui_download_click(), ro_gui_download_keypress(), ro_gui_get_icon_decimal(), ro_gui_options_connection_ok(), ro_gui_options_connection_proxy_type(), ro_gui_options_fonts_ok(), ro_gui_options_home_ok(), ro_gui_options_image_read(), ro_gui_options_interface_ok(), ro_gui_options_language_ok(), ro_gui_print_apply(), ro_gui_save_drag_end(), ro_gui_save_ok(), ro_gui_save_start_drag(), ro_gui_search_click(), ro_gui_search_keypress(), ro_gui_search_next(), ro_gui_url_bar_set_url(), ro_gui_wimp_event_memorise(), and ro_gui_wimp_event_prepare_gright_menu().
osspriteop_area * ro_gui_load_sprite_file | ( | const char * | pathname | ) |
Load a sprite file into memory.
pathname | file to load |
Definition at line 806 of file wimp.c.
References NSLOG, and ro_warn_user().
Referenced by gui_init(), and ro_gui_options_image_initialise().
void ro_gui_scroll | ( | wimp_scroll * | scroll | ) |
Generic window scroll event handler.
*scroll | Pointer to Scroll Event block. |
Definition at line 1131 of file wimp.c.
References NSLOG.
Referenced by ro_gui_handle_event().
bool ro_gui_set_caret_first | ( | wimp_w | w | ) |
Places the caret in the first available icon.
w | the window to place the caret in |
Definition at line 731 of file wimp.c.
References NSLOG, and ro_warn_user().
Referenced by print_update_sheets_shaded_state(), ro_gui_dialog_open(), ro_gui_dialog_open_persistent(), ro_gui_set_icon_deleted_state(), and ro_gui_set_icon_shaded_state().
void ro_gui_set_icon_button_type | ( | wimp_w | w, |
wimp_i | i, | ||
int | type | ||
) |
Set the button type of an icon.
w | window handle |
i | icon handle |
type | button type |
Definition at line 617 of file wimp.c.
References NSLOG, ro_warn_user(), and type.
void ro_gui_set_icon_decimal | ( | wimp_w | w, |
wimp_i | i, | ||
int | value, | ||
int | decimal_places | ||
) |
Set the contents of an icon to a number.
w | window handle |
i | icon handle |
value | value to use in icon. |
decimal_places | The number of decimal places to use. |
Definition at line 392 of file wimp.c.
References buffer, and ro_gui_set_icon_string().
Referenced by ro_gui_options_cache_click(), ro_gui_options_cache_initialise(), ro_gui_options_fonts_default(), ro_gui_options_fonts_initialise(), ro_gui_options_fonts_ok(), ro_gui_wimp_event_mouse_click(), and ro_gui_wimp_event_validate().
void ro_gui_set_icon_deleted_state | ( | wimp_w | w, |
wimp_i | i, | ||
bool | state | ||
) |
Set the deleted state of an icon.
w | window handle |
i | icon handle |
state | shaded state |
Definition at line 552 of file wimp.c.
References NSLOG, ro_gui_get_icon_deleted_state(), ro_gui_set_caret_first(), and ro_warn_user().
void ro_gui_set_icon_integer | ( | wimp_w | w, |
wimp_i | i, | ||
int | value | ||
) |
Set the contents of an icon to a number.
w | window handle |
i | icon handle |
value | value |
Definition at line 374 of file wimp.c.
References buffer, and ro_gui_set_icon_string().
Referenced by ro_gui_options_connection_default(), ro_gui_options_connection_initialise(), ro_gui_options_security_default(), ro_gui_options_security_initialise(), and ro_gui_print_prepare().
void ro_gui_set_icon_selected_state | ( | wimp_w | w, |
wimp_i | i, | ||
bool | state | ||
) |
Set the selected state of an icon.
w | window handle |
i | icon handle |
state | selected state |
Definition at line 444 of file wimp.c.
References NSLOG, ro_gui_get_icon_selected_state(), and ro_warn_user().
Referenced by ro_gui_dialog_prepare_zoom(), ro_gui_options_content_default(), ro_gui_options_content_initialise(), ro_gui_options_home_default(), ro_gui_options_home_initialise(), ro_gui_options_image_click(), ro_gui_options_image_initialise(), ro_gui_options_interface_default(), ro_gui_options_interface_initialise(), ro_gui_options_security_default(), ro_gui_options_security_initialise(), ro_gui_options_theme_click(), ro_gui_options_theme_initialise(), ro_gui_print_prepare(), ro_gui_search_keypress(), ro_gui_search_prepare(), ro_gui_wimp_event_mouse_click(), and ro_gui_wimp_event_restore().
void ro_gui_set_icon_shaded_state | ( | wimp_w | w, |
wimp_i | i, | ||
bool | state | ||
) |
Set the shaded state of an icon.
w | window handle |
i | icon handle |
state | shaded state |
Definition at line 487 of file wimp.c.
References NSLOG, ro_gui_get_icon_shaded_state(), ro_gui_set_caret_first(), and ro_warn_user().
Referenced by print_update_sheets_shaded_state(), ro_gui_button_bar_shade_button(), ro_gui_button_bar_sync_editors(), ro_gui_dialog_prepare_open_url(), ro_gui_dialog_prepare_zoom(), ro_gui_options_connection_update(), ro_gui_options_home_initialise(), ro_gui_options_interface_click(), ro_gui_options_interface_initialise(), ro_gui_print_prepare(), ro_gui_search_add_recent(), ro_gui_search_set_back_state(), ro_gui_search_set_forward_state(), ro_gui_throbber_icon_update(), ro_gui_url_bar_icon_update(), ro_gui_url_bar_update_urlsuggest(), ro_gui_wimp_event_restore(), theme_install_callback(), and theme_install_start().
void ro_gui_set_icon_sprite | ( | wimp_w | w, |
wimp_i | i, | ||
osspriteop_area * | area, | ||
const char * | name | ||
) |
Set an icon's sprite.
w | window handle |
i | icon handle |
area | sprite area containing sprite |
name | name of sprite in area (in local encoding) |
Definition at line 638 of file wimp.c.
References NSLOG, ro_gui_redraw_icon, and ro_warn_user().
Referenced by ro_gui_save_prepare().
void ro_gui_set_icon_string | ( | wimp_w | w, |
wimp_i | i, | ||
const char * | text, | ||
bool | is_utf8 | ||
) |
Set the contents of a text or sprite icon to a string.
w | window handle |
i | icon handle |
text | NUL terminated string (copied) |
is_utf8 | When true, the given string is UTF-8 encoded and will be converted to local encoding currently used by the Wimp. When false, the given string is assumed to be in local encoding in use by the Wimp. |
Definition at line 269 of file wimp.c.
References NSERROR_BAD_ENCODING, NSERROR_OK, NSLOG, ro_gui_redraw_icon, ro_gui_strlen(), ro_gui_strncmp(), ro_warn_user(), text(), and utf8_to_local_encoding().
Referenced by query_user_xy(), ro_gui_configure_register(), ro_gui_configure_translate(), ro_gui_dialog_init(), ro_gui_dialog_prepare_open_url(), ro_gui_dialog_prepare_zoom(), ro_gui_options_connection_default(), ro_gui_options_connection_initialise(), ro_gui_options_fonts_default(), ro_gui_options_fonts_initialise(), ro_gui_options_home_default(), ro_gui_options_home_initialise(), ro_gui_options_image_click(), ro_gui_options_image_initialise(), ro_gui_options_interface_default(), ro_gui_options_interface_initialise(), ro_gui_options_language_default(), ro_gui_options_language_initialise(), ro_gui_save_datasave_ack(), ro_gui_save_prepare(), ro_gui_search_prepare(), ro_gui_search_set_status(), ro_gui_set_icon_decimal(), ro_gui_set_icon_integer(), ro_gui_throbber_animate(), ro_gui_throbber_stop(), ro_gui_wimp_event_menu_selection(), ro_gui_wimp_event_restore(), ro_gui_window_prepare_objectinfo(), ro_gui_window_prepare_pageinfo(), ro_local_history_tooltip(), ro_warn_user(), theme_install_callback(), and theme_install_start().
void ro_gui_set_window_title | ( | wimp_w | w, |
const char * | text | ||
) |
Set a window title.
w | window handle |
text | new title (copied) |
Definition at line 675 of file wimp.c.
References NSERROR_BAD_ENCODING, NSERROR_OK, NSLOG, ro_warn_user(), text(), and utf8_to_local_encoding().
Referenced by gui_window_set_title(), ro_cookie_init(), ro_global_history_init(), ro_gui_print_prepare(), and ro_hotlist_init().
|
static |
RO GUI-specific strlen, for control character terminated strings.
str | The string to measure the length of |
Definition at line 1088 of file wimp.c.
Referenced by ro_gui_get_icon_string(), and ro_gui_set_icon_string().
|
static |
RO GUI-specific strncmp, for control character terminated strings.
s1 | The first string for comparison |
s2 | The second string for comparison |
len | Maximum number of bytes to be checked |
Definition at line 1110 of file wimp.c.
Referenced by ro_gui_set_icon_string().
void ro_gui_user_redraw | ( | wimp_draw * | redraw, |
bool | user_fill, | ||
os_colour | user_colour | ||
) |
Performs simple user redraw for a window.
redraw | wimp draw |
user_fill | whether to fill the redraw area |
user_colour | the colour to use when filling |
Definition at line 971 of file wimp.c.
References colourtrans_SET_BG_GCOL, NSLOG, and ro_warn_user().
Referenced by ro_gui_url_complete_redraw().
|
static |
Caches window furniture information.
w | the window to cache information from |
Definition at line 94 of file wimp.c.
References furniture_sizes, furniture_window, NSLOG, and ro_warn_user().
Referenced by ro_get_hscroll_height(), ro_get_title_height(), and ro_get_vscroll_width().
bool ro_gui_wimp_check_window_furniture | ( | wimp_w | w, |
wimp_window_flags | mask | ||
) |
Checks whether a piece of window furniture is present for a window.
w | the window to modify |
mask | the furniture flags to check |
Definition at line 1066 of file wimp.c.
References NSLOG, and ro_warn_user().
Referenced by ro_gui_wimp_event_keypress(), and ro_textarea_reflow().
os_error * ro_gui_wimp_get_sprite | ( | const char * | name, |
osspriteop_header ** | sprite | ||
) |
Locate a sprite in the Wimp sprite pool, returning a pointer to it.
name | sprite name |
sprite | receives pointer to sprite if found |
Definition at line 896 of file wimp.c.
Referenced by ro_gui_save_set_state(), and ro_gui_window_iconise().
bool ro_gui_wimp_get_sprite_dimensions | ( | osspriteop_area * | area, |
char * | sprite, | ||
int * | width, | ||
int * | height | ||
) |
Get the dimensions of a sprite.
*area | The sprite area to use. |
*sprite | Pointer to the sprite name. |
*width | Return the sprite width. |
*height | Return the sprite height. |
Definition at line 925 of file wimp.c.
References height, mode, NSLOG, ro_convert_pixels_to_os_units(), ro_warn_user(), and width.
Referenced by ro_gui_button_bar_rebuild(), and ro_gui_url_bar_rebuild().
bool ro_gui_wimp_read_eig_factors | ( | os_mode | mode, |
int * | xeig, | ||
int * | yeig | ||
) |
Reads a modes EIG factors.
[in] | mode | mode to read EIG factors for, or -1 for current |
[out] | xeig | The x eig value |
[out] | yeig | The y eig value |
Definition at line 123 of file wimp.c.
References mode, NSLOG, and ro_warn_user().
Referenced by image_redraw(), ro_convert_os_units_to_pixels(), and ro_convert_pixels_to_os_units().
bool ro_gui_wimp_sprite_exists | ( | const char * | sprite | ) |
Check if a sprite is present in the Wimp sprite pool.
sprite | name of sprite |
Definition at line 862 of file wimp.c.
References NSLOG, and ro_warn_user().
Referenced by gui_download_window_create(), ro_gui_url_bar_set_content_favicon(), ro_gui_url_complete_redraw(), ro_gui_window_prepare_objectinfo(), and ro_gui_window_prepare_pageinfo().
void ro_gui_wimp_update_window_furniture | ( | wimp_w | w, |
wimp_window_flags | bic_mask, | ||
wimp_window_flags | xor_mask | ||
) |
Sets whether a piece of window furniture is present for a window.
w | the window to modify |
bic_mask | the furniture flags to clear |
xor_mask | the furniture flags to toggle |
Definition at line 1016 of file wimp.c.
References NSLOG, parent, and ro_warn_user().
Referenced by ro_gui_dialog_add_persistent(), ro_gui_dialog_open_persistent(), ro_gui_menu_warning(), and ro_textarea_reflow().
|
static |
Definition at line 50 of file wimp.c.
Referenced by ro_get_hscroll_height(), ro_get_title_height(), ro_get_vscroll_width(), and ro_gui_wimp_cache_furniture_sizes().
|
static |
Definition at line 51 of file wimp.c.
Referenced by ro_gui_wimp_cache_furniture_sizes().