summaryrefslogtreecommitdiff
authorzecke <zecke>2002-10-14 13:16:07 (UTC)
committer zecke <zecke>2002-10-14 13:16:07 (UTC)
commit17e4897122da8089fadb05496d09fb196919f674 (patch) (unidiff)
tree5445c6761d4215bc1c532407c79ab3fbbae6b551
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 (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
@@ -107,8 +107,8 @@ struct ColorEntry
107 bold = rhs.bold; 107 bold = rhs.bold;
108 } 108 }
109 QColor color; 109 QColor color;
110 bool transparent; // if used on bg 110 bool transparent : 1; // if used on bg
111 bool bold; // if used on fg 111 bool bold : 1; // if used on fg
112}; 112};
113 113
114#endif // COMMON_H 114#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
@@ -17,10 +17,26 @@
17 17
18#define SCRWIDTH 16 // width of scrollbar 18#define SCRWIDTH 16 // width of scrollbar
19 19
20
21static const ColorEntry color_table[TABLE_COLORS] =
22{
23 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback
24 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red
25 ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow
26 ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta
27 ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White
28 // intensiv
29 ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ),
30 ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ),
31 ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ),
32 ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ),
33 ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 )
34};
35
20EmulationWidget::EmulationWidget( const Profile& config, QWidget *parent, const char* name ) : WidgetLayer( config, parent, name ) 36EmulationWidget::EmulationWidget( const Profile& config, QWidget *parent, const char* name ) : WidgetLayer( config, parent, name )
21{ 37{
22 38
23 // initialize font attributes 39 // initialize font attributes
24 QFontMetrics fm( font() ); 40 QFontMetrics fm( font() );
25 f_height = fm.height(); 41 f_height = fm.height();
26 f_width = fm.maxWidth(); 42 f_width = fm.maxWidth();
@@ -32,16 +48,16 @@ EmulationWidget::EmulationWidget( const Profile& config, QWidget *parent, const
32 48
33 // give reasonable defaults to m_columns, m_lines 49 // give reasonable defaults to m_columns, m_lines
34 calcGeometry(); 50 calcGeometry();
35 51
36 // load config 52 // load config
37 reloadConfig( config ); 53 reloadConfig( config );
38 54
39 m_resizing = false; 55 m_resizing = false;
40} 56}
41 57
42void EmulationWidget::reloadConfig( const Profile& config ) 58void EmulationWidget::reloadConfig( const Profile& config )
43{ 59{
44 60
45 // nothing yet 61 // nothing yet
46} 62}
47 63
@@ -107,7 +123,7 @@ void EmulationWidget::setImage( QArray<Character> const newimg, int lines, int c
107 setUpdatesEnabled( false ); 123 setUpdatesEnabled( false );
108 124
109 paint.begin( this ); 125 paint.begin( this );
110 126
111 QPoint tL = contentsRect().topLeft(); 127 QPoint tL = contentsRect().topLeft();
112 int tLx = tL.x(); 128 int tLx = tL.x();
113 int tLy = tL.y(); 129 int tLy = tL.y();
@@ -119,7 +135,7 @@ void EmulationWidget::setImage( QArray<Character> const newimg, int lines, int c
119 135
120 int lins = QMIN( m_lines, QMAX( 0, lines ) ); 136 int lins = QMIN( m_lines, QMAX( 0, lines ) );
121 int cols = QMIN( m_columns, QMAX( 0, columns ) ); 137 int cols = QMIN( m_columns, QMAX( 0, columns ) );
122 QArray<QChar> disstrU = QArray<QChar>( cols ); 138 QArray<QChar> disstrU = QArray<QChar>( cols );
123 139
124 for ( int y = 0; y < lins; ++y ) 140 for ( int y = 0; y < lins; ++y )
125 {int len; 141 {int len;
@@ -130,7 +146,7 @@ void EmulationWidget::setImage( QArray<Character> const newimg, int lines, int c
130 { 146 {
131 // disable, till widget works, WITHOUT blinking 147 // disable, till widget works, WITHOUT blinking
132 //hasBlinker |= ( ext[x].r & RE_BLINK ); 148 //hasBlinker |= ( ext[x].r & RE_BLINK );
133 149
134 if ( ext[x] != lcl[x] ) 150 if ( ext[x] != lcl[x] )
135 { 151 {
136 cr = ext[x].r; 152 cr = ext[x].r;
@@ -172,7 +188,7 @@ void EmulationWidget::paintEvent( QPaintEvent* pe )
172{ 188{
173 QPainter painter; 189 QPainter painter;
174 const QPixmap* pm = backgroundPixmap(); 190 const QPixmap* pm = backgroundPixmap();
175 191
176 painter.begin( this ); 192 painter.begin( this );
177 painter.setBackgroundMode( TransparentMode ); 193 painter.setBackgroundMode( TransparentMode );
178 194
@@ -180,12 +196,12 @@ void EmulationWidget::paintEvent( QPaintEvent* pe )
180 QPoint tL = contentsRect().topLeft(); 196 QPoint tL = contentsRect().topLeft();
181 int tLx = tL.x(); 197 int tLx = tL.x();
182 int tLy = tL.y(); 198 int tLy = tL.y();
183 199
184 int lux = QMIN(m_columns-1, QMAX(0,(rect.left() - tLx - m_blX ) / f_width)); 200 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)); 201 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)); 202 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)); 203 int rly = QMIN(m_lines-1, QMAX(0,(rect.bottom() - tLy - m_bY ) / f_height));
188 204
189 QChar *disstrU = new QChar[m_columns]; 205 QChar *disstrU = new QChar[m_columns];
190 for (int y = luy; y <= rly; y++) 206 for (int y = luy; y <= rly; y++)
191 for (int x = lux; x <= rlx; x++) 207 for (int x = lux; x <= rlx; x++)
@@ -205,7 +221,7 @@ void EmulationWidget::paintEvent( QPaintEvent* pe )
205 } 221 }
206 QString unistr(disstrU,len); 222 QString unistr(disstrU,len);
207 223
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 ); 224 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 );
209 x +=len -1; 225 x +=len -1;
210 } 226 }
211 delete [] disstrU; 227 delete [] disstrU;
@@ -240,13 +256,14 @@ void EmulationWidget::calcGeometry()
240 m_scrollbar->show(); 256 m_scrollbar->show();
241 break; 257 break;
242 } 258 }
243 259
244 m_lines = ( contentsRect().height() - 2 * rimY ) / f_height; 260 m_lines = ( contentsRect().height() - 2 * rimY ) / f_height;
245 m_bY = ( contentsRect().height() - (m_lines * f_height ) ) / 2; 261 m_bY = ( contentsRect().height() - (m_lines * f_height ) ) / 2;
246} 262}
247 263
248void EmulationWidget::drawAttrString( QString& string, QPainter &painter, QRect rect, Character attr, bool usePixmap, bool clear ) 264void EmulationWidget::drawAttrString( QString& string, QPainter &painter, QRect rect, Character attr, bool usePixmap, bool clear )
249{ 265{
266 qWarning("Color1 %s", color_table[attr.b].color.name().latin1() );
250 if ( usePixmap && color_table[attr.b].transparent ) 267 if ( usePixmap && color_table[attr.b].transparent )
251 { 268 {
252 painter.setBackgroundMode( TransparentMode ); 269 painter.setBackgroundMode( TransparentMode );
@@ -260,6 +277,7 @@ void EmulationWidget::drawAttrString( QString& string, QPainter &painter, QRect
260 else 277 else
261 { 278 {
262 painter.setBackgroundMode( OpaqueMode ); 279 painter.setBackgroundMode( OpaqueMode );
280 qWarning("Color %s", color_table[attr.b].color.name().latin1() );
263 painter.setBackgroundColor( color_table[attr.b].color ); 281 painter.setBackgroundColor( color_table[attr.b].color );
264 } 282 }
265 } 283 }
@@ -285,17 +303,4 @@ void EmulationWidget::setScroll( int cursor, int slines )
285} 303}
286 304
287 305
288static const ColorEntry color_table[TABLE_COLORS] = 306
289{
290 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback
291 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red
292 ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow
293 ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta
294 ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White
295 // intensiv
296 ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ),
297 ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ),
298 ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ),
299 ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ),
300 ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 )
301};
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
@@ -89,7 +89,7 @@ protected:
89 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 );
90 90
91protected: 91protected:
92 92
93 enum ScrollLocation 93 enum ScrollLocation
94 { 94 {
95 SCRNONE, 95 SCRNONE,
@@ -103,14 +103,14 @@ protected:
103 int m_blX; 103 int m_blX;
104 int m_blY; 104 int m_blY;
105 int m_brX; 105 int m_brX;
106 106
107 int m_bY; 107 int m_bY;
108 int m_bX; 108 int m_bX;
109 QScrollBar* m_scrollbar; 109 QScrollBar* m_scrollbar;
110 110
111 ScrollLocation scrollLoc; 111 ScrollLocation scrollLoc;
112 112
113 ColorEntry* color_table; 113 //ColorEntry* color_table;
114 114
115 bool blinking; 115 bool blinking;
116}; 116};