Index: src/QtWidgets/Makefile ================================================================== --- src/QtWidgets/Makefile +++ src/QtWidgets/Makefile @@ -1,12 +1,13 @@ include ../../extra.mk STATIC_PIC_LIB_NOINST = ${QTWIDGETS_LIB_A} STATIC_LIB_NOINST = ${QTWIDGETS_A} -SRCS = QtAction.mm \ - QtApplication.mm \ +SRCS = QtAbstractButton.mm \ + QtAction.mm \ + QtApplication.mm \ QtWidget.mm include ../../buildsys.mk CPPFLAGS += -I. -I../QtCore -I../QtGui -I../common ADDED src/QtWidgets/QtAbstractButton.h Index: src/QtWidgets/QtAbstractButton.h ================================================================== --- src/QtWidgets/QtAbstractButton.h +++ src/QtWidgets/QtAbstractButton.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2017, Jonathan Schleifer + * + * 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 "QtWidget.h" + +#include + +@interface QtAbstractButton: QtWidget +@property (readonly) QAbstractButton *qAbstractButton; +@property bool autoExclusive; +@property bool autoRepeat; +@property int autoRepeatDelay; +@property int autoRepeatInterval; +@property (getter=isCheckable) bool checkable; +@property (getter=isChecked) bool checked; +@property (getter=isDown) bool down; +@property QIcon icon; +@property of_dimension_t iconSize; +@property QKeySequence shortcut; +@property (copy) OFString *text; + +- initWithQAbstractButton: (QAbstractButton*)qAbstractButton; +- (QButtonGroup*)group; +@end + +namespace ObjQt { + +static OF_INLINE QtAbstractButton* +toOF(QAbstractButton *qAbstractButton) +{ + return [[[QtAbstractButton alloc] + initWithQAbstractButton: qAbstractButton] autorelease]; +} + +static OF_INLINE QAbstractButton* +toQt(QtAbstractButton *abstractButton) +{ + return [abstractButton qAbstractButton]; +} + +} ADDED src/QtWidgets/QtAbstractButton.mm Index: src/QtWidgets/QtAbstractButton.mm ================================================================== --- src/QtWidgets/QtAbstractButton.mm +++ src/QtWidgets/QtAbstractButton.mm @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2017, Jonathan Schleifer + * + * 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 "QtAbstractButton.h" +#import "OFString+QString.h" + +#import "helpers.h" + +using ObjQt::toOF; +using ObjQt::toQt; + +@implementation QtAbstractButton +- initWithQWidget: (QWidget*)qWidget +{ + OF_INVALID_INIT_METHOD +} + +- initWithQAbstractButton: (QAbstractButton*)qAbstractButton +{ + return [super initWithQWidget: qAbstractButton]; +} + +- (QAbstractButton*)qAbstractButton +{ + return qobject_cast(_qObject); +} + +- (bool)autoExclusive +{ + return toQt(self)->autoExclusive(); +} + +- (void)setAutoExclusive: (bool)autoExclusive +{ + toQt(self)->setAutoExclusive(autoExclusive); +} + +- (bool)autoRepeat +{ + return toQt(self)->autoRepeat(); +} + +- (void)setAutoRepeat: (bool)autoRepeat +{ + toQt(self)->setAutoRepeat(autoRepeat); +} + +- (int)autoRepeatDelay +{ + return toQt(self)->autoRepeatDelay(); +} + +- (void)setAutoRepeatDelay: (int)autoRepeatDelay +{ + toQt(self)->setAutoRepeatDelay(autoRepeatDelay); +} + +- (int)autoRepeatInterval +{ + return toQt(self)->autoRepeatInterval(); +} + +- (void)setAutoRepeatInterval: (int)autoRepeatInterval +{ + toQt(self)->setAutoRepeatInterval(autoRepeatInterval); +} + +- (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)isDown +{ + return toQt(self)->isDown(); +} + +- (void)setDown: (bool)down +{ + toQt(self)->setDown(down); +} + +- (QIcon)icon +{ + return toQt(self)->icon(); +} + +- (void)setIcon: (QIcon)icon +{ + toQt(self)->setIcon(icon); +} + +- (of_dimension_t)iconSize +{ + return toOF(toQt(self)->iconSize()); +} + +- (void)setIconSize: (of_dimension_t)iconSize +{ + toQt(self)->setIconSize(toQt(iconSize)); +} + +- (QKeySequence)shortcut +{ + return toQt(self)->shortcut(); +} + +- (void)setShortcut: (QKeySequence)shortcut +{ + toQt(self)->setShortcut(shortcut); +} + +- (OFString*)text +{ + return toOF(toQt(self)->text()); +} + +- (void)setText: (OFString*)text +{ + toQt(self)->setText(toQt(text)); +} + +- (QButtonGroup*)group +{ + return toQt(self)->group(); +} +@end