diff --git a/src/cpp/include/nodegui/QtWidgets/QWidget/qwidget_macro.h b/src/cpp/include/nodegui/QtWidgets/QWidget/qwidget_macro.h index 67ca8088b..8f23a5e4a 100644 --- a/src/cpp/include/nodegui/QtWidgets/QWidget/qwidget_macro.h +++ b/src/cpp/include/nodegui/QtWidgets/QWidget/qwidget_macro.h @@ -607,6 +607,14 @@ return env.Null(); \ } \ } \ + Napi::Value setFocusProxy(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + Napi::Object widgetObject = info[0].As(); \ + NodeWidgetWrap* widgetWrap = \ + Napi::ObjectWrap::Unwrap(widgetObject); \ + this->instance->setFocusProxy(widgetWrap->getInternalInstance()); \ + return env.Null(); \ + } \ Napi::Value focusWidget(const Napi::CallbackInfo& info) { \ Napi::Env env = info.Env(); \ QWidget* result = this->instance->focusWidget(); \ @@ -666,6 +674,42 @@ } else { \ return env.Null(); \ } \ + } \ + Napi::Value isAncestorOf(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + Napi::Object childWidgetObject = info[0].As(); \ + NodeWidgetWrap* childWidgetWrap = \ + Napi::ObjectWrap::Unwrap(childWidgetObject); \ + QWidget* child = childWidgetWrap->getInternalInstance(); \ + bool result = this->instance->isAncestorOf(child); \ + return Napi::Boolean::New(env, result); \ + } \ + Napi::Value isEnabledTo(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + Napi::Object ancestorWidgetObject = info[0].As(); \ + NodeWidgetWrap* ancestorWidgetWrap = \ + Napi::ObjectWrap::Unwrap(ancestorWidgetObject); \ + QWidget* ancestor = ancestorWidgetWrap->getInternalInstance(); \ + bool result = this->instance->isEnabledTo(ancestor); \ + return Napi::Boolean::New(env, result); \ + } \ + Napi::Value isVisibleTo(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + Napi::Object ancestorWidgetObject = info[0].As(); \ + NodeWidgetWrap* ancestorWidgetWrap = \ + Napi::ObjectWrap::Unwrap(ancestorWidgetObject); \ + QWidget* ancestor = ancestorWidgetWrap->getInternalInstance(); \ + bool result = this->instance->isVisibleTo(ancestor); \ + return Napi::Boolean::New(env, result); \ + } \ + Napi::Value stackUnder(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + Napi::Object wWidgetObject = info[0].As(); \ + NodeWidgetWrap* wWidgetWrap = \ + Napi::ObjectWrap::Unwrap(wWidgetObject); \ + QWidget* w = wWidgetWrap->getInternalInstance(); \ + this->instance->stackUnder(w); \ + return env.Null(); \ } #endif // QWIDGET_WRAPPED_METHODS_DECLARATION @@ -762,6 +806,7 @@ InstanceMethod("contentsRect", &WidgetWrapName::contentsRect), \ InstanceMethod("childAt", &WidgetWrapName::childAt), \ InstanceMethod("focusProxy", &WidgetWrapName::focusProxy), \ + InstanceMethod("setFocusProxy", &WidgetWrapName::setFocusProxy), \ InstanceMethod("focusWidget", &WidgetWrapName::focusWidget), \ InstanceMethod("nativeParentWidget", \ &WidgetWrapName::nativeParentWidget), \ @@ -769,7 +814,11 @@ InstanceMethod("parentWidget", &WidgetWrapName::parentWidget), \ InstanceMethod("previousInFocusChain", \ &WidgetWrapName::previousInFocusChain), \ - InstanceMethod("window", &WidgetWrapName::window), + InstanceMethod("window", &WidgetWrapName::window), \ + InstanceMethod("isAncestorOf", &WidgetWrapName::isAncestorOf), \ + InstanceMethod("isEnabledTo", &WidgetWrapName::isEnabledTo), \ + InstanceMethod("isVisibleTo", &WidgetWrapName::isVisibleTo), \ + InstanceMethod("stackUnder", &WidgetWrapName::stackUnder), #endif // QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE diff --git a/src/lib/QtWidgets/QWidget.ts b/src/lib/QtWidgets/QWidget.ts index a4e28e0dd..67dfdffae 100644 --- a/src/lib/QtWidgets/QWidget.ts +++ b/src/lib/QtWidgets/QWidget.ts @@ -115,7 +115,6 @@ export class QWidget extends Yo 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')); } @@ -201,11 +200,15 @@ export class QWidget extends Yo isActiveWindow(): boolean { return this.property('isActiveWindow').toBool(); } - // TODO: bool isAncestorOf(const QWidget *child) const + isAncestorOf(child: QWidget): boolean { + return this.native.isAncestorOf(child); + } isEnabled(): boolean { return this.property('enabled').toBool(); } - // TODO: bool isEnabledTo(const QWidget *ancestor) const + isEnabledTo(ancestor: QWidget): boolean { + return this.native.isEnabledTo(ancestor); + } isFullScreen(): boolean { return this.property('fullScreen').toBool(); } @@ -224,14 +227,15 @@ export class QWidget extends Yo isVisible(): boolean { return this.property('visible').toBool(); } - // TODO: bool isVisibleTo(const QWidget *ancestor) const + isVisibleTo(ancestor: QWidget): boolean { + return this.native.isVisibleTo(ancestor); + } isWindow(): boolean { return this.native.isWindow(); } isWindowModified(): boolean { return this.native.isWindowModified(); } - // TODO: QLayout * layout() const // TODO: Qt::LayoutDirection layoutDirection() const // TODO: QLocale locale() const mapFrom(parent: QWidget, pos: QPoint): QPoint { @@ -378,7 +382,9 @@ export class QWidget extends Yo setFocusPolicy(policy: FocusPolicy): void { this.setProperty('focusPolicy', policy); } - // TODO: void setFocusProxy(QWidget *w) + setFocusProxy(widget: QWidget): void { + this.native.setFocusProxy(widget); + } setFont(font: QFont): void { this.native.setProperty('font', font.native); } @@ -509,7 +515,9 @@ export class QWidget extends Yo } // PROP: QWidget // TODO: QSizePolicy sizePolicy() const - // TODO: void stackUnder(QWidget *w) + stackUnder(w: QWidget): void { + this.native.stackUnder(w); + } statusTip(): string { return this.property('statusTip').toString(); }