Add QResizeEvent class
This commit is contained in:
parent
1ab7d13b96
commit
21ed97037a
@ -58,6 +58,7 @@ add_library(${CORE_WIDGETS_ADDON} SHARED
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QEvent/QDropEvent/qdropevent_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QEvent/QDragMoveEvent/qdragmoveevent_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QEvent/QDragLeaveEvent/qdragleaveevent_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QEvent/QResizeEvent/qresizeevent_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QFontDatabase/qfontdatabase_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QFontMetrics/qfontmetrics_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QFontMetricsF/qfontmetricsf_wrap.cpp"
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
|
||||
#include <QResizeEvent>
|
||||
|
||||
#include "Extras/Export/export.h"
|
||||
#include "QtGui/QEvent/QEvent/qevent_macro.h"
|
||||
#include "core/Component/component_macro.h"
|
||||
|
||||
class DLL_EXPORT QResizeEventWrap : public Napi::ObjectWrap<QResizeEventWrap> {
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
QEVENT_WRAPPED_METHODS_DECLARATION
|
||||
|
||||
private:
|
||||
QResizeEvent* instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QResizeEventWrap(const Napi::CallbackInfo& info);
|
||||
~QResizeEventWrap();
|
||||
QResizeEvent* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
Napi::Value oldSize(const Napi::CallbackInfo& info);
|
||||
Napi::Value size(const Napi::CallbackInfo& info);
|
||||
};
|
||||
56
src/cpp/lib/QtGui/QEvent/QResizeEvent/qresizeevent_wrap.cpp
Normal file
56
src/cpp/lib/QtGui/QEvent/QResizeEvent/qresizeevent_wrap.cpp
Normal file
@ -0,0 +1,56 @@
|
||||
#include "QtCore/QSize/qsize_wrap.h"
|
||||
#include "QtGui/QEvent/QResizeEvent/qresizeevent_wrap.h"
|
||||
|
||||
#include "Extras/Utils/nutils.h"
|
||||
|
||||
Napi::FunctionReference QResizeEventWrap::constructor;
|
||||
|
||||
Napi::Object QResizeEventWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
Napi::HandleScope scope(env);
|
||||
char CLASSNAME[] = "QResizeEvent";
|
||||
Napi::Function func = DefineClass(
|
||||
env, CLASSNAME,
|
||||
{InstanceMethod("oldSize", &QResizeEventWrap::oldSize),
|
||||
InstanceMethod("size", &QResizeEventWrap::size),
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QResizeEventWrap)
|
||||
QEVENT_WRAPPED_METHODS_EXPORT_DEFINE(QResizeEventWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
return exports;
|
||||
}
|
||||
|
||||
QResizeEvent* QResizeEventWrap::getInternalInstance() { return this->instance; }
|
||||
|
||||
QResizeEventWrap::QResizeEventWrap(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QResizeEventWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
if (info.Length() == 1) {
|
||||
Napi::External<QResizeEvent> eventObject =
|
||||
info[0].As<Napi::External<QResizeEvent>>();
|
||||
this->instance = static_cast<QResizeEvent*>(eventObject.Data());
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
this->rawData = extrautils::configureComponent(this->getInternalInstance());
|
||||
}
|
||||
|
||||
QResizeEventWrap::~QResizeEventWrap() {
|
||||
// Do not destroy instance here. It will be done by Qt Event loop.
|
||||
}
|
||||
|
||||
Napi::Value QResizeEventWrap::oldSize(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
QSize size = this->instance->oldSize();
|
||||
auto instance = QSizeWrap::constructor.New({Napi::External<QSize>::New(
|
||||
env, new QSize(size.width(), size.height()))});
|
||||
return instance;
|
||||
}
|
||||
|
||||
Napi::Value QResizeEventWrap::size(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
QSize size = this->instance->size();
|
||||
auto instance = QSizeWrap::constructor.New({Napi::External<QSize>::New(
|
||||
env, new QSize(size.width(), size.height()))});
|
||||
return instance;
|
||||
}
|
||||
@ -31,6 +31,7 @@
|
||||
#include "QtGui/QEvent/QMouseEvent/qmouseevent_wrap.h"
|
||||
#include "QtGui/QEvent/QNativeGestureEvent/qnativegestureevent_wrap.h"
|
||||
#include "QtGui/QEvent/QPaintEvent/qpaintevent_wrap.h"
|
||||
#include "QtGui/QEvent/QResizeEvent/qresizeevent_wrap.h"
|
||||
#include "QtGui/QEvent/QTabletEvent/qtabletevent_wrap.h"
|
||||
#include "QtGui/QEvent/QWheelEvent/qwheelevent_wrap.h"
|
||||
#include "QtGui/QFont/qfont_wrap.h"
|
||||
@ -240,6 +241,7 @@ Napi::Object Main(Napi::Env env, Napi::Object exports) {
|
||||
QStyleFactoryWrap::init(env, exports);
|
||||
QScreenWrap::init(env, exports);
|
||||
QWindowWrap::init(env, exports);
|
||||
QResizeEventWrap::init(env, exports);
|
||||
|
||||
// Test
|
||||
CacheTestQObjectWrap::init(env, exports);
|
||||
|
||||
@ -32,6 +32,7 @@ export { QDropEvent } from './lib/QtGui/QEvent/QDropEvent';
|
||||
export { QDragMoveEvent } from './lib/QtGui/QEvent/QDragMoveEvent';
|
||||
export { QDragLeaveEvent } from './lib/QtGui/QEvent/QDragLeaveEvent';
|
||||
export { QPaintEvent } from './lib/QtGui/QEvent/QPaintEvent';
|
||||
export { QResizeEvent } from './lib/QtGui/QEvent/QResizeEvent';
|
||||
export { QScreen } from './lib/QtGui/QScreen';
|
||||
export { QWindow } from './lib/QtGui/QWindow';
|
||||
export { WidgetEventTypes } from './lib/core/EventWidget';
|
||||
|
||||
16
src/lib/QtGui/QEvent/QResizeEvent.ts
Normal file
16
src/lib/QtGui/QEvent/QResizeEvent.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import addon from '../../utils/addon';
|
||||
import { NativeRawPointer } from '../../core/Component';
|
||||
import { QEvent } from './QEvent';
|
||||
import { QSize } from '../../QtCore/QSize';
|
||||
|
||||
export class QResizeEvent extends QEvent {
|
||||
constructor(event: NativeRawPointer<'QEvent'>) {
|
||||
super(new addon.QResizeEvent(event));
|
||||
}
|
||||
oldSize(): QSize {
|
||||
return new QSize(this.native.oldSize());
|
||||
}
|
||||
size(): QSize {
|
||||
return new QSize(this.native.size());
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user