-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
3,938 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
reference | ||
Makefile | ||
*.stash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Scope Button, using QCocoaButton, AGScopeBar-master | ||
|
||
- NSTokenField | ||
- NSLevelIndicator | ||
- NSPathControl | ||
- NSSplitView | ||
- NSTextFinder | ||
- NSOutlineView in an NSScrollView (Source List) | ||
- NSDrawer | ||
- PDFView | ||
- WebView |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#ifndef qcocoabox_h__ | ||
#define qcocoabox_h__ | ||
|
||
#include <QPointer> | ||
#include "qcocoawidget.h" | ||
|
||
class QCocoaBoxPrivate; | ||
|
||
class QCocoaBox : public QCocoaWidget | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
|
||
enum BoxType { | ||
NSBoxPrimary = 0, // Specifies the primary box appearance. This is the default box type. | ||
NSBoxSecondary = 1, // Specifies the secondary box appearance. | ||
NSBoxSeparator = 2, // Specifies that the box is a separator. | ||
NSBoxOldStyle = 3 // Specifies that the box is an OS X v10.2–style box. | ||
}; | ||
|
||
QCocoaBox(QWidget * parent = 0); | ||
|
||
virtual QSize sizeHint() const; | ||
|
||
public: | ||
|
||
void setTitle(const QString &title); | ||
void setBoxType(BoxType type); | ||
|
||
void setContentWidget(QWidget *widget); | ||
|
||
signals: | ||
|
||
private: | ||
|
||
friend class QCocoaBoxPrivate; | ||
QPointer<QCocoaBoxPrivate> pimpl; | ||
QWidget *contents; | ||
}; | ||
|
||
#endif // qcocoabox_h__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#include "qcocoabox.h" | ||
|
||
#import <AppKit/NSBox.h> | ||
#import <AppKit/NSSlider.h> | ||
|
||
#import <Foundation/NSAutoreleasePool.h> | ||
|
||
class QCocoaBoxPrivate : public QObject | ||
{ | ||
protected: | ||
|
||
QPointer<QCocoaBox> parent; | ||
NSBox *nsBox; | ||
|
||
public: | ||
QCocoaBoxPrivate(NSBox *pControl, QCocoaBox *pParent) | ||
: QObject(pParent), parent(pParent), nsBox(pControl) | ||
{ | ||
|
||
} | ||
|
||
~QCocoaBoxPrivate() { } | ||
|
||
friend class QCocoaBox; | ||
}; | ||
|
||
QCocoaBox::QCocoaBox(QWidget * parent /*= 0*/) : QCocoaWidget(parent), contents(nullptr) | ||
{ | ||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | ||
|
||
NSBox *box = [[NSBox alloc] init]; | ||
[box setBoxType:(NSBoxType)NSBoxPrimary]; | ||
pimpl = new QCocoaBoxPrivate(box, this); | ||
|
||
setupLayout(box); | ||
|
||
setMinimumHeight(1); // for NSBoxSeparator | ||
|
||
[box release]; | ||
|
||
[pool drain]; | ||
} | ||
|
||
#define LEFT_RIGHT_MARGIN 10 | ||
#define TOP_MARGIN 20 | ||
#define BOTTOM_MARGIN 10 | ||
|
||
void QCocoaBox::setContentWidget(QWidget *widget) | ||
{ | ||
if (widget) | ||
{ | ||
QMacCocoaViewContainer *p = container(); | ||
|
||
if (p) | ||
{ | ||
QHBoxLayout *layout = new QHBoxLayout(p); | ||
layout->setContentsMargins(QMargins(LEFT_RIGHT_MARGIN, TOP_MARGIN, LEFT_RIGHT_MARGIN, BOTTOM_MARGIN)); | ||
layout->addWidget(widget); | ||
|
||
widget->adjustSize(); | ||
|
||
QSize minSize = widget->size(); | ||
minSize.setWidth(minSize.width() + LEFT_RIGHT_MARGIN*2); | ||
minSize.setHeight(minSize.height() + TOP_MARGIN + BOTTOM_MARGIN); | ||
|
||
setMinimumSize(minSize); | ||
|
||
widget->setPalette(Qt::transparent); // make sure it's transparent | ||
|
||
if (widget->layout()) | ||
widget->layout()->setContentsMargins(QMargins(0,0,0,0)); // make sure to have no margins | ||
} | ||
} | ||
} | ||
|
||
QSize QCocoaBox::sizeHint() const | ||
{ | ||
QSize sz; | ||
|
||
NSRect frame = [pimpl->nsBox frame]; | ||
sz = QSize(frame.size.width, ([pimpl->nsBox boxType] == (NSBoxType)NSBoxSeparator) ? 1 : frame.size.height); | ||
|
||
if (contents) | ||
sz = QSize(contents->width(), contents->height()); | ||
|
||
return sz; | ||
} | ||
|
||
void QCocoaBox::setTitle(const QString &title) | ||
{ | ||
QMacAutoReleasePool pool; | ||
[pimpl->nsBox setTitle: title.toNSString()]; | ||
} | ||
|
||
void QCocoaBox::setBoxType(BoxType type) | ||
{ | ||
[pimpl->nsBox setBoxType:(NSBoxType)type]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
#include "stdafx.h" | ||
|
||
#include "QCocoaButton.h" | ||
|
||
#include <QToolBar> | ||
#include <QToolButton> | ||
#include <QPushButton> | ||
#include <QVBoxLayout> | ||
|
||
class CocoaButtonPrivate | ||
{ | ||
public: | ||
CocoaButtonPrivate(QCocoaButton *button, QAbstractButton *abstractButton) | ||
: abstractButton(abstractButton) {} | ||
QPointer<QAbstractButton> abstractButton; | ||
}; | ||
|
||
QCocoaButton::QCocoaButton(QWidget *parent) | ||
: QCocoaWidget(parent) | ||
{ | ||
QAbstractButton *button = nullptr; | ||
|
||
if (qobject_cast<QToolBar*>(parent)) | ||
button = new QToolButton(this); | ||
else | ||
{ | ||
QPushButton *pushBtn = new QPushButton(this); | ||
|
||
button = pushBtn; | ||
} | ||
|
||
connect(button, SIGNAL(clicked()), this, SIGNAL(clicked())); | ||
pimpl.reset(new CocoaButtonPrivate(this, button)); | ||
|
||
QVBoxLayout *layout = new QVBoxLayout(this); | ||
layout->setMargin(0); | ||
layout->addWidget(button); | ||
} | ||
|
||
QCocoaButton::~QCocoaButton() | ||
{ | ||
|
||
} | ||
|
||
void QCocoaButton::setText(const QString &text) | ||
{ | ||
Q_ASSERT(pimpl); | ||
if (pimpl) | ||
pimpl->abstractButton->setText(text); | ||
} | ||
|
||
void QCocoaButton::setIcon(const QIcon &image) | ||
{ | ||
Q_ASSERT(pimpl); | ||
if (pimpl) | ||
pimpl->abstractButton->setIcon(image); | ||
} | ||
|
||
void QCocoaButton::setChecked(bool checked) | ||
{ | ||
Q_ASSERT(pimpl); | ||
if (pimpl) | ||
pimpl->abstractButton->setChecked(checked); | ||
} | ||
|
||
void QCocoaButton::setCheckable(bool checkable) | ||
{ | ||
Q_ASSERT(pimpl); | ||
if (pimpl) | ||
pimpl->abstractButton->setCheckable(checkable); | ||
} | ||
|
||
bool QCocoaButton::isChecked() | ||
{ | ||
Q_ASSERT(pimpl); | ||
if (!pimpl) | ||
return false; | ||
|
||
return pimpl->abstractButton->isChecked(); | ||
} | ||
|
||
QSize QCocoaButton::sizeHint() const | ||
{ | ||
Q_ASSERT(pimpl); | ||
if (!pimpl) | ||
return QSize(); | ||
|
||
return pimpl->abstractButton->sizeHint(); | ||
} | ||
|
||
void QCocoaButton::setToolTip(const QString& strTip) | ||
{ | ||
Q_ASSERT(pimpl); | ||
if (pimpl) | ||
pimpl->abstractButton->setToolTip(strTip); | ||
} | ||
|
||
void QCocoaButton::setBezelStyle(BezelStyle) | ||
{ | ||
// only for mac | ||
} | ||
|
||
QAbstractButton *QCocoaButton::abstractButton() | ||
{ | ||
return pimpl->abstractButton; | ||
} | ||
|
||
|
||
void QCocoaButton::setIconPosition(IconPosition pos) | ||
{ | ||
if (pos == IconOnly) | ||
{ | ||
setStyleSheet("QPushButton { text-align: left; }"); | ||
} | ||
} | ||
|
||
void QCocoaButton::setMenu(QMenu *menu) | ||
{ | ||
QPushButton *btn = qobject_cast<QPushButton *>(pimpl->abstractButton); | ||
|
||
if (btn) | ||
btn->setMenu(menu); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#ifndef qcocoabutton_h__ | ||
#define qcocoabutton_h__ | ||
|
||
#include "qcocoawidget.h" | ||
#include "qcocoaicon.h" | ||
|
||
#include <QPointer> | ||
#include <QPushButton> | ||
|
||
class CocoaButtonPrivate; | ||
|
||
class QCocoaButton : public QCocoaWidget | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
|
||
enum BezelStyle { // matches NSBezelStyle | ||
Rounded = 1, | ||
RegularSquare = 2, /* RegularSquare (Bevel buttons) are not recommended for use in apps that run in OS X v10.7 and later. | ||
You should consider alternatives, such as gradient buttons and segmented controls */ | ||
Disclosure = 5, | ||
ShadowlessSquare = 6, | ||
Circular = 7, /* Round buttons are not recommended for use in apps that run in OS X v10.7 and later. | ||
You should consider an alternative, such as a gradient button */ | ||
TexturedSquare = 8, | ||
HelpButton = 9, | ||
SmallSquare = 10, | ||
TexturedRounded = 11, | ||
RoundRect = 12, | ||
Recessed = 13, | ||
RoundedDisclosure = 14, | ||
Inline = 15 | ||
}; | ||
|
||
enum IconPosition { // matches NSCellImagePosition) | ||
NoIcon = 0, | ||
IconOnly = 1, | ||
IconLeft = 2, | ||
IconRight = 3, | ||
IconBelow = 4, | ||
IconAbove = 5, | ||
IconOverlaps = 6 | ||
//NSImageLeading API_AVAILABLE(macosx(10.12)) = 7, | ||
//NSImageTrailing API_AVAILABLE(macosx(10.12)) = 8 | ||
}; | ||
|
||
QCocoaButton(QWidget *parent); | ||
~QCocoaButton(); | ||
|
||
protected: | ||
|
||
QCocoaButton(QWidget *parent, CocoaButtonPrivate *customPrivate); | ||
|
||
public slots: | ||
|
||
virtual void setText(const QString &text); | ||
void setIcon(const QIcon &image); | ||
|
||
#ifdef Q_OS_MAC | ||
void setIcon(QCocoaIcon::StandardIcon icon); | ||
#endif | ||
|
||
void setIconPosition(IconPosition pos); | ||
|
||
void setChecked(bool checked); | ||
|
||
void setToolTip(const QString& strTip); | ||
|
||
public: | ||
|
||
virtual void setMenu(QMenu *menu); | ||
|
||
void setBezelStyle(BezelStyle bezelStyle = Rounded); | ||
|
||
void setCheckable(bool checkable); | ||
bool isChecked(); | ||
|
||
void initFrom(QPushButton * /* pOther */) {} | ||
|
||
QSize sizeHint() const override; | ||
|
||
QAbstractButton *abstractButton(); // helper method when you need to insert QCocoaButton into QDialogButtonBox | ||
|
||
signals: | ||
void clicked(bool checked = false); | ||
|
||
protected: | ||
|
||
friend class CocoaButtonPrivate; | ||
std::unique_ptr<CocoaButtonPrivate> pimpl; | ||
BezelStyle style; | ||
}; | ||
|
||
#endif // qcocoabutton_h__ |
Oops, something went wrong.