//---------------------------------------------------------------------------------------------------- void UISearchTextField::drawClearMark (CDrawContext* context) const { if (getText ().empty ()) return; SharedPointer<CGraphicsPath> path = owned (context->createGraphicsPath ()); if (path == 0) return; CRect r = getClearMarkRect (); CColor color (fontColor); color.alpha /= 2; context->setFillColor (color); context->setDrawMode (kAntiAliasing); context->drawEllipse (r, kDrawFilled); double h,s,v; color.toHSV (h, s, v); v = 1. - v; color.fromHSV (h, s, v); context->setFrameColor (color); context->setLineWidth (2.); r.inset (r.getWidth () / (M_PI * 2.) + 1, r.getHeight () / (M_PI * 2.) + 1); path->beginSubpath (r.getTopLeft ()); path->addLine (r.getBottomRight ()); path->beginSubpath (r.getBottomLeft ()); path->addLine (r.getTopRight ()); context->setDrawMode (kAntiAliasing|kNonIntegralMode); context->drawGraphicsPath (path, CDrawContext::kPathStroked); }
//----------------------------------------------------------------------------- void CSegmentButton::drawRect (CDrawContext* pContext, const CRect& dirtyRect) { bool isHorizontal = style == kHorizontal; SharedPointer<CGraphicsPath> path; if (gradient || gradientHighlighted || (getFrameWidth () > 0. && getFrameColor ().alpha != 0)) { CRect r (getViewSize ()); r.inset (getFrameWidth () / 2., getFrameWidth () / 2.); path = owned (pContext->createGraphicsPath ()); path->addRoundRect (r, getRoundRadius ()); } pContext->setDrawMode (kAntiAliasing); bool drawLines = getFrameWidth () > 0. && getFrameColor ().alpha != 0; if (drawLines) { pContext->setLineStyle (kLineSolid); pContext->setLineWidth (getFrameWidth ()); pContext->setFrameColor (getFrameColor ()); } if (gradient) { pContext->fillLinearGradient (path, *gradient, getViewSize ().getTopLeft (), getViewSize ().getBottomLeft ()); } uint32_t selectedIndex = getSelectedSegment (); for (uint32_t index = 0; index < segments.size (); ++index) { Segment& segment = segments[index]; if (!dirtyRect.rectOverlap (segment.rect)) continue; CRect oldClip; pContext->getClipRect (oldClip); CRect clipRect (segment.rect); clipRect.bound (oldClip); pContext->setClipRect (clipRect); bool selected = selectedIndex == index; if (selected && gradientHighlighted) pContext->fillLinearGradient (path, *gradientHighlighted, segment.rect.getTopLeft (), segment.rect.getBottomLeft ()); if (selected && segment.backgroundHighlighted) segment.backgroundHighlighted->draw (pContext, segment.rect); else if (segment.background) segment.background->draw (pContext, segment.rect); CDrawMethods::drawIconAndText (pContext, selected ? segment.iconHighlighted : segment.icon, segment.iconPosition, textAlignment, textMargin, segment.rect, segment.name, font, selected ? textColorHighlighted : textColor); pContext->setClipRect (oldClip); if (drawLines && index > 0 && index < segments.size ()) { path->beginSubpath (segment.rect.getTopLeft ()); path->addLine (isHorizontal ? segment.rect.getBottomLeft () : segment.rect.getTopRight ()); } } if (drawLines) pContext->drawGraphicsPath (path, CDrawContext::kPathStroked); setDirty (false); }