Index: ObjQt.pro ================================================================== --- ObjQt.pro +++ ObjQt.pro @@ -15,19 +15,23 @@ QtCore/QtCoreApplication.h \ QtCore/QtEvent.h \ QtCore/QtObject.h \ QtCore/QtThread.h \ QtGui/QtGuiApplication.h \ - QtWidgets/QtApplication.h + QtGui/QtPaintDevice.h \ + QtWidgets/QtApplication.h \ + QtWidgets/QtWidget.h SOURCES += QtCore/QtChildEvent.mm \ QtCore/QtCoreApplication.mm \ QtCore/QtEvent.mm \ QtCore/QtObject.mm \ QtCore/QtThread.mm \ QtGui/QtGuiApplication.mm \ - QtWidgets/QtApplication.mm + QtGui/QtPaintDevice.mm \ + QtWidgets/QtApplication.mm \ + QtWidgets/QtWidget.mm QMAKE_CXXFLAGS += $$system("objfw-config --cppflags --objcflags --cxxflags") QMAKE_CXXFLAGS_WARN_ON = -Wall \ -Werror \ -Wsemicolon-before-method-body \ ADDED QtGui/QtPaintDevice.h Index: QtGui/QtPaintDevice.h ================================================================== --- /dev/null +++ QtGui/QtPaintDevice.h @@ -0,0 +1,25 @@ +#import + +#include + +@protocol QtPaintDevice +- (QPaintDevice*)qPaintDevice; +- (int)colorCount; +- (int)depth; +- (int)devicePixelRatio; +- (double)devicePixelRatioF; +- (int)height; +- (int)heightMM; +- (int)logicalDPIX; +- (int)logicalDPIY; +- (QPaintEngine*)paintEngine; +- (bool)paintingActive; +- (int)physicalDPIX; +- (int)physicalDPIY; +- (int)width; +- (int)widthMM; +@end + +@interface QtPaintDevice: OFObject +@property (readonly) QObject *qObject; +@end ADDED QtGui/QtPaintDevice.mm Index: QtGui/QtPaintDevice.mm ================================================================== --- /dev/null +++ QtGui/QtPaintDevice.mm @@ -0,0 +1,82 @@ +#import "QtPaintDevice.h" + +#include + +@implementation QtPaintDevice +@dynamic qObject; + +- (QPaintDevice*)qPaintDevice +{ + return dynamic_cast([self qObject]); +} + +- (int)colorCount +{ + return [self qPaintDevice]->colorCount(); +} + +- (int)depth +{ + return [self qPaintDevice]->depth(); +} + +- (int)devicePixelRatio +{ + return [self qPaintDevice]->devicePixelRatio(); +} + +- (double)devicePixelRatioF +{ + return [self qPaintDevice]->devicePixelRatioF(); +} + +- (int)height +{ + return [self qPaintDevice]->height(); +} + +- (int)heightMM +{ + return [self qPaintDevice]->heightMM(); +} + +- (int)logicalDPIX +{ + return [self qPaintDevice]->logicalDpiX(); +} + +- (int)logicalDPIY +{ + return [self qPaintDevice]->logicalDpiY(); +} + +- (QPaintEngine*)paintEngine +{ + return [self qPaintDevice]->paintEngine(); +} + +- (bool)paintingActive +{ + return [self qPaintDevice]->paintingActive(); +} + +- (int)physicalDPIX +{ + return [self qPaintDevice]->physicalDpiX(); +} + +- (int)physicalDPIY +{ + return [self qPaintDevice]->physicalDpiY(); +} + +- (int)width +{ + return [self qPaintDevice]->width(); +} + +- (int)widthMM +{ + return [self qPaintDevice]->widthMM(); +} +@end Index: QtWidgets/QtApplication.h ================================================================== --- QtWidgets/QtApplication.h +++ QtWidgets/QtApplication.h @@ -5,11 +5,11 @@ @interface QtApplication: QtGuiApplication @property (readonly) QApplication *qApplication; @property bool autoSipEnabled; @property int cursorFlashTime; @property int doubleClickInterval; -@property QSize globalStrut; +@property of_dimension_t globalStrut; @property int keyboardInputInterval; @property int startDragDistance; @property int startDragTime; @property (copy) OFString *styleSheet; @property int wheelScrollLines; Index: QtWidgets/QtApplication.mm ================================================================== --- QtWidgets/QtApplication.mm +++ QtWidgets/QtApplication.mm @@ -46,18 +46,18 @@ - (void)setDoubleClickInterval: (int)doubleClickInterval { [self qApplication]->setDoubleClickInterval(doubleClickInterval); } -- (QSize)globalStrut +- (of_dimension_t)globalStrut { - return [self qApplication]->globalStrut(); + return QToOFDimension([self qApplication]->globalStrut()); } -- (void)setGlobalStrut: (QSize)globalStrut +- (void)setGlobalStrut: (of_dimension_t)globalStrut { - [self qApplication]->setGlobalStrut(globalStrut); + [self qApplication]->setGlobalStrut(OFToQSize(globalStrut)); } - (int)keyboardInputInterval { return [self qApplication]->keyboardInputInterval(); ADDED QtWidgets/QtWidget.h Index: QtWidgets/QtWidget.h ================================================================== --- /dev/null +++ QtWidgets/QtWidget.h @@ -0,0 +1,76 @@ +#import "QtObject.h" +#import "QtPaintDevice.h" + +#include + +@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 (readonly, getter=hasFocus) bool focus; +@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 (copy) OFString *windowFilePath; +@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; + +// TODO: Member functions + +- initWithQWidget: (QWidget*)qWidget; +- (void)unsetCursor; +- (void)unsetLayoutDirection; +- (void)unsetLocale; +@end + +@interface QtWidget (QtPaintDevice) +@end ADDED QtWidgets/QtWidget.mm Index: QtWidgets/QtWidget.mm ================================================================== --- /dev/null +++ QtWidgets/QtWidget.mm @@ -0,0 +1,530 @@ +#import "QtWidget.h" + +#import "helpers.h" + +#include +#include + +@implementation QtWidget ++ (void)initialize +{ + if (self == [QtWidget class]) + [self inheritMethodsFromClass: [QtPaintDevice class]]; +} + +- initWithQWidget: (QWidget*)qWidget +{ + return [super initWithQObject: qWidget]; +} + +- (QWidget*)qWidget +{ + return qobject_cast(_qObject); +} + +- (bool)acceptDrops +{ + return [self qWidget]->acceptDrops(); +} + +- (void)setAcceptDrops: (bool)acceptDrops +{ + [self qWidget]->setAcceptDrops(acceptDrops); +} + +- (OFString*)accessibleDescription +{ + return QToOFString([self qWidget]->accessibleDescription()); +} + +- (void)setAccessibleDescription: (OFString*)accessibleDescription +{ + [self qWidget]->setAccessibleDescription( + OFToQString(accessibleDescription)); +} + +- (OFString*)accessibleName +{ + return QToOFString([self qWidget]->accessibleName()); +} + +- (void)setAccessibleName: (OFString*)accessibleName +{ + [self qWidget]->setAccessibleName(OFToQString(accessibleName)); +} + +- (bool)autoFillBackground +{ + return [self qWidget]->autoFillBackground(); +} + +- (void)setAutoFillBackground: (bool)autoFillBackground +{ + [self qWidget]->setAutoFillBackground(autoFillBackground); +} + +- (of_dimension_t)baseSize +{ + return QToOFDimension([self qWidget]->baseSize()); +} + +- (void)setBaseSize: (of_dimension_t)baseSize +{ + [self qWidget]->setBaseSize(OFToQSize(baseSize)); +} + +- (of_rectangle_t)childrenRect +{ + return QToOFRectangle([self qWidget]->childrenRect()); +} + +- (QRegion)childrenRegion +{ + return [self qWidget]->childrenRegion(); +} + +- (Qt::ContextMenuPolicy)contextMenuPolicy +{ + return [self qWidget]->contextMenuPolicy(); +} + +- (void)setContextMenuPolicy: (Qt::ContextMenuPolicy)contextMenuPolicy +{ + [self qWidget]->setContextMenuPolicy(contextMenuPolicy); +} + +- (QCursor)cursor +{ + return [self qWidget]->cursor(); +} + +- (void)setCursor: (QCursor)cursor +{ + [self qWidget]->setCursor(cursor); +} + +- (void)unsetCursor +{ + [self qWidget]->unsetCursor(); +} + +- (bool)isEnabled +{ + return [self qWidget]->isEnabled(); +} + +- (void)setEnabled: (bool)enabled +{ + [self qWidget]->setEnabled(enabled); +} + +- (bool)hasFocus +{ + return [self qWidget]->hasFocus(); +} + +- (Qt::FocusPolicy)focusPolicy +{ + return [self qWidget]->focusPolicy(); +} + +- (void)setFocusPolicy: (Qt::FocusPolicy)focusPolicy +{ + [self qWidget]->setFocusPolicy(focusPolicy); +} + +- (const QFont&)font +{ + return [self qWidget]->font(); +} + +- (void)setFont: (const QFont&)font +{ + [self qWidget]->setFont(font); +} + +- (of_rectangle_t)frameGeometry +{ + return QToOFRectangle([self qWidget]->frameGeometry()); +} + +- (of_dimension_t)frameSize +{ + return QToOFDimension([self qWidget]->frameSize()); +} + +- (bool)isFullScreen +{ + return [self qWidget]->isFullScreen(); +} + +- (of_rectangle_t)geometry +{ + return QToOFRectangle([self qWidget]->geometry()); +} + +- (void)setGeometry: (of_rectangle_t)geometry +{ + [self qWidget]->setGeometry(OFToQRect(geometry)); +} + +- (int)height +{ + return [self qWidget]->height(); +} + +- (Qt::InputMethodHints)inputMethodHints +{ + return [self qWidget]->inputMethodHints(); +} + +- (void)setInputMethodHints: (Qt::InputMethodHints)inputMethodHints +{ + [self qWidget]->setInputMethodHints(inputMethodHints); +} + +- (bool)isActiveWindow +{ + return [self qWidget]->isActiveWindow(); +} + +- (Qt::LayoutDirection)layoutDirection +{ + return [self qWidget]->layoutDirection(); +} + +- (void)setLayoutDirection: (Qt::LayoutDirection)layoutDirection +{ + [self qWidget]->setLayoutDirection(layoutDirection); +} + +- (void)unsetLayoutDirection +{ + [self qWidget]->unsetLayoutDirection(); +} + +- (QLocale)locale +{ + return [self qWidget]->locale(); +} + +- (void)setLocale: (QLocale)locale +{ + [self qWidget]->setLocale(locale); +} + +- (void)unsetLocale +{ + [self qWidget]->unsetLocale(); +} + +- (bool)isMaximized +{ + return [self qWidget]->isMaximized(); +} + +- (int)maximumHeight +{ + return [self qWidget]->maximumHeight(); +} + +- (void)setMaximumHeight: (int)maximumHeight +{ + [self qWidget]->setMaximumHeight(maximumHeight); +} + +- (of_dimension_t)maximumSize +{ + return QToOFDimension([self qWidget]->maximumSize()); +} + +- (void)setMaximumSize: (of_dimension_t)maximumSize +{ + [self qWidget]->setMaximumSize(OFToQSize(maximumSize)); +} + +- (int)maximumWidth +{ + return [self qWidget]->maximumWidth(); +} + +- (void)setMaximumWidth: (int)maximumWidth +{ + [self qWidget]->setMaximumWidth(maximumWidth); +} + +- (bool)isMinimized +{ + return [self qWidget]->isMinimized(); +} + +- (int)minimumHeight +{ + return [self qWidget]->minimumHeight(); +} + +- (void)setMinimumHeight: (int)minimumHeight +{ + [self qWidget]->setMinimumHeight(minimumHeight); +} + +- (of_dimension_t)minimumSize +{ + return QToOFDimension([self qWidget]->minimumSize()); +} + +- (void)setMinimumSize: (of_dimension_t)minimumSize +{ + [self qWidget]->setMinimumSize(OFToQSize(minimumSize)); +} + +- (of_dimension_t)minimumSizeHint +{ + return QToOFDimension([self qWidget]->minimumSizeHint()); +} + +- (int)minimumWidth +{ + return [self qWidget]->minimumWidth(); +} + +- (void)setMinimumWidth: (int)minimumWidth +{ + [self qWidget]->setMinimumWidth(minimumWidth); +} + +- (bool)isModal +{ + return [self qWidget]->isModal(); +} + +- (bool)hasMouseTracking +{ + return [self qWidget]->hasMouseTracking(); +} + +- (void)setMouseTracking: (bool)mouseTracking +{ + [self qWidget]->setMouseTracking(mouseTracking); +} + +- (of_rectangle_t)normalGeometry +{ + return QToOFRectangle([self qWidget]->normalGeometry()); +} + +- (const QPalette&)palette +{ + return [self qWidget]->palette(); +} + +- (void)setPalette: (const QPalette&)palette +{ + [self qWidget]->setPalette(palette); +} + +- (of_point_t)pos +{ + return QToOFPoint([self qWidget]->pos()); +} + +- (void)moveToPosition: (of_point_t)pos +{ + [self qWidget]->move(OFToQPoint(pos)); +} + +- (of_rectangle_t)rect +{ + return QToOFRectangle([self qWidget]->rect()); +} + +- (of_dimension_t)size +{ + return QToOFDimension([self qWidget]->size()); +} + +- (void)resizeTo: (of_dimension_t)size +{ + [self qWidget]->resize(OFToQSize(size)); +} + +- (of_dimension_t)sizeHint +{ + return QToOFDimension([self qWidget]->sizeHint()); +} + +- (of_dimension_t)sizeIncrement +{ + return QToOFDimension([self qWidget]->sizeIncrement()); +} + +- (void)setSizeIncrement: (of_dimension_t)sizeIncrement +{ + [self qWidget]->setSizeIncrement(OFToQSize(sizeIncrement)); +} + +- (QSizePolicy)sizePolicy +{ + return [self qWidget]->sizePolicy(); +} + +- (void)setSizePolicy: (QSizePolicy)sizePolicy +{ + [self qWidget]->setSizePolicy(sizePolicy); +} + +- (OFString*)statusTip +{ + return QToOFString([self qWidget]->statusTip()); +} + +- (void)setStatusTip: (OFString*)statusTip +{ + [self qWidget]->setStatusTip(OFToQString(statusTip)); +} + +- (OFString*)styleSheet +{ + return QToOFString([self qWidget]->styleSheet()); +} + +- (void)setStyleSheet: (OFString*)styleSheet +{ + [self qWidget]->setStyleSheet(OFToQString(styleSheet)); +} + +- (OFString*)toolTip +{ + return QToOFString([self qWidget]->toolTip()); +} + +- (void)setToolTip: (OFString*)toolTip +{ + [self qWidget]->setToolTip(OFToQString(toolTip)); +} + +- (int)toolTipDuration +{ + return [self qWidget]->toolTipDuration(); +} + +- (void)setToolTipDuration: (int)toolTipDuration +{ + [self qWidget]->setToolTipDuration(toolTipDuration); +} + +- (bool)updatesEnabled +{ + return [self qWidget]->updatesEnabled(); +} + +- (void)setUpdatesEnabled: (bool)updatesEnabled +{ + [self qWidget]->setUpdatesEnabled(updatesEnabled); +} + +- (bool)isVisible +{ + return [self qWidget]->isVisible(); +} + +- (void)setVisible: (bool)visible +{ + [self qWidget]->setVisible(visible); +} + +- (OFString*)whatsThis +{ + return QToOFString([self qWidget]->whatsThis()); +} + +- (void)setWhatsThis: (OFString*)whatsThis +{ + [self qWidget]->setWhatsThis(OFToQString(whatsThis)); +} + +- (int)width +{ + return [self qWidget]->width(); +} + +- (OFString*)windowFilePath +{ + return QToOFString([self qWidget]->windowFilePath()); +} + +- (void)setWindowFilePath: (OFString*)windowFilePath +{ + [self qWidget]->setWindowFilePath(OFToQString(windowFilePath)); +} + +- (Qt::WindowFlags)windowFlags +{ + return [self qWidget]->windowFlags(); +} + +- (void)setWindowFlags: (Qt::WindowFlags)windowFlags +{ + [self qWidget]->setWindowFlags(windowFlags); +} + +- (QIcon)windowIcon +{ + return [self qWidget]->windowIcon(); +} + +- (void)setWindowIcon: (QIcon)windowIcon +{ + [self qWidget]->setWindowIcon(windowIcon); +} + +- (Qt::WindowModality)windowModality +{ + return [self qWidget]->windowModality(); +} + +- (void)setWindowModality: (Qt::WindowModality)windowModality +{ + [self qWidget]->setWindowModality(windowModality); +} + +- (bool)isWindowModified +{ + return [self qWidget]->isWindowModified(); +} + +- (void)setWindowModified: (bool)windowModified +{ + [self qWidget]->setWindowModified(windowModified); +} + +- (double)windowOpacity +{ + return [self qWidget]->windowOpacity(); +} + +- (void)setWindowOpacity: (double)windowOpacity +{ + [self qWidget]->setWindowOpacity(windowOpacity); +} + +- (OFString*)windowTitle +{ + return QToOFString([self qWidget]->windowTitle()); +} + +- (void)setWindowTitle: (OFString*)windowTitle +{ + [self qWidget]->setWindowTitle(OFToQString(windowTitle)); +} + +- (int)x +{ + return [self qWidget]->x(); +} + +- (int)y +{ + return [self qWidget]->y(); +} +@end Index: common/helpers.h ================================================================== --- common/helpers.h +++ common/helpers.h @@ -1,8 +1,10 @@ #import #include +#include +#include inline OFString* QToOFString(const QString &qString) { return [OFString stringWithUTF8String: qString.toUtf8()]; @@ -11,5 +13,43 @@ inline QString OFToQString(OFString *string) { return QString::fromUtf8([string UTF8String]); } + +inline of_dimension_t +QToOFDimension(const QSize &qSize) +{ + return of_dimension(qSize.width(), qSize.height()); +} + +inline of_point_t +QToOFPoint(const QPoint &qPoint) +{ + return of_point(qPoint.x(), qPoint.y()); +} + +inline QPoint +OFToQPoint(of_point_t point) +{ + return QPoint(point.x, point.y); +} + +inline QSize +OFToQSize(of_dimension_t dimension) +{ + return QSize(dimension.width, dimension.height); +} + +inline of_rectangle_t +QToOFRectangle(const QRect &qRect) +{ + return of_rectangle(qRect.x(), qRect.y(), + qRect.width(), qRect.height()); +} + +inline QRect +OFToQRect(of_rectangle_t rectangle) +{ + return QRect(rectangle.origin.x, rectangle.origin.y, + rectangle.size.width, rectangle.size.height); +}