예제 #1
0
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;
}
예제 #2
0
bool RenderTheme::isIndeterminate(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->isIndeterminate();
}
예제 #3
0
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();
}
예제 #4
0
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;
}
예제 #5
0
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();
}