BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
importtextview.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file gui2/dataloader/importtextview.h
6 //! @brief Defines class CLASS?
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2020
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_GUI2_DATALOADER_IMPORTTEXTVIEW_H
16 #define BORNAGAIN_GUI2_DATALOADER_IMPORTTEXTVIEW_H
17 
18 #include "darefl_export.h"
19 
20 //! Based on Qt example "codeeditor"
21 //! Copyright (C) 2016 The Qt Company Ltd.
22 
23 #include <QPlainTextEdit>
24 
25 class QPaintEvent;
26 class QResizeEvent;
27 class QSize;
28 class QWidget;
29 
30 namespace gui2 {
31 
32 class LineNumberArea;
33 
34 //! Text view to show imported data.
35 
36 class DAREFLCORE_EXPORT ImportTextView : public QPlainTextEdit {
37  Q_OBJECT
38 
39 public:
40  ImportTextView(QWidget* parent = nullptr);
41 
42  void lineNumberAreaPaintEvent(QPaintEvent* event);
43  int lineNumberAreaWidth();
44 
45 protected:
46  void resizeEvent(QResizeEvent* event) override;
47 
48 private slots:
49  void updateLineNumberAreaWidth(int newBlockCount);
50  void highlightCurrentLine();
51  void updateLineNumberArea(const QRect& rect, int dy);
52 
53 private:
54  QWidget* lineNumberArea;
55 };
56 
57 //! Area with line numbers.
58 
59 class DAREFLCORE_EXPORT LineNumberArea : public QWidget {
60 public:
61  LineNumberArea(ImportTextView* editor) : QWidget(editor), codeEditor(editor) {}
62 
63  QSize sizeHint() const override { return QSize(codeEditor->lineNumberAreaWidth(), 0); }
64 
65 protected:
66  void paintEvent(QPaintEvent* event) override { codeEditor->lineNumberAreaPaintEvent(event); }
67 
68 private:
70 };
71 
72 } // namespace gui2
73 
74 #endif // BORNAGAIN_GUI2_DATALOADER_IMPORTTEXTVIEW_H
Text view to show imported data.
Area with line numbers.
LineNumberArea(ImportTextView *editor)
QSize sizeHint() const override
ImportTextView * codeEditor
void paintEvent(QPaintEvent *event) override
Based on Qt example "codeeditor" Copyright (C) 2016 The Qt Company Ltd.
Definition: app_constants.h:20