vtextdocumentlayoutdata.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #ifndef VTEXTDOCUMENTLAYOUTDATA_H
  2. #define VTEXTDOCUMENTLAYOUTDATA_H
  3. // Denote the start and end position of a marker line.
  4. struct Marker
  5. {
  6. QPointF m_start;
  7. QPointF m_end;
  8. };
  9. struct ImagePaintInfo
  10. {
  11. // The rect to draw the image.
  12. QRectF m_rect;
  13. // Name of the image.
  14. QString m_name;
  15. // Forced background.
  16. QColor m_background;
  17. bool isValid() const
  18. {
  19. return !m_name.isEmpty();
  20. }
  21. bool hasForcedBackground() const
  22. {
  23. return m_background.isValid();
  24. }
  25. };
  26. struct BlockLayoutInfo
  27. {
  28. BlockLayoutInfo()
  29. : m_offset(-1)
  30. {
  31. }
  32. void reset()
  33. {
  34. m_offset = -1;
  35. m_rect = QRectF();
  36. m_markers.clear();
  37. m_images.clear();
  38. }
  39. bool isNull() const
  40. {
  41. return m_rect.isNull();
  42. }
  43. bool hasOffset() const
  44. {
  45. return m_offset > -1 && !m_rect.isNull();
  46. }
  47. qreal top() const
  48. {
  49. Q_ASSERT(hasOffset());
  50. return m_offset;
  51. }
  52. qreal bottom() const
  53. {
  54. Q_ASSERT(hasOffset());
  55. return m_offset + m_rect.height();
  56. }
  57. // Y offset of this block.
  58. // -1 for invalid.
  59. qreal m_offset;
  60. // The bounding rect of this block, including the margins.
  61. // Null for invalid.
  62. QRectF m_rect;
  63. // Markers to draw for this block.
  64. // Y is the offset within this block.
  65. QVector<Marker> m_markers;
  66. // Images to draw for this block.
  67. // Y is the offset within this block.
  68. QVector<ImagePaintInfo> m_images;
  69. };
  70. #endif // VTEXTDOCUMENTLAYOUTDATA_H