1 /* 2 * DQt - D bindings for the Qt Toolkit 3 * 4 * GNU Lesser General Public License Usage 5 * This file may be used under the terms of the GNU Lesser 6 * General Public License version 3 as published by the Free Software 7 * Foundation and appearing in the file LICENSE.LGPL3 included in the 8 * packaging of this file. Please review the following information to 9 * ensure the GNU Lesser General Public License version 3 requirements 10 * will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 11 */ 12 module qt.gui.icon; 13 extern(C++): 14 15 import qt.config; 16 import qt.core.global; 17 import qt.core.list; 18 import qt.core.namespace; 19 import qt.core.rect; 20 import qt.core.size; 21 import qt.core.string; 22 import qt.core.stringlist; 23 import qt.core.typeinfo; 24 import qt.core.variant; 25 import qt.gui.painter; 26 import qt.gui.pixmap; 27 import qt.gui.windowdefs; 28 import qt.helpers; 29 30 extern(C++, class) struct QIconPrivate; 31 extern(C++, class) struct QIconEngine; 32 33 /// Binding for C++ class [QIcon](https://doc.qt.io/qt-6/qicon.html). 34 @Q_RELOCATABLE_TYPE extern(C++, class) struct /+ Q_GUI_EXPORT +/ QIcon 35 { 36 public: 37 enum Mode { Normal, Disabled, Active, Selected } 38 enum State { On, Off } 39 40 /+this()/+ noexcept+/;+/ 41 42 this(ref const(QPixmap) pixmap); 43 @disable this(this); 44 this(ref const(QIcon) other); 45 /+ QIcon(QIcon &&other) noexcept 46 : d(qExchange(other.d, nullptr)) 47 {} +/ 48 /+ explicit +/this(ref const(QString) fileName); // file or resource name 49 /+ explicit +/this(QIconEngine* engine); 50 ~this(); 51 /+ref QIcon operator =(ref const(QIcon) other);+/ 52 /+ QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QIcon) +/ 53 /+ inline void swap(QIcon &other) noexcept 54 { qSwap(d, other.d); } +/ 55 /+bool operator ==(ref const(QIcon) ) const /+ = delete +/;+/ 56 /+bool operator !=(ref const(QIcon) ) const /+ = delete +/;+/ 57 58 /+auto opCast(T : QVariant)() const;+/ 59 60 QPixmap pixmap(ref const(QSize) size, Mode mode = Mode.Normal, State state = State.Off) const; 61 pragma(inline, true) QPixmap pixmap(int w, int h, Mode mode = Mode.Normal, State state = State.Off) const 62 { auto tmp = QSize(w, h); return pixmap(tmp, mode, state); } 63 pragma(inline, true) QPixmap pixmap(int extent, Mode mode = Mode.Normal, State state = State.Off) const 64 { auto tmp = QSize(extent, extent); return pixmap(tmp, mode, state); } 65 QPixmap pixmap(ref const(QSize) size, qreal devicePixelRatio, Mode mode = Mode.Normal, State state = State.Off) const; 66 /+ #if QT_DEPRECATED_SINCE(6, 0) +/ 67 /+ QT_DEPRECATED_VERSION_X_6_0("Use pixmap(size, devicePixelRatio) instead") +/ 68 QPixmap pixmap(QWindow* window, ref const(QSize) size, Mode mode = Mode.Normal, State state = State.Off) const; 69 /+ #endif +/ 70 71 QSize actualSize(ref const(QSize) size, Mode mode = Mode.Normal, State state = State.Off) const; 72 /+ #if QT_DEPRECATED_SINCE(6, 0) +/ 73 /+ QT_DEPRECATED_VERSION_X_6_0("Use actualSize(size) instead") +/ 74 QSize actualSize(QWindow* window, ref const(QSize) size, Mode mode = Mode.Normal, State state = State.Off) const; 75 /+ #endif +/ 76 77 QString name() const; 78 79 void paint(QPainter* painter, ref const(QRect) rect, /+ Qt:: +/qt.core.namespace.Alignment alignment = /+ Qt:: +/qt.core.namespace.AlignmentFlag.AlignCenter, Mode mode = Mode.Normal, State state = State.Off) const; 80 pragma(inline, true) void paint(QPainter* painter, int x, int y, int w, int h, /+ Qt:: +/qt.core.namespace.Alignment alignment = /+ Qt:: +/qt.core.namespace.AlignmentFlag.AlignCenter, Mode mode = Mode.Normal, State state = State.Off) const 81 { auto tmp = QRect(x, y, w, h); paint(painter, tmp, alignment, mode, state); } 82 83 bool isNull() const; 84 bool isDetached() const; 85 void detach(); 86 87 qint64 cacheKey() const; 88 89 void addPixmap(ref const(QPixmap) pixmap, Mode mode = Mode.Normal, State state = State.Off); 90 void addFile(ref const(QString) fileName, ref const(QSize) size = globalInitVar!QSize, Mode mode = Mode.Normal, State state = State.Off); 91 92 QList!(QSize) availableSizes(Mode mode = Mode.Normal, State state = State.Off) const; 93 94 void setIsMask(bool isMask); 95 bool isMask() const; 96 97 static QIcon fromTheme(ref const(QString) name); 98 static QIcon fromTheme(ref const(QString) name, ref const(QIcon) fallback); 99 static bool hasThemeIcon(ref const(QString) name); 100 101 static QStringList themeSearchPaths(); 102 static void setThemeSearchPaths(ref const(QStringList) searchpath); 103 104 static QStringList fallbackSearchPaths(); 105 static void setFallbackSearchPaths(ref const(QStringList) paths); 106 107 static QString themeName(); 108 static void setThemeName(ref const(QString) path); 109 110 static QString fallbackThemeName(); 111 static void setFallbackThemeName(ref const(QString) name); 112 113 /+ Q_DUMMY_COMPARISON_OPERATOR(QIcon) +/ 114 115 private: 116 QIconPrivate* d; 117 version(QT_NO_DATASTREAM){}else 118 { 119 /+ friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QIcon &); +/ 120 /+ friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QIcon &); +/ 121 } 122 123 public: 124 alias DataPtr = QIconPrivate*; 125 pragma(inline, true) ref DataPtr data_ptr() return { return d; } 126 mixin(CREATE_CONVENIENCE_WRAPPERS); 127 } 128 129 /+ Q_DECLARE_SHARED(QIcon) 130 131 #if !defined(QT_NO_DATASTREAM) 132 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QIcon &); 133 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QIcon &); 134 #endif 135 136 #ifndef QT_NO_DEBUG_STREAM 137 Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QIcon &); 138 #endif +/ 139 140 /+ Q_GUI_EXPORT +/ QString qt_findAtNxFile(ref const(QString) baseFileName, qreal targetDevicePixelRatio, 141 qreal* sourceDevicePixelRatio = null); 142