Salome HOME
refs #1458: disable chained panning on operations
[modules/gui.git] / tools / PyEditor / src / 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 "PyEditor.h"
27 #include "PyEditor_Settings.h"
28
29 #include <QPlainTextEdit>
30
31 class PyEditor_PyHighlighter;
32
33 class PYEDITOR_EXPORT PyEditor_Editor : public QPlainTextEdit
34 {
35   Q_OBJECT
36
37 public:
38   PyEditor_Editor( QWidget* = 0 );
39   virtual ~PyEditor_Editor();
40   
41   void setSettings( const PyEditor_Settings& );
42   const PyEditor_Settings& settings() const;
43   QString text() const;
44
45 public Q_SLOTS:
46   void deleteSelected();
47   void append( const QString& );  
48   void setText( const QString& text );
49
50 protected:
51   virtual void keyPressEvent( QKeyEvent* );
52   virtual void resizeEvent( QResizeEvent* );
53   virtual void paintEvent( QPaintEvent* );
54     
55 private Q_SLOTS:
56   void updateHighlightCurrentLine();
57   void matchParentheses();
58
59   void updateLineNumberAreaWidth( int );
60   void updateLineNumberArea( const QRect&, int );
61   
62 private:
63   bool matchLeftParenthesis( const QTextBlock&, int, int );
64   bool matchRightParenthesis( const QTextBlock&, int, int );
65   void createParenthesisSelection( int );
66   bool isLeftBrackets( QChar );
67   bool isRightBrackets( QChar );
68   void lineNumberAreaPaintEvent( QPaintEvent* );
69   int  lineNumberAreaWidth();
70
71   void handleHome( bool );
72   int  lineIndent();
73   void tabIndentation( bool );
74   void indentSelection( bool );
75   
76   int findFirstNonSpace( const QString& );
77   
78   QWidget*                myLineNumberArea;
79   PyEditor_PyHighlighter* mySyntaxHighlighter;
80   PyEditor_Settings       mySettings;
81
82   friend class PyEditor_LineNumberArea;
83 };
84
85 #endif // PYEDITOR_EDITOR_H