diff --git a/src/cpp/include/nodegui/QtWidgets/QWidget/qwidget_macro.h b/src/cpp/include/nodegui/QtWidgets/QWidget/qwidget_macro.h index f6eb6c937..67ca8088b 100644 --- a/src/cpp/include/nodegui/QtWidgets/QWidget/qwidget_macro.h +++ b/src/cpp/include/nodegui/QtWidgets/QWidget/qwidget_macro.h @@ -577,6 +577,95 @@ Napi::Env env = info.Env(); \ WId result = this->instance->winId(); \ return Napi::BigInt::New(env, static_cast(result)); \ + } \ + Napi::Value contentsRect(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + QRect result = this->instance->contentsRect(); \ + auto resultInstance = QRectWrap::constructor.New( \ + {Napi::External::New(env, new QRect(result))}); \ + return resultInstance; \ + } \ + Napi::Value childAt(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + int x = info[0].As().Int32Value(); \ + int y = info[1].As().Int32Value(); \ + QWidget* result = this->instance->childAt(x, y); \ + if (result) { \ + return WrapperCache::instance.getWrapper(env, \ + static_cast(result)); \ + } else { \ + return env.Null(); \ + } \ + } \ + Napi::Value focusProxy(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + QWidget* result = this->instance->focusProxy(); \ + if (result) { \ + return WrapperCache::instance.getWrapper(env, \ + static_cast(result)); \ + } else { \ + return env.Null(); \ + } \ + } \ + Napi::Value focusWidget(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + QWidget* result = this->instance->focusWidget(); \ + if (result) { \ + return WrapperCache::instance.getWrapper(env, \ + static_cast(result)); \ + } else { \ + return env.Null(); \ + } \ + } \ + Napi::Value nativeParentWidget(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + QWidget* result = this->instance->nativeParentWidget(); \ + if (result) { \ + return WrapperCache::instance.getWrapper(env, \ + static_cast(result)); \ + } else { \ + return env.Null(); \ + } \ + } \ + Napi::Value nextInFocusChain(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + QWidget* result = this->instance->nextInFocusChain(); \ + if (result) { \ + return WrapperCache::instance.getWrapper(env, \ + static_cast(result)); \ + } else { \ + return env.Null(); \ + } \ + } \ + Napi::Value parentWidget(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + QWidget* result = this->instance->parentWidget(); \ + if (result) { \ + return WrapperCache::instance.getWrapper(env, \ + static_cast(result)); \ + } else { \ + return env.Null(); \ + } \ + } \ + Napi::Value previousInFocusChain(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + QWidget* result = this->instance->previousInFocusChain(); \ + if (result) { \ + return WrapperCache::instance.getWrapper(env, \ + static_cast(result)); \ + } else { \ + return env.Null(); \ + } \ + } \ + Napi::Value window(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + QWidget* result = this->instance->window(); \ + if (result) { \ + return WrapperCache::instance.getWrapper(env, \ + static_cast(result)); \ + } else { \ + return env.Null(); \ + } \ } #endif // QWIDGET_WRAPPED_METHODS_DECLARATION @@ -669,7 +758,18 @@ InstanceMethod("unsetLocale", &WidgetWrapName::unsetLocale), \ InstanceMethod("windowRole", &WidgetWrapName::windowRole), \ InstanceMethod("heightForWidth", &WidgetWrapName::heightForWidth), \ - InstanceMethod("winId", &WidgetWrapName::winId), + InstanceMethod("winId", &WidgetWrapName::winId), \ + InstanceMethod("contentsRect", &WidgetWrapName::contentsRect), \ + InstanceMethod("childAt", &WidgetWrapName::childAt), \ + InstanceMethod("focusProxy", &WidgetWrapName::focusProxy), \ + InstanceMethod("focusWidget", &WidgetWrapName::focusWidget), \ + InstanceMethod("nativeParentWidget", \ + &WidgetWrapName::nativeParentWidget), \ + InstanceMethod("nextInFocusChain", &WidgetWrapName::nextInFocusChain), \ + InstanceMethod("parentWidget", &WidgetWrapName::parentWidget), \ + InstanceMethod("previousInFocusChain", \ + &WidgetWrapName::previousInFocusChain), \ + InstanceMethod("window", &WidgetWrapName::window), #endif // QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE diff --git a/src/lib/QtWidgets/QWidget.ts b/src/lib/QtWidgets/QWidget.ts index 047e9b33d..a4e28e0dd 100644 --- a/src/lib/QtWidgets/QWidget.ts +++ b/src/lib/QtWidgets/QWidget.ts @@ -107,13 +107,14 @@ export class QWidget extends Yo autoFillBackground(): boolean { return this.property('autoFillBackground').toBool(); } - // CLASS: QWidget // TODO: QPalette::ColorRole backgroundRole() const // TODO: QBackingStore * backingStore() const baseSize(): QSize { return QSize.fromQVariant(this.property('baseSize')); } - // TODO: QWidget * childAt(int x, int y) const + childAt(x: number, y: number): QWidget { + return wrapperCache.getWrapper(this.native.childAt(x, y)) as QWidget; + } // TODO: QWidget * childAt(const QPoint &p) const childrenRect(): QRect { return QRect.fromQVariant(this.property('childrenRect')); @@ -126,7 +127,9 @@ export class QWidget extends Yo this.native.clearMask(); } // TODO: QMargins contentsMargins() const - // TODO: QRect contentsRect() const + contentsRect(): QRect { + return new QRect(this.native.contentsRect()); + } contextMenuPolicy(): ContextMenuPolicy { return this.property('contextMenuPolicy').toInt(); } @@ -136,8 +139,13 @@ export class QWidget extends Yo this.native.ensurePolished(); } // TODO: Qt::FocusPolicy focusPolicy() const - // TODO: QWidget * focusProxy() const - // TODO: QWidget * focusWidget() const + focusProxy(): QWidget { + return wrapperCache.getWrapper(this.native.focusProxy()) as QWidget; + } + focusWidget(): QWidget { + return wrapperCache.getWrapper(this.native.focusWidget()) as QWidget; + } + font(): QFont { return QFont.fromQVariant(this.property('font')); } @@ -270,20 +278,28 @@ export class QWidget extends Yo move(x: number, y: number): void { this.native.move(x, y); } - // TODO: QWidget * nativeParentWidget() const - // TODO: QWidget * nextInFocusChain() const + nativeParentWidget(): QWidget { + return wrapperCache.getWrapper(this.native.nativeParentWidget()) as QWidget; + } + nextInFocusChain(): QWidget { + return wrapperCache.getWrapper(this.native.nextInFocusChain()) as QWidget; + } normalGeometry(): QRect { return QRect.fromQVariant(this.property('normalGeometry')); } // TODO: void overrideWindowFlags(Qt::WindowFlags flags) // TODO: const QPalette & palette() const - // TODO: QWidget * parentWidget() const + parentWidget(): QWidget { + return wrapperCache.getWrapper(this.native.parentWidget()) as QWidget; + } // PROP: QWidget pos(): { x: number; y: number } { return this.native.pos(); } - // TODO: QWidget * previousInFocusChain() const + previousInFocusChain(): QWidget { + return wrapperCache.getWrapper(this.native.previousInFocusChain()) as QWidget; + } rect(): QRect { return QRect.fromQVariant(this.property('rect')); } @@ -546,7 +562,10 @@ export class QWidget extends Yo winId(): number { return this.native.winId(); } - // TODO: QWidget * window() const + window(): QWidget { + return wrapperCache.getWrapper(this.native.window()) as QWidget; + } + windowFilePath(): string { return this.property('windowFilePath').toString(); }