SavedState (Direct2DLowLevelGraphicsContext& owner_)
          : owner (owner_), currentBrush (0),
            fontHeightToEmSizeFactor (1.0f), currentFontFace (0),
            clipsRect (false), shouldClipRect (false),
            clipsRectList (false), shouldClipRectList (false),
            clipsComplex (false), shouldClipComplex (false),
            clipsBitmap (false), shouldClipBitmap (false)
        {
            if (owner.currentState != nullptr)
            {
                // xxx seems like a very slow way to create one of these, and this is a performance
                // bottleneck.. Can the same internal objects be shared by multiple state objects, maybe using copy-on-write?
                setFill (owner.currentState->fillType);
                currentBrush = owner.currentState->currentBrush;
                clipRect = owner.currentState->clipRect;
                transform = owner.currentState->transform;

                font = owner.currentState->font;
                currentFontFace = owner.currentState->currentFontFace;
            }
            else
            {
                const D2D1_SIZE_U size (owner.renderingTarget->GetPixelSize());
                clipRect.setSize (size.width, size.height);
                setFill (FillType (Colours::black));
            }
        }
コード例 #2
0
int RoundRectItem::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QGraphicsObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    
#ifndef QT_NO_PROPERTIES
     if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< bool*>(_v) = fill(); break;
        }
        _id -= 1;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setFill(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 1;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 1;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
コード例 #3
0
Turtle::Turtle(Composite* owner){
  double pts_body[4][2] = {{0, 15}, {20, 0}, {0, -15}, {0,15}};
  setColor(COLOR("red"), false);
  setFill();
  penDown();
  reset(canvas_width()/2, canvas_height()/2,pts_body, 4, owner);
}
コード例 #4
0
ValueTree DrawableShape::FillAndStrokeState::getFillState (const Identifier& fillOrStrokeType)
{
    ValueTree v (state.getChildWithName (fillOrStrokeType));
    if (v.isValid())
        return v;

    setFill (fillOrStrokeType, FillType (Colours::black), nullptr, nullptr);
    return getFillState (fillOrStrokeType);
}
コード例 #5
0
ファイル: ScopePanel.cpp プロジェクト: hotelzululima/CubicSDR
ScopePanel::ScopePanel() : GLPanel(), scopeMode(SCOPE_MODE_Y) {
    setFill(GLPanelFillType::GLPANEL_FILL_NONE);
    bgPanel.setFill(GLPanelFillType::GLPANEL_FILL_GRAD_BAR_Y);
    bgPanelStereo[0].setFill(GLPanelFillType::GLPANEL_FILL_GRAD_BAR_Y);
    bgPanelStereo[0].setPosition(0, 0.5);
    bgPanelStereo[0].setSize(1, 0.5);
    bgPanelStereo[1].setFill(GLPanelFillType::GLPANEL_FILL_GRAD_BAR_Y);
    bgPanelStereo[1].setPosition(0, -0.5);
    bgPanelStereo[1].setSize(1, 0.5);
}
コード例 #6
0
ファイル: Program.cpp プロジェクト: nalune/MarkTwain
void paint()
{
	int width = getWindowWidth();
	int height = getWindowHeight();

	int radius = min(width, height) / 2;

	setFill(colorYellow);
	fillCircle(width / 2, height / 2, radius);
	setStroke(colorGreen, 10);
	drawCircle(width / 2, height / 2, radius);

	setFill(colorYellow);
	fillEllipse(200, 200, 350, 250);
	setStroke(colorGreen, 10);
	drawEllipse(200, 200, 350, 250);

	setStroke(colorBlue, 2);

	drawLine(10, 10, _mouseX, _mouseY);

	if(_pressedChar != 0)
	{
		char str[2] = {0};
		str[0] = _pressedChar;

		drawText(100, 100, str, 10, colorWhite, colorBlue);
	}

	char str[256] = {0};
	sprintf(str, "%d - HELLO COMPUTER", _secondElapsed);

	drawText(100, 200, str, 70, colorYellow, colorBlue);

	setFill((_secondElapsed % 2) == 0 ? colorBlue : colorRed);
	fillRectangle(200, 200, 100, 100);
	setStroke(colorGreen, 2);
	drawRectangle(200, 200, 100, 100);
}
コード例 #7
0
ファイル: checkbox.cpp プロジェクト: farmboy0/xoreos
void WidgetCheckBox::setState(bool state) {
	_state = state;

	// Preserve the current color after replacing the texture
	float textR, textG, textB, textA;
	float quadR, quadG, quadB, quadA;
	_text->getColor(textR, textG, textB, textA);
	_quad->getColor(quadR, quadG, quadB, quadA);

	setFill(_state ? "i_checkbox02" : "i_checkbox01");

	_text->setColor(textR, textG, textB, textA);
	_quad->setColor(quadR, quadG, quadB, quadA);

	setActive(true);
}
コード例 #8
0
ファイル: htmltable.c プロジェクト: TidyHuang/vizgems
static void
emit_html_cell(GVJ_t * job, htmlcell_t * cp, htmlenv_t * env)
{
    htmlmap_data_t saved;
    boxf pts = cp->data.box;
    pointf pos = env->pos;
    int inAnchor, doAnchor = (cp->data.href || cp->data.target);

    pts.LL.x += pos.x;
    pts.UR.x += pos.x;
    pts.LL.y += pos.y;
    pts.UR.y += pos.y;

    if (doAnchor && !(job->flags & EMIT_CLUSTERS_LAST))
	inAnchor = initAnchor(job, env, &cp->data, pts, &saved, 1);
    else
	inAnchor = 0;

    if (cp->data.bgcolor) {
	char* clrs[2];
	int filled = setFill (job, cp->data.bgcolor, cp->data.gradientangle, cp->data.style, clrs);
	gvrender_box(job, pts, filled);
	free (clrs[0]);
    }

    if (cp->data.border)
	doBorder(job, cp->data.pencolor, cp->data.border, pts);

    if (cp->child.kind == HTML_TBL)
	emit_html_tbl(job, cp->child.u.tbl, env);
    else if (cp->child.kind == HTML_IMAGE)
	emit_html_img(job, cp->child.u.img, env);
    else
	emit_html_txt(job, cp->child.u.txt, env);

    if (inAnchor)
	endAnchor (job, &saved, 1);

    if (doAnchor && (job->flags & EMIT_CLUSTERS_LAST)) {
	if (initAnchor(job, env, &cp->data, pts, &saved, 0))
	    endAnchor (job, &saved, 0);
    }
}
コード例 #9
0
ファイル: SpectrumPanel.cpp プロジェクト: digver/CubicSDR
SpectrumPanel::SpectrumPanel() {
    floorValue = 0;
    ceilValue = 1;
    showDb = false;
    fftSize = DEFAULT_FFT_SIZE;
    bandwidth = DEFAULT_DEMOD_BW;
    freq = 0;
    
    setFill(GLPANEL_FILL_GRAD_Y);
    setFillColor(ThemeMgr::mgr.currentTheme->fftBackground * 2.0, ThemeMgr::mgr.currentTheme->fftBackground);
    
    dbPanelCeil.setMarginPx(0);
    dbPanelCeil.setFill(GLPanel::GLPANEL_FILL_GRAD_X);
    dbPanelCeil.setFillColor(RGBA4f(0.2f,0.2f,0.2f,5.0f), RGBA4f(0.2f,0.2f,0.2f,0.0f));
    
    dbPanelFloor.setMarginPx(0);
    dbPanelFloor.setFill(GLPanel::GLPANEL_FILL_GRAD_X);
    dbPanelFloor.setFillColor(RGBA4f(0.2f,0.2f,0.2f,5.0f), RGBA4f(0.2f,0.2f,0.2f,0.0f));
}
コード例 #10
0
ファイル: Console.cpp プロジェクト: dasaro77/OGLText
Console::Console(DrawingContext* context) : DisplayBox(context) {
  this->buffer = new ConsoleBuffer(11);
  this->loadedBufferLine = -1;

  setKeyHandler(new ConsoleKeyHandler(this, buffer));

  // Default display box stylings
  setLine(2, 1, 0, 0);
  setFill(0.25, 0, 0);

  // Bind typeset config into basic language
  basicLanguage["yild"] = new SimpleSetAction<TypeSetMetadata>(
      buffer->getTypeSetMetadata(),
      &TypeSetMetadata::setYild);

  basicLanguage["strokeScale"] = new SimpleSetAction<TypeSetMetadata>(
      buffer->getTypeSetMetadata(),
      &TypeSetMetadata::setStrokeScale);

  basicLanguage["red"] = new SimpleSetAction<TypeSetMetadata>(
        buffer->getTypeSetMetadata(),
        &TypeSetMetadata::setRed);

  basicLanguage["green"] = new SimpleSetAction<TypeSetMetadata>(
        buffer->getTypeSetMetadata(),
        &TypeSetMetadata::setGreen);

  basicLanguage["blue"] = new SimpleSetAction<TypeSetMetadata>(
        buffer->getTypeSetMetadata(),
        &TypeSetMetadata::setBlue);

  basicLanguage["lineWidth"] = new SimpleSetAction<TypeSetMetadata>(
        buffer->getTypeSetMetadata(),
        &TypeSetMetadata::setLineWidth);

  basicLanguage["reset"] = new SimpleSetAction<TypeSetMetadata>(
      buffer->getTypeSetMetadata(),
      &TypeSetMetadata::reset);
}
コード例 #11
0
void QDeclarativeAnchors::resetFill()
{
    setFill(0);
}
コード例 #12
0
ファイル: htmltable.c プロジェクト: TidyHuang/vizgems
static void
emit_html_tbl(GVJ_t * job, htmltbl_t * tbl, htmlenv_t * env)
{
    boxf pts = tbl->data.box;
    pointf pos = env->pos;
    htmlcell_t **cells = tbl->u.n.cells;
    htmlcell_t *cp;
    static htmlfont_t savef;
    htmlmap_data_t saved;
    int anchor; /* if true, we need to undo anchor settings. */
    int doAnchor = (tbl->data.href || tbl->data.target);
    pointf AF[4];

    if (tbl->font)
	pushFontInfo(env, tbl->font, &savef);

    pts.LL.x += pos.x;
    pts.UR.x += pos.x;
    pts.LL.y += pos.y;
    pts.UR.y += pos.y;

    if (doAnchor && !(job->flags & EMIT_CLUSTERS_LAST))
	anchor = initAnchor(job, env, &tbl->data, pts, &saved, 1);
    else
	anchor = 0;
    /* Set up rounded style */
    if (tbl->data.style & ROUNDED) {
	AF[0] = pts.LL;
	AF[2] = pts.UR;
	if (tbl->data.border) {
	    double delta = ((double)tbl->data.border)/2.0;
	    AF[0].x += delta;
	    AF[0].y += delta;
	    AF[2].x -= delta;
	    AF[2].y -= delta;
	}
	AF[1].x = AF[2].x;
	AF[1].y = AF[0].y;
	AF[3].x = AF[0].x;
	AF[3].y = AF[2].y;
    }

    /* Fill first */
    if (tbl->data.bgcolor) {
	char* clrs[2];
	int filled = setFill (job, tbl->data.bgcolor, tbl->data.gradientangle, tbl->data.style, clrs);
	if (tbl->data.style & ROUNDED){
	    round_corners (job, AF, 4, tbl->data.style, filled);
	}
	else
	    gvrender_box(job, pts, filled);
	free (clrs[0]);
    }
     
    while (*cells) {
	emit_html_cell(job, *cells, env);
	cells++;
    }

    /* Draw table rules and border.
     * Draw after cells so we can draw over any fill.
     * At present, we set the penwidth to 1 for rules until we provide the calculations to take
     * into account wider rules.
     */
    cells = tbl->u.n.cells;
    gvrender_set_penwidth(job, 1.0);
    while ((cp = *cells++)){
	if (cp->ruled) emit_html_rules(job, cp, env, tbl->data.pencolor);
    }

    if (tbl->data.border) {
	if (tbl->data.style & ROUNDED) {
	    char* color = (tbl->data.pencolor ? tbl->data.pencolor : DEFAULT_COLOR);
	    gvrender_set_penwidth(job, tbl->data.border);
	    gvrender_set_pencolor(job, color);
	    round_corners (job, AF, 4, tbl->data.style, 0);
	}
	else
	    doBorder(job, tbl->data.pencolor, tbl->data.border, pts);
    }

    if (anchor)
	endAnchor (job, &saved, 1);

    if (doAnchor && (job->flags & EMIT_CLUSTERS_LAST)) {
	if (initAnchor(job, env, &tbl->data, pts, &saved, 0))
	    endAnchor (job, &saved, 0);
    }

    if (tbl->font)
	popFontInfo(env, &savef);
}
コード例 #13
0
ファイル: SVGResources.cpp プロジェクト: eocanha/webkit
bool SVGResources::buildCachedResources(const RenderElement& renderer, const RenderStyle& style)
{
    ASSERT(renderer.element());
    ASSERT_WITH_SECURITY_IMPLICATION(renderer.element()->isSVGElement());

    if (!renderer.element())
        return false;

    auto& element = downcast<SVGElement>(*renderer.element());

    Document& document = element.document();

    SVGDocumentExtensions& extensions = document.accessSVGExtensions();

    const AtomicString& tagName = element.localName();
    if (tagName.isNull())
        return false;

    const SVGRenderStyle& svgStyle = style.svgStyle();

    bool foundResources = false;
    if (clipperFilterMaskerTags().contains(tagName)) {
        if (svgStyle.hasClipper()) {
            AtomicString id(svgStyle.clipperResource());
            if (setClipper(getRenderSVGResourceById<RenderSVGResourceClipper>(document, id)))
                foundResources = true;
            else
                registerPendingResource(extensions, id, element);
        }

        if (style.hasFilter()) {
            const FilterOperations& filterOperations = style.filter();
            if (filterOperations.size() == 1) {
                const FilterOperation& filterOperation = *filterOperations.at(0);
                if (filterOperation.type() == FilterOperation::REFERENCE) {
                    const auto& referenceFilterOperation = downcast<ReferenceFilterOperation>(filterOperation);
                    AtomicString id = SVGURIReference::fragmentIdentifierFromIRIString(referenceFilterOperation.url(), element.document());
                    if (setFilter(getRenderSVGResourceById<RenderSVGResourceFilter>(document, id)))
                        foundResources = true;
                    else
                        registerPendingResource(extensions, id, element);
                }
            }
        }

        if (svgStyle.hasMasker()) {
            AtomicString id(svgStyle.maskerResource());
            if (setMasker(getRenderSVGResourceById<RenderSVGResourceMasker>(document, id)))
                foundResources = true;
            else
                registerPendingResource(extensions, id, element);
        }
    }

    if (markerTags().contains(tagName) && svgStyle.hasMarkers()) {
        AtomicString markerStartId(svgStyle.markerStartResource());
        if (setMarkerStart(getRenderSVGResourceById<RenderSVGResourceMarker>(document, markerStartId)))
            foundResources = true;
        else
            registerPendingResource(extensions, markerStartId, element);

        AtomicString markerMidId(svgStyle.markerMidResource());
        if (setMarkerMid(getRenderSVGResourceById<RenderSVGResourceMarker>(document, markerMidId)))
            foundResources = true;
        else
            registerPendingResource(extensions, markerMidId, element);

        AtomicString markerEndId(svgStyle.markerEndResource());
        if (setMarkerEnd(getRenderSVGResourceById<RenderSVGResourceMarker>(document, markerEndId)))
            foundResources = true;
        else
            registerPendingResource(extensions, markerEndId, element);
    }

    if (fillAndStrokeTags().contains(tagName)) {
        if (svgStyle.hasFill()) {
            bool hasPendingResource = false;
            AtomicString id;
            if (setFill(paintingResourceFromSVGPaint(document, svgStyle.fillPaintType(), svgStyle.fillPaintUri(), id, hasPendingResource)))
                foundResources = true;
            else if (hasPendingResource)
                registerPendingResource(extensions, id, element);
        }

        if (svgStyle.hasStroke()) {
            bool hasPendingResource = false;
            AtomicString id;
            if (setStroke(paintingResourceFromSVGPaint(document, svgStyle.strokePaintType(), svgStyle.strokePaintUri(), id, hasPendingResource)))
                foundResources = true;
            else if (hasPendingResource)
                registerPendingResource(extensions, id, element);
        }
    }

    if (chainableResourceTags().contains(tagName)) {
        AtomicString id(targetReferenceFromResource(element));
        if (setLinkedResource(getRenderSVGResourceContainerById(document, id)))
            foundResources = true;
        else
            registerPendingResource(extensions, id, element);
    }

    return foundResources;
}
コード例 #14
0
void DrawableShape::setFill (const FillType& newFill)
{
    setFill (RelativeFillType (newFill));
}
コード例 #15
0
void DrawableShape::refreshFillTypes (const FillAndStrokeState& newState, ComponentBuilder::ImageProvider* imageProvider)
{
    setFill (newState.getFill (FillAndStrokeState::fill, imageProvider));
    setStrokeFill (newState.getFill (FillAndStrokeState::stroke, imageProvider));
}
コード例 #16
0
void QSGAnchors::resetFill()
{
    setFill(0);
}
コード例 #17
0
ファイル: mtimpl.cpp プロジェクト: nalune/MarkTwain
void ensureBrushCreated()
{
	if(_currentBrush == NULL)
		setFill(colorBlack);
}
コード例 #18
0
ファイル: anchors.cpp プロジェクト: zccrs/Anchors
bool AnchorsBase::setFill(AnchorsBase *fill)
{
    return setFill(fill->target());
}
コード例 #19
0
void
CGnuPlotStyleRadar::
draw2D(CGnuPlotPlot *plot, CGnuPlotRenderer *renderer)
{
  CGnuPlotRadarStyleValue *value =
    CGnuPlotStyleValueMgrInst->getValue<CGnuPlotRadarStyleValue>(plot);

  if (! value) {
    value = plot->app()->device()->createRadarStyleValue(plot);

    CGnuPlotStyleValueMgrInst->setValue<CGnuPlotRadarStyleValue>(plot, value);
  }

  //---

  const CBBox2D &bbox = plot->bbox2D();

  CPoint2D pc = bbox.getCenter();
  double   r  = bbox.getWidth()/2;

  int np = -1;

  for (const auto &point : plot->getPoints2D()) {
    np = std::min(np < 0 ? INT_MAX : np, point.getNumValues());
  }

  if (np < 3)
    return;

  //double pw = renderer->pixelWidthToWindowWidth  (1);
  //double ph = renderer->pixelHeightToWindowHeight(1);

  CGnuPlotGroup *group = plot->group();

  const CGnuPlotKeyData  &keyData = plot->keyData();
  const CGnuPlotAxisData &xaxis   = group->xaxis(1);

  const CGnuPlotKey::Columns &columns = keyData.columns();

  double da = 360/np;

  std::vector<CPoint2D> points = radarPoints(value->angleStart(), pc, r, np);

  double v = getRange(plot);

  //---

  // draw border
  renderer->drawPolygon(points, value->borderColor(), value->borderWidth(), value->borderDash());

  //---

  // draw column labels (how determine indices)
  {
    double a = value->angleStart();

    for (int i = 1; i <= np && i < int(columns.size()); ++i) {
      CPoint2D p = radarPoint(pc, r, a);

      CHAlignType halign = CHALIGN_TYPE_CENTER;
      CVAlignType valign = CVALIGN_TYPE_CENTER;

      double dx = 0;
      double dy = 0;

      if      (p.x < pc.x - v/2) {
        halign = CHALIGN_TYPE_RIGHT;
        dx     = -8;
      }
      else if (p.x > pc.x + v/2) {
        halign = CHALIGN_TYPE_LEFT;
        dx     = 8;
      }

      if      (p.y < pc.y - v/2) {
        valign = CVALIGN_TYPE_TOP;
        dy     = 8;
      }
      else if (p.y > pc.y + v/2) {
        valign = CVALIGN_TYPE_BOTTOM;
        dy     = -8;
      }

      CRGBA tc = CRGBA(0,0,0);

      renderer->drawHAlignedText(p, HAlignPos(halign, dx), VAlignPos(valign, dy), columns[i], tc),

      a -= da;
    }
  }

  //---

  // draw axis if needed
  if (xaxis.isDisplayed()) {
    CRGBA ac = value->axisColor();

    ac.setAlpha(value->axisAlpha());

    double dr = 0.1;
    double ra = 0.1;

    while (ra < v) {
      std::vector<CPoint2D> points1 = radarPoints(value->angleStart(), pc, ra, np);

      renderer->drawPolygon(points1, ac, value->axisWidth(), value->axisDash());

      ra += dr;
    }

    for (const auto &p : points)
      renderer->drawLine(p, pc, ac, value->axisWidth(), value->axisDash());
  }

  //---

  bool cache = false;

  if (! renderer->isPseudo() && plot->isCacheActive()) {
    plot->updatePolygonCacheSize(plot->numPoints2D());

    cache = true;
  }

  int pi = 0;

  for (const auto &point : plot->getPoints2D()) {
    std::vector<CPoint2D> points1;

    double a = value->angleStart();

    for (int i = 0; i < np; ++i) {
      double v1;

      if (! point.getValue(i + 1, v1))
        continue;

      CPoint2D p = radarPoint(pc, v1, a);

      points1.push_back(p);

      a -= da;
    }

    CRGBA lc, fc;

    getPointsColor(value, pi + 1, lc, fc);

    if (cache) {
    //std::string label = (pi < int(columns.size()) ? columns[pi] : "");
      std::string label = xaxis.iticLabel(pi);

      auto polygon = plot->polygonObjects()[pi];

      polygon->setPoints(points1);
      polygon->setTipText(label);

      if (! polygon->testAndSetUsed()) {
        CGnuPlotFillP   fill  (polygon->fill  ()->dup());
        CGnuPlotStrokeP stroke(polygon->stroke()->dup());

        fill->setColor(fc);
        fill->setType (CGnuPlotTypes::FillType::SOLID);

        stroke->setColor   (lc);
        stroke->setWidth   (value->strokeWidth());
        stroke->setLineDash(value->strokeDash());

        polygon->setFill  (fill  );
        polygon->setStroke(stroke);
      }
    }
    else {
      renderer->fillPolygon(points1, fc);

      renderer->drawPolygon(points1, lc, value->strokeWidth(), value->strokeDash());
    }

    ++pi;
  }

  if (cache) {
    for (const auto &polygon : plot->polygonObjects())
      polygon->draw(renderer);
  }
}