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 
00030 #include "TECommon.h"
00031 
00032 extern unsigned short vt100_graphics[32];
00033 
00034 class TESession;
00035 
00036 // class Konsole;
00037 
00038 class TEWidget : public QFrame
00039 // a widget representing attributed text
00040 { 
00041   Q_OBJECT
00042 
00043 //  friend class Konsole;
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     // Dnd
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); // possible vt100 font extention
00161 
00162     //    bool fixed_font; // has fixed pitch
00163     int  font_h;     // height
00164     int  font_w;     // width
00165     int  font_a;     // ascend
00166 
00167     int blX;    // actual offset (left)
00168     int brX;    // actual offset (right)
00169     int bY;     // actual offset
00170 
00171     int lines;
00172     int columns;
00173     ca *image; // [lines][columns]
00174 
00175     ColorEntry color_table[TABLE_COLORS];
00176 
00177     BOOL resizing;
00178     bool mouse_marks;
00179 
00180     void makeImage();
00181 
00182     QPoint iPntSel; // initial selection point
00183     QPoint pntSel; // current selection point
00184     int    actSel; // selection state
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 //#define SCRNONE  0
00197 //#define SCRLEFT  1
00198 //#define SCRRIGHT 2
00199 
00200     BOOL blinking;   // hide text in paintEvent
00201     BOOL hasBlinker; // has characters to blink
00202     QTimer* blinkT;  // active when hasBlinker
00203     QPopupMenu* m_drop;
00204     QString dropText;
00205 
00206  public:
00207     // current session in this widget
00208     TESession *currentSession;
00209 
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