nodeguy/src/lib/QtWidgets/QTabWidget.ts
Atul R 6035b5d038
Re arrange folders to make more sense (#180)
* Re-arranged qtgui and core

* Re arranges qt widgets
2019-11-08 20:33:17 +01:00

55 lines
1.5 KiB
TypeScript

import addon from '../utils/addon';
import { NodeWidget } from './QWidget';
import { BaseWidgetEvents } from '../core/EventWidget';
import { NativeElement } from '../core/Component';
import { QIcon } from '../QtGui/QIcon';
import { TabPosition } from '../QtEnums';
export const QTabWidgetEvents = Object.freeze({
...BaseWidgetEvents,
currentChanged: 'currentChanged',
tabBarClicked: 'tabBarClicked',
tabBarDoubleClicked: 'tabBarDoubleClicked',
tabCloseRequested: 'tabCloseRequested',
});
export class QTabWidget extends NodeWidget {
native: NativeElement;
constructor(parent?: NodeWidget) {
let native;
if (parent) {
native = new addon.QTabWidget(parent.native);
} else {
native = new addon.QTabWidget();
}
super(native);
this.nodeParent = parent;
this.native = native;
}
addTab(page: NodeWidget, icon: QIcon, label: string): void {
this.nodeChildren.add(page);
this.native.addTab(page.native, icon.native, label);
}
setTabPosition(tabPosition: TabPosition): void {
this.native.setTabPosition(tabPosition);
}
setCurrentIndex(index: number): void {
this.native.setCurrentIndex(index);
}
currentIndex(): number {
return this.native.currentIndex();
}
removeTab(index: number): void {
this.native.removeTab(index);
}
setTabsClosable(closeable: boolean): void {
this.native.setTabsClosable(closeable);
}
}