-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathDeskNoteTextView.cpp
83 lines (69 loc) · 1.72 KB
/
DeskNoteTextView.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
/*
* Original copyright 2000 by Colin Stewart (http://www.owlfish.com/).
* All rights reserved.
* Distributed under the terms of the BSD (3-clause) License.
*
* Authors:
* Janus2, 2015
* Humdinger, 2021
*
*/
#include "DeskNoteTextView.h"
DeskNoteTextView::DeskNoteTextView(BRect textViewRect, const char* name,
BRect textRect, uint32 resizingMode, uint32 flags)
:
BTextView(textViewRect, name, textRect, resizingMode, flags)
{
strId << real_time_clock_usecs();
}
DeskNoteTextView::DeskNoteTextView(BMessage* data)
:
BTextView(data)
{
data->FindString("strId", &strId);
}
status_t
DeskNoteTextView::Archive(BMessage* data, bool deep) const
{
BTextView::Archive(data, deep);
data->AddString("class", "DeskNoteTextView");
data->AddString("add_on", app_signature);
data->AddString("strId", strId);
return B_NO_ERROR;
}
void
DeskNoteTextView::MessageReceived(BMessage* msg)
{
if (msg->WasDropped()) {
rgb_color* color;
ssize_t size;
if (msg->FindData("RGBColor", B_RGB_COLOR_TYPE,
(const void **)&color, &size) == B_OK) {
BMessenger messenger(Parent());
BMessage message(DN_COLOR);
message.AddData("color", B_RGB_COLOR_TYPE, color, sizeof(rgb_color));
messenger.SendMessage(&message);
return;
}
}
BTextView::MessageReceived(msg);
}
void
DeskNoteTextView::MouseDown(BPoint point)
{
if (!Window()->IsActive())
Window()->Activate(true);
BPoint mousePoint;
uint32 mouseButtons;
GetMouse(&mousePoint, &mouseButtons, false);
if (mouseButtons != B_SECONDARY_MOUSE_BUTTON)
BTextView::MouseDown(point);
Parent()->MouseDown(point);
}
BArchivable*
DeskNoteTextView::Instantiate(BMessage* data)
{
if (!validate_instantiation(data, "DeskNoteTextView"))
return NULL;
return new DeskNoteTextView(data);
}