* layout performance fix * adjust size, webdefaults * Add flexlayout owner to the context * revert * reorders setlayout and setflexnode * add defaults * fix mainwindow rootNode * properties to methods * Adds defaultsAdds flexutils measurewidget * introduce configure for all types of nodes. * lint fix * Revams flexlayout to handle dynamic content * Adds dynamic layout support for flex layout. * lint fix * fix few code updates
74 lines
2.4 KiB
C++
74 lines
2.4 KiB
C++
#include "QtWidgets/QCheckBox/qcheckbox_wrap.h"
|
|
|
|
#include <QWidget>
|
|
|
|
#include "Extras/Utils/nutils.h"
|
|
#include "QtWidgets/QWidget/qwidget_wrap.h"
|
|
|
|
Napi::FunctionReference QCheckBoxWrap::constructor;
|
|
|
|
Napi::Object QCheckBoxWrap::init(Napi::Env env, Napi::Object exports) {
|
|
Napi::HandleScope scope(env);
|
|
char CLASSNAME[] = "QCheckBox";
|
|
Napi::Function func =
|
|
DefineClass(env, CLASSNAME,
|
|
{InstanceMethod("setText", &QCheckBoxWrap::setText),
|
|
InstanceMethod("setChecked", &QCheckBoxWrap::setChecked),
|
|
InstanceMethod("isChecked", &QCheckBoxWrap::isChecked),
|
|
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QCheckBoxWrap)});
|
|
constructor = Napi::Persistent(func);
|
|
exports.Set(CLASSNAME, func);
|
|
return exports;
|
|
}
|
|
|
|
NCheckBox* QCheckBoxWrap::getInternalInstance() { return this->instance; }
|
|
|
|
QCheckBoxWrap::QCheckBoxWrap(const Napi::CallbackInfo& info)
|
|
: Napi::ObjectWrap<QCheckBoxWrap>(info) {
|
|
Napi::Env env = info.Env();
|
|
Napi::HandleScope scope(env);
|
|
|
|
if (info.Length() == 1) {
|
|
Napi::Object parentObject = info[0].As<Napi::Object>();
|
|
QWidgetWrap* parentWidgetWrap =
|
|
Napi::ObjectWrap<QWidgetWrap>::Unwrap(parentObject);
|
|
this->instance = new NCheckBox(parentWidgetWrap->getInternalInstance());
|
|
} else if (info.Length() == 0) {
|
|
this->instance = new NCheckBox();
|
|
} else {
|
|
Napi::TypeError::New(env, "Wrong number of arguments")
|
|
.ThrowAsJavaScriptException();
|
|
}
|
|
this->rawData = extrautils::configureQWidget(
|
|
this->getInternalInstance(), this->getInternalInstance()->getFlexNode(),
|
|
true);
|
|
}
|
|
|
|
QCheckBoxWrap::~QCheckBoxWrap() { extrautils::safeDelete(this->instance); }
|
|
|
|
Napi::Value QCheckBoxWrap::setText(const Napi::CallbackInfo& info) {
|
|
Napi::Env env = info.Env();
|
|
Napi::HandleScope scope(env);
|
|
|
|
Napi::String text = info[0].As<Napi::String>();
|
|
std::string label = text.Utf8Value();
|
|
this->instance->setText(label.c_str());
|
|
|
|
return env.Null();
|
|
}
|
|
|
|
Napi::Value QCheckBoxWrap::isChecked(const Napi::CallbackInfo& info) {
|
|
Napi::Env env = info.Env();
|
|
Napi::HandleScope scope(env);
|
|
bool isChecked = this->instance->isChecked();
|
|
return Napi::Value::From(env, isChecked);
|
|
}
|
|
|
|
Napi::Value QCheckBoxWrap::setChecked(const Napi::CallbackInfo& info) {
|
|
Napi::Env env = info.Env();
|
|
Napi::HandleScope scope(env);
|
|
Napi::Boolean check = info[0].As<Napi::Boolean>();
|
|
this->instance->setChecked(check.Value());
|
|
return env.Null();
|
|
}
|