qscistyle.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. // This module defines interface to the QsciStyle 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 QSCISTYLE_H
  20. #define QSCISTYLE_H
  21. #include <qcolor.h>
  22. #include <qfont.h>
  23. #include <qstring.h>
  24. #include <Qsci/qsciglobal.h>
  25. class QsciScintillaBase;
  26. //! \brief The QsciStyle class encapsulates all the attributes of a style.
  27. //!
  28. //! Each character of a document has an associated style which determines how
  29. //! the character is displayed, e.g. its font and color. A style is identified
  30. //! by a number. Lexers define styles for each of the language's features so
  31. //! that they are displayed differently. Some style numbers have hard-coded
  32. //! meanings, e.g. the style used for call tips.
  33. class QSCINTILLA_EXPORT QsciStyle
  34. {
  35. public:
  36. //! This enum defines the different ways the displayed case of the text can
  37. //! be changed.
  38. enum TextCase {
  39. //! The text is displayed as its original case.
  40. OriginalCase = 0,
  41. //! The text is displayed as upper case.
  42. UpperCase = 1,
  43. //! The text is displayed as lower case.
  44. LowerCase = 2
  45. };
  46. //! Constructs a QsciStyle instance for style number \a style. If \a style
  47. //! is negative then a new style number is automatically allocated.
  48. QsciStyle(int style = -1);
  49. //! Constructs a QsciStyle instance for style number \a style. If \a style
  50. //! is negative then a new style number is automatically allocated. The
  51. //! styles description, color, paper color, font and end-of-line fill are
  52. //! set to \a description, \a color, \a paper, \a font and \a eolFill
  53. //! respectively.
  54. QsciStyle(int style, const QString &description, const QColor &color,
  55. const QColor &paper, const QFont &font, bool eolFill = false);
  56. //! \internal Apply the style to a particular editor.
  57. void apply(QsciScintillaBase *sci) const;
  58. //! Returns the number of the style.
  59. int style() const {return style_nr;}
  60. //! The style's description is set to \a description.
  61. //!
  62. //! \sa description()
  63. void setDescription(const QString &description) {style_description = description;}
  64. //! Returns the style's description.
  65. //!
  66. //! \sa setDescription()
  67. QString description() const {return style_description;}
  68. //! The style's foreground color is set to \a color. The default is taken
  69. //! from the application's default palette.
  70. //!
  71. //! \sa color()
  72. void setColor(const QColor &color);
  73. //! Returns the style's foreground color.
  74. //!
  75. //! \sa setColor()
  76. QColor color() const {return style_color;}
  77. //! The style's background color is set to \a paper. The default is taken
  78. //! from the application's default palette.
  79. //!
  80. //! \sa paper()
  81. void setPaper(const QColor &paper);
  82. //! Returns the style's background color.
  83. //!
  84. //! \sa setPaper()
  85. QColor paper() const {return style_paper;}
  86. //! The style's font is set to \a font. The default is the application's
  87. //! default font.
  88. //!
  89. //! \sa font()
  90. void setFont(const QFont &font);
  91. //! Returns the style's font.
  92. //!
  93. //! \sa setFont()
  94. QFont font() const {return style_font;}
  95. //! The style's end-of-line fill is set to \a fill. The default is false.
  96. //!
  97. //! \sa eolFill()
  98. void setEolFill(bool fill);
  99. //! Returns the style's end-of-line fill.
  100. //!
  101. //! \sa setEolFill()
  102. bool eolFill() const {return style_eol_fill;}
  103. //! The style's text case is set to \a text_case. The default is
  104. //! OriginalCase.
  105. //!
  106. //! \sa textCase()
  107. void setTextCase(TextCase text_case);
  108. //! Returns the style's text case.
  109. //!
  110. //! \sa setTextCase()
  111. TextCase textCase() const {return style_case;}
  112. //! The style's visibility is set to \a visible. The default is true.
  113. //!
  114. //! \sa visible()
  115. void setVisible(bool visible);
  116. //! Returns the style's visibility.
  117. //!
  118. //! \sa setVisible()
  119. bool visible() const {return style_visible;}
  120. //! The style's changeability is set to \a changeable. The default is
  121. //! true.
  122. //!
  123. //! \sa changeable()
  124. void setChangeable(bool changeable);
  125. //! Returns the style's changeability.
  126. //!
  127. //! \sa setChangeable()
  128. bool changeable() const {return style_changeable;}
  129. //! The style's sensitivity to mouse clicks is set to \a hotspot. The
  130. //! default is false.
  131. //!
  132. //! \sa hotspot()
  133. void setHotspot(bool hotspot);
  134. //! Returns the style's sensitivity to mouse clicks.
  135. //!
  136. //! \sa setHotspot()
  137. bool hotspot() const {return style_hotspot;}
  138. //! Refresh the style settings.
  139. void refresh();
  140. private:
  141. int style_nr;
  142. QString style_description;
  143. QColor style_color;
  144. QColor style_paper;
  145. QFont style_font;
  146. bool style_eol_fill;
  147. TextCase style_case;
  148. bool style_visible;
  149. bool style_changeable;
  150. bool style_hotspot;
  151. void init(int style);
  152. };
  153. #endif