29#include "oslib/wimp.h"
49#define URLBAR_HEIGHT 52
50#define URLBAR_FAVICON_SIZE 16
51#define URLBAR_HOTLIST_SIZE 17
52#define URLBAR_PGINFO_WIDTH ((26) * 2)
53#define URLBAR_FAVICON_WIDTH ((5 + URLBAR_FAVICON_SIZE + 5) * 2)
54#define URLBAR_HOTLIST_WIDTH ((5 + URLBAR_HOTLIST_SIZE + 5) * 2)
55#define URLBAR_MIN_WIDTH 52
56#define URLBAR_GRIGHT_GUTTER 8
58#define URLBAR_PGINFO_NAME_LENGTH 12
59#define URLBAR_FAVICON_NAME_LENGTH 12
135 {
"resource:icons/hotlist-add.png", NULL, 0,
false },
136 {
"resource:icons/hotlist-rmv.png", NULL, 0,
false }
154 os_coord eig = {1, 1};
183 "xwimp_resize_icon: 0x%x: %s",
184 error->errnum, error->errmess);
204 "xwimp_resize_icon: 0x%x: %s",
205 error->errnum, error->errmess);
226 "xwimp_resize_icon: 0x%x: %s",
227 error->errnum, error->errmess);
233 if (xwimp_get_caret_position(&caret) == NULL) {
290 wimp_icon_create icon;
300 icon.icon.extent.x0 = 0;
301 icon.icon.extent.y0 = 0;
302 icon.icon.extent.x1 = 0;
303 icon.icon.extent.y1 = 0;
310 icon.icon.flags = wimp_ICON_BORDER |
311 (wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT) |
312 (wimp_BUTTON_DOUBLE_CLICK_DRAG << wimp_ICON_BUTTON_TYPE_SHIFT);
316 "xwimp_create_icon: 0x%x: %s",
317 error->errnum, error->errmess);
330 "xwimp_delete_icon: 0x%x: %s",
331 error->errnum, error->errmess);
345 icon.icon.flags = wimp_ICON_TEXT |
346 wimp_ICON_INDIRECTED |
349 (wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT);
352 icon.icon.flags |= (wimp_BUTTON_NEVER <<
353 wimp_ICON_BUTTON_TYPE_SHIFT);
355 icon.icon.flags |= (wimp_BUTTON_WRITE_CLICK_DRAG <<
356 wimp_ICON_BUTTON_TYPE_SHIFT);
358 icon.icon.flags |= (wimp_BUTTON_WRITABLE <<
359 wimp_ICON_BUTTON_TYPE_SHIFT);
364 "xwimp_create_icon: 0x%x: %s",
365 error->errnum, error->errmess);
379 "xwimp_delete_icon: 0x%x: %s",
380 error->errnum, error->errmess);
392 icon.icon.data.indirected_text.size = 1;
394 icon.icon.flags = wimp_ICON_TEXT |
396 wimp_ICON_INDIRECTED |
399 (wimp_BUTTON_CLICK << wimp_ICON_BUTTON_TYPE_SHIFT);
403 NSLOG(netsurf, INFO,
"xwimp_create_icon: 0x%x: %s",
404 error->errnum, error->errmess);
429 "xwimp_delete_icon: 0x%x: %s",
430 error->errnum, error->errmess);
500 switch (event->
type) {
524 NSLOG(netsurf, INFO,
"No memory for malloc()");
678 int x0,
int y0,
int x1,
int y1)
735 return (
url_bar == NULL) ? false :
true;
748 bool draw_pginfo =
true;
749 bool draw_favicon =
true;
750 bool draw_hotlist =
true;
756 if ((redraw->clip.x0 - (redraw->box.x0 - redraw->xscroll)) >
758 (redraw->clip.y0 - (redraw->box.y1 - redraw->yscroll)) >
760 (redraw->clip.x1 - (redraw->box.x0 - redraw->xscroll)) <
762 (redraw->clip.y1 - (redraw->box.y1 - redraw->yscroll)) <
768 if ((redraw->clip.x0 - (redraw->box.x0 - redraw->xscroll)) >
770 (redraw->clip.y0 - (redraw->box.y1 - redraw->yscroll)) >
772 (redraw->clip.x1 - (redraw->box.x0 - redraw->xscroll)) <
774 (redraw->clip.y1 - (redraw->box.y1 - redraw->yscroll)) <
777 draw_favicon =
false;
780 if ((redraw->clip.x0 - (redraw->box.x0 - redraw->xscroll)) >
782 (redraw->clip.y0 - (redraw->box.y1 - redraw->yscroll)) >
784 (redraw->clip.x1 - (redraw->box.x0 - redraw->xscroll)) <
786 (redraw->clip.y1 - (redraw->box.y1 - redraw->yscroll)) <
789 draw_hotlist =
false;
793 icon.flags = wimp_ICON_SPRITE |
794 wimp_ICON_INDIRECTED |
798 (wimp_COLOUR_WHITE << wimp_ICON_BG_COLOUR_SHIFT);
801 icon.data.indirected_sprite.size = 12;
808 xwimp_plot_icon(&icon);
814 icon.data.indirected_text.validation =
816 icon.data.indirected_text.size = 1;
817 icon.flags = wimp_ICON_TEXT | wimp_ICON_SPRITE |
818 wimp_ICON_INDIRECTED |
827 xwimp_plot_icon(&icon);
832 .background_images =
true,
836 xwimp_set_colour(wimp_COLOUR_WHITE);
838 (redraw->box.x0 - redraw->xscroll) +
840 (redraw->box.y1 - redraw->yscroll) +
842 xos_plot(os_PLOT_TO | os_PLOT_RECTANGLE,
843 (redraw->box.x0 - redraw->xscroll) +
845 (redraw->box.y1 - redraw->yscroll) +
873 .background_images =
true,
880 xwimp_set_colour(wimp_COLOUR_WHITE);
882 (redraw->box.x0 - redraw->xscroll) +
884 (redraw->box.y1 - redraw->yscroll) +
886 xos_plot(os_PLOT_TO | os_PLOT_RECTANGLE,
887 (redraw->box.x0 - redraw->xscroll) +
889 (redraw->box.y1 - redraw->yscroll) +
892 if (hotlist_icon->
ready ==
false) {
925 if (pos->x <
box->x0 ||
937 wimp_pointer *pointer,
938 wimp_window_state *state,
949 pos.x = pointer->pos.x - state->visible.x0 + state->xscroll;
950 pos.y = pointer->pos.y - state->visible.y1 + state->yscroll;
959 if (pointer->buttons == wimp_SINGLE_SELECT ||
960 pointer->buttons == wimp_SINGLE_ADJUST) {
962 if (pointer->buttons == wimp_SINGLE_SELECT &&
965 }
else if (pointer->buttons == wimp_SINGLE_ADJUST &&
973 if (pointer->buttons == wimp_SINGLE_SELECT &&
976 }
else if (pointer->buttons == wimp_SINGLE_ADJUST &&
988 if (pointer->buttons == wimp_DRAG_SELECT ||
989 pointer->buttons == wimp_DRAG_ADJUST) {
992 if (action != NULL) {
1000 if (action != NULL) {
1016 wimp_pointer *pointer)
1024 if (pointer != NULL) {
1052 if (urltxt != NULL &&
1084 wimp_window_state *
state,
1085 wimp_mouse_state buttons,
1086 const char **suffix)
1146 NSLOG(netsurf, INFO,
1147 "xwimp_set_caret_position: 0x%x: %s",
1148 error->errnum, error->errmess);
1167 char *local_text = NULL;
1168 const char *local_url;
1190 NSLOG(netsurf, INFO,
"utf8_to_enc failed");
1194 local_url = (local_text != NULL) ? local_text :
url;
1203 NSLOG(netsurf, WARNING,
1204 "URL too long to show in URL bar (%zu chars): %s",
1211 if (local_text != NULL) {
1229 error = xwimp_get_caret_position(&
caret);
1231 NSLOG(netsurf, INFO,
1232 "xwimp_get_caret_position: 0x%x: %s",
1233 error->errnum, error->errmess);
1241 const char *set_url;
1250 NSLOG(netsurf, INFO,
1251 "xwimp_set_caret_position: 0x%x: %s",
1311 wimp_icon_state
state;
1318 if (extent == NULL) {
1324 error = xwimp_get_icon_state(&
state);
1326 NSLOG(netsurf, INFO,
1327 "xwimp_get_icon_state: 0x%x: %s",
1328 error->errnum, error->errmess);
1333 extent->x0 =
state.icon.extent.x0;
1334 extent->y0 =
state.icon.extent.y0;
1335 extent->x1 =
state.icon.extent.x1;
1336 extent->y1 =
state.icon.extent.y1;
1345 wimp_pointer *pointer)
1458 const char *icon_name;
1467 icon_name =
"pgilocal";
1471 icon_name =
"pgiinsecure";
1475 icon_name =
"pgiwarning";
1479 icon_name =
"pgiwarning";
1483 icon_name =
"pgisecure";
1488 icon_name =
"pgiinternal";
1527 "small_%.3x",
type);
1563 return (
url_bar == NULL) ? false :
true;
Browser window creation and manipulation interface.
nserror browser_window_navigate(struct browser_window *bw, struct nsurl *url, struct nsurl *referrer, enum browser_window_nav_flags flags, char *post_urlenc, struct fetch_multipart_data *post_multipart, struct hlcache_handle *parent)
Start fetching a page in a browser window.
browser_window_page_info_state
Browser window page information states.
@ PAGE_STATE_INSECURE
Insecure page load.
@ PAGE_STATE_SECURE_ISSUES
Secure load, but has insecure elements.
@ PAGE_STATE_SECURE
Secure load.
@ PAGE_STATE_SECURE_OVERRIDE
Secure load, but had to override.
@ PAGE_STATE_LOCAL
Page loaded from file:/// etc.
@ PAGE_STATE_INTERNAL
Page loaded from internal handler.
browser_window_page_info_state browser_window_get_page_info_state(const struct browser_window *bw)
Request the current browser window page info state.
struct hlcache_handle * browser_window_get_content(struct browser_window *bw)
Get a cache handle for the content within a browser window.
@ BW_NAVIGATE_HISTORY
this will form a new history node (don't set for back/reload/etc)
content_type
The type of a content.
@ CONTENT_IMAGE
All images.
@ CONTENT_NONE
no type for content
@ CONTENT_MSG_DONE
content has finished processing
@ CONTENT_MSG_READY
may be displayed
nserror
Enumeration of error codes.
@ NSERROR_BAD_ENCODING
The character set is unknown.
nserror utf8_to_local_encoding(const char *string, size_t len, char **result)
nserror utf8_from_local_encoding(const char *string, size_t len, char **result)
bool ro_gui_hotlist_has_page(nsurl *url)
Report whether the hotlist contains a given URL.
theme_style
Theme styles, collecting groups of attributes for different locations.
Browser window handling (interface).
nserror hlcache_handle_release(hlcache_handle *handle)
Release a high-level cache handle.
nserror hlcache_handle_retrieve(nsurl *url, uint32_t flags, nsurl *referer, llcache_post_data *post, hlcache_handle_callback cb, void *pw, hlcache_child_context *child, content_type accepted_types, hlcache_handle **result)
Retrieve a high-level cache handle for an object.
High-level resource cache interface.
Public content interface.
bool content_redraw(struct hlcache_handle *h, struct content_redraw_data *data, const struct rect *clip, const struct redraw_context *ctx)
Display content on screen with optional tiling.
int content_get_height(struct hlcache_handle *h)
Retrieve height of content.
int content_get_width(struct hlcache_handle *h)
Retrieve width of content.
content_type content_get_type(struct hlcache_handle *h)
Retrieve computed type of content.
Target independent plotting interface.
#define NSLOG(catname, level, logmsg, args...)
const char * messages_get_errorcode(nserror code)
lookup of a message by errorcode from the standard Messages hash.
Localised message support (interface).
nserror nsurl_create(const char *const url_s, nsurl **url)
Create a NetSurf URL object from a URL string.
void nsurl_unref(nsurl *url)
Drop a reference to a NetSurf URL object.
struct nsurl nsurl
NetSurf URL object.
int ro_content_filetype(struct hlcache_handle *c)
Determine the RISC OS filetype for a content.
RISC OS filetpe interface.
nserror ro_warn_user(const char *warning, const char *detail)
Display a warning for a serious problem (eg memory exhaustion).
const struct plotter_table ro_plotters
RISC OS plotter operation table.
#define RO_GUI_MAX_URL_SIZE
osspriteop_area * ro_gui_theme_get_sprites(struct theme_descriptor *descriptor)
Returns a sprite area for use with the given theme.
struct gui_window * ro_gui_toolbar_lookup(wimp_w window)
Convert a toolbar RISC OS window handle to a gui_window.
nserror ro_gui_window_set_url(struct gui_window *g, nsurl *url)
Set the contents of a window's address bar.
int x
Coordinate of left padding edge relative to parent box, or relative to ancestor that contains this bo...
int y
Coordinate of top padding edge, relative as for x.
parameters to content redraw
int height
vertical dimension
bool repeat_y
whether content is tiled in y direction
bool repeat_x
whether content is tiled in x direction
int y
coordinate for top-left of redraw
int x
coordinate for top-left of redraw
colour background_colour
The background colour.
int width
dimensions to render content at (for scaling contents with intrinsic dimensions)
float scale
Scale for redraw (for scaling contents without intrinsic dimensions)
first entry in window list
struct gui_window::@32 mouse
struct browser_window * bw
The 'content' window that is rendered in the gui_window.
content_msg type
Event type.
bool interactive
Redraw to show interactive features.
Treeview content resource data.
struct hlcache_handle * c
struct hlcache_handle * content
char sprite[URLBAR_PGINFO_NAME_LENGTH]
struct theme_descriptor * theme
The applied theme (or NULL to use the default)
wimp_w window
The window and icon details.
struct url_bar::@51 pginfo
int x_min
The widget dimensions.
struct url_bar::@52 favicon
struct url_bar::@55 hotlist
osspriteop_area * sprites
struct url_bar::@54 suggest
UCS conversion tables (interface) This is only used if nothing claims Service_International,...
bool ro_gui_url_bar_test_for_text_field_click(struct url_bar *url_bar, wimp_pointer *pointer)
Test a pointer click to see if it was in the URL bar's text field.
static struct url_bar_resource url_bar_res[URLBAR_RES_LAST]
Treeview content resources.
void ro_gui_url_bar_fini(void)
Finalise the url bar module.
bool ro_gui_url_bar_page_info_change(struct url_bar *url_bar)
Update the page info icon.
static bool is_point_in_box(os_coord *pos, os_box *box)
check if os point is inside an os box
bool ro_gui_url_bar_get_url_extent(struct url_bar *url_bar, os_box *extent)
Return the current work area coordinates of the URL and favicon field's bounding box.
bool ro_gui_url_bar_take_caret(struct url_bar *url_bar)
Give a URL bar input focus.
bool ro_gui_url_bar_set_extent(struct url_bar *url_bar, int x0, int y0, int x1, int y1)
Set or update the dimensions to be used by the URL bar, in RO units.
static char text_validation[]
static bool ro_gui_url_bar_icon_resize(struct url_bar *url_bar, bool full)
Position the icons in the URL bar to take account of the currently configured extent.
static bool ro_gui_url_bar_icon_update(struct url_bar *url_bar)
Create or delete a URL bar's icons if required to bring it into sync with the current hidden setting.
const char * ro_gui_url_bar_get_url(struct url_bar *url_bar)
Return a pointer to the URL contained in a URL bar.
#define URLBAR_HOTLIST_SIZE
void ro_gui_url_bar_redraw(struct url_bar *url_bar, wimp_draw *redraw)
Handle redraw event rectangles in a URL bar.
bool ro_gui_url_bar_hide(struct url_bar *url_bar, bool hide)
Show or hide a URL bar.
bool ro_gui_url_bar_menu_prepare(struct url_bar *url_bar, wimp_i i, wimp_menu *menu, wimp_pointer *pointer)
Process offered menu prepare events from the parent window.
static char suggest_icon[]
void ro_gui_url_bar_set_url(struct url_bar *url_bar, const char *url, bool is_utf8, bool set_caret)
Set the content of a URL Bar field.
static void ro_gui_url_bar_set_hotlist(struct url_bar *url_bar, bool set)
Set the state of a URL Bar's hotlist icon.
#define URLBAR_PGINFO_WIDTH
static char null_text_string[]
bool ro_gui_url_bar_get_dims(struct url_bar *url_bar, int *width, int *height)
Return the MINIMUM dimensions required by the URL bar, in RO units, allowing for the current theme.
#define URLBAR_FAVICON_WIDTH
bool ro_gui_url_bar_set_site_favicon(struct url_bar *url_bar, struct hlcache_handle *h)
Set the favicon to a site supplied favicon image, or remove the image and return to using filetype-ba...
bool ro_gui_url_bar_init(void)
Initialise the url bar module.
bool ro_gui_url_bar_test_for_text_field_keypress(struct url_bar *url_bar, wimp_key *key)
Test a keypress to see if it was in the URL bar's text field.
void ro_gui_url_bar_update_hotlist(struct url_bar *url_bar)
Update the state of a URL Bar's hotlist icon to reflect any changes to the URL or the contents of the...
#define URLBAR_FAVICON_SIZE
#define URLBAR_PGINFO_NAME_LENGTH
struct url_bar * ro_gui_url_bar_create(struct theme_descriptor *theme)
Create a new url bar widget.
#define URLBAR_FAVICON_NAME_LENGTH
static char suggest_validation[]
bool ro_gui_url_bar_rebuild(struct url_bar *url_bar, struct theme_descriptor *theme, theme_style style, wimp_w window, bool display, bool shaded)
Place a URL bar into a toolbar window and initialise any theme-specific settings.
bool ro_gui_url_bar_set_content_favicon(struct url_bar *url_bar, struct gui_window *g)
Set the favicon to a RISC OS filetype sprite based on the type of the content within the supplied win...
@ URLBAR_RES_HOTLIST_REMOVE
bool ro_gui_url_bar_update_urlsuggest(struct url_bar *url_bar)
Update the state of the URL suggestion pop-up menu icon on a URL bar.
#define URLBAR_HOTLIST_WIDTH
static nserror ro_gui_url_bar_res_cb(hlcache_handle *handle, const hlcache_event *event, void *pw)
Callback for hlcache.
bool ro_gui_url_bar_help_suffix(struct url_bar *url_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 the URL bar.
#define URLBAR_GRIGHT_GUTTER
bool ro_gui_url_bar_menu_select(struct url_bar *url_bar, wimp_i i, wimp_menu *menu, wimp_selection *selection, menu_action action)
Process offered menu select events from the parent window.
bool ro_gui_url_bar_click(struct url_bar *url_bar, wimp_pointer *pointer, wimp_window_state *state, url_bar_action *action)
Handle mouse clicks in a URL bar.
void ro_gui_url_bar_destroy(struct url_bar *url_bar)
Destroy a url bar widget.
@ TOOLBAR_URL_DRAG_FAVICON
@ TOOLBAR_URL_ADJUST_PGINFO
@ TOOLBAR_URL_SELECT_PGINFO
@ TOOLBAR_URL_SELECT_HOTLIST
@ TOOLBAR_URL_ADJUST_HOTLIST
const char * ro_gui_url_suggest_get_selection(wimp_selection *selection)
Process a selection from the URL Suggest menu.
bool ro_gui_url_suggest_prepare_menu(void)
Builds the URL suggestion menu.
bool ro_gui_url_suggest_get_menu_available(void)
Check if there is a URL suggestion menu available for use.
URL Suggestion Menu (interface).
wimp_menu * ro_gui_url_suggest_menu
bool ro_gui_wimp_get_sprite_dimensions(osspriteop_area *area, char *sprite, int *width, int *height)
Get the dimensions of a sprite.
void ro_gui_set_icon_shaded_state(wimp_w w, wimp_i i, bool state)
Set the shaded state of an icon.
bool ro_gui_wimp_sprite_exists(const char *sprite)
Check if a sprite is present in the Wimp sprite pool.
const char * ro_gui_get_icon_string(wimp_w w, wimp_i i)
Read the contents of a text or sprite icon.
void ro_convert_pixels_to_os_units(os_coord *pixels, os_mode mode)
Converts the supplied os_coord from pixels to OS units.
#define ro_gui_redraw_icon(w, i)
Redraws an icon.
General RISC OS WIMP/OS library functions (interface).
bool ro_gui_wimp_event_register_menu_gright(wimp_w w, wimp_i i, wimp_i gright, wimp_menu *menu)
Register an icon menu to be automatically handled.
void ro_gui_wimp_event_deregister(wimp_w w, wimp_i i)
Free any resources associated with a specific icon in a window.
Automated RISC OS WIMP event handling (interface).
A collection of grubby utilities for working with OSLib's wimp API.
static bool ns_wimp_has_text_selection(void)
Check whether the OS supports text selection in writiable icons.
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.