From 710f0ce844573faf364dda63295dc942e5848fc9 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Tue, 21 Dec 2010 17:00:44 +0000 Subject: Add COLOUR option type. Add some colour options for rendering core interfaces. svn path=/trunk/netsurf/; revision=11117 --- desktop/options.c | 46 +++++++++++++++++++++++++++++++++++++++++++++- desktop/options.h | 6 ++++++ 2 files changed, 51 insertions(+), 1 deletion(-) (limited to 'desktop') diff --git a/desktop/options.c b/desktop/options.c index 47b42dc3b..5d49b9490 100644 --- a/desktop/options.c +++ b/desktop/options.c @@ -187,12 +187,17 @@ bool option_target_blank = true; /** Whether second mouse button opens in new tab */ bool option_button_2_tab = true; +/* Interface colours */ +colour option_gui_colour_bg_1 = 0xFFCCBB; /** Background (bbggrr) */ +colour option_gui_colour_fg_1 = 0x000000; /** Foreground (bbggrr) */ +colour option_gui_colour_fg_2 = 0xFFFBF8; /** Foreground selected (bbggrr) */ + EXTRA_OPTION_DEFINE struct { const char *key; - enum { OPTION_BOOL, OPTION_INTEGER, OPTION_STRING } type; + enum { OPTION_BOOL, OPTION_INTEGER, OPTION_STRING, OPTION_COLOUR } type; void *p; } option_table[] = { { "http_proxy", OPTION_BOOL, &option_http_proxy }, @@ -266,6 +271,11 @@ struct { OPTION_BOOL, &option_enable_PDF_compression}, { "enable_PDF_password", OPTION_BOOL, &option_enable_PDF_password}, + /* Interface colours */ + { "gui_colour_bg_1", OPTION_COLOUR, &option_gui_colour_bg_1}, + { "gui_colour_fg_1", OPTION_COLOUR, &option_gui_colour_fg_1}, + { "gui_colour_fg_2", OPTION_COLOUR, &option_gui_colour_fg_2}, + EXTRA_OPTION_TABLE }; @@ -285,6 +295,7 @@ void options_read(const char *path) { char s[100]; FILE *fp; + colour rgbcolour; /* RRGGBB */ fp = fopen(path, "r"); if (!fp) { @@ -320,6 +331,17 @@ void options_read(const char *path) atoi(value); break; + case OPTION_COLOUR: + sscanf(value, "%x", &rgbcolour); + *((colour *) option_table[i].p) = + ((0x000000FF & + rgbcolour) << 16) | + ((0x0000FF00 & + rgbcolour) << 0) | + ((0x00FF0000 & + rgbcolour) >> 16); + break; + case OPTION_STRING: free(*((char **) option_table[i].p)); *((char **) option_table[i].p) = @@ -358,6 +380,7 @@ void options_write(const char *path) { unsigned int i; FILE *fp; + colour rgbcolour; /* RRGGBB */ fp = fopen(path, "w"); if (!fp) { @@ -377,6 +400,16 @@ void options_write(const char *path) fprintf(fp, "%i", *((int *) option_table[i].p)); break; + case OPTION_COLOUR: + rgbcolour = ((0x000000FF & *((colour *) + option_table[i].p)) << 16) | + ((0x0000FF00 & *((colour *) + option_table[i].p)) << 0) | + ((0x00FF0000 & *((colour *) + option_table[i].p)) >> 16); + fprintf(fp, "%06x", rgbcolour); + break; + case OPTION_STRING: if (*((char **) option_table[i].p)) fprintf(fp, "%s", *((char **) option_table[i].p)); @@ -394,6 +427,7 @@ void options_write(const char *path) void options_dump(void) { unsigned int i; + colour rgbcolour; for (i = 0; i != option_table_entries; i++) { fprintf(stderr, "%s:", option_table[i].key); @@ -409,6 +443,16 @@ void options_dump(void) *((int *) option_table[i].p)); break; + case OPTION_COLOUR: + rgbcolour = ((0x000000FF | *((colour *) + option_table[i].p)) << 16) & + ((0x0000FF00 | *((colour *) + option_table[i].p)) << 0) & + ((0x00FF0000 | *((colour *) + option_table[i].p)) >> 16); + fprintf(stderr, "%x", rgbcolour); + break; + case OPTION_STRING: if (*((char **) option_table[i].p)) fprintf(stderr, "%s", diff --git a/desktop/options.h b/desktop/options.h index 2779692b6..308615d90 100644 --- a/desktop/options.h +++ b/desktop/options.h @@ -36,6 +36,7 @@ #define _NETSURF_DESKTOP_OPTIONS_H_ #include +#include "desktop/plot_style.h" struct tree; @@ -110,6 +111,11 @@ extern int option_max_fetchers_per_host; extern int option_max_cached_fetch_handles; extern bool option_suppress_curl_debug; +/* Interface colours */ +extern colour option_gui_colour_bg_1; +extern colour option_gui_colour_fg_1; +extern colour option_gui_colour_fg_2; + void options_read(const char *path); void options_write(const char *path); -- cgit v1.2.3