diff options
-rw-r--r-- | src/form.cc | 46 | ||||
-rw-r--r-- | src/html.cc | 14 | ||||
-rw-r--r-- | src/html_common.hh | 4 | ||||
-rw-r--r-- | src/table.cc | 36 |
4 files changed, 62 insertions, 38 deletions
diff --git a/src/form.cc b/src/form.cc index c79c31ed..78f2e66d 100644 --- a/src/form.cc +++ b/src/form.cc @@ -550,14 +550,15 @@ void Html_tag_open_input(DilloHtml *html, const char *tag, int tagsize) // gtk_entry_set_max_length(GTK_ENTRY(widget), // strtol(attrbuf, NULL, 10)); } + Color *bg; + if (prefs.standard_widget_colors) + bg = NULL; + else + bg = Color::createShaded(HT2LT(html), S_TOP(html)->current_bg_color); + HTML_SET_TOP_ATTR(html, backgroundColor, bg); - if (prefs.standard_widget_colors) { - HTML_SET_TOP_ATTR(html, color, NULL); - HTML_SET_TOP_ATTR(html, backgroundColor, NULL); - } DW2TB(html->dw)->addWidget (embed, S_TOP(html)->style); } - dFree(type); dFree(name); if (init_str != value) @@ -599,12 +600,14 @@ void Html_tag_open_isindex(DilloHtml *html, const char *tag, int tagsize) embed = new dw::core::ui::Embed (entryResource); Html_add_input(html, DILLO_HTML_INPUT_INDEX, embed, NULL, NULL, FALSE); - if (prefs.standard_widget_colors) { - HTML_SET_TOP_ATTR(html, color, NULL); - HTML_SET_TOP_ATTR(html, backgroundColor, NULL); - } + Color *bg; + if (prefs.standard_widget_colors) + bg = NULL; + else + bg = Color::createShaded(HT2LT(html), S_TOP(html)->current_bg_color); + HTML_SET_TOP_ATTR(html, backgroundColor, bg); DW2TB(html->dw)->addWidget (embed, S_TOP(html)->style); - + a_Url_free(action); html->InFlags &= ~IN_FORM; } @@ -664,6 +667,14 @@ void Html_tag_open_textarea(DilloHtml *html, const char *tag, int tagsize) if (a_Html_get_attr(html, tag, tagsize, "readonly")) textres->setEditable(false); Html_add_input(html, DILLO_HTML_INPUT_TEXTAREA, embed, name, NULL, false); + + Color *bg; + if (prefs.standard_widget_colors) + bg = NULL; + else + bg = Color::createShaded(HT2LT(html), S_TOP(html)->current_bg_color); + HTML_SET_TOP_ATTR(html, backgroundColor, bg); + DW2TB(html->dw)->addWidget (embed, S_TOP(html)->style); dFree(name); } @@ -738,12 +749,17 @@ void Html_tag_open_select(DilloHtml *html, const char *tag, int tagsize) res = factory->createOptionMenuResource (); } dw::core::ui::Embed *embed = new dw::core::ui::Embed(res); + + int bg; if (prefs.standard_widget_colors) { - /* Colors cannot be NULL because SELECT can contain other elements */ + /* Valid colors required; SELECT can contain other elements (BUG) */ HTML_SET_TOP_ATTR(html, color, Color::createSimple (HT2LT(html), 0)); - HTML_SET_TOP_ATTR(html, backgroundColor, - Color::createShaded (HT2LT(html), 0xffffff)); + bg = 0xffffff; + } else { + bg = S_TOP(html)->current_bg_color; } + HTML_SET_TOP_ATTR(html, backgroundColor, + Color::createShaded (HT2LT(html), bg)); DW2TB(html->dw)->addWidget (embed, S_TOP(html)->style); // size = 0; @@ -873,6 +889,8 @@ void Html_tag_open_button(DilloHtml *html, const char *tag, int tagsize) style_attrs.margin.setVal(0); style_attrs.borderWidth.setVal(0); style_attrs.padding.setVal(0); + style_attrs.backgroundColor = + Color::createShaded(HT2LT(html), S_TOP(html)->current_bg_color); style = Style::create (HT2LT(html), &style_attrs); page = new Textblock (prefs.limit_text_width); @@ -1925,6 +1943,8 @@ static dw::core::ui::Embed *Html_input_image(DilloHtml *html, (url = a_Html_url_new(html, attrbuf, NULL, 0))) { style_attrs = *S_TOP(html)->style; style_attrs.cursor = CURSOR_POINTER; + style_attrs.backgroundColor = + style::Color::createShaded(HT2LT(html), S_TOP(html)->current_bg_color); /* create new image and add it to the button */ if ((Image = a_Html_add_new_image(html, tag, tagsize, url, &style_attrs, diff --git a/src/html.cc b/src/html.cc index f5160e5c..68c3c8d0 100644 --- a/src/html.cc +++ b/src/html.cc @@ -479,6 +479,7 @@ DilloHtml::DilloHtml(BrowserWindow *p_bw, const DilloUrl *url, stack->getRef(0)->textblock = NULL; stack->getRef(0)->table = NULL; stack->getRef(0)->ref_list_item = NULL; + stack->getRef(0)->current_bg_color = prefs.bg_color; stack->getRef(0)->hand_over_break = false; InFlags = IN_NONE; @@ -541,8 +542,6 @@ void DilloHtml::initDw() style_attrs.initValues (); style_attrs.font = Font::create (HT2LT(this), &font_attrs); style_attrs.color = Color::createSimple (HT2LT(this), prefs.text_color); - style_attrs.backgroundColor = - Color::createShaded (HT2LT(this), prefs.bg_color); stack->getRef(0)->style = Style::create (HT2LT(this), &style_attrs); stack->getRef(0)->table_cell_style = NULL; @@ -1734,8 +1733,7 @@ static void Html_tag_open_body(DilloHtml *html, const char *tag, int tagsize) style = Style::create (HT2LT(html), &style_attrs); html->dw->setStyle (style); style->unref (); - HTML_SET_TOP_ATTR (html, backgroundColor, - Color::createShaded (HT2LT(html), color)); + S_TOP(html)->current_bg_color = color; } if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "text"))) { @@ -1757,7 +1755,7 @@ static void Html_tag_open_body(DilloHtml *html, const char *tag, int tagsize) a_Color_vc(html->visited_color, S_TOP(html)->style->color->getColor(), html->link_color, - S_TOP(html)->style->backgroundColor->getColor()); + S_TOP(html)->current_bg_color); } } @@ -2120,7 +2118,7 @@ DilloImage *a_Html_add_new_image(DilloHtml *html, const char *tag, style_attrs->x_img = html->images->size(); /* Add a new image widget to this page */ - Image = a_Image_new(0,0,alt_ptr,style_attrs->backgroundColor->getColor()); + Image = a_Image_new(0, 0, alt_ptr, S_TOP(html)->current_bg_color); if (add) { Html_add_widget(html, (Widget*)Image->dw, width_ptr, height_ptr, style_attrs); @@ -2499,7 +2497,7 @@ static void Html_tag_open_a(DilloHtml *html, const char *tag, int tagsize) a_Color_vc(html->visited_color, S_TOP(html)->style->color->getColor(), html->link_color, - S_TOP(html)->style->backgroundColor->getColor()), + S_TOP(html)->current_bg_color), */ ); } else { @@ -2811,7 +2809,7 @@ static void Html_tag_open_hr(DilloHtml *html, const char *tag, int tagsize) style_attrs.setBorderStyle (BORDER_INSET); style_attrs.setBorderColor (Color::createShaded (HT2LT(html), - style_attrs.backgroundColor->getColor())); + S_TOP(html)->current_bg_color)); if (size < 2) size = 2; } diff --git a/src/html_common.hh b/src/html_common.hh index d7b02b8e..c694123e 100644 --- a/src/html_common.hh +++ b/src/html_common.hh @@ -124,6 +124,10 @@ struct _DilloHtmlState { /* This is used to align list items (especially in enumerated lists) */ dw::core::Widget *ref_list_item; + /* This makes image processing faster than a function + a_Dw_widget_get_background_color. */ + int32_t current_bg_color; + /* This is used for list items etc; if it is set to TRUE, breaks have to be "handed over" (see Html_add_indented and Html_eventually_pop_dw). */ diff --git a/src/table.cc b/src/table.cc index 7b6a2906..ce5f5ae9 100644 --- a/src/table.cc +++ b/src/table.cc @@ -69,8 +69,8 @@ void Html_tag_open_table(DilloHtml *html, const char *tag, int tagsize) else style_attrs.borderWidth.setVal (border); - style_attrs.setBorderColor (Color::createShaded(HT2LT(html), - style_attrs.backgroundColor->getColor())); + style_attrs.setBorderColor ( + Color::createShaded(HT2LT(html), S_TOP(html)->current_bg_color)); style_attrs.setBorderStyle (BORDER_OUTSET); style_attrs.hBorderSpacing = cellspacing; style_attrs.vBorderSpacing = cellspacing; @@ -93,10 +93,9 @@ void Html_tag_open_table(DilloHtml *html, const char *tag, int tagsize) if (bgcolor != -1) { if (bgcolor == 0xffffff && !prefs.allow_white_bg) bgcolor = prefs.bg_color; + S_TOP(html)->current_bg_color = bgcolor; style_attrs.backgroundColor = Color::createShaded (HT2LT(html), bgcolor); - HTML_SET_TOP_ATTR (html, backgroundColor, - Color::createShaded (HT2LT(html), bgcolor)); } } @@ -137,7 +136,8 @@ void Html_tag_open_tr(DilloHtml *html, const char *tag, int tagsize) const char *attrbuf; dw::core::style::StyleAttrs style_attrs; dw::core::style::Style *style, *old_style; - int32_t bgcolor; + int32_t bgcolor = -1; + bool new_style = false; #ifdef USE_TABLES switch (S_TOP(html)->table_mode) { @@ -161,8 +161,7 @@ void Html_tag_open_tr(DilloHtml *html, const char *tag, int tagsize) style_attrs.backgroundColor = Color::createShaded (HT2LT(html), bgcolor); style = Style::create (HT2LT(html), &style_attrs); - HTML_SET_TOP_ATTR (html, backgroundColor, - Color::createShaded (HT2LT(html), bgcolor)); + S_TOP(html)->current_bg_color = bgcolor; } } @@ -176,14 +175,18 @@ void Html_tag_open_tr(DilloHtml *html, const char *tag, int tagsize) } style_attrs = *S_TOP(html)->table_cell_style; - a_Html_tag_set_valign_attr (html, tag, tagsize, &style_attrs); - style_attrs.backgroundColor = - Color::createShaded (HT2LT(html), - S_TOP(html)->style->backgroundColor->getColor()); - old_style = S_TOP(html)->table_cell_style; - S_TOP(html)->table_cell_style = - Style::create (HT2LT(html), &style_attrs); - old_style->unref (); + if (bgcolor != -1) { + style_attrs.backgroundColor =Color::createShaded(HT2LT(html),bgcolor); + new_style = true; + } + if (a_Html_tag_set_valign_attr (html, tag, tagsize, &style_attrs)) + new_style = true; + if (new_style) { + old_style = S_TOP(html)->table_cell_style; + S_TOP(html)->table_cell_style = + Style::create (HT2LT(html), &style_attrs); + old_style->unref (); + } break; default: break; @@ -292,8 +295,7 @@ static void Html_tag_open_table_cell(DilloHtml *html, new_style = TRUE; style_attrs.backgroundColor = Color::createShaded (HT2LT(html), bgcolor); - HTML_SET_TOP_ATTR (html, backgroundColor, - Color::createShaded (HT2LT(html), bgcolor)); + S_TOP(html)->current_bg_color = bgcolor; } } |