1 /***************************************************************************** 2 * * 3 * Elmer, A Finite Element Software for Multiphysical Problems * 4 * * 5 * Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland * 6 * * 7 * This program is free software; you can redistribute it and/or * 8 * modify it under the terms of the GNU General Public License * 9 * as published by the Free Software Foundation; either version 2 * 10 * of the License, or (at your option) any later version. * 11 * * 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. * 16 * * 17 * You should have received a copy of the GNU General Public License * 18 * along with this program (in file fem/GPL-2); if not, write to the * 19 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * 20 * Boston, MA 02110-1301, USA. * 21 * * 22 *****************************************************************************/ 23 24 /***************************************************************************** 25 * * 26 * ElmerGUI sifwindow * 27 * * 28 ***************************************************************************** 29 * * 30 * Authors: Mikko Lyly, Juha Ruokolainen and Peter Råback * 31 * Email: Juha.Ruokolainen@csc.fi * 32 * Web: http://www.csc.fi/elmer * 33 * Address: CSC - IT Center for Science Ltd. * 34 * Keilaranta 14 * 35 * 02101 Espoo, Finland * 36 * * 37 * Original Date: 15 Mar 2008 * 38 * * 39 *****************************************************************************/ 40 41 #ifndef SIFWINDOW_H 42 #define SIFWINDOW_H 43 44 #define SIF_HIGHLIGHTING_NONE 0 45 #define SIF_HIGHLIGHTING_LIGHT 1 46 #define SIF_HIGHLIGHTING_DARK 2 47 48 #include <QMainWindow> 49 #include <QSyntaxHighlighter> 50 51 class QTextEdit; 52 class QLineEdit; 53 54 class SifHighlighter : public QSyntaxHighlighter 55 { 56 Q_OBJECT 57 58 public: 59 SifHighlighter(int type, QTextDocument *parent = 0); 60 61 protected: 62 void highlightBlock(const QString &text); 63 64 private: 65 struct HighlightingRule 66 { 67 QRegExp pattern; 68 QTextCharFormat format; 69 }; 70 QVector<HighlightingRule> highlightingRules; 71 72 QRegExp commentStartExpression; 73 QRegExp commentEndExpression; 74 75 QTextCharFormat blockFormat; 76 QTextCharFormat classFormat; 77 QTextCharFormat commentFormat; 78 QTextCharFormat quotationFormat; 79 QTextCharFormat keywordFormat; 80 QTextCharFormat simulationTypeFormat; 81 QTextCharFormat valueFormat; 82 QTextCharFormat suffixFormat; 83 }; 84 85 class SifWindow : public QMainWindow 86 { 87 Q_OBJECT 88 89 public: 90 SifWindow(QWidget *parent = 0); 91 ~SifWindow(); 92 93 QSize minimumSizeHint() const; 94 QSize sizeHint() const; 95 96 QTextEdit* getTextEdit(void); 97 SifHighlighter *highlighter; 98 void setFirstTime(bool); 99 void setFound(bool); 100 101 private slots: 102 void newSlot(); 103 void openSlot(); 104 void saveSlot(); 105 void printSlot(); 106 void findSlot(); 107 void fontSlot(); 108 void highlightingNoneSlot(); 109 void highlightingLightSlot(); 110 void highlightingDarkSlot(); 111 void saveAndRunSlot(); 112 113 private: 114 QTextEdit *textEdit; 115 bool firstTime; 116 bool found; 117 118 QLineEdit *lineEdit; 119 120 QAction *newAct; 121 QAction *openAct; 122 QAction *saveAct; 123 QAction *printAct; 124 QAction *exitAct; 125 QAction *cutAct; 126 QAction *copyAct; 127 QAction *pasteAct; 128 QAction *findAct; 129 QAction *fontAct; 130 QAction *highlightingNoneAct; 131 QAction *highlightingLightAct; 132 QAction *highlightingDarkAct; 133 QAction *saveAndRunAct; 134 135 QMenu *fileMenu; 136 QMenu *editMenu; 137 QMenu *preferenceMenu; 138 QMenu *highlightingMenu; 139 140 QToolBar *fileToolBar; 141 QToolBar *editToolBar; 142 143 void createActions(); 144 void createMenus(); 145 void createToolBars(); 146 void createStatusBar(); 147 }; 148 149 #endif 150