NetSurf
Data Structures | Enumerations | Functions | Variables
button_bar.h File Reference

Button bars (interface). More...

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

Go to the source code of this file.

Data Structures

struct  button_bar_buttons
 

Enumerations

enum  button_bar_action {
  TOOLBAR_BUTTON_NONE = 0 , TOOLBAR_BUTTON_BACK , TOOLBAR_BUTTON_BACK_NEW , TOOLBAR_BUTTON_UP ,
  TOOLBAR_BUTTON_UP_NEW , TOOLBAR_BUTTON_FORWARD , TOOLBAR_BUTTON_FORWARD_NEW , TOOLBAR_BUTTON_STOP ,
  TOOLBAR_BUTTON_RELOAD , TOOLBAR_BUTTON_RELOAD_ALL , TOOLBAR_BUTTON_HOME , TOOLBAR_BUTTON_HISTORY_LOCAL ,
  TOOLBAR_BUTTON_HISTORY_GLOBAL , TOOLBAR_BUTTON_SAVE_SOURCE , TOOLBAR_BUTTON_SAVE_COMPLETE , TOOLBAR_BUTTON_PRINT ,
  TOOLBAR_BUTTON_BOOKMARK_OPEN , TOOLBAR_BUTTON_BOOKMARK_ADD , TOOLBAR_BUTTON_SCALE , TOOLBAR_BUTTON_SEARCH ,
  TOOLBAR_BUTTON_DELETE , TOOLBAR_BUTTON_EXPAND , TOOLBAR_BUTTON_COLLAPSE , TOOLBAR_BUTTON_OPEN ,
  TOOLBAR_BUTTON_CLOSE , TOOLBAR_BUTTON_LAUNCH , TOOLBAR_BUTTON_CREATE
}
 

Functions

struct button_barro_gui_button_bar_create (struct theme_descriptor *theme, const struct button_bar_buttons buttons[])
 Create a new button bar widget. More...
 
bool ro_gui_button_bar_link_editor (struct button_bar *target, struct button_bar *source, void(*refresh)(void *), void *client_data)
 Link two button bars together. More...
 
bool ro_gui_button_bar_rebuild (struct button_bar *button_bar, struct theme_descriptor *theme, theme_style style, wimp_w window, bool edit)
 Place a button bar into a toolbar window and initialise any theme-specific settings. More...
 
bool ro_gui_button_bar_arrange_buttons (struct button_bar *button_bar, char order[])
 Arrange buttons on a button bar, using an order string to specify the required button and separator layout. More...
 
void ro_gui_button_bar_destroy (struct button_bar *button_bar)
 Destroy a button bar widget. More...
 
bool ro_gui_button_bar_get_dims (struct button_bar *button_bar, int *width, int *height)
 Return the MINIMUM dimensions required by the button bar, in RO units, allowing for the current theme. More...
 
bool ro_gui_button_bar_set_extent (struct button_bar *button_bar, int x0, int y0, int x1, int y1)
 Set or update the dimensions to be used by the button bar, in RO units. More...
 
bool ro_gui_button_bar_hide (struct button_bar *button_bar, bool hide)
 Show or hide a button bar. More...
 
bool ro_gui_button_bar_shade_button (struct button_bar *button_bar, button_bar_action action, bool shaded)
 Shade or unshade a button in a bar corresponding to the given action. More...
 
void ro_gui_button_bar_redraw (struct button_bar *button_bar, wimp_draw *redraw)
 Handle redraw event rectangles in a button bar. More...
 
bool ro_gui_button_bar_click (struct button_bar *button_bar, wimp_pointer *pointer, wimp_window_state *state, button_bar_action *action)
 Handle mouse clicks in a button bar. More...
 
bool ro_gui_button_bar_help_suffix (struct button_bar *button_bar, wimp_i i, os_coord *mouse, wimp_window_state *state, wimp_mouse_state buttons, const char **suffix)
 Translate mouse data into an interactive help message for a button bar. More...
 
char * ro_gui_button_bar_get_config (struct button_bar *button_bar)
 Return a config string reflecting the configured order of buttons and spacers. More...
 

Variables

static const struct button_bar_buttons brower_toolbar_buttons []
 

Detailed Description

Button bars (interface).

Definition in file button_bar.h.

Enumeration Type Documentation

◆ button_bar_action

Enumerator
TOOLBAR_BUTTON_NONE 
TOOLBAR_BUTTON_BACK 
TOOLBAR_BUTTON_BACK_NEW 
TOOLBAR_BUTTON_UP 
TOOLBAR_BUTTON_UP_NEW 
TOOLBAR_BUTTON_FORWARD 
TOOLBAR_BUTTON_FORWARD_NEW 
TOOLBAR_BUTTON_STOP 
TOOLBAR_BUTTON_RELOAD 
TOOLBAR_BUTTON_RELOAD_ALL 
TOOLBAR_BUTTON_HOME 
TOOLBAR_BUTTON_HISTORY_LOCAL 
TOOLBAR_BUTTON_HISTORY_GLOBAL 
TOOLBAR_BUTTON_SAVE_SOURCE 
TOOLBAR_BUTTON_SAVE_COMPLETE 
TOOLBAR_BUTTON_PRINT 
TOOLBAR_BUTTON_BOOKMARK_OPEN 
TOOLBAR_BUTTON_BOOKMARK_ADD 
TOOLBAR_BUTTON_SCALE 
TOOLBAR_BUTTON_SEARCH 
TOOLBAR_BUTTON_DELETE 
TOOLBAR_BUTTON_EXPAND 
TOOLBAR_BUTTON_COLLAPSE 
TOOLBAR_BUTTON_OPEN 
TOOLBAR_BUTTON_CLOSE 
TOOLBAR_BUTTON_LAUNCH 
TOOLBAR_BUTTON_CREATE 

Definition at line 32 of file button_bar.h.

Function Documentation

◆ ro_gui_button_bar_arrange_buttons()

bool ro_gui_button_bar_arrange_buttons ( struct button_bar button_bar,
char  order[] 
)

Arrange buttons on a button bar, using an order string to specify the required button and separator layout.

Parameters
*button_barThe button bar to update.
order[]The button order configuration string.
Returns
true if successful; else false.

Definition at line 303 of file button_bar.c.

References button_bar::bar, button_bar_button::bar_next, button_bar::buttons, button_bar_button::next, ro_gui_button_bar_find_opt_key(), ro_gui_button_bar_place_buttons(), and button_bar_button::separator.

Referenced by ro_toolbar_add_buttons(), and ro_toolbar_set_button_order().

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

◆ ro_gui_button_bar_click()

bool ro_gui_button_bar_click ( struct button_bar button_bar,
wimp_pointer *  pointer,
wimp_window_state *  state,
button_bar_action action 
)

Handle mouse clicks in a button bar.

Parameters
*button_barThe button bar to use.
*pointerThe Wimp mouse click event data.
*stateThe toolbar window state.
*actionReturns the selected action, or TOOLBAR_BUTTON_NONE.
Returns
true if the event was handled exclusively; else false.

Definition at line 723 of file button_bar.c.

References button_bar_button::adjust_action, drag_opt, drag_separator, drag_start, button_bar::edit, button_bar::edit_source, button_bar::extent, button_bar::hidden, NSLOG, button_bar_button::opt_key, ro_gui_button_bar_drag_end(), ro_gui_button_bar_find_coords(), ro_gui_button_bar_find_icon(), ro_mouse_drag_start(), button_bar_button::select_action, separator_name, button_bar::separator_width, button_bar_button::shaded, button_bar_button::sprite, button_bar::sprites, box::x, button_bar_button::x_size, box::y, and button_bar_button::y_size.

Referenced by ro_toolbar_click().

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

◆ ro_gui_button_bar_create()

struct button_bar * ro_gui_button_bar_create ( struct theme_descriptor theme,
const struct button_bar_buttons  buttons[] 
)

Create a new button bar widget.

Parameters
*themeThe theme to apply (or NULL for the default).
buttons[]An array of button definitions for the bar.
Returns
A button bar handle, or NULL on failure.

Definition at line 130 of file button_bar.c.

References button_bar_buttons::adjust, button_bar::background, button_bar::bar, BUTTONBAR_SPRITE_NAME_LENGTH, BUTTONBAR_VALIDATION_LENGTH, button_bar::buttons, button_bar::edit, button_bar::edit_client_data, button_bar::edit_refresh, button_bar::edit_source, button_bar::edit_target, button_bar_buttons::help, button_bar::hidden, button_bar_button::icon, button_bar_buttons::icon, NSLOG, button_bar_buttons::opt_key, ro_gui_theme_get_sprites(), button_bar_buttons::select, button_bar::separator_width, button_bar::separators, button_bar::sprites, button_bar::theme, button_bar::vertical_offset, button_bar::window, button_bar::x_min, and button_bar::y_min.

Referenced by ro_toolbar_add_buttons().

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

◆ ro_gui_button_bar_destroy()

void ro_gui_button_bar_destroy ( struct button_bar button_bar)

Destroy a button bar widget.

Parameters
*button_barThe button bar to destroy.

Definition at line 395 of file button_bar.c.

References button_bar::buttons, and button_bar_button::next.

Referenced by ro_toolbar_destroy(), and ro_toolbar_rebuild().

Here is the caller graph for this function:

◆ ro_gui_button_bar_get_config()

char * ro_gui_button_bar_get_config ( struct button_bar button_bar)

Return a config string reflecting the configured order of buttons and spacers.

The string is allocated with malloc(), and should be free()d after use.

Parameters
*button_barThe button bar of interest.
Returns
Pointer to a config string, or NULL on failure.

Definition at line 1067 of file button_bar.c.

References button_bar::bar, button_bar_button::bar_next, NSLOG, button_bar_button::opt_key, ro_warn_user(), and button_bar_button::separator.

Referenced by ro_toolbar_toggle_edit().

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

◆ ro_gui_button_bar_get_dims()

bool ro_gui_button_bar_get_dims ( struct button_bar button_bar,
int *  width,
int *  height 
)

Return the MINIMUM dimensions required by the button bar, in RO units, allowing for the current theme.

Parameters
*button_barThe button bar of interest.
*widthReturn the required width.
*heightReturn the required height.
Returns
true if values are returned; else false.

Definition at line 416 of file button_bar.c.

References height, width, button_bar::x_min, and button_bar::y_min.

Referenced by ro_toolbar_refresh_widget_dimensions().

Here is the caller graph for this function:

◆ ro_gui_button_bar_help_suffix()

bool ro_gui_button_bar_help_suffix ( struct button_bar button_bar,
wimp_i  i,
os_coord *  mouse,
wimp_window_state *  state,
wimp_mouse_state  buttons,
const char **  suffix 
)

Translate mouse data into an interactive help message for a button bar.

Parameters
*button_barThe button bar to process.
iThe wimp icon under the pointer.
*mouseThe mouse position.
*stateThe toolbar window state.
buttonsThe mouse button state.
**suffixReturn a help token suffix, or "" for none.
Returns
true if handled exclusively; else false.

Definition at line 826 of file button_bar.c.

References button_bar::extent, button_bar_button::help_suffix, button_bar::hidden, and ro_gui_button_bar_find_icon().

Referenced by ro_toolbar_get_help_suffix().

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

◆ ro_gui_button_bar_hide()

bool ro_gui_button_bar_hide ( struct button_bar button_bar,
bool  hide 
)

Show or hide a button bar.

Parameters
*button_barThe button bar to hide.
hidetrue to hide the bar; false to show it.
Returns
true if successful; else false.

Definition at line 627 of file button_bar.c.

References button_bar::hidden, and ro_gui_button_bar_icon_update().

Referenced by ro_toolbar_add_buttons(), ro_toolbar_set_display_buttons(), and ro_toolbar_toggle_edit().

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

◆ ro_gui_button_bar_link_editor()

bool ro_gui_button_bar_link_editor ( struct button_bar target,
struct button_bar source,
void(*)(void *)  refresh,
void *  client_data 
)

Link two button bars together.

Join two button bars the target being the active bar, and the source being the editing bar used to supply valid buttons. The bars are checked to ensure that they are not already part of an edit pair, but are not checked for button-compatibility.

Parameters
targetThe target button bar.
sourceThe source button bar.
refreshThe refresh callback.
client_datacontext passed to the refresh callback
Returns
true if successful; else false.

Definition at line 220 of file button_bar.c.

References button_bar::edit_client_data, button_bar::edit_refresh, button_bar::edit_source, and button_bar::edit_target.

Referenced by ro_toolbar_add_buttons().

Here is the caller graph for this function:

◆ ro_gui_button_bar_rebuild()

bool ro_gui_button_bar_rebuild ( struct button_bar button_bar,
struct theme_descriptor theme,
theme_style  style,
wimp_w  window,
bool  edit 
)

Place a button bar into a toolbar window and initialise any theme-specific settings.

Any previous incarnation of the bar will be forgotten: this is for use when a new toolbar is being created, or when a toolbar has been deleted and rebuilt following a theme change.

Parameters
*button_barThe button bar to rebuild.
*themeThe theme to apply (or NULL for current).
styleThe theme style to apply.
windowThe window that the bar is in.
editThe edit mode of the button bar.
Returns
true on success; else false.

Definition at line 245 of file button_bar.c.

References button_bar::background, button_bar::buttons, button_bar::edit, button_bar::edit_target, height, button_bar_button::icon, button_bar_button::next, ro_gui_button_bar_icon_update(), ro_gui_button_bar_place_buttons(), ro_gui_button_bar_sync_editors(), ro_gui_theme_get_sprites(), ro_gui_theme_get_style_element(), ro_gui_wimp_get_sprite_dimensions(), separator_name, button_bar::separator_width, button_bar::separators, button_bar_button::sprite, button_bar::sprites, button_bar::theme, THEME_ELEMENT_BACKGROUND, button_bar::window, button_bar_button::x_size, and button_bar_button::y_size.

Referenced by ro_toolbar_rebuild().

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

◆ ro_gui_button_bar_redraw()

void ro_gui_button_bar_redraw ( struct button_bar button_bar,
wimp_draw *  redraw 
)

Handle redraw event rectangles in a button bar.

Parameters
*button_barThe button bar to use.
*redrawThe Wimp redraw rectangle to process.

Definition at line 672 of file button_bar.c.

References button_bar::bar, button_bar_button::bar_next, button_bar::edit, button_bar::extent, button_bar::hidden, button_bar_button::icon, button_bar_button::separator, separator_name, button_bar::separator_width, button_bar::separators, button_bar::sprites, button_bar::vertical_offset, button_bar_button::x_pos, button_bar_button::x_size, and button_bar::y_min.

Referenced by ro_toolbar_redraw().

Here is the caller graph for this function:

◆ ro_gui_button_bar_set_extent()

bool ro_gui_button_bar_set_extent ( struct button_bar button_bar,
int  x0,
int  y0,
int  x1,
int  y1 
)

Set or update the dimensions to be used by the button bar, in RO units.

If these are greater than the minimum required, the button bar will fill the extended space; if less, the call will fail.

Parameters
*button_barThe button bar to update.
x0The minimum X window position.
y0The minimum Y window position.
x1The maximum X window position.
y1The maximum Y window position.
Returns
true if size updated; else false.

Definition at line 437 of file button_bar.c.

References button_bar::extent, ro_gui_button_bar_icon_resize(), button_bar::vertical_offset, button_bar::window, button_bar::x_min, and button_bar::y_min.

Referenced by ro_toolbar_reformat_widgets().

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

◆ ro_gui_button_bar_shade_button()

bool ro_gui_button_bar_shade_button ( struct button_bar button_bar,
button_bar_action  action,
bool  shaded 
)

Shade or unshade a button in a bar corresponding to the given action.

Parameters
*button_barThe button bar to update.
actionThe action to update.
shadedtrue to shade the button; false to unshade.
Returns
true if successful; else false.

Definition at line 640 of file button_bar.c.

References button_bar::edit, button_bar::edit_target, button_bar_button::icon, ro_gui_button_bar_find_action(), ro_gui_set_icon_shaded_state(), button_bar_button::shaded, and button_bar::window.

Referenced by ro_toolbar_set_button_shaded_state().

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

Variable Documentation

◆ brower_toolbar_buttons

const struct button_bar_buttons brower_toolbar_buttons[]
static
Initial value:
= {
{"search", TOOLBAR_BUTTON_SEARCH, TOOLBAR_BUTTON_NONE, 'a', "10"},
}
@ TOOLBAR_BUTTON_BOOKMARK_OPEN
Definition: button_bar.h:49
@ TOOLBAR_BUTTON_SEARCH
Definition: button_bar.h:52
@ TOOLBAR_BUTTON_HISTORY_GLOBAL
Definition: button_bar.h:45
@ TOOLBAR_BUTTON_SCALE
Definition: button_bar.h:51
@ TOOLBAR_BUTTON_HOME
Definition: button_bar.h:43
@ TOOLBAR_BUTTON_HISTORY_LOCAL
Definition: button_bar.h:44
@ TOOLBAR_BUTTON_NONE
Definition: button_bar.h:33
@ TOOLBAR_BUTTON_BACK_NEW
Definition: button_bar.h:35
@ TOOLBAR_BUTTON_UP
Definition: button_bar.h:36
@ TOOLBAR_BUTTON_SAVE_COMPLETE
Definition: button_bar.h:47
@ TOOLBAR_BUTTON_BACK
Definition: button_bar.h:34
@ TOOLBAR_BUTTON_FORWARD_NEW
Definition: button_bar.h:39
@ TOOLBAR_BUTTON_BOOKMARK_ADD
Definition: button_bar.h:50
@ TOOLBAR_BUTTON_RELOAD
Definition: button_bar.h:41
@ TOOLBAR_BUTTON_SAVE_SOURCE
Definition: button_bar.h:46
@ TOOLBAR_BUTTON_UP_NEW
Definition: button_bar.h:37
@ TOOLBAR_BUTTON_FORWARD
Definition: button_bar.h:38
@ TOOLBAR_BUTTON_RELOAD_ALL
Definition: button_bar.h:42
@ TOOLBAR_BUTTON_PRINT
Definition: button_bar.h:48
@ TOOLBAR_BUTTON_STOP
Definition: button_bar.h:40

Definition at line 82 of file button_bar.h.

Referenced by gui_window_create(), and ro_gui_options_theme_load().