Merge branches/stevef/toolbars to trunk.
svn path=/trunk/netsurf/; revision=11741
This commit is contained in:
parent
f54fc080c2
commit
cd9c0998e9
|
@ -1,4 +1,4 @@
|
|||
# RISC OS Target makefile
|
||||
# RISC OS Target makefile
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# RISC OS target setup
|
||||
|
@ -68,13 +68,15 @@ endif
|
|||
S_RISCOS := 401login.c artworks.c assert.c awrender.s bitmap.c buffer.c \
|
||||
cookies.c configure.c debugwin.c dialog.c download.c draw.c \
|
||||
filetype.c font.c global_history.c gui.c help.c history.c \
|
||||
hotlist.c image.c menus.c message.c palettes.c plotters.c \
|
||||
plugin.c print.c query.c save.c save_draw.c save_pdf.c \
|
||||
schedule.c search.c searchweb.c sprite.c sslcert.c \
|
||||
textarea.c textselection.c theme.c theme_install.c thumbnail.c \
|
||||
treeview.c ucstables.c uri.c url_complete.c url_protocol.c \
|
||||
url_suggest.c wimp.c wimp_event.c window.c system_colour.c \
|
||||
gui/progress_bar.c gui/status_bar.c \
|
||||
hotlist.c iconbar.c image.c menus.c message.c palettes.c \
|
||||
plotters.c plugin.c print.c query.c save.c save_draw.c \
|
||||
save_pdf.c schedule.c search.c searchweb.c sprite.c sslcert.c \
|
||||
system_colour.c textarea.c textselection.c theme.c \
|
||||
theme_install.c thumbnail.c toolbar.c treeview.c ucstables.c \
|
||||
uri.c url_complete.c url_protocol.c url_suggest.c wimp.c \
|
||||
wimp_event.c window.c \
|
||||
$(addprefix gui/,button_bar.c progress_bar.c status_bar.c \
|
||||
throbber.c url_bar.c) \
|
||||
$(addprefix configure/,con_cache.c con_connect.c con_content.c \
|
||||
con_fonts.c con_home.c con_image.c con_inter.c con_language.c \
|
||||
con_memory.c con_secure.c con_theme.c)
|
||||
|
|
|
@ -60,7 +60,8 @@
|
|||
static int ro_gui_options_connection_proxy_type(wimp_w w);
|
||||
static void ro_gui_options_connection_default(wimp_pointer *pointer);
|
||||
static bool ro_gui_options_connection_ok(wimp_w w);
|
||||
static void ro_gui_options_connection_update(wimp_w w, wimp_i i);
|
||||
static bool ro_gui_options_connection_update(wimp_w w, wimp_i i, wimp_menu *m,
|
||||
wimp_selection *s, menu_action a);
|
||||
|
||||
bool ro_gui_options_connection_initialise(wimp_w w)
|
||||
{
|
||||
|
@ -88,7 +89,7 @@ bool ro_gui_options_connection_initialise(wimp_w w)
|
|||
option_max_fetchers_per_host);
|
||||
ro_gui_set_icon_integer(w, CONNECTION_CACHE_FETCH_FIELD,
|
||||
option_max_cached_fetch_handles);
|
||||
ro_gui_options_connection_update(w, -1);
|
||||
ro_gui_options_connection_update(w, -1, NULL, NULL, NO_ACTION);
|
||||
|
||||
/* register icons */
|
||||
ro_gui_wimp_event_register_menu_gright(w, CONNECTION_PROXY_FIELD,
|
||||
|
@ -124,7 +125,8 @@ bool ro_gui_options_connection_initialise(wimp_w w)
|
|||
|
||||
}
|
||||
|
||||
void ro_gui_options_connection_update(wimp_w w, wimp_i i)
|
||||
bool ro_gui_options_connection_update(wimp_w w, wimp_i i, wimp_menu *m,
|
||||
wimp_selection *s, menu_action a)
|
||||
{
|
||||
int proxy_type;
|
||||
bool host, user;
|
||||
|
@ -142,6 +144,8 @@ void ro_gui_options_connection_update(wimp_w w, wimp_i i)
|
|||
ro_gui_set_icon_shaded_state(w, CONNECTION_PROXY_USERNAME, !user);
|
||||
ro_gui_set_icon_shaded_state(w, CONNECTION_PROXY_PASSWORD_LABEL, !user);
|
||||
ro_gui_set_icon_shaded_state(w, CONNECTION_PROXY_PASSWORD, !user);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int ro_gui_options_connection_proxy_type(wimp_w w)
|
||||
|
@ -169,7 +173,7 @@ void ro_gui_options_connection_default(wimp_pointer *pointer)
|
|||
ro_gui_set_icon_integer(pointer->w, CONNECTION_MAX_FETCH_FIELD, 24);
|
||||
ro_gui_set_icon_integer(pointer->w, CONNECTION_HOST_FETCH_FIELD, 5);
|
||||
ro_gui_set_icon_integer(pointer->w, CONNECTION_CACHE_FETCH_FIELD, 6);
|
||||
ro_gui_options_connection_update(pointer->w, -1);
|
||||
ro_gui_options_connection_update(pointer->w, -1, NULL, NULL, NO_ACTION);
|
||||
}
|
||||
|
||||
bool ro_gui_options_connection_ok(wimp_w w)
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
#include "utils/messages.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
|
||||
#define HOME_URL_FIELD 3
|
||||
#define HOME_URL_GRIGHT 4
|
||||
#define HOME_OPEN_STARTUP 5
|
||||
|
@ -40,6 +39,8 @@
|
|||
|
||||
static void ro_gui_options_home_default(wimp_pointer *pointer);
|
||||
static bool ro_gui_options_home_ok(wimp_w w);
|
||||
static bool ro_gui_options_home_menu_prepare(wimp_w w, wimp_i i,
|
||||
wimp_menu *menu, wimp_pointer *pointer);
|
||||
|
||||
bool ro_gui_options_home_initialise(wimp_w w)
|
||||
{
|
||||
|
@ -53,13 +54,15 @@ bool ro_gui_options_home_initialise(wimp_w w)
|
|||
|
||||
/* initialise all functions for a newly created window */
|
||||
ro_gui_wimp_event_register_menu_gright(w, HOME_URL_FIELD,
|
||||
HOME_URL_GRIGHT, url_suggest_menu);
|
||||
HOME_URL_GRIGHT, ro_gui_url_suggest_menu);
|
||||
ro_gui_wimp_event_register_checkbox(w, HOME_OPEN_STARTUP);
|
||||
ro_gui_wimp_event_register_button(w, HOME_DEFAULT_BUTTON,
|
||||
ro_gui_options_home_default);
|
||||
ro_gui_wimp_event_register_cancel(w, HOME_CANCEL_BUTTON);
|
||||
ro_gui_wimp_event_register_ok(w, HOME_OK_BUTTON,
|
||||
ro_gui_options_home_ok);
|
||||
ro_gui_wimp_event_register_menu_prepare(w,
|
||||
ro_gui_options_home_menu_prepare);
|
||||
ro_gui_wimp_event_set_help_prefix(w, "HelpHomeConfig");
|
||||
ro_gui_wimp_event_memorise(w);
|
||||
return true;
|
||||
|
@ -84,3 +87,28 @@ bool ro_gui_options_home_ok(wimp_w w)
|
|||
ro_gui_save_options();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Callback to prepare menus in the Configure Home dialog. At present, this
|
||||
* only has to handle the URL Suggestion pop-up.
|
||||
*
|
||||
* \param w The window handle owning the menu.
|
||||
* \param i The icon handle owning the menu.
|
||||
* \param *menu The menu to be prepared.
|
||||
* \param *pointer The associated mouse click event block, or NULL
|
||||
* on an Adjust-click re-opening.
|
||||
* \return true if the event was handled; false if not.
|
||||
*/
|
||||
|
||||
bool ro_gui_options_home_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
|
||||
wimp_pointer *pointer)
|
||||
{
|
||||
if (menu != ro_gui_url_suggest_menu || i != HOME_URL_GRIGHT)
|
||||
return false;
|
||||
|
||||
if (pointer != NULL)
|
||||
ro_gui_url_suggest_prepare_menu();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -50,8 +50,9 @@
|
|||
static bool ro_gui_options_image_click(wimp_pointer *pointer);
|
||||
static bool ro_gui_options_image_ok(wimp_w w);
|
||||
static void ro_gui_options_image_redraw(wimp_draw *redraw);
|
||||
static void ro_gui_options_image_update(wimp_w w, wimp_i i);
|
||||
static void ro_gui_options_image_read(wimp_w w, unsigned int *bg,
|
||||
static bool ro_gui_options_image_update(wimp_w w, wimp_i i, wimp_menu *m,
|
||||
wimp_selection *s, menu_action a);
|
||||
static void ro_gui_options_image_read(wimp_w w, unsigned int *bg,
|
||||
unsigned int *fg);
|
||||
static void ro_gui_options_update_shading(wimp_w w);
|
||||
|
||||
|
@ -86,7 +87,7 @@ bool ro_gui_options_image_initialise(wimp_w w)
|
|||
image_quality_menu->entries[i].
|
||||
data.indirected_text.text, true);
|
||||
}
|
||||
ro_gui_set_icon_decimal(w, IMAGE_SPEED_FIELD,
|
||||
ro_gui_set_icon_decimal(w, IMAGE_SPEED_FIELD,
|
||||
option_minimum_gif_delay, 2);
|
||||
ro_gui_set_icon_selected_state(w, IMAGE_DISABLE_ANIMATION,
|
||||
!option_animate_images);
|
||||
|
@ -127,9 +128,12 @@ void ro_gui_options_image_finalise(wimp_w w)
|
|||
ro_gui_wimp_event_finalise(w);
|
||||
}
|
||||
|
||||
void ro_gui_options_image_update(wimp_w w, wimp_i i)
|
||||
bool ro_gui_options_image_update(wimp_w w, wimp_i i, wimp_menu *m,
|
||||
wimp_selection *s, menu_action a)
|
||||
{
|
||||
ro_gui_redraw_icon(w, IMAGE_CURRENT_DISPLAY);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ro_gui_options_image_redraw(wimp_draw *redraw)
|
||||
|
@ -204,11 +208,11 @@ bool ro_gui_options_image_click(wimp_pointer *pointer)
|
|||
ro_gui_options_image_read(pointer->w, &old_bg, &old_fg);
|
||||
switch (pointer->i) {
|
||||
case IMAGE_DEFAULT_BUTTON:
|
||||
ro_gui_set_icon_string(pointer->w,
|
||||
ro_gui_set_icon_string(pointer->w,
|
||||
IMAGE_FOREGROUND_FIELD,
|
||||
image_quality_menu->entries[3].
|
||||
data.indirected_text.text, true);
|
||||
ro_gui_set_icon_string(pointer->w,
|
||||
ro_gui_set_icon_string(pointer->w,
|
||||
IMAGE_BACKGROUND_FIELD,
|
||||
image_quality_menu->entries[2].
|
||||
data.indirected_text.text, true);
|
||||
|
@ -228,7 +232,8 @@ bool ro_gui_options_image_click(wimp_pointer *pointer)
|
|||
|
||||
ro_gui_options_image_read(pointer->w, &bg, &fg);
|
||||
if ((bg != old_bg) || (fg != old_fg))
|
||||
ro_gui_options_image_update(pointer->w, pointer->i);
|
||||
ro_gui_options_image_update(pointer->w, pointer->i,
|
||||
NULL, NULL, NO_ACTION);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -247,7 +252,7 @@ void ro_gui_options_update_shading(wimp_w w)
|
|||
|
||||
bool ro_gui_options_image_ok(wimp_w w)
|
||||
{
|
||||
ro_gui_options_image_read(w, (unsigned int *) &option_bg_plot_style,
|
||||
ro_gui_options_image_read(w, (unsigned int *) &option_bg_plot_style,
|
||||
(unsigned int *) &option_fg_plot_style);
|
||||
option_minimum_gif_delay = ro_gui_get_icon_decimal(w,
|
||||
IMAGE_SPEED_FIELD, 2);
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "riscos/menus.h"
|
||||
#include "riscos/options.h"
|
||||
#include "riscos/theme.h"
|
||||
#include "riscos/toolbar.h"
|
||||
#include "riscos/url_complete.h"
|
||||
#include "riscos/wimp.h"
|
||||
#include "riscos/wimp_event.h"
|
||||
|
@ -261,11 +262,17 @@ void ro_gui_options_theme_load(void)
|
|||
/* create toolbars for each theme */
|
||||
theme_count = 0;
|
||||
descriptor = theme_list;
|
||||
while (descriptor) {
|
||||
while (descriptor != NULL) {
|
||||
/* try to create a toolbar */
|
||||
toolbar = ro_gui_theme_create_toolbar(descriptor,
|
||||
THEME_BROWSER_TOOLBAR);
|
||||
if (toolbar) {
|
||||
toolbar = ro_toolbar_create(descriptor, NULL,
|
||||
THEME_STYLE_BROWSER_TOOLBAR,
|
||||
TOOLBAR_FLAGS_DISPLAY, NULL, NULL, NULL);
|
||||
if (toolbar != NULL) {
|
||||
ro_toolbar_add_buttons(toolbar, brower_toolbar_buttons,
|
||||
option_toolbar_browser);
|
||||
ro_toolbar_add_url(toolbar);
|
||||
ro_toolbar_add_throbber(toolbar);
|
||||
ro_toolbar_rebuild(toolbar);
|
||||
toolbar_display = calloc(sizeof(struct toolbar_display), 1);
|
||||
if (!toolbar_display) {
|
||||
LOG(("No memory for calloc()"));
|
||||
|
@ -311,21 +318,23 @@ void ro_gui_options_theme_load(void)
|
|||
/* update the toolbar */
|
||||
item_height = 44 + 44 + 16;
|
||||
if (link->next) item_height += 16;
|
||||
ro_gui_theme_process_toolbar(link->toolbar, parent_width);
|
||||
extent.y0 = nested_y - link->toolbar->height - item_height;
|
||||
ro_toolbar_process(link->toolbar, parent_width, false);
|
||||
extent.y0 = nested_y -
|
||||
ro_toolbar_height(link->toolbar) -
|
||||
item_height;
|
||||
if (link->next) extent.y0 -= 16;
|
||||
if (extent.y0 > min_extent) extent.y0 = min_extent;
|
||||
xwimp_set_extent(theme_pane, &extent);
|
||||
ro_gui_set_icon_button_type(link->toolbar->toolbar_handle,
|
||||
ICON_TOOLBAR_URL, wimp_BUTTON_NEVER);
|
||||
|
||||
/* create the descriptor icons and separator line */
|
||||
new_icon.icon.extent.x0 = 8;
|
||||
new_icon.icon.extent.x1 = parent_width - 8;
|
||||
new_icon.icon.flags &= ~wimp_ICON_BORDER;
|
||||
new_icon.icon.flags |= wimp_ICON_SPRITE;
|
||||
new_icon.icon.extent.y1 = nested_y - link->toolbar->height - 8;
|
||||
new_icon.icon.extent.y0 = nested_y - link->toolbar->height - 52;
|
||||
new_icon.icon.extent.y1 = nested_y -
|
||||
ro_toolbar_height(link->toolbar) - 8;
|
||||
new_icon.icon.extent.y0 = nested_y -
|
||||
ro_toolbar_height(link->toolbar) - 52;
|
||||
new_icon.icon.data.indirected_text_and_sprite.text =
|
||||
(char *)&link->descriptor->name;
|
||||
new_icon.icon.data.indirected_text_and_sprite.size =
|
||||
|
@ -363,10 +372,11 @@ void ro_gui_options_theme_load(void)
|
|||
}
|
||||
|
||||
/* nest the toolbar window */
|
||||
state.w = link->toolbar->toolbar_handle;
|
||||
state.w = ro_toolbar_get_window(link->toolbar);
|
||||
state.yscroll = 0;
|
||||
state.visible.y1 = nested_y + base_extent;
|
||||
state.visible.y0 = state.visible.y1 - link->toolbar->height + 2;
|
||||
state.visible.y0 = state.visible.y1 -
|
||||
ro_toolbar_height(link->toolbar) + 2;
|
||||
xwimp_open_window_nested(PTR_WIMP_OPEN(&state), theme_pane,
|
||||
wimp_CHILD_LINKS_PARENT_WORK_AREA
|
||||
<< wimp_CHILD_BS_EDGE_SHIFT |
|
||||
|
@ -374,7 +384,8 @@ void ro_gui_options_theme_load(void)
|
|||
<< wimp_CHILD_TS_EDGE_SHIFT);
|
||||
|
||||
/* continue processing */
|
||||
nested_y -= link->toolbar->height + item_height;
|
||||
nested_y -= ro_toolbar_height(link->toolbar) +
|
||||
item_height;
|
||||
link = link->next;
|
||||
}
|
||||
|
||||
|
@ -404,7 +415,7 @@ void ro_gui_options_theme_free(void)
|
|||
if (next_toolbar)
|
||||
xwimp_delete_icon(theme_pane,
|
||||
toolbar->icon_number + 2);
|
||||
ro_gui_theme_destroy_toolbar(toolbar->toolbar);
|
||||
ro_toolbar_destroy(toolbar->toolbar);
|
||||
free(toolbar);
|
||||
}
|
||||
toolbars = NULL;
|
||||
|
|
218
riscos/cookies.c
218
riscos/cookies.c
|
@ -36,7 +36,7 @@
|
|||
#include "riscos/dialog.h"
|
||||
#include "riscos/menus.h"
|
||||
#include "riscos/options.h"
|
||||
#include "riscos/theme.h"
|
||||
#include "riscos/toolbar.h"
|
||||
#include "riscos/treeview.h"
|
||||
#include "riscos/wimp.h"
|
||||
#include "riscos/wimp_event.h"
|
||||
|
@ -45,6 +45,22 @@
|
|||
#include "utils/url.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
static void ro_gui_cookies_toolbar_update_buttons(void);
|
||||
static void ro_gui_cookies_toolbar_save_buttons(char *config);
|
||||
static bool ro_gui_cookies_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
|
||||
wimp_pointer *pointer);
|
||||
static void ro_gui_cookies_menu_warning(wimp_w w, wimp_i i, wimp_menu *menu,
|
||||
wimp_selection *selection, menu_action action);
|
||||
static bool ro_gui_cookies_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
|
||||
wimp_selection *selection, menu_action action);
|
||||
static void ro_gui_cookies_toolbar_click(button_bar_action action);
|
||||
|
||||
struct ro_treeview_callbacks ro_cookies_treeview_callbacks = {
|
||||
ro_gui_cookies_toolbar_click,
|
||||
ro_gui_cookies_toolbar_update_buttons,
|
||||
ro_gui_cookies_toolbar_save_buttons
|
||||
};
|
||||
|
||||
/* The RISC OS cookie window, toolbar and treeview data. */
|
||||
|
||||
static struct ro_cookies_window {
|
||||
|
@ -76,21 +92,30 @@ void ro_gui_cookies_postinitialise(void)
|
|||
{
|
||||
/* Create our toolbar. */
|
||||
|
||||
cookies_window.toolbar = ro_gui_theme_create_toolbar(NULL,
|
||||
THEME_COOKIES_TOOLBAR);
|
||||
if (cookies_window.toolbar)
|
||||
ro_gui_theme_attach_toolbar(cookies_window.toolbar,
|
||||
cookies_window.window);
|
||||
cookies_window.toolbar = ro_toolbar_create(NULL, cookies_window.window,
|
||||
THEME_STYLE_COOKIES_TOOLBAR, TOOLBAR_FLAGS_NONE,
|
||||
ro_treeview_get_toolbar_callbacks(), NULL,
|
||||
"HelpCookiesToolbar");
|
||||
if (cookies_window.toolbar != NULL) {
|
||||
ro_toolbar_add_buttons(cookies_window.toolbar,
|
||||
cookies_toolbar_buttons,
|
||||
option_toolbar_cookies);
|
||||
ro_toolbar_rebuild(cookies_window.toolbar);
|
||||
}
|
||||
|
||||
/* Create the treeview with the window and toolbar. */
|
||||
|
||||
cookies_window.tv = ro_treeview_create(cookies_window.window,
|
||||
cookies_window.toolbar, cookies_get_tree_flags());
|
||||
cookies_window.toolbar, &ro_cookies_treeview_callbacks,
|
||||
cookies_get_tree_flags());
|
||||
if (cookies_window.tv == NULL) {
|
||||
LOG(("Failed to allocate treeview"));
|
||||
return;
|
||||
}
|
||||
|
||||
ro_toolbar_update_client_data(cookies_window.toolbar,
|
||||
cookies_window.tv);
|
||||
|
||||
/* Initialise the cookies into the tree. */
|
||||
|
||||
cookies_initialise(ro_treeview_get_tree(cookies_window.tv),
|
||||
|
@ -123,14 +148,18 @@ void ro_gui_cookies_postinitialise(void)
|
|||
};
|
||||
cookies_window.menu = ro_gui_menu_define_menu(&cookies_definition);
|
||||
|
||||
ro_gui_wimp_event_register_window_menu(cookies_window.window,
|
||||
cookies_window.menu, ro_gui_cookies_menu_prepare,
|
||||
ro_gui_cookies_menu_select, NULL,
|
||||
ro_gui_cookies_menu_warning, false);
|
||||
ro_gui_wimp_event_register_menu(cookies_window.window,
|
||||
cookies_window.menu, false, false);
|
||||
ro_gui_wimp_event_register_menu_prepare(cookies_window.window,
|
||||
ro_gui_cookies_menu_prepare);
|
||||
ro_gui_wimp_event_register_menu_selection(cookies_window.window,
|
||||
ro_gui_cookies_menu_select);
|
||||
ro_gui_wimp_event_register_menu_warning(cookies_window.window,
|
||||
ro_gui_cookies_menu_warning);
|
||||
}
|
||||
|
||||
/**
|
||||
* \TODO - Open the cookies window.
|
||||
* Open the cookies window.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -138,111 +167,128 @@ void ro_gui_cookies_open(void)
|
|||
{
|
||||
tree_set_redraw(ro_treeview_get_tree(cookies_window.tv), true);
|
||||
|
||||
ro_gui_cookies_toolbar_update_buttons();
|
||||
|
||||
if (!ro_gui_dialog_open_top(cookies_window.window,
|
||||
cookies_window.toolbar, 600, 800)) {
|
||||
ro_treeview_set_origin(cookies_window.tv, 0,
|
||||
-(ro_gui_theme_toolbar_height(
|
||||
cookies_window.toolbar)));
|
||||
-(ro_toolbar_height(cookies_window.toolbar)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle Mouse Click events on the toolbar.
|
||||
* Handle toolbar button clicks.
|
||||
*
|
||||
* \param *pointer Pointer to the Mouse Click Event block.
|
||||
* \return Return true if click handled; else false.
|
||||
* \param action The action to handle
|
||||
*/
|
||||
|
||||
bool ro_gui_cookies_toolbar_click(wimp_pointer *pointer)
|
||||
void ro_gui_cookies_toolbar_click(button_bar_action action)
|
||||
{
|
||||
if (pointer->buttons == wimp_CLICK_MENU)
|
||||
return ro_gui_wimp_event_process_window_menu_click(pointer);
|
||||
|
||||
if (cookies_window.toolbar->editor != NULL) {
|
||||
ro_gui_theme_toolbar_editor_click(cookies_window.toolbar,
|
||||
pointer);
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (pointer->i) {
|
||||
case ICON_TOOLBAR_DELETE:
|
||||
if (pointer->buttons == wimp_CLICK_SELECT) {
|
||||
cookies_delete_selected();
|
||||
return true;
|
||||
}
|
||||
switch (action) {
|
||||
case TOOLBAR_BUTTON_DELETE:
|
||||
cookies_delete_selected();
|
||||
break;
|
||||
case ICON_TOOLBAR_EXPAND:
|
||||
if (pointer->buttons == wimp_CLICK_SELECT) {
|
||||
cookies_expand_cookies();
|
||||
return true;
|
||||
} else if (pointer->buttons == wimp_CLICK_ADJUST) {
|
||||
cookies_collapse_cookies();
|
||||
return true;
|
||||
}
|
||||
|
||||
case TOOLBAR_BUTTON_EXPAND:
|
||||
cookies_expand_cookies();
|
||||
break;
|
||||
case ICON_TOOLBAR_OPEN:
|
||||
if (pointer->buttons == wimp_CLICK_SELECT) {
|
||||
cookies_expand_domains();
|
||||
return true;
|
||||
} else if (pointer->buttons == wimp_CLICK_ADJUST) {
|
||||
cookies_collapse_domains();
|
||||
return true;
|
||||
}
|
||||
|
||||
case TOOLBAR_BUTTON_COLLAPSE:
|
||||
cookies_collapse_cookies();
|
||||
break;
|
||||
|
||||
case TOOLBAR_BUTTON_OPEN:
|
||||
cookies_expand_domains();
|
||||
break;
|
||||
|
||||
case TOOLBAR_BUTTON_CLOSE:
|
||||
cookies_collapse_domains();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update the button state in the cookies toolbar.
|
||||
*/
|
||||
|
||||
void ro_gui_cookies_toolbar_update_buttons(void)
|
||||
{
|
||||
ro_toolbar_set_button_shaded_state(cookies_window.toolbar,
|
||||
TOOLBAR_BUTTON_DELETE,
|
||||
!ro_treeview_has_selection(cookies_window.tv));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save a new button arrangement in the cookies toolbar.
|
||||
*
|
||||
* \param *config The new button configuration string.
|
||||
*/
|
||||
|
||||
void ro_gui_cookies_toolbar_save_buttons(char *config)
|
||||
{
|
||||
if (option_toolbar_cookies != NULL)
|
||||
free(option_toolbar_cookies);
|
||||
option_toolbar_cookies = config;
|
||||
ro_gui_save_options();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prepare the cookies menu for opening
|
||||
*
|
||||
* \param window The window owning the menu.
|
||||
* \param w The window owning the menu.
|
||||
* \param i The icon owning the menu.
|
||||
* \param *menu The menu about to be opened.
|
||||
* \param *pointer Pointer to the relevant wimp event block, or
|
||||
* NULL for an Adjust click.
|
||||
* \return true if the event was handled; else false.
|
||||
*/
|
||||
|
||||
void ro_gui_cookies_menu_prepare(wimp_w window, wimp_menu *menu)
|
||||
bool ro_gui_cookies_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
|
||||
wimp_pointer *pointer)
|
||||
{
|
||||
bool selection;
|
||||
|
||||
if (menu != cookies_window.menu && menu != tree_toolbar_menu)
|
||||
return;
|
||||
if (menu != cookies_window.menu)
|
||||
return false;
|
||||
|
||||
if (menu == cookies_window.menu) {
|
||||
selection = ro_treeview_has_selection(cookies_window.tv);
|
||||
selection = ro_treeview_has_selection(cookies_window.tv);
|
||||
|
||||
ro_gui_menu_set_entry_shaded(cookies_window.menu, TREE_SELECTION,
|
||||
!selection);
|
||||
ro_gui_menu_set_entry_shaded(cookies_window.menu, TREE_CLEAR_SELECTION,
|
||||
!selection);
|
||||
}
|
||||
ro_gui_menu_set_entry_shaded(cookies_window.menu,
|
||||
TREE_SELECTION, !selection);
|
||||
ro_gui_menu_set_entry_shaded(cookies_window.menu,
|
||||
TREE_CLEAR_SELECTION, !selection);
|
||||
|
||||
ro_gui_menu_set_entry_shaded(menu, TOOLBAR_BUTTONS,
|
||||
(cookies_window.toolbar == NULL ||
|
||||
cookies_window.toolbar->editor));
|
||||
ro_toolbar_menu_option_shade(cookies_window.toolbar));
|
||||
ro_gui_menu_set_entry_ticked(menu, TOOLBAR_BUTTONS,
|
||||
(cookies_window.toolbar != NULL &&
|
||||
(cookies_window.toolbar->display_buttons ||
|
||||
(cookies_window.toolbar->editor))));
|
||||
ro_toolbar_menu_buttons_tick(cookies_window.toolbar));
|
||||
|
||||
ro_gui_menu_set_entry_shaded(menu, TOOLBAR_EDIT,
|
||||
cookies_window.toolbar == NULL);
|
||||
ro_toolbar_menu_edit_shade(cookies_window.toolbar));
|
||||
ro_gui_menu_set_entry_ticked(menu, TOOLBAR_EDIT,
|
||||
(cookies_window.toolbar != NULL &&
|
||||
cookies_window.toolbar->editor));
|
||||
ro_toolbar_menu_edit_tick(cookies_window.toolbar));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle submenu warnings for the cookies menu
|
||||
*
|
||||
* \param window The window owning the menu.
|
||||
* \param w The window owning the menu.
|
||||
* \param i The icon owning the menu.
|
||||
* \param *menu The menu to which the warning applies.
|
||||
* \param *selection The wimp menu selection data.
|
||||
* \param action The selected menu action.
|
||||
*/
|
||||
|
||||
void ro_gui_cookies_menu_warning(wimp_w window, wimp_menu *menu,
|
||||
void ro_gui_cookies_menu_warning(wimp_w w, wimp_i i, wimp_menu *menu,
|
||||
wimp_selection *selection, menu_action action)
|
||||
{
|
||||
/* Do nothing */
|
||||
|
@ -251,14 +297,15 @@ void ro_gui_cookies_menu_warning(wimp_w window, wimp_menu *menu,
|
|||
/**
|
||||
* Handle selections from the cookies menu
|
||||
*
|
||||
* \param window The window owning the menu.
|
||||
* \param w The window owning the menu.
|
||||
* \param i The icon owning the menu.
|
||||
* \param *menu The menu from which the selection was made.
|
||||
* \param *selection The wimp menu selection data.
|
||||
* \param action The selected menu action.
|
||||
* \return true if action accepted; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_cookies_menu_select(wimp_w window, wimp_menu *menu,
|
||||
bool ro_gui_cookies_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
|
||||
wimp_selection *selection, menu_action action)
|
||||
{
|
||||
switch (action) {
|
||||
|
@ -290,12 +337,12 @@ bool ro_gui_cookies_menu_select(wimp_w window, wimp_menu *menu,
|
|||
cookies_clear_selection();
|
||||
return true;
|
||||
case TOOLBAR_BUTTONS:
|
||||
cookies_window.toolbar->display_buttons =
|
||||
!cookies_window.toolbar->display_buttons;
|
||||
ro_gui_theme_refresh_toolbar(cookies_window.toolbar);
|
||||
ro_toolbar_set_display_buttons(cookies_window.toolbar,
|
||||
!ro_toolbar_get_display_buttons(
|
||||
cookies_window.toolbar));
|
||||
return true;
|
||||
case TOOLBAR_EDIT:
|
||||
ro_gui_theme_toggle_edit(cookies_window.toolbar);
|
||||
ro_toolbar_toggle_edit(cookies_window.toolbar);
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
@ -304,21 +351,6 @@ bool ro_gui_cookies_menu_select(wimp_w window, wimp_menu *menu,
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the theme details of the cookies window.
|
||||
*
|
||||
* \param full_update true to force a full theme change; false to
|
||||
* refresh the toolbar size.
|
||||
*/
|
||||
|
||||
void ro_gui_cookies_update_theme(bool full_update)
|
||||
{
|
||||
if (full_update)
|
||||
ro_treeview_update_theme(cookies_window.tv);
|
||||
else
|
||||
ro_treeview_update_toolbar(cookies_window.tv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a particular window handle is the cookies window
|
||||
*
|
||||
|
|
|
@ -30,16 +30,8 @@ void ro_gui_cookies_preinitialise(void);
|
|||
void ro_gui_cookies_postinitialise(void);
|
||||
bool ro_gui_cookies_check_window(wimp_w window);
|
||||
bool ro_gui_cookies_check_menu(wimp_menu *menu);
|
||||
bool ro_gui_cookies_toolbar_click(wimp_pointer *pointer);
|
||||
|
||||
void ro_gui_cookies_menu_prepare(wimp_w window, wimp_menu *menu);
|
||||
bool ro_gui_cookies_menu_select(wimp_w window, wimp_menu *menu,
|
||||
wimp_selection *selection, menu_action action);
|
||||
void ro_gui_cookies_menu_warning(wimp_w window, wimp_menu *menu,
|
||||
wimp_selection *selection, menu_action action);
|
||||
|
||||
void ro_gui_cookies_open(void);
|
||||
void ro_gui_cookies_update_theme(bool full_update);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include "riscos/options.h"
|
||||
#include "riscos/save.h"
|
||||
#include "riscos/sslcert.h"
|
||||
#include "riscos/theme.h"
|
||||
#include "riscos/toolbar.h"
|
||||
#include "riscos/url_complete.h"
|
||||
#include "riscos/url_suggest.h"
|
||||
#include "riscos/wimp.h"
|
||||
|
@ -86,6 +86,9 @@ static struct {
|
|||
|
||||
|
||||
static bool ro_gui_dialog_openurl_apply(wimp_w w);
|
||||
static bool ro_gui_dialog_open_url_menu_prepare(wimp_w w, wimp_i i,
|
||||
wimp_menu *menu, wimp_pointer *pointer);
|
||||
|
||||
static bool ro_gui_dialog_zoom_apply(wimp_w w);
|
||||
|
||||
/**
|
||||
|
@ -162,10 +165,12 @@ void ro_gui_dialog_init(void)
|
|||
/* open URL */
|
||||
dialog_openurl = ro_gui_dialog_create("open_url");
|
||||
ro_gui_wimp_event_register_menu_gright(dialog_openurl, ICON_OPENURL_URL,
|
||||
ICON_OPENURL_MENU, url_suggest_menu);
|
||||
ICON_OPENURL_MENU, ro_gui_url_suggest_menu);
|
||||
ro_gui_wimp_event_register_cancel(dialog_openurl, ICON_OPENURL_CANCEL);
|
||||
ro_gui_wimp_event_register_ok(dialog_openurl, ICON_OPENURL_OPEN,
|
||||
ro_gui_dialog_openurl_apply);
|
||||
ro_gui_wimp_event_register_menu_prepare(dialog_openurl,
|
||||
ro_gui_dialog_open_url_menu_prepare);
|
||||
ro_gui_wimp_event_set_help_prefix(dialog_openurl, "HelpOpenURL");
|
||||
|
||||
/* scale view */
|
||||
|
@ -426,8 +431,8 @@ bool ro_gui_dialog_open_top(wimp_w w, struct toolbar *toolbar,
|
|||
open = state.flags & wimp_WINDOW_OPEN;
|
||||
if (!open) {
|
||||
/* cancel any editing */
|
||||
if ((toolbar) && (toolbar->editor))
|
||||
ro_gui_theme_toggle_edit(toolbar);
|
||||
if (ro_toolbar_get_editing(toolbar))
|
||||
ro_toolbar_toggle_edit(toolbar);
|
||||
|
||||
/* move to the centre */
|
||||
ro_gui_screen_size(&screen_width, &screen_height);
|
||||
|
@ -443,7 +448,7 @@ bool ro_gui_dialog_open_top(wimp_w w, struct toolbar *toolbar,
|
|||
state.xscroll = 0;
|
||||
state.yscroll = 0;
|
||||
if (toolbar)
|
||||
state.yscroll = ro_gui_theme_toolbar_height(toolbar);
|
||||
state.yscroll = ro_toolbar_height(toolbar);
|
||||
}
|
||||
|
||||
/* open the window at the top of the stack */
|
||||
|
@ -727,3 +732,28 @@ void ro_gui_dialog_prepare_open_url(void)
|
|||
ICON_OPENURL_MENU, !ro_gui_url_suggest_prepare_menu());
|
||||
ro_gui_wimp_event_memorise(dialog_openurl);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Callback to prepare menus in the Open URL dialog. At present, this
|
||||
* only has to handle the URL Suggestion pop-up.
|
||||
*
|
||||
* \param w The window handle owning the menu.
|
||||
* \param i The icon handle owning the menu.
|
||||
* \param *menu The menu to be prepared.
|
||||
* \param *pointer The associated mouse click event block, or NULL
|
||||
* on an Adjust-click re-opening.
|
||||
* \return true if the event was handled; false if not.
|
||||
*/
|
||||
|
||||
bool ro_gui_dialog_open_url_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
|
||||
wimp_pointer *pointer)
|
||||
{
|
||||
if (menu != ro_gui_url_suggest_menu || i != ICON_OPENURL_MENU)
|
||||
return false;
|
||||
|
||||
if (pointer != NULL)
|
||||
return ro_gui_url_suggest_prepare_menu();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include "oslib/wimp.h"
|
||||
#include "riscos/theme.h"
|
||||
#include "riscos/toolbar.h"
|
||||
#include "riscos/gui.h"
|
||||
|
||||
void ro_gui_dialog_init(void);
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include "riscos/menus.h"
|
||||
#include "riscos/options.h"
|
||||
#include "riscos/save.h"
|
||||
#include "riscos/theme.h"
|
||||
#include "riscos/toolbar.h"
|
||||
#include "riscos/treeview.h"
|
||||
#include "riscos/wimp.h"
|
||||
#include "riscos/wimp_event.h"
|
||||
|
@ -47,6 +47,22 @@
|
|||
#include "utils/url.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
static void ro_gui_global_history_toolbar_update_buttons(void);
|
||||
static void ro_gui_global_history_toolbar_save_buttons(char *config);
|
||||
static bool ro_gui_global_history_menu_prepare(wimp_w w, wimp_i i,
|
||||
wimp_menu *menu, wimp_pointer *pointer);
|
||||
static void ro_gui_global_history_menu_warning(wimp_w w, wimp_i i,
|
||||
wimp_menu *menu, wimp_selection *selection, menu_action action);
|
||||
static bool ro_gui_global_history_menu_select(wimp_w w, wimp_i i,
|
||||
wimp_menu *menu, wimp_selection *selection, menu_action action);
|
||||
static void ro_gui_global_history_toolbar_click(button_bar_action action);
|
||||
|
||||
struct ro_treeview_callbacks ro_global_history_treeview_callbacks = {
|
||||
ro_gui_global_history_toolbar_click,
|
||||
ro_gui_global_history_toolbar_update_buttons,
|
||||
ro_gui_global_history_toolbar_save_buttons
|
||||
};
|
||||
|
||||
/* The RISC OS global history window, toolbar and treeview data */
|
||||
|
||||
static struct ro_global_history_window {
|
||||
|
@ -76,26 +92,35 @@ void ro_gui_global_history_preinitialise(void)
|
|||
|
||||
void ro_gui_global_history_postinitialise(void)
|
||||
{
|
||||
|
||||
/* Create our toolbar. */
|
||||
|
||||
global_history_window.toolbar = ro_gui_theme_create_toolbar(NULL,
|
||||
THEME_HISTORY_TOOLBAR);
|
||||
if (global_history_window.toolbar)
|
||||
ro_gui_theme_attach_toolbar(global_history_window.toolbar,
|
||||
global_history_window.window);
|
||||
global_history_window.toolbar = ro_toolbar_create(NULL,
|
||||
global_history_window.window,
|
||||
THEME_STYLE_GLOBAL_HISTORY_TOOLBAR, TOOLBAR_FLAGS_NONE,
|
||||
ro_treeview_get_toolbar_callbacks(), NULL,
|
||||
"HelpGHistoryToolbar");
|
||||
if (global_history_window.toolbar != NULL) {
|
||||
ro_toolbar_add_buttons(global_history_window.toolbar,
|
||||
global_history_toolbar_buttons,
|
||||
option_toolbar_history);
|
||||
ro_toolbar_rebuild(global_history_window.toolbar);
|
||||
}
|
||||
|
||||
/* Create the treeview with the window and toolbar. */
|
||||
|
||||
global_history_window.tv =
|
||||
ro_treeview_create(global_history_window.window,
|
||||
global_history_window.toolbar,
|
||||
&ro_global_history_treeview_callbacks,
|
||||
history_global_get_tree_flags());
|
||||
if (global_history_window.tv == NULL) {
|
||||
LOG(("Failed to allocate treeview"));
|
||||
return;
|
||||
}
|
||||
|
||||
ro_toolbar_update_client_data(global_history_window.toolbar,
|
||||
global_history_window.tv);
|
||||
|
||||
/* Initialise the global history into the tree. */
|
||||
|
||||
history_global_initialise(
|
||||
|
@ -130,11 +155,14 @@ void ro_gui_global_history_postinitialise(void)
|
|||
global_history_window.menu = ro_gui_menu_define_menu(
|
||||
&global_history_definition);
|
||||
|
||||
ro_gui_wimp_event_register_window_menu(global_history_window.window,
|
||||
global_history_window.menu,
|
||||
ro_gui_global_history_menu_prepare,
|
||||
ro_gui_global_history_menu_select, NULL,
|
||||
ro_gui_global_history_menu_warning, false);
|
||||
ro_gui_wimp_event_register_menu(global_history_window.window,
|
||||
global_history_window.menu, false, false);
|
||||
ro_gui_wimp_event_register_menu_prepare(global_history_window.window,
|
||||
ro_gui_global_history_menu_prepare);
|
||||
ro_gui_wimp_event_register_menu_selection(global_history_window.window,
|
||||
ro_gui_global_history_menu_select);
|
||||
ro_gui_wimp_event_register_menu_warning(global_history_window.window,
|
||||
ro_gui_global_history_menu_warning);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -145,120 +173,143 @@ void ro_gui_global_history_open(void)
|
|||
{
|
||||
tree_set_redraw(ro_treeview_get_tree(global_history_window.tv), true);
|
||||
|
||||
ro_gui_global_history_toolbar_update_buttons();
|
||||
|
||||
if (!ro_gui_dialog_open_top(global_history_window.window,
|
||||
global_history_window.toolbar, 600, 800)) {
|
||||
ro_treeview_set_origin(global_history_window.tv, 0,
|
||||
-(ro_gui_theme_toolbar_height(
|
||||
-(ro_toolbar_height(
|
||||
global_history_window.toolbar)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Mouse Click events on the toolbar.
|
||||
* Handle toolbar button clicks.
|
||||
*
|
||||
* \param *pointer Pointer to the Mouse Click Event block.
|
||||
* \return Return true if click handled; else false.
|
||||
* \param action The action to handle
|
||||
*/
|
||||
|
||||
bool ro_gui_global_history_toolbar_click(wimp_pointer *pointer)
|
||||
void ro_gui_global_history_toolbar_click(button_bar_action action)
|
||||
{
|
||||
if (pointer->buttons == wimp_CLICK_MENU)
|
||||
return ro_gui_wimp_event_process_window_menu_click(pointer);
|
||||
switch (action) {
|
||||
case TOOLBAR_BUTTON_DELETE:
|
||||
history_global_delete_selected();
|
||||
break;
|
||||
|
||||
if (global_history_window.toolbar->editor != NULL) {
|
||||
ro_gui_theme_toolbar_editor_click(global_history_window.toolbar,
|
||||
pointer);
|
||||
return true;
|
||||
}
|
||||
case TOOLBAR_BUTTON_EXPAND:
|
||||
history_global_expand_addresses();
|
||||
break;
|
||||
|
||||
switch (pointer->i) {
|
||||
case ICON_TOOLBAR_DELETE:
|
||||
if (pointer->buttons == wimp_CLICK_SELECT) {
|
||||
history_global_delete_selected();
|
||||
return true;
|
||||
}
|
||||
case TOOLBAR_BUTTON_COLLAPSE:
|
||||
history_global_collapse_addresses();
|
||||
break;
|
||||
case ICON_TOOLBAR_EXPAND:
|
||||
if (pointer->buttons == wimp_CLICK_SELECT) {
|
||||
history_global_expand_addresses();
|
||||
return true;
|
||||
} else if (pointer->buttons == wimp_CLICK_ADJUST) {
|
||||
history_global_collapse_addresses();
|
||||
return true;
|
||||
}
|
||||
|
||||
case TOOLBAR_BUTTON_OPEN:
|
||||
history_global_expand_directories();
|
||||
break;
|
||||
case ICON_TOOLBAR_OPEN:
|
||||
if (pointer->buttons == wimp_CLICK_SELECT) {
|
||||
history_global_expand_directories();
|
||||
return true;
|
||||
} else if (pointer->buttons == wimp_CLICK_ADJUST) {
|
||||
history_global_collapse_directories();
|
||||
return true;
|
||||
}
|
||||
|
||||
case TOOLBAR_BUTTON_CLOSE:
|
||||
history_global_collapse_directories();
|
||||
break;
|
||||
case ICON_TOOLBAR_LAUNCH:
|
||||
if (pointer->buttons == wimp_CLICK_SELECT) {
|
||||
history_global_launch_selected();
|
||||
return true;
|
||||
}
|
||||
|
||||
case TOOLBAR_BUTTON_LAUNCH:
|
||||
history_global_launch_selected();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
/**
|
||||
* Update the button state in the global history toolbar.
|
||||
*/
|
||||
|
||||
void ro_gui_global_history_toolbar_update_buttons(void)
|
||||
{
|
||||
ro_toolbar_set_button_shaded_state(global_history_window.toolbar,
|
||||
TOOLBAR_BUTTON_DELETE,
|
||||
!ro_treeview_has_selection(global_history_window.tv));
|
||||
|
||||
ro_toolbar_set_button_shaded_state(global_history_window.toolbar,
|
||||
TOOLBAR_BUTTON_LAUNCH,
|
||||
!ro_treeview_has_selection(global_history_window.tv));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save a new button arrangement in the global history toolbar.
|
||||
*
|
||||
* \param *config The new button configuration string.
|
||||
*/
|
||||
|
||||
void ro_gui_global_history_toolbar_save_buttons(char *config)
|
||||
{
|
||||
if (option_toolbar_history != NULL)
|
||||
free(option_toolbar_history);
|
||||
option_toolbar_history = config;
|
||||
ro_gui_save_options();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prepare the global history menu for opening
|
||||
*
|
||||
* \param window The window owning the menu.
|
||||
* \param w The window owning the menu.
|
||||
* \param i The icon owning the menu.
|
||||
* \param *menu The menu about to be opened.
|
||||
* \param *pointer Pointer to the relevant wimp event block, or
|
||||
* NULL for an Adjust click.
|
||||
* \return true if the event was handled; else false.
|
||||
*/
|
||||
|
||||
void ro_gui_global_history_menu_prepare(wimp_w window, wimp_menu *menu)
|
||||
bool ro_gui_global_history_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
|
||||
wimp_pointer *pointer)
|
||||
{
|
||||
bool selection;
|
||||
|
||||
if (menu != global_history_window.menu && menu != tree_toolbar_menu)
|
||||
return;
|
||||
if (menu != global_history_window.menu)
|
||||
return false;
|
||||
|
||||
if (menu == global_history_window.menu) {
|
||||
selection = ro_treeview_has_selection(global_history_window.tv);
|
||||
selection = ro_treeview_has_selection(global_history_window.tv);
|
||||
|
||||
ro_gui_menu_set_entry_shaded(global_history_window.menu,
|
||||
TREE_SELECTION, !selection);
|
||||
ro_gui_menu_set_entry_shaded(global_history_window.menu,
|
||||
TREE_CLEAR_SELECTION, !selection);
|
||||
ro_gui_menu_set_entry_shaded(global_history_window.menu,
|
||||
TREE_SELECTION, !selection);
|
||||
ro_gui_menu_set_entry_shaded(global_history_window.menu,
|
||||
TREE_CLEAR_SELECTION, !selection);
|
||||
|
||||
ro_gui_save_prepare(GUI_SAVE_HISTORY_EXPORT_HTML,
|
||||
NULL, NULL, NULL, NULL);
|
||||
}
|
||||
ro_gui_save_prepare(GUI_SAVE_HISTORY_EXPORT_HTML,
|
||||
NULL, NULL, NULL, NULL);
|
||||
|
||||
ro_gui_menu_set_entry_shaded(menu, TOOLBAR_BUTTONS,
|
||||
(global_history_window.toolbar == NULL ||
|
||||
global_history_window.toolbar->editor));
|
||||
ro_toolbar_menu_option_shade(
|
||||
global_history_window.toolbar));
|
||||
ro_gui_menu_set_entry_ticked(menu, TOOLBAR_BUTTONS,
|
||||
(global_history_window.toolbar != NULL &&
|
||||
(global_history_window.toolbar->display_buttons ||
|
||||
(global_history_window.toolbar->editor))));
|
||||
ro_toolbar_menu_buttons_tick(
|
||||
global_history_window.toolbar));
|
||||
|
||||
ro_gui_menu_set_entry_shaded(menu, TOOLBAR_EDIT,
|
||||
global_history_window.toolbar == NULL);
|
||||
ro_toolbar_menu_edit_shade(
|
||||
global_history_window.toolbar));
|
||||
ro_gui_menu_set_entry_ticked(menu, TOOLBAR_EDIT,
|
||||
(global_history_window.toolbar != NULL &&
|
||||
global_history_window.toolbar->editor));
|
||||
ro_toolbar_menu_edit_tick(
|
||||
global_history_window.toolbar));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle submenu warnings for the global_hostory menu
|
||||
*
|
||||
* \param window The window owning the menu.
|
||||
* \param w The window owning the menu.
|
||||
* \param i The icon owning the menu.
|
||||
* \param *menu The menu to which the warning applies.
|
||||
* \param *selection The wimp menu selection data.
|
||||
* \param action The selected menu action.
|
||||
*/
|
||||
|
||||
void ro_gui_global_history_menu_warning(wimp_w window, wimp_menu *menu,
|
||||
void ro_gui_global_history_menu_warning(wimp_w w, wimp_i i, wimp_menu *menu,
|
||||
wimp_selection *selection, menu_action action)
|
||||
{
|
||||
/* Do nothing */
|
||||
|
@ -267,19 +318,20 @@ void ro_gui_global_history_menu_warning(wimp_w window, wimp_menu *menu,
|
|||
/**
|
||||
* Handle selections from the global history menu
|
||||
*
|
||||
* \param window The window owning the menu.
|
||||
* \param w The window owning the menu.
|
||||
* \param i The icon owning the menu.
|
||||
* \param *menu The menu from which the selection was made.
|
||||
* \param *selection The wimp menu selection data.
|
||||
* \param action The selected menu action.
|
||||
* \return true if action accepted; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_global_history_menu_select(wimp_w window, wimp_menu *menu,
|
||||
bool ro_gui_global_history_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
|
||||
wimp_selection *selection, menu_action action)
|
||||
{
|
||||
switch (action) {
|
||||
case HISTORY_EXPORT:
|
||||
ro_gui_dialog_open_persistent(window, dialog_saveas, true);
|
||||
ro_gui_dialog_open_persistent(w, dialog_saveas, true);
|
||||
return true;
|
||||
case TREE_EXPAND_ALL:
|
||||
history_global_expand_all();
|
||||
|
@ -312,12 +364,12 @@ bool ro_gui_global_history_menu_select(wimp_w window, wimp_menu *menu,
|
|||
history_global_clear_selection();
|
||||
return true;
|
||||
case TOOLBAR_BUTTONS:
|
||||
global_history_window.toolbar->display_buttons =
|
||||
!global_history_window.toolbar->display_buttons;
|
||||
ro_gui_theme_refresh_toolbar(global_history_window.toolbar);
|
||||
ro_toolbar_set_display_buttons(global_history_window.toolbar,
|
||||
!ro_toolbar_get_display_buttons(
|
||||
global_history_window.toolbar));
|
||||
return true;
|
||||
case TOOLBAR_EDIT:
|
||||
ro_gui_theme_toggle_edit(global_history_window.toolbar);
|
||||
ro_toolbar_toggle_edit(global_history_window.toolbar);
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
@ -326,21 +378,6 @@ bool ro_gui_global_history_menu_select(wimp_w window, wimp_menu *menu,
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the theme details of the global history window.
|
||||
*
|
||||
* \param full_update true to force a full theme change; false to
|
||||
* refresh the toolbar size.
|
||||
*/
|
||||
|
||||
void ro_gui_global_history_update_theme(bool full_update)
|
||||
{
|
||||
if (full_update)
|
||||
ro_treeview_update_theme(global_history_window.tv);
|
||||
else
|
||||
ro_treeview_update_toolbar(global_history_window.tv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a particular window handle is the global history window
|
||||
*
|
||||
|
|
|
@ -30,16 +30,8 @@ void ro_gui_global_history_preinitialise(void);
|
|||
void ro_gui_global_history_postinitialise(void);
|
||||
void ro_gui_global_history_open(void);
|
||||
void ro_gui_global_history_save(void);
|
||||
void ro_gui_global_history_update_theme(bool full_update);
|
||||
bool ro_gui_global_history_check_window(wimp_w window);
|
||||
bool ro_gui_global_history_check_menu(wimp_menu *menu);
|
||||
bool ro_gui_global_history_toolbar_click(wimp_pointer *pointer);
|
||||
|
||||
void ro_gui_global_history_menu_prepare(wimp_w window, wimp_menu *menu);
|
||||
bool ro_gui_global_history_menu_select(wimp_w window, wimp_menu *menu,
|
||||
wimp_selection *selection, menu_action action);
|
||||
void ro_gui_global_history_menu_warning(wimp_w window, wimp_menu *menu,
|
||||
wimp_selection *selection, menu_action action);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
83
riscos/gui.c
83
riscos/gui.c
|
@ -74,6 +74,7 @@
|
|||
#include "riscos/gui.h"
|
||||
#include "riscos/help.h"
|
||||
#include "riscos/hotlist.h"
|
||||
#include "riscos/iconbar.h"
|
||||
#include "riscos/menus.h"
|
||||
#include "riscos/message.h"
|
||||
#include "riscos/options.h"
|
||||
|
@ -86,6 +87,7 @@
|
|||
#include "riscos/sslcert.h"
|
||||
#include "riscos/textselection.h"
|
||||
#include "riscos/theme.h"
|
||||
#include "riscos/toolbar.h"
|
||||
#include "riscos/treeview.h"
|
||||
#include "riscos/uri.h"
|
||||
#include "riscos/url_protocol.h"
|
||||
|
@ -93,6 +95,7 @@
|
|||
#include "riscos/wimp.h"
|
||||
#include "riscos/wimp_event.h"
|
||||
#include "riscos/wimputils.h"
|
||||
#include "riscos/window.h"
|
||||
#include "utils/filename.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/messages.h"
|
||||
|
@ -249,7 +252,6 @@ static struct
|
|||
static void ro_gui_create_dirs(void);
|
||||
static void ro_gui_create_dir(char *path);
|
||||
static void ro_gui_choose_language(void);
|
||||
static void ro_gui_icon_bar_create(void);
|
||||
static void ro_gui_signal(int sig);
|
||||
static void ro_gui_cleanup(void);
|
||||
static void ro_gui_handle_event(wimp_event_no event, wimp_block *block);
|
||||
|
@ -257,7 +259,6 @@ static void ro_gui_null_reason_code(void);
|
|||
static void ro_gui_close_window_request(wimp_close *close);
|
||||
static void ro_gui_pointer_leaving_window(wimp_leaving *leaving);
|
||||
static void ro_gui_pointer_entering_window(wimp_entering *entering);
|
||||
static bool ro_gui_icon_bar_click(wimp_pointer *pointer);
|
||||
static void ro_gui_check_resolvers(void);
|
||||
static void ro_gui_drag_end(wimp_dragged *drag);
|
||||
static void ro_gui_keypress(wimp_key *key);
|
||||
|
@ -349,7 +350,7 @@ static void gui_init(int argc, char** argv)
|
|||
option_theme_path = strdup("NetSurf:Themes");
|
||||
if (!option_theme_save)
|
||||
option_theme_save = strdup(CHOICES_PREFIX "Themes");
|
||||
|
||||
|
||||
tree_set_icon_dir(strdup("NetSurf:Resources.Icons"));
|
||||
|
||||
if (!option_theme || ! option_toolbar_browser ||
|
||||
|
@ -479,12 +480,16 @@ static void gui_init(int argc, char** argv)
|
|||
ro_gui_query_init();
|
||||
/* Initialise the history subsystem */
|
||||
ro_gui_history_init();
|
||||
/* Initialise toolbars */
|
||||
ro_toolbar_init();
|
||||
/* Initialise browser windows */
|
||||
ro_gui_window_initialise();
|
||||
|
||||
/* Done with the templates file */
|
||||
wimp_close_template();
|
||||
|
||||
/* Create Iconbar icon */
|
||||
ro_gui_icon_bar_create();
|
||||
/* Create Iconbar icon and menus */
|
||||
ro_gui_iconbar_initialise();
|
||||
|
||||
/* Finally, check Inet$Resolvers for sanity */
|
||||
ro_gui_check_resolvers();
|
||||
|
@ -620,31 +625,6 @@ const char *ro_gui_default_language(void)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create an iconbar icon.
|
||||
*/
|
||||
|
||||
void ro_gui_icon_bar_create(void)
|
||||
{
|
||||
os_error *error;
|
||||
|
||||
wimp_icon_create icon = {
|
||||
wimp_ICON_BAR_RIGHT,
|
||||
{ { 0, 0, 68, 68 },
|
||||
wimp_ICON_SPRITE | wimp_ICON_HCENTRED | wimp_ICON_VCENTRED |
|
||||
(wimp_BUTTON_CLICK << wimp_ICON_BUTTON_TYPE_SHIFT),
|
||||
{ "!netsurf" } } };
|
||||
error = xwimp_create_icon(&icon, 0);
|
||||
if (error) {
|
||||
LOG(("xwimp_create_icon: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
die(error->errmess);
|
||||
}
|
||||
ro_gui_wimp_event_register_mouse_click(wimp_ICON_BAR,
|
||||
ro_gui_icon_bar_click);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Warn the user if Inet$Resolvers is not set.
|
||||
*/
|
||||
|
@ -1233,43 +1213,6 @@ void ro_gui_pointer_entering_window(wimp_entering *entering)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle Mouse_Click events on the iconbar icon.
|
||||
*/
|
||||
|
||||
bool ro_gui_icon_bar_click(wimp_pointer *pointer)
|
||||
{
|
||||
char url[80];
|
||||
int key_down = 0;
|
||||
|
||||
if (pointer->buttons == wimp_CLICK_MENU) {
|
||||
ro_gui_menu_create(iconbar_menu, pointer->pos.x,
|
||||
96 + iconbar_menu_height, wimp_ICON_BAR,
|
||||
true);
|
||||
|
||||
} else if (pointer->buttons == wimp_CLICK_SELECT) {
|
||||
if (option_homepage_url && option_homepage_url[0]) {
|
||||
browser_window_create(option_homepage_url, NULL, 0,
|
||||
true, false);
|
||||
} else {
|
||||
snprintf(url, sizeof url,
|
||||
"file:///<NetSurf$Dir>/Docs/welcome/index_%s",
|
||||
option_language);
|
||||
browser_window_create(url, NULL, 0, true, false);
|
||||
}
|
||||
|
||||
} else if (pointer->buttons == wimp_CLICK_ADJUST) {
|
||||
xosbyte1(osbyte_SCAN_KEYBOARD, 0 ^ 0x80, 0, &key_down);
|
||||
if (key_down == 0)
|
||||
ro_gui_menu_handle_action(pointer->w, HOTLIST_SHOW,
|
||||
false);
|
||||
else
|
||||
ro_gui_debugwin_open();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle User_Drag_Box events.
|
||||
*/
|
||||
|
@ -1302,8 +1245,8 @@ void ro_gui_drag_end(wimp_dragged *drag)
|
|||
ro_treeview_drag_end(drag);
|
||||
break;
|
||||
|
||||
case GUI_DRAG_TOOLBAR_CONFIG:
|
||||
ro_gui_theme_toolbar_editor_drag_end(drag);
|
||||
case GUI_DRAG_BUTTONBAR:
|
||||
ro_gui_button_bar_drag_end(drag);
|
||||
break;
|
||||
|
||||
case GUI_DRAG_FRAME:
|
||||
|
@ -1376,7 +1319,7 @@ void ro_gui_user_message(wimp_event_no event, wimp_message *message)
|
|||
break;
|
||||
|
||||
case message_MENUS_DELETED:
|
||||
ro_gui_menu_closed(true);
|
||||
ro_gui_menu_closed();
|
||||
break;
|
||||
|
||||
case message_CLAIM_ENTITY:
|
||||
|
|
34
riscos/gui.h
34
riscos/gui.h
|
@ -67,7 +67,7 @@ extern bool print_active, print_text_black;
|
|||
|
||||
typedef enum { GUI_DRAG_NONE, GUI_DRAG_SELECTION, GUI_DRAG_DOWNLOAD_SAVE,
|
||||
GUI_DRAG_SAVE, GUI_DRAG_SCROLL, GUI_DRAG_STATUS_RESIZE,
|
||||
GUI_DRAG_TREEVIEW, GUI_DRAG_TOOLBAR_CONFIG,
|
||||
GUI_DRAG_TREEVIEW, GUI_DRAG_BUTTONBAR,
|
||||
GUI_DRAG_FRAME } gui_drag_type;
|
||||
|
||||
extern gui_drag_type gui_current_drag_type;
|
||||
|
@ -94,9 +94,6 @@ struct gui_window {
|
|||
|
||||
char title[256]; /**< Buffer for window title. */
|
||||
|
||||
int throbber; /**< Current frame of throbber animation. */
|
||||
int throbtime; /**< Time of last throbber frame. */
|
||||
|
||||
int iconise_icon; /**< ID number of icon when window is iconised */
|
||||
|
||||
char validation[12]; /**< Validation string for colours */
|
||||
|
@ -136,26 +133,28 @@ bool ro_gui_download_prequit(void);
|
|||
void ro_gui_401login_init(void);
|
||||
|
||||
/* in window.c */
|
||||
void ro_gui_scroll_request(wimp_scroll *scroll);
|
||||
bool ro_gui_window_dataload(struct gui_window *g, wimp_message *message);
|
||||
void ro_gui_window_mouse_at(struct gui_window *g, wimp_pointer *pointer);
|
||||
void ro_gui_window_iconise(struct gui_window *g,
|
||||
wimp_full_message_window_info *wi);
|
||||
void ro_gui_window_scroll_end(struct gui_window *g, wimp_dragged *drag);
|
||||
void ro_gui_window_frame_resize_end(struct gui_window *g, wimp_dragged *drag);
|
||||
bool ro_gui_toolbar_dataload(struct gui_window *g, wimp_message *message);
|
||||
void ro_gui_window_redraw_all(void);
|
||||
void ro_gui_window_update_boxes(void);
|
||||
void ro_gui_window_process_reformats(void);
|
||||
void ro_gui_window_quit(void);
|
||||
/* void ro_gui_window_close_all(void); */
|
||||
#define ro_gui_window_close_all ro_gui_window_quit /* no need for a separate fn */
|
||||
void ro_gui_window_update_theme(void);
|
||||
void ro_gui_window_mouse_at(struct gui_window *g, wimp_pointer *pointer);
|
||||
bool ro_gui_toolbar_click(wimp_pointer *pointer);
|
||||
void ro_gui_throb(void);
|
||||
void ro_gui_window_default_options(struct browser_window *bw);
|
||||
struct gui_window *ro_gui_window_lookup(wimp_w window);
|
||||
struct gui_window *ro_gui_toolbar_lookup(wimp_w window);
|
||||
void ro_gui_scroll_request(wimp_scroll *scroll);
|
||||
bool ro_gui_window_to_window_pos(struct gui_window *g, int x, int y,
|
||||
os_coord *pos);
|
||||
bool ro_gui_window_to_screen_pos(struct gui_window *g, int x, int y,
|
||||
os_coord *pos);
|
||||
bool ro_gui_window_dataload(struct gui_window *g, wimp_message *message);
|
||||
bool ro_gui_toolbar_dataload(struct gui_window *g, wimp_message *message);
|
||||
void ro_gui_window_process_reformats(void);
|
||||
void ro_gui_window_default_options(struct browser_window *bw);
|
||||
void ro_gui_window_redraw_all(void);
|
||||
void ro_gui_window_prepare_navigate_all(void);
|
||||
browser_mouse_state ro_gui_mouse_click_state(wimp_mouse_state buttons,
|
||||
wimp_icon_flags type);
|
||||
browser_mouse_state ro_gui_mouse_drag_state(wimp_mouse_state buttons,
|
||||
|
@ -163,12 +162,6 @@ browser_mouse_state ro_gui_mouse_drag_state(wimp_mouse_state buttons,
|
|||
bool ro_gui_shift_pressed(void);
|
||||
bool ro_gui_ctrl_pressed(void);
|
||||
bool ro_gui_alt_pressed(void);
|
||||
void ro_gui_window_scroll_end(struct gui_window *g, wimp_dragged *drag);
|
||||
void ro_gui_window_frame_resize_end(struct gui_window *g, wimp_dragged *drag);
|
||||
void ro_gui_window_iconise(struct gui_window *g,
|
||||
wimp_full_message_window_info *wi);
|
||||
bool ro_gui_window_navigate_up(struct gui_window *g, const char *url);
|
||||
void ro_gui_window_update_boxes(void);
|
||||
|
||||
/* in history.c */
|
||||
void ro_gui_history_init(void);
|
||||
|
@ -192,7 +185,6 @@ void ro_gui_debugwin_open(void);
|
|||
/* in search.c */
|
||||
void ro_gui_search_init(void);
|
||||
void ro_gui_search_prepare(struct browser_window *g);
|
||||
bool ro_gui_search_prepare_menu(void);
|
||||
|
||||
/* in print.c */
|
||||
void ro_gui_print_init(void);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,314 @@
|
|||
/*
|
||||
* Copyright 2005 Richard Wilson <info@tinct.net>
|
||||
* Copyright 2011 Stephen Fryatt <stevef@netsurf-browser.org>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
* NetSurf is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* NetSurf is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Button bars (interface).
|
||||
*/
|
||||
|
||||
#ifndef _NETSURF_RISCOS_BUTTONBAR_H_
|
||||
#define _NETSURF_RISCOS_BUTTONBAR_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "riscos/theme.h"
|
||||
|
||||
/* A list of possible toolbar actions. */
|
||||
|
||||
typedef enum {
|
||||
TOOLBAR_BUTTON_NONE = 0, /* Special case: no action */
|
||||
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
|
||||
} button_bar_action;
|
||||
|
||||
/* Button bar button source definitions.
|
||||
*
|
||||
* Help tokens are added to the help prefix for the given toolbar by the
|
||||
* help system, and correspond to the hard-coded icon numbers that were
|
||||
* assigned to the different buttons in the original toolbar implementation.
|
||||
* If the Messages file can be updated, these can change to something more
|
||||
* meaningful.
|
||||
*/
|
||||
|
||||
struct button_bar_buttons {
|
||||
const char *icon; /**< The sprite used for the icon. */
|
||||
button_bar_action select; /**< The action for select clicks. */
|
||||
button_bar_action adjust; /**< The action for Adjust clicks. */
|
||||
const char opt_key; /**< The char used in option strings. */
|
||||
const char *help; /**< The interactive help token. */
|
||||
};
|
||||
|
||||
/* \TODO -- Move these to the correct modules.
|
||||
*/
|
||||
|
||||
static const struct button_bar_buttons brower_toolbar_buttons[] = {
|
||||
{"back", TOOLBAR_BUTTON_BACK, TOOLBAR_BUTTON_BACK_NEW, '0', "0"},
|
||||
{"up", TOOLBAR_BUTTON_UP, TOOLBAR_BUTTON_UP_NEW, 'b', "11"},
|
||||
{"forward", TOOLBAR_BUTTON_FORWARD, TOOLBAR_BUTTON_FORWARD_NEW, '1', "1"},
|
||||
{"stop", TOOLBAR_BUTTON_STOP, TOOLBAR_BUTTON_NONE, '2', "2"},
|
||||
{"reload", TOOLBAR_BUTTON_RELOAD, TOOLBAR_BUTTON_RELOAD_ALL, '3', "3"},
|
||||
{"home", TOOLBAR_BUTTON_HOME, TOOLBAR_BUTTON_NONE, '4', "4"},
|
||||
{"history", TOOLBAR_BUTTON_HISTORY_LOCAL, TOOLBAR_BUTTON_HISTORY_GLOBAL, '5', "5"},
|
||||
{"save", TOOLBAR_BUTTON_SAVE_SOURCE, TOOLBAR_BUTTON_SAVE_COMPLETE, '6', "6"},
|
||||
{"print", TOOLBAR_BUTTON_PRINT, TOOLBAR_BUTTON_NONE, '7', "7"},
|
||||
{"hotlist", TOOLBAR_BUTTON_BOOKMARK_OPEN, TOOLBAR_BUTTON_BOOKMARK_ADD, '8', "8"},
|
||||
{"scale", TOOLBAR_BUTTON_SCALE, TOOLBAR_BUTTON_NONE, '9', "9"},
|
||||
{"search", TOOLBAR_BUTTON_SEARCH, TOOLBAR_BUTTON_NONE, 'a', "10"},
|
||||
{NULL, TOOLBAR_BUTTON_NONE, TOOLBAR_BUTTON_NONE, '\0', ""}
|
||||
};
|
||||
|
||||
static const struct button_bar_buttons cookies_toolbar_buttons[] = {
|
||||
{"delete", TOOLBAR_BUTTON_DELETE, TOOLBAR_BUTTON_NONE, '0', "0"},
|
||||
{"expand", TOOLBAR_BUTTON_EXPAND, TOOLBAR_BUTTON_COLLAPSE, '1', "1"},
|
||||
{"open", TOOLBAR_BUTTON_OPEN, TOOLBAR_BUTTON_CLOSE, '2', "2"},
|
||||
{NULL, TOOLBAR_BUTTON_NONE, TOOLBAR_BUTTON_NONE, '\0', ""}
|
||||
};
|
||||
|
||||
static const struct button_bar_buttons global_history_toolbar_buttons[] = {
|
||||
{"delete", TOOLBAR_BUTTON_DELETE, TOOLBAR_BUTTON_NONE, '0', "0"},
|
||||
{"expand", TOOLBAR_BUTTON_EXPAND, TOOLBAR_BUTTON_COLLAPSE, '1', "1"},
|
||||
{"open", TOOLBAR_BUTTON_OPEN, TOOLBAR_BUTTON_CLOSE, '2', "2"},
|
||||
{"launch", TOOLBAR_BUTTON_LAUNCH, TOOLBAR_BUTTON_NONE, '3', "3"},
|
||||
{NULL, TOOLBAR_BUTTON_NONE, TOOLBAR_BUTTON_NONE, '\0', ""}
|
||||
};
|
||||
|
||||
static const struct button_bar_buttons hotlist_toolbar_buttons[] = {
|
||||
{"delete", TOOLBAR_BUTTON_DELETE, TOOLBAR_BUTTON_NONE, '0', "0"},
|
||||
{"expand", TOOLBAR_BUTTON_EXPAND, TOOLBAR_BUTTON_COLLAPSE, '1', "1"},
|
||||
{"open", TOOLBAR_BUTTON_OPEN, TOOLBAR_BUTTON_CLOSE, '2', "2"},
|
||||
{"launch", TOOLBAR_BUTTON_LAUNCH, TOOLBAR_BUTTON_NONE, '3', "3"},
|
||||
{"create", TOOLBAR_BUTTON_CREATE, TOOLBAR_BUTTON_NONE, '4', "4"},
|
||||
{NULL, TOOLBAR_BUTTON_NONE, TOOLBAR_BUTTON_NONE, '\0', ""}
|
||||
};
|
||||
|
||||
struct button_bar;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new button bar widget.
|
||||
*
|
||||
* \param *theme The theme to apply (or NULL for the default).
|
||||
* \param buttons[] An array of button definitions for the bar.
|
||||
* \return A button bar handle, or NULL on failure.
|
||||
*/
|
||||
|
||||
struct button_bar *ro_gui_button_bar_create(struct theme_descriptor *theme,
|
||||
const struct button_bar_buttons buttons[]);
|
||||
|
||||
|
||||
/**
|
||||
* Link two button bars together: 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.
|
||||
*
|
||||
* \param *target The target button bar.
|
||||
* \param *source The source button bar.
|
||||
* \return true if successful; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_button_bar_link_editor(struct button_bar *target,
|
||||
struct button_bar *source, void (* refresh)(void *),
|
||||
void *client_data);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* \param *button_bar The button bar to rebuild.
|
||||
* \param *theme The theme to apply (or NULL for current).
|
||||
* \param style The theme style to apply.
|
||||
* \param window The window that the bar is in.
|
||||
* \param edit The edit mode of the button bar.
|
||||
* \return true on success; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_button_bar_rebuild(struct button_bar *button_bar,
|
||||
struct theme_descriptor *theme, theme_style style,
|
||||
wimp_w window, bool edit);
|
||||
|
||||
|
||||
/**
|
||||
* Arrange buttons on a button bar, using an order string to specify the
|
||||
* required button and separator layout.
|
||||
*
|
||||
* \param *button_bar The button bar to update.
|
||||
* \param order[] The button order configuration string.
|
||||
* \return true if successful; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_button_bar_arrange_buttons(struct button_bar *button_bar,
|
||||
char order[]);
|
||||
|
||||
|
||||
/**
|
||||
* Destroy a button bar widget.
|
||||
*
|
||||
* \param *button_bar The button bar to destroy.
|
||||
*/
|
||||
|
||||
void ro_gui_button_bar_destroy(struct button_bar *button_bar);
|
||||
|
||||
|
||||
/**
|
||||
* Return the MINIMUM dimensions required by the button bar, in RO units,
|
||||
* allowing for the current theme.
|
||||
*
|
||||
* \param *button_bar The button bar of interest.
|
||||
* \param *width Return the required width.
|
||||
* \param *height Return the required height.
|
||||
* \return true if values are returned; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_button_bar_get_dims(struct button_bar *button_bar,
|
||||
int *width, int *height);
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* \param *button_bar The button bar to update.
|
||||
* \param x0 The minimum X window position.
|
||||
* \param y0 The minimum Y window position.
|
||||
* \param x1 The maximum X window position.
|
||||
* \param y1 The maximum Y window position.
|
||||
* \return true if size updated; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_button_bar_set_extent(struct button_bar *button_bar,
|
||||
int x0, int y0, int x1, int y1);
|
||||
|
||||
|
||||
/**
|
||||
* Show or hide a button bar.
|
||||
*
|
||||
* \param *button_bar The button bar to hide.
|
||||
* \param hide true to hide the bar; false to show it.
|
||||
* \return true if successful; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_button_bar_hide(struct button_bar *button_bar, bool hide);
|
||||
|
||||
|
||||
/**
|
||||
* Shade or unshade a button in a bar corresponding to the given action.
|
||||
*
|
||||
* \param *button_bar The button bar to update.
|
||||
* \param action The action to update.
|
||||
* \param shaded true to shade the button; false to unshade.
|
||||
* \return true if successful; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_button_bar_shade_button(struct button_bar *button_bar,
|
||||
button_bar_action action, bool shaded);
|
||||
|
||||
|
||||
/**
|
||||
* Handle redraw event rectangles in a button bar.
|
||||
*
|
||||
* \param *button_bar The button bar to use.
|
||||
* \param *redraw The Wimp redraw rectangle to process.
|
||||
*/
|
||||
|
||||
void ro_gui_button_bar_redraw(struct button_bar *button_bar,
|
||||
wimp_draw *redraw);
|
||||
|
||||
|
||||
/**
|
||||
* Handle mouse clicks in a button bar.
|
||||
*
|
||||
* \param *button_bar The button bar to use.
|
||||
* \param *pointer The Wimp mouse click event data.
|
||||
* \param *state The toolbar window state.
|
||||
* \param *action Returns the selected action, or
|
||||
* TOOLBAR_BUTTON_NONE.
|
||||
* \return true if the event was handled exclusively;
|
||||
* else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_button_bar_click(struct button_bar *button_bar,
|
||||
wimp_pointer *pointer, wimp_window_state *state,
|
||||
button_bar_action *action);
|
||||
|
||||
|
||||
/**
|
||||
* Translate mouse data into an interactive help message for a button bar.
|
||||
*
|
||||
* \param *button_bar The button bar to process.
|
||||
* \param i The wimp icon under the pointer.
|
||||
* \param *mouse The mouse position.
|
||||
* \param *state The toolbar window state.
|
||||
* \param buttons The mouse button state.
|
||||
* \param **suffix Return a help token suffix, or "" for none.
|
||||
* \return true if handled exclusively; else false.
|
||||
*/
|
||||
|
||||
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);
|
||||
|
||||
|
||||
/**
|
||||
* Terminate a drag event that was initiated by a button bar.
|
||||
*
|
||||
* \param *drag The drag event data.
|
||||
*/
|
||||
|
||||
void ro_gui_button_bar_drag_end(wimp_dragged *drag);
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* \param *button_bar The button bar of interest.
|
||||
* \return Pointer to a config string, or NULL on failure.
|
||||
*/
|
||||
|
||||
char *ro_gui_button_bar_get_config(struct button_bar *button_bar);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,419 @@
|
|||
/*
|
||||
* Copyright 2004, 2005 Richard Wilson <info@tinct.net>
|
||||
* Copyright 2011 Stephen Fryatt <stevef@netsurf-browser.org>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
* NetSurf is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* NetSurf is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Throbber (implementation).
|
||||
*/
|
||||
|
||||
#include <alloca.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "oslib/os.h"
|
||||
#include "oslib/osspriteop.h"
|
||||
#include "oslib/wimp.h"
|
||||
#include "riscos/gui/throbber.h"
|
||||
#include "riscos/theme.h"
|
||||
#include "riscos/wimp.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
#define THROBBER_SPRITE_NAME_LENGTH 12
|
||||
#define THROBBER_ANIMATE_INTERVAL 10
|
||||
|
||||
struct throbber {
|
||||
/** The applied theme (or NULL to use the default) */
|
||||
struct theme_descriptor *theme;
|
||||
|
||||
/** The widget dimensions. */
|
||||
int x_min, y_min;
|
||||
|
||||
/** The window and icon details. */
|
||||
wimp_w window;
|
||||
wimp_i icon;
|
||||
os_box extent;
|
||||
osspriteop_area *sprites;
|
||||
bool hidden;
|
||||
bool shaded;
|
||||
|
||||
/** The animation details. */
|
||||
int max_frame;
|
||||
int current_frame;
|
||||
os_t last_update;
|
||||
char sprite_name[THROBBER_SPRITE_NAME_LENGTH];
|
||||
bool force_redraw;
|
||||
};
|
||||
|
||||
/*
|
||||
* Private function prototypes.
|
||||
*/
|
||||
|
||||
static bool ro_gui_throbber_icon_update(struct throbber *throbber);
|
||||
static bool ro_gui_throbber_icon_resize(struct throbber *throbber);
|
||||
|
||||
/* This is an exported interface documented in throbber.h */
|
||||
|
||||
struct throbber *ro_gui_throbber_create(struct theme_descriptor *theme)
|
||||
{
|
||||
struct throbber *throbber;
|
||||
|
||||
/* Allocate memory. */
|
||||
|
||||
throbber = malloc(sizeof(struct throbber));
|
||||
if (throbber == NULL) {
|
||||
LOG(("No memory for malloc()"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Set up default parameters. If reading the throbber theme data
|
||||
* fails, we give up and return a failure.
|
||||
*/
|
||||
|
||||
if (!ro_gui_theme_get_throbber_data(theme, &throbber->max_frame,
|
||||
&throbber->x_min, &throbber->y_min, NULL,
|
||||
&throbber->force_redraw)) {
|
||||
free(throbber);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
throbber->sprites = ro_gui_theme_get_sprites(theme);
|
||||
|
||||
throbber->theme = theme;
|
||||
|
||||
throbber->extent.x0 = 0;
|
||||
throbber->extent.y0 = 0;
|
||||
throbber->extent.x1 = 0;
|
||||
throbber->extent.y1 = 0;
|
||||
|
||||
throbber->current_frame = 0;
|
||||
throbber->last_update = 0;
|
||||
|
||||
throbber->window = NULL;
|
||||
throbber->icon = -1;
|
||||
|
||||
throbber->hidden = false;
|
||||
throbber->shaded = false;
|
||||
|
||||
return throbber;
|
||||
}
|
||||
|
||||
|
||||
/* This is an exported interface documented in throbber.h */
|
||||
|
||||
bool ro_gui_throbber_rebuild(struct throbber *throbber,
|
||||
struct theme_descriptor *theme, theme_style style,
|
||||
wimp_w window, bool shaded)
|
||||
{
|
||||
if (throbber == NULL)
|
||||
return false;
|
||||
|
||||
throbber->theme = theme;
|
||||
throbber->window = window;
|
||||
throbber->sprites = ro_gui_theme_get_sprites(theme);
|
||||
|
||||
throbber->icon = -1;
|
||||
|
||||
throbber->shaded = shaded;
|
||||
|
||||
strcpy(throbber->sprite_name, "throbber0");
|
||||
|
||||
if (!ro_gui_theme_get_throbber_data(theme, &throbber->max_frame,
|
||||
&throbber->x_min, &throbber->y_min, NULL,
|
||||
&throbber->force_redraw)) {
|
||||
free(throbber);
|
||||
return false;
|
||||
}
|
||||
|
||||
return ro_gui_throbber_icon_update(throbber);
|
||||
}
|
||||
|
||||
|
||||
/* This is an exported interface documented in throbber.h */
|
||||
|
||||
void ro_gui_throbber_destroy(struct throbber *throbber)
|
||||
{
|
||||
if (throbber == NULL)
|
||||
return;
|
||||
|
||||
free(throbber);
|
||||
}
|
||||
|
||||
|
||||
/* This is an exported interface documented in throbber.h */
|
||||
|
||||
bool ro_gui_throbber_get_dims(struct throbber *throbber,
|
||||
int *width, int *height)
|
||||
{
|
||||
if (throbber == NULL)
|
||||
return false;
|
||||
|
||||
if (throbber->x_min != -1 && throbber->y_min != -1) {
|
||||
if (width != NULL)
|
||||
*width = throbber->x_min;
|
||||
if (height != NULL)
|
||||
*height = throbber->y_min;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* This is an exported interface documented in throbber.h */
|
||||
|
||||
bool ro_gui_throbber_set_extent(struct throbber *throbber,
|
||||
int x0, int y0, int x1, int y1)
|
||||
{
|
||||
if (throbber == NULL)
|
||||
return false;
|
||||
|
||||
if ((x1 - x0) < throbber->x_min || (y1 - y0) < throbber->y_min)
|
||||
return false;
|
||||
|
||||
if (throbber->extent.x0 == x0 && throbber->extent.y0 == y0 &&
|
||||
throbber->extent.x1 == x1 &&
|
||||
throbber->extent.y1 == y1)
|
||||
return true;
|
||||
|
||||
/* Redraw the relevant bits of the toolbar. */
|
||||
|
||||
if (throbber->window != NULL && throbber->icon != -1) {
|
||||
xwimp_force_redraw(throbber->window,
|
||||
throbber->extent.x0, throbber->extent.y0,
|
||||
throbber->extent.x1, throbber->extent.y1);
|
||||
xwimp_force_redraw(throbber->window, x0, y0, x1, y1);
|
||||
}
|
||||
|
||||
/* Update the throbber position */
|
||||
|
||||
throbber->extent.x0 = x0;
|
||||
throbber->extent.y0 = y0;
|
||||
throbber->extent.x1 = x1;
|
||||
throbber->extent.y1 = y1;
|
||||
|
||||
return ro_gui_throbber_icon_resize(throbber);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create or delete a throbber's icon if required to bring it into sync with
|
||||
* the current hidden setting.
|
||||
*
|
||||
* \param *throbber The throbber to update.
|
||||
* \return true if successful; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_throbber_icon_update(struct throbber *throbber)
|
||||
{
|
||||
wimp_icon_create icon;
|
||||
os_error *error;
|
||||
|
||||
if (throbber == NULL || throbber->window == NULL)
|
||||
return false;
|
||||
|
||||
if (!throbber->hidden && throbber->icon == -1) {
|
||||
icon.w = throbber->window;
|
||||
icon.icon.extent.x0 = throbber->extent.x0;
|
||||
icon.icon.extent.y0 = throbber->extent.y0;
|
||||
icon.icon.extent.x1 = throbber->extent.x1;
|
||||
icon.icon.extent.y1 = throbber->extent.y1;
|
||||
icon.icon.flags = wimp_ICON_SPRITE | wimp_ICON_INDIRECTED |
|
||||
wimp_ICON_HCENTRED | wimp_ICON_VCENTRED;
|
||||
icon.icon.data.indirected_sprite.id =
|
||||
(osspriteop_id) throbber->sprite_name;
|
||||
icon.icon.data.indirected_sprite.area = throbber->sprites;
|
||||
icon.icon.data.indirected_sprite.size =
|
||||
THROBBER_SPRITE_NAME_LENGTH;
|
||||
|
||||
error = xwimp_create_icon(&icon, &throbber->icon);
|
||||
if (error != NULL) {
|
||||
LOG(("xwimp_create_icon: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
warn_user("WimpError", error->errmess);
|
||||
throbber->icon = -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ro_gui_throbber_icon_resize(throbber))
|
||||
return false;
|
||||
} else if (throbber->hidden && throbber->icon != -1) {
|
||||
error = xwimp_delete_icon(throbber->window, throbber->icon);
|
||||
if (error != NULL) {
|
||||
LOG(("xwimp_delete_icon: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
warn_user("WimpError", error->errmess);
|
||||
return false;
|
||||
}
|
||||
|
||||
throbber->icon = -1;
|
||||
}
|
||||
|
||||
if (throbber->icon != -1)
|
||||
ro_gui_set_icon_shaded_state(throbber->window,
|
||||
throbber->icon, throbber->shaded);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Position the icons in the throbber to take account of the currently
|
||||
* configured extent.
|
||||
*
|
||||
* \param *throbber The throbber to update.
|
||||
* \return true if successful; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_throbber_icon_resize(struct throbber *throbber)
|
||||
{
|
||||
os_error *error;
|
||||
|
||||
if (throbber->window == NULL)
|
||||
return false;
|
||||
|
||||
if (throbber->icon != -1) {
|
||||
error = xwimp_resize_icon(throbber->window, throbber->icon,
|
||||
throbber->extent.x0, throbber->extent.y0,
|
||||
throbber->extent.x1, throbber->extent.y1);
|
||||
if (error != NULL) {
|
||||
LOG(("xwimp_resize_icon: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
warn_user("WimpError", error->errmess);
|
||||
throbber->icon = -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* This is an exported interface documented in throbber.h */
|
||||
|
||||
bool ro_gui_throbber_hide(struct throbber *throbber, bool hide)
|
||||
{
|
||||
if (throbber == NULL || throbber->hidden == hide)
|
||||
return (throbber == NULL) ? false : true;
|
||||
|
||||
throbber->hidden = hide;
|
||||
|
||||
return ro_gui_throbber_icon_update(throbber);
|
||||
}
|
||||
|
||||
|
||||
/* This is an exported interface documented in throbber.h */
|
||||
|
||||
bool ro_gui_throbber_help_suffix(struct throbber *throbber, wimp_i i,
|
||||
os_coord *mouse, wimp_window_state *state,
|
||||
wimp_mouse_state buttons, const char **suffix)
|
||||
{
|
||||
os_coord pos;
|
||||
|
||||
if (throbber == NULL || throbber->hidden)
|
||||
return false;
|
||||
|
||||
/* Check that the click was within our part of the window. */
|
||||
|
||||
pos.x = mouse->x - state->visible.x0 + state->xscroll;
|
||||
pos.y = mouse->y - state->visible.y1 + state->yscroll;
|
||||
|
||||
if (pos.x < throbber->extent.x0 || pos.x > throbber->extent.x1 ||
|
||||
pos.y < throbber->extent.y0 ||
|
||||
pos.y > throbber->extent.y1)
|
||||
return false;
|
||||
|
||||
/* Return a hard-coded icon number that matches the one that was
|
||||
* always allocated to the throbber in a previous implementation.
|
||||
* If Messages can be updated, this could be changed.
|
||||
*/
|
||||
|
||||
if (i == throbber->icon)
|
||||
*suffix = "16";
|
||||
else
|
||||
*suffix = "";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* This is an exported interface documented in throbber.h */
|
||||
|
||||
bool ro_gui_throbber_animate(struct throbber *throbber)
|
||||
{
|
||||
os_t t;
|
||||
char sprite_name[THROBBER_SPRITE_NAME_LENGTH];
|
||||
|
||||
if (throbber == NULL || throbber->hidden)
|
||||
return (throbber == NULL) ? false : true;
|
||||
|
||||
xos_read_monotonic_time(&t);
|
||||
|
||||
/* Drop out if we're not ready for the next frame, unless this
|
||||
* call is to start animation from a stopped throbber (ie. if
|
||||
* the current frame is 0).
|
||||
*/
|
||||
|
||||
if ((t < (throbber->last_update + THROBBER_ANIMATE_INTERVAL)) &&
|
||||
(throbber->current_frame > 0))
|
||||
return true;
|
||||
|
||||
throbber->last_update = t;
|
||||
throbber->current_frame++;
|
||||
|
||||
if (throbber->current_frame > throbber->max_frame)
|
||||
throbber->current_frame = 1;
|
||||
|
||||
snprintf(sprite_name, THROBBER_SPRITE_NAME_LENGTH,
|
||||
"throbber%i", throbber->current_frame);
|
||||
ro_gui_set_icon_string(throbber->window, throbber->icon,
|
||||
sprite_name, true);
|
||||
|
||||
if (throbber->force_redraw)
|
||||
ro_gui_force_redraw_icon(throbber->window, throbber->icon);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* This is an exported interface documented in throbber.h */
|
||||
|
||||
bool ro_gui_throbber_stop(struct throbber *throbber)
|
||||
{
|
||||
char sprite_name[THROBBER_SPRITE_NAME_LENGTH];
|
||||
|
||||
if (throbber == NULL || throbber->hidden ||
|
||||
throbber->current_frame == 0)
|
||||
return (throbber == FALSE) ? false : true;
|
||||
|
||||
throbber->current_frame = 0;
|
||||
throbber->last_update = 0;
|
||||
|
||||
strcpy(sprite_name, "throbber0");
|
||||
ro_gui_set_icon_string(throbber->window, throbber->icon,
|
||||
sprite_name, true);
|
||||
|
||||
if (throbber->force_redraw)
|
||||
ro_gui_force_redraw_icon(throbber->window, throbber->icon);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -0,0 +1,144 @@
|
|||
/*
|
||||
* Copyright 2005 Richard Wilson <info@tinct.net>
|
||||
* Copyright 2011 Stephen Fryatt <stevef@netsurf-browser.org>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
* NetSurf is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* NetSurf is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Throbber (interface).
|
||||
*/
|
||||
|
||||
#ifndef _NETSURF_RISCOS_THROBBER_H_
|
||||
#define _NETSURF_RISCOS_THROBBER_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "riscos/theme.h"
|
||||
|
||||
struct throbber;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new throbber widget.
|
||||
*
|
||||
* \param *theme The theme to apply (or NULL for the default).
|
||||
* \return A throbber handle, or NULL on failure.
|
||||
*/
|
||||
|
||||
struct throbber *ro_gui_throbber_create(struct theme_descriptor *theme);
|
||||
|
||||
/**
|
||||
* Place a throbber into a toolbar window and initialise any theme-specific
|
||||
* settings. Any previous incarnation of the throbber 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.
|
||||
*
|
||||
* \param *throbber The throbber to rebuild.
|
||||
* \param *theme The theme to apply (or NULL for current).
|
||||
* \param style The theme style to apply.
|
||||
* \param window The window that the throbber is in.
|
||||
* \param shaded true if the bar should be throbber; else false.
|
||||
* \return true on success; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_throbber_rebuild(struct throbber *throbber,
|
||||
struct theme_descriptor *theme, theme_style style,
|
||||
wimp_w window, bool shaded);
|
||||
|
||||
|
||||
/**
|
||||
* Destroy a throbber widget.
|
||||
*
|
||||
* \param *throbber The throbber to destroy.
|
||||
*/
|
||||
|
||||
void ro_gui_throbber_destroy(struct throbber *throbber);
|
||||
|
||||
|
||||
/**
|
||||
* Return the MINIMUM dimensions required by the throbber, in RO units,
|
||||
* allowing for the current theme.
|
||||
*
|
||||
* \param *throbber The throbber of interest.
|
||||
* \param *width Return the required width.
|
||||
* \param *height Return the required height.
|
||||
* \return true if values are returned; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_throbber_get_dims(struct throbber *throbber,
|
||||
int *width, int *height);
|
||||
|
||||
|
||||
/**
|
||||
* Set or update the dimensions to be used by the throbber, in RO units.
|
||||
* If these are greater than the minimum required, the throbber will fill
|
||||
* the extended space; if less, the call will fail.
|
||||
*
|
||||
* \param *throbber The throbber to update.
|
||||
* \param width The desired width.
|
||||
* \param height The desired height.
|
||||
* \return true if size updated; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_throbber_set_extent(struct throbber *throbber,
|
||||
int x0, int y0, int x1, int y1);
|
||||
|
||||
|
||||
/**
|
||||
* Show or hide a throbber.
|
||||
*
|
||||
* \param *throbber The throbber to hide.
|
||||
* \param hide true to hide the throbber; false to show it.
|
||||
* \return true if successful; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_throbber_hide(struct throbber *throbber, bool hide);
|
||||
|
||||
|
||||
/**
|
||||
* Translate mouse data into an interactive help message for the throbber.
|
||||
*
|
||||
* \param *throbber The throbber to process.
|
||||
* \param i The wimp icon under the pointer.
|
||||
* \param *mouse The mouse position.
|
||||
* \param *state The toolbar window state.
|
||||
* \param buttons The mouse button state.
|
||||
* \param **suffix Return a help token suffix, or "" for none.
|
||||
* \return true if handled exclusively; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_throbber_help_suffix(struct throbber *throbber, wimp_i i,
|
||||
os_coord *screenpos, wimp_window_state *state,
|
||||
wimp_mouse_state buttons, const char **suffix);
|
||||
|
||||
/**
|
||||
* Start or update the amimation of a throbber.
|
||||
*
|
||||
* \param *throbber The throbber to amimate.
|
||||
*/
|
||||
|
||||
bool ro_gui_throbber_animate(struct throbber *throbber);
|
||||
|
||||
|
||||
/**
|
||||
* Stop the amimation of a throbber.
|
||||
*
|
||||
* \param *throbber The throbber to amimate.
|
||||
*/
|
||||
|
||||
bool ro_gui_throbber_stop(struct throbber *throbber);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,984 @@
|
|||
/*
|
||||
* Copyright 2004, 2005 Richard Wilson <info@tinct.net>
|
||||
* Copyright 2011 Stephen Fryatt <stevef@netsurf-browser.org>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
* NetSurf is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* NetSurf is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* URL bars (implementation).
|
||||
*/
|
||||
|
||||
#include <alloca.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "oslib/os.h"
|
||||
#include "oslib/osspriteop.h"
|
||||
#include "oslib/wimp.h"
|
||||
#include "riscos/gui/url_bar.h"
|
||||
#include "riscos/theme.h"
|
||||
#include "riscos/url_suggest.h"
|
||||
#include "riscos/wimp.h"
|
||||
#include "riscos/wimp_event.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
#define URLBAR_HEIGHT 52
|
||||
#define URLBAR_FAVICON_WIDTH 52
|
||||
#define URLBAR_MIN_WIDTH 52
|
||||
#define URLBAR_GRIGHT_GUTTER 8
|
||||
#define URLBAR_FAVICON_NAME_LENGTH 12
|
||||
#define URLBAR_INITIAL_LENGTH 256
|
||||
#define URLBAR_EXTEND_LENGTH 128
|
||||
#define URLBAR_FAVICON_SIZE 16
|
||||
|
||||
struct url_bar {
|
||||
/** The applied theme (or NULL to use the default) */
|
||||
struct theme_descriptor *theme;
|
||||
|
||||
/** The widget dimensions. */
|
||||
int x_min, y_min;
|
||||
|
||||
/** The window and icon details. */
|
||||
wimp_w window;
|
||||
os_box extent;
|
||||
|
||||
wimp_i container_icon;
|
||||
|
||||
char favicon_sprite[URLBAR_FAVICON_NAME_LENGTH];
|
||||
int favicon_type;
|
||||
struct hlcache_handle *favicon_content;
|
||||
os_box favicon_extent;
|
||||
os_coord favicon_offset;
|
||||
int favicon_width, favicon_height;
|
||||
|
||||
wimp_i text_icon;
|
||||
char *text_buffer;
|
||||
size_t text_size;
|
||||
|
||||
wimp_i suggest_icon;
|
||||
int suggest_x, suggest_y;
|
||||
|
||||
bool hidden;
|
||||
bool display;
|
||||
bool shaded;
|
||||
};
|
||||
|
||||
static char text_validation[] = "Pptr_write;KN";
|
||||
static char suggest_icon[] = "gright";
|
||||
static char suggest_validation[] = "R5;Sgright,pgright";
|
||||
static char null_text_string[] = "";
|
||||
|
||||
|
||||
/*
|
||||
* Private function prototypes.
|
||||
*/
|
||||
|
||||
static bool ro_gui_url_bar_icon_update(struct url_bar *url_bar);
|
||||
static bool ro_gui_url_bar_icon_resize(struct url_bar *url_bar, bool full);
|
||||
|
||||
/* This is an exported interface documented in url_bar.h */
|
||||
|
||||
struct url_bar *ro_gui_url_bar_create(struct theme_descriptor *theme)
|
||||
{
|
||||
struct url_bar *url_bar;
|
||||
|
||||
/* Allocate memory. */
|
||||
|
||||
url_bar = malloc(sizeof(struct url_bar));
|
||||
if (url_bar == NULL) {
|
||||
LOG(("No memory for malloc()"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Set up default parameters. */
|
||||
|
||||
url_bar->theme = theme;
|
||||
|
||||
url_bar->display = false;
|
||||
url_bar->shaded = false;
|
||||
|
||||
url_bar->x_min = URLBAR_FAVICON_WIDTH + URLBAR_MIN_WIDTH;
|
||||
url_bar->y_min = URLBAR_HEIGHT;
|
||||
|
||||
url_bar->extent.x0 = 0;
|
||||
url_bar->extent.y0 = 0;
|
||||
url_bar->extent.x1 = 0;
|
||||
url_bar->extent.y1 = 0;
|
||||
|
||||
url_bar->window = NULL;
|
||||
url_bar->container_icon = -1;
|
||||
url_bar->text_icon = -1;
|
||||
url_bar->suggest_icon = -1;
|
||||
|
||||
url_bar->favicon_extent.x0 = 0;
|
||||
url_bar->favicon_extent.y0 = 0;
|
||||
url_bar->favicon_extent.x1 = 0;
|
||||
url_bar->favicon_extent.y1 = 0;
|
||||
url_bar->favicon_width = 0;
|
||||
url_bar->favicon_height = 0;
|
||||
url_bar->favicon_content = NULL;
|
||||
url_bar->favicon_type = 0;
|
||||
strncpy(url_bar->favicon_sprite, "Ssmall_xxx",
|
||||
URLBAR_FAVICON_NAME_LENGTH);
|
||||
|
||||
url_bar->text_size = URLBAR_INITIAL_LENGTH;
|
||||
url_bar->text_buffer = malloc(url_bar->text_size);
|
||||
strncpy(url_bar->text_buffer, "", url_bar->text_size);
|
||||
|
||||
url_bar->hidden = false;
|
||||
|
||||
return url_bar;
|
||||
}
|
||||
|
||||
|
||||
/* This is an exported interface documented in url_bar.h */
|
||||
|
||||
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)
|
||||
{
|
||||
if (url_bar == NULL)
|
||||
return false;
|
||||
|
||||
url_bar->theme = theme;
|
||||
url_bar->window = window;
|
||||
|
||||
url_bar->display = display;
|
||||
url_bar->shaded = shaded;
|
||||
|
||||
url_bar->container_icon = -1;
|
||||
url_bar->text_icon = -1;
|
||||
url_bar->suggest_icon = -1;
|
||||
|
||||
ro_gui_wimp_get_sprite_dimensions((osspriteop_area *) -1,
|
||||
suggest_icon, &url_bar->suggest_x, &url_bar->suggest_y);
|
||||
|
||||
url_bar->x_min = URLBAR_FAVICON_WIDTH + URLBAR_MIN_WIDTH +
|
||||
URLBAR_GRIGHT_GUTTER + url_bar->suggest_x;
|
||||
url_bar->y_min = (url_bar->suggest_y > URLBAR_HEIGHT) ?
|
||||
url_bar->suggest_y : URLBAR_HEIGHT;
|
||||
|
||||
return ro_gui_url_bar_icon_update(url_bar);
|
||||
}
|
||||
|
||||
|
||||
/* This is an exported interface documented in url_bar.h */
|
||||
|
||||
void ro_gui_url_bar_destroy(struct url_bar *url_bar)
|
||||
{
|
||||
if (url_bar == NULL)
|
||||
return;
|
||||
|
||||
free(url_bar);
|
||||
}
|
||||
|
||||
|
||||
/* This is an exported interface documented in url_bar.h */
|
||||
|
||||
bool ro_gui_url_bar_get_dims(struct url_bar *url_bar,
|
||||
int *width, int *height)
|
||||
{
|
||||
if (url_bar == NULL)
|
||||
return false;
|
||||
|
||||
if (url_bar->x_min != -1 && url_bar->y_min != -1) {
|
||||
if (width != NULL)
|
||||
*width = url_bar->x_min;
|
||||
if (height != NULL)
|
||||
*height = url_bar->y_min;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* This is an exported interface documented in url_bar.h */
|
||||
|
||||
bool ro_gui_url_bar_set_extent(struct url_bar *url_bar,
|
||||
int x0, int y0, int x1, int y1)
|
||||
{
|
||||
bool stretch;
|
||||
|
||||
if (url_bar == NULL)
|
||||
return false;
|
||||
|
||||
if ((x1 - x0) < url_bar->x_min || (y1 - y0) < url_bar->y_min)
|
||||
return false;
|
||||
|
||||
if (url_bar->extent.x0 == x0 && url_bar->extent.y0 == y0 &&
|
||||
url_bar->extent.x1 == x1 &&
|
||||
url_bar->extent.y1 == y1)
|
||||
return true;
|
||||
|
||||
/* If it's only the length that changes, less needs to be updated. */
|
||||
|
||||
stretch = (url_bar->extent.x0 == x0 && url_bar->extent.y0 == y0 &&
|
||||
url_bar->extent.y1 == y1) ? true : false;
|
||||
|
||||
/* Redraw the relevant bits of the toolbar. */
|
||||
|
||||
if (url_bar->window != NULL && url_bar->container_icon != -1) {
|
||||
xwimp_force_redraw(url_bar->window,
|
||||
url_bar->extent.x0 +
|
||||
(stretch) ? URLBAR_FAVICON_WIDTH : 0,
|
||||
url_bar->extent.y0,
|
||||
url_bar->extent.x1, url_bar->extent.y1);
|
||||
xwimp_force_redraw(url_bar->window,
|
||||
x0 + (stretch) ? URLBAR_FAVICON_WIDTH : 0,
|
||||
y0, x1, y1);
|
||||
}
|
||||
|
||||
/* Reposition the URL bar icons. */
|
||||
|
||||
url_bar->extent.x0 = x0;
|
||||
url_bar->extent.y0 = y0;
|
||||
url_bar->extent.x1 = x1;
|
||||
url_bar->extent.y1 = y1;
|
||||
|
||||
return ro_gui_url_bar_icon_resize(url_bar, !stretch);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create or delete a URL bar's icons if required to bring it into sync with
|
||||
* the current hidden setting.
|
||||
*
|
||||
* \param *url_bar The URL bar to update.
|
||||
* \return true if successful; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_url_bar_icon_update(struct url_bar *url_bar)
|
||||
{
|
||||
wimp_icon_create icon;
|
||||
os_error *error;
|
||||
bool resize;
|
||||
|
||||
if (url_bar == NULL || url_bar->window == NULL)
|
||||
return false;
|
||||
|
||||
icon.w = url_bar->window;
|
||||
icon.icon.extent.x0 = 0;
|
||||
icon.icon.extent.y0 = 0;
|
||||
icon.icon.extent.x1 = 0;
|
||||
icon.icon.extent.y1 = 0;
|
||||
|
||||
resize = false;
|
||||
|
||||
/* Create or delete the container icon. */
|
||||
|
||||
if (!url_bar->hidden && url_bar->container_icon == -1) {
|
||||
icon.icon.flags = wimp_ICON_BORDER |
|
||||
(wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT);
|
||||
error = xwimp_create_icon(&icon, &url_bar->container_icon);
|
||||
if (error != NULL) {
|
||||
LOG(("xwimp_create_icon: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
warn_user("WimpError", error->errmess);
|
||||
url_bar->container_icon = -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
resize = true;
|
||||
} else if (url_bar->hidden && url_bar->container_icon != -1){
|
||||
error = xwimp_delete_icon(url_bar->window,
|
||||
url_bar->container_icon);
|
||||
if (error != NULL) {
|
||||
LOG(("xwimp_delete_icon: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
warn_user("WimpError", error->errmess);
|
||||
return false;
|
||||
}
|
||||
|
||||
url_bar->container_icon = -1;
|
||||
}
|
||||
|
||||
/* Create or delete the text icon. */
|
||||
|
||||
if (!url_bar->hidden && url_bar->text_icon == -1) {
|
||||
icon.icon.data.indirected_text.text = url_bar->text_buffer;
|
||||
icon.icon.data.indirected_text.validation = text_validation;
|
||||
icon.icon.data.indirected_text.size = url_bar->text_size;
|
||||
icon.icon.flags = wimp_ICON_TEXT | wimp_ICON_INDIRECTED |
|
||||
wimp_ICON_VCENTRED | wimp_ICON_FILLED |
|
||||
(wimp_COLOUR_BLACK <<
|
||||
wimp_ICON_FG_COLOUR_SHIFT);
|
||||
if (url_bar->display)
|
||||
icon.icon.flags |= (wimp_BUTTON_NEVER <<
|
||||
wimp_ICON_BUTTON_TYPE_SHIFT);
|
||||
else
|
||||
icon.icon.flags |= (wimp_BUTTON_WRITE_CLICK_DRAG <<
|
||||
wimp_ICON_BUTTON_TYPE_SHIFT);
|
||||
error = xwimp_create_icon(&icon, &url_bar->text_icon);
|
||||
if (error) {
|
||||
LOG(("xwimp_create_icon: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
warn_user("WimpError", error->errmess);
|
||||
url_bar->text_icon = -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
resize = true;
|
||||
} else if (url_bar->hidden && url_bar->text_icon != -1) {
|
||||
error = xwimp_delete_icon(url_bar->window,
|
||||
url_bar->text_icon);
|
||||
if (error != NULL) {
|
||||
LOG(("xwimp_delete_icon: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
warn_user("WimpError", error->errmess);
|
||||
return false;
|
||||
}
|
||||
|
||||
url_bar->text_icon = -1;
|
||||
}
|
||||
|
||||
/* Create or delete the suggest icon. */
|
||||
|
||||
if (!url_bar->hidden && url_bar->suggest_icon == -1) {
|
||||
icon.icon.data.indirected_text.text = null_text_string;
|
||||
icon.icon.data.indirected_text.size = 1;
|
||||
icon.icon.data.indirected_text.validation = suggest_validation;
|
||||
icon.icon.flags = wimp_ICON_TEXT | wimp_ICON_SPRITE |
|
||||
wimp_ICON_INDIRECTED | wimp_ICON_HCENTRED |
|
||||
wimp_ICON_VCENTRED | (wimp_BUTTON_CLICK <<
|
||||
wimp_ICON_BUTTON_TYPE_SHIFT);
|
||||
error = xwimp_create_icon(&icon, &url_bar->suggest_icon);
|
||||
if (error) {
|
||||
LOG(("xwimp_create_icon: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
warn_user("WimpError", error->errmess);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!url_bar->display)
|
||||
ro_gui_wimp_event_register_menu_gright(url_bar->window,
|
||||
wimp_ICON_WINDOW, url_bar->suggest_icon,
|
||||
ro_gui_url_suggest_menu);
|
||||
|
||||
if (!ro_gui_url_bar_update_urlsuggest(url_bar))
|
||||
return false;
|
||||
|
||||
resize = true;
|
||||
} else if (url_bar->hidden && url_bar->suggest_icon != -1) {
|
||||
ro_gui_wimp_event_deregister(url_bar->window,
|
||||
url_bar->suggest_icon);
|
||||
error = xwimp_delete_icon(url_bar->window,
|
||||
url_bar->suggest_icon);
|
||||
if (error != NULL) {
|
||||
LOG(("xwimp_delete_icon: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
warn_user("WimpError", error->errmess);
|
||||
return false;
|
||||
}
|
||||
|
||||
url_bar->suggest_icon = -1;
|
||||
}
|
||||
|
||||
/* If any icons were created, resize the bar. */
|
||||
|
||||
if (resize && !ro_gui_url_bar_icon_resize(url_bar, true))
|
||||
return false;
|
||||
|
||||
/* If there are any icons, apply shading as necessary. */
|
||||
|
||||
if (url_bar->container_icon != -1)
|
||||
ro_gui_set_icon_shaded_state(url_bar->window,
|
||||
url_bar->container_icon, url_bar->shaded);
|
||||
|
||||
if (url_bar->text_icon != -1)
|
||||
ro_gui_set_icon_shaded_state(url_bar->window,
|
||||
url_bar->text_icon, url_bar->shaded);
|
||||
|
||||
if (url_bar->suggest_icon != -1)
|
||||
ro_gui_set_icon_shaded_state(url_bar->window,
|
||||
url_bar->suggest_icon, url_bar->shaded);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Position the icons in the URL bar to take account of the currently
|
||||
* configured extent.
|
||||
*
|
||||
* \param *url_bar The URL bar to update.
|
||||
* \param full true to resize everything; false to move only
|
||||
* the right-hand end of the bar.
|
||||
* \return true if successful; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_url_bar_icon_resize(struct url_bar *url_bar, bool full)
|
||||
{
|
||||
int x0, y0, x1, y1;
|
||||
int centre;
|
||||
os_error *error;
|
||||
os_coord eig = {1, 1};
|
||||
wimp_caret caret;
|
||||
|
||||
if (url_bar == NULL || url_bar->window == NULL)
|
||||
return false;
|
||||
|
||||
/* calculate 1px in OS units */
|
||||
ro_convert_pixels_to_os_units(&eig, (os_mode) -1);
|
||||
|
||||
/* The vertical centre line of the widget's extent. */
|
||||
|
||||
centre = url_bar->extent.y0 +
|
||||
(url_bar->extent.y1 - url_bar->extent.y0) / 2;
|
||||
|
||||
/* Position the container icon. */
|
||||
|
||||
if (url_bar->container_icon != -1) {
|
||||
x0 = url_bar->extent.x0;
|
||||
x1 = url_bar->extent.x1 -
|
||||
url_bar->suggest_x - URLBAR_GRIGHT_GUTTER;
|
||||
|
||||
y0 = centre - (URLBAR_HEIGHT / 2);
|
||||
y1 = y0 + URLBAR_HEIGHT;
|
||||
|
||||
error = xwimp_resize_icon(url_bar->window,
|
||||
url_bar->container_icon,
|
||||
x0, y0, x1, y1);
|
||||
if (error != NULL) {
|
||||
LOG(("xwimp_resize_icon: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
warn_user("WimpError", error->errmess);
|
||||
url_bar->container_icon = -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* Position the URL Suggest icon. */
|
||||
|
||||
if (url_bar->suggest_icon != -1) {
|
||||
x0 = url_bar->extent.x1 - url_bar->suggest_x;
|
||||
x1 = url_bar->extent.x1;
|
||||
|
||||
y0 = centre - (url_bar->suggest_y / 2);
|
||||
y1 = y0 + url_bar->suggest_y;
|
||||
|
||||
error = xwimp_resize_icon(url_bar->window,
|
||||
url_bar->suggest_icon,
|
||||
x0, y0, x1, y1);
|
||||
if (error != NULL) {
|
||||
LOG(("xwimp_resize_icon: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
warn_user("WimpError", error->errmess);
|
||||
url_bar->suggest_icon = -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* Position the Text icon. */
|
||||
|
||||
if (url_bar->text_icon != -1) {
|
||||
x0 = url_bar->extent.x0 + URLBAR_FAVICON_WIDTH;
|
||||
x1 = url_bar->extent.x1 - eig.x -
|
||||
url_bar->suggest_x - URLBAR_GRIGHT_GUTTER;
|
||||
|
||||
y0 = centre - (URLBAR_HEIGHT / 2) + eig.y;
|
||||
y1 = y0 + URLBAR_HEIGHT - 2 * eig.y;
|
||||
|
||||
error = xwimp_resize_icon(url_bar->window,
|
||||
url_bar->text_icon,
|
||||
x0, y0, x1, y1);
|
||||
if (error != NULL) {
|
||||
LOG(("xwimp_resize_icon: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
warn_user("WimpError", error->errmess);
|
||||
url_bar->text_icon = -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (xwimp_get_caret_position(&caret) == NULL) {
|
||||
if ((caret.w == url_bar->window) &&
|
||||
(caret.i == url_bar->text_icon)) {
|
||||
xwimp_set_caret_position(url_bar->window,
|
||||
url_bar->text_icon, caret.pos.x,
|
||||
caret.pos.y, -1, caret.index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Position the Favicon icon. */
|
||||
|
||||
url_bar->favicon_extent.x0 = url_bar->extent.x0 + eig.x;
|
||||
url_bar->favicon_extent.x1 = url_bar->extent.x0 + URLBAR_FAVICON_WIDTH;
|
||||
url_bar->favicon_extent.y0 = centre - (URLBAR_HEIGHT / 2) + eig.y;
|
||||
url_bar->favicon_extent.y1 = url_bar->favicon_extent.y0 + URLBAR_HEIGHT
|
||||
- 2 * eig.y;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* This is an exported interface documented in url_bar.h */
|
||||
|
||||
bool ro_gui_url_bar_hide(struct url_bar *url_bar, bool hide)
|
||||
{
|
||||
if (url_bar == NULL || url_bar->hidden == hide)
|
||||
return (url_bar == NULL) ? false : true;
|
||||
|
||||
url_bar->hidden = hide;
|
||||
|
||||
return ro_gui_url_bar_icon_update(url_bar);
|
||||
}
|
||||
|
||||
|
||||
/* This is an exported interface documented in url_bar.h */
|
||||
|
||||
void ro_gui_url_bar_redraw(struct url_bar *url_bar, wimp_draw *redraw)
|
||||
{
|
||||
wimp_icon icon;
|
||||
struct rect clip;
|
||||
|
||||
/* Test for a valid URL bar, and then check that the redraw box
|
||||
* coincides with the bar's favicon extent.
|
||||
*/
|
||||
|
||||
if (url_bar == NULL || url_bar->hidden ||
|
||||
(redraw->clip.x0 - (redraw->box.x0 - redraw->xscroll))
|
||||
> (url_bar->favicon_extent.x1) ||
|
||||
(redraw->clip.y0 - (redraw->box.y1 - redraw->yscroll))
|
||||
> url_bar->favicon_extent.y1 ||
|
||||
(redraw->clip.x1 - (redraw->box.x0 - redraw->xscroll))
|
||||
< url_bar->favicon_extent.x0 ||
|
||||
(redraw->clip.y1 - (redraw->box.y1 - redraw->yscroll))
|
||||
< url_bar->favicon_extent.y0)
|
||||
return;
|
||||
|
||||
if (url_bar->favicon_content == NULL) {
|
||||
icon.data.indirected_text.text = null_text_string;
|
||||
icon.data.indirected_text.validation = url_bar->favicon_sprite;
|
||||
icon.data.indirected_text.size = 1;
|
||||
icon.flags = wimp_ICON_TEXT | wimp_ICON_SPRITE |
|
||||
wimp_ICON_INDIRECTED | wimp_ICON_FILLED |
|
||||
wimp_ICON_HCENTRED | wimp_ICON_VCENTRED;
|
||||
icon.extent.x0 = url_bar->favicon_extent.x0;
|
||||
icon.extent.x1 = url_bar->favicon_extent.x1;
|
||||
icon.extent.y0 = url_bar->favicon_extent.y0;
|
||||
icon.extent.y1 = url_bar->favicon_extent.y1;
|
||||
|
||||
xwimp_plot_icon(&icon);
|
||||
} else {
|
||||
xwimp_set_colour(wimp_COLOUR_WHITE);
|
||||
xos_plot(os_MOVE_TO,
|
||||
(redraw->box.x0 - redraw->xscroll) +
|
||||
url_bar->favicon_extent.x0,
|
||||
(redraw->box.y1 - redraw->yscroll) +
|
||||
url_bar->favicon_extent.y0);
|
||||
xos_plot(os_PLOT_TO | os_PLOT_RECTANGLE,
|
||||
(redraw->box.x0 - redraw->xscroll) +
|
||||
url_bar->favicon_extent.x1,
|
||||
(redraw->box.y1 - redraw->yscroll) +
|
||||
url_bar->favicon_extent.y1);
|
||||
|
||||
clip.x0 = (redraw->clip.x0 - ro_plot_origin_x) / 2;
|
||||
clip.y0 = (ro_plot_origin_y - redraw->clip.y0) / 2;
|
||||
clip.x1 = (redraw->clip.x1 - ro_plot_origin_x) / 2;
|
||||
clip.y1 = (ro_plot_origin_y - redraw->clip.y1) / 2;
|
||||
|
||||
content_redraw(url_bar->favicon_content,
|
||||
(url_bar->favicon_extent.x0 +
|
||||
url_bar->favicon_offset.x) / 2,
|
||||
(url_bar->favicon_offset.y -
|
||||
url_bar->favicon_extent.y1) / 2,
|
||||
url_bar->favicon_width, url_bar->favicon_height,
|
||||
&clip, 1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* This is an exported interface documented in url_bar.h */
|
||||
|
||||
bool ro_gui_url_bar_click(struct url_bar *url_bar,
|
||||
wimp_pointer *pointer, wimp_window_state *state,
|
||||
url_bar_action *action)
|
||||
{
|
||||
os_coord pos;
|
||||
|
||||
if (url_bar == NULL || url_bar->hidden ||
|
||||
url_bar->display || url_bar->shaded)
|
||||
return false;
|
||||
|
||||
/* Check that the click was within our part of the window. */
|
||||
|
||||
pos.x = pointer->pos.x - state->visible.x0 + state->xscroll;
|
||||
pos.y = pointer->pos.y - state->visible.y1 + state->yscroll;
|
||||
|
||||
if (pos.x < url_bar->extent.x0 || pos.x > url_bar->extent.x1 ||
|
||||
pos.y < url_bar->extent.y0 ||
|
||||
pos.y > url_bar->extent.y1)
|
||||
return false;
|
||||
|
||||
/* If we find a Select or Adjust drag, check if it originated on the
|
||||
* URL bar or over the favicon. If either, then return an event.
|
||||
*/
|
||||
|
||||
if (pointer->buttons == wimp_DRAG_SELECT ||
|
||||
pointer->buttons == wimp_DRAG_ADJUST) {
|
||||
if (pointer->i == url_bar->text_icon) {
|
||||
if (action != NULL)
|
||||
*action = TOOLBAR_URL_DRAG_URL;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pos.x >= url_bar->favicon_extent.x0 &&
|
||||
pos.x <= url_bar->favicon_extent.x1 &&
|
||||
pos.y >= url_bar->favicon_extent.y0 &&
|
||||
pos.y <=url_bar->favicon_extent.y1) {
|
||||
if (action != NULL)
|
||||
*action = TOOLBAR_URL_DRAG_FAVICON;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* This is an exported interface documented in url_bar.h */
|
||||
|
||||
bool ro_gui_url_bar_menu_prepare(struct url_bar *url_bar, wimp_i i,
|
||||
wimp_menu *menu, wimp_pointer *pointer)
|
||||
{
|
||||
if (url_bar == NULL || url_bar->suggest_icon != i ||
|
||||
menu != ro_gui_url_suggest_menu)
|
||||
return false;
|
||||
|
||||
if (pointer != NULL)
|
||||
return ro_gui_url_suggest_prepare_menu();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* This is an exported interface documented in url_bar.h */
|
||||
|
||||
bool ro_gui_url_bar_menu_select(struct url_bar *url_bar, wimp_i i,
|
||||
wimp_menu *menu, wimp_selection *selection, menu_action action)
|
||||
{
|
||||
const char *url;
|
||||
struct gui_window *g;
|
||||
|
||||
if (url_bar == NULL || url_bar->suggest_icon != i ||
|
||||
menu != ro_gui_url_suggest_menu)
|
||||
return false;
|
||||
|
||||
url = ro_gui_url_suggest_get_selection(selection);
|
||||
g = ro_gui_toolbar_lookup(url_bar->window);
|
||||
|
||||
if (url != NULL && g != NULL && g->bw != NULL) {
|
||||
gui_window_set_url(g, url);
|
||||
browser_window_go(g->bw, url, 0, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* This is an exported interface documented in url_bar.h */
|
||||
|
||||
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)
|
||||
{
|
||||
os_coord pos;
|
||||
|
||||
if (url_bar == NULL || url_bar->hidden)
|
||||
return false;
|
||||
|
||||
/* Check that the click was within our part of the window. */
|
||||
|
||||
pos.x = mouse->x - state->visible.x0 + state->xscroll;
|
||||
pos.y = mouse->y - state->visible.y1 + state->yscroll;
|
||||
|
||||
if (pos.x < url_bar->extent.x0 || pos.x > url_bar->extent.x1 ||
|
||||
pos.y < url_bar->extent.y0 ||
|
||||
pos.y > url_bar->extent.y1)
|
||||
return false;
|
||||
|
||||
/* Return hard-coded icon numbers that match the ones that were
|
||||
* always allocated to the URL bar in a previous implementation.
|
||||
* If Messages can be updated, this could be changed.
|
||||
*/
|
||||
|
||||
if (i == url_bar->text_icon)
|
||||
*suffix = "14";
|
||||
else if (i == url_bar->suggest_icon)
|
||||
*suffix = "15";
|
||||
else
|
||||
*suffix = "";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* This is an exported interface documented in url_bar.h */
|
||||
|
||||
bool ro_gui_url_bar_take_caret(struct url_bar *url_bar)
|
||||
{
|
||||
os_error *error;
|
||||
|
||||
if (url_bar == NULL || url_bar->hidden)
|
||||
return false;
|
||||
|
||||
error = xwimp_set_caret_position(url_bar->window, url_bar->text_icon,
|
||||
-1, -1, -1, 0);
|
||||
if (error) {
|
||||
LOG(("xwimp_set_caret_position: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
warn_user("WimpError", error->errmess);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* This is an exported interface documented in url_bar.h */
|
||||
|
||||
void ro_gui_url_bar_set_url(struct url_bar *url_bar, const char *url,
|
||||
bool is_utf8, bool set_caret)
|
||||
{
|
||||
wimp_caret caret;
|
||||
os_error *error;
|
||||
const char *set_url;
|
||||
|
||||
if (url_bar == NULL || url_bar->text_buffer == NULL)
|
||||
return;
|
||||
|
||||
if (url_bar->text_icon == -1) {
|
||||
strncpy(url_bar->text_buffer, url, url_bar->text_size);
|
||||
return;
|
||||
}
|
||||
|
||||
ro_gui_set_icon_string(url_bar->window, url_bar->text_icon,
|
||||
url, is_utf8);
|
||||
|
||||
error = xwimp_get_caret_position(&caret);
|
||||
if (error) {
|
||||
LOG(("xwimp_get_caret_position: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
warn_user("WimpError", error->errmess);
|
||||
return;
|
||||
}
|
||||
|
||||
if (set_caret || (caret.w == url_bar->window &&
|
||||
caret.i == url_bar->text_icon)) {
|
||||
set_url = ro_gui_get_icon_string(url_bar->window,
|
||||
url_bar->text_icon);
|
||||
|
||||
error = xwimp_set_caret_position(url_bar->window,
|
||||
url_bar->text_icon, 0, 0, -1, strlen(set_url));
|
||||
if (error) {
|
||||
LOG(("xwimp_set_caret_position: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
warn_user("WimpError", error->errmess);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* This is an exported interface documented in url_bar.h */
|
||||
|
||||
const char *ro_gui_url_bar_get_url(struct url_bar *url_bar)
|
||||
{
|
||||
if (url_bar == NULL)
|
||||
return NULL;
|
||||
|
||||
return (const char *) url_bar->text_buffer;
|
||||
}
|
||||
|
||||
|
||||
/* This is an exported interface documented in url_bar.h */
|
||||
|
||||
bool ro_gui_url_bar_get_url_extent(struct url_bar *url_bar, os_box *extent)
|
||||
{
|
||||
wimp_icon_state state;
|
||||
os_error *error;
|
||||
|
||||
if (url_bar == NULL || url_bar->hidden)
|
||||
return false;
|
||||
|
||||
if (extent == NULL)
|
||||
return true;
|
||||
|
||||
state.w = url_bar->window;
|
||||
state.i = url_bar->container_icon;
|
||||
error = xwimp_get_icon_state(&state);
|
||||
if (error) {
|
||||
LOG(("xwimp_get_icon_state: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
warn_user("WimpError", error->errmess);
|
||||
return false;
|
||||
}
|
||||
|
||||
extent->x0 = state.icon.extent.x0;
|
||||
extent->y0 = state.icon.extent.y0;
|
||||
extent->x1 = state.icon.extent.x1;
|
||||
extent->y1 = state.icon.extent.y1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* This is an exported interface documented in url_bar.h */
|
||||
|
||||
bool ro_gui_url_bar_test_for_text_field_click(struct url_bar *url_bar,
|
||||
wimp_pointer *pointer)
|
||||
{
|
||||
if (url_bar == NULL || url_bar->hidden || pointer == NULL)
|
||||
return false;
|
||||
|
||||
return (pointer->w == url_bar->window &&
|
||||
pointer->i == url_bar->text_icon) ? true : false;
|
||||
}
|
||||
|
||||
|
||||
/* This is an exported interface documented in url_bar.h */
|
||||
|
||||
bool ro_gui_url_bar_test_for_text_field_keypress(struct url_bar *url_bar,
|
||||
wimp_key *key)
|
||||
{
|
||||
if (url_bar == NULL || url_bar->hidden || key == NULL)
|
||||
return false;
|
||||
|
||||
return (key->w == url_bar->window &&
|
||||
key->i == url_bar->text_icon) ? true : false;
|
||||
}
|
||||
|
||||
|
||||
/* This is an exported interface documented in url_bar.h */
|
||||
|
||||
bool ro_gui_url_bar_set_site_favicon(struct url_bar *url_bar,
|
||||
struct hlcache_handle *h)
|
||||
{
|
||||
content_type type = CONTENT_OTHER;
|
||||
|
||||
if (url_bar == NULL)
|
||||
return false;
|
||||
|
||||
if (h != NULL)
|
||||
type = content_get_type(h);
|
||||
|
||||
// \TODO -- Maybe test for CONTENT_ICO ???
|
||||
|
||||
if (type != CONTENT_OTHER && type != CONTENT_UNKNOWN) {
|
||||
url_bar->favicon_content = h;
|
||||
url_bar->favicon_width = content_get_width(h);
|
||||
url_bar->favicon_height = content_get_height(h);
|
||||
|
||||
if (url_bar->favicon_width > URLBAR_FAVICON_SIZE)
|
||||
url_bar->favicon_width = URLBAR_FAVICON_SIZE;
|
||||
|
||||
if (url_bar->favicon_height > URLBAR_FAVICON_SIZE)
|
||||
url_bar->favicon_height = URLBAR_FAVICON_SIZE;
|
||||
|
||||
url_bar->favicon_offset.x = ((url_bar->favicon_extent.x1 -
|
||||
url_bar->favicon_extent.x0) -
|
||||
(url_bar->favicon_width * 2)) / 2;
|
||||
url_bar->favicon_offset.y = ((url_bar->favicon_extent.y1 -
|
||||
url_bar->favicon_extent.y0) -
|
||||
(url_bar->favicon_height * 2)) / 2;
|
||||
} else {
|
||||
url_bar->favicon_content = NULL;
|
||||
|
||||
if (url_bar->favicon_type != 0)
|
||||
snprintf(url_bar->favicon_sprite,
|
||||
URLBAR_FAVICON_NAME_LENGTH,
|
||||
"Ssmall_%.3x", url_bar->favicon_type);
|
||||
else
|
||||
snprintf(url_bar->favicon_sprite,
|
||||
URLBAR_FAVICON_NAME_LENGTH,
|
||||
"Ssmall_xxx");
|
||||
}
|
||||
|
||||
if (!url_bar->hidden)
|
||||
xwimp_force_redraw(url_bar->window,
|
||||
url_bar->favicon_extent.x0,
|
||||
url_bar->favicon_extent.y0,
|
||||
url_bar->favicon_extent.x1,
|
||||
url_bar->favicon_extent.y1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* This is an exported interface documented in url_bar.h */
|
||||
|
||||
bool ro_gui_url_bar_set_content_favicon(struct url_bar *url_bar,
|
||||
struct hlcache_handle *h)
|
||||
{
|
||||
int type = 0;
|
||||
char sprite[URLBAR_FAVICON_NAME_LENGTH];
|
||||
|
||||
if (url_bar == NULL)
|
||||
return false;
|
||||
|
||||
if (h != NULL)
|
||||
type = ro_content_filetype_from_type(content_get_type(h));
|
||||
|
||||
if (type != 0) {
|
||||
snprintf(sprite, URLBAR_FAVICON_NAME_LENGTH,
|
||||
"small_%.3x", type);
|
||||
|
||||
if (!ro_gui_wimp_sprite_exists(sprite))
|
||||
type = 0;
|
||||
}
|
||||
|
||||
url_bar->favicon_type = type;
|
||||
|
||||
if (url_bar->favicon_content == NULL) {
|
||||
if (type == 0)
|
||||
snprintf(url_bar->favicon_sprite,
|
||||
URLBAR_FAVICON_NAME_LENGTH, "Ssmall_xxx");
|
||||
else
|
||||
snprintf(url_bar->favicon_sprite,
|
||||
URLBAR_FAVICON_NAME_LENGTH, "S%s", sprite);
|
||||
|
||||
if (!url_bar->hidden)
|
||||
xwimp_force_redraw(url_bar->window,
|
||||
url_bar->favicon_extent.x0,
|
||||
url_bar->favicon_extent.y0,
|
||||
url_bar->favicon_extent.x1,
|
||||
url_bar->favicon_extent.y1);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* This is an exported interface documented in url_bar.h */
|
||||
|
||||
bool ro_gui_url_bar_update_urlsuggest(struct url_bar *url_bar)
|
||||
{
|
||||
if (url_bar == NULL || url_bar->hidden)
|
||||
return (url_bar == NULL) ? false : true;
|
||||
|
||||
if (url_bar->window != NULL && url_bar->suggest_icon != -1)
|
||||
ro_gui_set_icon_shaded_state(url_bar->window,
|
||||
url_bar->suggest_icon,
|
||||
!ro_gui_url_suggest_get_menu_available());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -0,0 +1,302 @@
|
|||
/*
|
||||
* Copyright 2005 Richard Wilson <info@tinct.net>
|
||||
* Copyright 2011 Stephen Fryatt <stevef@netsurf-browser.org>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
* NetSurf is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* NetSurf is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* URL bars (interface).
|
||||
*/
|
||||
|
||||
#ifndef _NETSURF_RISCOS_URLBAR_H_
|
||||
#define _NETSURF_RISCOS_URLBAR_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "riscos/menus.h"
|
||||
#include "riscos/theme.h"
|
||||
|
||||
/* A list of possible URL bar actions. */
|
||||
|
||||
typedef enum {
|
||||
TOOLBAR_URL_NONE = 0, /* Special case: no action */
|
||||
TOOLBAR_URL_DRAG_URL,
|
||||
TOOLBAR_URL_DRAG_FAVICON,
|
||||
} url_bar_action;
|
||||
|
||||
struct url_bar;
|
||||
|
||||
/**
|
||||
* Create a new url bar widget.
|
||||
*
|
||||
* \param *theme The theme to apply (or NULL for the default).
|
||||
* \return A url bar handle, or NULL on failure.
|
||||
*/
|
||||
|
||||
struct url_bar *ro_gui_url_bar_create(struct theme_descriptor *theme);
|
||||
|
||||
|
||||
/**
|
||||
* Place a URL 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.
|
||||
*
|
||||
* \param *url_bar The URL bar to rebuild.
|
||||
* \param *theme The theme to apply (or NULL for current).
|
||||
* \param style The theme style to apply.
|
||||
* \param window The window that the bar is in.
|
||||
* \param display true if the bar should be for display only.
|
||||
* \param shaded true if the bar should be shaded; else false.
|
||||
* \return true on success; else false.
|
||||
*/
|
||||
|
||||
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);
|
||||
|
||||
|
||||
/**
|
||||
* Destroy a url bar widget.
|
||||
*
|
||||
* \param *url_bar The url bar to destroy.
|
||||
*/
|
||||
|
||||
void ro_gui_url_bar_destroy(struct url_bar *url_bar);
|
||||
|
||||
|
||||
/**
|
||||
* Return the MINIMUM dimensions required by the URL bar, in RO units,
|
||||
* allowing for the current theme.
|
||||
*
|
||||
* \param *url_bar The URL bar of interest.
|
||||
* \param *width Return the required width.
|
||||
* \param *height Return the required height.
|
||||
* \return true if values are returned; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_url_bar_get_dims(struct url_bar *url_bar,
|
||||
int *width, int *height);
|
||||
|
||||
|
||||
/**
|
||||
* Set or update the dimensions to be used by the URL bar, in RO units.
|
||||
* If these are greater than the minimum required, the URL bar will fill
|
||||
* the extended space; if less, the call will fail.
|
||||
*
|
||||
* \param *url_bar The URL bar to update.
|
||||
* \param x0 The minimum X window position.
|
||||
* \param y0 The minimum Y window position.
|
||||
* \param x1 The maximum X window position.
|
||||
* \param y1 The maximum Y window position.
|
||||
* \return true if size updated; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_url_bar_set_extent(struct url_bar *url_bar,
|
||||
int x0, int y0, int x1, int y1);
|
||||
|
||||
|
||||
/**
|
||||
* Show or hide a URL bar.
|
||||
*
|
||||
* \param *url_bar The URL bar to hide.
|
||||
* \param hide true to hide the bar; false to show it.
|
||||
* \return true if successful; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_url_bar_hide(struct url_bar *url_bar, bool hide);
|
||||
|
||||
|
||||
/**
|
||||
* Handle redraw event rectangles in a URL bat.
|
||||
*
|
||||
* \param *url_bar The URL bar to use.
|
||||
* \param *redraw The Wimp redraw rectangle to process.
|
||||
*/
|
||||
|
||||
void ro_gui_url_bar_redraw(struct url_bar *url_bar, wimp_draw *redraw);
|
||||
|
||||
|
||||
/**
|
||||
* Handle mouse clicks in a URL bar.
|
||||
*
|
||||
* \param *url_bar The URL bar to use.
|
||||
* \param *pointer The Wimp mouse click event data.
|
||||
* \param *state The toolbar window state.
|
||||
* \param *action Returns the selected action, or
|
||||
* TOOLBAR_URL_NONE.
|
||||
* \return true if the event was handled exclusively;
|
||||
* else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_url_bar_click(struct url_bar *url_bar,
|
||||
wimp_pointer *pointer, wimp_window_state *state,
|
||||
url_bar_action *action);
|
||||
|
||||
|
||||
/**
|
||||
* Process offered menu prepare events from the parent window.
|
||||
*
|
||||
* \param *url_bar The URL bar in question.
|
||||
* \param i The icon owning the menu.
|
||||
* \param *menu The menu to be prepared.
|
||||
* \param *pointer The Wimp Pointer data from the event.
|
||||
* \return true if the event is claimed; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_url_bar_menu_prepare(struct url_bar *url_bar, wimp_i i,
|
||||
wimp_menu *menu, wimp_pointer *pointer);
|
||||
|
||||
|
||||
/**
|
||||
* Process offered menu select events from the parent window.
|
||||
*
|
||||
* \param *url_bar The URL bar in question.
|
||||
* \param i The icon owning the menu.
|
||||
* \param *menu The menu to be prepared.
|
||||
* \param *selection The wimp menu selection data.
|
||||
* \param action The selected menu action.
|
||||
* \return true if the event is claimed; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_url_bar_menu_select(struct url_bar *url_bar, wimp_i i,
|
||||
wimp_menu *menu, wimp_selection *selection, menu_action action);
|
||||
|
||||
|
||||
/**
|
||||
* Translate mouse data into an interactive help message for the URL bar.
|
||||
*
|
||||
* \param *url_bar The URL bar to process.
|
||||
* \param i The wimp icon under the pointer.
|
||||
* \param *mouse The mouse position.
|
||||
* \param *state The toolbar window state.
|
||||
* \param buttons The mouse button state.
|
||||
* \param **suffix Return a help token suffix, or "" for none.
|
||||
* \return true if handled exclusively; else false.
|
||||
*/
|
||||
|
||||
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);
|
||||
|
||||
|
||||
/**
|
||||
* Give a URL bar input focus.
|
||||
*
|
||||
* \param *url_bar The URL bar to give focus to.
|
||||
* \return true if successful; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_url_bar_take_caret(struct url_bar *url_bar);
|
||||
|
||||
|
||||
/**
|
||||
* Set the content of a URL Bar field.
|
||||
*
|
||||
* \param *url_bar The URL Bar to update.
|
||||
* \param *url The new url to insert.
|
||||
* \param is_utf8 true if the string is in utf8 encoding; false
|
||||
* if it is in local encoding.
|
||||
* \param set_caret true if the caret should be placed in the field;
|
||||
* else false.
|
||||
*/
|
||||
|
||||
void ro_gui_url_bar_set_url(struct url_bar *url_bar, const char *url,
|
||||
bool is_utf8, bool set_caret);
|
||||
|
||||
|
||||
/**
|
||||
* Return a pointer to the URL contained in a URL bar.
|
||||
*
|
||||
* \param *url_bar The URL Bar to look up the URL from.
|
||||
* \return Pointer to the URL, or NULL.
|
||||
*/
|
||||
|
||||
const char *ro_gui_url_bar_get_url(struct url_bar *url_bar);
|
||||
|
||||
|
||||
/**
|
||||
* Return the current work area coordinates of the URL and favicon field's
|
||||
* bounding box.
|
||||
*
|
||||
* \param *url_bar The URL bar to check.
|
||||
* \param *extent Returns the field extent.
|
||||
* \return true if successful; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_url_bar_get_url_extent(struct url_bar *url_bar, os_box *extent);
|
||||
|
||||
|
||||
/**
|
||||
* Test a pointer click to see if it was in the URL bar's text field.
|
||||
*
|
||||
* \param *url_bar The URL Bar to test.
|
||||
* \param *pointer The pointer event data to test.
|
||||
* \return true if the click was in the field; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_url_bar_test_for_text_field_click(struct url_bar *url_bar,
|
||||
wimp_pointer *pointer);
|
||||
|
||||
|
||||
/**
|
||||
* Test a keypress to see if it was in the URL bar's text field.
|
||||
*
|
||||
* \param *url_bar The URL Bar to test.
|
||||
* \param *pointer The pointer event data to test.
|
||||
* \return true if the click was in the field; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_url_bar_test_for_text_field_keypress(struct url_bar *url_bar,
|
||||
wimp_key *key);
|
||||
|
||||
|
||||
/**
|
||||
* Set the favicon to a site supplied favicon image, or remove the image
|
||||
* and return to using filetype-based icons.
|
||||
*
|
||||
* \param *url_bar The URL Bar to update the favicon on.
|
||||
* \param *h The content to use, or NULL to unset.
|
||||
* \return true if successful; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_url_bar_set_site_favicon(struct url_bar *url_bar,
|
||||
struct hlcache_handle *h);
|
||||
|
||||
|
||||
/**
|
||||
* Set the favicon to a RISC OS filetype sprite based on the type of the
|
||||
* supplied content.
|
||||
*
|
||||
* \param *url_bar The URL Bar to update the favicon on.
|
||||
* \param *h The content to use.
|
||||
* \return true if successful; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_url_bar_set_content_favicon(struct url_bar *url_bar,
|
||||
struct hlcache_handle *h);
|
||||
|
||||
|
||||
/**
|
||||
* Update the state of the URL suggestion pop-up menu icon on a URL bar.
|
||||
*
|
||||
* \param *url_bar The URL bar to update.
|
||||
* \return true if successful; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_url_bar_update_urlsuggest(struct url_bar *url_bar);
|
||||
|
||||
#endif
|
||||
|
|
@ -33,12 +33,13 @@
|
|||
#include "riscos/gui.h"
|
||||
#include "riscos/hotlist.h"
|
||||
#include "riscos/help.h"
|
||||
#include "riscos/iconbar.h"
|
||||
#include "riscos/menus.h"
|
||||
#include "riscos/options.h"
|
||||
#include "riscos/theme.h"
|
||||
#include "riscos/treeview.h"
|
||||
#include "riscos/wimp.h"
|
||||
#include "riscos/wimp_event.h"
|
||||
#include "riscos/window.h"
|
||||
#include "utils/messages.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/utf8.h"
|
||||
|
@ -91,18 +92,18 @@ static os_t help_time = 0;
|
|||
*/
|
||||
void ro_gui_interactive_help_request(wimp_message *message)
|
||||
{
|
||||
char message_token[32];
|
||||
char menu_buffer[4];
|
||||
wimp_selection menu_tree;
|
||||
help_full_message_request *message_data;
|
||||
wimp_w window;
|
||||
wimp_i icon;
|
||||
unsigned int index;
|
||||
bool greyed = false;
|
||||
wimp_menu *test_menu;
|
||||
os_error *error;
|
||||
const char *auto_text;
|
||||
int i;
|
||||
char message_token[32];
|
||||
char menu_buffer[4];
|
||||
wimp_selection menu_tree;
|
||||
help_full_message_request *message_data;
|
||||
wimp_w window;
|
||||
wimp_i icon;
|
||||
unsigned int index;
|
||||
bool greyed = false;
|
||||
wimp_menu *test_menu;
|
||||
os_error *error;
|
||||
const char *auto_text, *auto_suffix;
|
||||
int i;
|
||||
|
||||
/* check we aren't turned off */
|
||||
if (!option_interactive_help)
|
||||
|
@ -123,9 +124,15 @@ void ro_gui_interactive_help_request(wimp_message *message)
|
|||
|
||||
/* do the basic window checks */
|
||||
auto_text = ro_gui_wimp_event_get_help_prefix(window);
|
||||
if (auto_text)
|
||||
sprintf(message_token, "%s%i", auto_text, (int)icon);
|
||||
else if (window == wimp_ICON_BAR)
|
||||
if (auto_text != NULL) {
|
||||
auto_suffix = ro_gui_wimp_event_get_help_suffix(window, icon,
|
||||
&message_data->pos, message_data->buttons);
|
||||
|
||||
if (auto_suffix == NULL)
|
||||
sprintf(message_token, "%s%i", auto_text, (int)icon);
|
||||
else
|
||||
sprintf(message_token, "%s%s", auto_text, auto_suffix);
|
||||
} else if (window == wimp_ICON_BAR)
|
||||
sprintf(message_token, "HelpIconbar");
|
||||
else if (ro_gui_hotlist_check_window(message->data.data_xfer.w)) {
|
||||
i = ro_treeview_get_help(message_data);
|
||||
|
@ -171,9 +178,9 @@ void ro_gui_interactive_help_request(wimp_message *message)
|
|||
return;
|
||||
|
||||
/* get the menu prefix */
|
||||
if (current_menu == iconbar_menu)
|
||||
if (ro_gui_iconbar_check_menu(current_menu))
|
||||
sprintf(message_token, "HelpIconMenu");
|
||||
else if (current_menu == browser_menu)
|
||||
else if (ro_gui_window_check_menu(current_menu))
|
||||
sprintf(message_token, "HelpBrowserMenu");
|
||||
else if (ro_gui_hotlist_check_menu(current_menu))
|
||||
sprintf(message_token, "HelpHotlistMenu");
|
||||
|
|
242
riscos/hotlist.c
242
riscos/hotlist.c
|
@ -39,7 +39,7 @@
|
|||
#include "riscos/menus.h"
|
||||
#include "riscos/options.h"
|
||||
#include "riscos/save.h"
|
||||
#include "riscos/theme.h"
|
||||
#include "riscos/toolbar.h"
|
||||
#include "riscos/treeview.h"
|
||||
#include "riscos/wimp.h"
|
||||
#include "riscos/wimp_event.h"
|
||||
|
@ -48,6 +48,22 @@
|
|||
#include "utils/utils.h"
|
||||
#include "utils/url.h"
|
||||
|
||||
static void ro_gui_hotlist_toolbar_update_buttons(void);
|
||||
static void ro_gui_hotlist_toolbar_save_buttons(char *config);
|
||||
static bool ro_gui_hotlist_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
|
||||
wimp_pointer *pointer);
|
||||
static void ro_gui_hotlist_menu_warning(wimp_w w, wimp_i i, wimp_menu *menu,
|
||||
wimp_selection *selection, menu_action action);
|
||||
static bool ro_gui_hotlist_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
|
||||
wimp_selection *selection, menu_action action);
|
||||
static void ro_gui_hotlist_toolbar_click(button_bar_action action);
|
||||
|
||||
struct ro_treeview_callbacks ro_hotlist_treeview_callbacks = {
|
||||
ro_gui_hotlist_toolbar_click,
|
||||
ro_gui_hotlist_toolbar_update_buttons,
|
||||
ro_gui_hotlist_toolbar_save_buttons
|
||||
};
|
||||
|
||||
/* The RISC OS hotlist window, toolbar and treeview data. */
|
||||
|
||||
static struct ro_hotlist {
|
||||
|
@ -79,21 +95,30 @@ void ro_gui_hotlist_postinitialise(void)
|
|||
{
|
||||
/* Create our toolbar. */
|
||||
|
||||
hotlist_window.toolbar = ro_gui_theme_create_toolbar(NULL,
|
||||
THEME_HOTLIST_TOOLBAR);
|
||||
if (hotlist_window.toolbar)
|
||||
ro_gui_theme_attach_toolbar(hotlist_window.toolbar,
|
||||
hotlist_window.window);
|
||||
hotlist_window.toolbar = ro_toolbar_create(NULL, hotlist_window.window,
|
||||
THEME_STYLE_HOTLIST_TOOLBAR, TOOLBAR_FLAGS_NONE,
|
||||
ro_treeview_get_toolbar_callbacks(), NULL,
|
||||
"HelpHotToolbar");
|
||||
if (hotlist_window.toolbar != NULL) {
|
||||
ro_toolbar_add_buttons(hotlist_window.toolbar,
|
||||
hotlist_toolbar_buttons,
|
||||
option_toolbar_hotlist);
|
||||
ro_toolbar_rebuild(hotlist_window.toolbar);
|
||||
}
|
||||
|
||||
/* Create the treeview with the window and toolbar. */
|
||||
|
||||
hotlist_window.tv = ro_treeview_create(hotlist_window.window,
|
||||
hotlist_window.toolbar, hotlist_get_tree_flags());
|
||||
hotlist_window.toolbar, &ro_hotlist_treeview_callbacks,
|
||||
hotlist_get_tree_flags());
|
||||
if (hotlist_window.tv == NULL) {
|
||||
LOG(("Failed to allocate treeview"));
|
||||
return;
|
||||
}
|
||||
|
||||
ro_toolbar_update_client_data(hotlist_window.toolbar,
|
||||
hotlist_window.tv);
|
||||
|
||||
/* Initialise the hotlist into the tree. */
|
||||
|
||||
hotlist_initialise(ro_treeview_get_tree(hotlist_window.tv),
|
||||
|
@ -133,10 +158,14 @@ void ro_gui_hotlist_postinitialise(void)
|
|||
|
||||
hotlist_window.menu = ro_gui_menu_define_menu(&hotlist_definition);
|
||||
|
||||
ro_gui_wimp_event_register_window_menu(hotlist_window.window,
|
||||
hotlist_window.menu, ro_gui_hotlist_menu_prepare,
|
||||
ro_gui_hotlist_menu_select, NULL,
|
||||
ro_gui_hotlist_menu_warning, false);
|
||||
ro_gui_wimp_event_register_menu(hotlist_window.window,
|
||||
hotlist_window.menu, false, false);
|
||||
ro_gui_wimp_event_register_menu_prepare(hotlist_window.window,
|
||||
ro_gui_hotlist_menu_prepare);
|
||||
ro_gui_wimp_event_register_menu_selection(hotlist_window.window,
|
||||
ro_gui_hotlist_menu_select);
|
||||
ro_gui_wimp_event_register_menu_warning(hotlist_window.window,
|
||||
ro_gui_hotlist_menu_warning);
|
||||
}
|
||||
|
||||
|
||||
|
@ -149,82 +178,86 @@ void ro_gui_hotlist_open(void)
|
|||
{
|
||||
tree_set_redraw(ro_treeview_get_tree(hotlist_window.tv), true);
|
||||
|
||||
ro_gui_hotlist_toolbar_update_buttons();
|
||||
|
||||
if (!ro_gui_dialog_open_top(hotlist_window.window,
|
||||
hotlist_window.toolbar, 600, 800)) {
|
||||
|
||||
xwimp_set_caret_position(hotlist_window.window, -1, -100, -100, 32, -1);
|
||||
// \todo ro_gui_theme_process_toolbar(hotlist_window.toolbar, -1);
|
||||
ro_treeview_set_origin(hotlist_window.tv, 0,
|
||||
-(ro_gui_theme_toolbar_height(
|
||||
hotlist_window.toolbar)));
|
||||
// ro_gui_tree_stop_edit(tree);
|
||||
//
|
||||
// if (tree->root->child) {
|
||||
// tree_set_node_selected(tree, tree->root, false);
|
||||
// tree_handle_node_changed(tree, tree->root,
|
||||
// false, true);
|
||||
// }
|
||||
-(ro_toolbar_height(hotlist_window.toolbar)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Mouse Click events on the toolbar.
|
||||
* Handle toolbar button clicks.
|
||||
*
|
||||
* \param *pointer Pointer to the Mouse Click Event block.
|
||||
* \return Return true if click handled; else false.
|
||||
* \param action The action to handle
|
||||
*/
|
||||
|
||||
bool ro_gui_hotlist_toolbar_click(wimp_pointer *pointer)
|
||||
void ro_gui_hotlist_toolbar_click(button_bar_action action)
|
||||
{
|
||||
if (pointer->buttons == wimp_CLICK_MENU)
|
||||
return ro_gui_wimp_event_process_window_menu_click(pointer);
|
||||
switch (action) {
|
||||
case TOOLBAR_BUTTON_DELETE:
|
||||
hotlist_delete_selected();
|
||||
break;
|
||||
|
||||
if (hotlist_window.toolbar->editor != NULL) {
|
||||
ro_gui_theme_toolbar_editor_click(hotlist_window.toolbar,
|
||||
pointer);
|
||||
return true;
|
||||
}
|
||||
case TOOLBAR_BUTTON_EXPAND:
|
||||
hotlist_expand_addresses();
|
||||
break;
|
||||
|
||||
switch (pointer->i) {
|
||||
case ICON_TOOLBAR_DELETE:
|
||||
if (pointer->buttons == wimp_CLICK_SELECT) {
|
||||
hotlist_delete_selected();
|
||||
return true;
|
||||
}
|
||||
case TOOLBAR_BUTTON_COLLAPSE:
|
||||
hotlist_collapse_addresses();
|
||||
break;
|
||||
case ICON_TOOLBAR_EXPAND:
|
||||
if (pointer->buttons == wimp_CLICK_SELECT) {
|
||||
hotlist_expand_addresses();
|
||||
return true;
|
||||
} else if (pointer->buttons == wimp_CLICK_ADJUST) {
|
||||
hotlist_collapse_addresses();
|
||||
return true;
|
||||
}
|
||||
|
||||
case TOOLBAR_BUTTON_OPEN:
|
||||
hotlist_expand_directories();
|
||||
break;
|
||||
case ICON_TOOLBAR_OPEN:
|
||||
if (pointer->buttons == wimp_CLICK_SELECT) {
|
||||
hotlist_expand_directories();
|
||||
return true;
|
||||
} else if (pointer->buttons == wimp_CLICK_ADJUST) {
|
||||
hotlist_collapse_directories();
|
||||
return true;
|
||||
}
|
||||
|
||||
case TOOLBAR_BUTTON_CLOSE:
|
||||
hotlist_collapse_directories();
|
||||
break;
|
||||
case ICON_TOOLBAR_LAUNCH:
|
||||
if (pointer->buttons == wimp_CLICK_SELECT) {
|
||||
hotlist_launch_selected();
|
||||
return true;
|
||||
}
|
||||
|
||||
case TOOLBAR_BUTTON_LAUNCH:
|
||||
hotlist_launch_selected();
|
||||
break;
|
||||
case ICON_TOOLBAR_CREATE:
|
||||
if (pointer->buttons == wimp_CLICK_SELECT) {
|
||||
hotlist_add_folder();
|
||||
return true;
|
||||
}
|
||||
|
||||
case TOOLBAR_BUTTON_CREATE:
|
||||
hotlist_add_folder();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
/**
|
||||
* Update the button state in the hotlist toolbar.
|
||||
*/
|
||||
|
||||
void ro_gui_hotlist_toolbar_update_buttons(void)
|
||||
{
|
||||
ro_toolbar_set_button_shaded_state(hotlist_window.toolbar,
|
||||
TOOLBAR_BUTTON_DELETE,
|
||||
!ro_treeview_has_selection(hotlist_window.tv));
|
||||
|
||||
ro_toolbar_set_button_shaded_state(hotlist_window.toolbar,
|
||||
TOOLBAR_BUTTON_LAUNCH,
|
||||
!ro_treeview_has_selection(hotlist_window.tv));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save a new button arrangement in the hotlist toolbar.
|
||||
*
|
||||
* \param *config The new button configuration string.
|
||||
*/
|
||||
|
||||
void ro_gui_hotlist_toolbar_save_buttons(char *config)
|
||||
{
|
||||
if (option_toolbar_hotlist != NULL)
|
||||
free(option_toolbar_hotlist);
|
||||
option_toolbar_hotlist = config;
|
||||
ro_gui_save_options();
|
||||
}
|
||||
|
||||
|
||||
|
@ -233,53 +266,54 @@ bool ro_gui_hotlist_toolbar_click(wimp_pointer *pointer)
|
|||
*
|
||||
* \param window The window owning the menu.
|
||||
* \param *menu The menu about to be opened.
|
||||
* \param *pointer Pointer to the relevant wimp event block, or
|
||||
* NULL for an Adjust click.
|
||||
* \return true if the event was handled; else false.
|
||||
*/
|
||||
|
||||
void ro_gui_hotlist_menu_prepare(wimp_w window, wimp_menu *menu)
|
||||
bool ro_gui_hotlist_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
|
||||
wimp_pointer *pointer)
|
||||
{
|
||||
bool selection;
|
||||
|
||||
if (menu != hotlist_window.menu && menu != tree_toolbar_menu)
|
||||
return;
|
||||
if (menu != hotlist_window.menu)
|
||||
return false;
|
||||
|
||||
if (menu == hotlist_window.menu) {
|
||||
selection = ro_treeview_has_selection(hotlist_window.tv);
|
||||
selection = ro_treeview_has_selection(hotlist_window.tv);
|
||||
|
||||
ro_gui_menu_set_entry_shaded(hotlist_window.menu,
|
||||
TREE_SELECTION, !selection);
|
||||
ro_gui_menu_set_entry_shaded(hotlist_window.menu,
|
||||
TREE_CLEAR_SELECTION, !selection);
|
||||
ro_gui_menu_set_entry_shaded(hotlist_window.menu,
|
||||
TREE_SELECTION, !selection);
|
||||
ro_gui_menu_set_entry_shaded(hotlist_window.menu,
|
||||
TREE_CLEAR_SELECTION, !selection);
|
||||
|
||||
ro_gui_save_prepare(GUI_SAVE_HOTLIST_EXPORT_HTML,
|
||||
NULL, NULL, NULL, NULL);
|
||||
}
|
||||
ro_gui_save_prepare(GUI_SAVE_HOTLIST_EXPORT_HTML,
|
||||
NULL, NULL, NULL, NULL);
|
||||
|
||||
ro_gui_menu_set_entry_shaded(menu, TOOLBAR_BUTTONS,
|
||||
(hotlist_window.toolbar == NULL ||
|
||||
hotlist_window.toolbar->editor != NULL));
|
||||
ro_toolbar_menu_option_shade(hotlist_window.toolbar));
|
||||
ro_gui_menu_set_entry_ticked(menu, TOOLBAR_BUTTONS,
|
||||
(hotlist_window.toolbar != NULL &&
|
||||
(hotlist_window.toolbar->display_buttons ||
|
||||
(hotlist_window.toolbar->editor != NULL))));
|
||||
ro_toolbar_menu_buttons_tick(hotlist_window.toolbar));
|
||||
|
||||
ro_gui_menu_set_entry_shaded(menu, TOOLBAR_EDIT,
|
||||
hotlist_window.toolbar == NULL);
|
||||
ro_toolbar_menu_edit_shade(hotlist_window.toolbar));
|
||||
ro_gui_menu_set_entry_ticked(menu, TOOLBAR_EDIT,
|
||||
(hotlist_window.toolbar != NULL &&
|
||||
hotlist_window.toolbar->editor != NULL));
|
||||
ro_toolbar_menu_edit_tick(hotlist_window.toolbar));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle submenu warnings for the hotlist menu
|
||||
*
|
||||
* \param window The window owning the menu.
|
||||
* \param w The window owning the menu.
|
||||
* \param i The icon owning the menu.
|
||||
* \param *menu The menu to which the warning applies.
|
||||
* \param *selection The wimp menu selection data.
|
||||
* \param action The selected menu action.
|
||||
*/
|
||||
|
||||
void ro_gui_hotlist_menu_warning(wimp_w window, wimp_menu *menu,
|
||||
void ro_gui_hotlist_menu_warning(wimp_w w, wimp_i i, wimp_menu *menu,
|
||||
wimp_selection *selection, menu_action action)
|
||||
{
|
||||
/* Do nothing */
|
||||
|
@ -288,19 +322,20 @@ void ro_gui_hotlist_menu_warning(wimp_w window, wimp_menu *menu,
|
|||
/**
|
||||
* Handle selections from the hotlist menu
|
||||
*
|
||||
* \param window The window owning the menu.
|
||||
* \param w The window owning the menu.
|
||||
* \param i The icon owning the menu.
|
||||
* \param *menu The menu from which the selection was made.
|
||||
* \param *selection The wimp menu selection data.
|
||||
* \param action The selected menu action.
|
||||
* \return true if action accepted; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_hotlist_menu_select(wimp_w window, wimp_menu *menu,
|
||||
bool ro_gui_hotlist_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
|
||||
wimp_selection *selection, menu_action action)
|
||||
{
|
||||
switch (action) {
|
||||
case HOTLIST_EXPORT:
|
||||
ro_gui_dialog_open_persistent(window, dialog_saveas, true);
|
||||
ro_gui_dialog_open_persistent(w, dialog_saveas, true);
|
||||
return true;
|
||||
case TREE_NEW_FOLDER:
|
||||
hotlist_add_folder();
|
||||
|
@ -342,12 +377,12 @@ bool ro_gui_hotlist_menu_select(wimp_w window, wimp_menu *menu,
|
|||
hotlist_clear_selection();
|
||||
return true;
|
||||
case TOOLBAR_BUTTONS:
|
||||
hotlist_window.toolbar->display_buttons =
|
||||
!hotlist_window.toolbar->display_buttons;
|
||||
ro_gui_theme_refresh_toolbar(hotlist_window.toolbar);
|
||||
ro_toolbar_set_display_buttons(hotlist_window.toolbar,
|
||||
!ro_toolbar_get_display_buttons(
|
||||
hotlist_window.toolbar));
|
||||
return true;
|
||||
case TOOLBAR_EDIT:
|
||||
ro_gui_theme_toggle_edit(hotlist_window.toolbar);
|
||||
ro_toolbar_toggle_edit(hotlist_window.toolbar);
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
@ -356,21 +391,6 @@ bool ro_gui_hotlist_menu_select(wimp_w window, wimp_menu *menu,
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the theme details of the hotlist window.
|
||||
*
|
||||
* \param full_update true to force a full theme change; false to
|
||||
* refresh the toolbar size.
|
||||
*/
|
||||
|
||||
void ro_gui_hotlist_update_theme(bool full_update)
|
||||
{
|
||||
if (full_update)
|
||||
ro_treeview_update_theme(hotlist_window.tv);
|
||||
else
|
||||
ro_treeview_update_toolbar(hotlist_window.tv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a particular window handle is the hotlist window
|
||||
*
|
||||
|
|
|
@ -30,15 +30,8 @@ void ro_gui_hotlist_preinitialise(void);
|
|||
void ro_gui_hotlist_postinitialise(void);
|
||||
void ro_gui_hotlist_open(void);
|
||||
void ro_gui_hotlist_save(void);
|
||||
void ro_gui_hotlist_update_theme(bool full_update);
|
||||
bool ro_gui_hotlist_check_window(wimp_w window);
|
||||
bool ro_gui_hotlist_check_menu(wimp_menu *menu);
|
||||
bool ro_gui_hotlist_toolbar_click(wimp_pointer *pointer);
|
||||
void ro_gui_hotlist_menu_prepare(wimp_w window, wimp_menu *menu);
|
||||
bool ro_gui_hotlist_menu_select(wimp_w window, wimp_menu *menu,
|
||||
wimp_selection *selection, menu_action action);
|
||||
void ro_gui_hotlist_menu_warning(wimp_w window, wimp_menu *menu,
|
||||
wimp_selection *selection, menu_action action);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -0,0 +1,233 @@
|
|||
/*
|
||||
* Copyright 2010 Stephen Fryatt <stevef@netsurf-browser.org>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
* NetSurf is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* NetSurf is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Iconbar icon and menus (implementation).
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <features.h>
|
||||
#include "oslib/os.h"
|
||||
#include "oslib/osbyte.h"
|
||||
#include "oslib/wimp.h"
|
||||
#include "riscos/configure.h"
|
||||
#include "riscos/cookies.h"
|
||||
#include "riscos/dialog.h"
|
||||
#include "riscos/global_history.h"
|
||||
#include "riscos/hotlist.h"
|
||||
#include "riscos/iconbar.h"
|
||||
#include "riscos/options.h"
|
||||
#include "riscos/wimp_event.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
static bool ro_gui_iconbar_click(wimp_pointer *pointer);
|
||||
|
||||
static bool ro_gui_iconbar_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
|
||||
wimp_selection *selection, menu_action action);
|
||||
static void ro_gui_iconbar_menu_warning(wimp_w w, wimp_i i, wimp_menu *menu,
|
||||
wimp_selection *selection, menu_action action);
|
||||
|
||||
|
||||
static wimp_menu *ro_gui_iconbar_menu = NULL; /**< Iconbar menu handle */
|
||||
|
||||
/**
|
||||
* Initialise the iconbar menus, create an icon and register the necessary
|
||||
* handlers to look after them all.
|
||||
*/
|
||||
|
||||
void ro_gui_iconbar_initialise(void)
|
||||
{
|
||||
os_error *error;
|
||||
|
||||
/* Build the iconbar menu */
|
||||
|
||||
static const struct ns_menu iconbar_definition = {
|
||||
"NetSurf", {
|
||||
{ "Info", NO_ACTION, &dialog_info },
|
||||
{ "AppHelp", HELP_OPEN_CONTENTS, 0 },
|
||||
{ "Open", BROWSER_NAVIGATE_URL, 0 },
|
||||
{ "Open.OpenURL", BROWSER_NAVIGATE_URL, &dialog_openurl },
|
||||
{ "Open.HotlistShow", HOTLIST_SHOW, 0 },
|
||||
{ "Open.HistGlobal", HISTORY_SHOW_GLOBAL, 0 },
|
||||
{ "Open.ShowCookies", COOKIES_SHOW, 0 },
|
||||
{ "Choices", CHOICES_SHOW, 0 },
|
||||
{ "Quit", APPLICATION_QUIT, 0 },
|
||||
{NULL, 0, 0}
|
||||
}
|
||||
};
|
||||
ro_gui_iconbar_menu = ro_gui_menu_define_menu(&iconbar_definition);
|
||||
|
||||
/* Create an iconbar icon. */
|
||||
|
||||
wimp_icon_create icon = {
|
||||
wimp_ICON_BAR_RIGHT,
|
||||
{ { 0, 0, 68, 68 },
|
||||
wimp_ICON_SPRITE | wimp_ICON_HCENTRED | wimp_ICON_VCENTRED |
|
||||
(wimp_BUTTON_CLICK << wimp_ICON_BUTTON_TYPE_SHIFT),
|
||||
{ "!netsurf" } } };
|
||||
error = xwimp_create_icon(&icon, 0);
|
||||
if (error) {
|
||||
LOG(("xwimp_create_icon: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
die(error->errmess);
|
||||
}
|
||||
|
||||
/* Register handlers to look after clicks and menu actions. */
|
||||
|
||||
ro_gui_wimp_event_register_mouse_click(wimp_ICON_BAR,
|
||||
ro_gui_iconbar_click);
|
||||
|
||||
ro_gui_wimp_event_register_menu(wimp_ICON_BAR, ro_gui_iconbar_menu,
|
||||
true, true);
|
||||
ro_gui_wimp_event_register_menu_selection(wimp_ICON_BAR,
|
||||
ro_gui_iconbar_menu_select);
|
||||
ro_gui_wimp_event_register_menu_warning(wimp_ICON_BAR,
|
||||
ro_gui_iconbar_menu_warning);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle Mouse_Click events on the iconbar icon.
|
||||
*
|
||||
* \param *pointer The wimp event block to be processed.
|
||||
* \return true if the event was handled; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_iconbar_click(wimp_pointer *pointer)
|
||||
{
|
||||
char url[80];
|
||||
int key_down = 0;
|
||||
|
||||
switch (pointer->buttons) {
|
||||
case wimp_CLICK_SELECT:
|
||||
if (option_homepage_url && option_homepage_url[0]) {
|
||||
browser_window_create(option_homepage_url, NULL, 0,
|
||||
true, false);
|
||||
} else {
|
||||
snprintf(url, sizeof url,
|
||||
"file:///<NetSurf$Dir>/Docs/welcome/index_%s",
|
||||
option_language);
|
||||
browser_window_create(url, NULL, 0, true, false);
|
||||
}
|
||||
break;
|
||||
|
||||
case wimp_CLICK_ADJUST:
|
||||
xosbyte1(osbyte_SCAN_KEYBOARD, 0 ^ 0x80, 0, &key_down);
|
||||
if (key_down == 0)
|
||||
ro_gui_hotlist_open();
|
||||
else
|
||||
ro_gui_debugwin_open();
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle submenu warnings for the iconbar menu
|
||||
*
|
||||
* \param w The window owning the menu.
|
||||
* \param i The icon owning the menu.
|
||||
* \param *menu The menu to which the warning applies.
|
||||
* \param *selection The wimp menu selection data.
|
||||
* \param action The selected menu action.
|
||||
*/
|
||||
|
||||
void ro_gui_iconbar_menu_warning(wimp_w w, wimp_i i, wimp_menu *menu,
|
||||
wimp_selection *selection, menu_action action)
|
||||
{
|
||||
if (w != wimp_ICON_BAR || i != wimp_ICON_WINDOW)
|
||||
return;
|
||||
|
||||
switch (action) {
|
||||
case BROWSER_NAVIGATE_URL:
|
||||
ro_gui_dialog_prepare_open_url();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle selections from the iconbar menu
|
||||
*
|
||||
* \param w The window owning the menu.
|
||||
* \param i The icon owning the menu.
|
||||
* \param *selection The wimp menu selection data.
|
||||
* \param action The selected menu action.
|
||||
* \return true if action accepted; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_iconbar_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
|
||||
wimp_selection *selection, menu_action action)
|
||||
{
|
||||
if (w != wimp_ICON_BAR || i != wimp_ICON_WINDOW)
|
||||
return false;
|
||||
|
||||
switch (action) {
|
||||
case HELP_OPEN_CONTENTS:
|
||||
ro_gui_open_help_page("documentation/index");
|
||||
return true;
|
||||
case BROWSER_NAVIGATE_URL:
|
||||
ro_gui_dialog_prepare_open_url();
|
||||
ro_gui_dialog_open_persistent(NULL, dialog_openurl, true);
|
||||
return true;
|
||||
case HOTLIST_SHOW:
|
||||
ro_gui_hotlist_open();
|
||||
return true;
|
||||
case HISTORY_SHOW_GLOBAL:
|
||||
ro_gui_global_history_open();
|
||||
return true;
|
||||
case COOKIES_SHOW:
|
||||
ro_gui_cookies_open();
|
||||
return true;
|
||||
case CHOICES_SHOW:
|
||||
ro_gui_configure_show();
|
||||
return true;
|
||||
case APPLICATION_QUIT:
|
||||
if (ro_gui_prequit()) {
|
||||
LOG(("QUIT in response to user request"));
|
||||
netsurf_quit = true;
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a particular menu handle is the iconbar menu
|
||||
*
|
||||
* \param *menu The menu in question.
|
||||
* \return true if this menu is the iconbar menu
|
||||
*/
|
||||
|
||||
bool ro_gui_iconbar_check_menu(wimp_menu *menu)
|
||||
{
|
||||
return (ro_gui_iconbar_menu == menu) ? true : false;
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright 2010 Stephen Fryatt <stevef@netsurf-browser.org>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
* NetSurf is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* NetSurf is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Iconbar icon and menus (interface).
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifndef _NETSURF_RISCOS_ICONBAR_H_
|
||||
#define _NETSURF_RISCOS_ICONBAR_H_
|
||||
|
||||
void ro_gui_iconbar_initialise(void);
|
||||
bool ro_gui_iconbar_check_menu(wimp_menu *menu);
|
||||
|
||||
#endif
|
||||
|
1569
riscos/menus.c
1569
riscos/menus.c
File diff suppressed because it is too large
Load Diff
|
@ -23,13 +23,9 @@
|
|||
#include "oslib/wimp.h"
|
||||
#include "riscos/gui.h"
|
||||
|
||||
extern wimp_menu *iconbar_menu, *browser_menu, *hotlist_menu, *cookies_menu,
|
||||
*global_history_menu, *image_quality_menu,
|
||||
*browser_toolbar_menu, *tree_toolbar_menu, *proxy_type_menu;
|
||||
extern wimp_menu *languages_menu, *url_suggest_menu;
|
||||
extern wimp_menu *image_quality_menu, *proxy_type_menu, *languages_menu;
|
||||
|
||||
extern wimp_menu *current_menu;
|
||||
extern int iconbar_menu_height;
|
||||
|
||||
typedef enum {
|
||||
|
||||
|
@ -170,21 +166,16 @@ struct ns_menu {
|
|||
|
||||
|
||||
void ro_gui_menu_init(void);
|
||||
void ro_gui_menu_create(wimp_menu* menu, int x, int y, wimp_w w, bool prepare);
|
||||
bool ro_gui_menu_handle_action(wimp_w owner, menu_action action,
|
||||
bool windows_at_pointer);
|
||||
void ro_gui_menu_prepare_action(wimp_w owner, menu_action action,
|
||||
bool windows);
|
||||
void ro_gui_menu_closed(bool cleanup);
|
||||
void ro_gui_menu_objects_moved(void);
|
||||
void ro_gui_menu_create(wimp_menu* menu, int x, int y, wimp_w w);
|
||||
void ro_gui_menu_closed(void);
|
||||
void ro_gui_popup_menu(wimp_menu *menu, wimp_w w, wimp_i i);
|
||||
void ro_gui_menu_window_changed(wimp_w from, wimp_w to);
|
||||
void ro_gui_menu_selection(wimp_selection* selection);
|
||||
void ro_gui_menu_warning(wimp_message_menu_warning *warning);
|
||||
void ro_gui_menu_refresh(wimp_menu *menu);
|
||||
void ro_gui_menu_init_structure(wimp_menu *menu, int entries);
|
||||
void ro_gui_prepare_navigate(struct gui_window *gui);
|
||||
const char *ro_gui_menu_find_menu_entry_key(wimp_menu *menu,
|
||||
const char *translated);
|
||||
|
||||
wimp_menu *ro_gui_menu_define_menu(const struct ns_menu *menu);
|
||||
void ro_gui_menu_set_entry_shaded(wimp_menu *menu, menu_action action,
|
||||
bool shaded);
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
#include "riscos/gui.h"
|
||||
#include "riscos/options.h"
|
||||
#include "riscos/plugin.h"
|
||||
#include "riscos/theme.h"
|
||||
#include "riscos/toolbar.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/messages.h"
|
||||
#include "utils/url.h"
|
||||
|
@ -362,8 +362,7 @@ void plugin_open(struct content *c, struct browser_window *bw,
|
|||
|
||||
pmo.bbox.x0 = 10;
|
||||
/* avoid toolbar */
|
||||
pmo.bbox.y1 = -10 - (bw->window->toolbar ?
|
||||
bw->window->toolbar->height : 0);
|
||||
pmo.bbox.y1 = -10 - ro_toolbar_height(bw->window->toolbar);
|
||||
pmo.bbox.x1 = (state.visible.x1 - state.visible.x0) - 10;
|
||||
pmo.bbox.y0 = (state.visible.y0 - state.visible.y1) - 10;
|
||||
}
|
||||
|
@ -501,8 +500,8 @@ void plugin_reformat(struct content *c, int width, int height)
|
|||
/* standalone */
|
||||
x = 10 / 2;
|
||||
/* avoid toolbar */
|
||||
y = (10 + (c->data.plugin.bw->window->toolbar ?
|
||||
c->data.plugin.bw->window->toolbar->height : 0)) / 2;
|
||||
y = (10 + ro_toolbar_height(
|
||||
c->data.plugin.bw->window->toolbar0)) / 2;
|
||||
}
|
||||
|
||||
pmr.size = 52;
|
||||
|
|
|
@ -532,7 +532,7 @@ void ro_print_cleanup(void)
|
|||
print_text_black = false;
|
||||
print_prev_message = 0;
|
||||
print_max_sheets = -1;
|
||||
ro_gui_menu_closed(true);
|
||||
ro_gui_menu_closed();
|
||||
ro_gui_dialog_close(dialog_print);
|
||||
}
|
||||
|
||||
|
|
|
@ -66,6 +66,9 @@ wimp_menu *recent_search_menu = (wimp_menu *)&menu_recent;
|
|||
|
||||
static void ro_gui_search_end(wimp_w w);
|
||||
static bool ro_gui_search_next(wimp_w w);
|
||||
static bool ro_gui_search_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
|
||||
wimp_pointer *pointer);
|
||||
static bool ro_gui_search_prepare_menu(void);
|
||||
static bool ro_gui_search_click(wimp_pointer *pointer);
|
||||
static bool ro_gui_search_keypress(wimp_key *key);
|
||||
static search_flags_t ro_gui_search_update_flags(void);
|
||||
|
@ -90,6 +93,8 @@ void ro_gui_search_init(void)
|
|||
ro_gui_search_keypress);
|
||||
ro_gui_wimp_event_register_close_window(dialog_search,
|
||||
ro_gui_search_end);
|
||||
ro_gui_wimp_event_register_menu_prepare(dialog_search,
|
||||
ro_gui_search_menu_prepare);
|
||||
ro_gui_wimp_event_register_menu_gright(dialog_search,
|
||||
ICON_SEARCH_TEXT, ICON_SEARCH_MENU,
|
||||
recent_search_menu);
|
||||
|
@ -117,7 +122,7 @@ void ro_gui_search_init(void)
|
|||
bool ro_gui_search_next(wimp_w w)
|
||||
{
|
||||
search_data.search_insert = true;
|
||||
search_flags_t flags = SEARCH_FLAG_FORWARDS |
|
||||
search_flags_t flags = SEARCH_FLAG_FORWARDS |
|
||||
ro_gui_search_update_flags();
|
||||
if (search_verify_new(search_data.search_window,
|
||||
&ro_gui_search_callbacks, NULL))
|
||||
|
@ -127,13 +132,39 @@ bool ro_gui_search_next(wimp_w w)
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Callback to prepare menus in the Search dialog. At present, this
|
||||
* only has to handle the previous search pop-up.
|
||||
*
|
||||
* \param w The window handle owning the menu.
|
||||
* \param i The icon handle owning the menu.
|
||||
* \param *menu The menu to be prepared.
|
||||
* \param *pointer The associated mouse click event block, or NULL
|
||||
* on an Adjust-click re-opening.
|
||||
* \return true if the event was handled; false if not.
|
||||
*/
|
||||
|
||||
bool ro_gui_search_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
|
||||
wimp_pointer *pointer)
|
||||
{
|
||||
if (menu != recent_search_menu || i != ICON_SEARCH_MENU)
|
||||
return false;
|
||||
|
||||
if (pointer != NULL)
|
||||
return ro_gui_search_prepare_menu();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool ro_gui_search_click(wimp_pointer *pointer)
|
||||
{
|
||||
search_flags_t flags;
|
||||
switch (pointer->i) {
|
||||
case ICON_SEARCH_FIND_PREV:
|
||||
search_data.search_insert = true;
|
||||
flags = ~SEARCH_FLAG_FORWARDS &
|
||||
flags = ~SEARCH_FLAG_FORWARDS &
|
||||
ro_gui_search_update_flags();
|
||||
if (search_verify_new(search_data.search_window,
|
||||
&ro_gui_search_callbacks, NULL))
|
||||
|
@ -144,7 +175,7 @@ bool ro_gui_search_click(wimp_pointer *pointer)
|
|||
ICON_SEARCH_TEXT));
|
||||
return true;
|
||||
case ICON_SEARCH_CASE_SENSITIVE:
|
||||
flags = SEARCH_FLAG_FORWARDS |
|
||||
flags = SEARCH_FLAG_FORWARDS |
|
||||
ro_gui_search_update_flags();
|
||||
if (search_verify_new(search_data.search_window,
|
||||
&ro_gui_search_callbacks, NULL))
|
||||
|
@ -157,7 +188,7 @@ bool ro_gui_search_click(wimp_pointer *pointer)
|
|||
case ICON_SEARCH_SHOW_ALL:
|
||||
if (search_data.search_window->search_context != NULL)
|
||||
search_show_all(ro_gui_get_icon_selected_state(
|
||||
pointer->w, pointer->i),
|
||||
pointer->w, pointer->i),
|
||||
search_data.search_window->
|
||||
search_context);
|
||||
return true;
|
||||
|
@ -309,19 +340,19 @@ bool ro_gui_search_keypress(wimp_key *key)
|
|||
ICON_SEARCH_CASE_SENSITIVE);
|
||||
ro_gui_set_icon_selected_state(dialog_search,
|
||||
ICON_SEARCH_CASE_SENSITIVE, !state);
|
||||
flags = SEARCH_FLAG_FORWARDS |
|
||||
flags = SEARCH_FLAG_FORWARDS |
|
||||
ro_gui_search_update_flags();
|
||||
if (search_verify_new(search_data.search_window,
|
||||
&ro_gui_search_callbacks, NULL))
|
||||
search_step(search_data.search_window->
|
||||
search_context, flags,
|
||||
ro_gui_get_icon_string(
|
||||
dialog_search,
|
||||
dialog_search,
|
||||
ICON_SEARCH_TEXT));
|
||||
return true;
|
||||
case IS_WIMP_KEY | wimp_KEY_UP:
|
||||
search_data.search_insert = true;
|
||||
flags = ~SEARCH_FLAG_FORWARDS &
|
||||
flags = ~SEARCH_FLAG_FORWARDS &
|
||||
ro_gui_search_update_flags();
|
||||
if (search_verify_new(search_data.search_window,
|
||||
&ro_gui_search_callbacks, NULL))
|
||||
|
@ -333,7 +364,7 @@ bool ro_gui_search_keypress(wimp_key *key)
|
|||
return true;
|
||||
case IS_WIMP_KEY | wimp_KEY_DOWN:
|
||||
search_data.search_insert = true;
|
||||
flags = SEARCH_FLAG_FORWARDS |
|
||||
flags = SEARCH_FLAG_FORWARDS |
|
||||
ro_gui_search_update_flags();
|
||||
if (search_verify_new(search_data.search_window,
|
||||
&ro_gui_search_callbacks, NULL))
|
||||
|
@ -353,7 +384,7 @@ bool ro_gui_search_keypress(wimp_key *key)
|
|||
search_data.
|
||||
search_window->
|
||||
search_context);
|
||||
ro_gui_search_set_forward_state(true,
|
||||
ro_gui_search_set_forward_state(true,
|
||||
search_data.search_window);
|
||||
ro_gui_search_set_back_state(true,
|
||||
search_data.search_window);
|
||||
|
@ -362,15 +393,15 @@ bool ro_gui_search_keypress(wimp_key *key)
|
|||
if (key->c == 8 || /* backspace */
|
||||
key->c == 21 || /* ctrl u */
|
||||
(key->c >= 0x20 && key->c <= 0x7f)) {
|
||||
flags = SEARCH_FLAG_FORWARDS |
|
||||
flags = SEARCH_FLAG_FORWARDS |
|
||||
ro_gui_search_update_flags();
|
||||
if (search_data.search_window->search_context
|
||||
if (search_data.search_window->search_context
|
||||
!= NULL)
|
||||
search_destroy_context(
|
||||
search_data.
|
||||
search_window->
|
||||
search_context);
|
||||
ro_gui_search_set_forward_state(true,
|
||||
ro_gui_search_set_forward_state(true,
|
||||
search_data.search_window);
|
||||
ro_gui_search_set_back_state(true,
|
||||
search_data.search_window);
|
||||
|
@ -378,7 +409,7 @@ bool ro_gui_search_keypress(wimp_key *key)
|
|||
&ro_gui_search_callbacks,
|
||||
NULL))
|
||||
search_step(search_data.search_window->
|
||||
search_context, flags,
|
||||
search_context, flags,
|
||||
ro_gui_get_icon_string(
|
||||
dialog_search,
|
||||
ICON_SEARCH_TEXT));
|
||||
|
@ -438,7 +469,7 @@ void ro_gui_search_set_hourglass(bool active, void *p)
|
|||
|
||||
void ro_gui_search_set_forward_state(bool active, void *p)
|
||||
{
|
||||
ro_gui_set_icon_shaded_state(dialog_search, ICON_SEARCH_FIND_NEXT,
|
||||
ro_gui_set_icon_shaded_state(dialog_search, ICON_SEARCH_FIND_NEXT,
|
||||
!active);
|
||||
}
|
||||
|
||||
|
|
|
@ -149,8 +149,8 @@ void gui_cert_verify(const char *url,
|
|||
|
||||
/* Create the SSL data and build a tree from it. */
|
||||
|
||||
sslcert_window->tv = ro_treeview_create(sslcert_window->pane, NULL,
|
||||
sslcert_get_tree_flags());
|
||||
sslcert_window->tv = ro_treeview_create(sslcert_window->pane,
|
||||
NULL, NULL, sslcert_get_tree_flags());
|
||||
if (sslcert_window->tv == NULL) {
|
||||
LOG(("Failed to allocate treeview"));
|
||||
free(sslcert_window);
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "desktop/selection.h"
|
||||
#include "desktop/textinput.h"
|
||||
#include "riscos/gui.h"
|
||||
#include "riscos/menus.h"
|
||||
#include "riscos/message.h"
|
||||
#include "riscos/save.h"
|
||||
#include "riscos/textselection.h"
|
||||
|
@ -260,6 +261,8 @@ bool gui_empty_clipboard(void)
|
|||
|
||||
void gui_clear_selection(struct gui_window *g)
|
||||
{
|
||||
/* Refresh any open menu, in case it's the browser window menu. */
|
||||
ro_gui_menu_refresh(0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -566,7 +569,7 @@ void ro_gui_selection_dragging(wimp_message *message)
|
|||
|
||||
bw = g->bw;
|
||||
h = bw->current_content;
|
||||
if (h && content_get_type(h) == CONTENT_HTML &&
|
||||
if (h && content_get_type(h) == CONTENT_HTML &&
|
||||
html_get_box_tree(h)) {
|
||||
struct box *box = html_get_box_tree(h);
|
||||
|
||||
|
|
1857
riscos/theme.c
1857
riscos/theme.c
File diff suppressed because it is too large
Load Diff
126
riscos/theme.h
126
riscos/theme.h
|
@ -17,60 +17,32 @@
|
|||
*/
|
||||
|
||||
/** \file
|
||||
* Window themes and toolbars (interface).
|
||||
* Window themes(interface).
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "oslib/osspriteop.h"
|
||||
|
||||
#ifndef _NETSURF_RISCOS_THEME_H_
|
||||
#define _NETSURF_RISCOS_THEME_H_
|
||||
|
||||
/* icon numbers for browser toolbars */
|
||||
#define ICON_TOOLBAR_BACK 0
|
||||
#define ICON_TOOLBAR_FORWARD 1
|
||||
#define ICON_TOOLBAR_STOP 2
|
||||
#define ICON_TOOLBAR_RELOAD 3
|
||||
#define ICON_TOOLBAR_HOME 4
|
||||
#define ICON_TOOLBAR_HISTORY 5
|
||||
#define ICON_TOOLBAR_SAVE 6
|
||||
#define ICON_TOOLBAR_PRINT 7
|
||||
#define ICON_TOOLBAR_BOOKMARK 8
|
||||
#define ICON_TOOLBAR_SCALE 9
|
||||
#define ICON_TOOLBAR_SEARCH 10
|
||||
#define ICON_TOOLBAR_UP 11
|
||||
#define ICON_TOOLBAR_LAST 12
|
||||
#define ICON_TOOLBAR_SURROUND 12 // Must be after highest toolbar icon
|
||||
#define ICON_TOOLBAR_FAVICON 13
|
||||
#define ICON_TOOLBAR_URL 14
|
||||
#define ICON_TOOLBAR_SUGGEST 15
|
||||
#define ICON_TOOLBAR_THROBBER 16
|
||||
|
||||
/* icon numbers for hotlist/history toolbars */
|
||||
#define ICON_TOOLBAR_DELETE 0
|
||||
#define ICON_TOOLBAR_EXPAND 1
|
||||
#define ICON_TOOLBAR_OPEN 2
|
||||
#define ICON_TOOLBAR_COOKIES_LAST 4
|
||||
#define ICON_TOOLBAR_LAUNCH 3
|
||||
#define ICON_TOOLBAR_HISTORY_LAST 4
|
||||
#define ICON_TOOLBAR_CREATE 4 // must be after last history icon
|
||||
#define ICON_TOOLBAR_HOTLIST_LAST 5
|
||||
|
||||
/* editing toolbar separator number */
|
||||
#define ICON_TOOLBAR_SEPARATOR_BROWSER 11
|
||||
#define ICON_TOOLBAR_SEPARATOR_HOTLIST 5
|
||||
#define ICON_TOOLBAR_SEPARATOR_HISTORY 4
|
||||
#define ICON_TOOLBAR_SEPARATOR_COOKIES 3
|
||||
/** Theme styles, collecting groups of attributes for different locations. */
|
||||
|
||||
typedef enum {
|
||||
THEME_BROWSER_TOOLBAR,
|
||||
THEME_HOTLIST_TOOLBAR,
|
||||
THEME_HISTORY_TOOLBAR,
|
||||
THEME_COOKIES_TOOLBAR,
|
||||
THEME_BROWSER_EDIT_TOOLBAR,
|
||||
THEME_HOTLIST_EDIT_TOOLBAR,
|
||||
THEME_HISTORY_EDIT_TOOLBAR,
|
||||
THEME_COOKIES_EDIT_TOOLBAR
|
||||
} toolbar_type;
|
||||
THEME_STYLE_NONE = 0,
|
||||
THEME_STYLE_BROWSER_TOOLBAR,
|
||||
THEME_STYLE_HOTLIST_TOOLBAR,
|
||||
THEME_STYLE_COOKIES_TOOLBAR,
|
||||
THEME_STYLE_GLOBAL_HISTORY_TOOLBAR,
|
||||
THEME_STYLE_STATUS_BAR
|
||||
} theme_style;
|
||||
|
||||
/** Theme elements, which belong to styles. */
|
||||
|
||||
typedef enum {
|
||||
THEME_ELEMENT_FOREGROUND,
|
||||
THEME_ELEMENT_BACKGROUND
|
||||
} theme_element;
|
||||
|
||||
struct theme_file_header {
|
||||
unsigned int magic_value;
|
||||
|
@ -89,18 +61,6 @@ struct theme_file_header {
|
|||
unsigned int decompressed_sprite_size;
|
||||
};
|
||||
|
||||
struct toolbar_icon {
|
||||
int icon_number; /**< wimp icon number */
|
||||
bool display; /**< whether to display the icon */
|
||||
int x; /**< icon x position (valid only when displayed) */
|
||||
int y; /**< icon y position (valid only when displayed) */
|
||||
int width; /**< icon width */
|
||||
int height; /**< icon height */
|
||||
char name[12]; /**< icon name */
|
||||
char validation[40]; /**< validation string */
|
||||
struct toolbar_icon *next; /**< next toolbar icon, or NULL for no more */
|
||||
};
|
||||
|
||||
struct theme {
|
||||
osspriteop_area *sprite_area; /**< sprite area for theme */
|
||||
int throbber_width; /**< width of the throbber */
|
||||
|
@ -109,26 +69,6 @@ struct theme {
|
|||
int users; /**< number of users for the theme */
|
||||
};
|
||||
|
||||
struct toolbar {
|
||||
bool display_buttons; /**< display standard buttons */
|
||||
bool display_url; /**< display URL bar (if applicable) */
|
||||
bool display_throbber; /**< display throbber (if applicable) */
|
||||
int toolbar_current; /**< the size of the toolbar window in OS units */
|
||||
int height; /**< vertical extent of the toolbar (read only) */
|
||||
int max_height; /**< allowed vertical extent (read only) */
|
||||
int old_height; /**< height on last test (read only) */
|
||||
wimp_w toolbar_handle; /**< toolbar window handle */
|
||||
wimp_w parent_handle; /**< parent window handle (read only) */
|
||||
bool reformat_buttons; /**< buttons need reformatting */
|
||||
char *url_buffer; /**< buffer for status text (read only) */
|
||||
char *throbber_buffer; /**< buffer for status text (read only) */
|
||||
struct toolbar_icon *icon; /**< first toolbar icon (read only) */
|
||||
struct toolbar_icon *suggest; /**< suggestion toolbar icon (read only) */
|
||||
struct theme_descriptor *descriptor; /**< theme descriptor (read only) */
|
||||
toolbar_type type; /**< toolbar type (read only) */
|
||||
struct toolbar *editor; /**< toolbar editor */
|
||||
};
|
||||
|
||||
struct theme_descriptor {
|
||||
char *leafname; /**< theme leafname */
|
||||
char *filename; /**< theme filename */
|
||||
|
@ -151,33 +91,19 @@ void ro_gui_theme_initialise(void);
|
|||
void ro_gui_theme_finalise(void);
|
||||
struct theme_descriptor *ro_gui_theme_find(const char *leafname);
|
||||
struct theme_descriptor *ro_gui_theme_get_available(void);
|
||||
struct theme_descriptor *ro_gui_theme_get_current(void);
|
||||
osspriteop_area *ro_gui_theme_get_sprites(struct theme_descriptor *descriptor);
|
||||
int ro_gui_theme_get_style_element(struct theme_descriptor *descriptor,
|
||||
theme_style style, theme_element element);
|
||||
bool ro_gui_theme_get_throbber_data(struct theme_descriptor *descriptor,
|
||||
int *frames, int *width, int *height,
|
||||
bool *right, bool *redraw);
|
||||
|
||||
bool ro_gui_theme_read_file_header(struct theme_descriptor *descriptor,
|
||||
struct theme_file_header *file_header);
|
||||
|
||||
bool ro_gui_theme_open(struct theme_descriptor *descriptor, bool list);
|
||||
bool ro_gui_theme_apply(struct theme_descriptor *descriptor);
|
||||
void ro_gui_theme_close(struct theme_descriptor *descriptor, bool list);
|
||||
|
||||
struct toolbar *ro_gui_theme_create_toolbar(struct theme_descriptor *descriptor, toolbar_type type);
|
||||
bool ro_gui_theme_update_toolbar(struct theme_descriptor *descriptor, struct toolbar *toolbar);
|
||||
bool ro_gui_theme_attach_toolbar(struct toolbar *toolbar, wimp_w parent);
|
||||
bool ro_gui_theme_process_toolbar(struct toolbar *toolbar, int width);
|
||||
void ro_gui_theme_destroy_toolbar(struct toolbar *toolbar);
|
||||
void ro_gui_theme_refresh_toolbar(struct toolbar *toolbar);
|
||||
|
||||
void ro_gui_theme_toggle_edit(struct toolbar *toolbar);
|
||||
void ro_gui_theme_toolbar_editor_sync(struct toolbar *toolbar);
|
||||
void ro_gui_theme_toolbar_editor_click(struct toolbar *toolbar, wimp_pointer *pointer);
|
||||
void ro_gui_theme_toolbar_editor_drag_end(wimp_dragged *drag);
|
||||
|
||||
int ro_gui_theme_height_change(struct toolbar *toolbar);
|
||||
|
||||
struct toolbar_icon *ro_gui_theme_toolbar_get_icon(struct toolbar *toolbar, int x, int y);
|
||||
|
||||
#define ro_gui_theme_toolbar_height(toolbar) (toolbar->height + \
|
||||
(toolbar->editor ? toolbar->editor->height : 0) > toolbar->max_height ? \
|
||||
toolbar->max_height : toolbar->height + \
|
||||
(toolbar->editor ? toolbar->editor->height : 0))
|
||||
#define ro_gui_theme_toolbar_full_height(toolbar) (toolbar->height + \
|
||||
(toolbar->editor ? toolbar->editor->height : 0))
|
||||
#endif
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,525 @@
|
|||
/*
|
||||
* Copyright 2005 Richard Wilson <info@tinct.net>
|
||||
* Copyright 2010, 2011 Stephen Fryatt <stevef@netsurf-browser.org>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
* NetSurf is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* NetSurf is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Window toolbars (interface).
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "riscos/theme.h"
|
||||
#include "riscos/gui/button_bar.h"
|
||||
#include "riscos/gui/throbber.h"
|
||||
#include "riscos/gui/url_bar.h"
|
||||
|
||||
#ifndef _NETSURF_RISCOS_TOOLBAR_H_
|
||||
#define _NETSURF_RISCOS_TOOLBAR_H_
|
||||
|
||||
typedef enum {
|
||||
TOOLBAR_FLAGS_NONE = 0x00,
|
||||
TOOLBAR_FLAGS_DISPLAY = 0x01,
|
||||
TOOLBAR_FLAGS_EDIT = 0x02,
|
||||
} toolbar_flags;
|
||||
|
||||
/**
|
||||
* Widget action types that the toolbar can pass on to clients.
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
TOOLBAR_ACTION_NONE = 0,
|
||||
TOOLBAR_ACTION_BUTTON,
|
||||
TOOLBAR_ACTION_URL
|
||||
} toolbar_action_type;
|
||||
|
||||
/**
|
||||
* Union to hold the different widget action data that can be passed
|
||||
* from widget via toolbar to client.
|
||||
*/
|
||||
|
||||
union toolbar_action {
|
||||
button_bar_action button;
|
||||
url_bar_action url;
|
||||
};
|
||||
|
||||
struct toolbar;
|
||||
|
||||
struct toolbar_callbacks {
|
||||
/** Call on theme update */
|
||||
void (*theme_update)(void *, bool);
|
||||
|
||||
/** Call on bar size change */
|
||||
void (*change_size)(void *);
|
||||
|
||||
/** Call to update button states */
|
||||
void (*update_buttons)(void *);
|
||||
|
||||
/** Call to handle user actions */
|
||||
void (*user_action)(void *, toolbar_action_type, union toolbar_action);
|
||||
|
||||
/** Call to handle keypresses. */
|
||||
void (*key_press)(void *, wimp_key *);
|
||||
|
||||
/** Call on change to button order. */
|
||||
void (*save_buttons)(void *, char *);
|
||||
};
|
||||
|
||||
|
||||
#define ro_toolbar_menu_option_shade(toolbar) \
|
||||
(((toolbar) == NULL) || ro_toolbar_get_editing(toolbar))
|
||||
|
||||
#define ro_toolbar_menu_buttons_tick(toolbar) \
|
||||
(ro_toolbar_get_display_buttons(toolbar) || \
|
||||
ro_toolbar_get_editing(toolbar))
|
||||
|
||||
#define ro_toolbar_menu_url_tick(toolbar) \
|
||||
(ro_toolbar_get_display_url(toolbar))
|
||||
|
||||
#define ro_toolbar_menu_throbber_tick(toolbar) \
|
||||
(ro_toolbar_get_display_throbber(toolbar))
|
||||
|
||||
#define ro_toolbar_menu_edit_shade(toolbar) ((toolbar) == NULL)
|
||||
|
||||
#define ro_toolbar_menu_edit_tick(toolbar) (ro_toolbar_get_editing(toolbar))
|
||||
|
||||
|
||||
/* The new toolbar API */
|
||||
|
||||
|
||||
/**
|
||||
* Initialise the RISC OS toolbar widget.
|
||||
*/
|
||||
|
||||
void ro_toolbar_init(void);
|
||||
|
||||
|
||||
/**
|
||||
* Create a new toolbar, ready to have widgets added and to be attached to
|
||||
* a window. If a parent window is supplied, then the toolbar module will
|
||||
* handle the window attachments; if NULL, it is up to the client to sort this
|
||||
* out for itself.
|
||||
*
|
||||
* \param *descriptor The theme to apply, or NULL for the default.
|
||||
* \param parent The window to attach the toolbar to, or NULL.
|
||||
* \param style The theme style to apply.
|
||||
* \param bar_flags Toolbar flags for the new bar.
|
||||
* \param *callbacks A client callback block, or NULL for none.
|
||||
* \param *client_data A data pointer to pass to callbacks, or NULL.
|
||||
* \param *help The Help token prefix for interactive help.
|
||||
* \return The handle of the new bar, or NULL on failure.
|
||||
*/
|
||||
|
||||
struct toolbar *ro_toolbar_create(struct theme_descriptor *descriptor,
|
||||
wimp_w parent, theme_style style, toolbar_flags bar_flags,
|
||||
const struct toolbar_callbacks *callbacks, void *client_data,
|
||||
const char *help);
|
||||
|
||||
|
||||
/**
|
||||
* Add a button bar to a toolbar, and configure the buttons.
|
||||
*
|
||||
* \param *toolbar The toolbar to take the button bar.
|
||||
* \param buttons[] The button definitions.
|
||||
* \param *button_order The initial button order to use.
|
||||
* \return true if the action completed; else false.
|
||||
*/
|
||||
|
||||
bool ro_toolbar_add_buttons(struct toolbar *toolbar,
|
||||
const struct button_bar_buttons buttons[], char *button_order);
|
||||
|
||||
|
||||
/**
|
||||
* Add a throbber to a toolbar.
|
||||
*
|
||||
* \param *toolbar The toolbar to take the throbber.
|
||||
* \return true if the action completed; else false.
|
||||
*/
|
||||
|
||||
bool ro_toolbar_add_throbber(struct toolbar *toolbar);
|
||||
|
||||
|
||||
/**
|
||||
* Add a URL bar to a toolbar.
|
||||
*
|
||||
* \param *toolbar The toolbar to take the URL bar.
|
||||
* \return true if the action completed; else false.
|
||||
*/
|
||||
|
||||
bool ro_toolbar_add_url(struct toolbar *toolbar);
|
||||
|
||||
|
||||
/**
|
||||
* (Re-)build a toolbar to use the specified (or current) theme. If false
|
||||
* is returned, the toolbar may not be complete and should be deleted.
|
||||
*
|
||||
* \param *toolbar The toolbar to rebuild.
|
||||
* \return true if the action was successful; else false.
|
||||
*/
|
||||
|
||||
bool ro_toolbar_rebuild(struct toolbar *toolbar);
|
||||
|
||||
|
||||
/**
|
||||
* Attach or re-attach a toolbar to its parent window.
|
||||
*
|
||||
* \param *toolbar The toolbar to attach.
|
||||
* \param parent The window to attach the toolbar to.
|
||||
* \return true if the operation succeeded; else false.
|
||||
*/
|
||||
|
||||
bool ro_toolbar_attach(struct toolbar *toolbar, wimp_w parent);
|
||||
|
||||
|
||||
/**
|
||||
* Process a toolbar, updating its contents for a size or content change.
|
||||
*
|
||||
* \param *toolbar The toolbar to update.
|
||||
* \param width The width to reformat to, or -1 to use parent.
|
||||
* \param reformat true to force a widget reflow; else false.
|
||||
* \return true if the operation succeeded; else false.
|
||||
*/
|
||||
|
||||
bool ro_toolbar_process(struct toolbar *toolbar, int width, bool reformat);
|
||||
|
||||
|
||||
/**
|
||||
* Destroy a toolbar after use.
|
||||
*
|
||||
* \param *toolbar The toolbar to destroy.
|
||||
*/
|
||||
|
||||
void ro_toolbar_destroy(struct toolbar *toolbar);
|
||||
|
||||
|
||||
/**
|
||||
* Change the client data associated with a toolbar's callbacks.
|
||||
*
|
||||
* \param *toolbar the toolbar whose data is to be updated.
|
||||
* \param *client_data the new client data, or NULL for none.
|
||||
*/
|
||||
|
||||
void ro_toolbar_update_client_data(struct toolbar *toolbar, void *client_data);
|
||||
|
||||
|
||||
/**
|
||||
* Force the update of all toolbars buttons to reflect the current state.
|
||||
*/
|
||||
|
||||
void ro_toolbar_update_all_buttons(void);
|
||||
|
||||
|
||||
/**
|
||||
* Refresh a toolbar after it has been updated
|
||||
*
|
||||
* \param toolbar the toolbar to update
|
||||
*/
|
||||
|
||||
void ro_toolbar_refresh(struct toolbar *toolbar);
|
||||
|
||||
|
||||
/**
|
||||
* Force the update of all toolbars to reflect the application of a new theme.
|
||||
*/
|
||||
|
||||
void ro_toolbar_theme_update(void);
|
||||
|
||||
|
||||
/**
|
||||
* Find the toolbar associated with a given RO window handle.
|
||||
*
|
||||
* \param w the window handle to look up.
|
||||
* \return the toolbar handle, or NULL if a match wasn't found.
|
||||
*/
|
||||
|
||||
struct toolbar *ro_toolbar_parent_window_lookup(wimp_w w);
|
||||
|
||||
|
||||
/**
|
||||
* Find the toolbar using a given RO window handle for its pane.
|
||||
*
|
||||
* \param w the window (pane) handle to look up.
|
||||
* \return the toolbar handle, or NULL if a match wasn't found.
|
||||
*/
|
||||
|
||||
struct toolbar *ro_toolbar_window_lookup(wimp_w w);
|
||||
|
||||
|
||||
/**
|
||||
* Return the RO window handle of the parent window for a toolbar.
|
||||
*
|
||||
* \param *toolbar the toolbar to look up.
|
||||
* \return the RO window handle of the parent.
|
||||
*/
|
||||
|
||||
wimp_w ro_toolbar_get_parent_window(struct toolbar *toolbar);
|
||||
|
||||
|
||||
/**
|
||||
* Return the RO window handle of a toolbar.
|
||||
*
|
||||
* \param *toolbar the toolbar to look up.
|
||||
* \return the RO window handle of the bar.
|
||||
*/
|
||||
|
||||
wimp_w ro_toolbar_get_window(struct toolbar *toolbar);
|
||||
|
||||
|
||||
/**
|
||||
* Return the current height of a toolbar, allowing for available window
|
||||
* space.
|
||||
*
|
||||
* \param *toolbar The toolbar of interest.
|
||||
* \return The current toolbar height in OS units.
|
||||
*/
|
||||
|
||||
int ro_toolbar_height(struct toolbar *toolbar);
|
||||
|
||||
|
||||
/**
|
||||
* Return the full height that a toolbar could grow to, if space is available.
|
||||
*
|
||||
* \param *toolbar The toolbar of interest.
|
||||
* \return The full toolbar height in OS units.
|
||||
*/
|
||||
|
||||
int ro_toolbar_full_height(struct toolbar *toolbar);
|
||||
|
||||
|
||||
/**
|
||||
* Starts a toolbar throbber, if there is one active.
|
||||
*
|
||||
* \param *toolbar the toolbar to start throbbing.
|
||||
*/
|
||||
|
||||
void ro_toolbar_start_throbbing(struct toolbar *toolbar);
|
||||
|
||||
|
||||
/**
|
||||
* Stops a toolbar throbber, if there is one active.
|
||||
*
|
||||
* \param *toolbar the toolbar to stop throbbing.
|
||||
*/
|
||||
|
||||
void ro_toolbar_stop_throbbing(struct toolbar *toolbar);
|
||||
|
||||
|
||||
/**
|
||||
* Animate a toolbar throbber, if there is one active.
|
||||
*
|
||||
* \param *toolbar the toolbar to throb.
|
||||
*/
|
||||
|
||||
void ro_toolbar_throb(struct toolbar *toolbar);
|
||||
|
||||
/**
|
||||
* Change the arrangement of buttons and spacers on a button bar within a
|
||||
* toolbar.
|
||||
*
|
||||
* \param *toolbar The toolbar to change.
|
||||
* \param order[] The new button configuration.
|
||||
* \return true of the order was updated; else false.
|
||||
*/
|
||||
|
||||
bool ro_toolbar_set_button_order(struct toolbar *toolbar, char order[]);
|
||||
|
||||
|
||||
/**
|
||||
* Set the shaded state of a toolbar button.
|
||||
*
|
||||
* \param *toolbar the toolbar to update.
|
||||
* \param action the button action to update.
|
||||
* \param shaded true if the button should be shaded; else false.
|
||||
*/
|
||||
|
||||
void ro_toolbar_set_button_shaded_state(struct toolbar *toolbar,
|
||||
button_bar_action action, bool shaded);
|
||||
|
||||
/**
|
||||
* Give a toolbar input focus, placing the caret into the URL bar if one is
|
||||
* present. Currently a toolbar can only accept focus if it has a URL bar.
|
||||
*
|
||||
* \param *toolbar The toolbar to take the caret.
|
||||
* \return true if the caret was taken; else false.
|
||||
*/
|
||||
|
||||
bool ro_toolbar_take_caret(struct toolbar *toolbar);
|
||||
|
||||
|
||||
/**
|
||||
* Set the content of a toolbar's URL field.
|
||||
*
|
||||
* \param *toolbar the toolbar to update.
|
||||
* \param *url the new url to insert.
|
||||
* \param is_utf8 true if the string is in utf8 encoding; false
|
||||
* if it is in local encoding.
|
||||
* \param set_caret true if the caret should be placed in the field;
|
||||
* else false.
|
||||
*/
|
||||
|
||||
void ro_toolbar_set_url(struct toolbar *toolbar, const char *url,
|
||||
bool is_utf8, bool set_caret);
|
||||
|
||||
|
||||
/**
|
||||
* Return a pointer to the URL contained in a browser toolbar. If the toolbar
|
||||
* doesn't have a URL field, then NULL is returned instead.
|
||||
*
|
||||
* \param *toolbar The toolbar to look up the URL from.
|
||||
* \return pointer to the URL, or NULL.
|
||||
*/
|
||||
|
||||
const char *ro_toolbar_get_url(struct toolbar *toolbar);
|
||||
|
||||
|
||||
/**
|
||||
* Return the current work area coordinates of the URL and favicon field's
|
||||
* bounding box.
|
||||
*
|
||||
* \param *toolbar The toolbar to look up.
|
||||
* \param *extent Return the coordinates.
|
||||
* \return true if successful; else false.
|
||||
*/
|
||||
|
||||
bool ro_toolbar_get_url_field_extent(struct toolbar *toolbar, os_box *extent);
|
||||
|
||||
|
||||
/**
|
||||
* Update the favicon in a browser window toolbar to the supplied content, or
|
||||
* revert to using filetype-based icons.
|
||||
*
|
||||
* \param *toolbar The toolbar to refresh.
|
||||
* \param *h The new favicon to use, or NULL for none.
|
||||
*/
|
||||
|
||||
void ro_toolbar_set_site_favicon(struct toolbar *toolbar,
|
||||
struct hlcache_handle *h);
|
||||
|
||||
|
||||
/**
|
||||
* Update the favicon in a browser window toolbar to reflect the RISC OS
|
||||
* filetype of the supplied content. If the toolbar currently has a
|
||||
* site favicon set, then this call will be ignored.
|
||||
*
|
||||
* \param *toolbar The toolbar to refresh.
|
||||
* \param *h The page content to reflect.
|
||||
*/
|
||||
|
||||
void ro_toolbar_set_content_favicon(struct toolbar *toolbar,
|
||||
struct hlcache_handle *h);
|
||||
|
||||
|
||||
/**
|
||||
* Update the state of the URL suggestion pop-up menu icon on a toolbar.
|
||||
*
|
||||
* \param *toolbar The toolbar to update.
|
||||
*/
|
||||
|
||||
void ro_toolbar_update_urlsuggest(struct toolbar *toolbar);
|
||||
|
||||
|
||||
/**
|
||||
* Set the display button bar state for a toolbar.
|
||||
*
|
||||
* \param *toolbar the toolbar to update.
|
||||
* \param display true to display the button bar; else false.
|
||||
*/
|
||||
|
||||
void ro_toolbar_set_display_buttons(struct toolbar *toolbar, bool display);
|
||||
|
||||
|
||||
/**
|
||||
* Set the display URL bar state for a toolbar.
|
||||
*
|
||||
* \param *toolbar the toolbar to update.
|
||||
* \param display true to display the URL bar; else false.
|
||||
*/
|
||||
|
||||
void ro_toolbar_set_display_url(struct toolbar *toolbar, bool display);
|
||||
|
||||
|
||||
/**
|
||||
* Set the display throbber state for a toolbar.
|
||||
*
|
||||
* \param *toolbar the toolbar to update.
|
||||
* \param display true to display the throbber; else false.
|
||||
*/
|
||||
|
||||
void ro_toolbar_set_display_throbber(struct toolbar *toolbar, bool display);
|
||||
|
||||
|
||||
/**
|
||||
* Return true or false depending on whether the given toolbar is set to
|
||||
* display the button bar.
|
||||
*
|
||||
* \param *toolbar the toolbar of interest.
|
||||
* \return true if the toolbar exists and the button bar is
|
||||
* shown; else false.
|
||||
*/
|
||||
|
||||
bool ro_toolbar_get_display_buttons(struct toolbar *toolbar);
|
||||
|
||||
|
||||
/**
|
||||
* Return true or false depending on whether the given toolbar is set to
|
||||
* display the URL bar.
|
||||
*
|
||||
* \param *toolbar the toolbar of interest.
|
||||
* \return true if the toolbar exists and the URL bar is
|
||||
* shown; else false.
|
||||
*/
|
||||
|
||||
bool ro_toolbar_get_display_url(struct toolbar *toolbar);
|
||||
|
||||
|
||||
/**
|
||||
* Return true or false depending on whether the given toolbar is set to
|
||||
* display the throbber.
|
||||
*
|
||||
* \param *toolbar the toolbar of interest.
|
||||
* \return true if the toolbar exists and the throbber is
|
||||
* shown; else false.
|
||||
*/
|
||||
|
||||
bool ro_toolbar_get_display_throbber(struct toolbar *toolbar);
|
||||
|
||||
|
||||
/**
|
||||
* Return true or false depending on whether the given toolbar is currently
|
||||
* being edited.
|
||||
*
|
||||
* \param *toolbar the toolbar of interest.
|
||||
* \return true if the toolbar exists and is beng edited;
|
||||
* else false.
|
||||
*/
|
||||
|
||||
bool ro_toolbar_get_editing(struct toolbar *toolbar);
|
||||
|
||||
|
||||
/**
|
||||
* Toggle toolbar edit mode on the given toolbar. Only a button bar can be
|
||||
* edited, so edit mode can only be toggled if there's an editor button
|
||||
* bar defined.
|
||||
*
|
||||
* \param *toolbar The toolbar to be toggled.
|
||||
* \return true if the action was successful; false if
|
||||
* the action failed and the toolbar was destroyed.
|
||||
*/
|
||||
|
||||
bool ro_toolbar_toggle_edit(struct toolbar *toolbar);
|
||||
|
||||
#endif
|
||||
|
|
@ -46,7 +46,7 @@
|
|||
#include "riscos/gui.h"
|
||||
#include "riscos/image.h"
|
||||
#include "riscos/menus.h"
|
||||
#include "riscos/theme.h"
|
||||
#include "riscos/toolbar.h"
|
||||
#include "riscos/tinct.h"
|
||||
#include "riscos/textarea.h"
|
||||
#include "riscos/treeview.h"
|
||||
|
@ -87,6 +87,7 @@ struct ro_treeview
|
|||
int y; /*< Y coordinate of drag start */
|
||||
} drag_start;
|
||||
tree_drag_type drag; /*< The current drag type for the tree */
|
||||
struct ro_treeview_callbacks *callbacks; /*< Callback handlers */
|
||||
};
|
||||
|
||||
static void ro_treeview_redraw_request(int x, int y, int width, int height,
|
||||
|
@ -109,6 +110,13 @@ static bool ro_treeview_keypress(wimp_key *key);
|
|||
static void ro_treeview_set_window_extent(ro_treeview *tv,
|
||||
int width, int height);
|
||||
|
||||
static void ro_treeview_update_theme(void *data, bool ok);
|
||||
static void ro_treeview_update_toolbar(void *data);
|
||||
static void ro_treeview_button_update(void *data);
|
||||
static void ro_treeview_save_toolbar_buttons(void *data, char *config);
|
||||
static void ro_treeview_button_click(void *data,
|
||||
toolbar_action_type action_type, union toolbar_action action);
|
||||
|
||||
static const struct treeview_table ro_tree_callbacks = {
|
||||
ro_treeview_redraw_request,
|
||||
ro_treeview_resized,
|
||||
|
@ -116,18 +124,29 @@ static const struct treeview_table ro_tree_callbacks = {
|
|||
ro_treeview_get_window_dimensions
|
||||
};
|
||||
|
||||
static const struct toolbar_callbacks ro_treeview_toolbar_callbacks = {
|
||||
ro_treeview_update_theme,
|
||||
ro_treeview_update_toolbar,
|
||||
ro_treeview_button_update,
|
||||
ro_treeview_button_click,
|
||||
NULL, /* No toolbar keypress handler */
|
||||
ro_treeview_save_toolbar_buttons
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Create a RISC OS GUI implementation of a treeview tree.
|
||||
*
|
||||
* \param window The window to create the tree in.
|
||||
* \param *toolbar A toolbar to attach to the window.
|
||||
* \param *callbacks Callbacks to service the treeview.
|
||||
* \param flags The treeview flags.
|
||||
*
|
||||
* \return The RISC OS treeview pointer.
|
||||
*/
|
||||
|
||||
ro_treeview *ro_treeview_create(wimp_w window, struct toolbar *toolbar,
|
||||
unsigned int flags)
|
||||
struct ro_treeview_callbacks *callbacks, unsigned int flags)
|
||||
{
|
||||
ro_treeview *tv;
|
||||
|
||||
|
@ -166,6 +185,10 @@ ro_treeview *ro_treeview_create(wimp_w window, struct toolbar *toolbar,
|
|||
|
||||
tv->drag = TREE_NO_DRAG;
|
||||
|
||||
/* Record the callback info. */
|
||||
|
||||
tv->callbacks = callbacks;
|
||||
|
||||
/* Register wimp events to handle the supplied window. */
|
||||
|
||||
ro_gui_wimp_event_register_redraw_window(tv->w, ro_treeview_redraw);
|
||||
|
@ -193,6 +216,18 @@ void ro_treeview_destroy(ro_treeview *tv)
|
|||
free(tv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a pointer to a toolbar callbacks structure with the handlers to be
|
||||
* used by any treeview window toolbars.
|
||||
*
|
||||
* \return A pointer to the callback structure.
|
||||
*/
|
||||
|
||||
const struct toolbar_callbacks *ro_treeview_get_toolbar_callbacks(void)
|
||||
{
|
||||
return &ro_treeview_toolbar_callbacks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the redraw origin of a treeview tree in RISC OS graphics units.
|
||||
*
|
||||
|
@ -702,7 +737,7 @@ static void ro_treeview_open(wimp_open *open)
|
|||
}
|
||||
|
||||
if (tv->tb)
|
||||
ro_gui_theme_process_toolbar(tv->tb, -1);
|
||||
ro_toolbar_process(tv->tb, -1, false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -786,10 +821,16 @@ static bool ro_treeview_mouse_click(wimp_pointer *pointer)
|
|||
if (tv->drag == TREE_SELECT_DRAG ||
|
||||
tv->drag == TREE_MOVE_DRAG)
|
||||
ro_treeview_drag_start(tv, pointer, &state);
|
||||
|
||||
|
||||
if (tv->callbacks != NULL &&
|
||||
tv->callbacks->toolbar_button_update != NULL)
|
||||
tv->callbacks->toolbar_button_update();
|
||||
}
|
||||
|
||||
/* We assume that the owning module will have attached a window menu
|
||||
* to our parent window. If it hasn't, this call will quietly fail.
|
||||
* to our parent window with the auto flag unset (so that we can fudge
|
||||
* the selection above). If it hasn't, this call will quietly fail.
|
||||
*/
|
||||
|
||||
if (pointer->buttons == wimp_CLICK_MENU)
|
||||
|
@ -860,6 +901,10 @@ void ro_treeview_mouse_at(wimp_pointer *pointer)
|
|||
tv->drag_start.y, xpos, ypos);
|
||||
tv->drag = TREE_NO_DRAG;
|
||||
}
|
||||
|
||||
if (tv->callbacks != NULL &&
|
||||
tv->callbacks->toolbar_button_update != NULL)
|
||||
tv->callbacks->toolbar_button_update();
|
||||
}
|
||||
|
||||
|
||||
|
@ -884,7 +929,7 @@ static void ro_treeview_drag_start(ro_treeview *tv, wimp_pointer *pointer,
|
|||
drag.bbox.y0 = state->visible.y0;
|
||||
drag.bbox.x1 = state->visible.x1;
|
||||
drag.bbox.y1 = state->visible.y1 -
|
||||
ro_gui_theme_toolbar_height(tv->tb);
|
||||
ro_toolbar_height(tv->tb);
|
||||
|
||||
switch (tv->drag) {
|
||||
case TREE_SELECT_DRAG:
|
||||
|
@ -922,7 +967,7 @@ static void ro_treeview_drag_start(ro_treeview *tv, wimp_pointer *pointer,
|
|||
auto_scroll.pause_zone_sizes.y0 = 80;
|
||||
auto_scroll.pause_zone_sizes.x1 = 80;
|
||||
auto_scroll.pause_zone_sizes.y1 = 80 +
|
||||
ro_gui_theme_toolbar_height(tv->tb);
|
||||
ro_toolbar_height(tv->tb);
|
||||
auto_scroll.pause_duration = 0;
|
||||
auto_scroll.state_change = (void *) 1;
|
||||
|
||||
|
@ -1038,8 +1083,14 @@ static bool ro_treeview_keypress(wimp_key *key)
|
|||
}
|
||||
|
||||
if (!(c & IS_WIMP_KEY)) {
|
||||
if (tree_keypress(tv->tree, c))
|
||||
if (tree_keypress(tv->tree, c)) {
|
||||
if (tv->callbacks &&
|
||||
tv->callbacks->toolbar_button_update
|
||||
!= NULL)
|
||||
tv->callbacks->toolbar_button_update();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -1049,23 +1100,20 @@ static bool ro_treeview_keypress(wimp_key *key)
|
|||
/**
|
||||
* Update a treeview to use a new theme.
|
||||
*
|
||||
* \param *tv Pointer to the treeview to update.
|
||||
* \param *data Pointer to the treeview to update.
|
||||
* \param ok true if the bar still exists; else false.
|
||||
*/
|
||||
|
||||
void ro_treeview_update_theme(ro_treeview *tv)
|
||||
void ro_treeview_update_theme(void *data, bool ok)
|
||||
{
|
||||
if (tv != NULL && tv->tb != NULL){
|
||||
/* \todo -- Check for toolbar editing here. */
|
||||
ro_treeview *tv = (ro_treeview *) data;
|
||||
|
||||
if (!ro_gui_theme_update_toolbar(NULL, tv->tb)) {
|
||||
ro_gui_theme_destroy_toolbar(tv->tb);
|
||||
if (tv != NULL && tv->tb != NULL){
|
||||
if (ok) {
|
||||
ro_treeview_update_toolbar(tv);
|
||||
} else {
|
||||
tv->tb = NULL;
|
||||
}
|
||||
|
||||
/* \todo -- Check for toolbar editing here. */
|
||||
|
||||
ro_gui_theme_attach_toolbar(tv->tb, tv->w);
|
||||
ro_treeview_update_toolbar(tv);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1073,33 +1121,86 @@ void ro_treeview_update_theme(ro_treeview *tv)
|
|||
/**
|
||||
* Change the size of a treeview's toolbar and redraw the window.
|
||||
*
|
||||
* \param *tv The treeview to update.
|
||||
* \param *data The treeview to update.
|
||||
*/
|
||||
|
||||
void ro_treeview_update_toolbar(ro_treeview *tv)
|
||||
void ro_treeview_update_toolbar(void *data)
|
||||
{
|
||||
ro_treeview *tv = (ro_treeview *) data;
|
||||
|
||||
if (tv != NULL && tv->tb != NULL) {
|
||||
ro_treeview_set_origin(tv, 0,
|
||||
-(ro_gui_theme_toolbar_height(tv->tb)));
|
||||
-(ro_toolbar_height(tv->tb)));
|
||||
|
||||
xwimp_force_redraw(tv->w, 0, tv->extent.y, tv->extent.x, 0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update the toolbar icons in a treeview window's toolbar. As we're just
|
||||
* an intermediate widget, we pass the details on down the chain.
|
||||
*
|
||||
* \param *data The treeview owning the toolbar.
|
||||
*/
|
||||
|
||||
void ro_treeview_button_update(void *data)
|
||||
{
|
||||
ro_treeview *tv = (ro_treeview *) data;
|
||||
|
||||
if (tv == NULL || tv->callbacks == NULL)
|
||||
return;
|
||||
|
||||
if (tv->callbacks->toolbar_button_update != NULL)
|
||||
tv->callbacks->toolbar_button_update();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save a new button configuration from a treeview window's toolbar. As
|
||||
* we're just an intermediate widget, we pass the details on.
|
||||
*
|
||||
* \param *data The treeview owning the toolbar.
|
||||
* \param *config The new button config string.
|
||||
*/
|
||||
|
||||
void ro_treeview_save_toolbar_buttons(void *data, char *config)
|
||||
{
|
||||
ro_treeview *tv = (ro_treeview *) data;
|
||||
|
||||
if (tv == NULL || tv->callbacks == NULL)
|
||||
return;
|
||||
|
||||
if (tv->callbacks->toolbar_button_save != NULL)
|
||||
tv->callbacks->toolbar_button_save(config);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Process clicks on buttons in a treeview window's toolbar. As we're just
|
||||
* an intermediate widget, we just pass the details on down the chain.
|
||||
*
|
||||
* \param *data The treeview owning the click.
|
||||
* \param action_type The action type to be handled.
|
||||
* \param action The action to handle.
|
||||
*/
|
||||
|
||||
void ro_treeview_button_click(void *data,
|
||||
toolbar_action_type action_type, union toolbar_action action)
|
||||
{
|
||||
ro_treeview *tv = (ro_treeview *) data;
|
||||
|
||||
if (tv == NULL || tv->callbacks == NULL ||
|
||||
action_type != TOOLBAR_ACTION_BUTTON)
|
||||
return;
|
||||
|
||||
if (tv->callbacks->toolbar_button_click != NULL)
|
||||
tv->callbacks->toolbar_button_click(action.button);
|
||||
|
||||
if (tv->callbacks->toolbar_button_update != NULL)
|
||||
tv->callbacks->toolbar_button_update();
|
||||
}
|
||||
|
||||
#if 0
|
||||
if ((tree) && (tree->toolbar)) {
|
||||
if (tree->toolbar->editor)
|
||||
if (!ro_gui_theme_update_toolbar(NULL, tree->toolbar->editor))
|
||||
tree->toolbar->editor = NULL;
|
||||
if (!ro_gui_theme_update_toolbar(NULL, tree->toolbar)) {
|
||||
ro_gui_theme_destroy_toolbar(tree->toolbar);
|
||||
tree->toolbar = NULL;
|
||||
}
|
||||
ro_gui_theme_toolbar_editor_sync(tree->toolbar);
|
||||
ro_gui_theme_attach_toolbar(tree->toolbar, (wimp_w)tree->handle);
|
||||
tree_resized(tree);
|
||||
xwimp_force_redraw((wimp_w)tree->handle, 0, -16384, 16384, 16384);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Return a token identifying the interactive help message for a given cursor
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <oslib/wimp.h>
|
||||
|
||||
#include "desktop/tree.h"
|
||||
#include "riscos/toolbar.h"
|
||||
|
||||
/* defined in front end code */
|
||||
extern const char tree_directory_icon_name[];
|
||||
|
@ -36,13 +37,16 @@ extern const char tree_content_icon_name[];
|
|||
|
||||
typedef struct ro_treeview ro_treeview;
|
||||
|
||||
struct ro_treeview_table {
|
||||
void (*open_menu)(wimp_pointer *pointer);
|
||||
struct ro_treeview_callbacks {
|
||||
void (*toolbar_button_click)(button_bar_action action);
|
||||
void (*toolbar_button_update)(void);
|
||||
void (*toolbar_button_save)(char *);
|
||||
};
|
||||
|
||||
ro_treeview *ro_treeview_create(wimp_w window, struct toolbar *toolbar,
|
||||
unsigned int flags);
|
||||
struct ro_treeview_callbacks *callbacks, unsigned int flags);
|
||||
void ro_treeview_destroy(ro_treeview *tv);
|
||||
const struct toolbar_callbacks *ro_treeview_get_toolbar_callbacks(void);
|
||||
|
||||
struct tree *ro_treeview_get_tree(ro_treeview *tv);
|
||||
wimp_w ro_treeview_get_window(ro_treeview *tv);
|
||||
|
@ -51,8 +55,6 @@ bool ro_treeview_has_selection(ro_treeview *tv);
|
|||
void ro_treeview_set_origin(ro_treeview *tv, int x, int y);
|
||||
void ro_treeview_mouse_at(wimp_pointer *pointer);
|
||||
void ro_treeview_drag_end(wimp_dragged *drag);
|
||||
void ro_treeview_update_theme(ro_treeview *tv);
|
||||
void ro_treeview_update_toolbar(ro_treeview *tv);
|
||||
int ro_treeview_get_help(help_full_message_request *message_data);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include "utils/config.h"
|
||||
#include "content/fetch.h"
|
||||
#include "desktop/browser.h"
|
||||
#include "riscos/theme.h"
|
||||
#include "desktop/gui.h"
|
||||
#include "riscos/gui.h"
|
||||
#include "riscos/uri.h"
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include "riscos/global_history.h"
|
||||
#include "riscos/gui.h"
|
||||
#include "riscos/options.h"
|
||||
#include "riscos/theme.h"
|
||||
#include "riscos/toolbar.h"
|
||||
#include "riscos/url_complete.h"
|
||||
#include "riscos/wimp.h"
|
||||
#include "riscos/wimp_event.h"
|
||||
|
@ -62,59 +62,59 @@ static int mouse_y;
|
|||
static bool url_complete_callback(const char *url,
|
||||
const struct url_data *data);
|
||||
|
||||
/**
|
||||
* Should be called when the caret is placed into a URL completion icon.
|
||||
*
|
||||
* \param g the gui_window to initialise URL completion for
|
||||
*/
|
||||
void ro_gui_url_complete_start(struct gui_window *g)
|
||||
{
|
||||
const char *url;
|
||||
|
||||
if ((!g->toolbar) || (!g->toolbar->display_url) ||
|
||||
(g->window == url_complete_parent))
|
||||
/* This is an exported interface documented in url_complete.h */
|
||||
|
||||
void ro_gui_url_complete_start(struct toolbar *toolbar)
|
||||
{
|
||||
const char *url;
|
||||
wimp_w parent;
|
||||
|
||||
assert(toolbar != NULL);
|
||||
parent = ro_toolbar_get_parent_window(toolbar);
|
||||
|
||||
if (!ro_toolbar_get_display_url(toolbar) ||
|
||||
(parent == url_complete_parent))
|
||||
return;
|
||||
|
||||
ro_gui_url_complete_close(NULL, 0);
|
||||
url = ro_gui_get_icon_string(g->toolbar->toolbar_handle,
|
||||
ICON_TOOLBAR_URL);
|
||||
ro_gui_url_complete_close();
|
||||
url = ro_toolbar_get_url(toolbar);
|
||||
|
||||
url_complete_matched_string = strdup(url);
|
||||
if (url_complete_matched_string)
|
||||
url_complete_parent = g->window;
|
||||
url_complete_parent = parent;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handles a keypress for URL completion
|
||||
*
|
||||
* \param g the gui_window to update
|
||||
* \param key the key pressed (as UTF32 code or wimp key + bit31 set)
|
||||
* \return true to indicate keypress handled, false otherwise
|
||||
*/
|
||||
bool ro_gui_url_complete_keypress(struct gui_window *g, uint32_t key)
|
||||
/* This is an exported interface documented in url_complete.h */
|
||||
|
||||
bool ro_gui_url_complete_keypress(struct toolbar *toolbar, uint32_t key)
|
||||
{
|
||||
wimp_window_state state;
|
||||
char *match_url;
|
||||
const char *url;
|
||||
int i, lines;
|
||||
int old_selection;
|
||||
int height;
|
||||
os_error *error;
|
||||
bool currently_open;
|
||||
wimp_w parent;
|
||||
wimp_window_state state;
|
||||
char *match_url;
|
||||
const char *url;
|
||||
int i, lines;
|
||||
int old_selection;
|
||||
int height;
|
||||
os_error *error;
|
||||
bool currently_open;
|
||||
|
||||
assert(toolbar != NULL);
|
||||
parent = ro_toolbar_get_parent_window(toolbar);
|
||||
|
||||
/* we must have a toolbar/url bar */
|
||||
if ((!g->toolbar) || (!g->toolbar->display_url) ||
|
||||
if (!ro_toolbar_get_display_url(toolbar) ||
|
||||
(!option_url_suggestion)) {
|
||||
ro_gui_url_complete_close(NULL, 0);
|
||||
ro_gui_url_complete_close();
|
||||
return false;
|
||||
}
|
||||
|
||||
/* if we are currently active elsewhere, remove the previous window */
|
||||
currently_open = ((g->window == url_complete_parent) &&
|
||||
currently_open = ((parent == url_complete_parent) &&
|
||||
(url_complete_matches_available > 0));
|
||||
if (g->window != url_complete_parent)
|
||||
ro_gui_url_complete_close(NULL, 0);
|
||||
if (parent != url_complete_parent)
|
||||
ro_gui_url_complete_close();
|
||||
|
||||
/* forcibly open on down keys */
|
||||
if ((!currently_open) && (url_complete_matched_string)) {
|
||||
|
@ -129,12 +129,11 @@ bool ro_gui_url_complete_keypress(struct gui_window *g, uint32_t key)
|
|||
|
||||
|
||||
/* get the text to match */
|
||||
url_complete_parent = g->window;
|
||||
url = ro_gui_get_icon_string(g->toolbar->toolbar_handle,
|
||||
ICON_TOOLBAR_URL);
|
||||
match_url = strdup(url);
|
||||
if (!match_url) {
|
||||
ro_gui_url_complete_close(NULL, 0);
|
||||
url_complete_parent = parent;
|
||||
url = ro_toolbar_get_url(toolbar);
|
||||
match_url = (url != NULL) ? strdup(url) : NULL;
|
||||
if (match_url == NULL) {
|
||||
ro_gui_url_complete_close();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -181,7 +180,7 @@ bool ro_gui_url_complete_keypress(struct gui_window *g, uint32_t key)
|
|||
if (!url_complete_matches) {
|
||||
url_complete_matches = malloc(64 * sizeof(char *));
|
||||
if (!url_complete_matches) {
|
||||
ro_gui_url_complete_close(NULL, 0);
|
||||
ro_gui_url_complete_close();
|
||||
return false;
|
||||
}
|
||||
url_complete_matches_allocated = 64;
|
||||
|
@ -195,12 +194,12 @@ bool ro_gui_url_complete_keypress(struct gui_window *g, uint32_t key)
|
|||
urldb_iterate_partial(match_url, url_complete_callback);
|
||||
if ((url_complete_memory_exhausted) ||
|
||||
(url_complete_matches_available == 0)) {
|
||||
ro_gui_url_complete_close(NULL, 0);
|
||||
ro_gui_url_complete_close();
|
||||
return false;
|
||||
}
|
||||
|
||||
/* update the window */
|
||||
state.w = g->window;
|
||||
state.w = parent;
|
||||
error = xwimp_get_window_state(&state);
|
||||
if (error) {
|
||||
LOG(("xwimp_get_window_state: 0x%x: %s",
|
||||
|
@ -209,7 +208,7 @@ bool ro_gui_url_complete_keypress(struct gui_window *g, uint32_t key)
|
|||
return false;
|
||||
}
|
||||
url_complete_matches_reset = true;
|
||||
ro_gui_url_complete_resize(g, PTR_WIMP_OPEN(&state));
|
||||
ro_gui_url_complete_resize(toolbar, PTR_WIMP_OPEN(&state));
|
||||
url_complete_matches_reset = false;
|
||||
|
||||
/* redraw the relevant bits of the window */
|
||||
|
@ -300,14 +299,13 @@ bool ro_gui_url_complete_keypress(struct gui_window *g, uint32_t key)
|
|||
}
|
||||
|
||||
if (url_complete_matches_selection == -1) {
|
||||
ro_gui_set_icon_string(g->toolbar->toolbar_handle,
|
||||
ICON_TOOLBAR_URL,
|
||||
url_complete_original_url, true);
|
||||
ro_toolbar_set_url(toolbar,
|
||||
url_complete_original_url, true, false);
|
||||
} else {
|
||||
ro_gui_set_icon_string(g->toolbar->toolbar_handle,
|
||||
ICON_TOOLBAR_URL,
|
||||
ro_toolbar_set_url(toolbar,
|
||||
url_complete_matches[
|
||||
url_complete_matches_selection], true);
|
||||
url_complete_matches_selection],
|
||||
true, false);
|
||||
free(url_complete_matched_string);
|
||||
url_complete_matched_string = strdup(url_complete_matches[
|
||||
url_complete_matches_selection]);
|
||||
|
@ -343,6 +341,7 @@ bool ro_gui_url_complete_keypress(struct gui_window *g, uint32_t key)
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Callback function for urldb_iterate_partial
|
||||
*
|
||||
|
@ -350,6 +349,7 @@ bool ro_gui_url_complete_keypress(struct gui_window *g, uint32_t key)
|
|||
* \param data Data associated with URL
|
||||
* \return true to continue iteration, false otherwise
|
||||
*/
|
||||
|
||||
bool url_complete_callback(const char *url, const struct url_data *data)
|
||||
{
|
||||
const char **array_extend;
|
||||
|
@ -379,21 +379,18 @@ bool url_complete_callback(const char *url, const struct url_data *data)
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move and resize the url completion window to match the toolbar.
|
||||
*
|
||||
* \param g the gui_window to update
|
||||
* \param open the wimp_open request (updated on exit)
|
||||
*/
|
||||
void ro_gui_url_complete_resize(struct gui_window *g, wimp_open *open)
|
||||
|
||||
/* This is an exported interface documented in url_complete.h */
|
||||
|
||||
void ro_gui_url_complete_resize(struct toolbar *toolbar, wimp_open *open)
|
||||
{
|
||||
os_box extent = { 0, 0, 0, 0 };
|
||||
wimp_icon_state url_state;
|
||||
wimp_window_state toolbar_state;
|
||||
wimp_window_state state;
|
||||
os_error *error;
|
||||
int lines;
|
||||
int scroll_v = 0;
|
||||
os_box extent = { 0, 0, 0, 0 };
|
||||
os_box url_extent;
|
||||
wimp_window_state toolbar_state;
|
||||
wimp_window_state state;
|
||||
os_error *error;
|
||||
int lines;
|
||||
int scroll_v = 0;
|
||||
|
||||
/* only react to our window */
|
||||
if (open->w != url_complete_parent)
|
||||
|
@ -401,10 +398,10 @@ void ro_gui_url_complete_resize(struct gui_window *g, wimp_open *open)
|
|||
|
||||
/* if there is no toolbar, or there is no URL bar shown,
|
||||
* or there are no URL matches, close it */
|
||||
if ((!g->toolbar) || (!g->toolbar->display_url) ||
|
||||
if (!ro_toolbar_get_display_url(toolbar) ||
|
||||
(!url_complete_matches) ||
|
||||
(url_complete_matches_available == 0)) {
|
||||
ro_gui_url_complete_close(NULL, 0);
|
||||
ro_gui_url_complete_close();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -422,7 +419,7 @@ void ro_gui_url_complete_resize(struct gui_window *g, wimp_open *open)
|
|||
state.yscroll = 0;
|
||||
|
||||
/* move the window to the correct position */
|
||||
toolbar_state.w = g->toolbar->toolbar_handle;
|
||||
toolbar_state.w = ro_toolbar_get_window(toolbar);
|
||||
error = xwimp_get_window_state(&toolbar_state);
|
||||
if (error) {
|
||||
LOG(("xwimp_get_window_state: 0x%x: %s",
|
||||
|
@ -431,13 +428,8 @@ void ro_gui_url_complete_resize(struct gui_window *g, wimp_open *open)
|
|||
return;
|
||||
}
|
||||
|
||||
url_state.w = g->toolbar->toolbar_handle;
|
||||
url_state.i = ICON_TOOLBAR_SURROUND;
|
||||
error = xwimp_get_icon_state(&url_state);
|
||||
if (error) {
|
||||
LOG(("xwimp_get_window_state: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
warn_user("WimpError", error->errmess);
|
||||
if (!ro_toolbar_get_url_field_extent(toolbar, &url_extent)) {
|
||||
LOG(("Failed to read URL field extent."));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -460,10 +452,9 @@ void ro_gui_url_complete_resize(struct gui_window *g, wimp_open *open)
|
|||
scroll_v = ro_get_vscroll_width(NULL) - 2;
|
||||
state.flags |= wimp_WINDOW_VSCROLL;
|
||||
}
|
||||
state.visible.x0 = open->visible.x0 + 2 + url_state.icon.extent.x0;
|
||||
state.visible.x1 = open->visible.x0 - 2 +
|
||||
url_state.icon.extent.x1 - scroll_v;
|
||||
state.visible.y1 = open->visible.y1 - url_state.icon.extent.y1 + 2;
|
||||
state.visible.x0 = open->visible.x0 + 2 + url_extent.x0;
|
||||
state.visible.x1 = open->visible.x0 - 2 + url_extent.x1 - scroll_v;
|
||||
state.visible.y1 = open->visible.y1 - url_extent.y1 + 2;
|
||||
state.visible.y0 = state.visible.y1 - (lines * 44);
|
||||
if (state.visible.x1 + scroll_v > toolbar_state.visible.x1)
|
||||
state.visible.x1 = toolbar_state.visible.x1 - scroll_v;
|
||||
|
@ -488,23 +479,21 @@ void ro_gui_url_complete_resize(struct gui_window *g, wimp_open *open)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Try to close the current url completion window
|
||||
*
|
||||
* \param g the gui_window the user clicked on (or NULL to forcibly close)
|
||||
* \param i the icon the user clicked on to prompt the close
|
||||
* \return whether the window was closed
|
||||
*/
|
||||
bool ro_gui_url_complete_close(struct gui_window *g, wimp_i i)
|
||||
/* This is an exported interface documented in url_complete.h */
|
||||
|
||||
bool ro_gui_url_complete_close(void)
|
||||
{
|
||||
os_error *error;
|
||||
bool currently_open;
|
||||
os_error *error;
|
||||
bool currently_open;
|
||||
|
||||
if ((g && (i == ICON_TOOLBAR_URL) &&
|
||||
(g->window == url_complete_parent)))
|
||||
return false;
|
||||
/* There used to be a check here to see if the icon clicked was the
|
||||
* URL text field in the toolbar. Since this only applied to clicks
|
||||
* originating from the toolbar module following the restructuring,
|
||||
* and this check was better done within the toolbar, it has been
|
||||
* removed from this function and the associated parameters removed.
|
||||
*/
|
||||
|
||||
currently_open = ((url_complete_parent) &&
|
||||
currently_open = ((url_complete_parent != NULL) &&
|
||||
(url_complete_matches_available > 0));
|
||||
|
||||
free(url_complete_matches);
|
||||
|
@ -530,11 +519,8 @@ bool ro_gui_url_complete_close(struct gui_window *g, wimp_i i)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Redraws a section of the URL completion window
|
||||
*
|
||||
* \param redraw the area to redraw
|
||||
*/
|
||||
/* This is an exported interface documented in url_complete.h */
|
||||
|
||||
void ro_gui_url_complete_redraw(wimp_draw *redraw)
|
||||
{
|
||||
osbool more;
|
||||
|
@ -633,11 +619,8 @@ void ro_gui_url_complete_redraw(wimp_draw *redraw)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle mouse movement over the URL completion window.
|
||||
*
|
||||
* \param pointer the pointer state
|
||||
*/
|
||||
/* This is an exported interface documented in url_complete.h */
|
||||
|
||||
void ro_gui_url_complete_mouse_at(wimp_pointer *pointer)
|
||||
{
|
||||
wimp_mouse_state current;
|
||||
|
@ -649,12 +632,8 @@ void ro_gui_url_complete_mouse_at(wimp_pointer *pointer)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle mouse clicks in the URL completion window.
|
||||
*
|
||||
* \param pointer the pointer state
|
||||
* \return whether the click was handled
|
||||
*/
|
||||
/* This is an exported interface documented in url_complete.h */
|
||||
|
||||
bool ro_gui_url_complete_click(wimp_pointer *pointer)
|
||||
{
|
||||
wimp_window_state state;
|
||||
|
@ -685,9 +664,7 @@ bool ro_gui_url_complete_click(wimp_pointer *pointer)
|
|||
g = ro_gui_window_lookup(url_complete_parent);
|
||||
if (!g)
|
||||
return false;
|
||||
url = ro_gui_get_icon_string(
|
||||
g->toolbar->toolbar_handle,
|
||||
ICON_TOOLBAR_URL);
|
||||
url = ro_toolbar_get_url(g->toolbar);
|
||||
free(url_complete_original_url);
|
||||
url_complete_original_url = strdup(url);
|
||||
if (!url_complete_original_url)
|
||||
|
@ -722,10 +699,10 @@ bool ro_gui_url_complete_click(wimp_pointer *pointer)
|
|||
|
||||
/* Select sets the text and launches */
|
||||
if (pointer->buttons == wimp_CLICK_SELECT) {
|
||||
ro_gui_set_icon_string(g->toolbar->toolbar_handle,
|
||||
ICON_TOOLBAR_URL,
|
||||
ro_toolbar_set_url(g->toolbar,
|
||||
url_complete_matches[
|
||||
url_complete_matches_selection], true);
|
||||
url_complete_matches_selection],
|
||||
true, false);
|
||||
|
||||
/** \todo The interaction of components here is hideous */
|
||||
/* Do NOT make any attempt to use any of the global url
|
||||
|
@ -740,15 +717,16 @@ bool ro_gui_url_complete_click(wimp_pointer *pointer)
|
|||
url_complete_matches[
|
||||
url_complete_matches_selection],
|
||||
0, true);
|
||||
ro_gui_url_complete_close(NULL, 0);
|
||||
ro_gui_url_complete_close();
|
||||
|
||||
/* Adjust just sets the text */
|
||||
} else if (pointer->buttons == wimp_CLICK_ADJUST) {
|
||||
ro_gui_set_icon_string(g->toolbar->toolbar_handle,
|
||||
ICON_TOOLBAR_URL,
|
||||
ro_toolbar_set_url(g->toolbar,
|
||||
url_complete_matches[
|
||||
url_complete_matches_selection], true);
|
||||
ro_gui_url_complete_keypress(g, 0);
|
||||
url_complete_matches_selection],
|
||||
true, false);
|
||||
ro_gui_url_complete_keypress(g->toolbar, 0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,12 +29,72 @@
|
|||
|
||||
struct gui_window;
|
||||
|
||||
void ro_gui_url_complete_start(struct gui_window *g);
|
||||
bool ro_gui_url_complete_keypress(struct gui_window *g, uint32_t key);
|
||||
void ro_gui_url_complete_resize(struct gui_window *g, wimp_open *open);
|
||||
bool ro_gui_url_complete_close(struct gui_window *g, wimp_i i);
|
||||
/**
|
||||
* Should be called when the caret is placed into a URL completion icon.
|
||||
*
|
||||
* \param *toolbar The toolbar to initialise URL completion for.
|
||||
*/
|
||||
|
||||
void ro_gui_url_complete_start(struct toolbar *toolbar);
|
||||
|
||||
|
||||
/**
|
||||
* Handles a keypress for URL completion
|
||||
*
|
||||
* \param *toolbar The toolbar to be updated.
|
||||
* \param key the key pressed (as UTF32 code or
|
||||
* wimp key + bit31 set)
|
||||
* \return true to indicate keypress handled; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_url_complete_keypress(struct toolbar *toolbar, uint32_t key);
|
||||
|
||||
|
||||
/**
|
||||
* Move and resize the url completion window to match the toolbar.
|
||||
*
|
||||
* \param *toolbar The toolbar to update
|
||||
* \param *open the wimp_open request (updated on exit)
|
||||
*/
|
||||
|
||||
void ro_gui_url_complete_resize(struct toolbar *toolbar, wimp_open *open);
|
||||
|
||||
|
||||
/**
|
||||
* Try to close the current url completion window
|
||||
*
|
||||
* \return whether the window was closed
|
||||
*/
|
||||
|
||||
bool ro_gui_url_complete_close(void);
|
||||
|
||||
|
||||
/**
|
||||
* Redraws a section of the URL completion window
|
||||
*
|
||||
* \param redraw the area to redraw
|
||||
*/
|
||||
|
||||
void ro_gui_url_complete_redraw(wimp_draw *redraw);
|
||||
|
||||
|
||||
/**
|
||||
* Handle mouse movement over the URL completion window.
|
||||
*
|
||||
* \param pointer the pointer state
|
||||
*/
|
||||
|
||||
void ro_gui_url_complete_mouse_at(wimp_pointer *pointer);
|
||||
|
||||
|
||||
/**
|
||||
* Handle mouse clicks in the URL completion window.
|
||||
*
|
||||
* \param pointer the pointer state
|
||||
* \return whether the click was handled
|
||||
*/
|
||||
|
||||
bool ro_gui_url_complete_click(wimp_pointer *pointer);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -34,28 +34,29 @@ struct url_suggest_item {
|
|||
struct url_suggest_item *next; /*< The next URL in the list. */
|
||||
};
|
||||
|
||||
static bool url_suggest_callback(const char *url, const struct url_data *data);
|
||||
static bool ro_gui_url_suggest_callback(const char *url,
|
||||
const struct url_data *data);
|
||||
|
||||
static wimp_menu *suggest_menu;
|
||||
static int suggest_entries;
|
||||
static time_t suggest_time;
|
||||
static struct url_suggest_item *suggest_list;
|
||||
|
||||
static wimp_MENU(URL_SUGGEST_MAX_URLS) url_suggest_menu_block;
|
||||
wimp_menu *ro_gui_url_suggest_menu = (wimp_menu *) &url_suggest_menu_block;
|
||||
|
||||
|
||||
/**
|
||||
* Initialise the URL suggestion menu. A menu block which must be set to
|
||||
* contain URL_SUGGEST_MAX_URLS entries is passed in.
|
||||
* Initialise the URL suggestion menu. This MUST be called before anything
|
||||
* tries to use the URL menu.
|
||||
*
|
||||
* /param *menu The menu to use as the suggestion menu.
|
||||
* /return true if initialisation was OK; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_url_suggest_init(wimp_menu *menu)
|
||||
bool ro_gui_url_suggest_init(void)
|
||||
{
|
||||
suggest_menu = menu;
|
||||
|
||||
suggest_menu->title_data.indirected_text.text =
|
||||
ro_gui_url_suggest_menu->title_data.indirected_text.text =
|
||||
(char *) messages_get("URLSuggest");
|
||||
ro_gui_menu_init_structure((wimp_menu *) suggest_menu,
|
||||
ro_gui_menu_init_structure((wimp_menu *) ro_gui_url_suggest_menu,
|
||||
URL_SUGGEST_MAX_URLS);
|
||||
|
||||
suggest_entries = 0;
|
||||
|
@ -64,6 +65,21 @@ bool ro_gui_url_suggest_init(wimp_menu *menu)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if there is a URL suggestion menu available for use.
|
||||
*
|
||||
* \TODO -- Ideally this should be able to decide if there's a menu
|
||||
* available without actually having to build it all.
|
||||
*
|
||||
* /return true if the menu has entries; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_url_suggest_get_menu_available(void)
|
||||
{
|
||||
return ro_gui_url_suggest_prepare_menu();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Builds the URL suggestion menu. This is called by ro_gui_menu_create() when
|
||||
* it is asked to display the url_suggest_menu.
|
||||
|
@ -82,7 +98,7 @@ bool ro_gui_url_suggest_prepare_menu(void)
|
|||
suggest_list = NULL;
|
||||
suggest_time = time(NULL);
|
||||
|
||||
urldb_iterate_entries(url_suggest_callback);
|
||||
urldb_iterate_entries(ro_gui_url_suggest_callback);
|
||||
|
||||
/* If any menu entries were found, put them into the menu. The list
|
||||
* is in reverse order, last to first, so the menu is filled backwards.
|
||||
|
@ -100,10 +116,12 @@ bool ro_gui_url_suggest_prepare_menu(void)
|
|||
while (list != NULL && i > 0) {
|
||||
i--;
|
||||
|
||||
suggest_menu->entries[i].menu_flags = 0;
|
||||
suggest_menu->entries[i].data.indirected_text.text =
|
||||
ro_gui_url_suggest_menu->entries[i].menu_flags = 0;
|
||||
ro_gui_url_suggest_menu->
|
||||
entries[i].data.indirected_text.text =
|
||||
(char *) list->url;
|
||||
suggest_menu->entries[i].data.indirected_text.size =
|
||||
ro_gui_url_suggest_menu->
|
||||
entries[i].data.indirected_text.size =
|
||||
strlen(list->url) + 1;
|
||||
|
||||
next = list->next;
|
||||
|
@ -113,9 +131,10 @@ bool ro_gui_url_suggest_prepare_menu(void)
|
|||
|
||||
assert(i == 0);
|
||||
|
||||
suggest_menu->entries[0].menu_flags |=
|
||||
ro_gui_url_suggest_menu->entries[0].menu_flags |=
|
||||
wimp_MENU_TITLE_INDIRECTED;
|
||||
suggest_menu->entries[suggest_entries - 1].menu_flags |=
|
||||
ro_gui_url_suggest_menu->
|
||||
entries[suggest_entries - 1].menu_flags |=
|
||||
wimp_MENU_LAST;
|
||||
|
||||
return true;
|
||||
|
@ -133,7 +152,7 @@ bool ro_gui_url_suggest_prepare_menu(void)
|
|||
* \return true to continue iteration, false otherwise
|
||||
*/
|
||||
|
||||
bool url_suggest_callback(const char *url, const struct url_data *data)
|
||||
bool ro_gui_url_suggest_callback(const char *url, const struct url_data *data)
|
||||
{
|
||||
int count;
|
||||
unsigned int weight;
|
||||
|
@ -193,3 +212,21 @@ bool url_suggest_callback(const char *url, const struct url_data *data)
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Process a selection from the URL Suggest menu.
|
||||
*
|
||||
* \param *selection The menu selection.
|
||||
* \return Pointer to the URL that was selected, or NULL for none.
|
||||
*/
|
||||
|
||||
const char *ro_gui_url_suggest_get_selection(wimp_selection *selection)
|
||||
{
|
||||
const char *url = NULL;
|
||||
|
||||
if (selection->items[0] >= 0)
|
||||
url = ro_gui_url_suggest_menu->entries[selection->items[0]].
|
||||
data.indirected_text.text;
|
||||
|
||||
return url;
|
||||
}
|
||||
|
|
|
@ -27,8 +27,12 @@
|
|||
|
||||
#define URL_SUGGEST_MAX_URLS 16
|
||||
|
||||
bool ro_gui_url_suggest_init(wimp_menu *menu);
|
||||
extern wimp_menu *ro_gui_url_suggest_menu;
|
||||
|
||||
bool ro_gui_url_suggest_init(void);
|
||||
bool ro_gui_url_suggest_get_menu_available(void);
|
||||
bool ro_gui_url_suggest_prepare_menu(void);
|
||||
const char *ro_gui_url_suggest_get_selection(wimp_selection *selection);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
112
riscos/wimp.c
112
riscos/wimp.c
|
@ -36,7 +36,6 @@
|
|||
#include "desktop/gui.h"
|
||||
#include "riscos/gui.h"
|
||||
#include "riscos/oslib_pre7.h"
|
||||
#include "riscos/theme.h"
|
||||
#include "riscos/wimp.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/utf8.h"
|
||||
|
@ -545,6 +544,71 @@ bool ro_gui_get_icon_shaded_state(wimp_w w, wimp_i i)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the deleted state of an icon.
|
||||
*
|
||||
* \param w window handle
|
||||
* \param i icon handle
|
||||
* \param state shaded state
|
||||
*/
|
||||
void ro_gui_set_icon_deleted_state(wimp_w w, wimp_i i, bool state)
|
||||
{
|
||||
wimp_caret caret;
|
||||
os_error *error;
|
||||
|
||||
/* update the state */
|
||||
if (ro_gui_get_icon_deleted_state(w, i) == state)
|
||||
return;
|
||||
error = xwimp_set_icon_state(w, i,
|
||||
(state ? wimp_ICON_DELETED : 0), wimp_ICON_DELETED);
|
||||
if (error) {
|
||||
LOG(("xwimp_get_icon_state: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
warn_user("WimpError", error->errmess);
|
||||
}
|
||||
if (!state)
|
||||
return;
|
||||
|
||||
/* ensure the caret is not in a shaded icon */
|
||||
error = xwimp_get_caret_position(&caret);
|
||||
if (error) {
|
||||
LOG(("xwimp_get_caret_position: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
warn_user("WimpError", error->errmess);
|
||||
return;
|
||||
}
|
||||
if ((caret.w != w) || (caret.i != i))
|
||||
return;
|
||||
/* move the caret to the first avaiable writable */
|
||||
if (ro_gui_set_caret_first(w))
|
||||
return;
|
||||
/* lose the caret */
|
||||
error = xwimp_set_caret_position((wimp_w)-1, (wimp_i)-1, -1, -1, -1, -1);
|
||||
if (error) {
|
||||
LOG(("xwimp_set_caret_position: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
warn_user("WimpError", error->errmess);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the deleted state of an icon.
|
||||
*
|
||||
* \param w window handle
|
||||
* \param i icon handle
|
||||
*/
|
||||
bool ro_gui_get_icon_deleted_state(wimp_w w, wimp_i i)
|
||||
{
|
||||
wimp_icon_state ic;
|
||||
ic.w = w;
|
||||
ic.i = i;
|
||||
xwimp_get_icon_state(&ic);
|
||||
return (ic.icon.flags & wimp_ICON_DELETED) != 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the button type of an icon.
|
||||
*
|
||||
|
@ -840,6 +904,52 @@ os_error *ro_gui_wimp_get_sprite(const char *name, osspriteop_header **sprite)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the dimensions of a sprite
|
||||
*
|
||||
* \param *area The sprite area to use.
|
||||
* \param *sprite Pointer to the sprite name.
|
||||
* \param *width Return the sprite width.
|
||||
* \param *height Return the sprite height.
|
||||
* \return true if successful; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_wimp_get_sprite_dimensions(osspriteop_area *area, char *sprite,
|
||||
int *width, int *height)
|
||||
{
|
||||
os_error *error = NULL;
|
||||
os_mode mode;
|
||||
os_coord dimensions;
|
||||
|
||||
dimensions.x = 0;
|
||||
dimensions.y = 0;
|
||||
|
||||
if (area != (osspriteop_area *) -1)
|
||||
error = xosspriteop_read_sprite_info(osspriteop_USER_AREA,
|
||||
area, (osspriteop_id) sprite,
|
||||
&dimensions.x, &dimensions.y, 0, &mode);
|
||||
|
||||
if (error != NULL || area == (osspriteop_area *) -1)
|
||||
error = xwimpspriteop_read_sprite_info(sprite,
|
||||
&dimensions.x, &dimensions.y, 0, &mode);
|
||||
|
||||
if (error == NULL) {
|
||||
ro_convert_pixels_to_os_units(&dimensions, mode);
|
||||
if (width != NULL)
|
||||
*width = dimensions.x;
|
||||
if (height != NULL)
|
||||
*height = dimensions.y;
|
||||
} else if (error->errnum != error_SPRITE_OP_DOESNT_EXIST) {
|
||||
LOG(("xosspriteop_read_sprite_info: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
warn_user("MiscError", error->errmess);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Performs simple user redraw for a window.
|
||||
*
|
||||
|
|
|
@ -54,6 +54,8 @@ void ro_gui_set_icon_selected_state(wimp_w w, wimp_i i, bool state);
|
|||
bool ro_gui_get_icon_selected_state(wimp_w w, wimp_i i);
|
||||
void ro_gui_set_icon_shaded_state(wimp_w w, wimp_i i, bool state);
|
||||
bool ro_gui_get_icon_shaded_state(wimp_w w, wimp_i i);
|
||||
void ro_gui_set_icon_deleted_state(wimp_w w, wimp_i i, bool state);
|
||||
bool ro_gui_get_icon_deleted_state(wimp_w w, wimp_i i);
|
||||
void ro_gui_set_icon_button_type(wimp_w w, wimp_i i, int type);
|
||||
void ro_gui_set_icon_sprite(wimp_w w, wimp_i i, osspriteop_area *area,
|
||||
const char *name);
|
||||
|
@ -64,7 +66,8 @@ void ro_gui_open_window_centre(wimp_w parent, wimp_w child);
|
|||
osspriteop_area *ro_gui_load_sprite_file(const char *pathname);
|
||||
bool ro_gui_wimp_sprite_exists(const char *sprite);
|
||||
os_error *ro_gui_wimp_get_sprite(const char *name, osspriteop_header **sprite);
|
||||
|
||||
bool ro_gui_wimp_get_sprite_dimensions(osspriteop_area *area, char *sprite,
|
||||
int *width, int *height);
|
||||
|
||||
wimp_w ro_gui_set_window_background_colour(wimp_w window, wimp_colour background);
|
||||
void ro_gui_set_icon_colours(wimp_w window, wimp_i icon,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright 2005 Richard Wilson <info@tinct.net>
|
||||
* Copyright 2010 Stephen Fryatt <stevef@netsurf-browser.org>
|
||||
* Copyright 2010, 2011 Stephen Fryatt <stevef@netsurf-browser.org>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
|
@ -95,16 +95,19 @@ struct event_window {
|
|||
void (*open_window)(wimp_open *open);
|
||||
void (*close_window)(wimp_w w);
|
||||
void (*redraw_window)(wimp_draw *redraw);
|
||||
void (*menu_selection)(wimp_w w, wimp_i i);
|
||||
bool (*menu_prepare)(wimp_w w, wimp_i i, wimp_menu *m,
|
||||
wimp_pointer *p);
|
||||
bool (*menu_selection)(wimp_w w, wimp_i i, wimp_menu *m,
|
||||
wimp_selection *s, menu_action a);
|
||||
void (*menu_warning)(wimp_w w, wimp_i i, wimp_menu *m,
|
||||
wimp_selection *s, menu_action a);
|
||||
void (*menu_close)(wimp_w w, wimp_i i, wimp_menu *m);
|
||||
wimp_menu *window_menu;
|
||||
bool window_menu_auto;
|
||||
void (*window_menu_prepare)(wimp_w w, wimp_menu *m);
|
||||
bool (*window_menu_selection)(wimp_w w, wimp_menu *m,
|
||||
wimp_selection *s, menu_action action);
|
||||
void (*window_menu_close)(wimp_w w, wimp_menu *m);
|
||||
void (*window_menu_warning)(wimp_w w, wimp_menu *m,
|
||||
wimp_selection *s, menu_action action);
|
||||
bool window_menu_iconbar;
|
||||
const char *help_prefix;
|
||||
const char *(*get_help_suffix)(wimp_w w, wimp_i i, os_coord *pos,
|
||||
wimp_mouse_state buttons);
|
||||
void *user_data;
|
||||
struct icon_event *first;
|
||||
struct event_window *next;
|
||||
|
@ -117,7 +120,7 @@ static struct event_window *ro_gui_wimp_event_get_window(wimp_w w);
|
|||
static struct event_window *ro_gui_wimp_event_find_window(wimp_w w);
|
||||
static struct icon_event *ro_gui_wimp_event_get_event(wimp_w w, wimp_i i,
|
||||
event_type type);
|
||||
static void ro_gui_wimp_event_prepare_menu(wimp_w w, struct icon_event *event);
|
||||
static void ro_gui_wimp_event_prepare_gright_menu(wimp_w w, struct icon_event *event);
|
||||
static struct event_window *ro_gui_wimp_event_remove_window(wimp_w w);
|
||||
|
||||
static struct event_window *ro_gui_wimp_event_windows[WIN_HASH_SIZE];
|
||||
|
@ -243,6 +246,40 @@ bool ro_gui_wimp_event_validate(wimp_w w)
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transfer event data from one window to another. This can be used as an
|
||||
* alternative to ro_gui_wimp_event_finalise() and re-registering, if
|
||||
* events need to continue across a change of window handle.
|
||||
*
|
||||
* All aspects of the registered events MUST remain the same in the new
|
||||
* window!
|
||||
*
|
||||
* \param from The current window, which is to be deleted.
|
||||
* \param to The window to which the events should transfer.
|
||||
* \return true on success; false for an unknown window.
|
||||
*/
|
||||
|
||||
bool ro_gui_wimp_event_transfer(wimp_w from, wimp_w to)
|
||||
{
|
||||
struct event_window *window;
|
||||
int h;
|
||||
|
||||
LOG(("Transferring all events from window 0x%x to window 0x%x",
|
||||
(unsigned int) from, (unsigned int) to));
|
||||
|
||||
window = ro_gui_wimp_event_remove_window(from);
|
||||
if (window == NULL || window->w != from)
|
||||
return false;
|
||||
|
||||
h = WIN_HASH(to);
|
||||
window->w = to;
|
||||
window->next = ro_gui_wimp_event_windows[h];
|
||||
ro_gui_wimp_event_windows[h] = window;
|
||||
|
||||
ro_gui_menu_window_changed(from, to);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Free any resources associated with a window.
|
||||
|
@ -279,6 +316,61 @@ void ro_gui_wimp_event_finalise(wimp_w w)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Free any resources associated with a specific icon in a window.
|
||||
*
|
||||
* \param w The window containing the icon.
|
||||
* \param i The icon to free resources for.
|
||||
*/
|
||||
|
||||
void ro_gui_wimp_event_deregister(wimp_w w, wimp_i i)
|
||||
{
|
||||
struct event_window *window;
|
||||
struct icon_event *event, *parent, *child;
|
||||
|
||||
LOG(("Removing all events for window 0x%x, icon %d",
|
||||
(unsigned int)w, (int)i));
|
||||
window = ro_gui_wimp_event_get_window(w);
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
/* Remove any events that apply to the given icon. */
|
||||
|
||||
event = window->first;
|
||||
parent = NULL;
|
||||
|
||||
while (event != NULL) {
|
||||
child = event->next;
|
||||
|
||||
if (event->i == i) {
|
||||
LOG(("Removing event 0x%x", (unsigned int) event));
|
||||
|
||||
if (parent == NULL)
|
||||
window->first = child;
|
||||
else
|
||||
parent->next = child;
|
||||
|
||||
switch (event->type) {
|
||||
case EVENT_NUMERIC_FIELD:
|
||||
case EVENT_TEXT_FIELD:
|
||||
if (event->previous_value.textual)
|
||||
free(event->previous_value.textual);
|
||||
event->previous_value.textual = NULL;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
free(event);
|
||||
} else {
|
||||
parent = event;
|
||||
}
|
||||
|
||||
event = child;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the associated help prefix for a given window.
|
||||
*
|
||||
|
@ -315,6 +407,45 @@ const char *ro_gui_wimp_event_get_help_prefix(wimp_w w)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register a handler to decode help suffixes for a given window.
|
||||
*
|
||||
*/
|
||||
|
||||
bool ro_gui_wimp_event_register_help_suffix(wimp_w w,
|
||||
const char *(*get_help_suffix)(wimp_w w, wimp_i i,
|
||||
os_coord *pos, wimp_mouse_state buttons))
|
||||
{
|
||||
struct event_window *window;
|
||||
|
||||
window = ro_gui_wimp_event_get_window(w);
|
||||
if (!window)
|
||||
return false;
|
||||
window->get_help_suffix = get_help_suffix;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated help suffix.
|
||||
*
|
||||
* \param w The window to get the suffix for
|
||||
* \return The associated prefix, or NULL
|
||||
*/
|
||||
|
||||
const char *ro_gui_wimp_event_get_help_suffix(wimp_w w, wimp_i i,
|
||||
os_coord *pos, wimp_mouse_state buttons)
|
||||
{
|
||||
struct event_window *window;
|
||||
|
||||
window = ro_gui_wimp_event_find_window(w);
|
||||
if (window == NULL || window->get_help_suffix == NULL)
|
||||
return NULL;
|
||||
|
||||
return window->get_help_suffix(w, i, pos, buttons);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the user data associated with a window.
|
||||
*
|
||||
|
@ -371,7 +502,8 @@ void *ro_gui_wimp_event_get_user_data(wimp_w w)
|
|||
* \param menu the menu that has been selected
|
||||
* \param selection the selection information
|
||||
* \param action the menu action info from menus.c
|
||||
* \return true if the event was handled, false otherwise
|
||||
* \return true if the menu is OK for an Adjust re-open;
|
||||
* else false.
|
||||
*/
|
||||
bool ro_gui_wimp_event_menu_selection(wimp_w w, wimp_i i, wimp_menu *menu,
|
||||
wimp_selection *selection, menu_action action)
|
||||
|
@ -384,32 +516,33 @@ bool ro_gui_wimp_event_menu_selection(wimp_w w, wimp_i i, wimp_menu *menu,
|
|||
wimp_caret caret;
|
||||
wimp_icon_state ic;
|
||||
unsigned int button_type;
|
||||
bool prepared;
|
||||
|
||||
window = ro_gui_wimp_event_find_window(w);
|
||||
if (!window)
|
||||
if (window == NULL)
|
||||
return false;
|
||||
|
||||
/* Start by looking for an icon event that matches. If there isn't one,
|
||||
* then check to see if there is a window menu and associated
|
||||
* selection handler available instead.
|
||||
* then return details for an unconnected menu. It's up to the
|
||||
* event recipient to sort out if this is a window menu or not, based
|
||||
* on the menu handle passed back.
|
||||
*/
|
||||
|
||||
for (event = window->first; event; event = event->next)
|
||||
if ((event->type == EVENT_MENU_GRIGHT) && (event->i == i))
|
||||
break;
|
||||
if (!event) {
|
||||
if ((window->window_menu) && (window->window_menu == menu)
|
||||
&& (window->window_menu_selection)) {
|
||||
window->window_menu_selection(w, menu,
|
||||
selection, action);
|
||||
if (window->menu_selection)
|
||||
window->menu_selection(window->w, wimp_ICON_WINDOW,
|
||||
menu, selection, action);
|
||||
|
||||
/* Prepare the menu pending a possible Adjust click. */
|
||||
if (window->window_menu_prepare)
|
||||
window->window_menu_prepare(w, menu);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
/* Prepare the menu pending a possible Adjust click. */
|
||||
if (window->menu_prepare)
|
||||
if (!window->menu_prepare(window->w, wimp_ICON_WINDOW,
|
||||
menu, NULL))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
menu_entry = &menu->entries[selection->items[0]];
|
||||
|
@ -423,9 +556,15 @@ bool ro_gui_wimp_event_menu_selection(wimp_w w, wimp_i i, wimp_menu *menu,
|
|||
|
||||
ro_gui_set_icon_string(window->w, event->data.menu_gright.field,
|
||||
menu_entry->data.indirected_text.text, false);
|
||||
ro_gui_wimp_event_prepare_menu(window->w, event);
|
||||
if (window->menu_selection)
|
||||
window->menu_selection(window->w, event->i);
|
||||
window->menu_selection(window->w, event->i, menu,
|
||||
selection, action);
|
||||
prepared = true;
|
||||
if (window->menu_prepare)
|
||||
prepared = window->menu_prepare(window->w, event->i,
|
||||
menu, NULL);
|
||||
if (prepared)
|
||||
ro_gui_wimp_event_prepare_gright_menu(window->w, event);
|
||||
|
||||
/* set the caret for writable icons and send a CTRL+U keypress to
|
||||
* stimulate activity if needed */
|
||||
|
@ -441,7 +580,7 @@ bool ro_gui_wimp_event_menu_selection(wimp_w w, wimp_i i, wimp_menu *menu,
|
|||
button_type = (ic.icon.flags & wimp_ICON_BUTTON_TYPE) >> wimp_ICON_BUTTON_TYPE_SHIFT;
|
||||
if ((button_type != wimp_BUTTON_WRITABLE) &&
|
||||
(button_type != wimp_BUTTON_WRITE_CLICK_DRAG))
|
||||
return true;
|
||||
return prepared;
|
||||
error = xwimp_get_caret_position(&caret);
|
||||
if (error) {
|
||||
LOG(("xwimp_get_caret_position: 0x%x: %s",
|
||||
|
@ -463,7 +602,7 @@ bool ro_gui_wimp_event_menu_selection(wimp_w w, wimp_i i, wimp_menu *menu,
|
|||
key.c = 21; // ctrl+u
|
||||
window->keypress(&key);
|
||||
}
|
||||
return true;
|
||||
return prepared;
|
||||
}
|
||||
|
||||
|
||||
|
@ -493,6 +632,7 @@ bool ro_gui_wimp_event_mouse_click(wimp_pointer *pointer)
|
|||
wimp_window_state open;
|
||||
wimp_caret caret;
|
||||
os_error *error;
|
||||
bool prepared;
|
||||
|
||||
w = pointer->w;
|
||||
window = ro_gui_wimp_event_find_window(w);
|
||||
|
@ -500,7 +640,9 @@ bool ro_gui_wimp_event_mouse_click(wimp_pointer *pointer)
|
|||
return false;
|
||||
|
||||
/* Menu clicks take priority if there is an auto menu defined. */
|
||||
if ((window->window_menu) && (window->window_menu_auto)) {
|
||||
if ((pointer->buttons == wimp_CLICK_MENU) &&
|
||||
(window->window_menu != NULL) &&
|
||||
(window->window_menu_auto)) {
|
||||
ro_gui_wimp_event_process_window_menu_click(pointer);
|
||||
return true;
|
||||
}
|
||||
|
@ -574,7 +716,7 @@ bool ro_gui_wimp_event_mouse_click(wimp_pointer *pointer)
|
|||
}
|
||||
ro_gui_dialog_add_persistent(current_menu_window,
|
||||
pointer->w);
|
||||
ro_gui_menu_closed(false);
|
||||
ro_gui_menu_closed();
|
||||
gui_poll(true);
|
||||
error = xwimp_open_window(PTR_WIMP_OPEN(&open));
|
||||
if (error) {
|
||||
|
@ -596,8 +738,15 @@ bool ro_gui_wimp_event_mouse_click(wimp_pointer *pointer)
|
|||
}
|
||||
}
|
||||
/* display the menu */
|
||||
ro_gui_wimp_event_prepare_menu(pointer->w, event);
|
||||
ro_gui_popup_menu(event->data.menu_gright.menu, pointer->w, pointer->i);
|
||||
|
||||
prepared = true;
|
||||
if (window->menu_prepare != NULL)
|
||||
prepared = window->menu_prepare(pointer->w, pointer->i,
|
||||
event->data.menu_gright.menu, pointer);
|
||||
if (prepared) {
|
||||
ro_gui_wimp_event_prepare_gright_menu(pointer->w, event);
|
||||
ro_gui_popup_menu(event->data.menu_gright.menu, pointer->w, pointer->i);
|
||||
}
|
||||
break;
|
||||
case EVENT_CHECKBOX:
|
||||
break;
|
||||
|
@ -617,7 +766,7 @@ bool ro_gui_wimp_event_mouse_click(wimp_pointer *pointer)
|
|||
if (pointer->buttons & wimp_CLICK_SELECT) {
|
||||
ro_gui_dialog_close(pointer->w);
|
||||
ro_gui_wimp_event_close_window(pointer->w);
|
||||
ro_gui_menu_closed(true);
|
||||
ro_gui_menu_closed();
|
||||
} else {
|
||||
ro_gui_wimp_event_restore(pointer->w);
|
||||
}
|
||||
|
@ -636,7 +785,7 @@ bool ro_gui_wimp_event_mouse_click(wimp_pointer *pointer)
|
|||
* /param w the window owning the menu
|
||||
* /param event the icon event owning the menu
|
||||
*/
|
||||
void ro_gui_wimp_event_prepare_menu(wimp_w w, struct icon_event *event)
|
||||
void ro_gui_wimp_event_prepare_gright_menu(wimp_w w, struct icon_event *event)
|
||||
{
|
||||
int i;
|
||||
const char *text;
|
||||
|
@ -699,7 +848,7 @@ void ro_gui_wimp_event_ok_click(struct event_window *window,
|
|||
if (state & wimp_CLICK_SELECT) {
|
||||
ro_gui_dialog_close(window->w);
|
||||
ro_gui_wimp_event_close_window(window->w);
|
||||
ro_gui_menu_closed(true);
|
||||
ro_gui_menu_closed();
|
||||
} else {
|
||||
ro_gui_wimp_event_memorise(window->w);
|
||||
}
|
||||
|
@ -863,7 +1012,7 @@ bool ro_gui_wimp_event_keypress(wimp_key *key)
|
|||
}
|
||||
}
|
||||
} else {
|
||||
k.c |= (1u<<31);
|
||||
k.c |= IS_WIMP_KEY;
|
||||
}
|
||||
|
||||
/* registered routines take priority */
|
||||
|
@ -894,7 +1043,7 @@ bool ro_gui_wimp_event_keypress(wimp_key *key)
|
|||
return false;
|
||||
ro_gui_dialog_close(key->w);
|
||||
ro_gui_wimp_event_close_window(key->w);
|
||||
ro_gui_menu_closed(true);
|
||||
ro_gui_menu_closed();
|
||||
return true;
|
||||
/* Return performs the OK action */
|
||||
case wimp_KEY_RETURN:
|
||||
|
@ -975,23 +1124,102 @@ bool ro_gui_wimp_event_redraw_window(wimp_draw *redraw)
|
|||
|
||||
bool ro_gui_wimp_event_process_window_menu_click(wimp_pointer *pointer)
|
||||
{
|
||||
struct event_window *window;
|
||||
struct event_window *window;
|
||||
int xpos, ypos, line_height, gap_height, entry;
|
||||
|
||||
window = ro_gui_wimp_event_find_window(pointer->w);
|
||||
if ((window) && (window->window_menu)
|
||||
&& (pointer->buttons == wimp_CLICK_MENU)) {
|
||||
if (window->window_menu_prepare)
|
||||
window->window_menu_prepare(window->w,
|
||||
window->window_menu);
|
||||
if (window->menu_prepare)
|
||||
if (!window->menu_prepare(window->w, wimp_ICON_WINDOW,
|
||||
window->window_menu, pointer))
|
||||
return false;
|
||||
|
||||
ro_gui_menu_create(window->window_menu,
|
||||
pointer->pos.x, pointer->pos.y,
|
||||
window->w, false);
|
||||
if (window->window_menu_iconbar) {
|
||||
xpos = pointer->pos.x;
|
||||
ypos = 96;
|
||||
|
||||
line_height = window->window_menu->height +
|
||||
window->window_menu->gap;
|
||||
gap_height = 24; /* The fixed dotted line height */
|
||||
|
||||
entry = 0;
|
||||
do {
|
||||
ypos += line_height;
|
||||
if ((window->window_menu->
|
||||
entries[entry].menu_flags &
|
||||
wimp_MENU_SEPARATE) != 0)
|
||||
ypos += gap_height;
|
||||
} while ((window->window_menu->
|
||||
entries[entry++].menu_flags &
|
||||
wimp_MENU_LAST) == 0);
|
||||
} else {
|
||||
xpos = pointer->pos.x;
|
||||
ypos = pointer->pos.y;
|
||||
}
|
||||
|
||||
ro_gui_menu_create(window->window_menu, xpos, ypos, window->w);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Trigger a window's Prepare Menu event.
|
||||
*
|
||||
* \param w The window to use.
|
||||
* \param i The icon to use.
|
||||
* \param *menu The menu handle to use.
|
||||
* \return true if the affected menu was prepared OK; else
|
||||
* false.
|
||||
*/
|
||||
|
||||
bool ro_gui_wimp_event_prepare_menu(wimp_w w, wimp_i i, wimp_menu *menu)
|
||||
{
|
||||
struct event_window *window;
|
||||
|
||||
window = ro_gui_wimp_event_find_window(w);
|
||||
if (window == NULL)
|
||||
return false;
|
||||
|
||||
if (window->menu_prepare)
|
||||
return window->menu_prepare(w, i, menu, NULL);
|
||||
|
||||
/* The menu is always OK if there's no event handler. */
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a window menu to be (semi-)automatically handled.
|
||||
*
|
||||
* \param w The window to attach the menu to.
|
||||
* \param *m The menu to be attached.
|
||||
* \param menu_auto true if the menu should be opened autimatically
|
||||
* on Menu clicks with no task intervention; false
|
||||
* to pass clicks to the window's Mouse Event
|
||||
* handler and leave that to pass the menu click
|
||||
* back to us for handling and menu opening.
|
||||
* \param bool_position_ibar true if the menu should open in an iconbar
|
||||
* position; false to open at the pointer.
|
||||
* \return true if the menu was registed ok; else false.
|
||||
*/
|
||||
|
||||
bool ro_gui_wimp_event_register_menu(wimp_w w, wimp_menu *m,
|
||||
bool menu_auto, bool position_ibar)
|
||||
{
|
||||
struct event_window *window;
|
||||
|
||||
window = ro_gui_wimp_event_get_window(w);
|
||||
if (!window)
|
||||
return false;
|
||||
window->window_menu = m;
|
||||
window->window_menu_auto = menu_auto;
|
||||
window->window_menu_iconbar = position_ibar;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a numeric field to be automatically handled
|
||||
*/
|
||||
|
@ -1227,11 +1455,40 @@ bool ro_gui_wimp_event_register_redraw_window(wimp_w w,
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register a function to be called before a menu is (re-)opened.
|
||||
*
|
||||
* \param *w The window for which events should be returned.
|
||||
* \param *callback A function to be called beofre the menu is
|
||||
* (re-)opened.
|
||||
* \return true if the menu was registed ok; else false.
|
||||
*/
|
||||
bool ro_gui_wimp_event_register_menu_prepare(wimp_w w,
|
||||
bool (*callback)(wimp_w w, wimp_i i, wimp_menu *m,
|
||||
wimp_pointer *p))
|
||||
{
|
||||
struct event_window *window;
|
||||
|
||||
window = ro_gui_wimp_event_get_window(w);
|
||||
if (!window)
|
||||
return false;
|
||||
window->menu_prepare = callback;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register a function to be called following a menu selection.
|
||||
*
|
||||
* \param *w The window for which events should be returned.
|
||||
* \param *callback A function to be called when a selection is
|
||||
* made.
|
||||
* \return true if the menu was registed ok; else false.
|
||||
*/
|
||||
bool ro_gui_wimp_event_register_menu_selection(wimp_w w,
|
||||
void (*callback)(wimp_w w, wimp_i i))
|
||||
bool (*callback)(wimp_w w, wimp_i i, wimp_menu *m,
|
||||
wimp_selection *s, menu_action a))
|
||||
{
|
||||
struct event_window *window;
|
||||
|
||||
|
@ -1242,32 +1499,45 @@ bool ro_gui_wimp_event_register_menu_selection(wimp_w w,
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a set of functions to be called to handle a window menu.
|
||||
*
|
||||
* \param
|
||||
*/
|
||||
|
||||
bool ro_gui_wimp_event_register_window_menu(wimp_w w, wimp_menu *m,
|
||||
void (*callback_prepare)(wimp_w w, wimp_menu *m),
|
||||
bool (*callback_selection)(wimp_w w, wimp_menu *m,
|
||||
wimp_selection *s, menu_action action),
|
||||
void (*callback_close)(wimp_w w, wimp_menu *m),
|
||||
void (*callback_warning)(wimp_w w, wimp_menu *m,
|
||||
wimp_selection *s, menu_action action),
|
||||
bool menu_auto)
|
||||
/**
|
||||
* Register a function to be called when a sub-menu warning is received.
|
||||
*
|
||||
* \param *w The window for which events should be returned.
|
||||
* \param *callback A function to be called whenever a submenu
|
||||
* warning is received for the menu.
|
||||
* \return true if the menu was registed ok; else false.
|
||||
*/
|
||||
bool ro_gui_wimp_event_register_menu_warning(wimp_w w,
|
||||
void (*callback)(wimp_w w, wimp_i i, wimp_menu *m,
|
||||
wimp_selection *s, menu_action a))
|
||||
{
|
||||
struct event_window *window;
|
||||
|
||||
window = ro_gui_wimp_event_get_window(w);
|
||||
if (!window)
|
||||
return false;
|
||||
window->window_menu = m;
|
||||
window->window_menu_prepare = callback_prepare;
|
||||
window->window_menu_selection = callback_selection;
|
||||
window->window_menu_close = callback_close;
|
||||
window->window_menu_warning = callback_warning;
|
||||
window->window_menu_auto = menu_auto;
|
||||
window->menu_warning = callback;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register a function to be called before a menu is finally closed.
|
||||
*
|
||||
* \param *w The window for which events should be returned.
|
||||
* \param *callback A function to be called when the menu is closed.
|
||||
* \return true if the menu was registed ok; else false.
|
||||
*/
|
||||
bool ro_gui_wimp_event_register_menu_close(wimp_w w,
|
||||
void (*callback)(wimp_w w, wimp_i i, wimp_menu *m))
|
||||
{
|
||||
struct event_window *window;
|
||||
|
||||
window = ro_gui_wimp_event_get_window(w);
|
||||
if (!window)
|
||||
return false;
|
||||
window->menu_close = callback;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1408,20 +1678,29 @@ bool ro_gui_wimp_event_submenu_warning(wimp_w w, wimp_i i, wimp_menu *menu,
|
|||
for (event = window->first; event; event = event->next)
|
||||
if ((event->type == EVENT_MENU_GRIGHT) && (event->i == i))
|
||||
break;
|
||||
if (event)
|
||||
if (event) {
|
||||
if (window->menu_close != NULL &&
|
||||
event->type == EVENT_MENU_GRIGHT &&
|
||||
event->data.menu_gright.menu == menu) {
|
||||
window->menu_close(w, i, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* If the warning is for a window menu, then pass the event on to it. */
|
||||
|
||||
if ((window->window_menu) && (window->window_menu == menu)) {
|
||||
if (window->window_menu_warning) {
|
||||
window->window_menu_warning(w, menu, selection, action);
|
||||
if (window->menu_warning) {
|
||||
window->menu_warning(w, wimp_ICON_WINDOW, menu,
|
||||
selection, action);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle menus being closed. This is called from ro_gui_menu_closed(), in
|
||||
|
@ -1440,8 +1719,8 @@ void ro_gui_wimp_event_menus_closed(wimp_w w, wimp_i i, wimp_menu *menu)
|
|||
ro_gui_wimp_event_register_submenu(0);
|
||||
|
||||
/* Process the event for any window menus. Find the window data, then
|
||||
* try and match to an icon event. If we can, then there isn't anything
|
||||
* to do.
|
||||
* try and match to an icon event. If we can, then GRight menus are
|
||||
* sent the event; otherwise, we do nothing.
|
||||
*/
|
||||
|
||||
window = ro_gui_wimp_event_find_window(w);
|
||||
|
@ -1451,14 +1730,19 @@ void ro_gui_wimp_event_menus_closed(wimp_w w, wimp_i i, wimp_menu *menu)
|
|||
for (event = window->first; event; event = event->next)
|
||||
if ((event->type == EVENT_MENU_GRIGHT) && (event->i == i))
|
||||
break;
|
||||
if (event)
|
||||
if (event) {
|
||||
if (window->menu_close != NULL &&
|
||||
event->type == EVENT_MENU_GRIGHT &&
|
||||
event->data.menu_gright.menu == menu)
|
||||
window->menu_close(w, i, menu);
|
||||
return;
|
||||
}
|
||||
|
||||
/* If the close is for a window menu, then pass the event on to it. */
|
||||
|
||||
if ((window->window_menu) && (window->window_menu == menu) &&
|
||||
(window->window_menu_close))
|
||||
window->window_menu_close(w, menu);
|
||||
(window->menu_close))
|
||||
window->menu_close(w, wimp_ICON_WINDOW, menu);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright 2005 Richard Wilson <info@tinct.net>
|
||||
* Copyright 2010 Stephen Fryatt <stevef@netsurf-browser.org>
|
||||
* Copyright 2010, 2011 Stephen Fryatt <stevef@netsurf-browser.org>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
|
@ -31,7 +31,7 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "oslib/os.h"
|
||||
#include "oslib/wimp.h"
|
||||
#include "oslib/wimp.h"
|
||||
#include "riscos/menus.h"
|
||||
|
||||
#define IS_WIMP_KEY (1u<<31)
|
||||
|
@ -39,10 +39,17 @@
|
|||
bool ro_gui_wimp_event_memorise(wimp_w w);
|
||||
bool ro_gui_wimp_event_restore(wimp_w w);
|
||||
bool ro_gui_wimp_event_validate(wimp_w w);
|
||||
bool ro_gui_wimp_event_transfer(wimp_w from, wimp_w to);
|
||||
void ro_gui_wimp_event_finalise(wimp_w w);
|
||||
void ro_gui_wimp_event_deregister(wimp_w w, wimp_i i);
|
||||
|
||||
bool ro_gui_wimp_event_set_help_prefix(wimp_w w, const char *help_prefix);
|
||||
const char *ro_gui_wimp_event_get_help_prefix(wimp_w w);
|
||||
bool ro_gui_wimp_event_register_help_suffix(wimp_w w,
|
||||
const char *(*get_help_suffix)(wimp_w w, wimp_i i,
|
||||
os_coord *pos, wimp_mouse_state buttons));
|
||||
const char *ro_gui_wimp_event_get_help_suffix(wimp_w w, wimp_i i,
|
||||
os_coord *pos, wimp_mouse_state buttons);
|
||||
bool ro_gui_wimp_event_set_user_data(wimp_w w, void *user);
|
||||
void *ro_gui_wimp_event_get_user_data(wimp_w w);
|
||||
|
||||
|
@ -52,10 +59,13 @@ bool ro_gui_wimp_event_mouse_click(wimp_pointer *pointer);
|
|||
bool ro_gui_wimp_event_keypress(wimp_key *key);
|
||||
bool ro_gui_wimp_event_open_window(wimp_open *open);
|
||||
bool ro_gui_wimp_event_close_window(wimp_w w);
|
||||
bool ro_gui_wimp_event_redraw_window(wimp_draw *redraw);
|
||||
|
||||
bool ro_gui_wimp_event_process_window_menu_click(wimp_pointer *pointer);
|
||||
bool ro_gui_wimp_event_redraw_window(wimp_draw *redraw);
|
||||
|
||||
bool ro_gui_wimp_event_process_window_menu_click(wimp_pointer *pointer);
|
||||
bool ro_gui_wimp_event_prepare_menu(wimp_w w, wimp_i i, wimp_menu *menu);
|
||||
|
||||
bool ro_gui_wimp_event_register_menu(wimp_w w, wimp_menu *m,
|
||||
bool menu_auto, bool position_ibar);
|
||||
bool ro_gui_wimp_event_register_numeric_field(wimp_w w, wimp_i i, wimp_i up,
|
||||
wimp_i down, int min, int max, int stepping,
|
||||
int decimal_places);
|
||||
|
@ -80,18 +90,19 @@ bool ro_gui_wimp_event_register_close_window(wimp_w w,
|
|||
void (*callback)(wimp_w w));
|
||||
bool ro_gui_wimp_event_register_redraw_window(wimp_w w,
|
||||
void (*callback)(wimp_draw *redraw));
|
||||
bool ro_gui_wimp_event_register_menu_prepare(wimp_w w,
|
||||
bool (*callback)(wimp_w w, wimp_i i, wimp_menu *m,
|
||||
wimp_pointer *p));
|
||||
bool ro_gui_wimp_event_register_menu_selection(wimp_w w,
|
||||
void (*callback)(wimp_w w, wimp_i i));
|
||||
bool ro_gui_wimp_event_register_window_menu(wimp_w w, wimp_menu *m,
|
||||
void (*callback_prepare)(wimp_w w, wimp_menu *m),
|
||||
bool (*callback_selection)(wimp_w w, wimp_menu *m,
|
||||
wimp_selection *s, menu_action action),
|
||||
void (*callback_close)(wimp_w w, wimp_menu *m),
|
||||
void (*callback_warning)(wimp_w w, wimp_menu *m,
|
||||
wimp_selection *s, menu_action action),
|
||||
bool menu_auto);
|
||||
bool (*callback)(wimp_w w, wimp_i i, wimp_menu *m,
|
||||
wimp_selection *s, menu_action a));
|
||||
bool ro_gui_wimp_event_register_menu_warning(wimp_w w,
|
||||
void (*callback)(wimp_w w, wimp_i i, wimp_menu *m,
|
||||
wimp_selection *s, menu_action a));
|
||||
bool ro_gui_wimp_event_register_menu_close(wimp_w w,
|
||||
void (*callback)(wimp_w w, wimp_i i, wimp_menu *m));
|
||||
|
||||
bool ro_gui_wimp_event_submenu_warning(wimp_w w, wimp_i i, wimp_menu *menu,
|
||||
bool ro_gui_wimp_event_submenu_warning(wimp_w w, wimp_i i, wimp_menu *menu,
|
||||
wimp_selection *selection, menu_action action);
|
||||
void ro_gui_wimp_event_menus_closed(wimp_w w, wimp_i i, wimp_menu *menu);
|
||||
void ro_gui_wimp_event_register_submenu(wimp_w w);
|
||||
|
|
4435
riscos/window.c
4435
riscos/window.c
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright 2010, 2011 Stephen Fryatt <stevef@netsurf-browser.org>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
* NetSurf is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* NetSurf is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Browser window handling (interface).
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifndef _NETSURF_RISCOS_WINDOW_H_
|
||||
#define _NETSURF_RISCOS_WINDOW_H_
|
||||
|
||||
void ro_gui_window_initialise(void);
|
||||
|
||||
bool ro_gui_window_check_menu(wimp_menu *menu);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue