示例#1
0
xsTextSize xsCanvasContext::measureText(const xsTChar *text)
{
	xsGraphics *gc = xsGetSystemGc();
	xsTextSize size;
	xsMeasureText(gc, text, xsTcsLen(text), &font, &size.width, &size.height);
	return size;
}
示例#2
0
void xsCanvasContext::clearRect(float x, float y, float width, float height)
{
	xsGraphics *gc = xsGetSystemGc();
	xsSetColor(gc, XS_COLOR_WHITE);
	xsFillRectangle(gc, x, y, width, height);
	xsFlushScreen(x, y, x + width, y + height);
}
示例#3
0
void xsCanvasContext::strokeText(const xsTChar *text , float x, float y, xsU32 maxWidth)
{
	xsGraphics *gc = xsGetSystemGc();
	xsSetFont(gc, &font);
	float width, height;
	int count = xsTcsLen(text);
	xsMeasureText(gc, text, count, &font, &width, &height);
	maxWidth = maxWidth > width ? width : maxWidth;
	switch(textAlign)
	{
	case XS_TEXT_ALIGN_START:
		drawWithBaseline(text, count, x, y, maxWidth,0);
		break;
	case XS_TEXT_ALIGN_END:
		drawWithBaseline(text, count, x - width, y, maxWidth, 0);
		break;
	case XS_TEXT_ALIGN_LEFT:
		drawWithBaseline(text, count, x, y, maxWidth, 0);
		break;
	case XS_TEXT_ALIGN_CENTER:
		drawWithBaseline(text, count, x - width/2, y, maxWidth, 0);
		break;
	case XS_TEXT_ALIGN_RIGHT:
		drawWithBaseline(text, count, x - width, y, maxWidth, 0);
		break;
	}
}
示例#4
0
void xsCanvasContext::drawImage(xsImage* image,float x, float y, float width, float height)
{
	xsGraphics *gc = xsGetSystemGc();
	float originW,  originH;
	xsGetImageDimension(image, &originW, &originH);
	xsDrawImage(gc, image, x, y, width, height);
	xsFlushScreen(x, y, x + width, y + height);
}
示例#5
0
void xsCanvasContext::drawImage(xsImage* image,float x, float y)
{
	xsGraphics *gc = xsGetSystemGc();
	float originW,  originH;
	xsGetImageDimension(image, &originW, &originH);
	xsDrawImage(gc, image, x, y, 0, 0);
	xsRect clientRect;
	xsFlushScreen(x, y, originW, originH);
}
示例#6
0
文件: demoapp.cpp 项目: mixtile/xskit
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;
}
示例#7
0
void xsCanvasContext::translate(float x, float y)
{
	xsGraphics *gc = xsGetSystemGc();
	xsGcTranslate(gc, x, y);
	xsRect 	clientRect;
	if(xsGetClientRect(&clientRect))
	{
		xsFlushScreen(clientRect.left, clientRect.top, clientRect.right, clientRect.bottom);
	}
}
示例#8
0
void xsCanvasContext::fill()
{
	xsGraphics *gc = xsGetSystemGc();
	paintFill(gc);
	xsRect 	clientRect;
	if(xsGetClientRect(&clientRect))
	{
		xsFlushScreen(clientRect.left, clientRect.top, clientRect.right, clientRect.bottom);
	}
}
示例#9
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);
}
示例#10
0
void xsCanvasContext::drawImage(xsImage* image,float sx, float sy, float swidth, float sheight, float x, float y, float width, float height)
{
	xsGraphics *gc = xsGetSystemGc();
	xsRect clipRect;
	clipRect.left = x;
	clipRect.top = y;
	clipRect.right = x + width;
	clipRect.bottom = y + height;
	xsSetClipRect(gc, &clipRect);
	float originW,  originH;
	xsGetImageDimension(image, &originW, &originH);
	xsDrawImage(gc, image, x - sx, y - sy, originW * width/swidth, originH*height/sheight);
	xsResetClipRect(gc);
	xsFlushScreen(clipRect.left, clipRect.top, clipRect.right, clipRect.bottom);
}
示例#11
0
void xsCanvasContext::strokeRect(float x, float y, float width, float height)
{
	xsGraphics *gc = xsGetSystemGc();
	int i;
	lineWidth = lineWidth > 1.0 ? lineWidth : 1.0;
//another way to draw rectangle with specified linwWidth.
//	xsFillRectangle(gc, x - lineWidth + 1, y - lineWidth + 1, width + 2 * (lineWidth - 1), height + 2 * (lineWidth - 1), strokeColor);
//	xsFillRectangle(gc, x, y, width, height, XS_COLOR_WHITE);
	xsSetColor(gc, strokeColor);

	for(i = 0; i < lineWidth; i++)
	{
		xsDrawRectangle(gc, x - i, y - i, width + 2*i, height + 2*i);
	}
	xsFlushScreen(x - lineWidth, y - lineWidth, x + width + 2*lineWidth, y + height + 2*lineWidth);
}
示例#12
0
文件: gtkmain.cpp 项目: mixtile/xskit
static gboolean on_expose(GtkWidget *widget, GdkEventExpose *event,
                          gpointer data)
{
    cairo_t *cr = gdk_cairo_create(widget->window);
    xsGraphics *gc = xsGetSystemGc();

    cr = gdk_cairo_create(widget->window);

    //gdk_cairo_region(cr, event->region);
    cairo_set_source_surface(cr, XS_SURFACE(gc), 0, 0);
    cairo_paint(cr);

    cairo_destroy (cr);

    return FALSE;
}
示例#13
0
文件: demoapp.cpp 项目: mixtile/xskit
int DemoApp::onTimeout()
{
	xsGraphics *gc = xsGetSystemGc();

	// clear
	xsColor color = {255, 255, 255, 255};
	xsSetColor(gc, color);
	xsFillRectangle(gc, x, y, BOX_SIZE, BOX_SIZE);//, xsArgbToColor(0xFFFFFFFF));

	// draw new box
	x += rateX;
	y += rateY;

	if (x < 0 || x + BOX_SIZE > width)
		rateX = -rateX;
	if (y < 0 || y + BOX_SIZE > height)
		rateY = -rateY;

	xsDrawImage(gc, img, x, y, 0, 0);
	
	xsFlushScreen(0, 0, width - 1, height - 1);

	return 0;
}
示例#14
0
void	xsCanvasContext::transform(float xx, float yx, float xy, float yy, float x0, float y0)
{
	xsGcTransform(xsGetSystemGc(), xx, yx, xy, yy, x0, y0);
}
示例#15
0
void xsCanvasContext::rotate(float angle)
{
	xsGcRotate(xsGetSystemGc(), angle);
}
示例#16
0
void xsCanvasContext::scale(float scalewidth, float scaleheight)
{
	xsGcScale(xsGetSystemGc(), scalewidth, scaleheight);
}