Compare commits

...

23 Commits
qt6 ... master

Author SHA1 Message Date
Simon Edwards
f41edc2ea4 Bump the version 2023-03-07 22:48:15 +01:00
Simon Edwards
30ab4442cf
Merge pull request #999 from nodegui/input_methods
Add Input Method classes and support
2023-03-07 21:50:32 +01:00
Simon Edwards
90e556be6e Code formatting 2023-03-06 20:02:23 +01:00
Simon Edwards
e9ff6a93fb Improve docs for QInputMethodQueryEvent; extract nativeObjectFromVariantType() 2023-03-06 20:01:35 +01:00
Simon Edwards
5879ad7ec4 Use better types inside QInputMethodQueryEvent binding 2023-03-05 16:49:43 +01:00
Simon Edwards
731d186b01 Add QWidget.updateMicroFocus() method 2023-03-05 16:49:37 +01:00
Simon Edwards
47d98500cf Add Input Method classes and support 2023-03-04 10:29:55 +01:00
Simon Edwards
2561fd92f9 Prepare for release 2023-02-16 18:57:43 +01:00
Simon Edwards
9129cdef0d Remove useless app wide setting 2023-02-16 18:57:43 +01:00
Simon Edwards
613ee337aa
Merge pull request #996 from NathanaelA/addTableFeatures
Added clearSelection, selectAll, scrollToBottom, scrollToTop to QTableWidget
2023-02-14 22:31:53 +01:00
Nathanael Anderson
bd6595e40a Added clearSelection, selectAll, scrollToBottom, scrollToTop to QTableWidget 2023-02-14 14:13:36 -06:00
Simon Edwards
d827e51ba4 Bump the version 2023-01-24 22:39:27 +01:00
Simon Edwards
77fd5c5a3f Fix RPATH of the binary module on macos 2023-01-24 22:38:56 +01:00
Simon Edwards
a2e5b73107 Bump version 2023-01-14 11:00:08 +01:00
Simon Edwards
4e42f61faa Add applicationDisplayNameChanged & lastWindowClosed signals to QApplication 2023-01-14 10:59:27 +01:00
Simon Edwards
3a04d14872 Bump the version 2023-01-02 19:33:47 +01:00
Simon Edwards
e18e912d11
Merge pull request #984 from nodegui/qpainter_hidpi
QPainter HiDPI + QWidget methods
2023-01-02 18:41:03 +01:00
Simon Edwards
15478751db Add more QPaintDevice methods to QWidget 2022-12-31 13:54:22 +01:00
Simon Edwards
d715a4299d Add floating point versions of QPainter methods 2022-12-31 13:53:30 +01:00
Simon Edwards
09d450aef4 Attempt 2 at fixing Ubuntu GH workflow 2022-12-28 21:59:18 +01:00
Simon Edwards
e5fd79e4c1 Add OpenGL to Ubuntu GH workflow 2022-12-28 21:55:42 +01:00
Simon Edwards
86fc6689fb Bump the version to 0.58.0-rc1 2022-12-28 21:48:43 +01:00
Simon Edwards
d6ba15df55
Merge pull request #981 from nodegui/qt6
Upgrade to Qt 6.4.1
2022-12-28 21:45:24 +01:00
29 changed files with 850 additions and 81 deletions

View File

@ -14,6 +14,9 @@ jobs:
- uses: actions/setup-node@v2 - uses: actions/setup-node@v2
with: with:
node-version: '16.x' node-version: '16.x'
- name: Install ubuntu deps
if: contains(matrix.os, 'ubuntu-20.04')
run: sudo apt install mesa-common-dev libglu1-mesa-dev libegl1 libopengl-dev
- name: Install deps - name: Install deps
run: npm install run: npm install
- name: Build nodegui - name: Build nodegui

View File

@ -31,7 +31,7 @@ jobs:
- name: Install ubuntu deps - name: Install ubuntu deps
if: contains(matrix.os, 'ubuntu-20.04') if: contains(matrix.os, 'ubuntu-20.04')
run: sudo apt install mesa-common-dev libglu1-mesa-dev libegl1 run: sudo apt install mesa-common-dev libglu1-mesa-dev libegl1 libopengl-dev
- name: Install deps - name: Install deps
run: npm install run: npm install

View File

@ -14,8 +14,8 @@ jobs:
with: with:
node-version: '16.x' node-version: '16.x'
- name: Install ubuntu deps - name: Install ubuntu deps
if: contains(matrix.os, 'ubuntu') if: contains(matrix.os, 'ubuntu-20.04')
run: sudo apt install mesa-common-dev libglu1-mesa-dev libegl1 run: sudo apt install mesa-common-dev libglu1-mesa-dev libegl1 libopengl-dev
- name: Install deps - name: Install deps
run: npm install run: npm install
- name: Build nodegui - name: Build nodegui

View File

@ -11,6 +11,7 @@ set(CORE_WIDGETS_ADDON "nodegui_core")
project(${CORE_WIDGETS_ADDON}) project(${CORE_WIDGETS_ADDON})
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
# Note: CMake+moc also use this list when finding files which `moc` applied. # Note: CMake+moc also use this list when finding files which `moc` applied.
@ -61,6 +62,8 @@ add_library(${CORE_WIDGETS_ADDON} SHARED
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QEvent/QDragMoveEvent/qdragmoveevent_wrap.cpp" "${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QEvent/QDragMoveEvent/qdragmoveevent_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QEvent/QDragLeaveEvent/qdragleaveevent_wrap.cpp" "${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QEvent/QDragLeaveEvent/qdragleaveevent_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QEvent/QResizeEvent/qresizeevent_wrap.cpp" "${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QEvent/QResizeEvent/qresizeevent_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QEvent/QInputMethodEvent/qinputmethodevent_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QEvent/QInputMethodQueryEvent/qinputmethodqueryevent_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QFontDatabase/qfontdatabase_wrap.cpp" "${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QFontDatabase/qfontdatabase_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QFontMetrics/qfontmetrics_wrap.cpp" "${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QFontMetrics/qfontmetrics_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QFontMetricsF/qfontmetricsf_wrap.cpp" "${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QFontMetricsF/qfontmetricsf_wrap.cpp"
@ -265,6 +268,7 @@ if (UNIX AND NOT APPLE)
endif() endif()
if (APPLE) if (APPLE)
set(CMAKE_MACOSX_RPATH ON)
file(RELATIVE_PATH QT_LIBRARY_REL_PATH "${CMAKE_BINARY_DIR}/Release" "${QT_CMAKE_HOME_DIR}/../..") file(RELATIVE_PATH QT_LIBRARY_REL_PATH "${CMAKE_BINARY_DIR}/Release" "${QT_CMAKE_HOME_DIR}/../..")
set_target_properties(${CORE_WIDGETS_ADDON} PROPERTIES INSTALL_RPATH "@loader_path/${QT_LIBRARY_REL_PATH}") set_target_properties(${CORE_WIDGETS_ADDON} PROPERTIES INSTALL_RPATH "@loader_path/${QT_LIBRARY_REL_PATH}")
endif() endif()

18
package-lock.json generated
View File

@ -1,17 +1,17 @@
{ {
"name": "@nodegui/nodegui", "name": "@nodegui/nodegui",
"version": "0.57.3", "version": "0.59.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@nodegui/nodegui", "name": "@nodegui/nodegui",
"version": "0.57.3", "version": "0.59.0",
"hasInstallScript": true, "hasInstallScript": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@nodegui/artifact-installer": "^1.1.0", "@nodegui/artifact-installer": "^1.1.0",
"@nodegui/qode": "^16.4.3", "@nodegui/qode": "^18.12.1",
"cmake-js": "^6.2.1", "cmake-js": "^6.2.1",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"cuid": "^2.1.8", "cuid": "^2.1.8",
@ -1134,9 +1134,9 @@
} }
}, },
"node_modules/@nodegui/qode": { "node_modules/@nodegui/qode": {
"version": "16.4.3", "version": "18.12.1",
"resolved": "https://registry.npmjs.org/@nodegui/qode/-/qode-16.4.3.tgz", "resolved": "https://registry.npmjs.org/@nodegui/qode/-/qode-18.12.1.tgz",
"integrity": "sha512-WllfJVXffr3Rn7BSfo5cubZ5hx4OnQ7iqY/kj+2jwqUepzlRFKCvn9/vAJ/VXmiB0GZGcaCGM0U3rZGADdU5mw==", "integrity": "sha512-iJdNwMPif+NkbZeXQPek6IfKmmHt04Iy1dlRGVFaICU5nSpNDsSmzGxHrVdllQWGGzqvre82BOV3CgMxclGZtQ==",
"hasInstallScript": true, "hasInstallScript": true,
"dependencies": { "dependencies": {
"env-paths": "^2.2.1", "env-paths": "^2.2.1",
@ -6833,9 +6833,9 @@
} }
}, },
"@nodegui/qode": { "@nodegui/qode": {
"version": "16.4.3", "version": "18.12.1",
"resolved": "https://registry.npmjs.org/@nodegui/qode/-/qode-16.4.3.tgz", "resolved": "https://registry.npmjs.org/@nodegui/qode/-/qode-18.12.1.tgz",
"integrity": "sha512-WllfJVXffr3Rn7BSfo5cubZ5hx4OnQ7iqY/kj+2jwqUepzlRFKCvn9/vAJ/VXmiB0GZGcaCGM0U3rZGADdU5mw==", "integrity": "sha512-iJdNwMPif+NkbZeXQPek6IfKmmHt04Iy1dlRGVFaICU5nSpNDsSmzGxHrVdllQWGGzqvre82BOV3CgMxclGZtQ==",
"requires": { "requires": {
"env-paths": "^2.2.1", "env-paths": "^2.2.1",
"make-dir": "^3.1.0", "make-dir": "^3.1.0",

View File

@ -1,6 +1,6 @@
{ {
"name": "@nodegui/nodegui", "name": "@nodegui/nodegui",
"version": "0.57.3", "version": "0.59.0",
"description": "A cross-platform library to build native desktop apps.", "description": "A cross-platform library to build native desktop apps.",
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",
@ -15,6 +15,7 @@
}, },
"scripts": { "scripts": {
"dev": "npm run build && node ./scripts/qode.js dist/demo.js", "dev": "npm run build && node ./scripts/qode.js dist/demo.js",
"demo": "node ./scripts/qode.js dist/demo.js",
"build": "tsc && npm run build:addon", "build": "tsc && npm run build:addon",
"install": "npm run setupqt && (node ./scripts/skip.js || npm run setupbinary || npm run build:addon)", "install": "npm run setupqt && (node ./scripts/skip.js || npm run setupbinary || npm run build:addon)",
"setupqt": "node ./scripts/setupMiniQt.js", "setupqt": "node ./scripts/setupMiniQt.js",
@ -33,7 +34,7 @@
"engineStrict": false, "engineStrict": false,
"dependencies": { "dependencies": {
"@nodegui/artifact-installer": "^1.1.0", "@nodegui/artifact-installer": "^1.1.0",
"@nodegui/qode": "^16.4.3", "@nodegui/qode": "^18.12.1",
"cmake-js": "^6.2.1", "cmake-js": "^6.2.1",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"cuid": "^2.1.8", "cuid": "^2.1.8",

View File

@ -18,6 +18,14 @@ class DLL_EXPORT NApplication : public QApplication, public EventWidget {
// Qt Connects: Implement all signal connects here // Qt Connects: Implement all signal connects here
QOBJECT_SIGNALS QOBJECT_SIGNALS
QObject::connect(
this, &QGuiApplication::applicationDisplayNameChanged, [=]() {
Napi::Env env = this->emitOnNode.Env();
Napi::HandleScope scope(env);
this->emitOnNode.Call(
{Napi::String::New(env, "applicationDisplayNameChanged")});
});
QObject::connect( QObject::connect(
this, &QGuiApplication::focusWindowChanged, [=](QWindow* focusWindow) { this, &QGuiApplication::focusWindowChanged, [=](QWindow* focusWindow) {
Napi::Env env = this->emitOnNode.Env(); Napi::Env env = this->emitOnNode.Env();
@ -25,6 +33,12 @@ class DLL_EXPORT NApplication : public QApplication, public EventWidget {
this->emitOnNode.Call({Napi::String::New(env, "focusWindowChanged")}); this->emitOnNode.Call({Napi::String::New(env, "focusWindowChanged")});
}); });
QObject::connect(this, &QGuiApplication::lastWindowClosed, [=]() {
Napi::Env env = this->emitOnNode.Env();
Napi::HandleScope scope(env);
this->emitOnNode.Call({Napi::String::New(env, "lastWindowClosed")});
});
QObject::connect( QObject::connect(
this, &QGuiApplication::primaryScreenChanged, [=](QScreen* screen) { this, &QGuiApplication::primaryScreenChanged, [=](QScreen* screen) {
Napi::Env env = this->emitOnNode.Env(); Napi::Env env = this->emitOnNode.Env();

View File

@ -0,0 +1,32 @@
#pragma once
#include <napi.h>
#include <QInputMethodEvent>
#include "Extras/Export/export.h"
#include "QtGui/QEvent/QEvent/qevent_macro.h"
#include "core/Component/component_macro.h"
class DLL_EXPORT QInputMethodEventWrap
: public Napi::ObjectWrap<QInputMethodEventWrap> {
COMPONENT_WRAPPED_METHODS_DECLARATION
QEVENT_WRAPPED_METHODS_DECLARATION
private:
QInputMethodEvent* instance;
public:
static Napi::Object init(Napi::Env env, Napi::Object exports);
QInputMethodEventWrap(const Napi::CallbackInfo& info);
~QInputMethodEventWrap();
QInputMethodEvent* getInternalInstance();
// class constructor
static Napi::FunctionReference constructor;
// wrapped methods
Napi::Value commitString(const Napi::CallbackInfo& info);
Napi::Value preeditString(const Napi::CallbackInfo& info);
Napi::Value replacementLength(const Napi::CallbackInfo& info);
Napi::Value replacementStart(const Napi::CallbackInfo& info);
Napi::Value setCommitString(const Napi::CallbackInfo& info);
};

View File

@ -0,0 +1,30 @@
#pragma once
#include <napi.h>
#include <QInputMethodQueryEvent>
#include "Extras/Export/export.h"
#include "QtGui/QEvent/QEvent/qevent_macro.h"
#include "core/Component/component_macro.h"
class DLL_EXPORT QInputMethodQueryEventWrap
: public Napi::ObjectWrap<QInputMethodQueryEventWrap> {
COMPONENT_WRAPPED_METHODS_DECLARATION
QEVENT_WRAPPED_METHODS_DECLARATION
private:
QInputMethodQueryEvent* instance;
public:
static Napi::Object init(Napi::Env env, Napi::Object exports);
QInputMethodQueryEventWrap(const Napi::CallbackInfo& info);
~QInputMethodQueryEventWrap();
QInputMethodQueryEvent* getInternalInstance();
// class constructor
static Napi::FunctionReference constructor;
// wrapped methods
Napi::Value queries(const Napi::CallbackInfo& info);
Napi::Value setValue(const Napi::CallbackInfo& info);
Napi::Value value(const Napi::CallbackInfo& info);
};

View File

@ -20,38 +20,52 @@ class DLL_EXPORT QPainterWrap : public Napi::ObjectWrap<QPainterWrap> {
// class constructor // class constructor
static Napi::FunctionReference constructor; static Napi::FunctionReference constructor;
// wrapped methods // wrapped methods
Napi::Value drawArc(const Napi::CallbackInfo& info);
Napi::Value drawText(const Napi::CallbackInfo& info);
Napi::Value drawImage(const Napi::CallbackInfo& info);
Napi::Value drawPath(const Napi::CallbackInfo& info);
Napi::Value strokePath(const Napi::CallbackInfo& info);
Napi::Value begin(const Napi::CallbackInfo& info); Napi::Value begin(const Napi::CallbackInfo& info);
Napi::Value beginNativePainting(const Napi::CallbackInfo& info); Napi::Value beginNativePainting(const Napi::CallbackInfo& info);
Napi::Value boundingRect(const Napi::CallbackInfo& info);
Napi::Value boundingRectF(const Napi::CallbackInfo& info);
Napi::Value compositionMode(const Napi::CallbackInfo& info);
Napi::Value drawArc(const Napi::CallbackInfo& info);
Napi::Value drawArcF(const Napi::CallbackInfo& info);
Napi::Value drawChord(const Napi::CallbackInfo& info);
Napi::Value drawChordF(const Napi::CallbackInfo& info);
Napi::Value drawConvexPolygon(const Napi::CallbackInfo& info);
Napi::Value drawConvexPolygonF(const Napi::CallbackInfo& info);
Napi::Value drawEllipse(const Napi::CallbackInfo& info);
Napi::Value drawEllipseF(const Napi::CallbackInfo& info);
Napi::Value drawImage(const Napi::CallbackInfo& info);
Napi::Value drawImageF(const Napi::CallbackInfo& info);
Napi::Value drawLine(const Napi::CallbackInfo& info);
Napi::Value drawLineF(const Napi::CallbackInfo& info);
Napi::Value drawPath(const Napi::CallbackInfo& info);
Napi::Value drawPie(const Napi::CallbackInfo& info);
Napi::Value drawPieF(const Napi::CallbackInfo& info);
Napi::Value drawPoint(const Napi::CallbackInfo& info);
Napi::Value drawPointF(const Napi::CallbackInfo& info);
Napi::Value drawRect(const Napi::CallbackInfo& info);
Napi::Value drawRectF(const Napi::CallbackInfo& info);
Napi::Value drawText(const Napi::CallbackInfo& info);
Napi::Value drawTextF(const Napi::CallbackInfo& info);
Napi::Value end(const Napi::CallbackInfo& info); Napi::Value end(const Napi::CallbackInfo& info);
Napi::Value endNativePainting(const Napi::CallbackInfo& info); Napi::Value endNativePainting(const Napi::CallbackInfo& info);
Napi::Value eraseRect(const Napi::CallbackInfo& info);
Napi::Value eraseRectF(const Napi::CallbackInfo& info);
Napi::Value fillRect(const Napi::CallbackInfo& info);
Napi::Value fillRectF(const Napi::CallbackInfo& info);
Napi::Value opacity(const Napi::CallbackInfo& info);
Napi::Value restore(const Napi::CallbackInfo& info);
Napi::Value rotate(const Napi::CallbackInfo& info); Napi::Value rotate(const Napi::CallbackInfo& info);
Napi::Value save(const Napi::CallbackInfo& info);
Napi::Value scale(const Napi::CallbackInfo& info);
Napi::Value setBrush(const Napi::CallbackInfo& info);
Napi::Value setBrushOrigin(const Napi::CallbackInfo& info);
Napi::Value setBrushOriginF(const Napi::CallbackInfo& info);
Napi::Value setCompositionMode(const Napi::CallbackInfo& info);
Napi::Value setFont(const Napi::CallbackInfo& info); Napi::Value setFont(const Napi::CallbackInfo& info);
Napi::Value setOpacity(const Napi::CallbackInfo& info);
Napi::Value setPen(const Napi::CallbackInfo& info); Napi::Value setPen(const Napi::CallbackInfo& info);
Napi::Value setRenderHint(const Napi::CallbackInfo& info); Napi::Value setRenderHint(const Napi::CallbackInfo& info);
Napi::Value setTransform(const Napi::CallbackInfo& info); Napi::Value setTransform(const Napi::CallbackInfo& info);
Napi::Value setBrush(const Napi::CallbackInfo& info); Napi::Value strokePath(const Napi::CallbackInfo& info);
Napi::Value drawLine(const Napi::CallbackInfo& info);
Napi::Value drawEllipse(const Napi::CallbackInfo& info);
Napi::Value drawPie(const Napi::CallbackInfo& info);
Napi::Value scale(const Napi::CallbackInfo& info);
Napi::Value translate(const Napi::CallbackInfo& info); Napi::Value translate(const Napi::CallbackInfo& info);
Napi::Value drawConvexPolygon(const Napi::CallbackInfo& info);
Napi::Value save(const Napi::CallbackInfo& info);
Napi::Value restore(const Napi::CallbackInfo& info);
Napi::Value fillRect(const Napi::CallbackInfo& info);
Napi::Value compositionMode(const Napi::CallbackInfo& info);
Napi::Value setCompositionMode(const Napi::CallbackInfo& info);
Napi::Value opacity(const Napi::CallbackInfo& info);
Napi::Value setOpacity(const Napi::CallbackInfo& info);
Napi::Value drawPoint(const Napi::CallbackInfo& info);
Napi::Value drawRect(const Napi::CallbackInfo& info);
Napi::Value eraseRect(const Napi::CallbackInfo& info);
Napi::Value boundingRect(const Napi::CallbackInfo& info);
Napi::Value drawChord(const Napi::CallbackInfo& info);
Napi::Value setBrushOrigin(const Napi::CallbackInfo& info);
}; };

View File

@ -80,4 +80,8 @@ class DLL_EXPORT QTableWidgetWrap : public Napi::ObjectWrap<QTableWidgetWrap> {
Napi::Value setRowCount(const Napi::CallbackInfo& info); Napi::Value setRowCount(const Napi::CallbackInfo& info);
Napi::Value setSortingEnabled(const Napi::CallbackInfo& info); Napi::Value setSortingEnabled(const Napi::CallbackInfo& info);
Napi::Value isSortingEnabled(const Napi::CallbackInfo& info); Napi::Value isSortingEnabled(const Napi::CallbackInfo& info);
Napi::Value clearSelection(const Napi::CallbackInfo& info);
Napi::Value selectAll(const Napi::CallbackInfo& info);
Napi::Value scrollToBottom(const Napi::CallbackInfo& info);
Napi::Value scrollToTop(const Napi::CallbackInfo& info);
}; };

View File

@ -23,4 +23,8 @@ class DLL_EXPORT NWidget : public QWidget, public NodeWidget {
} }
virtual void connectSignalsToEventEmitter() { QWIDGET_SIGNALS } virtual void connectSignalsToEventEmitter() { QWIDGET_SIGNALS }
void _protected_updateMicroFocus(Qt::InputMethodQuery query) {
updateMicroFocus(query);
}
}; };

View File

@ -710,6 +710,71 @@
QWidget* w = wWidgetWrap->getInternalInstance(); \ QWidget* w = wWidgetWrap->getInternalInstance(); \
this->instance->stackUnder(w); \ this->instance->stackUnder(w); \
return env.Null(); \ return env.Null(); \
} \
Napi::Value colorCount(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
int result = this->instance->colorCount(); \
return Napi::Number::New(env, result); \
} \
Napi::Value depth(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
int result = this->instance->depth(); \
return Napi::Number::New(env, result); \
} \
Napi::Value devicePixelRatio(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
qreal result = this->instance->devicePixelRatio(); \
return Napi::Number::New(env, result); \
} \
Napi::Value devicePixelRatioF(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
qreal result = this->instance->devicePixelRatioF(); \
return Napi::Number::New(env, result); \
} \
Napi::Value heightMM(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
int result = this->instance->heightMM(); \
return Napi::Number::New(env, result); \
} \
Napi::Value logicalDpiX(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
int result = this->instance->logicalDpiX(); \
return Napi::Number::New(env, result); \
} \
Napi::Value logicalDpiY(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
int result = this->instance->logicalDpiY(); \
return Napi::Number::New(env, result); \
} \
Napi::Value paintingActive(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
bool result = this->instance->paintingActive(); \
return Napi::Boolean::New(env, result); \
} \
Napi::Value physicalDpiX(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
int result = this->instance->physicalDpiX(); \
return Napi::Number::New(env, result); \
} \
Napi::Value physicalDpiY(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
int result = this->instance->physicalDpiY(); \
return Napi::Number::New(env, result); \
} \
Napi::Value widthMM(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
int result = this->instance->widthMM(); \
return Napi::Number::New(env, result); \
} \
Napi::Value updateMicroFocus(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \
NWidget* nwidget = dynamic_cast<NWidget*>(this->instance.data()); \
if (nwidget) { \
Qt::InputMethodQuery query = static_cast<Qt::InputMethodQuery>( \
info[0].As<Napi::Number>().Int32Value()); \
nwidget->_protected_updateMicroFocus(query); \
} \
return env.Null(); \
} }
#endif // QWIDGET_WRAPPED_METHODS_DECLARATION #endif // QWIDGET_WRAPPED_METHODS_DECLARATION
@ -818,7 +883,19 @@
InstanceMethod("isAncestorOf", &WidgetWrapName::isAncestorOf), \ InstanceMethod("isAncestorOf", &WidgetWrapName::isAncestorOf), \
InstanceMethod("isEnabledTo", &WidgetWrapName::isEnabledTo), \ InstanceMethod("isEnabledTo", &WidgetWrapName::isEnabledTo), \
InstanceMethod("isVisibleTo", &WidgetWrapName::isVisibleTo), \ InstanceMethod("isVisibleTo", &WidgetWrapName::isVisibleTo), \
InstanceMethod("stackUnder", &WidgetWrapName::stackUnder), InstanceMethod("stackUnder", &WidgetWrapName::stackUnder), \
InstanceMethod("colorCount", &WidgetWrapName::colorCount), \
InstanceMethod("depth", &WidgetWrapName::depth), \
InstanceMethod("devicePixelRatio", &WidgetWrapName::devicePixelRatio), \
InstanceMethod("devicePixelRatioF", &WidgetWrapName::devicePixelRatioF), \
InstanceMethod("heightMM", &WidgetWrapName::heightMM), \
InstanceMethod("logicalDpiX", &WidgetWrapName::logicalDpiX), \
InstanceMethod("logicalDpiY", &WidgetWrapName::logicalDpiY), \
InstanceMethod("paintingActive", &WidgetWrapName::paintingActive), \
InstanceMethod("physicalDpiX", &WidgetWrapName::physicalDpiX), \
InstanceMethod("physicalDpiY", &WidgetWrapName::physicalDpiY), \
InstanceMethod("widthMM", &WidgetWrapName::widthMM), \
InstanceMethod("updateMicroFocus", &WidgetWrapName::updateMicroFocus),
#endif // QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE #endif // QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE

View File

@ -0,0 +1,90 @@
#include "QtGui/QEvent/QInputMethodEvent/qinputmethodevent_wrap.h"
#include <QString>
#include "Extras/Utils/nutils.h"
Napi::FunctionReference QInputMethodEventWrap::constructor;
Napi::Object QInputMethodEventWrap::init(Napi::Env env, Napi::Object exports) {
Napi::HandleScope scope(env);
char CLASSNAME[] = "QInputMethodEvent";
Napi::Function func = DefineClass(
env, CLASSNAME,
{InstanceMethod("commitString", &QInputMethodEventWrap::commitString),
InstanceMethod("preeditString", &QInputMethodEventWrap::preeditString),
InstanceMethod("replacementLength",
&QInputMethodEventWrap::replacementLength),
InstanceMethod("replacementStart",
&QInputMethodEventWrap::replacementStart),
InstanceMethod("setCommitString",
&QInputMethodEventWrap::setCommitString),
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QInputMethodEventWrap)
QEVENT_WRAPPED_METHODS_EXPORT_DEFINE(QInputMethodEventWrap)});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
return exports;
}
QInputMethodEvent* QInputMethodEventWrap::getInternalInstance() {
return this->instance;
}
QInputMethodEventWrap::QInputMethodEventWrap(const Napi::CallbackInfo& info)
: Napi::ObjectWrap<QInputMethodEventWrap>(info) {
Napi::Env env = info.Env();
if (info.Length() == 1) {
Napi::External<QInputMethodEvent> eventObject =
info[0].As<Napi::External<QInputMethodEvent>>();
this->instance = static_cast<QInputMethodEvent*>(eventObject.Data());
} else {
Napi::TypeError::New(env, "Wrong number of arguments")
.ThrowAsJavaScriptException();
}
this->rawData = extrautils::configureComponent(this->getInternalInstance());
}
QInputMethodEventWrap::~QInputMethodEventWrap() {
// Do not destroy instance here. It will be done by Qt Event loop.
}
Napi::Value QInputMethodEventWrap::setCommitString(
const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::String setCommitString = info[0].As<Napi::String>();
int replaceFrom = info[1].As<Napi::Number>().Int32Value();
int replaceLength = info[2].As<Napi::Number>().Int32Value();
this->instance->setCommitString(
QString::fromStdString(setCommitString.Utf8Value()), replaceFrom,
replaceLength);
return env.Null();
}
Napi::Value QInputMethodEventWrap::commitString(
const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
QString commitString = this->instance->commitString();
return Napi::Value::From(env, commitString.toStdString());
}
Napi::Value QInputMethodEventWrap::preeditString(
const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
QString preeditString = this->instance->preeditString();
return Napi::Value::From(env, preeditString.toStdString());
}
Napi::Value QInputMethodEventWrap::replacementLength(
const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
int x = this->instance->replacementLength();
return Napi::Number::From(env, x);
}
Napi::Value QInputMethodEventWrap::replacementStart(
const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
int x = this->instance->replacementStart();
return Napi::Number::From(env, x);
}

View File

@ -0,0 +1,79 @@
#include "QtGui/QEvent/QInputMethodQueryEvent/qinputmethodqueryevent_wrap.h"
#include <QString>
#include "Extras/Utils/nutils.h"
#include "QtCore/QVariant/qvariant_wrap.h"
Napi::FunctionReference QInputMethodQueryEventWrap::constructor;
Napi::Object QInputMethodQueryEventWrap::init(Napi::Env env,
Napi::Object exports) {
Napi::HandleScope scope(env);
char CLASSNAME[] = "QInputMethodQueryEvent";
Napi::Function func = DefineClass(
env, CLASSNAME,
{InstanceMethod("queries", &QInputMethodQueryEventWrap::queries),
InstanceMethod("setValue", &QInputMethodQueryEventWrap::setValue),
InstanceMethod("value", &QInputMethodQueryEventWrap::value),
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QInputMethodQueryEventWrap)
QEVENT_WRAPPED_METHODS_EXPORT_DEFINE(QInputMethodQueryEventWrap)});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
return exports;
}
QInputMethodQueryEvent* QInputMethodQueryEventWrap::getInternalInstance() {
return this->instance;
}
QInputMethodQueryEventWrap::QInputMethodQueryEventWrap(
const Napi::CallbackInfo& info)
: Napi::ObjectWrap<QInputMethodQueryEventWrap>(info) {
Napi::Env env = info.Env();
if (info.Length() == 1) {
Napi::External<QInputMethodQueryEvent> eventObject =
info[0].As<Napi::External<QInputMethodQueryEvent>>();
this->instance = static_cast<QInputMethodQueryEvent*>(eventObject.Data());
} else {
Napi::TypeError::New(env, "Wrong number of arguments")
.ThrowAsJavaScriptException();
}
this->rawData = extrautils::configureComponent(this->getInternalInstance());
}
QInputMethodQueryEventWrap::~QInputMethodQueryEventWrap() {
// Do not destroy instance here. It will be done by Qt Event loop.
}
Napi::Value QInputMethodQueryEventWrap::queries(
const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Qt::InputMethodQueries queries = this->instance->queries();
return Napi::Number::From(env, queries.toInt());
}
Napi::Value QInputMethodQueryEventWrap::setValue(
const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Qt::InputMethodQuery query = static_cast<Qt::InputMethodQuery>(
info[0].As<Napi::Number>().Int32Value());
Napi::Value value = info[1];
QVariant* valueVariant = extrautils::convertToQVariant(env, value);
this->instance->setValue(query, *valueVariant);
delete valueVariant;
return env.Null();
}
Napi::Value QInputMethodQueryEventWrap::value(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Qt::InputMethodQuery query = static_cast<Qt::InputMethodQuery>(
info[0].As<Napi::Number>().Int32Value());
QVariant value = this->instance->value(query);
auto instance = QVariantWrap::constructor.New(
{Napi::External<QVariant>::New(env, new QVariant(value))});
return instance;
}

View File

@ -453,7 +453,7 @@ void QImageWrap::setColorCount(const Napi::CallbackInfo& info) {
void QImageWrap::setDevicePixelRatio(const Napi::CallbackInfo& info) { void QImageWrap::setDevicePixelRatio(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
int64_t scaleFactor = info[0].As<Napi::Number>(); qreal scaleFactor = info[0].As<Napi::Number>();
this->instance->setDevicePixelRatio(scaleFactor); this->instance->setDevicePixelRatio(scaleFactor);
} }

View File

@ -2,7 +2,9 @@
#include "Extras/Utils/nutils.h" #include "Extras/Utils/nutils.h"
#include "QtCore/QPoint/qpoint_wrap.h" #include "QtCore/QPoint/qpoint_wrap.h"
#include "QtCore/QPointF/qpointf_wrap.h"
#include "QtCore/QRect/qrect_wrap.h" #include "QtCore/QRect/qrect_wrap.h"
#include "QtCore/QRectF/qrectf_wrap.h"
#include "QtGui/QBrush/qbrush_wrap.h" #include "QtGui/QBrush/qbrush_wrap.h"
#include "QtGui/QColor/qcolor_wrap.h" #include "QtGui/QColor/qcolor_wrap.h"
#include "QtGui/QFont/qfont_wrap.h" #include "QtGui/QFont/qfont_wrap.h"
@ -19,42 +21,55 @@ Napi::Object QPainterWrap::init(Napi::Env env, Napi::Object exports) {
char CLASSNAME[] = "QPainter"; char CLASSNAME[] = "QPainter";
Napi::Function func = DefineClass( Napi::Function func = DefineClass(
env, CLASSNAME, env, CLASSNAME,
{InstanceMethod("drawArc", &QPainterWrap::drawArc), {InstanceMethod("begin", &QPainterWrap::begin),
InstanceMethod("drawText", &QPainterWrap::drawText),
InstanceMethod("drawPath", &QPainterWrap::drawPath),
InstanceMethod("drawPie", &QPainterWrap::drawPie),
InstanceMethod("drawEllipse", &QPainterWrap::drawEllipse),
InstanceMethod("drawImage", &QPainterWrap::drawImage),
InstanceMethod("strokePath", &QPainterWrap::strokePath),
InstanceMethod("begin", &QPainterWrap::begin),
InstanceMethod("end", &QPainterWrap::end),
InstanceMethod("rotate", &QPainterWrap::rotate),
InstanceMethod("setFont", &QPainterWrap::setFont),
InstanceMethod("setPen", &QPainterWrap::setPen),
InstanceMethod("setBrush", &QPainterWrap::setBrush),
InstanceMethod("setTransform", &QPainterWrap::setTransform),
InstanceMethod("drawLine", &QPainterWrap::drawLine),
InstanceMethod("scale", &QPainterWrap::scale),
InstanceMethod("translate", &QPainterWrap::translate),
InstanceMethod("setRenderHint", &QPainterWrap::setRenderHint),
InstanceMethod("drawConvexPolygon", &QPainterWrap::drawConvexPolygon),
InstanceMethod("save", &QPainterWrap::save),
InstanceMethod("restore", &QPainterWrap::restore),
InstanceMethod("beginNativePainting", InstanceMethod("beginNativePainting",
&QPainterWrap::beginNativePainting), &QPainterWrap::beginNativePainting),
InstanceMethod("endNativePainting", &QPainterWrap::endNativePainting),
InstanceMethod("fillRect", &QPainterWrap::fillRect),
InstanceMethod("compositionMode", &QPainterWrap::compositionMode),
InstanceMethod("setCompositionMode", &QPainterWrap::setCompositionMode),
InstanceMethod("opacity", &QPainterWrap::opacity),
InstanceMethod("setOpacity", &QPainterWrap::setOpacity),
InstanceMethod("drawPoint", &QPainterWrap::drawPoint),
InstanceMethod("drawRect", &QPainterWrap::drawRect),
InstanceMethod("eraseRect", &QPainterWrap::eraseRect),
InstanceMethod("boundingRect", &QPainterWrap::boundingRect), InstanceMethod("boundingRect", &QPainterWrap::boundingRect),
InstanceMethod("boundingRectF", &QPainterWrap::boundingRectF),
InstanceMethod("compositionMode", &QPainterWrap::compositionMode),
InstanceMethod("drawArc", &QPainterWrap::drawArc),
InstanceMethod("drawArcF", &QPainterWrap::drawArcF),
InstanceMethod("drawChord", &QPainterWrap::drawChord), InstanceMethod("drawChord", &QPainterWrap::drawChord),
InstanceMethod("drawChordF", &QPainterWrap::drawChord),
InstanceMethod("drawConvexPolygon", &QPainterWrap::drawConvexPolygon),
InstanceMethod("drawConvexPolygonF", &QPainterWrap::drawConvexPolygonF),
InstanceMethod("drawEllipse", &QPainterWrap::drawEllipse),
InstanceMethod("drawEllipseF", &QPainterWrap::drawEllipseF),
InstanceMethod("drawImage", &QPainterWrap::drawImage),
InstanceMethod("drawImageF", &QPainterWrap::drawImageF),
InstanceMethod("drawLine", &QPainterWrap::drawLine),
InstanceMethod("drawLineF", &QPainterWrap::drawLineF),
InstanceMethod("drawPath", &QPainterWrap::drawPath),
InstanceMethod("drawPie", &QPainterWrap::drawPie), InstanceMethod("drawPie", &QPainterWrap::drawPie),
InstanceMethod("drawPieF", &QPainterWrap::drawPieF),
InstanceMethod("drawPoint", &QPainterWrap::drawPoint),
InstanceMethod("drawPointF", &QPainterWrap::drawPointF),
InstanceMethod("drawRect", &QPainterWrap::drawRect),
InstanceMethod("drawRectF", &QPainterWrap::drawRectF),
InstanceMethod("drawText", &QPainterWrap::drawText),
InstanceMethod("drawTextF", &QPainterWrap::drawTextF),
InstanceMethod("end", &QPainterWrap::end),
InstanceMethod("endNativePainting", &QPainterWrap::endNativePainting),
InstanceMethod("eraseRect", &QPainterWrap::eraseRect),
InstanceMethod("eraseRectF", &QPainterWrap::eraseRectF),
InstanceMethod("fillRect", &QPainterWrap::fillRect),
InstanceMethod("fillRectF", &QPainterWrap::fillRectF),
InstanceMethod("opacity", &QPainterWrap::opacity),
InstanceMethod("restore", &QPainterWrap::restore),
InstanceMethod("rotate", &QPainterWrap::rotate),
InstanceMethod("save", &QPainterWrap::save),
InstanceMethod("scale", &QPainterWrap::scale),
InstanceMethod("setBrush", &QPainterWrap::setBrush),
InstanceMethod("setBrushOrigin", &QPainterWrap::setBrushOrigin), InstanceMethod("setBrushOrigin", &QPainterWrap::setBrushOrigin),
InstanceMethod("setBrushOriginF", &QPainterWrap::setBrushOriginF),
InstanceMethod("setCompositionMode", &QPainterWrap::setCompositionMode),
InstanceMethod("setFont", &QPainterWrap::setFont),
InstanceMethod("setOpacity", &QPainterWrap::setOpacity),
InstanceMethod("setPen", &QPainterWrap::setPen),
InstanceMethod("setRenderHint", &QPainterWrap::setRenderHint),
InstanceMethod("setTransform", &QPainterWrap::setTransform),
InstanceMethod("strokePath", &QPainterWrap::strokePath),
InstanceMethod("translate", &QPainterWrap::translate),
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QPainterWrap)}); COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QPainterWrap)});
constructor = Napi::Persistent(func); constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func); exports.Set(CLASSNAME, func);
@ -91,6 +106,17 @@ Napi::Value QPainterWrap::drawArc(const Napi::CallbackInfo& info) {
this->instance->drawArc(x, y, width, height, startAngle, spanAngle); this->instance->drawArc(x, y, width, height, startAngle, spanAngle);
return env.Null(); return env.Null();
} }
Napi::Value QPainterWrap::drawArcF(const Napi::CallbackInfo& info) {
Napi::Env env = info.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();
int startAngle = info[4].As<Napi::Number>().Int32Value();
int spanAngle = info[5].As<Napi::Number>().Int32Value();
this->instance->drawArc(QRectF(x, y, width, height), startAngle, spanAngle);
return env.Null();
}
Napi::Value QPainterWrap::drawText(const Napi::CallbackInfo& info) { Napi::Value QPainterWrap::drawText(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
int x = info[0].As<Napi::Number>().Int32Value(); int x = info[0].As<Napi::Number>().Int32Value();
@ -100,6 +126,15 @@ Napi::Value QPainterWrap::drawText(const Napi::CallbackInfo& info) {
this->instance->drawText(x, y, QString::fromUtf8(text.c_str())); this->instance->drawText(x, y, QString::fromUtf8(text.c_str()));
return env.Null(); return env.Null();
} }
Napi::Value QPainterWrap::drawTextF(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
qreal x = info[0].As<Napi::Number>().DoubleValue();
qreal y = info[1].As<Napi::Number>().DoubleValue();
Napi::String napiText = info[2].As<Napi::String>();
std::string text = napiText.Utf8Value();
this->instance->drawText(QPointF(x, y), QString::fromUtf8(text.c_str()));
return env.Null();
}
Napi::Value QPainterWrap::drawPath(const Napi::CallbackInfo& info) { Napi::Value QPainterWrap::drawPath(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
Napi::Object pathObject = info[0].As<Napi::Object>(); Napi::Object pathObject = info[0].As<Napi::Object>();
@ -189,11 +224,27 @@ Napi::Value QPainterWrap::drawEllipse(const Napi::CallbackInfo& info) {
.ThrowAsJavaScriptException(); .ThrowAsJavaScriptException();
return env.Null(); return env.Null();
} }
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->drawEllipse(x, y, width, height);
return env.Null();
}
Napi::Value QPainterWrap::drawEllipseF(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
if (info.Length() < 4) {
Napi::TypeError::New(env, "Invalid number of arguments to drawEllipseF")
.ThrowAsJavaScriptException();
return env.Null();
}
qreal x = info[0].As<Napi::Number>().DoubleValue(); qreal x = info[0].As<Napi::Number>().DoubleValue();
qreal y = info[1].As<Napi::Number>().DoubleValue(); qreal y = info[1].As<Napi::Number>().DoubleValue();
qreal width = info[2].As<Napi::Number>().DoubleValue(); qreal width = info[2].As<Napi::Number>().DoubleValue();
qreal height = info[3].As<Napi::Number>().DoubleValue(); qreal height = info[3].As<Napi::Number>().DoubleValue();
this->instance->drawEllipse(x, y, width, height); this->instance->drawEllipse(QRectF(x, y, width, height));
return env.Null(); return env.Null();
} }
@ -217,7 +268,44 @@ Napi::Value QPainterWrap::drawImage(const Napi::CallbackInfo& info) {
return env.Null(); return env.Null();
} }
Napi::Value QPainterWrap::drawImageF(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
qreal x = info[0].As<Napi::Number>().DoubleValue();
qreal y = info[1].As<Napi::Number>().DoubleValue();
Napi::Object imageObject = info[2].As<Napi::Object>();
QImageWrap* imageWrap = Napi::ObjectWrap<QImageWrap>::Unwrap(imageObject);
QImage* image = imageWrap->getInternalInstance();
qreal sx = info[3].As<Napi::Number>().DoubleValue();
qreal sy = info[4].As<Napi::Number>().DoubleValue();
qreal sw = info[5].As<Napi::Number>().DoubleValue();
qreal sh = info[6].As<Napi::Number>().DoubleValue();
this->instance->drawImage(QPointF(x, y), *image, QRectF(sx, sy, sw, sh));
return env.Null();
}
Napi::Value QPainterWrap::drawPie(const Napi::CallbackInfo& info) { Napi::Value QPainterWrap::drawPie(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
if (info.Length() < 6) {
Napi::TypeError::New(env, "Invalid number of arguments to drawPie")
.ThrowAsJavaScriptException();
return env.Null();
}
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();
int startAngle = info[4].As<Napi::Number>().Int32Value();
int sweepLength = info[5].As<Napi::Number>().Int32Value();
this->instance->drawPie(x, y, width, height, startAngle, sweepLength);
return env.Null();
}
Napi::Value QPainterWrap::drawPieF(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
if (info.Length() < 6) { if (info.Length() < 6) {
Napi::TypeError::New(env, "Invalid number of arguments to drawPie") Napi::TypeError::New(env, "Invalid number of arguments to drawPie")
@ -228,12 +316,13 @@ Napi::Value QPainterWrap::drawPie(const Napi::CallbackInfo& info) {
qreal y = info[1].As<Napi::Number>().DoubleValue(); qreal y = info[1].As<Napi::Number>().DoubleValue();
qreal width = info[2].As<Napi::Number>().DoubleValue(); qreal width = info[2].As<Napi::Number>().DoubleValue();
qreal height = info[3].As<Napi::Number>().DoubleValue(); qreal height = info[3].As<Napi::Number>().DoubleValue();
qreal startAngle = info[4].As<Napi::Number>().DoubleValue(); int startAngle = info[4].As<Napi::Number>().Int32Value();
qreal sweepLength = info[5].As<Napi::Number>().DoubleValue(); int sweepLength = info[5].As<Napi::Number>().Int32Value();
this->instance->drawPie(x, y, width, height, startAngle, sweepLength); this->instance->drawPie(QRectF(x, y, width, height), startAngle, sweepLength);
return env.Null(); return env.Null();
} }
Napi::Value QPainterWrap::drawLine(const Napi::CallbackInfo& info) { Napi::Value QPainterWrap::drawLine(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
int x1 = info[0].As<Napi::Number>().Int32Value(); int x1 = info[0].As<Napi::Number>().Int32Value();
@ -243,6 +332,15 @@ Napi::Value QPainterWrap::drawLine(const Napi::CallbackInfo& info) {
this->instance->drawLine(x1, y1, x2, y2); this->instance->drawLine(x1, y1, x2, y2);
return env.Null(); return env.Null();
} }
Napi::Value QPainterWrap::drawLineF(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
qreal x1 = info[0].As<Napi::Number>().DoubleValue();
qreal y1 = info[1].As<Napi::Number>().DoubleValue();
qreal x2 = info[2].As<Napi::Number>().DoubleValue();
qreal y2 = info[3].As<Napi::Number>().DoubleValue();
this->instance->drawLine(QLineF(x1, y1, x2, y2));
return env.Null();
}
Napi::Value QPainterWrap::scale(const Napi::CallbackInfo& info) { Napi::Value QPainterWrap::scale(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
qreal sx = info[0].As<Napi::Number>().DoubleValue(); qreal sx = info[0].As<Napi::Number>().DoubleValue();
@ -270,6 +368,19 @@ Napi::Value QPainterWrap::drawConvexPolygon(const Napi::CallbackInfo& info) {
this->instance->drawConvexPolygon(polygon); this->instance->drawConvexPolygon(polygon);
return env.Null(); return env.Null();
} }
Napi::Value QPainterWrap::drawConvexPolygonF(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::Array pointsNapi = info[0].As<Napi::Array>();
QPolygonF polygon;
for (int i = 0; i < pointsNapi.Length(); i++) {
Napi::Object pointObject = pointsNapi.Get(i).As<Napi::Object>();
QPointFWrap* pointWrap = Napi::ObjectWrap<QPointFWrap>::Unwrap(pointObject);
QPointF* point = pointWrap->getInternalInstance();
polygon << *point;
}
this->instance->drawConvexPolygon(polygon);
return env.Null();
}
Napi::Value QPainterWrap::save(const Napi::CallbackInfo& info) { Napi::Value QPainterWrap::save(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
this->instance->save(); this->instance->save();
@ -349,6 +460,18 @@ Napi::Value QPainterWrap::fillRect(const Napi::CallbackInfo& info) {
this->instance->fillRect(x, y, width, height, *color); this->instance->fillRect(x, y, width, height, *color);
return env.Null(); return env.Null();
} }
Napi::Value QPainterWrap::fillRectF(const Napi::CallbackInfo& info) {
Napi::Env env = info.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();
Napi::Object colorObject = info[4].As<Napi::Object>();
QColorWrap* colorWrap = Napi::ObjectWrap<QColorWrap>::Unwrap(colorObject);
QColor* color = colorWrap->getInternalInstance();
this->instance->fillRect(QRectF(x, y, width, height), *color);
return env.Null();
}
Napi::Value QPainterWrap::compositionMode(const Napi::CallbackInfo& info) { Napi::Value QPainterWrap::compositionMode(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
uint mode = static_cast<uint>(this->instance->compositionMode()); uint mode = static_cast<uint>(this->instance->compositionMode());
@ -379,6 +502,13 @@ Napi::Value QPainterWrap::drawPoint(const Napi::CallbackInfo& info) {
this->instance->drawPoint(x, y); this->instance->drawPoint(x, y);
return env.Null(); return env.Null();
} }
Napi::Value QPainterWrap::drawPointF(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
qreal x = info[0].As<Napi::Number>().DoubleValue();
qreal y = info[1].As<Napi::Number>().DoubleValue();
this->instance->drawPoint(QPointF(x, y));
return env.Null();
}
Napi::Value QPainterWrap::drawRect(const Napi::CallbackInfo& info) { Napi::Value QPainterWrap::drawRect(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
int x = info[0].As<Napi::Number>().Int32Value(); int x = info[0].As<Napi::Number>().Int32Value();
@ -388,6 +518,15 @@ Napi::Value QPainterWrap::drawRect(const Napi::CallbackInfo& info) {
this->instance->drawRect(x, y, width, height); this->instance->drawRect(x, y, width, height);
return env.Null(); return env.Null();
} }
Napi::Value QPainterWrap::drawRectF(const Napi::CallbackInfo& info) {
Napi::Env env = info.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->drawRect(QRectF(x, y, width, height));
return env.Null();
}
Napi::Value QPainterWrap::eraseRect(const Napi::CallbackInfo& info) { Napi::Value QPainterWrap::eraseRect(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
int x = info[0].As<Napi::Number>().Int32Value(); int x = info[0].As<Napi::Number>().Int32Value();
@ -397,6 +536,15 @@ Napi::Value QPainterWrap::eraseRect(const Napi::CallbackInfo& info) {
this->instance->eraseRect(x, y, width, height); this->instance->eraseRect(x, y, width, height);
return env.Null(); return env.Null();
} }
Napi::Value QPainterWrap::eraseRectF(const Napi::CallbackInfo& info) {
Napi::Env env = info.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->eraseRect(QRectF(x, y, width, height));
return env.Null();
}
Napi::Value QPainterWrap::boundingRect(const Napi::CallbackInfo& info) { Napi::Value QPainterWrap::boundingRect(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
int x = info[0].As<Napi::Number>().Int32Value(); int x = info[0].As<Napi::Number>().Int32Value();
@ -411,6 +559,20 @@ Napi::Value QPainterWrap::boundingRect(const Napi::CallbackInfo& info) {
{Napi::External<QRect>::New(env, new QRect(result))}); {Napi::External<QRect>::New(env, new QRect(result))});
return resultInstance; return resultInstance;
} }
Napi::Value QPainterWrap::boundingRectF(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
qreal x = info[0].As<Napi::Number>().DoubleValue();
qreal y = info[1].As<Napi::Number>().DoubleValue();
qreal w = info[2].As<Napi::Number>().DoubleValue();
qreal h = info[3].As<Napi::Number>().DoubleValue();
int flags = info[4].As<Napi::Number>().Int32Value();
std::string textNapiText = info[5].As<Napi::String>().Utf8Value();
QString text = QString::fromUtf8(textNapiText.c_str());
QRectF result = this->instance->boundingRect(QRectF(x, y, w, h), flags, text);
auto resultInstance = QRectFWrap::constructor.New(
{Napi::External<QRectF>::New(env, new QRectF(result))});
return resultInstance;
}
Napi::Value QPainterWrap::drawChord(const Napi::CallbackInfo& info) { Napi::Value QPainterWrap::drawChord(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
int x = info[0].As<Napi::Number>().Int32Value(); int x = info[0].As<Napi::Number>().Int32Value();
@ -422,6 +584,17 @@ Napi::Value QPainterWrap::drawChord(const Napi::CallbackInfo& info) {
this->instance->drawChord(x, y, width, height, startAngle, spanAngle); this->instance->drawChord(x, y, width, height, startAngle, spanAngle);
return env.Null(); return env.Null();
} }
Napi::Value QPainterWrap::drawChordF(const Napi::CallbackInfo& info) {
Napi::Env env = info.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();
int startAngle = info[4].As<Napi::Number>().Int32Value();
int spanAngle = info[5].As<Napi::Number>().Int32Value();
this->instance->drawChord(QRectF(x, y, width, height), startAngle, spanAngle);
return env.Null();
}
Napi::Value QPainterWrap::setBrushOrigin(const Napi::CallbackInfo& info) { Napi::Value QPainterWrap::setBrushOrigin(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env(); Napi::Env env = info.Env();
int x = info[0].As<Napi::Number>().Int32Value(); int x = info[0].As<Napi::Number>().Int32Value();
@ -429,3 +602,10 @@ Napi::Value QPainterWrap::setBrushOrigin(const Napi::CallbackInfo& info) {
this->instance->setBrushOrigin(x, y); this->instance->setBrushOrigin(x, y);
return env.Null(); return env.Null();
} }
Napi::Value QPainterWrap::setBrushOriginF(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
qreal x = info[0].As<Napi::Number>().DoubleValue();
qreal y = info[1].As<Napi::Number>().DoubleValue();
this->instance->setBrushOrigin(QPointF(x, y));
return env.Null();
}

View File

@ -82,6 +82,10 @@ Napi::Object QTableWidgetWrap::init(Napi::Env env, Napi::Object exports) {
InstanceMethod("visualColumn", &QTableWidgetWrap::visualColumn), InstanceMethod("visualColumn", &QTableWidgetWrap::visualColumn),
InstanceMethod("visualItemRect", &QTableWidgetWrap::visualItemRect), InstanceMethod("visualItemRect", &QTableWidgetWrap::visualItemRect),
InstanceMethod("visualRow", &QTableWidgetWrap::visualRow), InstanceMethod("visualRow", &QTableWidgetWrap::visualRow),
InstanceMethod("clearSelection", &QTableWidgetWrap::clearSelection),
InstanceMethod("selectAll", &QTableWidgetWrap::selectAll),
InstanceMethod("scrollToBottom", &QTableWidgetWrap::scrollToBottom),
InstanceMethod("scrollToTop", &QTableWidgetWrap::scrollToTop),
QABSTRACTSCROLLAREA_WRAPPED_METHODS_EXPORT_DEFINE(QTableWidgetWrap)}); QABSTRACTSCROLLAREA_WRAPPED_METHODS_EXPORT_DEFINE(QTableWidgetWrap)});
constructor = Napi::Persistent(func); constructor = Napi::Persistent(func);
@ -647,3 +651,27 @@ Napi::Value QTableWidgetWrap::isSortingEnabled(const Napi::CallbackInfo& info) {
bool enabled = this->instance->isSortingEnabled(); bool enabled = this->instance->isSortingEnabled();
return Napi::Boolean::New(env, enabled); return Napi::Boolean::New(env, enabled);
} }
Napi::Value QTableWidgetWrap::clearSelection(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
this->instance->clearSelection();
return env.Null();
}
Napi::Value QTableWidgetWrap::selectAll(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
this->instance->clearSelection();
return env.Null();
}
Napi::Value QTableWidgetWrap::scrollToBottom(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
this->instance->scrollToBottom();
return env.Null();
}
Napi::Value QTableWidgetWrap::scrollToTop(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
this->instance->scrollToTop();
return env.Null();
}

View File

@ -19,7 +19,6 @@ int QtRunLoopWrapper() {
void integrate() { void integrate() {
// Bootstrap Qt // Bootstrap Qt
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts); QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
app = new NApplication(qode::qode_argc, qode::qode_argv); app = new NApplication(qode::qode_argc, qode::qode_argv);
qode::InjectCustomRunLoop(&QtRunLoopWrapper); qode::InjectCustomRunLoop(&QtRunLoopWrapper);
// Other init settings // Other init settings

View File

@ -27,6 +27,8 @@
#include "QtGui/QEvent/QDragLeaveEvent/qdragleaveevent_wrap.h" #include "QtGui/QEvent/QDragLeaveEvent/qdragleaveevent_wrap.h"
#include "QtGui/QEvent/QDragMoveEvent/qdragmoveevent_wrap.h" #include "QtGui/QEvent/QDragMoveEvent/qdragmoveevent_wrap.h"
#include "QtGui/QEvent/QDropEvent/qdropevent_wrap.h" #include "QtGui/QEvent/QDropEvent/qdropevent_wrap.h"
#include "QtGui/QEvent/QInputMethodEvent/qinputmethodevent_wrap.h"
#include "QtGui/QEvent/QInputMethodQueryEvent/qinputmethodqueryevent_wrap.h"
#include "QtGui/QEvent/QKeyEvent/qkeyevent_wrap.h" #include "QtGui/QEvent/QKeyEvent/qkeyevent_wrap.h"
#include "QtGui/QEvent/QMouseEvent/qmouseevent_wrap.h" #include "QtGui/QEvent/QMouseEvent/qmouseevent_wrap.h"
#include "QtGui/QEvent/QMoveEvent/qmoveevent_wrap.h" #include "QtGui/QEvent/QMoveEvent/qmoveevent_wrap.h"
@ -246,6 +248,8 @@ Napi::Object Main(Napi::Env env, Napi::Object exports) {
QResizeEventWrap::init(env, exports); QResizeEventWrap::init(env, exports);
QTimerEventWrap::init(env, exports); QTimerEventWrap::init(env, exports);
QAbstractItemDelegateWrap::init(env, exports); QAbstractItemDelegateWrap::init(env, exports);
QInputMethodEventWrap::init(env, exports);
QInputMethodQueryEventWrap::init(env, exports);
// Test // Test
CacheTestQObjectWrap::init(env, exports); CacheTestQObjectWrap::init(env, exports);

View File

@ -22,6 +22,8 @@ export { QFontDatabase, SystemFont, WritingSystem } from './lib/QtGui/QFontDatab
export { QFontMetrics } from './lib/QtGui/QFontMetrics'; export { QFontMetrics } from './lib/QtGui/QFontMetrics';
export { QFontMetricsF } from './lib/QtGui/QFontMetricsF'; export { QFontMetricsF } from './lib/QtGui/QFontMetricsF';
// Events: Maybe a separate module ? // Events: Maybe a separate module ?
export { QInputMethodEvent } from './lib/QtGui/QEvent/QInputMethodEvent';
export { QInputMethodQueryEvent } from './lib/QtGui/QEvent/QInputMethodQueryEvent';
export { QKeyEvent } from './lib/QtGui/QEvent/QKeyEvent'; export { QKeyEvent } from './lib/QtGui/QEvent/QKeyEvent';
export { QMouseEvent } from './lib/QtGui/QEvent/QMouseEvent'; export { QMouseEvent } from './lib/QtGui/QEvent/QMouseEvent';
export { QMoveEvent } from './lib/QtGui/QEvent/QMoveEvent'; export { QMoveEvent } from './lib/QtGui/QEvent/QMoveEvent';

View File

@ -1,8 +1,9 @@
import { NativeElement, Component } from '../core/Component'; import { NativeElement, Component } from '../core/Component';
import addon from '../utils/addon'; import addon from '../utils/addon';
import { checkIfNativeElement } from '../utils/helpers'; import { checkIfNativeElement } from '../utils/helpers';
import { QRect } from './QRect';
export type QVariantType = NativeElement | string | string[] | number | boolean; export type QVariantType = NativeElement | string | string[] | number | boolean | QRect;
export class QVariant extends Component { export class QVariant extends Component {
constructor(); constructor();
@ -35,3 +36,14 @@ export class QVariant extends Component {
return this.native.toStringList(); return this.native.toStringList();
} }
} }
/**
* Get the correct native object which should be passed down to the
* C++ wrapper from a QVariantType object.
*/
export function nativeObjectFromVariantType(obj: QVariantType): any {
if (obj instanceof QRect) {
return obj.native;
}
return obj;
}

View File

@ -1,6 +1,5 @@
export enum InputMethodQuery { export enum InputMethodQuery {
ImEnabled = 0x1, ImEnabled = 0x1,
ImMicroFocus = 0x2,
ImCursorRectangle = 0x2, ImCursorRectangle = 0x2,
ImFont = 0x4, ImFont = 0x4,
ImCursorPosition = 0x8, ImCursorPosition = 0x8,
@ -17,6 +16,7 @@ export enum InputMethodQuery {
ImEnterKeyType = 0x2000, ImEnterKeyType = 0x2000,
ImAnchorRectangle = 0x4000, ImAnchorRectangle = 0x4000,
ImInputItemClipRectangle = 0x8000, ImInputItemClipRectangle = 0x8000,
ImReadOnly = 0x10000,
//Masks: //Masks:
ImQueryAll = 0xffffffff, ImQueryAll = 0xffffffff,
} }

View File

@ -105,7 +105,9 @@ export class QApplication extends QObject<QApplicationSignals> {
wrapperCache.registerWrapper('QApplicationWrap', QApplication); wrapperCache.registerWrapper('QApplicationWrap', QApplication);
export interface QApplicationSignals extends QObjectSignals { export interface QApplicationSignals extends QObjectSignals {
applicationDisplayNameChanged: () => void;
focusWindowChanged: () => void; focusWindowChanged: () => void;
lastWindowClosed: () => void;
primaryScreenChanged: (screen: QScreen) => void; primaryScreenChanged: (screen: QScreen) => void;
screenAdded: (screen: QScreen) => void; screenAdded: (screen: QScreen) => void;
screenRemoved: (screen: QScreen) => void; screenRemoved: (screen: QScreen) => void;

View File

@ -0,0 +1,24 @@
import addon from '../../utils/addon';
import { NativeRawPointer } from '../../core/Component';
import { QEvent } from './QEvent';
export class QInputMethodEvent extends QEvent {
constructor(event: NativeRawPointer<'QEvent'>) {
super(new addon.QInputMethodEvent(event));
}
commitString(): string {
return this.native.commitString();
}
preeditString(): string {
return this.native.preeditString();
}
replacementLength(): number {
return this.native.replacementLength();
}
replacementStart(): number {
return this.native.replacementStart();
}
setCommitString(commitString: string, replaceFrom = 0, replaceLength = 0): void {
this.native.setCommitString(commitString, replaceFrom, replaceLength);
}
}

View File

@ -0,0 +1,28 @@
import addon from '../../utils/addon';
import { NativeRawPointer } from '../../core/Component';
import { QVariant, QVariantType, nativeObjectFromVariantType } from '../../QtCore/QVariant';
import { QEvent } from './QEvent';
/**
* Note: Qt performs some default processing for `QInputMethodQueryEvents`.
* When attaching an event listener via `addEventListener()` use the
* options object to specify that you want to run after the default
* processing, otherwise your `setValue()` calls will be overwritten.
*/
export class QInputMethodQueryEvent extends QEvent {
constructor(event: NativeRawPointer<'QEvent'>) {
super(new addon.QInputMethodQueryEvent(event));
}
queries(): number /* InputMethodQueries */ {
return this.native.queries();
}
setValue(query: number /* InputMethodQuery */, value: QVariantType): void {
this.native.setValue(query, nativeObjectFromVariantType(value));
}
value(query: number /* InputMethodQuery */): QVariant {
return new QVariant(this.native.value(query));
}
}

View File

@ -10,6 +10,7 @@ import { QWidget } from './QWidget';
import { QImage } from '../QtGui/QImage'; import { QImage } from '../QtGui/QImage';
import { QFont } from '../QtGui/QFont'; import { QFont } from '../QtGui/QFont';
import { QRect } from '../QtCore/QRect'; import { QRect } from '../QtCore/QRect';
import { QRectF } from '../QtCore/QRectF';
/** /**
@ -46,7 +47,7 @@ win.show();
https://github.com/nodegui/examples/blob/master/nodegui/custom-native-widget-qpainter https://github.com/nodegui/examples/blob/master/nodegui/custom-native-widget-qpainter
*/ */
export class QPainter extends Component { export class QPainter extends Component {
constructor(device?: Component) { constructor(device?: QWidget) {
let native: NativeElement; let native: NativeElement;
if (device) { if (device) {
native = new addon.QPainter(device.native); native = new addon.QPainter(device.native);
@ -74,6 +75,12 @@ export class QPainter extends Component {
boundingRect(x: number, y: number, w: number, h: number, flags: number, text: string): QRect { boundingRect(x: number, y: number, w: number, h: number, flags: number, text: string): QRect {
return new QRect(this.native.boundingRect(x, y, w, h, flags, text)); return new QRect(this.native.boundingRect(x, y, w, h, flags, text));
} }
/**
* Version of boundingRect() which takes floating point parameters.
*/
boundingRectF(x: number, y: number, w: number, h: number, flags: number, text: string): QRect {
return new QRectF(this.native.boundingRectF(x, y, w, h, flags, text));
}
// TODO: QRectF boundingRect(const QRectF &rectangle, const QString &text, const QTextOption &option = QTextOption()) // TODO: QRectF boundingRect(const QRectF &rectangle, const QString &text, const QTextOption &option = QTextOption())
// TODO: const QBrush & brush() const // TODO: const QBrush & brush() const
// TODO: QPoint brushOrigin() const // TODO: QPoint brushOrigin() const
@ -90,27 +97,61 @@ export class QPainter extends Component {
drawArc(x: number, y: number, width: number, height: number, startAngle: number, spanAngle: number): void { drawArc(x: number, y: number, width: number, height: number, startAngle: number, spanAngle: number): void {
this.native.drawArc(x, y, width, height, startAngle, spanAngle); this.native.drawArc(x, y, width, height, startAngle, spanAngle);
} }
/**
* Version of drawArc() which takes floating point parameters.
*/
drawArcF(x: number, y: number, width: number, height: number, startAngle: number, spanAngle: number): void {
this.native.drawArcF(x, y, width, height, startAngle, spanAngle);
}
// TODO: void drawChord(const QRectF &rectangle, int startAngle, int spanAngle) // TODO: void drawChord(const QRectF &rectangle, int startAngle, int spanAngle)
drawChord(x: number, y: number, width: number, height: number, startAngle: number, spanAngle: number): void { drawChord(x: number, y: number, width: number, height: number, startAngle: number, spanAngle: number): void {
this.native.drawChord(x, y, width, height, startAngle, spanAngle); this.native.drawChord(x, y, width, height, startAngle, spanAngle);
} }
/**
* Version of drawChord() which takes floating point parameters.
*/
drawChordF(x: number, y: number, width: number, height: number, startAngle: number, spanAngle: number): void {
this.native.drawChordF(x, y, width, height, startAngle, spanAngle);
}
// TODO: void drawChord(const QRect &rectangle, int startAngle, int spanAngle) // TODO: void drawChord(const QRect &rectangle, int startAngle, int spanAngle)
drawConvexPolygon(points: QPoint[]): void { drawConvexPolygon(points: QPoint[]): void {
const nativePoints = points.map((point) => point.native); const nativePoints = points.map((point) => point.native);
this.native.drawConvexPolygon(nativePoints); this.native.drawConvexPolygon(nativePoints);
} }
drawConvexPolygonF(points: QPoint[]): void {
const nativePoints = points.map((point) => point.native);
this.native.drawConvexPolygonF(nativePoints);
}
// TODO: void drawConvexPolygon(const QPolygonF &polygon) // TODO: void drawConvexPolygon(const QPolygonF &polygon)
drawEllipse(x: number, y: number, width: number, height: number): void { drawEllipse(x: number, y: number, width: number, height: number): void {
return this.native.drawEllipse(x, y, width, height); return this.native.drawEllipse(x, y, width, height);
} }
/**
* Version of drawEllipse() which takes floating point parameters.
*/
drawEllipseF(x: number, y: number, width: number, height: number): void {
return this.native.drawEllipseF(x, y, width, height);
}
// TODO: void drawEllipse(const QRectF &rectangle) // TODO: void drawEllipse(const QRectF &rectangle)
// TODO: void drawGlyphRun(const QPointF &position, const QGlyphRun &glyphs) // TODO: void drawGlyphRun(const QPointF &position, const QGlyphRun &glyphs)
drawImage(x: number, y: number, image: QImage, sx = 0, sy = 0, sw = -1, sh = -1): void { drawImage(x: number, y: number, image: QImage, sx = 0, sy = 0, sw = -1, sh = -1): void {
this.native.drawImage(x, y, image.native, sx, sy, sw, sh); this.native.drawImage(x, y, image.native, sx, sy, sw, sh);
} }
/**
* Version of drawImage() which takes floating point parameters.
*/
drawImageF(x: number, y: number, image: QImage, sx = 0, sy = 0, sw = -1, sh = -1): void {
this.native.drawImageF(x, y, image.native, sx, sy, sw, sh);
}
drawLine(x1: number, y1: number, x2: number, y2: number): void { drawLine(x1: number, y1: number, x2: number, y2: number): void {
this.native.drawLine(x1, y1, x2, y2); this.native.drawLine(x1, y1, x2, y2);
} }
/**
* Version of drawLine() which takes floating point parameters.
*/
drawLineF(x1: number, y1: number, x2: number, y2: number): void {
this.native.drawLineF(x1, y1, x2, y2);
}
// TODO: void drawLines(const QVector<QLineF> &lines) // TODO: void drawLines(const QVector<QLineF> &lines)
drawPath(path: QPainterPath): void { drawPath(path: QPainterPath): void {
return this.native.drawPath(path.native); return this.native.drawPath(path.native);
@ -119,22 +160,43 @@ export class QPainter extends Component {
drawPie(x: number, y: number, width: number, height: number, startAngle: number, sweepLength: number): void { drawPie(x: number, y: number, width: number, height: number, startAngle: number, sweepLength: number): void {
return this.native.drawPie(x, y, width, height, startAngle, sweepLength); return this.native.drawPie(x, y, width, height, startAngle, sweepLength);
} }
/**
* Version of drawPie() which takes floating point parameters.
*/
drawPieF(x: number, y: number, width: number, height: number, startAngle: number, sweepLength: number): void {
return this.native.drawPieF(x, y, width, height, startAngle, sweepLength);
}
// TODO: void drawPixmap(int x, int y, int w, int h, const QPixmap &pixmap, int sx, int sy, int sw, int sh) // TODO: void drawPixmap(int x, int y, int w, int h, const QPixmap &pixmap, int sx, int sy, int sw, int sh)
// TODO: void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, QPainter::PixmapFragmentHints hints = PixmapFragmentHints()) // TODO: void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, QPainter::PixmapFragmentHints hints = PixmapFragmentHints())
drawPoint(x: number, y: number): void { drawPoint(x: number, y: number): void {
this.native.drawPoint(x, y); this.native.drawPoint(x, y);
} }
drawPointF(x: number, y: number): void {
this.native.drawPointF(x, y);
}
// TODO: void drawPoints(const QPointF *points, int pointCount) // TODO: void drawPoints(const QPointF *points, int pointCount)
// TODO: void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule = Qt::OddEvenFill) // TODO: void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule = Qt::OddEvenFill)
drawRect(x: number, y: number, width: number, height: number): void { drawRect(x: number, y: number, width: number, height: number): void {
this.native.drawRect(x, y, width, height); this.native.drawRect(x, y, width, height);
} }
/**
* Version of drawRect() which takes floating point parameters.
*/
drawRectF(x: number, y: number, width: number, height: number): void {
this.native.drawRectF(x, y, width, height);
}
// TODO: void drawRects(const QVector<QRectF> &rectangles) // TODO: void drawRects(const QVector<QRectF> &rectangles)
// TODO: void drawRoundedRect(int x, int y, int w, int h, qreal xRadius, qreal yRadius, Qt::SizeMode mode = Qt::AbsoluteSize) // TODO: void drawRoundedRect(int x, int y, int w, int h, qreal xRadius, qreal yRadius, Qt::SizeMode mode = Qt::AbsoluteSize)
// TODO: void drawStaticText(int left, int top, const QStaticText &staticText) // TODO: void drawStaticText(int left, int top, const QStaticText &staticText)
drawText(x: number, y: number, text: string): void { drawText(x: number, y: number, text: string): void {
return this.native.drawText(x, y, text); return this.native.drawText(x, y, text);
} }
/**
* Version of drawText() which takes floating point parameters
*/
drawTextF(x: number, y: number, text: string): void {
return this.native.drawTextF(x, y, text);
}
// TODO: void drawText(int x, int y, int width, int height, int flags, const QString &text, QRect *boundingRect = nullptr) // TODO: void drawText(int x, int y, int width, int height, int flags, const QString &text, QRect *boundingRect = nullptr)
// TODO: void drawTiledPixmap(int x, int y, int width, int height, const QPixmap &pixmap, int sx = 0, int sy = 0) // TODO: void drawTiledPixmap(int x, int y, int width, int height, const QPixmap &pixmap, int sx = 0, int sy = 0)
end(): boolean { end(): boolean {
@ -146,9 +208,21 @@ export class QPainter extends Component {
eraseRect(x: number, y: number, width: number, height: number): void { eraseRect(x: number, y: number, width: number, height: number): void {
this.native.eraseRect(x, y, width, height); this.native.eraseRect(x, y, width, height);
} }
/**
* Version of eraseRect() which takes floating point parameters.
*/
eraseRectF(x: number, y: number, width: number, height: number): void {
this.native.eraseRectF(x, y, width, height);
}
fillRect(x: number, y: number, width: number, height: number, color: QColor): void { fillRect(x: number, y: number, width: number, height: number, color: QColor): void {
this.native.fillRect(x, y, width, height, color.native); this.native.fillRect(x, y, width, height, color.native);
} }
/**
* Version of fillRect() which takes floating point parameters.
*/
fillRectF(x: number, y: number, width: number, height: number, color: QColor): void {
this.native.fillRectF(x, y, width, height, color.native);
}
// TODO: const QFont & font() const // TODO: const QFont & font() const
// TODO: QFontInfo fontInfo() const // TODO: QFontInfo fontInfo() const
// TODO: QFontMetrics fontMetrics() const // TODO: QFontMetrics fontMetrics() const
@ -187,6 +261,12 @@ export class QPainter extends Component {
setBrushOrigin(x: number, y: number): void { setBrushOrigin(x: number, y: number): void {
this.native.setBrushOrigin(x, y); this.native.setBrushOrigin(x, y);
} }
/**
* Version of setBrushOrigin() which takes floating point parameters.
*/
setBrushOriginF(x: number, y: number): void {
this.native.setBrushOriginF(x, y);
}
setCompositionMode(mode: CompositionMode): void { setCompositionMode(mode: CompositionMode): void {
this.native.setCompositionMode(mode); this.native.setCompositionMode(mode);
} }

View File

@ -238,6 +238,18 @@ export class QTableWidget extends QAbstractScrollArea<QTableWidgetSignals> {
isSortingEnabled(): boolean { isSortingEnabled(): boolean {
return this.native.isSortingEnabled(); return this.native.isSortingEnabled();
} }
selectAll(): void {
this.native.selectAll();
}
clearSelection(): void {
this.native.clearSelection();
}
scrollToTop(): void {
this.native.scrollToTop();
}
scrollToBottom(): void {
this.native.scrollToBottom();
}
} }
wrapperCache.registerWrapper('QTableWidgetWrap', QTableWidget); wrapperCache.registerWrapper('QTableWidgetWrap', QTableWidget);

View File

@ -2,7 +2,7 @@ import addon from '../utils/addon';
import { QLayout } from './QLayout'; import { QLayout } from './QLayout';
import { NativeElement } from '../core/Component'; import { NativeElement } from '../core/Component';
import { FlexLayout } from '../core/FlexLayout'; import { FlexLayout } from '../core/FlexLayout';
import { WidgetAttribute, WindowType, ContextMenuPolicy, FocusReason, FocusPolicy } from '../QtEnums'; import { WidgetAttribute, WindowType, ContextMenuPolicy, FocusReason, FocusPolicy, InputMethodQuery } from '../QtEnums';
import { QIcon } from '../QtGui/QIcon'; import { QIcon } from '../QtGui/QIcon';
import { QCursor } from '../QtGui/QCursor'; import { QCursor } from '../QtGui/QCursor';
import { CursorShape, WindowState } from '../QtEnums'; import { CursorShape, WindowState } from '../QtEnums';
@ -193,7 +193,9 @@ export class QWidget<Signals extends QWidgetSignals = QWidgetSignals> extends Yo
heightForWidth(w: number): number { heightForWidth(w: number): number {
return this.native.heightForWidth(w); return this.native.heightForWidth(w);
} }
// TODO: Qt::InputMethodHints inputMethodHints() const inputMethodHints(): number {
return this.property('inputMethodHints').toInt();
}
// TODO: virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const // TODO: virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const
// TODO: void insertAction(QAction *before, QAction *action) // TODO: void insertAction(QAction *before, QAction *action)
// TODO: void insertActions(QAction *before, QList<QAction *> actions) // TODO: void insertActions(QAction *before, QList<QAction *> actions)
@ -396,7 +398,9 @@ export class QWidget<Signals extends QWidgetSignals = QWidgetSignals> extends Yo
setGraphicsEffect(effect: QGraphicsEffect<any>): void { setGraphicsEffect(effect: QGraphicsEffect<any>): void {
this.native.setGraphicsEffect(effect.native); this.native.setGraphicsEffect(effect.native);
} }
// TODO: void setInputMethodHints(Qt::InputMethodHints hints) setInputMethodHints(hints: number): void {
this.setProperty('inputMethodHints', hints);
}
setInlineStyle(style: string, postprocess = true): void { setInlineStyle(style: string, postprocess = true): void {
if (postprocess) { if (postprocess) {
this._rawInlineStyle = style; this._rawInlineStyle = style;
@ -560,6 +564,11 @@ export class QWidget<Signals extends QWidgetSignals = QWidgetSignals> extends Yo
updatesEnabled(): boolean { updatesEnabled(): boolean {
return this.property('updatesEnabled').toBool(); return this.property('updatesEnabled').toBool();
} }
updateMicroFocus(query: number = InputMethodQuery.ImQueryAll): void {
this.native.updateMicroFocus(query);
}
// TODO: QRegion visibleRegion() const // TODO: QRegion visibleRegion() const
whatsThis(): string { whatsThis(): string {
return this.property('whatsThis').toString(); return this.property('whatsThis').toString();
@ -611,6 +620,43 @@ export class QWidget<Signals extends QWidgetSignals = QWidgetSignals> extends Yo
return this.property('y').toInt(); return this.property('y').toInt();
} }
// QPaintDevice public methods
colorCount(): number {
return this.native.colorCount();
}
depth(): number {
return this.native.depth();
}
devicePixelRatio(): number {
return this.native.devicePixelRatio();
}
devicePixelRatioF(): number {
return this.native.devicePixelRatioF();
}
heightMM(): number {
return this.native.heightMM();
}
logicalDpiX(): number {
return this.native.logicalDpiX();
}
logicalDpiY(): number {
return this.native.logicalDpiY();
}
paintingActive(): boolean {
return this.native.paintingActive();
}
physicalDpiX(): number {
return this.native.physicalDpiX();
}
physicalDpiY(): number {
return this.native.physicalDpiY();
}
widthMM(): number {
return this.native.widthMM();
}
// TODO: virtual QPaintEngine * paintEngine() const = 0
// *** Public Slots *** // *** Public Slots ***
close(): boolean { close(): boolean {
return this.native.close(); return this.native.close();