From 9d305e4ec0e621ac76adbed65780aa5ea73a0dd9 Mon Sep 17 00:00:00 2001 From: Richard Wilson Date: Sun, 23 May 2004 12:22:05 +0000 Subject: [project @ 2004-05-23 12:22:05 by rjw] Improved style guide compliance and (incomplete) option to save window starting characteristics. svn path=/import/netsurf/; revision=891 --- riscos/menus.c | 28 ++++++++++++++++++++++------ riscos/options.h | 22 +++++++++++++++++++++- riscos/wimp.c | 21 ++++++++++++++++++++- riscos/wimp.h | 1 + riscos/window.c | 23 ++++++++++++++--------- 5 files changed, 78 insertions(+), 17 deletions(-) (limited to 'riscos') diff --git a/riscos/menus.c b/riscos/menus.c index a756451b5..76207efad 100644 --- a/riscos/menus.c +++ b/riscos/menus.c @@ -186,15 +186,27 @@ static wimp_MENU(4) toolbar_menu = { }; +/* Window submenu +*/ +static wimp_MENU(2) window_menu = { + { "Window" }, 7,2,7,0, 300, 44, 0, + { + { 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS | wimp_ICON_SHADED, { "WindowSave" } }, + { wimp_MENU_LAST, wimp_NO_SUB_MENU, DEFAULT_FLAGS | wimp_ICON_SHADED, { "WindowReset" } } + } +}; + + /* View submenu */ -static wimp_MENU(4) view_menu = { +static wimp_MENU(5) view_menu = { { "View" }, 7,2,7,0, 300, 44, 0, { - { wimp_MENU_GIVE_WARNING, (wimp_menu *)1, DEFAULT_FLAGS, { "ScaleView" } }, - { wimp_MENU_GIVE_WARNING, (wimp_menu *)&image_menu, DEFAULT_FLAGS, { "Images" } }, - { wimp_MENU_SEPARATE | wimp_MENU_GIVE_WARNING, (wimp_menu *)&toolbar_menu, DEFAULT_FLAGS, { "Toolbars" } }, - { wimp_MENU_LAST, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "OptDefault" } } + { wimp_MENU_GIVE_WARNING, (wimp_menu *)1, DEFAULT_FLAGS, { "ScaleView" } }, + { wimp_MENU_GIVE_WARNING, (wimp_menu *)&image_menu, DEFAULT_FLAGS, { "Images" } }, + { wimp_MENU_GIVE_WARNING, (wimp_menu *)&toolbar_menu, DEFAULT_FLAGS, { "Toolbars" } }, + { wimp_MENU_SEPARATE, (wimp_menu *)&window_menu, DEFAULT_FLAGS | wimp_ICON_SHADED, { "Window" } }, + { wimp_MENU_LAST, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "OptDefault" } } } }; @@ -263,6 +275,7 @@ static wimp_menu *browser_navigate_menu = (wimp_menu *)&navigate_menu; static wimp_menu *browser_view_menu = (wimp_menu *)&view_menu; static wimp_menu *browser_image_menu = (wimp_menu *)&image_menu; static wimp_menu *browser_toolbar_menu = (wimp_menu *)&toolbar_menu; +static wimp_menu *browser_window_menu = (wimp_menu *)&window_menu; static wimp_menu *browser_utilities_menu = (wimp_menu *)&utilities_menu; static wimp_menu *browser_hotlist_menu = (wimp_menu *)&hotlist_menu; static wimp_menu *browser_help_menu = (wimp_menu *)&help_menu; @@ -286,6 +299,7 @@ void ro_gui_menus_init(void) translate_menu(browser_view_menu); translate_menu(browser_image_menu); translate_menu(browser_toolbar_menu); + translate_menu(browser_window_menu); translate_menu(browser_utilities_menu); translate_menu(browser_hotlist_menu); translate_menu(browser_help_menu); @@ -531,7 +545,9 @@ void ro_gui_menu_selection(wimp_selection *selection) } ro_gui_menu_prepare_toolbars(); break; - case 3: /* Make default */ + case 3: /* Window -> */ + break; + case 4: /* Make default */ gui_window_default_options(current_gui->data.browser.bw); break; } diff --git a/riscos/options.h b/riscos/options.h index 095a799c8..3dfb44d4d 100644 --- a/riscos/options.h +++ b/riscos/options.h @@ -4,6 +4,7 @@ * http://www.opensource.org/licenses/gpl-license * Copyright 2003 Phil Mellor * Copyright 2004 James Bursa + * Copyright 2004 Richard Wilson */ /** \file @@ -32,6 +33,13 @@ extern bool option_toolbar_show_buttons; extern bool option_toolbar_show_address; extern bool option_toolbar_show_throbber; extern bool option_animate_images; +extern int option_window_x; +extern int option_window_y; +extern int option_window_width; +extern int option_window_height; +extern int option_window_screen_width; +extern int option_window_screen_height; + #define EXTRA_OPTION_DEFINE \ bool option_use_mouse_gestures = false;\ @@ -51,6 +59,12 @@ bool option_toolbar_show_buttons = true; \ bool option_toolbar_show_address = true; \ bool option_toolbar_show_throbber = true; \ bool option_animate_images = true; +int option_window_x = 0; +int option_window_y = 0; +int option_window_width = 0; +int option_window_height = 0; +int option_window_screen_width = 0; +int option_window_screen_height = 0; #define EXTRA_OPTION_TABLE \ { "use_mouse_gestures", OPTION_BOOL, &option_use_mouse_gestures },\ @@ -69,6 +83,12 @@ bool option_animate_images = true; { "toolbar_show_buttons", OPTION_BOOL, &option_toolbar_show_buttons }, \ { "toolbar_show_address", OPTION_BOOL, &option_toolbar_show_address }, \ { "toolbar_show_throbber", OPTION_BOOL, &option_toolbar_show_throbber }, \ -{ "animate_images", OPTION_BOOL, &option_animate_images } +{ "animate_images", OPTION_BOOL, &option_animate_images }, \ +{ "window_x", OPTION_INTEGER, &option_window_x }, \ +{ "window_y", OPTION_INTEGER, &option_window_y }, \ +{ "window_width", OPTION_INTEGER, &option_window_width }, \ +{ "window_height", OPTION_INTEGER, &option_window_height }, \ +{ "window_screen_width", OPTION_INTEGER, &option_window_screen_width }, \ +{ "window_screen_height", OPTION_INTEGER, &option_window_screen_height } #endif diff --git a/riscos/wimp.c b/riscos/wimp.c index 5cfc2728d..b5f16e69b 100644 --- a/riscos/wimp.c +++ b/riscos/wimp.c @@ -26,13 +26,13 @@ */ static wimpextend_furniture_sizes furniture_sizes; + /** * Gets the default horzontal scrollbar height */ int ro_get_hscroll_height(wimp_w w) { wimp_version_no version; - /* Read the hscroll height */ furniture_sizes.w = w; @@ -54,6 +54,25 @@ int ro_get_hscroll_height(wimp_w w) { return furniture_sizes.border_widths.y0; } + +/** + * Gets the default horzontal scrollbar height + */ +int ro_get_vscroll_width(wimp_w w) { + wimp_version_no version; + + /* Read the hscroll height + */ + furniture_sizes.w = w; + furniture_sizes.border_widths.x1 = 38; + xwimpextend_get_furniture_sizes(&furniture_sizes); + + /* Return the standard (unhacked) size + */ + return furniture_sizes.border_widths.x1; +} + + /** * Reads a modes EIG factors. * diff --git a/riscos/wimp.h b/riscos/wimp.h index 3ac3ed4c4..f759e0487 100644 --- a/riscos/wimp.h +++ b/riscos/wimp.h @@ -27,6 +27,7 @@ struct eig_factors { int ro_get_hscroll_height(wimp_w w); +int ro_get_vscroll_width(wimp_w w); struct eig_factors ro_read_eig_factors(os_mode mode); void ro_convert_os_units_to_pixels(os_coord *os_units, os_mode mode); void ro_convert_pixels_to_os_units(os_coord *pixels, os_mode mode); diff --git a/riscos/window.c b/riscos/window.c index 53f87e1fc..8a3bcbb57 100644 --- a/riscos/window.c +++ b/riscos/window.c @@ -63,22 +63,23 @@ bool gui_window_in_list(gui_window *g) { gui_window *gui_create_browser_window(struct browser_window *bw, struct browser_window *clone) { - int screen_width, screen_height, win_width, win_height; + int screen_width, screen_height, win_width, win_height, scroll_width; wimp_window window; wimp_window_state state; - gui_window* g = (gui_window*) xcalloc(1, sizeof(gui_window)); + gui_window* g = (gui_window*)calloc(1, sizeof(gui_window)); + if (!g) return NULL; g->type = GUI_BROWSER_WINDOW; g->data.browser.bw = bw; ro_gui_screen_size(&screen_width, &screen_height); - win_width = screen_width * 3 / 4; + win_width = screen_width * 5 / 8; if (1600 < win_width) win_width = 1600; - win_height = win_width * 3 / 4; + win_height = win_width * 5 / 8; - window.visible.x0 = ((screen_width - win_width) / 2) + (48 * (window_count%5)); + window.visible.x0 = (screen_width - win_width) / 2; window.visible.y0 = ((screen_height - win_height) / 2) - (48 * (window_count%5)); window.visible.x1 = window.visible.x0 + win_width; window.visible.y1 = window.visible.y0 + win_height; @@ -131,10 +132,14 @@ gui_window *gui_create_browser_window(struct browser_window *bw, struct browser_ bw->window = g; gui_window_clone_options(bw, clone); - state.w = g->window; - wimp_get_window_state(&state); - state.next = wimp_TOP; - ro_gui_window_open(g, (wimp_open*)&state); + /* Open the window + */ + state.w = g->window; + wimp_get_window_state(&state); + scroll_width = ro_get_vscroll_width(g->window); + state.visible.x0 -= scroll_width; + state.next = wimp_TOP; + ro_gui_window_open(g, (wimp_open*)&state); /* Set the caret position to the URL bar */ -- cgit v1.2.3