xref: /haiku/src/add-ons/translators/stxt/STXTView.cpp (revision 4f00613311d0bd6b70fa82ce19931c41f071ea4e)
1 /*****************************************************************************/
2 // STXTView
3 // Written by Michael Wilber, OBOS Translation Kit Team
4 //
5 // STXTView.cpp
6 //
7 // This BView based object displays information about the STXTTranslator.
8 //
9 //
10 // Copyright (c) 2002 OpenBeOS Project
11 //
12 // Permission is hereby granted, free of charge, to any person obtaining a
13 // copy of this software and associated documentation files (the "Software"),
14 // to deal in the Software without restriction, including without limitation
15 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 // and/or sell copies of the Software, and to permit persons to whom the
17 // Software is furnished to do so, subject to the following conditions:
18 //
19 // The above copyright notice and this permission notice shall be included
20 // in all copies or substantial portions of the Software.
21 //
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28 // DEALINGS IN THE SOFTWARE.
29 /*****************************************************************************/
30 
31 #include <stdio.h>
32 #include <string.h>
33 #include "STXTView.h"
34 #include "STXTTranslator.h"
35 
36 // ---------------------------------------------------------------
37 // Constructor
38 //
39 // Sets up the view settings
40 //
41 // Preconditions:
42 //
43 // Parameters:
44 //
45 // Postconditions:
46 //
47 // Returns:
48 // ---------------------------------------------------------------
49 STXTView::STXTView(const BRect &frame, const char *name,
50 	uint32 resize, uint32 flags, TranslatorSettings *settings)
51 	:	BView(frame, name, resize, flags)
52 {
53 	fSettings = settings;
54 
55 	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
56 }
57 
58 // ---------------------------------------------------------------
59 // Destructor
60 //
61 // Does nothing
62 //
63 // Preconditions:
64 //
65 // Parameters:
66 //
67 // Postconditions:
68 //
69 // Returns:
70 // ---------------------------------------------------------------
71 STXTView::~STXTView()
72 {
73 	fSettings->Release();
74 }
75 
76 // ---------------------------------------------------------------
77 // Draw
78 //
79 // Draws information about the STXTTranslator to this view.
80 //
81 // Preconditions:
82 //
83 // Parameters: area,	not used
84 //
85 // Postconditions:
86 //
87 // Returns:
88 // ---------------------------------------------------------------
89 void
90 STXTView::Draw(BRect area)
91 {
92 	SetFont(be_bold_font);
93 	font_height fh;
94 	GetFontHeight(&fh);
95 	float xbold, ybold;
96 	xbold = fh.descent + 1;
97 	ybold = fh.ascent + fh.descent * 2 + fh.leading;
98 
99 	char title[] = "OpenBeOS StyledEdit Files Translator";
100 	DrawString(title, BPoint(xbold, ybold));
101 
102 	SetFont(be_plain_font);
103 	font_height plainh;
104 	GetFontHeight(&plainh);
105 	float yplain;
106 	yplain = plainh.ascent + plainh.descent * 2 + plainh.leading;
107 
108 	char detail[100];
109 	sprintf(detail, "Version %d.%d.%d %s",
110 		static_cast<int>(B_TRANSLATION_MAJOR_VERSION(STXT_TRANSLATOR_VERSION)),
111 		static_cast<int>(B_TRANSLATION_MINOR_VERSION(STXT_TRANSLATOR_VERSION)),
112 		static_cast<int>(B_TRANSLATION_REVISION_VERSION(STXT_TRANSLATOR_VERSION)),
113 		__DATE__);
114 	DrawString(detail, BPoint(xbold, yplain + ybold));
115 /*	char copyright[] = "© 2002 OpenBeOS Project";
116 	DrawString(copyright, BPoint(xbold, yplain * 2 + ybold));
117 */
118 	char writtenby[] = "Written by the OBOS Translation Kit Team";
119 	DrawString(writtenby, BPoint(xbold, yplain * 7 + ybold));
120 }
121