AboutView::AboutView(BRect frame) : BView (frame, "AboutView", B_FOLLOW_ALL, B_WILL_DRAW) { SetViewColor(126,126,190); fLogo = BTranslationUtils::GetBitmap('JPG ',"AboutPalEdit.jpg"); app_info ai; version_info vi; be_app->GetAppInfo(&ai); BFile file(&ai.ref,B_READ_ONLY); BAppFileInfo appinfo(&file); appinfo.GetVersionInfo(&vi,B_APP_VERSION_KIND); BString variety; switch(vi.variety) { case 0: variety="d"; break; case 1: variety="a"; break; case 2: variety="b"; break; case 3: variety="g"; break; case 4: variety="rc"; break; default: variety="Final"; break; } if(variety != "Final") sprintf(version,"%s %lu.%lu %s%lu","Version",vi.major,vi.middle, variety.String(),vi.internal); else sprintf(version,"%s %lu.%lu","Version",vi.major,vi.middle); font_height height; be_plain_font->GetHeight(&height); versionpos.y = fLogo->Bounds().bottom - 5; versionpos.x = fLogo->Bounds().right - StringWidth(version) - 7; SetDrawingMode(B_OP_OVER); SetFont(be_bold_font); }
AboutView::AboutView(BRect frame) : BView (frame, "AboutView", B_FOLLOW_ALL, B_WILL_DRAW) { SetViewColor(126,126,190); fLogo=BTranslationUtils::GetBitmap('PNG ',"BeVexedAbout.png"); app_info ai; version_info vi; be_app->GetAppInfo(&ai); BFile file(&ai.ref,B_READ_ONLY); BAppFileInfo appinfo(&file); appinfo.GetVersionInfo(&vi,B_APP_VERSION_KIND); BString variety; switch(vi.variety) { case 0: variety=TRANSLATE("d"); break; case 1: variety=TRANSLATE("a"); break; case 2: variety=TRANSLATE("b"); break; case 3: variety=TRANSLATE("g"); break; case 4: variety=TRANSLATE("rc"); break; default: variety=TRANSLATE("Final"); break; } if(variety!="Final") sprintf(version,"%s %lu.%lu %s%lu",TRANSLATE("v"),vi.major, vi.middle,variety.String(),vi.internal); else sprintf(version,"%s %lu.%lu",TRANSLATE("v"),vi.major,vi.middle); font_height height; be_plain_font->GetHeight(&height); versionpos.y=height.ascent+height.descent+height.leading+5; versionpos.x=fLogo->Bounds().right - 5 - StringWidth(version); SetDrawingMode(B_OP_OVER); }
/** Hook function: called when user requests about information. */ void BmeApp::AboutRequested() { //get application version, from SimplyVorbis code! app_info ai; version_info vi; be_app->GetAppInfo(&ai); BFile file(&ai.ref,B_READ_ONLY); BAppFileInfo appinfo(&file); appinfo.GetVersionInfo(&vi,B_APP_VERSION_KIND); BString variety; switch(vi.variety) { case 0: variety = "d"; break; case 1: variety = "a"; break; case 2: variety = "b"; break; case 3: variety = "g"; break; case 4: variety = "rc"; break; default: variety = "Final"; break; } char version[64]; if(variety!="Final") sprintf(version,"%s %lu.%lu %s%lu","v",vi.major, vi.middle,variety.String(),vi.internal); else sprintf(version,"%s %lu.%lu","v",vi.major,vi.middle); BString bmeVersion = "Bme "; bmeVersion << version << "\n\n" << AppConstants::K_ABOUT_TEXT; BAlert *alert = new BAlert("Info", bmeVersion.String(), "OK"); alert->Go(NULL); }
/** * Obtains all of the information currently available for this plugin. */ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info, PRLibrary **outLibrary) { *outLibrary = nsnull; info.fVersion = nsnull; nsCAutoString fullPath; if (NS_FAILED(rv = mPlugin->GetNativePath(fullPath))) return rv; nsCAutoString fileName; if (NS_FAILED(rv = mPlugin->GetNativeLeafName(fileName))) return rv; const char *path = fullPath.get(); int i; #ifdef NS_PLUGIN_BEOS_DEBUG printf("nsPluginFile::GetPluginInfo() an attempt to load MIME String\n"); printf("path = <%s>\n", path); #endif // get supported mime types BFile file(path, B_READ_ONLY); if (file.InitCheck() != B_OK) return NS_ERROR_FAILURE; BAppFileInfo appinfo(&file); if (appinfo.InitCheck() != B_OK) return NS_ERROR_FAILURE; BMessage msg; if (appinfo.GetSupportedTypes(&msg) != B_OK) return NS_ERROR_FAILURE; uint32 type; int32 types_num; if (msg.GetInfo("types", &type, &types_num) != B_OK || type != B_STRING_TYPE) return NS_ERROR_FAILURE; // set mime types to plugin info info.fMimeTypeArray =(char **)PR_Malloc(types_num * sizeof(char *)); info.fMimeDescriptionArray =(char **)PR_Malloc(types_num * sizeof(char *)); info.fExtensionArray =(char **)PR_Malloc(types_num * sizeof(char *)); for (i = 0 ; i < types_num ; i ++) { // get mime string const char *mtype; if (msg.FindString("types", i, &mtype) != B_OK) { types_num = i; break; } // get (short)description for the mime char desc[B_MIME_TYPE_LENGTH+1] = ""; BMimeType mime(mtype) ; if (mime.InitCheck() == B_OK) mime.GetShortDescription(desc); // get file extensions for the mime char extensions[B_MIME_TYPE_LENGTH+1] = ""; GetMimeExtensions(mtype, extensions, B_MIME_TYPE_LENGTH+1); #ifdef NS_PLUGIN_BEOS_DEBUG printf(" mime = %30s | %10s | %15s |\n", mtype, extensions, desc); #endif info.fMimeTypeArray[i] = PL_strdup( mtype ? mtype : (char *)"" ) ; info.fMimeDescriptionArray[i] = PL_strdup( desc ) ; info.fExtensionArray[i] = PL_strdup( extensions ); } // get name and description of this plugin version_info vinfo; if (appinfo.GetVersionInfo(&vinfo, B_APP_VERSION_KIND) == B_OK && *vinfo.short_info) { // XXX convert UTF-8 2byte chars to 1 byte chars, to avoid string corruption info.fName = ToNewCString(NS_ConvertUTF8toUTF16(vinfo.short_info)); info.fDescription = ToNewCString(NS_ConvertUTF8toUTF16(vinfo.long_info)); } else { // use filename as its name info.fName = GetFileName(path); info.fDescription = PL_strdup(""); } info.fVariantCount = types_num; info.fFullPath = PL_strdup(fullPath.get()); info.fFileName = PL_strdup(fileName.get()); #ifdef NS_PLUGIN_BEOS_DEBUG printf("info.fFileName = %s\n", info.fFileName); printf("info.fName = %s\n", info.fName); printf("info.fDescription = %s\n", info.fDescription); #endif return NS_OK; }
/** * Creates a DOM document of this project and returns it. * * @param onlyselected If TRUE, only selected objects are used, otherwise the whole project * is used * @param obj If != NULL, only @a obj is used from the project * @returns The DOM document */ QDomDocument Project::getDomDocument(bool onlyselected/*=FALSE*/, GObject* obj/*=NULL*/) { Machine* m = machine; m->correctCodes(); QString prolog="<?xml version=\"1.0\"?>\n" "<!DOCTYPE qfsmproject SYSTEM \"qfsm.dtd\">\n\n" "<qfsmproject>\n" "</qfsmproject>\n"; QDomDocument domdoc; QDomElement root, me, one, ine, onme, itranse; QDomText ontext, intext, onmtext; QString stmp; int inits; GState* s; GITransition* initt; GTransition* t; QList<GState*> slist; QList<GTransition*> tlist; double xpos, ypos, endx, endy, c1x, c1y, c2x, c2y; AppInfo appinfo(qApp->mainWidget()); domdoc.setContent(prolog); if (!m) return domdoc; root = domdoc.documentElement(); // Machine root.setAttribute("author", "Qfsm"); root.setAttribute("version", appinfo.getVersion()); me = domdoc.createElement("machine"); me.setAttribute("name", m->getName()); me.setAttribute("version", m->getVersion()); me.setAttribute("author", m->getAuthor()); me.setAttribute("description", m->getDescription()); me.setAttribute("type", m->getType()); me.setAttribute("nummooreout", m->getNumMooreOutputs()); me.setAttribute("numbits", m->getNumEncodingBits()); me.setAttribute("numin", m->getNumInputs()); me.setAttribute("numout", m->getNumOutputs()); s = m->getInitialState(); if (s) { inits = s->getEncoding(); me.setAttribute("initialstate", inits); } me.setAttribute("statefont", m->getSFont().family()); me.setAttribute("statefontsize", m->getSFont().pointSize()); me.setAttribute("statefontweight", m->getSFont().weight()); me.setAttribute("statefontitalic", m->getSFont().italic()); me.setAttribute("transfont", m->getTFont().family()); me.setAttribute("transfontsize", m->getTFont().pointSize()); me.setAttribute("transfontweight", m->getTFont().weight()); me.setAttribute("transfontitalic", m->getTFont().italic()); me.setAttribute("arrowtype", m->getArrowType()); me.setAttribute("draw_it", m->getDrawITrans()); root.appendChild(me); // Input/Output names onme = domdoc.createElement("outputnames_moore"); ine = domdoc.createElement("inputnames"); one = domdoc.createElement("outputnames"); intext = domdoc.createTextNode(m->getMealyInputNames()); ontext = domdoc.createTextNode(m->getMealyOutputNames()); onmtext = domdoc.createTextNode(m->getMooreOutputNames()); ine.appendChild(intext); one.appendChild(ontext); onme.appendChild(onmtext); me.appendChild(onme); me.appendChild(ine); me.appendChild(one); // Initial Transition initt = m->getInitialTransition(); if (initt) { initt->getPos(xpos, ypos); initt->getEndPos(endx, endy); itranse = domdoc.createElement("itransition"); itranse.setAttribute("xpos", xpos); itranse.setAttribute("ypos", ypos); itranse.setAttribute("endx", endx); itranse.setAttribute("endy", endy); me.appendChild(itranse); } // States slist = m->getSList(); QListIterator<GState*> sit(slist); for(;sit.hasNext();) { s = sit.next(); if (!s->isDeleted() && (!onlyselected || s->isSelected() || (s==obj && s!=NULL))) { s->getPos(xpos, ypos); QDomElement se = domdoc.createElement("state"); QDomText st = domdoc.createTextNode(s->getStateName()); se.setAttribute("description", s->getDescription()); se.setAttribute("code", s->getEncoding()); se.setAttribute("moore_outputs", s->getMooreOutputsStr()); se.setAttribute("xpos", xpos); se.setAttribute("ypos", ypos); se.setAttribute("radius", s->getRadius()); se.setAttribute("pencolor", s->getColor().rgb() & 0xffffff); se.setAttribute("linewidth", s->getLineWidth()); se.setAttribute("finalstate", s->isFinalState()); se.setAttribute("entry_actions", s->getEntryActions()); se.setAttribute("exit_actions", s->getExitActions()); se.appendChild(st); me.appendChild(se); } } // Transitions sit.toFront(); for(; sit.hasNext();) { s = sit.next(); QListIterator<GTransition*> tit(s->tlist); GState *send; for(;tit.hasNext();) { t = tit.next(); if (!t->isDeleted() && (!onlyselected || t->isSelected() || (t==obj && t!=NULL))) { t->getPos(xpos, ypos); t->getEndPos(endx, endy); t->getCPoint1(c1x, c1y); t->getCPoint2(c2x, c2y); QDomElement te = domdoc.createElement("transition"); te.setAttribute("type", t->getInfo()->getType()); te.setAttribute("xpos", xpos); te.setAttribute("ypos", ypos); te.setAttribute("endx", endx); te.setAttribute("endy", endy); te.setAttribute("c1x", c1x); te.setAttribute("c1y", c1y); te.setAttribute("c2x", c2x); te.setAttribute("c2y", c2y); te.setAttribute("straight", t->isStraight()); te.setAttribute("description", t->getDescription()); send = (GState*)t->getEnd(); if (!onlyselected || s->isSelected()) { QDomElement from = domdoc.createElement("from"); QString sfrom; sfrom.sprintf("%d", s->getEncoding()); QDomText fromt = domdoc.createTextNode(sfrom); from.appendChild(fromt); te.appendChild(from); } if (send && (!onlyselected || send->isSelected())) { QDomElement to = domdoc.createElement("to"); QString sto; sto.sprintf("%d", send->getEncoding()); QDomText tot = domdoc.createTextNode(sto); to.appendChild(tot); te.appendChild(to); } QDomElement inpute, outpute; QDomText inputt, outputt; inpute = domdoc.createElement("inputs"); inpute.setAttribute("invert", t->getInfo()->getInputInfo()->isInverted()); inpute.setAttribute("any", t->getInfo()->getInputInfo()->getAnyInput()); inpute.setAttribute("default", t->getInfo()->getInputInfo()->isDefault()); outpute = domdoc.createElement("outputs"); inputt = domdoc.createTextNode(t->getInfo()->getInputsStr(NULL)); outputt = domdoc.createTextNode(t->getInfo()->getOutputsStr(NULL)); inpute.appendChild(inputt); outpute.appendChild(outputt); te.appendChild(inpute); te.appendChild(outpute); me.appendChild(te); } } } // Phantom State s = m->getPhantomState(); QListIterator<GTransition*> tit(s->tlist); GState *send; for(;tit.hasNext();) { t = tit.next(); if (!t->isDeleted() && (!onlyselected || t->isSelected() || (t==obj && t!=NULL))) { t->getPos(xpos, ypos); t->getEndPos(endx, endy); t->getCPoint1(c1x, c1y); t->getCPoint2(c2x, c2y); QDomElement te = domdoc.createElement("transition"); te.setAttribute("type", t->getInfo()->getType()); te.setAttribute("xpos", xpos); te.setAttribute("ypos", ypos); te.setAttribute("endx", endx); te.setAttribute("endy", endy); te.setAttribute("c1x", c1x); te.setAttribute("c1y", c1y); te.setAttribute("c2x", c2x); te.setAttribute("c2y", c2y); te.setAttribute("straight", t->isStraight()); send = (GState*)t->getEnd(); if (send && (!onlyselected || send->isSelected())) { QDomElement to = domdoc.createElement("to"); QString sto; sto.sprintf("%d", send->getEncoding()); QDomText tot = domdoc.createTextNode(sto); to.appendChild(tot); te.appendChild(to); } QDomElement inpute, outpute; QDomText inputt, outputt; inpute = domdoc.createElement("inputs"); outpute = domdoc.createElement("outputs"); inputt = domdoc.createTextNode(t->getInfo()->getInputsStr(NULL)); outputt = domdoc.createTextNode(t->getInfo()->getOutputsStr(NULL)); inpute.appendChild(inputt); outpute.appendChild(outputt); te.appendChild(inpute); te.appendChild(outpute); me.appendChild(te); } } return domdoc; }