From 765c02622b23acbfdf0ec426e1e9d5beb2158680 Mon Sep 17 00:00:00 2001 From: James Bursa Date: Fri, 13 Feb 2004 23:07:42 +0000 Subject: [project @ 2004-02-13 23:07:42 by bursa] Add font size configuration and fix proxy options bug. svn path=/import/netsurf/; revision=538 --- riscos/dialog.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- riscos/font.c | 11 ++++++++--- riscos/gui.h | 6 ++++++ riscos/options.h | 12 ++++++------ 4 files changed, 74 insertions(+), 10 deletions(-) (limited to 'riscos') diff --git a/riscos/dialog.c b/riscos/dialog.c index 6f6cf46d2..561f27d70 100644 --- a/riscos/dialog.c +++ b/riscos/dialog.c @@ -32,9 +32,13 @@ wimp_w dialog_info, dialog_saveas, dialog_config, dialog_config_br, ; wimp_menu* theme_menu = NULL; +static int font_size; +static int font_min_size; + static void ro_gui_dialog_click_config(wimp_pointer *pointer); static void ro_gui_dialog_click_config_br(wimp_pointer *pointer); +static void ro_gui_dialog_update_config_br(void); static void ro_gui_dialog_click_config_prox(wimp_pointer *pointer); static void ro_gui_dialog_click_config_th(wimp_pointer *pointer); static void set_browser_choices(void); @@ -248,10 +252,54 @@ void ro_gui_dialog_click_config_br(wimp_pointer *pointer) gui_window_show(bw->window); browser_window_open_location(bw, GESTURES_URL); break; + case ICON_CONFIG_BR_FONTSIZE_DEC: + if (font_size == 50) + break; + font_size--; + if (font_size < font_min_size) + font_min_size = font_size; + ro_gui_dialog_update_config_br(); + break; + case ICON_CONFIG_BR_FONTSIZE_INC: + if (font_size == 1000) + break; + font_size++; + ro_gui_dialog_update_config_br(); + break; + case ICON_CONFIG_BR_MINSIZE_DEC: + if (font_min_size == 10) + break; + font_min_size--; + ro_gui_dialog_update_config_br(); + break; + case ICON_CONFIG_BR_MINSIZE_INC: + if (font_min_size == 500) + break; + font_min_size++; + if (font_size < font_min_size) + font_size = font_min_size; + ro_gui_dialog_update_config_br(); + break; } } +/** + * Update font size icons in browser choices dialog. + */ + +void ro_gui_dialog_update_config_br(void) +{ + char s[10]; + sprintf(s, "%i.%ipt", font_size / 10, font_size % 10); + set_icon_string(dialog_config_br, ICON_CONFIG_BR_FONTSIZE, s); + sprintf(s, "%i.%ipt", font_min_size / 10, font_min_size % 10); + set_icon_string(dialog_config_br, ICON_CONFIG_BR_MINSIZE, s); + wimp_set_icon_state(dialog_config_br, ICON_CONFIG_BR_FONTSIZE, 0, 0); + wimp_set_icon_state(dialog_config_br, ICON_CONFIG_BR_MINSIZE, 0, 0); +} + + /** * Handle clicks in the Proxy Choices dialog. */ @@ -335,6 +383,9 @@ void set_browser_choices(void) option_allow_text_selection); set_icon_state(dialog_config_br, ICON_CONFIG_BR_TOOLBAR, option_show_toolbar); + font_size = option_font_size; + font_min_size = option_font_min_size; + ro_gui_dialog_update_config_br(); } @@ -350,6 +401,8 @@ void get_browser_choices(void) ICON_CONFIG_BR_TEXT); option_show_toolbar = get_icon_state(dialog_config_br, ICON_CONFIG_BR_TOOLBAR); + option_font_size = font_size; + option_font_min_size = font_min_size; } @@ -362,7 +415,7 @@ void set_proxy_choices(void) set_icon_state(dialog_config_prox, ICON_CONFIG_PROX_HTTP, option_http_proxy); set_icon_string(dialog_config_prox, ICON_CONFIG_PROX_HTTPHOST, - option_http_proxy_host); + option_http_proxy_host ? "" : option_http_proxy_host); set_icon_string_i(dialog_config_prox, ICON_CONFIG_PROX_HTTPPORT, option_http_proxy_port); } diff --git a/riscos/font.c b/riscos/font.c index 70dbea29f..46234031f 100644 --- a/riscos/font.c +++ b/riscos/font.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 2003 James Bursa + * Copyright 2004 James Bursa * Copyright 2003 Phil Mellor */ @@ -132,7 +132,7 @@ struct font_set *font_new_set() struct font_data *font_open(struct font_set *set, struct css_style *style) { struct font_data *data; - unsigned int size = 16 * 11; + unsigned int size = option_font_size * 1.6; unsigned int f = 0; font_f handle; os_error *error; @@ -141,7 +141,12 @@ struct font_data *font_open(struct font_set *set, struct css_style *style) assert(style); if (style->font_size.size == CSS_FONT_SIZE_LENGTH) - size = style->font_size.value.length.value * 16; + size = len(&style->font_size.value.length, style) * + 72.0 / 90.0 * 16; + if (size < option_font_min_size * 1.6) + size = option_font_min_size * 1.6; + if (1600 < size) + size = 1600; switch (style->font_family) { case CSS_FONT_FAMILY_SANS_SERIF: diff --git a/riscos/gui.h b/riscos/gui.h index 96c1e9fc0..c90e08e09 100644 --- a/riscos/gui.h +++ b/riscos/gui.h @@ -187,6 +187,12 @@ void ro_gui_history_click(wimp_pointer *pointer); #define ICON_CONFIG_BR_GESTURES 3 #define ICON_CONFIG_BR_TEXT 4 #define ICON_CONFIG_BR_TOOLBAR 5 +#define ICON_CONFIG_BR_FONTSIZE 7 +#define ICON_CONFIG_BR_FONTSIZE_DEC 8 +#define ICON_CONFIG_BR_FONTSIZE_INC 9 +#define ICON_CONFIG_BR_MINSIZE 11 +#define ICON_CONFIG_BR_MINSIZE_DEC 12 +#define ICON_CONFIG_BR_MINSIZE_INC 13 #define ICON_CONFIG_PROX_OK 0 #define ICON_CONFIG_PROX_CANCEL 1 diff --git a/riscos/options.h b/riscos/options.h index 368e1964c..965216170 100644 --- a/riscos/options.h +++ b/riscos/options.h @@ -15,15 +15,15 @@ #include "netsurf/desktop/options.h" -extern int option_use_mouse_gestures; -extern int option_allow_text_selection; -extern int option_show_toolbar; +extern bool option_use_mouse_gestures; +extern bool option_allow_text_selection; +extern bool option_show_toolbar; extern char *option_theme; #define EXTRA_OPTION_DEFINE \ -int option_use_mouse_gestures = false;\ -int option_allow_text_selection = true;\ -int option_show_toolbar = true;\ +bool option_use_mouse_gestures = false;\ +bool option_allow_text_selection = true;\ +bool option_show_toolbar = true;\ char *option_theme = 0; #define EXTRA_OPTION_TABLE \ -- cgit v1.2.3