Add a proper build system

Also lowers the minimum required Qt version to 5.5.
This commit is contained in:
Jonathan Schleifer 2017-04-18 01:25:45 +02:00
parent f30c404f3d
commit c3ea2c3893
No known key found for this signature in database
GPG key ID: 28D65178B37F33E3
42 changed files with 5146 additions and 58 deletions

24
src/Makefile Normal file
View file

@ -0,0 +1,24 @@
include ../extra.mk
SUBDIRS = QtCore \
QtGui \
QtWidgets \
common
SHARED_LIB = ${OBJQT_SHARED_LIB}
STATIC_LIB = ${OBJQT_STATIC_LIB}
LIB_MAJOR = 0
LIB_MINOR = 0
OBJS_EXTRA = ${QTCORE_QTCORE_A} \
${QTGUI_QTGUI_A} \
${QTWIDGETS_QTWIDGETS_A} \
${COMMON_COMMON_A}
LIB_OBJS_EXTRA = ${QTCORE_QTCORE_LIB_A} \
${QTGUI_QTGUI_LIB_A} \
${QTWIDGETS_QTWIDGETS_LIB_A} \
${COMMON_COMMON_LIB_A}
include ../buildsys.mk
LD = ${OBJCXX}

14
src/QtCore/Makefile Normal file
View file

@ -0,0 +1,14 @@
include ../../extra.mk
STATIC_PIC_LIB_NOINST = ${QTCORE_LIB_A}
STATIC_LIB_NOINST = ${QTCORE_A}
SRCS = QtChildEvent.mm \
QtCoreApplication.mm \
QtEvent.mm \
QtObject.mm \
QtThread.mm
include ../../buildsys.mk
CPPFLAGS += -I. -I../common

54
src/QtCore/QtChildEvent.h Normal file
View file

@ -0,0 +1,54 @@
/*
* Copyright (c) 2017, Jonathan Schleifer <js@heap.zone>
*
* https://heap.zone/git/objqt.git
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice is present in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#import "QtEvent.h"
@class QtObject;
@interface QtChildEvent: QtEvent
@property (readonly) QChildEvent *qChildEvent;
@property (readonly, getter=isAdded) bool added;
@property (readonly, retain) QtObject *child;
@property (readonly, getter=isPolished) bool polished;
@property (readonly, getter=isRemoved) bool removed;
- initWithQChildEvent: (QChildEvent*)qChildEvent;
- initWithType: (QChildEvent::Type)type
child: (QtObject*)child;
@end
namespace ObjQt {
static OF_INLINE QtChildEvent*
toOF(QChildEvent *qChildEvent)
{
return [[[QtChildEvent alloc]
initWithQChildEvent: qChildEvent] autorelease];
}
static OF_INLINE QChildEvent*
toQt(QtChildEvent *childEvent)
{
return [childEvent qChildEvent];
}
}

View file

@ -0,0 +1,81 @@
/*
* Copyright (c) 2017, Jonathan Schleifer <js@heap.zone>
*
* https://heap.zone/git/objqt.git
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice is present in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#import "QtChildEvent.h"
#import "QtObject.h"
using ObjQt::toOF;
using ObjQt::toQt;
@implementation QtChildEvent
- initWithQEvent: (QEvent*)event
{
OF_INVALID_INIT_METHOD
}
- initWithQChildEvent: (QChildEvent*)event
{
return [super initWithQEvent: event];
}
- initWithType: (QChildEvent::Type)type
child: (QtObject*)child
{
try {
self = [self initWithQChildEvent:
new QChildEvent(type, toQt(child))];
[self takeOwnership];
return self;
} catch (const std::bad_alloc &e) {
self = [super initWithQEvent: NULL];
[self release];
throw;
}
}
- (QChildEvent*)qChildEvent
{
return dynamic_cast<QChildEvent*>(_qEvent);
}
- (bool)isAdded
{
return toQt(self)->added();
}
- (QtObject*)child
{
return toOF(toQt(self)->child());
}
- (bool)isPolished
{
return toQt(self)->polished();
}
- (bool)isRemoved
{
return toQt(self)->removed();
}
@end

View file

@ -0,0 +1,56 @@
/*
* Copyright (c) 2017, Jonathan Schleifer <js@heap.zone>
*
* https://heap.zone/git/objqt.git
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice is present in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#import "QtObject.h"
#include <QCoreApplication>
@interface QtCoreApplication: QtObject
@property (readonly) QCoreApplication *qCoreApplication;
@property (copy) OFString *applicationName, *applicationVersion;
@property (copy) OFString *organizationDomain, *organizationName;
@property (getter=isQuitLockEnabled) bool quitLockEnabled;
- initWithQCoreApplication: (QCoreApplication*)qCoreApplication;
- (void)installNativeEventFilter: (QAbstractNativeEventFilter*)filterObject;
- (void)quit;
- (void)removeNativeEventFilter: (QAbstractNativeEventFilter*)filterObject;
- (bool)sendEvent: (QtEvent*)event
receiver: (QtObject*)receiver;
@end
namespace ObjQt {
static OF_INLINE QtCoreApplication*
toOF(QCoreApplication *qCoreApplication)
{
return [[[QtCoreApplication alloc]
initWithQCoreApplication: qCoreApplication] autorelease];
}
static OF_INLINE QCoreApplication*
toQt(QtCoreApplication *coreApplication)
{
return [coreApplication qCoreApplication];
}
}

View file

@ -0,0 +1,116 @@
/*
* Copyright (c) 2017, Jonathan Schleifer <js@heap.zone>
*
* https://heap.zone/git/objqt.git
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice is present in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#import "QtCoreApplication.h"
#import "QtEvent.h"
#import "OFString+QString.h"
using ObjQt::toOF;
using ObjQt::toQt;
@implementation QtCoreApplication
- initWithQObject: (QObject*)qObject
{
OF_INVALID_INIT_METHOD
}
- initWithQCoreApplication: (QCoreApplication*)qCoreApplication
{
return [super initWithQObject: qCoreApplication];
}
- (QCoreApplication*)qCoreApplication
{
return qobject_cast<QCoreApplication*>(_qObject);
}
- (OFString*)applicationName
{
return toOF(toQt(self)->applicationName());
}
- (void)setApplicationName: (OFString*)applicationName
{
toQt(self)->setApplicationName(toQt(applicationName));
}
- (OFString*)applicationVersion
{
return toOF(toQt(self)->applicationVersion());
}
- (void)installNativeEventFilter: (QAbstractNativeEventFilter*)filterObject
{
toQt(self)->installNativeEventFilter(filterObject);
}
- (void)setApplicationVersion: (OFString*)applicationVersion
{
toQt(self)->setApplicationVersion(toQt(applicationVersion));
}
- (OFString*)organizationDomain
{
return toOF(toQt(self)->organizationDomain());
}
- (void)setOrganizationDomain: (OFString*)organizationDomain
{
toQt(self)->setOrganizationDomain(toQt(organizationDomain));
}
- (OFString*)organizationName
{
return toOF(toQt(self)->organizationName());
}
- (void)setOrganizationName: (OFString*)organizationName
{
toQt(self)->setOrganizationName(toQt(organizationName));
}
- (void)quit
{
toQt(self)->quit();
}
- (bool)isQuitLockEnabled
{
return toQt(self)->isQuitLockEnabled();
}
- (void)setQuitLockEnabled: (bool)quitLockEnabled
{
toQt(self)->setQuitLockEnabled(quitLockEnabled);
}
- (void)removeNativeEventFilter: (QAbstractNativeEventFilter*)filterObject
{
toQt(self)->removeNativeEventFilter(filterObject);
}
- (bool)sendEvent: (QtEvent*)event
receiver: (QtObject*)receiver
{
return toQt(self)->notify(toQt(receiver), toQt(event));
}
@end

60
src/QtCore/QtEvent.h Normal file
View file

@ -0,0 +1,60 @@
/*
* Copyright (c) 2017, Jonathan Schleifer <js@heap.zone>
*
* https://heap.zone/git/objqt.git
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice is present in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#import <ObjFW/ObjFW.h>
#import "QtOwnershipManaging.h"
#include <QEvent>
@interface QtEvent: OFObject <QtOwnershipManaging>
{
QEvent *_qEvent;
bool _ownsEvent;
}
@property (readonly) QEvent *qEvent;
@property (getter=isAccepted) bool accepted;
@property (readonly, getter=isSpontaneous) bool spontaneous;
@property (readonly) QEvent::Type type;
+ (int)registerEventType: (int)hint;
- initWithQEvent: (QEvent*)qEvent;
- (void)accept;
- (void)ignore;
@end
namespace ObjQt {
static OF_INLINE QtEvent*
toOF(QEvent *qEvent)
{
return [[[QtEvent alloc] initWithQEvent: qEvent] autorelease];
}
static OF_INLINE QEvent*
toQt(QtEvent *event)
{
return [event qEvent];
}
}

96
src/QtCore/QtEvent.mm Normal file
View file

@ -0,0 +1,96 @@
/*
* Copyright (c) 2017, Jonathan Schleifer <js@heap.zone>
*
* https://heap.zone/git/objqt.git
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice is present in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#import "QtEvent.h"
@implementation QtEvent
@synthesize qEvent = _qEvent;
+ (int)registerEventType: (int)hint
{
return QEvent::registerEventType(hint);
}
- init
{
OF_INVALID_INIT_METHOD
}
- initWithQEvent: (QEvent*)qEvent
{
self = [super init];
_qEvent = qEvent;
return self;
}
- (void)dealloc
{
if (_ownsEvent)
delete _qEvent;
[super dealloc];
}
- (void)takeOwnership
{
OF_ENSURE(!_ownsEvent);
_ownsEvent = true;
}
- (void)giveUpOwnership
{
OF_ENSURE(_ownsEvent);
_ownsEvent = false;
}
- (void)accept
{
_qEvent->accept();
}
- (void)ignore
{
_qEvent->ignore();
}
- (bool)isAccepted
{
return _qEvent->isAccepted();
}
- (void)setAccepted: (bool)accepted
{
_qEvent->setAccepted(accepted);
}
- (bool)isSpontaneous
{
return _qEvent->spontaneous();
}
- (QEvent::Type)type
{
return _qEvent->type();
}
@end

98
src/QtCore/QtObject.h Normal file
View file

@ -0,0 +1,98 @@
/*
* Copyright (c) 2017, Jonathan Schleifer <js@heap.zone>
*
* https://heap.zone/git/objqt.git
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice is present in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#import <ObjFW/ObjFW.h>
#import "QtOwnershipManaging.h"
#include <QObject>
@class QtEvent;
@class QtThread;
@interface QtObject: OFObject <QtOwnershipManaging>
{
QObject *_qObject;
bool _ownsObject;
}
@property (readonly) QObject *qObject;
@property (readonly) const QMetaObject *metaObject;
@property (retain) QtObject *parent;
@property (copy) OFString *objectName;
- initWithQObject: (QObject*)qObject;
- (bool)setBlockSignals: (bool)block;
- (OFArray OF_GENERIC(QtObject*)*)children;
- (QMetaObject::Connection)connectSignal: (OFString*)signal
sender: (QtObject*)sender
method: (OFString*)method
type: (Qt::ConnectionType)type;
- (bool)disconnectSignal: (OFString*)signal
receiver: (QtObject*)receiver
method: (OFString*)method;
- (bool)disconnectAllSignalsForReceiver: (QtObject*)receiver
method: (OFString*)method;
- (void)dumpObjectInfo;
- (void)dumpObjectTree;
- (OFArray OF_GENERIC(OFDataArray*)*)dynamicPropertyNames;
- (bool)handleEvent: (QtEvent*)event;
- (bool)filterEvent: (QtEvent*)event
forObject: (QtObject*)watched;
// MISSING: T findChild(const QString &name = QString(),
// Qt::FindChildOptions options = Qt::FindChildrenRecursively) const;
// MISSING QList<T> findChildren(const QString &name = QString(),
// Qt::FindChildOptions options = Qt::FindChildrenRecursively) const;
// MISSING: QList<T> findChildren(const QRegExp &regExp,
// Qt::FindChildOptions options = Qt::FindChildrenRecursively) const;
- (bool)inheritsClassWithName: (OFString*)className;
- (void)installEventFilter: (QtObject*)filterObj;
- (bool)isWidgetType;
- (bool)isWindowType;
- (void)killTimerWithID: (int)ID;
- (void)moveToThread: (QtThread*)targetThread;
- (QVariant)propertyForName: (OFString*)name;
- (void)removeEventFilter: (QtObject*)obj;
- (bool)setProperty: (QVariant&)value
forName: (OFString*)name;
- (bool)signalsBlocked;
- (int)startTimerWithInterval: (int)interval
type: (Qt::TimerType)type;
- (QtThread*)thread;
- (void)deleteLater;
@end
namespace ObjQt {
static OF_INLINE QtObject*
toOF(QObject *qObject)
{
return [[[QtObject alloc] initWithQObject: qObject] autorelease];
}
static OF_INLINE QObject*
toQt(QtObject *object)
{
return [object qObject];
}
}

247
src/QtCore/QtObject.mm Normal file
View file

@ -0,0 +1,247 @@
/*
* Copyright (c) 2017, Jonathan Schleifer <js@heap.zone>
*
* https://heap.zone/git/objqt.git
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice is present in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#import "QtObject.h"
#import "QtEvent.h"
#import "QtThread.h"
#import "OFString+QString.h"
#import "OFDataArray+QByteArray.h"
#include <QVariant>
using ObjQt::toOF;
using ObjQt::toQt;
@implementation QtObject
@synthesize qObject = _qObject;
- init
{
OF_INVALID_INIT_METHOD
}
- initWithQObject: (QObject*)qObject
{
self = [super init];
_qObject = qObject;
return self;
}
- (void)dealloc
{
if (_ownsObject)
delete _qObject;
[super dealloc];
}
- (void)takeOwnership
{
OF_ENSURE(!_ownsObject);
_ownsObject = true;
}
- (void)giveUpOwnership
{
OF_ENSURE(_ownsObject);
_ownsObject = false;
}
- (OFString*)objectName
{
return toOF(_qObject->objectName());
}
- (void)setObjectName: (OFString*)objectName
{
_qObject->setObjectName(toQt(objectName));
}
- (bool)setBlockSignals: (bool)block
{
return _qObject->blockSignals(block);
}
- (OFArray OF_GENERIC(QtObject*)*)children
{
const QObjectList &qChildren = _qObject->children();
OFMutableArray *children = [OFMutableArray arrayWithCapacity:
qChildren.count()];
void *pool = objc_autoreleasePoolPush();
for (QObject *qChild: qChildren)
[children addObject: toOF(qChild)];
[children makeImmutable];
objc_autoreleasePoolPop(pool);
return children;
}
- (QMetaObject::Connection)connectSignal: (OFString*)signal
sender: (QtObject*)sender
method: (OFString*)method
type: (Qt::ConnectionType)type
{
return _qObject->connect(toQt(sender),
[signal UTF8String], [method UTF8String], type);
}
- (bool)disconnectSignal: (OFString*)signal
receiver: (QtObject*)receiver
method: (OFString*)method
{
return _qObject->disconnect([signal UTF8String], toQt(receiver),
[method UTF8String]);
}
- (bool)disconnectAllSignalsForReceiver: (QtObject*)receiver
method: (OFString*)method
{
return _qObject->disconnect(toQt(receiver), [method UTF8String]);
}
- (void)dumpObjectInfo
{
_qObject->dumpObjectInfo();
}
- (void)dumpObjectTree
{
_qObject->dumpObjectTree();
}
- (OFArray OF_GENERIC(OFDataArray*)*)dynamicPropertyNames
{
const QList<QByteArray> &dynamicPropertyNames =
_qObject->dynamicPropertyNames();
OFMutableArray *ret =
[OFMutableArray arrayWithCapacity: dynamicPropertyNames.count()];
void *pool = objc_autoreleasePoolPush();
for (const QByteArray &dynamicPropertyName: dynamicPropertyNames)
[ret addObject: toOF(dynamicPropertyName)];
[ret makeImmutable];
objc_autoreleasePoolPop(pool);
return ret;
}
- (bool)handleEvent: (QtEvent*)event
{
return _qObject->event(toQt(event));
}
- (bool)filterEvent: (QtEvent*)event
forObject: (QtObject*)watched
{
return _qObject->eventFilter(toQt(watched), toQt(event));
}
- (bool)inheritsClassWithName: (OFString*)className
{
return _qObject->inherits([className UTF8String]);
}
- (void)installEventFilter: (QtObject*)filterObj
{
_qObject->installEventFilter(toQt(filterObj));
}
- (bool)isWidgetType
{
return _qObject->isWidgetType();
}
- (bool)isWindowType
{
return _qObject->isWindowType();
}
- (void)killTimerWithID: (int)ID
{
_qObject->killTimer(ID);
}
- (const QMetaObject*)metaObject
{
return _qObject->metaObject();
}
- (void)moveToThread: (QtThread*)targetThread
{
_qObject->moveToThread(toQt(targetThread));
}
- (QtObject*)parent
{
return toOF(_qObject->parent());
}
- (void)setParent: (QtObject*)parent
{
_qObject->setParent(toQt(parent));
}
- (QVariant)propertyForName: (OFString*)name
{
return _qObject->property([name UTF8String]);
}
- (void)removeEventFilter: (QtObject*)obj
{
_qObject->removeEventFilter(toQt(obj));
}
- (bool)setProperty: (QVariant&)value
forName: (OFString*)name
{
return _qObject->setProperty([name UTF8String], value);
}
- (bool)signalsBlocked
{
return _qObject->signalsBlocked();
}
- (int)startTimerWithInterval: (int)interval
type: (Qt::TimerType)type
{
return _qObject->startTimer(interval, type);
}
- (QtThread*)thread
{
return toOF(_qObject->thread());
}
- (void)deleteLater
{
OF_ENSURE(!_ownsObject);
_qObject->deleteLater();
}
@end

60
src/QtCore/QtThread.h Normal file
View file

@ -0,0 +1,60 @@
/*
* Copyright (c) 2017, Jonathan Schleifer <js@heap.zone>
*
* https://heap.zone/git/objqt.git
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice is present in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#import "QtObject.h"
#include <QThread>
@interface QtThread: QtObject
@property (readonly) QThread *qThread;
@property QAbstractEventDispatcher *eventDispatcher;
@property (readonly, getter=isFinished) bool finished;
@property (readonly, getter=isInterruptionRequested) bool interruptionRequested;
@property (readonly, getter=isRunning) bool running;
@property (readonly) int loopLevel;
@property QThread::Priority priority;
@property unsigned int stackSize;
- initWithQThread: (QThread*)qThread;
- (void)exitWithReturnCode: (int)returnCode;
- (void)requestInterruption;
- (bool)waitForMilliseconds: (unsigned long)time;
- (void)quit;
- (void)startWithPriority: (QThread::Priority)priority;
- (void)terminate;
@end
namespace ObjQt {
static OF_INLINE QtThread*
toOF(QThread *qThread)
{
return [[[QtThread alloc] initWithQThread: qThread] autorelease];
}
static OF_INLINE QThread*
toQt(QtThread *thread)
{
return [thread qThread];
}
}

122
src/QtCore/QtThread.mm Normal file
View file

@ -0,0 +1,122 @@
/*
* Copyright (c) 2017, Jonathan Schleifer <js@heap.zone>
*
* https://heap.zone/git/objqt.git
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice is present in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#import "QtThread.h"
using ObjQt::toQt;
@implementation QtThread: QtObject
- initWithQObject: (QObject*)qObject
{
OF_INVALID_INIT_METHOD
}
- initWithQThread: (QThread*)qThread
{
return [super initWithQObject: qThread];
}
- (QThread*)qThread
{
return qobject_cast<QThread*>(_qObject);
}
- (QAbstractEventDispatcher*)eventDispatcher
{
return toQt(self)->eventDispatcher();
}
- (void)setEventDispatcher: (QAbstractEventDispatcher*)eventDispatcher
{
toQt(self)->setEventDispatcher(eventDispatcher);
}
- (void)exitWithReturnCode: (int)returnCode
{
toQt(self)->exit(returnCode);
}
- (bool)isFinished
{
return toQt(self)->isFinished();
}
- (bool)isInterruptionRequested
{
return toQt(self)->isInterruptionRequested();
}
- (bool)isRunning
{
return toQt(self)->isRunning();
}
- (int)loopLevel
{
return toQt(self)->loopLevel();
}
- (QThread::Priority)priority
{
return toQt(self)->priority();
}
- (void)setPriority: (QThread::Priority)priority
{
toQt(self)->setPriority(priority);
}
- (void)requestInterruption
{
toQt(self)->requestInterruption();
}
- (unsigned int)stackSize
{
return toQt(self)->stackSize();
}
- (void)setStackSize: (unsigned int)stackSize
{
toQt(self)->setStackSize(stackSize);
}
- (bool)waitForMilliseconds: (unsigned long)time
{
return toQt(self)->wait(time);
}
- (void)quit
{
toQt(self)->quit();
}
- (void)startWithPriority: (QThread::Priority)priority
{
toQt(self)->start(priority);
}
- (void)terminate
{
toQt(self)->terminate();
}
@end

11
src/QtGui/Makefile Normal file
View file

@ -0,0 +1,11 @@
include ../../extra.mk
STATIC_PIC_LIB_NOINST = ${QTGUI_LIB_A}
STATIC_LIB_NOINST = ${QTGUI_A}
SRCS = QtGUIApplication.mm \
QtPaintDevice.mm
include ../../buildsys.mk
CPPFLAGS += -I. -I../QtCore -I../common

View file

@ -0,0 +1,62 @@
/*
* Copyright (c) 2017, Jonathan Schleifer <js@heap.zone>
*
* https://heap.zone/git/objqt.git
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice is present in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#import "QtCoreApplication.h"
#include <QGuiApplication>
@interface QtGUIApplication: QtCoreApplication
@property (readonly) QGuiApplication *qGuiApplication;
@property (copy) OFString *applicationDisplayName;
#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
@property (copy) OFString *desktopFileName;
#endif
@property Qt::LayoutDirection layoutDirection;
@property (readonly, copy) OFString *platformName;
@property (readonly) QScreen *primaryScreen;
@property bool quitsOnLastWindowClosed;
@property QIcon windowIcon;
- initWithQGuiApplication: (QGuiApplication*)qGuiApplication;
- (double)devicePixelRatio;
- (bool)isSavingSession;
- (bool)isSessionRestored;
- (OFString*)sessionID;
- (OFString*)sessionKey;
@end
namespace ObjQt {
static OF_INLINE QtGUIApplication*
toOF(QGuiApplication *qGuiApplication)
{
return [[[QtGUIApplication alloc]
initWithQGuiApplication: qGuiApplication] autorelease];
}
static OF_INLINE QGuiApplication*
toQt(QtGUIApplication *GUIApplication)
{
return [GUIApplication qGuiApplication];
}
}

View file

@ -0,0 +1,133 @@
/*
* Copyright (c) 2017, Jonathan Schleifer <js@heap.zone>
*
* https://heap.zone/git/objqt.git
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice is present in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#import "QtGUIApplication.h"
#import "OFString+QString.h"
#include <QIcon>
using ObjQt::toOF;
using ObjQt::toQt;
@implementation QtGUIApplication
- initWithQCoreApplication: (QCoreApplication*)qCoreApplication
{
OF_INVALID_INIT_METHOD
}
- initWithQGuiApplication: (QGuiApplication*)qGuiApplication
{
return [super initWithQCoreApplication: qGuiApplication];
}
- (QGuiApplication*)qGuiApplication
{
return qobject_cast<QGuiApplication*>(_qObject);
}
- (OFString*)applicationDisplayName
{
return toOF(toQt(self)->applicationDisplayName());
}
- (void)setApplicationDisplayName: (OFString*)applicationDisplayName
{
toQt(self)->setApplicationDisplayName(toQt(applicationDisplayName));
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
- (OFString*)desktopFileName
{
return toOF(toQt(self)->desktopFileName());
}
- (void)setDesktopFileName: (OFString*)desktopFileName
{
toQt(self)->setDesktopFileName(toQt(desktopFileName));
}
#endif
- (double)devicePixelRatio
{
return toQt(self)->devicePixelRatio();
}
- (bool)isSavingSession
{
return toQt(self)->isSavingSession();
}
- (bool)isSessionRestored
{
return toQt(self)->isSessionRestored();
}
- (Qt::LayoutDirection)layoutDirection
{
return toQt(self)->layoutDirection();
}
- (void)setLayoutDirection: (Qt::LayoutDirection)layoutDirection
{
toQt(self)->setLayoutDirection(layoutDirection);
}
- (OFString*)platformName
{
return toOF(toQt(self)->platformName());
}
- (QScreen*)primaryScreen
{
return toQt(self)->primaryScreen();
}
- (bool)quitsOnLastWindowClosed
{
return toQt(self)->quitOnLastWindowClosed();
}
- (void)setQuitsOnLastWindowClosed: (bool)quitsOnLastWindowClosed
{
toQt(self)->setQuitOnLastWindowClosed(quitsOnLastWindowClosed);
}
- (OFString*)sessionID
{
return toOF(toQt(self)->sessionId());
}
- (OFString*)sessionKey
{
return toOF(toQt(self)->sessionKey());
}
- (QIcon)windowIcon
{
return toQt(self)->windowIcon();
}
- (void)setWindowIcon: (QIcon)windowIcon
{
toQt(self)->setWindowIcon(windowIcon);
}
@end

59
src/QtGui/QtPaintDevice.h Normal file
View file

@ -0,0 +1,59 @@
/*
* Copyright (c) 2017, Jonathan Schleifer <js@heap.zone>
*
* https://heap.zone/git/objqt.git
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice is present in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#import <ObjFW/ObjFW.h>
#include <QPaintDevice>
@protocol QtPaintDevice
- (QPaintDevice*)qPaintDevice;
- (int)colorCount;
- (int)depth;
- (int)devicePixelRatio;
#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
- (double)devicePixelRatioF;
#endif
- (int)height;
- (int)heightMM;
- (int)logicalDPIX;
- (int)logicalDPIY;
- (QPaintEngine*)paintEngine;
- (bool)paintingActive;
- (int)physicalDPIX;
- (int)physicalDPIY;
- (int)width;
- (int)widthMM;
@end
@interface QtPaintDevice: OFObject <QtPaintDevice>
@property (readonly) QObject *qObject;
@end
namespace ObjQt {
static OF_INLINE QPaintDevice*
toQt(QtPaintDevice *paintDevice)
{
return [paintDevice qPaintDevice];
}
}

108
src/QtGui/QtPaintDevice.mm Normal file
View file

@ -0,0 +1,108 @@
/*
* Copyright (c) 2017, Jonathan Schleifer <js@heap.zone>
*
* https://heap.zone/git/objqt.git
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice is present in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#import "QtPaintDevice.h"
#include <QObject>
using ObjQt::toQt;
@implementation QtPaintDevice
@dynamic qObject;
- (QPaintDevice*)qPaintDevice
{
return dynamic_cast<QPaintDevice*>([self qObject]);
}
- (int)colorCount
{
return toQt(self)->colorCount();
}
- (int)depth
{
return toQt(self)->depth();
}
- (int)devicePixelRatio
{
return toQt(self)->devicePixelRatio();
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
- (double)devicePixelRatioF
{
return toQt(self)->devicePixelRatioF();
}
#endif
- (int)height
{
return toQt(self)->height();
}
- (int)heightMM
{
return toQt(self)->heightMM();
}
- (int)logicalDPIX
{
return toQt(self)->logicalDpiX();
}
- (int)logicalDPIY
{
return toQt(self)->logicalDpiY();
}
- (QPaintEngine*)paintEngine
{
return toQt(self)->paintEngine();
}
- (bool)paintingActive
{
return toQt(self)->paintingActive();
}
- (int)physicalDPIX
{
return toQt(self)->physicalDpiX();
}
- (int)physicalDPIY
{
return toQt(self)->physicalDpiY();
}
- (int)width
{
return toQt(self)->width();
}
- (int)widthMM
{
return toQt(self)->widthMM();
}
@end

12
src/QtWidgets/Makefile Normal file
View file

@ -0,0 +1,12 @@
include ../../extra.mk
STATIC_PIC_LIB_NOINST = ${QTWIDGETS_LIB_A}
STATIC_LIB_NOINST = ${QTWIDGETS_A}
SRCS = QtAction.mm \
QtApplication.mm \
QtWidget.mm
include ../../buildsys.mk
CPPFLAGS += -I. -I../QtCore -I../QtGui -I../common

82
src/QtWidgets/QtAction.h Normal file
View file

@ -0,0 +1,82 @@
/*
* Copyright (c) 2017, Jonathan Schleifer <js@heap.zone>
*
* https://heap.zone/git/objqt.git
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice is present in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#import "QtObject.h"
#include <QAction>
@class QtWidget;
@interface QtAction: QtObject
@property (readonly) QAction *qAction;
@property bool autoRepeat;
@property (getter=isCheckable) bool checkable;
@property (getter=isChecked) bool checked;
@property (getter=isEnabled) bool enabled;
@property QFont font;
@property QIcon icon;
@property (copy) OFString *iconText;
@property (getter=isIconVisibleInMenu) bool iconVisibleInMenu;
@property QAction::MenuRole menuRole;
@property QAction::Priority priority;
@property QKeySequence shortcut;
@property Qt::ShortcutContext shortcutContext;
@property (copy) OFString *statusTip;
@property (copy) OFString *text;
@property (copy) OFString *toolTip;
@property (getter=isVisible) bool visible;
@property (copy) OFString *whatsThis;
- initWithQAction: (QAction*)qAction;
- (QActionGroup*)actionGroup;
- (void)activate: (QAction::ActionEvent)event;
- (QList<QGraphicsWidget*>)associatedGraphicsWidgets;
- (OFArray OF_GENERIC(QtWidget*)*)associatedWidgets;
- (QVariant)data;
- (bool)isSeparator;
- (QMenu*)menu;
- (QtWidget*)parentWidget;
- (void)setActionGroup: (QActionGroup*)group;
- (void)setData: (const QVariant&)data;
- (void)setMenu: (QMenu*)menu;
- (void)setSeparator: (bool)isSeparator;
- (void)setShortcuts: (const QList<QKeySequence>&)shortcuts;
- (void)setShortcutsWithStandardKey: (QKeySequence::StandardKey)key;
- (QList<QKeySequence>)shortcuts;
- (bool)showStatusText: (QtWidget*)widget;
@end
namespace ObjQt {
static OF_INLINE QtAction*
toOF(QAction *qAction)
{
return [[[QtAction alloc] initWithQAction: qAction] autorelease];
}
static OF_INLINE QAction*
toQt(QtAction *action)
{
return [action qAction];
}
}

307
src/QtWidgets/QtAction.mm Normal file
View file

@ -0,0 +1,307 @@
/*
* Copyright (c) 2017, Jonathan Schleifer <js@heap.zone>
*
* https://heap.zone/git/objqt.git
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice is present in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#import "QtAction.h"
#import "QtWidget.h"
#import "OFString+QString.h"
using ObjQt::toOF;
using ObjQt::toQt;
@implementation QtAction
- initWithQObject: (QObject*)qObject
{
OF_INVALID_INIT_METHOD
}
- initWithQAction: (QAction*)qAction
{
return [super initWithQObject: qAction];
}
- (QAction*)qAction
{
return qobject_cast<QAction*>(_qObject);
}
- (bool)autoRepeat
{
return toQt(self)->autoRepeat();
}
- (void)setAutoRepeat: (bool)autoRepeat
{
toQt(self)->setAutoRepeat(autoRepeat);
}
- (bool)isCheckable
{
return toQt(self)->isCheckable();
}
- (void)setCheckable: (bool)checkable
{
toQt(self)->setCheckable(checkable);
}
- (bool)isChecked
{
return toQt(self)->isChecked();
}
- (void)setChecked: (bool)checked
{
toQt(self)->setChecked(checked);
}
- (bool)isEnabled
{
return toQt(self)->isEnabled();
}
- (void)setEnabled: (bool)enabled
{
toQt(self)->setEnabled(enabled);
}
- (QFont)font
{
return toQt(self)->font();
}
- (void)setFont: (QFont)font
{
toQt(self)->setFont(font);
}
- (QIcon)icon
{
return toQt(self)->icon();
}
- (void)setIcon: (QIcon)icon
{
toQt(self)->setIcon(icon);
}
- (OFString*)iconText
{
return toOF(toQt(self)->iconText());
}
- (void)setIconText: (OFString*)iconText
{
toQt(self)->setIconText(toQt(iconText));
}
- (bool)isIconVisibleInMenu
{
return toQt(self)->isIconVisibleInMenu();
}
- (void)setIconVisibleInMenu: (bool)iconVisibleInMenu
{
toQt(self)->setIconVisibleInMenu(iconVisibleInMenu);
}
- (QAction::MenuRole)menuRole
{
return toQt(self)->menuRole();
}
- (void)setMenuRole: (QAction::MenuRole)menuRole
{
toQt(self)->setMenuRole(menuRole);
}
- (QAction::Priority)priority
{
return toQt(self)->priority();
}
- (void)setPriority: (QAction::Priority)priority
{
toQt(self)->setPriority(priority);
}
- (QKeySequence)shortcut
{
return toQt(self)->shortcut();
}
- (void)setShortcut: (QKeySequence)shortcut
{
toQt(self)->setShortcut(shortcut);
}
- (Qt::ShortcutContext)shortcutContext
{
return toQt(self)->shortcutContext();
}
- (void)setShortcutContext: (Qt::ShortcutContext)shortcutContext
{
toQt(self)->setShortcutContext(shortcutContext);
}
- (OFString*)statusTip
{
return toOF(toQt(self)->statusTip());
}
- (void)setStatusTip: (OFString*)statusTip
{
toQt(self)->setStatusTip(toQt(statusTip));
}
- (OFString*)text
{
return toOF(toQt(self)->text());
}
- (void)setText: (OFString*)text
{
toQt(self)->setText(toQt(text));
}
- (OFString*)toolTip
{
return toOF(toQt(self)->toolTip());
}
- (void)setToolTip: (OFString*)toolTip
{
toQt(self)->setToolTip(toQt(toolTip));
}
- (bool)isVisible
{
return toQt(self)->isVisible();
}
- (void)setVisible: (bool)visible
{
toQt(self)->setVisible(visible);
}
- (OFString*)whatsThis
{
return toOF(toQt(self)->whatsThis());
}
- (void)setWhatsThis: (OFString*)whatsThis
{
toQt(self)->setWhatsThis(toQt(whatsThis));
}
- (QActionGroup*)actionGroup
{
return toQt(self)->actionGroup();
}
- (void)activate: (QAction::ActionEvent)event
{
toQt(self)->activate(event);
}
- (QList<QGraphicsWidget*>)associatedGraphicsWidgets
{
return toQt(self)->associatedGraphicsWidgets();
}
- (OFArray OF_GENERIC(QtWidget*)*)associatedWidgets
{
const QList<QWidget*> &widgets = toQt(self)->associatedWidgets();
OFMutableArray *ret =
[OFMutableArray arrayWithCapacity: widgets.count()];
void *pool = objc_autoreleasePoolPush();
for (QWidget *widget: widgets)
[ret addObject: toOF(widget)];
[ret makeImmutable];
objc_autoreleasePoolPop(pool);
return ret;
}
- (QVariant)data
{
return toQt(self)->data();
}
- (bool)isSeparator
{
return toQt(self)->isSeparator();
}
- (QMenu*)menu
{
return toQt(self)->menu();
}
- (QtWidget*)parentWidget
{
return toOF(toQt(self)->parentWidget());
}
- (void)setActionGroup: (QActionGroup*)group
{
toQt(self)->setActionGroup(group);
}
- (void)setData: (const QVariant&)userData
{
toQt(self)->setData(userData);
}
- (void)setMenu: (QMenu*)menu
{
toQt(self)->setMenu(menu);
}
- (void)setSeparator: (bool)isSeparator
{
toQt(self)->setSeparator(isSeparator);
}
- (void)setShortcuts: (const QList<QKeySequence>&)shortcuts
{
toQt(self)->setShortcuts(shortcuts);
}
- (void)setShortcutsWithStandardKey: (QKeySequence::StandardKey)key
{
toQt(self)->setShortcuts(key);
}
- (QList<QKeySequence>)shortcuts
{
return toQt(self)->shortcuts();
}
- (bool)showStatusText: (QtWidget*)widget
{
return toQt(self)->showStatusText(toQt(widget));
}
@end

View file

@ -0,0 +1,59 @@
/*
* Copyright (c) 2017, Jonathan Schleifer <js@heap.zone>
*
* https://heap.zone/git/objqt.git
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice is present in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#import "QtGUIApplication.h"
#include <QApplication>
@interface QtApplication: QtGUIApplication
@property (readonly) QApplication *qApplication;
@property bool autoSIPEnabled;
@property int cursorFlashTime;
@property int doubleClickInterval;
@property of_dimension_t globalStrut;
@property int keyboardInputInterval;
@property int startDragDistance;
@property int startDragTime;
@property (copy) OFString *styleSheet;
@property int wheelScrollLines;
- initWithQApplication: (QApplication*)qApplication;
- (void)aboutQt;
- (void)closeAllWindows;
@end
namespace ObjQt {
static OF_INLINE QtApplication*
toOF(QApplication *qApplication)
{
return [[[QtApplication alloc]
initWithQApplication: qApplication] autorelease];
}
static OF_INLINE QApplication*
toQt(QtApplication *application)
{
return [application qApplication];
}
}

View file

@ -0,0 +1,146 @@
/*
* Copyright (c) 2017, Jonathan Schleifer <js@heap.zone>
*
* https://heap.zone/git/objqt.git
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice is present in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#import "QtApplication.h"
#import "OFString+QString.h"
#import "helpers.h"
using ObjQt::toOF;
using ObjQt::toQt;
@implementation QtApplication
- initWithQGuiApplication: (QGuiApplication*)qGuiApplication
{
OF_INVALID_INIT_METHOD
}
- initWithQApplication: (QApplication*)qApplication
{
return [super initWithQGuiApplication: qApplication];
}
- (QApplication*)qApplication
{
return qobject_cast<QApplication*>(_qObject);
}
- (bool)autoSIPEnabled
{
return toQt(self)->autoSipEnabled();
}
- (void)setAutoSIPEnabled: (bool)autoSIPEnabled
{
toQt(self)->setAutoSipEnabled(autoSIPEnabled);
}
- (int)cursorFlashTime
{
return toQt(self)->cursorFlashTime();
}
- (void)setCursorFlashTime: (int)cursorFlashTime
{
toQt(self)->setCursorFlashTime(cursorFlashTime);
}
- (int)doubleClickInterval
{
return toQt(self)->doubleClickInterval();
}
- (void)setDoubleClickInterval: (int)doubleClickInterval
{
toQt(self)->setDoubleClickInterval(doubleClickInterval);
}
- (of_dimension_t)globalStrut
{
return toOF(toQt(self)->globalStrut());
}
- (void)setGlobalStrut: (of_dimension_t)globalStrut
{
toQt(self)->setGlobalStrut(toQt(globalStrut));
}
- (int)keyboardInputInterval
{
return toQt(self)->keyboardInputInterval();
}
- (void)setKeyboardInputInterval: (int)keyboardInputInterval
{
toQt(self)->setKeyboardInputInterval(keyboardInputInterval);
}
- (int)startDragDistance
{
return toQt(self)->startDragDistance();
}
- (void)setStartDragDistance: (int)startDragDistance
{
toQt(self)->setStartDragDistance(startDragDistance);
}
- (int)startDragTime
{
return toQt(self)->startDragTime();
}
- (void)setStartDragTime: (int)startDragTime
{
toQt(self)->setStartDragTime(startDragTime);
}
- (OFString*)styleSheet
{
return toOF(toQt(self)->styleSheet());
}
- (void)setStyleSheet: (OFString*)styleSheet
{
toQt(self)->setStyleSheet(toQt(styleSheet));
}
- (int)wheelScrollLines
{
return toQt(self)->wheelScrollLines();
}
- (void)setWheelScrollLines: (int)wheelScrollLines
{
toQt(self)->setWheelScrollLines(wheelScrollLines);
}
- (void)aboutQt
{
toQt(self)->aboutQt();
}
- (void)closeAllWindows
{
toQt(self)->closeAllWindows();
}
@end

240
src/QtWidgets/QtWidget.h Normal file
View file

@ -0,0 +1,240 @@
/*
* Copyright (c) 2017, Jonathan Schleifer <js@heap.zone>
*
* https://heap.zone/git/objqt.git
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice is present in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#import "QtObject.h"
#import "QtPaintDevice.h"
#include <QWidget>
@class QtAction;
@interface QtWidget: QtObject
@property (readonly) QWidget *qWidget;
@property bool acceptDrops;
@property (copy) OFString *accessibleDescription;
@property (copy) OFString *accessibleName;
@property bool autoFillBackground;
@property of_dimension_t baseSize;
@property (readonly) of_rectangle_t childrenRect;
@property (readonly) QRegion childrenRegion;
@property Qt::ContextMenuPolicy contextMenuPolicy;
@property QCursor cursor;
@property (getter=isEnabled) bool enabled;
@property Qt::FocusPolicy focusPolicy;
@property const QFont &font;
@property (readonly) of_rectangle_t frameGeometry;
@property (readonly) of_dimension_t frameSize;
@property (readonly, getter=isFullScreen) bool fullScreen;
@property of_rectangle_t geometry;
@property (readonly) int height;
@property Qt::InputMethodHints inputMethodHints;
@property (readonly) bool isActiveWindow;
@property Qt::LayoutDirection layoutDirection;
@property QLocale locale;
@property (readonly, getter=isMaximized) bool maximized;
@property int maximumHeight;
@property of_dimension_t maximumSize;
@property int maximumWidth;
@property (readonly, getter=isMinimized) bool minimized;
@property int minimumHeight;
@property of_dimension_t minimumSize;
@property (readonly) of_dimension_t minimumSizeHint;
@property int minimumWidth;
@property (readonly, getter=isModal) bool modal;
@property (getter=hasMouseTracking) bool mouseTracking;
@property (readonly) of_rectangle_t normalGeometry;
@property const QPalette &palette;
@property (setter=moveToPosition:) of_point_t pos;
@property (readonly) of_rectangle_t rect;
@property (setter=resizeTo:) of_dimension_t size;
@property (readonly) of_dimension_t sizeHint;
@property of_dimension_t sizeIncrement;
@property QSizePolicy sizePolicy;
@property (copy) OFString *statusTip;
@property (copy) OFString *styleSheet;
@property (copy) OFString *toolTip;
@property int toolTipDuration;
@property bool updatesEnabled;
@property (getter=isVisible) bool visible;
@property (copy) OFString *whatsThis;
@property (readonly) int width;
@property Qt::WindowFlags windowFlags;
@property QIcon windowIcon;
@property Qt::WindowModality windowModality;
@property (getter=isWindowModified) bool windowModified;
@property double windowOpacity;
@property (copy) OFString *windowTitle;
@property (readonly) int x;
@property (readonly) int y;
- initWithQWidget: (QWidget*)qWidget;
- (OFArray OF_GENERIC(QtAction*)*)actions;
- (void)activateWindow;
- (void)addAction: (QtAction*)action;
- (void)addActions: (OFArray OF_GENERIC(QtAction*)*)actions;
- (void)adjustSize;
- (QPalette::ColorRole)backgroundRole;
- (QBackingStore*)backingStore;
- (QtWidget*)childAt: (of_point_t)point;
- (void)clearFocus;
- (void)clearMask;
- (QMargins)contentsMargins;
- (of_rectangle_t)contentsRect;
- (WId)effectiveWinID;
- (void)ensurePolished;
- (QtWidget*)focusProxy;
- (QtWidget*)focusWidget;
- (QFontInfo)fontInfo;
- (QFontMetrics)fontMetrics;
- (QPalette::ColorRole)foregroundRole;
- (QPixmap)grabRectangle: (of_rectangle_t)rectangle;
- (void)grabGesture: (Qt::GestureType)gesture;
- (void)grabGesture: (Qt::GestureType)gesture
flags: (Qt::GestureFlags)flags;
- (void)grabKeyboard;
- (void)grabMouse;
- (void)grabMouseWithCursor: (const QCursor&)cursor;
- (int)grabShortcutWithKey: (const QKeySequence&)key;
- (int)grabShortcutWithKey: (const QKeySequence&)key
context: (Qt::ShortcutContext)context;
- (QGraphicsEffect*)graphicsEffect;
- (QGraphicsProxyWidget*)graphicsProxyWidget;
#ifdef QT_KEYPAD_NAVIGATION
- (bool)hasEditFocus;
#endif
- (bool)hasFocus;
- (bool)hasHeightForWidth;
- (int)heightForWidth: (int)w;
- (QVariant)queryInputMethod: (Qt::InputMethodQuery)query;
- (void)insertAction: (QtAction*)action
before: (QtAction*)before;
- (void)insertActions: (OFArray OF_GENERIC(QtAction*)*)actions
before: (QtAction*)before;
- (bool)isAncestorOf: (QtWidget*)child;
- (bool)isEnabledTo: (QtWidget*)ancestor;
- (bool)isHidden;
- (bool)isVisibleTo: (QtWidget*)ancestor;
- (bool)isWindow;
- (of_point_t)mapPosition: (of_point_t)pos
from: (QtWidget*)parent;
- (of_point_t)mapPositionFromGlobal: (of_point_t)pos;
- (of_point_t)mapPositionFromParent: (of_point_t)pos;
- (of_point_t)mapPosition: (of_point_t)pos
to: (QtWidget*)parent;
- (of_point_t)mapPositionToGlobal: (of_point_t)pos;
- (of_point_t)mapPositionToParent: (of_point_t)pos;
- (QRegion)mask;
- (QtWidget*)nativeParentWidget;
- (QtWidget*)nextInFocusChain;
- (void)overrideWindowFlags: (Qt::WindowFlags)flags;
- (QtWidget*)parentWidget;
- (QtWidget*)previousInFocusChain;
- (void)releaseKeyboard;
- (void)releaseMouse;
- (void)releaseShortcut: (int)ID;
- (void)removeAction: (QtAction*)action;
- (void)renderIntoPaintDevice: (QtObject <QtPaintDevice>*)target
targetOffset: (of_point_t)targetOffset
sourceRegion: (QRegion)sourceRegion;
- (void)renderIntoPaintDevice: (QtObject <QtPaintDevice>*)target
targetOffset: (of_point_t)targetOffset
sourceRegion: (QRegion)sourceRegion
flags: (QWidget::RenderFlags)renderFlags;
- (void)renderIntoPainter: (QPainter*)target
targetOffset: (of_point_t)targetOffset
sourceRegion: (QRegion)sourceRegion;
- (void)renderIntoPainter: (QPainter*)target
targetOffset: (of_point_t)targetOffset
sourceRegion: (QRegion)sourceRegion
flags: (QWidget::RenderFlags)renderFlags;
- (void)repaintInRectangle: (of_rectangle_t)rect;
- (void)repaintInRegion: (const QRegion&)region;
- (bool)restoreGeometry: (OFDataArray*)geometry;
- (OFDataArray*)saveGeometry;
- (void)scrollRight: (int)dx
down: (int)dy;
- (void)scrollRight: (int)dx
down: (int)dy
inRectangle: (of_rectangle_t)rect;
- (void)setAttribute: (Qt::WidgetAttribute)attribute
to: (bool)on;
#ifdef QT_KEYPAD_NAVIGATION
- (void)setEditFocus: (bool)enable;
#endif
- (void)setFixedHeight: (int)height;
- (void)setFixedSize: (of_dimension_t)size;
- (void)setFixedWidth: (int)width;
- (void)setFocus: (Qt::FocusReason)reason;
- (void)setFocusProxy: (QtWidget*)widget;
- (void)setForegroundRole: (QPalette::ColorRole)role;
- (void)setGraphicsEffect: (QGraphicsEffect*)effect;
- (void)setLayout: (QLayout*)layout;
- (void)setMaskFromBitmap: (const QBitmap&)bitmap;
- (void)setMask: (const QRegion&)region;
- (void)setParent: (QtWidget*)parent;
- (void)setParent: (QtWidget*)parent
flags: (Qt::WindowFlags)flags;
- (void)setAutoRepeat: (bool)enable
forShortcut: (int)ID;
- (void)setEnabled: (bool)enable
forShortcut: (int)ID;
- (void)setStyle: (QStyle*)style;
- (void)setWindowRole: (OFString*)role;
- (void)setWindowState: (Qt::WindowStates)windowState;
- (void)stackUnder: (QtWidget*)widget;
- (QStyle*)style;
- (bool)testAttribute: (Qt::WidgetAttribute)attribute;
- (bool)isUnderMouse;
- (void)ungrabGesture: (Qt::GestureType)gesture;
- (void)unsetCursor;
- (void)unsetLayoutDirection;
- (void)unsetLocale;
- (void)updateInRectangle: (of_rectangle_t)rect;
- (void)updateInRegion: (const QRegion&)region;
- (void)updateGeometry;
- (QRegion)visibleRegion;
- (WId)winID;
- (QtWidget*)window;
- (QWindow*)windowHandle;
- (OFString*)windowRole;
- (Qt::WindowStates)windowState;
- (Qt::WindowType)windowType;
@end
@interface QtWidget (QtPaintDevice) <QtPaintDevice>
@end
namespace ObjQt {
static OF_INLINE QtWidget*
toOF(QWidget *qWidget)
{
return [[[QtWidget alloc] initWithQWidget: qWidget] autorelease];
}
static OF_INLINE QWidget*
toQt(QtWidget *widget)
{
return [widget qWidget];
}
}

1114
src/QtWidgets/QtWidget.mm Normal file

File diff suppressed because it is too large Load diff

11
src/common/Makefile Normal file
View file

@ -0,0 +1,11 @@
include ../../extra.mk
STATIC_PIC_LIB_NOINST = ${COMMON_LIB_A}
STATIC_LIB_NOINST = ${COMMON_A}
SRCS = OFDataArray+QByteArray.mm \
OFString+QString.mm
include ../../buildsys.mk
CPPFLAGS += -I. -I../QtCore

View file

@ -0,0 +1,46 @@
/*
* Copyright (c) 2017, Jonathan Schleifer <js@heap.zone>
*
* https://heap.zone/git/objqt.git
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice is present in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#import <ObjFW/ObjFW.h>
#include <QByteArray>
@interface OFDataArray (QByteArray)
+ (instancetype)dataArrayWithQByteArray: (const QByteArray&)qByteArray;
- (QByteArray)qByteArray;
@end
namespace ObjQt {
static OF_INLINE OFDataArray*
toOF(const QByteArray &qByteArray)
{
return [OFDataArray dataArrayWithQByteArray: qByteArray];
}
static OF_INLINE QByteArray
toQt(OFDataArray *dataArray)
{
return [dataArray qByteArray];
}
}

View file

@ -0,0 +1,39 @@
/*
* Copyright (c) 2017, Jonathan Schleifer <js@heap.zone>
*
* https://heap.zone/git/objqt.git
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice is present in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#import "OFDataArray+QByteArray.h"
@implementation OFDataArray (QByteArray)
+ (instancetype)dataArrayWithQByteArray: (const QByteArray&)qByteArray
{
OFDataArray *ret = [OFDataArray dataArray];
[ret addItems: qByteArray.data()
count: qByteArray.count()];
return ret;
}
- (QByteArray)qByteArray
{
return QByteArray((char*)[self items], [self count] * [self itemSize]);
}
@end

View file

@ -0,0 +1,47 @@
/*
* Copyright (c) 2017, Jonathan Schleifer <js@heap.zone>
*
* https://heap.zone/git/objqt.git
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice is present in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#import <ObjFW/ObjFW.h>
#include <QString>
@interface OFString (QString)
+ (instancetype)stringWithQString: (const QString&)qString;
- initWithQString: (const QString&)qString;
- (QString)qString;
@end
namespace ObjQt {
static OF_INLINE OFString*
toOF(const QString &qString)
{
return [OFString stringWithQString: qString];
}
static OF_INLINE QString
toQt(OFString *string)
{
return [string qString];
}
}

View file

@ -0,0 +1,52 @@
/*
* Copyright (c) 2017, Jonathan Schleifer <js@heap.zone>
*
* https://heap.zone/git/objqt.git
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice is present in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#import "OFString+QString.h"
@implementation OFString (QString)
+ stringWithQString: (const QString&)qString
{
return [[[self alloc] initWithQString: qString] autorelease];
}
- initWithQString: (const QString&)qString
{
static_assert(sizeof(QChar) == sizeof(of_char16_t),
"QChar and of_char16_t have a different size!");
return [self initWithUTF16String: (of_char16_t*)qString.data()
length: qString.length()];
}
- (QString)qString
{
static_assert(sizeof(of_char16_t) == sizeof(QChar),
"of_char16_t and QChar have a different size!");
void *pool = objc_autoreleasePoolPush();
QString ret = QString((QChar*)[self UTF16String]);
objc_autoreleasePoolPop(pool);
return ret;
}
@end

View file

@ -0,0 +1,28 @@
/*
* Copyright (c) 2017, Jonathan Schleifer <js@heap.zone>
*
* https://heap.zone/git/objqt.git
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice is present in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#import <ObjFW/ObjFW.h>
@protocol QtOwnershipManaging
- (void)takeOwnership;
- (void)giveUpOwnership;
@end

75
src/common/helpers.h Normal file
View file

@ -0,0 +1,75 @@
/*
* Copyright (c) 2017, Jonathan Schleifer <js@heap.zone>
*
* https://heap.zone/git/objqt.git
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice is present in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#import <ObjFW/ObjFW.h>
#include <QSize>
#include <QRect>
#import "QtObject.h"
#import "QtAction.h"
#import "QtEvent.h"
#import "QtChildEvent.h"
#import "QtThread.h"
#import "QtWidget.h"
namespace ObjQt {
static OF_INLINE of_point_t
toOF(const QPoint &qPoint)
{
return of_point(qPoint.x(), qPoint.y());
}
static OF_INLINE QPoint
toQt(of_point_t point)
{
return QPoint(point.x, point.y);
}
static OF_INLINE of_dimension_t
toOF(const QSize &qSize)
{
return of_dimension(qSize.width(), qSize.height());
}
static OF_INLINE QSize
toQt(of_dimension_t dimension)
{
return QSize(dimension.width, dimension.height);
}
static OF_INLINE of_rectangle_t
toOF(const QRect &qRect)
{
return of_rectangle(qRect.x(), qRect.y(),
qRect.width(), qRect.height());
}
static OF_INLINE QRect
toQt(of_rectangle_t rectangle)
{
return QRect(rectangle.origin.x, rectangle.origin.y,
rectangle.size.width, rectangle.size.height);
}
}