forked from leavengood/Haiku-Browser
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProxyView.cpp
More file actions
108 lines (84 loc) · 2.31 KB
/
ProxyView.cpp
File metadata and controls
108 lines (84 loc) · 2.31 KB
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
108
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright 2009, Ryan Leavengood, leavengood@gmail.com
// All rights reserved.
//
// Distributed under the terms of the MIT License.
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include "ProxyView.h"
#include "BitmapHelper.h"
#include "BrowserIcons.h"
#include "Constants.h"
#include "Tranquility.h"
#include <syslog.h>
ProxyView::ProxyView(BRect frame, const char *name)
: BView(frame, name, B_FOLLOW_ALL_SIDES, B_WILL_DRAW|B_FRAME_EVENTS)
{
BMessage requestRenderApp(kMsgRequestRenderApp);
requestRenderApp.AddPointer("proxyView", (void *)this);
be_app->PostMessage(&requestRenderApp);
}
ProxyView::~ProxyView()
{
BMessage leaveRenderApp(kMsgLeaveRenderApp);
leaveRenderApp.AddInt32("proxyID", fID);
be_app->PostMessage(&leaveRenderApp);
}
void
ProxyView::Draw(BRect updateRect)
{
}
void
ProxyView::FrameResized(float width, float height)
{
}
void
ProxyView::MouseDown(BPoint point)
{
syslog(LOG_DEBUG, "Tranquility, ProxyView: received mouse down message, forwarding it to be_app");
_ForwardCurrentMessage();
}
void
ProxyView::MouseMoved(BPoint point, uint32 transit, const BMessage* message)
{
syslog(LOG_DEBUG, "Tranquility, ProxyView: received mouse moved message, forwarding it to be_app");
_ForwardCurrentMessage();
}
void
ProxyView::DrawSadTab(const char *error)
{
BBitmap *sadTab = RetrieveBitmap(kSadTabBitmap, BRect(0, 0, 255, 255));
if (Window()->Lock()) {
MovePenTo(Bounds().Width() / 2 - 127, Bounds().Height() / 2 - 177);
DrawBitmap(sadTab);
MovePenTo(Bounds().Width() / 2 - 45, Bounds().Height() / 2 + 55);
BFont font;
GetFont(&font);
font.SetSize(18.0);
font.SetFace(B_BOLD_FACE);
SetFont(&font, B_FONT_SIZE | B_FONT_FACE);
SetLowColor(0, 0, 0);
SetHighColor(255, 255, 255);
DrawString("Aw, Snap!");
MovePenTo(Bounds().Width() / 2 - 90, Bounds().Height() / 2 + 70);
font.SetSize(12.0);
font.SetFace(B_REGULAR_FACE);
SetFont(&font, B_FONT_SIZE | B_FONT_FACE);
DrawString(error);
Window()->Unlock();
}
}
void
ProxyView::SetID(int32 id)
{
fID = id;
}
void
ProxyView::_ForwardCurrentMessage()
{
BMessage forward(kMsgForward);
forward.AddMessage("original", Window()->CurrentMessage());
forward.AddInt32("proxyID", fID);
be_app->PostMessage(&forward);
}