Simplify and tidy up RISC OS gui_ functions. Fix toolbar height changing issues for framesets.

svn path=/trunk/netsurf/; revision=2924
This commit is contained in:
Richard Wilson 2006-09-06 22:15:58 +00:00
parent d5540f344d
commit 3e0c02e8e5
10 changed files with 1040 additions and 1173 deletions

View File

@ -263,7 +263,7 @@ void browser_window_recalculate_iframes(struct browser_window *bw) {
assert(bw);
/* update window dimensions */
gui_window_get_dimensions(bw->window, &bw_width, &bw_height);
gui_window_get_dimensions(bw->window, &bw_width, &bw_height, false);
if (!bw->parent) {
bw->x0 = 0;
bw->y0 = 0;
@ -383,7 +383,7 @@ void browser_window_recalculate_frameset(struct browser_window *bw) {
/* window dimensions */
if (!bw->parent) {
gui_window_get_dimensions(bw->window, &bw_width, &bw_height);
gui_window_get_dimensions(bw->window, &bw_width, &bw_height, false);
bw->x0 = 0;
bw->y0 = 0;
bw->x1 = bw_width;
@ -751,6 +751,7 @@ void browser_window_go_post(struct browser_window *bw, const char *url,
char url_buf[256];
int depth = 0;
struct browser_window *cur;
int width, height;
LOG(("bw %p, url %s", bw, url));
assert(bw);
@ -810,13 +811,13 @@ void browser_window_go_post(struct browser_window *bw, const char *url,
browser_window_remove_caret(bw);
browser_window_destroy_children(bw);
gui_window_get_dimensions(bw->window, &width, &height, true);
browser_window_set_status(bw, messages_get("Loading"));
bw->history_add = history_add;
bw->time0 = clock();
c = fetchcache(url2, browser_window_callback, (intptr_t) bw, 0,
gui_window_get_width(bw->window),
gui_window_get_height(bw->window),
false,
width, height, false,
post_urlenc, post_multipart, true, download);
free(url2);
if (!c) {
@ -835,9 +836,7 @@ void browser_window_go_post(struct browser_window *bw, const char *url,
bw->download = download;
fetchcache_go(c, option_send_referer ? referer : 0,
browser_window_callback, (intptr_t) bw, 0,
gui_window_get_width(bw->window),
gui_window_get_height(bw->window),
browser_window_callback, (intptr_t) bw, 0, width, height,
post_urlenc, post_multipart, true);
}

View File

@ -67,9 +67,8 @@ void gui_window_scroll_visible(struct gui_window *g, int x0, int y0,
int x1, int y1);
void gui_window_position_frame(struct gui_window *g, int x0, int y0,
int x1, int y1);
void gui_window_get_dimensions(struct gui_window *g, int *width, int *height);
int gui_window_get_width(struct gui_window *g);
int gui_window_get_height(struct gui_window *g);
void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
bool scaled);
void gui_window_update_extent(struct gui_window *g);
void gui_window_set_status(struct gui_window *g, const char *text);
void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape);
@ -83,8 +82,8 @@ void gui_window_new_content(struct gui_window *g);
bool gui_window_scroll_start(struct gui_window *g);
bool gui_window_box_scroll_start(struct gui_window *g,
int x0, int y0, int x1, int y1);
void gui_window_save_as_link(struct gui_window *g, struct content *c);
bool gui_window_frame_resize_start(struct gui_window *g);
void gui_window_save_as_link(struct gui_window *g, struct content *c);
struct gui_download_window *gui_download_window_create(const char *url,
const char *mime_type, struct fetch *fetch,

View File

@ -137,7 +137,6 @@ void ro_gui_cert_open(struct tree *tree, struct node *node);
/* in window.c */
void ro_gui_window_quit(void);
void ro_gui_window_update_theme(void);
void ro_gui_window_update_dimensions(struct gui_window *g, int yscroll);
void ro_gui_window_mouse_at(struct gui_window *g, wimp_pointer *pointer);
bool ro_gui_toolbar_click(wimp_pointer *pointer);
bool ro_gui_status_click(wimp_pointer *pointer);
@ -146,9 +145,8 @@ struct gui_window *ro_gui_window_lookup(wimp_w window);
struct gui_window *ro_gui_toolbar_lookup(wimp_w window);
struct gui_window *ro_gui_status_lookup(wimp_w window);
void ro_gui_scroll_request(wimp_scroll *scroll);
int window_x_units(int x, wimp_window_state *state);
int window_y_units(int y, wimp_window_state *state);
bool window_screen_pos(struct gui_window *g, int x, int y, os_coord *pos);
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);

View File

@ -447,10 +447,9 @@ void ro_gui_menu_init(void)
* Display a menu.
*/
void ro_gui_menu_create(wimp_menu *menu, int x, int y, wimp_w w) {
int doc_x, doc_y;
wimp_window_state state;
struct gui_window *g;
os_error *error;
os_coord pos;
int i;
menu_action action;
struct menu_definition *definition;
@ -467,26 +466,14 @@ void ro_gui_menu_create(wimp_menu *menu, int x, int y, wimp_w w) {
/* read the object under the pointer for a new gui_window menu */
if ((!current_menu) && (menu == browser_menu)) {
state.w = w;
error = xwimp_get_window_state(&state);
if (error) {
LOG(("xwimp_get_window_state: 0x%x: %s",
error->errnum, error->errmess));
warn_user("WimpError", error->errmess);
return;
}
g = ro_gui_window_lookup(w);
assert(g);
doc_x = window_x_units(x, &state) / 2 / g->option.scale;
doc_y = -window_y_units(y, &state) / 2 / g->option.scale;
if (!ro_gui_window_to_window_pos(g, x, y, &pos))
return;
current_menu_object_box = NULL;
if (g->bw->current_content &&
g->bw->current_content->type == CONTENT_HTML)
current_menu_object_box = box_object_at_point(
g->bw->current_content, doc_x, doc_y);
current_menu_object_box = box_object_at_point(g->bw->current_content, pos.x, pos.y);
}
/* store the menu characteristics */
@ -776,17 +763,13 @@ void ro_gui_menu_warning(wimp_message_menu_warning *warning) {
* \param toolbar the toolbar to update
*/
void ro_gui_menu_refresh_toolbar(struct toolbar *toolbar) {
int height;
assert(toolbar);
toolbar->reformat_buttons = true;
height = toolbar->height;
ro_gui_theme_process_toolbar(toolbar, -1);
if (toolbar->type == THEME_BROWSER_TOOLBAR) {
ro_gui_window_update_dimensions(
ro_gui_window_lookup(current_menu_window),
height - toolbar->height);
gui_window_update_extent(ro_gui_window_lookup(current_menu_window));
} else if (toolbar->type == THEME_HOTLIST_TOOLBAR) {
tree_resized(hotlist_tree);
xwimp_force_redraw((wimp_w)hotlist_tree->handle,
@ -795,6 +778,10 @@ void ro_gui_menu_refresh_toolbar(struct toolbar *toolbar) {
tree_resized(global_history_tree);
xwimp_force_redraw((wimp_w)global_history_tree->handle,
0,-16384, 16384, 16384);
} else if (toolbar->type == THEME_COOKIES_TOOLBAR) {
tree_resized(cookies_tree);
xwimp_force_redraw((wimp_w)cookies_tree->handle,
0,-16384, 16384, 16384);
}
}

View File

@ -137,10 +137,9 @@ void gui_start_selection(struct gui_window *g)
void ro_gui_selection_drag_end(struct gui_window *g, wimp_dragged *drag)
{
wimp_auto_scroll_info scroll;
wimp_window_state state;
wimp_pointer pointer;
os_error *error;
int x, y;
os_coord pos;
LOG(("ending text selection drag"));
@ -167,20 +166,10 @@ void ro_gui_selection_drag_end(struct gui_window *g, wimp_dragged *drag)
return;
}
state.w = g->window;
error = xwimp_get_window_state(&state);
if (error) {
LOG(("xwimp_get_window_state 0x%x : %s",
error->errnum, error->errmess));
warn_user("WimpError", error->errmess);
return;
}
x = window_x_units(drag->final.x0, &state) / 2 / g->option.scale;
y = -window_y_units(drag->final.y0, &state) / 2 / g->option.scale;
browser_window_mouse_drag_end(g->bw,
ro_gui_mouse_click_state(pointer.buttons), x, y);
if (ro_gui_window_to_window_pos(g, drag->final.x0, drag->final.y0, &pos))
browser_window_mouse_drag_end(g->bw,
ro_gui_mouse_click_state(pointer.buttons),
pos.x, pos.y);
}
@ -369,7 +358,7 @@ void gui_paste_from_clipboard(struct gui_window *g, int x, int y)
os_error *error;
os_coord pos;
if (!window_screen_pos(g, x, y, &pos))
if (!ro_gui_window_to_screen_pos(g, x, y, &pos))
return;
msg.size = sizeof(msg);
@ -510,15 +499,13 @@ void ro_gui_selection_dragging(wimp_message *message)
struct box *textarea = NULL;
struct box *text_box = NULL;
struct browser_window *bw;
wimp_window_state state;
struct content *content;
int gadget_box_x = 0;
int gadget_box_y = 0;
struct gui_window *g;
os_error *error;
os_coord pos;
int box_x = 0;
int box_y = 0;
int x, y;
/* with autoscrolling, we will probably need to remember the gui_window and
override the drag->w window handle which could be any window on the desktop */
@ -535,20 +522,8 @@ void ro_gui_selection_dragging(wimp_message *message)
return;
}
state.w = drag->w;
error = xwimp_get_window_state(&state);
if (error) {
LOG(("xwimp_get_window_state: 0x%x: %s\n",
error->errnum, error->errmess));
warn_user("WimpError", error->errmess);
drag_claimed = false;
if (!ro_gui_window_to_window_pos(g, drag->pos.x, drag->pos.y, &pos))
return;
}
x = window_x_units(drag->pos.x, &state) / 2 /
g->option.scale;
y = -window_y_units(drag->pos.y, &state) / 2 /
g->option.scale;
bw = g->bw;
content = bw->current_content;
@ -557,7 +532,7 @@ void ro_gui_selection_dragging(wimp_message *message)
struct box *box = content->data.html.layout;
while ((box = box_at_point(box, x, y, &box_x, &box_y, &content))) {
while ((box = box_at_point(box, pos.x, pos.y, &box_x, &box_y, &content))) {
if (box->style &&
box->style->visibility == CSS_VISIBILITY_HIDDEN)
continue;
@ -591,8 +566,8 @@ void ro_gui_selection_dragging(wimp_message *message)
else
gui_window_set_pointer(g, GUI_POINTER_CARET);
text_box = textarea_get_position(textarea, x - gadget_box_x,
y - gadget_box_y, &char_offset, &pixel_offset);
text_box = textarea_get_position(textarea, pos.x - gadget_box_x,
pos.y - gadget_box_y, &char_offset, &pixel_offset);
caret_set_position(&ghost_caret, bw, text_box, char_offset, pixel_offset);
drag_claimed = true;

View File

@ -568,6 +568,9 @@ bool ro_gui_theme_apply(struct theme_descriptor *descriptor) {
/* apply the theme to all the current windows */
ro_gui_window_update_theme();
ro_gui_tree_update_theme(hotlist_tree);
ro_gui_tree_update_theme(global_history_tree);
ro_gui_tree_update_theme(cookies_tree);
ro_gui_theme_close(theme_previous, false);
return true;
}
@ -833,6 +836,7 @@ struct toolbar *ro_gui_theme_create_toolbar(struct theme_descriptor *descriptor,
ro_gui_theme_destroy_toolbar(toolbar);
return NULL;
}
toolbar->old_height = ro_gui_theme_toolbar_full_height(toolbar);
return toolbar;
}
@ -1751,7 +1755,6 @@ void ro_gui_theme_destroy_toolbar(struct toolbar *toolbar) {
* \param toolbar the toolbar to toggle editing for
*/
void ro_gui_theme_toggle_edit(struct toolbar *toolbar) {
int height;
int icons = 0;
struct toolbar_icon *icon;
struct gui_window *g = NULL;
@ -1812,14 +1815,13 @@ void ro_gui_theme_toggle_edit(struct toolbar *toolbar) {
}
/* turn off editing */
height = toolbar->editor->height;
ro_gui_theme_destroy_toolbar(toolbar->editor);
toolbar->editor = NULL;
ro_gui_theme_update_toolbar(toolbar->descriptor, toolbar);
switch (toolbar->type) {
case THEME_BROWSER_TOOLBAR:
if (g)
ro_gui_window_update_dimensions(g, height);
gui_window_update_extent(g);
break;
default:
if (toolbar->parent_handle)
@ -1863,8 +1865,7 @@ void ro_gui_theme_toggle_edit(struct toolbar *toolbar) {
switch (toolbar->type) {
case THEME_BROWSER_TOOLBAR:
if (g)
ro_gui_window_update_dimensions(g,
-toolbar->editor->height);
gui_window_update_extent(g);
break;
default:
if (toolbar->parent_handle) {
@ -2426,3 +2427,12 @@ void ro_gui_theme_status_open(wimp_open *open) {
if (toolbar->status_width > 10000) toolbar->status_width = 10000;
ro_gui_theme_process_toolbar(toolbar, -1);
}
int ro_gui_theme_height_change(struct toolbar *toolbar) {
int height, cur_height;
cur_height = ro_gui_theme_toolbar_full_height(toolbar);
height = toolbar->old_height - cur_height;
toolbar->old_height = cur_height;
return height;
}

View File

@ -108,6 +108,7 @@ struct toolbar {
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 status_handle; /**< status window handle (if applicable) */
wimp_w parent_handle; /**< parent window handle (read only) */
@ -162,6 +163,8 @@ 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 + \

View File

@ -1490,3 +1490,20 @@ bool ro_gui_tree_launch_node(struct tree *tree, struct node *node) {
int ro_gui_tree_help(int x, int y) {
return -1;
}
void ro_gui_tree_update_theme(struct tree *tree) {
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);
}
}

View File

@ -45,5 +45,6 @@ void ro_gui_tree_scroll_visible(struct tree *tree, struct node_element *element)
void ro_gui_tree_get_tree_coordinates(struct tree *tree, int x, int y,
int *tree_x, int *tree_y);
int ro_gui_tree_help(int x, int y);
void ro_gui_tree_update_theme(struct tree *tree);
#endif

File diff suppressed because it is too large Load Diff