summaryrefslogtreecommitdiff
path: root/noncore
authorzecke <zecke>2002-10-14 13:16:07 (UTC)
committer zecke <zecke>2002-10-14 13:16:07 (UTC)
commit17e4897122da8089fadb05496d09fb196919f674 (patch) (side-by-side diff)
tree5445c6761d4215bc1c532407c79ab3fbbae6b551 /noncore
parent767d7347ce002e7633278d66758e17d49f40b0f0 (diff)
downloadopie-17e4897122da8089fadb05496d09fb196919f674.zip
opie-17e4897122da8089fadb05496d09fb196919f674.tar.gz
opie-17e4897122da8089fadb05496d09fb196919f674.tar.bz2
Hi Murphy!
One ColorEntry *color_table in the class and one color table at the end of the file Which one does the Compiler pick? Fix crashes! ColorEntry use bitfields
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/common.h4
-rw-r--r--noncore/apps/opie-console/emulation_widget.cpp59
-rw-r--r--noncore/apps/opie-console/emulation_widget.h6
3 files changed, 37 insertions, 32 deletions
diff --git a/noncore/apps/opie-console/common.h b/noncore/apps/opie-console/common.h
index a621ff5..645d5c5 100644
--- a/noncore/apps/opie-console/common.h
+++ b/noncore/apps/opie-console/common.h
@@ -98,17 +98,17 @@ inline BOOL operator != (Character a, Character b)
/*!
*/
struct ColorEntry
{
ColorEntry(QColor c, bool tr, bool b) : color(c), transparent(tr), bold(b) {}
ColorEntry() : transparent(false), bold(false) {} // default constructors
void operator=(const ColorEntry& rhs) {
color = rhs.color;
transparent = rhs.transparent;
bold = rhs.bold;
}
QColor color;
- bool transparent; // if used on bg
- bool bold; // if used on fg
+ bool transparent : 1; // if used on bg
+ bool bold : 1; // if used on fg
};
#endif // COMMON_H
diff --git a/noncore/apps/opie-console/emulation_widget.cpp b/noncore/apps/opie-console/emulation_widget.cpp
index 5a02fac..9138f29 100644
--- a/noncore/apps/opie-console/emulation_widget.cpp
+++ b/noncore/apps/opie-console/emulation_widget.cpp
@@ -8,49 +8,65 @@
#include <qwidget.h>
#include <qarray.h>
#include <qstring.h>
#include <qpainter.h>
#include <qrect.h>
#include <qscrollbar.h>
#define rimX 0 // left/right rim width
#define rimY 0 // top/bottom rim high
#define SCRWIDTH 16 // width of scrollbar
+
+static const ColorEntry color_table[TABLE_COLORS] =
+{
+ ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback
+ ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red
+ ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow
+ ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta
+ ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White
+ // intensiv
+ ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ),
+ ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ),
+ ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ),
+ ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ),
+ ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 )
+};
+
EmulationWidget::EmulationWidget( const Profile& config, QWidget *parent, const char* name ) : WidgetLayer( config, parent, name )
{
- // initialize font attributes
+ // initialize font attributes
QFontMetrics fm( font() );
f_height = fm.height();
f_width = fm.maxWidth();
f_ascent = fm.ascent();
// initialize scrollbar related vars
m_scrollbar = new QScrollBar( this );
m_scrollbar->setCursor( arrowCursor );
// give reasonable defaults to m_columns, m_lines
calcGeometry();
-
+
// load config
reloadConfig( config );
-
+
m_resizing = false;
}
void EmulationWidget::reloadConfig( const Profile& config )
{
-
+
// nothing yet
}
EmulationWidget::~EmulationWidget()
{
//clean up
}
static QChar vt100extended(QChar c)
{
switch (c.unicode())
{
@@ -98,48 +114,48 @@ QSize EmulationWidget::calcSize( int cols, int lins ) const
return QSize( f_width * cols + 2 * rimX + frw + scw, f_height * lins + 2 * rimY + frh );
}
void EmulationWidget::setImage( QArray<Character> const newimg, int lines, int columns )
{
const QPixmap* pm = backgroundPixmap();
QPainter paint;
// dont allow updates, while drawing
setUpdatesEnabled( false );
paint.begin( this );
-
+
QPoint tL = contentsRect().topLeft();
int tLx = tL.x();
int tLy = tL.y();
// hasBlinker = false;
int cf = -1;
int cb = -1;
int cr = -1;
int lins = QMIN( m_lines, QMAX( 0, lines ) );
int cols = QMIN( m_columns, QMAX( 0, columns ) );
- QArray<QChar> disstrU = QArray<QChar>( cols );
+ QArray<QChar> disstrU = QArray<QChar>( cols );
for ( int y = 0; y < lins; ++y )
{ int len;
const Character* lcl = &m_image[y * m_columns];
const Character* ext = &newimg[y * m_columns];
if ( ! m_resizing )
for ( int x = 0; x < cols; ++x )
{
// disable, till widget works, WITHOUT blinking
//hasBlinker |= ( ext[x].r & RE_BLINK );
-
+
if ( ext[x] != lcl[x] )
{
cr = ext[x].r;
cb = ext[x].b;
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 );
@@ -163,58 +179,58 @@ void EmulationWidget::setImage( QArray<Character> const newimg, int lines, int c
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 );
+ 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 != 0l, false );
x +=len -1;
}
delete [] disstrU;
drawFrame( &painter );
painter.end();
}
void EmulationWidget::calcGeometry()
{
m_scrollbar->resize(QApplication::style().scrollBarExtent().width(), contentsRect().height() );
switch( scrollLoc )
@@ -231,44 +247,46 @@ void EmulationWidget::calcGeometry()
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;
}
-void EmulationWidget::drawAttrString( QString& string, QPainter &painter, QRect rect, Character attr, bool usePixmap, bool clear )
+void EmulationWidget::drawAttrString( QString& string, QPainter &painter, QRect rect, Character attr, bool usePixmap, bool clear )
{
+ qWarning("Color1 %s", color_table[attr.b].color.name().latin1() );
if ( usePixmap && color_table[attr.b].transparent )
{
painter.setBackgroundMode( TransparentMode );
if ( clear )
erase( rect );
}
else
{
if ( blinking )
painter.fillRect( rect, color_table[attr.b].color );
else
{
painter.setBackgroundMode( OpaqueMode );
+ qWarning("Color %s", color_table[attr.b].color.name().latin1() );
painter.setBackgroundColor( color_table[attr.b].color );
}
}
if ( color_table[attr.f].bold )
painter.setPen( QColor( 0x8F, 0x00, 0x00 ) );
else
painter.setPen( color_table[attr.f].color );
painter.drawText( rect.x(), rect.y() + f_ascent, string );
}
@@ -276,26 +294,13 @@ void EmulationWidget::drawAttrString( QString& string, QPainter &painter, QRect
// scrollbar
// ////////////////////
void EmulationWidget::scroll( int value )
{
}
void EmulationWidget::setScroll( int cursor, int slines )
{
}
-static const ColorEntry color_table[TABLE_COLORS] =
-{
- ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback
- ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red
- ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow
- ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta
- ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White
- // intensiv
- ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ),
- ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ),
- ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ),
- ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ),
- ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 )
-};
+
diff --git a/noncore/apps/opie-console/emulation_widget.h b/noncore/apps/opie-console/emulation_widget.h
index d050681..f12b961 100644
--- a/noncore/apps/opie-console/emulation_widget.h
+++ b/noncore/apps/opie-console/emulation_widget.h
@@ -80,37 +80,37 @@ protected:
/**
* 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;
-
+
int m_bY;
int m_bX;
QScrollBar* m_scrollbar;
ScrollLocation scrollLoc;
- ColorEntry* color_table;
+// ColorEntry* color_table;
bool blinking;
};