qtextobject.sip 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. // qtextobject.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 QTextObject : public QObject
  22. {
  23. %TypeHeaderCode
  24. #include <qtextobject.h>
  25. %End
  26. protected:
  27. explicit QTextObject(QTextDocument *doc);
  28. virtual ~QTextObject();
  29. void setFormat(const QTextFormat &format);
  30. public:
  31. QTextFormat format() const;
  32. int formatIndex() const;
  33. QTextDocument *document() const;
  34. int objectIndex() const;
  35. };
  36. class QTextBlockGroup : public QTextObject
  37. {
  38. %TypeHeaderCode
  39. #include <qtextobject.h>
  40. %End
  41. protected:
  42. explicit QTextBlockGroup(QTextDocument *doc);
  43. virtual ~QTextBlockGroup();
  44. virtual void blockInserted(const QTextBlock &block);
  45. virtual void blockRemoved(const QTextBlock &block);
  46. virtual void blockFormatChanged(const QTextBlock &block);
  47. QList<QTextBlock> blockList() const;
  48. };
  49. class QTextFrame : public QTextObject
  50. {
  51. %TypeHeaderCode
  52. #include <qtextobject.h>
  53. %End
  54. public:
  55. explicit QTextFrame(QTextDocument *doc);
  56. virtual ~QTextFrame();
  57. QTextFrameFormat frameFormat() const;
  58. QTextCursor firstCursorPosition() const;
  59. QTextCursor lastCursorPosition() const;
  60. int firstPosition() const;
  61. int lastPosition() const;
  62. QList<QTextFrame *> childFrames() const;
  63. QTextFrame *parentFrame() const;
  64. class iterator
  65. {
  66. %TypeHeaderCode
  67. #include <qtextobject.h>
  68. %End
  69. public:
  70. iterator();
  71. QTextFrame *parentFrame() const;
  72. QTextFrame *currentFrame() const;
  73. QTextBlock currentBlock() const;
  74. bool atEnd() const;
  75. bool operator==(const QTextFrame::iterator &o) const;
  76. bool operator!=(const QTextFrame::iterator &o) const;
  77. QTextFrame::iterator &operator+=(int);
  78. %MethodCode
  79. if (a0 > 0)
  80. while (a0--)
  81. (*sipCpp)++;
  82. else if (a0 < 0)
  83. while (a0++)
  84. (*sipCpp)--;
  85. %End
  86. QTextFrame::iterator &operator-=(int);
  87. %MethodCode
  88. if (a0 > 0)
  89. while (a0--)
  90. (*sipCpp)--;
  91. else if (a0 < 0)
  92. while (a0++)
  93. (*sipCpp)++;
  94. %End
  95. };
  96. typedef QTextFrame::iterator Iterator;
  97. QTextFrame::iterator begin() const;
  98. QTextFrame::iterator end() const;
  99. void setFrameFormat(const QTextFrameFormat &aformat);
  100. };
  101. class QTextBlock /Supertype=PyQt6.sip.wrapper/
  102. {
  103. %TypeHeaderCode
  104. #include <qtextobject.h>
  105. %End
  106. public:
  107. QTextBlock();
  108. QTextBlock(const QTextBlock &o);
  109. bool isValid() const;
  110. bool operator==(const QTextBlock &o) const;
  111. bool operator!=(const QTextBlock &o) const;
  112. bool operator<(const QTextBlock &o) const;
  113. int position() const;
  114. int length() const;
  115. bool contains(int position) const;
  116. QTextLayout *layout() const;
  117. QTextBlockFormat blockFormat() const;
  118. int blockFormatIndex() const;
  119. QTextCharFormat charFormat() const;
  120. int charFormatIndex() const;
  121. QString text() const;
  122. const QTextDocument *document() const;
  123. QTextList *textList() const;
  124. class iterator
  125. {
  126. %TypeHeaderCode
  127. #include <qtextobject.h>
  128. %End
  129. public:
  130. iterator();
  131. QTextFragment fragment() const;
  132. bool atEnd() const;
  133. bool operator==(const QTextBlock::iterator &o) const;
  134. bool operator!=(const QTextBlock::iterator &o) const;
  135. QTextBlock::iterator &operator+=(int);
  136. %MethodCode
  137. if (a0 > 0)
  138. while (a0--)
  139. (*sipCpp)++;
  140. else if (a0 < 0)
  141. while (a0++)
  142. (*sipCpp)--;
  143. %End
  144. QTextBlock::iterator &operator-=(int);
  145. %MethodCode
  146. if (a0 > 0)
  147. while (a0--)
  148. (*sipCpp)--;
  149. else if (a0 < 0)
  150. while (a0++)
  151. (*sipCpp)++;
  152. %End
  153. };
  154. typedef QTextBlock::iterator Iterator;
  155. QTextBlock::iterator begin() const;
  156. QTextBlock::iterator end() const;
  157. QTextBlock next() const;
  158. QTextBlock previous() const;
  159. QTextBlockUserData *userData() const;
  160. void setUserData(QTextBlockUserData *data /GetWrapper/);
  161. %MethodCode
  162. // Ownership of the user data is with the document not the text block.
  163. const QTextDocument *td = sipCpp->document();
  164. if (td)
  165. {
  166. PyObject *py_td = qtgui_wrap_ancestors(const_cast<QTextDocument *>(td),
  167. sipType_QTextDocument);
  168. if (!py_td)
  169. {
  170. sipIsErr = 1;
  171. }
  172. else
  173. {
  174. sipTransferTo(a0Wrapper, py_td);
  175. Py_DECREF(py_td);
  176. }
  177. }
  178. sipCpp->setUserData(a0);
  179. %End
  180. int userState() const;
  181. void setUserState(int state);
  182. void clearLayout();
  183. int revision() const;
  184. void setRevision(int rev);
  185. bool isVisible() const;
  186. void setVisible(bool visible);
  187. int blockNumber() const;
  188. int firstLineNumber() const;
  189. void setLineCount(int count);
  190. int lineCount() const;
  191. Qt::LayoutDirection textDirection() const;
  192. QList<QTextLayout::FormatRange> textFormats() const;
  193. };
  194. class QTextFragment
  195. {
  196. %TypeHeaderCode
  197. #include <qtextobject.h>
  198. %End
  199. public:
  200. QTextFragment();
  201. QTextFragment(const QTextFragment &o);
  202. bool isValid() const;
  203. bool operator==(const QTextFragment &o) const;
  204. bool operator!=(const QTextFragment &o) const;
  205. bool operator<(const QTextFragment &o) const;
  206. int position() const;
  207. int length() const;
  208. bool contains(int position) const;
  209. QTextCharFormat charFormat() const;
  210. int charFormatIndex() const;
  211. QString text() const;
  212. %If (PyQt_RawFont)
  213. QList<QGlyphRun> glyphRuns(int from = -1, int length = -1) const;
  214. %End
  215. };
  216. class QTextBlockUserData /Supertype=PyQt6.sip.wrapper/
  217. {
  218. %TypeHeaderCode
  219. #include <qtextobject.h>
  220. %End
  221. public:
  222. virtual ~QTextBlockUserData();
  223. };
  224. %ModuleHeaderCode
  225. PyObject *qtgui_wrap_ancestors(QObject *obj, const sipTypeDef *td);
  226. %End
  227. %ModuleCode
  228. // Wrap a QObject and ensure that it's ancestors are all wrapped with the
  229. // correct ownerships.
  230. static PyObject *qtgui_wrap_ancestors_worker(QObject *obj)
  231. {
  232. if (!obj)
  233. {
  234. Py_INCREF(Py_None);
  235. return Py_None;
  236. }
  237. PyObject *py_parent = qtgui_wrap_ancestors_worker(obj->parent());
  238. if (!py_parent)
  239. return 0;
  240. PyObject *py_obj = sipConvertFromType(obj, sipType_QObject,
  241. (py_parent != Py_None ? py_parent : 0));
  242. Py_DECREF(py_parent);
  243. return py_obj;
  244. }
  245. PyObject *qtgui_wrap_ancestors(QObject *obj, const sipTypeDef *td)
  246. {
  247. PyObject *py_parent = qtgui_wrap_ancestors_worker(obj->parent());
  248. if (!py_parent)
  249. return 0;
  250. PyObject *py_obj = sipConvertFromType(obj, td,
  251. (py_parent != Py_None ? py_parent : 0));
  252. Py_DECREF(py_parent);
  253. return py_obj;
  254. }
  255. %End