1 /* -*- tab-width: 4 -*- 2 * 3 * Electric(tm) VLSI Design Systems 4 * 5 * File: graphqt.h 6 * Qt Window System interface 7 * Written by: Dmitry Nadezhin, Instutute for Design Problems in Microelectronics, Russian Academy of Sciences 8 * 9 * Copyright (c) 2001 Static Free Software. 10 * 11 * Electric(tm) is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * Electric(tm) is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with Electric(tm); see the file COPYING. If not, write to 23 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, 24 * Boston, Mass 02111-1307, USA. 25 * 26 * Static Free Software 27 * 4119 Alpine Road 28 * Portola Valley, California 94028 29 * info@staticfreesoft.com 30 */ 31 32 #ifndef GRAPHQT_H 33 #define GRAPHQT_H 34 35 #include "global.h" 36 37 #include <qapplication.h> 38 #include <qbitmap.h> 39 #include <qcursor.h> 40 #include <qframe.h> 41 #include <qimage.h> 42 #include <qmainwindow.h> 43 #include <qpainter.h> 44 #include <qpixmap.h> 45 #include <qpopupmenu.h> 46 #include <qprocess.h> 47 #include <qvbox.h> 48 49 #ifdef MACOSX 50 /* CHARPIXMAP - use 32-bit QPixmap instead of 1-bit QBitmap for glyph drawing */ 51 # define CHARPIXMAP 52 # define MESSMENU /* menu in messages window */ 53 # define DOUBLESELECT 54 #endif 55 56 //#define USEMDI 57 58 #ifndef Q_ASSERT 59 # define Q_ASSERT(x) ASSERT(x) 60 #endif 61 #ifndef Q_CHECK_PTR 62 # define Q_CHECK_PTR(p) CHECK_PTR(p) 63 #endif 64 65 #define GTRACE 0 /* etrace flag of usual graphics trace */ 66 #define GTRACE_CONT 0 /* etrace flag of usual graphics trace (continue line) */ 67 68 struct Ipopupmenu; 69 class QHBox; 70 class QLabel; 71 class QLineEdit; 72 class QTextEdit; 73 class QPaintDevice; 74 class QWorkspace; 75 class EFont; 76 class EMessages; 77 class EStatusItem; 78 79 class EMessages: public QVBox 80 { 81 Q_OBJECT 82 public: 83 EMessages( QWidget *parent = 0 ); 84 void clear(); 85 char *getString(char *prompt); 86 void putString(char *s, BOOLEAN important); 87 void setFont(); 88 void setColor( QColor &bg, QColor &fg ); 89 public slots: 90 void lineEntered(); 91 void setIcons(); 92 protected: 93 void windowActivationChange( bool oldActive ); 94 void keyPressEvent( QKeyEvent *e ); 95 bool eventFilter( QObject *watched, QEvent *e ); 96 private: 97 QTextEdit *scroll; 98 QHBox *input; 99 QLabel *prompt; 100 QLineEdit *line; 101 bool stopped; 102 }; 103 104 void gra_initfaces( QStringList &facelist ); 105 void gra_termfaces(); 106 107 class GraphicsDraw: public QWidget 108 { 109 Q_OBJECT 110 public: 111 GraphicsDraw( QWidget *parent ); 112 void focusInEvent( QFocusEvent *e ); 113 void focusOutEvent( QFocusEvent *e ); 114 void paintEvent( QPaintEvent *e ); 115 void keyPressEvent( QKeyEvent *e ); 116 void keyReleaseEvent( QKeyEvent *e ); 117 void mouseDoubleClickEvent( QMouseEvent *e ); 118 void mouseMoveEvent( QMouseEvent *e ); 119 void mousePressEvent( QMouseEvent *e ); 120 void mouseReleaseEvent( QMouseEvent *e ); 121 void resizeEvent( QResizeEvent *e ); 122 void wheelEvent( QWheelEvent * e); 123 bool eventFilter( QObject *watched, QEvent *e ); 124 protected: 125 void windowActivationChange( bool oldActive ); 126 private: 127 void keepCursorPos( QPoint pos ); 128 void buttonPressed( QPoint pos, INTSML but ); 129 void recalcSize(); 130 public: 131 WINDOWFRAME *wf; 132 int colorvalue[256]; 133 /* offscreen data is in "image" and drawn by "graphdraw.c" */ 134 QImage image; 135 private: 136 bool metaheld; // Unix Meta key mod doesn't come through in key modifier state 137 }; 138 139 class EMainWindow: public QMainWindow 140 { 141 Q_OBJECT 142 public: 143 EMainWindow( QWidget *parent, char *name, WFlags f, BOOLEAN status ); 144 ~EMainWindow(); 145 void makepdmenu( Ipopupmenu *pm, INTSML value); 146 INTSML pulldownindex( Ipopupmenu *pm ); 147 void pulldownmenuload(); 148 void nativemenurename( Ipopupmenu *pm, INTBIG pindex); 149 void addStatusItem( int stretch, char *str ); 150 void removeStatusItem( int i ); 151 void changeStatusItem( int i, char *str ); 152 public slots: 153 void menuAction( int id ); 154 private: 155 EStatusItem *statusItems[100]; 156 QPopupMenu **pulldownmenus; /* list of Windows pulldown menus */ 157 char **pulldowns; /* list of Electric pulldown menu names */ 158 INTSML pulldownmenucount; /* number of pulldown menus */ 159 }; 160 161 class EApplicationWindow: public EMainWindow 162 { 163 Q_OBJECT 164 public: 165 EApplicationWindow(); 166 #ifdef USEMDI 167 QWorkspace *ws; 168 #endif 169 }; 170 171 class EApplication: public QApplication 172 { 173 Q_OBJECT 174 public: 175 EApplication( int &argc, char **argv); 176 ~EApplication(); 177 bool notify( QObject *receiver, QEvent *e ); 178 EMessages *messages; 179 EApplicationWindow *mw; 180 static char *localize (QString qstr); 181 static char *localizeFilePath (QString filePath, bool addSeparator ); 182 int translatekey(QKeyEvent *e, INTBIG *special); 183 #ifdef DOUBLESELECT 184 void activationChange(); 185 #endif 186 187 QBitmap textbits; 188 #ifdef CHARPIXMAP 189 QPixmap charbits; 190 #else 191 QBitmap charbits; 192 #endif 193 EFont *curfont; 194 QStringList facelist; 195 QString defface; 196 QFont fixedfont; 197 198 QBitmap programicon; 199 QCursor realcursor; 200 QCursor nomousecursor; 201 QCursor drawcursor; 202 QCursor nullcursor; 203 QCursor menucursor; 204 QCursor handcursor; 205 QCursor techcursor; 206 QCursor ibeamcursor; 207 QCursor lrcursor; 208 QCursor udcursor; 209 210 /* trackcursor */ 211 INTSML waitforpush; 212 BOOLEAN (*whileup)(INTBIG x, INTBIG y); 213 void (*whendown)(void); 214 BOOLEAN (*eachdown)(INTBIG x, INTBIG y); 215 BOOLEAN (*eachchar)(INTBIG x, INTBIG y, INTSML c); 216 217 /* modalloop */ 218 BOOLEAN (*charhandler)(INTSML chr, INTBIG special); 219 BOOLEAN (*buttonhandler)(INTBIG x, INTBIG y, INTBIG but); 220 221 public slots: 222 void toolTimeSlice(); 223 }; 224 225 class EStatusItem: public QFrame 226 { 227 Q_OBJECT 228 public: 229 EStatusItem( QWidget *parent, char *name = 0 ); 230 void setText( const QString &text ); 231 protected: 232 void drawContents( QPainter *p ); 233 private: 234 QString stext; 235 }; 236 237 class EPopupMenu: public QPopupMenu 238 { 239 Q_OBJECT 240 public: 241 EPopupMenu( QWidget *parent, struct Ipopupmenu *menu ); 242 private: 243 void keyPressEvent( QKeyEvent *e ); 244 struct Ipopupmenu *menu; 245 }; 246 247 class EProcessPrivate: public QProcess 248 { 249 Q_OBJECT 250 friend class EProcess; 251 public: 252 EProcessPrivate(); 253 private: 254 void idle(); 255 QByteArray buf; 256 uint bufp; 257 }; 258 259 extern EApplication *gra; 260 261 #endif 262