xref: /haiku/src/add-ons/translators/rtf/ConfigView.cpp (revision b0944c78b074a8110bd98e060415d0e8f38a7f65)
1 /*
2  * Copyright 2004-2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 
7 #include "ConfigView.h"
8 #include "RTFTranslator.h"
9 
10 #include <Catalog.h>
11 #include <StringView.h>
12 
13 #include <stdio.h>
14 
15 #undef B_TRANSLATION_CONTEXT
16 #define B_TRANSLATION_CONTEXT "ConfigView"
17 
18 
19 ConfigView::ConfigView(const BRect &frame, uint32 resize, uint32 flags)
20 	: BView(frame, B_TRANSLATE("RTF-Translator Settings"), resize, flags)
21 {
22 	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
23 
24 	font_height fontHeight;
25 	be_bold_font->GetHeight(&fontHeight);
26 	float height = fontHeight.descent + fontHeight.ascent + fontHeight.leading;
27 
28 	BRect rect(10, 10, 200, 10 + height);
29 	BStringView *stringView = new BStringView(rect, "title",
30 		B_TRANSLATE("Rich Text Format (RTF) translator"));
31 	stringView->SetFont(be_bold_font);
32 	stringView->ResizeToPreferred();
33 	AddChild(stringView);
34 
35 	float maxWidth = stringView->Bounds().Width();
36 
37 	rect.OffsetBy(0, height + 10);
38 	char version[256];
39 	snprintf(version, sizeof(version), B_TRANSLATE("Version %d.%d.%d, %s"),
40 		static_cast<int>(B_TRANSLATION_MAJOR_VERSION(RTF_TRANSLATOR_VERSION)),
41 		static_cast<int>(B_TRANSLATION_MINOR_VERSION(RTF_TRANSLATOR_VERSION)),
42 		static_cast<int>(B_TRANSLATION_REVISION_VERSION(
43 			RTF_TRANSLATOR_VERSION)), __DATE__);
44 	stringView = new BStringView(rect, "version", version);
45 	stringView->ResizeToPreferred();
46 	AddChild(stringView);
47 
48 	if (stringView->Bounds().Width() > maxWidth)
49 		maxWidth = stringView->Bounds().Width();
50 
51 	GetFontHeight(&fontHeight);
52 	height = fontHeight.descent + fontHeight.ascent + fontHeight.leading;
53 
54 	rect.OffsetBy(0, height + 5);
55 	stringView = new BStringView(rect,
56 		"Copyright", B_UTF8_COPYRIGHT "2004-2006 Haiku Inc.");
57 	stringView->ResizeToPreferred();
58 	AddChild(stringView);
59 
60 	if (maxWidth + 20 > Bounds().Width())
61 		ResizeTo(maxWidth + 20, Bounds().Height());
62 }
63 
64 
65 ConfigView::~ConfigView()
66 {
67 }
68 
69