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 HUDSlider::draw(GraphicsContext& context) { // Draw gutter IntSize radius(m_rect.height() / 2, m_rect.height() / 2); context.fillRoundedRect(FloatRoundedRect(m_rect, radius, radius, radius, radius), Color(sliderGutterColor), ColorSpaceDeviceRGB); // Draw button context.setStrokeColor(Color(sliderButtonColor), ColorSpaceDeviceRGB); context.setFillColor(Color(sliderButtonColor), ColorSpaceDeviceRGB); if (m_buttonShape == RoundButton) { context.drawEllipse(IntRect(m_rect.location().x() + m_buttonPosition, m_rect.location().y() - (m_buttonSize - m_rect.height()) / 2, m_buttonSize, m_buttonSize)); return; } // Draw a diamond FloatPoint points[4]; float half = static_cast<float>(m_buttonSize) / 2; points[0].setX(m_rect.location().x() + m_buttonPosition + half); points[0].setY(m_rect.location().y()); points[1].setX(m_rect.location().x() + m_buttonPosition + m_buttonSize); points[1].setY(m_rect.location().y() + half); points[2].setX(m_rect.location().x() + m_buttonPosition + half); points[2].setY(m_rect.location().y() + m_buttonSize); points[3].setX(m_rect.location().x() + m_buttonPosition); points[3].setY(m_rect.location().y() + half); context.drawConvexPolygon(4, points, true); }
void HUDSlider::draw(GraphicsContext& context) { // Draw gutter IntSize radius(m_rect.height() / 2, m_rect.height() / 2); context.fillRoundedRect(FloatRoundedRect(m_rect, radius, radius, radius, radius), Color(sliderGutterColor)); // Draw button context.setStrokeColor(Color(sliderButtonColor)); context.setFillColor(Color(sliderButtonColor)); if (m_buttonShape == RoundButton) { context.drawEllipse(IntRect(m_rect.location().x() + m_buttonPosition, m_rect.location().y() - (m_buttonSize - m_rect.height()) / 2, m_buttonSize, m_buttonSize)); return; } // Draw a diamond float half = static_cast<float>(m_buttonSize) / 2; Vector<FloatPoint> points = { FloatPoint(m_rect.location().x() + m_buttonPosition + half, m_rect.location().y()), FloatPoint(m_rect.location().x() + m_buttonPosition + m_buttonSize, m_rect.location().y() + half), FloatPoint(m_rect.location().x() + m_buttonPosition + half, m_rect.location().y() + m_buttonSize), FloatPoint(m_rect.location().x() + m_buttonPosition, m_rect.location().y() + half) }; context.drawPath(Path::polygonPathFromPoints(points)); }
void DrawEllipse::apply(GraphicsContext& context) const { context.drawEllipse(m_rect); }
void RenderListMarker::paint(PaintInfo& paintInfo, int tx, int ty) { if (paintInfo.phase != PaintPhaseForeground) return; if (style()->visibility() != VISIBLE) return; IntRect marker = getRelativeMarkerRect(); marker.move(tx, ty); IntRect box(tx + m_x, ty + m_y, m_width, m_height); if (box.y() > paintInfo.rect.bottom() || box.y() + box.height() < paintInfo.rect.y()) return; if (hasBoxDecorations()) paintBoxDecorations(paintInfo, box.x(), box.y()); GraphicsContext* context = paintInfo.context; context->setFont(style()->font()); if (isImage()) { #if PLATFORM(MAC) if (style()->highlight() != nullAtom && !paintInfo.context->paintingDisabled()) paintCustomHighlight(tx, ty, style()->highlight(), true); #endif context->drawImage(m_image->image(), marker.location()); if (selectionState() != SelectionNone) context->fillRect(selectionRect(), selectionBackgroundColor()); return; } #if PLATFORM(MAC) // FIXME: paint gap between marker and list item proper if (style()->highlight() != nullAtom && !paintInfo.context->paintingDisabled()) paintCustomHighlight(tx, ty, style()->highlight(), true); #endif if (selectionState() != SelectionNone) context->fillRect(selectionRect(), selectionBackgroundColor()); const Color color(style()->color()); context->setStrokeColor(color); context->setStrokeStyle(SolidStroke); context->setStrokeThickness(1.0f); context->setFillColor(color); switch (style()->listStyleType()) { case DISC: context->drawEllipse(marker); return; case CIRCLE: context->setFillColor(Color::transparent); context->drawEllipse(marker); return; case SQUARE: context->drawRect(marker); return; case LNONE: return; case ARMENIAN: case CJK_IDEOGRAPHIC: case DECIMAL_LEADING_ZERO: case GEORGIAN: case HEBREW: case HIRAGANA: case HIRAGANA_IROHA: case KATAKANA: case KATAKANA_IROHA: case LDECIMAL: case LOWER_ALPHA: case LOWER_GREEK: case LOWER_LATIN: case LOWER_ROMAN: case UPPER_ALPHA: case UPPER_LATIN: case UPPER_ROMAN: break; } if (m_text.isEmpty()) return; TextRun textRun(m_text); // Text is not arbitrary. We can judge whether it's RTL from the first character, // and we only need to handle the direction RightToLeft for now. bool textNeedsReversing = direction(m_text[0]) == RightToLeft; Vector<UChar> reversedText; if (textNeedsReversing) { int length = m_text.length(); reversedText.resize(length); for (int i = 0; i < length; ++i) reversedText[length - i - 1] = m_text[i]; textRun = TextRun(reversedText.data(), length); } const Font& font = style()->font(); if (style()->direction() == LTR) { int width = font.width(textRun); context->drawText(textRun, marker.location()); const UChar periodSpace[2] = { '.', ' ' }; context->drawText(TextRun(periodSpace, 2), marker.location() + IntSize(width, 0)); } else { const UChar spacePeriod[2] = { ' ', '.' }; TextRun spacePeriodRun(spacePeriod, 2); int width = font.width(spacePeriodRun); context->drawText(spacePeriodRun, marker.location()); context->drawText(textRun, marker.location() + IntSize(width, 0)); } }