From ba197f29c7e4784a6d649b262d3951e5e7fef41b Mon Sep 17 00:00:00 2001 From: Steve Fryatt Date: Sun, 24 Oct 2010 20:00:45 +0000 Subject: Partially re-enable toolbar buttons in RO treeview windows. svn path=/trunk/netsurf/; revision=10906 --- riscos/cookies.c | 47 +++++++++++++++++++++++++++++++++++++ riscos/cookies.h | 1 + riscos/global_history.c | 53 ++++++++++++++++++++++++++++++++++++++++++ riscos/global_history.h | 1 + riscos/hotlist.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ riscos/hotlist.h | 1 + riscos/theme.c | 8 ++++++- riscos/treeview.c | 37 ----------------------------- riscos/treeview.h | 1 - 9 files changed, 172 insertions(+), 39 deletions(-) (limited to 'riscos') diff --git a/riscos/cookies.c b/riscos/cookies.c index b0c035adc..e19a1a2fa 100644 --- a/riscos/cookies.c +++ b/riscos/cookies.c @@ -150,6 +150,53 @@ void ro_gui_cookies_open(void) } } + +/** + * Handle Mouse Click events on the toolbar. + * + * \param *pointer Pointer to the Mouse Click Event block. + * \return Return true if click handled; else false. + */ + +bool ro_gui_cookies_toolbar_click(wimp_pointer *pointer) +{ + switch (pointer->i) { + case ICON_TOOLBAR_DELETE: + if (pointer->buttons == wimp_CLICK_SELECT) { + cookies_delete_selected(); + return true; + } + 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; + } + 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; + } + break; + } + + /* \todo -- 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. + */ + + if (pointer->buttons == wimp_CLICK_MENU) + return ro_gui_wimp_event_process_window_menu_click(pointer); + + return false; +} + /** * Prepare the cookies menu for opening * diff --git a/riscos/cookies.h b/riscos/cookies.h index 3539ed9a0..8c9c14925 100644 --- a/riscos/cookies.h +++ b/riscos/cookies.h @@ -28,6 +28,7 @@ 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_open(void); void ro_gui_cookies_update_theme(void); diff --git a/riscos/global_history.c b/riscos/global_history.c index e9f5ea6ad..44d39b93a 100644 --- a/riscos/global_history.c +++ b/riscos/global_history.c @@ -158,6 +158,59 @@ void ro_gui_global_history_open(void) } } +/** + * Handle Mouse Click events on the toolbar. + * + * \param *pointer Pointer to the Mouse Click Event block. + * \return Return true if click handled; else false. + */ + +bool ro_gui_global_history_toolbar_click(wimp_pointer *pointer) +{ + switch (pointer->i) { + case ICON_TOOLBAR_DELETE: + if (pointer->buttons == wimp_CLICK_SELECT) { + history_global_delete_selected(); + return true; + } + 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; + } + 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; + } + break; + case ICON_TOOLBAR_LAUNCH: + if (pointer->buttons == wimp_CLICK_SELECT) { + history_global_launch_selected(); + return true; + } + break; + } + + /* \todo -- 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. + */ + + if (pointer->buttons == wimp_CLICK_MENU) + return ro_gui_wimp_event_process_window_menu_click(pointer); + + return true; +} + + /** * Prepare the global history menu for opening * diff --git a/riscos/global_history.h b/riscos/global_history.h index 951836d5d..7ca2ed9da 100644 --- a/riscos/global_history.h +++ b/riscos/global_history.h @@ -31,6 +31,7 @@ void ro_gui_global_history_save(void); void ro_gui_global_history_update_theme(void); 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); #endif diff --git a/riscos/hotlist.c b/riscos/hotlist.c index 6e2d176cc..aed66532a 100644 --- a/riscos/hotlist.c +++ b/riscos/hotlist.c @@ -172,6 +172,68 @@ void ro_gui_hotlist_open(void) } } +/** + * Handle Mouse Click events on the toolbar. + * + * \param *pointer Pointer to the Mouse Click Event block. + * \return Return true if click handled; else false. + */ + +bool ro_gui_hotlist_toolbar_click(wimp_pointer *pointer) +{ + LOG(("Entering hotlist toolbar handler: b=%d, i=%d", pointer->buttons, pointer->i)); + + switch (pointer->i) { + case ICON_TOOLBAR_DELETE: + if (pointer->buttons == wimp_CLICK_SELECT) { + hotlist_delete_selected(); + return true; + } + 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; + } + 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; + } + break; + case ICON_TOOLBAR_LAUNCH: + if (pointer->buttons == wimp_CLICK_SELECT) { + hotlist_launch_selected(); + return true; + } + break; + case ICON_TOOLBAR_CREATE: + if (pointer->buttons == wimp_CLICK_SELECT) { + hotlist_add_folder(); + return true; + } + break; + } + + + /* \todo -- 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. + */ + + if (pointer->buttons == wimp_CLICK_MENU) + return ro_gui_wimp_event_process_window_menu_click(pointer); + + return true; +} + + /** * Prepare the hotlist menu for opening * diff --git a/riscos/hotlist.h b/riscos/hotlist.h index e416b2124..346f14fe9 100644 --- a/riscos/hotlist.h +++ b/riscos/hotlist.h @@ -31,6 +31,7 @@ void ro_gui_hotlist_save(void); void ro_gui_hotlist_update_theme(void); 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); #endif diff --git a/riscos/theme.c b/riscos/theme.c index 3f142cdd3..b5c5d8eb5 100644 --- a/riscos/theme.c +++ b/riscos/theme.c @@ -949,12 +949,18 @@ bool ro_gui_theme_update_toolbar(struct theme_descriptor *descriptor, break; case THEME_HOTLIST_TOOLBAR: case THEME_HOTLIST_EDIT_TOOLBAR: + ro_gui_wimp_event_register_mouse_click(toolbar->toolbar_handle, + ro_gui_hotlist_toolbar_click); + break; case THEME_HISTORY_TOOLBAR: case THEME_HISTORY_EDIT_TOOLBAR: + ro_gui_wimp_event_register_mouse_click(toolbar->toolbar_handle, + ro_gui_global_history_toolbar_click); + break; case THEME_COOKIES_TOOLBAR: case THEME_COOKIES_EDIT_TOOLBAR: ro_gui_wimp_event_register_mouse_click(toolbar->toolbar_handle, - ro_gui_treeview_toolbar_click); + ro_gui_cookies_toolbar_click); break; default: break; diff --git a/riscos/treeview.c b/riscos/treeview.c index c992fdda7..27e014cac 100644 --- a/riscos/treeview.c +++ b/riscos/treeview.c @@ -172,8 +172,6 @@ ro_treeview *ro_treeview_create(wimp_w window, struct toolbar *toolbar, ro_gui_wimp_event_register_keypress(tv->w, ro_treeview_keypress); ro_gui_wimp_event_set_user_data(tv->w, tv); - /* \todo Register wimp events to handle the supplied toolbar? */ - return tv; } @@ -915,41 +913,6 @@ static bool ro_treeview_keypress(wimp_key *key) return false; } -/** Respond to a mouse click on a treeview toolbar. - * - * \param pointer Pointer to the MouseClick Event block. - * \return true if the event was handled; else false. - */ - -bool ro_gui_treeview_toolbar_click(wimp_pointer *pointer) -{ - struct toolbar *tb; - ro_treeview *tv; - - tb = (struct toolbar *) ro_gui_wimp_event_get_user_data(pointer->w); - if (tb == NULL) { - LOG(("NULL toolbar block for window: 0x%x", - (unsigned int) pointer->w)); - return false; - } - - tv = (ro_treeview *) ro_gui_wimp_event_get_user_data(tb->parent_handle); - if (tv == NULL) { - LOG(("NULL treeview block for parent window: 0x%x", - (unsigned int) tb->parent_handle)); - return false; - } - - /* \todo -- Handle menu clicks here... */ - - /* \todo -- Deal with the editor here... */ - - switch (pointer->i) { - - } - - return true; -} /** * Update a treeview to use a new theme. diff --git a/riscos/treeview.h b/riscos/treeview.h index 7aa129e1b..be0a3478e 100644 --- a/riscos/treeview.h +++ b/riscos/treeview.h @@ -46,7 +46,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_w w, wimp_pointer *pointer); -bool ro_gui_treeview_toolbar_click(wimp_pointer *pointer); void ro_treeview_update_theme(ro_treeview *tv); int ro_treeview_get_help(help_full_message_request *message_data); -- cgit v1.2.3