Exemple #1
0
void xsCanvasContext::drawWithBaseline(const xsTChar* text, int count, float x, float y, float maxWidth, int drawFlag)
{
	xsGraphics *gc = xsGetSystemGc();
	float width, height;
	xsMeasureText(gc, text, count, &font, &width, &height);
	if(drawFlag == 0)//stroke
	{
		switch(textBaseline)
		{
		case XS_BASELINE_ALPHABETIC:
			break;
		case XS_BASELINE_TOP:
			xsDrawBorderText(gc, text, count, x, y, maxWidth, XS_COLOR_WHITE,strokeColor, XS_TRUE);
			break;
		case XS_BASELINE_HANGING:
			xsDrawBorderText(gc, text, count, x, y, maxWidth, XS_COLOR_WHITE,strokeColor, XS_TRUE);
			break;
		case XS_BASELINE_MIDDLE:
			xsDrawBorderText(gc, text, count, x, y + height/2, maxWidth, XS_COLOR_WHITE,strokeColor, XS_TRUE);
			break;
		case XS_BASELINE_IDEOGRAPHIC:
			break;
		case XS_BASELINE_BOTTOM:
			xsDrawBorderText(gc, text, count, x, y - height/2, maxWidth, XS_COLOR_WHITE,strokeColor, XS_TRUE);
			break;
		}
	}
	else if(drawFlag == 1)//fill
	{
		switch(textBaseline)
		{
		case XS_BASELINE_ALPHABETIC:
			break;
		case XS_BASELINE_TOP:
			xsDrawBorderText(gc, text, count, x, y, maxWidth, fillColor, XS_COLOR_WHITE, XS_FALSE);
			break;
		case XS_BASELINE_HANGING:
			break;
		case XS_BASELINE_MIDDLE:
			xsDrawBorderText(gc, text, count, x, y + height/2, maxWidth, fillColor, XS_COLOR_WHITE, XS_FALSE);
			break;
		case XS_BASELINE_IDEOGRAPHIC:
			break;
		case XS_BASELINE_BOTTOM:
			xsDrawBorderText(gc, text, count, x, y - height/2, maxWidth, fillColor, XS_COLOR_WHITE, XS_FALSE);
			break;
		}
	}
	int screenWidth, screenHeight;
	xsGetScreenDimension(&screenWidth, &screenHeight);
	xsFlushScreen(0, 0, screenWidth - 1, screenHeight - 1);
}
Exemple #2
0
int DemoApp::start()
{
	xsColor color = {255,255,255,255};
	xsSetColor(xsGetSystemGc(), color);
	xsGetScreenDimension(&width, &height);
	xsFillRectangle(xsGetSystemGc(), 0, 0, width, height);//, xsArgbToColor(0xFFFFFFFF));
	xsFlushScreen(0, 0, width - 1, height - 1);

	const char * js = getManifest()->getStartup();
	invokeJavascript(js, LOAD_JS_STRING);

	x = (width - BOX_SIZE) / 2;
	y = (height - BOX_SIZE) / 2;
	//img = this->getResource()->loadImage(xsT("logo-48x48.jpg"));
	//timer = xsStartTimer(20, _onTimeout, this);

	return XS_EC_OK;
}