FskErr KprApplicationNew(KprApplication* it, char* url, char* id, Boolean breakOnStart, Boolean breakOnExceptions) { KprCoordinatesRecord coordinates = { kprLeftRight, kprTopBottom, 0, 0, 0, 0, 0, 0 }; xsAllocation allocation = { 2 * 1024 * 1024, 1024 * 1024, 64 * 1024, 8 * 1024, 2048, 16000, 1993 }; FskErr err = kFskErrNone; KprApplication self; bailIfError(FskMemPtrNewClear(sizeof(KprApplicationRecord), it)); self = *it; FskInstrumentedItemNew(self, NULL, &KprApplicationInstrumentation); self->dispatch = &KprApplicationDispatchRecord; self->flags = kprContainer | kprClip | kprVisible; KprContentInitialize((KprContent)self, &coordinates, NULL, NULL); bailIfError(KprURLMerge(gShell->url, url, &self->url)); if (id) { self->id = FskStrDoCopy(id); bailIfNULL(self->id); } self->the = xsAliasMachine(&allocation, gShell->root, self->url, self); if (!self->the) BAIL(kFskErrMemFull); FskInstrumentedItemSendMessageNormal(self, kprInstrumentedContentCreateMachine, self); xsBeginHost(self->the); xsResult = xsNewHostFunction(KPR_include, 1); xsSet(xsResult, xsID("uri"), xsString(self->url)); xsNewHostProperty(xsGlobal, xsID("include"), xsResult, xsDontDelete | xsDontSet, xsDontScript | xsDontDelete | xsDontSet); xsResult = xsNewHostFunction(KPR_require, 1); xsSet(xsResult, xsID("uri"), xsString(self->url)); xsNewHostProperty(xsGlobal, xsID("require"), xsResult, xsDontDelete | xsDontSet, xsDontScript | xsDontDelete | xsDontSet); xsResult = xsNewInstanceOf(xsGet(xsGet(xsGlobal, xsID("KPR")), xsID("application"))); self->slot = xsResult; xsSetHostData(xsResult, self); (void)xsCall1(xsGet(xsGlobal, xsID("Object")), xsID("seal"), xsResult); xsNewHostProperty(xsGlobal, xsID("application"), xsResult, xsDontDelete | xsDontSet, xsDontScript | xsDontDelete | xsDontSet); xsNewHostProperty(xsGlobal, xsID("shell"), xsNull, xsDontDelete | xsDontSet, xsDontScript | xsDontDelete | xsDontSet); if (breakOnStart) xsDebugger(); if (breakOnExceptions) (void)xsCall1(xsGet(xsGet(xsGlobal, xsID("xs")), xsID("debug")), xsID("setBreakOnException"), xsBoolean(breakOnExceptions)); (void)xsCall1(xsGlobal, xsID("include"), xsString(self->url)); xsEndHost(self->the); KprContentChainPrepend(&gShell->applicationChain, self, 0, NULL); bail: return err; }
FskErr KprLabelNew(KprLabel *it, KprCoordinates coordinates, KprSkin skin, KprStyle style, char* text) { FskErr err = kFskErrNone; KprLabel self; bailIfError(FskMemPtrNewClear(sizeof(KprLabelRecord), it)); self = *it; FskInstrumentedItemNew(self, NULL, &KprLabelInstrumentation); self->dispatch = &KprLabelDispatchRecord; self->flags = kprVisible; KprContentInitialize((KprContent)self, coordinates, skin, style); KprLabelSetString(self, text); bail: return err; }
FskErr KprHostNew(KprHost* it, KprCoordinates coordinates, char* url, char* id, Boolean breakOnStart, Boolean breakOnExceptions) { FskErr err = kFskErrNone; KprHost self = NULL; KprApplication application = NULL; bailIfError(FskMemPtrNewClear(sizeof(KprHostRecord), it)); self = *it; FskInstrumentedItemNew(self, NULL, &KprHostInstrumentation); self->dispatch = &KprHostDispatchRecord; self->flags = kprHost | kprContainer | kprClip | kprVisible; KprContentInitialize((KprContent)self, coordinates, NULL, NULL); bailIfError(KprApplicationNew(&application, url, id, breakOnStart, breakOnExceptions)); KprContainerAdd((KprContainer)self, (KprContent)application); bail: return err; }
FskErr KprCanvasNew(KprCanvas* it, KprCoordinates coordinates) { FskErr err = kFskErrNone; KprCanvas self; bailIfError(FskMemPtrNewClear(sizeof(KprCanvasRecord), it)); self = *it; FskInstrumentedItemNew(self, NULL, &KprCanvasInstrumentation); self->dispatch = &KprCanvasDispatchRecord; self->flags = kprVisible; KprContentInitialize((KprContent)self, coordinates, NULL, NULL); if (coordinates->width && coordinates->height) { bailIfError(FskCanvasNew(coordinates->width, coordinates->height, PreferredPixelFormat(), &self->cnv)); FskCanvas2dSetOpenGLSourceAccelerated(self->cnv, true); } bail: return err; }