|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef EXPRESSIONFIELD_H
|
|
Toshihiro Shimizu |
890ddd |
#define EXPRESSIONFIELD_H
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tgrammar.h"
|
|
Toshihiro Shimizu |
890ddd |
#include <qwidget></qwidget>
|
|
Toshihiro Shimizu |
890ddd |
#include <qtextedit></qtextedit>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#undef DVAPI
|
|
Toshihiro Shimizu |
890ddd |
#undef DVVAR
|
|
Toshihiro Shimizu |
890ddd |
#ifdef TOONZQT_EXPORTS
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_EXPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_EXPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_IMPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_IMPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// forward declaration
|
|
Toshihiro Shimizu |
890ddd |
class QPushButton;
|
|
Toshihiro Shimizu |
890ddd |
class QCompleter;
|
|
Toshihiro Shimizu |
890ddd |
class QListView;
|
|
Toshihiro Shimizu |
890ddd |
class QModelIndex;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace DVGui {
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
/*! \class DVGui::ExpressionField
|
|
Shinya Kitaoka |
120a6e |
\brief The ExpressionField allows to edit expressions (i.e.
|
|
Shinya Kitaoka |
120a6e |
formulas as '34*(5-2)')
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
Inherits \b QWidget.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DVAPI ExpressionField : public QTextEdit {
|
|
Shinya Kitaoka |
120a6e |
Q_OBJECT
|
|
Shinya Kitaoka |
120a6e |
bool m_editing;
|
|
Shinya Kitaoka |
120a6e |
const TSyntax::Grammar *m_grammar;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class SyntaxHighlighter;
|
|
Shinya Kitaoka |
120a6e |
SyntaxHighlighter *m_syntaxHighlighter;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QListView *m_completerPopup;
|
|
Shinya Kitaoka |
120a6e |
int m_completerStartPos;
|
|
Shinya Kitaoka |
120a6e |
TSyntax::Grammar::Suggestions m_suggestions;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
ExpressionField(QWidget *parent = 0);
|
|
Shinya Kitaoka |
120a6e |
~ExpressionField();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void setExpression(std::string expression);
|
|
Shinya Kitaoka |
120a6e |
std::string getExpression() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void setGrammar(const TSyntax::Grammar *grammar);
|
|
Shinya Kitaoka |
120a6e |
const TSyntax::Grammar *getGrammar() const { return m_grammar; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Shinya Kitaoka |
120a6e |
void openCompleterPopup();
|
|
Shinya Kitaoka |
120a6e |
bool updateCompleterPopup();
|
|
Shinya Kitaoka |
120a6e |
void insertCompletion();
|
|
Shinya Kitaoka |
120a6e |
int computeSuggestions();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Shinya Kitaoka |
120a6e |
bool event(QEvent *e);
|
|
Shinya Kitaoka |
120a6e |
void keyPressEvent(QKeyEvent *e);
|
|
Shinya Kitaoka |
120a6e |
void focusInEvent(QFocusEvent *e);
|
|
Shinya Kitaoka |
120a6e |
void focusOutEvent(QFocusEvent *e);
|
|
Shinya Kitaoka |
120a6e |
void showEvent(QShowEvent *);
|
|
Shinya Kitaoka |
120a6e |
void hideEvent(QHideEvent *);
|
|
Shinya Kitaoka |
120a6e |
bool eventFilter(QObject *obj, QEvent *e);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private slots:
|
|
Shinya Kitaoka |
120a6e |
void onTextChanged();
|
|
Shinya Kitaoka |
120a6e |
void onCursorPositionChanged();
|
|
Shinya Kitaoka |
120a6e |
void insertCompletion(const QModelIndex &index);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
signals:
|
|
Shinya Kitaoka |
120a6e |
void expressionChanged();
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
} // namespace DVGui
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#endif // FILEFIELD_H
|