Added setAcceptDrops, acceptDrops to QWidget for creating drag-drop extensions (#613)

* Added QWheelEvent

* removed x y

* Added QNativeGestureEvent

* Changed wrong type of QNativeGestureEventWrap value

* Added QTabletEvent

* Fixing build error for QTabletEvent

* adding dropaction

* fix typos

* Added more functions to QPainterPath

* Added more functions to QPainterPath

* Fixed multiple typos

* Fixed multiple typos

* Got QPainterPath additions working.

* Modified QPainterPath to use qreal instead

* Added QPointF, added a few missing methods to QPoint

* Added QRectF

* implemented QRectF

* Added acceptDrops and setAcceptDrops to QWidget, will be useful for addon implementation of Drag and Drop

Co-authored-by: Switt Kongdachalert <switt1995@yahoo.com>
This commit is contained in:
swittk 2020-06-26 21:53:43 +07:00 committed by GitHub
parent b0570fcdc5
commit 3fadf33113
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 2756 additions and 25 deletions

View File

@ -48,6 +48,8 @@ add_library(${CORE_WIDGETS_ADDON} SHARED
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QEvent/QWheelEvent/qwheelevent_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QEvent/QNativeGestureEvent/qnativegestureevent_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QEvent/QTabletEvent/qtabletevent_wrap.cpp"
"${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/QFontDatabase/qfontdatabase_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QPicture/qpicture_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QPixmap/qpixmap_wrap.cpp"
@ -65,7 +67,9 @@ add_library(${CORE_WIDGETS_ADDON} SHARED
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtCore/QSize/qsize_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtCore/QSettings/qsettings_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtCore/QRect/qrect_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtCore/QRectF/qrectf_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtCore/QPoint/qpoint_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtCore/QPointF/qpointf_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtCore/QTime/qtime_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtCore/QUrl/qurl_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QWidget/qwidget_wrap.cpp"

View File

@ -23,6 +23,9 @@ class DLL_EXPORT QPointWrap : public Napi::ObjectWrap<QPointWrap> {
Napi::Value setY(const Napi::CallbackInfo& info);
Napi::Value x(const Napi::CallbackInfo& info);
Napi::Value y(const Napi::CallbackInfo& info);
Napi::Value isNull(const Napi::CallbackInfo& info);
Napi::Value manhattanLength(const Napi::CallbackInfo& info);
Napi::Value transposed(const Napi::CallbackInfo& info);
};
namespace StaticQPointWrapMethods {

View File

@ -0,0 +1,38 @@
#pragma once
#include <napi.h>
#include <QPointF>
#include "Extras/Export/export.h"
#include "core/Component/component_macro.h"
class DLL_EXPORT QPointFWrap : public Napi::ObjectWrap<QPointFWrap> {
COMPONENT_WRAPPED_METHODS_DECLARATION
private:
std::unique_ptr<QPointF> instance;
public:
static Napi::Object init(Napi::Env env, Napi::Object exports);
QPointFWrap(const Napi::CallbackInfo& info);
~QPointFWrap();
QPointF* getInternalInstance();
// class constructor
static Napi::FunctionReference constructor;
// wrapped methods
Napi::Value dotProduct(const Napi::CallbackInfo& info);
Napi::Value isNull(const Napi::CallbackInfo& info);
Napi::Value manhattanLength(const Napi::CallbackInfo& info);
Napi::Value setX(const Napi::CallbackInfo& info);
Napi::Value setY(const Napi::CallbackInfo& info);
Napi::Value toPoint(const Napi::CallbackInfo& info);
Napi::Value transposed(const Napi::CallbackInfo& info);
Napi::Value x(const Napi::CallbackInfo& info);
Napi::Value y(const Napi::CallbackInfo& info);
};
namespace StaticQPointFWrapMethods {
DLL_EXPORT Napi::Value dotProduct(const Napi::CallbackInfo& info);
} // namespace StaticQPointFWrapMethods

View File

@ -0,0 +1,82 @@
#pragma once
#include <napi.h>
#include <QRectF>
#include "Extras/Export/export.h"
#include "core/Component/component_macro.h"
class DLL_EXPORT QRectFWrap : public Napi::ObjectWrap<QRectFWrap> {
COMPONENT_WRAPPED_METHODS_DECLARATION
private:
std::unique_ptr<QRectF> instance;
public:
static Napi::Object init(Napi::Env env, Napi::Object exports);
QRectFWrap(const Napi::CallbackInfo& info);
~QRectFWrap();
QRectF* getInternalInstance();
// class constructor
static Napi::FunctionReference constructor;
// wrapped methods
Napi::Value adjust(const Napi::CallbackInfo& info);
Napi::Value adjusted(const Napi::CallbackInfo& info);
Napi::Value bottom(const Napi::CallbackInfo& info);
Napi::Value bottomLeft(const Napi::CallbackInfo& info);
Napi::Value bottomRight(const Napi::CallbackInfo& info);
Napi::Value center(const Napi::CallbackInfo& info);
Napi::Value contains(const Napi::CallbackInfo& info);
Napi::Value contains_QRect(const Napi::CallbackInfo& info);
Napi::Value contains_QPoint(const Napi::CallbackInfo& info);
Napi::Value height(const Napi::CallbackInfo& info);
Napi::Value intersected(const Napi::CallbackInfo& info);
Napi::Value intersects(const Napi::CallbackInfo& info);
Napi::Value isEmpty(const Napi::CallbackInfo& info);
Napi::Value isNull(const Napi::CallbackInfo& info);
Napi::Value isValid(const Napi::CallbackInfo& info);
Napi::Value left(const Napi::CallbackInfo& info);
Napi::Value moveBottom(const Napi::CallbackInfo& info);
Napi::Value moveBottomLeft(const Napi::CallbackInfo& info);
Napi::Value moveBottomRight(const Napi::CallbackInfo& info);
Napi::Value moveCenter(const Napi::CallbackInfo& info);
Napi::Value moveLeft(const Napi::CallbackInfo& info);
Napi::Value moveRight(const Napi::CallbackInfo& info);
Napi::Value moveTo(const Napi::CallbackInfo& info);
Napi::Value moveTo_QPoint(const Napi::CallbackInfo& info);
Napi::Value moveTop(const Napi::CallbackInfo& info);
Napi::Value moveTopLeft(const Napi::CallbackInfo& info);
Napi::Value moveTopRight(const Napi::CallbackInfo& info);
Napi::Value normalized(const Napi::CallbackInfo& info);
Napi::Value right(const Napi::CallbackInfo& info);
Napi::Value setBottom(const Napi::CallbackInfo& info);
Napi::Value setBottomLeft(const Napi::CallbackInfo& info);
Napi::Value setBottomRight(const Napi::CallbackInfo& info);
Napi::Value setCoords(const Napi::CallbackInfo& info);
Napi::Value setHeight(const Napi::CallbackInfo& info);
Napi::Value setLeft(const Napi::CallbackInfo& info);
Napi::Value setRect(const Napi::CallbackInfo& info);
Napi::Value setRight(const Napi::CallbackInfo& info);
Napi::Value setTop(const Napi::CallbackInfo& info);
Napi::Value setTopLeft(const Napi::CallbackInfo& info);
Napi::Value setTopRight(const Napi::CallbackInfo& info);
Napi::Value setWidth(const Napi::CallbackInfo& info);
Napi::Value setX(const Napi::CallbackInfo& info);
Napi::Value setY(const Napi::CallbackInfo& info);
Napi::Value toAlignedRect(const Napi::CallbackInfo& info);
Napi::Value toRect(const Napi::CallbackInfo& info);
Napi::Value top(const Napi::CallbackInfo& info);
Napi::Value topLeft(const Napi::CallbackInfo& info);
Napi::Value topRight(const Napi::CallbackInfo& info);
Napi::Value translate(const Napi::CallbackInfo& info);
Napi::Value translate_QPoint(const Napi::CallbackInfo& info);
Napi::Value translated(const Napi::CallbackInfo& info);
Napi::Value translated_QPoint(const Napi::CallbackInfo& info);
Napi::Value transposed(const Napi::CallbackInfo& info);
Napi::Value united(const Napi::CallbackInfo& info);
Napi::Value width(const Napi::CallbackInfo& info);
Napi::Value x(const Napi::CallbackInfo& info);
Napi::Value y(const Napi::CallbackInfo& info);
};

View File

@ -0,0 +1,55 @@
#pragma once
#include <napi.h>
#include <QDragMoveEvent>
#include "Extras/Export/export.h"
#include "core/Component/component_macro.h"
/*
NOTE : QDragMoveEvent inherits from QDropEvent
- Is it possible to inherit from QDropEventWrap directly?
*/
class DLL_EXPORT QDragMoveEventWrap
: public Napi::ObjectWrap<QDragMoveEventWrap> {
COMPONENT_WRAPPED_METHODS_DECLARATION
private:
QDragMoveEvent* instance;
public:
static Napi::Object init(Napi::Env env, Napi::Object exports);
QDragMoveEventWrap(const Napi::CallbackInfo& info);
~QDragMoveEventWrap();
QDragMoveEvent* getInternalInstance();
// class constructor
static Napi::FunctionReference constructor;
// methods of QDragMoveEvent itself
// Napi::Value accept(const Napi::CallbackInfo& info); //already in qevent
Napi::Value answerRect(const Napi::CallbackInfo& info);
// Napi::Value ignore(const Napi::CallbackInfo& info); //already in qevent
// methods copied from QDropEvent
Napi::Value acceptProposedAction(const Napi::CallbackInfo& info);
Napi::Value dropAction(const Napi::CallbackInfo& info);
Napi::Value keyboardModifiers(const Napi::CallbackInfo& info);
Napi::Value mouseButtons(const Napi::CallbackInfo& info);
// Need to implement mimeData first?
// Napi::Value QDragMoveEventWrap::mimeData
Napi::Value pos(const Napi::CallbackInfo& info);
Napi::Value possibleActions(const Napi::CallbackInfo& info);
Napi::Value proposedAction(const Napi::CallbackInfo& info);
Napi::Value setDropAction(const Napi::CallbackInfo& info);
// Methods from QEvent (Not using macro because accept and ignore are overloaded)
Napi::Value accept(const Napi::CallbackInfo& info);
Napi::Value ignore(const Napi::CallbackInfo& info);
Napi::Value isAccepted(const Napi::CallbackInfo& info);
Napi::Value setAccepted(const Napi::CallbackInfo& info);
Napi::Value spontaneous(const Napi::CallbackInfo& info);
Napi::Value _type(const Napi::CallbackInfo& info);
};

View File

@ -0,0 +1,38 @@
#pragma once
#include <napi.h>
#include <QDropEvent>
#include "QtGui/QEvent/QEvent/qevent_macro.h"
#include "Extras/Export/export.h"
#include "core/Component/component_macro.h"
class DLL_EXPORT QDropEventWrap : public Napi::ObjectWrap<QDropEventWrap> {
COMPONENT_WRAPPED_METHODS_DECLARATION
private:
QDropEvent* instance;
public:
static Napi::Object init(Napi::Env env, Napi::Object exports);
QDropEventWrap(const Napi::CallbackInfo& info);
~QDropEventWrap();
QDropEvent* getInternalInstance();
// class constructor
static Napi::FunctionReference constructor;
// wrapped methods
Napi::Value acceptProposedAction(const Napi::CallbackInfo& info);
Napi::Value dropAction(const Napi::CallbackInfo& info);
Napi::Value keyboardModifiers(const Napi::CallbackInfo& info);
Napi::Value mouseButtons(const Napi::CallbackInfo& info);
// Need to implement mimeData first?
// Napi::Value QDropEventWrap::mimeData
Napi::Value pos(const Napi::CallbackInfo& info);
Napi::Value possibleActions(const Napi::CallbackInfo& info);
Napi::Value proposedAction(const Napi::CallbackInfo& info);
Napi::Value setDropAction(const Napi::CallbackInfo& info);
// Methods from QEvent
QEVENT_WRAPPED_METHODS_DECLARATION
};

View File

@ -0,0 +1,45 @@
#ifndef QEVENT_WRAPPED_METHODS_DECLARATION
#define QEVENT_WRAPPED_METHODS_DECLARATION \
Napi::Value accept(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
this->instance->accept(); \
return env.Null(); \
} \
Napi::Value ignore(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
this->instance->ignore(); \
return env.Null(); \
} \
Napi::Value isAccepted(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
bool v = this->instance->isAccepted(); \
return Napi::Boolean::From(env, v); \
} \
Napi::Value setAccepted(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
bool v = info[0].As<Napi::Boolean>().Value(); \
this->instance->setAccepted(v); \
return env.Null(); \
} \
Napi::Value spontaneous(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
bool v = this->instance->spontaneous(); \
return Napi::Boolean::From(env, v); \
} \
Napi::Value _type(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
int v = static_cast<int>(this->instance->type()); \
return Napi::Number::From(env, v); \
}
#endif
#ifndef QEVENT_WRAPPED_METHODS_EXPORT_DEFINE
#define QEVENT_WRAPPED_METHODS_EXPORT_DEFINE(WidgetWrapName) \
InstanceMethod("accept", &WidgetWrapName::accept), \
InstanceMethod("ignore", &WidgetWrapName::ignore), \
InstanceMethod("isAccepted", &WidgetWrapName::isAccepted), \
InstanceMethod("setAccepted", &WidgetWrapName::setAccepted), \
InstanceMethod("spontaneous", &WidgetWrapName::spontaneous), \
InstanceMethod("_type", &WidgetWrapName::_type), // Rename to _type to prevent conflict
#endif

View File

@ -23,7 +23,7 @@ class DLL_EXPORT QTabletEventWrap : public Napi::ObjectWrap<QTabletEventWrap> {
// wrapped methods
Napi::Value button(const Napi::CallbackInfo& info);
Napi::Value buttons(const Napi::CallbackInfo& info);
//Somehow this method isn't found on build?
// Somehow this method isn't found on build?
// Napi::Value deviceType(const Napi::CallbackInfo& info);
Napi::Value globalPos(const Napi::CallbackInfo& info);
Napi::Value globalPosF(const Napi::CallbackInfo& info);

View File

@ -25,4 +25,53 @@ class DLL_EXPORT QPainterPathWrap : public Napi::ObjectWrap<QPainterPathWrap> {
Napi::Value cubicTo(const Napi::CallbackInfo& info);
Napi::Value quadTo(const Napi::CallbackInfo& info);
Napi::Value closeSubpath(const Napi::CallbackInfo& info);
Napi::Value addEllipse(const Napi::CallbackInfo& info);
Napi::Value addPath(const Napi::CallbackInfo& info);
// Needs QVector, QPolygonF to be implemented
// Napi::Value addPolygon(const Napi::CallbackInfo& info);
// Needs QRegion to be implemented
// Napi::Value addRegion(const Napi::CallbackInfo& info);
Napi::Value addRoundedRect(const Napi::CallbackInfo& info);
Napi::Value addText(const Napi::CallbackInfo& info);
Napi::Value angleAtPercent(const Napi::CallbackInfo& info);
Napi::Value arcMoveTo(const Napi::CallbackInfo& info);
Napi::Value arcTo(const Napi::CallbackInfo& info);
Napi::Value boundingRect(const Napi::CallbackInfo& info);
Napi::Value capacity(const Napi::CallbackInfo& info);
Napi::Value clear(const Napi::CallbackInfo& info);
Napi::Value connectPath(const Napi::CallbackInfo& info);
// Needs to access internal QPointF, QRectF, or QPainterPath
// Napi::Value contains(const Napi::CallbackInfo& info);
Napi::Value controlPointRect(const Napi::CallbackInfo& info);
Napi::Value currentPosition(const Napi::CallbackInfo& info);
// Needs to implement QPainterPath::Element
// Napi::Value elementAt(const Napi::CallbackInfo& info);
Napi::Value elementCount(const Napi::CallbackInfo& info);
Napi::Value fillRule(const Napi::CallbackInfo& info);
// A bit complex, needs native object access
// Napi::Value intersected(const Napi::CallbackInfo& info);
Napi::Value intersects(const Napi::CallbackInfo& info);
Napi::Value isEmpty(const Napi::CallbackInfo& info);
Napi::Value length(const Napi::CallbackInfo& info);
Napi::Value percentAtLength(const Napi::CallbackInfo& info);
Napi::Value pointAtPercent(const Napi::CallbackInfo& info);
Napi::Value reserve(const Napi::CallbackInfo& info);
Napi::Value setElementPositionAt(const Napi::CallbackInfo& info);
Napi::Value setFillRule(const Napi::CallbackInfo& info);
// Requires creating another native object... Not sure about this
// Napi::Value simplified(const Napi::CallbackInfo& info);
Napi::Value slopeAtPercent(const Napi::CallbackInfo& info);
// Requires creating another native object
// Napi::Value subtracted(const Napi::CallbackInfo& info);
Napi::Value swap(const Napi::CallbackInfo& info);
// Requires creating another native object
// Napi::Value toFillPolygon(const Napi::CallbackInfo& info);
// Napi::Value toReversed(const Napi::CallbackInfo& info);
// Napi::Value toSubpathPolygons(const Napi::CallbackInfo& info);
// Requires creating another native object
Napi::Value translate(const Napi::CallbackInfo& info);
// Napi::Value translated(const Napi::CallbackInfo& info);
// Napi::Value united(const Napi::CallbackInfo& info);
};

View File

@ -420,6 +420,18 @@
qobject_cast<QGraphicsEffect*>(effectWrap->getInternalInstance()); \
this->instance->setGraphicsEffect(effect); \
return env.Null(); \
} \
Napi::Value acceptDrops(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
Napi::HandleScope scope(env); \
return Napi::Boolean::From(env, this->instance->acceptDrops()); \
} \
Napi::Value setAcceptDrops(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
Napi::HandleScope scope(env); \
bool v = info[0].As<Napi::Boolean>().Value(); \
this->instance->setAcceptDrops(v); \
return env.Null(); \
}
#endif // QWIDGET_WRAPPED_METHODS_DECLARATION
@ -479,7 +491,10 @@
InstanceMethod("addAction", &WidgetWrapName::addAction), \
InstanceMethod("removeAction", &WidgetWrapName::removeAction), \
InstanceMethod("repolish", &WidgetWrapName::repolish), \
InstanceMethod("setGraphicsEffect", &WidgetWrapName::setGraphicsEffect),
InstanceMethod("setGraphicsEffect", &WidgetWrapName::setGraphicsEffect),\
InstanceMethod("acceptDrops", &WidgetWrapName::acceptDrops), \
InstanceMethod("setAcceptDrops", &WidgetWrapName::setAcceptDrops),
#endif // QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE

View File

@ -14,6 +14,9 @@ Napi::Object QPointWrap::init(Napi::Env env, Napi::Object exports) {
InstanceMethod("x", &QPointWrap::x),
InstanceMethod("setY", &QPointWrap::setY),
InstanceMethod("y", &QPointWrap::y),
InstanceMethod("isNull", &QPointWrap::isNull),
InstanceMethod("manhattanLength", &QPointWrap::manhattanLength),
InstanceMethod("transposed", &QPointWrap::transposed),
StaticMethod("fromQVariant", &StaticQPointWrapMethods::fromQVariant),
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QPointWrap)});
constructor = Napi::Persistent(func);
@ -84,3 +87,26 @@ Napi::Value StaticQPointWrapMethods::fromQVariant(
{Napi::External<QPoint>::New(env, new QPoint(point))});
return instance;
}
Napi::Value QPointWrap::isNull(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Boolean::New(env, this->instance->isNull());
}
Napi::Value QPointWrap::manhattanLength(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Number::New(env, this->instance->manhattanLength());
}
Napi::Value QPointWrap::transposed(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QPoint ret = this->instance->transposed();
auto instance = QPointWrap::constructor.New(
{Napi::External<QPoint>::New(env, new QPoint(ret))});
return instance;
}

View File

@ -0,0 +1,132 @@
#include "QtCore/QPointF/qpointf_wrap.h"
#include "Extras/Utils/nutils.h"
#include "QtCore/QPoint/qpoint_wrap.h"
Napi::FunctionReference QPointFWrap::constructor;
Napi::Object QPointFWrap::init(Napi::Env env, Napi::Object exports) {
Napi::HandleScope scope(env);
char CLASSNAME[] = "QPointF";
Napi::Function func = DefineClass(
env, CLASSNAME,
{// Methods inherited from QDropEvent
InstanceMethod("isNull", &QPointFWrap::isNull),
InstanceMethod("manhattanLength", &QPointFWrap::manhattanLength),
InstanceMethod("setX", &QPointFWrap::setX),
InstanceMethod("setY", &QPointFWrap::setY),
InstanceMethod("toPoint", &QPointFWrap::toPoint),
InstanceMethod("transposed", &QPointFWrap::transposed),
InstanceMethod("x", &QPointFWrap::x),
InstanceMethod("y", &QPointFWrap::y),
StaticMethod("dotProduct", &StaticQPointFWrapMethods::dotProduct),
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QPointFWrap)});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
return exports;
}
QPointFWrap::~QPointFWrap() { this->instance.reset(); }
QPointF* QPointFWrap::getInternalInstance() { return this->instance.get(); }
QPointFWrap::QPointFWrap(const Napi::CallbackInfo& info)
: Napi::ObjectWrap<QPointFWrap>(info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
if (info.Length() == 2) {
qreal xpos = info[0].As<Napi::Number>().DoubleValue();
qreal ypos = info[1].As<Napi::Number>().DoubleValue();
this->instance = std::make_unique<QPointF>(xpos, ypos);
} else if (info.Length() == 1) {
this->instance =
std::unique_ptr<QPointF>(info[0].As<Napi::External<QPointF>>().Data());
} else if (info.Length() == 0) {
this->instance = std::make_unique<QPointF>();
} else {
Napi::TypeError::New(env, "Wrong number of arguments")
.ThrowAsJavaScriptException();
}
this->rawData = extrautils::configureComponent(this->getInternalInstance());
}
// Instance Methods Here
Napi::Value StaticQPointFWrapMethods::dotProduct(
const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Object wrap0_0 = info[0].As<Napi::Object>();
QPointFWrap* wrap0_1 = Napi::ObjectWrap<QPointFWrap>::Unwrap(wrap0_0);
QPointF* input0 = wrap0_1->getInternalInstance();
Napi::Object wrap1_0 = info[1].As<Napi::Object>();
QPointFWrap* wrap1_1 = Napi::ObjectWrap<QPointFWrap>::Unwrap(wrap1_0);
QPointF* input1 = wrap1_1->getInternalInstance();
return Napi::Number::New(env, QPointF::dotProduct(*input0, *input1));
}
Napi::Value QPointFWrap::isNull(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Boolean::New(env, this->instance->isNull());
}
Napi::Value QPointFWrap::manhattanLength(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Number::New(env, this->instance->manhattanLength());
}
Napi::Value QPointFWrap::setX(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
qreal input0 = info[0].As<Napi::Number>().DoubleValue();
this->instance->setX(input0);
return env.Null();
}
Napi::Value QPointFWrap::setY(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
qreal input0 = info[0].As<Napi::Number>().DoubleValue();
this->instance->setY(input0);
return env.Null();
}
Napi::Value QPointFWrap::toPoint(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QPoint ret = this->instance->toPoint();
auto instance = QPointWrap::constructor.New(
{Napi::External<QPoint>::New(env, new QPoint(ret))});
return instance;
}
Napi::Value QPointFWrap::transposed(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QPointF ret = this->instance->transposed();
auto instance = QPointFWrap::constructor.New(
{Napi::External<QPointF>::New(env, new QPointF(ret))});
return instance;
}
Napi::Value QPointFWrap::x(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Number::New(env, this->instance->x());
}
Napi::Value QPointFWrap::y(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Number::New(env, this->instance->y());
}

View File

@ -0,0 +1,666 @@
#include "QtCore/QRectF/qrectf_wrap.h"
#include "Extras/Utils/nutils.h"
#include "QtCore/QPointF/qpointf_wrap.h"
#include "QtCore/QRect/qrect_wrap.h"
Napi::FunctionReference QRectFWrap::constructor;
Napi::Object QRectFWrap::init(Napi::Env env, Napi::Object exports) {
Napi::HandleScope scope(env);
char CLASSNAME[] = "QRectF";
Napi::Function func = DefineClass(
env, CLASSNAME,
{InstanceMethod("adjust", &QRectFWrap::adjust),
InstanceMethod("adjusted", &QRectFWrap::adjusted),
InstanceMethod("bottom", &QRectFWrap::bottom),
InstanceMethod("bottomLeft", &QRectFWrap::bottomLeft),
InstanceMethod("bottomRight", &QRectFWrap::bottomRight),
InstanceMethod("center", &QRectFWrap::center),
InstanceMethod("contains", &QRectFWrap::contains),
InstanceMethod("contains_QRect", &QRectFWrap::contains_QRect),
InstanceMethod("contains_QPoint", &QRectFWrap::contains_QPoint),
InstanceMethod("height", &QRectFWrap::height),
InstanceMethod("intersected", &QRectFWrap::intersected),
InstanceMethod("intersects", &QRectFWrap::intersects),
InstanceMethod("isEmpty", &QRectFWrap::isEmpty),
InstanceMethod("isNull", &QRectFWrap::isNull),
InstanceMethod("isValid", &QRectFWrap::isValid),
InstanceMethod("left", &QRectFWrap::left),
InstanceMethod("moveBottom", &QRectFWrap::moveBottom),
InstanceMethod("moveBottomLeft", &QRectFWrap::moveBottomLeft),
InstanceMethod("moveBottomRight", &QRectFWrap::moveBottomRight),
InstanceMethod("moveCenter", &QRectFWrap::moveCenter),
InstanceMethod("moveLeft", &QRectFWrap::moveLeft),
InstanceMethod("moveRight", &QRectFWrap::moveRight),
InstanceMethod("moveTo", &QRectFWrap::moveTo),
InstanceMethod("moveTo_QPoint", &QRectFWrap::moveTo_QPoint),
InstanceMethod("moveTop", &QRectFWrap::moveTop),
InstanceMethod("moveTopLeft", &QRectFWrap::moveTopLeft),
InstanceMethod("moveTopRight", &QRectFWrap::moveTopRight),
InstanceMethod("normalized", &QRectFWrap::normalized),
InstanceMethod("right", &QRectFWrap::right),
InstanceMethod("setBottom", &QRectFWrap::setBottom),
InstanceMethod("setBottomLeft", &QRectFWrap::setBottomLeft),
InstanceMethod("setBottomRight", &QRectFWrap::setBottomRight),
InstanceMethod("setCoords", &QRectFWrap::setCoords),
InstanceMethod("setHeight", &QRectFWrap::setHeight),
InstanceMethod("setLeft", &QRectFWrap::setLeft),
InstanceMethod("setRect", &QRectFWrap::setRect),
InstanceMethod("setRight", &QRectFWrap::setRight),
InstanceMethod("setTop", &QRectFWrap::setTop),
InstanceMethod("setTopLeft", &QRectFWrap::setTopLeft),
InstanceMethod("setTopRight", &QRectFWrap::setTopRight),
InstanceMethod("setWidth", &QRectFWrap::setWidth),
InstanceMethod("setX", &QRectFWrap::setX),
InstanceMethod("setY", &QRectFWrap::setY),
InstanceMethod("toAlignedRect", &QRectFWrap::toAlignedRect),
InstanceMethod("toRect", &QRectFWrap::toRect),
InstanceMethod("top", &QRectFWrap::top),
InstanceMethod("topLeft", &QRectFWrap::topLeft),
InstanceMethod("topRight", &QRectFWrap::topRight),
InstanceMethod("translate", &QRectFWrap::translate),
InstanceMethod("translate_QPoint", &QRectFWrap::translate_QPoint),
InstanceMethod("translated", &QRectFWrap::translated),
InstanceMethod("translated_QPoint", &QRectFWrap::translated_QPoint),
InstanceMethod("transposed", &QRectFWrap::transposed),
InstanceMethod("united", &QRectFWrap::united),
InstanceMethod("width", &QRectFWrap::width),
InstanceMethod("x", &QRectFWrap::x),
InstanceMethod("y", &QRectFWrap::y),
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QRectFWrap)});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
return exports;
}
QRectF* QRectFWrap::getInternalInstance() { return this->instance.get(); }
QRectFWrap::~QRectFWrap() { this->instance.reset(); }
QRectFWrap::QRectFWrap(const Napi::CallbackInfo& info)
: Napi::ObjectWrap<QRectFWrap>(info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
if (info.Length() == 4) {
qreal x = info[0].As<Napi::Number>().DoubleValue();
qreal y = info[1].As<Napi::Number>().DoubleValue();
qreal width = info[2].As<Napi::Number>().DoubleValue();
qreal height = info[3].As<Napi::Number>().DoubleValue();
this->instance = std::make_unique<QRectF>(x, y, width, height);
} else if (info.Length() == 1) {
this->instance =
std::unique_ptr<QRectF>(info[0].As<Napi::External<QRectF>>().Data());
} else if (info.Length() == 0) {
this->instance = std::make_unique<QRectF>();
} else {
Napi::TypeError::New(env, "Wrong number of arguments")
.ThrowAsJavaScriptException();
}
this->rawData = extrautils::configureComponent(this->getInternalInstance());
}
// Instance Methods Here
Napi::Value QRectFWrap::adjust(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
qreal input0 = info[0].As<Napi::Number>().DoubleValue();
qreal input1 = info[1].As<Napi::Number>().DoubleValue();
qreal input2 = info[2].As<Napi::Number>().DoubleValue();
qreal input3 = info[3].As<Napi::Number>().DoubleValue();
this->instance->adjust(input0, input1, input2, input3);
return env.Null();
}
Napi::Value QRectFWrap::adjusted(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
qreal input0 = info[0].As<Napi::Number>().DoubleValue();
qreal input1 = info[1].As<Napi::Number>().DoubleValue();
qreal input2 = info[2].As<Napi::Number>().DoubleValue();
qreal input3 = info[3].As<Napi::Number>().DoubleValue();
QRectF ret = this->instance->adjusted(input0, input1, input2, input3);
auto instance = QRectFWrap::constructor.New(
{Napi::External<QRectF>::New(env, new QRectF(ret))});
return instance;
}
Napi::Value QRectFWrap::bottom(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Number::New(env, this->instance->bottom());
}
Napi::Value QRectFWrap::bottomLeft(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QPointF ret = this->instance->bottomLeft();
auto instance = QPointFWrap::constructor.New(
{Napi::External<QPointF>::New(env, new QPointF(ret))});
return instance;
}
Napi::Value QRectFWrap::bottomRight(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QPointF ret = this->instance->bottomRight();
auto instance = QPointFWrap::constructor.New(
{Napi::External<QPointF>::New(env, new QPointF(ret))});
return instance;
}
Napi::Value QRectFWrap::center(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QPointF ret = this->instance->center();
auto instance = QPointFWrap::constructor.New(
{Napi::External<QPointF>::New(env, new QPointF(ret))});
return instance;
}
Napi::Value QRectFWrap::contains_QPoint(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Object wrap0_0 = info[0].As<Napi::Object>();
QPointFWrap* wrap0_1 = Napi::ObjectWrap<QPointFWrap>::Unwrap(wrap0_0);
QPointF* input0 = wrap0_1->getInternalInstance();
return Napi::Boolean::New(env, this->instance->contains(*input0));
}
Napi::Value QRectFWrap::contains_QRect(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Object wrap0_0 = info[0].As<Napi::Object>();
QRectFWrap* wrap0_1 = Napi::ObjectWrap<QRectFWrap>::Unwrap(wrap0_0);
QRectF* input0 = wrap0_1->getInternalInstance();
return Napi::Boolean::New(env, this->instance->contains(*input0));
}
Napi::Value QRectFWrap::contains(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
qreal input0 = info[0].As<Napi::Number>().DoubleValue();
qreal input1 = info[1].As<Napi::Number>().DoubleValue();
return Napi::Boolean::New(env, this->instance->contains(input0, input1));
}
Napi::Value QRectFWrap::height(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Number::New(env, this->instance->height());
}
Napi::Value QRectFWrap::intersected(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Object wrap0_0 = info[0].As<Napi::Object>();
QRectFWrap* wrap0_1 = Napi::ObjectWrap<QRectFWrap>::Unwrap(wrap0_0);
QRectF* input0 = wrap0_1->getInternalInstance();
QRectF ret = this->instance->intersected(*input0);
auto instance = QRectFWrap::constructor.New(
{Napi::External<QRectF>::New(env, new QRectF(ret))});
return instance;
}
Napi::Value QRectFWrap::intersects(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Object wrap0_0 = info[0].As<Napi::Object>();
QRectFWrap* wrap0_1 = Napi::ObjectWrap<QRectFWrap>::Unwrap(wrap0_0);
QRectF* input0 = wrap0_1->getInternalInstance();
return Napi::Boolean::New(env, this->instance->intersects(*input0));
}
Napi::Value QRectFWrap::isEmpty(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Boolean::New(env, this->instance->isEmpty());
}
Napi::Value QRectFWrap::isNull(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Boolean::New(env, this->instance->isNull());
}
Napi::Value QRectFWrap::isValid(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Boolean::New(env, this->instance->isValid());
}
Napi::Value QRectFWrap::left(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Number::New(env, this->instance->left());
}
Napi::Value QRectFWrap::moveBottom(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
qreal input0 = info[0].As<Napi::Number>().DoubleValue();
this->instance->moveBottom(input0);
return env.Null();
}
Napi::Value QRectFWrap::moveBottomLeft(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Object wrap0_0 = info[0].As<Napi::Object>();
QPointFWrap* wrap0_1 = Napi::ObjectWrap<QPointFWrap>::Unwrap(wrap0_0);
QPointF* input0 = wrap0_1->getInternalInstance();
this->instance->moveBottomLeft(*input0);
return env.Null();
}
Napi::Value QRectFWrap::moveBottomRight(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Object wrap0_0 = info[0].As<Napi::Object>();
QPointFWrap* wrap0_1 = Napi::ObjectWrap<QPointFWrap>::Unwrap(wrap0_0);
QPointF* input0 = wrap0_1->getInternalInstance();
this->instance->moveBottomRight(*input0);
return env.Null();
}
Napi::Value QRectFWrap::moveCenter(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Object wrap0_0 = info[0].As<Napi::Object>();
QPointFWrap* wrap0_1 = Napi::ObjectWrap<QPointFWrap>::Unwrap(wrap0_0);
QPointF* input0 = wrap0_1->getInternalInstance();
this->instance->moveCenter(*input0);
return env.Null();
}
Napi::Value QRectFWrap::moveLeft(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
qreal input0 = info[0].As<Napi::Number>().DoubleValue();
this->instance->moveLeft(input0);
return env.Null();
}
Napi::Value QRectFWrap::moveRight(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
qreal input0 = info[0].As<Napi::Number>().DoubleValue();
this->instance->moveRight(input0);
return env.Null();
}
Napi::Value QRectFWrap::moveTo(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
qreal input0 = info[0].As<Napi::Number>().DoubleValue();
qreal input1 = info[1].As<Napi::Number>().DoubleValue();
this->instance->moveTo(input0, input1);
return env.Null();
}
Napi::Value QRectFWrap::moveTo_QPoint(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Object wrap0_0 = info[0].As<Napi::Object>();
QPointFWrap* wrap0_1 = Napi::ObjectWrap<QPointFWrap>::Unwrap(wrap0_0);
QPointF* input0 = wrap0_1->getInternalInstance();
this->instance->moveTo(*input0);
return env.Null();
}
Napi::Value QRectFWrap::moveTop(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
qreal input0 = info[0].As<Napi::Number>().DoubleValue();
this->instance->moveTop(input0);
return env.Null();
}
Napi::Value QRectFWrap::moveTopLeft(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Object wrap0_0 = info[0].As<Napi::Object>();
QPointFWrap* wrap0_1 = Napi::ObjectWrap<QPointFWrap>::Unwrap(wrap0_0);
QPointF* input0 = wrap0_1->getInternalInstance();
this->instance->moveTopLeft(*input0);
return env.Null();
}
Napi::Value QRectFWrap::moveTopRight(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Object wrap0_0 = info[0].As<Napi::Object>();
QPointFWrap* wrap0_1 = Napi::ObjectWrap<QPointFWrap>::Unwrap(wrap0_0);
QPointF* input0 = wrap0_1->getInternalInstance();
this->instance->moveTopRight(*input0);
return env.Null();
}
Napi::Value QRectFWrap::normalized(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QRectF ret = this->instance->normalized();
auto instance = QRectFWrap::constructor.New(
{Napi::External<QRectF>::New(env, new QRectF(ret))});
return instance;
}
Napi::Value QRectFWrap::right(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Number::New(env, this->instance->right());
}
Napi::Value QRectFWrap::setBottom(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
qreal input0 = info[0].As<Napi::Number>().DoubleValue();
this->instance->setBottom(input0);
return env.Null();
}
Napi::Value QRectFWrap::setBottomLeft(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Object wrap0_0 = info[0].As<Napi::Object>();
QPointFWrap* wrap0_1 = Napi::ObjectWrap<QPointFWrap>::Unwrap(wrap0_0);
QPointF* input0 = wrap0_1->getInternalInstance();
this->instance->setBottomLeft(*input0);
return env.Null();
}
Napi::Value QRectFWrap::setBottomRight(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Object wrap0_0 = info[0].As<Napi::Object>();
QPointFWrap* wrap0_1 = Napi::ObjectWrap<QPointFWrap>::Unwrap(wrap0_0);
QPointF* input0 = wrap0_1->getInternalInstance();
this->instance->setBottomRight(*input0);
return env.Null();
}
Napi::Value QRectFWrap::setCoords(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
qreal input0 = info[0].As<Napi::Number>().DoubleValue();
qreal input1 = info[1].As<Napi::Number>().DoubleValue();
qreal input2 = info[2].As<Napi::Number>().DoubleValue();
qreal input3 = info[3].As<Napi::Number>().DoubleValue();
this->instance->setCoords(input0, input1, input2, input3);
return env.Null();
}
Napi::Value QRectFWrap::setHeight(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
qreal input0 = info[0].As<Napi::Number>().DoubleValue();
this->instance->setHeight(input0);
return env.Null();
}
Napi::Value QRectFWrap::setLeft(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
qreal input0 = info[0].As<Napi::Number>().DoubleValue();
this->instance->setLeft(input0);
return env.Null();
}
Napi::Value QRectFWrap::setRect(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
qreal input0 = info[0].As<Napi::Number>().DoubleValue();
qreal input1 = info[1].As<Napi::Number>().DoubleValue();
qreal input2 = info[2].As<Napi::Number>().DoubleValue();
qreal input3 = info[3].As<Napi::Number>().DoubleValue();
this->instance->setRect(input0, input1, input2, input3);
return env.Null();
}
Napi::Value QRectFWrap::setRight(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
qreal input0 = info[0].As<Napi::Number>().DoubleValue();
this->instance->setRight(input0);
return env.Null();
}
Napi::Value QRectFWrap::setTop(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
qreal input0 = info[0].As<Napi::Number>().DoubleValue();
this->instance->setTop(input0);
return env.Null();
}
Napi::Value QRectFWrap::setTopLeft(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Object wrap0_0 = info[0].As<Napi::Object>();
QPointFWrap* wrap0_1 = Napi::ObjectWrap<QPointFWrap>::Unwrap(wrap0_0);
QPointF* input0 = wrap0_1->getInternalInstance();
this->instance->setTopLeft(*input0);
return env.Null();
}
Napi::Value QRectFWrap::setTopRight(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Object wrap0_0 = info[0].As<Napi::Object>();
QPointFWrap* wrap0_1 = Napi::ObjectWrap<QPointFWrap>::Unwrap(wrap0_0);
QPointF* input0 = wrap0_1->getInternalInstance();
this->instance->setTopRight(*input0);
return env.Null();
}
Napi::Value QRectFWrap::setWidth(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
qreal input0 = info[0].As<Napi::Number>().DoubleValue();
this->instance->setWidth(input0);
return env.Null();
}
Napi::Value QRectFWrap::setX(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
qreal input0 = info[0].As<Napi::Number>().DoubleValue();
this->instance->setX(input0);
return env.Null();
}
Napi::Value QRectFWrap::setY(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
qreal input0 = info[0].As<Napi::Number>().DoubleValue();
this->instance->setY(input0);
return env.Null();
}
Napi::Value QRectFWrap::toAlignedRect(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QRect ret = this->instance->toAlignedRect();
auto instance = QRectWrap::constructor.New(
{Napi::External<QRect>::New(env, new QRect(ret))});
return instance;
}
Napi::Value QRectFWrap::toRect(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QRect ret = this->instance->toRect();
auto instance = QRectWrap::constructor.New(
{Napi::External<QRect>::New(env, new QRect(ret))});
return instance;
}
Napi::Value QRectFWrap::top(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Number::New(env, this->instance->top());
}
Napi::Value QRectFWrap::topLeft(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QPointF ret = this->instance->topLeft();
auto instance = QPointFWrap::constructor.New(
{Napi::External<QPointF>::New(env, new QPointF(ret))});
return instance;
}
Napi::Value QRectFWrap::topRight(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QPointF ret = this->instance->topRight();
auto instance = QPointFWrap::constructor.New(
{Napi::External<QPointF>::New(env, new QPointF(ret))});
return instance;
}
Napi::Value QRectFWrap::translate(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
qreal input0 = info[0].As<Napi::Number>().DoubleValue();
qreal input1 = info[1].As<Napi::Number>().DoubleValue();
this->instance->translate(input0, input1);
return env.Null();
}
Napi::Value QRectFWrap::translate_QPoint(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Object wrap0_0 = info[0].As<Napi::Object>();
QPointFWrap* wrap0_1 = Napi::ObjectWrap<QPointFWrap>::Unwrap(wrap0_0);
QPointF* input0 = wrap0_1->getInternalInstance();
this->instance->translate(*input0);
return env.Null();
}
Napi::Value QRectFWrap::translated(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
qreal input0 = info[0].As<Napi::Number>().DoubleValue();
qreal input1 = info[1].As<Napi::Number>().DoubleValue();
QRectF ret = this->instance->translated(input0, input1);
auto instance = QRectFWrap::constructor.New(
{Napi::External<QRectF>::New(env, new QRectF(ret))});
return instance;
}
Napi::Value QRectFWrap::translated_QPoint(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Object wrap0_0 = info[0].As<Napi::Object>();
QPointFWrap* wrap0_1 = Napi::ObjectWrap<QPointFWrap>::Unwrap(wrap0_0);
QPointF* input0 = wrap0_1->getInternalInstance();
QRectF ret = this->instance->translated(*input0);
auto instance = QRectFWrap::constructor.New(
{Napi::External<QRectF>::New(env, new QRectF(ret))});
return instance;
}
Napi::Value QRectFWrap::transposed(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
QRectF ret = this->instance->transposed();
auto instance = QRectFWrap::constructor.New(
{Napi::External<QRectF>::New(env, new QRectF(ret))});
return instance;
}
Napi::Value QRectFWrap::united(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Object wrap0_0 = info[0].As<Napi::Object>();
QRectFWrap* wrap0_1 = Napi::ObjectWrap<QRectFWrap>::Unwrap(wrap0_0);
QRectF* input0 = wrap0_1->getInternalInstance();
QRectF ret = this->instance->united(*input0);
auto instance = QRectFWrap::constructor.New(
{Napi::External<QRectF>::New(env, new QRectF(ret))});
return instance;
}
Napi::Value QRectFWrap::width(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Number::New(env, this->instance->width());
}
Napi::Value QRectFWrap::x(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Number::New(env, this->instance->x());
}
Napi::Value QRectFWrap::y(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
return Napi::Number::New(env, this->instance->y());
}

View File

@ -0,0 +1,223 @@
#include "QtGui/QEvent/QDragMoveEvent/qdragmoveevent_wrap.h"
#include "QtCore/QRect/qrect_wrap.h"
#include <QPoint>
#include "Extras/Utils/nutils.h"
Napi::FunctionReference QDragMoveEventWrap::constructor;
Napi::Object QDragMoveEventWrap::init(Napi::Env env, Napi::Object exports) {
Napi::HandleScope scope(env);
char CLASSNAME[] = "QDragMoveEvent";
Napi::Function func = DefineClass(
env, CLASSNAME,
{// Methods inherited from QDropEvent
InstanceMethod("acceptProposedAction",
&QDragMoveEventWrap::acceptProposedAction),
InstanceMethod("dropAction", &QDragMoveEventWrap::dropAction),
InstanceMethod("keyboardModifiers",
&QDragMoveEventWrap::keyboardModifiers),
// InstanceMethod("mimeData", &QDragMoveEventWrap::mimeData),
InstanceMethod("mouseButtons", &QDragMoveEventWrap::mouseButtons),
InstanceMethod("pos", &QDragMoveEventWrap::pos),
InstanceMethod("possibleActions", &QDragMoveEventWrap::possibleActions),
InstanceMethod("proposedAction", &QDragMoveEventWrap::proposedAction),
// InstanceMethod("source", &QDragMoveEventWrap::source),
// Methods inherited from QEvent
InstanceMethod("accept", &QDragMoveEventWrap::accept),
InstanceMethod("ignore", &QDragMoveEventWrap::ignore),
InstanceMethod("isAccepted", &QDragMoveEventWrap::isAccepted),
InstanceMethod("setAccepted", &QDragMoveEventWrap::setAccepted),
InstanceMethod("spontaneous", &QDragMoveEventWrap::spontaneous),
InstanceMethod(
"_type",
&QDragMoveEventWrap::_type), // Rename to _type to prevent conflict
// Methods of this class
InstanceMethod("answerRect", &QDragMoveEventWrap::proposedAction),
// accept and ignore are re-implementations of qevent ones
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QDragMoveEventWrap)});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
return exports;
}
QDragMoveEvent* QDragMoveEventWrap::getInternalInstance() {
return this->instance;
}
QDragMoveEventWrap::QDragMoveEventWrap(const Napi::CallbackInfo& info)
: Napi::ObjectWrap<QDragMoveEventWrap>(info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
if (info.Length() == 1) {
Napi::External<QDragMoveEvent> eventObject =
info[0].As<Napi::External<QDragMoveEvent>>();
this->instance = static_cast<QDragMoveEvent*>(eventObject.Data());
} else {
Napi::TypeError::New(env, "Wrong number of arguments")
.ThrowAsJavaScriptException();
}
this->rawData = extrautils::configureComponent(this->getInternalInstance());
}
QDragMoveEventWrap::~QDragMoveEventWrap() {
// Do not destroy instance here. It will be done by Qt Event loop.
}
Napi::Value QDragMoveEventWrap::acceptProposedAction(
const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
this->instance->acceptProposedAction();
return env.Null();
}
Napi::Value QDragMoveEventWrap::dropAction(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
int action = static_cast<int>(this->instance->dropAction());
return Napi::Number::From(env, action);
}
Napi::Value QDragMoveEventWrap::keyboardModifiers(
const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
int modifierFlags = static_cast<int>(this->instance->keyboardModifiers());
return Napi::Number::From(env, modifierFlags);
}
Napi::Value QDragMoveEventWrap::mouseButtons(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
int m = static_cast<int>(this->instance->mouseButtons());
return Napi::Number::From(env, m);
}
// TODO: Implement MimeData to do this...
// Napi::Value QDragMoveEventWrap::mimeData(const Napi::CallbackInfo& info) {
// Napi::Env env = info.Env();
// int modifierFlags = static_cast<int>(this->instance->keyboardModifiers());
// return Napi::Number::From(env, modifierFlags);
// }
Napi::Value QDragMoveEventWrap::pos(const Napi::CallbackInfo& info) {
// Uses QPoint
Napi::Env env = info.Env();
QPoint point = static_cast<QPoint>(this->instance->pos());
int x = static_cast<int>(point.x());
int y = static_cast<int>(point.y());
Napi::Object obj = Napi::Object::New(env);
obj.Set("x", Napi::Number::From(env, x));
obj.Set("y", Napi::Number::From(env, y));
return obj;
}
Napi::Value QDragMoveEventWrap::possibleActions(
const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
int v = static_cast<int>(this->instance->possibleActions());
return Napi::Number::From(env, v);
}
Napi::Value QDragMoveEventWrap::proposedAction(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
int v = static_cast<int>(this->instance->possibleActions());
return Napi::Number::From(env, v);
}
Napi::Value QDragMoveEventWrap::setDropAction(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
int dropFlags;
if (info.Length() < 1) {
dropFlags = 1; // Default to copy operation
return env.Null();
} else {
Napi::Number num = info[0].ToNumber();
dropFlags = static_cast<int>(num.Int32Value());
}
this->instance->setDropAction(static_cast<Qt::DropAction>(dropFlags));
return env.Null();
}
// Needs QWidget references... should I ?
// Napi::Value QDragMoveEventWrap::source(const Napi::CallbackInfo& info) {
// Napi::Env env = info.Env();
// return env.Null();
// }
Napi::Value QDragMoveEventWrap::accept(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
if (info.Length() == 4) {
int x = info[0].As<Napi::Number>().Int32Value();
int y = info[1].As<Napi::Number>().Int32Value();
int width = info[2].As<Napi::Number>().Int32Value();
int height = info[3].As<Napi::Number>().Int32Value();
this->instance->accept(QRect(x, y, width, height));
} else if (info.Length() == 1) {
Napi::Object wrap0_0 = info[0].As<Napi::Object>();
QRectWrap* wrap0_1 = Napi::ObjectWrap<QRectWrap>::Unwrap(wrap0_0);
QRect* input0 = wrap0_1->getInternalInstance();
this->instance->accept(*input0);
} else {
this->instance->accept();
}
return env.Null();
}
Napi::Value QDragMoveEventWrap::answerRect(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
QRect r = static_cast<QRect>(this->instance->answerRect());
int x = static_cast<int>(r.x());
int y = static_cast<int>(r.y());
int w = static_cast<int>(r.width());
int h = static_cast<int>(r.height());
Napi::Object obj = Napi::Object::New(env);
obj.Set("x", Napi::Number::From(env, x));
obj.Set("y", Napi::Number::From(env, y));
obj.Set("width", Napi::Number::From(env, w));
obj.Set("height", Napi::Number::From(env, h));
return obj;
}
Napi::Value QDragMoveEventWrap::ignore(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
if (info.Length() == 4) {
int x = info[0].As<Napi::Number>().Int32Value();
int y = info[1].As<Napi::Number>().Int32Value();
int width = info[2].As<Napi::Number>().Int32Value();
int height = info[3].As<Napi::Number>().Int32Value();
this->instance->ignore(QRect(x, y, width, height));
}else if (info.Length() == 1) {
Napi::Object wrap0_0 = info[0].As<Napi::Object>();
QRectWrap* wrap0_1 = Napi::ObjectWrap<QRectWrap>::Unwrap(wrap0_0);
QRect* input0 = wrap0_1->getInternalInstance();
this->instance->ignore(*input0);
} else {
this->instance->ignore();
}
return env.Null();
}
// Methods from QEvent --------------------------------------------
// accept and ignore are reimplemented above
Napi::Value QDragMoveEventWrap::isAccepted(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
bool v = this->instance->isAccepted();
return Napi::Boolean::From(env, v);
}
Napi::Value QDragMoveEventWrap::setAccepted(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
bool v = info[0].As<Napi::Boolean>().Value();
this->instance->setAccepted(v);
return env.Null();
}
Napi::Value QDragMoveEventWrap::spontaneous(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
bool v = this->instance->spontaneous();
return Napi::Boolean::From(env, v);
}
Napi::Value QDragMoveEventWrap::_type(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
int v = static_cast<int>(this->instance->type());
return Napi::Number::From(env, v);
}

View File

@ -0,0 +1,131 @@
#include "QtGui/QEvent/QDropEvent/qdropevent_wrap.h"
#include <QPoint>
#include "Extras/Utils/nutils.h"
Napi::FunctionReference QDropEventWrap::constructor;
Napi::Object QDropEventWrap::init(Napi::Env env, Napi::Object exports) {
Napi::HandleScope scope(env);
char CLASSNAME[] = "QDropEvent";
Napi::Function func = DefineClass(
env, CLASSNAME,
{InstanceMethod("acceptProposedAction",
&QDropEventWrap::acceptProposedAction),
InstanceMethod("dropAction", &QDropEventWrap::dropAction),
InstanceMethod("keyboardModifiers", &QDropEventWrap::keyboardModifiers),
// InstanceMethod("mimeData", &QDropEventWrap::mimeData),
InstanceMethod("mouseButtons", &QDropEventWrap::mouseButtons),
InstanceMethod("pos", &QDropEventWrap::pos),
InstanceMethod("possibleActions", &QDropEventWrap::possibleActions),
InstanceMethod("proposedAction", &QDropEventWrap::proposedAction),
// InstanceMethod("source", &QDropEventWrap::source),
// Methods inherited from QEvent
QEVENT_WRAPPED_METHODS_EXPORT_DEFINE(QDropEventWrap)
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QDropEventWrap)});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
return exports;
}
QDropEvent* QDropEventWrap::getInternalInstance() { return this->instance; }
QDropEventWrap::QDropEventWrap(const Napi::CallbackInfo& info)
: Napi::ObjectWrap<QDropEventWrap>(info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
if (info.Length() == 1) {
Napi::External<QDropEvent> eventObject =
info[0].As<Napi::External<QDropEvent>>();
this->instance = static_cast<QDropEvent*>(eventObject.Data());
} else {
Napi::TypeError::New(env, "Wrong number of arguments")
.ThrowAsJavaScriptException();
}
this->rawData = extrautils::configureComponent(this->getInternalInstance());
}
QDropEventWrap::~QDropEventWrap() {
// Do not destroy instance here. It will be done by Qt Event loop.
}
Napi::Value QDropEventWrap::acceptProposedAction(
const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
this->instance->acceptProposedAction();
return env.Null();
}
Napi::Value QDropEventWrap::dropAction(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
int action = static_cast<int>(this->instance->dropAction());
return Napi::Number::From(env, action);
}
Napi::Value QDropEventWrap::keyboardModifiers(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
int modifierFlags = static_cast<int>(this->instance->keyboardModifiers());
return Napi::Number::From(env, modifierFlags);
}
Napi::Value QDropEventWrap::mouseButtons(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
int m = static_cast<int>(this->instance->mouseButtons());
return Napi::Number::From(env, m);
}
// TODO: Implement MimeData to do this...
// Napi::Value QDropEventWrap::mimeData(const Napi::CallbackInfo& info) {
// Napi::Env env = info.Env();
// int modifierFlags = static_cast<int>(this->instance->keyboardModifiers());
// return Napi::Number::From(env, modifierFlags);
// }
Napi::Value QDropEventWrap::pos(const Napi::CallbackInfo& info) {
// Uses QPoint
Napi::Env env = info.Env();
QPoint point = static_cast<QPoint>(this->instance->pos());
int x = static_cast<int>(point.x());
int y = static_cast<int>(point.y());
Napi::Object obj = Napi::Object::New(env);
obj.Set("x", Napi::Number::From(env, x));
obj.Set("y", Napi::Number::From(env, y));
return obj;
}
Napi::Value QDropEventWrap::possibleActions(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
int v = static_cast<int>(this->instance->possibleActions());
return Napi::Number::From(env, v);
}
Napi::Value QDropEventWrap::proposedAction(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
int v = static_cast<int>(this->instance->possibleActions());
return Napi::Number::From(env, v);
}
Napi::Value QDropEventWrap::setDropAction(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
int dropFlags;
if (info.Length() < 1) {
dropFlags = 1; // Default to copy operation
return env.Null();
} else {
Napi::Number num = info[0].ToNumber();
dropFlags = static_cast<int>(num.Int32Value());
}
this->instance->setDropAction(static_cast<Qt::DropAction>(dropFlags));
return env.Null();
}
// Needs QWidget references... should I ?
// Napi::Value QDropEventWrap::source(const Napi::CallbackInfo& info) {
// Napi::Env env = info.Env();
// return env.Null();
// }
// Methods from QEvent defined in Macro already

View File

@ -15,7 +15,7 @@ Napi::Object QTabletEventWrap::init(Napi::Env env, Napi::Object exports) {
env, CLASSNAME,
{InstanceMethod("button", &QTabletEventWrap::button),
InstanceMethod("buttons", &QTabletEventWrap::buttons),
// InstanceMethod("deviceType", &QTabletEventWrap::deviceType),
// InstanceMethod("deviceType", &QTabletEventWrap::deviceType),
InstanceMethod("globalPos", &QTabletEventWrap::globalPos),
InstanceMethod("globalPosF", &QTabletEventWrap::globalPosF),
InstanceMethod("globalX", &QTabletEventWrap::globalX),
@ -25,7 +25,8 @@ Napi::Object QTabletEventWrap::init(Napi::Env env, Napi::Object exports) {
InstanceMethod("posF", &QTabletEventWrap::posF),
InstanceMethod("pressure", &QTabletEventWrap::pressure),
InstanceMethod("rotation", &QTabletEventWrap::rotation),
InstanceMethod("tangentialPressure", &QTabletEventWrap::tangentialPressure),
InstanceMethod("tangentialPressure",
&QTabletEventWrap::tangentialPressure),
InstanceMethod("uniqueId", &QTabletEventWrap::uniqueId),
InstanceMethod("x", &QTabletEventWrap::x),
InstanceMethod("xTilt", &QTabletEventWrap::xTilt),
@ -60,7 +61,6 @@ QTabletEventWrap::~QTabletEventWrap() {
// Do not destroy instance here. It will be done by Qt Event loop.
}
Napi::Value QTabletEventWrap::button(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
int b = static_cast<int>(this->instance->button());
@ -145,7 +145,8 @@ Napi::Value QTabletEventWrap::rotation(const Napi::CallbackInfo& info) {
qreal v = static_cast<qreal>(this->instance->rotation());
return Napi::Number::From(env, v);
}
Napi::Value QTabletEventWrap::tangentialPressure(const Napi::CallbackInfo& info) {
Napi::Value QTabletEventWrap::tangentialPressure(
const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
qreal v = static_cast<qreal>(this->instance->tangentialPressure());
return Napi::Number::From(env, v);

View File

@ -1,7 +1,10 @@
#include "QtWidgets/QPainterPath/qpainterpath_wrap.h"
#include <iostream>
#include "Extras/Utils/nutils.h"
#include "QtCore/QPoint/qpoint_wrap.h"
#include "QtGui/QFont/qfont_wrap.h"
Napi::FunctionReference QPainterPathWrap::constructor;
@ -16,6 +19,34 @@ Napi::Object QPainterPathWrap::init(Napi::Env env, Napi::Object exports) {
InstanceMethod("cubicTo", &QPainterPathWrap::cubicTo),
InstanceMethod("quadTo", &QPainterPathWrap::quadTo),
InstanceMethod("closeSubpath", &QPainterPathWrap::closeSubpath),
InstanceMethod("addEllipse", &QPainterPathWrap::addEllipse),
InstanceMethod("addPath", &QPainterPathWrap::addPath),
InstanceMethod("addRect", &QPainterPathWrap::addRect),
InstanceMethod("addRoundedRect", &QPainterPathWrap::addRoundedRect),
InstanceMethod("addText", &QPainterPathWrap::addText),
InstanceMethod("angleAtPercent", &QPainterPathWrap::angleAtPercent),
InstanceMethod("arcMoveTo", &QPainterPathWrap::arcMoveTo),
InstanceMethod("arcTo", &QPainterPathWrap::arcTo),
InstanceMethod("boundingRect", &QPainterPathWrap::boundingRect),
InstanceMethod("capacity", &QPainterPathWrap::capacity),
InstanceMethod("clear", &QPainterPathWrap::clear),
InstanceMethod("connectPath", &QPainterPathWrap::connectPath),
InstanceMethod("controlPointRect", &QPainterPathWrap::controlPointRect),
InstanceMethod("currentPosition", &QPainterPathWrap::currentPosition),
InstanceMethod("elementCount", &QPainterPathWrap::elementCount),
InstanceMethod("fillRule", &QPainterPathWrap::fillRule),
InstanceMethod("intersects", &QPainterPathWrap::intersects),
InstanceMethod("isEmpty", &QPainterPathWrap::isEmpty),
InstanceMethod("length", &QPainterPathWrap::length),
InstanceMethod("percentAtLength", &QPainterPathWrap::percentAtLength),
InstanceMethod("pointAtPercent", &QPainterPathWrap::pointAtPercent),
InstanceMethod("reserve", &QPainterPathWrap::reserve),
InstanceMethod("setElementPositionAt",
&QPainterPathWrap::setElementPositionAt),
InstanceMethod("setFillRule", &QPainterPathWrap::setFillRule),
InstanceMethod("slopeAtPercent", &QPainterPathWrap::slopeAtPercent),
InstanceMethod("swap", &QPainterPathWrap::swap),
InstanceMethod("translate", &QPainterPathWrap::translate),
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QPainterPathWrap)});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
@ -43,48 +74,48 @@ QPainterPathWrap::QPainterPathWrap(const Napi::CallbackInfo& info)
Napi::Value QPainterPathWrap::moveTo(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
int x = info[0].As<Napi::Number>().Int32Value();
int y = info[1].As<Napi::Number>().Int32Value();
qreal x = info[0].As<Napi::Number>().DoubleValue();
qreal y = info[1].As<Napi::Number>().DoubleValue();
this->instance->moveTo(x, y);
return env.Null();
}
Napi::Value QPainterPathWrap::addRect(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
int x = info[0].As<Napi::Number>().Int32Value();
int y = info[1].As<Napi::Number>().Int32Value();
int width = info[2].As<Napi::Number>().Int32Value();
int height = info[3].As<Napi::Number>().Int32Value();
qreal x = info[0].As<Napi::Number>().DoubleValue();
qreal y = info[1].As<Napi::Number>().DoubleValue();
qreal width = info[2].As<Napi::Number>().DoubleValue();
qreal height = info[3].As<Napi::Number>().DoubleValue();
this->instance->addRect(x, y, width, height);
return env.Null();
}
Napi::Value QPainterPathWrap::lineTo(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
int x = info[0].As<Napi::Number>().Int32Value();
int y = info[1].As<Napi::Number>().Int32Value();
qreal x = info[0].As<Napi::Number>().DoubleValue();
qreal y = info[1].As<Napi::Number>().DoubleValue();
this->instance->lineTo(x, y);
return env.Null();
}
Napi::Value QPainterPathWrap::cubicTo(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
int c1X = info[0].As<Napi::Number>().Int32Value();
int c1Y = info[1].As<Napi::Number>().Int32Value();
int c2X = info[2].As<Napi::Number>().Int32Value();
int c2Y = info[3].As<Napi::Number>().Int32Value();
int endPointX = info[4].As<Napi::Number>().Int32Value();
int endPointY = info[5].As<Napi::Number>().Int32Value();
qreal c1X = info[0].As<Napi::Number>().DoubleValue();
qreal c1Y = info[1].As<Napi::Number>().DoubleValue();
qreal c2X = info[2].As<Napi::Number>().DoubleValue();
qreal c2Y = info[3].As<Napi::Number>().DoubleValue();
qreal endPointX = info[4].As<Napi::Number>().DoubleValue();
qreal endPointY = info[5].As<Napi::Number>().DoubleValue();
this->instance->cubicTo(c1X, c1Y, c2X, c2Y, endPointX, endPointY);
return env.Null();
}
Napi::Value QPainterPathWrap::quadTo(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
int cx = info[0].As<Napi::Number>().Int32Value();
int cy = info[1].As<Napi::Number>().Int32Value();
int endPointX = info[2].As<Napi::Number>().Int32Value();
int endPointY = info[3].As<Napi::Number>().Int32Value();
qreal cx = info[0].As<Napi::Number>().DoubleValue();
qreal cy = info[1].As<Napi::Number>().DoubleValue();
qreal endPointX = info[2].As<Napi::Number>().DoubleValue();
qreal endPointY = info[3].As<Napi::Number>().DoubleValue();
this->instance->quadTo(cx, cy, endPointX, endPointY);
return env.Null();
}
@ -94,3 +125,304 @@ Napi::Value QPainterPathWrap::closeSubpath(const Napi::CallbackInfo& info) {
this->instance->closeSubpath();
return env.Null();
}
Napi::Value QPainterPathWrap::addEllipse(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
qreal x = info[0].As<Napi::Number>().DoubleValue();
qreal y = info[1].As<Napi::Number>().DoubleValue();
qreal width = info[2].As<Napi::Number>().DoubleValue();
qreal height = info[3].As<Napi::Number>().DoubleValue();
this->instance->addEllipse(x, y, width, height);
return env.Null();
}
Napi::Value QPainterPathWrap::addPath(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
if (info.Length() < 1) {
Napi::TypeError::New(env, "No Path Specified to addPath")
.ThrowAsJavaScriptException();
return env.Null();
}
Napi::Object pathObject = info[0].As<Napi::Object>();
QPainterPathWrap* pathWrap =
Napi::ObjectWrap<QPainterPathWrap>::Unwrap(pathObject);
QPainterPath* pathToAdd = pathWrap->getInternalInstance();
this->instance->addPath(*pathToAdd);
return env.Null();
}
// Napi::Value addPolygon(const Napi::CallbackInfo& info) {
// }
Napi::Value QPainterPathWrap::addRoundedRect(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
if (info.Length() >= 6) {
qreal x = info[0].As<Napi::Number>().DoubleValue();
qreal y = info[1].As<Napi::Number>().DoubleValue();
qreal width = info[2].As<Napi::Number>().DoubleValue();
qreal height = info[3].As<Napi::Number>().DoubleValue();
qreal xRadius = info[4].As<Napi::Number>().DoubleValue();
qreal yRadius = info[5].As<Napi::Number>().DoubleValue();
if (info.Length() >= 7) {
Qt::SizeMode mode =
static_cast<Qt::SizeMode>(info[6].As<Napi::Number>().Int32Value());
this->instance->addRoundedRect(x, y, width, height, xRadius, yRadius,
mode);
} else {
this->instance->addRoundedRect(x, y, width, height, xRadius, yRadius,
Qt::SizeMode::AbsoluteSize);
}
} else {
Napi::TypeError::New(env, "Invalid number of arguments to addRoundedRect")
.ThrowAsJavaScriptException();
return env.Null();
}
return env.Null();
}
Napi::Value QPainterPathWrap::addText(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
if (info.Length() < 4) {
Napi::TypeError::New(env, "Invalid number of arguments to addText")
.ThrowAsJavaScriptException();
return env.Null();
}
qreal x = info[0].As<Napi::Number>().DoubleValue();
qreal y = info[1].As<Napi::Number>().DoubleValue();
Napi::Object fontObject = info[2].As<Napi::Object>();
QFontWrap* fontWrap = Napi::ObjectWrap<QFontWrap>::Unwrap(fontObject);
QFont* qfont = fontWrap->getInternalInstance();
Napi::String text = info[3].As<Napi::String>();
this->instance->addText(x, y, *qfont,
QString::fromStdString(text.Utf8Value()));
return env.Null();
}
Napi::Value QPainterPathWrap::angleAtPercent(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
if (info.Length() < 1) {
Napi::TypeError::New(env, "Invalid number of arguments to angleAtPercent")
.ThrowAsJavaScriptException();
return env.Null();
}
qreal t = info[0].As<Napi::Number>().DoubleValue();
qreal v = static_cast<qreal>(this->instance->angleAtPercent(t));
return Napi::Number::From(env, v);
}
Napi::Value QPainterPathWrap::arcMoveTo(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
if (info.Length() < 5) {
Napi::TypeError::New(env, "Invalid number of arguments to arcMoveTo")
.ThrowAsJavaScriptException();
return env.Null();
}
qreal x = info[0].As<Napi::Number>().DoubleValue();
qreal y = info[1].As<Napi::Number>().DoubleValue();
qreal width = info[2].As<Napi::Number>().DoubleValue();
qreal height = info[3].As<Napi::Number>().DoubleValue();
qreal angle = info[4].As<Napi::Number>().DoubleValue();
this->instance->arcMoveTo(x, y, width, height, angle);
return env.Null();
}
Napi::Value QPainterPathWrap::arcTo(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
if (info.Length() < 6) {
Napi::TypeError::New(env, "Invalid number of arguments to arcTo")
.ThrowAsJavaScriptException();
return env.Null();
}
qreal x = info[0].As<Napi::Number>().DoubleValue();
qreal y = info[1].As<Napi::Number>().DoubleValue();
qreal width = info[2].As<Napi::Number>().DoubleValue();
qreal height = info[3].As<Napi::Number>().DoubleValue();
qreal startAngle = info[4].As<Napi::Number>().DoubleValue();
qreal sweepLength = info[4].As<Napi::Number>().DoubleValue();
this->instance->arcTo(x, y, width, height, startAngle, sweepLength);
return env.Null();
}
Napi::Value QPainterPathWrap::boundingRect(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
QRectF rect = static_cast<QRectF>(this->instance->boundingRect());
qreal x = static_cast<qreal>(rect.x());
qreal y = static_cast<qreal>(rect.y());
qreal width = static_cast<qreal>(rect.width());
qreal height = static_cast<qreal>(rect.height());
Napi::Object obj = Napi::Object::New(env);
obj.Set("x", Napi::Number::From(env, x));
obj.Set("y", Napi::Number::From(env, y));
obj.Set("width", Napi::Number::From(env, width));
obj.Set("height", Napi::Number::From(env, height));
return obj;
}
Napi::Value QPainterPathWrap::capacity(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
int v = static_cast<int>(this->instance->capacity());
return Napi::Number::From(env, v);
}
Napi::Value QPainterPathWrap::clear(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
this->instance->clear();
return env.Null();
}
Napi::Value QPainterPathWrap::connectPath(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
if (info.Length() < 1) {
Napi::TypeError::New(env, "No Path Specified to connectPath")
.ThrowAsJavaScriptException();
return env.Null();
}
Napi::Object pathObject = info[0].As<Napi::Object>();
QPainterPathWrap* pathWrap =
Napi::ObjectWrap<QPainterPathWrap>::Unwrap(pathObject);
QPainterPath* pathToAdd = pathWrap->getInternalInstance();
this->instance->connectPath(*pathToAdd);
return env.Null();
}
Napi::Value QPainterPathWrap::controlPointRect(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
QRectF rect = static_cast<QRectF>(this->instance->controlPointRect());
qreal x = static_cast<qreal>(rect.x());
qreal y = static_cast<qreal>(rect.y());
qreal width = static_cast<qreal>(rect.width());
qreal height = static_cast<qreal>(rect.height());
Napi::Object obj = Napi::Object::New(env);
obj.Set("x", Napi::Number::From(env, x));
obj.Set("y", Napi::Number::From(env, y));
obj.Set("width", Napi::Number::From(env, width));
obj.Set("height", Napi::Number::From(env, height));
return obj;
}
Napi::Value QPainterPathWrap::currentPosition(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
QPointF point = static_cast<QPointF>(this->instance->currentPosition());
qreal x = static_cast<qreal>(point.x());
qreal y = static_cast<qreal>(point.y());
Napi::Object obj = Napi::Object::New(env);
obj.Set("x", Napi::Number::From(env, x));
obj.Set("y", Napi::Number::From(env, y));
return obj;
}
Napi::Value QPainterPathWrap::elementCount(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
int v = static_cast<int>(this->instance->elementCount());
return Napi::Number::From(env, v);
}
Napi::Value QPainterPathWrap::fillRule(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
int v = static_cast<int>(this->instance->fillRule());
return Napi::Number::From(env, v);
}
Napi::Value QPainterPathWrap::intersects(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Object pathObject = info[0].As<Napi::Object>();
QPainterPathWrap* pathWrap =
Napi::ObjectWrap<QPainterPathWrap>::Unwrap(pathObject);
QPainterPath* path = pathWrap->getInternalInstance();
bool result = static_cast<bool>(this->instance->intersects(*path));
return Napi::Boolean::From(env, result);
}
Napi::Value QPainterPathWrap::isEmpty(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
bool v = static_cast<bool>(this->instance->isEmpty());
return Napi::Number::From(env, v);
}
Napi::Value QPainterPathWrap::length(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
qreal v = static_cast<qreal>(this->instance->length());
return Napi::Number::From(env, v);
}
Napi::Value QPainterPathWrap::percentAtLength(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
int l = info[0].As<Napi::Number>().Int32Value();
qreal v = static_cast<qreal>(this->instance->percentAtLength(l));
return Napi::Number::From(env, v);
}
Napi::Value QPainterPathWrap::pointAtPercent(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
qreal p = info[0].As<Napi::Number>().DoubleValue();
QPointF point = static_cast<QPointF>(this->instance->pointAtPercent(p));
qreal x = static_cast<qreal>(point.x());
qreal y = static_cast<qreal>(point.y());
Napi::Object obj = Napi::Object::New(env);
obj.Set("x", Napi::Number::From(env, x));
obj.Set("y", Napi::Number::From(env, y));
return obj;
}
Napi::Value QPainterPathWrap::reserve(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
int s = info[0].As<Napi::Number>().Int32Value();
this->instance->reserve(s);
return env.Null();
}
Napi::Value QPainterPathWrap::setElementPositionAt(
const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
int index = info[0].As<Napi::Number>().Int32Value();
qreal x = info[1].As<Napi::Number>().DoubleValue();
qreal y = info[2].As<Napi::Number>().DoubleValue();
this->instance->setElementPositionAt(index, x, y);
return env.Null();
}
Napi::Value QPainterPathWrap::setFillRule(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
int v = info[0].As<Napi::Number>().Int32Value();
this->instance->setFillRule(static_cast<Qt::FillRule>(v));
return env.Null();
}
Napi::Value QPainterPathWrap::slopeAtPercent(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
qreal v = info[0].As<Napi::Number>().DoubleValue();
qreal slope = static_cast<qreal>(this->instance->slopeAtPercent(v));
return Napi::Number::From(env, slope);
}
// Napi::Value subtracted(const Napi::CallbackInfo& info);
Napi::Value QPainterPathWrap::swap(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Object pathObject = info[0].As<Napi::Object>();
QPainterPathWrap* pathWrap =
Napi::ObjectWrap<QPainterPathWrap>::Unwrap(pathObject);
QPainterPath* pathToAdd = pathWrap->getInternalInstance();
this->instance->swap(*pathToAdd);
return env.Null();
}
// Napi::Value toFillPolygon(const Napi::CallbackInfo& info);
// Napi::Value toReversed(const Napi::CallbackInfo& info);
// Napi::Value toSubpathPolygons(const Napi::CallbackInfo& info);
Napi::Value QPainterPathWrap::translate(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
qreal x = info[0].As<Napi::Number>().DoubleValue();
qreal y = info[1].As<Napi::Number>().DoubleValue();
this->instance->translate(x, y);
return env.Null();
}
// Napi::Value translated(const Napi::CallbackInfo& info);
// Napi::Value united(const Napi::CallbackInfo& info);

View File

@ -6,7 +6,9 @@
#include "QtCore/QModelIndex/qmodelindex_wrap.h"
#include "QtCore/QObject/qobject_wrap.h"
#include "QtCore/QPoint/qpoint_wrap.h"
#include "QtCore/QPointF/qpointf_wrap.h"
#include "QtCore/QRect/qrect_wrap.h"
#include "QtCore/QRectF/qrectf_wrap.h"
#include "QtCore/QSettings/qsettings_wrap.h"
#include "QtCore/QSize/qsize_wrap.h"
#include "QtCore/QTime/qtime_wrap.h"
@ -17,11 +19,13 @@
#include "QtGui/QClipboard/qclipboard_wrap.h"
#include "QtGui/QColor/qcolor_wrap.h"
#include "QtGui/QCursor/qcursor_wrap.h"
#include "QtGui/QEvent/QDragMoveEvent/qdragmoveevent_wrap.h"
#include "QtGui/QEvent/QDropEvent/qdropevent_wrap.h"
#include "QtGui/QEvent/QKeyEvent/qkeyevent_wrap.h"
#include "QtGui/QEvent/QMouseEvent/qmouseevent_wrap.h"
#include "QtGui/QEvent/QNativeGestureEvent/qnativegestureevent_wrap.h"
#include "QtGui/QEvent/QWheelEvent/qwheelevent_wrap.h"
#include "QtGui/QEvent/QTabletEvent/qtabletevent_wrap.h"
#include "QtGui/QEvent/QWheelEvent/qwheelevent_wrap.h"
#include "QtGui/QFont/qfont_wrap.h"
#include "QtGui/QFontDatabase/qfontdatabase_wrap.h"
#include "QtGui/QIcon/qicon_wrap.h"
@ -109,7 +113,9 @@ Napi::Object Main(Napi::Env env, Napi::Object exports) {
QModelIndexWrap::init(env, exports);
QObjectWrap::init(env, exports);
QPointWrap::init(env, exports);
QPointFWrap::init(env, exports);
QRectWrap::init(env, exports);
QRectFWrap::init(env, exports);
QSizeWrap::init(env, exports);
QTimeWrap::init(env, exports);
QUrlWrap::init(env, exports);
@ -171,6 +177,8 @@ Napi::Object Main(Napi::Env env, Napi::Object exports) {
QMouseEventWrap::init(env, exports);
QWheelEventWrap::init(env, exports);
QTabletEventWrap::init(env, exports);
QDropEventWrap::init(env, exports);
QDragMoveEventWrap::init(env, exports);
QNativeGestureEventWrap::init(env, exports);
QPlainTextEditWrap::init(env, exports);
QDialWrap::init(env, exports);

View File

@ -23,6 +23,8 @@ export { QMouseEvent } from './lib/QtGui/QEvent/QMouseEvent';
export { QWheelEvent } from './lib/QtGui/QEvent/QWheelEvent';
export { QNativeGestureEvent } from './lib/QtGui/QEvent/QNativeGestureEvent';
export { QTabletEvent } from './lib/QtGui/QEvent/QTabletEvent';
export { QDropEvent } from './lib/QtGui/QEvent/QDropEvent';
export { QDragMoveEvent } from './lib/QtGui/QEvent/QDragMoveEvent';
export { WidgetEventTypes } from './lib/core/EventWidget';
// Abstract:
export { NodeWidget, QWidget, QWidgetSignals } from './lib/QtWidgets/QWidget';
@ -125,7 +127,9 @@ export { QObject, QObjectSignals, NodeObject } from './lib/QtCore/QObject';
export { QVariant } from './lib/QtCore/QVariant';
export { QSize } from './lib/QtCore/QSize';
export { QRect } from './lib/QtCore/QRect';
export { QRectF } from './lib/QtCore/QRectF';
export { QPoint } from './lib/QtCore/QPoint';
export { QPointF } from './lib/QtCore/QPointF';
export { QColor } from './lib/QtGui/QColor';
export { QTime } from './lib/QtCore/QTime';
export { QUrl, ParsingMode } from './lib/QtCore/QUrl';

View File

@ -2,6 +2,10 @@ import { NativeElement, Component } from '../core/Component';
import addon from '../utils/addon';
import { checkIfNativeElement } from '../utils/helpers';
import { QVariant } from './QVariant';
/**
* The QPoint class defines a point in the plane using integer precision.
*/
export class QPoint extends Component {
native: NativeElement;
constructor();
@ -29,6 +33,24 @@ export class QPoint extends Component {
y(): number {
return this.native.y();
}
/**
* Returns true if both the x and y coordinates are set to 0.0 (ignoring the sign); otherwise returns false.
*/
isNull(): boolean {
return this.native.isNull();
}
/**
* Returns the sum of the absolute values of x() and y(), traditionally known as the "Manhattan length" of the vector from the origin to the point.
*/
manhattanLength(): number {
return this.native.manhattanLength();
}
/**
* Returns a point with x and y coordinates exchanged
*/
transposed(): QPoint {
return new QPoint(this.native.transposed());
}
static fromQVariant(variant: QVariant): QPoint {
return new QPoint(addon.QPoint.fromQVariant(variant.native));
}

85
src/lib/QtCore/QPointF.ts Normal file
View File

@ -0,0 +1,85 @@
import { NativeElement, Component } from '../core/Component';
import addon from '../utils/addon';
import { checkIfNativeElement } from '../utils/helpers';
import { QPoint } from './QPoint';
/**
* The QPointF class defines a point in the plane using floating point precision
*
* A point is specified by a x coordinate and an y coordinate which can be accessed using the x() and y() functions. The coordinates of the point are specified using floating point numbers for accuracy. The isNull() function returns true if both x and y are set to 0.0. The coordinates can be set (or altered) using the setX() and setY() functions
*
* In addition, the QPointF class provides a constructor converting a QPoint object into a QPointF object, and a corresponding toPoint() function which returns a QPoint copy of this point.
*/
export class QPointF extends Component {
native: NativeElement;
constructor();
constructor(nativeElement: NativeElement);
constructor(x?: number, y?: number);
constructor(point: QPoint);
constructor(arg?: NativeElement | number | QPoint, y = 0) {
super();
if (checkIfNativeElement(arg)) {
this.native = arg as NativeElement;
} else if (typeof arg === 'number') {
this.native = new addon.QPointF(arg, y);
} else if (arg instanceof QPoint) {
this.native = new addon.QPointF(arg.x(), arg.y());
} else {
this.native = new addon.QPointF();
}
}
/**
* Sets the x coordinate of this point to the given x coordinate.
*/
setX(value: number): void {
this.native.setX(value);
}
/**
* Sets the y coordinate of this point to the given y coordinate.
*/
setY(value: number): void {
this.native.setY(value);
}
/**
* Returns the x coordinate of this point
*/
x(): number {
return this.native.x();
}
/**
* Returns the y coordinate of this point
*/
y(): number {
return this.native.y();
}
/**
* Returns true if both the x and y coordinates are set to 0.0 (ignoring the sign); otherwise returns false.
*/
isNull(): boolean {
return this.native.isNull();
}
/**
* Returns the sum of the absolute values of x() and y(), traditionally known as the "Manhattan length" of the vector from the origin to the point.
*/
manhattanLength(): number {
return this.native.manhattanLength();
}
/**
* Returns a point with x and y coordinates exchanged
*/
transposed(): QPointF {
return new QPointF(this.native.transposed());
}
/**
* Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rounded coordinates.
*/
toPoint(): QPoint {
return new QPoint(this.native.toPoint());
}
/**
* Returns the dot product of p1 and p2
*/
static dotProduct(p1: QPointF, p2: QPointF): number {
return addon.QPointF.dotProduct(p1.native, p2.native);
}
}

403
src/lib/QtCore/QRectF.ts Normal file
View File

@ -0,0 +1,403 @@
import { NativeElement, Component } from '../core/Component';
import addon from '../utils/addon';
import { checkIfNativeElement } from '../utils/helpers';
import { QPointF } from './QPointF';
import { QRect } from './QRect';
/**
* description
*/
export class QRectF extends Component {
native: NativeElement;
constructor();
constructor(nativeElement: NativeElement);
constructor(x?: number, y?: number, width?: number, height?: number);
constructor(arg?: NativeElement | number, y = 0, width = 0, height = 0) {
super();
const count = arguments.length;
if (count > 1) {
this.native = new addon.QRectF(arg, y, width, height);
} else if (count == 1 && checkIfNativeElement(arg)) {
this.native = arg as NativeElement;
} else {
this.native = new addon.QRectF();
}
}
/**
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
*/
adjust(dx1: number, dy1: number, dx2: number, dy2: number): void {
return this.native.adjust(dx1, dy1, dx2, dy2);
}
/**
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of this rectangle.
*/
adjusted(dx1: number, dy1: number, dx2: number, dy2: number): QRectF {
return new QRectF(this.native.adjusted(dx1, dy1, dx2, dy2));
}
/**
Returns the y-coordinate of the rectangle's bottom edge.
*/
bottom(): number {
return this.native.bottom();
}
/**
Returns the position of the rectangle's bottom-left corner.
*/
bottomLeft(): QPointF {
return new QPointF(this.native.bottomLeft());
}
/**
Returns the position of the rectangle's bottom-right corner.
*/
bottomRight(): QPointF {
return new QPointF(this.native.bottomRight());
}
/**
Returns the center point of the rectangle.
*/
center(): QPointF {
return new QPointF(this.native.center());
}
/**
* Returns true if the given point is inside or on the edge of the rectangle; otherwise returns false.
*/
contains(arg0: QRectF | number | QPointF, y: number): boolean {
if (arg0 instanceof QRectF) {
return this.native.contains_QRect(arg0.native);
} else if (arg0 instanceof QPointF) {
return this.native.contains_QPoint(arg0.native);
}
return this.native.contains(arg0, y);
}
/**
Returns the height of the rectangle.
*/
height(): number {
return this.native.height();
}
/**
Returns the intersection of this rectangle and the given rectangle. Note that r.intersected(s) is equivalent to r & s.
*/
intersected(rectangle: QRectF): QRectF {
return new QRectF(this.native.intersected(rectangle.native));
}
/**
Returns true if this rectangle intersects with the given rectangle (i.e. there is a non-empty area of overlap between them), otherwise returns false.
*/
intersects(rectangle: QRectF): boolean {
return this.native.intersects(rectangle.native);
}
/**
Returns true if the rectangle is empty, otherwise returns false.
*/
isEmpty(): boolean {
return this.native.isEmpty();
}
/**
Returns true if the rectangle is a null rectangle, otherwise returns false.
*/
isNull(): boolean {
return this.native.isNull();
}
/**
Returns true if the rectangle is valid, otherwise returns false.
*/
isValid(): boolean {
return this.native.isValid();
}
/**
Returns the x-coordinate of the rectangle's left edge. Equivalent to x().
*/
left(): number {
return this.native.left();
}
/**
Moves the rectangle vertically, leaving the rectangle's bottom edge at the given y coordinate. The rectangle's size is unchanged.
*/
moveBottom(y: number): void {
return this.native.moveBottom(y);
}
/**
Moves the rectangle, leaving the bottom-left corner at the given position. The rectangle's size is unchanged.
*/
moveBottomLeft(position: QPointF): void {
return this.native.moveBottomLeft(position.native);
}
/**
Moves the rectangle, leaving the bottom-right corner at the given position. The rectangle's size is unchanged.
*/
moveBottomRight(position: QPointF): void {
return this.native.moveBottomRight(position.native);
}
/**
Moves the rectangle, leaving the center point at the given position. The rectangle's size is unchanged.
*/
moveCenter(position: QPointF): void {
return this.native.moveCenter(position.native);
}
/**
Moves the rectangle horizontally, leaving the rectangle's left edge at the given x coordinate. The rectangle's size is unchanged.
*/
moveLeft(x: number): void {
return this.native.moveLeft(x);
}
/**
Moves the rectangle horizontally, leaving the rectangle's right edge at the given x coordinate. The rectangle's size is unchanged.
*/
moveRight(x: number): void {
return this.native.moveRight(x);
}
/**
Moves the rectangle, leaving the top-left corner at the given position (x, y). The rectangle's size is unchanged.
*/
moveTo(xOrPos: number | QPointF, y: number): void {
if (xOrPos instanceof QPointF) {
return this.native.moveTo_QPoint(xOrPos.native);
}
return this.native.moveTo(xOrPos, y);
}
/**
Moves the rectangle vertically, leaving the rectangle's top line at the given y coordinate. The rectangle's size is unchanged.
*/
moveTop(y: number): void {
return this.native.moveTop(y);
}
/**
Moves the rectangle, leaving the top-left corner at the given position. The rectangle's size is unchanged.
*/
moveTopLeft(position: QPointF): void {
return this.native.moveTopLeft(position.native);
}
/**
Moves the rectangle, leaving the top-right corner at the given position. The rectangle's size is unchanged.
*/
moveTopRight(position: QPointF): void {
return this.native.moveTopRight(position.native);
}
/**
Returns a normalized rectangle; i.e., a rectangle that has a non-negative width and height.
*/
normalized(): QRectF {
return new QRectF(this.native.normalized());
}
/**
Returns the x-coordinate of the rectangle's right edge.
*/
right(): number {
return this.native.right();
}
/**
Sets the bottom edge of the rectangle to the given y coordinate. May change the height, but will never change the top edge of the rectangle.
*/
setBottom(y: number): void {
return this.native.setBottom(y);
}
/**
Set the bottom-left corner of the rectangle to the given position. May change the size, but will never change the top-right corner of the rectangle.
*/
setBottomLeft(position: QPointF): void {
return this.native.setBottomLeft(position.native);
}
/**
Set the bottom-right corner of the rectangle to the given position. May change the size, but will never change the top-left corner of the rectangle.
*/
setBottomRight(position: QPointF): void {
return this.native.setBottomRight(position.native);
}
/**
Sets the coordinates of the rectangle's top-left corner to (x1, y1), and the coordinates of its bottom-right corner to (x2, y2).
*/
setCoords(x1: number, y1: number, x2: number, y2: number): void {
return this.native.setCoords(x1, y1, x2, y2);
}
/**
Sets the height of the rectangle to the given height. The bottom edge is changed, but not the top one.
*/
setHeight(height: number): void {
return this.native.setHeight(height);
}
/**
Sets the left edge of the rectangle to the given x coordinate. May change the width, but will never change the right edge of the rectangle.
*/
setLeft(x: number): void {
return this.native.setLeft(x);
}
/**
Sets the coordinates of the rectangle's top-left corner to (x, y), and its size to the given width and height.
*/
setRect(x: number, y: number, width: number, height: number): void {
return this.native.setRect(x, y, width, height);
}
/**
Sets the right edge of the rectangle to the given x coordinate. May change the width, but will never change the left edge of the rectangle.
*/
setRight(x: number): void {
return this.native.setRight(x);
}
/**
Sets the top edge of the rectangle to the given y coordinate. May change the height, but will never change the bottom edge of the rectangle.
*/
setTop(y: number): void {
return this.native.setTop(y);
}
/**
Set the top-left corner of the rectangle to the given position. May change the size, but will never change the bottom-right corner of the rectangle.
*/
setTopLeft(position: QPointF): void {
return this.native.setTopLeft(position.native);
}
/**
Set the top-right corner of the rectangle to the given position. May change the size, but will never change the bottom-left corner of the rectangle.
*/
setTopRight(position: QPointF): void {
return this.native.setTopRight(position.native);
}
/**
Sets the width of the rectangle to the given width. The right edge is changed, but not the left one.
*/
setWidth(width: number): void {
return this.native.setWidth(width);
}
/**
Sets the left edge of the rectangle to the given x coordinate. May change the width, but will never change the right edge of the rectangle.
*/
setX(x: number): void {
return this.native.setX(x);
}
/**
Sets the top edge of the rectangle to the given y coordinate. May change the height, but will never change the bottom edge of the rectangle.
*/
setY(y: number): void {
return this.native.setY(y);
}
/**
Returns a QRect based on the values of this rectangle that is the smallest possible integer rectangle that completely contains this rectangle.
*/
toAlignedRect(): QRect {
return new QRect(this.native.toAlignedRect());
}
/**
Returns a QRect based on the values of this rectangle. Note that the coordinates in the returned rectangle are rounded to the nearest integer.
*/
toRect(): QRect {
return new QRect(this.native.toRect());
}
/**
Returns the y-coordinate of the rectangle's top edge. Equivalent to y().
*/
top(): number {
return this.native.top();
}
/**
Returns the position of the rectangle's top-left corner.
*/
topLeft(): QPointF {
return new QPointF(this.native.topLeft());
}
/**
Returns the position of the rectangle's top-right corner.
*/
topRight(): QPointF {
return new QPointF(this.native.topRight());
}
/**
Moves the rectangle dx along the x-axis and dy along the y-axis, relative to the current position. Positive values move the rectangle to the right and downwards.
*/
translate(dxOrOffset: number | QPointF, dy: number): void {
if (dxOrOffset instanceof QPointF) {
return this.native.translate_QPoint(dxOrOffset.native);
}
return this.native.translate(dxOrOffset, dy);
}
/**
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis, relative to the current position. Positive values move the rectangle to the right and down.
*/
translated(dxOrOffset: number | QPointF, dy: number): QRectF {
if (dxOrOffset instanceof QPointF) {
return new QRectF(this.native.translated_QPoint(dxOrOffset.native));
}
return new QRectF(this.native.translated(dxOrOffset, dy));
}
/**
Returns a copy of the rectangle that has its width and height exchanged:
*/
transposed(): QRectF {
return new QRectF(this.native.transposed());
}
/**
Returns the bounding rectangle of this rectangle and the given rectangle.
*/
united(rectangle: QRectF): QRectF {
return new QRectF(this.native.united(rectangle));
}
/**
Returns the width of the rectangle.
*/
width(): number {
return this.native.width();
}
/**
Returns the x-coordinate of the rectangle's left edge. Equivalent to left().
*/
x(): number {
return this.native.x();
}
/**
Returns the y-coordinate of the rectangle's top edge. Equivalent to top().
*/
y(): number {
return this.native.y();
}
}

View File

@ -0,0 +1,143 @@
import addon from '../../utils/addon';
import { NativeElement } from '../../core/Component';
import { DropAction } from '../../QtEnums';
export class QDragMoveEvent {
native: NativeElement;
constructor(event: NativeElement) {
this.native = new addon.QDragMoveEvent(event);
}
/**
* Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
* Setting the accept parameter indicates that the event receiver wants the event. Unwanted events might be propagated to the parent widget
*
* If the rectangle is provided, also notifies that future moves will also be acceptable if they remain within the rectangle given on the widget.
* This can improve performance, but may also be ignored by the underlying system.
* If the rectangle is empty, drag move events will be sent continuously. This is useful if the source is scrolling in a timer event.
*/
accept(x?: number, y?: number, width?: number, height?: number): void {
if (arguments.length == 4) {
this.native.accept(x, y, width, height);
} else {
this.native.accept();
}
}
/**
* Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
* Clearing the accept parameter indicates that the event receiver does not want the event.
* Unwanted events might be propagated to the parent widget.
*/
ignore(x?: number, y?: number, width?: number, height?: number): void {
if (arguments.length == 4) {
this.native.ignore(x, y, width, height);
} else {
this.native.ignore();
}
}
answerRect(): { x: number; y: number; width: number; height: number } {
return this.native.answerRect();
}
//Below : Methods inherited from QDropEvent ---------------------------------------
/** Sets the drop action to be the proposed action */
acceptProposedAction(): void {
return this.native.acceptProposedAction();
}
/**
* Returns the action to be performed on the data by the target.
* This may be different from the action supplied in proposedAction()
* if you have called setDropAction() to explicitly choose a drop action
*/
dropAction(): DropAction {
return this.native.dropAction();
}
/**
* Returns the modifier keys that are pressed
*
* see Qt::KeyboardModifier for flags
*/
keyboardModifiers(): number {
return this.native.keyboardModifiers();
}
/*
* Cannot implement yet; need to implement QMimeData first
* Returns the data that was dropped on the widget and its associated MIME type information
*/
// mimeData(): QMimeData {
// return this.native.pos();
// }
/**
* Returns the mouse buttons that are pressed
*
* See Qt::MouseButton for flags
*/
mouseButtons(): number {
return this.native.mouseButtons();
}
/**
* Returns the position where the drop was made
*/
pos(): { x: number; y: number } {
return this.native.pos();
}
/**
* Returns the position where the drop was made
*/
posF(): { x: number; y: number } {
return this.native.posF();
}
/**
* Returns an OR-combination of possible drop actions.
*
* See Qt::DropAction for flags
*/
possibleActions(): number {
return this.native.possibleActions();
}
/**
* Returns the proposed drop action
*
*/
proposedAction(): DropAction {
return this.native.proposedAction();
}
setDropAction(action: DropAction): void {
return this.native.setDropAction(action);
}
/*
If the source of the drag operation is a widget in this application, this function returns that source; otherwise it returns nullptr. The source of the operation is the first parameter to the QDrag object used instantiate the drag.
This is useful if your widget needs special behavior when dragging to itself.
Not implemented yet, because I'm unsure about casting pointers and comparisons in Node.JS
*/
// source(): QObject {
// return this.native.source();
// }
//Methods from QEvent ---------------------------
isAccepted(): boolean {
return this.native.isAccepted();
}
/**
* Sets the accept flag of the event object
*/
setAccepted(accepted: boolean): void {
return this.native.setAccepted(accepted);
}
/**
* Returns true if the event originated outside the application (a system event); otherwise returns false.
*
* The return value of this function is not defined for paint events.
*/
spontaneous(): boolean {
return this.native.spontaneous();
}
/**
* Returns the event type
* @returns {Number} This is QEvent::Type
*/
type(): number {
return this.native._type();
}
}

View File

@ -0,0 +1,126 @@
import addon from '../../utils/addon';
import { NativeElement } from '../../core/Component';
import { DropAction } from '../../QtEnums';
export class QDropEvent {
native: NativeElement;
constructor(event: NativeElement) {
this.native = new addon.QDropEvent(event);
}
/** Sets the drop action to be the proposed action */
acceptProposedAction(): void {
return this.native.acceptProposedAction();
}
/**
* Returns the action to be performed on the data by the target.
* This may be different from the action supplied in proposedAction()
* if you have called setDropAction() to explicitly choose a drop action
*/
dropAction(): DropAction {
return this.native.dropAction();
}
/**
* Returns the modifier keys that are pressed
*
* see Qt::KeyboardModifier for flags
*/
keyboardModifiers(): number {
return this.native.keyboardModifiers();
}
/*
* Cannot implement yet; need to implement QMimeData first
* Returns the data that was dropped on the widget and its associated MIME type information
*/
// mimeData(): QMimeData {
// return this.native.pos();
// }
/**
* Returns the mouse buttons that are pressed
*
* See Qt::MouseButton for flags
*/
mouseButtons(): number {
return this.native.mouseButtons();
}
/**
* Returns the position where the drop was made
*/
pos(): { x: number; y: number } {
return this.native.pos();
}
/**
* Returns the position where the drop was made
*/
posF(): { x: number; y: number } {
return this.native.posF();
}
/**
* Returns an OR-combination of possible drop actions.
*
* See Qt::DropAction for flags
*/
possibleActions(): number {
return this.native.possibleActions();
}
/**
* Returns the proposed drop action
*
*/
proposedAction(): DropAction {
return this.native.proposedAction();
}
setDropAction(action: DropAction): void {
return this.native.setDropAction(action);
}
/*
If the source of the drag operation is a widget in this application, this function returns that source; otherwise it returns nullptr. The source of the operation is the first parameter to the QDrag object used instantiate the drag.
This is useful if your widget needs special behavior when dragging to itself.
Not implemented yet, because I'm unsure about casting pointers and comparisons in Node.JS
*/
// source(): QObject {
// return this.native.source();
// }
//Methods from QEvent ---------------------------
/**
* Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
* Setting the accept parameter indicates that the event receiver wants the event. Unwanted events might be propagated to the parent widget
*/
accept(): void {
return this.native.accept();
}
/**
* Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
* Clearing the accept parameter indicates that the event receiver does not want the event.
* Unwanted events might be propagated to the parent widget.
*/
ignore(): void {
return this.native.ignore();
}
isAccepted(): boolean {
return this.native.isAccepted();
}
/**
* Sets the accept flag of the event object
*/
setAccepted(accepted: boolean): void {
return this.native.setAccepted(accepted);
}
/**
* Returns true if the event originated outside the application (a system event); otherwise returns false.
*
* The return value of this function is not defined for paint events.
*/
spontaneous(): boolean {
return this.native.spontaneous();
}
/**
* Returns the event type
* @returns {Number} This is QEvent::Type
*/
type(): number {
return this.native._type();
}
}

View File

@ -1,5 +1,7 @@
import addon from '../utils/addon';
import { Component, NativeElement } from '../core/Component';
import { SizeMode, FillRule } from '../QtEnums';
import { QFont } from '../QtGui/QFont';
/**
@ -40,4 +42,96 @@ export class QPainterPath extends Component {
closeSubpath(): void {
return this.native.closeSubpath();
}
addEllipse(x: number, y: number, width: number, height: number): void {
return this.native.addEllipse(x, y, width, height);
}
addPath(path: QPainterPath): void {
return this.native.addPath(path.native);
}
addRoundedRect(
x: number,
y: number,
width: number,
height: number,
xRadius: number,
yRadius: number,
mode: SizeMode = SizeMode.AbsoluteSize,
): void {
return this.native.addRoundedRect(x, y, width, height, xRadius, yRadius, mode);
}
addText(x: number, y: number, font: QFont, text: string): void {
return this.native.addText(x, y, font.native, text);
}
angleAtPercent(t: number): number {
return this.native.angleAtPercent(t);
}
arcMoveTo(x: number, y: number, width: number, height: number, angle: number): void {
return this.native.arcMoveTo(x, y, width, height, angle);
}
arcTo(x: number, y: number, width: number, height: number, startAngle: number, sweepLength: number): void {
return this.native.arcTo(x, y, width, height, startAngle, sweepLength);
}
boundingRect(): { x: number; y: number; width: number; height: number } {
return this.native.boundingRect();
}
capacity(): number {
return this.native.capacity();
}
clear(): void {
return this.native.clear();
}
connectPath(path: QPainterPath): void {
return this.native.connectPath(path.native);
}
controlPointRect(): { x: number; y: number; width: number; height: number } {
return this.native.controlPointRect();
}
currentPosition(): { x: number; y: number } {
return this.native.currentPosition();
}
elementCount(): number {
return this.native.elementCount();
}
fillRule(): FillRule {
return this.native.fillRule();
}
intersects(path: QPainterPath): boolean {
return this.native.intersects(path.native);
}
isEmpty(): boolean {
return this.native.isEmpty();
}
length(): number {
return this.native.length();
}
percentAtLength(len: number): number {
return this.native.percentAtLength(len);
}
pointAtPercent(p: number): { x: number; y: number } {
return this.native.pointAtPercent(p);
}
reserve(size: number): void {
return this.native.reserve(size);
}
setElementPositionAt(index: number, x: number, y: number): void {
return this.native.setElementPositionAt(index, x, y);
}
setFillRule(fillRule: FillRule): void {
return this.native.setFillRule(fillRule);
}
slopeAtPercent(p: number): number {
return this.native.slopeAtPercent(p);
}
swap(other: QPainterPath): void {
return this.native.swap(other.native);
}
translate(x: number, y: number): void {
return this.native.translate(x, y);
}
}

View File

@ -271,6 +271,12 @@ export abstract class NodeWidget<Signals extends QWidgetSignals> extends YogaWid
this._effect = effect;
this.native.setGraphicsEffect(effect.native);
}
setAcceptDrops(on: boolean): void {
this.native.setAcceptDrops(on);
}
acceptDrops(): boolean {
return this.native.acceptDrops();
}
}
export interface QWidgetSignals extends QObjectSignals {