1 /**************************************************************************** 2 ** 3 ** DQt - D bindings for the Qt Toolkit 4 ** 5 ** GNU Lesser General Public License Usage 6 ** This file may be used under the terms of the GNU Lesser 7 ** General Public License version 3 as published by the Free Software 8 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 9 ** packaging of this file. Please review the following information to 10 ** ensure the GNU Lesser General Public License version 3 requirements 11 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 12 ** 13 ****************************************************************************/ 14 module qt.gui.textoption; 15 extern(C++): 16 17 import qt.config; 18 import qt.core.flags; 19 import qt.core.global; 20 import qt.core.list; 21 import qt.core.namespace; 22 import qt.core.qchar; 23 import qt.helpers; 24 25 /+ template <typename T> class QList; +/ 26 struct QTextOptionPrivate; 27 28 extern(C++, class) struct /+ Q_GUI_EXPORT +/ QTextOption 29 { 30 public: 31 enum TabType { 32 LeftTab, 33 RightTab, 34 CenterTab, 35 DelimiterTab 36 } 37 38 struct /+ Q_GUI_EXPORT +/ Tab { 39 @disable this(); 40 /+pragma(inline, true) this() 41 { 42 this.position = 80; 43 this.type = QTextOption.TabType.LeftTab; 44 }+/ 45 pragma(inline, true) this(qreal pos, TabType tabType, QChar delim = QChar()) 46 { 47 this.position = pos; 48 this.type = tabType; 49 this.delimiter = delim; 50 } 51 52 /+pragma(inline, true) bool operator ==(ref const(Tab) other) const { 53 return type == other.type 54 && qFuzzyCompare(position, other.position) 55 && delimiter == other.delimiter; 56 }+/ 57 58 /+pragma(inline, true) bool operator !=(ref const(Tab) other) const { 59 return !operator==(other); 60 }+/ 61 62 qreal position = 80; 63 TabType type = QTextOption.TabType.LeftTab; 64 QChar delimiter; 65 } 66 67 /*@disable this(); 68 pragma(mangle, defaultConstructorMangling(__traits(identifier, typeof(this)))) 69 ref typeof(this) rawConstructor(); 70 static typeof(this) create() 71 { 72 typeof(this) r = typeof(this).init; 73 r.rawConstructor(); 74 return r; 75 }*/ 76 77 /*implicit*/ this(/+ Qt:: +/qt.core.namespace.Alignment alignment); 78 ~this(); 79 80 @disable this(this); 81 this(ref const(QTextOption) o); 82 /+ref QTextOption operator =(ref const(QTextOption) o);+/ 83 84 pragma(inline, true) void setAlignment(/+ Qt:: +/qt.core.namespace.Alignment aalignment) 85 { align_ = cast(uint)(aalignment.toInt); } 86 pragma(inline, true) /+ Qt:: +/qt.core.namespace.Alignment alignment() const { return /+ Qt:: +/qt.core.namespace.Alignment(cast(QFlag)(align_)); } 87 88 pragma(inline, true) void setTextDirection(/+ Qt:: +/qt.core.namespace.LayoutDirection aDirection) { this.direction = aDirection; } 89 // pragma(inline, true) /+ Qt:: +/qt.core.namespace.LayoutDirection textDirection() const { return /+ Qt:: +/qt.core.namespace.LayoutDirection(direction); } 90 91 enum WrapMode { 92 NoWrap, 93 WordWrap, 94 ManualWrap, 95 WrapAnywhere, 96 WrapAtWordBoundaryOrAnywhere 97 } 98 pragma(inline, true) void setWrapMode(WrapMode wrap) { wordWrap = wrap; } 99 pragma(inline, true) WrapMode wrapMode() const { return static_cast!(WrapMode)(wordWrap); } 100 101 enum Flag { 102 ShowTabsAndSpaces = 0x1, 103 ShowLineAndParagraphSeparators = 0x2, 104 AddSpaceForLineAndParagraphSeparators = 0x4, 105 SuppressColors = 0x8, 106 ShowDocumentTerminator = 0x10, 107 IncludeTrailingSpaces = 0x80000000 108 } 109 /+ Q_DECLARE_FLAGS(Flags, Flag) +/ 110 alias Flags = QFlags!(Flag); pragma(inline, true) void setFlags(Flags aflags) 111 { f = cast(uint)(aflags); } 112 // pragma(inline, true) Flags flags() const { return Flags(cast(QFlag)(f)); } 113 114 /+ #if QT_DEPRECATED_SINCE(5, 10) +/ 115 /+ QT_DEPRECATED +/ pragma(inline, true) void setTabStop(qreal atabStop) 116 { setTabStopDistance(atabStop); } 117 /+ QT_DEPRECATED +/ pragma(inline, true) qreal tabStop() const { return tabStopDistance(); } 118 /+ #endif +/ 119 120 pragma(inline, true) void setTabStopDistance(qreal atabStop) 121 { tab = atabStop; } 122 pragma(inline, true) qreal tabStopDistance() const { return tab; } 123 124 void setTabArray(ref const(QList!(qreal)) tabStops); 125 QList!(qreal) tabArray() const; 126 127 void setTabs(ref const(QList!(Tab)) tabStops); 128 QList!(Tab) tabs() const; 129 130 void setUseDesignMetrics(bool b) { design = b; } 131 bool useDesignMetrics() const { return (design) != 0; } 132 133 private: 134 /+ uint align : 8; +/ 135 uint bitfieldData_align = (WrapMode.WordWrap << 8) | (AlignmentFlag.AlignLeft); 136 final uint align_() const 137 { 138 return (bitfieldData_align >> 0) & 0xff; 139 } 140 final uint align_(uint value) 141 { 142 bitfieldData_align = (bitfieldData_align & ~0xff) | ((value & 0xff) << 0); 143 return value; 144 } 145 /+ uint wordWrap : 4; +/ 146 final uint wordWrap() const 147 { 148 return (bitfieldData_align >> 8) & 0xf; 149 } 150 final uint wordWrap(uint value) 151 { 152 bitfieldData_align = (bitfieldData_align & ~0xf00) | ((value & 0xf) << 8); 153 return value; 154 } 155 /+ uint design : 1; +/ 156 final uint design() const 157 { 158 return (bitfieldData_align >> 12) & 0x1; 159 } 160 final uint design(uint value) 161 { 162 bitfieldData_align = (bitfieldData_align & ~0x1000) | ((value & 0x1) << 12); 163 return value; 164 } 165 /+ uint direction : 2; +/ 166 final uint direction() const 167 { 168 return (bitfieldData_align >> 13) & 0x3; 169 } 170 final uint direction(uint value) 171 { 172 bitfieldData_align = (bitfieldData_align & ~0x6000) | ((value & 0x3) << 13); 173 return value; 174 } 175 /+ uint unused : 17; +/ 176 final uint unused() const 177 { 178 return (bitfieldData_align >> 15) & 0x1ffff; 179 } 180 final uint unused(uint value) 181 { 182 bitfieldData_align = (bitfieldData_align & ~0xffff8000) | ((value & 0x1ffff) << 15); 183 return value; 184 } 185 uint unused2; // ### Qt 6: remove unnecessary, extra 32 bits 186 uint f; 187 qreal tab = -1; 188 QTextOptionPrivate* d; 189 } 190 /+pragma(inline, true) QFlags!(QTextOption.Flags.enum_type) operator |(QTextOption.Flags.enum_type f1, QTextOption.Flags.enum_type f2)/+noexcept+/{return QFlags!(QTextOption.Flags.enum_type)(f1)|f2;}+/ 191 /+pragma(inline, true) QFlags!(QTextOption.Flags.enum_type) operator |(QTextOption.Flags.enum_type f1, QFlags!(QTextOption.Flags.enum_type) f2)/+noexcept+/{return f2|f1;}+/ 192 /+pragma(inline, true) QIncompatibleFlag operator |(QTextOption.Flags.enum_type f1, int f2)/+noexcept+/{return QIncompatibleFlag(int(f1)|f2);}+/ 193 194 /+ Q_DECLARE_OPERATORS_FOR_FLAGS(QTextOption::Flags) 195 #if QT_DEPRECATED_SINCE(5, 10) 196 #endif 197 198 199 Q_DECLARE_METATYPE( QTextOption::Tab ) +/ 200