itom  3.0.0
abstractPyScintillaWidget.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2016, Institut fuer Technische Optik (ITO),
5  Universitaet Stuttgart, Germany
6 
7  This file is part of itom.
8 
9  itom is free software; you can redistribute it and/or modify it
10  under the terms of the GNU Library General Public Licence as published by
11  the Free Software Foundation; either version 2 of the Licence, or (at
12  your option) any later version.
13 
14  itom is distributed in the hope that it will be useful, but
15  WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
17  General Public Licence for more details.
18 
19  You should have received a copy of the GNU Library General Public License
20  along with itom. If not, see <http://www.gnu.org/licenses/>.
21 *********************************************************************** */
22 
23 #ifndef ABSTRACTPYSCINTILLAWIDGET
24 #define ABSTRACTPYSCINTILLAWIDGET
25 
26 #include "../common/sharedStructures.h"
27 
28 // Under Windows, define QSCINTILLA_MAKE_DLL to create a Scintilla DLL, or
29 // define QSCINTILLA_DLL to link against a Scintilla DLL, or define neither
30 // to either build or link against a static Scintilla library.
32 #define QSCINTILLA_DLL //http://www.riverbankcomputing.com/pipermail/qscintilla/2007-March/000034.html
33 
34 #include <Qsci/qsciscintilla.h>
35 #include <Qsci/qscilexerpython.h>
36 #include <Qsci/qsciapis.h>
37 #include <qevent.h>
38 #include "../organizer/qsciApiManager.h"
39 #include <qstringlist.h>
40 #include <qrect.h>
41 #include <qpixmap.h>
42 
43 namespace ito {
44 
45 class AbstractPyScintillaWidget : public QsciScintilla
46 {
47  Q_OBJECT //-> see: #define QSCINTILLA_DLL //http://www.riverbankcomputing.com/pipermail/qscintilla/2007-March/000034.html in sharedStructures.h
48 
49 public:
50  AbstractPyScintillaWidget(QWidget* parent = NULL);
52 
53  QString getWordAtPosition(const int &line, const int &index);
54 
55 protected:
56 
57  enum tUserSelectionState { selNo, selRange };
58 
59  void init();
60  //bool event ( QEvent * event );
61 
62  virtual void loadSettings(); //overwrite this method if you want to load further settings
63 
64 // void mouseReleaseEvent(QMouseEvent * event);
65 // void keyReleaseEvent(QKeyEvent * event);
66  void checkUserSelectionState();
67  QString formatPythonCodePart(const QString &text, int &lineCount);
68  QString formatConsoleCodePart(const QString &text);
69 
70  QPixmap loadMarker(const QString &name, int sizeAt96dpi);
71 
72  tUserSelectionState m_userSelectionState;
73 
74 private:
75  QsciLexerPython* qSciLex;
76  QsciApiManager *m_pApiManager;
77 
78  QStringList m_installedApiFiles;
79  bool m_textIndicatorActive;
80  int m_textIndicatorNr; //number of indicator which marks all appearances of the currently selected text
81  int getSpaceTabCount(const QString &s);
82  bool haveToIndention(QString s);
83 
84 public slots:
85  void selectionChanged();
86  void reloadSettings() { loadSettings(); };
87 
88 signals:
89  void userSelectionChanged(int lineFrom, int indexFrom, int lineTo, int indexTo);
90 
91 };
92 
93 } //end namespace ito
94 
95 #endif
Definition: qsciApiManager.h:42
Definition: abstractPyScintillaWidget.h:45
virtual void loadSettings()
Definition: abstractPyScintillaWidget.cpp:79
Definition: apiFunctionsGraph.cpp:39
int getSpaceTabCount(const QString &s)
counts the numbers of leading tabs or spaces of a string
Definition: abstractPyScintillaWidget.cpp:434
bool haveToIndention(QString s)
checks if text line contains a colon sign as last valid character (only comments or spaces are allowe...
Definition: abstractPyScintillaWidget.cpp:457