Ejemplo n.º 1
0
void KPR_canvas_set_height(xsMachine *the)
{
	FskErr err = kFskErrNone;
	KprCanvas self = xsGetHostData(xsThis);
	if (self->shell) {
		KprShellAdjust(self->shell);
		KprContentSizeBy((KprContent)self, 0, xsToInteger(xsArg(0)) - self->bounds.height);
	}
	else {
		SInt32 height = xsToInteger(xsArg(0));
		FskRectangleRecord bounds;
		if (self->cnv)
			FskBitmapGetBounds(FskGetCanvasBitmap(self->cnv), &bounds);
		else
			FskRectangleSetEmpty(&bounds);
		if ((height != bounds.height)) {
			FskCanvasDispose(self->cnv);
			self->cnv = NULL;
			if (bounds.width && height) {
				bailIfError(FskCanvasNew(bounds.width, bounds.height, PreferredPixelFormat(), &self->cnv));
                FskCanvas2dSetOpenGLSourceAccelerated(self->cnv, true);
            }
		}
	}
bail:
	return;
}
Ejemplo n.º 2
0
void KPR_canvas_get_height(xsMachine *the)
{
	KprCanvas self = xsGetHostData(xsThis);
	if (self->cnv) {
		FskRectangleRecord bounds;
		FskBitmapGetBounds(FskGetCanvasBitmap(self->cnv), &bounds);
		xsResult = xsInteger(bounds.height);
	}
	else if (self->shell) {
		KprShellAdjust(self->shell);
		xsResult = xsInteger(self->bounds.height);
	}
}
Ejemplo n.º 3
0
void KPR_canvas_get_size(xsMachine *the)
{
	KprCanvas self = xsGetHostData(xsThis);
	xsResult = xsNewInstanceOf(xsObjectPrototype);
	if (self->cnv) {
		FskRectangleRecord bounds;
		FskBitmapGetBounds(FskGetCanvasBitmap(self->cnv), &bounds);
		xsNewHostProperty(xsResult, xsID_width, xsInteger(bounds.width), xsDefault, xsDontScript);
		xsNewHostProperty(xsResult, xsID_height, xsInteger(bounds.height), xsDefault, xsDontScript);
	}
	else if (self->shell) {
		KprShellAdjust(self->shell);
		xsNewHostProperty(xsResult, xsID_width, xsInteger(self->bounds.width), xsDefault, xsDontScript);
		xsNewHostProperty(xsResult, xsID_height, xsInteger(self->bounds.height), xsDefault, xsDontScript);
	}
}
Ejemplo n.º 4
0
void KPR_canvas_set_size(xsMachine *the)
{
	FskErr err = kFskErrNone;
	KprCanvas self = xsGetHostData(xsThis);
	SInt32 width = 0, height = 0;
	if (self->shell) {
		KprShellAdjust(self->shell);
		xsEnterSandbox();
		if (xsFindInteger(xsArg(0), xsID_width, &width))
			width -= self->bounds.width;
		if (xsFindInteger(xsArg(0), xsID_height, &height))
			height -= self->bounds.height;
		xsLeaveSandbox();
		KprContentSizeBy((KprContent)self, width, height);
	}
	else {
		FskRectangleRecord bounds;
		xsEnterSandbox();
		if (!xsFindInteger(xsArg(0), xsID_width, &width))
			width = self->coordinates.width;
		if (!xsFindInteger(xsArg(0), xsID_height, &height))
			height = self->coordinates.height;
		xsLeaveSandbox();
		if (self->cnv)
			FskBitmapGetBounds(FskGetCanvasBitmap(self->cnv), &bounds);
		else
			FskRectangleSetEmpty(&bounds);
		if ((width != bounds.width) || (height != bounds.height)) {
			FskCanvasDispose(self->cnv);
			self->cnv = NULL;
			if (width && height) {
				bailIfError(FskCanvasNew(width, height, PreferredPixelFormat(), &self->cnv));
                FskCanvas2dSetOpenGLSourceAccelerated(self->cnv, true);
            }
		}
	}
bail:
	return;
}
Ejemplo n.º 5
0
void KPR_host_adapt(xsMachine* the)
{
	KprHost self = xsGetHostData(xsThis);
	KprHostAdapt(self);
	KprShellAdjust(self->shell);
}