import addon from "../utils/addon"; import { QWidget, QWidgetSignals } from "./QWidget"; import { NativeElement, NativeRawPointer } from "../core/Component"; import { QObject, QObjectSignals } from "../QtCore/QObject"; import { QAbstractButton, QAbstractButtonSignals } from "./QAbstractButton"; import { checkIfNativeElement } from "../utils/helpers"; import { wrapperCache } from "../core/WrapperCache"; export interface QButtonGroupSignals extends QObjectSignals { onClick: (id: number) => void; onMousedown: (id: number) => void; onMouseup: (id: number) => void; onToggle: (id: number, checked: boolean) => void; } export class QButtonGroup extends QObject { constructor(arg?: QWidget | NativeElement) { let native: NativeElement; if (checkIfNativeElement(arg)) { native = arg as NativeElement; } else if (arg != null) { const parent = arg as QWidget; native = new addon.QButtonGroup(parent.native); } else { native = new addon.QButtonGroup(); } super(native); } addButton(button: QAbstractButton, id = -1): void { this.native?.addButton(button.native, id); } removeButton(button: QAbstractButton): void { this.native?.removeButton(button.native); } setExclusive(exculsive: boolean): void { this.native?.setProperty("exclusive", exculsive); } checkedId(): number { return this.native?.checkedId(); } exclusive(): boolean { return this.property("exclusive").toBool(); } setId(button: QAbstractButton, id: number): void { this.native?.setId(button.native, id); } id(button: QAbstractButton): number { return this.native?.id(button.native); } buttons(): QAbstractButton[] { return this.native?.buttons(); } checkedButton(): NativeRawPointer<"QAbstractButton*"> { return this.native?.checkedButton(); } button(id: number): NativeRawPointer<"QAbstractButton*"> { return this.native?.button(id); } } wrapperCache.registerWrapper("QButtonGroupWrap", QButtonGroup);