itom 2.2.1
|
00001 /* ******************************************************************** 00002 itom software 00003 URL: http://www.uni-stuttgart.de/ito 00004 Copyright (C) 2016, Institut fuer Technische Optik (ITO), 00005 Universitaet Stuttgart, Germany 00006 00007 This file is part of itom. 00008 00009 itom is free software; you can redistribute it and/or modify it 00010 under the terms of the GNU Library General Public Licence as published by 00011 the Free Software Foundation; either version 2 of the Licence, or (at 00012 your option) any later version. 00013 00014 itom is distributed in the hope that it will be useful, but 00015 WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library 00017 General Public Licence for more details. 00018 00019 You should have received a copy of the GNU Library General Public License 00020 along with itom. If not, see <http://www.gnu.org/licenses/>. 00021 *********************************************************************** */ 00022 00023 #ifndef ABSTRACTPYSCINTILLAWIDGET 00024 #define ABSTRACTPYSCINTILLAWIDGET 00025 00026 #include "../common/sharedStructures.h" 00027 00028 // Under Windows, define QSCINTILLA_MAKE_DLL to create a Scintilla DLL, or 00029 // define QSCINTILLA_DLL to link against a Scintilla DLL, or define neither 00030 // to either build or link against a static Scintilla library. 00032 #define QSCINTILLA_DLL //http://www.riverbankcomputing.com/pipermail/qscintilla/2007-March/000034.html 00033 00034 #include <Qsci/qsciscintilla.h> 00035 #include <Qsci/qscilexerpython.h> 00036 #include <Qsci/qsciapis.h> 00037 #include <qevent.h> 00038 #include "../organizer/qsciApiManager.h" 00039 #include <qstringlist.h> 00040 #include <qrect.h> 00041 00042 namespace ito { 00043 00044 class AbstractPyScintillaWidget : public QsciScintilla 00045 { 00046 Q_OBJECT //-> see: #define QSCINTILLA_DLL //http://www.riverbankcomputing.com/pipermail/qscintilla/2007-March/000034.html in sharedStructures.h 00047 00048 public: 00049 AbstractPyScintillaWidget(QWidget* parent = NULL); 00050 ~AbstractPyScintillaWidget(); 00051 00052 QString getWordAtPosition(const int &line, const int &index); 00053 00054 protected: 00055 00056 enum tUserSelectionState { selNo, selRange }; 00057 00058 void init(); 00059 //bool event ( QEvent * event ); 00060 00061 virtual void loadSettings(); //overwrite this method if you want to load further settings 00062 00063 // void mouseReleaseEvent(QMouseEvent * event); 00064 // void keyReleaseEvent(QKeyEvent * event); 00065 void checkUserSelectionState(); 00066 QString formatPythonCodePart(const QString &text, int &lineCount); 00067 QString formatConsoleCodePart(const QString &text); 00068 00069 tUserSelectionState m_userSelectionState; 00070 00071 private: 00072 QsciLexerPython* qSciLex; 00073 QsciApiManager *m_pApiManager; 00074 00075 QStringList m_installedApiFiles; 00076 bool m_textIndicatorActive; 00077 int m_textIndicatorNr; //number of indicator which marks all appearances of the currently selected text 00078 int getSpaceTabCount(const QString &s); 00079 bool haveToIndention(QString s); 00080 00081 public slots: 00082 void selectionChanged(); 00083 void reloadSettings() { loadSettings(); }; 00084 00085 signals: 00086 void userSelectionChanged(int lineFrom, int indexFrom, int lineTo, int indexTo); 00087 00088 }; 00089 00090 } //end namespace ito 00091 00092 #endif