import { NativeElement } from "../core/Component"; import { checkIfNativeElement, registerNativeWrapFunction, } from "../utils/helpers"; import { QObject, QObjectSignals } from "../QtCore/QObject"; import { QRect } from "../QtCore/QRect"; import { QSizeF } from "../QtCore/QSizeF"; import { QSize } from "../QtCore/QSize"; import { wrapperCache } from "../core/WrapperCache"; import { QPixmap } from "./QPixmap"; import { ScreenOrientation } from "../QtEnums/ScreenOrientation"; export class QScreen extends QObject { constructor(native: NativeElement) { if (!checkIfNativeElement(native)) { throw new Error("QScreen cannot be initialised this way."); } super(native); } availableGeometry(): QRect { return QRect.fromQVariant(this.property("availableGeometry")); } availableSize(): QSize { return QSize.fromQVariant(this.property("availableSize")); } availableVirtualGeometry(): QRect { return QRect.fromQVariant(this.property("availableVirtualGeometry")); } availableVirtualSize(): QSize { return QSize.fromQVariant(this.property("availableVirtualSize")); } depth(): number { return this.property("depth").toInt(); } devicePixelRatio(): number { return this.property("devicePixelRatio").toDouble(); } geometry(): QRect { return QRect.fromQVariant(this.property("geometry")); } grabWindow(window: number, x = 0, y = 0, width = -1, height = -1): QPixmap { return new QPixmap(this.native?.grabWindow(window, x, y, width, height)); } logicalDotsPerInch(): number { return this.property("logicalDotsPerInch").toDouble(); } logicalDotsPerInchX(): number { return this.property("logicalDotsPerInchX").toDouble(); } logicalDotsPerInchY(): number { return this.property("logicalDotsPerInchY").toDouble(); } manufacturer(): string { return this.property("manufacturer").toString(); } model(): string { return this.property("model").toString(); } name(): string { return this.property("name").toString(); } nativeOrientation(): ScreenOrientation { return this.property("nativeOrientation").toInt(); } orientation(): ScreenOrientation { return this.property("orientation").toInt(); } physicalDotsPerInch(): number { return this.property("physicalDotsPerInch").toDouble(); } physicalDotsPerInchX(): number { return this.property("physicalDotsPerInchX").toDouble(); } physicalDotsPerInchY(): number { return this.property("physicalDotsPerInchY").toDouble(); } physicalSize(): QSizeF { return QSizeF.fromQVariant(this.property("physicalSize")); } primaryOrientation(): ScreenOrientation { return this.property("primaryOrientation").toInt(); } refreshRate(): number { return this.property("refreshRate").toDouble(); } serialNumber(): string { return this.property("serialNumber").toString(); } size(): QSize { return QSize.fromQVariant(this.property("size")); } virtualGeometry(): QRect { return QRect.fromQVariant(this.property("virtualGeometry")); } virtualSize(): QSize { return QSize.fromQVariant(this.property("virtualSize")); } } wrapperCache.registerWrapper("QScreenWrap", QScreen); export interface QScreenSignals extends QObjectSignals { onAvailableGeometryChange: (geometry: QRect) => void; onGeometryChange: (geometry: QRect) => void; onLogicalDotsPerInchChange: (dpi: number) => void; onOrientationChange: (orientation: ScreenOrientation) => void; onPhysicalDotsPerInchChange: (dpi: number) => void; onPhysicalSizeChange: (size: QSizeF) => void; onPrimaryOrientationChange: (orientation: ScreenOrientation) => void; onRefreshRateChange: (refreshRate: number) => void; onVirtualGeometryChange: (rect: QRect) => void; } registerNativeWrapFunction("QScreenWrap", (native: any) => { return wrapperCache.get(QScreen, native); });