00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef TE_WIDGET_H
00019 #define TE_WIDGET_H
00020
00021 #include <qwidget.h>
00022 #include <qlabel.h>
00023 #include <qtimer.h>
00024 #include <qcolor.h>
00025 #include <qkeycode.h>
00026 #include <qscrollbar.h>
00027
00028 #include <qpopupmenu.h>
00029
00030 #include "TECommon.h"
00031
00032 extern unsigned short vt100_graphics[32];
00033
00034 class TESession;
00035
00036
00037
00038 class TEWidget : public QFrame
00039
00040 {
00041 Q_OBJECT
00042
00043
00044
00045 public:
00046
00047 TEWidget(QWidget *parent=0, const char *name=0);
00048 virtual ~TEWidget();
00049
00050 public:
00051
00052 QColor getDefaultBackColor();
00053
00054 const ColorEntry* getColorTable() const;
00055 const ColorEntry* getdefaultColorTable() const;
00056 void setColorTable(const ColorEntry table[]);
00057 void setScrollbarLocation(int loc);
00058 enum { SCRNONE=0, SCRLEFT=1, SCRRIGHT=2 };
00059 void setScroll(int cursor, int lines);
00060 void doScroll(int lines);
00061 void doHScroll(int lines);
00062 void emitSelection();
00063 void setWrapAt(int columns);
00064
00065 void setImage(const ca* const newimg, int lines, int columns);
00066
00067 int Lines() { return lines; }
00068 int Columns() { return columns; }
00069
00070 void calcGeometry();
00071 void propagateSize();
00072 QSize calcSize(int cols, int lins) const;
00073
00074 QSize sizeHint() const;
00075
00076 bool useHorzScroll;
00077 bool useBeep;
00078 int color_menu_item;
00079
00080 void Bell();
00081 void emitText(QString text);
00082 void pasteClipboard();
00083
00084 signals:
00085
00086 void keyPressedSignal(QKeyEvent *e);
00087 void mouseSignal(int cb, int cx, int cy);
00088 void changedImageSizeSignal(int lines, int columns);
00089 void changedHistoryCursor(int value);
00090 void changedHorzCursor(int value);
00091 void configureRequest( TEWidget*, int state, int x, int y );
00092
00093 void clearSelectionSignal();
00094 void beginSelectionSignal( const int x, const int y );
00095 void extendSelectionSignal( const int x, const int y );
00096 void endSelectionSignal(const BOOL preserve_line_breaks);
00097
00098 void changeFontSize(int);
00099 void toggleFullScreen();
00100 void setFullScreen(bool);
00101 void changeSession(int);
00102 void newSession();
00103
00104 protected:
00105 virtual void styleChange( QStyle& );
00106
00107 bool eventFilter( QObject *, QEvent * );
00108
00109 void drawAttrStr(QPainter &paint, QRect rect,
00110 QString& str, ca attr, BOOL pm, BOOL clear);
00111 void paintEvent( QPaintEvent * );
00112
00113 void resizeEvent(QResizeEvent*);
00114
00115 void fontChange(const QFont &font);
00116 void frameChanged();
00117
00118 void mouseDoubleClickEvent(QMouseEvent* ev);
00119 void mousePressEvent( QMouseEvent* );
00120 void mouseReleaseEvent( QMouseEvent* );
00121 void mouseMoveEvent( QMouseEvent* );
00122
00123 void focusInEvent( QFocusEvent * );
00124 void focusOutEvent( QFocusEvent * );
00125 bool focusNextPrevChild( bool next );
00126
00127 #ifndef QT_NO_DRAGANDDROP
00128
00129 void dragEnterEvent(QDragEnterEvent* event);
00130 void dropEvent(QDropEvent* event);
00131 #endif
00132
00133 virtual int charClass(char) const;
00134
00135 void clearImage();
00136
00137 public:
00138 const QPixmap *backgroundPixmap();
00139
00140 void setSelection(const QString &t);
00141
00142 virtual void setFont(const QFont &);
00143 void setVTFont(const QFont &);
00144 QFont getVTFont();
00145
00146 void setMouseMarks(bool on);
00147
00148 public slots:
00149
00150 void onClearSelection();
00151
00152 protected slots:
00153
00154 void scrollChanged(int value);
00155 void hScrollChanged(int value);
00156 void blinkEvent();
00157
00158 private:
00159
00160 QChar (*fontMap)(QChar);
00161
00162
00163 int font_h;
00164 int font_w;
00165 int font_a;
00166
00167 int blX;
00168 int brX;
00169 int bY;
00170
00171 int lines;
00172 int columns;
00173 ca *image;
00174
00175 ColorEntry color_table[TABLE_COLORS];
00176
00177 BOOL resizing;
00178 bool mouse_marks;
00179
00180 void makeImage();
00181
00182 QPoint iPntSel;
00183 QPoint pntSel;
00184 int actSel;
00185 BOOL word_selection_mode;
00186 BOOL preserve_line_breaks;
00187
00188 QClipboard* cb;
00189 QScrollBar* scrollbar, *hScrollbar;
00190
00191 int scrollLoc, hScrollLoc;
00192 int hposition, vcolumns;
00193
00194 int mouse_down_x, mouse_down_y;
00195
00196
00197
00198
00199
00200 BOOL blinking;
00201 BOOL hasBlinker;
00202 QTimer* blinkT;
00203 QPopupMenu* m_drop;
00204 QString dropText;
00205
00206 public:
00207
00208 TESession *currentSession;
00209
00210 private slots:
00211 void drop_menu_activated(int item);
00212 };
00213
00214 #endif // TE_WIDGET_H