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
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Copyright 2008, Jérôme Duval. All rights reserved.
|
||||
* Copyright 2005-2007, Axel Dörfler, [email protected]. All rights reserved.
|
||||
* Copyright 2009, Maxime Simon, [email protected]. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@@ -10,57 +11,63 @@
|
||||
|
||||
#include <StringView.h>
|
||||
#include <CheckBox.h>
|
||||
#include <GroupLayout.h>
|
||||
#include <GroupLayoutBuilder.h>
|
||||
#include <SpaceLayoutItem.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
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()
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
};
|
||||
|
||||
|
||||
@@ -229,7 +229,7 @@ EXRTranslator::DerivedTranslate(BPositionIO* source,
|
||||
BView *
|
||||
EXRTranslator::NewConfigView(TranslatorSettings *settings)
|
||||
{
|
||||
return new ConfigView(BRect(0, 0, 225, 175));
|
||||
return new ConfigView();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,10 +14,14 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Additional authors: Stephan Aßmus, <[email protected]>
|
||||
// Maxime Simon, <[email protected]>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <GridLayoutBuilder.h>
|
||||
#include <GroupLayout.h>
|
||||
#include <GroupLayoutBuilder.h>
|
||||
#include <InterfaceKit.h>
|
||||
#include <String.h>
|
||||
|
||||
@@ -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, [email protected]";
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
#include "GIFWindow.h"
|
||||
#include "GIFView.h"
|
||||
#include <Application.h>
|
||||
#include <GroupLayout.h>
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <Application.h>
|
||||
#include <Alert.h>
|
||||
#include <Screen.h>
|
||||
#include <GroupLayout.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -21,6 +21,11 @@
|
||||
#include <MenuItem.h>
|
||||
#include <CheckBox.h>
|
||||
#include <Bitmap.h>
|
||||
#include <StringView.h>
|
||||
#include <GridLayoutBuilder.h>
|
||||
#include <GroupLayout.h>
|
||||
#include <GroupLayoutBuilder.h>
|
||||
#include <SpaceLayoutItem.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
@@ -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<int>(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<int>(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);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright 2005-2007, Axel Dörfler, [email protected]. All rights reserved.
|
||||
* Copyright 2009, Maxime Simon, [email protected]. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@@ -9,54 +10,56 @@
|
||||
|
||||
#include <StringView.h>
|
||||
#include <CheckBox.h>
|
||||
#include <GroupLayout.h>
|
||||
#include <GroupLayoutBuilder.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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();
|
||||
};
|
||||
|
||||
|
||||
@@ -326,7 +326,7 @@ RAWTranslator::DerivedTranslate(BPositionIO* stream,
|
||||
BView *
|
||||
RAWTranslator::NewConfigView(TranslatorSettings *settings)
|
||||
{
|
||||
return new ConfigView(BRect(0, 0, 225, 175));
|
||||
return new ConfigView();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#if SHOW_MODE && TEST_MODE
|
||||
# include <Bitmap.h>
|
||||
# include <BitmapStream.h>
|
||||
# include <GroupLayout.h>
|
||||
# include <String.h>
|
||||
# include <View.h>
|
||||
# include <Window.h>
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
|
||||
#include <Screen.h>
|
||||
#include <Alert.h>
|
||||
#include <GroupLayout.h>
|
||||
#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;
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*****************************************************************************/
|
||||
// TGAView
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
// Use of Layout API added by Maxime Simon, [email protected], 2009.
|
||||
//
|
||||
// TGAView.cpp
|
||||
//
|
||||
@@ -28,6 +29,10 @@
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <GroupLayout.h>
|
||||
#include <GroupLayoutBuilder.h>
|
||||
#include <SpaceLayoutItem.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -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<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",
|
||||
"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<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__);
|
||||
DrawString(detail, BPoint(xbold, yplain + ybold));
|
||||
|
||||
DrawString("Written by the Haiku Translation Kit team",
|
||||
BPoint(xbold, yplain * 7 + ybold));
|
||||
}
|
||||
|
||||
@@ -33,12 +33,12 @@
|
||||
|
||||
#include <View.h>
|
||||
#include <CheckBox.h>
|
||||
#include <StringView.h>
|
||||
#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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// TIFFView
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
// Picking the compression method added by Stephan Aßmus, <[email protected]>
|
||||
// Use of Layout API added by Maxime Simon, [email protected], 2009.
|
||||
//
|
||||
// TIFFView.cpp
|
||||
//
|
||||
@@ -32,6 +33,9 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <GridLayoutBuilder.h>
|
||||
#include <GroupLayout.h>
|
||||
#include <GroupLayoutBuilder.h>
|
||||
#include <MenuBar.h>
|
||||
#include <MenuField.h>
|
||||
#include <MenuItem.h>
|
||||
@@ -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<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);
|
||||
@@ -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<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__);
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,12 +34,12 @@
|
||||
|
||||
#include <View.h>
|
||||
#include <MenuField.h>
|
||||
#include <StringView.h>
|
||||
#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;
|
||||
|
||||
Reference in New Issue
Block a user