File: pqPythonLineNumberArea.h

package info (click to toggle)
paraview 5.13.2%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 544,220 kB
  • sloc: cpp: 3,374,605; ansic: 1,332,409; python: 150,381; xml: 122,166; sql: 65,887; sh: 7,317; javascript: 5,262; yacc: 4,417; java: 3,977; perl: 2,363; lex: 1,929; f90: 1,397; makefile: 170; objc: 153; tcl: 59; pascal: 50; fortran: 29
file content (63 lines) | stat: -rw-r--r-- 1,754 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
// SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
// SPDX-License-Identifier: BSD-3-Clause

#ifndef pqPythonLineNumberArea_h
#define pqPythonLineNumberArea_h

#include "pqPythonModule.h"

#include <QWidget>

class QTextEdit;

/**
 * @class pqPythonLineNumberArea
 * @brief QWidget that displays line number for a QTextEdit.
 * @details This widget is to be associated with a QTextEdit
 * widget (stored as text) this class. It displays the number
 * of lines inside the text and highlight the line where the
 * cursor is.
 *
 * This must be used inside a QHLayout and placed either left
 * or right of the refered text. The paintEvent is in charge
 * of painting this widget.
 */
class PQPYTHON_EXPORT pqPythonLineNumberArea : public QWidget
{
  Q_OBJECT

public:
  /* @brief Constructs a pqPythonLineNumberArea given a text
   * @param parent the parent widget for the Qt ownership
   * @param text the text to display the line from
   */
  explicit pqPythonLineNumberArea(QWidget* parent, const QTextEdit& text)
    : QWidget(parent)
    , TextEdit(text)
  {
  }

  /**
   * @brief Return the size hint based on the number of lines present in the text
   */
  QSize sizeHint() const override;

protected:
  /** @brief Paint the widget
   * @details This method paints the widget area by going through the
   * visible block inside text. Are displayed the line number from
   * the text in one color and the line containing the cursor
   * in another color.
   * @param event the pain event
   */
  void paintEvent(QPaintEvent* event) override;

private:
  /**
   * @brief The text to display the number of line on
   */
  const QTextEdit& TextEdit;
};

#endif // pqPythonLineNumberArea_h