From fbb1139214f3c4fa7925c572eca05e27873e05ea Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sun, 30 Jan 2011 13:40:47 +0000 Subject: add default system colour handlers to each frontend svn path=/trunk/netsurf/; revision=11530 --- amiga/Makefile.target | 2 +- amiga/system_colour.c | 284 ++++++++++++++++++++++++++++++++++++++++++++ atari/Makefile.target | 2 +- atari/system_colour.c | 284 ++++++++++++++++++++++++++++++++++++++++++++ beos/Makefile.target | 2 +- beos/system_colour.cpp | 284 ++++++++++++++++++++++++++++++++++++++++++++ cocoa/Makefile.target | 11 +- cocoa/system_colour.m | 284 ++++++++++++++++++++++++++++++++++++++++++++ css/css.c | 4 +- css/select.c | 3 +- desktop/gui.h | 13 ++ desktop/netsurf.c | 14 +++ desktop/options.c | 61 ++++++++++ desktop/options.h | 29 +++++ framebuffer/Makefile.target | 2 +- framebuffer/system_colour.c | 284 ++++++++++++++++++++++++++++++++++++++++++++ gtk/Makefile.target | 2 +- gtk/gui.c | 1 - gtk/system_colour.c | 284 ++++++++++++++++++++++++++++++++++++++++++++ riscos/Makefile.target | 4 +- riscos/system_colour.c | 284 ++++++++++++++++++++++++++++++++++++++++++++ windows/Makefile.target | 2 +- windows/system_colour.c | 284 ++++++++++++++++++++++++++++++++++++++++++++ 23 files changed, 2407 insertions(+), 17 deletions(-) create mode 100644 amiga/system_colour.c create mode 100644 atari/system_colour.c create mode 100644 beos/system_colour.cpp create mode 100644 cocoa/system_colour.m create mode 100644 framebuffer/system_colour.c create mode 100644 gtk/system_colour.c create mode 100644 riscos/system_colour.c create mode 100644 windows/system_colour.c diff --git a/amiga/Makefile.target b/amiga/Makefile.target index 734f1a198..4d7022e19 100644 --- a/amiga/Makefile.target +++ b/amiga/Makefile.target @@ -59,7 +59,7 @@ S_AMIGA := compat.c gui.c tree.c history.c hotlist.c schedule.c \ plotters.c object.c menu.c save_pdf.c arexx.c version.c \ cookies.c context_menu.c clipboard.c save_complete.c \ fetch_mailto.c search.c history_local.c download.c iff_dr2d.c \ - sslcert.c gui_options.c print.c theme.c drag.c icon.c \ + sslcert.c gui_options.c print.c theme.c drag.c icon.c system_colour.c \ stringview/stringview.c stringview/urlhistory.c S_AMIGA := $(addprefix amiga/,$(S_AMIGA)) diff --git a/amiga/system_colour.c b/amiga/system_colour.c new file mode 100644 index 000000000..b58717492 --- /dev/null +++ b/amiga/system_colour.c @@ -0,0 +1,284 @@ +/* + * Copyright 2011 Vincent Sanders + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** \file + * System colour handling + * + */ + +#include "utils/utils.h" +#include "utils/log.h" +#include "desktop/gui.h" +#include "desktop/options.h" + +struct gui_system_colour_ctx { + const char *name; + int length; + css_color colour; + colour *option_colour; + lwc_string *lwcstr; +}; + +static struct gui_system_colour_ctx colour_list[] = { + { + "ActiveBorder", + SLEN("ActiveBorder"), + 0xff000000, + &option_sys_colour_ActiveBorder, + NULL + }, { + "ActiveCaption", + SLEN("ActiveCaption"), + 0xffdddddd, + &option_sys_colour_ActiveCaption, + NULL + }, { + "AppWorkspace", + SLEN("AppWorkspace"), + 0xffeeeeee, + &option_sys_colour_AppWorkspace, + NULL + }, { + "Background", + SLEN("Background"), + 0xff0000aa, + &option_sys_colour_Background, + NULL + }, { + "ButtonFace", + SLEN("ButtonFace"), + 0xffaaaaaa, + &option_sys_colour_ButtonFace, + NULL + }, { + "ButtonHighlight", + SLEN("ButtonHighlight"), + 0xffdddddd, + &option_sys_colour_ButtonHighlight, + NULL + }, { + "ButtonShadow", + SLEN("ButtonShadow"), + 0xffbbbbbb, + &option_sys_colour_ButtonShadow, + NULL + }, { + "ButtonText", + SLEN("ButtonText"), + 0xff000000, + &option_sys_colour_ButtonText, + NULL + }, { + "CaptionText", + SLEN("CaptionText"), + 0xff000000, + &option_sys_colour_CaptionText, + NULL + }, { + "GrayText", + SLEN("GrayText"), + 0xffcccccc, + &option_sys_colour_GrayText, + NULL + }, { + "Highlight", + SLEN("Highlight"), + 0xff0000ee, + &option_sys_colour_Highlight, + NULL + }, { + "HighlightText", + SLEN("HighlightText"), + 0xff000000, + &option_sys_colour_HighlightText, + NULL + }, { + "InactiveBorder", + SLEN("InactiveBorder"), + 0xffffffff, + &option_sys_colour_InactiveBorder, + NULL + }, { + "InactiveCaption", + SLEN("InactiveCaption"), + 0xffffffff, + &option_sys_colour_InactiveCaption, + NULL + }, { + "InactiveCaptionText", + SLEN("InactiveCaptionText"), + 0xffcccccc, + &option_sys_colour_InactiveCaptionText, + NULL + }, { + "InfoBackground", + SLEN("InfoBackground"), + 0xffaaaaaa, + &option_sys_colour_InfoBackground, + NULL + }, { + "InfoText", + SLEN("InfoText"), + 0xff000000, + &option_sys_colour_InfoText, + NULL + }, { + "Menu", + SLEN("Menu"), + 0xffaaaaaa, + &option_sys_colour_Menu, + NULL + }, { + "MenuText", + SLEN("MenuText"), + 0xff000000, + &option_sys_colour_MenuText, + NULL + }, { + "Scrollbar", + SLEN("Scrollbar"), + 0xffaaaaaa, + &option_sys_colour_Scrollbar, + NULL + }, { + "ThreeDDarkShadow", + SLEN("ThreeDDarkShadow"), + 0xff555555, + &option_sys_colour_ThreeDDarkShadow, + NULL + }, { + "ThreeDFace", + SLEN("ThreeDFace"), + 0xffdddddd, + &option_sys_colour_ThreeDFace, + NULL + }, { + "ThreeDHighlight", + SLEN("ThreeDHighlight"), + 0xffaaaaaa, + &option_sys_colour_ThreeDHighlight, + NULL + }, { + "ThreeDLightShadow", + SLEN("ThreeDLightShadow"), + 0xff999999, + &option_sys_colour_ThreeDLightShadow, + NULL + }, { + "ThreeDShadow", + SLEN("ThreeDShadow"), + 0xff777777, + &option_sys_colour_ThreeDShadow, + NULL + }, { + "Window", + SLEN("Window"), + 0xffaaaaaa, + &option_sys_colour_Window, + NULL + }, { + "WindowFrame", + SLEN("WindowFrame"), + 0xff000000, + &option_sys_colour_WindowFrame, + NULL + }, { + + "WindowText", + SLEN("WindowText"), + 0xff000000, + &option_sys_colour_WindowText, + NULL + }, + +}; + +#define colour_list_len (sizeof(colour_list) / sizeof(struct gui_system_colour_ctx)) + +static struct gui_system_colour_ctx *gui_system_colour_pw = NULL; + + +bool gui_system_colour_init(void) +{ + unsigned int ccount; + + if (gui_system_colour_pw != NULL) + return false; + + /* Intern colour strings */ + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (lwc_intern_string(colour_list[ccount].name, + colour_list[ccount].length, + &(colour_list[ccount].lwcstr)) != lwc_error_ok) { + return false; + } + } + + /* pull in options if set (ie not transparent) */ + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (*(colour_list[ccount].option_colour) != 0) { + colour_list[ccount].colour = *(colour_list[ccount].option_colour); + } + } + + gui_system_colour_pw = colour_list; + + return true; +} + +void gui_system_colour_finalize(void) +{ + unsigned int ccount; + + for (ccount = 0; ccount < colour_list_len; ccount++) { + lwc_string_unref(colour_list[ccount].lwcstr); + } +} + +colour gui_system_colour_char(char *name) +{ + colour ret = 0xff00000; + unsigned int ccount; + + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (strncasecmp(name, + colour_list[ccount].name, + colour_list[ccount].length) == 0) { + ret = colour_list[ccount].colour; + break; + } + } + return ret; +} + +css_error gui_system_colour(void *pw, lwc_string *name, css_color *colour) +{ + unsigned int ccount; + bool match; + + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (lwc_string_caseless_isequal(name, + colour_list[ccount].lwcstr, + &match) == lwc_error_ok && match) { + *colour = colour_list[ccount].colour; + return CSS_OK; + } + } + + return CSS_INVALID; +} diff --git a/atari/Makefile.target b/atari/Makefile.target index 8ceef2123..6a5c374e3 100644 --- a/atari/Makefile.target +++ b/atari/Makefile.target @@ -40,7 +40,7 @@ S_ATARI := gui.c findfile.c filetype.c misc.c bitmap.c schedule.c \ plot.c plot/plotter.c plot/plotter_vdi.c plot/eddi.s \ plot/font_vdi.c plot/font_freetype.c \ browser_win.c toolbar.c statusbar.c browser.c \ - global_evnt.c + global_evnt.c system_colour.c S_ATARI := $(addprefix atari/,$(S_ATARI)) diff --git a/atari/system_colour.c b/atari/system_colour.c new file mode 100644 index 000000000..b58717492 --- /dev/null +++ b/atari/system_colour.c @@ -0,0 +1,284 @@ +/* + * Copyright 2011 Vincent Sanders + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** \file + * System colour handling + * + */ + +#include "utils/utils.h" +#include "utils/log.h" +#include "desktop/gui.h" +#include "desktop/options.h" + +struct gui_system_colour_ctx { + const char *name; + int length; + css_color colour; + colour *option_colour; + lwc_string *lwcstr; +}; + +static struct gui_system_colour_ctx colour_list[] = { + { + "ActiveBorder", + SLEN("ActiveBorder"), + 0xff000000, + &option_sys_colour_ActiveBorder, + NULL + }, { + "ActiveCaption", + SLEN("ActiveCaption"), + 0xffdddddd, + &option_sys_colour_ActiveCaption, + NULL + }, { + "AppWorkspace", + SLEN("AppWorkspace"), + 0xffeeeeee, + &option_sys_colour_AppWorkspace, + NULL + }, { + "Background", + SLEN("Background"), + 0xff0000aa, + &option_sys_colour_Background, + NULL + }, { + "ButtonFace", + SLEN("ButtonFace"), + 0xffaaaaaa, + &option_sys_colour_ButtonFace, + NULL + }, { + "ButtonHighlight", + SLEN("ButtonHighlight"), + 0xffdddddd, + &option_sys_colour_ButtonHighlight, + NULL + }, { + "ButtonShadow", + SLEN("ButtonShadow"), + 0xffbbbbbb, + &option_sys_colour_ButtonShadow, + NULL + }, { + "ButtonText", + SLEN("ButtonText"), + 0xff000000, + &option_sys_colour_ButtonText, + NULL + }, { + "CaptionText", + SLEN("CaptionText"), + 0xff000000, + &option_sys_colour_CaptionText, + NULL + }, { + "GrayText", + SLEN("GrayText"), + 0xffcccccc, + &option_sys_colour_GrayText, + NULL + }, { + "Highlight", + SLEN("Highlight"), + 0xff0000ee, + &option_sys_colour_Highlight, + NULL + }, { + "HighlightText", + SLEN("HighlightText"), + 0xff000000, + &option_sys_colour_HighlightText, + NULL + }, { + "InactiveBorder", + SLEN("InactiveBorder"), + 0xffffffff, + &option_sys_colour_InactiveBorder, + NULL + }, { + "InactiveCaption", + SLEN("InactiveCaption"), + 0xffffffff, + &option_sys_colour_InactiveCaption, + NULL + }, { + "InactiveCaptionText", + SLEN("InactiveCaptionText"), + 0xffcccccc, + &option_sys_colour_InactiveCaptionText, + NULL + }, { + "InfoBackground", + SLEN("InfoBackground"), + 0xffaaaaaa, + &option_sys_colour_InfoBackground, + NULL + }, { + "InfoText", + SLEN("InfoText"), + 0xff000000, + &option_sys_colour_InfoText, + NULL + }, { + "Menu", + SLEN("Menu"), + 0xffaaaaaa, + &option_sys_colour_Menu, + NULL + }, { + "MenuText", + SLEN("MenuText"), + 0xff000000, + &option_sys_colour_MenuText, + NULL + }, { + "Scrollbar", + SLEN("Scrollbar"), + 0xffaaaaaa, + &option_sys_colour_Scrollbar, + NULL + }, { + "ThreeDDarkShadow", + SLEN("ThreeDDarkShadow"), + 0xff555555, + &option_sys_colour_ThreeDDarkShadow, + NULL + }, { + "ThreeDFace", + SLEN("ThreeDFace"), + 0xffdddddd, + &option_sys_colour_ThreeDFace, + NULL + }, { + "ThreeDHighlight", + SLEN("ThreeDHighlight"), + 0xffaaaaaa, + &option_sys_colour_ThreeDHighlight, + NULL + }, { + "ThreeDLightShadow", + SLEN("ThreeDLightShadow"), + 0xff999999, + &option_sys_colour_ThreeDLightShadow, + NULL + }, { + "ThreeDShadow", + SLEN("ThreeDShadow"), + 0xff777777, + &option_sys_colour_ThreeDShadow, + NULL + }, { + "Window", + SLEN("Window"), + 0xffaaaaaa, + &option_sys_colour_Window, + NULL + }, { + "WindowFrame", + SLEN("WindowFrame"), + 0xff000000, + &option_sys_colour_WindowFrame, + NULL + }, { + + "WindowText", + SLEN("WindowText"), + 0xff000000, + &option_sys_colour_WindowText, + NULL + }, + +}; + +#define colour_list_len (sizeof(colour_list) / sizeof(struct gui_system_colour_ctx)) + +static struct gui_system_colour_ctx *gui_system_colour_pw = NULL; + + +bool gui_system_colour_init(void) +{ + unsigned int ccount; + + if (gui_system_colour_pw != NULL) + return false; + + /* Intern colour strings */ + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (lwc_intern_string(colour_list[ccount].name, + colour_list[ccount].length, + &(colour_list[ccount].lwcstr)) != lwc_error_ok) { + return false; + } + } + + /* pull in options if set (ie not transparent) */ + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (*(colour_list[ccount].option_colour) != 0) { + colour_list[ccount].colour = *(colour_list[ccount].option_colour); + } + } + + gui_system_colour_pw = colour_list; + + return true; +} + +void gui_system_colour_finalize(void) +{ + unsigned int ccount; + + for (ccount = 0; ccount < colour_list_len; ccount++) { + lwc_string_unref(colour_list[ccount].lwcstr); + } +} + +colour gui_system_colour_char(char *name) +{ + colour ret = 0xff00000; + unsigned int ccount; + + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (strncasecmp(name, + colour_list[ccount].name, + colour_list[ccount].length) == 0) { + ret = colour_list[ccount].colour; + break; + } + } + return ret; +} + +css_error gui_system_colour(void *pw, lwc_string *name, css_color *colour) +{ + unsigned int ccount; + bool match; + + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (lwc_string_caseless_isequal(name, + colour_list[ccount].lwcstr, + &match) == lwc_error_ok && match) { + *colour = colour_list[ccount].colour; + return CSS_OK; + } + } + + return CSS_INVALID; +} diff --git a/beos/Makefile.target b/beos/Makefile.target index 9225a10bc..8cb837530 100644 --- a/beos/Makefile.target +++ b/beos/Makefile.target @@ -89,7 +89,7 @@ S_BEOS := beos_about.cpp beos_bitmap.cpp beos_fetch_rsrc.cpp \ beos_options.cpp beos_plotters.cpp beos_save_complete.cpp \ beos_scaffolding.cpp beos_search.cpp beos_schedule.cpp \ beos_thumbnail.cpp beos_treeview.cpp beos_throbber.cpp \ - beos_window.cpp + beos_window.cpp system_colour.cpp S_BEOS := $(addprefix beos/,$(S_BEOS)) RDEF_BEOS := beos_res.rdef RDEF_BEOS := $(addprefix beos/,$(RDEF_BEOS)) diff --git a/beos/system_colour.cpp b/beos/system_colour.cpp new file mode 100644 index 000000000..b58717492 --- /dev/null +++ b/beos/system_colour.cpp @@ -0,0 +1,284 @@ +/* + * Copyright 2011 Vincent Sanders + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** \file + * System colour handling + * + */ + +#include "utils/utils.h" +#include "utils/log.h" +#include "desktop/gui.h" +#include "desktop/options.h" + +struct gui_system_colour_ctx { + const char *name; + int length; + css_color colour; + colour *option_colour; + lwc_string *lwcstr; +}; + +static struct gui_system_colour_ctx colour_list[] = { + { + "ActiveBorder", + SLEN("ActiveBorder"), + 0xff000000, + &option_sys_colour_ActiveBorder, + NULL + }, { + "ActiveCaption", + SLEN("ActiveCaption"), + 0xffdddddd, + &option_sys_colour_ActiveCaption, + NULL + }, { + "AppWorkspace", + SLEN("AppWorkspace"), + 0xffeeeeee, + &option_sys_colour_AppWorkspace, + NULL + }, { + "Background", + SLEN("Background"), + 0xff0000aa, + &option_sys_colour_Background, + NULL + }, { + "ButtonFace", + SLEN("ButtonFace"), + 0xffaaaaaa, + &option_sys_colour_ButtonFace, + NULL + }, { + "ButtonHighlight", + SLEN("ButtonHighlight"), + 0xffdddddd, + &option_sys_colour_ButtonHighlight, + NULL + }, { + "ButtonShadow", + SLEN("ButtonShadow"), + 0xffbbbbbb, + &option_sys_colour_ButtonShadow, + NULL + }, { + "ButtonText", + SLEN("ButtonText"), + 0xff000000, + &option_sys_colour_ButtonText, + NULL + }, { + "CaptionText", + SLEN("CaptionText"), + 0xff000000, + &option_sys_colour_CaptionText, + NULL + }, { + "GrayText", + SLEN("GrayText"), + 0xffcccccc, + &option_sys_colour_GrayText, + NULL + }, { + "Highlight", + SLEN("Highlight"), + 0xff0000ee, + &option_sys_colour_Highlight, + NULL + }, { + "HighlightText", + SLEN("HighlightText"), + 0xff000000, + &option_sys_colour_HighlightText, + NULL + }, { + "InactiveBorder", + SLEN("InactiveBorder"), + 0xffffffff, + &option_sys_colour_InactiveBorder, + NULL + }, { + "InactiveCaption", + SLEN("InactiveCaption"), + 0xffffffff, + &option_sys_colour_InactiveCaption, + NULL + }, { + "InactiveCaptionText", + SLEN("InactiveCaptionText"), + 0xffcccccc, + &option_sys_colour_InactiveCaptionText, + NULL + }, { + "InfoBackground", + SLEN("InfoBackground"), + 0xffaaaaaa, + &option_sys_colour_InfoBackground, + NULL + }, { + "InfoText", + SLEN("InfoText"), + 0xff000000, + &option_sys_colour_InfoText, + NULL + }, { + "Menu", + SLEN("Menu"), + 0xffaaaaaa, + &option_sys_colour_Menu, + NULL + }, { + "MenuText", + SLEN("MenuText"), + 0xff000000, + &option_sys_colour_MenuText, + NULL + }, { + "Scrollbar", + SLEN("Scrollbar"), + 0xffaaaaaa, + &option_sys_colour_Scrollbar, + NULL + }, { + "ThreeDDarkShadow", + SLEN("ThreeDDarkShadow"), + 0xff555555, + &option_sys_colour_ThreeDDarkShadow, + NULL + }, { + "ThreeDFace", + SLEN("ThreeDFace"), + 0xffdddddd, + &option_sys_colour_ThreeDFace, + NULL + }, { + "ThreeDHighlight", + SLEN("ThreeDHighlight"), + 0xffaaaaaa, + &option_sys_colour_ThreeDHighlight, + NULL + }, { + "ThreeDLightShadow", + SLEN("ThreeDLightShadow"), + 0xff999999, + &option_sys_colour_ThreeDLightShadow, + NULL + }, { + "ThreeDShadow", + SLEN("ThreeDShadow"), + 0xff777777, + &option_sys_colour_ThreeDShadow, + NULL + }, { + "Window", + SLEN("Window"), + 0xffaaaaaa, + &option_sys_colour_Window, + NULL + }, { + "WindowFrame", + SLEN("WindowFrame"), + 0xff000000, + &option_sys_colour_WindowFrame, + NULL + }, { + + "WindowText", + SLEN("WindowText"), + 0xff000000, + &option_sys_colour_WindowText, + NULL + }, + +}; + +#define colour_list_len (sizeof(colour_list) / sizeof(struct gui_system_colour_ctx)) + +static struct gui_system_colour_ctx *gui_system_colour_pw = NULL; + + +bool gui_system_colour_init(void) +{ + unsigned int ccount; + + if (gui_system_colour_pw != NULL) + return false; + + /* Intern colour strings */ + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (lwc_intern_string(colour_list[ccount].name, + colour_list[ccount].length, + &(colour_list[ccount].lwcstr)) != lwc_error_ok) { + return false; + } + } + + /* pull in options if set (ie not transparent) */ + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (*(colour_list[ccount].option_colour) != 0) { + colour_list[ccount].colour = *(colour_list[ccount].option_colour); + } + } + + gui_system_colour_pw = colour_list; + + return true; +} + +void gui_system_colour_finalize(void) +{ + unsigned int ccount; + + for (ccount = 0; ccount < colour_list_len; ccount++) { + lwc_string_unref(colour_list[ccount].lwcstr); + } +} + +colour gui_system_colour_char(char *name) +{ + colour ret = 0xff00000; + unsigned int ccount; + + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (strncasecmp(name, + colour_list[ccount].name, + colour_list[ccount].length) == 0) { + ret = colour_list[ccount].colour; + break; + } + } + return ret; +} + +css_error gui_system_colour(void *pw, lwc_string *name, css_color *colour) +{ + unsigned int ccount; + bool match; + + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (lwc_string_caseless_isequal(name, + colour_list[ccount].lwcstr, + &match) == lwc_error_ok && match) { + *colour = colour_list[ccount].colour; + return CSS_OK; + } + } + + return CSS_INVALID; +} diff --git a/cocoa/Makefile.target b/cocoa/Makefile.target index 841325cf2..754e433bf 100644 --- a/cocoa/Makefile.target +++ b/cocoa/Makefile.target @@ -16,7 +16,7 @@ # shut up zconf.h and zlib.h #CFLAGS += -D_LARGEFILE64_SOURCE=1 - + # for timerisset() CFLAGS += -D_DARWIN_C_SOURCE @@ -54,7 +54,7 @@ endif ifneq ($(UNIVERSAL),) UNIVERSAL_FLAGS := $(foreach arch,$(UNIVERSAL),-arch $(arch) ) CFLAGS += $(UNIVERSAL_FLAGS) - LDFLAGS += $(UNIVERSAL_FLAGS) + LDFLAGS += $(UNIVERSAL_FLAGS) CXXFLAGS += $(UNIVERSAL_FLAGS) endif @@ -86,7 +86,8 @@ S_COCOA := \ thumbnail.m \ url.m \ utf8.m \ - utils.m + utils.m \ + system_colour.m S_TABBAR := \ NSBezierPath_AMShading.m \ @@ -121,7 +122,7 @@ R_RESOURCES := $(addprefix cocoa/res/,$(R_RESOURCES)) LANGUAGES := de en fr it nl LOCALIZED_RESOURCES := Messages - + TABBAR_RESOURCES := AquaTabClose_Front_Pressed.png \ AquaTabClose_Front_Rollover.png \ AquaTabClose_Front.png \ @@ -167,7 +168,7 @@ NetSurf.app: NetSurf cocoa/Makefile.target $(R_RESOURCES) $(S_NIBS) NetSurf.app/ cp -pLR $(R_RESOURCES) NetSurf.app/Contents/Resources cp -pLR $(S_NIBS) NetSurf.app/Contents/Resources echo 'APPL????' > NetSurf.app/Contents/PkgInfo - + NetSurf.app/Contents/Info.plist: cocoa/res/NetSurf-Info.plist cocoa/Makefile.target mkdir -p NetSurf.app/Contents sed -e 's/$${EXECUTABLE_NAME}/$(EXETARGET)/' \ diff --git a/cocoa/system_colour.m b/cocoa/system_colour.m new file mode 100644 index 000000000..975fea2f5 --- /dev/null +++ b/cocoa/system_colour.m @@ -0,0 +1,284 @@ +/* + * Copyright 2011 Vincent Sanders + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** \file + * System colour handling + * + */ + +#import "utils/utils.h" +#import "utils/log.h" +#import "desktop/gui.h" +#import "desktop/options.h" + +struct gui_system_colour_ctx { + const char *name; + int length; + css_color colour; + colour *option_colour; + lwc_string *lwcstr; +}; + +static struct gui_system_colour_ctx colour_list[] = { + { + "ActiveBorder", + SLEN("ActiveBorder"), + 0xff000000, + &option_sys_colour_ActiveBorder, + NULL + }, { + "ActiveCaption", + SLEN("ActiveCaption"), + 0xffdddddd, + &option_sys_colour_ActiveCaption, + NULL + }, { + "AppWorkspace", + SLEN("AppWorkspace"), + 0xffeeeeee, + &option_sys_colour_AppWorkspace, + NULL + }, { + "Background", + SLEN("Background"), + 0xff0000aa, + &option_sys_colour_Background, + NULL + }, { + "ButtonFace", + SLEN("ButtonFace"), + 0xffaaaaaa, + &option_sys_colour_ButtonFace, + NULL + }, { + "ButtonHighlight", + SLEN("ButtonHighlight"), + 0xffdddddd, + &option_sys_colour_ButtonHighlight, + NULL + }, { + "ButtonShadow", + SLEN("ButtonShadow"), + 0xffbbbbbb, + &option_sys_colour_ButtonShadow, + NULL + }, { + "ButtonText", + SLEN("ButtonText"), + 0xff000000, + &option_sys_colour_ButtonText, + NULL + }, { + "CaptionText", + SLEN("CaptionText"), + 0xff000000, + &option_sys_colour_CaptionText, + NULL + }, { + "GrayText", + SLEN("GrayText"), + 0xffcccccc, + &option_sys_colour_GrayText, + NULL + }, { + "Highlight", + SLEN("Highlight"), + 0xff0000ee, + &option_sys_colour_Highlight, + NULL + }, { + "HighlightText", + SLEN("HighlightText"), + 0xff000000, + &option_sys_colour_HighlightText, + NULL + }, { + "InactiveBorder", + SLEN("InactiveBorder"), + 0xffffffff, + &option_sys_colour_InactiveBorder, + NULL + }, { + "InactiveCaption", + SLEN("InactiveCaption"), + 0xffffffff, + &option_sys_colour_InactiveCaption, + NULL + }, { + "InactiveCaptionText", + SLEN("InactiveCaptionText"), + 0xffcccccc, + &option_sys_colour_InactiveCaptionText, + NULL + }, { + "InfoBackground", + SLEN("InfoBackground"), + 0xffaaaaaa, + &option_sys_colour_InfoBackground, + NULL + }, { + "InfoText", + SLEN("InfoText"), + 0xff000000, + &option_sys_colour_InfoText, + NULL + }, { + "Menu", + SLEN("Menu"), + 0xffaaaaaa, + &option_sys_colour_Menu, + NULL + }, { + "MenuText", + SLEN("MenuText"), + 0xff000000, + &option_sys_colour_MenuText, + NULL + }, { + "Scrollbar", + SLEN("Scrollbar"), + 0xffaaaaaa, + &option_sys_colour_Scrollbar, + NULL + }, { + "ThreeDDarkShadow", + SLEN("ThreeDDarkShadow"), + 0xff555555, + &option_sys_colour_ThreeDDarkShadow, + NULL + }, { + "ThreeDFace", + SLEN("ThreeDFace"), + 0xffdddddd, + &option_sys_colour_ThreeDFace, + NULL + }, { + "ThreeDHighlight", + SLEN("ThreeDHighlight"), + 0xffaaaaaa, + &option_sys_colour_ThreeDHighlight, + NULL + }, { + "ThreeDLightShadow", + SLEN("ThreeDLightShadow"), + 0xff999999, + &option_sys_colour_ThreeDLightShadow, + NULL + }, { + "ThreeDShadow", + SLEN("ThreeDShadow"), + 0xff777777, + &option_sys_colour_ThreeDShadow, + NULL + }, { + "Window", + SLEN("Window"), + 0xffaaaaaa, + &option_sys_colour_Window, + NULL + }, { + "WindowFrame", + SLEN("WindowFrame"), + 0xff000000, + &option_sys_colour_WindowFrame, + NULL + }, { + + "WindowText", + SLEN("WindowText"), + 0xff000000, + &option_sys_colour_WindowText, + NULL + }, + +}; + +#define colour_list_len (sizeof(colour_list) / sizeof(struct gui_system_colour_ctx)) + +static struct gui_system_colour_ctx *gui_system_colour_pw = NULL; + + +bool gui_system_colour_init(void) +{ + unsigned int ccount; + + if (gui_system_colour_pw != NULL) + return false; + + /* Intern colour strings */ + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (lwc_intern_string(colour_list[ccount].name, + colour_list[ccount].length, + &(colour_list[ccount].lwcstr)) != lwc_error_ok) { + return false; + } + } + + /* pull in options if set (ie not transparent) */ + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (*(colour_list[ccount].option_colour) != 0) { + colour_list[ccount].colour = *(colour_list[ccount].option_colour); + } + } + + gui_system_colour_pw = colour_list; + + return true; +} + +void gui_system_colour_finalize(void) +{ + unsigned int ccount; + + for (ccount = 0; ccount < colour_list_len; ccount++) { + lwc_string_unref(colour_list[ccount].lwcstr); + } +} + +colour gui_system_colour_char(char *name) +{ + colour ret = 0xff00000; + unsigned int ccount; + + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (strncasecmp(name, + colour_list[ccount].name, + colour_list[ccount].length) == 0) { + ret = colour_list[ccount].colour; + break; + } + } + return ret; +} + +css_error gui_system_colour(void *pw, lwc_string *name, css_color *colour) +{ + unsigned int ccount; + bool match; + + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (lwc_string_caseless_isequal(name, + colour_list[ccount].lwcstr, + &match) == lwc_error_ok && match) { + *colour = colour_list[ccount].colour; + return CSS_OK; + } + } + + return CSS_INVALID; +} diff --git a/css/css.c b/css/css.c index 5616403ef..8f3beddb1 100644 --- a/css/css.c +++ b/css/css.c @@ -118,7 +118,7 @@ nserror nscss_create_css_data(struct content_css_data *c, params.resolve_pw = NULL; params.import = NULL; params.import_pw = NULL; - params.color = NULL; + params.color = gui_system_colour; params.color_pw = NULL; error = css_stylesheet_create(¶ms, ns_realloc, NULL, &c->sheet); @@ -460,7 +460,7 @@ css_error nscss_import_complete(struct content_css_data *c, params.resolve_pw = NULL; params.import = NULL; params.import_pw = NULL; - params.color = NULL; + params.color = gui_system_colour; params.color_pw = NULL; error = css_stylesheet_create(¶ms, diff --git a/css/select.c b/css/select.c index 2aae5fbae..415e148fe 100644 --- a/css/select.c +++ b/css/select.c @@ -26,6 +26,7 @@ #include "css/internal.h" #include "css/select.h" #include "css/utils.h" +#include "desktop/gui.h" #include "desktop/options.h" #include "utils/log.h" #include "utils/url.h" @@ -148,7 +149,7 @@ css_stylesheet *nscss_create_inline_style(const uint8_t *data, size_t len, params.resolve_pw = NULL; params.import = NULL; params.import_pw = NULL; - params.color = NULL; + params.color = gui_system_colour; params.color_pw = NULL; error = css_stylesheet_create(¶ms, alloc, pw, &sheet); diff --git a/desktop/gui.h b/desktop/gui.h index abfb413cc..b50aab67f 100644 --- a/desktop/gui.h +++ b/desktop/gui.h @@ -56,6 +56,10 @@ typedef enum { GUI_POINTER_DEFAULT, GUI_POINTER_POINT, GUI_POINTER_CARET, GUI_POINTER_PROGRESS } gui_pointer_shape; #include + +#include +#include + #include "utils/config.h" #include "content/content.h" #include "content/hlcache.h" @@ -141,4 +145,13 @@ void gui_cert_verify(const char *url, const struct ssl_cert_info *certs, unsigned long num, nserror (*cb)(bool proceed, void *pw), void *cbpw); +/** css callback to obtain named system colours from a frontend. */ +css_error gui_system_colour(void *pw, lwc_string *name, css_color *color); + +/** Obtain a named system colour from a frontend. */ +colour gui_system_colour_char(char *name); + +bool gui_system_colour_init(void); +void gui_system_colour_finalize(void); + #endif diff --git a/desktop/netsurf.c b/desktop/netsurf.c index fc51a99e0..d0b57b569 100644 --- a/desktop/netsurf.c +++ b/desktop/netsurf.c @@ -152,6 +152,9 @@ nserror netsurf_init(int *pargc, llcache_initialise(netsurf_llcache_query_handler, NULL); + /* Initialize system colours */ + gui_system_colour_init(); + return NSERROR_OK; } @@ -177,20 +180,31 @@ void netsurf_exit(void) { LOG(("Closing GUI")); gui_quit(); + LOG(("Closing search and related resources")); search_web_cleanup(); + LOG(("Finalising high-level cache")); hlcache_finalise(); + LOG(("Finalising low-level cache")); llcache_finalise(); + LOG(("Closing fetches")); fetch_quit(); + LOG(("Closing utf8")); utf8_finalise(); + LOG(("Destroying URLdb")); urldb_destroy(); + + LOG(("Destroying System colours")); + gui_system_colour_finalize(); + LOG(("Remaining lwc strings:")); lwc_iterate_strings(netsurf_lwc_iterator, NULL); + LOG(("Exited successfully")); } diff --git a/desktop/options.c b/desktop/options.c index 93e25fc63..520be7563 100644 --- a/desktop/options.c +++ b/desktop/options.c @@ -193,6 +193,37 @@ 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) */ +/* system colours */ +colour option_sys_colour_ActiveBorder = 0x00000000; +colour option_sys_colour_ActiveCaption = 0x00000000; +colour option_sys_colour_AppWorkspace = 0x00000000; +colour option_sys_colour_Background = 0x00000000; +colour option_sys_colour_ButtonFace = 0x00000000; +colour option_sys_colour_ButtonHighlight = 0x00000000; +colour option_sys_colour_ButtonShadow = 0x00000000; +colour option_sys_colour_ButtonText = 0x00000000; +colour option_sys_colour_CaptionText = 0x0000000; +colour option_sys_colour_GrayText = 0x00000000; +colour option_sys_colour_Highlight = 0x00000000; +colour option_sys_colour_HighlightText = 0x00000000; +colour option_sys_colour_InactiveBorder = 0x00000000; +colour option_sys_colour_InactiveCaption = 0x00000000; +colour option_sys_colour_InactiveCaptionText = 0x00000000; +colour option_sys_colour_InfoBackground = 0x00000000; +colour option_sys_colour_InfoText = 0x00000000; +colour option_sys_colour_Menu = 0x00000000; +colour option_sys_colour_MenuText = 0x0000000; +colour option_sys_colour_Scrollbar = 0x0000000; +colour option_sys_colour_ThreeDDarkShadow = 0x000000; +colour option_sys_colour_ThreeDFace = 0x000000; +colour option_sys_colour_ThreeDHighlight = 0x000000; +colour option_sys_colour_ThreeDLightShadow = 0x000000; +colour option_sys_colour_ThreeDShadow = 0x000000; +colour option_sys_colour_Window = 0x000000; +colour option_sys_colour_WindowFrame = 0x000000; +colour option_sys_colour_WindowText = 0x000000; + + EXTRA_OPTION_DEFINE @@ -276,6 +307,36 @@ struct { { "gui_colour_fg_1", OPTION_COLOUR, &option_gui_colour_fg_1}, { "gui_colour_fg_2", OPTION_COLOUR, &option_gui_colour_fg_2}, + /* System colours */ + { "sys_colour_ActiveBorder",OPTION_COLOUR,&option_sys_colour_ActiveBorder }, + { "sys_colour_ActiveCaption",OPTION_COLOUR,&option_sys_colour_ActiveCaption }, + { "sys_colour_AppWorkspace",OPTION_COLOUR,&option_sys_colour_AppWorkspace }, + { "sys_colour_Background",OPTION_COLOUR,&option_sys_colour_Background }, + { "sys_colour_ButtonFace",OPTION_COLOUR,&option_sys_colour_ButtonFace }, + { "sys_colour_ButtonHighlight",OPTION_COLOUR,&option_sys_colour_ButtonHighlight }, + { "sys_colour_ButtonShadow",OPTION_COLOUR,&option_sys_colour_ButtonShadow }, + { "sys_colour_ButtonText",OPTION_COLOUR,&option_sys_colour_ButtonText }, + { "sys_colour_CaptionText",OPTION_COLOUR,&option_sys_colour_CaptionText }, + { "sys_colour_GrayText",OPTION_COLOUR,&option_sys_colour_GrayText }, + { "sys_colour_Highlight",OPTION_COLOUR,&option_sys_colour_Highlight }, + { "sys_colour_HighlightText",OPTION_COLOUR,&option_sys_colour_HighlightText }, + { "sys_colour_InactiveBorder",OPTION_COLOUR,&option_sys_colour_InactiveBorder }, + { "sys_colour_InactiveCaption",OPTION_COLOUR,&option_sys_colour_InactiveCaption }, + { "sys_colour_InactiveCaptionText",OPTION_COLOUR,&option_sys_colour_InactiveCaptionText }, + { "sys_colour_InfoBackground",OPTION_COLOUR,&option_sys_colour_InfoBackground }, + { "sys_colour_InfoText",OPTION_COLOUR,&option_sys_colour_InfoText }, + { "sys_colour_Menu",OPTION_COLOUR,&option_sys_colour_Menu }, + { "sys_colour_MenuText",OPTION_COLOUR,&option_sys_colour_MenuText }, + { "sys_colour_Scrollbar",OPTION_COLOUR,&option_sys_colour_Scrollbar }, + { "sys_colour_ThreeDDarkShadow",OPTION_COLOUR,&option_sys_colour_ThreeDDarkShadow }, + { "sys_colour_ThreeDFace",OPTION_COLOUR,&option_sys_colour_ThreeDFace }, + { "sys_colour_ThreeDHighlight",OPTION_COLOUR,&option_sys_colour_ThreeDHighlight }, + { "sys_colour_ThreeDLightShadow",OPTION_COLOUR,&option_sys_colour_ThreeDLightShadow }, + { "sys_colour_ThreeDShadow",OPTION_COLOUR,&option_sys_colour_ThreeDShadow }, + { "sys_colour_Window",OPTION_COLOUR,&option_sys_colour_Window }, + { "sys_colour_WindowFrame",OPTION_COLOUR,&option_sys_colour_WindowFrame }, + { "sys_colour_WindowText",OPTION_COLOUR,&option_sys_colour_WindowText }, + EXTRA_OPTION_TABLE }; diff --git a/desktop/options.h b/desktop/options.h index 3fded50d4..5231322ad 100644 --- a/desktop/options.h +++ b/desktop/options.h @@ -113,6 +113,35 @@ extern colour option_gui_colour_bg_1; extern colour option_gui_colour_fg_1; extern colour option_gui_colour_fg_2; +extern colour option_sys_colour_ActiveBorder; +extern colour option_sys_colour_ActiveCaption; +extern colour option_sys_colour_AppWorkspace; +extern colour option_sys_colour_Background; +extern colour option_sys_colour_ButtonFace; +extern colour option_sys_colour_ButtonHighlight; +extern colour option_sys_colour_ButtonShadow; +extern colour option_sys_colour_ButtonText; +extern colour option_sys_colour_CaptionText; +extern colour option_sys_colour_GrayText; +extern colour option_sys_colour_Highlight; +extern colour option_sys_colour_HighlightText; +extern colour option_sys_colour_InactiveBorder; +extern colour option_sys_colour_InactiveCaption; +extern colour option_sys_colour_InactiveCaptionText; +extern colour option_sys_colour_InfoBackground; +extern colour option_sys_colour_InfoText; +extern colour option_sys_colour_Menu; +extern colour option_sys_colour_MenuText; +extern colour option_sys_colour_Scrollbar; +extern colour option_sys_colour_ThreeDDarkShadow; +extern colour option_sys_colour_ThreeDFace; +extern colour option_sys_colour_ThreeDHighlight; +extern colour option_sys_colour_ThreeDLightShadow; +extern colour option_sys_colour_ThreeDShadow; +extern colour option_sys_colour_Window; +extern colour option_sys_colour_WindowFrame; +extern colour option_sys_colour_WindowText; + void options_read(const char *path); void options_write(const char *path); diff --git a/framebuffer/Makefile.target b/framebuffer/Makefile.target index a60c22fc6..e9dd8a883 100644 --- a/framebuffer/Makefile.target +++ b/framebuffer/Makefile.target @@ -134,7 +134,7 @@ $(eval $(foreach V,$(filter FB_IMAGE_%,$(.VARIABLES)),$(call convert_image,$($(V # S_FRAMEBUFFER are sources purely for the framebuffer build S_FRAMEBUFFER := gui.c framebuffer.c tree.c save.c schedule.c \ thumbnail.c misc.c bitmap.c filetype.c login.c findfile.c \ - localhistory.c + localhistory.c system_colour.c S_FRAMEBUFFER_FBTK := fbtk.c event.c fill.c bitmap.c user.c window.c \ text.c scroll.c osk.c diff --git a/framebuffer/system_colour.c b/framebuffer/system_colour.c new file mode 100644 index 000000000..b58717492 --- /dev/null +++ b/framebuffer/system_colour.c @@ -0,0 +1,284 @@ +/* + * Copyright 2011 Vincent Sanders + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** \file + * System colour handling + * + */ + +#include "utils/utils.h" +#include "utils/log.h" +#include "desktop/gui.h" +#include "desktop/options.h" + +struct gui_system_colour_ctx { + const char *name; + int length; + css_color colour; + colour *option_colour; + lwc_string *lwcstr; +}; + +static struct gui_system_colour_ctx colour_list[] = { + { + "ActiveBorder", + SLEN("ActiveBorder"), + 0xff000000, + &option_sys_colour_ActiveBorder, + NULL + }, { + "ActiveCaption", + SLEN("ActiveCaption"), + 0xffdddddd, + &option_sys_colour_ActiveCaption, + NULL + }, { + "AppWorkspace", + SLEN("AppWorkspace"), + 0xffeeeeee, + &option_sys_colour_AppWorkspace, + NULL + }, { + "Background", + SLEN("Background"), + 0xff0000aa, + &option_sys_colour_Background, + NULL + }, { + "ButtonFace", + SLEN("ButtonFace"), + 0xffaaaaaa, + &option_sys_colour_ButtonFace, + NULL + }, { + "ButtonHighlight", + SLEN("ButtonHighlight"), + 0xffdddddd, + &option_sys_colour_ButtonHighlight, + NULL + }, { + "ButtonShadow", + SLEN("ButtonShadow"), + 0xffbbbbbb, + &option_sys_colour_ButtonShadow, + NULL + }, { + "ButtonText", + SLEN("ButtonText"), + 0xff000000, + &option_sys_colour_ButtonText, + NULL + }, { + "CaptionText", + SLEN("CaptionText"), + 0xff000000, + &option_sys_colour_CaptionText, + NULL + }, { + "GrayText", + SLEN("GrayText"), + 0xffcccccc, + &option_sys_colour_GrayText, + NULL + }, { + "Highlight", + SLEN("Highlight"), + 0xff0000ee, + &option_sys_colour_Highlight, + NULL + }, { + "HighlightText", + SLEN("HighlightText"), + 0xff000000, + &option_sys_colour_HighlightText, + NULL + }, { + "InactiveBorder", + SLEN("InactiveBorder"), + 0xffffffff, + &option_sys_colour_InactiveBorder, + NULL + }, { + "InactiveCaption", + SLEN("InactiveCaption"), + 0xffffffff, + &option_sys_colour_InactiveCaption, + NULL + }, { + "InactiveCaptionText", + SLEN("InactiveCaptionText"), + 0xffcccccc, + &option_sys_colour_InactiveCaptionText, + NULL + }, { + "InfoBackground", + SLEN("InfoBackground"), + 0xffaaaaaa, + &option_sys_colour_InfoBackground, + NULL + }, { + "InfoText", + SLEN("InfoText"), + 0xff000000, + &option_sys_colour_InfoText, + NULL + }, { + "Menu", + SLEN("Menu"), + 0xffaaaaaa, + &option_sys_colour_Menu, + NULL + }, { + "MenuText", + SLEN("MenuText"), + 0xff000000, + &option_sys_colour_MenuText, + NULL + }, { + "Scrollbar", + SLEN("Scrollbar"), + 0xffaaaaaa, + &option_sys_colour_Scrollbar, + NULL + }, { + "ThreeDDarkShadow", + SLEN("ThreeDDarkShadow"), + 0xff555555, + &option_sys_colour_ThreeDDarkShadow, + NULL + }, { + "ThreeDFace", + SLEN("ThreeDFace"), + 0xffdddddd, + &option_sys_colour_ThreeDFace, + NULL + }, { + "ThreeDHighlight", + SLEN("ThreeDHighlight"), + 0xffaaaaaa, + &option_sys_colour_ThreeDHighlight, + NULL + }, { + "ThreeDLightShadow", + SLEN("ThreeDLightShadow"), + 0xff999999, + &option_sys_colour_ThreeDLightShadow, + NULL + }, { + "ThreeDShadow", + SLEN("ThreeDShadow"), + 0xff777777, + &option_sys_colour_ThreeDShadow, + NULL + }, { + "Window", + SLEN("Window"), + 0xffaaaaaa, + &option_sys_colour_Window, + NULL + }, { + "WindowFrame", + SLEN("WindowFrame"), + 0xff000000, + &option_sys_colour_WindowFrame, + NULL + }, { + + "WindowText", + SLEN("WindowText"), + 0xff000000, + &option_sys_colour_WindowText, + NULL + }, + +}; + +#define colour_list_len (sizeof(colour_list) / sizeof(struct gui_system_colour_ctx)) + +static struct gui_system_colour_ctx *gui_system_colour_pw = NULL; + + +bool gui_system_colour_init(void) +{ + unsigned int ccount; + + if (gui_system_colour_pw != NULL) + return false; + + /* Intern colour strings */ + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (lwc_intern_string(colour_list[ccount].name, + colour_list[ccount].length, + &(colour_list[ccount].lwcstr)) != lwc_error_ok) { + return false; + } + } + + /* pull in options if set (ie not transparent) */ + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (*(colour_list[ccount].option_colour) != 0) { + colour_list[ccount].colour = *(colour_list[ccount].option_colour); + } + } + + gui_system_colour_pw = colour_list; + + return true; +} + +void gui_system_colour_finalize(void) +{ + unsigned int ccount; + + for (ccount = 0; ccount < colour_list_len; ccount++) { + lwc_string_unref(colour_list[ccount].lwcstr); + } +} + +colour gui_system_colour_char(char *name) +{ + colour ret = 0xff00000; + unsigned int ccount; + + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (strncasecmp(name, + colour_list[ccount].name, + colour_list[ccount].length) == 0) { + ret = colour_list[ccount].colour; + break; + } + } + return ret; +} + +css_error gui_system_colour(void *pw, lwc_string *name, css_color *colour) +{ + unsigned int ccount; + bool match; + + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (lwc_string_caseless_isequal(name, + colour_list[ccount].lwcstr, + &match) == lwc_error_ok && match) { + *colour = colour_list[ccount].colour; + return CSS_OK; + } + } + + return CSS_INVALID; +} diff --git a/gtk/Makefile.target b/gtk/Makefile.target index 9fd780a7c..1ab4f3ca4 100644 --- a/gtk/Makefile.target +++ b/gtk/Makefile.target @@ -61,7 +61,7 @@ S_GTK := font_pango.c bitmap.c gui.c schedule.c thumbnail.c plotters.c \ treeview.c scaffolding.c completion.c login.c throbber.c \ selection.c history.c window.c filetype.c download.c menu.c \ print.c save.c search.c tabs.c theme.c toolbar.c \ - sexy_icon_entry.c compat.c cookies.c hotlist.c \ + sexy_icon_entry.c compat.c cookies.c hotlist.c system_colour.c \ $(addprefix dialogs/,options.c about.c source.c) S_GTK := $(addprefix gtk/,$(S_GTK)) $(addprefix utils/,container.c) # code in utils/container.ch is non-universal it seems diff --git a/gtk/gui.c b/gtk/gui.c index 98a0c3322..8a92f83dc 100644 --- a/gtk/gui.c +++ b/gtk/gui.c @@ -598,7 +598,6 @@ int main(int argc, char** argv) netsurf_exit(); - return 0; } diff --git a/gtk/system_colour.c b/gtk/system_colour.c new file mode 100644 index 000000000..b58717492 --- /dev/null +++ b/gtk/system_colour.c @@ -0,0 +1,284 @@ +/* + * Copyright 2011 Vincent Sanders + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** \file + * System colour handling + * + */ + +#include "utils/utils.h" +#include "utils/log.h" +#include "desktop/gui.h" +#include "desktop/options.h" + +struct gui_system_colour_ctx { + const char *name; + int length; + css_color colour; + colour *option_colour; + lwc_string *lwcstr; +}; + +static struct gui_system_colour_ctx colour_list[] = { + { + "ActiveBorder", + SLEN("ActiveBorder"), + 0xff000000, + &option_sys_colour_ActiveBorder, + NULL + }, { + "ActiveCaption", + SLEN("ActiveCaption"), + 0xffdddddd, + &option_sys_colour_ActiveCaption, + NULL + }, { + "AppWorkspace", + SLEN("AppWorkspace"), + 0xffeeeeee, + &option_sys_colour_AppWorkspace, + NULL + }, { + "Background", + SLEN("Background"), + 0xff0000aa, + &option_sys_colour_Background, + NULL + }, { + "ButtonFace", + SLEN("ButtonFace"), + 0xffaaaaaa, + &option_sys_colour_ButtonFace, + NULL + }, { + "ButtonHighlight", + SLEN("ButtonHighlight"), + 0xffdddddd, + &option_sys_colour_ButtonHighlight, + NULL + }, { + "ButtonShadow", + SLEN("ButtonShadow"), + 0xffbbbbbb, + &option_sys_colour_ButtonShadow, + NULL + }, { + "ButtonText", + SLEN("ButtonText"), + 0xff000000, + &option_sys_colour_ButtonText, + NULL + }, { + "CaptionText", + SLEN("CaptionText"), + 0xff000000, + &option_sys_colour_CaptionText, + NULL + }, { + "GrayText", + SLEN("GrayText"), + 0xffcccccc, + &option_sys_colour_GrayText, + NULL + }, { + "Highlight", + SLEN("Highlight"), + 0xff0000ee, + &option_sys_colour_Highlight, + NULL + }, { + "HighlightText", + SLEN("HighlightText"), + 0xff000000, + &option_sys_colour_HighlightText, + NULL + }, { + "InactiveBorder", + SLEN("InactiveBorder"), + 0xffffffff, + &option_sys_colour_InactiveBorder, + NULL + }, { + "InactiveCaption", + SLEN("InactiveCaption"), + 0xffffffff, + &option_sys_colour_InactiveCaption, + NULL + }, { + "InactiveCaptionText", + SLEN("InactiveCaptionText"), + 0xffcccccc, + &option_sys_colour_InactiveCaptionText, + NULL + }, { + "InfoBackground", + SLEN("InfoBackground"), + 0xffaaaaaa, + &option_sys_colour_InfoBackground, + NULL + }, { + "InfoText", + SLEN("InfoText"), + 0xff000000, + &option_sys_colour_InfoText, + NULL + }, { + "Menu", + SLEN("Menu"), + 0xffaaaaaa, + &option_sys_colour_Menu, + NULL + }, { + "MenuText", + SLEN("MenuText"), + 0xff000000, + &option_sys_colour_MenuText, + NULL + }, { + "Scrollbar", + SLEN("Scrollbar"), + 0xffaaaaaa, + &option_sys_colour_Scrollbar, + NULL + }, { + "ThreeDDarkShadow", + SLEN("ThreeDDarkShadow"), + 0xff555555, + &option_sys_colour_ThreeDDarkShadow, + NULL + }, { + "ThreeDFace", + SLEN("ThreeDFace"), + 0xffdddddd, + &option_sys_colour_ThreeDFace, + NULL + }, { + "ThreeDHighlight", + SLEN("ThreeDHighlight"), + 0xffaaaaaa, + &option_sys_colour_ThreeDHighlight, + NULL + }, { + "ThreeDLightShadow", + SLEN("ThreeDLightShadow"), + 0xff999999, + &option_sys_colour_ThreeDLightShadow, + NULL + }, { + "ThreeDShadow", + SLEN("ThreeDShadow"), + 0xff777777, + &option_sys_colour_ThreeDShadow, + NULL + }, { + "Window", + SLEN("Window"), + 0xffaaaaaa, + &option_sys_colour_Window, + NULL + }, { + "WindowFrame", + SLEN("WindowFrame"), + 0xff000000, + &option_sys_colour_WindowFrame, + NULL + }, { + + "WindowText", + SLEN("WindowText"), + 0xff000000, + &option_sys_colour_WindowText, + NULL + }, + +}; + +#define colour_list_len (sizeof(colour_list) / sizeof(struct gui_system_colour_ctx)) + +static struct gui_system_colour_ctx *gui_system_colour_pw = NULL; + + +bool gui_system_colour_init(void) +{ + unsigned int ccount; + + if (gui_system_colour_pw != NULL) + return false; + + /* Intern colour strings */ + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (lwc_intern_string(colour_list[ccount].name, + colour_list[ccount].length, + &(colour_list[ccount].lwcstr)) != lwc_error_ok) { + return false; + } + } + + /* pull in options if set (ie not transparent) */ + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (*(colour_list[ccount].option_colour) != 0) { + colour_list[ccount].colour = *(colour_list[ccount].option_colour); + } + } + + gui_system_colour_pw = colour_list; + + return true; +} + +void gui_system_colour_finalize(void) +{ + unsigned int ccount; + + for (ccount = 0; ccount < colour_list_len; ccount++) { + lwc_string_unref(colour_list[ccount].lwcstr); + } +} + +colour gui_system_colour_char(char *name) +{ + colour ret = 0xff00000; + unsigned int ccount; + + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (strncasecmp(name, + colour_list[ccount].name, + colour_list[ccount].length) == 0) { + ret = colour_list[ccount].colour; + break; + } + } + return ret; +} + +css_error gui_system_colour(void *pw, lwc_string *name, css_color *colour) +{ + unsigned int ccount; + bool match; + + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (lwc_string_caseless_isequal(name, + colour_list[ccount].lwcstr, + &match) == lwc_error_ok && match) { + *colour = colour_list[ccount].colour; + return CSS_OK; + } + } + + return CSS_INVALID; +} diff --git a/riscos/Makefile.target b/riscos/Makefile.target index 3b614f03b..685979d77 100644 --- a/riscos/Makefile.target +++ b/riscos/Makefile.target @@ -73,8 +73,8 @@ S_RISCOS := 401login.c artworks.c assert.c awrender.s bitmap.c buffer.c \ schedule.c search.c searchweb.c sprite.c sslcert.c \ textarea.c textselection.c theme.c theme_install.c thumbnail.c \ treeview.c ucstables.c uri.c url_complete.c url_protocol.c \ - url_suggest.c wimp.c wimp_event.c window.c gui/progress_bar.c \ - gui/status_bar.c \ + url_suggest.c wimp.c wimp_event.c window.c system_colour.c \ + gui/progress_bar.c gui/status_bar.c \ $(addprefix configure/,con_cache.c con_connect.c con_content.c \ con_fonts.c con_home.c con_image.c con_inter.c con_language.c \ con_memory.c con_secure.c con_theme.c) diff --git a/riscos/system_colour.c b/riscos/system_colour.c new file mode 100644 index 000000000..b58717492 --- /dev/null +++ b/riscos/system_colour.c @@ -0,0 +1,284 @@ +/* + * Copyright 2011 Vincent Sanders + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** \file + * System colour handling + * + */ + +#include "utils/utils.h" +#include "utils/log.h" +#include "desktop/gui.h" +#include "desktop/options.h" + +struct gui_system_colour_ctx { + const char *name; + int length; + css_color colour; + colour *option_colour; + lwc_string *lwcstr; +}; + +static struct gui_system_colour_ctx colour_list[] = { + { + "ActiveBorder", + SLEN("ActiveBorder"), + 0xff000000, + &option_sys_colour_ActiveBorder, + NULL + }, { + "ActiveCaption", + SLEN("ActiveCaption"), + 0xffdddddd, + &option_sys_colour_ActiveCaption, + NULL + }, { + "AppWorkspace", + SLEN("AppWorkspace"), + 0xffeeeeee, + &option_sys_colour_AppWorkspace, + NULL + }, { + "Background", + SLEN("Background"), + 0xff0000aa, + &option_sys_colour_Background, + NULL + }, { + "ButtonFace", + SLEN("ButtonFace"), + 0xffaaaaaa, + &option_sys_colour_ButtonFace, + NULL + }, { + "ButtonHighlight", + SLEN("ButtonHighlight"), + 0xffdddddd, + &option_sys_colour_ButtonHighlight, + NULL + }, { + "ButtonShadow", + SLEN("ButtonShadow"), + 0xffbbbbbb, + &option_sys_colour_ButtonShadow, + NULL + }, { + "ButtonText", + SLEN("ButtonText"), + 0xff000000, + &option_sys_colour_ButtonText, + NULL + }, { + "CaptionText", + SLEN("CaptionText"), + 0xff000000, + &option_sys_colour_CaptionText, + NULL + }, { + "GrayText", + SLEN("GrayText"), + 0xffcccccc, + &option_sys_colour_GrayText, + NULL + }, { + "Highlight", + SLEN("Highlight"), + 0xff0000ee, + &option_sys_colour_Highlight, + NULL + }, { + "HighlightText", + SLEN("HighlightText"), + 0xff000000, + &option_sys_colour_HighlightText, + NULL + }, { + "InactiveBorder", + SLEN("InactiveBorder"), + 0xffffffff, + &option_sys_colour_InactiveBorder, + NULL + }, { + "InactiveCaption", + SLEN("InactiveCaption"), + 0xffffffff, + &option_sys_colour_InactiveCaption, + NULL + }, { + "InactiveCaptionText", + SLEN("InactiveCaptionText"), + 0xffcccccc, + &option_sys_colour_InactiveCaptionText, + NULL + }, { + "InfoBackground", + SLEN("InfoBackground"), + 0xffaaaaaa, + &option_sys_colour_InfoBackground, + NULL + }, { + "InfoText", + SLEN("InfoText"), + 0xff000000, + &option_sys_colour_InfoText, + NULL + }, { + "Menu", + SLEN("Menu"), + 0xffaaaaaa, + &option_sys_colour_Menu, + NULL + }, { + "MenuText", + SLEN("MenuText"), + 0xff000000, + &option_sys_colour_MenuText, + NULL + }, { + "Scrollbar", + SLEN("Scrollbar"), + 0xffaaaaaa, + &option_sys_colour_Scrollbar, + NULL + }, { + "ThreeDDarkShadow", + SLEN("ThreeDDarkShadow"), + 0xff555555, + &option_sys_colour_ThreeDDarkShadow, + NULL + }, { + "ThreeDFace", + SLEN("ThreeDFace"), + 0xffdddddd, + &option_sys_colour_ThreeDFace, + NULL + }, { + "ThreeDHighlight", + SLEN("ThreeDHighlight"), + 0xffaaaaaa, + &option_sys_colour_ThreeDHighlight, + NULL + }, { + "ThreeDLightShadow", + SLEN("ThreeDLightShadow"), + 0xff999999, + &option_sys_colour_ThreeDLightShadow, + NULL + }, { + "ThreeDShadow", + SLEN("ThreeDShadow"), + 0xff777777, + &option_sys_colour_ThreeDShadow, + NULL + }, { + "Window", + SLEN("Window"), + 0xffaaaaaa, + &option_sys_colour_Window, + NULL + }, { + "WindowFrame", + SLEN("WindowFrame"), + 0xff000000, + &option_sys_colour_WindowFrame, + NULL + }, { + + "WindowText", + SLEN("WindowText"), + 0xff000000, + &option_sys_colour_WindowText, + NULL + }, + +}; + +#define colour_list_len (sizeof(colour_list) / sizeof(struct gui_system_colour_ctx)) + +static struct gui_system_colour_ctx *gui_system_colour_pw = NULL; + + +bool gui_system_colour_init(void) +{ + unsigned int ccount; + + if (gui_system_colour_pw != NULL) + return false; + + /* Intern colour strings */ + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (lwc_intern_string(colour_list[ccount].name, + colour_list[ccount].length, + &(colour_list[ccount].lwcstr)) != lwc_error_ok) { + return false; + } + } + + /* pull in options if set (ie not transparent) */ + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (*(colour_list[ccount].option_colour) != 0) { + colour_list[ccount].colour = *(colour_list[ccount].option_colour); + } + } + + gui_system_colour_pw = colour_list; + + return true; +} + +void gui_system_colour_finalize(void) +{ + unsigned int ccount; + + for (ccount = 0; ccount < colour_list_len; ccount++) { + lwc_string_unref(colour_list[ccount].lwcstr); + } +} + +colour gui_system_colour_char(char *name) +{ + colour ret = 0xff00000; + unsigned int ccount; + + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (strncasecmp(name, + colour_list[ccount].name, + colour_list[ccount].length) == 0) { + ret = colour_list[ccount].colour; + break; + } + } + return ret; +} + +css_error gui_system_colour(void *pw, lwc_string *name, css_color *colour) +{ + unsigned int ccount; + bool match; + + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (lwc_string_caseless_isequal(name, + colour_list[ccount].lwcstr, + &match) == lwc_error_ok && match) { + *colour = colour_list[ccount].colour; + return CSS_OK; + } + } + + return CSS_INVALID; +} diff --git a/windows/Makefile.target b/windows/Makefile.target index 9d8f2a0f0..0249a1b67 100644 --- a/windows/Makefile.target +++ b/windows/Makefile.target @@ -48,7 +48,7 @@ S_RESOURCES := windows_resource.o # S_WINDOWS are sources purely for the windows build S_WINDOWS := about.c bitmap.c download.c filetype.c findfile.c font.c \ gui.c localhistory.c login.c misc.c plot.c prefs.c schedule.c \ - thumbnail.c tree.c windbg.c + thumbnail.c tree.c windbg.c system_colour.c S_WINDOWS := $(addprefix windows/,$(S_WINDOWS)) SOURCES := $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_WINDOWS) $(S_RESOURCES) diff --git a/windows/system_colour.c b/windows/system_colour.c new file mode 100644 index 000000000..b58717492 --- /dev/null +++ b/windows/system_colour.c @@ -0,0 +1,284 @@ +/* + * Copyright 2011 Vincent Sanders + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** \file + * System colour handling + * + */ + +#include "utils/utils.h" +#include "utils/log.h" +#include "desktop/gui.h" +#include "desktop/options.h" + +struct gui_system_colour_ctx { + const char *name; + int length; + css_color colour; + colour *option_colour; + lwc_string *lwcstr; +}; + +static struct gui_system_colour_ctx colour_list[] = { + { + "ActiveBorder", + SLEN("ActiveBorder"), + 0xff000000, + &option_sys_colour_ActiveBorder, + NULL + }, { + "ActiveCaption", + SLEN("ActiveCaption"), + 0xffdddddd, + &option_sys_colour_ActiveCaption, + NULL + }, { + "AppWorkspace", + SLEN("AppWorkspace"), + 0xffeeeeee, + &option_sys_colour_AppWorkspace, + NULL + }, { + "Background", + SLEN("Background"), + 0xff0000aa, + &option_sys_colour_Background, + NULL + }, { + "ButtonFace", + SLEN("ButtonFace"), + 0xffaaaaaa, + &option_sys_colour_ButtonFace, + NULL + }, { + "ButtonHighlight", + SLEN("ButtonHighlight"), + 0xffdddddd, + &option_sys_colour_ButtonHighlight, + NULL + }, { + "ButtonShadow", + SLEN("ButtonShadow"), + 0xffbbbbbb, + &option_sys_colour_ButtonShadow, + NULL + }, { + "ButtonText", + SLEN("ButtonText"), + 0xff000000, + &option_sys_colour_ButtonText, + NULL + }, { + "CaptionText", + SLEN("CaptionText"), + 0xff000000, + &option_sys_colour_CaptionText, + NULL + }, { + "GrayText", + SLEN("GrayText"), + 0xffcccccc, + &option_sys_colour_GrayText, + NULL + }, { + "Highlight", + SLEN("Highlight"), + 0xff0000ee, + &option_sys_colour_Highlight, + NULL + }, { + "HighlightText", + SLEN("HighlightText"), + 0xff000000, + &option_sys_colour_HighlightText, + NULL + }, { + "InactiveBorder", + SLEN("InactiveBorder"), + 0xffffffff, + &option_sys_colour_InactiveBorder, + NULL + }, { + "InactiveCaption", + SLEN("InactiveCaption"), + 0xffffffff, + &option_sys_colour_InactiveCaption, + NULL + }, { + "InactiveCaptionText", + SLEN("InactiveCaptionText"), + 0xffcccccc, + &option_sys_colour_InactiveCaptionText, + NULL + }, { + "InfoBackground", + SLEN("InfoBackground"), + 0xffaaaaaa, + &option_sys_colour_InfoBackground, + NULL + }, { + "InfoText", + SLEN("InfoText"), + 0xff000000, + &option_sys_colour_InfoText, + NULL + }, { + "Menu", + SLEN("Menu"), + 0xffaaaaaa, + &option_sys_colour_Menu, + NULL + }, { + "MenuText", + SLEN("MenuText"), + 0xff000000, + &option_sys_colour_MenuText, + NULL + }, { + "Scrollbar", + SLEN("Scrollbar"), + 0xffaaaaaa, + &option_sys_colour_Scrollbar, + NULL + }, { + "ThreeDDarkShadow", + SLEN("ThreeDDarkShadow"), + 0xff555555, + &option_sys_colour_ThreeDDarkShadow, + NULL + }, { + "ThreeDFace", + SLEN("ThreeDFace"), + 0xffdddddd, + &option_sys_colour_ThreeDFace, + NULL + }, { + "ThreeDHighlight", + SLEN("ThreeDHighlight"), + 0xffaaaaaa, + &option_sys_colour_ThreeDHighlight, + NULL + }, { + "ThreeDLightShadow", + SLEN("ThreeDLightShadow"), + 0xff999999, + &option_sys_colour_ThreeDLightShadow, + NULL + }, { + "ThreeDShadow", + SLEN("ThreeDShadow"), + 0xff777777, + &option_sys_colour_ThreeDShadow, + NULL + }, { + "Window", + SLEN("Window"), + 0xffaaaaaa, + &option_sys_colour_Window, + NULL + }, { + "WindowFrame", + SLEN("WindowFrame"), + 0xff000000, + &option_sys_colour_WindowFrame, + NULL + }, { + + "WindowText", + SLEN("WindowText"), + 0xff000000, + &option_sys_colour_WindowText, + NULL + }, + +}; + +#define colour_list_len (sizeof(colour_list) / sizeof(struct gui_system_colour_ctx)) + +static struct gui_system_colour_ctx *gui_system_colour_pw = NULL; + + +bool gui_system_colour_init(void) +{ + unsigned int ccount; + + if (gui_system_colour_pw != NULL) + return false; + + /* Intern colour strings */ + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (lwc_intern_string(colour_list[ccount].name, + colour_list[ccount].length, + &(colour_list[ccount].lwcstr)) != lwc_error_ok) { + return false; + } + } + + /* pull in options if set (ie not transparent) */ + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (*(colour_list[ccount].option_colour) != 0) { + colour_list[ccount].colour = *(colour_list[ccount].option_colour); + } + } + + gui_system_colour_pw = colour_list; + + return true; +} + +void gui_system_colour_finalize(void) +{ + unsigned int ccount; + + for (ccount = 0; ccount < colour_list_len; ccount++) { + lwc_string_unref(colour_list[ccount].lwcstr); + } +} + +colour gui_system_colour_char(char *name) +{ + colour ret = 0xff00000; + unsigned int ccount; + + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (strncasecmp(name, + colour_list[ccount].name, + colour_list[ccount].length) == 0) { + ret = colour_list[ccount].colour; + break; + } + } + return ret; +} + +css_error gui_system_colour(void *pw, lwc_string *name, css_color *colour) +{ + unsigned int ccount; + bool match; + + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (lwc_string_caseless_isequal(name, + colour_list[ccount].lwcstr, + &match) == lwc_error_ok && match) { + *colour = colour_list[ccount].colour; + return CSS_OK; + } + } + + return CSS_INVALID; +} -- cgit v1.2.3