packages feed

qtah-cpp-qt5 0.3.0 → 0.3.1

raw patch · 6 files changed

+316/−2 lines, 6 files

Files

cpp/qtah.pro view
@@ -21,7 +21,7 @@  TARGET = qtah TEMPLATE = lib-VERSION = 0.3.0+VERSION = 0.3.1 # Doesn't seem to work here: CONFIG += c++11 QMAKE_CXXFLAGS += -std=c++11 
+ cpp/qtahopenglwindow.hpp view
@@ -0,0 +1,106 @@+#ifndef QTAH_WRAP_QOPENGLWINDOW_HPP+#define QTAH_WRAP_QOPENGLWINDOW_HPP++// This file is part of Qtah.+//+// Copyright 2015-2017 The Qtah Authors.+//+// This program is free software: you can redistribute it and/or modify+// it under the terms of the GNU Lesser General Public License as published by+// the Free Software Foundation, either version 3 of the License, or+// (at your option) any later version.+//+// This program is distributed in the hope that it will be useful,+// but WITHOUT ANY WARRANTY; without even the implied warranty of+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the+// GNU Lesser General Public License for more details.+//+// You should have received a copy of the GNU Lesser General Public License+// along with this program.  If not, see <http://www.gnu.org/licenses/>.++#if QT_VERSION >= 0x050400++#include <QOpenGLWindow>+#include <QtGlobal>+#include "b_callback.hpp"++namespace qtah {+namespace qtahopenglwindow {++class QtahOpenGLWindow : public QOpenGLWindow {+public:+    QtahOpenGLWindow(UpdateBehavior updateBehavior = NoPartialUpdate, QWindow* parent = Q_NULLPTR)+        : QOpenGLWindow(updateBehavior, parent) {}++    QtahOpenGLWindow(+        QOpenGLContext* shareContext,+        UpdateBehavior updateBehavior = NoPartialUpdate,+        QWindow *parent = Q_NULLPTR)+        : QOpenGLWindow(shareContext, updateBehavior, parent) {}++    virtual ~QtahOpenGLWindow() {}++    virtual void onInitializeGL() {+        if (onInitializeGL_) {+            onInitializeGL_();+        }+    }++    virtual void onPaintGL() {+        if (onPaintGL_) {+            onPaintGL_();+        }+    }++    virtual void onPaintOverGL() {+        if (onPaintOverGL_) {+            onPaintOverGL_();+        }+    }++    virtual void onPaintUnderGL() {+        if (onPaintUnderGL_) {+            onPaintUnderGL_();+        }+    }++    virtual void onResizeGL(int width, int height) {+        if (onResizeGL_) {+            onResizeGL_(width, height);+        }+    }++    void onInitializeGL(CallbackVoid handler) {+        onInitializeGL_ = handler;+    }++    void onPaintGL(CallbackVoid handler) {+        onPaintGL_ = handler;+    }++    void onPaintOverGL(CallbackVoid handler) {+        onPaintOverGL_ = handler;+    }++    void onPaintUnderGL(CallbackVoid handler) {+        onPaintUnderGL_ = handler;+    }++    void onResizeGL(CallbackIntIntVoid handler) {+        onResizeGL_ = handler;+    }++private:+    CallbackVoid onInitializeGL_;+    CallbackVoid onPaintGL_;+    CallbackVoid onPaintOverGL_;+    CallbackVoid onPaintUnderGL_;+    CallbackIntIntVoid onResizeGL_;+};++}  // namespace qtahopenglwindow+}  // namespace qtah++#endif++#endif // QTAH_WRAP_QOPENGLWINDOW_HPP
+ cpp/qtahrasterwindow.hpp view
@@ -0,0 +1,54 @@+#ifndef QTAH_WRAP_QRASTERWINDOW_HPP+#define QTAH_WRAP_QRASTERWINDOW_HPP++// This file is part of Qtah.+//+// Copyright 2015-2017 The Qtah Authors.+//+// This program is free software: you can redistribute it and/or modify+// it under the terms of the GNU Lesser General Public License as published by+// the Free Software Foundation, either version 3 of the License, or+// (at your option) any later version.+//+// This program is distributed in the hope that it will be useful,+// but WITHOUT ANY WARRANTY; without even the implied warranty of+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the+// GNU Lesser General Public License for more details.+//+// You should have received a copy of the GNU Lesser General Public License+// along with this program.  If not, see <http://www.gnu.org/licenses/>.++#if QT_VERSION >= 0x050400++#include <QRasterWindow>+#include <QtGlobal>+#include "b_callback.hpp"++namespace qtah {+namespace qtahrasterwindow {++class QtahRasterWindow : public QRasterWindow {+public:+    QtahRasterWindow(QWindow* parent = Q_NULLPTR) : QRasterWindow(parent) {}+    virtual ~QtahRasterWindow() {}++    virtual void paintEvent(QPaintEvent* paintEvent) {+        if (onPaintEvent_) {+            onPaintEvent_(paintEvent);+        }+    }++    void onPaintEvent(CallbackPtrQPaintEventVoid handler) {+        onPaintEvent_ = handler;+    }++private:+    CallbackPtrQPaintEventVoid onPaintEvent_;+};++}  // namespace qtahrasterwindow+}  // namespace qtah++#endif++#endif // QTAH_WRAP_QRASTERWINDOW_HPP
+ cpp/wrap_qimage.cpp view
@@ -0,0 +1,103 @@+// This file is part of Qtah.+//+// Copyright 2015-2017 The Qtah Authors.+//+// This program is free software: you can redistribute it and/or modify+// it under the terms of the GNU Lesser General Public License as published by+// the Free Software Foundation, either version 3 of the License, or+// (at your option) any later version.+//+// This program is distributed in the hope that it will be useful,+// but WITHOUT ANY WARRANTY; without even the implied warranty of+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the+// GNU Lesser General Public License for more details.+//+// You should have received a copy of the GNU Lesser General Public License+// along with this program.  If not, see <http://www.gnu.org/licenses/>.++#include "wrap_qimage.hpp"++namespace qtah {+namespace qimage {++#if QT_VERSION >= 0x050000++void callCleanup(void* cleanupFunction) {+    CallbackVoid* fn = static_cast<CallbackVoid*>(cleanupFunction);+    (*fn)();+    delete fn;+}++QImage* create(+    uchar* data,+    int width,+    int height,+    QImage::Format format,+    CallbackVoid cleanupFunction) {+    void* cleanupFunctionOnHeap = static_cast<void*>(new CallbackVoid(cleanupFunction));+    return new QImage(data, width, height, format, &callCleanup, cleanupFunctionOnHeap);+}++QImage* create(+    const uchar* data,+    int width,+    int height,+    QImage::Format format,+    CallbackVoid cleanupFunction) {+    void* cleanupFunctionOnHeap = static_cast<void*>(new CallbackVoid(cleanupFunction));+    return new QImage(data, width, height, format, &callCleanup, cleanupFunctionOnHeap);+}++QImage* create(+    uchar* data,+    int width,+    int height,+    int bytesPerLine,+    QImage::Format format,+    CallbackVoid cleanupFunction) {+    void* cleanupFunctionOnHeap = static_cast<void*>(new CallbackVoid(cleanupFunction));+    return new QImage(+        data, width, height, bytesPerLine, format, &callCleanup, cleanupFunctionOnHeap);+}++QImage* create(+    const uchar* data,+    int width,+    int height,+    int bytesPerLine,+    QImage::Format format,+    CallbackVoid cleanupFunction) {+    void* cleanupFunctionOnHeap = static_cast<void*>(new CallbackVoid(cleanupFunction));+    return new QImage(+        data, width, height, bytesPerLine, format, &callCleanup, cleanupFunctionOnHeap);+}++#endif++QImage* create(const QString& fileName, const QString& format) {+    std::string formatStr(format.toStdString());+    return new QImage(fileName, formatStr.c_str());+}++QImage* fromData(const uchar* data, int len, const QString& format) {+    std::string formatStr(format.toStdString());+    return new QImage(QImage::fromData(data, len, formatStr.c_str()));+}++bool load(QImage& image, const QString& fileName, const QString& format) {+    std::string formatStr(format.toStdString());+    return image.load(fileName, formatStr.c_str());+}++bool loadFromData(QImage& image, const uchar* data, int len, const QString& format) {+    std::string formatStr(format.toStdString());+    return image.loadFromData(data, len, formatStr.c_str());+}++bool save(QImage& image, const QString& fileName, const QString& format, int quality) {+    std::string formatStr(format.toStdString());+    return image.save(fileName, formatStr.c_str(), quality);+}++}  // namespace qimage+}  // namespace qtah
+ cpp/wrap_qimage.hpp view
@@ -0,0 +1,47 @@+#ifndef QTAH_WRAP_QIMAGE_HPP+#define QTAH_WRAP_QIMAGE_HPP++// This file is part of Qtah.+//+// Copyright 2015-2017 The Qtah Authors.+//+// This program is free software: you can redistribute it and/or modify+// it under the terms of the GNU Lesser General Public License as published by+// the Free Software Foundation, either version 3 of the License, or+// (at your option) any later version.+//+// This program is distributed in the hope that it will be useful,+// but WITHOUT ANY WARRANTY; without even the implied warranty of+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the+// GNU Lesser General Public License for more details.+//+// You should have received a copy of the GNU Lesser General Public License+// along with this program.  If not, see <http://www.gnu.org/licenses/>.++#include <QImage>+#include <QtGlobal>+#include "b_callback.hpp"++namespace qtah {+namespace qimage {++#if QT_VERSION >= 0x050000+QImage* create(uchar*, int, int, QImage::Format, CallbackVoid);+QImage* create(const uchar*, int, int, QImage::Format, CallbackVoid);+QImage* create(uchar*, int, int, int, QImage::Format, CallbackVoid);+QImage* create(const uchar*, int, int, int, QImage::Format, CallbackVoid);+#endif+QImage* create(const QString&, const QString&);++QImage* fromData(const uchar*, int, const QString&);++bool load(QImage&, const QString&, const QString&);++bool loadFromData(QImage&, const uchar*, int, const QString&);++bool save(QImage&, const QString&, const QString&, int);++}  // namespace qimage+}  // namespace qtah++#endif // QTAH_WRAP_QIMAGE_HPP
qtah-cpp-qt5.cabal view
@@ -1,5 +1,5 @@ name: qtah-cpp-qt5-version: 0.3.0+version: 0.3.1 synopsis: Qt bindings for Haskell - C++ library homepage: http://khumba.net/projects/qtah license: LGPL-3@@ -20,6 +20,8 @@   cpp/encode.hpp   cpp/event.hpp   cpp/qtah.pro+  cpp/qtahopenglwindow.hpp+  cpp/qtahrasterwindow.hpp   cpp/wrap_qapplication.cpp   cpp/wrap_qapplication.hpp   cpp/wrap_qcoreapplication.cpp@@ -28,6 +30,8 @@   cpp/wrap_qformlayout.hpp   cpp/wrap_qgridlayout.cpp   cpp/wrap_qgridlayout.hpp+  cpp/wrap_qimage.cpp+  cpp/wrap_qimage.hpp   cpp/wrap_qstring.cpp   cpp/wrap_qstring.hpp