void litehtml::el_table::parse_styles(bool is_reparse) { html_tag::parse_styles(is_reparse); m_border_collapse = (border_collapse) value_index(get_style_property(_t("border-collapse"), true, _t("separate")), border_collapse_strings, border_collapse_separate); if(m_border_collapse == border_collapse_separate) { m_css_border_spacing_x.fromString(get_style_property(_t("-litehtml-border-spacing-x"), true, _t("0px"))); m_css_border_spacing_y.fromString(get_style_property(_t("-litehtml-border-spacing-y"), true, _t("0px"))); int fntsz = get_font_size(); document::ptr doc = get_document(); m_border_spacing_x = doc->cvt_units(m_css_border_spacing_x, fntsz); m_border_spacing_y = doc->cvt_units(m_css_border_spacing_y, fntsz); } else { m_border_spacing_x = 0; m_border_spacing_y = 0; m_padding.bottom = 0; m_padding.top = 0; m_padding.left = 0; m_padding.right = 0; m_css_padding.bottom.set_value(0, css_units_px); m_css_padding.top.set_value(0, css_units_px); m_css_padding.left.set_value(0, css_units_px); m_css_padding.right.set_value(0, css_units_px); } }
void litehtml::el_before_after_base::add_style(const litehtml::style& st) { html_tag::add_style(st); tstring content = get_style_property(_t("content"), false, _t("")); if(!content.empty()) { int idx = value_index(content.c_str(), content_property_string); if(idx < 0) { tstring fnc; tstring::size_type i = 0; while(i < content.length() && i != tstring::npos) { if(content.at(i) == _t('"')) { fnc.clear(); i++; tstring::size_type pos = content.find(_t('"'), i); tstring txt; if(pos == tstring::npos) { txt = content.substr(i); i = tstring::npos; } else { txt = content.substr(i, pos - i); i = pos + 1; } add_text(txt); } else if(content.at(i) == _t('(')) { i++; litehtml::trim(fnc); litehtml::lcase(fnc); tstring::size_type pos = content.find(_t(')'), i); tstring params; if(pos == tstring::npos) { params = content.substr(i); i = tstring::npos; } else { params = content.substr(i, pos - i); i = pos + 1; } add_function(fnc, params); fnc.clear(); } else { fnc += content.at(i); i++; } } } } }
litehtml::web_color litehtml::element::get_color( const tchar_t* prop_name, bool inherited, const litehtml::web_color& def_color ) { const tchar_t* clrstr = get_style_property(prop_name, inherited, 0); if(!clrstr) { return def_color; } return web_color::from_string(clrstr); }
void MyWidget::on_realize() { //Do not call base class Gtk::Widget::on_realize(). //It's intended only for widgets that set_has_window(false). set_realized(); //Get the themed style from the CSS file: get_style_property("example_scale", m_scale); std::cout << "m_scale (example_scale from the theme/css-file) is: " << m_scale << std::endl; if(!m_refGdkWindow) { //Create the GdkWindow: GdkWindowAttr attributes; memset(&attributes, 0, sizeof(attributes)); Gtk::Allocation allocation = get_allocation(); //Set initial position and size of the Gdk::Window: attributes.x = allocation.get_x(); attributes.y = allocation.get_y(); attributes.width = allocation.get_width(); attributes.height = allocation.get_height(); attributes.event_mask = get_events () | Gdk::EXPOSURE_MASK; attributes.window_type = GDK_WINDOW_CHILD; attributes.wclass = GDK_INPUT_OUTPUT; m_refGdkWindow = Gdk::Window::create(get_parent_window(), &attributes, GDK_WA_X | GDK_WA_Y); set_window(m_refGdkWindow); //set colors override_background_color(Gdk::RGBA("red")); override_color(Gdk::RGBA("blue")); //make the widget receive expose events m_refGdkWindow->set_user_data(gobj()); } }
void litehtml::el_text::parse_styles(bool is_reparse) { m_text_transform = (text_transform) value_index(get_style_property(_t("text-transform"), true, _t("none")), text_transform_strings, text_transform_none); if(m_text_transform != text_transform_none) { m_transformed_text = m_text; m_use_transformed = true; m_doc->container()->transform_text(m_transformed_text, m_text_transform); } if(is_white_space()) { m_transformed_text = _t(" "); m_use_transformed = true; } else { if(m_text == _t("\t")) { m_transformed_text = _t(" "); m_use_transformed = true; } if(m_text == _t("\n") || m_text == _t("\r")) { m_transformed_text = _t(""); m_use_transformed = true; } } font_metrics fm; uint_ptr font = m_parent->get_font(&fm); if(is_break()) { m_size.height = 0; m_size.width = 0; } else { m_size.height = fm.height; m_size.width = m_doc->container()->text_width(m_use_transformed ? m_transformed_text.c_str() : m_text.c_str(), font); } m_draw_spaces = fm.draw_spaces; }