summaryrefslogtreecommitdiff
path: root/riscos
diff options
context:
space:
mode:
authorRichard Wilson <rjw@netsurf-browser.org>2005-03-18 23:52:38 +0000
committerRichard Wilson <rjw@netsurf-browser.org>2005-03-18 23:52:38 +0000
commit036622f35fc98ad154a982f1dd6f384f66d79707 (patch)
tree89f47a06134b137a24df04417799330eff9a1cfb /riscos
parent793bb9119a04a109c2ac55200f0d4a00d026dee0 (diff)
downloadnetsurf-036622f35fc98ad154a982f1dd6f384f66d79707.tar.gz
netsurf-036622f35fc98ad154a982f1dd6f384f66d79707.tar.bz2
[project @ 2005-03-18 23:52:38 by rjw]
Allow windows to be resized to an absolute minimum (toolbars collapse.) svn path=/import/netsurf/; revision=1541
Diffstat (limited to 'riscos')
-rw-r--r--riscos/global_history.c13
-rw-r--r--riscos/gui.c24
-rw-r--r--riscos/gui.h1
-rw-r--r--riscos/help.c54
-rw-r--r--riscos/hotlist.c15
-rw-r--r--riscos/menus.c20
-rw-r--r--riscos/theme.c49
-rw-r--r--riscos/theme.h3
-rw-r--r--riscos/treeview.c70
-rw-r--r--riscos/treeview.h5
-rw-r--r--riscos/window.c57
11 files changed, 199 insertions, 112 deletions
diff --git a/riscos/global_history.c b/riscos/global_history.c
index 87b4b1739..c0ee1ac9e 100644
--- a/riscos/global_history.c
+++ b/riscos/global_history.c
@@ -76,7 +76,7 @@ static wimp_window history_window_definition = {
wimp_BUTTON_DOUBLE_CLICK_DRAG << wimp_ICON_BUTTON_TYPE_SHIFT,
wimpspriteop_AREA,
1,
- 100,
+ 1,
{""},
0,
{}
@@ -86,7 +86,6 @@ static wimp_window history_window_definition = {
/* The history window, toolbar and plot origins
*/
static wimp_w global_history_window;
-struct toolbar *global_history_toolbar;
struct tree *global_history_tree;
void ro_gui_global_history_initialise(void) {
@@ -134,13 +133,11 @@ void ro_gui_global_history_initialise(void) {
/* Create our toolbar
*/
- global_history_toolbar = ro_gui_theme_create_toolbar(NULL,
+ global_history_tree->toolbar = ro_gui_theme_create_toolbar(NULL,
THEME_HISTORY_TOOLBAR);
- if (global_history_toolbar) {
- ro_gui_theme_attach_toolbar(global_history_toolbar,
+ if (global_history_tree->toolbar)
+ ro_gui_theme_attach_toolbar(global_history_tree->toolbar,
global_history_window);
- global_history_tree->offset_y = global_history_toolbar->height;
- }
/* load recent URLs */
fp = fopen(GLOBAL_HISTORY_RECENT_READ, "r");
@@ -331,7 +328,7 @@ void ro_gui_global_history_save_node(struct node *node, FILE *fp) {
* Shows the history window.
*/
void ro_gui_global_history_show(void) {
- ro_gui_tree_show(global_history_tree, global_history_toolbar);
+ ro_gui_tree_show(global_history_tree);
ro_gui_menu_prepare_global_history();
}
diff --git a/riscos/gui.c b/riscos/gui.c
index cee09ef8d..fe12a5eac 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -785,13 +785,14 @@ void ro_gui_redraw_window_request(wimp_draw *redraw)
ro_gui_url_complete_redraw(redraw);
else if ((hotlist_tree) && (redraw->w == (wimp_w)hotlist_tree->handle))
ro_gui_tree_redraw(redraw, hotlist_tree);
- else if ((hotlist_toolbar) && (hotlist_toolbar->toolbar_handle == redraw->w))
- ro_gui_theme_redraw(hotlist_toolbar, redraw);
+ else if ((hotlist_tree) && (hotlist_tree->toolbar) &&
+ (hotlist_tree->toolbar->toolbar_handle == redraw->w))
+ ro_gui_theme_redraw(hotlist_tree->toolbar, redraw);
else if ((global_history_tree) && (redraw->w == (wimp_w)global_history_tree->handle))
ro_gui_tree_redraw(redraw, global_history_tree);
- else if ((global_history_toolbar) &&
- (global_history_toolbar->toolbar_handle == redraw->w))
- ro_gui_theme_redraw(global_history_toolbar, redraw);
+ else if ((global_history_tree) && (global_history_tree->toolbar) &&
+ (global_history_tree->toolbar->toolbar_handle == redraw->w))
+ ro_gui_theme_redraw(global_history_tree->toolbar, redraw);
else if (redraw->w == dialog_debug)
ro_gui_debugwin_redraw(redraw);
else if ((g = ro_gui_window_lookup(redraw->w)) != NULL)
@@ -918,13 +919,12 @@ void ro_gui_mouse_click(wimp_pointer *pointer)
ro_gui_global_history_click(pointer);
else if (pointer->w == dialog_saveas)
ro_gui_save_click(pointer);
- else if (hotlist_toolbar &&
- hotlist_toolbar->toolbar_handle == pointer->w)
- ro_gui_tree_toolbar_click(pointer, hotlist_tree, hotlist_toolbar);
- else if (global_history_toolbar &&
- global_history_toolbar->toolbar_handle == pointer->w)
- ro_gui_tree_toolbar_click(pointer, global_history_tree,
- global_history_toolbar);
+ else if ((hotlist_tree) && (hotlist_tree->toolbar) &&
+ (hotlist_tree->toolbar->toolbar_handle == pointer->w))
+ ro_gui_tree_toolbar_click(pointer, hotlist_tree);
+ else if ((global_history_tree) && (global_history_tree->toolbar) &&
+ (global_history_tree->toolbar->toolbar_handle == pointer->w))
+ ro_gui_tree_toolbar_click(pointer, global_history_tree);
else if ((g = ro_gui_window_lookup(pointer->w)) != NULL)
ro_gui_window_click(g, pointer);
else if ((g = ro_gui_toolbar_lookup(pointer->w)) != NULL)
diff --git a/riscos/gui.h b/riscos/gui.h
index 0f8661b88..49ffe2c58 100644
--- a/riscos/gui.h
+++ b/riscos/gui.h
@@ -43,7 +43,6 @@ extern bool gui_reformat_pending;
extern bool gui_redraw_debug;
extern wimp_menu *current_menu;
extern osspriteop_area *gui_sprites;
-extern struct toolbar *hotlist_toolbar, *global_history_toolbar;
extern bool dialog_folder_add, dialog_entry_add, hotlist_insert;
extern bool print_active, print_text_black;
extern struct tree *hotlist_tree, *global_history_tree;
diff --git a/riscos/help.c b/riscos/help.c
index b6d7c0bb3..70016a5be 100644
--- a/riscos/help.c
+++ b/riscos/help.c
@@ -2,7 +2,7 @@
* This file is part of NetSurf, http://netsurf.sourceforge.net/
* Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license
- * Copyright 2004 Richard Wilson <not_ginger_matt@users.sourceforge.net>
+ * Copyright 2004, 2005 Richard Wilson <info@tinct.net>
*/
/** \file
@@ -16,6 +16,7 @@
#include "oslib/os.h"
#include "oslib/taskmanager.h"
#include "oslib/wimp.h"
+#include "netsurf/riscos/global_history.h"
#include "netsurf/riscos/gui.h"
#include "netsurf/riscos/help.h"
#include "netsurf/riscos/theme.h"
@@ -27,25 +28,27 @@
/* Recognised help keys
====================
- HelpIconbar Iconbar (no icon suffix is used)
-
- HelpAppInfo Application info window
- HelpBrowser Browser window [*]
- HelpHistory History window [*]
- HelpObjInfo Object info window
- HelpPageInfo Page info window
- HelpSaveAs Save as window
- HelpScaleView Scale view window
- HelpStatus Status window
- HelpToolbar Toolbar window
- HelpHotlist Hotlist window [*]
- HelpHotToolbar Hotlist window toolbar
- HelpHotEntry Hotlist entry window
- HelpHotFolder Hotlist entry window
-
- HelpIconMenu Iconbar menu
- HelpBrowserMenu Browser window menu
- HelpHotlistMenu Hotlist window menu
+ HelpIconbar Iconbar (no icon suffix is used)
+
+ HelpAppInfo Application info window
+ HelpBrowser Browser window [*]
+ HelpHistory History window [*]
+ HelpObjInfo Object info window
+ HelpPageInfo Page info window
+ HelpSaveAs Save as window
+ HelpScaleView Scale view window
+ HelpStatus Status window
+ HelpToolbar Toolbar window
+ HelpHotlist Hotlist window [*]
+ HelpHotToolbar Hotlist window toolbar
+ HelpHotEntry Hotlist entry window
+ HelpHotFolder Hotlist entry window
+ HelpGHistory Global history window [*]
+ HelpGHistoryToolbar Global history window toolbar
+
+ HelpIconMenu Iconbar menu
+ HelpBrowserMenu Browser window menu
+ HelpHotlistMenu Hotlist window menu
The prefixes are followed by either the icon number (eg 'HelpToolbar7'), or a series
of numbers representing the menu structure (eg 'HelpBrowserMenu3-1-2').
@@ -123,9 +126,16 @@ void ro_gui_interactive_help_request(wimp_message *message) {
sprintf(message_token, "HelpHotlist%i",
ro_gui_hotlist_help(message_data->pos.x,
message_data->pos.y));
- } else if (hotlist_toolbar &&
- window == hotlist_toolbar->toolbar_handle) {
+ } else if ((hotlist_tree) && (hotlist_tree->toolbar) &&
+ (window == hotlist_tree->toolbar->toolbar_handle)) {
sprintf(message_token, "HelpHotToolbar%i", (int)icon);
+ } else if ((global_history_tree) && (window == (wimp_w)global_history_tree->handle)) {
+ sprintf(message_token, "HelpGHistory%i",
+ ro_gui_global_history_help(message_data->pos.x,
+ message_data->pos.y));
+ } else if ((global_history_tree) && (global_history_tree->toolbar) &&
+ (window == global_history_tree->toolbar->toolbar_handle)) {
+ sprintf(message_token, "HelpGHistoryToolbar%i", (int)icon);
} else if ((g = ro_gui_window_lookup(window)) != NULL) {
sprintf(message_token, "HelpBrowser%i", (int)icon);
} else if ((g = ro_gui_toolbar_lookup(window)) != NULL) {
diff --git a/riscos/hotlist.c b/riscos/hotlist.c
index cdcf9960b..7cccd635c 100644
--- a/riscos/hotlist.c
+++ b/riscos/hotlist.c
@@ -2,7 +2,7 @@
* This file is part of NetSurf, http://netsurf.sourceforge.net/
* Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license
- * Copyright 2004 Richard Wilson <not_ginger_matt@users.sourceforge.net>
+ * Copyright 2004, 2005 Richard Wilson <info@tinct.net>
*/
/** \file
@@ -64,7 +64,7 @@ static wimp_window hotlist_window_definition = {
wimp_BUTTON_DOUBLE_CLICK_DRAG << wimp_ICON_BUTTON_TYPE_SHIFT,
wimpspriteop_AREA,
1,
- 100,
+ 1,
{""},
0,
{}
@@ -74,7 +74,6 @@ static wimp_window hotlist_window_definition = {
/* The hotlist window, toolbar and plot origins
*/
static wimp_w hotlist_window;
-struct toolbar *hotlist_toolbar;
struct tree *hotlist_tree;
/* Whether the editing facilities are for add so that we know how
@@ -137,11 +136,9 @@ void ro_gui_hotlist_initialise(void) {
/* Create our toolbar
*/
- hotlist_toolbar = ro_gui_theme_create_toolbar(NULL, THEME_HOTLIST_TOOLBAR);
- if (hotlist_toolbar) {
- ro_gui_theme_attach_toolbar(hotlist_toolbar, hotlist_window);
- hotlist_tree->offset_y = hotlist_toolbar->height;
- }
+ hotlist_tree->toolbar = ro_gui_theme_create_toolbar(NULL, THEME_HOTLIST_TOOLBAR);
+ if (hotlist_tree->toolbar)
+ ro_gui_theme_attach_toolbar(hotlist_tree->toolbar, hotlist_window);
}
@@ -168,7 +165,7 @@ void ro_gui_hotlist_save(void) {
* Shows the hotlist window.
*/
void ro_gui_hotlist_show(void) {
- ro_gui_tree_show(hotlist_tree, hotlist_toolbar);
+ ro_gui_tree_show(hotlist_tree);
ro_gui_menu_prepare_hotlist();
}
diff --git a/riscos/menus.c b/riscos/menus.c
index 9c7fd4347..55c4ed8a5 100644
--- a/riscos/menus.c
+++ b/riscos/menus.c
@@ -2007,9 +2007,11 @@ void ro_gui_menu_prepare_hotlist(void) {
bool reopen = false;
bool selection = false;
struct node *single = NULL;
+ struct toolbar *hotlist_toolbar;
if (!hotlist_tree)
return;
+ hotlist_toolbar = hotlist_tree->toolbar;
if (hotlist_tree->root->child) {
single = tree_get_selected_node(hotlist_tree->root->child);
@@ -2022,13 +2024,13 @@ void ro_gui_menu_prepare_hotlist(void) {
hotlist_file_menu->entries[2].icon_flags |= wimp_ICON_SHADED;
hotlist_file_menu->entries[3].icon_flags &= wimp_ICON_SHADED;
}
- ro_gui_set_icon_shaded_state(hotlist_toolbar->toolbar_handle,
- ICON_TOOLBAR_OPEN, !hotlist_tree->root->child);
- ro_gui_set_icon_shaded_state(hotlist_toolbar->toolbar_handle,
- ICON_TOOLBAR_EXPAND, !hotlist_tree->root->child);
if (hotlist_toolbar) {
ro_gui_set_icon_shaded_state(hotlist_toolbar->toolbar_handle,
+ ICON_TOOLBAR_OPEN, !hotlist_tree->root->child);
+ ro_gui_set_icon_shaded_state(hotlist_toolbar->toolbar_handle,
+ ICON_TOOLBAR_EXPAND, !hotlist_tree->root->child);
+ ro_gui_set_icon_shaded_state(hotlist_toolbar->toolbar_handle,
ICON_TOOLBAR_DELETE, !selection);
ro_gui_set_icon_shaded_state(hotlist_toolbar->toolbar_handle,
ICON_TOOLBAR_LAUNCH, !selection);
@@ -2070,9 +2072,11 @@ void ro_gui_menu_prepare_global_history(void) {
os_error *error;
bool reopen = false;
bool selection = false;
+ struct toolbar *global_history_toolbar;
if (!global_history_tree)
return;
+ global_history_toolbar = global_history_tree->toolbar;
if (global_history_tree->root->child) {
selection = tree_has_selection(global_history_tree->root->child);
@@ -2084,12 +2088,12 @@ void ro_gui_menu_prepare_global_history(void) {
history_file_menu->entries[1].icon_flags |= wimp_ICON_SHADED;
history_file_menu->entries[2].icon_flags |= wimp_ICON_SHADED;
}
- ro_gui_set_icon_shaded_state(global_history_toolbar->toolbar_handle,
+
+ if (global_history_toolbar) {
+ ro_gui_set_icon_shaded_state(global_history_toolbar->toolbar_handle,
ICON_TOOLBAR_OPEN, !global_history_tree->root->child);
- ro_gui_set_icon_shaded_state(global_history_toolbar->toolbar_handle,
+ ro_gui_set_icon_shaded_state(global_history_toolbar->toolbar_handle,
ICON_TOOLBAR_EXPAND, !global_history_tree->root->child);
-
- if (hotlist_toolbar) {
ro_gui_set_icon_shaded_state(global_history_toolbar->toolbar_handle,
ICON_TOOLBAR_DELETE, !selection);
ro_gui_set_icon_shaded_state(global_history_toolbar->toolbar_handle,
diff --git a/riscos/theme.c b/riscos/theme.c
index a6615d3c3..c1c2fc704 100644
--- a/riscos/theme.c
+++ b/riscos/theme.c
@@ -994,21 +994,23 @@ bool ro_gui_theme_update_toolbar(struct theme_descriptor *descriptor, struct too
bool ro_gui_theme_attach_toolbar(struct toolbar *toolbar, wimp_w parent) {
wimp_outline outline;
wimp_window_state state;
+ int height;
if (!toolbar) return false;
/* Attach/close the window
*/
toolbar->parent_handle = parent;
- if (toolbar->height > 0) {
+ height = ro_gui_theme_toolbar_height(toolbar);
+ if (height > 0) {
outline.w = parent;
xwimp_get_window_outline(&outline);
state.w = parent;
xwimp_get_window_state(&state);
state.w = toolbar->toolbar_handle;
state.visible.x1 = outline.outline.x1 - 2;
- state.visible.y0 = state.visible.y1 - toolbar->height + 2;
+ state.visible.y0 = state.visible.y1 - height + 2;
state.xscroll = 0;
- state.yscroll = 0;
+ state.yscroll = toolbar->height; /* clipped by WIMP to extent */
xwimp_open_window_nested((wimp_open *)&state, parent,
wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT
<< wimp_CHILD_XORIGIN_SHIFT |
@@ -1090,6 +1092,7 @@ bool ro_gui_theme_process_toolbar(struct toolbar *toolbar, int width) {
wimp_w parent = NULL;
wimp_outline outline;
wimp_window_state state;
+ int height = -1;
int throbber_x = -1;
int status_max;
int left_edge, right_edge, bottom_edge;
@@ -1144,6 +1147,46 @@ bool ro_gui_theme_process_toolbar(struct toolbar *toolbar, int width) {
width = outline.outline.x1 - outline.outline.x0 - 2;
}
}
+
+ /* Find the parent visible height to clip our toolbar height to
+ */
+ if ((toolbar->toolbar_handle) && (toolbar->parent_handle)) {
+ /* Get the current state
+ */
+ state.w = toolbar->parent_handle;
+ 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 false;
+ }
+
+ height = state.visible.y1 - state.visible.y0 + 2;
+
+ /* We can't obscure the height of the scroll bar as we lose the resize
+ icon if we do.
+ */
+ if ((state.flags & wimp_WINDOW_SIZE_ICON) && !(state.flags & wimp_WINDOW_HSCROLL))
+ height -= ro_get_hscroll_height(0) - 2;
+
+ /* Update our position
+ */
+ if (height != toolbar->max_height) {
+ if ((state.flags & wimp_WINDOW_SIZE_ICON) &&
+ !(state.flags & wimp_WINDOW_HSCROLL) &&
+ (toolbar->height > toolbar->max_height))
+ xwimp_force_redraw(toolbar->parent_handle,
+ 0, -16384, 16384, 16384);
+ toolbar->max_height = height;
+ ro_gui_theme_attach_toolbar(toolbar, toolbar->parent_handle);
+ if ((state.flags & wimp_WINDOW_SIZE_ICON) &&
+ !(state.flags & wimp_WINDOW_HSCROLL) &&
+ (toolbar->height > toolbar->max_height))
+ xwimp_force_redraw(toolbar->parent_handle,
+ 0, -16384, 16384, 16384);
+ }
+ }
/* Reformat the buttons starting with the throbber
*/
diff --git a/riscos/theme.h b/riscos/theme.h
index 3a86c05ac..38a8c2343 100644
--- a/riscos/theme.h
+++ b/riscos/theme.h
@@ -66,6 +66,7 @@ struct toolbar {
int status_current; /**< the size of the status window in OS units */
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) */
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) */
@@ -120,4 +121,6 @@ void ro_gui_theme_destroy_toolbar(struct toolbar *toolbar);
struct toolbar_icon *ro_gui_theme_toolbar_get_icon(struct toolbar *toolbar, int x, int y);
bool ro_gui_theme_toolbar_separator_following(struct toolbar_icon *icon);
+#define ro_gui_theme_toolbar_height(toolbar) toolbar->height > toolbar->max_height ? \
+ toolbar->max_height : toolbar->height
#endif
diff --git a/riscos/treeview.c b/riscos/treeview.c
index 805df40d8..8e9e057dc 100644
--- a/riscos/treeview.c
+++ b/riscos/treeview.c
@@ -121,6 +121,8 @@ void tree_redraw_area(struct tree *tree, int x, int y, int width, int height) {
assert(tree);
assert(tree->handle);
+ if (tree->toolbar)
+ y += ro_gui_theme_toolbar_height(tree->toolbar);
error = xwimp_force_redraw((wimp_w)tree->handle, tree->offset_x + x - 2,
-tree->offset_y - y - height, tree->offset_x + x + width + 4,
-tree->offset_y - y);
@@ -177,19 +179,24 @@ void tree_draw_line(struct tree *tree, int x, int y, int width, int height) {
void tree_draw_node_element(struct tree *tree, struct node_element *element) {
os_error *error;
int temp;
+ int toolbar_height = 0;
assert(tree);
assert(element);
assert(element->parent);
+
+ if (tree->toolbar)
+ toolbar_height = ro_gui_theme_toolbar_height(tree->toolbar);
+
ro_gui_tree_icon.flags = wimp_ICON_INDIRECTED | wimp_ICON_VCENTRED |
(wimp_COLOUR_VERY_LIGHT_GREY << wimp_ICON_BG_COLOUR_SHIFT);
ro_gui_tree_icon.extent.x0 = tree->offset_x + element->box.x;
- ro_gui_tree_icon.extent.y1 = -tree->offset_y - element->box.y;
+ ro_gui_tree_icon.extent.y1 = -tree->offset_y - element->box.y - toolbar_height;
ro_gui_tree_icon.extent.x1 = tree->offset_x + element->box.x +
element->box.width;
ro_gui_tree_icon.extent.y0 = -tree->offset_y - element->box.y -
- element->box.height;
+ element->box.height - toolbar_height;
if (&element->parent->data == element) {
if (element->parent->selected)
ro_gui_tree_icon.flags |= wimp_ICON_SELECTED;
@@ -319,6 +326,8 @@ void tree_initialise_redraw(struct tree *tree) {
ro_gui_tree_origin_x = state.visible.x0 - state.xscroll + tree->offset_x;
ro_gui_tree_origin_y = state.visible.y1 - state.yscroll - tree->offset_y;
+ if (tree->toolbar)
+ ro_gui_tree_origin_y -= ro_gui_theme_toolbar_height(tree->toolbar);
}
@@ -530,6 +539,7 @@ void tree_resized(struct tree *tree) {
void ro_gui_tree_redraw(wimp_draw *redraw, struct tree *tree) {
osbool more;
int clip_x0, clip_x1, clip_y0, clip_y1, origin_x, origin_y;
+
more = wimp_redraw_window(redraw);
while (more) {
@@ -539,6 +549,8 @@ void ro_gui_tree_redraw(wimp_draw *redraw, struct tree *tree) {
clip_y1 = redraw->clip.y1;
origin_x = redraw->box.x0 - redraw->xscroll;
origin_y = redraw->box.y1 - redraw->yscroll;
+ if (tree->toolbar)
+ origin_y -= ro_gui_theme_toolbar_height(tree->toolbar);
tree_draw(tree, clip_x0 - origin_x - tree->offset_x,
origin_y - clip_y1 - tree->offset_y,
clip_x1 - clip_x0, clip_y1 - clip_y0);
@@ -806,11 +818,10 @@ void ro_gui_tree_menu_closed(struct tree *tree) {
*
* \param pointer the pointer state
*/
-void ro_gui_tree_toolbar_click(wimp_pointer* pointer, struct tree *tree,
- struct toolbar *toolbar) {
+void ro_gui_tree_toolbar_click(wimp_pointer* pointer, struct tree *tree) {
struct node *node;
- current_toolbar = toolbar;
+ current_toolbar = tree->toolbar;
ro_gui_tree_stop_edit(tree);
switch (pointer->i) {
@@ -855,12 +866,15 @@ void ro_gui_tree_start_edit(struct tree *tree, struct node_element *element,
os_error *error;
wimp_window_state state;
struct node *parent;
+ int toolbar_height = 0;
assert(tree);
assert(element);
if (tree->editing)
ro_gui_tree_stop_edit(tree);
+ if (tree->toolbar)
+ toolbar_height = ro_gui_theme_toolbar_height(tree->toolbar);
parent = element->parent;
if (&parent->data == element)
@@ -879,8 +893,9 @@ void ro_gui_tree_start_edit(struct tree *tree, struct node_element *element,
ro_gui_tree_edit_icon.icon.extent.x0 = tree->offset_x + element->box.x - 2;
ro_gui_tree_edit_icon.icon.extent.x1 = tree->offset_x +
element->box.x + element->box.width + 2;
- ro_gui_tree_edit_icon.icon.extent.y1 = -tree->offset_y - element->box.y;
- ro_gui_tree_edit_icon.icon.extent.y0 = -tree->offset_y -
+ ro_gui_tree_edit_icon.icon.extent.y1 = -tree->offset_y - toolbar_height -
+ element->box.y;
+ ro_gui_tree_edit_icon.icon.extent.y0 = -tree->offset_y - toolbar_height -
element->box.y - element->box.height;
if (element->type == NODE_ELEMENT_TEXT_PLUS_SPRITE)
ro_gui_tree_edit_icon.icon.extent.x0 += NODE_INSTEP;
@@ -951,9 +966,13 @@ void ro_gui_tree_scroll_visible(struct tree *tree, struct node_element *element)
wimp_window_state state;
int x0, x1, y0, y1;
os_error *error;
+ int toolbar_height = 0;
assert(element);
+ if (tree->toolbar)
+ toolbar_height = ro_gui_theme_toolbar_height(tree->toolbar);
+
state.w = (wimp_w)tree->handle;
error = xwimp_get_window_state(&state);
if (error)
@@ -964,16 +983,17 @@ void ro_gui_tree_scroll_visible(struct tree *tree, struct node_element *element)
x0 = state.xscroll;
y0 = -state.yscroll;
x1 = x0 + state.visible.x1 - state.visible.x0 - tree->offset_x;
- y1 = y0 - state.visible.y0 + state.visible.y1 - tree->offset_y;
+ y1 = y0 - state.visible.y0 + state.visible.y1 - tree->offset_y - toolbar_height;
- state.yscroll = state.visible.y1 - state.visible.y0 - tree->offset_y - y1;
+ state.yscroll = state.visible.y1 - state.visible.y0 - tree->offset_y -
+ toolbar_height - y1;
if ((element->box.y >= y0) && (element->box.y + element->box.height <= y1))
return;
if (element->box.y < y0)
state.yscroll = -element->box.y;
if (element->box.y + element->box.height > y1)
state.yscroll = state.visible.y1 - state.visible.y0 -
- tree->offset_y -
+ tree->offset_y - toolbar_height -
(element->box.y + element->box.height);
ro_gui_tree_open((wimp_open *)&state, tree);
}
@@ -982,16 +1002,18 @@ void ro_gui_tree_scroll_visible(struct tree *tree, struct node_element *element)
/**
* Shows the a tree window.
*/
-void ro_gui_tree_show(struct tree *tree, struct toolbar *toolbar) {
+void ro_gui_tree_show(struct tree *tree) {
os_error *error;
int screen_width, screen_height;
wimp_window_state state;
int dimension;
int scroll_width;
+ struct toolbar *toolbar;
/* We may have failed to initialise
*/
if (!tree) return;
+ toolbar = tree->toolbar;
/* Get the window state
*/
@@ -1033,7 +1055,7 @@ void ro_gui_tree_show(struct tree *tree, struct toolbar *toolbar) {
state.xscroll = 0;
state.yscroll = 0;
if (toolbar)
- state.yscroll = toolbar->height;
+ state.yscroll = ro_gui_theme_toolbar_height(toolbar);
}
/* Open the window at the top of the stack
@@ -1057,13 +1079,19 @@ void ro_gui_tree_open(wimp_open *open, struct tree *tree) {
os_error *error;
int width;
int height;
+ int toolbar_height = 0;
+
+ if (!tree)
+ return;
+ if (tree->toolbar)
+ toolbar_height = ro_gui_theme_toolbar_height(tree->toolbar);
width = open->visible.x1 - open->visible.x0;
if (width < (tree->offset_x + tree->width))
width = tree->offset_x + tree->width;
height = open->visible.y1 - open->visible.y0;
- if (height < (tree->offset_y + tree->height))
- height = tree->offset_y + tree->height;
+ if (height < (tree->offset_y + toolbar_height + tree->height))
+ height = tree->offset_y + toolbar_height + tree->height;
if ((height != tree->window_height) || (width != tree->window_width)) {
os_box extent = { 0, -height, width, 0};
@@ -1083,6 +1111,9 @@ void ro_gui_tree_open(wimp_open *open, struct tree *tree) {
error->errnum, error->errmess));
warn_user("WimpError", error->errmess);
}
+ if (tree->toolbar)
+ ro_gui_theme_process_toolbar(tree->toolbar, -1);
+
}
@@ -1159,6 +1190,11 @@ void ro_gui_tree_selection_drag_end(wimp_dragged *drag) {
wimp_auto_scroll_info scroll;
os_error *error;
int x0, y0, x1, y1;
+ int toolbar_height = 0;
+
+ if (ro_gui_tree_current_drag_tree->toolbar)
+ toolbar_height = ro_gui_theme_toolbar_height(
+ ro_gui_tree_current_drag_tree->toolbar);
scroll.w = (wimp_w)ro_gui_tree_current_drag_tree->handle;
error = xwimp_auto_scroll(0, &scroll, 0);
@@ -1177,11 +1213,11 @@ void ro_gui_tree_selection_drag_end(wimp_dragged *drag) {
x0 = drag->final.x0 - state.visible.x0 - state.xscroll +
ro_gui_tree_current_drag_tree->offset_x;
y0 = state.visible.y1 - state.yscroll - drag->final.y0 -
- ro_gui_tree_current_drag_tree->offset_y;
+ ro_gui_tree_current_drag_tree->offset_y - toolbar_height;
x1 = drag->final.x1 - state.visible.x0 - state.xscroll +
ro_gui_tree_current_drag_tree->offset_x;
y1 = state.visible.y1 - state.yscroll - drag->final.y1 -
- ro_gui_tree_current_drag_tree->offset_y;
+ ro_gui_tree_current_drag_tree->offset_y - toolbar_height;
tree_handle_selection_area(ro_gui_tree_current_drag_tree, x0, y0,
x1 - x0, y1 - y0,
(ro_gui_tree_current_drag_buttons == (wimp_CLICK_ADJUST << 4)));
@@ -1220,6 +1256,8 @@ void ro_gui_tree_get_tree_coordinates(struct tree *tree, int x, int y,
}
*tree_x = x - state.visible.x0 - state.xscroll + tree->offset_x;
*tree_y = state.visible.y1 - state.yscroll - y - tree->offset_y;
+ if (tree->toolbar)
+ *tree_y -= ro_gui_theme_toolbar_height(tree->toolbar);
}
diff --git a/riscos/treeview.h b/riscos/treeview.h
index a3631de04..053709f66 100644
--- a/riscos/treeview.h
+++ b/riscos/treeview.h
@@ -30,11 +30,10 @@ bool ro_gui_tree_initialise(void);
void ro_gui_tree_redraw(wimp_draw *redraw, struct tree *tree);
bool ro_gui_tree_click(wimp_pointer *pointer, struct tree *tree);
void ro_gui_tree_menu_closed(struct tree *tree);
-void ro_gui_tree_toolbar_click(wimp_pointer* pointer, struct tree *tree,
- struct toolbar *toolbar);
+void ro_gui_tree_toolbar_click(wimp_pointer* pointer, struct tree *tree);
void ro_gui_tree_stop_edit(struct tree *tree);
void ro_gui_tree_open(wimp_open *open, struct tree *tree);
-void ro_gui_tree_show(struct tree *tree, struct toolbar *toolbar);
+void ro_gui_tree_show(struct tree *tree);
bool ro_gui_tree_keypress(int key, struct tree *tree);
void ro_gui_tree_selection_drag_end(wimp_dragged *drag);
void ro_gui_tree_move_drag_end(wimp_dragged *drag);
diff --git a/riscos/window.c b/riscos/window.c
index 90ef2df42..60a65572c 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -205,8 +205,8 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
window.work_flags = wimp_BUTTON_CLICK_DRAG <<
wimp_ICON_BUTTON_TYPE_SHIFT;
window.sprite_area = wimpspriteop_AREA;
- window.xmin = 100;
- window.ymin = 100;
+ window.xmin = 1;
+ window.ymin = 1;
window.title_data.indirected_text.text = g->title;
window.title_data.indirected_text.validation = (char *) -1;
window.title_data.indirected_text.size = 255;
@@ -882,45 +882,39 @@ void ro_gui_window_update_theme(void) {
struct gui_window *g;
for (g = window_list; g; g = g->next) {
if (g->toolbar) {
- height = g->toolbar->height;
+ height = ro_gui_theme_toolbar_height(g->toolbar);
if (!ro_gui_theme_update_toolbar(NULL, g->toolbar)) {
ro_gui_theme_destroy_toolbar(g->toolbar);
g->toolbar = NULL;
if (height != 0)
ro_gui_window_update_dimensions(g, height);
} else {
- if (height != g->toolbar->height)
+ if (height != (ro_gui_theme_toolbar_height(g->toolbar)))
ro_gui_window_update_dimensions(g, height -
- g->toolbar->height);
+ ro_gui_theme_toolbar_height(g->toolbar));
}
ro_gui_prepare_navigate(g);
}
}
- if (hotlist_toolbar) {
- if (!ro_gui_theme_update_toolbar(NULL, hotlist_toolbar)) {
- ro_gui_theme_destroy_toolbar(hotlist_toolbar);
- hotlist_toolbar = NULL;
- }
- if (hotlist_tree) {
- ro_gui_theme_attach_toolbar(hotlist_toolbar,
- (wimp_w)hotlist_tree->handle);
- hotlist_tree->offset_y = hotlist_toolbar->height;
- xwimp_force_redraw((wimp_w)hotlist_tree->handle,
- 0, -16384, 16384, 16384);
+ if ((hotlist_tree) && (hotlist_tree->toolbar)) {
+ if (!ro_gui_theme_update_toolbar(NULL, hotlist_tree->toolbar)) {
+ ro_gui_theme_destroy_toolbar(hotlist_tree->toolbar);
+ hotlist_tree->toolbar = NULL;
}
+ ro_gui_theme_attach_toolbar(hotlist_tree->toolbar,
+ (wimp_w)hotlist_tree->handle);
+ xwimp_force_redraw((wimp_w)hotlist_tree->handle,
+ 0, -16384, 16384, 16384);
}
- if (global_history_toolbar) {
- if (!ro_gui_theme_update_toolbar(NULL, global_history_toolbar)) {
- ro_gui_theme_destroy_toolbar(global_history_toolbar);
- global_history_toolbar = NULL;
- }
- if (global_history_tree) {
- ro_gui_theme_attach_toolbar(global_history_toolbar,
- (wimp_w)global_history_tree->handle);
- global_history_tree->offset_y = global_history_toolbar->height;
- xwimp_force_redraw((wimp_w)global_history_tree->handle,
- 0, -16384, 16384, 16384);
+ if ((global_history_tree) && (global_history_tree->toolbar)) {
+ if (!ro_gui_theme_update_toolbar(NULL, global_history_tree->toolbar)) {
+ ro_gui_theme_destroy_toolbar(global_history_tree->toolbar);
+ global_history_tree->toolbar = NULL;
}
+ ro_gui_theme_attach_toolbar(global_history_tree->toolbar,
+ (wimp_w)global_history_tree->handle);
+ xwimp_force_redraw((wimp_w)global_history_tree->handle,
+ 0, -16384, 16384, 16384);
}
}
@@ -1558,6 +1552,7 @@ bool ro_gui_window_keypress(struct gui_window *g, int key, bool toolbar)
return true;
case wimp_KEY_CONTROL + wimp_KEY_F2: /* Close window. */
+ ro_gui_url_complete_close(NULL, 0);
browser_window_destroy(g->bw);
return true;
@@ -1657,7 +1652,7 @@ bool ro_gui_window_keypress(struct gui_window *g, int key, bool toolbar)
return true;
case wimp_KEY_ESCAPE:
- if (ro_gui_url_complete_close(0, 0)) {
+ if (ro_gui_url_complete_close(NULL, 0)) {
ro_gui_url_complete_start(g);
return true;
}
@@ -1727,7 +1722,8 @@ bool ro_gui_window_keypress(struct gui_window *g, int key, bool toolbar)
state.w = g->window;
wimp_get_window_state(&state);
y = state.visible.y1 - state.visible.y0 - 32;
- y -= g->toolbar->height;
+ if (g->toolbar)
+ y -= g->toolbar->height;
switch (key) {
case wimp_KEY_UP:
@@ -1768,7 +1764,8 @@ void ro_gui_scroll_request(wimp_scroll *scroll)
x = scroll->visible.x1 - scroll->visible.x0 - 32;
y = scroll->visible.y1 - scroll->visible.y0 - 32;
- y -= g->toolbar->height;
+ if (g->toolbar)
+ y -= g->toolbar->height;
switch (scroll->xmin) {
case wimp_SCROLL_PAGE_LEFT: