Radio button
This commit is contained in:
parent
5d0fe00795
commit
3e9a230404
@ -24,6 +24,7 @@
|
||||
"../src/cpp/QtWidgets/QPushButton/qpushbutton_wrap.cpp",
|
||||
"../src/cpp/QtWidgets/QCheckBox/qcheckbox_wrap.cpp",
|
||||
"../src/cpp/QtWidgets/QProgressBar/qprogressbar_wrap.cpp",
|
||||
"../src/cpp/QtWidgets/QRadioButton/qradiobutton_wrap.cpp",
|
||||
],
|
||||
}
|
||||
]
|
||||
|
||||
4
demo.ts
4
demo.ts
@ -5,6 +5,7 @@ import { QLabel } from "./src/lib/QtWidgets/QLabel";
|
||||
import { QPushButton } from "./src/lib/QtWidgets/QPushButton";
|
||||
import { QCheckBox } from "./src/lib/QtWidgets/QCheckBox";
|
||||
import { QProgressBar } from "./src/lib/QtWidgets/QProgressBar";
|
||||
import { QRadioButton } from "./src/lib/QtWidgets/QRadioButton";
|
||||
|
||||
const win = new QMainWindow();
|
||||
const view = new QWidget();
|
||||
@ -26,11 +27,14 @@ checkbox.setText("Pumpkeen");
|
||||
|
||||
const progressbar = new QProgressBar();
|
||||
|
||||
const radiobutton = new QRadioButton();
|
||||
|
||||
gridLayout.addWidget(label);
|
||||
gridLayout.addWidget(label2);
|
||||
gridLayout.addWidget(button1);
|
||||
gridLayout.addWidget(checkbox);
|
||||
gridLayout.addWidget(progressbar);
|
||||
gridLayout.addWidget(radiobutton);
|
||||
|
||||
view.setLayout(gridLayout);
|
||||
|
||||
|
||||
47
src/cpp/QtWidgets/QRadioButton/qradiobutton_wrap.cpp
Normal file
47
src/cpp/QtWidgets/QRadioButton/qradiobutton_wrap.cpp
Normal file
@ -0,0 +1,47 @@
|
||||
|
||||
#include "qradiobutton_wrap.h"
|
||||
#include "src/cpp/QtGui/QWidget/qwidget_wrap.h"
|
||||
#include "src/cpp/Extras/Utils/utils.h"
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
Napi::FunctionReference QRadioButtonWrap::constructor;
|
||||
|
||||
Napi::Object QRadioButtonWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
Napi::HandleScope scope(env);
|
||||
char CLASSNAME[] = "QRadioButton";
|
||||
Napi::Function func = DefineClass(env, CLASSNAME, {
|
||||
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QRadioButtonWrap)
|
||||
});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
}
|
||||
|
||||
QRadioButton* QRadioButtonWrap::getInternalInstance() {
|
||||
return this->instance;
|
||||
}
|
||||
|
||||
QRadioButtonWrap::QRadioButtonWrap(const Napi::CallbackInfo& info): Napi::ObjectWrap<QRadioButtonWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
if(info.Length() == 1) {
|
||||
if(info[0].IsObject()){
|
||||
Napi::Object object_parent = info[0].As<Napi::Object>();
|
||||
QWidgetWrap* w_parent = Napi::ObjectWrap<QWidgetWrap>::Unwrap(object_parent);
|
||||
this->instance = new QRadioButton(w_parent->getInternalInstance()); //this sets the parent to current widget
|
||||
}else{
|
||||
extrautils::throwTypeError(env, "Wrong type of arguments");
|
||||
}
|
||||
}else if (info.Length() == 0){
|
||||
this->instance = new QRadioButton();
|
||||
}else {
|
||||
extrautils::throwTypeError(env, "Wrong number of arguments");
|
||||
}
|
||||
}
|
||||
|
||||
QRadioButtonWrap::~QRadioButtonWrap() {
|
||||
delete this->instance;
|
||||
}
|
||||
|
||||
22
src/cpp/QtWidgets/QRadioButton/qradiobutton_wrap.h
Normal file
22
src/cpp/QtWidgets/QRadioButton/qradiobutton_wrap.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef QRADIOBUTTON_WRAP_H
|
||||
#define QRADIOBUTTON_WRAP_H
|
||||
#include <napi.h>
|
||||
#include <QRadioButton>
|
||||
#include "src/cpp/QtGui/QWidget/qwidget_macro.h"
|
||||
|
||||
class QRadioButtonWrap : public Napi::ObjectWrap<QRadioButtonWrap>{
|
||||
private:
|
||||
QRadioButton* instance;
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QRadioButtonWrap(const Napi::CallbackInfo& info);
|
||||
~QRadioButtonWrap();
|
||||
QRadioButton* getInternalInstance();
|
||||
//class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
//wrapped methods
|
||||
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -7,6 +7,7 @@
|
||||
#include "src/cpp/QtWidgets/QPushButton/qpushbutton_wrap.h"
|
||||
#include "src/cpp/QtWidgets/QCheckBox/qcheckbox_wrap.h"
|
||||
#include "src/cpp/QtWidgets/QProgressBar/qprogressbar_wrap.h"
|
||||
#include "src/cpp/QtWidgets/QRadioButton/qradiobutton_wrap.h"
|
||||
#include <napi.h>
|
||||
|
||||
//private : will not be accessibe in js
|
||||
@ -23,6 +24,7 @@ Napi::Object Main(Napi::Env env, Napi::Object exports) {
|
||||
QPushButtonWrap::init(env, exports);
|
||||
QCheckBoxWrap::init(env, exports);
|
||||
QProgressBarWrap::init(env, exports);
|
||||
QRadioButtonWrap::init(env, exports);
|
||||
return QLabelWrap::init(env, exports);
|
||||
}
|
||||
|
||||
|
||||
17
src/lib/QtWidgets/QRadioButton/index.ts
Normal file
17
src/lib/QtWidgets/QRadioButton/index.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import addon from "../../core/addon";
|
||||
import { NodeWidget } from "../../QtGui/QWidget";
|
||||
import { QLayout } from "../QLayout";
|
||||
|
||||
export class QRadioButton extends NodeWidget {
|
||||
native: any;
|
||||
layout?: QLayout;
|
||||
constructor(parent?: NodeWidget) {
|
||||
super();
|
||||
if (parent) {
|
||||
this.native = new addon.QRadioButton(parent.native);
|
||||
this.parent = parent;
|
||||
} else {
|
||||
this.native = new addon.QRadioButton();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user