author | llornkcor <llornkcor> | 2002-10-31 14:49:24 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-10-31 14:49:24 (UTC) |
commit | c3a6f53669140cf9e3c953772c610cd91d69ab78 (patch) (unidiff) | |
tree | ab8579e66582aedc01da2aea4272e754902e9287 /core/apps/embeddedkonsole/TEWidget.cpp | |
parent | 7d8a563125b981718ae963ba6308e3506e870045 (diff) | |
download | opie-c3a6f53669140cf9e3c953772c610cd91d69ab78.zip opie-c3a6f53669140cf9e3c953772c610cd91d69ab78.tar.gz opie-c3a6f53669140cf9e3c953772c610cd91d69ab78.tar.bz2 |
no wrap mode taken from console, gui needs work
Diffstat (limited to 'core/apps/embeddedkonsole/TEWidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/apps/embeddedkonsole/TEWidget.cpp | 169 |
1 files changed, 154 insertions, 15 deletions
diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp index b1ad008..c10c7a8 100644 --- a/core/apps/embeddedkonsole/TEWidget.cpp +++ b/core/apps/embeddedkonsole/TEWidget.cpp | |||
@@ -52,6 +52,13 @@ | |||
52 | #include "session.h" | 52 | #include "session.h" |
53 | #include <qpe/config.h> | 53 | #include <qpe/config.h> |
54 | 54 | ||
55 | #include <qpe/resource.h> | ||
56 | #include <qpe/sound.h> | ||
57 | |||
58 | #ifdef QWS | ||
59 | #include <qpe/qcopenvelope_qws.h> | ||
60 | #endif | ||
61 | |||
55 | #include <qcursor.h> | 62 | #include <qcursor.h> |
56 | #include <qregexp.h> | 63 | #include <qregexp.h> |
57 | #include <qpainter.h> | 64 | #include <qpainter.h> |
@@ -287,6 +294,13 @@ TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) | |||
287 | scrollbar->setCursor( arrowCursor ); | 294 | scrollbar->setCursor( arrowCursor ); |
288 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); | 295 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); |
289 | 296 | ||
297 | hScrollbar = new QScrollBar(this); | ||
298 | hScrollbar->setCursor( arrowCursor ); | ||
299 | hScrollbar->setOrientation(QScrollBar::Horizontal); | ||
300 | hScrollbar->setMaximumHeight(16); | ||
301 | |||
302 | connect( hScrollbar, SIGNAL(valueChanged(int)), this, SLOT( hScrollChanged(int))); | ||
303 | |||
290 | Config cfg("Konsole"); | 304 | Config cfg("Konsole"); |
291 | cfg.setGroup("ScrollBar"); | 305 | cfg.setGroup("ScrollBar"); |
292 | switch( cfg.readNumEntry("Position",2)){ | 306 | switch( cfg.readNumEntry("Position",2)){ |
@@ -301,6 +315,8 @@ TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) | |||
301 | break; | 315 | break; |
302 | }; | 316 | }; |
303 | 317 | ||
318 | useHorzScroll=cfg.readBoolEntry("HorzScroll",0); | ||
319 | |||
304 | blinkT = new QTimer(this); | 320 | blinkT = new QTimer(this); |
305 | connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); | 321 | connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); |
306 | // blinking = FALSE; | 322 | // blinking = FALSE; |
@@ -315,6 +331,7 @@ TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) | |||
315 | font_h = 1; | 331 | font_h = 1; |
316 | font_a = 1; | 332 | font_a = 1; |
317 | word_selection_mode = FALSE; | 333 | word_selection_mode = FALSE; |
334 | hposition = 0; | ||
318 | 335 | ||
319 | setMouseMarks(TRUE); | 336 | setMouseMarks(TRUE); |
320 | setVTFont( QFont("fixed") ); | 337 | setVTFont( QFont("fixed") ); |
@@ -410,10 +427,7 @@ HCNT("setImage"); | |||
410 | int lins = QMIN(this->lines, QMAX(0,lines )); | 427 | int lins = QMIN(this->lines, QMAX(0,lines )); |
411 | int cols = QMIN(this->columns,QMAX(0,columns)); | 428 | int cols = QMIN(this->columns,QMAX(0,columns)); |
412 | QChar *disstrU = new QChar[cols]; | 429 | QChar *disstrU = new QChar[cols]; |
413 | 430 | for (y = 0; y < lins; y++) { | |
414 | //{ static int cnt = 0; printf("setImage %d\n",cnt++); } | ||
415 | for (y = 0; y < lins; y++) | ||
416 | { | ||
417 | const ca* lcl = &image[y*this->columns]; | 431 | const ca* lcl = &image[y*this->columns]; |
418 | const ca* const ext = &newimg[y*columns]; | 432 | const ca* const ext = &newimg[y*columns]; |
419 | if (!resizing) // not while resizing, we're expecting a paintEvent | 433 | if (!resizing) // not while resizing, we're expecting a paintEvent |
@@ -588,11 +602,18 @@ void TEWidget::propagateSize() | |||
588 | /* */ | 602 | /* */ |
589 | /* ------------------------------------------------------------------------- */ | 603 | /* ------------------------------------------------------------------------- */ |
590 | 604 | ||
591 | void TEWidget::scrollChanged(int) | 605 | void TEWidget::scrollChanged(int) { |
592 | { | ||
593 | emit changedHistoryCursor(scrollbar->value()); //expose | 606 | emit changedHistoryCursor(scrollbar->value()); //expose |
594 | } | 607 | } |
595 | 608 | ||
609 | void TEWidget::hScrollChanged(int loc) { | ||
610 | hposition = loc; | ||
611 | propagateSize(); | ||
612 | update(); | ||
613 | |||
614 | // emit changedHorzCursor( hScrollbar->value()); //expose | ||
615 | } | ||
616 | |||
596 | void TEWidget::setScroll(int cursor, int slines) | 617 | void TEWidget::setScroll(int cursor, int slines) |
597 | { | 618 | { |
598 | disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); | 619 | disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); |
@@ -697,6 +718,7 @@ void TEWidget::mouseMoveEvent(QMouseEvent* ev) | |||
697 | int tLx = tL.x(); | 718 | int tLx = tL.x(); |
698 | int tLy = tL.y(); | 719 | int tLy = tL.y(); |
699 | int scroll = scrollbar->value(); | 720 | int scroll = scrollbar->value(); |
721 | // int hScroll = hScrollbar->value(); | ||
700 | 722 | ||
701 | // we're in the process of moving the mouse with the left button pressed | 723 | // we're in the process of moving the mouse with the left button pressed |
702 | // the mouse cursor will kept catched within the bounds of the text in | 724 | // the mouse cursor will kept catched within the bounds of the text in |
@@ -973,6 +995,10 @@ void TEWidget::doScroll(int lines) | |||
973 | scrollbar->setValue(scrollbar->value()+lines); | 995 | scrollbar->setValue(scrollbar->value()+lines); |
974 | } | 996 | } |
975 | 997 | ||
998 | void TEWidget::doHScroll(int lines) { | ||
999 | hScrollbar->setValue( hScrollbar->value()+lines); | ||
1000 | } | ||
1001 | |||
976 | bool TEWidget::eventFilter( QObject *obj, QEvent *e ) | 1002 | bool TEWidget::eventFilter( QObject *obj, QEvent *e ) |
977 | { | 1003 | { |
978 | if ( (e->type() == QEvent::Accel || | 1004 | if ( (e->type() == QEvent::Accel || |
@@ -1078,7 +1104,17 @@ void TEWidget::frameChanged() | |||
1078 | 1104 | ||
1079 | void TEWidget::Bell() | 1105 | void TEWidget::Bell() |
1080 | { | 1106 | { |
1081 | QApplication::beep(); | 1107 | //#ifdef QT_QWS_CUSTOM |
1108 | //# ifndef QT_NO_COP | ||
1109 | QCopEnvelope( "QPE/TaskBar", "soundAlarm()" ); | ||
1110 | //# endif | ||
1111 | //#else | ||
1112 | //# ifndef QT_NO_SOUND | ||
1113 | // QSound::play(Resource::findSound("alarm")); | ||
1114 | //# endif | ||
1115 | //#endif | ||
1116 | |||
1117 | // QApplication::beep(); | ||
1082 | } | 1118 | } |
1083 | 1119 | ||
1084 | /* ------------------------------------------------------------------------- */ | 1120 | /* ------------------------------------------------------------------------- */ |
@@ -1105,10 +1141,80 @@ void TEWidget::clearImage() | |||
1105 | 1141 | ||
1106 | void TEWidget::calcGeometry() | 1142 | void TEWidget::calcGeometry() |
1107 | { | 1143 | { |
1108 | //FIXME: set rimX == rimY == 0 when running in full screen mode. | 1144 | int showhscrollbar = 1; |
1145 | int hwidth = 0; | ||
1146 | int dcolumns; | ||
1147 | Config cfg("Konsole"); | ||
1148 | cfg.setGroup("ScrollBar"); | ||
1149 | useHorzScroll=cfg.readBoolEntry("HorzScroll",0); | ||
1150 | |||
1151 | if(vcolumns == 0) showhscrollbar = 0; | ||
1152 | if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width(); | ||
1153 | |||
1154 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), | ||
1155 | contentsRect().height() - hwidth); | ||
1156 | |||
1157 | switch(scrollLoc) { | ||
1158 | case SCRNONE : | ||
1159 | columns = ( contentsRect().width() - 2 * rimX ) / font_w; | ||
1160 | dcolumns = columns; | ||
1161 | if(vcolumns) columns = vcolumns; | ||
1162 | blX = (contentsRect().width() - (columns*font_w) ) / 2; | ||
1163 | if(showhscrollbar) | ||
1164 | blX = -hposition * font_w; | ||
1165 | brX = blX; | ||
1166 | scrollbar->hide(); | ||
1167 | break; | ||
1168 | case SCRLEFT : | ||
1169 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | ||
1170 | dcolumns = columns; | ||
1171 | if(vcolumns) columns = vcolumns; | ||
1172 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | ||
1173 | if(showhscrollbar) | ||
1174 | brX = -hposition * font_w; | ||
1175 | blX = brX + scrollbar->width(); | ||
1176 | scrollbar->move(contentsRect().topLeft()); | ||
1177 | scrollbar->show(); | ||
1178 | break; | ||
1179 | case SCRRIGHT: | ||
1180 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | ||
1181 | dcolumns = columns; | ||
1182 | if(vcolumns) columns = vcolumns; | ||
1183 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | ||
1184 | if(showhscrollbar) | ||
1185 | blX = -hposition * font_w; | ||
1186 | brX = blX; | ||
1187 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); | ||
1188 | scrollbar->show(); | ||
1189 | break; | ||
1190 | } | ||
1191 | //FIXME: support 'rounding' styles | ||
1192 | lines = ( contentsRect().height() - 2 * rimY ) / font_h; | ||
1193 | bY = (contentsRect().height() - (lines *font_h)) / 2; | ||
1109 | 1194 | ||
1110 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), | 1195 | if(showhscrollbar == 1) { |
1196 | hScrollbar->resize(contentsRect().width() - hwidth, hwidth); | ||
1197 | hScrollbar->setRange(0, vcolumns - dcolumns); | ||
1198 | |||
1199 | QPoint p = contentsRect().bottomLeft(); | ||
1200 | hScrollbar->move(QPoint(p.x(), p.y() - hwidth)); | ||
1201 | hScrollbar->show(); | ||
1202 | } | ||
1203 | else hScrollbar->hide(); | ||
1204 | |||
1205 | if(showhscrollbar == 1) { | ||
1206 | lines = lines - (hwidth / font_h) - 1; | ||
1207 | if(lines < 1) lines = 1; | ||
1208 | } | ||
1209 | |||
1210 | /*//FIXME: set rimX == rimY == 0 when running in full screen mode. | ||
1211 | Config cfg("Konsole"); | ||
1212 | cfg.setGroup("ScrollBar"); | ||
1213 | useHorzScroll=cfg.readBoolEntry("HorzScroll",0); | ||
1214 | |||
1215 | scrollbar->resize( QApplication::style().scrollBarExtent().width(), | ||
1111 | contentsRect().height()); | 1216 | contentsRect().height()); |
1217 | qDebug("font_w %d", font_w); | ||
1112 | switch(scrollLoc) | 1218 | switch(scrollLoc) |
1113 | { | 1219 | { |
1114 | case SCRNONE : | 1220 | case SCRNONE : |
@@ -1119,22 +1225,47 @@ void TEWidget::calcGeometry() | |||
1119 | break; | 1225 | break; |
1120 | case SCRLEFT : | 1226 | case SCRLEFT : |
1121 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | 1227 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; |
1228 | if(useHorzScroll) columns = columns * (font_w/2); | ||
1122 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | 1229 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; |
1123 | blX = brX + scrollbar->width(); | 1230 | blX = brX + scrollbar->width(); |
1124 | scrollbar->move(contentsRect().topLeft()); | 1231 | scrollbar->move(contentsRect().topLeft()); |
1125 | scrollbar->show(); | 1232 | scrollbar->show(); |
1126 | break; | 1233 | break; |
1127 | case SCRRIGHT: | 1234 | case SCRRIGHT: |
1128 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | 1235 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width() ) / font_w; |
1129 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | 1236 | if(useHorzScroll) columns = columns * (font_w/2); |
1130 | brX = blX; | 1237 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; |
1131 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); | 1238 | if(useHorzScroll) { |
1239 | brX = blX =2; | ||
1240 | } else { | ||
1241 | brX=blX; | ||
1242 | } | ||
1243 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0) ); | ||
1132 | scrollbar->show(); | 1244 | scrollbar->show(); |
1133 | break; | 1245 | break; |
1134 | } | 1246 | } |
1247 | |||
1248 | if( !scrollbar->isHidden()) | ||
1249 | hScrollbar->resize( contentsRect().width()-SCRWIDTH, QApplication::style() | ||
1250 | .scrollBarExtent().height()); | ||
1251 | else | ||
1252 | hScrollbar->resize( contentsRect().width(), QApplication::style() | ||
1253 | .scrollBarExtent().height()); | ||
1254 | |||
1255 | hScrollbar->move( 0, contentsRect().height() - SCRWIDTH); | ||
1256 | |||
1257 | |||
1258 | if(useHorzScroll) { | ||
1259 | hScrollbar->show(); | ||
1260 | lines = ( (contentsRect().height() - SCRWIDTH) - 2 * rimY ) / font_h; | ||
1261 | bY = ((contentsRect().height() - SCRWIDTH) - (lines *font_h)) / 2; | ||
1262 | } else { | ||
1263 | hScrollbar->hide(); | ||
1264 | lines = (contentsRect().height() - 2 * rimY ) / font_h; | ||
1265 | bY = (contentsRect().height() - (lines *font_h)) / 2; | ||
1266 | } | ||
1267 | */ | ||
1135 | //FIXME: support 'rounding' styles | 1268 | //FIXME: support 'rounding' styles |
1136 | lines = ( contentsRect().height() - 2 * rimY ) / font_h; | ||
1137 | bY = (contentsRect().height() - (lines *font_h)) / 2; | ||
1138 | } | 1269 | } |
1139 | 1270 | ||
1140 | void TEWidget::makeImage() | 1271 | void TEWidget::makeImage() |
@@ -1266,3 +1397,11 @@ void TEWidget::drop_menu_activated(int item) | |||
1266 | #endif | 1397 | #endif |
1267 | } | 1398 | } |
1268 | 1399 | ||
1400 | void TEWidget::setWrapAt(int columns) | ||
1401 | { | ||
1402 | vcolumns = columns; | ||
1403 | propagateSize(); | ||
1404 | update(); | ||
1405 | } | ||
1406 | |||
1407 | |||