bool RenderThemeBal::paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) { i.context->save(); i.context->setStrokeStyle(SolidStroke); i.context->setStrokeColor(Color::black); PassRefPtr<RenderStyle> style = RenderStyle::create(); addIntrinsicMargins(style.get()); EBorderStyle v = INSET; style->setBorderTopStyle(v); style->setBorderLeftStyle(v); style->setBorderBottomStyle(v); style->setBorderRightStyle(v); int borderWidth = 1; style->setBorderTopWidth(borderWidth); style->setBorderLeftWidth(borderWidth); style->setBorderBottomWidth(borderWidth); style->setBorderRightWidth(borderWidth); toRenderBox(o)->paintFillLayerExtended(i, o->style()->backgroundColor(), o->style()->backgroundLayers(), r.y(), toRenderBox(o)->height(), r.x(), r.y(), toRenderBox(o)->width(), toRenderBox(o)->height()); toRenderBox(o)->paintBorder(i.context, r.x(), r.y(), r.width(), r.height(), style.get(), true, true); if( o->node()->active() ) { IntRect r2(r); r2.inflate(-2); i.context->setFillColor(WebCore::Color(0xc0,0xc0,0xc0)); i.context->drawRect(r2); v = GROOVE; style->setBorderTopStyle(v); style->setBorderLeftStyle(v); style->setBorderBottomStyle(v); style->setBorderRightStyle(v); int borderWidth = 1; style->setBorderTopWidth(borderWidth); style->setBorderLeftWidth(borderWidth); style->setBorderBottomWidth(borderWidth); style->setBorderRightWidth(borderWidth); toRenderBox(o)->paintFillLayerExtended(i, o->style()->backgroundColor(), o->style()->backgroundLayers(), r.y(), toRenderBox(o)->height(), r.x(), r.y(), toRenderBox(o)->width(), toRenderBox(o)->height()); toRenderBox(o)->paintBorder(i.context, r.x(), r.y(), r.width(), r.height(), style.get(), true, true); } InputElement *input = toInputElement(static_cast<Element*>(o->node())); if(input && input->isChecked()) { i.context->setStrokeColor(Color::black); i.context->setStrokeStyle(SolidStroke); IntRect r2(r); r2.inflate(-borderWidth-2); i.context->drawLine(IntPoint(r2.x(),r2.y()), IntPoint(r2.x()+r2.width(),r2.y()+r2.height())); i.context->drawLine(IntPoint(r2.x()+r2.width(),r2.y()), IntPoint(r2.x(),r2.y()+r2.height())); } i.context->restore(); return false; }
bool RenderTheme::isChecked(const RenderObject* o) const { if (!o->node()) return false; InputElement* inputElement = o->node()->toInputElement(); if (!inputElement) return false; return inputElement->isChecked(); }
bool RenderTheme::isChecked(const RenderObject* o) const { if (!o->node() || !o->node()->isElementNode()) return false; InputElement* inputElement = toInputElement(static_cast<Element*>(o->node())); if (!inputElement) return false; return inputElement->isChecked(); }
bool RenderThemeAndroid::paintRadio(RenderObject* obj, const PaintInfo& info, const IntRect& rect) { Node* node = obj->node(); Element* element = static_cast<Element*>(node); if (element) { InputElement* input = element->toInputElement(); GraphicsContext* context = info.context; if (!element->isEnabledFormControl()) { context->setAlpha(0.5f); } const IntRect inner = IntRect(rect.x() - 2, rect.y() - 2, rect.width() - 4, rect.height() - 4); context->setFillColor(Color(defaultBgBright), context->fillColorSpace()); context->setStrokeColor(Color(defaultBgBright), context->strokeColorSpace()); context->setStrokeThickness(1.0f); //SAMSUNG CHANGE [Cq - 5912] /* if (input->isCheckbox()) { context->drawRect(inner); } else { context->drawEllipse(inner); } context->setStrokeColor(Color(defaultFgColor), context->strokeColorSpace());*/ //SAMSUNG CHANGE [Cq - 5912] if (input->isCheckbox()) { context->drawRect(IntRect(inner.x() + 2, inner.y() + 2, inner.width() -4, inner.height() - 4)); } else { context->drawEllipse(IntRect(inner.x() + 2, inner.y() + 2, inner.width() -4, inner.height() - 4)); } if (input->isChecked()) { context->setFillColor(Color(defaultCheckColor), context->fillColorSpace()); context->setStrokeColor(Color(defaultCheckColor), context->strokeColorSpace()); if (input->isCheckbox()) { const float w2 = ((float) rect.width() / 2); const float cx = ((float) rect.x()); const float cy = ((float) rect.y()); context->save(); // magic numbers due to weird scale in context context->translate(cx + w2 / 2.2f, cy + w2 / 1.2f); context->rotate(3.93f); // 225 degrees context->drawRect(IntRect(0, 0, rect.width() / 4, 2)); context->rotate(1.57f); // 90 degrees context->drawRect(IntRect(0, 0, rect.width() / 2, 2)); context->restore(); } else { context->drawEllipse(IntRect(inner.x() + 5, inner.y() + 5, inner.width() - 10, inner.height() - 10)); } } } return false; }
void CheckedRadioButtons::removeButton(HTMLFormControlElement* element) { if (element->name().isEmpty() || !m_nameToCheckedRadioButtonMap) return; NameToInputMap::iterator it = m_nameToCheckedRadioButtonMap->find(element->name().impl()); if (it == m_nameToCheckedRadioButtonMap->end() || it->second != element) return; InputElement* inputElement = toInputElement(element); ASSERT_UNUSED(inputElement, inputElement); ASSERT(inputElement->isChecked()); ASSERT(element->isRadioButton()); m_nameToCheckedRadioButtonMap->remove(it); if (m_nameToCheckedRadioButtonMap->isEmpty()) m_nameToCheckedRadioButtonMap.clear(); }
bool RenderThemeBal::paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) { i.context->save(); i.context->setStrokeStyle(SolidStroke); PassRefPtr<RenderStyle> style = RenderStyle::create(); EBorderStyle v = RIDGE; style->setBorderTopStyle(v); style->setBorderLeftStyle(v); style->setBorderBottomStyle(v); style->setBorderRightStyle(v); #if PLATFORM(AMIGAOS4) int borderWidth = 2; #else int borderWidth = 1; #endif style->setBorderTopWidth(borderWidth); style->setBorderLeftWidth(borderWidth); style->setBorderBottomWidth(borderWidth); style->setBorderRightWidth(borderWidth); toRenderBox(o)->paintFillLayerExtended(i, o->style()->backgroundColor(), o->style()->backgroundLayers(), r.y(), toRenderBox(o)->height(), r.x(), r.y(), toRenderBox(o)->width(), toRenderBox(o)->height()); toRenderBox(o)->paintBorder(i.context, r.x(), r.y(), r.width(), r.height(), style.get(), true, true); InputElement *input = toInputElement(static_cast<Element*>(o->node())); if(input && input->isChecked()) { IntRect r2(r); #if PLATFORM(AMIGAOS4) r2.inflate(-borderWidth - 1); i.context->setFillColor(Color(0xFF618ECE)); #else r2.inflate(-borderWidth - 2); #endif i.context->drawRect(r2); } i.context->restore(); return false; }
void RenderRadio::paintObject(PaintInfo& i, int _tx, int _ty) { ASSERT(node()); Element* element = static_cast<Element*>(node()); InputElement* inputElement = toInputElement(element); bool isEnabled = element->isEnabledFormControl(); bool isChecked = inputElement->isChecked(); i.context->save(); RefPtr<Image> image = Image::loadPlatformResource( "radioButtonStates" ).get(); IntPoint destPt( _tx, _ty ); IntRect srcRect( 0, 0, 14, 16 ); if (isEnabled) { if (node()->active()) { if (isChecked) { srcRect.move( 75, 0 ); } else { srcRect.move( 60, 0 ); } } else if (node()->hovered()) { if (isChecked) { srcRect.move( 45, 0 ); } else { srcRect.move( 30, 0 ); } } else { if (isChecked) { srcRect.move( 15, 0 ); } else { } } } else { if (isChecked) { srcRect.move( 105, 0 ); } else { srcRect.move( 90, 0 ); } } i.context->drawImage( image.get(), DeviceColorSpace, destPt, srcRect ); // draw the focus ring. // if (node()->focused()) { IntRect focusRingSrcRect( 120, 0, 15, 17 ); i.context->drawImage( image.get(), DeviceColorSpace, destPt, focusRingSrcRect ); } #if 0 // this is the old "moveto - lineto" drawing code IntRect checkRect(_tx + borderLeft() , _ty + borderTop() , width() - borderLeft() - borderRight() , height() - borderBottom() - borderTop()); Color fillColor(0xff, 0xff, 0xff, 0x00); Color rectColor(0x18, 0x52, 0x84); Color checkColor(0x21, 0xa5, 0x21); if (!node()->isEnabled()) { rectColor = Color(0xce, 0xce, 0xdb); checkColor = Color(0xce, 0xce, 0xdb); } i.context->setStrokeThickness(1); i.context->setStrokeStyle(SolidStroke); i.context->setStrokeColor(rectColor); i.context->setFillColor(fillColor); i.context->drawEllipse(checkRect); if(node()->isEnabled() && node()->hovered()) { i.context->setStrokeColor(Color(0xff, 0xb5, 0x31)); IntRect hoverRect = checkRect; hoverRect.inflateX(-1); hoverRect.inflateY(-1); i.context->drawEllipse( hoverRect ); hoverRect.inflateX(-1); hoverRect.inflateY(-1); i.context->drawEllipse( hoverRect ); } if (isChecked) { i.context->setStrokeThickness(2); i.context->setStrokeColor(checkColor); i.context->setFillColor(checkColor); IntRect fillRect = checkRect; fillRect.inflateX(-2); fillRect.inflateY(-2); i.context->drawEllipse(fillRect); } #endif i.context->restore(); }