2011-01-30 16:40:47 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2011 Vincent Sanders <vince@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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-01-30 20:25:36 +03:00
|
|
|
#define __STDBOOL_H__ 1
|
|
|
|
#include <assert.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#include <InterfaceDefs.h>
|
2011-01-30 22:23:42 +03:00
|
|
|
#include <Screen.h>
|
2011-01-30 20:25:36 +03:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
2011-01-30 16:40:47 +03:00
|
|
|
#include "utils/utils.h"
|
|
|
|
#include "utils/log.h"
|
|
|
|
#include "desktop/gui.h"
|
|
|
|
#include "desktop/options.h"
|
2011-01-30 20:25:36 +03:00
|
|
|
#include "desktop/plot_style.h"
|
|
|
|
|
|
|
|
}
|
2011-01-30 16:40:47 +03:00
|
|
|
|
2011-01-30 22:23:42 +03:00
|
|
|
#include "beos/beos_gui.h"
|
|
|
|
|
|
|
|
|
|
|
|
#if !defined(__HAIKU__) && !defined(B_BEOS_VERSION_DANO)
|
|
|
|
/* more ui_colors, R5 only had a few defined... */
|
|
|
|
#define B_PANEL_TEXT_COLOR ((color_which)10)
|
|
|
|
#define B_DOCUMENT_BACKGROUND_COLOR ((color_which)11)
|
|
|
|
#define B_DOCUMENT_TEXT_COLOR ((color_which)12)
|
|
|
|
#define B_CONTROL_BACKGROUND_COLOR ((color_which)13)
|
|
|
|
#define B_CONTROL_TEXT_COLOR ((color_which)14)
|
|
|
|
#define B_CONTROL_BORDER_COLOR ((color_which)15)
|
|
|
|
#define B_CONTROL_HIGHLIGHT_COLOR ((color_which)16)
|
|
|
|
#define B_NAVIGATION_BASE_COLOR ((color_which)4)
|
|
|
|
#define B_NAVIGATION_PULSE_COLOR ((color_which)17)
|
|
|
|
#define B_SHINE_COLOR ((color_which)18)
|
|
|
|
#define B_SHADOW_COLOR ((color_which)19)
|
|
|
|
#define B_MENU_SELECTED_BORDER_COLOR ((color_which)9)
|
|
|
|
#define B_TOOLTIP_BACKGROUND_COLOR ((color_which)20)
|
|
|
|
#define B_TOOLTIP_TEXT_COLOR ((color_which)21)
|
|
|
|
#define B_SUCCESS_COLOR ((color_which)100)
|
|
|
|
#define B_FAILURE_COLOR ((color_which)101)
|
|
|
|
#define B_MENU_SELECTED_BACKGROUND_COLOR B_MENU_SELECTION_BACKGROUND_COLOR
|
|
|
|
#define B_RANDOM_COLOR ((color_which)0x80000000)
|
|
|
|
#define B_MICHELANGELO_FAVORITE_COLOR ((color_which)0x80000001)
|
|
|
|
#define B_DSANDLER_FAVORITE_SKY_COLOR ((color_which)0x80000002)
|
|
|
|
#define B_DSANDLER_FAVORITE_INK_COLOR ((color_which)0x80000003)
|
|
|
|
#define B_DSANDLER_FAVORITE_SHOES_COLOR ((color_which)0x80000004)
|
|
|
|
#define B_DAVE_BROWN_FAVORITE_COLOR ((color_which)0x80000005)
|
|
|
|
#endif
|
|
|
|
#define NOCOL ((color_which)0)
|
|
|
|
|
|
|
|
|
2011-01-30 16:40:47 +03:00
|
|
|
struct gui_system_colour_ctx {
|
|
|
|
const char *name;
|
|
|
|
int length;
|
2011-01-30 20:25:36 +03:00
|
|
|
css_color css_colour;
|
2011-01-30 16:40:47 +03:00
|
|
|
colour *option_colour;
|
|
|
|
lwc_string *lwcstr;
|
2011-01-30 22:23:42 +03:00
|
|
|
color_which ui;
|
2011-01-30 16:40:47 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct gui_system_colour_ctx colour_list[] = {
|
|
|
|
{
|
|
|
|
"ActiveBorder",
|
|
|
|
SLEN("ActiveBorder"),
|
|
|
|
0xff000000,
|
|
|
|
&option_sys_colour_ActiveBorder,
|
2011-01-30 22:23:42 +03:00
|
|
|
NULL,
|
|
|
|
NOCOL
|
2011-01-30 16:40:47 +03:00
|
|
|
}, {
|
|
|
|
"ActiveCaption",
|
|
|
|
SLEN("ActiveCaption"),
|
|
|
|
0xffdddddd,
|
|
|
|
&option_sys_colour_ActiveCaption,
|
2011-01-30 22:23:42 +03:00
|
|
|
NULL,
|
|
|
|
B_WINDOW_TAB_COLOR
|
2011-01-30 16:40:47 +03:00
|
|
|
}, {
|
|
|
|
"AppWorkspace",
|
|
|
|
SLEN("AppWorkspace"),
|
|
|
|
0xffeeeeee,
|
|
|
|
&option_sys_colour_AppWorkspace,
|
2011-01-30 22:23:42 +03:00
|
|
|
NULL,
|
|
|
|
B_PANEL_BACKGROUND_COLOR
|
2011-01-30 16:40:47 +03:00
|
|
|
}, {
|
|
|
|
"Background",
|
|
|
|
SLEN("Background"),
|
|
|
|
0xff0000aa,
|
|
|
|
&option_sys_colour_Background,
|
2011-01-30 22:23:42 +03:00
|
|
|
NULL,
|
|
|
|
B_DESKTOP_COLOR
|
2011-01-30 16:40:47 +03:00
|
|
|
}, {
|
|
|
|
"ButtonFace",
|
|
|
|
SLEN("ButtonFace"),
|
|
|
|
0xffaaaaaa,
|
|
|
|
&option_sys_colour_ButtonFace,
|
2011-01-30 22:23:42 +03:00
|
|
|
NULL,
|
|
|
|
B_CONTROL_BACKGROUND_COLOR
|
2011-01-30 16:40:47 +03:00
|
|
|
}, {
|
|
|
|
"ButtonHighlight",
|
|
|
|
SLEN("ButtonHighlight"),
|
|
|
|
0xffdddddd,
|
|
|
|
&option_sys_colour_ButtonHighlight,
|
2011-01-30 22:23:42 +03:00
|
|
|
NULL,
|
|
|
|
B_CONTROL_HIGHLIGHT_COLOR
|
2011-01-30 16:40:47 +03:00
|
|
|
}, {
|
|
|
|
"ButtonShadow",
|
|
|
|
SLEN("ButtonShadow"),
|
|
|
|
0xffbbbbbb,
|
|
|
|
&option_sys_colour_ButtonShadow,
|
2011-01-30 22:23:42 +03:00
|
|
|
NULL,
|
|
|
|
NOCOL
|
2011-01-30 16:40:47 +03:00
|
|
|
}, {
|
|
|
|
"ButtonText",
|
|
|
|
SLEN("ButtonText"),
|
|
|
|
0xff000000,
|
|
|
|
&option_sys_colour_ButtonText,
|
2011-01-30 22:23:42 +03:00
|
|
|
NULL,
|
|
|
|
B_CONTROL_TEXT_COLOR
|
2011-01-30 16:40:47 +03:00
|
|
|
}, {
|
|
|
|
"CaptionText",
|
|
|
|
SLEN("CaptionText"),
|
|
|
|
0xff000000,
|
|
|
|
&option_sys_colour_CaptionText,
|
2011-01-30 22:23:42 +03:00
|
|
|
NULL,
|
|
|
|
NOCOL
|
2011-01-30 16:40:47 +03:00
|
|
|
}, {
|
|
|
|
"GrayText",
|
|
|
|
SLEN("GrayText"),
|
|
|
|
0xffcccccc,
|
|
|
|
&option_sys_colour_GrayText,
|
2011-01-30 22:23:42 +03:00
|
|
|
NULL,
|
|
|
|
NOCOL
|
2011-01-30 16:40:47 +03:00
|
|
|
}, {
|
|
|
|
"Highlight",
|
|
|
|
SLEN("Highlight"),
|
|
|
|
0xff0000ee,
|
|
|
|
&option_sys_colour_Highlight,
|
2011-01-30 22:23:42 +03:00
|
|
|
NULL,
|
|
|
|
NOCOL
|
2011-01-30 16:40:47 +03:00
|
|
|
}, {
|
|
|
|
"HighlightText",
|
|
|
|
SLEN("HighlightText"),
|
|
|
|
0xff000000,
|
|
|
|
&option_sys_colour_HighlightText,
|
2011-01-30 22:23:42 +03:00
|
|
|
NULL,
|
|
|
|
NOCOL
|
2011-01-30 16:40:47 +03:00
|
|
|
}, {
|
|
|
|
"InactiveBorder",
|
|
|
|
SLEN("InactiveBorder"),
|
|
|
|
0xffffffff,
|
|
|
|
&option_sys_colour_InactiveBorder,
|
2011-01-30 22:23:42 +03:00
|
|
|
NULL,
|
|
|
|
NOCOL
|
2011-01-30 16:40:47 +03:00
|
|
|
}, {
|
|
|
|
"InactiveCaption",
|
|
|
|
SLEN("InactiveCaption"),
|
|
|
|
0xffffffff,
|
|
|
|
&option_sys_colour_InactiveCaption,
|
2011-01-30 22:23:42 +03:00
|
|
|
NULL,
|
|
|
|
NOCOL
|
2011-01-30 16:40:47 +03:00
|
|
|
}, {
|
|
|
|
"InactiveCaptionText",
|
|
|
|
SLEN("InactiveCaptionText"),
|
|
|
|
0xffcccccc,
|
|
|
|
&option_sys_colour_InactiveCaptionText,
|
2011-01-30 22:23:42 +03:00
|
|
|
NULL,
|
|
|
|
NOCOL
|
2011-01-30 16:40:47 +03:00
|
|
|
}, {
|
|
|
|
"InfoBackground",
|
|
|
|
SLEN("InfoBackground"),
|
|
|
|
0xffaaaaaa,
|
|
|
|
&option_sys_colour_InfoBackground,
|
2011-01-30 22:23:42 +03:00
|
|
|
NULL,
|
|
|
|
B_TOOLTIP_BACKGROUND_COLOR
|
2011-01-30 16:40:47 +03:00
|
|
|
}, {
|
|
|
|
"InfoText",
|
|
|
|
SLEN("InfoText"),
|
|
|
|
0xff000000,
|
|
|
|
&option_sys_colour_InfoText,
|
2011-01-30 22:23:42 +03:00
|
|
|
NULL,
|
|
|
|
B_TOOLTIP_TEXT_COLOR
|
2011-01-30 16:40:47 +03:00
|
|
|
}, {
|
|
|
|
"Menu",
|
|
|
|
SLEN("Menu"),
|
|
|
|
0xffaaaaaa,
|
|
|
|
&option_sys_colour_Menu,
|
2011-01-30 22:23:42 +03:00
|
|
|
NULL,
|
|
|
|
B_MENU_BACKGROUND_COLOR
|
2011-01-30 16:40:47 +03:00
|
|
|
}, {
|
|
|
|
"MenuText",
|
|
|
|
SLEN("MenuText"),
|
|
|
|
0xff000000,
|
|
|
|
&option_sys_colour_MenuText,
|
2011-01-30 22:23:42 +03:00
|
|
|
NULL,
|
|
|
|
B_MENU_ITEM_TEXT_COLOR
|
2011-01-30 16:40:47 +03:00
|
|
|
}, {
|
|
|
|
"Scrollbar",
|
|
|
|
SLEN("Scrollbar"),
|
|
|
|
0xffaaaaaa,
|
|
|
|
&option_sys_colour_Scrollbar,
|
2011-01-30 22:23:42 +03:00
|
|
|
NULL,
|
|
|
|
NOCOL
|
2011-01-30 16:40:47 +03:00
|
|
|
}, {
|
|
|
|
"ThreeDDarkShadow",
|
|
|
|
SLEN("ThreeDDarkShadow"),
|
|
|
|
0xff555555,
|
|
|
|
&option_sys_colour_ThreeDDarkShadow,
|
2011-01-30 22:23:42 +03:00
|
|
|
NULL,
|
|
|
|
NOCOL
|
2011-01-30 16:40:47 +03:00
|
|
|
}, {
|
|
|
|
"ThreeDFace",
|
|
|
|
SLEN("ThreeDFace"),
|
|
|
|
0xffdddddd,
|
|
|
|
&option_sys_colour_ThreeDFace,
|
2011-01-30 22:23:42 +03:00
|
|
|
NULL,
|
|
|
|
NOCOL
|
2011-01-30 16:40:47 +03:00
|
|
|
}, {
|
|
|
|
"ThreeDHighlight",
|
|
|
|
SLEN("ThreeDHighlight"),
|
|
|
|
0xffaaaaaa,
|
|
|
|
&option_sys_colour_ThreeDHighlight,
|
2011-01-30 22:23:42 +03:00
|
|
|
NULL,
|
|
|
|
NOCOL
|
2011-01-30 16:40:47 +03:00
|
|
|
}, {
|
|
|
|
"ThreeDLightShadow",
|
|
|
|
SLEN("ThreeDLightShadow"),
|
|
|
|
0xff999999,
|
|
|
|
&option_sys_colour_ThreeDLightShadow,
|
2011-01-30 22:23:42 +03:00
|
|
|
NULL,
|
|
|
|
NOCOL
|
2011-01-30 16:40:47 +03:00
|
|
|
}, {
|
|
|
|
"ThreeDShadow",
|
|
|
|
SLEN("ThreeDShadow"),
|
|
|
|
0xff777777,
|
|
|
|
&option_sys_colour_ThreeDShadow,
|
2011-01-30 22:23:42 +03:00
|
|
|
NULL,
|
|
|
|
NOCOL
|
2011-01-30 16:40:47 +03:00
|
|
|
}, {
|
|
|
|
"Window",
|
|
|
|
SLEN("Window"),
|
|
|
|
0xffaaaaaa,
|
|
|
|
&option_sys_colour_Window,
|
2011-01-30 22:23:42 +03:00
|
|
|
NULL,
|
|
|
|
B_DOCUMENT_BACKGROUND_COLOR
|
2011-01-30 16:40:47 +03:00
|
|
|
}, {
|
|
|
|
"WindowFrame",
|
|
|
|
SLEN("WindowFrame"),
|
|
|
|
0xff000000,
|
|
|
|
&option_sys_colour_WindowFrame,
|
2011-01-30 22:23:42 +03:00
|
|
|
NULL,
|
|
|
|
NOCOL
|
2011-01-30 16:40:47 +03:00
|
|
|
}, {
|
|
|
|
|
|
|
|
"WindowText",
|
|
|
|
SLEN("WindowText"),
|
|
|
|
0xff000000,
|
|
|
|
&option_sys_colour_WindowText,
|
2011-01-30 22:23:42 +03:00
|
|
|
NULL,
|
|
|
|
B_DOCUMENT_TEXT_COLOR
|
2011-01-30 16:40:47 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#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) {
|
2011-01-30 20:25:36 +03:00
|
|
|
colour_list[ccount].css_colour = *(colour_list[ccount].option_colour);
|
2011-01-30 16:40:47 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-30 22:23:42 +03:00
|
|
|
nsbeos_update_system_ui_colors();
|
|
|
|
|
2011-01-30 16:40:47 +03:00
|
|
|
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) {
|
2011-01-30 20:25:36 +03:00
|
|
|
ret = colour_list[ccount].css_colour;
|
2011-01-30 16:40:47 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-01-30 20:25:36 +03:00
|
|
|
css_error gui_system_colour(void *pw, lwc_string *name, css_color *css_colour)
|
2011-01-30 16:40:47 +03:00
|
|
|
{
|
|
|
|
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) {
|
2011-01-30 20:25:36 +03:00
|
|
|
*css_colour = colour_list[ccount].css_colour;
|
2011-01-30 16:40:47 +03:00
|
|
|
return CSS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return CSS_INVALID;
|
|
|
|
}
|
2011-01-30 22:23:42 +03:00
|
|
|
|
|
|
|
void nsbeos_update_system_ui_colors(void)
|
|
|
|
{
|
|
|
|
unsigned int ccount;
|
|
|
|
|
|
|
|
for (ccount = 0; ccount < colour_list_len; ccount++) {
|
|
|
|
if (colour_list[ccount].ui == NOCOL)
|
|
|
|
continue;
|
|
|
|
rgb_color c = ui_color(colour_list[ccount].ui);
|
|
|
|
if (colour_list[ccount].ui == B_DESKTOP_COLOR) {
|
|
|
|
BScreen s;
|
|
|
|
c = s.DesktopColor();
|
|
|
|
}
|
|
|
|
|
|
|
|
//printf("uic[%d] = ui_color(%d) %02x %02x %02x %02x\n", ccount,
|
|
|
|
// colour_list[ccount].ui, c.red, c.green, c.blue, c.alpha);
|
|
|
|
|
|
|
|
colour_list[ccount].css_colour = 0xff000000
|
|
|
|
| ((((uint32_t)c.red << 16) & 0xff0000)
|
|
|
|
| ((c.green << 8) & 0x00ff00)
|
|
|
|
| ((c.blue) & 0x0000ff));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|