author | ibotty <ibotty> | 2002-10-14 11:44:23 (UTC) |
---|---|---|
committer | ibotty <ibotty> | 2002-10-14 11:44:23 (UTC) |
commit | 767d7347ce002e7633278d66758e17d49f40b0f0 (patch) (side-by-side diff) | |
tree | d6611d0151cd4c42e51fc98c8e8c87a93788e128 | |
parent | 0bccef01b70fec98e744fab286f5ea443287cdad (diff) | |
download | opie-767d7347ce002e7633278d66758e17d49f40b0f0.zip opie-767d7347ce002e7633278d66758e17d49f40b0f0.tar.gz opie-767d7347ce002e7633278d66758e17d49f40b0f0.tar.bz2 |
widget should now update properly
-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 @@ -138,64 +138,110 @@ void EmulationWidget::setImage( QArray<Character> const newimg, int lines, int c if ( ext[x].f != cf ) cf = ext[x].f; int lln = cols - x; disstrU[0] = vt100extended( ext[x+0].c ); for ( len = 1; len < lln; ++len ) { if ( ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || ext[x+len] == lcl[x+len] ) break; disstrU[len] = vt100extended( ext[x+len].c ); } QString unistr( disstrU, len ); 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 ); x += len -1; } } // make image become newimg memcpy( (void*) lcl, (const void*) ext, cols*sizeof( Character ) ); } drawFrame( &paint ); paint.end(); setUpdatesEnabled( true ); /*if ( hasBlinker && !blinkT->isActive() ) blinkT->start(1000); //ms if ( ! hasBlinker && blinkT->isActive() ) { blinkT->stop(); blinking = false; }*/ delete [] disstrU; } + +void EmulationWidget::paintEvent( QPaintEvent* pe ) +{ + QPainter painter; + const QPixmap* pm = backgroundPixmap(); + + painter.begin( this ); + painter.setBackgroundMode( TransparentMode ); + + QRect rect = pe->rect().intersect( contentsRect() ); + QPoint tL = contentsRect().topLeft(); + int tLx = tL.x(); + int tLy = tL.y(); + + int lux = QMIN(m_columns-1, QMAX(0,(rect.left() - tLx - m_blX ) / f_width)); + int luy = QMIN(m_lines-1, QMAX(0,(rect.top() - tLy - m_bY ) / f_height)); + int rlx = QMIN(m_columns-1, QMAX(0,(rect.right() - tLx - m_blX ) / f_width)); + int rly = QMIN(m_lines-1, QMAX(0,(rect.bottom() - tLy - m_bY ) / f_height)); + + QChar *disstrU = new QChar[m_columns]; + for (int y = luy; y <= rly; y++) + for (int x = lux; x <= rlx; x++) + { + int len = 1; + disstrU[0] = vt100extended(m_image[loc(x,y)].c); + int cf = m_image[loc(x,y)].f; + int cb = m_image[loc(x,y)].b; + int cr = m_image[loc(x,y)].r; + while (x+len <= rlx && + m_image[loc(x+len,y)].f == cf && + m_image[loc(x+len,y)].b == cb && + m_image[loc(x+len,y)].r == cr ) + { + disstrU[len] = vt100extended(m_image[loc(x+len,y)].c); + len += 1; + } + QString unistr(disstrU,len); + + 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 ); + x +=len -1; + } + delete [] disstrU; + drawFrame( &painter ); + painter.end(); +} + void EmulationWidget::calcGeometry() { m_scrollbar->resize(QApplication::style().scrollBarExtent().width(), contentsRect().height() ); switch( scrollLoc ) { case SCRNONE : m_columns = ( contentsRect().width() -2 * rimX ) / f_width; m_blX = ( contentsRect().width() - ( m_columns*f_width ) ) / 2; m_brX = m_blX; m_scrollbar->hide(); break; case SCRLEFT : m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width; m_brX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2; m_blX = m_brX + m_scrollbar->width(); m_scrollbar->move( contentsRect().topLeft() ); m_scrollbar->show(); break; case SCRIGHT: m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width; m_blX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2; m_brX = m_blX; m_scrollbar->move( contentsRect().topRight() - QPoint (m_scrollbar->width()-1,0 ) ); m_scrollbar->show(); break; } m_lines = ( contentsRect().height() - 2 * rimY ) / f_height; m_bY = ( contentsRect().height() - (m_lines * f_height ) ) / 2; } 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 @@ -41,64 +41,66 @@ public: * @param int lines, lines of the new image * @param int columns, columns of the new image */ virtual void setImage( QArray<Character> const newimg, int columns, int lines ); /** * reloads configuration * @param const Profile& config, configuration */ virtual void reloadConfig( const Profile& config ); /** * sets the scrollbar (not yet implemented) */ virtual void setScroll( int cursor, int slines ); /** * scrolls (not yet implemented) * @param int value, scroll by this value */ virtual void scroll( int value ); virtual QSize calcSize( int cols, int lins ) const; protected: /** * calculates current image bounds */ virtual void calcGeometry(); + void paintEvent( QPaintEvent* event ); + /** * @param const ColorEntry* table, the new color table */ void setColorTable( const ColorEntry table[] ); /** * draws a String * @param QString& string, string to be drawn * @param QPainter& painter, painter, that should draw * @param QRect rect, rect to be drawn into * @param Character attr, attributes of Characters * @param bool usePixmap, if to use the background pixmap (currently not supported) * @param bool clear, if rect should be cleared */ void drawAttrString( QString& string, QPainter& painter, QRect rect, Character attr, bool pm, bool clear ); protected: enum ScrollLocation { SCRNONE, SCRLEFT, SCRIGHT }; int f_height; int f_width; int f_ascent; int m_blX; int m_blY; int m_brX; |