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