Merge pull request #60 from nodegui/feature/adds-scrollarea

Adds scrollarea
This commit is contained in:
Atul R 2019-08-24 19:23:18 +02:00 committed by GitHub
commit f36691adb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 698 additions and 406 deletions

View File

@ -27,5 +27,6 @@
"../src/cpp/QtWidgets/QRadioButton/qradiobutton_wrap.cpp",
"../src/cpp/QtWidgets/QLineEdit/qlineedit_wrap.cpp",
"../src/cpp/QtWidgets/QPlainTextEdit/qplaintextedit_wrap.cpp",
"../src/cpp/QtWidgets/QScrollArea/qscrollarea_wrap.cpp"
],
}

View File

@ -11,6 +11,7 @@
"../src/cpp/autogen/npushbutton_moc.cpp",
"../src/cpp/autogen/nspinbox_moc.cpp",
"../src/cpp/autogen/nradiobutton_moc.cpp",
"../src/cpp/autogen/nplaintextedit_moc.cpp"
"../src/cpp/autogen/nplaintextedit_moc.cpp",
"../src/cpp/autogen/nscrollarea_moc.cpp"
]
}

View File

@ -10,6 +10,7 @@
"src/cpp/QtWidgets/QPushButton/npushbutton.h",
"src/cpp/QtWidgets/QSpinBox/nspinbox.h",
"src/cpp/QtWidgets/QRadioButton/nradiobutton.h",
"src/cpp/QtWidgets/QPlainTextEdit/nplaintextedit.h"
"src/cpp/QtWidgets/QPlainTextEdit/nplaintextedit.h",
"src/cpp/QtWidgets/QScrollArea/nscrollarea.h"
]
}

View File

@ -43,6 +43,10 @@
- [QApplication (Application)](api/QApplication.md)
- [QMainWindow (Window)](api/QMainWindow.md)
- [QWidget (View)](api/QWidget.md)
- [QSpinBox ()](api/QSpinBox.md)
- [QAbstractScrollArea ()](api/QAbstractScrollArea.md)
- [QScrollArea ()](api/QScrollArea.md)
- [QPlainTextEdit (TextEdit)](api/QPlainTextEdit.md)
- [QLabel (Text/Image)](api/QLabel.md)
- [QPushButton (Button)](api/QPushButton.md)
- [QRadioButton (RadioButton)](api/QRadioButton.md)
@ -51,6 +55,7 @@
- [QProgressBar (ProgressBar)](api/QProgressBar.md)
- [FlexLayout](api/FlexLayout.md)
- [QPixmap](api/QPixmap.md)
- [QIcon](api/QIcon.md)
- [Qt Enums](api/QtEnums.md)
### Internal Modules

View File

@ -0,0 +1,35 @@
## Class: QAbstractScrollArea
> Abstract class to add functionalities common to all scrollarea based widgets.
**This class implements all methods, properties of Qt's [QAbstractScrollArea class](https://doc.qt.io/qt-5/qabstractscrollarea.html) so that it can be inherited by all scoll based widgets**
`QAbstractScrollArea` is an abstract class and hence no instances of the same should be created. It exists so that we can add similar functionalities to all scrollable widget's easily. If you wish to create a scollarea use [QScrollArea](api/QScrollArea.md) instead.
**QAbstractScrollArea is the base class for all widgets. It inherits from another abstract class [NodeWidget](api/NodeWidget.md)**
QAbstractScrollArea will list all methods and properties that are common to all scrollable widgets in the NodeGui world.
### Static Methods
QAbstractScrollArea can access all the static methods defined in [NodeWidget](api/NodeWidget.md)
### Instance Properties
QAbstractScrollArea can access all the instance properties defined in [NodeWidget](api/NodeWidget.md)
### Instance Methods
QAbstractScrollArea can access all the instance methods defined in [NodeWidget](api/NodeWidget.md)
Additionally it also has the following instance methods:
#### `widget.setViewport(widget)`
Sets the viewport to be the given widget. It calls the native method [QAbstractScrollArea: setViewport](https://doc.qt.io/qt-5/qabstractscrollarea.html#setViewport).
- `widget` NodeWidget.
#### `widget.viewport()`
Returns the viewport widget (NodeWidget). It calls the native method [QAbstractScrollArea: viewport](https://doc.qt.io/qt-5/qabstractscrollarea.html#viewport).

46
docs/api/QScrollArea.md Normal file
View File

@ -0,0 +1,46 @@
## Class: QScrollArea
> A `QScrollArea` provides a scrolling view onto another widget.
**This class is a JS wrapper around Qt's [QScrollArea class](https://doc.qt.io/qt-5/qscrollarea.html)**
**QScrollArea inherits from [QAbstractScrollArea](api/QAbstractScrollArea.md)**
### Example
```javascript
const { QScrollArea } = require("@nodegui/nodegui");
const scrollArea = new QScrollArea();
scrollArea.setInlineStyle("flex: 1; width:'100%';");
const imageLabel = new QLabel();
const pixmap = new QPixmap(
path.resolve(__dirname, "../extras/assets/kitchen.png")
);
imageLabel.setPixmap(pixmap);
scrollArea.setWidget(imageLabel);
```
### `new QScrollArea(parent?)`
- `parent` NodeWidget (_optional_). Any widget inheriting from NodeWidget can be passed as a parent. This will make this widget, the child of the parent widget.
### Static Methods
QScrollArea can access all the static methods defined in [QAbstractScrollArea](api/QAbstractScrollArea.md)
### Instance Properties
QScrollArea can access all the instance properties defined in [QAbstractScrollArea](api/QAbstractScrollArea.md)
### Instance Methods
QScrollArea can access all the instance methods defined in [QAbstractScrollArea](api/QAbstractScrollArea.md). Additionally it also has the following instance methods:
#### `scrollArea.setWidget(widget)`
Sets the scroll area's widget. It calls the native method [QScrollArea: setWidget](https://doc.qt.io/qt-5/qscrollarea.html#setWidget).
- `widget` NodeWidget - Any widget you want to enclose in a scroll area.

View File

@ -0,0 +1,43 @@
#pragma once
#include "src/cpp/QtWidgets/QWidget/qwidget_wrap.h"
#include "src/cpp/QtWidgets/QWidget/qwidget_macro.h"
#include "deps/spdlog/spdlog.h"
/*
This macro adds common QAbstractScrollArea exported methods
The exported methods are taken into this macro to avoid writing them in each and every widget we export.
*/
#ifndef QABSTRACTSCROLLAREA_WRAPPED_METHODS_DECLARATION
#define QABSTRACTSCROLLAREA_WRAPPED_METHODS_DECLARATION \
QWIDGET_WRAPPED_METHODS_DECLARATION \
Napi::Value setViewport(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
Napi::HandleScope scope(env); \
Napi::Object viewPortObject = info[0].As<Napi::Object>(); \
QWidgetWrap* viewPortWidgetWrap = Napi::ObjectWrap<QWidgetWrap>::Unwrap(viewPortObject); \
QWidget* viewPort = viewPortWidgetWrap->getInternalInstance(); \
this->instance->setViewport(viewPort); \
return env.Null(); \
} \
\
Napi::Value viewport(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
Napi::HandleScope scope(env); \
QWidget* viewPort = this->instance->viewport(); \
NWidget* nviewPort = reinterpret_cast<NWidget*>(viewPort); \
auto instance = QWidgetWrap::constructor.New({ Napi::External<NWidget>::New(env, nviewPort) }); \
return instance; \
} \
\
#endif //QABSTRACTSCROLLAREA_WRAPPED_METHODS_DECLARATION
#ifndef QABSTRACTSCROLLAREA_WRAPPED_METHODS_EXPORT_DEFINE
#define QABSTRACTSCROLLAREA_WRAPPED_METHODS_EXPORT_DEFINE(WidgetWrapName) \
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(WidgetWrapName) \
InstanceMethod("setViewport", &WidgetWrapName::setViewport), \
InstanceMethod("viewport",&WidgetWrapName::viewport), \
#endif // QABSTRACTSCROLLAREA_WRAPPED_METHODS_EXPORT_DEFINE

View File

@ -15,6 +15,7 @@ Napi::Object QPlainTextEditWrap::init(Napi::Env env, Napi::Object exports) {
InstanceMethod("toPlainText",&QPlainTextEditWrap::toPlainText),
InstanceMethod("clear", &QPlainTextEditWrap::clear),
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QPlainTextEditWrap)
QABSTRACTSCROLLAREA_WRAPPED_METHODS_EXPORT_DEFINE(QPlainTextEditWrap)
});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);

View File

@ -3,7 +3,7 @@
#include <napi.h>
#include "nplaintextedit.h"
#include "src/cpp/QtWidgets/QWidget/qwidget_macro.h"
#include "src/cpp/QtWidgets/QAbstractScrollArea/qabstractscrollarea_macro.h"
class QPlainTextEditWrap : public Napi::ObjectWrap<QPlainTextEditWrap>{
private:
@ -17,7 +17,7 @@ class QPlainTextEditWrap : public Napi::ObjectWrap<QPlainTextEditWrap>{
static Napi::FunctionReference constructor;
//wrapped methods
QWIDGET_WRAPPED_METHODS_DECLARATION
QABSTRACTSCROLLAREA_WRAPPED_METHODS_DECLARATION
Napi::Value setPlainText(const Napi::CallbackInfo& info);
Napi::Value toPlainText(const Napi::CallbackInfo &info);
Napi::Value clear(const Napi::CallbackInfo &info);

View File

@ -0,0 +1,13 @@
#pragma once
#include <QScrollArea>
#include "src/cpp/core/NodeWidget/nodewidget.h"
class NScrollArea: public QScrollArea, public NodeWidget
{
NODEWIDGET_IMPLEMENTATIONS(QScrollArea)
public:
using QScrollArea::QScrollArea; //inherit all constructors of QScrollArea
};

View File

@ -0,0 +1,49 @@
#include "qscrollarea_wrap.h"
#include "src/cpp/QtWidgets/QWidget/qwidget_wrap.h"
#include "src/cpp/Extras/Utils/nutils.h"
Napi::FunctionReference QScrollAreaWrap::constructor;
Napi::Object QScrollAreaWrap::init(Napi::Env env, Napi::Object exports) {
Napi::HandleScope scope(env);
char CLASSNAME[] = "QScrollArea";
Napi::Function func = DefineClass(env, CLASSNAME, {
InstanceMethod("setWidget", &QScrollAreaWrap::setWidget),
QABSTRACTSCROLLAREA_WRAPPED_METHODS_EXPORT_DEFINE(QScrollAreaWrap)
});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
return exports;
}
NScrollArea* QScrollAreaWrap::getInternalInstance() {
return this->instance;
}
QScrollAreaWrap::QScrollAreaWrap(const Napi::CallbackInfo& info): Napi::ObjectWrap<QScrollAreaWrap>(info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
if(info.Length() == 1) {
Napi::Object parentObject = info[0].As<Napi::Object>();
QWidgetWrap* parentWidgetWrap = Napi::ObjectWrap<QWidgetWrap>::Unwrap(parentObject);
this->instance = new NScrollArea(parentWidgetWrap->getInternalInstance()); //this sets the parent to current widget
}else if (info.Length() == 0){
this->instance = new NScrollArea();
}else {
Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException();
}
}
QScrollAreaWrap::~QScrollAreaWrap() {
delete this->instance;
}
Napi::Value QScrollAreaWrap::setWidget(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Object contentWidget = info[0].As<Napi::Object>();
QWidgetWrap* contentWidgetWrap = Napi::ObjectWrap<QWidgetWrap>::Unwrap(contentWidget);
this->instance->setWidget(contentWidgetWrap->getInternalInstance());
return env.Null();
}

View File

@ -0,0 +1,23 @@
#pragma once
#include <napi.h>
#include "nscrollarea.h"
#include "src/cpp/QtWidgets/QAbstractScrollArea/qabstractscrollarea_macro.h"
class QScrollAreaWrap : public Napi::ObjectWrap<QScrollAreaWrap>{
private:
NScrollArea* instance;
public:
static Napi::Object init(Napi::Env env, Napi::Object exports);
QScrollAreaWrap(const Napi::CallbackInfo& info);
~QScrollAreaWrap();
NScrollArea* getInternalInstance();
//class constructor
static Napi::FunctionReference constructor;
//wrapped methods
Napi::Value setWidget(const Napi::CallbackInfo &info);
QABSTRACTSCROLLAREA_WRAPPED_METHODS_DECLARATION
};

View File

@ -1,4 +1,4 @@
#include "QSpinBox_wrap.h"
#include "qspinbox_wrap.h"
#include "src/cpp/QtWidgets/QWidget/qwidget_wrap.h"
#include "src/cpp/QtGui/QIcon/qicon_wrap.h"
#include "src/cpp/Extras/Utils/nutils.h"
@ -19,7 +19,7 @@ Napi::Object QSpinBoxWrap::init(Napi::Env env, Napi::Object exports) {
InstanceMethod("minimum", &QSpinBoxWrap::minimum),
InstanceMethod("value", &QSpinBoxWrap::value),
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QSpinBoxWrap)
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QSpinBoxWrap)
});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
@ -35,9 +35,9 @@ QSpinBoxWrap::QSpinBoxWrap(const Napi::CallbackInfo& info): Napi::ObjectWrap<QSp
Napi::HandleScope scope(env);
if(info.Length() == 1) {
Napi::Object parentObject = info[0].As<Napi::Object>();
QWidgetWrap* parentWidgetWrap = Napi::ObjectWrap<QWidgetWrap>::Unwrap(parentObject);
this->instance = new NSpinBox(parentWidgetWrap->getInternalInstance()); //this sets the parent to current widget
Napi::Object parentObject = info[0].As<Napi::Object>();
QWidgetWrap* parentWidgetWrap = Napi::ObjectWrap<QWidgetWrap>::Unwrap(parentObject);
this->instance = new NSpinBox(parentWidgetWrap->getInternalInstance()); //this sets the parent to current widget
} else if (info.Length() == 0){
this->instance = new NSpinBox();
} else {

View File

@ -1,326 +0,0 @@
/****************************************************************************
** Meta object code from reading C++ file 'nwidget.h'
**
** Created by: The Qt Meta Object Compiler version 67 (Qt 5.12.1)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "nwidget.h"
#include <QtCore/qbytearray.h>
#include <QtCore/qmetatype.h>
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'nwidget.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 67
#error "This file was generated using the moc from 5.12.1. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
struct qt_meta_stringdata_NWidget_t {
QByteArrayData data[45];
char stringdata0[485];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
qptrdiff(offsetof(qt_meta_stringdata_NWidget_t, stringdata0) + ofs \
- idx * sizeof(QByteArrayData)) \
)
static const qt_meta_stringdata_NWidget_t qt_meta_stringdata_NWidget = {
{
QT_MOC_LITERAL(0, 0, 7), // "NWidget"
QT_MOC_LITERAL(1, 8, 7), // "display"
QT_MOC_LITERAL(2, 16, 10), // "alignItems"
QT_MOC_LITERAL(3, 27, 12), // "alignContent"
QT_MOC_LITERAL(4, 40, 9), // "alignSelf"
QT_MOC_LITERAL(5, 50, 14), // "justifyContent"
QT_MOC_LITERAL(6, 65, 9), // "direction"
QT_MOC_LITERAL(7, 75, 13), // "flexDirection"
QT_MOC_LITERAL(8, 89, 8), // "overflow"
QT_MOC_LITERAL(9, 98, 8), // "position"
QT_MOC_LITERAL(10, 107, 8), // "flexWrap"
QT_MOC_LITERAL(11, 116, 4), // "flex"
QT_MOC_LITERAL(12, 121, 8), // "flexGrow"
QT_MOC_LITERAL(13, 130, 10), // "flexShrink"
QT_MOC_LITERAL(14, 141, 11), // "aspectRatio"
QT_MOC_LITERAL(15, 153, 3), // "top"
QT_MOC_LITERAL(16, 157, 5), // "right"
QT_MOC_LITERAL(17, 163, 6), // "bottom"
QT_MOC_LITERAL(18, 170, 4), // "left"
QT_MOC_LITERAL(19, 175, 9), // "flexBasis"
QT_MOC_LITERAL(20, 185, 8), // "minWidth"
QT_MOC_LITERAL(21, 194, 9), // "minHeight"
QT_MOC_LITERAL(22, 204, 8), // "maxWidth"
QT_MOC_LITERAL(23, 213, 9), // "maxHeight"
QT_MOC_LITERAL(24, 223, 10), // "paddingTop"
QT_MOC_LITERAL(25, 234, 12), // "paddingRight"
QT_MOC_LITERAL(26, 247, 13), // "paddingBottom"
QT_MOC_LITERAL(27, 261, 11), // "paddingLeft"
QT_MOC_LITERAL(28, 273, 17), // "paddingHorizontal"
QT_MOC_LITERAL(29, 291, 15), // "paddingVertical"
QT_MOC_LITERAL(30, 307, 7), // "padding"
QT_MOC_LITERAL(31, 315, 9), // "marginTop"
QT_MOC_LITERAL(32, 325, 11), // "marginRight"
QT_MOC_LITERAL(33, 337, 12), // "marginBottom"
QT_MOC_LITERAL(34, 350, 10), // "marginLeft"
QT_MOC_LITERAL(35, 361, 16), // "marginHorizontal"
QT_MOC_LITERAL(36, 378, 14), // "marginVertical"
QT_MOC_LITERAL(37, 393, 6), // "margin"
QT_MOC_LITERAL(38, 400, 9), // "borderTop"
QT_MOC_LITERAL(39, 410, 11), // "borderRight"
QT_MOC_LITERAL(40, 422, 12), // "borderBottom"
QT_MOC_LITERAL(41, 435, 10), // "borderLeft"
QT_MOC_LITERAL(42, 446, 16), // "borderHorizontal"
QT_MOC_LITERAL(43, 463, 14), // "borderVertical"
QT_MOC_LITERAL(44, 478, 6) // "border"
},
"NWidget\0display\0alignItems\0alignContent\0"
"alignSelf\0justifyContent\0direction\0"
"flexDirection\0overflow\0position\0"
"flexWrap\0flex\0flexGrow\0flexShrink\0"
"aspectRatio\0top\0right\0bottom\0left\0"
"flexBasis\0minWidth\0minHeight\0maxWidth\0"
"maxHeight\0paddingTop\0paddingRight\0"
"paddingBottom\0paddingLeft\0paddingHorizontal\0"
"paddingVertical\0padding\0marginTop\0"
"marginRight\0marginBottom\0marginLeft\0"
"marginHorizontal\0marginVertical\0margin\0"
"borderTop\0borderRight\0borderBottom\0"
"borderLeft\0borderHorizontal\0borderVertical\0"
"border"
};
#undef QT_MOC_LITERAL
static const uint qt_meta_data_NWidget[] = {
// content:
8, // revision
0, // classname
0, 0, // classinfo
0, 0, // methods
44, 14, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
// properties: name, type, flags
1, QMetaType::QString, 0x00095003,
2, QMetaType::QString, 0x00095003,
3, QMetaType::QString, 0x00095003,
4, QMetaType::QString, 0x00095003,
5, QMetaType::QString, 0x00095003,
6, QMetaType::QString, 0x00095003,
7, QMetaType::QString, 0x00095003,
8, QMetaType::QString, 0x00095003,
9, QMetaType::QString, 0x00095003,
10, QMetaType::QString, 0x00095003,
11, QMetaType::Float, 0x00095003,
12, QMetaType::Float, 0x00095003,
13, QMetaType::Float, 0x00095003,
14, QMetaType::Float, 0x00095003,
15, QMetaType::QString, 0x00095003,
16, QMetaType::QString, 0x00095003,
17, QMetaType::QString, 0x00095003,
18, QMetaType::QString, 0x00095003,
19, QMetaType::QString, 0x00095003,
20, QMetaType::QString, 0x00095003,
21, QMetaType::QString, 0x00095003,
22, QMetaType::QString, 0x00095003,
23, QMetaType::QString, 0x00095003,
24, QMetaType::QString, 0x00095003,
25, QMetaType::QString, 0x00095003,
26, QMetaType::QString, 0x00095003,
27, QMetaType::QString, 0x00095003,
28, QMetaType::QString, 0x00095003,
29, QMetaType::QString, 0x00095003,
30, QMetaType::QString, 0x00095003,
31, QMetaType::QString, 0x00095003,
32, QMetaType::QString, 0x00095003,
33, QMetaType::QString, 0x00095003,
34, QMetaType::QString, 0x00095003,
35, QMetaType::QString, 0x00095003,
36, QMetaType::QString, 0x00095003,
37, QMetaType::QString, 0x00095003,
38, QMetaType::Float, 0x00095003,
39, QMetaType::Float, 0x00095003,
40, QMetaType::Float, 0x00095003,
41, QMetaType::Float, 0x00095003,
42, QMetaType::Float, 0x00095003,
43, QMetaType::Float, 0x00095003,
44, QMetaType::Float, 0x00095003,
0 // eod
};
void NWidget::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
#ifndef QT_NO_PROPERTIES
if (_c == QMetaObject::ReadProperty) {
auto *_t = static_cast<NWidget *>(_o);
Q_UNUSED(_t)
void *_v = _a[0];
switch (_id) {
case 0: *reinterpret_cast< QString*>(_v) = _t->_yDisplay; break;
case 1: *reinterpret_cast< QString*>(_v) = _t->_yAlignItems; break;
case 2: *reinterpret_cast< QString*>(_v) = _t->_yAlignContent; break;
case 3: *reinterpret_cast< QString*>(_v) = _t->_yAlignSelf; break;
case 4: *reinterpret_cast< QString*>(_v) = _t->_yJustifyContent; break;
case 5: *reinterpret_cast< QString*>(_v) = _t->_yDirection; break;
case 6: *reinterpret_cast< QString*>(_v) = _t->_yFlexDirection; break;
case 7: *reinterpret_cast< QString*>(_v) = _t->_yOverflow; break;
case 8: *reinterpret_cast< QString*>(_v) = _t->_yPosition; break;
case 9: *reinterpret_cast< QString*>(_v) = _t->_yFlexWrap; break;
case 10: *reinterpret_cast< float*>(_v) = _t->_yFlex; break;
case 11: *reinterpret_cast< float*>(_v) = _t->_yFlexGrow; break;
case 12: *reinterpret_cast< float*>(_v) = _t->_yFlexShrink; break;
case 13: *reinterpret_cast< float*>(_v) = _t->_yAspectRatio; break;
case 14: *reinterpret_cast< QString*>(_v) = _t->_yTop; break;
case 15: *reinterpret_cast< QString*>(_v) = _t->_yRight; break;
case 16: *reinterpret_cast< QString*>(_v) = _t->_yBottom; break;
case 17: *reinterpret_cast< QString*>(_v) = _t->_yLeft; break;
case 18: *reinterpret_cast< QString*>(_v) = _t->_yFlexBasis; break;
case 19: *reinterpret_cast< QString*>(_v) = _t->_yMinWidth; break;
case 20: *reinterpret_cast< QString*>(_v) = _t->_yMinHeight; break;
case 21: *reinterpret_cast< QString*>(_v) = _t->_yMaxWidth; break;
case 22: *reinterpret_cast< QString*>(_v) = _t->_yMaxHeight; break;
case 23: *reinterpret_cast< QString*>(_v) = _t->_yPaddingTop; break;
case 24: *reinterpret_cast< QString*>(_v) = _t->_yPaddingRight; break;
case 25: *reinterpret_cast< QString*>(_v) = _t->_yPaddingBottom; break;
case 26: *reinterpret_cast< QString*>(_v) = _t->_yPaddingLeft; break;
case 27: *reinterpret_cast< QString*>(_v) = _t->_yPaddingHorizontal; break;
case 28: *reinterpret_cast< QString*>(_v) = _t->_yPaddingVertical; break;
case 29: *reinterpret_cast< QString*>(_v) = _t->_yPadding; break;
case 30: *reinterpret_cast< QString*>(_v) = _t->_yMarginTop; break;
case 31: *reinterpret_cast< QString*>(_v) = _t->_yMarginRight; break;
case 32: *reinterpret_cast< QString*>(_v) = _t->_yMarginBottom; break;
case 33: *reinterpret_cast< QString*>(_v) = _t->_yMarginLeft; break;
case 34: *reinterpret_cast< QString*>(_v) = _t->_yMarginHorizontal; break;
case 35: *reinterpret_cast< QString*>(_v) = _t->_yMarginVertical; break;
case 36: *reinterpret_cast< QString*>(_v) = _t->_yMargin; break;
case 37: *reinterpret_cast< float*>(_v) = _t->_yBorderTop; break;
case 38: *reinterpret_cast< float*>(_v) = _t->_yBorderRight; break;
case 39: *reinterpret_cast< float*>(_v) = _t->_yBorderBottom; break;
case 40: *reinterpret_cast< float*>(_v) = _t->_yBorderLeft; break;
case 41: *reinterpret_cast< float*>(_v) = _t->_yBorderHorizontal; break;
case 42: *reinterpret_cast< float*>(_v) = _t->_yBorderVertical; break;
case 43: *reinterpret_cast< float*>(_v) = _t->_yBorder; break;
default: break;
}
} else if (_c == QMetaObject::WriteProperty) {
auto *_t = static_cast<NWidget *>(_o);
Q_UNUSED(_t)
void *_v = _a[0];
switch (_id) {
case 0: _t->setYDisplay(*reinterpret_cast< QString*>(_v)); break;
case 1: _t->setYAlignItems(*reinterpret_cast< QString*>(_v)); break;
case 2: _t->setYAlignContent(*reinterpret_cast< QString*>(_v)); break;
case 3: _t->setYAlignSelf(*reinterpret_cast< QString*>(_v)); break;
case 4: _t->setYJustifyContent(*reinterpret_cast< QString*>(_v)); break;
case 5: _t->setYDirection(*reinterpret_cast< QString*>(_v)); break;
case 6: _t->setYFlexDirection(*reinterpret_cast< QString*>(_v)); break;
case 7: _t->setYOverflow(*reinterpret_cast< QString*>(_v)); break;
case 8: _t->setYPosition(*reinterpret_cast< QString*>(_v)); break;
case 9: _t->setYFlexWrap(*reinterpret_cast< QString*>(_v)); break;
case 10: _t->setYFlex(*reinterpret_cast< float*>(_v)); break;
case 11: _t->setYFlexGrow(*reinterpret_cast< float*>(_v)); break;
case 12: _t->setYFlexShrink(*reinterpret_cast< float*>(_v)); break;
case 13: _t->setYAspectRatio(*reinterpret_cast< float*>(_v)); break;
case 14: _t->setYNodeTop(*reinterpret_cast< QString*>(_v)); break;
case 15: _t->setYNodeRight(*reinterpret_cast< QString*>(_v)); break;
case 16: _t->setYNodeBottom(*reinterpret_cast< QString*>(_v)); break;
case 17: _t->setYNodeLeft(*reinterpret_cast< QString*>(_v)); break;
case 18: _t->setYFlexBasis(*reinterpret_cast< QString*>(_v)); break;
case 19: _t->setYMinWidth(*reinterpret_cast< QString*>(_v)); break;
case 20: _t->setYMinHeight(*reinterpret_cast< QString*>(_v)); break;
case 21: _t->setYMaxWidth(*reinterpret_cast< QString*>(_v)); break;
case 22: _t->setYMaxHeight(*reinterpret_cast< QString*>(_v)); break;
case 23: _t->setYPaddingTop(*reinterpret_cast< QString*>(_v)); break;
case 24: _t->setYPaddingRight(*reinterpret_cast< QString*>(_v)); break;
case 25: _t->setYPaddingBottom(*reinterpret_cast< QString*>(_v)); break;
case 26: _t->setYPaddingLeft(*reinterpret_cast< QString*>(_v)); break;
case 27: _t->setYPaddingHorizontal(*reinterpret_cast< QString*>(_v)); break;
case 28: _t->setYPaddingVertical(*reinterpret_cast< QString*>(_v)); break;
case 29: _t->setYPadding(*reinterpret_cast< QString*>(_v)); break;
case 30: _t->setYMarginTop(*reinterpret_cast< QString*>(_v)); break;
case 31: _t->setYMarginRight(*reinterpret_cast< QString*>(_v)); break;
case 32: _t->setYMarginBottom(*reinterpret_cast< QString*>(_v)); break;
case 33: _t->setYMarginLeft(*reinterpret_cast< QString*>(_v)); break;
case 34: _t->setYMarginHorizontal(*reinterpret_cast< QString*>(_v)); break;
case 35: _t->setYMarginVertical(*reinterpret_cast< QString*>(_v)); break;
case 36: _t->setYMarginAll(*reinterpret_cast< QString*>(_v)); break;
case 37: _t->setYBorderTop(*reinterpret_cast< float*>(_v)); break;
case 38: _t->setYBorderRight(*reinterpret_cast< float*>(_v)); break;
case 39: _t->setYBorderBottom(*reinterpret_cast< float*>(_v)); break;
case 40: _t->setYBorderLeft(*reinterpret_cast< float*>(_v)); break;
case 41: _t->setYBorderHorizontal(*reinterpret_cast< float*>(_v)); break;
case 42: _t->setYBorderVertical(*reinterpret_cast< float*>(_v)); break;
case 43: _t->setYBorder(*reinterpret_cast< float*>(_v)); break;
default: break;
}
} else if (_c == QMetaObject::ResetProperty) {
}
#endif // QT_NO_PROPERTIES
Q_UNUSED(_o);
Q_UNUSED(_id);
Q_UNUSED(_c);
Q_UNUSED(_a);
}
QT_INIT_METAOBJECT const QMetaObject NWidget::staticMetaObject = { {
&QWidget::staticMetaObject,
qt_meta_stringdata_NWidget.data,
qt_meta_data_NWidget,
qt_static_metacall,
nullptr,
nullptr
} };
const QMetaObject *NWidget::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}
void *NWidget::qt_metacast(const char *_clname)
{
if (!_clname) return nullptr;
if (!strcmp(_clname, qt_meta_stringdata_NWidget.stringdata0))
return static_cast<void*>(this);
if (!strcmp(_clname, "YogaWidget"))
return static_cast< YogaWidget*>(this);
return QWidget::qt_metacast(_clname);
}
int NWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QWidget::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
#ifndef QT_NO_PROPERTIES
if (_c == QMetaObject::ReadProperty || _c == QMetaObject::WriteProperty
|| _c == QMetaObject::ResetProperty || _c == QMetaObject::RegisterPropertyMetaType) {
qt_static_metacall(this, _c, _id, _a);
_id -= 44;
} else if (_c == QMetaObject::QueryPropertyDesignable) {
_id -= 44;
} else if (_c == QMetaObject::QueryPropertyScriptable) {
_id -= 44;
} else if (_c == QMetaObject::QueryPropertyStored) {
_id -= 44;
} else if (_c == QMetaObject::QueryPropertyEditable) {
_id -= 44;
} else if (_c == QMetaObject::QueryPropertyUser) {
_id -= 44;
}
#endif // QT_NO_PROPERTIES
return _id;
}
QT_WARNING_POP
QT_END_MOC_NAMESPACE

View File

@ -18,19 +18,19 @@ YOGAWIDGET_WRAPPED_METHODS_DECLARATION \
EVENTWIDGET_WRAPPED_METHODS_DECLARATION \
\
Napi::Value show(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
Napi::HandleScope scope(env); \
this->instance->show(); \
return env.Null(); \
Napi::Env env = info.Env(); \
Napi::HandleScope scope(env); \
this->instance->show(); \
return env.Null(); \
} \
\
Napi::Value resize(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
Napi::HandleScope scope(env); \
Napi::Number width = info[0].As<Napi::Number>(); \
Napi::Number height = info[1].As<Napi::Number>(); \
this->instance->resize(width.Int32Value(), height.Int32Value()); \
return env.Null(); \
Napi::Env env = info.Env(); \
Napi::HandleScope scope(env); \
Napi::Number width = info[0].As<Napi::Number>(); \
Napi::Number height = info[1].As<Napi::Number>(); \
this->instance->resize(width.Int32Value(), height.Int32Value()); \
return env.Null(); \
} \
\
Napi::Value close(const Napi::CallbackInfo& info) { \
@ -41,12 +41,12 @@ Napi::Value close(const Napi::CallbackInfo& info) { \
} \
\
Napi::Value setLayout(const Napi::CallbackInfo& info){ \
Napi::Env env = info.Env(); \
Napi::HandleScope scope(env); \
Napi::Object layoutObject = info[0].As<Napi::Object>(); \
QLayoutWrap* layoutWrap = Napi::ObjectWrap<QLayoutWrap>::Unwrap(layoutObject); \
this->instance->setLayout(layoutWrap->getInternalInstance()); \
return env.Null(); \
Napi::Env env = info.Env(); \
Napi::HandleScope scope(env); \
Napi::Object layoutObject = info[0].As<Napi::Object>(); \
QLayoutWrap* layoutWrap = Napi::ObjectWrap<QLayoutWrap>::Unwrap(layoutObject); \
this->instance->setLayout(layoutWrap->getInternalInstance()); \
return env.Null(); \
} \
\
Napi::Value setStyleSheet(const Napi::CallbackInfo& info){ \
@ -72,10 +72,10 @@ Napi::Value styleSheet(const Napi::CallbackInfo& info){ \
return Napi::String::New(env, stylesheet.toStdString()); \
} \
Napi::Value hide(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
Napi::HandleScope scope(env); \
this->instance->hide(); \
return env.Null(); \
Napi::Env env = info.Env(); \
Napi::HandleScope scope(env); \
this->instance->hide(); \
return env.Null(); \
} \
Napi::Value move(const Napi::CallbackInfo& info){ \
Napi::Env env = info.Env(); \
@ -87,11 +87,11 @@ Napi::Value move(const Napi::CallbackInfo& info){ \
} \
\
Napi::Value setObjectName(const Napi::CallbackInfo& info){ \
Napi::Env env = info.Env(); \
Napi::HandleScope scope(env); \
Napi::String objectName = info[0].As<Napi::String>(); \
this->instance->setObjectName(QString::fromStdString(objectName.Utf8Value())); \
return env.Null(); \
Napi::Env env = info.Env(); \
Napi::HandleScope scope(env); \
Napi::String objectName = info[0].As<Napi::String>(); \
this->instance->setObjectName(QString::fromStdString(objectName.Utf8Value())); \
return env.Null(); \
} \
Napi::Value objectName(const Napi::CallbackInfo& info){ \
Napi::Env env = info.Env(); \
@ -100,18 +100,18 @@ Napi::Value objectName(const Napi::CallbackInfo& info){ \
return Napi::String::New(env, objectName.toStdString()); \
} \
Napi::Value setMouseTracking(const Napi::CallbackInfo& info){ \
Napi::Env env = info.Env(); \
Napi::HandleScope scope(env); \
Napi::Boolean isMouseTracked = info[0].As<Napi::Boolean>(); \
this->instance->setMouseTracking(isMouseTracked.Value()); \
return env.Null(); \
Napi::Env env = info.Env(); \
Napi::HandleScope scope(env); \
Napi::Boolean isMouseTracked = info[0].As<Napi::Boolean>(); \
this->instance->setMouseTracking(isMouseTracked.Value()); \
return env.Null(); \
} \
Napi::Value setEnabled(const Napi::CallbackInfo& info){ \
Napi::Env env = info.Env(); \
Napi::HandleScope scope(env); \
Napi::Boolean enabled = info[0].As<Napi::Boolean>(); \
this->instance->setEnabled(enabled.Value()); \
return env.Null(); \
Napi::Env env = info.Env(); \
Napi::HandleScope scope(env); \
Napi::Boolean enabled = info[0].As<Napi::Boolean>(); \
this->instance->setEnabled(enabled.Value()); \
return env.Null(); \
} \
Napi::Value setFixedSize(const Napi::CallbackInfo& info){ \
Napi::Env env = info.Env(); \

View File

@ -23,10 +23,14 @@ QWidgetWrap::QWidgetWrap(const Napi::CallbackInfo& info): Napi::ObjectWrap<QWidg
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
if(info.Length() == 1) {
Napi::Object parentObject = info[0].As<Napi::Object>();
QWidgetWrap* parentWidgetWrap = Napi::ObjectWrap<QWidgetWrap>::Unwrap(parentObject);
this->instance = new NWidget(parentWidgetWrap->getInternalInstance()); //this sets the parent to current widget
}else if (info.Length() == 0){
if(info[0].IsExternal()){
this->instance = info[0].As<Napi::External<NWidget>>().Data();
} else {
Napi::Object parentObject = info[0].As<Napi::Object>();
QWidgetWrap* parentWidgetWrap = Napi::ObjectWrap<QWidgetWrap>::Unwrap(parentObject);
this->instance = new NWidget(parentWidgetWrap->getInternalInstance()); //this sets the parent to current widget
}
} else if (info.Length() == 0){
this->instance = new NWidget();
}else {
Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException();

View File

@ -0,0 +1,337 @@
/****************************************************************************
** Meta object code from reading C++ file 'nscrollarea.h'
**
** Created by: The Qt Meta Object Compiler version 67 (Qt 5.13.0)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include <memory>
#include "../QtWidgets/QScrollArea/nscrollarea.h"
#include <QtCore/qbytearray.h>
#include <QtCore/qmetatype.h>
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'nscrollarea.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 67
#error "This file was generated using the moc from 5.13.0. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
struct qt_meta_stringdata_NScrollArea_t {
QByteArrayData data[47];
char stringdata0[548];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
qptrdiff(offsetof(qt_meta_stringdata_NScrollArea_t, stringdata0) + ofs \
- idx * sizeof(QByteArrayData)) \
)
static const qt_meta_stringdata_NScrollArea_t qt_meta_stringdata_NScrollArea = {
{
QT_MOC_LITERAL(0, 0, 11), // "NScrollArea"
QT_MOC_LITERAL(1, 12, 8), // "yDisplay"
QT_MOC_LITERAL(2, 21, 11), // "yAlignItems"
QT_MOC_LITERAL(3, 33, 13), // "yAlignContent"
QT_MOC_LITERAL(4, 47, 10), // "yAlignSelf"
QT_MOC_LITERAL(5, 58, 15), // "yJustifyContent"
QT_MOC_LITERAL(6, 74, 10), // "yDirection"
QT_MOC_LITERAL(7, 85, 14), // "yFlexDirection"
QT_MOC_LITERAL(8, 100, 9), // "yOverflow"
QT_MOC_LITERAL(9, 110, 9), // "yPosition"
QT_MOC_LITERAL(10, 120, 9), // "yFlexWrap"
QT_MOC_LITERAL(11, 130, 5), // "yFlex"
QT_MOC_LITERAL(12, 136, 9), // "yFlexGrow"
QT_MOC_LITERAL(13, 146, 11), // "yFlexShrink"
QT_MOC_LITERAL(14, 158, 12), // "yAspectRatio"
QT_MOC_LITERAL(15, 171, 4), // "yTop"
QT_MOC_LITERAL(16, 176, 6), // "yRight"
QT_MOC_LITERAL(17, 183, 7), // "yBottom"
QT_MOC_LITERAL(18, 191, 5), // "yLeft"
QT_MOC_LITERAL(19, 197, 10), // "yFlexBasis"
QT_MOC_LITERAL(20, 208, 9), // "yMinWidth"
QT_MOC_LITERAL(21, 218, 10), // "yMinHeight"
QT_MOC_LITERAL(22, 229, 6), // "yWidth"
QT_MOC_LITERAL(23, 236, 7), // "yHeight"
QT_MOC_LITERAL(24, 244, 9), // "yMaxWidth"
QT_MOC_LITERAL(25, 254, 10), // "yMaxHeight"
QT_MOC_LITERAL(26, 265, 11), // "yPaddingTop"
QT_MOC_LITERAL(27, 277, 13), // "yPaddingRight"
QT_MOC_LITERAL(28, 291, 14), // "yPaddingBottom"
QT_MOC_LITERAL(29, 306, 12), // "yPaddingLeft"
QT_MOC_LITERAL(30, 319, 18), // "yPaddingHorizontal"
QT_MOC_LITERAL(31, 338, 16), // "yPaddingVertical"
QT_MOC_LITERAL(32, 355, 8), // "yPadding"
QT_MOC_LITERAL(33, 364, 10), // "yMarginTop"
QT_MOC_LITERAL(34, 375, 12), // "yMarginRight"
QT_MOC_LITERAL(35, 388, 13), // "yMarginBottom"
QT_MOC_LITERAL(36, 402, 11), // "yMarginLeft"
QT_MOC_LITERAL(37, 414, 17), // "yMarginHorizontal"
QT_MOC_LITERAL(38, 432, 15), // "yMarginVertical"
QT_MOC_LITERAL(39, 448, 7), // "yMargin"
QT_MOC_LITERAL(40, 456, 10), // "yBorderTop"
QT_MOC_LITERAL(41, 467, 12), // "yBorderRight"
QT_MOC_LITERAL(42, 480, 13), // "yBorderBottom"
QT_MOC_LITERAL(43, 494, 11), // "yBorderLeft"
QT_MOC_LITERAL(44, 506, 17), // "yBorderHorizontal"
QT_MOC_LITERAL(45, 524, 15), // "yBorderVertical"
QT_MOC_LITERAL(46, 540, 7) // "yBorder"
},
"NScrollArea\0yDisplay\0yAlignItems\0"
"yAlignContent\0yAlignSelf\0yJustifyContent\0"
"yDirection\0yFlexDirection\0yOverflow\0"
"yPosition\0yFlexWrap\0yFlex\0yFlexGrow\0"
"yFlexShrink\0yAspectRatio\0yTop\0yRight\0"
"yBottom\0yLeft\0yFlexBasis\0yMinWidth\0"
"yMinHeight\0yWidth\0yHeight\0yMaxWidth\0"
"yMaxHeight\0yPaddingTop\0yPaddingRight\0"
"yPaddingBottom\0yPaddingLeft\0"
"yPaddingHorizontal\0yPaddingVertical\0"
"yPadding\0yMarginTop\0yMarginRight\0"
"yMarginBottom\0yMarginLeft\0yMarginHorizontal\0"
"yMarginVertical\0yMargin\0yBorderTop\0"
"yBorderRight\0yBorderBottom\0yBorderLeft\0"
"yBorderHorizontal\0yBorderVertical\0"
"yBorder"
};
#undef QT_MOC_LITERAL
static const uint qt_meta_data_NScrollArea[] = {
// content:
8, // revision
0, // classname
0, 0, // classinfo
0, 0, // methods
46, 14, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
// properties: name, type, flags
1, QMetaType::QString, 0x00095103,
2, QMetaType::QString, 0x00095103,
3, QMetaType::QString, 0x00095103,
4, QMetaType::QString, 0x00095103,
5, QMetaType::QString, 0x00095103,
6, QMetaType::QString, 0x00095103,
7, QMetaType::QString, 0x00095103,
8, QMetaType::QString, 0x00095103,
9, QMetaType::QString, 0x00095103,
10, QMetaType::QString, 0x00095103,
11, QMetaType::Float, 0x00095103,
12, QMetaType::Float, 0x00095103,
13, QMetaType::Float, 0x00095103,
14, QMetaType::Float, 0x00095103,
15, QMetaType::QString, 0x00095003,
16, QMetaType::QString, 0x00095003,
17, QMetaType::QString, 0x00095003,
18, QMetaType::QString, 0x00095003,
19, QMetaType::QString, 0x00095103,
20, QMetaType::QString, 0x00095103,
21, QMetaType::QString, 0x00095103,
22, QMetaType::QString, 0x00095103,
23, QMetaType::QString, 0x00095103,
24, QMetaType::QString, 0x00095103,
25, QMetaType::QString, 0x00095103,
26, QMetaType::QString, 0x00095103,
27, QMetaType::QString, 0x00095103,
28, QMetaType::QString, 0x00095103,
29, QMetaType::QString, 0x00095103,
30, QMetaType::QString, 0x00095103,
31, QMetaType::QString, 0x00095103,
32, QMetaType::QString, 0x00095103,
33, QMetaType::QString, 0x00095103,
34, QMetaType::QString, 0x00095103,
35, QMetaType::QString, 0x00095103,
36, QMetaType::QString, 0x00095103,
37, QMetaType::QString, 0x00095103,
38, QMetaType::QString, 0x00095103,
39, QMetaType::QString, 0x00095003,
40, QMetaType::Float, 0x00095103,
41, QMetaType::Float, 0x00095103,
42, QMetaType::Float, 0x00095103,
43, QMetaType::Float, 0x00095103,
44, QMetaType::Float, 0x00095103,
45, QMetaType::Float, 0x00095103,
46, QMetaType::Float, 0x00095103,
0 // eod
};
void NScrollArea::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
#ifndef QT_NO_PROPERTIES
if (_c == QMetaObject::ReadProperty) {
auto *_t = static_cast<NScrollArea *>(_o);
Q_UNUSED(_t)
void *_v = _a[0];
switch (_id) {
case 0: *reinterpret_cast< QString*>(_v) = _t->_yDisplay; break;
case 1: *reinterpret_cast< QString*>(_v) = _t->_yAlignItems; break;
case 2: *reinterpret_cast< QString*>(_v) = _t->_yAlignContent; break;
case 3: *reinterpret_cast< QString*>(_v) = _t->_yAlignSelf; break;
case 4: *reinterpret_cast< QString*>(_v) = _t->_yJustifyContent; break;
case 5: *reinterpret_cast< QString*>(_v) = _t->_yDirection; break;
case 6: *reinterpret_cast< QString*>(_v) = _t->_yFlexDirection; break;
case 7: *reinterpret_cast< QString*>(_v) = _t->_yOverflow; break;
case 8: *reinterpret_cast< QString*>(_v) = _t->_yPosition; break;
case 9: *reinterpret_cast< QString*>(_v) = _t->_yFlexWrap; break;
case 10: *reinterpret_cast< float*>(_v) = _t->_yFlex; break;
case 11: *reinterpret_cast< float*>(_v) = _t->_yFlexGrow; break;
case 12: *reinterpret_cast< float*>(_v) = _t->_yFlexShrink; break;
case 13: *reinterpret_cast< float*>(_v) = _t->_yAspectRatio; break;
case 14: *reinterpret_cast< QString*>(_v) = _t->_yTop; break;
case 15: *reinterpret_cast< QString*>(_v) = _t->_yRight; break;
case 16: *reinterpret_cast< QString*>(_v) = _t->_yBottom; break;
case 17: *reinterpret_cast< QString*>(_v) = _t->_yLeft; break;
case 18: *reinterpret_cast< QString*>(_v) = _t->_yFlexBasis; break;
case 19: *reinterpret_cast< QString*>(_v) = _t->_yMinWidth; break;
case 20: *reinterpret_cast< QString*>(_v) = _t->_yMinHeight; break;
case 21: *reinterpret_cast< QString*>(_v) = _t->_yWidth; break;
case 22: *reinterpret_cast< QString*>(_v) = _t->_yHeight; break;
case 23: *reinterpret_cast< QString*>(_v) = _t->_yMaxWidth; break;
case 24: *reinterpret_cast< QString*>(_v) = _t->_yMaxHeight; break;
case 25: *reinterpret_cast< QString*>(_v) = _t->_yPaddingTop; break;
case 26: *reinterpret_cast< QString*>(_v) = _t->_yPaddingRight; break;
case 27: *reinterpret_cast< QString*>(_v) = _t->_yPaddingBottom; break;
case 28: *reinterpret_cast< QString*>(_v) = _t->_yPaddingLeft; break;
case 29: *reinterpret_cast< QString*>(_v) = _t->_yPaddingHorizontal; break;
case 30: *reinterpret_cast< QString*>(_v) = _t->_yPaddingVertical; break;
case 31: *reinterpret_cast< QString*>(_v) = _t->_yPadding; break;
case 32: *reinterpret_cast< QString*>(_v) = _t->_yMarginTop; break;
case 33: *reinterpret_cast< QString*>(_v) = _t->_yMarginRight; break;
case 34: *reinterpret_cast< QString*>(_v) = _t->_yMarginBottom; break;
case 35: *reinterpret_cast< QString*>(_v) = _t->_yMarginLeft; break;
case 36: *reinterpret_cast< QString*>(_v) = _t->_yMarginHorizontal; break;
case 37: *reinterpret_cast< QString*>(_v) = _t->_yMarginVertical; break;
case 38: *reinterpret_cast< QString*>(_v) = _t->_yMargin; break;
case 39: *reinterpret_cast< float*>(_v) = _t->_yBorderTop; break;
case 40: *reinterpret_cast< float*>(_v) = _t->_yBorderRight; break;
case 41: *reinterpret_cast< float*>(_v) = _t->_yBorderBottom; break;
case 42: *reinterpret_cast< float*>(_v) = _t->_yBorderLeft; break;
case 43: *reinterpret_cast< float*>(_v) = _t->_yBorderHorizontal; break;
case 44: *reinterpret_cast< float*>(_v) = _t->_yBorderVertical; break;
case 45: *reinterpret_cast< float*>(_v) = _t->_yBorder; break;
default: break;
}
} else if (_c == QMetaObject::WriteProperty) {
auto *_t = static_cast<NScrollArea *>(_o);
Q_UNUSED(_t)
void *_v = _a[0];
switch (_id) {
case 0: _t->setYDisplay(*reinterpret_cast< QString*>(_v)); break;
case 1: _t->setYAlignItems(*reinterpret_cast< QString*>(_v)); break;
case 2: _t->setYAlignContent(*reinterpret_cast< QString*>(_v)); break;
case 3: _t->setYAlignSelf(*reinterpret_cast< QString*>(_v)); break;
case 4: _t->setYJustifyContent(*reinterpret_cast< QString*>(_v)); break;
case 5: _t->setYDirection(*reinterpret_cast< QString*>(_v)); break;
case 6: _t->setYFlexDirection(*reinterpret_cast< QString*>(_v)); break;
case 7: _t->setYOverflow(*reinterpret_cast< QString*>(_v)); break;
case 8: _t->setYPosition(*reinterpret_cast< QString*>(_v)); break;
case 9: _t->setYFlexWrap(*reinterpret_cast< QString*>(_v)); break;
case 10: _t->setYFlex(*reinterpret_cast< float*>(_v)); break;
case 11: _t->setYFlexGrow(*reinterpret_cast< float*>(_v)); break;
case 12: _t->setYFlexShrink(*reinterpret_cast< float*>(_v)); break;
case 13: _t->setYAspectRatio(*reinterpret_cast< float*>(_v)); break;
case 14: _t->setYNodeTop(*reinterpret_cast< QString*>(_v)); break;
case 15: _t->setYNodeRight(*reinterpret_cast< QString*>(_v)); break;
case 16: _t->setYNodeBottom(*reinterpret_cast< QString*>(_v)); break;
case 17: _t->setYNodeLeft(*reinterpret_cast< QString*>(_v)); break;
case 18: _t->setYFlexBasis(*reinterpret_cast< QString*>(_v)); break;
case 19: _t->setYMinWidth(*reinterpret_cast< QString*>(_v)); break;
case 20: _t->setYMinHeight(*reinterpret_cast< QString*>(_v)); break;
case 21: _t->setYWidth(*reinterpret_cast< QString*>(_v)); break;
case 22: _t->setYHeight(*reinterpret_cast< QString*>(_v)); break;
case 23: _t->setYMaxWidth(*reinterpret_cast< QString*>(_v)); break;
case 24: _t->setYMaxHeight(*reinterpret_cast< QString*>(_v)); break;
case 25: _t->setYPaddingTop(*reinterpret_cast< QString*>(_v)); break;
case 26: _t->setYPaddingRight(*reinterpret_cast< QString*>(_v)); break;
case 27: _t->setYPaddingBottom(*reinterpret_cast< QString*>(_v)); break;
case 28: _t->setYPaddingLeft(*reinterpret_cast< QString*>(_v)); break;
case 29: _t->setYPaddingHorizontal(*reinterpret_cast< QString*>(_v)); break;
case 30: _t->setYPaddingVertical(*reinterpret_cast< QString*>(_v)); break;
case 31: _t->setYPadding(*reinterpret_cast< QString*>(_v)); break;
case 32: _t->setYMarginTop(*reinterpret_cast< QString*>(_v)); break;
case 33: _t->setYMarginRight(*reinterpret_cast< QString*>(_v)); break;
case 34: _t->setYMarginBottom(*reinterpret_cast< QString*>(_v)); break;
case 35: _t->setYMarginLeft(*reinterpret_cast< QString*>(_v)); break;
case 36: _t->setYMarginHorizontal(*reinterpret_cast< QString*>(_v)); break;
case 37: _t->setYMarginVertical(*reinterpret_cast< QString*>(_v)); break;
case 38: _t->setYMarginAll(*reinterpret_cast< QString*>(_v)); break;
case 39: _t->setYBorderTop(*reinterpret_cast< float*>(_v)); break;
case 40: _t->setYBorderRight(*reinterpret_cast< float*>(_v)); break;
case 41: _t->setYBorderBottom(*reinterpret_cast< float*>(_v)); break;
case 42: _t->setYBorderLeft(*reinterpret_cast< float*>(_v)); break;
case 43: _t->setYBorderHorizontal(*reinterpret_cast< float*>(_v)); break;
case 44: _t->setYBorderVertical(*reinterpret_cast< float*>(_v)); break;
case 45: _t->setYBorder(*reinterpret_cast< float*>(_v)); break;
default: break;
}
} else if (_c == QMetaObject::ResetProperty) {
}
#endif // QT_NO_PROPERTIES
Q_UNUSED(_o);
Q_UNUSED(_id);
Q_UNUSED(_c);
Q_UNUSED(_a);
}
QT_INIT_METAOBJECT const QMetaObject NScrollArea::staticMetaObject = { {
&QScrollArea::staticMetaObject,
qt_meta_stringdata_NScrollArea.data,
qt_meta_data_NScrollArea,
qt_static_metacall,
nullptr,
nullptr
} };
const QMetaObject *NScrollArea::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}
void *NScrollArea::qt_metacast(const char *_clname)
{
if (!_clname) return nullptr;
if (!strcmp(_clname, qt_meta_stringdata_NScrollArea.stringdata0))
return static_cast<void*>(this);
if (!strcmp(_clname, "NodeWidget"))
return static_cast< NodeWidget*>(this);
return QScrollArea::qt_metacast(_clname);
}
int NScrollArea::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QScrollArea::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
#ifndef QT_NO_PROPERTIES
if (_c == QMetaObject::ReadProperty || _c == QMetaObject::WriteProperty
|| _c == QMetaObject::ResetProperty || _c == QMetaObject::RegisterPropertyMetaType) {
qt_static_metacall(this, _c, _id, _a);
_id -= 46;
} else if (_c == QMetaObject::QueryPropertyDesignable) {
_id -= 46;
} else if (_c == QMetaObject::QueryPropertyScriptable) {
_id -= 46;
} else if (_c == QMetaObject::QueryPropertyStored) {
_id -= 46;
} else if (_c == QMetaObject::QueryPropertyEditable) {
_id -= 46;
} else if (_c == QMetaObject::QueryPropertyUser) {
_id -= 46;
}
#endif // QT_NO_PROPERTIES
return _id;
}
QT_WARNING_POP
QT_END_MOC_NAMESPACE

View File

@ -15,6 +15,7 @@
#include "src/cpp/QtWidgets/QPlainTextEdit/qplaintextedit_wrap.h"
#include "src/cpp/core/FlexLayout/flexlayout_wrap.h"
#include "src/cpp/QtGui/QEvent/QKeyEvent/qkeyevent_wrap.h"
#include "src/cpp/QtWidgets/QScrollArea/qscrollarea_wrap.h"
#include <napi.h>
// These cant be instantiated in JS Side
void InitPrivateHelpers(Napi::Env env){
@ -38,7 +39,9 @@ Napi::Object Main(Napi::Env env, Napi::Object exports) {
QLineEditWrap::init(env, exports);
QKeyEventWrap::init(env, exports);
QPlainTextEditWrap::init(env, exports);
return QLabelWrap::init(env, exports);
QLabelWrap::init(env, exports);
QScrollAreaWrap::init(env, exports);
return exports;
}
NODE_API_MODULE(NODE_GYP_MODULE_NAME, Main)

View File

@ -9,9 +9,10 @@ import {
FlexLayout,
QWidget,
QIcon,
QPlainTextEdit,
QPlainTextEditEvents
QPlainTextEdit
} from "./index";
import { QScrollArea } from "./lib/QtWidgets/QScrollArea";
import { QPixmap } from "./lib/QtGui/QPixmap";
const path = require("path");
@ -29,7 +30,6 @@ const lineEdit = new QLineEdit();
lineEdit.setPlaceholderText("Enter your thoughts here");
lineEdit.setObjectName("editable");
const button = new QPushButton();
button.setText("Push Push Push!");
button.setObjectName("btn");
@ -52,15 +52,18 @@ const rootView = new QWidget();
rootView.setObjectName("root");
rootView.setLayout(new FlexLayout());
const lineEditLabel = new QLabel();
lineEditLabel.setInlineStyle("font-size: 12px;");
lineEditLabel.setText("PlainTextEdit's bound Value");
const textEdit = new QPlainTextEdit();
textEdit.setPlainText("Hello");
textEdit.addEventListener(QPlainTextEditEvents.textChanged, () => {
lineEditLabel.setText(textEdit.toPlainText());
});
const scrollArea = new QScrollArea();
scrollArea.setInlineStyle("flex: 1; width:'100%';");
const imageLabel = new QLabel();
const pixmap = new QPixmap(
path.resolve(__dirname, "../extras/assets/kitchen.png")
);
imageLabel.setPixmap(pixmap);
scrollArea.setWidget(imageLabel);
if (rootView.layout) {
rootView.layout.addWidget(label);
@ -70,7 +73,7 @@ if (rootView.layout) {
rootView.layout.addWidget(button);
rootView.layout.addWidget(progressbar);
rootView.layout.addWidget(textEdit);
rootView.layout.addWidget(lineEditLabel);
rootView.layout.addWidget(scrollArea);
}
win.setCentralWidget(rootView);

View File

@ -1,11 +1,11 @@
// enums
export * from "./lib/QtEnums";
export { QApplication } from "./lib/QtGui/QApplication";
export { QWidget, QWidgetEvents } from "./lib/QtGui/QWidget";
export { QWidget, QWidgetEvents } from "./lib/QtWidgets/QWidget";
export { QPixmap } from "./lib/QtGui/QPixmap";
export { QIcon } from "./lib/QtGui/QIcon";
// Abstract:
export { NodeWidget } from "./lib/QtGui/QWidget";
export { NodeWidget } from "./lib/QtWidgets/QWidget";
export { NodeLayout } from "./lib/QtWidgets/QLayout";
// Widgets:
export { QCheckBox, QCheckBoxEvents } from "./lib/QtWidgets/QCheckBox";
@ -14,12 +14,13 @@ export { QLineEdit, QLineEditEvents } from "./lib/QtWidgets/QLineEdit";
export { QMainWindow, QMainWindowEvents } from "./lib/QtWidgets/QMainWindow";
export { QProgressBar, QProgressBarEvents } from "./lib/QtWidgets/QProgressBar";
export { QPushButton, QPushButtonEvents } from "./lib/QtWidgets/QPushButton";
export { QSpinBox , QSpinBoxEvents } from "./lib/QtWidgets/QSpinBox";
export { QSpinBox, QSpinBoxEvents } from "./lib/QtWidgets/QSpinBox";
export { QRadioButton, QRadioButtonEvents } from "./lib/QtWidgets/QRadioButton";
export {
QPlainTextEdit,
QPlainTextEditEvents
} from "./lib/QtWidgets/QPlainTextEdit";
export { QScrollArea, QScrollAreaEvents } from "./lib/QtWidgets/QScrollArea";
// Layouts:
export { QGridLayout } from "./lib/QtWidgets/QGridLayout";
export { FlexLayout } from "./lib/core/FlexLayout";

View File

@ -0,0 +1,15 @@
import { NodeWidget, QWidget } from "../QWidget";
export abstract class QAbstractScrollArea extends NodeWidget {
viewportWidget?: NodeWidget;
setViewport = (widget: NodeWidget) => {
this.viewportWidget = widget;
this.native.setViewport(widget.native);
};
viewport = (): QWidget => {
if (!this.viewportWidget) {
this.viewportWidget = new QWidget(this.native.viewport());
}
return this.viewportWidget;
};
}

View File

@ -1,5 +1,5 @@
import addon from "../../core/addon";
import { NodeWidget } from "../../QtGui/QWidget";
import { NodeWidget } from "../QWidget";
import { BaseWidgetEvents } from "../../core/EventWidget";
import { NativeElement } from "../../core/Component";

View File

@ -1,5 +1,5 @@
import addon from "../../core/addon";
import { NodeWidget } from "../../QtGui/QWidget";
import { NodeWidget } from "../QWidget";
import { NodeLayout } from "../QLayout";
import { NativeElement } from "../../core/Component";

View File

@ -1,5 +1,5 @@
import addon from "../../core/addon";
import { NodeWidget } from "../../QtGui/QWidget";
import { NodeWidget } from "../QWidget";
import { BaseWidgetEvents } from "../../core/EventWidget";
import { NativeElement } from "../../core/Component";
import { QPixmap } from "../../QtGui/QPixmap";

View File

@ -1,5 +1,5 @@
import { Component } from "../../core/Component";
import { NodeWidget } from "../../QtGui/QWidget";
import { NodeWidget } from "../QWidget";
// All Layouts should extend this abstract class.
export abstract class NodeLayout extends Component {

View File

@ -1,5 +1,5 @@
import addon from "../../core/addon";
import { NodeWidget } from "../../QtGui/QWidget";
import { NodeWidget } from "../QWidget";
import { BaseWidgetEvents } from "../../core/EventWidget";
import { NativeElement } from "../../core/Component";

View File

@ -1,5 +1,5 @@
import addon from "../../core/addon";
import { NodeWidget } from "../../QtGui/QWidget";
import { NodeWidget } from "../QWidget";
import { BaseWidgetEvents } from "../../core/EventWidget";
import { NativeElement } from "../../core/Component";
import { NodeLayout } from "../QLayout";

View File

@ -1,14 +1,15 @@
import addon from "../../core/addon";
import { NodeWidget } from "../../QtGui/QWidget";
import { NodeWidget } from "../QWidget";
import { BaseWidgetEvents } from "../../core/EventWidget";
import { NativeElement } from "../../core/Component";
import { QAbstractScrollArea } from "../QAbstractScrollArea";
export const QPlainTextEditEvents = Object.freeze({
...BaseWidgetEvents,
textChanged: "textChanged",
textChanged: "textChanged"
});
export class QPlainTextEdit extends NodeWidget {
export class QPlainTextEdit extends QAbstractScrollArea {
native: NativeElement;
constructor(parent?: NodeWidget) {
let native;

View File

@ -1,5 +1,5 @@
import addon from "../../core/addon";
import { NodeWidget } from "../../QtGui/QWidget";
import { NodeWidget } from "../QWidget";
import { BaseWidgetEvents } from "../../core/EventWidget";
import { NativeElement } from "../../core/Component";
import { Orientation } from "../../QtEnums";

View File

@ -1,5 +1,5 @@
import addon from "../../core/addon";
import { NodeWidget } from "../../QtGui/QWidget";
import { NodeWidget } from "../QWidget";
import { BaseWidgetEvents } from "../../core/EventWidget";
import { NativeElement } from "../../core/Component";
import { QIcon } from "../../QtGui/QIcon";

View File

@ -1,5 +1,5 @@
import addon from "../../core/addon";
import { NodeWidget } from "../../QtGui/QWidget";
import { NodeWidget } from "../QWidget";
import { BaseWidgetEvents } from "../../core/EventWidget";
import { NativeElement } from "../../core/Component";

View File

@ -0,0 +1,29 @@
import addon from "../../core/addon";
import { NodeWidget } from "../QWidget";
import { BaseWidgetEvents } from "../../core/EventWidget";
import { NativeElement } from "../../core/Component";
import { QAbstractScrollArea } from "../QAbstractScrollArea";
export const QScrollAreaEvents = Object.freeze({
...BaseWidgetEvents
});
export class QScrollArea extends QAbstractScrollArea {
native: NativeElement;
contentWidget?: NodeWidget;
constructor(parent?: NodeWidget) {
let native;
if (parent) {
native = new addon.QScrollArea(parent.native);
} else {
native = new addon.QScrollArea();
}
super(native);
this.native = native;
this.parent = parent;
// bind member functions
}
setWidget(widget: NodeWidget) {
this.contentWidget = widget;
this.native.setWidget(widget.native);
}
}

View File

@ -1,5 +1,5 @@
import addon from "../../core/addon";
import { NodeWidget } from "../../QtGui/QWidget";
import { NodeWidget } from "../QWidget";
import { BaseWidgetEvents } from "../../core/EventWidget";
import { NativeElement } from "../../core/Component";
import { QIcon } from "../../QtGui/QIcon";

View File

@ -1,5 +1,5 @@
import addon from "../../core/addon";
import { NodeLayout } from "../../QtWidgets/QLayout";
import { NodeLayout } from "../QLayout";
import { EventWidget, BaseWidgetEvents } from "../../core/EventWidget";
import { NativeElement } from "../../core/Component";
import { FlexLayout } from "../../core/FlexLayout";
@ -9,6 +9,7 @@ import {
StyleSheet,
prepareInlineStyleSheet
} from "../../core/Style/StyleSheet";
import { checkIfNativeElement } from "../../utils";
// All Widgets should extend from NodeWidget
// Implement all native QWidget methods here so that all widgets get access to those aswell
export abstract class NodeWidget extends EventWidget {
@ -105,11 +106,17 @@ export abstract class NodeWidget extends EventWidget {
};
}
type arg = NodeWidget | NativeElement;
export class QWidget extends NodeWidget {
native: NativeElement;
constructor(parent?: QWidget) {
constructor(arg?: arg) {
let native;
if (parent) {
let parent;
if (checkIfNativeElement(arg)) {
native = arg as NativeElement;
} else if (arg as NodeWidget) {
parent = arg as NodeWidget;
native = new addon.QWidget(parent.native);
} else {
native = new addon.QWidget();

View File

@ -1,5 +1,5 @@
import addon from "../addon";
import { NodeWidget } from "../../QtGui/QWidget";
import { NodeWidget } from "../../QtWidgets/QWidget";
import { NodeLayout } from "../../QtWidgets/QLayout";
import { FlexNode } from "../YogaWidget";
import { NativeElement } from "../Component";

View File

@ -1,7 +1,7 @@
import postcss from "postcss";
import cuid from "cuid";
import nodeguiAutoPrefixer from "postcss-nodegui-autoprefixer";
import { NodeWidget } from "../../QtGui/QWidget";
import { NodeWidget } from "../../QtWidgets/QWidget";
export class StyleSheet {
static create = async (cssString: string): Promise<string> => {
const { css } = await postcss([nodeguiAutoPrefixer()])