Repository navigation
Expand file tree
/
Copy pathReplWindow.cpp
More file actions
110 lines (90 loc) · 2.32 KB
/
Copy pathReplWindow.cpp
File metadata and controls
110 lines (90 loc) · 2.32 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
109
110
/*
* Copyright 2016. All rights reserved.
* Distributed under the terms of the MIT license.
*
* Author:
* Humdinger, [email protected]
*/
#include <stdio.h>
#include <Catalog.h>
#include <ControlLook.h>
#include <LayoutBuilder.h>
#include <SeparatorView.h>
#include <Size.h>
#include <TextView.h>
#include "Constants.h"
#include "ReplWindow.h"
#include "ReplView.h"
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "ReplWindow"
ReplWindow::ReplWindow(BRect frame)
:
BWindow(BRect(0, 0, 350, 100), B_TRANSLATE("Clipboard monitor"),
B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS |
B_CLOSE_ON_ESCAPE, B_ALL_WORKSPACES)
{
_BuildLayout();
frame.OffsetBy(40.0, 90.0);
MoveTo(frame.LeftTop());
}
ReplWindow::~ReplWindow()
{
}
void
ReplWindow::FrameResized(float width, float height)
{
fClipMonitorView->TruncateClip(width);
BWindow::FrameResized(width, height);
}
void
ReplWindow::MessageReceived(BMessage* message)
{
switch (message->what)
{
default:
{
BWindow::MessageReceived(message);
break;
}
}
}
bool
ReplWindow::QuitRequested()
{
if (!IsHidden())
Hide();
return false;
}
void
ReplWindow::_BuildLayout()
{
// Clipboard contents view
fClipMonitorView = new ReplView();
// Text
BFont infoFont(*be_plain_font);
infoFont.SetFace(B_ITALIC_FACE);
rgb_color infoColor = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
B_DARKEN_4_TINT);
BTextView* welcomeText = new BTextView("text", &infoFont, &infoColor,
B_WILL_DRAW | B_SUPPORTS_LAYOUT);
welcomeText->MakeEditable(false);
welcomeText->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
welcomeText->SetStylable(true);
welcomeText->SetAlignment(B_ALIGN_CENTER);
welcomeText->SetText(B_TRANSLATE(
"Resize the window to your needs and drag the replicant handle "
"onto the Desktop.\nTry dropping a color e.g. from Icon-O-Matic."));
font_height fheight;
infoFont.GetHeight(&fheight);
welcomeText->SetExplicitMinSize(BSize(B_SIZE_UNSET,
(fheight.ascent + fheight.descent + fheight.leading) * 3.0));
welcomeText->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
static const float spacing = be_control_look->DefaultItemSpacing();
BLayoutBuilder::Group<>(this, B_VERTICAL, spacing)
.SetInsets(spacing)
.Add(fClipMonitorView)
.Add(new BSeparatorView(B_HORIZONTAL))
.Add(welcomeText)
.AddGlue(10)
.End();
}