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
|