summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/emulation_widget.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-console/emulation_widget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/emulation_widget.cpp32
1 files changed, 19 insertions, 13 deletions
diff --git a/noncore/apps/opie-console/emulation_widget.cpp b/noncore/apps/opie-console/emulation_widget.cpp
index 9138f29..d8e342b 100644
--- a/noncore/apps/opie-console/emulation_widget.cpp
+++ b/noncore/apps/opie-console/emulation_widget.cpp
@@ -12,54 +12,55 @@
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 20
21static const ColorEntry color_table[TABLE_COLORS] = 21static const ColorEntry color_table[TABLE_COLORS] =
22{ 22{
23 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback 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 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 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 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 27 ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White
28 // intensiv 28 // intensiv
29 ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ), 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 ), 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 ), 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 ), 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 ) 33 ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 )
34}; 34};
35 35
36EmulationWidget::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 )
37{ 37{
38 38
39 // initialize font attributes 39 // initialize font attributes
40 QFontMetrics fm( font() ); 40 QFontMetrics fm( font() );
41 f_height = fm.height(); 41 f_height = fm.height();
42 f_width = fm.maxWidth(); 42 f_width = fm.maxWidth();
43 f_ascent = fm.ascent(); 43 f_ascent = fm.ascent();
44 44
45
45 // initialize scrollbar related vars 46 // initialize scrollbar related vars
46 m_scrollbar = new QScrollBar( this ); 47 m_scrollbar = new QScrollBar( this );
47 m_scrollbar->setCursor( arrowCursor ); 48 m_scrollbar->setCursor( arrowCursor );
48 49
49 // give reasonable defaults to m_columns, m_lines 50 // give reasonable defaults to m_columns, m_lines
50 calcGeometry(); 51 calcGeometry();
51 52
52 // load config 53 // load config
53 reloadConfig( config ); 54 reloadConfig( config );
54 55
55 m_resizing = false; 56 m_resizing = false;
56} 57}
57 58
58void EmulationWidget::reloadConfig( const Profile& config ) 59void EmulationWidget::reloadConfig( const Profile& config )
59{ 60{
60 61
61 // nothing yet 62 // nothing yet
62} 63}
63 64
64EmulationWidget::~EmulationWidget() 65EmulationWidget::~EmulationWidget()
65{ 66{
@@ -100,24 +101,25 @@ static QChar vt100extended(QChar c)
100 case 0x03c0 : return 28; 101 case 0x03c0 : return 28;
101 case 0x2260 : return 29; 102 case 0x2260 : return 29;
102 case 0x00a3 : return 30; 103 case 0x00a3 : return 30;
103 case 0x00b7 : return 31; 104 case 0x00b7 : return 31;
104 } 105 }
105 return c; 106 return c;
106} 107}
107 108
108 109
109QSize EmulationWidget::calcSize( int cols, int lins ) const 110QSize EmulationWidget::calcSize( int cols, int lins ) const
110{ 111{
111 int frw = width() - contentsRect().width(); 112 int frw = width() - contentsRect().width();
113
112 int frh = height() - contentsRect().height(); 114 int frh = height() - contentsRect().height();
113 int scw = (scrollLoc == SCRNONE? 0 : m_scrollbar->width() ); 115 int scw = (scrollLoc == SCRNONE? 0 : m_scrollbar->width() );
114 return QSize( f_width * cols + 2 * rimX + frw + scw, f_height * lins + 2 * rimY + frh ); 116 return QSize( f_width * cols + 2 * rimX + frw + scw, f_height * lins + 2 * rimY + frh );
115} 117}
116 118
117void EmulationWidget::setImage( QArray<Character> const newimg, int lines, int columns ) 119void EmulationWidget::setImage( QArray<Character> const newimg, int lines, int columns )
118{ 120{
119 const QPixmap* pm = backgroundPixmap(); 121 const QPixmap* pm = backgroundPixmap();
120 QPainter paint; 122 QPainter paint;
121 123
122 // dont allow updates, while drawing 124 // dont allow updates, while drawing
123 setUpdatesEnabled( false ); 125 setUpdatesEnabled( false );
@@ -224,25 +226,29 @@ void EmulationWidget::paintEvent( QPaintEvent* pe )
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 ); 226 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 );
225 x +=len -1; 227 x +=len -1;
226 } 228 }
227 delete [] disstrU; 229 delete [] disstrU;
228 drawFrame( &painter ); 230 drawFrame( &painter );
229 painter.end(); 231 painter.end();
230} 232}
231 233
232void EmulationWidget::calcGeometry() 234void EmulationWidget::calcGeometry()
233{ 235{
234 m_scrollbar->resize(QApplication::style().scrollBarExtent().width(), contentsRect().height() ); 236 m_scrollbar->resize(QApplication::style().scrollBarExtent().width(), contentsRect().height() );
235 237
236 switch( scrollLoc ) 238 qDebug( QString(" TEST").arg( contentsRect().width() ) );
239 qDebug( QString(" TEST").arg( contentsRect().height() ) );
240 qDebug("NEUER TESTT!!!!!!!!");
241
242 switch( scrollLoc )
237 { 243 {
238 case SCRNONE : 244 case SCRNONE :
239 m_columns = ( contentsRect().width() -2 * rimX ) / f_width; 245 m_columns = ( contentsRect().width() -2 * rimX ) / f_width;
240 m_blX = ( contentsRect().width() - ( m_columns*f_width ) ) / 2; 246 m_blX = ( contentsRect().width() - ( m_columns*f_width ) ) / 2;
241 m_brX = m_blX; 247 m_brX = m_blX;
242 m_scrollbar->hide(); 248 m_scrollbar->hide();
243 break; 249 break;
244 case SCRLEFT : 250 case SCRLEFT :
245 m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width; 251 m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width;
246 m_brX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2; 252 m_brX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2;
247 m_blX = m_brX + m_scrollbar->width(); 253 m_blX = m_brX + m_scrollbar->width();
248 m_scrollbar->move( contentsRect().topLeft() ); 254 m_scrollbar->move( contentsRect().topLeft() );