Adds progress bar value, max, min
This commit is contained in:
parent
e9414162cf
commit
69a4897ce3
3
demo.ts
3
demo.ts
@ -29,6 +29,9 @@ button.setText("Push Push Push!");
|
||||
button.setObjectName("btn");
|
||||
|
||||
const progressbar = new QProgressBar();
|
||||
progressbar.setValue(6);
|
||||
progressbar.setMinimum(1);
|
||||
progressbar.setMaximum(15);
|
||||
|
||||
const radioButton = new QRadioButton();
|
||||
radioButton.setText("Roger that!");
|
||||
|
||||
@ -11,6 +11,10 @@ Napi::Object QProgressBarWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
Napi::HandleScope scope(env);
|
||||
char CLASSNAME[] = "QProgressBar";
|
||||
Napi::Function func = DefineClass(env, CLASSNAME, {
|
||||
InstanceMethod("setValue", &QProgressBarWrap::setValue),
|
||||
InstanceMethod("setMaximum", &QProgressBarWrap::setMaximum),
|
||||
InstanceMethod("setMinimum", &QProgressBarWrap::setMinimum),
|
||||
InstanceMethod("value", &QProgressBarWrap::value),
|
||||
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QProgressBarWrap)
|
||||
});
|
||||
constructor = Napi::Persistent(func);
|
||||
@ -43,3 +47,33 @@ QProgressBarWrap::~QProgressBarWrap() {
|
||||
delete this->instance;
|
||||
}
|
||||
|
||||
Napi::Value QProgressBarWrap::setValue(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
Napi::Number value = info[0].As<Napi::Number>();
|
||||
this->instance->setValue(value.Int32Value());
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QProgressBarWrap::setMaximum(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
Napi::Number value = info[0].As<Napi::Number>();
|
||||
this->instance->setMaximum(value.Int32Value());
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QProgressBarWrap::setMinimum(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
Napi::Number value = info[0].As<Napi::Number>();
|
||||
this->instance->setMinimum(value.Int32Value());
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QProgressBarWrap::value(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
int value = this->instance->value();
|
||||
return Napi::Number::New(env, value);
|
||||
}
|
||||
|
||||
@ -15,7 +15,11 @@ class QProgressBarWrap : public Napi::ObjectWrap<QProgressBarWrap>{
|
||||
//class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
//wrapped methods
|
||||
|
||||
Napi::Value setValue(const Napi::CallbackInfo& info);
|
||||
Napi::Value setMaximum(const Napi::CallbackInfo& info);
|
||||
Napi::Value setMinimum(const Napi::CallbackInfo& info);
|
||||
Napi::Value value(const Napi::CallbackInfo& info);
|
||||
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
|
||||
@ -19,5 +19,21 @@ export class QProgressBar extends NodeWidget {
|
||||
this.native = native;
|
||||
this.parent = parent;
|
||||
// bind member functions
|
||||
this.setValue.bind(this);
|
||||
this.setMinimum.bind(this);
|
||||
this.setMaximum.bind(this);
|
||||
this.value.bind(this);
|
||||
}
|
||||
setValue(value: number) {
|
||||
this.native.setValue(value);
|
||||
}
|
||||
setMinimum(min: number) {
|
||||
this.native.setMinimum(min);
|
||||
}
|
||||
setMaximum(max: number) {
|
||||
this.native.setMaximum(max);
|
||||
}
|
||||
value(): number {
|
||||
return this.native.value();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user