-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJSEUIButton.cpp
More file actions
190 lines (133 loc) · 5.13 KB
/
JSEUIButton.cpp
File metadata and controls
190 lines (133 loc) · 5.13 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#include "JSE.h"
#include "JSEUIButton.h"
using namespace v8;
namespace JSE { namespace UI {
void JSEUIButton::SetMethods(Isolate *&isolate, Handle<FunctionTemplate> &tpl)
{
tpl->SetClassName(String::NewFromUtf8(isolate, "Button"));
JSE_SET_PROTOTYPE_METHOD(tpl, "click", Proto_click);
JSE_UI_SET_ACCESSOR(tpl, "left", Get_left, Set_left);
JSE_UI_SET_ACCESSOR(tpl, "top", Get_top, Set_top);
JSE_UI_SET_ACCESSOR(tpl, "width", Get_width, Set_width);
JSE_UI_SET_ACCESSOR(tpl, "height", Get_height, Set_height);
JSE_UI_SET_ACCESSOR(tpl, "visible", Get_visible, Set_visible);
JSE_UI_SET_ACCESSOR(tpl, "text", Get_text, Set_text);
}
void JSEUIButton::SetEvents(JSEUIButton *self, JSEUIButtonImpl *selfImpl)
{
JSE_UI_SET_EVENTS(self, On_click(), selfImpl, clicked());
}
void JSEUIButton::Proto_click(const v8::FunctionCallbackInfo<v8::Value> &info)
{
Isolate *isolate = Isolate::GetCurrent();
HandleScope scope(isolate);
JSEUIButtonImpl *buttonImpl = GetImpl(info);
buttonImpl->Click();
info.GetReturnValue().Set(Boolean::New(isolate, true));
}
void JSEUIButton::Set_left(Local<String> prop, Local<Value> value, const PropertyCallbackInfo<void> &info)
{
Isolate *isolate = Isolate::GetCurrent();
HandleScope scope(isolate);
JSEUIButtonImpl *buttonImpl = GetImpl(info);
int left = value->Int32Value();
buttonImpl->move(left, buttonImpl->pos().y());
info.GetReturnValue().Set(left);
}
void JSEUIButton::Get_left(Local<String> prop, const PropertyCallbackInfo<Value> &info)
{
Isolate *isolate = Isolate::GetCurrent();
HandleScope scope(isolate);
JSEUIButtonImpl *buttonImpl = GetImpl(info);
info.GetReturnValue().Set(Integer::New(isolate, buttonImpl->pos().x()));
}
void JSEUIButton::Set_top(Local<String> prop, Local<Value> value, const PropertyCallbackInfo<void> &info)
{
Isolate *isolate = Isolate::GetCurrent();
HandleScope scope(isolate);
JSEUIButtonImpl *buttonImpl = GetImpl(info);
int top = value->Int32Value();
buttonImpl->move(buttonImpl->pos().x(), top);
info.GetReturnValue().Set(top);
}
void JSEUIButton::Get_top(Local<String> prop, const PropertyCallbackInfo<Value> &info)
{
Isolate *isolate = Isolate::GetCurrent();
HandleScope scope(isolate);
JSEUIButtonImpl *buttonImpl = GetImpl(info);
info.GetReturnValue().Set(Integer::New(isolate, buttonImpl->pos().y()));
}
void JSEUIButton::Set_width(Local<String> prop, Local<Value> value, const PropertyCallbackInfo<void> &info)
{
Isolate *isolate = Isolate::GetCurrent();
HandleScope scope(isolate);
JSEUIButtonImpl *buttonImpl = GetImpl(info);
int width = value->Int32Value();
buttonImpl->resize(width, buttonImpl->size().height());
}
void JSEUIButton::Get_width(Local<String> prop, const PropertyCallbackInfo<Value> &info)
{
Isolate *isolate = Isolate::GetCurrent();
HandleScope scope(isolate);
JSEUIButtonImpl *buttonImpl = GetImpl(info);
info.GetReturnValue().Set(Integer::New(isolate, buttonImpl->size().width()));
}
void JSEUIButton::Set_height(Local<String> prop, Local<Value> value, const PropertyCallbackInfo<void> &info)
{
Isolate *isolate = Isolate::GetCurrent();
HandleScope scope(isolate);
JSEUIButtonImpl *buttonImpl = GetImpl(info);
int height = value->Int32Value();
buttonImpl->resize(buttonImpl->size().width(), height);
}
void JSEUIButton::Get_height(Local<String> prop, const PropertyCallbackInfo<Value> &info)
{
Isolate *isolate = Isolate::GetCurrent();
HandleScope scope(isolate);
JSEUIButtonImpl *buttonImpl = GetImpl(info);
info.GetReturnValue().Set(Integer::New(isolate, buttonImpl->size().height()));
}
void JSEUIButton::Set_visible(Local<String> prop, Local<Value> value, const PropertyCallbackInfo<void> &info)
{
Isolate *isolate = Isolate::GetCurrent();
HandleScope scope(isolate);
JSEUIButtonImpl *buttonImpl = GetImpl(info);
bool visible = value->BooleanValue();
if (visible)
{
buttonImpl->show();
}
else
{
buttonImpl->hide();
}
}
void JSEUIButton::Get_visible(Local<String> prop, const PropertyCallbackInfo<Value> &info)
{
Isolate *isolate = Isolate::GetCurrent();
HandleScope scope(isolate);
JSEUIButtonImpl *buttonImpl = GetImpl(info);
info.GetReturnValue().Set(Boolean::New(isolate, buttonImpl->isVisible()));
}
void JSEUIButton::Set_text(Local<String> prop, Local<Value> value, const PropertyCallbackInfo<void> &info)
{
Isolate *isolate = Isolate::GetCurrent();
HandleScope scope(isolate);
JSEUIButtonImpl *buttonImpl = GetImpl(info);
buttonImpl->setText(*String::Utf8Value(value->ToString()));
}
void JSEUIButton::Get_text(Local<String> prop, const PropertyCallbackInfo<Value> &info)
{
Isolate *isolate = Isolate::GetCurrent();
HandleScope scope(isolate);
JSEUIButtonImpl *buttonImpl = GetImpl(info);
info.GetReturnValue().Set(String::NewFromUtf8(isolate, buttonImpl->text().toLocal8Bit().constData()));
}
void JSEUIButton::On_click(void)
{
v8::Isolate *isolate = Isolate::GetCurrent();
Locker locker(isolate);
HandleScope scope(isolate);
Invoke(this, "click", 0, nullptr);
}
}}