Exemplo n.º 1
0
    void InputField::update(const PhantomTime& time) {
        Composite::update(time);

        // Resize
        Box3 *bb = &this->getBoundingBox();
        bb->size.x = (bb->size.x > bb->size.y / 2.5f * _text.length()) ? bb->size.x : bb->size.y / 2.5f * _text.length();

        paint();
        paintText();
        mouseClickListener();

        if(_hasFocus) {
            std::vector<char> *chars = getDriver()->getInput()->getKeyboardState()->changes();
            for(char c : *chars) {
                if(c == '\b') { // Action for backspace.
                    if(_text.size() > 0) {
                        _text.erase(_text.end() - 1);
                    }
                }
                else if(c == '\n' || c == '\r') {
                    onUnClicked(getDriver()->getInput()->getMouseState());
                }
                else {
                    _text.append(1, c);
                }
            }
        }
    }
Exemplo n.º 2
0
void Colorsel::paintEvent(QPaintEvent *)
{
    paintBorder();
    paintBar();
    paintValue();
    paintText();
}
Exemplo n.º 3
0
void KFileIVIDesktop::paintItem( TQPainter *p, const TQColorGroup &cg)
{
  TQColorGroup colors = updateColors(cg);

  TQIconView* view = iconView();
  Q_ASSERT( view );

  if ( !view )
    return;

  if ( !wordWrap() )
    return;

  p->save();

  // draw the pixmap as in TDEIconViewItem::paintItem(...)
  paintPixmap(p, colors);

  //
  // Paint the text as shadowed if the shadow is available
  //
  if (m_shadow != 0L && (static_cast<KDesktopShadowSettings *> (m_shadow->shadowSettings()))->isEnabled())
    drawShadowedText(p, colors);
  else {
    paintFontUpdate(p);
    paintText(p, colors);
  }

  p->restore();

  paintOverlay(p);
  paintOverlayProgressBar(p);
}
Exemplo n.º 4
0
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
	switch (msg) {
		case WM_CREATE:
			gRequestSender = new RequestSender(IDC_SEND_BUTTON);
			if (!setup_window(hwnd, hDefaultFont)) {
				MessageBoxA(NULL, "Failed to create dialog item(s)", "Error!", MB_ICONEXCLAMATION | MB_OK);
				return NULL;
			};
			CheckRadioButton(hwnd, IDC_RADIO_GET, IDC_RADIO_OPTIONS, IDC_RADIO_GET);
			break;
		case WM_CTLCOLORLISTBOX:
			return (LONG)gHBRBackground;
		case WM_PAINT:
			paintText(hwnd);
			break;
		case WM_COMMAND:
			handleCommand(hwnd, msg, wParam, lParam);
			break;
		case WM_CLOSE:
			delete gRequestSender;
			WSACleanup();
			PostQuitMessage(0);
			break;
		case WM_DESTROY:
			DestroyWindow(hwnd);
			break;
		default:
			return DefWindowProc(hwnd, msg, wParam, lParam);
	}
	return 0;
}
void AMScanThumbnailGridViewItemDelegate::paint(QPainter *painter,
												const QStyleOptionViewItem &option,
												const QModelIndex &index) const
{

    if(option.rect.isEmpty() || !index.isValid())
		return;

    painter->save();

   if(!index.parent().isValid()) {
        // Is a scan

		switch (index.column()) {
		case 0:
            paintText(painter, option, index.data(Qt::DisplayRole).toString());
			break;
		case 1:
			paintText(painter, option, index.data(Qt::DisplayRole).toString());
			break;
		case 3:
			paintText(painter, option,
					  AMDateTimeUtils::prettyDateTime(index.data(Qt::DisplayRole).toDateTime()));
			break;
		case 4:
			paintText(painter, option, index.data(Qt::DisplayRole).toString());
			break;
        default:
			break;
		}

	} else {
		// Is a thumbnail
		switch (index.column()) {
		case 1:
			paintThumbnail(painter, option, index.data(Qt::DecorationRole).value<QPixmap>());
			break;
		case 2:
			paintText(painter, option, index.data(Qt::DisplayRole).toString());
			break;
		default:
			break;
		}
	}

	painter->restore();
}
Exemplo n.º 6
0
/*-------------------------------------------------------------------*/
void BlockTextDrawOutline(POBJECT pObj, WINDOWINFO *pwi, BOOL bIgnorelayer)
{
   blocktext *pT = (blocktext *)pObj;

   if (pwi->usdrawlayer == pT->bt.usLayer || bIgnorelayer)
      paintText(pwi->hps,pwi,pObj,NULL, MODE_OUTLINE);
   return;
}
QImage WebbrowserThumbnailGenerator::generate(const QString& url) const
{
    auto image = createGradientImage(Qt::darkCyan, Qt::white);
    auto host = QUrl{url}.host();
    if (host.startsWith("www."))
        host.remove(0, 4);
    paintText(image, host.isEmpty() ? "Webbrowser" : host);
    return image;
}
Exemplo n.º 8
0
void QStaticTextPrivate::init()
{
    delete[] items;
    delete[] glyphPool;
    delete[] positionPool;

    position = QPointF(0, 0);

    // Draw once to count number of items and glyphs, so that we can use as little memory
    // as possible to store the data
    DrawTextItemDevice counterDevice;
    {
        QPainter painter(&counterDevice);
        painter.setFont(font);
        painter.setTransform(matrix);

        paintText(QPointF(0, 0), &painter);

    }

    itemCount = counterDevice.itemCount();    
    items = new QStaticTextItem[itemCount];

    if (useBackendOptimizations) {
        for (int i=0; i<itemCount; ++i)
            items[i].useBackendOptimizations = true;
    }


    int glyphCount = counterDevice.glyphCount();
    glyphPool = new glyph_t[glyphCount];
    positionPool = new QFixedPoint[glyphCount];

    // Draw again to actually record the items and glyphs
    DrawTextItemDevice recorderDevice(itemCount, items, glyphCount, positionPool, glyphPool);
    {
        QPainter painter(&recorderDevice);
        painter.setFont(font);
        painter.setTransform(matrix);

        paintText(QPointF(0, 0), &painter);
    }

}
Exemplo n.º 9
0
//***************************************************************************
void Kwave::ScaleWidget::drawLog(QPainter &p, int w, int h, bool inverse)
{
    // only use base 10 for now, tested with others too,
    // but not configurable through a property
    const int base = 10;

    int dir = (inverse) ? -1 : +1;

    p.setPen(palette().dark().color());
    p.drawLine (0, dir*(h-1), dir*w, dir*(h-1));
    p.drawLine (dir*(w-1), 0, dir*(w-1), dir*(h-1));

    p.setPen(palette().text().color());

    int a, x;
    const int h2 = h;

    Q_ASSERT(m_low >= 0);
    Q_ASSERT(m_high > m_low);

    int dec_lo = (m_low) ? Kwave::toInt(floor(log(m_low)/log(base))) : 0;
    int dec_hi = Kwave::toInt(ceil(log(m_high)/log(base)));
    int decades = qAbs(dec_hi - dec_lo) + 1;

    // check if we have enough space for the small lines within a decade
    int w1 = Kwave::toInt(w / decades); // pixels per decade
    bool small_lines = (w1 - Kwave::toInt(
	static_cast<double>(w1) * log(base-1)/log(base))) > 1;

    // print the lines
    for (a = 0; a < decades; ++a) {
	// big line, for each decade
	x = Kwave::toInt((w-1) * a / decades);
	p.drawLine (dir * x, dir * 1, dir * x, dir * (h2 - 2));

	w1 = Kwave::toInt((w - 1) * (a + 1) / decades) - x + 1;
	if (small_lines) {
	    // small lines, within the decade
	    for (int i = 1; i < base; i++) {
		int x1 = x + Kwave::toInt(static_cast<double>(w1) *
		    log(i) / log(base));
		p.drawLine (dir * x1, dir * 1, dir * x1, dir * ((h2 / 2) - 2));
	    }
	}
    }

    // print the text
    for (a = 0; a < decades; ++a) {
	QString buf = _("%1 %2");
	int value = Kwave::toInt(pow(base, dec_lo + a));
	buf = buf.arg(value).arg(m_unittext);
	x = ((w - 1) * a) / decades;
	paintText(p, dir * (x + 4), dir * (h - FONTSIZE - 4), inverse, buf);
    }
}
Exemplo n.º 10
0
void PaintMethods::paintDebugDrawing(QPainter& painter, const DebugDrawing& debugDrawing, const QTransform& baseTrans)
{
  for(const DebugDrawing::Element* e = debugDrawing.getFirst(); e; e = debugDrawing.getNext(e))
    switch(e->type)
    {
      case DebugDrawing::Element::POLYGON:
      {
        paintPolygon(*static_cast<const DebugDrawing::Polygon*>(e), painter);
        break;
      }
      case DebugDrawing::Element::GRID_RGBA:
      {
        paintGridRGBA(*static_cast<const DebugDrawing::GridRGBA*>(e), painter);
        break;
      }
      case DebugDrawing::Element::GRID_MONO:
      {
        paintGridMono(*static_cast<const DebugDrawing::GridMono*>(e), painter);
        break;
      }
      case DebugDrawing::Element::ELLIPSE:
      {
        paintEllipse(*static_cast<const DebugDrawing::Ellipse*>(e), painter);
        break;
      }
      case DebugDrawing::Element::ARC:
      {
        paintArc(*static_cast<const DebugDrawing::Arc*>(e), painter);
        break;
      }
      case DebugDrawing::Element::RECTANGLE:
      {
        paintRectangle(*static_cast<const DebugDrawing::Rectangle*>(e), painter);
        break;
      }
      case DebugDrawing::Element::LINE:
      {
        paintLine(*static_cast<const DebugDrawing::Line*>(e), painter);
        break;
      }
      case DebugDrawing::Element::ORIGIN:
      {
        paintOrigin(*static_cast<const DebugDrawing::Origin*>(e), painter, baseTrans);
        break;
      }
      case DebugDrawing::Element::TEXT:
      {
        paintText(*static_cast<const DebugDrawing::Text*>(e), painter);
        break;
      }
      default:
        break;
    }
}
Exemplo n.º 11
0
void SkinListDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex &index) const
{
    painter->save();

    paintBackground(painter, option);

    paintIcon(painter, option, index);

    paintText(painter, option, index);

    painter->restore();
}
Exemplo n.º 12
0
void controlUC::paint(HDC hDC, const RECT& rcPaint)
{
	if( !::IntersectRect(&m_rcPaint, &rcPaint, &m_rcItem) ) return;

	// »æÖÆÑ­Ðò£º±³¾°ÑÕÉ«->±³¾°Í¼->״̬ͼ->Îı¾->±ß¿ò
	if( m_cxyBorderRound.cx > 0 || m_cxyBorderRound.cy > 0 ) {
		//renderClip roundClip;
		//renderClip::generateRoundClip(hDC, m_rcPaint,  m_rcItem, m_cxyBorderRound.cx, m_cxyBorderRound.cy, roundClip);
		paintBkColor(hDC);
		paintBkImage(hDC);
		paintStatusImage(hDC);
		paintText(hDC);
		paintBorder(hDC);
	}
	else {
		paintBkColor(hDC);
		paintBkImage(hDC);
		paintStatusImage(hDC);
		paintText(hDC);
		paintBorder(hDC);
	}
}
Exemplo n.º 13
0
QImage FolderThumbnailGenerator::_createFolderImage(
    const QDir& dir, const bool generateThumbnails) const
{
    QImage img = createGradientImage(Qt::black, Qt::white);

    const QFileInfoList& fileList = _getSupportedFilesInDir(dir);

    if (generateThumbnails && fileList.size() > 0)
        _paintThumbnailsMosaic(img, fileList);
    else
        paintText(img, FOLDER_TEXT);

    return img;
}
Exemplo n.º 14
0
void BasicBlockItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget /*= 0*/)
{
  if (_needRepaint == true || _width == 0.0 || _height == 0.0)
  {
    _cache = QPixmap(QSize(_width, _height));
    QPainter cachedPainter(&_cache);
    paintBackground(cachedPainter);
    cachedPainter.setRenderHint(QPainter::TextAntialiasing);
    paintText(cachedPainter);
    _needRepaint = false;
  }

  painter->drawPixmap(0, 0, _cache);
}
Exemplo n.º 15
0
void TextPainter::paintTextInContext(GraphicsContext& context, float amountToIncreaseStrokeWidthBy)
{
    SavedDrawingStateForMask savedDrawingStateForMask = m_savedDrawingStateForMask;
    
    ASSERT(m_savedDrawingStateForMask.m_textPaintStyle);
    ASSERT(m_savedDrawingStateForMask.m_selectionPaintStyle);
    m_savedDrawingStateForMask.m_context = &context;
    m_savedDrawingStateForMask.m_textPaintStyle->strokeWidth += amountToIncreaseStrokeWidthBy;
    m_savedDrawingStateForMask.m_selectionPaintStyle->strokeWidth += amountToIncreaseStrokeWidthBy;
    m_savedDrawingStateForMask.m_textShadow = nullptr;
    m_savedDrawingStateForMask.m_selectionShadow = nullptr;
    paintText();

    m_savedDrawingStateForMask = savedDrawingStateForMask;
}
void UIGDetailsElement::paintElementInfo(QPainter *pPainter, const QStyleOptionGraphicsItem*)
{
    /* Initialize some necessary variables: */
    int iMargin = data(ElementData_Margin).toInt();
    int iSpacing = data(ElementData_Spacing).toInt();

    /* Calculate attributes: */
    int iPixmapHeight = m_pixmapSize.height();
    int iNameHeight = m_nameSize.height();
    int iMaximumHeight = qMax(iPixmapHeight, iNameHeight);

    /* Prepare color: */
    QPalette pal = palette();
    QColor buttonTextColor = pal.color(QPalette::Active, QPalette::ButtonText);
    QColor linkTextColor = pal.color(QPalette::Active, QPalette::Link);

    /* Paint pixmap: */
    int iElementPixmapX = 2 * iMargin;
    int iElementPixmapY = iPixmapHeight == iMaximumHeight ?
                          iMargin : iMargin + (iMaximumHeight - iPixmapHeight) / 2;
    paintPixmap(/* Painter: */
                pPainter,
                /* Rectangle to paint in: */
                QRect(QPoint(iElementPixmapX, iElementPixmapY), m_pixmapSize),
                /* Pixmap to paint: */
                m_pixmap);

    /* Paint name: */
    int iMachineNameX = iElementPixmapX +
                        m_pixmapSize.width() +
                        iSpacing;
    int iMachineNameY = iNameHeight == iMaximumHeight ?
                        iMargin : iMargin + (iMaximumHeight - iNameHeight) / 2;
    paintText(/* Painter: */
              pPainter,
              /* Rectangle to paint in: */
              QPoint(iMachineNameX, iMachineNameY),
              /* Font to paint text: */
              m_nameFont,
              /* Paint device: */
              model()->paintDevice(),
              /* Text to paint: */
              m_strName,
              /* Name hovered? */
              m_fNameHovered ? linkTextColor : buttonTextColor);
}
Exemplo n.º 17
0
void QStaticTextPrivate::init()
{
    delete[] items;
    delete[] glyphPool;
    delete[] positionPool;
    delete[] charPool;

    position = QPointF(0, 0);

    DrawTextItemDevice device(untransformedCoordinates, useBackendOptimizations);
    {
        QPainter painter(&device);
        painter.setFont(font);
        painter.setTransform(matrix);

        paintText(QPointF(0, 0), &painter);
    }

    QVector<QStaticTextItem> deviceItems = device.items();
    QVector<QFixedPoint> positions = device.positions();
    QVector<glyph_t> glyphs = device.glyphs();
    QVector<QChar> chars = device.chars();

    itemCount = deviceItems.size();
    items = new QStaticTextItem[itemCount];

    glyphPool = new glyph_t[glyphs.size()];
    memcpy(glyphPool, glyphs.constData(), glyphs.size() * sizeof(glyph_t));

    positionPool = new QFixedPoint[positions.size()];
    memcpy(positionPool, positions.constData(), positions.size() * sizeof(QFixedPoint));

    charPool = new QChar[chars.size()];
    memcpy(charPool, chars.constData(), chars.size() * sizeof(QChar));

    for (int i=0; i<itemCount; ++i) {
        items[i] = deviceItems.at(i);

        items[i].glyphs = glyphPool + items[i].glyphOffset;
        items[i].glyphPositions = positionPool + items[i].positionOffset;
        items[i].chars = charPool + items[i].charOffset;
    }

    needsRelayout = false;
}
Exemplo n.º 18
0
void DisassemblyView::paintEvent(QPaintEvent * evt)
{
  if (_needRepaint == true)
  {
    _cache = QPixmap(viewport()->size());
    QPainter cachedPainter(&_cache);
    paintBackground(cachedPainter);
    paintSelection(cachedPainter);
    cachedPainter.setRenderHint(QPainter::TextAntialiasing);
    cachedPainter.setFont(font());
    paintText(cachedPainter);
    _needRepaint = false;
  }

  QPainter p(viewport());
  p.drawPixmap(0, 0, _cache);
  paintCursor(p);
}
Exemplo n.º 19
0
//***************************************************************************
void Kwave::ScaleWidget::drawLinear(QPainter &p, int w, int h, bool inverse)
{
    int dir = (inverse) ? -1 : +1;

    p.setPen(palette().dark().color());
    p.drawLine(0, dir * (h - 1), dir * w, dir * (h - 1));
    p.drawLine(dir * (w - 1), 0, dir * (w - 1), dir * (h - 1));

    p.setPen(palette().text().color());

    int a, x;
    double ofs;
    double t = w - 1;
    int h2 = h;

    // print the lines
    while ((t / 10 > 1) && (h2 > 0)) {
	for (ofs = 0; ofs < w - 1; ofs += t) {
	    for (a = 0; a < 4; ++a) {
		x = Kwave::toInt(ofs + (t * a / 4));
		p.drawLine (dir * x, dir * 1, dir * x, dir * (h2 - 2));
	    }
	}
	h2 >>= 1;
	t /= 4;
    }

    // print the text
    for (a = 0; a < 4; ++a) {
	QString buf = _("%1 %2");
	int value = m_low + (((m_high - m_low)* (inverse ? (4 - a) : a)) / 4);
	buf = buf.arg(value).arg(m_unittext);
	x = ((w - 1) * a) / 4;
	paintText(p, dir * (x + 4), dir * (h - FONTSIZE - 4), inverse, buf);
    }

}
void SVGInlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit, LayoutUnit)
{
    ASSERT(paintInfo.shouldPaintWithinRoot(renderer()));
    ASSERT(paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection);
    ASSERT(truncation() == cNoTruncation);

    if (renderer()->style()->visibility() != VISIBLE)
        return;

    // Note: We're explicitely not supporting composition & custom underlines and custom highlighters - unlike InlineTextBox.
    // If we ever need that for SVG, it's very easy to refactor and reuse the code.

    RenderObject* parentRenderer = parent()->renderer();
    ASSERT(parentRenderer);

    bool paintSelectedTextOnly = paintInfo.phase == PaintPhaseSelection;
    bool hasSelection = !parentRenderer->document().printing() && selectionState() != RenderObject::SelectionNone;
    if (!hasSelection && paintSelectedTextOnly)
        return;

    RenderSVGInlineText* textRenderer = toRenderSVGInlineText(this->textRenderer());
    ASSERT(textRenderer);
    if (!textShouldBePainted(textRenderer))
        return;

    RenderStyle* style = parentRenderer->style();
    ASSERT(style);

    paintDocumentMarkers(paintInfo.context, paintOffset, style, textRenderer->scaledFont(), true);

    const SVGRenderStyle* svgStyle = style->svgStyle();
    ASSERT(svgStyle);

    bool hasFill = svgStyle->hasFill();
    bool hasVisibleStroke = svgStyle->hasVisibleStroke();

    RenderStyle* selectionStyle = style;
    if (hasSelection) {
        selectionStyle = parentRenderer->getCachedPseudoStyle(SELECTION);
        if (selectionStyle) {
            const SVGRenderStyle* svgSelectionStyle = selectionStyle->svgStyle();
            ASSERT(svgSelectionStyle);

            if (!hasFill)
                hasFill = svgSelectionStyle->hasFill();
            if (!hasVisibleStroke)
                hasVisibleStroke = svgSelectionStyle->hasVisibleStroke();
        } else
            selectionStyle = style;
    }

    if (textRenderer->frame() && textRenderer->frame()->view() && textRenderer->frame()->view()->paintBehavior() & PaintBehaviorRenderingSVGMask) {
        hasFill = true;
        hasVisibleStroke = false;
    }

    AffineTransform fragmentTransform;
    unsigned textFragmentsSize = m_textFragments.size();
    for (unsigned i = 0; i < textFragmentsSize; ++i) {
        SVGTextFragment& fragment = m_textFragments.at(i);
        ASSERT(!m_paintingResource);

        GraphicsContextStateSaver stateSaver(*paintInfo.context, false);
        fragment.buildFragmentTransform(fragmentTransform);
        if (!fragmentTransform.isIdentity()) {
            stateSaver.save();
            paintInfo.context->concatCTM(fragmentTransform);
        }

        // Spec: All text decorations except line-through should be drawn before the text is filled and stroked; thus, the text is rendered on top of these decorations.
        unsigned decorations = style->textDecorationsInEffect();
        if (decorations & TextDecorationUnderline)
            paintDecoration(paintInfo.context, TextDecorationUnderline, fragment);
        if (decorations & TextDecorationOverline)
            paintDecoration(paintInfo.context, TextDecorationOverline, fragment);

        for (int i = 0; i < 3; i++) {
            switch (svgStyle->paintOrderType(i)) {
            case PT_FILL:
                // Fill text
                if (hasFill) {
                    m_paintingResourceMode = ApplyToFillMode | ApplyToTextMode;
                    paintText(paintInfo.context, style, selectionStyle, fragment, hasSelection, paintSelectedTextOnly);
                }
                break;
            case PT_STROKE:
                // Stroke text
                if (hasVisibleStroke) {
                    m_paintingResourceMode = ApplyToStrokeMode | ApplyToTextMode;
                    paintText(paintInfo.context, style, selectionStyle, fragment, hasSelection, paintSelectedTextOnly);
                }
                break;
            case PT_MARKERS:
                // Markers don't apply to text
                break;
            default:
                ASSERT_NOT_REACHED();
                break;
            }
        }

        // Spec: Line-through should be drawn after the text is filled and stroked; thus, the line-through is rendered on top of the text.
        if (decorations & TextDecorationLineThrough)
            paintDecoration(paintInfo.context, TextDecorationLineThrough, fragment);

        m_paintingResourceMode = ApplyToDefaultMode;
    }

    ASSERT(!m_paintingResource);
}
Exemplo n.º 21
0
/*---------------------------------------------------------------------------*/
void BlockTextPrepPrint(POBJECT pObj, WINDOWINFO *pwi)
{
   paintText(pwi->hps,pwi,pObj,NULL,MODE_PREPPRINTING);
}
Exemplo n.º 22
0
/*-------------------------------------------------------------------*/
void drawBlockText(HPS hps,WINDOWINFO *pwi,POBJECT pObj,RECTL *prcl)
{
   paintText(hps,pwi,pObj,prcl, MODE_NORMAL);
}
void UIGChooserItemMachine::paintMachineInfo(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption)
{
    /* Prepare variables: */
    QRect fullRect = pOption->rect;
    int iFullHeight = fullRect.height();
    int iMargin = data(MachineItemData_Margin).toInt();
    int iMachineItemMajorSpacing = data(MachineItemData_MajorSpacing).toInt();
    int iMachineItemMinorSpacing = data(MachineItemData_MinorSpacing).toInt();
    int iMachineItemTextSpacing = data(MachineItemData_TextSpacing).toInt();
    QSize machinePixmapSize = data(MachineItemData_PixmapSize).toSize();
    QSize machineNameSize = data(MachineItemData_NameSize).toSize();
    QSize snapshotNameSize = data(MachineItemData_SnapshotNameSize).toSize();
    QSize machineStatePixmapSize = data(MachineItemData_StatePixmapSize).toSize();
    QSize machineStateTextSize = data(MachineItemData_StateTextSize).toSize();

    /* Update palette: */
    if (model()->selectionList().contains(this))
    {
        QPalette pal = palette();
        pPainter->setPen(pal.color(QPalette::HighlightedText));
    }

    /* Calculate indents: */
    int iLeftColumnIndent = iMargin;

    /* Paint left column: */
    {
        /* Prepare variables: */
        int iMachinePixmapX = iLeftColumnIndent;
        int iMachinePixmapY = (iFullHeight - machinePixmapSize.height()) / 2;
        /* Paint pixmap: */
        paintPixmap(/* Painter: */
                    pPainter,
                    /* Rectangle to paint in: */
                    QRect(QPoint(iMachinePixmapX, iMachinePixmapY), machinePixmapSize),
                    /* Pixmap to paint: */
                    data(MachineItemData_Pixmap).value<QIcon>().pixmap(machinePixmapSize));
    }

    /* Calculate indents: */
    int iRightColumnIndent = iLeftColumnIndent +
                             machinePixmapSize.width() +
                             iMachineItemMajorSpacing;

    /* Paint right column: */
    {
        /* Calculate indents: */
        int iTopLineHeight = qMax(machineNameSize.height(), snapshotNameSize.height());
        int iBottomLineHeight = qMax(machineStatePixmapSize.height(), machineStateTextSize.height());
        int iRightColumnHeight = iTopLineHeight + iMachineItemTextSpacing + iBottomLineHeight;
        int iTopLineIndent = (iFullHeight - iRightColumnHeight) / 2;

        /* Paint top line: */
        {
            /* Paint left element: */
            {
                /* Prepare variables: */
                int iNameX = iRightColumnIndent;
                int iNameY = iTopLineIndent;
                /* Paint name: */
                paintText(/* Painter: */
                          pPainter,
                          /* Point to paint in: */
                          QPoint(iNameX, iNameY),
                          /* Font to paint text: */
                          data(MachineItemData_NameFont).value<QFont>(),
                          /* Paint device: */
                          model()->paintDevice(),
                          /* Text to paint: */
                          data(MachineItemData_Name).toString());
            }

            /* Calculate indents: */
            int iSnapshotNameIndent = iRightColumnIndent +
                                      machineNameSize.width() +
                                      iMachineItemMinorSpacing;

            /* Paint right element: */
            if (!snapshotName().isEmpty())
            {
                /* Prepare variables: */
                int iSnapshotNameX = iSnapshotNameIndent;
                int iSnapshotNameY = iTopLineIndent;
                /* Paint snapshot name: */
                paintText(/* Painter: */
                          pPainter,
                          /* Point to paint in: */
                          QPoint(iSnapshotNameX, iSnapshotNameY),
                          /* Font to paint text: */
                          data(MachineItemData_SnapshotNameFont).value<QFont>(),
                          /* Paint device: */
                          model()->paintDevice(),
                          /* Text to paint: */
                          data(MachineItemData_SnapshotName).toString());
            }
        }

        /* Calculate indents: */
        int iBottomLineIndent = iTopLineIndent + iTopLineHeight;

        /* Paint bottom line: */
        {
            /* Paint left element: */
            {
                /* Prepare variables: */
                int iMachineStatePixmapX = iRightColumnIndent;
                int iMachineStatePixmapY = iBottomLineIndent;
                /* Paint state pixmap: */
                paintPixmap(/* Painter: */
                            pPainter,
                            /* Rectangle to paint in: */
                            QRect(QPoint(iMachineStatePixmapX, iMachineStatePixmapY), machineStatePixmapSize),
                            /* Pixmap to paint: */
                            data(MachineItemData_StatePixmap).value<QIcon>().pixmap(machineStatePixmapSize));
            }

            /* Calculate indents: */
            int iMachineStateTextIndent = iRightColumnIndent +
                                          machineStatePixmapSize.width() +
                                          iMachineItemMinorSpacing;

            /* Paint right element: */
            {
                /* Prepare variables: */
                int iMachineStateTextX = iMachineStateTextIndent;
                int iMachineStateTextY = iBottomLineIndent;
                /* Paint state text: */
                paintText(/* Painter: */
                          pPainter,
                          /* Point to paint in: */
                          QPoint(iMachineStateTextX, iMachineStateTextY),
                          /* Font to paint text: */
                          data(MachineItemData_StateTextFont).value<QFont>(),
                          /* Paint device: */
                          model()->paintDevice(),
                          /* Text to paint: */
                          data(MachineItemData_StateText).toString());
            }
        }
    }

    /* Tool-bar: */
    if (m_pToolBar)
    {
        /* Show/hide tool-bar: */
        if (isHovered())
        {
            if (!m_pToolBar->isVisible())
                m_pToolBar->show();
        }
        else
        {
            if (m_pToolBar->isVisible())
                m_pToolBar->hide();
        }
    }
}
Exemplo n.º 24
0
void SVGInlineTextBox::paint(PaintInfo& paintInfo, int, int)
{
    ASSERT(paintInfo.shouldPaintWithinRoot(renderer()));
    ASSERT(paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection);
    ASSERT(truncation() == cNoTruncation);

    if (renderer()->style()->visibility() != VISIBLE)
        return;

    // Note: We're explicitely not supporting composition & custom underlines and custom highlighters - unlike InlineTextBox.
    // If we ever need that for SVG, it's very easy to refactor and reuse the code.

    RenderObject* parentRenderer = parent()->renderer();
    ASSERT(parentRenderer);

    bool paintSelectedTextOnly = paintInfo.phase == PaintPhaseSelection;
    bool hasSelection = !parentRenderer->document()->printing() && selectionState() != RenderObject::SelectionNone;
    if (!hasSelection && paintSelectedTextOnly)
        return;

    RenderStyle* style = parentRenderer->style();
    ASSERT(style);

    const SVGRenderStyle* svgStyle = style->svgStyle();
    ASSERT(svgStyle);

    bool hasFill = svgStyle->hasFill();
    bool hasStroke = svgStyle->hasStroke();

    RenderStyle* selectionStyle = style;
    if (hasSelection) {
        selectionStyle = parentRenderer->getCachedPseudoStyle(SELECTION);
        if (selectionStyle) {
            const SVGRenderStyle* svgSelectionStyle = selectionStyle->svgStyle();
            ASSERT(svgSelectionStyle);

            if (!hasFill)
                hasFill = svgSelectionStyle->hasFill();
            if (!hasStroke)
                hasStroke = svgSelectionStyle->hasStroke();
        } else
            selectionStyle = style;
    }

    unsigned textFragmentsSize = m_textFragments.size();
    for (unsigned i = 0; i < textFragmentsSize; ++i) {
        SVGTextFragment& fragment = m_textFragments.at(i);
        ASSERT(!m_paintingResource);

        paintInfo.context->save();

        if (!fragment.transform.isIdentity())
            paintInfo.context->concatCTM(fragment.transform);

        // Spec: All text decorations except line-through should be drawn before the text is filled and stroked; thus, the text is rendered on top of these decorations.
        int decorations = style->textDecorationsInEffect();
        if (decorations & UNDERLINE)
            paintDecoration(paintInfo.context, UNDERLINE, fragment);
        if (decorations & OVERLINE)
            paintDecoration(paintInfo.context, OVERLINE, fragment);

        // Fill text
        if (hasFill) {
            m_paintingResourceMode = ApplyToFillMode | ApplyToTextMode;
            paintText(paintInfo.context, style, selectionStyle, fragment, hasSelection, paintSelectedTextOnly);
        }

        // Stroke text
        if (hasStroke) {
            m_paintingResourceMode = ApplyToStrokeMode | ApplyToTextMode;
            paintText(paintInfo.context, style, selectionStyle, fragment, hasSelection, paintSelectedTextOnly);
        }

        // Spec: Line-through should be drawn after the text is filled and stroked; thus, the line-through is rendered on top of the text.
        if (decorations & LINE_THROUGH)
            paintDecoration(paintInfo.context, LINE_THROUGH, fragment);

        m_paintingResourceMode = ApplyToDefaultMode;
        paintInfo.context->restore();
    }

    ASSERT(!m_paintingResource);
}
Exemplo n.º 25
0
QImage ImageThumbnailGenerator::_createLargeImagePlaceholder() const
{
    QImage img = createGradientImage( Qt::darkBlue, Qt::white );
    paintText( img, "LARGE\nIMAGE" );
    return img;
}
Exemplo n.º 26
0
void QSlide::paintEvent(QPaintEvent *)
{
    paintBorder();
    paintText();
    paintGrid();
}
Exemplo n.º 27
0
void SVGInlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit, LayoutUnit)
{
    ASSERT(paintInfo.shouldPaintWithinRoot(renderer()));
    ASSERT(paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection);
    ASSERT(truncation() == cNoTruncation);

    if (renderer().style().visibility() != VISIBLE)
        return;

    // Note: We're explicitely not supporting composition & custom underlines and custom highlighters - unlike InlineTextBox.
    // If we ever need that for SVG, it's very easy to refactor and reuse the code.

    auto& parentRenderer = parent()->renderer();

    bool paintSelectedTextOnly = paintInfo.phase == PaintPhaseSelection;
    bool hasSelection = !parentRenderer.document().printing() && selectionState() != RenderObject::SelectionNone;
    if (!hasSelection && paintSelectedTextOnly)
        return;

    if (!textShouldBePainted(renderer()))
        return;

    RenderStyle& style = parentRenderer.style();

    const SVGRenderStyle& svgStyle = style.svgStyle();

    bool hasFill = svgStyle.hasFill();
    bool hasVisibleStroke = svgStyle.hasVisibleStroke();

    RenderStyle* selectionStyle = &style;
    if (hasSelection) {
        selectionStyle = parentRenderer.getCachedPseudoStyle(SELECTION);
        if (selectionStyle) {
            const SVGRenderStyle& svgSelectionStyle = selectionStyle->svgStyle();

            if (!hasFill)
                hasFill = svgSelectionStyle.hasFill();
            if (!hasVisibleStroke)
                hasVisibleStroke = svgSelectionStyle.hasVisibleStroke();
        } else
            selectionStyle = &style;
    }

    if (renderer().view().frameView().paintBehavior() & PaintBehaviorRenderingSVGMask) {
        hasFill = true;
        hasVisibleStroke = false;
    }

    AffineTransform fragmentTransform;
    unsigned textFragmentsSize = m_textFragments.size();
    for (unsigned i = 0; i < textFragmentsSize; ++i) {
        SVGTextFragment& fragment = m_textFragments.at(i);
        ASSERT(!m_paintingResource);

        GraphicsContextStateSaver stateSaver(paintInfo.context());
        fragment.buildFragmentTransform(fragmentTransform);
        if (!fragmentTransform.isIdentity())
            paintInfo.context().concatCTM(fragmentTransform);

        // Spec: All text decorations except line-through should be drawn before the text is filled and stroked; thus, the text is rendered on top of these decorations.
        int decorations = style.textDecorationsInEffect();
        if (decorations & TextDecorationUnderline)
            paintDecoration(paintInfo.context(), TextDecorationUnderline, fragment);
        if (decorations & TextDecorationOverline)
            paintDecoration(paintInfo.context(), TextDecorationOverline, fragment);

        auto paintOrder = style.svgStyle().paintTypesForPaintOrder();
        for (unsigned i = 0; i < paintOrder.size(); ++i) {
            switch (paintOrder.at(i)) {
            case PaintTypeFill:
                if (!hasFill)
                    continue;
                m_paintingResourceMode = ApplyToFillMode | ApplyToTextMode;
                paintText(paintInfo.context(), &style, selectionStyle, fragment, hasSelection, paintSelectedTextOnly);
                break;
            case PaintTypeStroke:
                if (!hasVisibleStroke)
                    continue;
                m_paintingResourceMode = ApplyToStrokeMode | ApplyToTextMode;
                paintText(paintInfo.context(), &style, selectionStyle, fragment, hasSelection, paintSelectedTextOnly);
                break;
            case PaintTypeMarkers:
                continue;
            }
        }

        // Spec: Line-through should be drawn after the text is filled and stroked; thus, the line-through is rendered on top of the text.
        if (decorations & TextDecorationLineThrough)
            paintDecoration(paintInfo.context(), TextDecorationLineThrough, fragment);

        m_paintingResourceMode = ApplyToDefaultMode;
    }

    // Finally, paint the outline if any.
    if (renderer().style().hasOutline() && is<RenderInline>(parentRenderer))
        downcast<RenderInline>(parentRenderer).paintOutline(paintInfo, paintOffset);

    ASSERT(!m_paintingResource);
}
void UIGSelectorItemMachine::paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, QWidget * /* pWidget = 0 */)
{
    /* Initialize some necessary variables: */
    QRect fullRect = pOption->rect;
    int iMachineItemMargin = data(MachineItemData_MachineItemMargin).toInt();
    int iMachineItemMajorSpacing = data(MachineItemData_MachineItemMajorSpacing).toInt();
    int iMachineItemMinorSpacing = data(MachineItemData_MachineItemMinorSpacing).toInt();
    int iMachineItemTextSpacing = data(MachineItemData_MachineItemTextSpacing).toInt();
    QSize machinePixmapSize = data(MachineItemData_MachinePixmapSize).toSize();
    QSize machineNameSize = data(MachineItemData_MachineNameSize).toSize();
    QString strSnapshotName = data(MachineItemData_SnapshotName).toString();
    QSize snapshotNameSize = data(MachineItemData_SnapshotNameSize).toSize();
    QSize machineStatePixmapSize = data(MachineItemData_MachineStatePixmapSize).toSize();
    QSize machineStateTextSize = data(MachineItemData_MachineStateTextSize).toSize();

    /* Paint background: */
    paintBackground(/* Painter: */
                    pPainter,
                    /* Rectangle to paint in: */
                    fullRect,
                    /* Has parent? */
                    parentItem(),
                    /* Is item selected? */
                    model()->selectionList().contains(this),
                    /* Gradient darkness for animation: */
                    gradient(),
                    /* Show drag where? */
                    dragTokenPlace());

    /* Paint pixmap: */
    paintPixmap(/* Painter: */
                pPainter,
                /* Rectangle to paint in: */
                QRect(fullRect.topLeft() +
                      QPoint(iMachineItemMargin, iMachineItemMargin),
                      machinePixmapSize),
                /* Pixmap to paint: */
                data(MachineItemData_MachinePixmap).value<QIcon>().pixmap(machinePixmapSize));

    /* Paint name: */
    paintText(/* Painter: */
              pPainter,
              /* Rectangle to paint in: */
              QRect(fullRect.topLeft() +
                    QPoint(iMachineItemMargin, iMachineItemMargin) +
                    QPoint(machinePixmapSize.width() + iMachineItemMajorSpacing, 0),
                    machineNameSize),
              /* Font to paint text: */
              data(MachineItemData_MachineNameFont).value<QFont>(),
              /* Text to paint: */
              data(MachineItemData_MachineName).toString());

    /* Paint snapshot name (if necessary): */
    if (!strSnapshotName.isEmpty())
        paintText(/* Painter: */
                  pPainter,
                  /* Rectangle to paint in: */
                  QRect(fullRect.topLeft() +
                        QPoint(iMachineItemMargin, iMachineItemMargin) +
                        QPoint(machinePixmapSize.width() + iMachineItemMajorSpacing, 0) +
                        QPoint(machineNameSize.width() + iMachineItemMinorSpacing, 0),
                        snapshotNameSize),
                  /* Font to paint text: */
                  data(MachineItemData_SnapshotNameFont).value<QFont>(),
                  /* Text to paint: */
                  QString("(%1)").arg(strSnapshotName));

    /* Paint state pixmap: */
    paintPixmap(/* Painter: */
                pPainter,
                /* Rectangle to paint in: */
                QRect(fullRect.topLeft() +
                      QPoint(iMachineItemMargin, iMachineItemMargin) +
                      QPoint(machinePixmapSize.width() + iMachineItemMajorSpacing, 0) +
                      QPoint(0, machineNameSize.height() + iMachineItemTextSpacing),
                      machineStatePixmapSize),
                /* Pixmap to paint: */
                data(MachineItemData_MachineStatePixmap).value<QIcon>().pixmap(machineStatePixmapSize));

    /* Paint state text: */
    paintText(/* Painter: */
              pPainter,
              /* Rectangle to paint in: */
              QRect(fullRect.topLeft() +
                    QPoint(iMachineItemMargin, iMachineItemMargin) +
                    QPoint(machinePixmapSize.width() + iMachineItemMajorSpacing, 0) +
                    QPoint(0, machineNameSize.height() + iMachineItemTextSpacing) +
                    QPoint(machineStatePixmapSize.width() + iMachineItemMinorSpacing, 0),
                    machineStateTextSize),
              /* Font to paint text: */
              data(MachineItemData_MachineStateTextFont).value<QFont>(),
              /* Text to paint: */
              data(MachineItemData_MachineStateText).toString());

    /* Paint focus (if necessary): */
    if (model()->focusItem() == this)
        paintFocus(/* Painter: */
                   pPainter,
                   /* Rectangle to paint in: */
                   fullRect);
}
void SVGInlineTextBoxPainter::paintTextFragments(const PaintInfo& paintInfo, LayoutObject& parentLayoutObject)
{
    const ComputedStyle& style = parentLayoutObject.styleRef();
    const SVGComputedStyle& svgStyle = style.svgStyle();

    bool hasFill = svgStyle.hasFill();
    bool hasVisibleStroke = svgStyle.hasVisibleStroke();

    const ComputedStyle* selectionStyle = &style;
    bool shouldPaintSelection = this->shouldPaintSelection();
    if (shouldPaintSelection) {
        selectionStyle = parentLayoutObject.getCachedPseudoStyle(SELECTION);
        if (selectionStyle) {
            const SVGComputedStyle& svgSelectionStyle = selectionStyle->svgStyle();

            if (!hasFill)
                hasFill = svgSelectionStyle.hasFill();
            if (!hasVisibleStroke)
                hasVisibleStroke = svgSelectionStyle.hasVisibleStroke();
        } else {
            selectionStyle = &style;
        }
    }

    if (paintInfo.isRenderingClipPathAsMaskImage()) {
        hasFill = true;
        hasVisibleStroke = false;
    }

    AffineTransform fragmentTransform;
    unsigned textFragmentsSize = m_svgInlineTextBox.textFragments().size();
    for (unsigned i = 0; i < textFragmentsSize; ++i) {
        SVGTextFragment& fragment = m_svgInlineTextBox.textFragments().at(i);

        GraphicsContextStateSaver stateSaver(*paintInfo.context, false);
        fragment.buildFragmentTransform(fragmentTransform);
        if (!fragmentTransform.isIdentity()) {
            stateSaver.save();
            paintInfo.context->concatCTM(fragmentTransform);
        }

        // Spec: All text decorations except line-through should be drawn before the text is filled and stroked; thus, the text is rendered on top of these decorations.
        unsigned decorations = style.textDecorationsInEffect();
        if (decorations & TextDecorationUnderline)
            paintDecoration(paintInfo, TextDecorationUnderline, fragment);
        if (decorations & TextDecorationOverline)
            paintDecoration(paintInfo, TextDecorationOverline, fragment);

        for (int i = 0; i < 3; i++) {
            switch (svgStyle.paintOrderType(i)) {
            case PT_FILL:
                if (hasFill)
                    paintText(paintInfo, style, *selectionStyle, fragment, ApplyToFillMode, shouldPaintSelection);
                break;
            case PT_STROKE:
                if (hasVisibleStroke)
                    paintText(paintInfo, style, *selectionStyle, fragment, ApplyToStrokeMode, shouldPaintSelection);
                break;
            case PT_MARKERS:
                // Markers don't apply to text
                break;
            default:
                ASSERT_NOT_REACHED();
                break;
            }
        }

        // Spec: Line-through should be drawn after the text is filled and stroked; thus, the line-through is rendered on top of the text.
        if (decorations & TextDecorationLineThrough)
            paintDecoration(paintInfo, TextDecorationLineThrough, fragment);
    }
}
Exemplo n.º 30
0
void t_libraryEditor::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
    QBrush polyBrush;
    polyBrush.setColor(g_color);
    QPen dotPen;
    uint8_t minThickness = 4;
    painter.setRenderHint(QPainter::Antialiasing, true);
    painter.scale(scale, scale);
    painter.translate(offsetx,offsety);
    painter.setBackgroundMode(Qt::OpaqueMode);
    painter.setBackground(QBrush(QColor(255,255,255)));
    painter.fillRect(-2000,-2000,4000,4000,QColor(255,255,255));

    dotPen.setStyle(Qt::DashLine);
    dotPen.setColor(QColor(200,200,200));
    dotPen.setWidth(0);
    painter.setPen(dotPen);
    for(int16_t x = -2000; x != 2000; x += 50)
    {
        painter.drawLine(x,-2000,x,2000);
        painter.drawLine(-2000,x,2000,x);
    }

    if(haveComp)
    {
        for(uint16_t t = 0; t != currentComponent->items.size(); ++t)
        {
            if(currentComponent->items.at(t)->thickness < minThickness)
                currentComponent->items.at(t)->thickness = minThickness;
            if(currentComponent->items.at(t)->type == 'P')
            {
                t_PolylineObject *ob = static_cast<t_PolylineObject*>(currentComponent->items.at(t));
                paintPolygon(painter, *ob);
            }
            else if(currentComponent->items.at(t)->type == 'C')
            {
                t_CircleObject *ob = static_cast<t_CircleObject*>(currentComponent->items.at(t));
                paintCircle(painter, *ob);
            }
            else if(currentComponent->items.at(t)->type == 'X')
            {
                t_PinObject *ob = static_cast<t_PinObject*>(currentComponent->items.at(t));
                paintPin(painter, *ob);
            }
            else if(currentComponent->items.at(t)->type == 'S')
            {
                t_RectangleObject *ob = static_cast<t_RectangleObject*>(currentComponent->items.at(t));
                paintRectangle(painter, *ob);
            }
            else if(currentComponent->items.at(t)->type == 'A')
            {
                t_ArcObject *ob = static_cast<t_ArcObject*>(currentComponent->items.at(t));
                paintArc(painter, *ob);
            }
        }
        for(uint8_t t = 0; t != currentComponent->fields.size(); ++t)
        {
            t_component_field tF = currentComponent->fields.at(t);
            if(tF.flags & (1 << VISIBLE))
            {
                paintText(painter, tF);
            }
        }
    }

/*    if(incompleteStage)
    {
        dotPen.setWidth(5);
        dotPen.setStyle(Qt::SolidLine);
        dotPen.setColor(QColor(200,100,100));
        painter.setPen(dotPen);
        painter.drawLine(incompleteLine);
    }
    else if(pinPlacement)
    {
        dotPen.setWidth(1);
        dotPen.setColor(QColor(100,200,100));
        painter.setPen(dotPen);
        painter.drawEllipse(incompleteLine.p2(), 10, 10);
    }
    */
    dotPen.setColor(QColor(100,100,100));
    dotPen.setWidth(1);
    painter.setPen(dotPen);
    painter.drawLine(0,-10,0,10);
    painter.drawLine(-10,0,10,0);
    event->accept();
}