changed to class properties instead. Added calculator base example starting

This commit is contained in:
Atul R
2019-06-09 21:05:02 +02:00
parent 695d1df039
commit 001d83b860
12 changed files with 114 additions and 119 deletions
+4 -4
View File
@@ -3,10 +3,10 @@ import { Component } from "../../core/Component";
export class QApplication extends Component {
native = new addon.QApplication();
processEvents() {
processEvents = () => {
this.native.processEvents();
}
exec() {
};
exec = () => {
this.native.exec();
}
};
}
+12 -12
View File
@@ -7,25 +7,25 @@ import { NodeLayout } from "../../QtWidgets/QLayout";
export abstract class NodeWidget extends YogaWidget {
type = "widget";
layout?: NodeLayout;
show() {
show = () => {
this.native.show();
}
resize(width: number, height: number) {
};
resize = (width: number, height: number) => {
this.native.resize(width, height);
}
close() {
};
close = () => {
this.native.close();
}
setLayout(parentLayout: NodeLayout) {
};
setLayout = (parentLayout: NodeLayout) => {
this.native.setLayout(parentLayout.native);
this.layout = parentLayout;
}
setStyleSheet(style: string) {
};
setStyleSheet = (style: string) => {
this.native.setStyleSheet(style);
}
hide() {
};
hide = () => {
this.native.hide();
}
};
}
export class QWidget extends NodeWidget {
+2 -2
View File
@@ -11,7 +11,7 @@ export class QCheckBox extends NodeWidget {
this.native = new addon.QCheckBox();
}
}
setText(text: string) {
setText = (text: string) => {
this.native.setText(text);
}
};
}
+2 -2
View File
@@ -13,8 +13,8 @@ export class QGridLayout extends NodeLayout {
this.native = new addon.QGridLayout();
}
}
addWidget(widget: NodeWidget) {
addWidget = (widget: NodeWidget) => {
this.native.addWidget(widget.native);
this.children.add(widget);
}
};
}
+6 -11
View File
@@ -1,6 +1,5 @@
import addon from "../../core/addon";
import { NodeWidget } from "../../QtGui/QWidget";
import { FlexNode } from "../../core/FlexLayout/FlexNode";
export class QLabel extends NodeWidget {
native: any;
@@ -13,17 +12,13 @@ export class QLabel extends NodeWidget {
this.native = new addon.QLabel();
}
}
setWordWrap(on: boolean) {
setWordWrap = (on: boolean) => {
this.native.setWordWrap(on);
}
setText(text: string | number) {
};
setText = (text: string | number) => {
this.native.setText(`${text}`);
}
text() {
};
text = () => {
return this.native.text();
}
getFlexNode(): FlexNode {
const nativeFlexNode = this.native.getFlexNode();
return new FlexNode(nativeFlexNode);
}
};
}
+4 -4
View File
@@ -11,11 +11,11 @@ export class QMainWindow extends NodeWidget {
this.native = new addon.QMainWindow();
}
}
setCentralWidget(widget: NodeWidget) {
setCentralWidget = (widget: NodeWidget) => {
this.native.setCentralWidget(widget.native);
this.children.add(widget);
}
setFixedSize(width: number, height: number) {
};
setFixedSize = (width: number, height: number) => {
this.native.setFixedSize(width, height);
}
};
}
+1
View File
@@ -21,6 +21,7 @@ export class QPushButton extends SignalNodeWidget {
super(native);
this.parent = parent;
this.native = native;
this.setText.bind(this);
}
setText(text: string | number) {
+2 -2
View File
@@ -6,7 +6,7 @@ export class FlexNode extends Component {
super();
this.native = nativeNode;
}
debugValue() {
debugValue = (): void => {
return this.native.debugValue();
}
};
}
+4 -4
View File
@@ -8,14 +8,14 @@ export class FlexLayout extends NodeLayout {
protected flexNode?: FlexNode;
protected childFlexNodes = new Set<FlexNode>();
addWidget(childWidget: NodeWidget, childFlexNode: FlexNode) {
addWidget = (childWidget: NodeWidget, childFlexNode: FlexNode) => {
this.children.add(childWidget);
this.childFlexNodes.add(childFlexNode);
this.native.addWidget(childWidget.native, childFlexNode.native);
}
setFlexNode(flexNode: FlexNode) {
};
setFlexNode = (flexNode: FlexNode) => {
this.flexNode = flexNode;
this.native.setFlexNode(flexNode.native);
}
};
}
+5 -2
View File
@@ -13,7 +13,10 @@ export abstract class SignalNodeWidget extends NodeWidget {
}
}
setSignalListener(signalType: string, callback: (payload?: any) => void) {
setSignalListener = (
signalType: string,
callback: (payload?: any) => void
) => {
this.emitter.on(signalType, callback);
}
};
}
+2 -2
View File
@@ -2,7 +2,7 @@ import { Component } from "../Component";
import { FlexNode } from "../FlexLayout/FlexNode";
export abstract class YogaWidget extends Component {
getFlexNode(): FlexNode {
getFlexNode = (): FlexNode => {
return new FlexNode(this.native.getFlexNode());
}
};
}