qtextlayout.sip 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. // qtextlayout.sip generated by MetaSIP
  2. //
  3. // This file is part of the QtGui Python extension module.
  4. //
  5. // Copyright (c) 2026 Riverbank Computing Limited <info@riverbankcomputing.com>
  6. //
  7. // This file is part of PyQt6.
  8. //
  9. // This file may be used under the terms of the GNU General Public License
  10. // version 3.0 as published by the Free Software Foundation and appearing in
  11. // the file LICENSE included in the packaging of this file. Please review the
  12. // following information to ensure the GNU General Public License version 3.0
  13. // requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  14. //
  15. // If you do not wish to use this file under the terms of the GPL version 3.0
  16. // then you may purchase a commercial license. For more information contact
  17. // info@riverbankcomputing.com.
  18. //
  19. // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  20. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  21. class QTextInlineObject
  22. {
  23. %TypeHeaderCode
  24. #include <qtextlayout.h>
  25. %End
  26. public:
  27. bool isValid() const;
  28. QRectF rect() const;
  29. qreal width() const;
  30. qreal ascent() const;
  31. qreal descent() const;
  32. qreal height() const;
  33. Qt::LayoutDirection textDirection() const;
  34. void setWidth(qreal w);
  35. void setAscent(qreal a);
  36. void setDescent(qreal d);
  37. int textPosition() const;
  38. int formatIndex() const;
  39. QTextFormat format() const;
  40. };
  41. class QTextLayout
  42. {
  43. %TypeHeaderCode
  44. #include <qtextlayout.h>
  45. %End
  46. public:
  47. QTextLayout();
  48. QTextLayout(const QString &text);
  49. QTextLayout(const QString &text, const QFont &font, const QPaintDevice *paintdevice = 0);
  50. QTextLayout(const QTextBlock &b);
  51. ~QTextLayout();
  52. void setFont(const QFont &f);
  53. QFont font() const;
  54. void setText(const QString &string);
  55. QString text() const;
  56. void setTextOption(const QTextOption &option);
  57. const QTextOption &textOption() const;
  58. void setPreeditArea(int position, const QString &text);
  59. int preeditAreaPosition() const;
  60. QString preeditAreaText() const;
  61. struct FormatRange
  62. {
  63. %TypeHeaderCode
  64. #include <qtextlayout.h>
  65. %End
  66. int start;
  67. int length;
  68. QTextCharFormat format;
  69. };
  70. void setCacheEnabled(bool enable);
  71. bool cacheEnabled() const;
  72. void beginLayout();
  73. void endLayout();
  74. QTextLine createLine();
  75. int lineCount() const;
  76. QTextLine lineAt(int i) const;
  77. QTextLine lineForTextPosition(int pos) const;
  78. enum CursorMode
  79. {
  80. SkipCharacters,
  81. SkipWords,
  82. };
  83. bool isValidCursorPosition(int pos) const;
  84. int nextCursorPosition(int oldPos, QTextLayout::CursorMode mode = QTextLayout::SkipCharacters) const;
  85. int previousCursorPosition(int oldPos, QTextLayout::CursorMode mode = QTextLayout::SkipCharacters) const;
  86. void draw(QPainter *p, const QPointF &pos, const QList<QTextLayout::FormatRange> &selections = QList<QTextLayout::FormatRange>(), const QRectF &clip = QRectF()) const;
  87. void drawCursor(QPainter *p, const QPointF &pos, int cursorPosition) const;
  88. void drawCursor(QPainter *p, const QPointF &pos, int cursorPosition, int width) const;
  89. QPointF position() const;
  90. void setPosition(const QPointF &p);
  91. QRectF boundingRect() const;
  92. qreal minimumWidth() const;
  93. qreal maximumWidth() const;
  94. void clearLayout();
  95. void setCursorMoveStyle(Qt::CursorMoveStyle style);
  96. Qt::CursorMoveStyle cursorMoveStyle() const;
  97. int leftCursorPosition(int oldPos) const;
  98. int rightCursorPosition(int oldPos) const;
  99. %If (PyQt_RawFont)
  100. QList<QGlyphRun> glyphRuns(int from = -1, int length = -1) const;
  101. %End
  102. %If (Qt_6_5_0 -)
  103. QList<QGlyphRun> glyphRuns(int from, int length, QTextLayout::GlyphRunRetrievalFlags flags) const;
  104. %End
  105. void setFormats(const QList<QTextLayout::FormatRange> &overrides);
  106. QList<QTextLayout::FormatRange> formats() const;
  107. void clearFormats();
  108. %If (Qt_6_5_0 -)
  109. enum GlyphRunRetrievalFlag : quint16
  110. {
  111. RetrieveGlyphIndexes,
  112. RetrieveGlyphPositions,
  113. RetrieveStringIndexes,
  114. RetrieveString,
  115. DefaultRetrievalFlags,
  116. RetrieveAll,
  117. };
  118. %End
  119. %If (Qt_6_5_0 -)
  120. typedef QFlags<QTextLayout::GlyphRunRetrievalFlag> GlyphRunRetrievalFlags;
  121. %End
  122. private:
  123. QTextLayout(const QTextLayout &);
  124. };
  125. class QTextLine
  126. {
  127. %TypeHeaderCode
  128. #include <qtextlayout.h>
  129. %End
  130. public:
  131. QTextLine();
  132. bool isValid() const;
  133. QRectF rect() const;
  134. qreal x() const;
  135. qreal y() const;
  136. qreal width() const;
  137. qreal ascent() const;
  138. qreal descent() const;
  139. qreal height() const;
  140. qreal naturalTextWidth() const;
  141. QRectF naturalTextRect() const;
  142. enum Edge
  143. {
  144. Leading,
  145. Trailing,
  146. };
  147. enum CursorPosition
  148. {
  149. CursorBetweenCharacters,
  150. CursorOnCharacter,
  151. };
  152. qreal cursorToX(int *cursorPos /In,Out/, QTextLine::Edge edge = QTextLine::Leading) const;
  153. int xToCursor(qreal x, QTextLine::CursorPosition edge = QTextLine::CursorBetweenCharacters) const;
  154. void setLineWidth(qreal width);
  155. void setNumColumns(int columns);
  156. void setNumColumns(int columns, qreal alignmentWidth);
  157. void setPosition(const QPointF &pos);
  158. int textStart() const;
  159. int textLength() const;
  160. int lineNumber() const;
  161. void draw(QPainter *painter, const QPointF &position) const;
  162. QPointF position() const;
  163. qreal leading() const;
  164. void setLeadingIncluded(bool included);
  165. bool leadingIncluded() const;
  166. qreal horizontalAdvance() const;
  167. %If (PyQt_RawFont)
  168. QList<QGlyphRun> glyphRuns(int from = -1, int length = -1) const;
  169. %End
  170. %If (Qt_6_5_0 -)
  171. QList<QGlyphRun> glyphRuns(int from, int length, QTextLayout::GlyphRunRetrievalFlags flags) const;
  172. %End
  173. };
  174. bool operator==(const QTextLayout::FormatRange &lhs, const QTextLayout::FormatRange &rhs);
  175. bool operator!=(const QTextLayout::FormatRange &lhs, const QTextLayout::FormatRange &rhs);