From 6e3995cc6552f7ca4c97d330b89ee27ac84191b0 Mon Sep 17 00:00:00 2001 From: Richard Wilson Date: Sun, 11 Jul 2004 21:45:51 +0000 Subject: [project @ 2004-07-11 21:45:51 by rjw] Inversion of hotlist icon functionality. Automatic placement of caret for dialog windows. Escape closes dialog windows. svn path=/import/netsurf/; revision=1071 --- riscos/dialog.c | 14 ++++++++++++++ riscos/wimp.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ riscos/wimp.h | 1 + riscos/window.c | 2 +- 4 files changed, 63 insertions(+), 1 deletion(-) (limited to 'riscos') diff --git a/riscos/dialog.c b/riscos/dialog.c index 208850c0d..aaeed4e89 100644 --- a/riscos/dialog.c +++ b/riscos/dialog.c @@ -214,6 +214,10 @@ void ro_gui_dialog_open(wimp_w w) open.visible.y1 = screen_y + dy; open.next = wimp_TOP; wimp_open_window((wimp_open *) &open); + + /* Set the caret position + */ + ro_gui_set_caret_first(w); } @@ -252,6 +256,10 @@ void ro_gui_dialog_open_persistant(wimp_w parent, wimp_w w) { open.next = wimp_TOP; wimp_open_window((wimp_open *) &open); + /* Set the caret position + */ + ro_gui_set_caret_first(w); + /* Add a mapping */ if (parent == NULL) return; @@ -295,6 +303,12 @@ void ro_gui_dialog_close_persistant(wimp_w parent) { bool ro_gui_dialog_keypress(wimp_key *key) { + + if (key->c == wimp_KEY_ESCAPE) { + ro_gui_dialog_close(key->w); + return true; + } + #ifdef WITH_AUTH if (key->w == dialog_401li) return ro_gui_401login_keypress(key); diff --git a/riscos/wimp.c b/riscos/wimp.c index 40f26f686..e125a0419 100644 --- a/riscos/wimp.c +++ b/riscos/wimp.c @@ -270,6 +270,53 @@ void ro_gui_set_window_title(wimp_w w, const char *text) { } +/** + * Places the caret in the first available icon + */ +void ro_gui_set_caret_first(wimp_w w) { + int icon, button; + wimp_window_info_base window; + wimp_icon_state state; + os_error *error; + + /* Get the window details + */ + window.w = w; + error = xwimp_get_window_info_header_only((wimp_window_info *)&window); + if (error) { + LOG(("xwimp_get_window_info: 0x%x: %s", + error->errnum, error->errmess)); + warn_user("WimpError", error->errmess); + return; + } + + /* Work through our icons + */ + state.w = w; + for (icon = 0; icon < window.icon_count; icon++) { + /* Get the icon state + */ + state.i = icon; + error = xwimp_get_icon_state(&state); + if (error) { + LOG(("xwimp_get_window_info: 0x%x: %s", + error->errnum, error->errmess)); + warn_user("WimpError", error->errmess); + return; + } + + /* Check if it's writable + */ + button = (state.icon.flags >> wimp_ICON_BUTTON_TYPE_SHIFT) & 0xf; + if ((button == wimp_BUTTON_WRITE_CLICK_DRAG) || + (button == wimp_BUTTON_WRITABLE)) { + xwimp_set_caret_position(w, icon, 0, 0, -1, strlen(state.icon.data.indirected_text.text)); + return; + } + } +} + + /** * Load a sprite file into memory. * diff --git a/riscos/wimp.h b/riscos/wimp.h index 4936d1e42..4680f0d74 100644 --- a/riscos/wimp.h +++ b/riscos/wimp.h @@ -40,6 +40,7 @@ void ro_gui_set_icon_integer(wimp_w w, wimp_i i, int value); int ro_gui_get_icon_selected_state(wimp_w w, wimp_i i); #define ro_gui_set_icon_shaded_state(w, i, state) xwimp_set_icon_state(w, i, (state ? wimp_ICON_SHADED : 0), wimp_ICON_SHADED) void ro_gui_set_window_title(wimp_w w, const char *title); +void ro_gui_set_caret_first(wimp_w w); osspriteop_area *ro_gui_load_sprite_file(const char *pathname); bool ro_gui_wimp_sprite_exists(const char *sprite); diff --git a/riscos/window.c b/riscos/window.c index 7e3bbae24..e9d5329a3 100644 --- a/riscos/window.c +++ b/riscos/window.c @@ -739,7 +739,7 @@ void ro_gui_toolbar_click(gui_window* g, wimp_pointer* pointer) { pointer->pos.x, pointer->pos.y); break; case ICON_TOOLBAR_BOOKMARK: - if (pointer->buttons == wimp_CLICK_SELECT) { + if (pointer->buttons == wimp_CLICK_ADJUST) { ro_gui_hotlist_add(g->title, g->data.browser.bw->current_content); } else { ro_gui_hotlist_show(); -- cgit v1.2.3