author | zecke <zecke> | 2002-10-14 13:16:07 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-14 13:16:07 (UTC) |
commit | 17e4897122da8089fadb05496d09fb196919f674 (patch) (unidiff) | |
tree | 5445c6761d4215bc1c532407c79ab3fbbae6b551 | |
parent | 767d7347ce002e7633278d66758e17d49f40b0f0 (diff) | |
download | opie-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
-rw-r--r-- | noncore/apps/opie-console/common.h | 4 | ||||
-rw-r--r-- | noncore/apps/opie-console/emulation_widget.cpp | 59 | ||||
-rw-r--r-- | noncore/apps/opie-console/emulation_widget.h | 6 |
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 | |||
@@ -86,29 +86,29 @@ public: | |||
86 | }; | 86 | }; |
87 | 87 | ||
88 | inline BOOL operator == (Character a, Character b) | 88 | inline BOOL operator == (Character a, Character b) |
89 | { | 89 | { |
90 | return a.c == b.c && a.f == b.f && a.b == b.b && a.r == b.r; | 90 | return a.c == b.c && a.f == b.f && a.b == b.b && a.r == b.r; |
91 | } | 91 | } |
92 | 92 | ||
93 | inline BOOL operator != (Character a, Character b) | 93 | inline BOOL operator != (Character a, Character b) |
94 | { | 94 | { |
95 | return a.c != b.c || a.f != b.f || a.b != b.b || a.r != b.r; | 95 | return a.c != b.c || a.f != b.f || a.b != b.b || a.r != b.r; |
96 | } | 96 | } |
97 | 97 | ||
98 | /*! | 98 | /*! |
99 | */ | 99 | */ |
100 | struct ColorEntry | 100 | struct ColorEntry |
101 | { | 101 | { |
102 | ColorEntry(QColor c, bool tr, bool b) : color(c), transparent(tr), bold(b) {} | 102 | ColorEntry(QColor c, bool tr, bool b) : color(c), transparent(tr), bold(b) {} |
103 | ColorEntry() : transparent(false), bold(false) {} // default constructors | 103 | ColorEntry() : transparent(false), bold(false) {} // default constructors |
104 | void operator=(const ColorEntry& rhs) { | 104 | void operator=(const ColorEntry& rhs) { |
105 | color = rhs.color; | 105 | color = rhs.color; |
106 | transparent = rhs.transparent; | 106 | transparent = rhs.transparent; |
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 | |||
@@ -1,68 +1,84 @@ | |||
1 | // opie-console includes | 1 | // opie-console includes |
2 | #include "emulation_widget.h" | 2 | #include "emulation_widget.h" |
3 | #include "common.h" | 3 | #include "common.h" |
4 | #include "widget_layer.h" | 4 | #include "widget_layer.h" |
5 | #include "profile.h" | 5 | #include "profile.h" |
6 | 6 | ||
7 | // qt includes | 7 | // qt includes |
8 | #include <qwidget.h> | 8 | #include <qwidget.h> |
9 | #include <qarray.h> | 9 | #include <qarray.h> |
10 | #include <qstring.h> | 10 | #include <qstring.h> |
11 | #include <qpainter.h> | 11 | #include <qpainter.h> |
12 | #include <qrect.h> | 12 | #include <qrect.h> |
13 | #include <qscrollbar.h> | 13 | #include <qscrollbar.h> |
14 | 14 | ||
15 | #define rimX 0 // left/right rim width | 15 | #define rimX 0 // left/right rim width |
16 | #define rimY 0 // top/bottom rim high | 16 | #define rimY 0 // top/bottom rim high |
17 | 17 | ||
18 | #define SCRWIDTH 16 // width of scrollbar | 18 | #define SCRWIDTH 16 // width of scrollbar |
19 | 19 | ||
20 | |||
21 | static 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 | |||
20 | EmulationWidget::EmulationWidget( const Profile& config, QWidget *parent, const char* name ) : WidgetLayer( config, parent, name ) | 36 | EmulationWidget::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(); |
27 | f_ascent = fm.ascent(); | 43 | f_ascent = fm.ascent(); |
28 | 44 | ||
29 | // initialize scrollbar related vars | 45 | // initialize scrollbar related vars |
30 | m_scrollbar = new QScrollBar( this ); | 46 | m_scrollbar = new QScrollBar( this ); |
31 | m_scrollbar->setCursor( arrowCursor ); | 47 | m_scrollbar->setCursor( arrowCursor ); |
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 | ||
42 | void EmulationWidget::reloadConfig( const Profile& config ) | 58 | void EmulationWidget::reloadConfig( const Profile& config ) |
43 | { | 59 | { |
44 | 60 | ||
45 | // nothing yet | 61 | // nothing yet |
46 | } | 62 | } |
47 | 63 | ||
48 | EmulationWidget::~EmulationWidget() | 64 | EmulationWidget::~EmulationWidget() |
49 | { | 65 | { |
50 | //clean up | 66 | //clean up |
51 | } | 67 | } |
52 | 68 | ||
53 | static QChar vt100extended(QChar c) | 69 | static QChar vt100extended(QChar c) |
54 | { | 70 | { |
55 | switch (c.unicode()) | 71 | switch (c.unicode()) |
56 | { | 72 | { |
57 | case 0x25c6 : return 1; | 73 | case 0x25c6 : return 1; |
58 | case 0x2592 : return 2; | 74 | case 0x2592 : return 2; |
59 | case 0x2409 : return 3; | 75 | case 0x2409 : return 3; |
60 | case 0x240c : return 4; | 76 | case 0x240c : return 4; |
61 | case 0x240d : return 5; | 77 | case 0x240d : return 5; |
62 | case 0x240a : return 6; | 78 | case 0x240a : return 6; |
63 | case 0x00b0 : return 7; | 79 | case 0x00b0 : return 7; |
64 | case 0x00b1 : return 8; | 80 | case 0x00b1 : return 8; |
65 | case 0x2424 : return 9; | 81 | case 0x2424 : return 9; |
66 | case 0x240b : return 10; | 82 | case 0x240b : return 10; |
67 | case 0x2518 : return 11; | 83 | case 0x2518 : return 11; |
68 | case 0x2510 : return 12; | 84 | case 0x2510 : return 12; |
@@ -86,216 +102,205 @@ static QChar vt100extended(QChar c) | |||
86 | case 0x00a3 : return 30; | 102 | case 0x00a3 : return 30; |
87 | case 0x00b7 : return 31; | 103 | case 0x00b7 : return 31; |
88 | } | 104 | } |
89 | return c; | 105 | return c; |
90 | } | 106 | } |
91 | 107 | ||
92 | 108 | ||
93 | QSize EmulationWidget::calcSize( int cols, int lins ) const | 109 | QSize EmulationWidget::calcSize( int cols, int lins ) const |
94 | { | 110 | { |
95 | int frw = width() - contentsRect().width(); | 111 | int frw = width() - contentsRect().width(); |
96 | int frh = height() - contentsRect().height(); | 112 | int frh = height() - contentsRect().height(); |
97 | int scw = (scrollLoc == SCRNONE? 0 : m_scrollbar->width() ); | 113 | int scw = (scrollLoc == SCRNONE? 0 : m_scrollbar->width() ); |
98 | return QSize( f_width * cols + 2 * rimX + frw + scw, f_height * lins + 2 * rimY + frh ); | 114 | return QSize( f_width * cols + 2 * rimX + frw + scw, f_height * lins + 2 * rimY + frh ); |
99 | } | 115 | } |
100 | 116 | ||
101 | void EmulationWidget::setImage( QArray<Character> const newimg, int lines, int columns ) | 117 | void EmulationWidget::setImage( QArray<Character> const newimg, int lines, int columns ) |
102 | { | 118 | { |
103 | const QPixmap* pm = backgroundPixmap(); | 119 | const QPixmap* pm = backgroundPixmap(); |
104 | QPainter paint; | 120 | QPainter paint; |
105 | 121 | ||
106 | // dont allow updates, while drawing | 122 | // dont allow updates, while drawing |
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(); |
114 | //hasBlinker = false; | 130 | //hasBlinker = false; |
115 | 131 | ||
116 | int cf = -1; | 132 | int cf = -1; |
117 | int cb = -1; | 133 | int cb = -1; |
118 | int cr = -1; | 134 | int cr = -1; |
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; |
126 | const Character* lcl = &m_image[y * m_columns]; | 142 | const Character* lcl = &m_image[y * m_columns]; |
127 | const Character* ext = &newimg[y * m_columns]; | 143 | const Character* ext = &newimg[y * m_columns]; |
128 | if ( ! m_resizing ) | 144 | if ( ! m_resizing ) |
129 | for ( int x = 0; x < cols; ++x ) | 145 | for ( int x = 0; x < cols; ++x ) |
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; |
137 | cb = ext[x].b; | 153 | cb = ext[x].b; |
138 | if ( ext[x].f != cf ) cf = ext[x].f; | 154 | if ( ext[x].f != cf ) cf = ext[x].f; |
139 | int lln = cols - x; | 155 | int lln = cols - x; |
140 | disstrU[0] = vt100extended( ext[x+0].c ); | 156 | disstrU[0] = vt100extended( ext[x+0].c ); |
141 | for ( len = 1; len < lln; ++len ) | 157 | for ( len = 1; len < lln; ++len ) |
142 | { | 158 | { |
143 | if ( ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || ext[x+len] == lcl[x+len] ) | 159 | if ( ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || ext[x+len] == lcl[x+len] ) |
144 | break; | 160 | break; |
145 | disstrU[len] = vt100extended( ext[x+len].c ); | 161 | disstrU[len] = vt100extended( ext[x+len].c ); |
146 | } | 162 | } |
147 | QString unistr( disstrU, len ); | 163 | 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 ); | 164 | 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; | 165 | x += len -1; |
150 | } | 166 | } |
151 | } | 167 | } |
152 | // make image become newimg | 168 | // make image become newimg |
153 | memcpy( (void*) lcl, (const void*) ext, cols*sizeof( Character ) ); | 169 | memcpy( (void*) lcl, (const void*) ext, cols*sizeof( Character ) ); |
154 | } | 170 | } |
155 | drawFrame( &paint ); | 171 | drawFrame( &paint ); |
156 | paint.end(); | 172 | paint.end(); |
157 | setUpdatesEnabled( true ); | 173 | setUpdatesEnabled( true ); |
158 | 174 | ||
159 | /*if ( hasBlinker && !blinkT->isActive() ) | 175 | /*if ( hasBlinker && !blinkT->isActive() ) |
160 | blinkT->start(1000); //ms | 176 | blinkT->start(1000); //ms |
161 | if ( ! hasBlinker && blinkT->isActive() ) | 177 | if ( ! hasBlinker && blinkT->isActive() ) |
162 | { | 178 | { |
163 | blinkT->stop(); | 179 | blinkT->stop(); |
164 | blinking = false; | 180 | blinking = false; |
165 | }*/ | 181 | }*/ |
166 | 182 | ||
167 | delete [] disstrU; | 183 | delete [] disstrU; |
168 | } | 184 | } |
169 | 185 | ||
170 | 186 | ||
171 | void EmulationWidget::paintEvent( QPaintEvent* pe ) | 187 | 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 | ||
179 | QRect rect = pe->rect().intersect( contentsRect() ); | 195 | QRect rect = pe->rect().intersect( contentsRect() ); |
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++) |
192 | { | 208 | { |
193 | int len = 1; | 209 | int len = 1; |
194 | disstrU[0] = vt100extended(m_image[loc(x,y)].c); | 210 | disstrU[0] = vt100extended(m_image[loc(x,y)].c); |
195 | int cf = m_image[loc(x,y)].f; | 211 | int cf = m_image[loc(x,y)].f; |
196 | int cb = m_image[loc(x,y)].b; | 212 | int cb = m_image[loc(x,y)].b; |
197 | int cr = m_image[loc(x,y)].r; | 213 | int cr = m_image[loc(x,y)].r; |
198 | while (x+len <= rlx && | 214 | while (x+len <= rlx && |
199 | m_image[loc(x+len,y)].f == cf && | 215 | m_image[loc(x+len,y)].f == cf && |
200 | m_image[loc(x+len,y)].b == cb && | 216 | m_image[loc(x+len,y)].b == cb && |
201 | m_image[loc(x+len,y)].r == cr ) | 217 | m_image[loc(x+len,y)].r == cr ) |
202 | { | 218 | { |
203 | disstrU[len] = vt100extended(m_image[loc(x+len,y)].c); | 219 | disstrU[len] = vt100extended(m_image[loc(x+len,y)].c); |
204 | len += 1; | 220 | len += 1; |
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; |
212 | drawFrame( &painter ); | 228 | drawFrame( &painter ); |
213 | painter.end(); | 229 | painter.end(); |
214 | } | 230 | } |
215 | 231 | ||
216 | void EmulationWidget::calcGeometry() | 232 | void EmulationWidget::calcGeometry() |
217 | { | 233 | { |
218 | m_scrollbar->resize(QApplication::style().scrollBarExtent().width(), contentsRect().height() ); | 234 | m_scrollbar->resize(QApplication::style().scrollBarExtent().width(), contentsRect().height() ); |
219 | 235 | ||
220 | switch( scrollLoc ) | 236 | switch( scrollLoc ) |
221 | { | 237 | { |
222 | case SCRNONE : | 238 | case SCRNONE : |
223 | m_columns = ( contentsRect().width() -2 * rimX ) / f_width; | 239 | m_columns = ( contentsRect().width() -2 * rimX ) / f_width; |
224 | m_blX = ( contentsRect().width() - ( m_columns*f_width ) ) / 2; | 240 | m_blX = ( contentsRect().width() - ( m_columns*f_width ) ) / 2; |
225 | m_brX = m_blX; | 241 | m_brX = m_blX; |
226 | m_scrollbar->hide(); | 242 | m_scrollbar->hide(); |
227 | break; | 243 | break; |
228 | case SCRLEFT : | 244 | case SCRLEFT : |
229 | m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width; | 245 | m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width; |
230 | m_brX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2; | 246 | m_brX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2; |
231 | m_blX = m_brX + m_scrollbar->width(); | 247 | m_blX = m_brX + m_scrollbar->width(); |
232 | m_scrollbar->move( contentsRect().topLeft() ); | 248 | m_scrollbar->move( contentsRect().topLeft() ); |
233 | m_scrollbar->show(); | 249 | m_scrollbar->show(); |
234 | break; | 250 | break; |
235 | case SCRIGHT: | 251 | case SCRIGHT: |
236 | m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width; | 252 | m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width; |
237 | m_blX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2; | 253 | m_blX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2; |
238 | m_brX = m_blX; | 254 | m_brX = m_blX; |
239 | m_scrollbar->move( contentsRect().topRight() - QPoint (m_scrollbar->width()-1,0 ) ); | 255 | m_scrollbar->move( contentsRect().topRight() - QPoint (m_scrollbar->width()-1,0 ) ); |
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 | ||
248 | void EmulationWidget::drawAttrString( QString& string, QPainter &painter, QRect rect, Character attr, bool usePixmap, bool clear ) | 264 | void 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 ); |
253 | if ( clear ) | 270 | if ( clear ) |
254 | erase( rect ); | 271 | erase( rect ); |
255 | } | 272 | } |
256 | else | 273 | else |
257 | { | 274 | { |
258 | if ( blinking ) | 275 | if ( blinking ) |
259 | painter.fillRect( rect, color_table[attr.b].color ); | 276 | painter.fillRect( rect, color_table[attr.b].color ); |
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 | } |
266 | if ( color_table[attr.f].bold ) | 284 | if ( color_table[attr.f].bold ) |
267 | painter.setPen( QColor( 0x8F, 0x00, 0x00 ) ); | 285 | painter.setPen( QColor( 0x8F, 0x00, 0x00 ) ); |
268 | else | 286 | else |
269 | painter.setPen( color_table[attr.f].color ); | 287 | painter.setPen( color_table[attr.f].color ); |
270 | painter.drawText( rect.x(), rect.y() + f_ascent, string ); | 288 | painter.drawText( rect.x(), rect.y() + f_ascent, string ); |
271 | 289 | ||
272 | } | 290 | } |
273 | 291 | ||
274 | 292 | ||
275 | /////////////////////// | 293 | /////////////////////// |
276 | // scrollbar | 294 | // scrollbar |
277 | // //////////////////// | 295 | // //////////////////// |
278 | 296 | ||
279 | void EmulationWidget::scroll( int value ) | 297 | void EmulationWidget::scroll( int value ) |
280 | { | 298 | { |
281 | } | 299 | } |
282 | 300 | ||
283 | void EmulationWidget::setScroll( int cursor, int slines ) | 301 | void EmulationWidget::setScroll( int cursor, int slines ) |
284 | { | 302 | { |
285 | } | 303 | } |
286 | 304 | ||
287 | 305 | ||
288 | static 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 | |||
@@ -68,49 +68,49 @@ protected: | |||
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 ); | 73 | void paintEvent( QPaintEvent* event ); |
74 | 74 | ||
75 | /** | 75 | /** |
76 | * @param const ColorEntry* table, the new color table | 76 | * @param const ColorEntry* table, the new color table |
77 | */ | 77 | */ |
78 | void setColorTable( const ColorEntry table[] ); | 78 | void setColorTable( const ColorEntry table[] ); |
79 | 79 | ||
80 | /** | 80 | /** |
81 | * draws a String | 81 | * draws a String |
82 | * @param QString& string, string to be drawn | 82 | * @param QString& string, string to be drawn |
83 | * @param QPainter& painter, painter, that should draw | 83 | * @param QPainter& painter, painter, that should draw |
84 | * @param QRect rect, rect to be drawn into | 84 | * @param QRect rect, rect to be drawn into |
85 | * @param Character attr, attributes of Characters | 85 | * @param Character attr, attributes of Characters |
86 | * @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) |
87 | * @param bool clear, if rect should be cleared | 87 | * @param bool clear, if rect should be cleared |
88 | */ | 88 | */ |
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 | ||
91 | protected: | 91 | protected: |
92 | 92 | ||
93 | enum ScrollLocation | 93 | enum ScrollLocation |
94 | { | 94 | { |
95 | SCRNONE, | 95 | SCRNONE, |
96 | SCRLEFT, | 96 | SCRLEFT, |
97 | SCRIGHT | 97 | SCRIGHT |
98 | }; | 98 | }; |
99 | 99 | ||
100 | int f_height; | 100 | int f_height; |
101 | int f_width; | 101 | int f_width; |
102 | int f_ascent; | 102 | int f_ascent; |
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 | }; |