From a76f629efad0ba4d6518d918a39dbcc6097fe536 Mon Sep 17 00:00:00 2001 From: Ryan Leavengood Date: Sat, 6 Mar 2010 04:45:43 +0000 Subject: [PATCH] Apply patch from Maxime Simon to make several translators use the Layout API. There are a few small changes from myself, such as adding a copyright for Maxime in files with bigger changes. Also because this patch was so old I had to do some manual patching, and added back the title and description on the TGA and TIFF translators. I think this improves things a lot, though there is still some work to do to improve the consistency of the translator settings views. I think this mostly fixes #2117, though I may leave the ticket open until a few more things are resolved. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35769 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/translators/exr/ConfigView.cpp | 69 ++++--- src/add-ons/translators/exr/ConfigView.h | 3 +- src/add-ons/translators/exr/EXRTranslator.cpp | 2 +- src/add-ons/translators/exr/main.cpp | 2 +- src/add-ons/translators/gif/GIFTranslator.cpp | 5 +- src/add-ons/translators/gif/GIFView.cpp | 176 ++++++++---------- src/add-ons/translators/gif/GIFView.h | 2 +- src/add-ons/translators/gif/GIFWindow.cpp | 10 +- src/add-ons/translators/ppm/PPMMain.cpp | 10 +- src/add-ons/translators/ppm/PPMTranslator.cpp | 105 ++++++----- src/add-ons/translators/raw/ConfigView.cpp | 61 +++--- src/add-ons/translators/raw/ConfigView.h | 3 +- src/add-ons/translators/raw/RAWTranslator.cpp | 2 +- src/add-ons/translators/raw/main.cpp | 11 +- .../translators/shared/BaseTranslator.cpp | 4 + .../translators/shared/TranslatorWindow.cpp | 7 +- .../translators/shared/TranslatorWindow.h | 3 +- src/add-ons/translators/tga/TGAMain.cpp | 3 +- src/add-ons/translators/tga/TGATranslator.cpp | 3 +- src/add-ons/translators/tga/TGAView.cpp | 96 +++++----- src/add-ons/translators/tga/TGAView.h | 10 +- src/add-ons/translators/tiff/TIFFMain.cpp | 3 +- .../translators/tiff/TIFFTranslator.cpp | 3 +- src/add-ons/translators/tiff/TIFFView.cpp | 115 ++++++------ src/add-ons/translators/tiff/TIFFView.h | 10 +- 25 files changed, 353 insertions(+), 365 deletions(-) diff --git a/src/add-ons/translators/exr/ConfigView.cpp b/src/add-ons/translators/exr/ConfigView.cpp index fbe6bcbecb..8ff7f3f53e 100644 --- a/src/add-ons/translators/exr/ConfigView.cpp +++ b/src/add-ons/translators/exr/ConfigView.cpp @@ -1,6 +1,7 @@ /* * Copyright 2008, Jérôme Duval. All rights reserved. * Copyright 2005-2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Copyright 2009, Maxime Simon, maxime.simon@gmail.com. All rights reserved. * Distributed under the terms of the MIT License. */ @@ -10,57 +11,63 @@ #include #include +#include +#include +#include #include #include -ConfigView::ConfigView(const BRect &frame, uint32 resize, uint32 flags) - : BView(frame, "EXRTranslator Settings", resize, flags) +ConfigView::ConfigView(uint32 flags) + : BView("EXRTranslator Settings", flags) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - font_height fontHeight; - be_bold_font->GetHeight(&fontHeight); - float height = fontHeight.descent + fontHeight.ascent + fontHeight.leading; + BStringView *fTitle = new BStringView("title", "EXR Images"); + fTitle->SetFont(be_bold_font); - BRect rect(10, 10, 200, 10 + height); - BStringView *stringView = new BStringView(rect, "title", "EXR images"); - stringView->SetFont(be_bold_font); - stringView->ResizeToPreferred(); - AddChild(stringView); - - rect.OffsetBy(0, height + 10); char version[256]; sprintf(version, "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__); - stringView = new BStringView(rect, "version", version); - stringView->ResizeToPreferred(); - AddChild(stringView); + BStringView *fVersion = new BStringView("version", version); - GetFontHeight(&fontHeight); - height = fontHeight.descent + fontHeight.ascent + fontHeight.leading; + BStringView *fCopyright = new BStringView("copyright", + B_UTF8_COPYRIGHT "2008 Haiku Inc."); - rect.OffsetBy(0, height + 5); - stringView = new BStringView(rect, "copyright", B_UTF8_COPYRIGHT "2008 Haiku Inc."); - stringView->ResizeToPreferred(); - AddChild(stringView); + BStringView *fCopyright2 = new BStringView("copyright2", + "Based on OpenEXR (http://www.openexr.com)"); - rect.OffsetBy(0, height + 10); - stringView = new BStringView(rect, "copyright2", "Based on OpenEXR (http://www.openexr.com)"); - stringView->ResizeToPreferred(); - AddChild(stringView); + BStringView *fCopyright3 = new BStringView("copyright3", + B_UTF8_COPYRIGHT "2006, Industrial Light & Magic,"); - rect.OffsetBy(0, height + 5); - stringView = new BStringView(rect, "copyright3", B_UTF8_COPYRIGHT "2006, Industrial Light & Magic, a division of Lucasfilm " - "Entertainment Company Ltd"); - stringView->ResizeToPreferred(); - AddChild(stringView); + BStringView *fCopyright4 = new BStringView("copyright4", + "a division of Lucasfilm Entertainment Company Ltd"); + + // Build the layout + SetLayout(new BGroupLayout(B_HORIZONTAL)); + + AddChild(BGroupLayoutBuilder(B_VERTICAL, 7) + .Add(fTitle) + .Add(fVersion) + .AddGlue() + .Add(fCopyright) + .Add(fCopyright2) + .AddGlue() + .Add(fCopyright3) + .Add(fCopyright4) + .AddGlue() + .SetInsets(5, 5, 5, 5) + ); + + BFont font; + GetFont(&font); + SetExplicitPreferredSize(BSize((font.Size() * 400)/12, (font.Size() * 200)/12)); } - + ConfigView::~ConfigView() { diff --git a/src/add-ons/translators/exr/ConfigView.h b/src/add-ons/translators/exr/ConfigView.h index dfb0abf5fb..ed86a79f9b 100644 --- a/src/add-ons/translators/exr/ConfigView.h +++ b/src/add-ons/translators/exr/ConfigView.h @@ -11,8 +11,7 @@ class ConfigView : public BView { public: - ConfigView(const BRect &frame, uint32 resize = B_FOLLOW_ALL, - uint32 flags = B_WILL_DRAW); + ConfigView(uint32 flags = B_WILL_DRAW); virtual ~ConfigView(); }; diff --git a/src/add-ons/translators/exr/EXRTranslator.cpp b/src/add-ons/translators/exr/EXRTranslator.cpp index a665768573..859eeaa2e6 100644 --- a/src/add-ons/translators/exr/EXRTranslator.cpp +++ b/src/add-ons/translators/exr/EXRTranslator.cpp @@ -229,7 +229,7 @@ EXRTranslator::DerivedTranslate(BPositionIO* source, BView * EXRTranslator::NewConfigView(TranslatorSettings *settings) { - return new ConfigView(BRect(0, 0, 225, 175)); + return new ConfigView(); } diff --git a/src/add-ons/translators/exr/main.cpp b/src/add-ons/translators/exr/main.cpp index da66e913f6..03c3d71fd0 100644 --- a/src/add-ons/translators/exr/main.cpp +++ b/src/add-ons/translators/exr/main.cpp @@ -16,7 +16,7 @@ main(int /*argc*/, char **/*argv*/) BApplication app("application/x-vnd.Haiku-EXRTranslator"); status_t result; - result = LaunchTranslatorWindow(new EXRTranslator, "EXR Settings", BRect(0, 0, 225, 175)); + result = LaunchTranslatorWindow(new EXRTranslator, "EXR Settings"); if (result != B_OK) return 1; diff --git a/src/add-ons/translators/gif/GIFTranslator.cpp b/src/add-ons/translators/gif/GIFTranslator.cpp index da2f13e713..510fd88cb6 100644 --- a/src/add-ons/translators/gif/GIFTranslator.cpp +++ b/src/add-ons/translators/gif/GIFTranslator.cpp @@ -61,9 +61,10 @@ translation_format outputFormats[] = { status_t MakeConfig(BMessage *ioExtension, BView **outView, BRect *outExtent) { - outExtent->Set(0, 0, 239, 239); - GIFView *gifview = new GIFView(*outExtent, "TranslatorView"); + GIFView *gifview = new GIFView("TranslatorView"); *outView = gifview; + gifview->ResizeTo(gifview->ExplicitPreferredSize()); + *outExtent = gifview->Bounds(); return B_OK; } diff --git a/src/add-ons/translators/gif/GIFView.cpp b/src/add-ons/translators/gif/GIFView.cpp index 4426819995..194cffec13 100644 --- a/src/add-ons/translators/gif/GIFView.cpp +++ b/src/add-ons/translators/gif/GIFView.cpp @@ -14,10 +14,14 @@ //////////////////////////////////////////////////////////////////////////////// // Additional authors: Stephan Aßmus, +// Maxime Simon, #include #include +#include +#include +#include #include #include @@ -30,41 +34,21 @@ extern int32 translatorVersion; extern char translatorName[]; // constructor -GIFView::GIFView(BRect rect, const char *name) - : BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW) +GIFView::GIFView(const char *name) + : BView(name, B_WILL_DRAW) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - - font_height fh; - be_bold_font->GetHeight(&fh); - BRect r(10, 15, 10 + be_bold_font->StringWidth(translatorName), - 15 + fh.ascent + fh.descent); - BStringView *title = new BStringView(r, "Title", translatorName); + BStringView *title = new BStringView("Title", translatorName); title->SetFont(be_bold_font); - AddChild(title); char version_string[100]; sprintf(version_string, "v%d.%d.%d %s", (int)(translatorVersion >> 8), (int)((translatorVersion >> 4) & 0xf), (int)(translatorVersion & 0xf), __DATE__); - be_plain_font->GetHeight(&fh); - r.bottom = r.top + fh.ascent + fh.descent; - r.left = r.right + 2.0 * r.Height(); - r.right = r.left + be_plain_font->StringWidth(version_string); - - BStringView *version = new BStringView(r, "Version", version_string); - version->SetFont(be_plain_font); - AddChild(version); + BStringView *version = new BStringView("Version", version_string); const char *copyrightString = "©2003 Daniel Switkin, software@switkin.com"; - r.top = r.bottom + 5; - r.left = 10; - r.bottom = r.top + fh.ascent + fh.descent; - r.right = rect.right - 10; - - BStringView *copyright = new BStringView(r, "Copyright", copyrightString); - copyright->ResizeToPreferred(); - AddChild(copyright); + BStringView *copyright = new BStringView("Copyright", copyrightString); // menu fields (Palette & Colors) fWebSafeMI = new BMenuItem("Websafe", new BMessage(GV_WEB_SAFE), 0, 0); @@ -89,81 +73,34 @@ GIFView::GIFView(BRect rect, const char *name) count *= 2; } fColorCount256MI = fColorCountMI[7]; - - r.top = r.bottom + 14; - r.bottom = r.top + 24; - fPaletteMF = new BMenuField(r, "PaletteMenuField", "Palette: ", - fPaletteM, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE); - AddChild(fPaletteMF); - - r.top = r.bottom + 5; - r.bottom = r.top + 24; - fColorCountMF = new BMenuField(r, "ColorCountMenuField", "Colors: ", - fColorCountM, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE); - AddChild(fColorCountMF); - - // align menu fields - float maxLabelWidth = ceilf(max_c(be_plain_font->StringWidth("Colors: "), - be_plain_font->StringWidth("Palette: "))); - fPaletteMF->SetDivider(maxLabelWidth + 7); - fColorCountMF->SetDivider(maxLabelWidth + 7); - - // check boxen - r.top = fColorCountMF->Frame().bottom + 5; - r.bottom = r.top + 10; - fUseDitheringCB = new BCheckBox(r, "UseDithering", "Use dithering", - new BMessage(GV_USE_DITHERING)); - AddChild(fUseDitheringCB); - - r.top = fUseDitheringCB->Frame().bottom + 2; - r.bottom = r.top + 10; - fInterlacedCB = new BCheckBox(r, "Interlaced", "Write interlaced images", - new BMessage(GV_INTERLACED)); - AddChild(fInterlacedCB); - - r.top = fInterlacedCB->Frame().bottom + 2; - r.bottom = r.top + 10; - fUseTransparentCB = new BCheckBox(r, "UseTransparent", "Write transparent images", - new BMessage(GV_USE_TRANSPARENT)); - AddChild(fUseTransparentCB); - - // radio buttons - r.top = fUseTransparentCB->Frame().bottom + 2; - r.bottom = r.top + 10; - r.right = r.left + be_plain_font->StringWidth("Automatic (from alpha channel)") + 20; - fUseTransparentAutoRB = new BRadioButton(r, "UseTransparentAuto", "Automatic (from alpha channel)", - new BMessage(GV_USE_TRANSPARENT_AUTO)); - AddChild(fUseTransparentAutoRB); - - r.top = fUseTransparentAutoRB->Frame().bottom + 0; - r.bottom = r.top + 10; - r.left = 10; - r.right = r.left + be_plain_font->StringWidth("Use RGB color") + 20; - fUseTransparentColorRB = new BRadioButton(r, "UseTransparentColor", "Use RGB color", - new BMessage(GV_USE_TRANSPARENT_COLOR)); - AddChild(fUseTransparentColorRB); - - r.left = r.right + 1; - r.right = r.left + 30; - fTransparentRedTC = new BTextControl(r, "TransparentRed", "", "0", - new BMessage(GV_TRANSPARENT_RED)); - AddChild(fTransparentRedTC); - fTransparentRedTC->SetDivider(0); - - r.left = r.right + 5; - r.right = r.left + 30; - fTransparentGreenTC = new BTextControl(r, "TransparentGreen", "", "0", - new BMessage(GV_TRANSPARENT_GREEN)); - AddChild(fTransparentGreenTC); - fTransparentGreenTC->SetDivider(0); - - r.left = r.right + 5; - r.right = r.left + 30; - fTransparentBlueTC = new BTextControl(r, "TransparentBlue", "", "0", - new BMessage(GV_TRANSPARENT_BLUE)); - AddChild(fTransparentBlueTC); - fTransparentBlueTC->SetDivider(0); + fPaletteMF = new BMenuField("Palette", fPaletteM, NULL); + + fColorCountMF = new BMenuField("Colors", fColorCountM, NULL); + + // check boxes + fUseDitheringCB = new BCheckBox("Use dithering", + new BMessage(GV_USE_DITHERING)); + + fInterlacedCB = new BCheckBox("Write interlaced images", + new BMessage(GV_INTERLACED)); + + fUseTransparentCB = new BCheckBox("Write transparent images", + new BMessage(GV_USE_TRANSPARENT)); + + // radio buttons + fUseTransparentAutoRB = new BRadioButton("Automatic (from alpha channel)", + new BMessage(GV_USE_TRANSPARENT_AUTO)); + + fUseTransparentColorRB = new BRadioButton("Use RGB color", + new BMessage(GV_USE_TRANSPARENT_COLOR)); + + fTransparentRedTC = new BTextControl("", "0", new BMessage(GV_TRANSPARENT_RED)); + + fTransparentGreenTC = new BTextControl("", "0", new BMessage(GV_TRANSPARENT_GREEN)); + + fTransparentBlueTC = new BTextControl("", "0", new BMessage(GV_TRANSPARENT_BLUE)); + BTextView *tr = fTransparentRedTC->TextView(); BTextView *tg = fTransparentGreenTC->TextView(); BTextView *tb = fTransparentBlueTC->TextView(); @@ -176,10 +113,45 @@ GIFView::GIFView(BRect rect, const char *name) } } - RestorePrefs(); + SetLayout(new BGroupLayout(B_HORIZONTAL)); - if (copyright->Frame().right + 10 > Bounds().Width()) - ResizeTo(copyright->Frame().right + 10, Bounds().Height()); + AddChild(BGroupLayoutBuilder(B_VERTICAL, 7) + .Add(BGridLayoutBuilder(10, 10) + .Add(title, 0, 0) + .Add(version, 1, 0) + ) + .Add(copyright) + .AddGlue() + + .Add(BGridLayoutBuilder(10, 10) + .Add(fPaletteMF->CreateLabelLayoutItem(), 0, 0) + .Add(fPaletteMF->CreateMenuBarLayoutItem(), 1, 0) + + .Add(fColorCountMF->CreateLabelLayoutItem(), 0, 1) + .Add(fColorCountMF->CreateMenuBarLayoutItem(), 1, 1) + ) + .AddGlue() + + .Add(fUseDitheringCB) + .Add(fInterlacedCB) + .Add(fUseTransparentCB) + + .Add(fUseTransparentAutoRB) + .Add(BGridLayoutBuilder(10, 10) + .Add(fUseTransparentColorRB, 0, 0) + .Add(fTransparentRedTC, 1, 0) + .Add(fTransparentGreenTC, 2, 0) + .Add(fTransparentBlueTC, 3, 0) + ) + .AddGlue() + .SetInsets(5, 5, 5, 5) + ); + + BFont font; + GetFont(&font); + SetExplicitPreferredSize(BSize((font.Size() * 400)/12, (font.Size() * 300)/12)); + + RestorePrefs(); } diff --git a/src/add-ons/translators/gif/GIFView.h b/src/add-ons/translators/gif/GIFView.h index 8a16dac703..9ff5310a3c 100644 --- a/src/add-ons/translators/gif/GIFView.h +++ b/src/add-ons/translators/gif/GIFView.h @@ -44,7 +44,7 @@ class Prefs; class GIFView : public BView { public: - GIFView(BRect rect, const char* name); + GIFView(const char* name); virtual ~GIFView(); virtual void MessageReceived(BMessage* message); diff --git a/src/add-ons/translators/gif/GIFWindow.cpp b/src/add-ons/translators/gif/GIFWindow.cpp index 3628f42efa..a9a360997f 100644 --- a/src/add-ons/translators/gif/GIFWindow.cpp +++ b/src/add-ons/translators/gif/GIFWindow.cpp @@ -16,13 +16,13 @@ #include "GIFWindow.h" #include "GIFView.h" #include +#include GIFWindow::GIFWindow(BRect rect, const char *name) : - BWindow(rect, name, B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE, - B_CURRENT_WORKSPACE) { - - BRect r(Bounds()); - gifview = new GIFView(r, "GIFView"); + BWindow(rect, name, B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE + | B_AUTO_UPDATE_SIZE_LIMITS, B_CURRENT_WORKSPACE) { + SetLayout(new BGroupLayout(B_HORIZONTAL)); + gifview = new GIFView("GIFView"); AddChild(gifview); } diff --git a/src/add-ons/translators/ppm/PPMMain.cpp b/src/add-ons/translators/ppm/PPMMain.cpp index 35262f8250..b88992ffbb 100644 --- a/src/add-ons/translators/ppm/PPMMain.cpp +++ b/src/add-ons/translators/ppm/PPMMain.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include @@ -20,10 +21,11 @@ class PPMWindow : public BWindow { public: - PPMWindow( - BRect area) : - BWindow(area, "PPM Settings", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE) + PPMWindow(BRect area) : + BWindow(area, "PPM Settings", B_TITLED_WINDOW, + B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS) { + SetLayout(new BGroupLayout(B_HORIZONTAL)); } ~PPMWindow() { @@ -39,7 +41,7 @@ main() { BApplication app("application/x-vnd.Haiku-PPMTranslator"); BView * v = NULL; - BRect r(0,0,225,175); + BRect r(0, 0, 1, 1); if (MakeConfig(NULL, &v, &r)) { BAlert * err = new BAlert("Error", "Something is wrong with the PPMTranslator!", "OK"); err->Go(); diff --git a/src/add-ons/translators/ppm/PPMTranslator.cpp b/src/add-ons/translators/ppm/PPMTranslator.cpp index 8401eb25bc..cd9233ecb7 100644 --- a/src/add-ons/translators/ppm/PPMTranslator.cpp +++ b/src/add-ons/translators/ppm/PPMTranslator.cpp @@ -21,6 +21,11 @@ #include #include #include +#include +#include +#include +#include +#include #include #include @@ -430,14 +435,28 @@ class PPMView : { public: PPMView( - const BRect & frame, const char * name, - uint32 resize, uint32 flags) : - BView(frame, name, resize, flags) + BView(name, flags) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetLowColor(ViewColor()); + + mTitle = new BStringView("title", "PPM Image Translator"); + mTitle->SetFont(be_bold_font); + + char detail[100]; + int ver = static_cast(translatorVersion); + sprintf(detail, "Version %d.%d.%d %s", ver >> 8, ((ver >> 4) & 0xf), + (ver & 0xf), __DATE__); + mDetail = new BStringView("detail", detail); + + mBasedOn = new BStringView("basedOn", + "Based on PPMTranslator sample code"); + + mCopyright = new BStringView("copyright", + "Sample code copyright 1999, Be Incorporated"); + mMenu = new BPopUpMenu("Color Space"); mMenu->AddItem(new BMenuItem("None", CSMessage(B_NO_COLOR_SPACE))); mMenu->AddItem(new BMenuItem("RGB 8:8:8 32 bits", CSMessage(B_RGB32))); @@ -458,18 +477,37 @@ public: mMenu->AddItem(new BMenuItem("RGB 5:5:5 16 bits big-endian", CSMessage(B_RGB15_BIG))); mMenu->AddItem(new BMenuItem("RGBA 5:5:5:1 16 bits big-endian", CSMessage(B_RGBA15_BIG))); mMenu->AddItem(new BMenuItem("RGB 5:6:5 16 bits big-endian", CSMessage(B_RGB16))); - mField = new BMenuField(BRect(10,110,190,130), "Color Space Field", "Input color space", mMenu); - mField->SetDivider(mField->StringWidth(mField->Label()) + 7); - mField->SetViewColor(ViewColor()); - AddChild(mField); - SelectColorSpace(g_settings.out_space); - BMessage * msg = new BMessage(CHANGE_ASCII); - mAscii = new BCheckBox(BRect(10,135,170,155), "Write ASCII", "Write ASCII", msg); - if (g_settings.write_ascii) { - mAscii->SetValue(1); - } - mAscii->SetViewColor(ViewColor()); - AddChild(mAscii); + mField = new BMenuField("Input Color Space", mMenu, NULL); + mField->SetViewColor(ViewColor()); + SelectColorSpace(g_settings.out_space); + BMessage * msg = new BMessage(CHANGE_ASCII); + mAscii = new BCheckBox("Write ASCII", msg); + if (g_settings.write_ascii) + mAscii->SetValue(1); + mAscii->SetViewColor(ViewColor()); + + // Build the layout + SetLayout(new BGroupLayout(B_HORIZONTAL)); + + AddChild(BGroupLayoutBuilder(B_VERTICAL, 7) + .Add(mTitle) + .Add(mDetail) + .AddGlue() + .Add(mBasedOn) + .Add(mCopyright) + .AddGlue() + .Add(BGridLayoutBuilder(10, 10) + .Add(mField->CreateLabelLayoutItem(), 0, 0) + .Add(mField->CreateMenuBarLayoutItem(), 1, 0) + .Add(mAscii, 0, 1) + ) + .AddGlue() + .SetInsets(5, 5, 5, 5) + ); + + BFont font; + GetFont(&font); + SetExplicitPreferredSize(BSize((font.Size() * 350)/12, (font.Size() * 200)/12)); } ~PPMView() { @@ -481,36 +519,6 @@ public: CHANGE_ASCII }; -virtual void 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; - - char title[] = "PPM image translator"; - DrawString(title, 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]; - int ver = static_cast(translatorVersion); - sprintf(detail, "Version %d.%d.%d %s", ver >> 8, ((ver >> 4) & 0xf), - (ver & 0xf), __DATE__); - DrawString(detail, BPoint(xbold, yplain + ybold)); - - DrawString("Based on PPMTranslator sample code", - BPoint(xbold, yplain * 3 + ybold)); - DrawString("Sample code copyright 1999, Be Incorporated", - BPoint(xbold, yplain * 4 + ybold)); - } virtual void MessageReceived( BMessage * message) { @@ -559,6 +567,10 @@ virtual void AllAttached() } private: + BStringView * mTitle; + BStringView * mDetail; + BStringView * mBasedOn; + BStringView * mCopyright; BPopUpMenu * mMenu; BMenuField * mField; BCheckBox * mAscii; @@ -604,8 +616,9 @@ MakeConfig( /* optional */ BView * * outView, BRect * outExtent) { - PPMView * v = new PPMView(BRect(0,0,225,175), "PPMTranslator Settings", B_FOLLOW_ALL, B_WILL_DRAW); + PPMView * v = new PPMView("PPMTranslator Settings", B_WILL_DRAW); *outView = v; + v->ResizeTo(v->ExplicitPreferredSize());; *outExtent = v->Bounds(); if (ioExtension) { v->SetSettings(ioExtension); diff --git a/src/add-ons/translators/raw/ConfigView.cpp b/src/add-ons/translators/raw/ConfigView.cpp index aee402dfb4..e1428b4222 100644 --- a/src/add-ons/translators/raw/ConfigView.cpp +++ b/src/add-ons/translators/raw/ConfigView.cpp @@ -1,5 +1,6 @@ /* * Copyright 2005-2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Copyright 2009, Maxime Simon, maxime.simon@gmail.com. All rights reserved. * Distributed under the terms of the MIT License. */ @@ -9,54 +10,56 @@ #include #include +#include +#include #include #include -ConfigView::ConfigView(const BRect &frame, uint32 resize, uint32 flags) - : BView(frame, "RAWTranslator Settings", resize, flags) +ConfigView::ConfigView(uint32 flags) + : BView("RAWTranslator Settings", flags) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - font_height fontHeight; - be_bold_font->GetHeight(&fontHeight); - float height = fontHeight.descent + fontHeight.ascent + fontHeight.leading; + BStringView *fTitle = new BStringView("title", "RAW Images"); + fTitle->SetFont(be_bold_font); - BRect rect(10, 10, 200, 10 + height); - BStringView *stringView = new BStringView(rect, "title", "RAW images"); - stringView->SetFont(be_bold_font); - stringView->ResizeToPreferred(); - AddChild(stringView); - - rect.OffsetBy(0, height + 10); char version[256]; sprintf(version, "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__); - stringView = new BStringView(rect, "version", version); - stringView->ResizeToPreferred(); - AddChild(stringView); + BStringView *fVersion = new BStringView("version", version); - GetFontHeight(&fontHeight); - height = fontHeight.descent + fontHeight.ascent + fontHeight.leading; + BStringView *fCopyright = new BStringView("copyright", + B_UTF8_COPYRIGHT "2007-2009 Haiku Inc."); - rect.OffsetBy(0, height + 5); - stringView = new BStringView(rect, "copyright", B_UTF8_COPYRIGHT "2007 Haiku Inc."); - stringView->ResizeToPreferred(); - AddChild(stringView); + BStringView *fCopyright2 = new BStringView("copyright2", + "Based on Dave Coffin's dcraw 8.63"); - rect.OffsetBy(0, height + 10); - stringView = new BStringView(rect, "copyright2", "Based on Dave Coffin's dcraw 8.63"); - stringView->ResizeToPreferred(); - AddChild(stringView); + BStringView *fCopyright3 = new BStringView("copyright3", + B_UTF8_COPYRIGHT "1997-2007 Dave Coffin"); - rect.OffsetBy(0, height + 5); - stringView = new BStringView(rect, "copyright3", B_UTF8_COPYRIGHT "1997-2007 Dave Coffin"); - stringView->ResizeToPreferred(); - AddChild(stringView); + // Build the layout + SetLayout(new BGroupLayout(B_HORIZONTAL)); + + AddChild(BGroupLayoutBuilder(B_VERTICAL, 7) + .Add(fTitle) + .AddGlue() + .Add(fVersion) + .Add(fCopyright) + .AddGlue() + .Add(fCopyright2) + .Add(fCopyright3) + .AddGlue() + .SetInsets(5, 5, 5, 5) + ); + + BFont font; + GetFont(&font); + SetExplicitPreferredSize(BSize((font.Size() * 233)/12, (font.Size() * 200)/12)); } diff --git a/src/add-ons/translators/raw/ConfigView.h b/src/add-ons/translators/raw/ConfigView.h index dfb0abf5fb..ed86a79f9b 100644 --- a/src/add-ons/translators/raw/ConfigView.h +++ b/src/add-ons/translators/raw/ConfigView.h @@ -11,8 +11,7 @@ class ConfigView : public BView { public: - ConfigView(const BRect &frame, uint32 resize = B_FOLLOW_ALL, - uint32 flags = B_WILL_DRAW); + ConfigView(uint32 flags = B_WILL_DRAW); virtual ~ConfigView(); }; diff --git a/src/add-ons/translators/raw/RAWTranslator.cpp b/src/add-ons/translators/raw/RAWTranslator.cpp index 205945bea8..718ee98842 100644 --- a/src/add-ons/translators/raw/RAWTranslator.cpp +++ b/src/add-ons/translators/raw/RAWTranslator.cpp @@ -326,7 +326,7 @@ RAWTranslator::DerivedTranslate(BPositionIO* stream, BView * RAWTranslator::NewConfigView(TranslatorSettings *settings) { - return new ConfigView(BRect(0, 0, 225, 175)); + return new ConfigView(); } diff --git a/src/add-ons/translators/raw/main.cpp b/src/add-ons/translators/raw/main.cpp index 6b3e2f352f..f6ed9aa336 100644 --- a/src/add-ons/translators/raw/main.cpp +++ b/src/add-ons/translators/raw/main.cpp @@ -15,6 +15,7 @@ #if SHOW_MODE && TEST_MODE # include # include +# include # include # include # include @@ -114,14 +115,13 @@ main(int argc, char **argv) if (status == B_OK) status = output.DetachBitmap(&bitmap); if (status == B_OK) { - BWindow* window = new BWindow(BRect(50, 50, - bitmap->Bounds().Width() + 50, - bitmap->Bounds().Height() + 50), + BWindow* window = new BWindow(BRect(0, 0, 1, 1), "RAW", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS - | B_NOT_RESIZABLE); + | B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS); BView* view = new BView(window->Bounds(), NULL, B_WILL_DRAW, B_FOLLOW_NONE); window->AddChild(view); + window->SetLayout(new BGroupLayout(B_HORIZONTAL)); window->Show(); snooze(300000); window->Lock(); @@ -140,8 +140,7 @@ main(int argc, char **argv) } #endif - status_t status = LaunchTranslatorWindow(new RAWTranslator, "RAW Settings", - BRect(0, 0, 225, 175)); + status_t status = LaunchTranslatorWindow(new RAWTranslator, "RAW Settings"); if (status != B_OK) return 1; diff --git a/src/add-ons/translators/shared/BaseTranslator.cpp b/src/add-ons/translators/shared/BaseTranslator.cpp index 65b54c1183..80fed094fc 100644 --- a/src/add-ons/translators/shared/BaseTranslator.cpp +++ b/src/add-ons/translators/shared/BaseTranslator.cpp @@ -642,8 +642,12 @@ BaseTranslator::MakeConfigurationView(BMessage *ioExtension, BView **outView, BView *view = NewConfigView(AcquireSettings()); // implemented in derived class + if (view) { *outView = view; + if ((view->Flags() & B_SUPPORTS_LAYOUT) != 0) + view->ResizeTo(view->ExplicitPreferredSize()); + *outExtent = view->Bounds(); return B_OK; diff --git a/src/add-ons/translators/shared/TranslatorWindow.cpp b/src/add-ons/translators/shared/TranslatorWindow.cpp index 18ecc89c14..6d07da4242 100644 --- a/src/add-ons/translators/shared/TranslatorWindow.cpp +++ b/src/add-ons/translators/shared/TranslatorWindow.cpp @@ -31,6 +31,7 @@ #include #include +#include #include "TranslatorWindow.h" // --------------------------------------------------------------- @@ -48,8 +49,11 @@ // --------------------------------------------------------------- TranslatorWindow::TranslatorWindow(BRect area, const char *title) : BWindow(area, title, B_TITLED_WINDOW, - B_NOT_RESIZABLE | B_NOT_ZOOMABLE) + B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS) { + SetLayout(new BGroupLayout(B_HORIZONTAL)); + // Set the layout on layout window + // Do nothing for a non-layout window } // --------------------------------------------------------------- @@ -85,7 +89,6 @@ LaunchTranslatorWindow(BTranslator *translator, const char *title, BRect rect) translator = NULL; TranslatorWindow *wnd = new TranslatorWindow(rect, title); - view->ResizeTo(rect.Width(), rect.Height()); wnd->AddChild(view); BPoint wndpt = B_ORIGIN; { diff --git a/src/add-ons/translators/shared/TranslatorWindow.h b/src/add-ons/translators/shared/TranslatorWindow.h index fb299bacbf..58025095b7 100644 --- a/src/add-ons/translators/shared/TranslatorWindow.h +++ b/src/add-ons/translators/shared/TranslatorWindow.h @@ -48,7 +48,8 @@ public: }; status_t -LaunchTranslatorWindow(BTranslator *translator, const char *title, BRect rect); +LaunchTranslatorWindow(BTranslator *translator, const char *title, + BRect rect = BRect(0, 0, 1, 1)); #endif // #ifndef TRANSLATORWINDOW_H diff --git a/src/add-ons/translators/tga/TGAMain.cpp b/src/add-ons/translators/tga/TGAMain.cpp index 8e7015e418..910faa9f64 100644 --- a/src/add-ons/translators/tga/TGAMain.cpp +++ b/src/add-ons/translators/tga/TGAMain.cpp @@ -49,8 +49,7 @@ main() { BApplication app("application/x-vnd.Haiku-TGATranslator"); status_t result; - result = LaunchTranslatorWindow(new TGATranslator, - "TGA Settings", BRect(0, 0, 225, 175)); + result = LaunchTranslatorWindow(new TGATranslator, "TGA Settings"); if (result == B_OK) { app.Run(); return 0; diff --git a/src/add-ons/translators/tga/TGATranslator.cpp b/src/add-ons/translators/tga/TGATranslator.cpp index 06568d264d..3acb7266a2 100644 --- a/src/add-ons/translators/tga/TGATranslator.cpp +++ b/src/add-ons/translators/tga/TGATranslator.cpp @@ -2188,7 +2188,6 @@ TGATranslator::DerivedTranslate(BPositionIO *inSource, BView * TGATranslator::NewConfigView(TranslatorSettings *settings) { - return new TGAView(BRect(0, 0, 225, 175), "TGATranslator Settings", - B_FOLLOW_ALL, B_WILL_DRAW, settings); + return new TGAView("TGATranslator Settings", B_WILL_DRAW, settings); } diff --git a/src/add-ons/translators/tga/TGAView.cpp b/src/add-ons/translators/tga/TGAView.cpp index 66a5a90f36..de7fbb3ea0 100644 --- a/src/add-ons/translators/tga/TGAView.cpp +++ b/src/add-ons/translators/tga/TGAView.cpp @@ -1,6 +1,7 @@ /*****************************************************************************/ // TGAView // Written by Michael Wilber, OBOS Translation Kit Team +// Use of Layout API added by Maxime Simon, maxime.simon@gmail.com, 2009. // // TGAView.cpp // @@ -28,6 +29,10 @@ // DEALINGS IN THE SOFTWARE. /*****************************************************************************/ +#include +#include +#include + #include #include @@ -36,32 +41,57 @@ #include "TGATranslator.h" -TGAView::TGAView(const BRect& frame, const char* name, uint32 resize, - uint32 flags, TranslatorSettings* settings) +TGAView::TGAView(const char *name, uint32 flags, TranslatorSettings *settings) : - BView(frame, name, resize, flags), + BView(name, flags), fSettings(settings) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetLowColor(ViewColor()); - fpchkIgnoreAlpha = new BCheckBox(BRect(10, 45, 180, 62), - "Ignore TGA alpha channel", "Ignore TGA alpha channel", + fTitle = new BStringView("title", "TGA Image Translator"); + fTitle->SetFont(be_bold_font); + + char detail[100]; + sprintf(detail, "Version %d.%d.%d %s", + static_cast(B_TRANSLATION_MAJOR_VERSION(TGA_TRANSLATOR_VERSION)), + static_cast(B_TRANSLATION_MINOR_VERSION(TGA_TRANSLATOR_VERSION)), + static_cast(B_TRANSLATION_REVISION_VERSION(TGA_TRANSLATOR_VERSION)), + __DATE__); + fDetail = new BStringView("detail", detail); + fWrittenBy = new BStringView("writtenby", + "Written by the Haiku Translation Kit Team"); + + fpchkIgnoreAlpha = new BCheckBox("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()); - AddChild(fpchkIgnoreAlpha); - fpchkIgnoreAlpha->ResizeToPreferred(); - - fpchkRLE = new BCheckBox(BRect(10, 67, 180, 84), - "Save with RLE compression", "Save with RLE compression", + int32 val = (fSettings->SetGetBool(TGA_SETTING_IGNORE_ALPHA)) ? 1 : 0; + fpchkIgnoreAlpha->SetValue(val); + fpchkIgnoreAlpha->SetViewColor(ViewColor()); + + fpchkRLE = new BCheckBox("Save with RLE Compression", new BMessage(CHANGE_RLE)); - val = (fSettings->SetGetBool(TGA_SETTING_RLE)) ? 1 : 0; - fpchkRLE->SetValue(val); - fpchkRLE->SetViewColor(ViewColor()); - AddChild(fpchkRLE); - fpchkRLE->ResizeToPreferred(); + 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)); } @@ -103,33 +133,3 @@ TGAView::MessageReceived(BMessage* message) } } - -void -TGAView::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; - - DrawString("TGA image translator", 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(B_TRANSLATION_MAJOR_VERSION(TGA_TRANSLATOR_VERSION)), - static_cast(B_TRANSLATION_MINOR_VERSION(TGA_TRANSLATOR_VERSION)), - static_cast(B_TRANSLATION_REVISION_VERSION(TGA_TRANSLATOR_VERSION)), - __DATE__); - DrawString(detail, BPoint(xbold, yplain + ybold)); - - DrawString("Written by the Haiku Translation Kit team", - BPoint(xbold, yplain * 7 + ybold)); -} diff --git a/src/add-ons/translators/tga/TGAView.h b/src/add-ons/translators/tga/TGAView.h index 0f23e47e7f..a27e6551e8 100644 --- a/src/add-ons/translators/tga/TGAView.h +++ b/src/add-ons/translators/tga/TGAView.h @@ -33,12 +33,12 @@ #include #include +#include #include "TranslatorSettings.h" class TGAView : public BView { public: - TGAView(const BRect &frame, const char *name, uint32 resize, - uint32 flags, TranslatorSettings *settings); + TGAView(const char *name, uint32 flags, TranslatorSettings *settings); // sets up the view ~TGAView(); @@ -46,12 +46,12 @@ public: virtual void AllAttached(); virtual void MessageReceived(BMessage *message); - - virtual void Draw(BRect area); - // draws information about the TGATranslator enum { CHANGE_RLE, CHANGE_IGNORE_ALPHA }; private: + BStringView *fTitle; + BStringView *fDetail; + BStringView *fWrittenBy; BCheckBox *fpchkIgnoreAlpha; BCheckBox *fpchkRLE; diff --git a/src/add-ons/translators/tiff/TIFFMain.cpp b/src/add-ons/translators/tiff/TIFFMain.cpp index 94776e3754..1298e5ca3a 100644 --- a/src/add-ons/translators/tiff/TIFFMain.cpp +++ b/src/add-ons/translators/tiff/TIFFMain.cpp @@ -54,8 +54,7 @@ main() { BApplication app("application/x-vnd.Haiku-TIFFTranslator"); status_t result; - result = LaunchTranslatorWindow(new TIFFTranslator, - "TIFF Settings", BRect(0, 0, 225, 175)); + result = LaunchTranslatorWindow(new TIFFTranslator, "TIFF Settings"); if (result == B_OK) { app.Run(); return 0; diff --git a/src/add-ons/translators/tiff/TIFFTranslator.cpp b/src/add-ons/translators/tiff/TIFFTranslator.cpp index d7207190da..ad2adfc3bb 100644 --- a/src/add-ons/translators/tiff/TIFFTranslator.cpp +++ b/src/add-ons/translators/tiff/TIFFTranslator.cpp @@ -945,6 +945,5 @@ TIFFTranslator::DerivedTranslate(BPositionIO *inSource, BView * TIFFTranslator::NewConfigView(TranslatorSettings *settings) { - return new TIFFView(BRect(0, 0, 225, 175), "TIFFTranslator Settings", - B_FOLLOW_ALL, B_WILL_DRAW, settings); + return new TIFFView("TIFFTranslator Settings", B_WILL_DRAW, settings); } diff --git a/src/add-ons/translators/tiff/TIFFView.cpp b/src/add-ons/translators/tiff/TIFFView.cpp index 25c381cf6a..5642487c7c 100644 --- a/src/add-ons/translators/tiff/TIFFView.cpp +++ b/src/add-ons/translators/tiff/TIFFView.cpp @@ -2,6 +2,7 @@ // TIFFView // Written by Michael Wilber, OBOS Translation Kit Team // Picking the compression method added by Stephan Aßmus, +// Use of Layout API added by Maxime Simon, maxime.simon@gmail.com, 2009. // // TIFFView.cpp // @@ -32,6 +33,9 @@ #include #include +#include +#include +#include #include #include #include @@ -73,15 +77,35 @@ add_menu_item(BMenu* menu, // // Returns: // --------------------------------------------------------------- -TIFFView::TIFFView(const BRect &frame, const char *name, - uint32 resize, uint32 flags, TranslatorSettings *settings) - : BView(frame, name, resize, flags) +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(B_TRANSLATION_MAJOR_VERSION(TIFF_TRANSLATOR_VERSION)), + static_cast(B_TRANSLATION_MINOR_VERSION(TIFF_TRANSLATOR_VERSION)), + static_cast(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); @@ -98,13 +122,31 @@ TIFFView::TIFFView(const BRect &frame, const char *name, // TODO ? - strip encoding is not implemented in libTIFF for this compression // add_menu_item(menu, COMPRESSION_JP2000, "JPEG2000", currentCompression); - fCompressionMF = new BMenuField(BRect(20, 50, 215, 70), "compression", - "Use compression:", menu, true); - fCompressionMF->ResizeToPreferred(); - fCompressionMF->SetDivider( - fCompressionMF->StringWidth(fCompressionMF->Label()) + 7); - AddChild(fCompressionMF); - + 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)); } // --------------------------------------------------------------- @@ -148,7 +190,6 @@ TIFFView::MessageReceived(BMessage* message) fSettings->SetGetInt32(TIFF_SETTING_COMPRESSION, &value); fSettings->SaveSettings(); } - fCompressionMF->ResizeToPreferred(); break; } default: @@ -178,55 +219,3 @@ TIFFView::AllAttached() } -// --------------------------------------------------------------- -// Draw -// -// Draws information about the TIFFTranslator to this view. -// -// Preconditions: -// -// Parameters: area, not used -// -// Postconditions: -// -// Returns: -// --------------------------------------------------------------- -void -TIFFView::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; - - char title[] = "TIFF image translator"; - DrawString(title, 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(B_TRANSLATION_MAJOR_VERSION(TIFF_TRANSLATOR_VERSION)), - static_cast(B_TRANSLATION_MINOR_VERSION(TIFF_TRANSLATOR_VERSION)), - static_cast(B_TRANSLATION_REVISION_VERSION(TIFF_TRANSLATOR_VERSION)), - __DATE__); - DrawString(detail, BPoint(xbold, yplain + ybold)); - - int32 lineno = 6; - DrawString("TIFF library:", BPoint(xbold, yplain * lineno + ybold)); - lineno += 2; - - char libtiff[] = TIFFLIB_VERSION_STR; - char *tok = strtok(libtiff, "\n"); - while (tok) { - DrawString(tok, BPoint(xbold, yplain * lineno + ybold)); - lineno++; - tok = strtok(NULL, "\n"); - } -} diff --git a/src/add-ons/translators/tiff/TIFFView.h b/src/add-ons/translators/tiff/TIFFView.h index 1894add138..51e2c428aa 100644 --- a/src/add-ons/translators/tiff/TIFFView.h +++ b/src/add-ons/translators/tiff/TIFFView.h @@ -34,12 +34,12 @@ #include #include +#include #include "TranslatorSettings.h" class TIFFView : public BView { public: - TIFFView(const BRect &frame, const char *name, uint32 resize, - uint32 flags, TranslatorSettings *settings); + TIFFView(const char *name, uint32 flags, TranslatorSettings *settings); // sets up the view ~TIFFView(); @@ -48,14 +48,14 @@ public: virtual void AllAttached(); virtual void MessageReceived(BMessage *message); - virtual void Draw(BRect area); - // draws information about the TIFFTranslator - enum { MSG_COMPRESSION_CHANGED = 'cmch', }; private: + BStringView* fTitle; + BStringView* fDetail; + BStringView* fLibTIFF[5]; BMenuField* fCompressionMF; TranslatorSettings *fSettings;