summaryrefslogtreecommitdiff
path: root/riscos
diff options
context:
space:
mode:
authorSteve Fryatt <steve@stevefryatt.org.uk>2011-02-25 23:26:36 +0000
committerSteve Fryatt <steve@stevefryatt.org.uk>2011-02-25 23:26:36 +0000
commita34cd9c8c671c9af6f222d47ee79d66aa5a3ff14 (patch)
tree0a5a712df7d6b8934a625784f53e8f47e14392e6 /riscos
parent66ed6d8867868c1ee00ac3956c712000aedc901f (diff)
downloadnetsurf-a34cd9c8c671c9af6f222d47ee79d66aa5a3ff14.tar.gz
netsurf-a34cd9c8c671c9af6f222d47ee79d66aa5a3ff14.tar.bz2
Take CSS System Colours from the RISC OS Desktop palette at start and on mode/palette change.
Need to revisit and confirm some of the mappings. svn path=/trunk/netsurf/; revision=11814
Diffstat (limited to 'riscos')
-rw-r--r--riscos/gui.c7
-rw-r--r--riscos/system_colour.c384
-rw-r--r--riscos/system_colour.h34
3 files changed, 269 insertions, 156 deletions
diff --git a/riscos/gui.c b/riscos/gui.c
index e7ca63741..2ef625863 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -86,6 +86,7 @@
#include "riscos/query.h"
#include "riscos/save.h"
#include "riscos/sslcert.h"
+#include "riscos/system_colour.h"
#include "riscos/textselection.h"
#include "riscos/theme.h"
#include "riscos/toolbar.h"
@@ -212,6 +213,7 @@ static ns_wimp_message_list task_messages = {
message_DRAGGING,
message_DRAG_CLAIM,
message_MODE_CHANGE,
+ message_PALETTE_CHANGE,
message_FONT_CHANGED,
message_URI_PROCESS,
message_URI_RETURN_RESULT,
@@ -1339,6 +1341,11 @@ void ro_gui_user_message(wimp_event_no event, wimp_message *message)
case message_MODE_CHANGE:
ro_gui_get_screen_properties();
rufl_invalidate_cache();
+ ro_gui_system_colour_update();
+ break;
+
+ case message_PALETTE_CHANGE:
+ ro_gui_system_colour_update();
break;
case message_FONT_CHANGED:
diff --git a/riscos/system_colour.c b/riscos/system_colour.c
index b58717492..dbb909c36 100644
--- a/riscos/system_colour.c
+++ b/riscos/system_colour.c
@@ -21,189 +21,225 @@
*
*/
+#include "oslib/os.h"
+#include "oslib/wimp.h"
#include "utils/utils.h"
#include "utils/log.h"
#include "desktop/gui.h"
#include "desktop/options.h"
+#include "riscos/system_colour.h"
struct gui_system_colour_ctx {
const char *name;
int length;
css_color colour;
+ wimp_colour system_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
+/* \TODO -- The wimp_COLOUR_... values in the table below map the colour
+ * definitions to parts of the RISC OS desktop palette. In places
+ * this is fairly arbitrary, and could probably do with re-checking.
+ */
+
+static struct gui_system_colour_ctx colour_list[] = {
+ {
+ "ActiveBorder",
+ SLEN("ActiveBorder"),
+ 0xff000000,
+ wimp_COLOUR_BLACK,
+ &option_sys_colour_ActiveBorder,
+ NULL
}, {
- "ButtonFace",
- SLEN("ButtonFace"),
- 0xffaaaaaa,
- &option_sys_colour_ButtonFace,
- NULL
+ "ActiveCaption",
+ SLEN("ActiveCaption"),
+ 0xffdddddd,
+ wimp_COLOUR_CREAM,
+ &option_sys_colour_ActiveCaption,
+ NULL
}, {
- "ButtonHighlight",
- SLEN("ButtonHighlight"),
- 0xffdddddd,
- &option_sys_colour_ButtonHighlight,
+ "AppWorkspace",
+ SLEN("AppWorkspace"),
+ 0xffeeeeee,
+ wimp_COLOUR_VERY_LIGHT_GREY,
+ &option_sys_colour_AppWorkspace,
NULL
}, {
- "ButtonShadow",
- SLEN("ButtonShadow"),
- 0xffbbbbbb,
- &option_sys_colour_ButtonShadow,
- NULL
+ "Background",
+ SLEN("Background"),
+ 0xff0000aa,
+ wimp_COLOUR_VERY_LIGHT_GREY, /* \TODO -- Check */
+ &option_sys_colour_Background,
+ NULL
}, {
- "ButtonText",
- SLEN("ButtonText"),
- 0xff000000,
- &option_sys_colour_ButtonText,
- NULL
+ "ButtonFace",
+ SLEN("ButtonFace"),
+ 0xffaaaaaa,
+ wimp_COLOUR_VERY_LIGHT_GREY,
+ &option_sys_colour_ButtonFace,
+ NULL
}, {
- "CaptionText",
- SLEN("CaptionText"),
- 0xff000000,
- &option_sys_colour_CaptionText,
- NULL
+ "ButtonHighlight",
+ SLEN("ButtonHighlight"),
+ 0xffdddddd,
+ wimp_COLOUR_DARK_GREY, /* \TODO -- Check */
+ &option_sys_colour_ButtonHighlight,
+ NULL
}, {
- "GrayText",
- SLEN("GrayText"),
- 0xffcccccc,
- &option_sys_colour_GrayText,
- NULL
+ "ButtonShadow",
+ SLEN("ButtonShadow"),
+ 0xffbbbbbb,
+ wimp_COLOUR_MID_DARK_GREY,
+ &option_sys_colour_ButtonShadow,
+ NULL
}, {
- "Highlight",
- SLEN("Highlight"),
- 0xff0000ee,
- &option_sys_colour_Highlight,
- NULL
+ "ButtonText",
+ SLEN("ButtonText"),
+ 0xff000000,
+ wimp_COLOUR_BLACK,
+ &option_sys_colour_ButtonText,
+ NULL
}, {
- "HighlightText",
- SLEN("HighlightText"),
- 0xff000000,
- &option_sys_colour_HighlightText,
- NULL
+ "CaptionText",
+ SLEN("CaptionText"),
+ 0xff000000,
+ wimp_COLOUR_BLACK,
+ &option_sys_colour_CaptionText,
+ NULL
}, {
- "InactiveBorder",
- SLEN("InactiveBorder"),
- 0xffffffff,
- &option_sys_colour_InactiveBorder,
- NULL
+ "GrayText",
+ SLEN("GrayText"),
+ 0xffcccccc,
+ wimp_COLOUR_MID_LIGHT_GREY, /* \TODO -- Check */
+ &option_sys_colour_GrayText,
+ NULL
}, {
- "InactiveCaption",
- SLEN("InactiveCaption"),
- 0xffffffff,
- &option_sys_colour_InactiveCaption,
- NULL
+ "Highlight",
+ SLEN("Highlight"),
+ 0xff0000ee,
+ wimp_COLOUR_BLACK,
+ &option_sys_colour_Highlight,
+ NULL
}, {
- "InactiveCaptionText",
- SLEN("InactiveCaptionText"),
- 0xffcccccc,
- &option_sys_colour_InactiveCaptionText,
- NULL
+ "HighlightText",
+ SLEN("HighlightText"),
+ 0xff000000,
+ wimp_COLOUR_WHITE,
+ &option_sys_colour_HighlightText,
+ NULL
}, {
- "InfoBackground",
- SLEN("InfoBackground"),
- 0xffaaaaaa,
- &option_sys_colour_InfoBackground,
- NULL
+ "InactiveBorder",
+ SLEN("InactiveBorder"),
+ 0xffffffff,
+ wimp_COLOUR_BLACK,
+ &option_sys_colour_InactiveBorder,
+ NULL
+ }, {
+ "InactiveCaption",
+ SLEN("InactiveCaption"),
+ 0xffffffff,
+ wimp_COLOUR_LIGHT_GREY,
+ &option_sys_colour_InactiveCaption,
+ NULL
+ }, {
+ "InactiveCaptionText",
+ SLEN("InactiveCaptionText"),
+ 0xffcccccc,
+ wimp_COLOUR_BLACK,
+ &option_sys_colour_InactiveCaptionText,
+ NULL
+ }, {
+ "InfoBackground",
+ SLEN("InfoBackground"),
+ 0xffaaaaaa,
+ wimp_COLOUR_CREAM,
+ &option_sys_colour_InfoBackground,
+ NULL
}, {
- "InfoText",
- SLEN("InfoText"),
- 0xff000000,
- &option_sys_colour_InfoText,
- NULL
+ "InfoText",
+ SLEN("InfoText"),
+ 0xff000000,
+ wimp_COLOUR_BLACK,
+ &option_sys_colour_InfoText,
+ NULL
}, {
- "Menu",
- SLEN("Menu"),
- 0xffaaaaaa,
- &option_sys_colour_Menu,
- NULL
+ "Menu",
+ SLEN("Menu"),
+ 0xffaaaaaa,
+ wimp_COLOUR_WHITE,
+ &option_sys_colour_Menu,
+ NULL
}, {
- "MenuText",
- SLEN("MenuText"),
- 0xff000000,
- &option_sys_colour_MenuText,
- NULL
+ "MenuText",
+ SLEN("MenuText"),
+ 0xff000000,
+ wimp_COLOUR_BLACK,
+ &option_sys_colour_MenuText,
+ NULL
}, {
- "Scrollbar",
- SLEN("Scrollbar"),
- 0xffaaaaaa,
- &option_sys_colour_Scrollbar,
- NULL
+ "Scrollbar",
+ SLEN("Scrollbar"),
+ 0xffaaaaaa,
+ wimp_COLOUR_LIGHT_GREY, /* \TODO -- Check */
+ &option_sys_colour_Scrollbar,
+ NULL
}, {
- "ThreeDDarkShadow",
- SLEN("ThreeDDarkShadow"),
- 0xff555555,
- &option_sys_colour_ThreeDDarkShadow,
- NULL
+ "ThreeDDarkShadow",
+ SLEN("ThreeDDarkShadow"),
+ 0xff555555,
+ wimp_COLOUR_MID_DARK_GREY,
+ &option_sys_colour_ThreeDDarkShadow,
+ NULL
}, {
- "ThreeDFace",
- SLEN("ThreeDFace"),
- 0xffdddddd,
- &option_sys_colour_ThreeDFace,
- NULL
+ "ThreeDFace",
+ SLEN("ThreeDFace"),
+ 0xffdddddd,
+ wimp_COLOUR_VERY_LIGHT_GREY,
+ &option_sys_colour_ThreeDFace,
+ NULL
}, {
- "ThreeDHighlight",
- SLEN("ThreeDHighlight"),
- 0xffaaaaaa,
- &option_sys_colour_ThreeDHighlight,
- NULL
+ "ThreeDHighlight",
+ SLEN("ThreeDHighlight"),
+ 0xffaaaaaa,
+ wimp_COLOUR_WHITE,
+ &option_sys_colour_ThreeDHighlight,
+ NULL
}, {
- "ThreeDLightShadow",
- SLEN("ThreeDLightShadow"),
- 0xff999999,
- &option_sys_colour_ThreeDLightShadow,
- NULL
+ "ThreeDLightShadow",
+ SLEN("ThreeDLightShadow"),
+ 0xff999999,
+ wimp_COLOUR_WHITE,
+ &option_sys_colour_ThreeDLightShadow,
+ NULL
}, {
- "ThreeDShadow",
- SLEN("ThreeDShadow"),
- 0xff777777,
- &option_sys_colour_ThreeDShadow,
- NULL
+ "ThreeDShadow",
+ SLEN("ThreeDShadow"),
+ 0xff777777,
+ wimp_COLOUR_MID_DARK_GREY,
+ &option_sys_colour_ThreeDShadow,
+ NULL
}, {
- "Window",
- SLEN("Window"),
- 0xffaaaaaa,
- &option_sys_colour_Window,
- NULL
+ "Window",
+ SLEN("Window"),
+ 0xffaaaaaa,
+ wimp_COLOUR_VERY_LIGHT_GREY,
+ &option_sys_colour_Window,
+ NULL
}, {
- "WindowFrame",
- SLEN("WindowFrame"),
- 0xff000000,
- &option_sys_colour_WindowFrame,
- NULL
+ "WindowFrame",
+ SLEN("WindowFrame"),
+ 0xff000000,
+ wimp_COLOUR_BLACK,
+ &option_sys_colour_WindowFrame,
+ NULL
}, {
-
- "WindowText",
- SLEN("WindowText"),
- 0xff000000,
- &option_sys_colour_WindowText,
- NULL
+ "WindowText",
+ SLEN("WindowText"),
+ 0xff000000,
+ wimp_COLOUR_BLACK,
+ &option_sys_colour_WindowText,
+ NULL
},
};
@@ -212,19 +248,18 @@ static struct gui_system_colour_ctx colour_list[] = {
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)
+ 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) {
+ if (lwc_intern_string(colour_list[ccount].name,
+ colour_list[ccount].length,
+ &(colour_list[ccount].lwcstr)) != lwc_error_ok) {
return false;
}
}
@@ -232,12 +267,15 @@ bool gui_system_colour_init(void)
/* 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);
+ colour_list[ccount].colour =
+ *(colour_list[ccount].option_colour);
}
}
+ ro_gui_system_colour_update();
+
gui_system_colour_pw = colour_list;
-
+
return true;
}
@@ -256,8 +294,8 @@ colour gui_system_colour_char(char *name)
unsigned int ccount;
for (ccount = 0; ccount < colour_list_len; ccount++) {
- if (strncasecmp(name,
- colour_list[ccount].name,
+ if (strncasecmp(name,
+ colour_list[ccount].name,
colour_list[ccount].length) == 0) {
ret = colour_list[ccount].colour;
break;
@@ -272,13 +310,47 @@ css_error gui_system_colour(void *pw, lwc_string *name, css_color *colour)
bool match;
for (ccount = 0; ccount < colour_list_len; ccount++) {
- if (lwc_string_caseless_isequal(name,
+ 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;
}
+
+
+#define ro_gui_system_colour_convert_os_to_css(os) (0xff000000 | \
+ (((os) & 0x0000ff00) << 8) | \
+ (((os) & 0x00ff0000) >> 8) | \
+ (((os) & 0xff000000) >> 24))
+
+
+/* This is a exported interface for the RISC OS frontend,
+ * documented in riscos/system_colour.h
+ */
+
+void ro_gui_system_colour_update(void)
+{
+ os_error *error;
+ os_PALETTE(20) palette;
+ unsigned int ccount;
+
+ error = xwimp_read_palette((os_palette *) &palette);
+ if (error != NULL) {
+ LOG(("xwimp_read_palette: 0x%x: %s",
+ error->errnum, error->errmess));
+ return;
+ }
+
+ for (ccount = 0; ccount < colour_list_len; ccount++) {
+ if (*(colour_list[ccount].option_colour) == 0) {
+ colour_list[ccount].colour =
+ ro_gui_system_colour_convert_os_to_css(
+ palette.entries[colour_list[ccount].
+ system_colour]);
+ }
+ }
+}
diff --git a/riscos/system_colour.h b/riscos/system_colour.h
new file mode 100644
index 000000000..a6672e305
--- /dev/null
+++ b/riscos/system_colour.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2011 Stephen Fryatt <stevef@netsurf-browser.org>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+/** \file
+ * System colour handling (frontend internal interface)
+ */
+
+#ifndef _NETSURF_RISCOS_SYSTEM_COLOUR_H_
+#define _NETSURF_RISCOS_SYSTEM_COLOUR_H_
+
+/**
+ * Scan the CSS system colour definitions, and update any that haven't been
+ * overridden in NetSurf's options to reflect the current Desktop palette.
+ */
+
+void ro_gui_system_colour_update(void);
+
+#endif
+