1 /* 2 * Copyright 2002-2009, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT license. 4 * 5 * Authors: 6 * Michael Wilber 7 * Axel Dörfler, axeld@pinc-software.de 8 */ 9 10 /*! A view with information about the BMPTranslator. */ 11 12 13 #include "BMPView.h" 14 #include "BMPTranslator.h" 15 16 #include <Catalog.h> 17 #include <StringView.h> 18 19 #include <stdio.h> 20 21 #undef B_TRANSLATE_CONTEXT 22 #define B_TRANSLATE_CONTEXT "BMPView" 23 24 25 BMPView::BMPView(const BRect &frame, const char *name, uint32 resizeMode, 26 uint32 flags, TranslatorSettings *settings) 27 : BView(frame, name, resizeMode, flags) 28 { 29 fSettings = settings; 30 SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 31 32 font_height fontHeight; 33 be_bold_font->GetHeight(&fontHeight); 34 float height = fontHeight.descent + fontHeight.ascent + fontHeight.leading; 35 36 BRect rect(10, 10, 200, 10 + height); 37 BStringView *stringView = new BStringView(rect, "title", 38 B_TRANSLATE("BMP image translator")); 39 stringView->SetFont(be_bold_font); 40 stringView->ResizeToPreferred(); 41 AddChild(stringView); 42 43 float maxWidth = stringView->Bounds().Width(); 44 45 rect.OffsetBy(0, height + 10); 46 char version[256]; 47 snprintf(version, sizeof(version), B_TRANSLATE("Version %d.%d.%d, %s"), 48 int(B_TRANSLATION_MAJOR_VERSION(BMP_TRANSLATOR_VERSION)), 49 int(B_TRANSLATION_MINOR_VERSION(BMP_TRANSLATOR_VERSION)), 50 int(B_TRANSLATION_REVISION_VERSION(BMP_TRANSLATOR_VERSION)), 51 __DATE__); 52 stringView = new BStringView(rect, "version", version); 53 stringView->ResizeToPreferred(); 54 AddChild(stringView); 55 56 if (stringView->Bounds().Width() > maxWidth) 57 maxWidth = stringView->Bounds().Width(); 58 59 GetFontHeight(&fontHeight); 60 height = fontHeight.descent + fontHeight.ascent + fontHeight.leading; 61 62 rect.OffsetBy(0, height + 5); 63 stringView = new BStringView(rect, "Copyright", B_UTF8_COPYRIGHT "2002-2010 Haiku Inc."); 64 stringView->ResizeToPreferred(); 65 AddChild(stringView); 66 67 if (maxWidth + 20 > Bounds().Width()) 68 ResizeTo(maxWidth + 20, Bounds().Height()); 69 } 70 71 72 BMPView::~BMPView() 73 { 74 fSettings->Release(); 75 } 76 77