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.textobject; 13 extern(C++): 14 15 import qt.config; 16 import qt.core.list; 17 import qt.core.namespace; 18 import qt.core.object; 19 import qt.core.string; 20 import qt.core.typeinfo; 21 import qt.gui.textcursor; 22 import qt.gui.textdocument; 23 import qt.gui.textformat; 24 import qt.gui.textlayout; 25 import qt.gui.textlist; 26 import qt.helpers; 27 version(QT_NO_RAWFONT){}else 28 import qt.gui.glyphrun; 29 30 extern(C++, class) struct QTextObjectPrivate; 31 32 /// Binding for C++ class [QTextObject](https://doc.qt.io/qt-6/qtextobject.html). 33 class /+ Q_GUI_EXPORT +/ QTextObject : QObject 34 { 35 mixin(Q_OBJECT); 36 37 protected: 38 /+ explicit +/this(QTextDocument doc); 39 mixin(mangleWindows("??1QTextObject@@MEAA@XZ", q{ 40 public ~this(); 41 })); 42 43 final void setFormat(ref const(QTextFormat) format); 44 45 public: 46 final QTextFormat format() const; 47 final int formatIndex() const; 48 49 final QTextDocument document() const; 50 51 final int objectIndex() const; 52 53 protected: 54 this(ref QTextObjectPrivate p, QTextDocument doc); 55 56 private: 57 /+ Q_DECLARE_PRIVATE(QTextObject) +/ 58 /+ Q_DISABLE_COPY(QTextObject) +/ 59 /+ friend class QTextDocumentPrivate; +/ 60 mixin(CREATE_CONVENIENCE_WRAPPERS); 61 } 62 63 extern(C++, class) struct QTextBlockGroupPrivate; 64 /// Binding for C++ class [QTextBlockGroup](https://doc.qt.io/qt-6/qtextblockgroup.html). 65 class /+ Q_GUI_EXPORT +/ QTextBlockGroup : QTextObject 66 { 67 mixin(Q_OBJECT); 68 69 protected: 70 /+ explicit +/this(QTextDocument doc); 71 ~this(); 72 73 /+ virtual +/ void blockInserted(ref const(QTextBlock) block); 74 /+ virtual +/ void blockRemoved(ref const(QTextBlock) block); 75 /+ virtual +/ void blockFormatChanged(ref const(QTextBlock) block); 76 77 final QList!(QTextBlock) blockList() const; 78 79 protected: 80 this(ref QTextBlockGroupPrivate p, QTextDocument doc); 81 private: 82 /+ Q_DECLARE_PRIVATE(QTextBlockGroup) +/ 83 /+ Q_DISABLE_COPY(QTextBlockGroup) +/ 84 /+ friend class QTextDocumentPrivate; +/ 85 mixin(CREATE_CONVENIENCE_WRAPPERS); 86 } 87 88 class /+ Q_GUI_EXPORT +/ QTextFrameLayoutData { 89 public: 90 /+ virtual +/~this(); 91 } 92 93 extern(C++, class) struct QTextFramePrivate; 94 /// Binding for C++ class [QTextFrame](https://doc.qt.io/qt-6/qtextframe.html). 95 class /+ Q_GUI_EXPORT +/ QTextFrame : QTextObject 96 { 97 mixin(Q_OBJECT); 98 99 public: 100 /+ explicit +/this(QTextDocument doc); 101 ~this(); 102 103 pragma(inline, true) final void setFrameFormat(ref const(QTextFrameFormat) aformat) 104 { QTextObject.setFormat(aformat); } 105 final QTextFrameFormat frameFormat() const { return QTextObject.format().toFrameFormat(); } 106 107 final QTextCursor firstCursorPosition() const; 108 final QTextCursor lastCursorPosition() const; 109 final int firstPosition() const; 110 final int lastPosition() const; 111 112 final QTextFrameLayoutData layoutData() const; 113 final void setLayoutData(QTextFrameLayoutData data); 114 115 final QList!(QTextFrame) childFrames() const; 116 final QTextFrame parentFrame() const; 117 118 extern(C++, class) struct iterator { 119 private: 120 QTextFrame f = null; 121 int b = 0; 122 int e = 0; 123 QTextFrame cf = null; 124 int cb = 0; 125 126 /+ friend class QTextFrame; +/ 127 /+ friend class QTextTableCell; +/ 128 /+ friend class QTextDocumentLayoutPrivate; +/ 129 pragma(inline, true) this(QTextFrame frame, int block, int begin, int end) 130 { 131 this.f = frame; 132 this.b = begin; 133 this.e = end; 134 this.cb = block; 135 } 136 public: 137 /+ constexpr iterator() noexcept = default; +/ 138 //QTextFrame parentFrame() const { return f; } 139 140 //QTextFrame currentFrame() const { return cf; } 141 /+ Q_GUI_EXPORT +/ QTextBlock currentBlock() const; 142 143 bool atEnd() const { return !cf && cb == e; } 144 145 /+pragma(inline, true) bool operator ==(ref const(iterator) o) const { return f == o.f && cf == o.cf && cb == o.cb; }+/ 146 /+pragma(inline, true) bool operator !=(ref const(iterator) o) const { return f != o.f || cf != o.cf || cb != o.cb; }+/ 147 /+ Q_GUI_EXPORT +/ ref iterator opUnary(string op)() if(op == "++"); 148 /+pragma(inline, true) iterator operator ++(int) { iterator tmp = this; operator++(); return tmp; }+/ 149 /+ Q_GUI_EXPORT +/ ref iterator opUnary(string op)() if(op == "--"); 150 /+pragma(inline, true) iterator operator --(int) { iterator tmp = this; operator--(); return tmp; }+/ 151 } 152 153 /+ friend class iterator; +/ 154 // more Qt 155 alias Iterator = iterator; 156 157 final iterator begin() const; 158 final iterator end() const; 159 160 protected: 161 this(ref QTextFramePrivate p, QTextDocument doc); 162 private: 163 /+ friend class QTextDocumentPrivate; +/ 164 /+ Q_DECLARE_PRIVATE(QTextFrame) +/ 165 /+ Q_DISABLE_COPY(QTextFrame) +/ 166 mixin(CREATE_CONVENIENCE_WRAPPERS); 167 } 168 /+ Q_DECLARE_TYPEINFO(QTextFrame::iterator, Q_RELOCATABLE_TYPE); +/ 169 170 /// Binding for C++ class [QTextBlockUserData](https://doc.qt.io/qt-6/qtextblockuserdata.html). 171 class /+ Q_GUI_EXPORT +/ QTextBlockUserData { 172 public: 173 /+ virtual +/~this(); 174 } 175 176 /// Binding for C++ class [QTextBlock](https://doc.qt.io/qt-6/qtextblock.html). 177 @Q_RELOCATABLE_TYPE extern(C++, class) struct /+ Q_GUI_EXPORT +/ QTextBlock 178 { 179 private: 180 /+ friend class QSyntaxHighlighter; +/ 181 public: 182 pragma(inline, true) this(QTextDocumentPrivate* priv, int b) 183 { 184 this.p = priv; 185 this.n = b; 186 } 187 /+pragma(inline, true) this() 188 { 189 this.p = null; 190 this.n = 0; 191 }+/ 192 pragma(inline, true) this(ref const(QTextBlock) o) 193 { 194 this.p = cast(QTextDocumentPrivate*)o.p; 195 this.n = o.n; 196 } 197 /+pragma(inline, true) ref QTextBlock operator =(ref const(QTextBlock) o) { p = o.p; n = o.n; return this; }+/ 198 199 bool isValid() const; 200 201 /+pragma(inline, true) bool operator ==(ref const(QTextBlock) o) const { return p == o.p && n == o.n; }+/ 202 /+pragma(inline, true) bool operator !=(ref const(QTextBlock) o) const { return p != o.p || n != o.n; }+/ 203 /+pragma(inline, true) bool operator <(ref const(QTextBlock) o) const { return position() < o.position(); }+/ 204 205 int position() const; 206 int length() const; 207 bool contains(int position) const; 208 209 QTextLayout* layout() const; 210 void clearLayout(); 211 QTextBlockFormat blockFormat() const; 212 int blockFormatIndex() const; 213 QTextCharFormat charFormat() const; 214 int charFormatIndex() const; 215 216 /+ Qt:: +/qt.core.namespace.LayoutDirection textDirection() const; 217 218 QString text() const; 219 220 QList!(QTextLayout.FormatRange) textFormats() const; 221 222 mixin(changeWindowsMangling(q{mangleClassesTailConst}, q{ 223 const(QTextDocument) document() const; 224 })); 225 226 QTextList textList() const; 227 228 QTextBlockUserData userData() const; 229 void setUserData(QTextBlockUserData data); 230 231 int userState() const; 232 void setUserState(int state); 233 234 int revision() const; 235 void setRevision(int rev); 236 237 bool isVisible() const; 238 void setVisible(bool visible); 239 240 int blockNumber() const; 241 int firstLineNumber() const; 242 243 void setLineCount(int count); 244 int lineCount() const; 245 246 extern(C++, class) struct iterator { 247 private: 248 const(QTextDocumentPrivate)* p = null; 249 int b = 0; 250 int e = 0; 251 int n = 0; 252 /+ friend class QTextBlock; +/ 253 this(const(QTextDocumentPrivate)* priv, int begin, int end, int f) 254 { 255 this.p = priv; 256 this.b = begin; 257 this.e = end; 258 this.n = f; 259 } 260 public: 261 /+ constexpr iterator() = default; +/ 262 263 /+ Q_GUI_EXPORT +/ QTextFragment fragment() const; 264 265 bool atEnd() const { return n == e; } 266 267 /+pragma(inline, true) bool operator ==(ref const(iterator) o) const { return p == o.p && n == o.n; }+/ 268 /+pragma(inline, true) bool operator !=(ref const(iterator) o) const { return p != o.p || n != o.n; }+/ 269 /+ Q_GUI_EXPORT +/ ref iterator opUnary(string op)() if(op == "++"); 270 /+pragma(inline, true) iterator operator ++(int) { iterator tmp = this; operator++(); return tmp; }+/ 271 /+ Q_GUI_EXPORT +/ ref iterator opUnary(string op)() if(op == "--"); 272 /+pragma(inline, true) iterator operator --(int) { iterator tmp = this; operator--(); return tmp; }+/ 273 } 274 275 // more Qt 276 alias Iterator = iterator; 277 278 iterator begin() const; 279 iterator end() const; 280 281 QTextBlock next() const; 282 QTextBlock previous() const; 283 284 pragma(inline, true) int fragmentIndex() const { return n; } 285 286 private: 287 QTextDocumentPrivate* p = null; 288 int n = 0; 289 /+ friend class QTextDocumentPrivate; +/ 290 /+ friend class QTextLayout; +/ 291 mixin(CREATE_CONVENIENCE_WRAPPERS); 292 } 293 294 /+ Q_DECLARE_TYPEINFO(QTextBlock, Q_RELOCATABLE_TYPE); 295 Q_DECLARE_TYPEINFO(QTextBlock::iterator, Q_RELOCATABLE_TYPE); +/ 296 297 298 /// Binding for C++ class [QTextFragment](https://doc.qt.io/qt-6/qtextfragment.html). 299 @Q_RELOCATABLE_TYPE extern(C++, class) struct /+ Q_GUI_EXPORT +/ QTextFragment 300 { 301 public: 302 pragma(inline, true) this(const(QTextDocumentPrivate)* priv, int f, int fe) 303 { 304 this.p = priv; 305 this.n = f; 306 this.ne = fe; 307 } 308 @disable this(); 309 /+pragma(inline, true) this() 310 { 311 this.p = null; 312 this.n = 0; 313 this.ne = 0; 314 }+/ 315 @disable this(this); 316 pragma(inline, true) this(ref const(QTextFragment) o) 317 { 318 this.p = o.p; 319 this.n = o.n; 320 this.ne = o.ne; 321 } 322 /+pragma(inline, true) ref QTextFragment operator =(ref const(QTextFragment) o) { p = o.p; n = o.n; ne = o.ne; return this; }+/ 323 324 pragma(inline, true) bool isValid() const { return p && n; } 325 326 /+pragma(inline, true) bool operator ==(ref const(QTextFragment) o) const { return p == o.p && n == o.n; }+/ 327 /+pragma(inline, true) bool operator !=(ref const(QTextFragment) o) const { return p != o.p || n != o.n; }+/ 328 /+pragma(inline, true) bool operator <(ref const(QTextFragment) o) const { return position() < o.position(); }+/ 329 330 int position() const; 331 int length() const; 332 bool contains(int position) const; 333 334 QTextCharFormat charFormat() const; 335 int charFormatIndex() const; 336 QString text() const; 337 338 version(QT_NO_RAWFONT){}else 339 { 340 QList!(QGlyphRun) glyphRuns(int from = -1, int length = -1) const; 341 } 342 343 private: 344 const(QTextDocumentPrivate)* p = null; 345 int n = 0; 346 int ne = 0; 347 mixin(CREATE_CONVENIENCE_WRAPPERS); 348 } 349 350 /+ Q_DECLARE_TYPEINFO(QTextFragment, Q_RELOCATABLE_TYPE); +/ 351