aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dillorc5
-rw-r--r--dw/layout.cc15
-rw-r--r--dw/layout.hh5
-rw-r--r--dw/widget.cc10
-rw-r--r--src/css.cc3
-rw-r--r--src/html.cc28
-rw-r--r--src/prefs.c1
-rw-r--r--src/prefs.h1
-rw-r--r--src/prefsparser.cc7
-rw-r--r--src/uicmd.cc4
-rw-r--r--src/web.cc5
11 files changed, 63 insertions, 21 deletions
diff --git a/dillorc b/dillorc
index ba132ba0..713a290a 100644
--- a/dillorc
+++ b/dillorc
@@ -46,6 +46,11 @@
# RENDERING SECTION
#-------------------------------------------------------------------------
+# Set the background color
+# bg_color=gray
+# bg_color=0xd6d6c0
+#bg_color=0xdcd1ba
+
# Default fonts:
#
# If FLTK2 has been configured with Xft enabled (the default), you can
diff --git a/dw/layout.cc b/dw/layout.cc
index b30831c7..aa9f05ed 100644
--- a/dw/layout.cc
+++ b/dw/layout.cc
@@ -246,7 +246,6 @@ void Layout::addWidget (Widget *widget)
canvasHeightGreater = false;
setSizeHints ();
- updateBgColor ();
queueResize ();
}
@@ -609,17 +608,11 @@ void Layout::updateCursor ()
setCursor (style::CURSOR_DEFAULT);
}
-void Layout::updateBgColor ()
+void Layout::setBgColor (style::Color *color)
{
- /* The toplevel widget should always have a defined background color,
- * except at the beginning. Searching a defined background is not
- * necessary. */
- if (topLevel && topLevel->getStyle() &&
- topLevel->getStyle()->backgroundColor)
- bgColor = topLevel->getStyle()->backgroundColor;
- else
- bgColor = NULL;
- view->setBgColor (bgColor);
+ bgColor = color;
+ if (view)
+ view->setBgColor (bgColor);
}
void Layout::resizeIdle ()
diff --git a/dw/layout.hh b/dw/layout.hh
index 304cf166..dc9bf227 100644
--- a/dw/layout.hh
+++ b/dw/layout.hh
@@ -202,7 +202,6 @@ private:
void removeAnchor (Widget *widget, char* name);
void setCursor (style::Cursor cursor);
void updateCursor ();
- void updateBgColor ();
void queueDraw (int x, int y, int width, int height);
void queueDrawExcept (int x, int y, int width, int height,
int ex, int ey, int ewidth, int eheight);
@@ -362,6 +361,10 @@ public:
/** \brief See dw::core::FindtextState::resetSearch. */
inline void resetSearch () { findtextState.resetSearch (); }
+
+ void setBgColor (style::Color *color);
+
+ inline style::Color* getBgColor () { return bgColor; }
};
} // namespace dw
diff --git a/dw/widget.cc b/dw/widget.cc
index fb0d29e0..ee8cb17c 100644
--- a/dw/widget.cc
+++ b/dw/widget.cc
@@ -302,8 +302,6 @@ void Widget::setStyle (style::Style *style)
this->style = style;
if (layout != NULL) {
- if (parent == NULL)
- layout->updateBgColor ();
layout->updateCursor ();
}
@@ -339,9 +337,7 @@ style::Color *Widget::getBgColor ()
widget = widget->parent;
}
- MSG_WARN("No background color found!\n");
- return NULL;
-
+ return layout->getBgColor ();
}
@@ -399,7 +395,9 @@ void Widget::drawWidgetBox (View *view, Rectangle *area, bool inverse)
* widget->style->background_color is NULL (shining through).
*/
/** \todo Background images? */
- if (parent && style->backgroundColor)
+
+ if (style->backgroundColor &&
+ (parent || layout->getBgColor () != style->backgroundColor))
style::drawBackground (view, &viewArea, allocation.x, allocation.y,
allocation.width, getHeight (), style, inverse);
}
diff --git a/src/css.cc b/src/css.cc
index 5e6e1486..ea64a26c 100644
--- a/src/css.cc
+++ b/src/css.cc
@@ -558,8 +558,7 @@ void CssContext::addRule (CssSelector *sel, CssPropertyList *props,
*/
void CssContext::buildUserAgentStyle () {
const char *cssBuf =
- "body {background-color: #e0e0a3; font-family: sans-serif; color: black;"
- " margin: 5px}"
+ "body {margin: 5px}"
"big {font-size: 1.17em}"
"blockquote, dd {margin-left: 40px; margin-right: 40px}"
"center {text-align: center}"
diff --git a/src/html.cc b/src/html.cc
index 778d0b6b..9b53a082 100644
--- a/src/html.cc
+++ b/src/html.cc
@@ -1715,6 +1715,9 @@ static void Html_tag_open_body(DilloHtml *html, const char *tag, int tagsize)
Textblock *textblock;
int32_t color;
int tag_index_a = a_Html_tag_index ("a");
+ int tag_index_body = a_Html_tag_index ("body");
+ int tag_index_html = a_Html_tag_index ("html");
+ style::Color *bgColor;
if (!(html->InFlags & IN_BODY))
html->InFlags |= IN_BODY;
@@ -1729,6 +1732,22 @@ static void Html_tag_open_body(DilloHtml *html, const char *tag, int tagsize)
BUG_MSG("unclosed HEAD element\n");
}
+ html->styleEngine->endElement(tag_index_body);
+ html->styleEngine->endElement(tag_index_html);
+ html->styleEngine->startElement(tag_index_html);
+ bgColor = html->styleEngine->style ()->backgroundColor;
+ html->styleEngine->startElement(tag_index_body);
+
+ if ((attrbuf = Html_get_attr2(html, tag, tagsize, "id",
+ HTML_LeftTrim | HTML_RightTrim)))
+ html->styleEngine->setId(attrbuf);
+ if ((attrbuf = Html_get_attr2(html, tag, tagsize, "class",
+ HTML_LeftTrim | HTML_RightTrim)))
+ html->styleEngine->setClass(attrbuf);
+ if ((attrbuf = Html_get_attr2(html, tag, tagsize, "style",
+ HTML_LeftTrim | HTML_RightTrim)))
+ html->styleEngine->setStyle(attrbuf);
+
textblock = HT2TB(html);
if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "bgcolor"))) {
@@ -1753,6 +1772,14 @@ static void Html_tag_open_body(DilloHtml *html, const char *tag, int tagsize)
html->dw->setStyle (html->styleEngine->style ());
+ /* Set canvas color if not already set from Html_open_html().
+ */
+ if (!bgColor)
+ bgColor = html->styleEngine->style ()->backgroundColor;
+
+ if (bgColor)
+ HT2LT(html)->setBgColor(bgColor);
+
/* Determine a color for visited links.
* This color is computed once per page and used for immediate feedback
* when clicking a link.
@@ -1777,6 +1804,7 @@ static void Html_tag_open_body(DilloHtml *html, const char *tag, int tagsize)
html->styleEngine->backgroundStyle()->backgroundColor->getColor());
}
+
S_TOP(html)->parse_mode = DILLO_HTML_PARSE_MODE_BODY;
}
diff --git a/src/prefs.c b/src/prefs.c
index 5514c01a..f968710a 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -36,6 +36,7 @@ DilloPrefs prefs;
void a_Prefs_init(void)
{
prefs.allow_white_bg = TRUE;
+ prefs.bg_color = 0xdcd1ba;
prefs.buffered_drawing = 1;
prefs.contrast_visited_color = TRUE;
prefs.enterpress_forces_submit = FALSE;
diff --git a/src/prefs.h b/src/prefs.h
index 684262ed..4009925c 100644
--- a/src/prefs.h
+++ b/src/prefs.h
@@ -46,6 +46,7 @@ struct _DilloPrefs {
DilloUrl *start_page;
DilloUrl *home;
bool_t allow_white_bg;
+ int32_t bg_color;
bool_t contrast_visited_color;
bool_t show_tooltip;
int panel_size;
diff --git a/src/prefsparser.cc b/src/prefsparser.cc
index 78cade0b..95f98c16 100644
--- a/src/prefsparser.cc
+++ b/src/prefsparser.cc
@@ -16,11 +16,13 @@
#include "prefs.h"
#include "misc.h"
#include "msg.h"
+#include "colors.h"
#include "prefsparser.hh"
typedef enum {
PREFS_BOOL,
+ PREFS_COLOR,
PREFS_STRING,
PREFS_URL,
PREFS_INT32,
@@ -43,10 +45,12 @@ int PrefsParser::parseOption(char *name, char *value)
{
const SymNode_t *node;
uint_t i;
+ int st;
/* Symbol array, sorted alphabetically */
const SymNode_t symbols[] = {
{ "allow_white_bg", &prefs.allow_white_bg, PREFS_BOOL },
+ { "bg_color", &prefs.bg_color, PREFS_COLOR },
{ "buffered_drawing", &prefs.buffered_drawing, PREFS_INT32 },
{ "contrast_visited_color", &prefs.contrast_visited_color, PREFS_BOOL },
{ "enterpress_forces_submit", &prefs.enterpress_forces_submit,
@@ -122,6 +126,9 @@ int PrefsParser::parseOption(char *name, char *value)
*(bool_t *)node->pref = (!dStrcasecmp(value, "yes") ||
!dStrcasecmp(value, "true"));
break;
+ case PREFS_COLOR:
+ *(int32_t *)node->pref = a_Color_parse(value, *(int32_t*)node->pref,&st);
+ break;
case PREFS_STRING:
dFree(*(char **)node->pref);
*(char **)node->pref = dStrdup(value);
diff --git a/src/uicmd.cc b/src/uicmd.cc
index 93836735..001165d6 100644
--- a/src/uicmd.cc
+++ b/src/uicmd.cc
@@ -449,6 +449,8 @@ BrowserWindow *a_UIcmd_browser_window_new(int ww, int wh,
// Now create the Dw render layout and viewport
FltkPlatform *platform = new FltkPlatform ();
Layout *layout = new Layout (platform);
+ style::Color *bgColor = style::Color::create (layout, prefs.bg_color);
+ layout->setBgColor (bgColor);
FltkViewport *viewport = new FltkViewport (0, 0, 1, 1);
if (prefs.buffered_drawing == 1)
@@ -507,6 +509,8 @@ static BrowserWindow *UIcmd_tab_new(const void *vbw)
// Now create the Dw render layout and viewport
FltkPlatform *platform = new FltkPlatform ();
Layout *layout = new Layout (platform);
+ style::Color *bgColor = style::Color::create (layout, prefs.bg_color);
+ layout->setBgColor (bgColor);
FltkViewport *viewport = new FltkViewport (0, 0, 1, 1);
diff --git a/src/web.cc b/src/web.cc
index 17302b1c..1b5741ae 100644
--- a/src/web.cc
+++ b/src/web.cc
@@ -61,10 +61,13 @@ int a_Web_dispatch_by_type (const char *Type, DilloWeb *Web,
if (Web->flags & WEB_RootUrl) {
/* We have RootUrl! */
+ style::Color *bgColor = style::Color::create (layout, prefs.bg_color);
+ Web->bgColor = bgColor->getColor ();
+ layout->setBgColor (bgColor);
+
/* Set a style for the widget */
StyleEngine styleEngine (layout);
styleEngine.startElement ("body");
- Web->bgColor= styleEngine.backgroundStyle()->backgroundColor->getColor();
dw = (Widget*) a_Mime_set_viewer(Type, Web, Call, Data);
if (dw == NULL)