-rw-r--r-- | noncore/apps/opie-console/emulation_widget.cpp | 9 | ||||
-rw-r--r-- | noncore/apps/opie-console/emulation_widget.h | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/widget_layer.cpp | 6 | ||||
-rw-r--r-- | noncore/apps/opie-console/widget_layer.h | 5 |
4 files changed, 21 insertions, 1 deletions
diff --git a/noncore/apps/opie-console/emulation_widget.cpp b/noncore/apps/opie-console/emulation_widget.cpp index e11c5e4..40199fa 100644 --- a/noncore/apps/opie-console/emulation_widget.cpp +++ b/noncore/apps/opie-console/emulation_widget.cpp | |||
@@ -61,92 +61,99 @@ static QChar vt100extended(QChar c) | |||
61 | case 0x240d : return 5; | 61 | case 0x240d : return 5; |
62 | case 0x240a : return 6; | 62 | case 0x240a : return 6; |
63 | case 0x00b0 : return 7; | 63 | case 0x00b0 : return 7; |
64 | case 0x00b1 : return 8; | 64 | case 0x00b1 : return 8; |
65 | case 0x2424 : return 9; | 65 | case 0x2424 : return 9; |
66 | case 0x240b : return 10; | 66 | case 0x240b : return 10; |
67 | case 0x2518 : return 11; | 67 | case 0x2518 : return 11; |
68 | case 0x2510 : return 12; | 68 | case 0x2510 : return 12; |
69 | case 0x250c : return 13; | 69 | case 0x250c : return 13; |
70 | case 0x2514 : return 14; | 70 | case 0x2514 : return 14; |
71 | case 0x253c : return 15; | 71 | case 0x253c : return 15; |
72 | case 0xf800 : return 16; | 72 | case 0xf800 : return 16; |
73 | case 0xf801 : return 17; | 73 | case 0xf801 : return 17; |
74 | case 0x2500 : return 18; | 74 | case 0x2500 : return 18; |
75 | case 0xf803 : return 19; | 75 | case 0xf803 : return 19; |
76 | case 0xf804 : return 20; | 76 | case 0xf804 : return 20; |
77 | case 0x251c : return 21; | 77 | case 0x251c : return 21; |
78 | case 0x2524 : return 22; | 78 | case 0x2524 : return 22; |
79 | case 0x2534 : return 23; | 79 | case 0x2534 : return 23; |
80 | case 0x252c : return 24; | 80 | case 0x252c : return 24; |
81 | case 0x2502 : return 25; | 81 | case 0x2502 : return 25; |
82 | case 0x2264 : return 26; | 82 | case 0x2264 : return 26; |
83 | case 0x2265 : return 27; | 83 | case 0x2265 : return 27; |
84 | case 0x03c0 : return 28; | 84 | case 0x03c0 : return 28; |
85 | case 0x2260 : return 29; | 85 | case 0x2260 : return 29; |
86 | case 0x00a3 : return 30; | 86 | case 0x00a3 : return 30; |
87 | case 0x00b7 : return 31; | 87 | case 0x00b7 : return 31; |
88 | } | 88 | } |
89 | return c; | 89 | return c; |
90 | } | 90 | } |
91 | 91 | ||
92 | 92 | ||
93 | QSize EmulationWidget::calcSize( int cols, int lins ) const | ||
94 | { | ||
95 | int frw = width() - contentsRect().width(); | ||
96 | int frh = height() - contentsRect().height(); | ||
97 | int scw = (scrollLoc == SCRNONE? 0 : m_scrollbar->width() ); | ||
98 | return QSize( f_width * cols + 2 * rimX + frw + scw, f_height * lins + 2 * rimY + frh ); | ||
99 | } | ||
93 | 100 | ||
94 | void EmulationWidget::setImage( QArray<Character> const newimg, int lines, int columns ) | 101 | void EmulationWidget::setImage( QArray<Character> const newimg, int lines, int columns ) |
95 | { | 102 | { |
96 | const QPixmap* pm = backgroundPixmap(); | 103 | const QPixmap* pm = backgroundPixmap(); |
97 | QPainter paint; | 104 | QPainter paint; |
98 | 105 | ||
99 | // dont allow updates, while drawing | 106 | // dont allow updates, while drawing |
100 | setUpdatesEnabled( false ); | 107 | setUpdatesEnabled( false ); |
101 | 108 | ||
102 | paint.begin( this ); | 109 | paint.begin( this ); |
103 | 110 | ||
104 | QPoint tL = contentsRect().topLeft(); | 111 | QPoint tL = contentsRect().topLeft(); |
105 | int tLx = tL.x(); | 112 | int tLx = tL.x(); |
106 | int tLy = tL.y(); | 113 | int tLy = tL.y(); |
107 | //hasBlinker = false; | 114 | //hasBlinker = false; |
108 | 115 | ||
109 | int cf = -1; | 116 | int cf = -1; |
110 | int cb = -1; | 117 | int cb = -1; |
111 | int cr = -1; | 118 | int cr = -1; |
112 | 119 | ||
113 | int lins = QMIN( m_lines, QMAX( 0, lines ) ); | 120 | int lins = QMIN( m_lines, QMAX( 0, lines ) ); |
114 | int cols = QMIN( m_columns, QMAX( 0, columns ) ); | 121 | int cols = QMIN( m_columns, QMAX( 0, columns ) ); |
115 | QArray<QChar> disstrU = QArray<QChar>( cols ); | 122 | QArray<QChar> disstrU = QArray<QChar>( cols ); |
116 | 123 | ||
117 | for ( int y = 0; y < lins; ++y ) | 124 | for ( int y = 0; y < lins; ++y ) |
118 | {int len; | 125 | {int len; |
119 | const Character* lcl = &m_image[y * m_columns]; | 126 | const Character* lcl = &m_image[y * m_columns]; |
120 | const Character* ext = &newimg[y * columns]; | 127 | const Character* ext = &newimg[y * m_columns]; |
121 | if ( ! m_resizing ) | 128 | if ( ! m_resizing ) |
122 | for ( int x = 0; x < cols; ++x ) | 129 | for ( int x = 0; x < cols; ++x ) |
123 | { | 130 | { |
124 | // disable, till widget works, WITHOUT blinking | 131 | // disable, till widget works, WITHOUT blinking |
125 | //hasBlinker |= ( ext[x].r & RE_BLINK ); | 132 | //hasBlinker |= ( ext[x].r & RE_BLINK ); |
126 | 133 | ||
127 | if ( ext[x] != lcl[x] ) | 134 | if ( ext[x] != lcl[x] ) |
128 | { | 135 | { |
129 | cr = ext[x].r; | 136 | cr = ext[x].r; |
130 | cb = ext[x].b; | 137 | cb = ext[x].b; |
131 | if ( ext[x].f != cf ) cf = ext[x].f; | 138 | if ( ext[x].f != cf ) cf = ext[x].f; |
132 | int lln = cols - x; | 139 | int lln = cols - x; |
133 | disstrU[0] = vt100extended( ext[x+0].c ); | 140 | disstrU[0] = vt100extended( ext[x+0].c ); |
134 | for ( len = 1; len < lln; ++len ) | 141 | for ( len = 1; len < lln; ++len ) |
135 | { | 142 | { |
136 | if ( ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || ext[x+len] == lcl[x+len] ) | 143 | if ( ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || ext[x+len] == lcl[x+len] ) |
137 | break; | 144 | break; |
138 | disstrU[len] = vt100extended( ext[x+len].c ); | 145 | disstrU[len] = vt100extended( ext[x+len].c ); |
139 | } | 146 | } |
140 | QString unistr( disstrU, len ); | 147 | QString unistr( disstrU, len ); |
141 | drawAttrString( unistr, paint, QRect( m_blX+tLx+f_width*x, m_bY+tLy+f_height*y, f_width*len, f_height ), ext[x], pm != NULL, true ); | 148 | drawAttrString( unistr, paint, QRect( m_blX+tLx+f_width*x, m_bY+tLy+f_height*y, f_width*len, f_height ), ext[x], pm != NULL, true ); |
142 | x += len -1; | 149 | x += len -1; |
143 | } | 150 | } |
144 | } | 151 | } |
145 | // make image become newimg | 152 | // make image become newimg |
146 | memcpy( (void*) lcl, (const void*) ext, cols*sizeof( Character ) ); | 153 | memcpy( (void*) lcl, (const void*) ext, cols*sizeof( Character ) ); |
147 | } | 154 | } |
148 | drawFrame( &paint ); | 155 | drawFrame( &paint ); |
149 | paint.end(); | 156 | paint.end(); |
150 | setUpdatesEnabled( true ); | 157 | setUpdatesEnabled( true ); |
151 | 158 | ||
152 | /*if ( hasBlinker && !blinkT->isActive() ) | 159 | /*if ( hasBlinker && !blinkT->isActive() ) |
diff --git a/noncore/apps/opie-console/emulation_widget.h b/noncore/apps/opie-console/emulation_widget.h index e185534..5e20dc4 100644 --- a/noncore/apps/opie-console/emulation_widget.h +++ b/noncore/apps/opie-console/emulation_widget.h | |||
@@ -31,64 +31,66 @@ public: | |||
31 | EmulationWidget( const Profile& config, QWidget *parent=0, const char *name =0 ); | 31 | EmulationWidget( const Profile& config, QWidget *parent=0, const char *name =0 ); |
32 | 32 | ||
33 | /** | 33 | /** |
34 | * destructor | 34 | * destructor |
35 | */ | 35 | */ |
36 | ~EmulationWidget(); | 36 | ~EmulationWidget(); |
37 | 37 | ||
38 | /** | 38 | /** |
39 | * sets the image | 39 | * sets the image |
40 | * @param QArray<Character> const newimg, the new image | 40 | * @param QArray<Character> const newimg, the new image |
41 | * @param int lines, lines of the new image | 41 | * @param int lines, lines of the new image |
42 | * @param int columns, columns of the new image | 42 | * @param int columns, columns of the new image |
43 | */ | 43 | */ |
44 | virtual void setImage( QArray<Character> const newimg, int columns, int lines ); | 44 | virtual void setImage( QArray<Character> const newimg, int columns, int lines ); |
45 | 45 | ||
46 | /** | 46 | /** |
47 | * reloads configuration | 47 | * reloads configuration |
48 | * @param const Profile& config, configuration | 48 | * @param const Profile& config, configuration |
49 | */ | 49 | */ |
50 | virtual void reloadConfig( const Profile& config ); | 50 | virtual void reloadConfig( const Profile& config ); |
51 | 51 | ||
52 | /** | 52 | /** |
53 | * sets the scrollbar (not yet implemented) | 53 | * sets the scrollbar (not yet implemented) |
54 | */ | 54 | */ |
55 | virtual void setScroll( int cursor, int slines ); | 55 | virtual void setScroll( int cursor, int slines ); |
56 | 56 | ||
57 | /** | 57 | /** |
58 | * scrolls (not yet implemented) | 58 | * scrolls (not yet implemented) |
59 | * @param int value, scroll by this value | 59 | * @param int value, scroll by this value |
60 | */ | 60 | */ |
61 | virtual void scroll( int value ); | 61 | virtual void scroll( int value ); |
62 | 62 | ||
63 | virtual QSize calcSize( int cols, int lins ) const; | ||
64 | |||
63 | protected: | 65 | protected: |
64 | 66 | ||
65 | /** | 67 | /** |
66 | * calculates current image bounds | 68 | * calculates current image bounds |
67 | */ | 69 | */ |
68 | virtual void calcGeometry(); | 70 | virtual void calcGeometry(); |
69 | 71 | ||
70 | 72 | ||
71 | /** | 73 | /** |
72 | * @param const ColorEntry* table, the new color table | 74 | * @param const ColorEntry* table, the new color table |
73 | */ | 75 | */ |
74 | void setColorTable( const ColorEntry table[] ); | 76 | void setColorTable( const ColorEntry table[] ); |
75 | 77 | ||
76 | /** | 78 | /** |
77 | * draws a String | 79 | * draws a String |
78 | * @param QString& string, string to be drawn | 80 | * @param QString& string, string to be drawn |
79 | * @param QPainter& painter, painter, that should draw | 81 | * @param QPainter& painter, painter, that should draw |
80 | * @param QRect rect, rect to be drawn into | 82 | * @param QRect rect, rect to be drawn into |
81 | * @param Character attr, attributes of Characters | 83 | * @param Character attr, attributes of Characters |
82 | * @param bool usePixmap, if to use the background pixmap (currently not supported) | 84 | * @param bool usePixmap, if to use the background pixmap (currently not supported) |
83 | * @param bool clear, if rect should be cleared | 85 | * @param bool clear, if rect should be cleared |
84 | */ | 86 | */ |
85 | void drawAttrString( QString& string, QPainter& painter, QRect rect, Character attr, bool pm, bool clear ); | 87 | void drawAttrString( QString& string, QPainter& painter, QRect rect, Character attr, bool pm, bool clear ); |
86 | 88 | ||
87 | protected: | 89 | protected: |
88 | 90 | ||
89 | enum ScrollLocation | 91 | enum ScrollLocation |
90 | { | 92 | { |
91 | SCRNONE, | 93 | SCRNONE, |
92 | SCRLEFT, | 94 | SCRLEFT, |
93 | SCRIGHT | 95 | SCRIGHT |
94 | }; | 96 | }; |
diff --git a/noncore/apps/opie-console/widget_layer.cpp b/noncore/apps/opie-console/widget_layer.cpp index e4b0ede..ac84f8b 100644 --- a/noncore/apps/opie-console/widget_layer.cpp +++ b/noncore/apps/opie-console/widget_layer.cpp | |||
@@ -24,64 +24,70 @@ | |||
24 | WidgetLayer::WidgetLayer( const Profile &config, QWidget *parent, const char *name ) : QFrame( parent, name ) | 24 | WidgetLayer::WidgetLayer( const Profile &config, QWidget *parent, const char *name ) : QFrame( parent, name ) |
25 | { | 25 | { |
26 | // get the clipboard | 26 | // get the clipboard |
27 | m_clipboard = QApplication::clipboard(); | 27 | m_clipboard = QApplication::clipboard(); |
28 | 28 | ||
29 | // when data on clipboard changes, clear selection | 29 | // when data on clipboard changes, clear selection |
30 | QObject::connect( (QObject*) m_clipboard, SIGNAL( dataChanged() ), | 30 | QObject::connect( (QObject*) m_clipboard, SIGNAL( dataChanged() ), |
31 | (QObject*)this, SLOT( onClearSelection() ) ); | 31 | (QObject*)this, SLOT( onClearSelection() ) ); |
32 | 32 | ||
33 | // initialize vars: | 33 | // initialize vars: |
34 | m_lines = 1; | 34 | m_lines = 1; |
35 | m_columns = 1; | 35 | m_columns = 1; |
36 | m_resizing = false; | 36 | m_resizing = false; |
37 | 37 | ||
38 | // just for demonstrating | 38 | // just for demonstrating |
39 | //m_image = QArray<Character>( m_lines * m_columns ); | 39 | //m_image = QArray<Character>( m_lines * m_columns ); |
40 | m_image = QArray<Character>( 1 ); | 40 | m_image = QArray<Character>( 1 ); |
41 | 41 | ||
42 | // we need to install an event filter, | 42 | // we need to install an event filter, |
43 | // to emit keypresses. | 43 | // to emit keypresses. |
44 | qApp->installEventFilter( this ); | 44 | qApp->installEventFilter( this ); |
45 | 45 | ||
46 | } | 46 | } |
47 | 47 | ||
48 | 48 | ||
49 | WidgetLayer::~WidgetLayer() | 49 | WidgetLayer::~WidgetLayer() |
50 | { | 50 | { |
51 | // clean up | 51 | // clean up |
52 | delete m_image; | 52 | delete m_image; |
53 | } | 53 | } |
54 | 54 | ||
55 | 55 | ||
56 | QSize WidgetLayer::sizeHint() | ||
57 | { | ||
58 | return size(); | ||
59 | } | ||
60 | |||
61 | |||
56 | /* --------------------------------- audio ---------------------------------- */ | 62 | /* --------------------------------- audio ---------------------------------- */ |
57 | 63 | ||
58 | void WidgetLayer::bell() | 64 | void WidgetLayer::bell() |
59 | { | 65 | { |
60 | QApplication::beep(); | 66 | QApplication::beep(); |
61 | } | 67 | } |
62 | 68 | ||
63 | bool WidgetLayer::eventFilter( QObject *obj, QEvent *e ) | 69 | bool WidgetLayer::eventFilter( QObject *obj, QEvent *e ) |
64 | { | 70 | { |
65 | if ( (e->type() == QEvent::Accel || | 71 | if ( (e->type() == QEvent::Accel || |
66 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { | 72 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { |
67 | static_cast<QKeyEvent *>( e )->ignore(); | 73 | static_cast<QKeyEvent *>( e )->ignore(); |
68 | return true; | 74 | return true; |
69 | } | 75 | } |
70 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) | 76 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) |
71 | return false; // not us | 77 | return false; // not us |
72 | 78 | ||
73 | #ifdef FAKE_CTRL_AND_ALT | 79 | #ifdef FAKE_CTRL_AND_ALT |
74 | static bool control = false; | 80 | static bool control = false; |
75 | static bool alt = false; | 81 | static bool alt = false; |
76 | // qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); | 82 | // qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); |
77 | bool dele = false; | 83 | bool dele = false; |
78 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 84 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
79 | QKeyEvent* ke = (QKeyEvent*)e; | 85 | QKeyEvent* ke = (QKeyEvent*)e; |
80 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); | 86 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); |
81 | switch (ke->key()) { | 87 | switch (ke->key()) { |
82 | case Key_F9: // let this be "Control" | 88 | case Key_F9: // let this be "Control" |
83 | control = keydown; | 89 | control = keydown; |
84 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); | 90 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); |
85 | dele=TRUE; | 91 | dele=TRUE; |
86 | break; | 92 | break; |
87 | case Key_F13: // let this be "Alt" | 93 | case Key_F13: // let this be "Alt" |
diff --git a/noncore/apps/opie-console/widget_layer.h b/noncore/apps/opie-console/widget_layer.h index 0c290f3..6812711 100644 --- a/noncore/apps/opie-console/widget_layer.h +++ b/noncore/apps/opie-console/widget_layer.h | |||
@@ -94,64 +94,69 @@ public: | |||
94 | /** | 94 | /** |
95 | * set selection (clipboard) to text | 95 | * set selection (clipboard) to text |
96 | * @param const QString &text, the text to be selected | 96 | * @param const QString &text, the text to be selected |
97 | */ | 97 | */ |
98 | void setSelection( const QString &text ); | 98 | void setSelection( const QString &text ); |
99 | 99 | ||
100 | /** | 100 | /** |
101 | * paste content of clipboard | 101 | * paste content of clipboard |
102 | */ | 102 | */ |
103 | void pasteClipboard(); | 103 | void pasteClipboard(); |
104 | 104 | ||
105 | 105 | ||
106 | /** | 106 | /** |
107 | * reload configuration | 107 | * reload configuration |
108 | * @param const Profile& config, the config to be used (may be the same as in constructor) | 108 | * @param const Profile& config, the config to be used (may be the same as in constructor) |
109 | */ | 109 | */ |
110 | virtual void reloadConfig( const Profile& config ) = 0; | 110 | virtual void reloadConfig( const Profile& config ) = 0; |
111 | 111 | ||
112 | 112 | ||
113 | /** | 113 | /** |
114 | * sets the scrollbar (if implemented by successor of this class) | 114 | * sets the scrollbar (if implemented by successor of this class) |
115 | */ | 115 | */ |
116 | virtual void setScroll( int cursor, int slines ) = 0; | 116 | virtual void setScroll( int cursor, int slines ) = 0; |
117 | 117 | ||
118 | /** | 118 | /** |
119 | * scrolls (if implemented, by successor of this class) | 119 | * scrolls (if implemented, by successor of this class) |
120 | * @param int value, how much the widget should scroll up (positive value) or down (negative value) | 120 | * @param int value, how much the widget should scroll up (positive value) or down (negative value) |
121 | */ | 121 | */ |
122 | virtual void scroll( int value ) = 0; | 122 | virtual void scroll( int value ) = 0; |
123 | 123 | ||
124 | 124 | ||
125 | virtual bool eventFilter( QObject *obj, QEvent *event ); | 125 | virtual bool eventFilter( QObject *obj, QEvent *event ); |
126 | |||
127 | |||
128 | QSize sizeHint(); | ||
129 | |||
130 | virtual QSize calcSize( int cols, int lins ) const = 0; | ||
126 | signals: | 131 | signals: |
127 | 132 | ||
128 | /** | 133 | /** |
129 | * key was pressed | 134 | * key was pressed |
130 | */ | 135 | */ |
131 | void keyPressed( QKeyEvent *e ); | 136 | void keyPressed( QKeyEvent *e ); |
132 | 137 | ||
133 | /** | 138 | /** |
134 | * whenever Mouse selects something | 139 | * whenever Mouse selects something |
135 | * @param int button, the button that us pressed : | 140 | * @param int button, the button that us pressed : |
136 | * 0left Button | 141 | * 0left Button |
137 | * 3Button released | 142 | * 3Button released |
138 | * @param int x, x position | 143 | * @param int x, x position |
139 | * @param int y, y position | 144 | * @param int y, y position |
140 | * | 145 | * |
141 | * // numbering due to layout in old TEWidget | 146 | * // numbering due to layout in old TEWidget |
142 | */ | 147 | */ |
143 | void mousePressed( int button, int x, int y ); | 148 | void mousePressed( int button, int x, int y ); |
144 | 149 | ||
145 | /** | 150 | /** |
146 | * size of image changed | 151 | * size of image changed |
147 | * @param int lines, line count of new size | 152 | * @param int lines, line count of new size |
148 | * @param int columns, column count of new size | 153 | * @param int columns, column count of new size |
149 | */ | 154 | */ |
150 | void imageSizeChanged( int lines, int columns ); | 155 | void imageSizeChanged( int lines, int columns ); |
151 | 156 | ||
152 | /** | 157 | /** |
153 | * cursor in history changed | 158 | * cursor in history changed |
154 | * @param int value, value of history cursor | 159 | * @param int value, value of history cursor |
155 | */ | 160 | */ |
156 | void historyCursorChanged( int value ); | 161 | void historyCursorChanged( int value ); |
157 | 162 | ||