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:30:32 +03:00
|
|
|
#include "amiga/gui.h"
|
2011-01-30 16:40:47 +03:00
|
|
|
#include "utils/utils.h"
|
|
|
|
#include "utils/log.h"
|
|
|
|
#include "desktop/gui.h"
|
|
|
|
#include "desktop/options.h"
|
2012-03-27 01:13:00 +04:00
|
|
|
#include "desktop/tree.h"
|
2011-01-30 16:40:47 +03:00
|
|
|
|
2011-01-30 20:30:32 +03:00
|
|
|
#include <proto/graphics.h>
|
|
|
|
#include <proto/intuition.h>
|
2011-07-03 21:22:23 +04:00
|
|
|
#include <proto/Picasso96API.h>
|
2011-07-03 22:20:18 +04:00
|
|
|
#include <intuition/gui.h>
|
2011-01-30 20:30:32 +03:00
|
|
|
#include <intuition/screens.h>
|
|
|
|
|
2011-07-03 22:20:18 +04:00
|
|
|
#define AMINS_SCROLLERPEN NUMDRIPENS
|
|
|
|
|
2011-01-30 16:40:47 +03:00
|
|
|
struct gui_system_colour_ctx {
|
|
|
|
const char *name;
|
|
|
|
int length;
|
|
|
|
css_color colour;
|
|
|
|
colour *option_colour;
|
2011-01-30 20:30:32 +03:00
|
|
|
UWORD amiga_pen;
|
2011-01-30 16:40:47 +03:00
|
|
|
lwc_string *lwcstr;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct gui_system_colour_ctx colour_list[] = {
|
|
|
|
{
|
|
|
|
"ActiveBorder",
|
|
|
|
SLEN("ActiveBorder"),
|
|
|
|
0xff000000,
|
2012-03-22 13:34:34 +04:00
|
|
|
&nsoption_colour(sys_colour_ActiveBorder),
|
2011-01-30 20:30:32 +03:00
|
|
|
FILLPEN,
|
2011-01-30 16:40:47 +03:00
|
|
|
NULL
|
|
|
|
}, {
|
|
|
|
"ActiveCaption",
|
|
|
|
SLEN("ActiveCaption"),
|
|
|
|
0xffdddddd,
|
2012-03-22 13:34:34 +04:00
|
|
|
&nsoption_colour(sys_colour_ActiveCaption),
|
2011-01-30 20:30:32 +03:00
|
|
|
FILLPEN,
|
2011-01-30 16:40:47 +03:00
|
|
|
NULL
|
|
|
|
}, {
|
|
|
|
"AppWorkspace",
|
|
|
|
SLEN("AppWorkspace"),
|
|
|
|
0xffeeeeee,
|
2012-03-22 13:34:34 +04:00
|
|
|
&nsoption_colour(sys_colour_AppWorkspace),
|
2011-01-30 20:30:32 +03:00
|
|
|
BACKGROUNDPEN,
|
2011-01-30 16:40:47 +03:00
|
|
|
NULL
|
|
|
|
}, {
|
|
|
|
"Background",
|
|
|
|
SLEN("Background"),
|
|
|
|
0xff0000aa,
|
2012-03-22 13:34:34 +04:00
|
|
|
&nsoption_colour(sys_colour_Background),
|
2011-01-30 20:30:32 +03:00
|
|
|
BACKGROUNDPEN,
|
2011-01-30 16:40:47 +03:00
|
|
|
NULL
|
|
|
|
}, {
|
|
|
|
"ButtonFace",
|
|
|
|
SLEN("ButtonFace"),
|
|
|
|
0xffaaaaaa,
|
2012-03-22 13:34:34 +04:00
|
|
|
&nsoption_colour(sys_colour_ButtonFace),
|
2011-01-30 20:30:32 +03:00
|
|
|
FOREGROUNDPEN,
|
2011-01-30 16:40:47 +03:00
|
|
|
NULL
|
|
|
|
}, {
|
|
|
|
"ButtonHighlight",
|
|
|
|
SLEN("ButtonHighlight"),
|
|
|
|
0xffdddddd,
|
2012-03-22 13:34:34 +04:00
|
|
|
&nsoption_colour(sys_colour_ButtonHighlight),
|
2011-01-30 20:30:32 +03:00
|
|
|
FORESHINEPEN,
|
2011-01-30 16:40:47 +03:00
|
|
|
NULL
|
|
|
|
}, {
|
|
|
|
"ButtonShadow",
|
|
|
|
SLEN("ButtonShadow"),
|
|
|
|
0xffbbbbbb,
|
2012-03-22 13:34:34 +04:00
|
|
|
&nsoption_colour(sys_colour_ButtonShadow),
|
2011-01-30 20:30:32 +03:00
|
|
|
FORESHADOWPEN,
|
2011-01-30 16:40:47 +03:00
|
|
|
NULL
|
|
|
|
}, {
|
|
|
|
"ButtonText",
|
|
|
|
SLEN("ButtonText"),
|
|
|
|
0xff000000,
|
2012-03-22 13:34:34 +04:00
|
|
|
&nsoption_colour(sys_colour_ButtonText),
|
2011-01-30 20:30:32 +03:00
|
|
|
TEXTPEN,
|
2011-01-30 16:40:47 +03:00
|
|
|
NULL
|
|
|
|
}, {
|
|
|
|
"CaptionText",
|
|
|
|
SLEN("CaptionText"),
|
|
|
|
0xff000000,
|
2012-03-22 13:34:34 +04:00
|
|
|
&nsoption_colour(sys_colour_CaptionText),
|
2011-01-30 20:30:32 +03:00
|
|
|
FILLTEXTPEN,
|
2011-01-30 16:40:47 +03:00
|
|
|
NULL
|
|
|
|
}, {
|
|
|
|
"GrayText",
|
|
|
|
SLEN("GrayText"),
|
|
|
|
0xffcccccc,
|
2012-03-22 13:34:34 +04:00
|
|
|
&nsoption_colour(sys_colour_GrayText),
|
2011-01-30 20:30:32 +03:00
|
|
|
DISABLEDTEXTPEN,
|
2011-01-30 16:40:47 +03:00
|
|
|
NULL
|
|
|
|
}, {
|
|
|
|
"Highlight",
|
|
|
|
SLEN("Highlight"),
|
|
|
|
0xff0000ee,
|
2012-03-22 13:34:34 +04:00
|
|
|
&nsoption_colour(sys_colour_Highlight),
|
2011-01-30 20:30:32 +03:00
|
|
|
SELECTPEN,
|
2011-01-30 16:40:47 +03:00
|
|
|
NULL
|
|
|
|
}, {
|
|
|
|
"HighlightText",
|
|
|
|
SLEN("HighlightText"),
|
|
|
|
0xff000000,
|
2012-03-22 13:34:34 +04:00
|
|
|
&nsoption_colour(sys_colour_HighlightText),
|
2011-01-30 20:30:32 +03:00
|
|
|
SELECTTEXTPEN,
|
2011-01-30 16:40:47 +03:00
|
|
|
NULL
|
|
|
|
}, {
|
|
|
|
"InactiveBorder",
|
|
|
|
SLEN("InactiveBorder"),
|
|
|
|
0xffffffff,
|
2012-03-22 13:34:34 +04:00
|
|
|
&nsoption_colour(sys_colour_InactiveBorder),
|
2011-01-30 20:30:32 +03:00
|
|
|
INACTIVEFILLPEN,
|
2011-01-30 16:40:47 +03:00
|
|
|
NULL
|
|
|
|
}, {
|
|
|
|
"InactiveCaption",
|
|
|
|
SLEN("InactiveCaption"),
|
|
|
|
0xffffffff,
|
2012-03-22 13:34:34 +04:00
|
|
|
&nsoption_colour(sys_colour_InactiveCaption),
|
2011-01-30 20:30:32 +03:00
|
|
|
INACTIVEFILLPEN,
|
2011-01-30 16:40:47 +03:00
|
|
|
NULL
|
|
|
|
}, {
|
|
|
|
"InactiveCaptionText",
|
|
|
|
SLEN("InactiveCaptionText"),
|
|
|
|
0xffcccccc,
|
2012-03-22 13:34:34 +04:00
|
|
|
&nsoption_colour(sys_colour_InactiveCaptionText),
|
2011-01-30 20:30:32 +03:00
|
|
|
INACTIVEFILLTEXTPEN,
|
2011-01-30 16:40:47 +03:00
|
|
|
NULL
|
|
|
|
}, {
|
|
|
|
"InfoBackground",
|
|
|
|
SLEN("InfoBackground"),
|
|
|
|
0xffaaaaaa,
|
2012-03-22 13:34:34 +04:00
|
|
|
&nsoption_colour(sys_colour_InfoBackground),
|
2011-01-30 20:30:32 +03:00
|
|
|
BACKGROUNDPEN, /* This is wrong, HelpHint backgrounds are pale yellow but doesn't seem to be a DrawInfo pen defined for it. */
|
2011-01-30 16:40:47 +03:00
|
|
|
NULL
|
|
|
|
}, {
|
|
|
|
"InfoText",
|
|
|
|
SLEN("InfoText"),
|
|
|
|
0xff000000,
|
2012-03-22 13:34:34 +04:00
|
|
|
&nsoption_colour(sys_colour_InfoText),
|
2011-01-30 20:30:32 +03:00
|
|
|
TEXTPEN,
|
2011-01-30 16:40:47 +03:00
|
|
|
NULL
|
|
|
|
}, {
|
|
|
|
"Menu",
|
|
|
|
SLEN("Menu"),
|
|
|
|
0xffaaaaaa,
|
2012-03-22 13:34:34 +04:00
|
|
|
&nsoption_colour(sys_colour_Menu),
|
2011-01-30 20:30:32 +03:00
|
|
|
MENUBACKGROUNDPEN,
|
2011-01-30 16:40:47 +03:00
|
|
|
NULL
|
|
|
|
}, {
|
|
|
|
"MenuText",
|
|
|
|
SLEN("MenuText"),
|
|
|
|
0xff000000,
|
2012-03-22 13:34:34 +04:00
|
|
|
&nsoption_colour(sys_colour_MenuText),
|
2011-01-30 20:30:32 +03:00
|
|
|
MENUTEXTPEN,
|
2011-01-30 16:40:47 +03:00
|
|
|
NULL
|
|
|
|
}, {
|
|
|
|
"Scrollbar",
|
|
|
|
SLEN("Scrollbar"),
|
|
|
|
0xffaaaaaa,
|
2012-03-22 13:34:34 +04:00
|
|
|
&nsoption_colour(sys_colour_Scrollbar),
|
2011-07-03 22:20:18 +04:00
|
|
|
AMINS_SCROLLERPEN,
|
2011-01-30 16:40:47 +03:00
|
|
|
NULL
|
|
|
|
}, {
|
|
|
|
"ThreeDDarkShadow",
|
|
|
|
SLEN("ThreeDDarkShadow"),
|
|
|
|
0xff555555,
|
2012-03-22 13:34:34 +04:00
|
|
|
&nsoption_colour(sys_colour_ThreeDDarkShadow),
|
2011-01-30 20:30:32 +03:00
|
|
|
FORESHADOWPEN,
|
2011-01-30 16:40:47 +03:00
|
|
|
NULL
|
|
|
|
}, {
|
|
|
|
"ThreeDFace",
|
|
|
|
SLEN("ThreeDFace"),
|
|
|
|
0xffdddddd,
|
2012-03-22 13:34:34 +04:00
|
|
|
&nsoption_colour(sys_colour_ThreeDFace),
|
2011-01-30 20:30:32 +03:00
|
|
|
FOREGROUNDPEN,
|
2011-01-30 16:40:47 +03:00
|
|
|
NULL
|
|
|
|
}, {
|
|
|
|
"ThreeDHighlight",
|
|
|
|
SLEN("ThreeDHighlight"),
|
|
|
|
0xffaaaaaa,
|
2012-03-22 13:34:34 +04:00
|
|
|
&nsoption_colour(sys_colour_ThreeDHighlight),
|
2011-01-30 20:30:32 +03:00
|
|
|
FORESHINEPEN,
|
2011-01-30 16:40:47 +03:00
|
|
|
NULL
|
|
|
|
}, {
|
|
|
|
"ThreeDLightShadow",
|
|
|
|
SLEN("ThreeDLightShadow"),
|
|
|
|
0xff999999,
|
2012-03-22 13:34:34 +04:00
|
|
|
&nsoption_colour(sys_colour_ThreeDLightShadow),
|
2011-01-30 20:30:32 +03:00
|
|
|
HALFSHINEPEN,
|
2011-01-30 16:40:47 +03:00
|
|
|
NULL
|
|
|
|
}, {
|
|
|
|
"ThreeDShadow",
|
|
|
|
SLEN("ThreeDShadow"),
|
|
|
|
0xff777777,
|
2012-03-22 13:34:34 +04:00
|
|
|
&nsoption_colour(sys_colour_ThreeDShadow),
|
2011-01-30 20:30:32 +03:00
|
|
|
HALFSHADOWPEN,
|
2011-01-30 16:40:47 +03:00
|
|
|
NULL
|
|
|
|
}, {
|
|
|
|
"Window",
|
|
|
|
SLEN("Window"),
|
|
|
|
0xffaaaaaa,
|
2012-03-22 13:34:34 +04:00
|
|
|
&nsoption_colour(sys_colour_Window),
|
2011-01-30 20:30:32 +03:00
|
|
|
BACKGROUNDPEN,
|
2011-01-30 16:40:47 +03:00
|
|
|
NULL
|
|
|
|
}, {
|
|
|
|
"WindowFrame",
|
|
|
|
SLEN("WindowFrame"),
|
|
|
|
0xff000000,
|
2012-03-22 13:34:34 +04:00
|
|
|
&nsoption_colour(sys_colour_WindowFrame),
|
2011-01-30 20:30:32 +03:00
|
|
|
INACTIVEFILLPEN,
|
2011-01-30 16:40:47 +03:00
|
|
|
NULL
|
|
|
|
}, {
|
|
|
|
|
|
|
|
"WindowText",
|
|
|
|
SLEN("WindowText"),
|
|
|
|
0xff000000,
|
2012-03-22 13:34:34 +04:00
|
|
|
&nsoption_colour(sys_colour_WindowText),
|
2012-03-27 23:25:02 +04:00
|
|
|
TEXTPEN,
|
2011-01-30 16:40:47 +03:00
|
|
|
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;
|
|
|
|
|
2011-01-30 20:30:32 +03:00
|
|
|
css_color ami_css_colour_from_pen(struct Screen *screen, UWORD pen);
|
2011-01-30 16:40:47 +03:00
|
|
|
|
2011-07-03 22:20:18 +04:00
|
|
|
UWORD ami_system_colour_scrollbar_fgpen(struct DrawInfo *drinfo)
|
|
|
|
{
|
|
|
|
LONG scrollerfillpen = FALSE;
|
|
|
|
|
|
|
|
GetGUIAttrs(NULL, drinfo, GUIA_PropKnobColor, &scrollerfillpen, TAG_DONE);
|
|
|
|
|
|
|
|
if(scrollerfillpen) return FILLPEN;
|
|
|
|
else return FOREGROUNDPEN;
|
|
|
|
}
|
|
|
|
|
2011-01-30 16:40:47 +03:00
|
|
|
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);
|
|
|
|
}
|
2011-01-30 20:30:32 +03:00
|
|
|
else if(scrn) {
|
|
|
|
colour_list[ccount].colour =
|
|
|
|
ami_css_colour_from_pen(scrn, colour_list[ccount].amiga_pen);
|
|
|
|
}
|
2011-01-30 16:40:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
gui_system_colour_pw = colour_list;
|
2012-03-27 01:13:00 +04:00
|
|
|
tree_setup_colours();
|
|
|
|
|
2011-01-30 16:40:47 +03:00
|
|
|
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);
|
|
|
|
}
|
2011-01-30 20:30:32 +03:00
|
|
|
|
|
|
|
gui_system_colour_pw = NULL;
|
2011-01-30 16:40:47 +03:00
|
|
|
}
|
|
|
|
|
2012-03-27 23:25:02 +04:00
|
|
|
colour ami_css_color_to_colour(css_color c)
|
|
|
|
{
|
|
|
|
return (c & 0xFF00FF00) | ((c >> 16) & 0xFF) | ((c & 0xFF) << 16);
|
|
|
|
}
|
|
|
|
|
2012-03-27 14:47:29 +04:00
|
|
|
colour gui_system_colour_char(const char *name)
|
2011-01-30 16:40:47 +03:00
|
|
|
{
|
|
|
|
colour ret = 0xff00000;
|
|
|
|
unsigned int ccount;
|
|
|
|
|
|
|
|
for (ccount = 0; ccount < colour_list_len; ccount++) {
|
2012-03-27 15:02:35 +04:00
|
|
|
if (strcmp(name, colour_list[ccount].name) == 0) {
|
2012-03-27 23:25:02 +04:00
|
|
|
ret = ami_css_color_to_colour(colour_list[ccount].colour);
|
2011-01-30 16:40:47 +03:00
|
|
|
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;
|
|
|
|
}
|
2011-01-30 20:30:32 +03:00
|
|
|
|
|
|
|
css_color ami_css_colour_from_pen(struct Screen *screen, UWORD pen)
|
|
|
|
{
|
2011-01-31 01:57:56 +03:00
|
|
|
css_color css_colour = 0x00000000;
|
|
|
|
ULONG colour[3];
|
2011-01-30 20:30:32 +03:00
|
|
|
struct DrawInfo *drinfo = GetScreenDrawInfo(screen);
|
|
|
|
|
|
|
|
if(drinfo == NULL) return 0x00000000;
|
|
|
|
|
2011-07-03 22:20:18 +04:00
|
|
|
if(pen == AMINS_SCROLLERPEN) pen = ami_system_colour_scrollbar_fgpen(drinfo);
|
|
|
|
|
2011-01-31 01:57:56 +03:00
|
|
|
/* Get the colour of the pen being used for "pen" */
|
2011-01-30 20:30:32 +03:00
|
|
|
GetRGB32(screen->ViewPort.ColorMap, drinfo->dri_Pens[pen], 1, (ULONG *)&colour);
|
|
|
|
|
2011-01-31 01:57:56 +03:00
|
|
|
/* convert it to a css_color */
|
|
|
|
css_colour = (0xff << 24) |
|
|
|
|
((colour[0] & 0xff000000) >> 8) |
|
|
|
|
((colour[1] & 0xff000000) >> 16) |
|
|
|
|
((colour[2] & 0xff000000) >> 24);
|
2011-01-30 20:30:32 +03:00
|
|
|
|
|
|
|
FreeScreenDrawInfo(screen, drinfo);
|
2011-01-31 01:57:56 +03:00
|
|
|
return css_colour;
|
2011-01-30 20:30:32 +03:00
|
|
|
}
|