Merge pull request #506 from andrewcsmith/patch-2
[supercollider.git] / QtCollider / widgets / QcTextEdit.h
blob4d34c70a8a17d2164736e33e882fc7825aa63d58
1 /************************************************************************
3 * Copyright 2010 Jakob Leben (jakob.leben@gmail.com)
5 * This file is part of SuperCollider Qt GUI.
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ************************************************************************/
22 #ifndef QC_TEXT_EDIT
23 #define QC_TEXT_EDIT
25 #include "../QcHelper.h"
27 #include <QTextEdit>
29 class QcTextEdit : public QTextEdit, QcHelper
31 Q_OBJECT
32 Q_PROPERTY( QString document READ documentFilename WRITE setDocument );
33 Q_PROPERTY( int selectionStart READ selectionStart );
34 Q_PROPERTY( int selectionSize READ selectionSize );
35 Q_PROPERTY( QString selectedString READ selectedString WRITE replaceSelectedText );
36 Q_PROPERTY( QFont textFont READ dummyFont WRITE setTextFont );
37 Q_PROPERTY( QColor textColor READ dummyColor WRITE setTextColor );
38 Q_PROPERTY( VariantList rangeColor
39 READ dummyVariantList WRITE setRangeColor );
40 Q_PROPERTY( VariantList rangeFont
41 READ dummyVariantList WRITE setRangeFont );
42 Q_PROPERTY( VariantList rangeText
43 READ dummyVariantList WRITE setRangeText );
44 Q_PROPERTY( bool enterInterpretsSelection
45 READ interpretSelection WRITE setInterpretSelection );
47 public:
48 QcTextEdit();
49 QString documentFilename() const;
50 void setDocument( const QString & );
51 int selectionStart() const;
52 int selectionSize() const;
53 Q_INVOKABLE void select( int start, int size );
54 QString selectedString() const;
55 void replaceSelectedText( const QString & );
56 bool interpretSelection() const { return _interpretSelection; }
57 void setInterpretSelection( bool b ) { _interpretSelection = b; }
58 void setTextFont( const QFont & );
59 void setTextColor( const QColor & );
60 void setRangeColor( const VariantList & );
61 void setRangeFont( const VariantList & );
62 void setRangeText( const VariantList & );
64 Q_SIGNALS:
65 void interpret( const QString & code );
67 protected:
68 virtual void keyPressEvent( QKeyEvent * );
69 virtual void insertFromMimeData ( const QMimeData * );
71 private:
72 QString & prepareText( QString & str ) const;
74 QString _document;
75 bool _interpretSelection;
78 #endif