Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

TEWidget.h

Go to the documentation of this file.
00001 /* ----------------------------------------------------------------------- */
00002 /*                                                                         */
00003 /* [te_widget.h]           Terminal Emulation Widget                       */
00004 /*                                                                         */
00005 /* ----------------------------------------------------------------------- */
00006 /*                                                                         */
00007 /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de>         */
00008 /*                                                                         */
00009 /* This file is part of Konsole - an X terminal for KDE                    */
00010 /*                                                                         */
00011 /* ----------------------------------------------------------------------- */
00012 /*                        */
00013 /* Ported Konsole to Qt/Embedded                                              */
00014 /*                        */
00015 /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com>                  */
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 #include <qpushbutton.h>
00030 
00031 #include "TECommon.h"
00032 
00033 extern unsigned short vt100_graphics[32];
00034 
00035 
00036 
00037 
00038 
00039 class TESession;
00040 
00041 // class Konsole;
00042 
00043 class TEWidget : public QFrame
00044 // a widget representing attributed text
00045 {
00046     Q_OBJECT
00047 
00048 //  friend class Konsole;
00049 
00050 public:
00051 
00052     TEWidget(QWidget *parent=0, const char *name=0);
00053     virtual ~TEWidget();
00054 
00055 public:
00056 
00057     QColor getDefaultBackColor();
00058     QPushButton *cornerButton();
00059 
00060     const ColorEntry* getColorTable() const;
00061     const ColorEntry* getdefaultColorTable() const;
00062     void              setColorTable(const ColorEntry table[]);
00063 
00064     void setScrollbarLocation(int loc);
00065     enum { SCRNONE=0, SCRLEFT=1, SCRRIGHT=2 };
00066 
00067     void setScroll(int cursor, int lines);
00068     void doScroll(int lines);
00069 
00070     void emitSelection();
00071 
00072         void setWrapAt(int columns);
00073 
00074 public:
00075 
00076     void setImage(const ca* const newimg, int lines, int columns);
00077 
00078     int  Lines()   { return lines;   }
00079     int  Columns() { return columns; }
00080 
00081     void calcGeometry();
00082     void propagateSize();
00083     QSize calcSize(int cols, int lins) const;
00084 
00085     QSize sizeHint() const;
00086 
00087 public:
00088 
00089     void Bell();
00090     void emitText(QString text);
00091     void pasteClipboard();
00092 
00093 signals:
00094 
00095     void keyPressedSignal(QKeyEvent *e);
00096     void mouseSignal(int cb, int cx, int cy);
00097     void changedImageSizeSignal(int lines, int columns);
00098     void changedHistoryCursor(int value);
00099     void configureRequest( TEWidget*, int state, int x, int y );
00100 
00101     void clearSelectionSignal();
00102     void beginSelectionSignal( const int x, const int y );
00103     void extendSelectionSignal( const int x, const int y );
00104     void endSelectionSignal(const BOOL preserve_line_breaks);
00105 
00106 
00107 protected:
00108 
00109     virtual void styleChange( QStyle& );
00110 
00111     bool eventFilter( QObject *, QEvent * );
00112 
00113     void drawAttrStr(QPainter &paint, QRect rect,
00114                      QString& str, ca attr, BOOL pm, BOOL clear);
00115     void paintEvent( QPaintEvent * );
00116 
00117     void resizeEvent(QResizeEvent*);
00118 
00119     void fontChange(const QFont &font);
00120     void frameChanged();
00121 
00122     void mouseDoubleClickEvent(QMouseEvent* ev);
00123     void mousePressEvent( QMouseEvent* );
00124     void mouseReleaseEvent( QMouseEvent* );
00125     void mouseMoveEvent( QMouseEvent* );
00126 
00127     void focusInEvent( QFocusEvent * );
00128     void focusOutEvent( QFocusEvent * );
00129     bool focusNextPrevChild( bool next );
00130 
00131 #ifdef QT_NO_DRAGANDDROP_FOO_BAR_
00132     // Dnd
00133     void dragEnterEvent(QDragEnterEvent* event);
00134     void dropEvent(QDropEvent* event);
00135 #endif
00136 
00137     virtual int charClass(char) const;
00138 
00139     void clearImage();
00140 
00141 public:
00142     const QPixmap *backgroundPixmap();
00143 
00144     void setSelection(const QString &t);
00145 
00146     virtual void setFont(const QFont &);
00147     void setVTFont(const QFont &);
00148     QFont getVTFont();
00149 
00150     void setMouseMarks(bool on);
00151 
00152 public slots:
00153 
00154     void onClearSelection();
00155 
00156 protected slots:
00157 
00158     void scrollChanged(int value);
00159     void hscrollChanged(int value);
00160     void blinkEvent();
00161 
00162 private:
00163 
00164     QChar (*fontMap)(QChar); // possible vt100 font extention
00165 
00166     bool fixed_font; // has fixed pitch
00167     int  font_h;     // height
00168     int  font_w;     // width
00169     int  font_a;     // ascend
00170 
00171     int blX;    // actual offset (left)
00172     int brX;    // actual offset (right)
00173     int bY;     // actual offset
00174 
00175     int lines;
00176     int columns;
00177     ca *image; // [lines][columns]
00178 
00179     ColorEntry color_table[TABLE_COLORS];
00180 
00181     BOOL resizing;
00182     bool mouse_marks;
00183 
00184     void makeImage();
00185 
00186     QPoint iPntSel; // initial selection point
00187     QPoint pntSel; // current selection point
00188     int    actSel; // selection state
00189     BOOL    word_selection_mode;
00190     BOOL    preserve_line_breaks;
00191 
00192     QPushButton *m_cornerButton;
00193     QClipboard*    cb;
00194     QScrollBar* scrollbar, *hscrollbar;
00195     int         scrollLoc;
00196         int hposition, vcolumns;
00197 
00198 //#define SCRNONE  0
00199 //#define SCRLEFT  1
00200 //#define SCRRIGHT 2
00201 
00202     BOOL blinking;   // hide text in paintEvent
00203     BOOL hasBlinker; // has characters to blink
00204     QTimer* blinkT;  // active when hasBlinker
00205     QPopupMenu* m_drop;
00206     QString dropText;
00207  public:
00208     // current session in this widget
00209     TESession *currentSession;
00210 private slots:
00211     void drop_menu_activated(int item);
00212 };
00213 
00214 #endif // TE_WIDGET_H

Generated on Sat Nov 5 16:15:28 2005 for OPIE by  doxygen 1.4.2