xref: /haiku/src/add-ons/translators/rtf/ConfigView.cpp (revision 9760dcae2038d47442f4658c2575844c6cf92c40)
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 <StringView.h>
11 
12 #include <stdio.h>
13 
14 
15 ConfigView::ConfigView(const BRect &frame, uint32 resize, uint32 flags)
16 	: BView(frame, "RTF-Translator Settings", resize, flags)
17 {
18 	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
19 
20 	font_height fontHeight;
21 	be_bold_font->GetHeight(&fontHeight);
22 	float height = fontHeight.descent + fontHeight.ascent + fontHeight.leading;
23 
24 	BRect rect(10, 10, 200, 10 + height);
25 	BStringView *stringView = new BStringView(rect, "title", "Rich Text Format (RTF) files");
26 	stringView->SetFont(be_bold_font);
27 	stringView->ResizeToPreferred();
28 	AddChild(stringView);
29 
30 	float maxWidth = stringView->Bounds().Width();
31 
32 	rect.OffsetBy(0, height + 10);
33 	char version[256];
34 	snprintf(version, sizeof(version), "Version %d.%d.%d, %s",
35 		int(B_TRANSLATION_MAJOR_VERSION(RTF_TRANSLATOR_VERSION)),
36 		int(B_TRANSLATION_MINOR_VERSION(RTF_TRANSLATOR_VERSION)),
37 		int(B_TRANSLATION_REVISION_VERSION(RTF_TRANSLATOR_VERSION)),
38 		__DATE__);
39 	stringView = new BStringView(rect, "version", version);
40 	stringView->ResizeToPreferred();
41 	AddChild(stringView);
42 
43 	if (stringView->Bounds().Width() > maxWidth)
44 		maxWidth = stringView->Bounds().Width();
45 
46 	GetFontHeight(&fontHeight);
47 	height = fontHeight.descent + fontHeight.ascent + fontHeight.leading;
48 
49 	rect.OffsetBy(0, height + 5);
50 	stringView = new BStringView(rect, "Copyright", B_UTF8_COPYRIGHT "2004-2006 Haiku Inc.");
51 	stringView->ResizeToPreferred();
52 	AddChild(stringView);
53 
54 	if (maxWidth + 20 > Bounds().Width())
55 		ResizeTo(maxWidth + 20, Bounds().Height());
56 }
57 
58 
59 ConfigView::~ConfigView()
60 {
61 }
62 
63