qsciprinter.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // This module defines interface to the QsciPrinter class.
  2. //
  3. // Copyright (c) 2017 Riverbank Computing Limited <info@riverbankcomputing.com>
  4. //
  5. // This file is part of QScintilla.
  6. //
  7. // This file may be used under the terms of the GNU General Public License
  8. // version 3.0 as published by the Free Software Foundation and appearing in
  9. // the file LICENSE included in the packaging of this file. Please review the
  10. // following information to ensure the GNU General Public License version 3.0
  11. // requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  12. //
  13. // If you do not wish to use this file under the terms of the GPL version 3.0
  14. // then you may purchase a commercial license. For more information contact
  15. // info@riverbankcomputing.com.
  16. //
  17. // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  18. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  19. #ifndef QSCIPRINTER_H
  20. #define QSCIPRINTER_H
  21. // This is needed for Qt v5.0.0-alpha.
  22. #if defined(B0)
  23. #undef B0
  24. #endif
  25. #include <qprinter.h>
  26. #if !defined(QT_NO_PRINTER)
  27. #include <Qsci/qsciglobal.h>
  28. #include <Qsci/qsciscintilla.h>
  29. QT_BEGIN_NAMESPACE
  30. class QRect;
  31. class QPainter;
  32. QT_END_NAMESPACE
  33. class QsciScintillaBase;
  34. //! \brief The QsciPrinter class is a sub-class of the Qt QPrinter class that
  35. //! is able to print the text of a Scintilla document.
  36. //!
  37. //! The class can be further sub-classed to alter to layout of the text, adding
  38. //! headers and footers for example.
  39. class QSCINTILLA_EXPORT QsciPrinter : public QPrinter
  40. {
  41. public:
  42. //! Constructs a printer paint device with mode \a mode.
  43. QsciPrinter(PrinterMode mode = ScreenResolution);
  44. //! Destroys the QsciPrinter instance.
  45. virtual ~QsciPrinter();
  46. //! Format a page, by adding headers and footers for example, before the
  47. //! document text is drawn on it. \a painter is the painter to be used to
  48. //! add customised text and graphics. \a drawing is true if the page is
  49. //! actually being drawn rather than being sized. \a painter drawing
  50. //! methods must only be called when \a drawing is true. \a area is the
  51. //! area of the page that will be used to draw the text. This should be
  52. //! modified if it is necessary to reserve space for any customised text or
  53. //! graphics. By default the area is relative to the printable area of the
  54. //! page. Use QPrinter::setFullPage() because calling printRange() if you
  55. //! want to try and print over the whole page. \a pagenr is the number of
  56. //! the page. The first page is numbered 1.
  57. virtual void formatPage(QPainter &painter, bool drawing, QRect &area,
  58. int pagenr);
  59. //! Return the number of points to add to each font when printing.
  60. //!
  61. //! \sa setMagnification()
  62. int magnification() const {return mag;}
  63. //! Sets the number of points to add to each font when printing to \a
  64. //! magnification.
  65. //!
  66. //! \sa magnification()
  67. virtual void setMagnification(int magnification);
  68. //! Print a range of lines from the Scintilla instance \a qsb. \a from is
  69. //! the first line to print and a negative value signifies the first line
  70. //! of text. \a to is the last line to print and a negative value
  71. //! signifies the last line of text. true is returned if there was no
  72. //! error.
  73. virtual int printRange(QsciScintillaBase *qsb, int from = -1, int to = -1);
  74. //! Return the line wrap mode used when printing. The default is
  75. //! QsciScintilla::WrapWord.
  76. //!
  77. //! \sa setWrapMode()
  78. QsciScintilla::WrapMode wrapMode() const {return wrap;}
  79. //! Sets the line wrap mode used when printing to \a wmode.
  80. //!
  81. //! \sa wrapMode()
  82. virtual void setWrapMode(QsciScintilla::WrapMode wmode);
  83. private:
  84. int mag;
  85. QsciScintilla::WrapMode wrap;
  86. QsciPrinter(const QsciPrinter &);
  87. QsciPrinter &operator=(const QsciPrinter &);
  88. };
  89. #endif
  90. #endif