00001 /* 00002 * (c) Disney Enterprises, Inc. All rights reserved. 00003 * 00004 * This file is licensed under the terms of the Microsoft Public License (MS-PL) 00005 * as defined at: http://opensource.org/licenses/MS-PL. 00006 * 00007 * A complete copy of this license is included in this distribution as the file 00008 * LICENSE. 00009 * 00010 * @file SeExprEdDialog.h 00011 * @brief A basic editor/browser/previewer for expression editing 00012 * @author jlacewel 00013 */ 00014 #ifndef _MY_EXPR_EDITOR_H 00015 #define _MY_EXPR_EDITOR_H 00016 00017 #include <QtCore/QObject> 00018 #include <QtGui/QMessageBox> 00019 #include <QtOpenGL/QGLWidget> 00020 #include <QtGui/QHBoxLayout> 00021 #include <QtGui/QSplitter> 00022 #include <QtGui/QPalette> 00023 #include <QtGui/QPushButton> 00024 #include <QtGui/QFileDialog> 00025 #include <QtGui/QSpacerItem> 00026 #include <QtGui/QSizePolicy> 00027 00028 //#include <SeExpression.h> 00029 00030 #include <iostream> 00031 #include <fstream> 00032 00033 #include "SeExprEditor.h" 00034 00035 00036 class SeExprEdGrapherWidget; 00037 class SeExprEdBrowser; 00038 class QTabWidget; 00039 00040 class SeExprEdDialog:public QDialog 00041 { 00042 Q_OBJECT 00043 00044 public: 00045 SeExprEditor* editor; 00046 SeExprEdBrowser* browser; 00047 private: 00048 SeExprEdGrapherWidget* grapher; 00049 QLabel* previewCommentLabel; 00050 QPushButton* acceptButton; 00051 QPushButton* cancelButton; 00052 SeExprEdControlCollection* controls; 00053 00054 QPushButton *applyButton,*previewButton,*saveButton,*saveAsButton; 00055 QPushButton *saveLocalButton,*clearButton; 00056 QLineEdit* helpFindBox; 00057 QTimer* showEditorTimer; 00058 QTextBrowser* helpBrowser; 00059 QTextCursor cursor; 00060 QString prevFind; 00061 int _currentEditorIdx; 00062 public: 00063 SeExprEdDialog(QWidget* parent); 00064 00065 std::string getExpressionString() 00066 { 00067 return editor->getExpr(); 00068 } 00069 00070 void setExpressionString(const std::string& str) 00071 { 00072 clearExpression(); 00073 editor->setExpr(str, /*apply*/ true); 00074 } 00075 00076 int exec(); 00077 00078 // Show the Nth editor dialog 00079 void showEditor(int idx); 00080 00081 private: 00082 void setupHelp(QTabWidget* tab); 00083 00084 protected: 00085 void keyPressEvent(QKeyEvent* event); 00086 void findHelper(QTextDocument::FindFlags flags); 00087 00088 signals: 00089 void expressionApplied(); 00090 private slots: 00091 void verifiedApply(); 00092 void verifiedAccept(); 00093 void findNextInHelp(); 00094 void findPrevInHelp(); 00095 void _showEditor(); 00096 public slots: 00097 00098 void applyExpression(); 00099 00100 void clearExpression(); 00101 00102 }; 00103 00104 #endif