]> SALOME platform Git repositories - modules/gui.git/blob - src/PyEditor/PyEditor_Editor.h
Salome HOME
Copyright update: 2016
[modules/gui.git] / src / PyEditor / PyEditor_Editor.h
1 // Copyright (C) 2015-2016  OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // File   : PyEditor_Editor.h
20 // Author : Maxim GLIBIN, Open CASCADE S.A.S. (maxim.glibin@opencascade.com)
21 //
22
23 #ifndef PYEDITOR_EDITOR_H
24 #define PYEDITOR_EDITOR_H
25
26 #include <QPlainTextEdit>
27 #include "PyEditor.h"
28
29 class PyEditor_PyHighlighter;
30 class PyEditor_Settings;
31 class QtxResourceMgr;
32
33 class PYEDITOR_EXPORT PyEditor_Editor : public QPlainTextEdit
34 {
35   Q_OBJECT
36
37 public:
38   PyEditor_Editor( bool isSingle = false, QtxResourceMgr* = 0,  QWidget* = 0 );
39   virtual ~PyEditor_Editor();
40   
41   void lineNumberAreaPaintEvent( QPaintEvent* );
42   int  lineNumberAreaWidth();
43
44   void updateStatement();
45   PyEditor_Settings* settings();
46
47 public Q_SLOTS:
48   void deleteSelected();
49   void append ( const QString & );  
50   void setText ( const QString & text );
51 protected:
52   virtual void keyPressEvent( QKeyEvent* );
53   virtual void resizeEvent( QResizeEvent* );
54   virtual void paintEvent( QPaintEvent* );
55     
56 private Q_SLOTS:
57   void updateHighlightCurrentLine();
58   void matchParentheses();
59
60   void updateLineNumberAreaWidth( int );
61   void updateLineNumberArea( const QRect&, int );
62   
63 private:
64   bool matchLeftParenthesis( const QTextBlock&, int, int );
65   bool matchRightParenthesis( const QTextBlock&, int, int );
66   void createParenthesisSelection( int );
67   bool isLeftBrackets( QChar );
68   bool isRightBrackets( QChar );
69   
70   void handleHome( bool );
71   int  lineIndent();
72   void tabIndentation( bool );
73   void indentSelection( bool );
74   
75   int findFirstNonSpace( const QString& );
76   
77   QWidget*                my_LineNumberArea;
78   PyEditor_PyHighlighter* my_SyntaxHighlighter;
79   PyEditor_Settings*      my_Settings;
80 };
81
82 #endif // PYEDITOR_EDITOR_H