// --------------------------------------------------------------- // Constructor // // Sets up the version info and the name of the translator so that // these values can be returned when they are requested. // // Preconditions: // // Parameters: // // Postconditions: // // Returns: // --------------------------------------------------------------- BaseTranslator::BaseTranslator(const char *name, const char *info, const int32 version, const translation_format *inFormats, int32 inCount, const translation_format *outFormats, int32 outCount, const char *settingsFile, TranSetting *defaults, int32 defCount, uint32 tranGroup, uint32 tranType) : BTranslator() { fSettings = new TranslatorSettings(settingsFile, defaults, defCount); fSettings->LoadSettings(); // load settings from the Base Translator settings file fVersion = version; fName = new char[strlen(name) + 1]; strcpy(fName, name); fInfo = new char[strlen(info) + 41]; sprintf(fInfo, "%s v%d.%d.%d %s", info, static_cast<int>(B_TRANSLATION_MAJOR_VERSION(fVersion)), static_cast<int>(B_TRANSLATION_MINOR_VERSION(fVersion)), static_cast<int>(B_TRANSLATION_REVISION_VERSION(fVersion)), __DATE__); fInputFormats = inFormats; fInputCount = (fInputFormats) ? inCount : 0; fOutputFormats = outFormats; fOutputCount = (fOutputFormats) ? outCount : 0; fTranGroup = tranGroup; fTranType = tranType; }
WonderBrushView::WonderBrushView(const BRect &frame, const char *name, uint32 resize, uint32 flags, TranslatorSettings *settings) : BView(frame, name, resize, flags), fSettings(settings) { SetViewUIColor(B_PANEL_BACKGROUND_COLOR); BStringView *titleView = new BStringView("title", B_TRANSLATE("WonderBrush image translator")); titleView->SetFont(be_bold_font); char version[100]; sprintf(version, B_TRANSLATE("Version %d.%d.%d, %s"), static_cast<int>(B_TRANSLATION_MAJOR_VERSION(WBI_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_MINOR_VERSION(WBI_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_REVISION_VERSION( WBI_TRANSLATOR_VERSION)), __DATE__); BStringView *versionView = new BStringView("version", version); BStringView *copyrightView = new BStringView("copyright", kWBICopyright); BStringView *copyright2View = new BStringView("copyright2", B_TRANSLATE("written by:")); BStringView *copyright3View = new BStringView("copyright3", kAuthor); BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .SetInsets(B_USE_DEFAULT_SPACING) .Add(titleView) .Add(versionView) .Add(copyrightView) .AddGlue() .Add(copyright2View) .Add(copyright3View); }
ConfigView::ConfigView(const BRect &frame, uint32 resize, uint32 flags) : BView(frame, B_TRANSLATE("RTF-Translator Settings"), resize, flags) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); BStringView *titleView = new BStringView("title", B_TRANSLATE("Rich Text Format (RTF) translator")); titleView->SetFont(be_bold_font); char version[256]; snprintf(version, sizeof(version), B_TRANSLATE("Version %d.%d.%d, %s"), static_cast<int>(B_TRANSLATION_MAJOR_VERSION(RTF_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_MINOR_VERSION(RTF_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_REVISION_VERSION( RTF_TRANSLATOR_VERSION)), __DATE__); BStringView *versionView = new BStringView("version", version); BStringView *copyrightView = new BStringView( "Copyright", B_UTF8_COPYRIGHT "2004-2006 Haiku Inc."); BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .SetInsets(B_USE_DEFAULT_SPACING) .Add(titleView) .Add(versionView) .Add(copyrightView) .AddGlue(); }
void DataTranslationsWindow::_ShowInfoAlert(int32 id) { const char* name = NULL; const char* info = NULL; BPath path; int32 version = 0; _GetTranslatorInfo(id, name, info, version, path); const char* labels[] = { B_TRANSLATE("Name:"), B_TRANSLATE("Version:"), B_TRANSLATE("Info:"), B_TRANSLATE("Path:"), NULL }; int offsets[4]; BString message; BString temp; offsets[0] = 0; temp.SetToFormat("%s %s\n", labels[0], name); message.Append(temp); offsets[1] = message.Length(); // Convert the version number into a readable format temp.SetToFormat("%s %" B_PRId32 ".%" B_PRId32 ".%" B_PRId32 "\n\n", labels[1], B_TRANSLATION_MAJOR_VERSION(version), B_TRANSLATION_MINOR_VERSION(version), B_TRANSLATION_REVISION_VERSION(version)); message.Append(temp); offsets[2] = message.Length(); temp.SetToFormat("%s\n%s\n\n", labels[2], info); message.Append(temp); offsets[3] = message.Length(); temp.SetToFormat("%s %s\n", labels[3], path.Path()); message.Append(temp); BAlert* alert = new BAlert(B_TRANSLATE("Info"), message.String(), B_TRANSLATE("OK")); BTextView* view = alert->TextView(); BFont font; view->SetStylable(true); view->GetFont(&font); font.SetFace(B_BOLD_FACE); for (int32 i = 0; labels[i]; i++) { view->SetFontAndColor(offsets[i], offsets[i] + strlen(labels[i]), &font); } alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); }
HVIFView::HVIFView(const char* name, uint32 flags, TranslatorSettings *settings) : BView(name, flags, new BGroupLayout(B_VERTICAL)), fSettings(settings) { BAlignment labelAlignment(B_ALIGN_LEFT, B_ALIGN_NO_VERTICAL); BStringView* title= new BStringView("title", B_TRANSLATE("Native Haiku icon format translator")); title->SetFont(be_bold_font); title->SetExplicitAlignment(labelAlignment); char versionString[256]; snprintf(versionString, sizeof(versionString), B_TRANSLATE("Version %d.%d.%d, %s"), int(B_TRANSLATION_MAJOR_VERSION(HVIF_TRANSLATOR_VERSION)), int(B_TRANSLATION_MINOR_VERSION(HVIF_TRANSLATOR_VERSION)), int(B_TRANSLATION_REVISION_VERSION(HVIF_TRANSLATOR_VERSION)), __DATE__); BStringView* version = new BStringView("version", versionString); version->SetExplicitAlignment(labelAlignment); BStringView* copyright = new BStringView("copyright", B_UTF8_COPYRIGHT"2009 Haiku Inc."); copyright->SetExplicitAlignment(labelAlignment); int32 renderSize = fSettings->SetGetInt32(HVIF_SETTING_RENDER_SIZE); BString label = B_TRANSLATE("Render size:"); label << " " << renderSize; fRenderSize = new BSlider("renderSize", label.String(), NULL, 1, 32, B_HORIZONTAL); fRenderSize->SetValue(renderSize / 8); fRenderSize->SetHashMarks(B_HASH_MARKS_BOTTOM); fRenderSize->SetHashMarkCount(16); fRenderSize->SetModificationMessage( new BMessage(HVIF_SETTING_RENDER_SIZE_CHANGED)); fRenderSize->SetExplicitAlignment(labelAlignment); float padding = 5.0f; BLayoutBuilder::Group<>(this, B_VERTICAL, padding) .SetInsets(padding) .Add(title) .Add(version) .Add(copyright) .Add(fRenderSize) .AddGlue(); BFont font; GetFont(&font); SetExplicitPreferredSize( BSize((font.Size() * 270) / 12, (font.Size() * 100) / 12)); }
RTFTranslator::RTFTranslator() { char info[256]; sprintf(info, B_TRANSLATE("Rich Text Format translator v%d.%d.%d %s"), static_cast<int>(B_TRANSLATION_MAJOR_VERSION(RTF_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_MINOR_VERSION(RTF_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_REVISION_VERSION( RTF_TRANSLATOR_VERSION)), __DATE__); fInfo = strdup(info); }
TGAView::TGAView(const char *name, uint32 flags, TranslatorSettings *settings) : BView(name, flags), fSettings(settings) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetLowColor(ViewColor()); fTitle = new BStringView("title", B_TRANSLATE("TGA Image Translator")); fTitle->SetFont(be_bold_font); char detail[100]; sprintf(detail, B_TRANSLATE("Version %d.%d.%d %s"), static_cast<int>(B_TRANSLATION_MAJOR_VERSION(TGA_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_MINOR_VERSION(TGA_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_REVISION_VERSION( TGA_TRANSLATOR_VERSION)), __DATE__); fDetail = new BStringView("detail", detail); fWrittenBy = new BStringView("writtenby", B_TRANSLATE("Written by the Haiku Translation Kit Team")); fpchkIgnoreAlpha = new BCheckBox(B_TRANSLATE("Ignore TGA alpha channel"), new BMessage(CHANGE_IGNORE_ALPHA)); int32 val = (fSettings->SetGetBool(TGA_SETTING_IGNORE_ALPHA)) ? 1 : 0; fpchkIgnoreAlpha->SetValue(val); fpchkIgnoreAlpha->SetViewColor(ViewColor()); fpchkRLE = new BCheckBox(B_TRANSLATE("Save with RLE Compression"), new BMessage(CHANGE_RLE)); val = (fSettings->SetGetBool(TGA_SETTING_RLE)) ? 1 : 0; fpchkRLE->SetValue(val); fpchkRLE->SetViewColor(ViewColor()); // Build the layout SetLayout(new BGroupLayout(B_HORIZONTAL)); AddChild(BGroupLayoutBuilder(B_VERTICAL, 7) .Add(fTitle) .Add(fDetail) .AddGlue() .Add(fpchkIgnoreAlpha) .Add(fpchkRLE) .AddGlue() .Add(fWrittenBy) .AddGlue() .SetInsets(5, 5, 5, 5) ); BFont font; GetFont(&font); SetExplicitPreferredSize(BSize((font.Size() * 333)/12, (font.Size() * 200)/12)); }
ConfigView::ConfigView(TranslatorSettings *settings) : BGroupView("ICNSTranslator Settings", B_VERTICAL, 0) { fSettings = settings; BStringView *titleView = new BStringView("title", B_TRANSLATE("Apple icon translator")); titleView->SetFont(be_bold_font); char version[256]; sprintf(version, B_TRANSLATE("Version %d.%d.%d, %s"), int(B_TRANSLATION_MAJOR_VERSION(ICNS_TRANSLATOR_VERSION)), int(B_TRANSLATION_MINOR_VERSION(ICNS_TRANSLATOR_VERSION)), int(B_TRANSLATION_REVISION_VERSION(ICNS_TRANSLATOR_VERSION)), __DATE__); BStringView *versionView = new BStringView("version", version); BStringView *copyrightView = new BStringView("copyright", B_UTF8_COPYRIGHT "2005-2006 Haiku Inc."); BStringView *copyright2View = new BStringView("my_copyright", B_UTF8_COPYRIGHT "2012 Gerasim Troeglazov <*****@*****.**>."); BStringView *infoView = new BStringView("support_sizes", B_TRANSLATE("Valid sizes: 16, 32, 48, 128, 256, 512, 1024")); BStringView *info2View = new BStringView("support_colors", B_TRANSLATE("Valid colors: RGB32, RGBA32")); BStringView *copyright3View = new BStringView("copyright3", "libicns v0.8.1\n"); BStringView *copyright4View = new BStringView("copyright4", "2001-2012 Mathew Eis <*****@*****.**>"); BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .SetInsets(B_USE_DEFAULT_SPACING) .Add(titleView) .Add(versionView) .Add(copyrightView) .Add(copyright2View) .AddGlue() .Add(infoView) .Add(info2View) .AddGlue() .Add(copyright3View) .Add(copyright4View); SetExplicitPreferredSize(GroupLayout()->MinSize()); }
ConfigView::ConfigView(uint32 flags) : BView("EXRTranslator Settings", flags) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); BStringView *fTitle = new BStringView("title", B_TRANSLATE("EXR image translator")); fTitle->SetFont(be_bold_font); char version[256]; sprintf(version, B_TRANSLATE("Version %d.%d.%d, %s"), int(B_TRANSLATION_MAJOR_VERSION(EXR_TRANSLATOR_VERSION)), int(B_TRANSLATION_MINOR_VERSION(EXR_TRANSLATOR_VERSION)), int(B_TRANSLATION_REVISION_VERSION(EXR_TRANSLATOR_VERSION)), __DATE__); BStringView *fVersion = new BStringView("version", version); BStringView *fCopyright = new BStringView("copyright", B_UTF8_COPYRIGHT "2008 Haiku Inc."); BStringView *fCopyright2 = new BStringView("copyright2", B_TRANSLATE("Based on OpenEXR (http://www.openexr.com)")); BStringView *fCopyright3 = new BStringView("copyright3", B_UTF8_COPYRIGHT "2006, Industrial Light & Magic,"); BStringView *fCopyright4 = new BStringView("copyright4", B_TRANSLATE("a division of Lucasfilm Entertainment Company Ltd")); // Build the layout BLayoutBuilder::Group<>(this, B_VERTICAL, 7) .SetInsets(5) .Add(fTitle) .Add(fVersion) .AddGlue() .Add(fCopyright) .Add(fCopyright2) .AddGlue() .Add(fCopyright3) .Add(fCopyright4) .AddGlue(); BFont font; GetFont(&font); SetExplicitPreferredSize(BSize(font.Size() * 400 / 12, font.Size() * 200 / 12)); }
ConfigView::ConfigView(const BRect &frame, uint32 resize, uint32 flags) : BView(frame, B_TRANSLATE("RTF-Translator Settings"), resize, flags) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); font_height fontHeight; be_bold_font->GetHeight(&fontHeight); float height = fontHeight.descent + fontHeight.ascent + fontHeight.leading; BRect rect(10, 10, 200, 10 + height); BStringView *stringView = new BStringView(rect, "title", B_TRANSLATE("Rich Text Format (RTF) files")); stringView->SetFont(be_bold_font); stringView->ResizeToPreferred(); AddChild(stringView); float maxWidth = stringView->Bounds().Width(); rect.OffsetBy(0, height + 10); char version[256]; snprintf(version, sizeof(version), B_TRANSLATE("Version %d.%d.%d, %s"), static_cast<int>(B_TRANSLATION_MAJOR_VERSION(RTF_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_MINOR_VERSION(RTF_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_REVISION_VERSION( RTF_TRANSLATOR_VERSION)), __DATE__); stringView = new BStringView(rect, "version", version); stringView->ResizeToPreferred(); AddChild(stringView); if (stringView->Bounds().Width() > maxWidth) maxWidth = stringView->Bounds().Width(); GetFontHeight(&fontHeight); height = fontHeight.descent + fontHeight.ascent + fontHeight.leading; rect.OffsetBy(0, height + 5); stringView = new BStringView(rect, "Copyright", B_UTF8_COPYRIGHT "2004-2006 Haiku Inc."); stringView->ResizeToPreferred(); AddChild(stringView); if (maxWidth + 20 > Bounds().Width()) ResizeTo(maxWidth + 20, Bounds().Height()); }
// --------------------------------------------------------------- // Draw // // Draws information about the SGITranslator to this view. // // Preconditions: // // Parameters: area, not used // // Postconditions: // // Returns: // --------------------------------------------------------------- void SGIView::Draw(BRect area) { SetFont(be_bold_font); font_height fh; GetFontHeight(&fh); float xbold, ybold; xbold = fh.descent + 1; ybold = fh.ascent + fh.descent * 2 + fh.leading; const char* text = "SGI image translator"; DrawString(text, BPoint(xbold, ybold)); SetFont(be_plain_font); font_height plainh; GetFontHeight(&plainh); float yplain; yplain = plainh.ascent + plainh.descent * 2 + plainh.leading; char detail[100]; sprintf(detail, "Version %d.%d.%d %s", static_cast<int>(B_TRANSLATION_MAJOR_VERSION(SGI_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_MINOR_VERSION(SGI_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_REVISION_VERSION(SGI_TRANSLATOR_VERSION)), __DATE__); DrawString(detail, BPoint(xbold, yplain + ybold)); BPoint offset = fCompressionMF->Frame().LeftBottom(); offset.x += xbold; offset.y += 2 * ybold; text = "written by:"; DrawString(text, offset); offset.y += ybold; DrawString(author, offset); offset.y += 2 * ybold; text = "based on GIMP SGI plugin v1.5:"; DrawString(text, offset); offset.y += ybold; DrawString(kSGICopyright, offset); }
/*static*/ const char* BTranslatorRoster::Version(int32* outCurVersion, int32* outMinVersion, int32 inAppVersion) { if (!outCurVersion || !outMinVersion) return ""; static char vString[50]; static char vDate[] = __DATE__; if (!vString[0]) { sprintf(vString, "Translation Kit v%d.%d.%d %s\n", int(B_TRANSLATION_MAJOR_VERSION(B_TRANSLATION_CURRENT_VERSION)), int(B_TRANSLATION_MINOR_VERSION(B_TRANSLATION_CURRENT_VERSION)), int(B_TRANSLATION_REVISION_VERSION(B_TRANSLATION_CURRENT_VERSION)), vDate); } *outCurVersion = B_TRANSLATION_CURRENT_VERSION; *outMinVersion = B_TRANSLATION_MIN_VERSION; return vString; }
void WonderBrushView::Draw(BRect area) { SetFont(be_bold_font); font_height fh; GetFontHeight(&fh); float xbold = fh.descent + 1; float ybold = fh.ascent + fh.descent * 2 + fh.leading; BPoint offset(xbold, ybold); const char* text = B_TRANSLATE("WonderBrush image translator"); DrawString(text, offset); SetFont(be_plain_font); font_height plainh; GetFontHeight(&plainh); float yplain = plainh.ascent + plainh.descent * 2 + plainh.leading; offset.y += yplain; char detail[100]; sprintf(detail, B_TRANSLATE("Version %d.%d.%d %s"), static_cast<int>(B_TRANSLATION_MAJOR_VERSION(WBI_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_MINOR_VERSION(WBI_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_REVISION_VERSION( WBI_TRANSLATOR_VERSION)), __DATE__); DrawString(detail, offset); offset.y += 2 * ybold; text = B_TRANSLATE("written by:"); DrawString(text, offset); offset.y += ybold; DrawString(kAuthor, offset); offset.y += 2 * ybold; DrawString(kWBICopyright, offset); }
ConfigView::ConfigView(uint32 flags) : BView(kShortName2, flags) { SetViewUIColor(B_PANEL_BACKGROUND_COLOR); BStringView *fTitle = new BStringView("title", B_TRANSLATE("RAW image translator")); fTitle->SetFont(be_bold_font); char version[256]; sprintf(version, B_TRANSLATE("Version %d.%d.%d, %s"), int(B_TRANSLATION_MAJOR_VERSION(RAW_TRANSLATOR_VERSION)), int(B_TRANSLATION_MINOR_VERSION(RAW_TRANSLATOR_VERSION)), int(B_TRANSLATION_REVISION_VERSION(RAW_TRANSLATOR_VERSION)), __DATE__); BStringView *fVersion = new BStringView("version", version); BStringView *fCopyright = new BStringView("copyright", B_UTF8_COPYRIGHT "2007-2009 Haiku Inc."); BStringView *fCopyright2 = new BStringView("copyright2", B_TRANSLATE("Based on Dave Coffin's dcraw 8.63")); BStringView *fCopyright3 = new BStringView("copyright3", B_UTF8_COPYRIGHT "1997-2007 Dave Coffin"); // Build the layout BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .SetInsets(B_USE_DEFAULT_SPACING) .Add(fTitle) .Add(fVersion) .Add(fCopyright) .AddGlue() .Add(fCopyright2) .Add(fCopyright3); BFont font; GetFont(&font); SetExplicitPreferredSize(BSize((font.Size() * 233)/12, (font.Size() * 200)/12)); }
void DataTranslationsWindow::_ShowInfoAlert(int32 id) { const char* name = NULL; const char* info = NULL; BPath path; int32 version = 0; _GetTranslatorInfo(id, name, info, version, path); BString message; // Convert the version number into a readable format snprintf(message.LockBuffer(2048), 2048, B_TRANSLATE("Name: %s \nVersion: %ld.%ld.%ld\n\n" "Info:\n%s\n\nPath:\n%s\n"), name, B_TRANSLATION_MAJOR_VERSION(version), B_TRANSLATION_MINOR_VERSION(version), B_TRANSLATION_REVISION_VERSION(version), info, path.Path()); message.UnlockBuffer(); BAlert* alert = new BAlert(B_TRANSLATE("Info"), message.String(), B_TRANSLATE("OK")); BTextView* view = alert->TextView(); BFont font; view->SetStylable(true); view->GetFont(&font); font.SetFace(B_BOLD_FACE); const char* labels[] = { B_TRANSLATE("Name:"), B_TRANSLATE("Version:"), B_TRANSLATE("Info:"), B_TRANSLATE("Path:"), NULL }; for (int32 i = 0; labels[i]; i++) { int32 index = message.FindFirst(labels[i]); view->SetFontAndColor(index, index + strlen(labels[i]), &font); } alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); }
void DataTranslationsWindow::_ShowInfoAlert(int32 id) { const char* name = NULL; const char* info = NULL; BPath path; int32 version = 0; _GetTranslatorInfo(id, name, info, version, path); BString message; message << "Name: " << name << "\nVersion: "; // Convert the version number into a readable format message << (int)B_TRANSLATION_MAJOR_VERSION(version) << '.' << (int)B_TRANSLATION_MINOR_VERSION(version) << '.' << (int)B_TRANSLATION_REVISION_VERSION(version); message << "\nInfo: " << info << "\n\nPath:\n" << path.Path() << "\n"; BAlert *alert = new BAlert("info", message.String(), "OK"); BTextView *view = alert->TextView(); BFont font; view->SetStylable(true); view->GetFont(&font); font.SetFace(B_BOLD_FACE); const char* labels[] = {"Name:", "Version:", "Info:", "Path:", NULL}; for (int32 i = 0; labels[i]; i++) { int32 index = message.FindFirst(labels[i]); view->SetFontAndColor(index, index + strlen(labels[i]), &font); } alert->Go(); }
SGIView::SGIView(const char* name, uint32 flags, TranslatorSettings* settings) : BView(name, flags, new BGroupLayout(B_VERTICAL)), fSettings(settings) { BPopUpMenu* menu = new BPopUpMenu("pick compression"); uint32 currentCompression = fSettings->SetGetInt32(SGI_SETTING_COMPRESSION); // create the menu items with the various compression methods add_menu_item(menu, SGI_COMP_NONE, B_TRANSLATE("None"), currentCompression); //menu->AddSeparatorItem(); add_menu_item(menu, SGI_COMP_RLE, B_TRANSLATE("RLE"), currentCompression); // DON'T turn this on, it's so slow that I didn't wait long enough // the one time I tested this. So I don't know if the code even works. // Supposedly, this would look for an already written scanline, and // modify the scanline tables so that the current row is not written // at all... //add_menu_item(menu, SGI_COMP_ARLE, "Agressive RLE", currentCompression); fCompressionMF = new BMenuField("compression", B_TRANSLATE("Use compression:"), menu); BAlignment labelAlignment(B_ALIGN_LEFT, B_ALIGN_NO_VERTICAL); BStringView* titleView = new BStringView("title", B_TRANSLATE("SGI image translator")); titleView->SetFont(be_bold_font); titleView->SetExplicitAlignment(labelAlignment); char detail[100]; sprintf(detail, B_TRANSLATE("Version %d.%d.%d %s"), static_cast<int>(B_TRANSLATION_MAJOR_VERSION(SGI_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_MINOR_VERSION(SGI_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_REVISION_VERSION( SGI_TRANSLATOR_VERSION)), __DATE__); BStringView* detailView = new BStringView("details", detail); detailView->SetExplicitAlignment(labelAlignment); BTextView* infoView = new BTextView("info"); infoView->SetText(BString(B_TRANSLATE("written by:\n")) .Append(author) .Append(B_TRANSLATE("\n\nbased on GIMP SGI plugin v1.5:\n")) .Append(kSGICopyright).String()); infoView->SetExplicitAlignment(labelAlignment); infoView->SetWordWrap(false); infoView->MakeEditable(false); infoView->MakeResizable(true); infoView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); float padding = 5.0f; BLayoutBuilder::Group<>(this, B_VERTICAL, padding) .SetInsets(padding) .Add(titleView) .Add(detailView) .AddGroup(B_HORIZONTAL) .Add(fCompressionMF) .AddGlue() .End() .Add(infoView) .AddGlue(); BFont font; GetFont(&font); SetExplicitPreferredSize(BSize((font.Size() * 390) / 12, (font.Size() * 180) / 12)); // TODO: remove this workaround for ticket #4217 infoView->SetExplicitPreferredSize( BSize(infoView->LineWidth(4), infoView->TextHeight(0, 80))); infoView->SetExplicitMaxSize(infoView->ExplicitPreferredSize()); infoView->SetExplicitMinSize(infoView->ExplicitPreferredSize()); }
// --------------------------------------------------------------- // Constructor // // Sets up the view settings // // Preconditions: // // Parameters: // // Postconditions: // // Returns: // --------------------------------------------------------------- TIFFView::TIFFView(const char *name, uint32 flags, TranslatorSettings *settings) : BView(name, flags) { fSettings = settings; SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetLowColor(ViewColor()); fTitle = new BStringView("title", "TIFF Image Translator"); fTitle->SetFont(be_bold_font); char detail[100]; sprintf(detail, "Version %d.%d.%d %s", static_cast<int>(B_TRANSLATION_MAJOR_VERSION(TIFF_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_MINOR_VERSION(TIFF_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_REVISION_VERSION(TIFF_TRANSLATOR_VERSION)), __DATE__); fDetail = new BStringView("detail", detail); int16 i = 1; fLibTIFF[0] = new BStringView(NULL, "TIFF Library:"); char libtiff[] = TIFFLIB_VERSION_STR; char *tok = strtok(libtiff, "\n"); while (i < 5 && tok) { fLibTIFF[i] = new BStringView(NULL, tok); tok = strtok(NULL, "\n"); i++; } BPopUpMenu* menu = new BPopUpMenu("pick compression"); uint32 currentCompression = fSettings->SetGetInt32(TIFF_SETTING_COMPRESSION); // create the menu items with the various compression methods add_menu_item(menu, COMPRESSION_NONE, "None", currentCompression); menu->AddSeparatorItem(); add_menu_item(menu, COMPRESSION_PACKBITS, "RLE (Packbits)", currentCompression); add_menu_item(menu, COMPRESSION_DEFLATE, "ZIP (Deflate)", currentCompression); add_menu_item(menu, COMPRESSION_LZW, "LZW", currentCompression); // TODO: the disabled compression modes are not configured in libTIFF // menu->AddSeparatorItem(); // add_menu_item(menu, COMPRESSION_JPEG, "JPEG", currentCompression); // TODO ? - strip encoding is not implemented in libTIFF for this compression // add_menu_item(menu, COMPRESSION_JP2000, "JPEG2000", currentCompression); fCompressionMF = new BMenuField("Use Compression:", menu, NULL); // Build the layout SetLayout(new BGroupLayout(B_VERTICAL)); i = 0; AddChild(BGroupLayoutBuilder(B_VERTICAL, 7) .Add(fTitle) .Add(fDetail) .AddGlue() .Add(fCompressionMF) .AddGlue() .Add(fLibTIFF[0]) .Add(fLibTIFF[1]) .Add(fLibTIFF[2]) .Add(fLibTIFF[3]) // Theses 4 adding above work because we know there are 4 strings // but it's fragile: one string less in the library version and the application breaks .AddGlue() .SetInsets(5, 5, 5, 5) ); BFont font; GetFont(&font); SetExplicitPreferredSize(BSize((font.Size() * 350)/12, (font.Size() * 200)/12)); }
ConfigView::ConfigView(TranslatorSettings *settings) : BGroupView("ICNSTranslator Settings", B_VERTICAL, 0) { fSettings = settings; BAlignment leftAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET); BStringView *stringView = new BStringView("title", "OptiPNG Translator"); stringView->SetFont(be_bold_font); stringView->SetExplicitAlignment(leftAlignment); AddChild(stringView); float spacing = be_control_look->DefaultItemSpacing(); AddChild(BSpaceLayoutItem::CreateVerticalStrut(spacing)); char version[256]; sprintf(version, "Version %d.%d.%d, %s", int(B_TRANSLATION_MAJOR_VERSION(OPTIPNG_TRANSLATOR_VERSION)), int(B_TRANSLATION_MINOR_VERSION(OPTIPNG_TRANSLATOR_VERSION)), int(B_TRANSLATION_REVISION_VERSION(OPTIPNG_TRANSLATOR_VERSION)), __DATE__); stringView = new BStringView("version", version); stringView->SetExplicitAlignment(leftAlignment); AddChild(stringView); stringView = new BStringView("my_copyright", B_UTF8_COPYRIGHT "2013 Luke <*****@*****.**>."); stringView->SetExplicitAlignment(leftAlignment); AddChild(stringView); AddChild(BSpaceLayoutItem::CreateVerticalStrut(spacing)); fOptimizationLevel = new BSlider( "optimization", "Optimization level:", new BMessage(kMsgOptim), 0, 7, B_HORIZONTAL, B_BLOCK_THUMB); fOptimizationLevel->SetHashMarks(B_HASH_MARKS_BOTTOM); fOptimizationLevel->SetHashMarkCount(8); fOptimizationLevel->SetLimitLabels("Low", "High"); fOptimizationLevel->SetValue( fSettings->SetGetInt32(OPTIPNG_SETTING_OPTIMIZATION_LEVEL)); AddChild(fOptimizationLevel); fBitDepthCheckBox = new BCheckBox((char*)OPTIPNG_SETTING_BIT_DEPTH_REDUCTION, "Reduce bit depth:", new BMessage(kMsgBitDepth)); if (fSettings->SetGetBool(OPTIPNG_SETTING_BIT_DEPTH_REDUCTION)) fBitDepthCheckBox->SetValue(B_CONTROL_ON); AddChild(fBitDepthCheckBox); fColorTypeCheckBox = new BCheckBox((char*)OPTIPNG_SETTING_COLOR_TYPE_REDUCTION, "Reduce color type:", new BMessage(kMsgColorType)); if (fSettings->SetGetBool(OPTIPNG_SETTING_COLOR_TYPE_REDUCTION)) fColorTypeCheckBox->SetValue(B_CONTROL_ON); AddChild(fColorTypeCheckBox); fPaletteCheckBox = new BCheckBox((char*)OPTIPNG_SETTING_PALETTE_REDUCTION, "Reduce palette size:", new BMessage(kMsgPaletteReduc)); if (fSettings->SetGetBool(OPTIPNG_SETTING_PALETTE_REDUCTION)) fPaletteCheckBox->SetValue(B_CONTROL_ON); AddChild(fPaletteCheckBox); AddChild(BSpaceLayoutItem::CreateGlue()); GroupLayout()->SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING); SetExplicitPreferredSize(GroupLayout()->MinSize()); }
ConfigView::ConfigView(TranslatorSettings* settings) : BGroupView(B_TRANSLATE("WebPTranslator Settings"), B_VERTICAL), fSettings(settings) { SetViewUIColor(B_PANEL_BACKGROUND_COLOR); BStringView* title = new BStringView("title", B_TRANSLATE("WebP image translator")); title->SetFont(be_bold_font); char versionString[256]; sprintf(versionString, "v%d.%d.%d, %s", static_cast<int>(B_TRANSLATION_MAJOR_VERSION(WEBP_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_MINOR_VERSION(WEBP_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_REVISION_VERSION( WEBP_TRANSLATOR_VERSION)), __DATE__); BStringView* version = new BStringView("version", versionString); BString copyrightsText; BStringView *copyrightView = new BStringView("Copyright", B_TRANSLATE(B_UTF8_COPYRIGHT "2010-2011 Haiku Inc.")); BStringView *copyright2View = new BStringView("Copyright2", B_TRANSLATE("Based on libwebp v0.1,")); BStringView *copyright3View = new BStringView("Copyright3", B_TRANSLATE(B_UTF8_COPYRIGHT "2010-2011 Google Inc.")); // output parameters fPresetsMenu = new BPopUpMenu(B_TRANSLATE("Preset")); const struct preset_name* preset = kPresetNames; while (preset->name != NULL) { BMessage* msg = new BMessage(kMsgPreset); msg->AddInt32("value", preset->id); BMenuItem* item = new BMenuItem(preset->name, msg); if (fSettings->SetGetInt32(WEBP_SETTING_PRESET) == preset->id) item->SetMarked(true); fPresetsMenu->AddItem(item); preset++; } BMenuField* presetsField = new BMenuField(B_TRANSLATE("Output preset:"), fPresetsMenu); fQualitySlider = new BSlider("quality", B_TRANSLATE("Output quality:"), new BMessage(kMsgQuality), 0, 100, B_HORIZONTAL, B_BLOCK_THUMB); fQualitySlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fQualitySlider->SetHashMarkCount(10); fQualitySlider->SetLimitLabels(B_TRANSLATE("Low"), B_TRANSLATE("High")); fQualitySlider->SetValue(fSettings->SetGetInt32(WEBP_SETTING_QUALITY)); fMethodSlider = new BSlider("method", B_TRANSLATE("Compression method:"), new BMessage(kMsgMethod), 0, 6, B_HORIZONTAL, B_BLOCK_THUMB); fMethodSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fMethodSlider->SetHashMarkCount(7); fMethodSlider->SetLimitLabels(B_TRANSLATE("Fast"), B_TRANSLATE("Slower but better")); fMethodSlider->SetValue(fSettings->SetGetInt32(WEBP_SETTING_METHOD)); fPreprocessingCheckBox = new BCheckBox("preprocessing", B_TRANSLATE("Preprocessing filter"), new BMessage(kMsgPreprocessing)); if (fSettings->SetGetBool(WEBP_SETTING_PREPROCESSING)) fPreprocessingCheckBox->SetValue(B_CONTROL_ON); // Build the layout BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .SetInsets(B_USE_DEFAULT_SPACING) .Add(title) .Add(version) .Add(copyrightView) .AddGlue() .AddGrid(B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING) .Add(presetsField->CreateLabelLayoutItem(), 0, 0) .AddGroup(B_HORIZONTAL, 0.0f, 1, 0) .Add(presetsField->CreateMenuBarLayoutItem(), 0.0f) .AddGlue() .End() .End() .Add(fQualitySlider) .Add(fMethodSlider) .Add(fPreprocessingCheckBox) .AddGlue() .Add(copyright2View) .Add(copyright3View); BFont font; GetFont(&font); SetExplicitPreferredSize(BSize((font.Size() * 250) / 12, (font.Size() * 350) / 12)); }
GIFView::GIFView(TranslatorSettings* settings) : BGroupView("GIFView", B_VERTICAL), fSettings(settings) { SetViewUIColor(B_PANEL_BACKGROUND_COLOR); fTitle = new BStringView("Title", B_TRANSLATE("GIF image translator")); fTitle->SetFont(be_bold_font); char version_string[100]; snprintf(version_string, sizeof(version_string), B_TRANSLATE("Version %d.%d.%d, %s"), int(B_TRANSLATION_MAJOR_VERSION(GIF_TRANSLATOR_VERSION)), int(B_TRANSLATION_MINOR_VERSION(GIF_TRANSLATOR_VERSION)), int(B_TRANSLATION_REVISION_VERSION(GIF_TRANSLATOR_VERSION)), __DATE__); fVersion = new BStringView("Version", version_string); const char* copyrightString = "©2003 Daniel Switkin, [email protected]"; fCopyright = new BStringView("Copyright", copyrightString); // menu fields (Palette & Colors) fWebSafeMI = new BMenuItem(B_TRANSLATE("Websafe"), new BMessage(GV_WEB_SAFE), 0, 0); fBeOSSystemMI = new BMenuItem(B_TRANSLATE("BeOS system"), new BMessage(GV_BEOS_SYSTEM), 0, 0); fGreyScaleMI = new BMenuItem(B_TRANSLATE("Greyscale"), new BMessage(GV_GREYSCALE), 0, 0); fOptimalMI = new BMenuItem(B_TRANSLATE("Optimal"), new BMessage(GV_OPTIMAL), 0, 0); fPaletteM = new BPopUpMenu("PalettePopUpMenu", true, true, B_ITEMS_IN_COLUMN); fPaletteM->AddItem(fWebSafeMI); fPaletteM->AddItem(fBeOSSystemMI); fPaletteM->AddItem(fGreyScaleMI); fPaletteM->AddItem(fOptimalMI); fColorCountM = new BPopUpMenu("ColorCountPopUpMenu", true, true, B_ITEMS_IN_COLUMN); int32 count = 2; for (int32 i = 0; i < 8; i++) { BMessage* message = new BMessage(GV_SET_COLOR_COUNT); message->AddInt32(GIF_SETTING_PALETTE_SIZE, i + 1); BString label; label << count; fColorCountMI[i] = new BMenuItem(label.String(), message, 0, 0); fColorCountM->AddItem(fColorCountMI[i]); count *= 2; } fColorCount256MI = fColorCountMI[7]; fPaletteMF = new BMenuField(B_TRANSLATE("Palette:"), fPaletteM); fPaletteMF->SetAlignment(B_ALIGN_RIGHT); fColorCountMF = new BMenuField(B_TRANSLATE("Colors:"), fColorCountM); fColorCountMF->SetAlignment(B_ALIGN_RIGHT); // check boxes fUseDitheringCB = new BCheckBox(B_TRANSLATE("Use dithering"), new BMessage(GV_USE_DITHERING)); fDitheringBox = new BBox("dithering", B_WILL_DRAW, B_NO_BORDER); fDitheringBox->SetLabel(fUseDitheringCB); fInterlacedCB = new BCheckBox(B_TRANSLATE("Write interlaced images"), new BMessage(GV_INTERLACED)); fInterlacedBox = new BBox("interlaced", B_WILL_DRAW, B_NO_BORDER); fInterlacedBox->SetLabel(fInterlacedCB); fUseTransparentCB = new BCheckBox(B_TRANSLATE("Write transparent images"), new BMessage(GV_USE_TRANSPARENT)); // radio buttons fUseTransparentAutoRB = new BRadioButton( B_TRANSLATE("Automatic (from alpha channel)"), new BMessage(GV_USE_TRANSPARENT_AUTO)); fUseTransparentColorRB = new BRadioButton(B_TRANSLATE("Use RGB color"), new BMessage(GV_USE_TRANSPARENT_COLOR)); // text controls fRedTextControl = new BTextControl("", "0", new BMessage(GV_TRANSPARENT_RED)); fGreenTextControl = new BTextControl("", "0", new BMessage(GV_TRANSPARENT_GREEN)); fBlueTextControl = new BTextControl("", "0", new BMessage(GV_TRANSPARENT_BLUE)); fTransparentBox = new BBox(B_FANCY_BORDER, BLayoutBuilder::Grid<>(3.0f, 5.0f) .Add(fUseTransparentAutoRB, 0, 0, 4, 1) .Add(fUseTransparentColorRB, 0, 1) .Add(fRedTextControl, 1, 1) .Add(fGreenTextControl, 2, 1) .Add(fBlueTextControl, 3, 1) .SetInsets(10.0f, 6.0f, 10.0f, 10.0f) .View()); fTransparentBox->SetLabel(fUseTransparentCB); BTextView* redTextView = fRedTextControl->TextView(); BTextView* greenTextView = fGreenTextControl->TextView(); BTextView* bluetextView = fBlueTextControl->TextView(); for (uint32 x = 0; x < 256; x++) { if (x < '0' || x > '9') { redTextView->DisallowChar(x); greenTextView->DisallowChar(x); bluetextView->DisallowChar(x); } } BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .SetInsets(B_USE_DEFAULT_SPACING) .Add(fTitle) .Add(fVersion) .Add(fCopyright) .AddGlue() .AddGrid(10.0f, 5.0f) .Add(fPaletteMF->CreateLabelLayoutItem(), 0, 0) .Add(fPaletteMF->CreateMenuBarLayoutItem(), 1, 0) .Add(fColorCountMF->CreateLabelLayoutItem(), 0, 1) .Add(fColorCountMF->CreateMenuBarLayoutItem(), 1, 1) .End() .AddStrut(B_USE_SMALL_SPACING) .Add(fDitheringBox) .Add(fInterlacedBox) .Add(fTransparentBox) .AddGlue() .End(); fSettings->Acquire(); RestorePrefs(); }
ConfigView::ConfigView(TranslatorSettings *settings) : BGroupView(B_TRANSLATE("PSDTranslator Settings"), B_VERTICAL, 0) { fSettings = settings; BPopUpMenu* compressionPopupMenu = new BPopUpMenu("popup_compression"); uint32 currentCompression = fSettings->SetGetInt32(PSD_SETTING_COMPRESSION); _AddItemToMenu(compressionPopupMenu, B_TRANSLATE("Uncompressed"), MSG_COMPRESSION_CHANGED, PSD_COMPRESSED_RAW, currentCompression); _AddItemToMenu(compressionPopupMenu, B_TRANSLATE("RLE"), MSG_COMPRESSION_CHANGED, PSD_COMPRESSED_RLE, currentCompression); fCompressionField = new BMenuField("compression", B_TRANSLATE("Compression: "), compressionPopupMenu); fCompressionField->SetAlignment(B_ALIGN_RIGHT); BPopUpMenu* versionPopupMenu = new BPopUpMenu("popup_version"); uint32 currentVersion = fSettings->SetGetInt32(PSD_SETTING_VERSION); _AddItemToMenu(versionPopupMenu, B_TRANSLATE("Photoshop Document (PSD file)"), MSG_VERSION_CHANGED, PSD_FILE, currentVersion); _AddItemToMenu(versionPopupMenu, B_TRANSLATE("Photoshop Big Document (PSB file)"), MSG_VERSION_CHANGED, PSB_FILE, currentVersion); fVersionField = new BMenuField("version", B_TRANSLATE("Format: "), versionPopupMenu); fVersionField->SetAlignment(B_ALIGN_RIGHT); BStringView *titleView = new BStringView("title", B_TRANSLATE("Photoshop image translator")); titleView->SetFont(be_bold_font); char version[256]; sprintf(version, B_TRANSLATE("Version %d.%d.%d, %s"), int(B_TRANSLATION_MAJOR_VERSION(PSD_TRANSLATOR_VERSION)), int(B_TRANSLATION_MINOR_VERSION(PSD_TRANSLATOR_VERSION)), int(B_TRANSLATION_REVISION_VERSION(PSD_TRANSLATOR_VERSION)), __DATE__); BStringView *versionView = new BStringView("version", version); BStringView *copyrightView = new BStringView("copyright", B_UTF8_COPYRIGHT "2005-2013 Haiku Inc."); BStringView *copyright2View = new BStringView("my_copyright", B_UTF8_COPYRIGHT "2012-2013 Gerasim Troeglazov <*****@*****.**>"); BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .SetInsets(B_USE_DEFAULT_SPACING) .Add(titleView) .Add(versionView) .Add(copyrightView) .AddGlue() .AddGrid(10.0f, 5.0f) .Add(fVersionField->CreateLabelLayoutItem(), 0, 0) .Add(fVersionField->CreateMenuBarLayoutItem(), 1, 0) .Add(fCompressionField->CreateLabelLayoutItem(), 0, 1) .Add(fCompressionField->CreateMenuBarLayoutItem(), 1, 1) .End() .AddGlue() .Add(copyright2View); SetExplicitPreferredSize(GroupLayout()->MinSize()); }