From 15478751db8cb6b1fa857c690e40fbb67036c625 Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Sat, 31 Dec 2022 13:54:22 +0100 Subject: [PATCH] Add more `QPaintDevice` methods to `QWidget` --- .../nodegui/QtWidgets/QWidget/qwidget_macro.h | 68 ++++++++++++++++++- src/lib/QtWidgets/QWidget.ts | 37 ++++++++++ 2 files changed, 104 insertions(+), 1 deletion(-) diff --git a/src/cpp/include/nodegui/QtWidgets/QWidget/qwidget_macro.h b/src/cpp/include/nodegui/QtWidgets/QWidget/qwidget_macro.h index 8f23a5e4a..da1d49c9e 100644 --- a/src/cpp/include/nodegui/QtWidgets/QWidget/qwidget_macro.h +++ b/src/cpp/include/nodegui/QtWidgets/QWidget/qwidget_macro.h @@ -710,6 +710,61 @@ QWidget* w = wWidgetWrap->getInternalInstance(); \ this->instance->stackUnder(w); \ return env.Null(); \ + } \ + Napi::Value colorCount(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + int result = this->instance->colorCount(); \ + return Napi::Number::New(env, result); \ + } \ + Napi::Value depth(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + int result = this->instance->depth(); \ + return Napi::Number::New(env, result); \ + } \ + Napi::Value devicePixelRatio(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + qreal result = this->instance->devicePixelRatio(); \ + return Napi::Number::New(env, result); \ + } \ + Napi::Value devicePixelRatioF(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + qreal result = this->instance->devicePixelRatioF(); \ + return Napi::Number::New(env, result); \ + } \ + Napi::Value heightMM(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + int result = this->instance->heightMM(); \ + return Napi::Number::New(env, result); \ + } \ + Napi::Value logicalDpiX(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + int result = this->instance->logicalDpiX(); \ + return Napi::Number::New(env, result); \ + } \ + Napi::Value logicalDpiY(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + int result = this->instance->logicalDpiY(); \ + return Napi::Number::New(env, result); \ + } \ + Napi::Value paintingActive(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + bool result = this->instance->paintingActive(); \ + return Napi::Boolean::New(env, result); \ + } \ + Napi::Value physicalDpiX(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + int result = this->instance->physicalDpiX(); \ + return Napi::Number::New(env, result); \ + } \ + Napi::Value physicalDpiY(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + int result = this->instance->physicalDpiY(); \ + return Napi::Number::New(env, result); \ + } \ + Napi::Value widthMM(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + int result = this->instance->widthMM(); \ + return Napi::Number::New(env, result); \ } #endif // QWIDGET_WRAPPED_METHODS_DECLARATION @@ -818,7 +873,18 @@ InstanceMethod("isAncestorOf", &WidgetWrapName::isAncestorOf), \ InstanceMethod("isEnabledTo", &WidgetWrapName::isEnabledTo), \ InstanceMethod("isVisibleTo", &WidgetWrapName::isVisibleTo), \ - InstanceMethod("stackUnder", &WidgetWrapName::stackUnder), + InstanceMethod("stackUnder", &WidgetWrapName::stackUnder), \ + InstanceMethod("colorCount", &WidgetWrapName::colorCount), \ + InstanceMethod("depth", &WidgetWrapName::depth), \ + InstanceMethod("devicePixelRatio", &WidgetWrapName::devicePixelRatio), \ + InstanceMethod("devicePixelRatioF", &WidgetWrapName::devicePixelRatioF), \ + InstanceMethod("heightMM", &WidgetWrapName::heightMM), \ + InstanceMethod("logicalDpiX", &WidgetWrapName::logicalDpiX), \ + InstanceMethod("logicalDpiY", &WidgetWrapName::logicalDpiY), \ + InstanceMethod("paintingActive", &WidgetWrapName::paintingActive), \ + InstanceMethod("physicalDpiX", &WidgetWrapName::physicalDpiX), \ + InstanceMethod("physicalDpiY", &WidgetWrapName::physicalDpiY), \ + InstanceMethod("widthMM", &WidgetWrapName::widthMM), #endif // QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE diff --git a/src/lib/QtWidgets/QWidget.ts b/src/lib/QtWidgets/QWidget.ts index 67dfdffae..a6125c6c6 100644 --- a/src/lib/QtWidgets/QWidget.ts +++ b/src/lib/QtWidgets/QWidget.ts @@ -611,6 +611,43 @@ export class QWidget extends Yo return this.property('y').toInt(); } + // QPaintDevice public methods + colorCount(): number { + return this.native.colorCount(); + } + depth(): number { + return this.native.depth(); + } + devicePixelRatio(): number { + return this.native.devicePixelRatio(); + } + devicePixelRatioF(): number { + return this.native.devicePixelRatioF(); + } + heightMM(): number { + return this.native.heightMM(); + } + logicalDpiX(): number { + return this.native.logicalDpiX(); + } + logicalDpiY(): number { + return this.native.logicalDpiY(); + } + paintingActive(): boolean { + return this.native.paintingActive(); + } + physicalDpiX(): number { + return this.native.physicalDpiX(); + } + physicalDpiY(): number { + return this.native.physicalDpiY(); + } + widthMM(): number { + return this.native.widthMM(); + } + + // TODO: virtual QPaintEngine * paintEngine() const = 0 + // *** Public Slots *** close(): boolean { return this.native.close();