-rw-r--r-- | noncore/apps/opie-console/emulation_widget.cpp | 46 | ||||
-rw-r--r-- | noncore/apps/opie-console/emulation_widget.h | 2 |
2 files changed, 48 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/emulation_widget.cpp b/noncore/apps/opie-console/emulation_widget.cpp index 40199fa..5a02fac 100644 --- a/noncore/apps/opie-console/emulation_widget.cpp +++ b/noncore/apps/opie-console/emulation_widget.cpp | |||
@@ -42,214 +42,260 @@ EmulationWidget::EmulationWidget( const Profile& config, QWidget *parent, const | |||
42 | void EmulationWidget::reloadConfig( const Profile& config ) | 42 | void EmulationWidget::reloadConfig( const Profile& config ) |
43 | { | 43 | { |
44 | 44 | ||
45 | // nothing yet | 45 | // nothing yet |
46 | } | 46 | } |
47 | 47 | ||
48 | EmulationWidget::~EmulationWidget() | 48 | EmulationWidget::~EmulationWidget() |
49 | { | 49 | { |
50 | //clean up | 50 | //clean up |
51 | } | 51 | } |
52 | 52 | ||
53 | static QChar vt100extended(QChar c) | 53 | static QChar vt100extended(QChar c) |
54 | { | 54 | { |
55 | switch (c.unicode()) | 55 | switch (c.unicode()) |
56 | { | 56 | { |
57 | case 0x25c6 : return 1; | 57 | case 0x25c6 : return 1; |
58 | case 0x2592 : return 2; | 58 | case 0x2592 : return 2; |
59 | case 0x2409 : return 3; | 59 | case 0x2409 : return 3; |
60 | case 0x240c : return 4; | 60 | case 0x240c : return 4; |
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 | 93 | QSize EmulationWidget::calcSize( int cols, int lins ) const |
94 | { | 94 | { |
95 | int frw = width() - contentsRect().width(); | 95 | int frw = width() - contentsRect().width(); |
96 | int frh = height() - contentsRect().height(); | 96 | int frh = height() - contentsRect().height(); |
97 | int scw = (scrollLoc == SCRNONE? 0 : m_scrollbar->width() ); | 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 ); | 98 | return QSize( f_width * cols + 2 * rimX + frw + scw, f_height * lins + 2 * rimY + frh ); |
99 | } | 99 | } |
100 | 100 | ||
101 | void EmulationWidget::setImage( QArray<Character> const newimg, int lines, int columns ) | 101 | void EmulationWidget::setImage( QArray<Character> const newimg, int lines, int columns ) |
102 | { | 102 | { |
103 | const QPixmap* pm = backgroundPixmap(); | 103 | const QPixmap* pm = backgroundPixmap(); |
104 | QPainter paint; | 104 | QPainter paint; |
105 | 105 | ||
106 | // dont allow updates, while drawing | 106 | // dont allow updates, while drawing |
107 | setUpdatesEnabled( false ); | 107 | setUpdatesEnabled( false ); |
108 | 108 | ||
109 | paint.begin( this ); | 109 | paint.begin( this ); |
110 | 110 | ||
111 | QPoint tL = contentsRect().topLeft(); | 111 | QPoint tL = contentsRect().topLeft(); |
112 | int tLx = tL.x(); | 112 | int tLx = tL.x(); |
113 | int tLy = tL.y(); | 113 | int tLy = tL.y(); |
114 | //hasBlinker = false; | 114 | //hasBlinker = false; |
115 | 115 | ||
116 | int cf = -1; | 116 | int cf = -1; |
117 | int cb = -1; | 117 | int cb = -1; |
118 | int cr = -1; | 118 | int cr = -1; |
119 | 119 | ||
120 | int lins = QMIN( m_lines, QMAX( 0, lines ) ); | 120 | int lins = QMIN( m_lines, QMAX( 0, lines ) ); |
121 | int cols = QMIN( m_columns, QMAX( 0, columns ) ); | 121 | int cols = QMIN( m_columns, QMAX( 0, columns ) ); |
122 | QArray<QChar> disstrU = QArray<QChar>( cols ); | 122 | QArray<QChar> disstrU = QArray<QChar>( cols ); |
123 | 123 | ||
124 | for ( int y = 0; y < lins; ++y ) | 124 | for ( int y = 0; y < lins; ++y ) |
125 | {int len; | 125 | {int len; |
126 | const Character* lcl = &m_image[y * m_columns]; | 126 | const Character* lcl = &m_image[y * m_columns]; |
127 | const Character* ext = &newimg[y * m_columns]; | 127 | const Character* ext = &newimg[y * m_columns]; |
128 | if ( ! m_resizing ) | 128 | if ( ! m_resizing ) |
129 | for ( int x = 0; x < cols; ++x ) | 129 | for ( int x = 0; x < cols; ++x ) |
130 | { | 130 | { |
131 | // disable, till widget works, WITHOUT blinking | 131 | // disable, till widget works, WITHOUT blinking |
132 | //hasBlinker |= ( ext[x].r & RE_BLINK ); | 132 | //hasBlinker |= ( ext[x].r & RE_BLINK ); |
133 | 133 | ||
134 | if ( ext[x] != lcl[x] ) | 134 | if ( ext[x] != lcl[x] ) |
135 | { | 135 | { |
136 | cr = ext[x].r; | 136 | cr = ext[x].r; |
137 | cb = ext[x].b; | 137 | cb = ext[x].b; |
138 | if ( ext[x].f != cf ) cf = ext[x].f; | 138 | if ( ext[x].f != cf ) cf = ext[x].f; |
139 | int lln = cols - x; | 139 | int lln = cols - x; |
140 | disstrU[0] = vt100extended( ext[x+0].c ); | 140 | disstrU[0] = vt100extended( ext[x+0].c ); |
141 | for ( len = 1; len < lln; ++len ) | 141 | for ( len = 1; len < lln; ++len ) |
142 | { | 142 | { |
143 | 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] ) |
144 | break; | 144 | break; |
145 | disstrU[len] = vt100extended( ext[x+len].c ); | 145 | disstrU[len] = vt100extended( ext[x+len].c ); |
146 | } | 146 | } |
147 | QString unistr( disstrU, len ); | 147 | QString unistr( disstrU, len ); |
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 ); | 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 ); |
149 | x += len -1; | 149 | x += len -1; |
150 | } | 150 | } |
151 | } | 151 | } |
152 | // make image become newimg | 152 | // make image become newimg |
153 | memcpy( (void*) lcl, (const void*) ext, cols*sizeof( Character ) ); | 153 | memcpy( (void*) lcl, (const void*) ext, cols*sizeof( Character ) ); |
154 | } | 154 | } |
155 | drawFrame( &paint ); | 155 | drawFrame( &paint ); |
156 | paint.end(); | 156 | paint.end(); |
157 | setUpdatesEnabled( true ); | 157 | setUpdatesEnabled( true ); |
158 | 158 | ||
159 | /*if ( hasBlinker && !blinkT->isActive() ) | 159 | /*if ( hasBlinker && !blinkT->isActive() ) |
160 | blinkT->start(1000); //ms | 160 | blinkT->start(1000); //ms |
161 | if ( ! hasBlinker && blinkT->isActive() ) | 161 | if ( ! hasBlinker && blinkT->isActive() ) |
162 | { | 162 | { |
163 | blinkT->stop(); | 163 | blinkT->stop(); |
164 | blinking = false; | 164 | blinking = false; |
165 | }*/ | 165 | }*/ |
166 | 166 | ||
167 | delete [] disstrU; | 167 | delete [] disstrU; |
168 | } | 168 | } |
169 | 169 | ||
170 | |||
171 | void EmulationWidget::paintEvent( QPaintEvent* pe ) | ||
172 | { | ||
173 | QPainter painter; | ||
174 | const QPixmap* pm = backgroundPixmap(); | ||
175 | |||
176 | painter.begin( this ); | ||
177 | painter.setBackgroundMode( TransparentMode ); | ||
178 | |||
179 | QRect rect = pe->rect().intersect( contentsRect() ); | ||
180 | QPoint tL = contentsRect().topLeft(); | ||
181 | int tLx = tL.x(); | ||
182 | int tLy = tL.y(); | ||
183 | |||
184 | int lux = QMIN(m_columns-1, QMAX(0,(rect.left() - tLx - m_blX ) / f_width)); | ||
185 | int luy = QMIN(m_lines-1, QMAX(0,(rect.top() - tLy - m_bY ) / f_height)); | ||
186 | int rlx = QMIN(m_columns-1, QMAX(0,(rect.right() - tLx - m_blX ) / f_width)); | ||
187 | int rly = QMIN(m_lines-1, QMAX(0,(rect.bottom() - tLy - m_bY ) / f_height)); | ||
188 | |||
189 | QChar *disstrU = new QChar[m_columns]; | ||
190 | for (int y = luy; y <= rly; y++) | ||
191 | for (int x = lux; x <= rlx; x++) | ||
192 | { | ||
193 | int len = 1; | ||
194 | disstrU[0] = vt100extended(m_image[loc(x,y)].c); | ||
195 | int cf = m_image[loc(x,y)].f; | ||
196 | int cb = m_image[loc(x,y)].b; | ||
197 | int cr = m_image[loc(x,y)].r; | ||
198 | while (x+len <= rlx && | ||
199 | m_image[loc(x+len,y)].f == cf && | ||
200 | m_image[loc(x+len,y)].b == cb && | ||
201 | m_image[loc(x+len,y)].r == cr ) | ||
202 | { | ||
203 | disstrU[len] = vt100extended(m_image[loc(x+len,y)].c); | ||
204 | len += 1; | ||
205 | } | ||
206 | QString unistr(disstrU,len); | ||
207 | |||
208 | drawAttrString( unistr, painter, QRect( m_blX+tLx+f_width*x,m_bY+tLy+f_height*y,f_width*len,f_height ), m_image[loc(x ,y )], pm != NULL, false ); | ||
209 | x +=len -1; | ||
210 | } | ||
211 | delete [] disstrU; | ||
212 | drawFrame( &painter ); | ||
213 | painter.end(); | ||
214 | } | ||
215 | |||
170 | void EmulationWidget::calcGeometry() | 216 | void EmulationWidget::calcGeometry() |
171 | { | 217 | { |
172 | m_scrollbar->resize(QApplication::style().scrollBarExtent().width(), contentsRect().height() ); | 218 | m_scrollbar->resize(QApplication::style().scrollBarExtent().width(), contentsRect().height() ); |
173 | 219 | ||
174 | switch( scrollLoc ) | 220 | switch( scrollLoc ) |
175 | { | 221 | { |
176 | case SCRNONE : | 222 | case SCRNONE : |
177 | m_columns = ( contentsRect().width() -2 * rimX ) / f_width; | 223 | m_columns = ( contentsRect().width() -2 * rimX ) / f_width; |
178 | m_blX = ( contentsRect().width() - ( m_columns*f_width ) ) / 2; | 224 | m_blX = ( contentsRect().width() - ( m_columns*f_width ) ) / 2; |
179 | m_brX = m_blX; | 225 | m_brX = m_blX; |
180 | m_scrollbar->hide(); | 226 | m_scrollbar->hide(); |
181 | break; | 227 | break; |
182 | case SCRLEFT : | 228 | case SCRLEFT : |
183 | m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width; | 229 | m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width; |
184 | m_brX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2; | 230 | m_brX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2; |
185 | m_blX = m_brX + m_scrollbar->width(); | 231 | m_blX = m_brX + m_scrollbar->width(); |
186 | m_scrollbar->move( contentsRect().topLeft() ); | 232 | m_scrollbar->move( contentsRect().topLeft() ); |
187 | m_scrollbar->show(); | 233 | m_scrollbar->show(); |
188 | break; | 234 | break; |
189 | case SCRIGHT: | 235 | case SCRIGHT: |
190 | m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width; | 236 | m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width; |
191 | m_blX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2; | 237 | m_blX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2; |
192 | m_brX = m_blX; | 238 | m_brX = m_blX; |
193 | m_scrollbar->move( contentsRect().topRight() - QPoint (m_scrollbar->width()-1,0 ) ); | 239 | m_scrollbar->move( contentsRect().topRight() - QPoint (m_scrollbar->width()-1,0 ) ); |
194 | m_scrollbar->show(); | 240 | m_scrollbar->show(); |
195 | break; | 241 | break; |
196 | } | 242 | } |
197 | 243 | ||
198 | m_lines = ( contentsRect().height() - 2 * rimY ) / f_height; | 244 | m_lines = ( contentsRect().height() - 2 * rimY ) / f_height; |
199 | m_bY = ( contentsRect().height() - (m_lines * f_height ) ) / 2; | 245 | m_bY = ( contentsRect().height() - (m_lines * f_height ) ) / 2; |
200 | } | 246 | } |
201 | 247 | ||
202 | void EmulationWidget::drawAttrString( QString& string, QPainter &painter, QRect rect, Character attr, bool usePixmap, bool clear ) | 248 | void EmulationWidget::drawAttrString( QString& string, QPainter &painter, QRect rect, Character attr, bool usePixmap, bool clear ) |
203 | { | 249 | { |
204 | if ( usePixmap && color_table[attr.b].transparent ) | 250 | if ( usePixmap && color_table[attr.b].transparent ) |
205 | { | 251 | { |
206 | painter.setBackgroundMode( TransparentMode ); | 252 | painter.setBackgroundMode( TransparentMode ); |
207 | if ( clear ) | 253 | if ( clear ) |
208 | erase( rect ); | 254 | erase( rect ); |
209 | } | 255 | } |
210 | else | 256 | else |
211 | { | 257 | { |
212 | if ( blinking ) | 258 | if ( blinking ) |
213 | painter.fillRect( rect, color_table[attr.b].color ); | 259 | painter.fillRect( rect, color_table[attr.b].color ); |
214 | else | 260 | else |
215 | { | 261 | { |
216 | painter.setBackgroundMode( OpaqueMode ); | 262 | painter.setBackgroundMode( OpaqueMode ); |
217 | painter.setBackgroundColor( color_table[attr.b].color ); | 263 | painter.setBackgroundColor( color_table[attr.b].color ); |
218 | } | 264 | } |
219 | } | 265 | } |
220 | if ( color_table[attr.f].bold ) | 266 | if ( color_table[attr.f].bold ) |
221 | painter.setPen( QColor( 0x8F, 0x00, 0x00 ) ); | 267 | painter.setPen( QColor( 0x8F, 0x00, 0x00 ) ); |
222 | else | 268 | else |
223 | painter.setPen( color_table[attr.f].color ); | 269 | painter.setPen( color_table[attr.f].color ); |
224 | painter.drawText( rect.x(), rect.y() + f_ascent, string ); | 270 | painter.drawText( rect.x(), rect.y() + f_ascent, string ); |
225 | 271 | ||
226 | } | 272 | } |
227 | 273 | ||
228 | 274 | ||
229 | /////////////////////// | 275 | /////////////////////// |
230 | // scrollbar | 276 | // scrollbar |
231 | // //////////////////// | 277 | // //////////////////// |
232 | 278 | ||
233 | void EmulationWidget::scroll( int value ) | 279 | void EmulationWidget::scroll( int value ) |
234 | { | 280 | { |
235 | } | 281 | } |
236 | 282 | ||
237 | void EmulationWidget::setScroll( int cursor, int slines ) | 283 | void EmulationWidget::setScroll( int cursor, int slines ) |
238 | { | 284 | { |
239 | } | 285 | } |
240 | 286 | ||
241 | 287 | ||
242 | static const ColorEntry color_table[TABLE_COLORS] = | 288 | static const ColorEntry color_table[TABLE_COLORS] = |
243 | { | 289 | { |
244 | ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback | 290 | ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback |
245 | ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red | 291 | ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red |
246 | ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow | 292 | ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow |
247 | ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta | 293 | ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta |
248 | ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White | 294 | ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White |
249 | // intensiv | 295 | // intensiv |
250 | ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ), | 296 | ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ), |
251 | ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ), | 297 | ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ), |
252 | ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ), | 298 | ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ), |
253 | ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), | 299 | ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), |
254 | ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 ) | 300 | ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 ) |
255 | }; | 301 | }; |
diff --git a/noncore/apps/opie-console/emulation_widget.h b/noncore/apps/opie-console/emulation_widget.h index 5e20dc4..d050681 100644 --- a/noncore/apps/opie-console/emulation_widget.h +++ b/noncore/apps/opie-console/emulation_widget.h | |||
@@ -1,114 +1,116 @@ | |||
1 | // opie console includes | 1 | // opie console includes |
2 | #include "widget_layer.h" | 2 | #include "widget_layer.h" |
3 | #include "profile.h" | 3 | #include "profile.h" |
4 | #include "common.h" | 4 | #include "common.h" |
5 | 5 | ||
6 | // qt includes | 6 | // qt includes |
7 | #include <qwidget.h> | 7 | #include <qwidget.h> |
8 | #include <qpainter.h> | 8 | #include <qpainter.h> |
9 | #include <qstring.h> | 9 | #include <qstring.h> |
10 | #include <qarray.h> | 10 | #include <qarray.h> |
11 | #include <qrect.h> | 11 | #include <qrect.h> |
12 | 12 | ||
13 | 13 | ||
14 | 14 | ||
15 | /** | 15 | /** |
16 | * EmulationWidget | 16 | * EmulationWidget |
17 | * simple implementation of EmulationLayer | 17 | * simple implementation of EmulationLayer |
18 | * (doesn't support scrollbar, history, etc, yet) | 18 | * (doesn't support scrollbar, history, etc, yet) |
19 | */ | 19 | */ |
20 | class EmulationWidget : public WidgetLayer | 20 | class EmulationWidget : public WidgetLayer |
21 | { Q_OBJECT | 21 | { Q_OBJECT |
22 | 22 | ||
23 | public: | 23 | public: |
24 | 24 | ||
25 | /** | 25 | /** |
26 | * constructor | 26 | * constructor |
27 | * @param const Profile& config, the configuration | 27 | * @param const Profile& config, the configuration |
28 | * @param QWidget* parent, parent widget | 28 | * @param QWidget* parent, parent widget |
29 | * @param const char* name, the name of the widget | 29 | * @param const char* name, the name of the widget |
30 | */ | 30 | */ |
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; | 63 | virtual QSize calcSize( int cols, int lins ) const; |
64 | 64 | ||
65 | protected: | 65 | protected: |
66 | 66 | ||
67 | /** | 67 | /** |
68 | * calculates current image bounds | 68 | * calculates current image bounds |
69 | */ | 69 | */ |
70 | virtual void calcGeometry(); | 70 | virtual void calcGeometry(); |
71 | 71 | ||
72 | 72 | ||
73 | void paintEvent( QPaintEvent* event ); | ||
74 | |||
73 | /** | 75 | /** |
74 | * @param const ColorEntry* table, the new color table | 76 | * @param const ColorEntry* table, the new color table |
75 | */ | 77 | */ |
76 | void setColorTable( const ColorEntry table[] ); | 78 | void setColorTable( const ColorEntry table[] ); |
77 | 79 | ||
78 | /** | 80 | /** |
79 | * draws a String | 81 | * draws a String |
80 | * @param QString& string, string to be drawn | 82 | * @param QString& string, string to be drawn |
81 | * @param QPainter& painter, painter, that should draw | 83 | * @param QPainter& painter, painter, that should draw |
82 | * @param QRect rect, rect to be drawn into | 84 | * @param QRect rect, rect to be drawn into |
83 | * @param Character attr, attributes of Characters | 85 | * @param Character attr, attributes of Characters |
84 | * @param bool usePixmap, if to use the background pixmap (currently not supported) | 86 | * @param bool usePixmap, if to use the background pixmap (currently not supported) |
85 | * @param bool clear, if rect should be cleared | 87 | * @param bool clear, if rect should be cleared |
86 | */ | 88 | */ |
87 | void drawAttrString( QString& string, QPainter& painter, QRect rect, Character attr, bool pm, bool clear ); | 89 | void drawAttrString( QString& string, QPainter& painter, QRect rect, Character attr, bool pm, bool clear ); |
88 | 90 | ||
89 | protected: | 91 | protected: |
90 | 92 | ||
91 | enum ScrollLocation | 93 | enum ScrollLocation |
92 | { | 94 | { |
93 | SCRNONE, | 95 | SCRNONE, |
94 | SCRLEFT, | 96 | SCRLEFT, |
95 | SCRIGHT | 97 | SCRIGHT |
96 | }; | 98 | }; |
97 | 99 | ||
98 | int f_height; | 100 | int f_height; |
99 | int f_width; | 101 | int f_width; |
100 | int f_ascent; | 102 | int f_ascent; |
101 | int m_blX; | 103 | int m_blX; |
102 | int m_blY; | 104 | int m_blY; |
103 | int m_brX; | 105 | int m_brX; |
104 | 106 | ||
105 | int m_bY; | 107 | int m_bY; |
106 | int m_bX; | 108 | int m_bX; |
107 | QScrollBar* m_scrollbar; | 109 | QScrollBar* m_scrollbar; |
108 | 110 | ||
109 | ScrollLocation scrollLoc; | 111 | ScrollLocation scrollLoc; |
110 | 112 | ||
111 | ColorEntry* color_table; | 113 | ColorEntry* color_table; |
112 | 114 | ||
113 | bool blinking; | 115 | bool blinking; |
114 | }; | 116 | }; |