Make toOF/toQt more powerful and complete QtWidget

This commit is contained in:
Jonathan Schleifer 2017-04-15 19:18:52 +02:00
parent b37c5f6fc5
commit d8f3aa90ec
No known key found for this signature in database
GPG key ID: 28D65178B37F33E3
24 changed files with 1047 additions and 385 deletions

View file

@ -56,6 +56,7 @@
- (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;
@ -63,3 +64,19 @@
- (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];
}
}

View file

@ -22,8 +22,10 @@
#import "QtAction.h"
#import "QtWidget.h"
#import "OFString+QString.h"
#import "helpers.h"
using ObjQt::toOF;
using ObjQt::toQt;
@implementation QtAction
- initWithQObject: (QObject*)qObject
@ -43,199 +45,198 @@
- (bool)autoRepeat
{
return [self qAction]->autoRepeat();
return toQt(self)->autoRepeat();
}
- (void)setAutoRepeat: (bool)autoRepeat
{
[self qAction]->setAutoRepeat(autoRepeat);
toQt(self)->setAutoRepeat(autoRepeat);
}
- (bool)isCheckable
{
return [self qAction]->isCheckable();
return toQt(self)->isCheckable();
}
- (void)setCheckable: (bool)checkable
{
[self qAction]->setCheckable(checkable);
toQt(self)->setCheckable(checkable);
}
- (bool)isChecked
{
return [self qAction]->isChecked();
return toQt(self)->isChecked();
}
- (void)setChecked: (bool)checked
{
[self qAction]->setChecked(checked);
toQt(self)->setChecked(checked);
}
- (bool)isEnabled
{
return [self qAction]->isEnabled();
return toQt(self)->isEnabled();
}
- (void)setEnabled: (bool)enabled
{
[self qAction]->setEnabled(enabled);
toQt(self)->setEnabled(enabled);
}
- (QFont)font
{
return [self qAction]->font();
return toQt(self)->font();
}
- (void)setFont: (QFont)font
{
[self qAction]->setFont(font);
toQt(self)->setFont(font);
}
- (QIcon)icon
{
return [self qAction]->icon();
return toQt(self)->icon();
}
- (void)setIcon: (QIcon)icon
{
[self qAction]->setIcon(icon);
toQt(self)->setIcon(icon);
}
- (OFString*)iconText
{
return toOF([self qAction]->iconText());
return toOF(toQt(self)->iconText());
}
- (void)setIconText: (OFString*)iconText
{
[self qAction]->setIconText(toQt(iconText));
toQt(self)->setIconText(toQt(iconText));
}
- (bool)isIconVisibleInMenu
{
return [self qAction]->isIconVisibleInMenu();
return toQt(self)->isIconVisibleInMenu();
}
- (void)setIconVisibleInMenu: (bool)iconVisibleInMenu
{
[self qAction]->setIconVisibleInMenu(iconVisibleInMenu);
toQt(self)->setIconVisibleInMenu(iconVisibleInMenu);
}
- (QAction::MenuRole)menuRole
{
return [self qAction]->menuRole();
return toQt(self)->menuRole();
}
- (void)setMenuRole: (QAction::MenuRole)menuRole
{
[self qAction]->setMenuRole(menuRole);
toQt(self)->setMenuRole(menuRole);
}
- (QAction::Priority)priority
{
return [self qAction]->priority();
return toQt(self)->priority();
}
- (void)setPriority: (QAction::Priority)priority
{
[self qAction]->setPriority(priority);
toQt(self)->setPriority(priority);
}
- (QKeySequence)shortcut
{
return [self qAction]->shortcut();
return toQt(self)->shortcut();
}
- (void)setShortcut: (QKeySequence)shortcut
{
[self qAction]->setShortcut(shortcut);
toQt(self)->setShortcut(shortcut);
}
- (Qt::ShortcutContext)shortcutContext
{
return [self qAction]->shortcutContext();
return toQt(self)->shortcutContext();
}
- (void)setShortcutContext: (Qt::ShortcutContext)shortcutContext
{
[self qAction]->setShortcutContext(shortcutContext);
toQt(self)->setShortcutContext(shortcutContext);
}
- (OFString*)statusTip
{
return toOF([self qAction]->statusTip());
return toOF(toQt(self)->statusTip());
}
- (void)setStatusTip: (OFString*)statusTip
{
[self qAction]->setStatusTip(toQt(statusTip));
toQt(self)->setStatusTip(toQt(statusTip));
}
- (OFString*)text
{
return toOF([self qAction]->text());
return toOF(toQt(self)->text());
}
- (void)setText: (OFString*)text
{
[self qAction]->setText(toQt(text));
toQt(self)->setText(toQt(text));
}
- (OFString*)toolTip
{
return toOF([self qAction]->toolTip());
return toOF(toQt(self)->toolTip());
}
- (void)setToolTip: (OFString*)toolTip
{
[self qAction]->setToolTip(toQt(toolTip));
toQt(self)->setToolTip(toQt(toolTip));
}
- (bool)isVisible
{
return [self qAction]->isVisible();
return toQt(self)->isVisible();
}
- (void)setVisible: (bool)visible
{
[self qAction]->setVisible(visible);
toQt(self)->setVisible(visible);
}
- (OFString*)whatsThis
{
return toOF([self qAction]->whatsThis());
return toOF(toQt(self)->whatsThis());
}
- (void)setWhatsThis: (OFString*)whatsThis
{
[self qAction]->setWhatsThis(toQt(whatsThis));
toQt(self)->setWhatsThis(toQt(whatsThis));
}
- (QActionGroup*)actionGroup
{
return [self qAction]->actionGroup();
return toQt(self)->actionGroup();
}
- (void)activate: (QAction::ActionEvent)event
{
[self qAction]->activate(event);
toQt(self)->activate(event);
}
- (QList<QGraphicsWidget*>)associatedGraphicsWidgets
{
return [self qAction]->associatedGraphicsWidgets();
return toQt(self)->associatedGraphicsWidgets();
}
- (OFArray OF_GENERIC(QtWidget*)*)associatedWidgets
{
const QList<QWidget*> &widgets = [self qAction]->associatedWidgets();
const QList<QWidget*> &widgets = toQt(self)->associatedWidgets();
OFMutableArray *ret =
[OFMutableArray arrayWithCapacity: widgets.count()];
void *pool = objc_autoreleasePoolPush();
for (QWidget *widget: widgets)
[ret addObject:
[[[QtWidget alloc] initWithQWidget: widget] autorelease]];
[ret addObject: toOF(widget)];
[ret makeImmutable];
@ -246,57 +247,61 @@
- (QVariant)data
{
return [self qAction]->data();
return toQt(self)->data();
}
- (bool)isSeparator
{
return [self qAction]->isSeparator();
return toQt(self)->isSeparator();
}
- (QMenu*)menu
{
return [self qAction]->menu();
return toQt(self)->menu();
}
- (QtWidget*)parentWidget
{
return [[[QtWidget alloc] initWithQWidget:
[self qAction]->parentWidget()] autorelease];
return toOF(toQt(self)->parentWidget());
}
- (void)setActionGroup: (QActionGroup*)group
{
[self qAction]->setActionGroup(group);
toQt(self)->setActionGroup(group);
}
- (void)setData: (const QVariant&)userData
{
toQt(self)->setData(userData);
}
- (void)setMenu: (QMenu*)menu
{
[self qAction]->setMenu(menu);
toQt(self)->setMenu(menu);
}
- (void)setSeparator: (bool)isSeparator
{
[self qAction]->setSeparator(isSeparator);
toQt(self)->setSeparator(isSeparator);
}
- (void)setShortcuts: (const QList<QKeySequence>&)shortcuts
{
[self qAction]->setShortcuts(shortcuts);
toQt(self)->setShortcuts(shortcuts);
}
- (void)setShortcutsWithStandardKey: (QKeySequence::StandardKey)key
{
[self qAction]->setShortcuts(key);
toQt(self)->setShortcuts(key);
}
- (QList<QKeySequence>)shortcuts
{
return [self qAction]->shortcuts();
return toQt(self)->shortcuts();
}
- (bool)showStatusText: (QtWidget*)widget
{
return [self qAction]->showStatusText([widget qWidget]);
return toQt(self)->showStatusText(toQt(widget));
}
@end

View file

@ -20,13 +20,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#import "QtGuiApplication.h"
#import "QtGUIApplication.h"
#include <QApplication>
@interface QtApplication: QtGuiApplication
@interface QtApplication: QtGUIApplication
@property (readonly) QApplication *qApplication;
@property bool autoSipEnabled;
@property bool autoSIPEnabled;
@property int cursorFlashTime;
@property int doubleClickInterval;
@property of_dimension_t globalStrut;
@ -38,7 +38,22 @@
- initWithQApplication: (QApplication*)qApplication;
- (void)aboutQt;
- (bool)autoSipEnabled;
- (void)closeAllWindows;
- (void)setAutoSipEnabled: (bool)enabled;
@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

@ -21,9 +21,13 @@
*/
#import "QtApplication.h"
#import "OFString+QString.h"
#import "helpers.h"
using ObjQt::toOF;
using ObjQt::toQt;
@implementation QtApplication
- initWithQGuiApplication: (QGuiApplication*)qGuiApplication
{
@ -40,103 +44,103 @@
return qobject_cast<QApplication*>(_qObject);
}
- (bool)autoSipEnabled
- (bool)autoSIPEnabled
{
return [self qApplication]->autoSipEnabled();
return toQt(self)->autoSipEnabled();
}
- (void)setAutoSipEnabled: (bool)autoSipEnabled
- (void)setAutoSIPEnabled: (bool)autoSIPEnabled
{
[self qApplication]->setAutoSipEnabled(autoSipEnabled);
toQt(self)->setAutoSipEnabled(autoSIPEnabled);
}
- (int)cursorFlashTime
{
return [self qApplication]->cursorFlashTime();
return toQt(self)->cursorFlashTime();
}
- (void)setCursorFlashTime: (int)cursorFlashTime
{
[self qApplication]->setCursorFlashTime(cursorFlashTime);
toQt(self)->setCursorFlashTime(cursorFlashTime);
}
- (int)doubleClickInterval
{
return [self qApplication]->doubleClickInterval();
return toQt(self)->doubleClickInterval();
}
- (void)setDoubleClickInterval: (int)doubleClickInterval
{
[self qApplication]->setDoubleClickInterval(doubleClickInterval);
toQt(self)->setDoubleClickInterval(doubleClickInterval);
}
- (of_dimension_t)globalStrut
{
return toOF([self qApplication]->globalStrut());
return toOF(toQt(self)->globalStrut());
}
- (void)setGlobalStrut: (of_dimension_t)globalStrut
{
[self qApplication]->setGlobalStrut(toQt(globalStrut));
toQt(self)->setGlobalStrut(toQt(globalStrut));
}
- (int)keyboardInputInterval
{
return [self qApplication]->keyboardInputInterval();
return toQt(self)->keyboardInputInterval();
}
- (void)setKeyboardInputInterval: (int)keyboardInputInterval
{
[self qApplication]->setKeyboardInputInterval(keyboardInputInterval);
toQt(self)->setKeyboardInputInterval(keyboardInputInterval);
}
- (int)startDragDistance
{
return [self qApplication]->startDragDistance();
return toQt(self)->startDragDistance();
}
- (void)setStartDragDistance: (int)startDragDistance
{
[self qApplication]->setStartDragDistance(startDragDistance);
toQt(self)->setStartDragDistance(startDragDistance);
}
- (int)startDragTime
{
return [self qApplication]->startDragTime();
return toQt(self)->startDragTime();
}
- (void)setStartDragTime: (int)startDragTime
{
[self qApplication]->setStartDragTime(startDragTime);
toQt(self)->setStartDragTime(startDragTime);
}
- (OFString*)styleSheet
{
return toOF([self qApplication]->styleSheet());
return toOF(toQt(self)->styleSheet());
}
- (void)setStyleSheet: (OFString*)styleSheet
{
[self qApplication]->setStyleSheet(toQt(styleSheet));
toQt(self)->setStyleSheet(toQt(styleSheet));
}
- (int)wheelScrollLines
{
return [self qApplication]->wheelScrollLines();
return toQt(self)->wheelScrollLines();
}
- (void)setWheelScrollLines: (int)wheelScrollLines
{
[self qApplication]->setWheelScrollLines(wheelScrollLines);
toQt(self)->setWheelScrollLines(wheelScrollLines);
}
- (void)aboutQt
{
[self qApplication]->aboutQt();
toQt(self)->aboutQt();
}
- (void)closeAllWindows
{
[self qApplication]->closeAllWindows();
toQt(self)->closeAllWindows();
}
@end

View file

@ -39,7 +39,6 @@
@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;
@ -78,7 +77,6 @@
@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;
@ -101,7 +99,7 @@
- (void)clearMask;
- (QMargins)contentsMargins;
- (of_rectangle_t)contentsRect;
- (WId)effectiveWinId;
- (WId)effectiveWinID;
- (void)ensurePolished;
- (QtWidget*)focusProxy;
- (QtWidget*)focusWidget;
@ -123,6 +121,7 @@
#ifdef QT_KEYPAD_NAVIGATION
- (bool)hasEditFocus;
#endif
- (bool)hasFocus;
- (bool)hasHeightForWidth;
- (int)heightForWidth: (int)w;
- (QVariant)queryInputMethod: (Qt::InputMethodQuery)query;
@ -135,19 +134,107 @@
- (bool)isHidden;
- (bool)isVisibleTo: (QtWidget*)ancestor;
- (bool)isWindow;
// QPoint mapFrom(const QWidget *parent, const QPoint &pos) const
// QPoint mapFromGlobal(const QPoint &pos) const
// QPoint mapFromParent(const QPoint &pos) const
// QPoint mapTo(const QWidget *parent, const QPoint &pos) const
// QPoint mapToGlobal(const QPoint &pos) const
// QPoint mapToParent(const QPoint &pos) const
// QRegion mask() const
// ...
- (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];
}
}

File diff suppressed because it is too large Load diff