53 lines
1.7 KiB
C++
53 lines
1.7 KiB
C++
|
|
#include "QtWidgets/QDial/qdial_wrap.h"
|
|
|
|
#include <QWidget>
|
|
|
|
#include "Extras/Utils/nutils.h"
|
|
#include "QtWidgets/QWidget/qwidget_wrap.h"
|
|
|
|
Napi::FunctionReference QDialWrap::constructor;
|
|
|
|
Napi::Object QDialWrap::init(Napi::Env env, Napi::Object exports) {
|
|
Napi::HandleScope scope(env);
|
|
char CLASSNAME[] = "QDial";
|
|
Napi::Function func =
|
|
DefineClass(env, CLASSNAME,
|
|
{QABSTRACTSLIDER_WRAPPED_METHODS_EXPORT_DEFINE(QDialWrap)});
|
|
constructor = Napi::Persistent(func);
|
|
exports.Set(CLASSNAME, func);
|
|
QOBJECT_REGISTER_WRAPPER(QDial, QDialWrap);
|
|
return exports;
|
|
}
|
|
|
|
QDial* QDialWrap::getInternalInstance() { return this->instance; }
|
|
|
|
QDialWrap::QDialWrap(const Napi::CallbackInfo& info)
|
|
: Napi::ObjectWrap<QDialWrap>(info) {
|
|
Napi::Env env = info.Env();
|
|
size_t argCount = info.Length();
|
|
if (argCount == 0) {
|
|
// --- Construct a new instance
|
|
this->instance = new NDial();
|
|
} else if (argCount == 1) {
|
|
if (info[0].IsExternal()) {
|
|
// --- Wrap a given C++ instance
|
|
this->instance = info[0].As<Napi::External<QDial>>().Data();
|
|
} else {
|
|
// --- Construct a new instance and pass a parent
|
|
Napi::Object parentObject = info[0].As<Napi::Object>();
|
|
NodeWidgetWrap* parentWidgetWrap =
|
|
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(parentObject);
|
|
this->instance = new NDial(parentWidgetWrap->getInternalInstance());
|
|
}
|
|
} else {
|
|
Napi::TypeError::New(
|
|
env, "NodeGui: QDialWrap: Wrong number of arguments to constructor")
|
|
.ThrowAsJavaScriptException();
|
|
}
|
|
this->rawData =
|
|
extrautils::configureQWidget(this->getInternalInstance(), true);
|
|
}
|
|
|
|
QDialWrap::~QDialWrap() { extrautils::safeDelete(this->instance); }
|