xref: /haiku/src/add-ons/translators/icns/ConfigView.cpp (revision e5d65858f2361fe0552495b61620c84dcee6bc00)
1  /*
2   * Copyright 2012, Gerasim Troeglazov, 3dEyes@gmail.com. All rights reserved.
3   * Distributed under the terms of the MIT License.
4   */
5  
6  #include "ConfigView.h"
7  #include "ICNSTranslator.h"
8  
9  #include <Catalog.h>
10  #include <StringView.h>
11  #include <SpaceLayoutItem.h>
12  #include <ControlLook.h>
13  
14  #include <stdio.h>
15  
16  #undef B_TRANSLATION_CONTEXT
17  #define B_TRANSLATION_CONTEXT "ICNSConfig"
18  
19  extern "C" {
20  #include <openjpeg.h>
21  };
22  
23  
24  ConfigView::ConfigView(TranslatorSettings *settings)
25  	: BGroupView("ICNSTranslator Settings", B_VERTICAL, 0)
26  {
27  	fSettings = settings;
28  	BAlignment leftAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET);
29  
30  	BStringView *stringView = new BStringView("title", B_TRANSLATE("Apple icon translator"));
31  	stringView->SetFont(be_bold_font);
32  	stringView->SetExplicitAlignment(leftAlignment);
33  	AddChild(stringView);
34  
35  	float spacing = be_control_look->DefaultItemSpacing();
36  	AddChild(BSpaceLayoutItem::CreateVerticalStrut(spacing));
37  
38  	char version[256];
39  	sprintf(version, B_TRANSLATE("Version %d.%d.%d, %s"),
40  		int(B_TRANSLATION_MAJOR_VERSION(ICNS_TRANSLATOR_VERSION)),
41  		int(B_TRANSLATION_MINOR_VERSION(ICNS_TRANSLATOR_VERSION)),
42  		int(B_TRANSLATION_REVISION_VERSION(ICNS_TRANSLATOR_VERSION)),
43  		__DATE__);
44  	stringView = new BStringView("version", version);
45  	stringView->SetExplicitAlignment(leftAlignment);
46  	AddChild(stringView);
47  
48  	stringView = new BStringView("copyright",
49  		B_UTF8_COPYRIGHT "2005-2006 Haiku Inc.");
50  	stringView->SetExplicitAlignment(leftAlignment);
51  	AddChild(stringView);
52  
53  	stringView = new BStringView("my_copyright",
54  		B_UTF8_COPYRIGHT "2012 Gerasim Troeglazov <3dEyes@gmail.com>.");
55  	stringView->SetExplicitAlignment(leftAlignment);
56  	AddChild(stringView);
57  
58  	AddChild(BSpaceLayoutItem::CreateVerticalStrut(spacing));
59  
60  	stringView = new BStringView("support_sizes",
61  		"Valid sizes: 16, 32, 48, 128, 256, 512, 1024");
62  	stringView->SetExplicitAlignment(leftAlignment);
63  	AddChild(stringView);
64  
65  	stringView = new BStringView("support_colors",
66  		"Valid colors: RGB32, RGBA32");
67  	stringView->SetExplicitAlignment(leftAlignment);
68  	AddChild(stringView);
69  
70  	AddChild(BSpaceLayoutItem::CreateVerticalStrut(spacing));
71  
72  	BString copyrightText;
73  	copyrightText << "libicns v0.8.1\n"
74  		<< B_UTF8_COPYRIGHT "2001-2012 Mathew Eis <mathew@eisbox.net>\n\n"
75  		<< "OpenJPEG " << opj_version() << "\n"
76  		<< B_UTF8_COPYRIGHT "2002-2012, Communications and Remote Sensing "
77  		<< "Laboratory, Universite catholique de Louvain (UCL), Belgium";
78  
79  	fCopyrightView = new BTextView("CopyrightLibs");
80  	fCopyrightView->SetExplicitAlignment(leftAlignment);
81  	fCopyrightView->MakeEditable(false);
82  	fCopyrightView->MakeResizable(true);
83  	fCopyrightView->SetWordWrap(true);
84  	fCopyrightView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
85  	fCopyrightView->SetText(copyrightText.String());
86  	fCopyrightView->SetExplicitMinSize(BSize(300,200));
87  
88  	BFont font;
89  	font.SetSize(font.Size() * 0.9);
90  	fCopyrightView->SetFontAndColor(&font, B_FONT_SIZE, NULL);
91  	AddChild(fCopyrightView);
92  
93  	fCopyrightView->SetExplicitAlignment(leftAlignment);
94  
95  	AddChild(BSpaceLayoutItem::CreateGlue());
96  	GroupLayout()->SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
97  		B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING);
98  
99  	SetExplicitPreferredSize(GroupLayout()->MinSize());
100  }
101  
102  
103  ConfigView::~ConfigView()
104  {
105  	fSettings->Release();
106  }
107  
108