forked from nodegui/nodegui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqframe_wrap.cpp
More file actions
40 lines (33 loc) · 1.33 KB
/
qframe_wrap.cpp
File metadata and controls
40 lines (33 loc) · 1.33 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
#include "QtWidgets/QFrame/qframe_wrap.h"
#include "Extras/Utils/nutils.h"
Napi::FunctionReference QFrameWrap::constructor;
Napi::Object QFrameWrap::init(Napi::Env env, Napi::Object exports) {
Napi::HandleScope scope(env);
char CLASSNAME[] = "QFrame";
Napi::Function func = DefineClass(
env, CLASSNAME, {QFRAME_WRAPPED_METHODS_EXPORT_DEFINE(QFrameWrap)});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
return exports;
}
NFrame* QFrameWrap::getInternalInstance() { return this->instance; }
QFrameWrap::~QFrameWrap() { extrautils::safeDelete(this->instance); }
QFrameWrap::QFrameWrap(const Napi::CallbackInfo& info)
: Napi::ObjectWrap<QFrameWrap>(info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
if (info.Length() == 1) {
Napi::Object parentObject = info[0].As<Napi::Object>();
NodeWidgetWrap* parentWidgetWrap =
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(parentObject);
this->instance = new NFrame(parentWidgetWrap->getInternalInstance());
} else if (info.Length() == 0) {
this->instance = new NFrame();
} else {
Napi::TypeError::New(env, "Wrong number of arguments")
.ThrowAsJavaScriptException();
}
this->rawData = extrautils::configureQWidget(
this->getInternalInstance(), this->getInternalInstance()->getFlexNode(),
false);
}