static void compile_init_actions(int frameno, int debug) { int i; int found=0; SWFAction action; char ppfile[PATH_MAX]; for (i=0; i<num_init_actions; ++i) { init_action* ia = &(init_actions[i]); char* file; if ( ia->frameno != frameno ) continue; file = ia->file; sprintf(ppfile, "%s.frame%d.init%d.pp", outputfile, frameno, found); action = makeswf_compile_source(file, ppfile, debug); printf("Adding %s to frame %d init actions... ", file, frameno); SWFMovie_add(mo, newSWFInitAction(action)); printf("done.\n"); ++found; } }
SEXP MingSWFNew(SEXP file, SEXP height, SEXP width, SEXP scale, SEXP version, SEXP bg, SEXP fonts, SEXP initAS, SEXP labelMethod){ int bgcolor = RGBpar(bg,0); /* R Graphics Device: in GraphicsDevice.h */ pDevDesc RGD; /* R Graphics Engine: in GraphicsEngine.h */ pGEDevDesc RGE; /* Ming Graphics Device */ MingSWFDesc *MGD; if (!(RGD = (pDevDesc)calloc(1, sizeof(NewDevDesc)))) return R_NilValue; if (!(MGD = (MingSWFDesc *)calloc(1, sizeof(MingSWFDesc)))){ free(RGD); error("unable to start device mingswf"); return R_NilValue; } MGD->version = asInteger(version); Ming_setScale(asInteger(scale));/* default for library is 20 */ MGD->movie = newSWFMovieWithVersion(MGD->version); MGD->file=(char *)CHAR(STRING_ELT(file,0)); /* Initialize SWF file */ SWFMovie_setDimension(MGD->movie,asReal(width),asReal(height)); SWFMovie_setBackground(MGD->movie, REDC(bgcolor), GREENC(bgcolor), BLUEC(bgcolor)); SWFMovie_setRate(MGD->movie, 1.0); SWFMovie_setNumberOfFrames(MGD->movie, 1); SWFMovie_add(MGD->movie,newSWFInitAction(newSWFAction( "_root.createEmptyMovieClip('popup',65534);" "_root.popup._visible = false;" "_root.popup.createTextField('Label',65535,0,0,0,0);" "_root.popup.Label.multiline = true;" "_root.popup.Label.html = true;" "_root.movePopUp = function (){" " if (_root._xmouse <= _root.popup.Label._width+20){" " _root.popup._x = _root._xmouse+20;" " } else {" " _root.popup._x = _root._xmouse-_root.popup.Label._width-10;" " }" " if (_root._ymouse <= _root.popup.Label._height+20){" " _root.popup._y = _root._ymouse+15;" " } else {" " _root.popup._y = _root._ymouse-_root.popup.Label._height-10;" " }" " updateAfterEvent();" "};" "_root.showPopUp = function(obj){" " _root.popup.Label.htmlText = obj.Label;" " obj.oldAlpha = obj._alpha;" " obj._alpha = 50;" " _root.popup.Label.autoSize = true;" " _root.popup.lineStyle(20,0xc2c2c2);" " _root.popup.beginFill(0xc2c2c2);" " _root.popup.moveTo(0,0);" " _root.popup.lineTo(_root.popup.Label._width-5,0);" " _root.popup.lineTo(_root.popup.Label._width-5,_root.popup.Label._height-5);" " _root.popup.lineTo(0,_root.popup.Label._height-5);" " _root.popup.lineTo(0,0);" " _root.popup._visible = true;" " obj.onMouseMove = _root.movePopUp;" " _root.movePopUp();" "};" "_root.hidePopUp = function(obj){" " obj._alpha = obj.oldAlpha;" " delete obj.onMouseMove;" " _root.popup.clear();" " _root.popup._visible = false;" "};" ))); RGD->deviceSpecific = (void *) MGD; /* Callbacks */ RGD->close = MingSWFClose; RGD->activate = MingSWFActivate; RGD->deactivate = MingSWFDeactivate; RGD->size = MingSWFSize; RGD->newPage = MingSWFNewPage; RGD->clip = MingSWFClip; RGD->strWidth = MingSWFStrWidth; RGD->text = MingSWFText; RGD->rect = MingSWFRect; RGD->circle = MingSWFCircle; RGD->line = MingSWFLine; RGD->polyline = MingSWFPolyline; RGD->polygon = MingSWFPolygon; RGD->locator = MingSWFLocator; RGD->mode = MingSWFMode; RGD->metricInfo = MingSWFMetricInfo; RGD->hasTextUTF8 = TRUE; RGD->strWidthUTF8 = MingSWFStrWidth; RGD->textUTF8 = MingSWFText; RGD->wantSymbolUTF8 = TRUE; /* Initialise RGD */ RGD->left = RGD->clipLeft = 0; RGD->top = RGD->clipTop = 0; RGD->right = RGD->clipRight = asReal(width); RGD->bottom = RGD->clipBottom = asReal(height); RGD->xCharOffset = 0.4900; RGD->yCharOffset = 0.3333; RGD->yLineBias = 0.1; RGD->ipr[0] = 1.0/72.0; RGD->ipr[1] = 1.0/72.0; RGD->cra[0] = 0.9 * 12; RGD->cra[1] = 1.2 * 12; RGD->gamma = 1.0; RGD->canClip = FALSE; RGD->canChangeGamma = FALSE; RGD->canHAdj = 2; RGD->startps = 12.0; RGD->startcol = R_RGB(0,0,0); RGD->startfill = 0xffffffff; RGD->startlty = LTY_SOLID; RGD->startfont = 1; RGD->startgamma = RGD->gamma; RGD->displayListOn = TRUE; /* Add to the device list */ RGE = GEcreateDevDesc(RGD); MGD->RGE = RGE; GEaddDevice(RGE); GEinitDisplayList(RGE); return ScalarInteger(1 + GEdeviceNumber(RGE)); }