NetSurf
Data Structures | Macros | Enumerations | Functions | Variables
toolbar.c File Reference
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <limits.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>
#include <math.h>
#include "utils/log.h"
#include "utils/nsoption.h"
#include "utils/nsurl.h"
#include "utils/utf8.h"
#include "netsurf/browser_window.h"
#include "netsurf/mouse.h"
#include "netsurf/plotters.h"
#include "netsurf/keypress.h"
#include "desktop/browser_history.h"
#include "desktop/hotlist.h"
#include "desktop/textarea.h"
#include "atari/clipboard.h"
#include "atari/gui.h"
#include "atari/search.h"
#include "atari/toolbar.h"
#include "atari/rootwin.h"
#include "atari/misc.h"
#include "atari/plot/plot.h"
#include "cflib.h"
#include "atari/res/netsurf.rsh"
#include "atari/encoding.h"
Include dependency graph for toolbar.c:

Go to the source code of this file.

Data Structures

struct  s_tb_button
 
struct  s_toolbar_style
 

Macros

#define TB_BUTTON_WIDTH   32
 
#define THROBBER_WIDTH   32
 
#define THROBBER_MIN_INDEX   1
 
#define THROBBER_MAX_INDEX   12
 
#define THROBBER_INACTIVE_INDEX   13
 
#define TOOLBAR_BUTTON_NUM_STATES   2
 
#define LAST_TOOLBAR_AREA   TOOLBAR_AREA_SEARCH
 

Enumerations

enum  e_toolbar_button_states { button_on = 0 , button_off = 1 }
 

Functions

static void tb_txt_request_redraw (void *data, int x, int y, int w, int h)
 Callback for textarea redraw. More...
 
static struct s_tb_buttonfind_button (struct s_toolbar *tb, int rsc_id)
 Find a button for a specific resource ID. More...
 
static void tb_txt_callback (void *data, struct textarea_msg *msg)
 
static struct s_tb_buttonbutton_init (struct s_toolbar *tb, OBJECT *tree, int index, struct s_tb_button *instance)
 
static short __CDECL toolbar_url_userdraw (PARMBLK *parmblock)
 
void toolbar_init (void)
 
void toolbar_exit (void)
 
struct s_toolbartoolbar_create (struct s_gui_win_root *owner)
 
void toolbar_destroy (struct s_toolbar *tb)
 
static int toolbar_calculate_height (struct s_toolbar *tb)
 
static void toolbar_reflow (struct s_toolbar *tb)
 
void toolbar_redraw (struct s_toolbar *tb, GRECT *clip)
 
void toolbar_update_buttons (struct s_toolbar *tb, struct browser_window *bw, short button)
 
void toolbar_set_width (struct s_toolbar *tb, short w)
 
void toolbar_set_origin (struct s_toolbar *tb, short x, short y)
 
void toolbar_set_dimensions (struct s_toolbar *tb, GRECT *area)
 
void toolbar_set_url (struct s_toolbar *tb, const char *text)
 
void toolbar_set_throbber_state (struct s_toolbar *tb, bool active)
 
void toolbar_set_visible (struct s_toolbar *tb, short area, bool visible)
 
void toolbar_set_reflow (struct s_toolbar *tb, bool do_reflow)
 
void toolbar_set_attached (struct s_toolbar *tb, bool attached)
 
void toolbar_throbber_progress (struct s_toolbar *tb)
 
bool toolbar_text_input (struct s_toolbar *tb, char *text)
 
bool toolbar_key_input (struct s_toolbar *tb, short nkc)
 
void toolbar_mouse_input (struct s_toolbar *tb, short obj, short button)
 
void toolbar_get_grect (struct s_toolbar *tb, short which, GRECT *dst)
 Receive a specific region of the toolbar. More...
 
struct textareatoolbar_get_textarea (struct s_toolbar *tb, enum toolbar_textarea which)
 
char * toolbar_get_url (struct s_toolbar *tb)
 
nsurltoolbar_get_nsurl (struct s_toolbar *tb)
 
OBJECT * toolbar_get_form (struct s_toolbar *tb)
 
void toolbar_back_click (struct s_toolbar *tb)
 
void toolbar_reload_click (struct s_toolbar *tb)
 
void toolbar_forward_click (struct s_toolbar *tb)
 
void toolbar_home_click (struct s_toolbar *tb)
 
void toolbar_stop_click (struct s_toolbar *tb)
 
void toolbar_favorite_click (struct s_toolbar *tb)
 
void toolbar_crypto_click (struct s_toolbar *tb)
 

Variables

char * option_homepage_url
 
void * h_gem_rsrc
 
struct gui_windowinput_window
 
long atari_plot_flags
 
int atari_plot_vdi_handle
 
EVMULT_OUT aes_event_out
 
static OBJECT * aes_toolbar = NULL
 
static OBJECT * throbber_form = NULL
 
static bool init = false
 
static int area_navigation_height = 0
 
static int area_search_height = 0
 
static int area_full_height = 0
 
static float toolbar_url_scale = 1.0
 
static plot_font_style_t font_style_url
 
static struct s_tb_button tb_buttons []
 
static struct s_toolbar_style toolbar_styles []
 
static const struct redraw_context toolbar_rdrw_ctx
 

Macro Definition Documentation

◆ LAST_TOOLBAR_AREA

#define LAST_TOOLBAR_AREA   TOOLBAR_AREA_SEARCH

◆ TB_BUTTON_WIDTH

#define TB_BUTTON_WIDTH   32

Definition at line 55 of file toolbar.c.

◆ THROBBER_INACTIVE_INDEX

#define THROBBER_INACTIVE_INDEX   13

Definition at line 59 of file toolbar.c.

◆ THROBBER_MAX_INDEX

#define THROBBER_MAX_INDEX   12

Definition at line 58 of file toolbar.c.

◆ THROBBER_MIN_INDEX

#define THROBBER_MIN_INDEX   1

Definition at line 57 of file toolbar.c.

◆ THROBBER_WIDTH

#define THROBBER_WIDTH   32

Definition at line 56 of file toolbar.c.

◆ TOOLBAR_BUTTON_NUM_STATES

#define TOOLBAR_BUTTON_NUM_STATES   2

Definition at line 65 of file toolbar.c.

Enumeration Type Documentation

◆ e_toolbar_button_states

Enumerator
button_on 
button_off 

Definition at line 61 of file toolbar.c.

Function Documentation

◆ button_init()

static struct s_tb_button * button_init ( struct s_toolbar tb,
OBJECT *  tree,
int  index,
struct s_tb_button instance 
)
static

Definition at line 221 of file toolbar.c.

References s_tb_button::index, s_tb_button::owner, and tb_buttons.

Referenced by toolbar_create().

Here is the caller graph for this function:

◆ find_button()

static struct s_tb_button * find_button ( struct s_toolbar tb,
int  rsc_id 
)
static

Find a button for a specific resource ID.

Definition at line 167 of file toolbar.c.

References s_toolbar::buttons, and s_tb_button::rsc_id.

Referenced by toolbar_mouse_input(), and toolbar_update_buttons().

Here is the caller graph for this function:

◆ tb_txt_callback()

static void tb_txt_callback ( void *  data,
struct textarea_msg msg 
)
static

Definition at line 202 of file toolbar.c.

References textarea_msg::data, textarea_msg::redraw, tb_txt_request_redraw(), TEXTAREA_MSG_DRAG_REPORT, TEXTAREA_MSG_REDRAW_REQUEST, textarea_msg::type, rect::x0, rect::x1, rect::y0, and rect::y1.

Referenced by toolbar_create().

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

◆ tb_txt_request_redraw()

static void tb_txt_request_redraw ( void *  data,
int  x,
int  y,
int  w,
int  h 
)
static

Callback for textarea redraw.

Definition at line 182 of file toolbar.c.

References s_tb_button::area, s_toolbar::area, s_toolbar::attached, s_toolbar::owner, toolbar_get_grect(), and window_schedule_redraw_grect().

Referenced by tb_txt_callback().

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

◆ toolbar_back_click()

void toolbar_back_click ( struct s_toolbar tb)

Definition at line 917 of file toolbar.c.

References gui_window::browser, browser_window_back_available(), browser_window_history_back(), browser_window::bw, gui_window::bw, s_browser::bw, s_toolbar::owner, and window_get_active_gui_window().

Referenced by menu_back().

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

◆ toolbar_calculate_height()

static int toolbar_calculate_height ( struct s_toolbar tb)
static

Definition at line 347 of file toolbar.c.

References area_navigation_height, area_search_height, s_toolbar::search_visible, and s_toolbar::visible.

Referenced by toolbar_reflow().

Here is the caller graph for this function:

◆ toolbar_create()

struct s_toolbar * toolbar_create ( struct s_gui_win_root owner)

◆ toolbar_crypto_click()

void toolbar_crypto_click ( struct s_toolbar tb)

Definition at line 1036 of file toolbar.c.

◆ toolbar_destroy()

void toolbar_destroy ( struct s_toolbar tb)

Definition at line 337 of file toolbar.c.

References s_toolbar::buttons, s_toolbar::form, s_url_widget::textarea, textarea_destroy(), and s_toolbar::url.

Referenced by window_destroy().

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

◆ toolbar_exit()

void toolbar_exit ( void  )

Definition at line 261 of file toolbar.c.

Referenced by gui_quit().

Here is the caller graph for this function:

◆ toolbar_favorite_click()

void toolbar_favorite_click ( struct s_toolbar tb)

Definition at line 1008 of file toolbar.c.

References hotlist_add_url(), hotlist_has_url(), hotlist_remove_url(), nsurl_create(), nsurl_unref(), and toolbar_get_url().

Here is the call graph for this function:

◆ toolbar_forward_click()

void toolbar_forward_click ( struct s_toolbar tb)

Definition at line 945 of file toolbar.c.

References gui_window::browser, browser_window_forward_available(), browser_window_history_forward(), browser_window::bw, gui_window::bw, s_browser::bw, s_toolbar::owner, and window_get_active_gui_window().

Referenced by menu_forward().

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

◆ toolbar_get_form()

OBJECT * toolbar_get_form ( struct s_toolbar tb)

Definition at line 910 of file toolbar.c.

References s_toolbar::form.

Referenced by nsatari_search_set_back_state(), nsatari_search_set_forward_state(), on_window_key_input(), toolbar_set_visible(), and window_open_search().

Here is the caller graph for this function:

◆ toolbar_get_grect()

void toolbar_get_grect ( struct s_toolbar tb,
short  which,
GRECT *  dst 
)

Receive a specific region of the toolbar.

Parameters
tb- the toolbar pointer
which- the area to retrieve: 0 to receive the workarea, all other values must be an resource ID of the TOOLBAR tree.
dst- GRECT pointer receiving the area.

Definition at line 854 of file toolbar.c.

References s_toolbar::form, s_toolbar::reflow, and toolbar_reflow().

Referenced by tb_txt_request_redraw(), toolbar_mouse_input(), toolbar_redraw(), toolbar_set_origin(), toolbar_set_throbber_state(), toolbar_set_url(), toolbar_set_width(), toolbar_throbber_progress(), toolbar_update_buttons(), window_get_grect(), and window_restore_active_gui_window().

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

◆ toolbar_get_nsurl()

nsurl * toolbar_get_nsurl ( struct s_toolbar tb)

Definition at line 896 of file toolbar.c.

References nsurl_create(), and toolbar_get_url().

Here is the call graph for this function:

◆ toolbar_get_textarea()

struct textarea * toolbar_get_textarea ( struct s_toolbar tb,
enum toolbar_textarea  which 
)

Definition at line 875 of file toolbar.c.

References s_url_widget::textarea, and s_toolbar::url.

◆ toolbar_get_url()

char * toolbar_get_url ( struct s_toolbar tb)

Definition at line 881 of file toolbar.c.

References s_url_widget::textarea, textarea_get_text(), and s_toolbar::url.

Referenced by toolbar_favorite_click(), and toolbar_get_nsurl().

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

◆ toolbar_home_click()

void toolbar_home_click ( struct s_toolbar tb)

Definition at line 960 of file toolbar.c.

References atari_warn_user(), gui_window::browser, browser_window_navigate(), browser_window::bw, gui_window::bw, s_browser::bw, BW_NAVIGATE_HISTORY, NSERROR_OK, nsoption_charp, nsurl_create(), nsurl_unref(), s_toolbar::owner, gui_window::url, and window_get_active_gui_window().

Referenced by menu_home().

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

◆ toolbar_init()

void toolbar_init ( void  )

Definition at line 236 of file toolbar.c.

References aes_toolbar, area_full_height, area_navigation_height, area_search_height, init, throbber_form, and toolbar_url_userdraw().

Referenced by gui_init().

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

◆ toolbar_key_input()

bool toolbar_key_input ( struct s_toolbar tb,
short  nkc 
)

Definition at line 677 of file toolbar.c.

References atari_warn_user(), BROWSER, gui_window::browser, browser_window_navigate(), s_browser::bw, BW_NAVIGATE_HISTORY, clip(), clip_length, nkc_to_input_key(), NS_KEY_COPY_SELECTION, NS_KEY_CR, NS_KEY_DELETE_LEFT, NS_KEY_ESCAPE, NS_KEY_NL, NS_KEY_PASTE, NS_KEY_SELECT_ALL, NSERROR_OK, nsurl_create(), nsurl_unref(), s_toolbar::owner, PATH_MAX, scrap_txt_read(), scrap_txt_write(), text(), s_url_widget::textarea, textarea_get_text(), textarea_keypress(), toolbar_set_url(), gui_window::url, s_toolbar::url, utf8_from_local_encoding(), window_get_active_gui_window(), and window_set_focus().

Referenced by gui_window_create(), on_window_key_input(), and window_set_focus().

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

◆ toolbar_mouse_input()

void toolbar_mouse_input ( struct s_toolbar tb,
short  obj,
short  button 
)

◆ toolbar_redraw()

void toolbar_redraw ( struct s_toolbar tb,
GRECT *  clip 
)

Definition at line 416 of file toolbar.c.

References s_toolbar::area, s_toolbar::attached, clip(), s_toolbar::form, s_throbber_widget::index, plot_set_dimensions(), plot_set_scale(), s_toolbar::reflow, s_url_widget::textarea, textarea_redraw(), s_toolbar::throbber, throbber_form, toolbar_get_grect(), toolbar_rdrw_ctx, toolbar_reflow(), toolbar_url_scale, s_toolbar::url, and rect::x0.

Referenced by toolbar_redraw_cb(), and window_process_redraws().

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

◆ toolbar_reflow()

static void toolbar_reflow ( struct s_toolbar tb)
static

Definition at line 364 of file toolbar.c.

References s_toolbar::area, s_toolbar::btcnt, button_off, button_on, s_toolbar::buttons, s_toolbar::form, s_throbber_widget::index, s_toolbar::reflow, s_tb_button::rsc_id, s_toolbar::search_visible, s_tb_button::state, s_toolbar::throbber, throbber_form, and toolbar_calculate_height().

Referenced by toolbar_get_grect(), toolbar_redraw(), toolbar_set_dimensions(), and toolbar_set_width().

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

◆ toolbar_reload_click()

void toolbar_reload_click ( struct s_toolbar tb)

Definition at line 932 of file toolbar.c.

References gui_window::browser, browser_window_reload(), browser_window::bw, gui_window::bw, s_browser::bw, s_toolbar::owner, and window_get_active_gui_window().

Referenced by menu_reload().

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

◆ toolbar_set_attached()

void toolbar_set_attached ( struct s_toolbar tb,
bool  attached 
)

Definition at line 643 of file toolbar.c.

References s_toolbar::attached.

Referenced by window_open().

Here is the caller graph for this function:

◆ toolbar_set_dimensions()

void toolbar_set_dimensions ( struct s_toolbar tb,
GRECT *  area 
)

Definition at line 561 of file toolbar.c.

References s_tb_button::area, s_toolbar::area, s_toolbar::form, s_toolbar::reflow, s_url_widget::textarea, textarea_set_dimensions(), toolbar_reflow(), and s_toolbar::url.

Referenced by window_open().

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

◆ toolbar_set_origin()

void toolbar_set_origin ( struct s_toolbar tb,
short  x,
short  y 
)

Definition at line 548 of file toolbar.c.

References s_toolbar::area, s_toolbar::reflow, and toolbar_get_grect().

Referenced by on_resized().

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

◆ toolbar_set_reflow()

void toolbar_set_reflow ( struct s_toolbar tb,
bool  do_reflow 
)

Definition at line 638 of file toolbar.c.

References s_toolbar::reflow.

◆ toolbar_set_throbber_state()

void toolbar_set_throbber_state ( struct s_toolbar tb,
bool  active 
)

Definition at line 600 of file toolbar.c.

References gui_window::active, s_throbber_widget::index, s_toolbar::owner, s_toolbar::reflow, s_throbber_widget::running, s_toolbar::throbber, THROBBER_INACTIVE_INDEX, THROBBER_MIN_INDEX, toolbar_get_grect(), and window_schedule_redraw_grect().

Referenced by gui_window_start_throbber(), and gui_window_stop_throbber().

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

◆ toolbar_set_url()

void toolbar_set_url ( struct s_toolbar tb,
const char *  text 
)

Definition at line 584 of file toolbar.c.

References s_tb_button::area, s_toolbar::attached, gui_window::browser, s_browser::bw, NSLOG, s_toolbar::owner, text(), s_url_widget::textarea, textarea_set_text(), toolbar_get_grect(), toolbar_update_buttons(), s_toolbar::url, s_toolbar::visible, window_get_active_gui_window(), and window_schedule_redraw_grect().

Referenced by gui_window_set_url(), toolbar_key_input(), and window_restore_active_gui_window().

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

◆ toolbar_set_visible()

void toolbar_set_visible ( struct s_toolbar tb,
short  area,
bool  visible 
)

Definition at line 616 of file toolbar.c.

References s_toolbar::reflow, s_toolbar::search_visible, toolbar_get_form(), and s_toolbar::visible.

Referenced by window_close_search(), and window_open_search().

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

◆ toolbar_set_width()

void toolbar_set_width ( struct s_toolbar tb,
short  w 
)

Definition at line 528 of file toolbar.c.

References s_toolbar::area, s_toolbar::form, s_toolbar::reflow, s_url_widget::textarea, textarea_set_dimensions(), toolbar_get_grect(), toolbar_reflow(), and s_toolbar::url.

Referenced by on_resized().

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

◆ toolbar_stop_click()

void toolbar_stop_click ( struct s_toolbar tb)

Definition at line 992 of file toolbar.c.

References gui_window::browser, browser_window_stop(), browser_window::bw, gui_window::bw, s_browser::bw, s_toolbar::owner, and window_get_active_gui_window().

Referenced by menu_stop().

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

◆ toolbar_text_input()

bool toolbar_text_input ( struct s_toolbar tb,
char *  text 
)

Definition at line 668 of file toolbar.c.

References NSLOG.

◆ toolbar_throbber_progress()

void toolbar_throbber_progress ( struct s_toolbar tb)

Definition at line 649 of file toolbar.c.

References s_throbber_widget::index, s_toolbar::owner, s_toolbar::reflow, s_throbber_widget::running, s_toolbar::throbber, THROBBER_MAX_INDEX, THROBBER_MIN_INDEX, toolbar_get_grect(), and window_schedule_redraw_grect().

Referenced by throbber_advance().

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

◆ toolbar_update_buttons()

void toolbar_update_buttons ( struct s_toolbar tb,
struct browser_window bw,
short  button 
)

Definition at line 458 of file toolbar.c.

References s_tb_button::area, s_toolbar::attached, browser_window_back_available(), browser_window_forward_available(), browser_window_reload_available(), browser_window_stop_available(), button_off, button_on, find_button(), NSLOG, s_toolbar::owner, s_tb_button::state, toolbar_get_grect(), and window_schedule_redraw_grect().

Referenced by toolbar_mouse_input(), toolbar_set_url(), and window_update_back_forward().

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

◆ toolbar_url_userdraw()

static short __CDECL toolbar_url_userdraw ( PARMBLK *  parmblock)
static

Definition at line 231 of file toolbar.c.

Referenced by toolbar_init().

Here is the caller graph for this function:

Variable Documentation

◆ aes_event_out

EVMULT_OUT aes_event_out
extern

Definition at line 105 of file gui.c.

Referenced by atari_poll(), and toolbar_mouse_input().

◆ aes_toolbar

OBJECT* aes_toolbar = NULL
static

Definition at line 87 of file toolbar.c.

Referenced by toolbar_create(), and toolbar_init().

◆ area_full_height

int area_full_height = 0
static

Definition at line 92 of file toolbar.c.

Referenced by toolbar_init().

◆ area_navigation_height

int area_navigation_height = 0
static

Definition at line 90 of file toolbar.c.

Referenced by toolbar_calculate_height(), and toolbar_init().

◆ area_search_height

int area_search_height = 0
static

Definition at line 91 of file toolbar.c.

Referenced by toolbar_calculate_height(), and toolbar_init().

◆ atari_plot_flags

long atari_plot_flags
extern

Definition at line 209 of file plot.c.

Referenced by bitmap_convert_tc(), plot_get_flags(), plot_init(), plot_lock(), and plot_unlock().

◆ atari_plot_vdi_handle

int atari_plot_vdi_handle
extern

◆ font_style_url

plot_font_style_t font_style_url
static
Initial value:
= {
.size = 14*PLOT_STYLE_SCALE,
.weight = 400,
.flags = FONTF_NONE,
.background = 0xffffff,
.foreground = 0x0
}
@ FONTF_NONE
Definition: plot_style.h:102
@ PLOT_FONT_FAMILY_SANS_SERIF
Definition: plot_style.h:89
#define PLOT_STYLE_SCALE
Scaling factor for plot styles.
Definition: plot_style.h:45

Definition at line 95 of file toolbar.c.

Referenced by toolbar_create().

◆ h_gem_rsrc

void* h_gem_rsrc
extern

Definition at line 76 of file gui.c.

◆ init

bool init = false
static

Definition at line 89 of file toolbar.c.

Referenced by menu_save_page(), toolbar_create(), and toolbar_init().

◆ input_window

struct gui_window* input_window
extern

◆ option_homepage_url

char* option_homepage_url
extern

Definition at line 88 of file gui.c.

Referenced by main(), and process_cmdline().

◆ tb_buttons

struct s_tb_button tb_buttons[]
static

Definition at line 107 of file toolbar.c.

Referenced by button_init(), ro_corewindow_init(), and toolbar_create().

◆ throbber_form

OBJECT* throbber_form = NULL
static

Definition at line 88 of file toolbar.c.

Referenced by toolbar_init(), toolbar_redraw(), and toolbar_reflow().

◆ toolbar_rdrw_ctx

const struct redraw_context toolbar_rdrw_ctx
static
Initial value:
= {
.interactive = true,
.background_images = true,
.plot = &atari_plotters
}
const struct plotter_table atari_plotters
atari plottr operation table
Definition: plot.c:2507

Definition at line 156 of file toolbar.c.

Referenced by toolbar_redraw().

◆ toolbar_styles

struct s_toolbar_style toolbar_styles[]
static
Initial value:
= {
{9},
{14},
{18},
{18}
}

Definition at line 145 of file toolbar.c.

Referenced by toolbar_create().

◆ toolbar_url_scale

float toolbar_url_scale = 1.0
static

Definition at line 93 of file toolbar.c.

Referenced by toolbar_redraw().