void SkStaticTextView::onInflate(const SkDOM& dom, const SkDOM::Node* node)
{
#if 0
	this->INHERITED::onInflate(dom, node);

	int	index;
	if ((index = dom.findList(node, "mode", "fixed,auto-width,auto-height")) >= 0)
		this->setMode((Mode)index);
	else
		assert_no_attr(dom, node, "mode");

	if ((index = dom.findList(node, "spacing-align", "start,center,end")) >= 0)
		this->setSpacingAlign((SkTextBox::SpacingAlign)index);
	else
		assert_no_attr(dom, node, "spacing-align");

	SkScalar s[2];
	if (dom.findScalars(node, "margin", s, 2))
		this->setMargin(s[0], s[1]);
	else
		assert_no_attr(dom, node, "margin");

	const char* text = dom.findAttr(node, "text");
	if (text)
		this->setText(text);

	if ((node = dom.getFirstChild(node, "paint")) != NULL &&
		(node = dom.getFirstChild(node, "screenplay")) != NULL)
	{
		inflate_paint(dom, node, &fPaint);
	}
#endif
}
Пример #2
0
void SkStackViewLayout::onInflate(const SkDOM& dom, const SkDOM::Node* node)
{
	int			index;
	SkScalar	value[4];

	if ((index = dom.findList(node, "orient", "horizontal,vertical")) >= 0)
		this->setOrient((Orient)index);
	else
		assert_no_attr(dom, node, "orient");

	if (dom.findScalars(node, "margin", value, 4))
	{
		SkRect	margin;
		margin.set(value[0], value[1], value[2], value[3]);
		this->setMargin(margin);
	}
	else
		assert_no_attr(dom, node, "margin");

	if (dom.findScalar(node, "spacer", value))
		this->setSpacer(value[0]);
	else
		assert_no_attr(dom, node, "spacer");

	if ((index = dom.findList(node, "pack", "start,center,end")) >= 0)
		this->setPack((Pack)index);
	else
		assert_no_attr(dom, node, "pack");

	if ((index = dom.findList(node, "align", "start,center,end,stretch")) >= 0)
		this->setAlign((Align)index);
	else
		assert_no_attr(dom, node, "align");
}
Пример #3
0
	SkDOMListSource(const SkDOM& dom, const SkDOM::Node* node) : fDirTail(">")
	{
		const SkDOM::Node* child = dom.getFirstChild(node, "item");
		int	count = 0;

		while (child)
		{
			count += 1;
			child = dom.getNextSibling(child, "item");
		}

		fCount = count;
		fList = NULL;
		if (count)
		{
			ItemRec* rec = fList = new ItemRec[count];

			child = dom.getFirstChild(node, "item");
			while (child)
			{
				rec->fLabel.set(dom.findAttr(child, "label"));
				rec->fTail.set(dom.findAttr(child, "tail"));
				rec->fAltTail.set(dom.findAttr(child, "alt-tail"));
				rec->fTarget.set(dom.findAttr(child, "target"));
				rec->fType = kUnknown_Type;

				int	index = dom.findList(child, "type", "dir,toggle");
				if (index >= 0)
					rec->fType = (Type)(index + 1);

				child = dom.getNextSibling(child, "item");
				rec += 1;
			}
		}
	}
Пример #4
0
void SkPaint_Inflate(SkPaint* paint, const SkDOM& dom, const SkDOM::Node* node)
{
	SkASSERT(paint);
	SkASSERT(&dom);
	SkASSERT(node);

	SkScalar x;

	if (dom.findScalar(node, "stroke-width", &x))
		paint->setStrokeWidth(x);
	if (dom.findScalar(node, "text-size", &x))
		paint->setTextSize(x);
	
	bool	b;

	SkASSERT("legacy: use is-stroke" && !dom.findBool(node, "is-frame", &b));

	if (dom.findBool(node, "is-stroke", &b))
		paint->setStyle(b ? SkPaint::kStroke_Style : SkPaint::kFill_Style);
	if (dom.findBool(node, "is-antialias", &b))
		paint->setAntiAlias(b);
	if (dom.findBool(node, "is-lineartext", &b))
		paint->setLinearText(b);

	const char* str = dom.findAttr(node, "color");
	if (str)
	{
		SkColor	c = paint->getColor();
		if (SkParse::FindColor(str, &c))
			paint->setColor(c);
	}

	// do this AFTER parsing for the color
	if (dom.findScalar(node, "opacity", &x))
	{
		x = SkMaxScalar(0, SkMinScalar(x, SK_Scalar1));
		paint->setAlpha(SkScalarRound(x * 255));
	}

	int	index = dom.findList(node, "text-anchor", "left,center,right");
	if (index >= 0)
		paint->setTextAlign((SkPaint::Align)index);

	SkShader* shader = inflate_shader(dom, node);
	if (shader)
		paint->setShader(shader)->unref();
}