-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathAboutWindow.cpp
107 lines (90 loc) · 2.23 KB
/
AboutWindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
* Copyright 2009-2012 Scott McCreary
* Based on BeVexed by DarkWyrm Copyright 2007-2009
*
* Distributed under terms of the MIT License.
*
*/
#include <Application.h>
#include <AppFileInfo.h>
#include <Roster.h>
#include <String.h>
#include <stdio.h>
#include <Screen.h>
#include <TranslationUtils.h>
#include "AboutWindow.h"
// In case I want to localize this later
#define TRANSLATE(x) x
AboutWindow::AboutWindow(void)
: BWindow(BRect(100,100,500,400),"HexVexed", B_MODAL_WINDOW_LOOK,
B_MODAL_APP_WINDOW_FEEL,
B_NOT_ZOOMABLE | B_NOT_RESIZABLE)
{
BScreen screen;
BRect screenrect(screen.Frame());
AboutView *aboutview=new AboutView(Bounds());
AddChild(aboutview);
MoveTo( (screenrect.Width()-Frame().Width())/2, (screenrect.Height()-Frame().Height())/2 );
}
AboutView::AboutView(BRect frame)
: BView (frame, "AboutView", B_FOLLOW_ALL, B_WILL_DRAW)
{
SetViewColor(126,126,190);
fLogo=BTranslationUtils::GetBitmap('PNG ',"HexVexedAbout.png");
app_info ai;
version_info vi;
be_app->GetAppInfo(&ai);
BFile file(&ai.ref,B_READ_ONLY);
BAppFileInfo appinfo(&file);
appinfo.GetVersionInfo(&vi,B_APP_VERSION_KIND);
BString variety;
switch(vi.variety)
{
case 0:
variety=TRANSLATE("d");
break;
case 1:
variety=TRANSLATE("a");
break;
case 2:
variety=TRANSLATE("b");
break;
case 3:
variety=TRANSLATE("g");
break;
case 4:
variety=TRANSLATE("rc");
break;
default:
variety=TRANSLATE("Final");
break;
}
if(variety!="Final")
sprintf(version,"%s %lu.%lu %s%lu",TRANSLATE("v"),vi.major,
vi.middle,variety.String(),vi.internal);
else
sprintf(version,"%s %lu.%lu",TRANSLATE("v"),vi.major,vi.middle);
font_height height;
be_plain_font->GetHeight(&height);
versionpos.y=height.ascent+height.descent+height.leading+5;
versionpos.x=fLogo->Bounds().right - 5 - StringWidth(version);
SetDrawingMode(B_OP_OVER);
}
AboutView::~AboutView(void)
{
delete fLogo;
}
void AboutView::MouseDown(BPoint pt)
{
Window()->PostMessage(B_QUIT_REQUESTED);
}
void AboutView::AttachedToWindow(void)
{
Window()->ResizeTo(fLogo->Bounds().Width(),fLogo->Bounds().Height());
}
void AboutView::Draw(BRect update)
{
DrawBitmap(fLogo, BPoint(0,0));
// SetHighColor(224,224,224);
// DrawString(version,versionpos);
}