summaryrefslogtreecommitdiff
authoribotty <ibotty>2002-10-14 08:54:34 (UTC)
committer ibotty <ibotty>2002-10-14 08:54:34 (UTC)
commit59d6018e53537e15d27cd0174adefba2ec8b8f6e (patch) (unidiff)
tree5f55e9c314b7918b1abf92d2a98561039a499084
parent2c2d282f3d665035300873bddab6e64c843ebc0e (diff)
downloadopie-59d6018e53537e15d27cd0174adefba2ec8b8f6e.zip
opie-59d6018e53537e15d27cd0174adefba2ec8b8f6e.tar.gz
opie-59d6018e53537e15d27cd0174adefba2ec8b8f6e.tar.bz2
added sizeHint method, hopefully (dont really think so) fixes size problem
VS: ----------------------------------------------------------------------
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/emulation_widget.cpp9
-rw-r--r--noncore/apps/opie-console/emulation_widget.h2
-rw-r--r--noncore/apps/opie-console/widget_layer.cpp6
-rw-r--r--noncore/apps/opie-console/widget_layer.h5
4 files changed, 21 insertions, 1 deletions
diff --git a/noncore/apps/opie-console/emulation_widget.cpp b/noncore/apps/opie-console/emulation_widget.cpp
index e11c5e4..40199fa 100644
--- a/noncore/apps/opie-console/emulation_widget.cpp
+++ b/noncore/apps/opie-console/emulation_widget.cpp
@@ -1,248 +1,255 @@
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
20EmulationWidget::EmulationWidget( const Profile& config, QWidget *parent, const char* name ) : WidgetLayer( config, parent, name ) 20EmulationWidget::EmulationWidget( const Profile& config, QWidget *parent, const char* name ) : WidgetLayer( config, parent, name )
21{ 21{
22 22
23 // initialize font attributes 23 // initialize font attributes
24 QFontMetrics fm( font() ); 24 QFontMetrics fm( font() );
25 f_height = fm.height(); 25 f_height = fm.height();
26 f_width = fm.maxWidth(); 26 f_width = fm.maxWidth();
27 f_ascent = fm.ascent(); 27 f_ascent = fm.ascent();
28 28
29 // initialize scrollbar related vars 29 // initialize scrollbar related vars
30 m_scrollbar = new QScrollBar( this ); 30 m_scrollbar = new QScrollBar( this );
31 m_scrollbar->setCursor( arrowCursor ); 31 m_scrollbar->setCursor( arrowCursor );
32 32
33 // give reasonable defaults to m_columns, m_lines 33 // give reasonable defaults to m_columns, m_lines
34 calcGeometry(); 34 calcGeometry();
35 35
36 // load config 36 // load config
37 reloadConfig( config ); 37 reloadConfig( config );
38 38
39 m_resizing = false; 39 m_resizing = false;
40} 40}
41 41
42void EmulationWidget::reloadConfig( const Profile& config ) 42void EmulationWidget::reloadConfig( const Profile& config )
43{ 43{
44 44
45 // nothing yet 45 // nothing yet
46} 46}
47 47
48EmulationWidget::~EmulationWidget() 48EmulationWidget::~EmulationWidget()
49{ 49{
50 //clean up 50 //clean up
51} 51}
52 52
53static QChar vt100extended(QChar c) 53static QChar vt100extended(QChar c)
54{ 54{
55 switch (c.unicode()) 55 switch (c.unicode())
56 { 56 {
57 case 0x25c6 : return 1; 57 case 0x25c6 : return 1;
58 case 0x2592 : return 2; 58 case 0x2592 : return 2;
59 case 0x2409 : return 3; 59 case 0x2409 : return 3;
60 case 0x240c : return 4; 60 case 0x240c : return 4;
61 case 0x240d : return 5; 61 case 0x240d : return 5;
62 case 0x240a : return 6; 62 case 0x240a : return 6;
63 case 0x00b0 : return 7; 63 case 0x00b0 : return 7;
64 case 0x00b1 : return 8; 64 case 0x00b1 : return 8;
65 case 0x2424 : return 9; 65 case 0x2424 : return 9;
66 case 0x240b : return 10; 66 case 0x240b : return 10;
67 case 0x2518 : return 11; 67 case 0x2518 : return 11;
68 case 0x2510 : return 12; 68 case 0x2510 : return 12;
69 case 0x250c : return 13; 69 case 0x250c : return 13;
70 case 0x2514 : return 14; 70 case 0x2514 : return 14;
71 case 0x253c : return 15; 71 case 0x253c : return 15;
72 case 0xf800 : return 16; 72 case 0xf800 : return 16;
73 case 0xf801 : return 17; 73 case 0xf801 : return 17;
74 case 0x2500 : return 18; 74 case 0x2500 : return 18;
75 case 0xf803 : return 19; 75 case 0xf803 : return 19;
76 case 0xf804 : return 20; 76 case 0xf804 : return 20;
77 case 0x251c : return 21; 77 case 0x251c : return 21;
78 case 0x2524 : return 22; 78 case 0x2524 : return 22;
79 case 0x2534 : return 23; 79 case 0x2534 : return 23;
80 case 0x252c : return 24; 80 case 0x252c : return 24;
81 case 0x2502 : return 25; 81 case 0x2502 : return 25;
82 case 0x2264 : return 26; 82 case 0x2264 : return 26;
83 case 0x2265 : return 27; 83 case 0x2265 : return 27;
84 case 0x03c0 : return 28; 84 case 0x03c0 : return 28;
85 case 0x2260 : return 29; 85 case 0x2260 : return 29;
86 case 0x00a3 : return 30; 86 case 0x00a3 : return 30;
87 case 0x00b7 : return 31; 87 case 0x00b7 : return 31;
88 } 88 }
89 return c; 89 return c;
90} 90}
91 91
92 92
93QSize EmulationWidget::calcSize( int cols, int lins ) const
94{
95 int frw = width() - contentsRect().width();
96 int frh = height() - contentsRect().height();
97 int scw = (scrollLoc == SCRNONE? 0 : m_scrollbar->width() );
98 return QSize( f_width * cols + 2 * rimX + frw + scw, f_height * lins + 2 * rimY + frh );
99}
93 100
94void EmulationWidget::setImage( QArray<Character> const newimg, int lines, int columns ) 101void EmulationWidget::setImage( QArray<Character> const newimg, int lines, int columns )
95{ 102{
96 const QPixmap* pm = backgroundPixmap(); 103 const QPixmap* pm = backgroundPixmap();
97 QPainter paint; 104 QPainter paint;
98 105
99 // dont allow updates, while drawing 106 // dont allow updates, while drawing
100 setUpdatesEnabled( false ); 107 setUpdatesEnabled( false );
101 108
102 paint.begin( this ); 109 paint.begin( this );
103 110
104 QPoint tL = contentsRect().topLeft(); 111 QPoint tL = contentsRect().topLeft();
105 int tLx = tL.x(); 112 int tLx = tL.x();
106 int tLy = tL.y(); 113 int tLy = tL.y();
107 //hasBlinker = false; 114 //hasBlinker = false;
108 115
109 int cf = -1; 116 int cf = -1;
110 int cb = -1; 117 int cb = -1;
111 int cr = -1; 118 int cr = -1;
112 119
113 int lins = QMIN( m_lines, QMAX( 0, lines ) ); 120 int lins = QMIN( m_lines, QMAX( 0, lines ) );
114 int cols = QMIN( m_columns, QMAX( 0, columns ) ); 121 int cols = QMIN( m_columns, QMAX( 0, columns ) );
115 QArray<QChar> disstrU = QArray<QChar>( cols ); 122 QArray<QChar> disstrU = QArray<QChar>( cols );
116 123
117 for ( int y = 0; y < lins; ++y ) 124 for ( int y = 0; y < lins; ++y )
118 {int len; 125 {int len;
119 const Character* lcl = &m_image[y * m_columns]; 126 const Character* lcl = &m_image[y * m_columns];
120 const Character* ext = &newimg[y * columns]; 127 const Character* ext = &newimg[y * m_columns];
121 if ( ! m_resizing ) 128 if ( ! m_resizing )
122 for ( int x = 0; x < cols; ++x ) 129 for ( int x = 0; x < cols; ++x )
123 { 130 {
124 // disable, till widget works, WITHOUT blinking 131 // disable, till widget works, WITHOUT blinking
125 //hasBlinker |= ( ext[x].r & RE_BLINK ); 132 //hasBlinker |= ( ext[x].r & RE_BLINK );
126 133
127 if ( ext[x] != lcl[x] ) 134 if ( ext[x] != lcl[x] )
128 { 135 {
129 cr = ext[x].r; 136 cr = ext[x].r;
130 cb = ext[x].b; 137 cb = ext[x].b;
131 if ( ext[x].f != cf ) cf = ext[x].f; 138 if ( ext[x].f != cf ) cf = ext[x].f;
132 int lln = cols - x; 139 int lln = cols - x;
133 disstrU[0] = vt100extended( ext[x+0].c ); 140 disstrU[0] = vt100extended( ext[x+0].c );
134 for ( len = 1; len < lln; ++len ) 141 for ( len = 1; len < lln; ++len )
135 { 142 {
136 if ( ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || ext[x+len] == lcl[x+len] ) 143 if ( ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || ext[x+len] == lcl[x+len] )
137 break; 144 break;
138 disstrU[len] = vt100extended( ext[x+len].c ); 145 disstrU[len] = vt100extended( ext[x+len].c );
139 } 146 }
140 QString unistr( disstrU, len ); 147 QString unistr( disstrU, len );
141 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 ); 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 );
142 x += len -1; 149 x += len -1;
143 } 150 }
144 } 151 }
145 // make image become newimg 152 // make image become newimg
146 memcpy( (void*) lcl, (const void*) ext, cols*sizeof( Character ) ); 153 memcpy( (void*) lcl, (const void*) ext, cols*sizeof( Character ) );
147 } 154 }
148 drawFrame( &paint ); 155 drawFrame( &paint );
149 paint.end(); 156 paint.end();
150 setUpdatesEnabled( true ); 157 setUpdatesEnabled( true );
151 158
152 /*if ( hasBlinker && !blinkT->isActive() ) 159 /*if ( hasBlinker && !blinkT->isActive() )
153 blinkT->start(1000); //ms 160 blinkT->start(1000); //ms
154 if ( ! hasBlinker && blinkT->isActive() ) 161 if ( ! hasBlinker && blinkT->isActive() )
155 { 162 {
156 blinkT->stop(); 163 blinkT->stop();
157 blinking = false; 164 blinking = false;
158 }*/ 165 }*/
159 166
160 delete [] disstrU; 167 delete [] disstrU;
161} 168}
162 169
163void EmulationWidget::calcGeometry() 170void EmulationWidget::calcGeometry()
164{ 171{
165 m_scrollbar->resize(QApplication::style().scrollBarExtent().width(), contentsRect().height() ); 172 m_scrollbar->resize(QApplication::style().scrollBarExtent().width(), contentsRect().height() );
166 173
167 switch( scrollLoc ) 174 switch( scrollLoc )
168 { 175 {
169 case SCRNONE : 176 case SCRNONE :
170 m_columns = ( contentsRect().width() -2 * rimX ) / f_width; 177 m_columns = ( contentsRect().width() -2 * rimX ) / f_width;
171 m_blX = ( contentsRect().width() - ( m_columns*f_width ) ) / 2; 178 m_blX = ( contentsRect().width() - ( m_columns*f_width ) ) / 2;
172 m_brX = m_blX; 179 m_brX = m_blX;
173 m_scrollbar->hide(); 180 m_scrollbar->hide();
174 break; 181 break;
175 case SCRLEFT : 182 case SCRLEFT :
176 m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width; 183 m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width;
177 m_brX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2; 184 m_brX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2;
178 m_blX = m_brX + m_scrollbar->width(); 185 m_blX = m_brX + m_scrollbar->width();
179 m_scrollbar->move( contentsRect().topLeft() ); 186 m_scrollbar->move( contentsRect().topLeft() );
180 m_scrollbar->show(); 187 m_scrollbar->show();
181 break; 188 break;
182 case SCRIGHT: 189 case SCRIGHT:
183 m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width; 190 m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width;
184 m_blX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2; 191 m_blX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2;
185 m_brX = m_blX; 192 m_brX = m_blX;
186 m_scrollbar->move( contentsRect().topRight() - QPoint (m_scrollbar->width()-1,0 ) ); 193 m_scrollbar->move( contentsRect().topRight() - QPoint (m_scrollbar->width()-1,0 ) );
187 m_scrollbar->show(); 194 m_scrollbar->show();
188 break; 195 break;
189 } 196 }
190 197
191 m_lines = ( contentsRect().height() - 2 * rimY ) / f_height; 198 m_lines = ( contentsRect().height() - 2 * rimY ) / f_height;
192 m_bY = ( contentsRect().height() - (m_lines * f_height ) ) / 2; 199 m_bY = ( contentsRect().height() - (m_lines * f_height ) ) / 2;
193} 200}
194 201
195void EmulationWidget::drawAttrString( QString& string, QPainter &painter, QRect rect, Character attr, bool usePixmap, bool clear ) 202void EmulationWidget::drawAttrString( QString& string, QPainter &painter, QRect rect, Character attr, bool usePixmap, bool clear )
196{ 203{
197 if ( usePixmap && color_table[attr.b].transparent ) 204 if ( usePixmap && color_table[attr.b].transparent )
198 { 205 {
199 painter.setBackgroundMode( TransparentMode ); 206 painter.setBackgroundMode( TransparentMode );
200 if ( clear ) 207 if ( clear )
201 erase( rect ); 208 erase( rect );
202 } 209 }
203 else 210 else
204 { 211 {
205 if ( blinking ) 212 if ( blinking )
206 painter.fillRect( rect, color_table[attr.b].color ); 213 painter.fillRect( rect, color_table[attr.b].color );
207 else 214 else
208 { 215 {
209 painter.setBackgroundMode( OpaqueMode ); 216 painter.setBackgroundMode( OpaqueMode );
210 painter.setBackgroundColor( color_table[attr.b].color ); 217 painter.setBackgroundColor( color_table[attr.b].color );
211 } 218 }
212 } 219 }
213 if ( color_table[attr.f].bold ) 220 if ( color_table[attr.f].bold )
214 painter.setPen( QColor( 0x8F, 0x00, 0x00 ) ); 221 painter.setPen( QColor( 0x8F, 0x00, 0x00 ) );
215 else 222 else
216 painter.setPen( color_table[attr.f].color ); 223 painter.setPen( color_table[attr.f].color );
217 painter.drawText( rect.x(), rect.y() + f_ascent, string ); 224 painter.drawText( rect.x(), rect.y() + f_ascent, string );
218 225
219} 226}
220 227
221 228
222/////////////////////// 229///////////////////////
223// scrollbar 230// scrollbar
224// //////////////////// 231// ////////////////////
225 232
226void EmulationWidget::scroll( int value ) 233void EmulationWidget::scroll( int value )
227{ 234{
228} 235}
229 236
230void EmulationWidget::setScroll( int cursor, int slines ) 237void EmulationWidget::setScroll( int cursor, int slines )
231{ 238{
232} 239}
233 240
234 241
235static const ColorEntry color_table[TABLE_COLORS] = 242static const ColorEntry color_table[TABLE_COLORS] =
236{ 243{
237 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback 244 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback
238 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red 245 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red
239 ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow 246 ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow
240 ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta 247 ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta
241 ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White 248 ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White
242 // intensiv 249 // intensiv
243 ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ), 250 ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ),
244 ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ), 251 ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ),
245 ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ), 252 ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ),
246 ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), 253 ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ),
247 ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 ) 254 ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 )
248}; 255};
diff --git a/noncore/apps/opie-console/emulation_widget.h b/noncore/apps/opie-console/emulation_widget.h
index e185534..5e20dc4 100644
--- a/noncore/apps/opie-console/emulation_widget.h
+++ b/noncore/apps/opie-console/emulation_widget.h
@@ -1,112 +1,114 @@
1// opie console includes 1// opie console includes
2#include "widget_layer.h" 2#include "widget_layer.h"
3#include "profile.h" 3#include "profile.h"
4#include "common.h" 4#include "common.h"
5 5
6// qt includes 6// qt includes
7#include <qwidget.h> 7#include <qwidget.h>
8#include <qpainter.h> 8#include <qpainter.h>
9#include <qstring.h> 9#include <qstring.h>
10#include <qarray.h> 10#include <qarray.h>
11#include <qrect.h> 11#include <qrect.h>
12 12
13 13
14 14
15/** 15/**
16 * EmulationWidget 16 * EmulationWidget
17 * simple implementation of EmulationLayer 17 * simple implementation of EmulationLayer
18 * (doesn't support scrollbar, history, etc, yet) 18 * (doesn't support scrollbar, history, etc, yet)
19 */ 19 */
20class EmulationWidget : public WidgetLayer 20class EmulationWidget : public WidgetLayer
21{ Q_OBJECT 21{ Q_OBJECT
22 22
23public: 23public:
24 24
25 /** 25 /**
26 * constructor 26 * constructor
27 * @param const Profile& config, the configuration 27 * @param const Profile& config, the configuration
28 * @param QWidget* parent, parent widget 28 * @param QWidget* parent, parent widget
29 * @param const char* name, the name of the widget 29 * @param const char* name, the name of the widget
30 */ 30 */
31 EmulationWidget( const Profile& config, QWidget *parent=0, const char *name =0 ); 31 EmulationWidget( const Profile& config, QWidget *parent=0, const char *name =0 );
32 32
33 /** 33 /**
34 * destructor 34 * destructor
35 */ 35 */
36 ~EmulationWidget(); 36 ~EmulationWidget();
37 37
38 /** 38 /**
39 * sets the image 39 * sets the image
40 * @param QArray<Character> const newimg, the new image 40 * @param QArray<Character> const newimg, the new image
41 * @param int lines, lines of the new image 41 * @param int lines, lines of the new image
42 * @param int columns, columns of the new image 42 * @param int columns, columns of the new image
43 */ 43 */
44 virtual void setImage( QArray<Character> const newimg, int columns, int lines ); 44 virtual void setImage( QArray<Character> const newimg, int columns, int lines );
45 45
46 /** 46 /**
47 * reloads configuration 47 * reloads configuration
48 * @param const Profile& config, configuration 48 * @param const Profile& config, configuration
49 */ 49 */
50 virtual void reloadConfig( const Profile& config ); 50 virtual void reloadConfig( const Profile& config );
51 51
52 /** 52 /**
53 * sets the scrollbar (not yet implemented) 53 * sets the scrollbar (not yet implemented)
54 */ 54 */
55 virtual void setScroll( int cursor, int slines ); 55 virtual void setScroll( int cursor, int slines );
56 56
57 /** 57 /**
58 * scrolls (not yet implemented) 58 * scrolls (not yet implemented)
59 * @param int value, scroll by this value 59 * @param int value, scroll by this value
60 */ 60 */
61 virtual void scroll( int value ); 61 virtual void scroll( int value );
62 62
63 virtual QSize calcSize( int cols, int lins ) const;
64
63protected: 65protected:
64 66
65 /** 67 /**
66 * calculates current image bounds 68 * calculates current image bounds
67 */ 69 */
68 virtual void calcGeometry(); 70 virtual void calcGeometry();
69 71
70 72
71 /** 73 /**
72 * @param const ColorEntry* table, the new color table 74 * @param const ColorEntry* table, the new color table
73 */ 75 */
74 void setColorTable( const ColorEntry table[] ); 76 void setColorTable( const ColorEntry table[] );
75 77
76 /** 78 /**
77 * draws a String 79 * draws a String
78 * @param QString& string, string to be drawn 80 * @param QString& string, string to be drawn
79 * @param QPainter& painter, painter, that should draw 81 * @param QPainter& painter, painter, that should draw
80 * @param QRect rect, rect to be drawn into 82 * @param QRect rect, rect to be drawn into
81 * @param Character attr, attributes of Characters 83 * @param Character attr, attributes of Characters
82 * @param bool usePixmap, if to use the background pixmap (currently not supported) 84 * @param bool usePixmap, if to use the background pixmap (currently not supported)
83 * @param bool clear, if rect should be cleared 85 * @param bool clear, if rect should be cleared
84 */ 86 */
85 void drawAttrString( QString& string, QPainter& painter, QRect rect, Character attr, bool pm, bool clear ); 87 void drawAttrString( QString& string, QPainter& painter, QRect rect, Character attr, bool pm, bool clear );
86 88
87protected: 89protected:
88 90
89 enum ScrollLocation 91 enum ScrollLocation
90 { 92 {
91 SCRNONE, 93 SCRNONE,
92 SCRLEFT, 94 SCRLEFT,
93 SCRIGHT 95 SCRIGHT
94 }; 96 };
95 97
96 int f_height; 98 int f_height;
97 int f_width; 99 int f_width;
98 int f_ascent; 100 int f_ascent;
99 int m_blX; 101 int m_blX;
100 int m_blY; 102 int m_blY;
101 int m_brX; 103 int m_brX;
102 104
103 int m_bY; 105 int m_bY;
104 int m_bX; 106 int m_bX;
105 QScrollBar* m_scrollbar; 107 QScrollBar* m_scrollbar;
106 108
107 ScrollLocation scrollLoc; 109 ScrollLocation scrollLoc;
108 110
109 ColorEntry* color_table; 111 ColorEntry* color_table;
110 112
111 bool blinking; 113 bool blinking;
112}; 114};
diff --git a/noncore/apps/opie-console/widget_layer.cpp b/noncore/apps/opie-console/widget_layer.cpp
index e4b0ede..ac84f8b 100644
--- a/noncore/apps/opie-console/widget_layer.cpp
+++ b/noncore/apps/opie-console/widget_layer.cpp
@@ -1,243 +1,249 @@
1/* ------------------------------------------------------------------------- */ 1/* ------------------------------------------------------------------------- */
2/* */ 2/* */
3/* widget_layer.cpp Widget Layer */ 3/* widget_layer.cpp Widget Layer */
4/* */ 4/* */
5/* opie developers <opie@handhelds.org> */ 5/* opie developers <opie@handhelds.org> */
6/* */ 6/* */
7/* ------------------------------------------------------------------------- */ 7/* ------------------------------------------------------------------------- */
8 8
9 9
10 10
11#include "widget_layer.h" 11#include "widget_layer.h"
12 12
13#include <qclipboard.h> 13#include <qclipboard.h>
14#include <qregexp.h> 14#include <qregexp.h>
15#include <qglobal.h> 15#include <qglobal.h>
16 16
17#include <string.h> 17#include <string.h>
18//#include < 18//#include <
19 19
20#include "common.h" 20#include "common.h"
21 21
22 22
23 23
24WidgetLayer::WidgetLayer( const Profile &config, QWidget *parent, const char *name ) : QFrame( parent, name ) 24WidgetLayer::WidgetLayer( const Profile &config, QWidget *parent, const char *name ) : QFrame( parent, name )
25{ 25{
26 // get the clipboard 26 // get the clipboard
27 m_clipboard = QApplication::clipboard(); 27 m_clipboard = QApplication::clipboard();
28 28
29 // when data on clipboard changes, clear selection 29 // when data on clipboard changes, clear selection
30 QObject::connect( (QObject*) m_clipboard, SIGNAL( dataChanged() ), 30 QObject::connect( (QObject*) m_clipboard, SIGNAL( dataChanged() ),
31 (QObject*)this, SLOT( onClearSelection() ) ); 31 (QObject*)this, SLOT( onClearSelection() ) );
32 32
33 // initialize vars: 33 // initialize vars:
34 m_lines = 1; 34 m_lines = 1;
35 m_columns = 1; 35 m_columns = 1;
36 m_resizing = false; 36 m_resizing = false;
37 37
38 // just for demonstrating 38 // just for demonstrating
39 //m_image = QArray<Character>( m_lines * m_columns ); 39 //m_image = QArray<Character>( m_lines * m_columns );
40 m_image = QArray<Character>( 1 ); 40 m_image = QArray<Character>( 1 );
41 41
42 // we need to install an event filter, 42 // we need to install an event filter,
43 // to emit keypresses. 43 // to emit keypresses.
44 qApp->installEventFilter( this ); 44 qApp->installEventFilter( this );
45 45
46} 46}
47 47
48 48
49WidgetLayer::~WidgetLayer() 49WidgetLayer::~WidgetLayer()
50{ 50{
51 // clean up 51 // clean up
52 delete m_image; 52 delete m_image;
53} 53}
54 54
55 55
56QSize WidgetLayer::sizeHint()
57{
58 return size();
59}
60
61
56/* --------------------------------- audio ---------------------------------- */ 62/* --------------------------------- audio ---------------------------------- */
57 63
58void WidgetLayer::bell() 64void WidgetLayer::bell()
59{ 65{
60 QApplication::beep(); 66 QApplication::beep();
61} 67}
62 68
63bool WidgetLayer::eventFilter( QObject *obj, QEvent *e ) 69bool WidgetLayer::eventFilter( QObject *obj, QEvent *e )
64{ 70{
65 if ( (e->type() == QEvent::Accel || 71 if ( (e->type() == QEvent::Accel ||
66 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { 72 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) {
67 static_cast<QKeyEvent *>( e )->ignore(); 73 static_cast<QKeyEvent *>( e )->ignore();
68 return true; 74 return true;
69 } 75 }
70 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) 76 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ )
71 return false; // not us 77 return false; // not us
72 78
73#ifdef FAKE_CTRL_AND_ALT 79#ifdef FAKE_CTRL_AND_ALT
74 static bool control = false; 80 static bool control = false;
75 static bool alt = false; 81 static bool alt = false;
76// qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); 82// qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:");
77 bool dele = false; 83 bool dele = false;
78 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 84 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
79 QKeyEvent* ke = (QKeyEvent*)e; 85 QKeyEvent* ke = (QKeyEvent*)e;
80 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); 86 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat();
81 switch (ke->key()) { 87 switch (ke->key()) {
82 case Key_F9: // let this be "Control" 88 case Key_F9: // let this be "Control"
83 control = keydown; 89 control = keydown;
84 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); 90 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state());
85 dele=TRUE; 91 dele=TRUE;
86 break; 92 break;
87 case Key_F13: // let this be "Alt" 93 case Key_F13: // let this be "Alt"
88 alt = keydown; 94 alt = keydown;
89 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); 95 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state());
90 dele=TRUE; 96 dele=TRUE;
91 break; 97 break;
92 default: 98 default:
93 if ( control ) { 99 if ( control ) {
94 int a = toupper(ke->ascii())-64; 100 int a = toupper(ke->ascii())-64;
95 if ( a >= 0 && a < ' ' ) { 101 if ( a >= 0 && a < ' ' ) {
96 e = new QKeyEvent(e->type(), ke->key(), 102 e = new QKeyEvent(e->type(), ke->key(),
97 a, ke->state()|ControlButton, 103 a, ke->state()|ControlButton,
98QChar(a,0)); 104QChar(a,0));
99 dele=TRUE; 105 dele=TRUE;
100 } 106 }
101 } 107 }
102 if ( alt ) { 108 if ( alt ) {
103 e = new QKeyEvent(e->type(), ke->key(), 109 e = new QKeyEvent(e->type(), ke->key(),
104 ke->ascii(), ke->state()|AltButton, ke->text()); 110 ke->ascii(), ke->state()|AltButton, ke->text());
105 dele=TRUE; 111 dele=TRUE;
106 } 112 }
107 } 113 }
108 } 114 }
109#endif 115#endif
110 116
111 if ( e->type() == QEvent::KeyPress ) { 117 if ( e->type() == QEvent::KeyPress ) {
112 QKeyEvent* ke = (QKeyEvent*)e; 118 QKeyEvent* ke = (QKeyEvent*)e;
113 //actSel=0; // Key stroke implies a screen update, so Widget won't 119 //actSel=0; // Key stroke implies a screen update, so Widget won't
114 // know where the current selection is. 120 // know where the current selection is.
115 121
116// qDebug("key pressed is 0x%x",ke->key()); 122// qDebug("key pressed is 0x%x",ke->key());
117 123
118 if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker 124 if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker
119 insertText("\\"); // expose 125 insertText("\\"); // expose
120 } else 126 } else
121 emit keyPressed( ke ); // expose 127 emit keyPressed( ke ); // expose
122 ke->accept(); 128 ke->accept();
123#ifdef FAKE_CTRL_AND_ALT 129#ifdef FAKE_CTRL_AND_ALT
124 if ( dele ) delete e; 130 if ( dele ) delete e;
125#endif 131#endif
126 return true; // stop the event 132 return true; // stop the event
127 } 133 }
128 return QFrame::eventFilter( obj, e ); 134 return QFrame::eventFilter( obj, e );
129} 135}
130 136
131 137
132/* --------------------------------- screen --------------------------------- */ 138/* --------------------------------- screen --------------------------------- */
133 139
134 140
135void WidgetLayer::propagateSize() 141void WidgetLayer::propagateSize()
136{ 142{
137 QArray<Character> oldimage = m_image.copy(); 143 QArray<Character> oldimage = m_image.copy();
138 int oldlines = m_lines; 144 int oldlines = m_lines;
139 int oldcolumns = m_columns; 145 int oldcolumns = m_columns;
140 146
141 makeImage(); 147 makeImage();
142 148
143 // copy old image, to reduce flicker 149 // copy old image, to reduce flicker
144 if ( ! oldimage.isEmpty() ) 150 if ( ! oldimage.isEmpty() )
145 { 151 {
146 int lins = QMIN( oldlines, m_lines ); 152 int lins = QMIN( oldlines, m_lines );
147 int cols = QMIN( oldcolumns, m_columns ); 153 int cols = QMIN( oldcolumns, m_columns );
148 for ( int lin = 0; lin < lins; ++lin ) 154 for ( int lin = 0; lin < lins; ++lin )
149 { 155 {
150 memcpy( (void*) &m_image[m_columns*lin], 156 memcpy( (void*) &m_image[m_columns*lin],
151 (void*) &oldimage[oldcolumns*lin], 157 (void*) &oldimage[oldcolumns*lin],
152 cols*sizeof( Character ) ); 158 cols*sizeof( Character ) );
153 } 159 }
154 } 160 }
155 else 161 else
156 clearImage(); 162 clearImage();
157 163
158 delete oldimage; 164 delete oldimage;
159 165
160 m_resizing = true; 166 m_resizing = true;
161 emit imageSizeChanged( m_lines, m_columns ); 167 emit imageSizeChanged( m_lines, m_columns );
162 m_resizing = false; 168 m_resizing = false;
163} 169}
164 170
165void WidgetLayer::makeImage() 171void WidgetLayer::makeImage()
166{ 172{
167 calcGeometry(); 173 calcGeometry();
168 m_image = QArray<Character>( m_columns * m_lines ); 174 m_image = QArray<Character>( m_columns * m_lines );
169 clearImage(); 175 clearImage();
170} 176}
171 177
172void WidgetLayer::clearImage() 178void WidgetLayer::clearImage()
173{ 179{
174 //should this belong here?? 180 //should this belong here??
175 for ( int y = 0; y < m_lines; y++ ) 181 for ( int y = 0; y < m_lines; y++ )
176 for ( int x = 0; x < m_columns; x++ ) 182 for ( int x = 0; x < m_columns; x++ )
177 { 183 {
178 m_image[loc(x,y)].c = 0xff; 184 m_image[loc(x,y)].c = 0xff;
179 m_image[loc(x,y)].f = 0xff; 185 m_image[loc(x,y)].f = 0xff;
180 m_image[loc(x,y)].b = 0xff; 186 m_image[loc(x,y)].b = 0xff;
181 m_image[loc(x,y)].r = 0xff; 187 m_image[loc(x,y)].r = 0xff;
182 } 188 }
183} 189}
184 190
185/* --------------------------------- selection ------------------------------ */ 191/* --------------------------------- selection ------------------------------ */
186 192
187void WidgetLayer::pasteClipboard() 193void WidgetLayer::pasteClipboard()
188{ 194{
189 insertSelection(); 195 insertSelection();
190} 196}
191 197
192 198
193void WidgetLayer::insertSelection() 199void WidgetLayer::insertSelection()
194{ 200{
195 QString text = QApplication::clipboard()->text(); 201 QString text = QApplication::clipboard()->text();
196 if ( ! text.isNull() ) 202 if ( ! text.isNull() )
197 { 203 {
198 text.replace( QRegExp( "\n" ), "\r" ); 204 text.replace( QRegExp( "\n" ), "\r" );
199 insertText( text ); 205 insertText( text );
200 // selection should be unselected 206 // selection should be unselected
201 emit selectionCleared(); 207 emit selectionCleared();
202 } 208 }
203} 209}
204 210
205void WidgetLayer::insertText( QString text ) 211void WidgetLayer::insertText( QString text )
206{ 212{
207 // text is inserted as key event 213 // text is inserted as key event
208 QKeyEvent e( QEvent::KeyPress, 0, -1, 0, text); 214 QKeyEvent e( QEvent::KeyPress, 0, -1, 0, text);
209 emit keyPressed( &e ); 215 emit keyPressed( &e );
210} 216}
211 217
212void WidgetLayer::onClearSelection() 218void WidgetLayer::onClearSelection()
213{ 219{
214 emit selectionCleared(); 220 emit selectionCleared();
215} 221}
216 222
217void WidgetLayer::setSelection( const QString& text ) 223void WidgetLayer::setSelection( const QString& text )
218{ 224{
219 // why get the clipboard, we have it as instance var... 225 // why get the clipboard, we have it as instance var...
220 QObject *m_clipboard = QApplication::clipboard(); 226 QObject *m_clipboard = QApplication::clipboard();
221 227
222 // we know, that cliboard changes, when we change clipboard 228 // we know, that cliboard changes, when we change clipboard
223 QObject::disconnect( (QObject*) m_clipboard, SIGNAL( dataChanged() ), 229 QObject::disconnect( (QObject*) m_clipboard, SIGNAL( dataChanged() ),
224 (QObject*) this, SLOT( selectionCleared() ) ); 230 (QObject*) this, SLOT( selectionCleared() ) );
225 231
226 QApplication::clipboard()->setText( text ); 232 QApplication::clipboard()->setText( text );
227 233
228 QObject::connect( (QObject*) m_clipboard, SIGNAL( dataChanged() ), 234 QObject::connect( (QObject*) m_clipboard, SIGNAL( dataChanged() ),
229 (QObject*) this, SLOT( selectionCleared() ) ); 235 (QObject*) this, SLOT( selectionCleared() ) );
230} 236}
231 237
232 238
233///////// 239/////////
234// special font characters 240// special font characters
235///////// 241/////////
236unsigned short vt100_graphics[32] = 242unsigned short vt100_graphics[32] =
237{ // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15 243{ // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15
238 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, 244 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0,
239 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, 245 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c,
240 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, 246 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534,
241 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 247 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7
242}; 248};
243 249
diff --git a/noncore/apps/opie-console/widget_layer.h b/noncore/apps/opie-console/widget_layer.h
index 0c290f3..6812711 100644
--- a/noncore/apps/opie-console/widget_layer.h
+++ b/noncore/apps/opie-console/widget_layer.h
@@ -1,260 +1,265 @@
1/* -------------------------------------------------------------------------- */ 1/* -------------------------------------------------------------------------- */
2/* */ 2/* */
3/* [widget_layer.h] Widget Layer */ 3/* [widget_layer.h] Widget Layer */
4/* */ 4/* */
5/* -------------------------------------------------------------------------- */ 5/* -------------------------------------------------------------------------- */
6 6
7// proposal of a widget Layer in opie-console 7// proposal of a widget Layer in opie-console
8// 8//
9// fellow devels: 9// fellow devels:
10// just mail me (ibotty@web.de), what you additionally need from the main widget 10// just mail me (ibotty@web.de), what you additionally need from the main widget
11// (or say in chat) 11// (or say in chat)
12 12
13#ifndef WIDGET_LAYER_H 13#ifndef WIDGET_LAYER_H
14#define WIDGET_LAYER_H 14#define WIDGET_LAYER_H
15 15
16// qt includes 16// qt includes
17#include <qapplication.h> 17#include <qapplication.h>
18#include <qframe.h> 18#include <qframe.h>
19#include <qarray.h> 19#include <qarray.h>
20#include <qtimer.h> 20#include <qtimer.h>
21#include <qkeycode.h> 21#include <qkeycode.h>
22#include <qclipboard.h> 22#include <qclipboard.h>
23 23
24 24
25// opie-console includes 25// opie-console includes
26#include "session.h" 26#include "session.h"
27#include "common.h" 27#include "common.h"
28#include "profile.h" 28#include "profile.h"
29 29
30 30
31/* 31/*
32 * given a pseudo location ( column, line ), 32 * given a pseudo location ( column, line ),
33 * returns the actual index, in the QArray<Character> 33 * returns the actual index, in the QArray<Character>
34 */ 34 */
35#define loc(X,Y) ((Y)*m_columns+(X)) 35#define loc(X,Y) ((Y)*m_columns+(X))
36 36
37 37
38 38
39extern unsigned short vt100_graphics[32]; 39extern unsigned short vt100_graphics[32];
40 40
41class WidgetLayer : public QFrame 41class WidgetLayer : public QFrame
42{ Q_OBJECT 42{ Q_OBJECT
43 43
44public: 44public:
45 45
46 /** 46 /**
47 * constructor 47 * constructor
48 * @param const Profile &config, the configuration for this widget 48 * @param const Profile &config, the configuration for this widget
49 * @param QWidget *parent, the parent widget 49 * @param QWidget *parent, the parent widget
50 * @param const char *name, the name of the widget, defaults to "" 50 * @param const char *name, the name of the widget, defaults to ""
51 */ 51 */
52 WidgetLayer( const Profile& config, QWidget *parent=0, const char *name=0 ); 52 WidgetLayer( const Profile& config, QWidget *parent=0, const char *name=0 );
53 53
54 /** 54 /**
55 * destructor 55 * destructor
56 */ 56 */
57 virtual ~WidgetLayer(); 57 virtual ~WidgetLayer();
58 58
59public: 59public:
60 /** 60 /**
61 * sets the image 61 * sets the image
62 * @param QArray<Character> const newimg, the new image 62 * @param QArray<Character> const newimg, the new image
63 * @param int lines, lines count of newimg 63 * @param int lines, lines count of newimg
64 * @param int columns, columns count of newimg 64 * @param int columns, columns count of newimg
65 */ 65 */
66 virtual void setImage( QArray<Character> const newimg, int lines, int colums ) = 0; 66 virtual void setImage( QArray<Character> const newimg, int lines, int colums ) = 0;
67 67
68 /** 68 /**
69 * annoy the user 69 * annoy the user
70 */ 70 */
71 void bell(); 71 void bell();
72 72
73 /** 73 /**
74 * @return int m_lines, the lines count 74 * @return int m_lines, the lines count
75 */ 75 */
76 int lines(){ return m_lines; } 76 int lines(){ return m_lines; }
77 77
78 /** 78 /**
79 * @return int m_columns, the columns count 79 * @return int m_columns, the columns count
80 */ 80 */
81 int columns(){ return m_columns; } 81 int columns(){ return m_columns; }
82 82
83 /** 83 /**
84 * insert current selection (currently this is only the clipboard) 84 * insert current selection (currently this is only the clipboard)
85 */ 85 */
86 void insertSelection(); 86 void insertSelection();
87 87
88 /** 88 /**
89 * insert text 89 * insert text
90 * @param QString text, the text to be inserted 90 * @param QString text, the text to be inserted
91 */ 91 */
92 void insertText( QString text ); 92 void insertText( QString text );
93 93
94 /** 94 /**
95 * set selection (clipboard) to text 95 * set selection (clipboard) to text
96 * @param const QString &text, the text to be selected 96 * @param const QString &text, the text to be selected
97 */ 97 */
98 void setSelection( const QString &text ); 98 void setSelection( const QString &text );
99 99
100 /** 100 /**
101 * paste content of clipboard 101 * paste content of clipboard
102 */ 102 */
103 void pasteClipboard(); 103 void pasteClipboard();
104 104
105 105
106 /** 106 /**
107 * reload configuration 107 * reload configuration
108 * @param const Profile& config, the config to be used (may be the same as in constructor) 108 * @param const Profile& config, the config to be used (may be the same as in constructor)
109 */ 109 */
110 virtual void reloadConfig( const Profile& config ) = 0; 110 virtual void reloadConfig( const Profile& config ) = 0;
111 111
112 112
113 /** 113 /**
114 * sets the scrollbar (if implemented by successor of this class) 114 * sets the scrollbar (if implemented by successor of this class)
115 */ 115 */
116 virtual void setScroll( int cursor, int slines ) = 0; 116 virtual void setScroll( int cursor, int slines ) = 0;
117 117
118 /** 118 /**
119 * scrolls (if implemented, by successor of this class) 119 * scrolls (if implemented, by successor of this class)
120 * @param int value, how much the widget should scroll up (positive value) or down (negative value) 120 * @param int value, how much the widget should scroll up (positive value) or down (negative value)
121 */ 121 */
122 virtual void scroll( int value ) = 0; 122 virtual void scroll( int value ) = 0;
123 123
124 124
125 virtual bool eventFilter( QObject *obj, QEvent *event ); 125 virtual bool eventFilter( QObject *obj, QEvent *event );
126
127
128 QSize sizeHint();
129
130 virtual QSize calcSize( int cols, int lins ) const = 0;
126signals: 131signals:
127 132
128 /** 133 /**
129 * key was pressed 134 * key was pressed
130 */ 135 */
131 void keyPressed( QKeyEvent *e ); 136 void keyPressed( QKeyEvent *e );
132 137
133 /** 138 /**
134 * whenever Mouse selects something 139 * whenever Mouse selects something
135 * @param int button, the button that us pressed : 140 * @param int button, the button that us pressed :
136 * 0left Button 141 * 0left Button
137 * 3Button released 142 * 3Button released
138 * @param int x, x position 143 * @param int x, x position
139 * @param int y, y position 144 * @param int y, y position
140 * 145 *
141 * // numbering due to layout in old TEWidget 146 * // numbering due to layout in old TEWidget
142 */ 147 */
143 void mousePressed( int button, int x, int y ); 148 void mousePressed( int button, int x, int y );
144 149
145 /** 150 /**
146 * size of image changed 151 * size of image changed
147 * @param int lines, line count of new size 152 * @param int lines, line count of new size
148 * @param int columns, column count of new size 153 * @param int columns, column count of new size
149 */ 154 */
150 void imageSizeChanged( int lines, int columns ); 155 void imageSizeChanged( int lines, int columns );
151 156
152 /** 157 /**
153 * cursor in history changed 158 * cursor in history changed
154 * @param int value, value of history cursor 159 * @param int value, value of history cursor
155 */ 160 */
156 void historyCursorChanged( int value ); 161 void historyCursorChanged( int value );
157 162
158 /** 163 /**
159 * selection should be cleared 164 * selection should be cleared
160 */ 165 */
161 void selectionCleared(); 166 void selectionCleared();
162 167
163 /** 168 /**
164 * selection begin 169 * selection begin
165 * @param const int x, x position 170 * @param const int x, x position
166 * @param const int y, y position 171 * @param const int y, y position
167 */ 172 */
168 void selectionBegin( const int x, const int y ); 173 void selectionBegin( const int x, const int y );
169 174
170 /** 175 /**
171 * selection extended 176 * selection extended
172 * (from begin (s.a.) to x, y) 177 * (from begin (s.a.) to x, y)
173 * @param const int x, x position 178 * @param const int x, x position
174 * @param const int y, y position 179 * @param const int y, y position
175 */ 180 */
176 void selectionExtended( const int x, const int y ); 181 void selectionExtended( const int x, const int y );
177 182
178 /** 183 /**
179 * selection end 184 * selection end
180 * @param const bool lineBreakPreserve, preserve line breaks in selection 185 * @param const bool lineBreakPreserve, preserve line breaks in selection
181 */ 186 */
182 void selectionEnd( const bool lineBreakPreserve ); 187 void selectionEnd( const bool lineBreakPreserve );
183 188
184 189
185 190
186// protected methods 191// protected methods
187protected: 192protected:
188 193
189 // image operations 194 // image operations
190 195
191 /** 196 /**
192 * changes image, to suit new size 197 * changes image, to suit new size
193 * TODO: find meaningful name! 198 * TODO: find meaningful name!
194 */ 199 */
195 void propagateSize(); 200 void propagateSize();
196 201
197 /** 202 /**
198 *determines count of lines and columns 203 *determines count of lines and columns
199 */ 204 */
200 virtual void calcGeometry() = 0; 205 virtual void calcGeometry() = 0;
201 206
202 /** 207 /**
203 * makes an empty image 208 * makes an empty image
204 */ 209 */
205 void makeImage(); 210 void makeImage();
206 211
207 /** 212 /**
208 * clears the image 213 * clears the image
209 */ 214 */
210 void clearImage(); 215 void clearImage();
211 216
212protected slots: 217protected slots:
213 218
214 /** 219 /**
215 * clear selection 220 * clear selection
216 */ 221 */
217 void onClearSelection(); 222 void onClearSelection();
218 223
219 224
220// protected vars 225// protected vars
221protected: 226protected:
222 227
223 /** 228 /**
224 * current Session 229 * current Session
225 */ 230 */
226 Session *m_session; 231 Session *m_session;
227 232
228 /** 233 /**
229 * current character image 234 * current character image
230 * 235 *
231 * a Character at loc( column, line ) 236 * a Character at loc( column, line )
232 * has the actual index: 237 * has the actual index:
233 * ix = line * m_columns + column; 238 * ix = line * m_columns + column;
234 * 239 *
235 * use loc( x, y ) macro to access. 240 * use loc( x, y ) macro to access.
236 */ 241 */
237 QArray<Character> m_image; 242 QArray<Character> m_image;
238 243
239 /** 244 /**
240 * lines count 245 * lines count
241 */ 246 */
242 int m_lines; 247 int m_lines;
243 248
244 /** 249 /**
245 * columns count 250 * columns count
246 */ 251 */
247 int m_columns; 252 int m_columns;
248 253
249 /** 254 /**
250 * clipboard 255 * clipboard
251 */ 256 */
252 QClipboard* m_clipboard; 257 QClipboard* m_clipboard;
253 258
254 /** 259 /**
255 * whether widget is resizing 260 * whether widget is resizing
256 */ 261 */
257 bool m_resizing; 262 bool m_resizing;
258}; 263};
259 264
260#endif // WIDGET_LAYER_H 265#endif // WIDGET_LAYER_H