-rw-r--r-- | noncore/apps/opie-console/TEWidget.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/TEWidget.cpp b/noncore/apps/opie-console/TEWidget.cpp index bf9a313..2db214c 100644 --- a/noncore/apps/opie-console/TEWidget.cpp +++ b/noncore/apps/opie-console/TEWidget.cpp | |||
@@ -1114,135 +1114,139 @@ void TEWidget::frameChanged() | |||
1114 | 1114 | ||
1115 | /* ------------------------------------------------------------------------- */ | 1115 | /* ------------------------------------------------------------------------- */ |
1116 | /* */ | 1116 | /* */ |
1117 | /* Sound */ | 1117 | /* Sound */ |
1118 | /* */ | 1118 | /* */ |
1119 | /* ------------------------------------------------------------------------- */ | 1119 | /* ------------------------------------------------------------------------- */ |
1120 | 1120 | ||
1121 | void TEWidget::Bell() | 1121 | void TEWidget::Bell() |
1122 | { | 1122 | { |
1123 | QApplication::beep(); | 1123 | QApplication::beep(); |
1124 | } | 1124 | } |
1125 | 1125 | ||
1126 | /* ------------------------------------------------------------------------- */ | 1126 | /* ------------------------------------------------------------------------- */ |
1127 | /* */ | 1127 | /* */ |
1128 | /* Auxiluary */ | 1128 | /* Auxiluary */ |
1129 | /* */ | 1129 | /* */ |
1130 | /* ------------------------------------------------------------------------- */ | 1130 | /* ------------------------------------------------------------------------- */ |
1131 | 1131 | ||
1132 | void TEWidget::clearImage() | 1132 | void TEWidget::clearImage() |
1133 | // initialize the image | 1133 | // initialize the image |
1134 | // for internal use only | 1134 | // for internal use only |
1135 | { | 1135 | { |
1136 | for (int y = 0; y < lines; y++) | 1136 | for (int y = 0; y < lines; y++) |
1137 | for (int x = 0; x < columns; x++) | 1137 | for (int x = 0; x < columns; x++) |
1138 | { | 1138 | { |
1139 | image[loc(x,y)].c = 0xff; //' '; | 1139 | image[loc(x,y)].c = 0xff; //' '; |
1140 | image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; | 1140 | image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; |
1141 | image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; | 1141 | image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; |
1142 | image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; | 1142 | image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; |
1143 | } | 1143 | } |
1144 | } | 1144 | } |
1145 | 1145 | ||
1146 | // Create Image /////////////////////////////////////////////////////// | 1146 | // Create Image /////////////////////////////////////////////////////// |
1147 | 1147 | ||
1148 | void TEWidget::calcGeometry() | 1148 | void TEWidget::calcGeometry() |
1149 | { | 1149 | { |
1150 | //FIXME: set rimX == rimY == 0 when running in full screen mode. | 1150 | //FIXME: set rimX == rimY == 0 when running in full screen mode. |
1151 | 1151 | ||
1152 | int showhscrollbar = 1; | 1152 | int showhscrollbar = 1; |
1153 | int hwidth = 0; | 1153 | int hwidth = 0; |
1154 | 1154 | ||
1155 | if(vcolumns == 0) showhscrollbar = 0; | 1155 | if(vcolumns == 0) showhscrollbar = 0; |
1156 | if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width(); | 1156 | if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width(); |
1157 | 1157 | ||
1158 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), | 1158 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), |
1159 | contentsRect().height() - hwidth); | 1159 | contentsRect().height() - hwidth); |
1160 | 1160 | ||
1161 | if(showhscrollbar == 1) | 1161 | if(showhscrollbar == 1) |
1162 | { | 1162 | { |
1163 | hscrollbar->resize(contentsRect().width() - hwidth, hwidth); | 1163 | hscrollbar->resize(contentsRect().width() - hwidth, hwidth); |
1164 | hscrollbar->setRange(0, 40); | 1164 | hscrollbar->setRange(0, 40); |
1165 | 1165 | ||
1166 | QPoint p = contentsRect().bottomLeft(); | 1166 | QPoint p = contentsRect().bottomLeft(); |
1167 | hscrollbar->move(QPoint(p.x(), p.y() - hwidth)); | 1167 | hscrollbar->move(QPoint(p.x(), p.y() - hwidth)); |
1168 | hscrollbar->show(); | 1168 | hscrollbar->show(); |
1169 | } | 1169 | } |
1170 | else hscrollbar->hide(); | 1170 | else hscrollbar->hide(); |
1171 | 1171 | ||
1172 | switch(scrollLoc) | 1172 | switch(scrollLoc) |
1173 | { | 1173 | { |
1174 | case SCRNONE : | 1174 | case SCRNONE : |
1175 | columns = ( contentsRect().width() - 2 * rimX ) / font_w; | 1175 | columns = ( contentsRect().width() - 2 * rimX ) / font_w; |
1176 | if(vcolumns) columns = vcolumns; | 1176 | if(vcolumns) columns = vcolumns; |
1177 | blX = (contentsRect().width() - (columns*font_w) ) / 2; | 1177 | blX = (contentsRect().width() - (columns*font_w) ) / 2; |
1178 | if(showhscrollbar) | ||
1179 | blX = -hposition * font_w; | ||
1178 | brX = blX; | 1180 | brX = blX; |
1179 | scrollbar->hide(); | 1181 | scrollbar->hide(); |
1180 | break; | 1182 | break; |
1181 | case SCRLEFT : | 1183 | case SCRLEFT : |
1182 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | 1184 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; |
1183 | if(vcolumns) columns = vcolumns; | 1185 | if(vcolumns) columns = vcolumns; |
1184 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | 1186 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; |
1187 | if(showhscrollbar) | ||
1188 | brX = -hposition * font_w; | ||
1185 | blX = brX + scrollbar->width(); | 1189 | blX = brX + scrollbar->width(); |
1186 | scrollbar->move(contentsRect().topLeft()); | 1190 | scrollbar->move(contentsRect().topLeft()); |
1187 | scrollbar->show(); | 1191 | scrollbar->show(); |
1188 | break; | 1192 | break; |
1189 | case SCRRIGHT: | 1193 | case SCRRIGHT: |
1190 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | 1194 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; |
1191 | if(vcolumns) columns = vcolumns; | 1195 | if(vcolumns) columns = vcolumns; |
1192 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | 1196 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; |
1193 | if(showhscrollbar) | 1197 | if(showhscrollbar) |
1194 | blX = -hposition * font_w; | 1198 | blX = -hposition * font_w; |
1195 | brX = blX; | 1199 | brX = blX; |
1196 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); | 1200 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); |
1197 | scrollbar->show(); | 1201 | scrollbar->show(); |
1198 | break; | 1202 | break; |
1199 | } | 1203 | } |
1200 | //FIXME: support 'rounding' styles | 1204 | //FIXME: support 'rounding' styles |
1201 | lines = ( contentsRect().height() - 2 * rimY ) / font_h; | 1205 | lines = ( contentsRect().height() - 2 * rimY ) / font_h; |
1202 | bY = (contentsRect().height() - (lines *font_h)) / 2; | 1206 | bY = (contentsRect().height() - (lines *font_h)) / 2; |
1203 | 1207 | ||
1204 | if(showhscrollbar == 1) | 1208 | if(showhscrollbar == 1) |
1205 | { | 1209 | { |
1206 | //bY = bY - 10; | 1210 | //bY = bY - 10; |
1207 | lines = lines - 1; | 1211 | lines = lines - 1; |
1208 | } | 1212 | } |
1209 | } | 1213 | } |
1210 | 1214 | ||
1211 | void TEWidget::makeImage() | 1215 | void TEWidget::makeImage() |
1212 | //FIXME: rename 'calcGeometry? | 1216 | //FIXME: rename 'calcGeometry? |
1213 | { | 1217 | { |
1214 | calcGeometry(); | 1218 | calcGeometry(); |
1215 | image = (ca*) malloc(lines*columns*sizeof(ca)); | 1219 | image = (ca*) malloc(lines*columns*sizeof(ca)); |
1216 | clearImage(); | 1220 | clearImage(); |
1217 | } | 1221 | } |
1218 | 1222 | ||
1219 | // calculate the needed size | 1223 | // calculate the needed size |
1220 | QSize TEWidget::calcSize(int cols, int lins) const | 1224 | QSize TEWidget::calcSize(int cols, int lins) const |
1221 | { | 1225 | { |
1222 | int frw = width() - contentsRect().width(); | 1226 | int frw = width() - contentsRect().width(); |
1223 | int frh = height() - contentsRect().height(); | 1227 | int frh = height() - contentsRect().height(); |
1224 | int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); | 1228 | int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); |
1225 | return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); | 1229 | return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); |
1226 | } | 1230 | } |
1227 | 1231 | ||
1228 | QSize TEWidget::sizeHint() const | 1232 | QSize TEWidget::sizeHint() const |
1229 | { | 1233 | { |
1230 | return size(); | 1234 | return size(); |
1231 | } | 1235 | } |
1232 | 1236 | ||
1233 | void TEWidget::styleChange(QStyle &) | 1237 | void TEWidget::styleChange(QStyle &) |
1234 | { | 1238 | { |
1235 | propagateSize(); | 1239 | propagateSize(); |
1236 | } | 1240 | } |
1237 | 1241 | ||
1238 | #ifndef QT_NO_DRAGANDDROP | 1242 | #ifndef QT_NO_DRAGANDDROP |
1239 | 1243 | ||
1240 | /* --------------------------------------------------------------------- */ | 1244 | /* --------------------------------------------------------------------- */ |
1241 | /* */ | 1245 | /* */ |
1242 | /* Drag & Drop */ | 1246 | /* Drag & Drop */ |
1243 | /* */ | 1247 | /* */ |
1244 | /* --------------------------------------------------------------------- */ | 1248 | /* --------------------------------------------------------------------- */ |
1245 | 1249 | ||
1246 | 1250 | ||
1247 | void TEWidget::dragEnterEvent(QDragEnterEvent* e) | 1251 | void TEWidget::dragEnterEvent(QDragEnterEvent* e) |
1248 | { | 1252 | { |
@@ -1283,67 +1287,69 @@ void TEWidget::dropEvent(QDropEvent* event) | |||
1283 | } | 1287 | } |
1284 | 1288 | ||
1285 | if (bPopup) | 1289 | if (bPopup) |
1286 | // m_drop->popup(pos() + event->pos()); | 1290 | // m_drop->popup(pos() + event->pos()); |
1287 | m_drop->popup(mapToGlobal(event->pos())); | 1291 | m_drop->popup(mapToGlobal(event->pos())); |
1288 | else | 1292 | else |
1289 | { | 1293 | { |
1290 | if (currentSession) { | 1294 | if (currentSession) { |
1291 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1295 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1292 | } | 1296 | } |
1293 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; | 1297 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; |
1294 | } | 1298 | } |
1295 | } | 1299 | } |
1296 | } | 1300 | } |
1297 | else if(QTextDrag::decode(event, dropText)) { | 1301 | else if(QTextDrag::decode(event, dropText)) { |
1298 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; | 1302 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; |
1299 | if (currentSession) { | 1303 | if (currentSession) { |
1300 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1304 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1301 | } | 1305 | } |
1302 | // Paste it | 1306 | // Paste it |
1303 | } | 1307 | } |
1304 | } | 1308 | } |
1305 | #endif | 1309 | #endif |
1306 | 1310 | ||
1307 | 1311 | ||
1308 | void TEWidget::drop_menu_activated(int) | 1312 | void TEWidget::drop_menu_activated(int) |
1309 | { | 1313 | { |
1310 | #ifndef QT_NO_DRAGANDDROP | 1314 | #ifndef QT_NO_DRAGANDDROP |
1311 | switch (item) | 1315 | switch (item) |
1312 | { | 1316 | { |
1313 | case 0: // paste | 1317 | case 0: // paste |
1314 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1318 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1315 | // KWM::activate((Window)this->winId()); | 1319 | // KWM::activate((Window)this->winId()); |
1316 | break; | 1320 | break; |
1317 | case 1: // cd ... | 1321 | case 1: // cd ... |
1318 | currentSession->getEmulation()->sendString("cd "); | 1322 | currentSession->getEmulation()->sendString("cd "); |
1319 | struct stat statbuf; | 1323 | struct stat statbuf; |
1320 | if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) | 1324 | if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) |
1321 | { | 1325 | { |
1322 | if ( !S_ISDIR(statbuf.st_mode) ) | 1326 | if ( !S_ISDIR(statbuf.st_mode) ) |
1323 | { | 1327 | { |
1324 | /* | 1328 | /* |
1325 | KURL url; | 1329 | KURL url; |
1326 | url.setPath( dropText ); | 1330 | url.setPath( dropText ); |
1327 | dropText = url.directory( true, false ); // remove filename | 1331 | dropText = url.directory( true, false ); // remove filename |
1328 | */ | 1332 | */ |
1329 | } | 1333 | } |
1330 | } | 1334 | } |
1331 | dropText.replace(QRegExp(" "), "\\ "); // escape spaces | 1335 | dropText.replace(QRegExp(" "), "\\ "); // escape spaces |
1332 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1336 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1333 | currentSession->getEmulation()->sendString("\n"); | 1337 | currentSession->getEmulation()->sendString("\n"); |
1334 | // KWM::activate((Window)this->winId()); | 1338 | // KWM::activate((Window)this->winId()); |
1335 | break; | 1339 | break; |
1336 | } | 1340 | } |
1337 | #endif | 1341 | #endif |
1338 | } | 1342 | } |
1339 | 1343 | ||
1340 | QPushButton* TEWidget::cornerButton() { | 1344 | QPushButton* TEWidget::cornerButton() { |
1341 | return m_cornerButton; | 1345 | return m_cornerButton; |
1342 | } | 1346 | } |
1343 | 1347 | ||
1344 | void TEWidget::setWrapAt(int columns) | 1348 | void TEWidget::setWrapAt(int columns) |
1345 | { | 1349 | { |
1346 | vcolumns = columns; | 1350 | vcolumns = columns; |
1351 | propagateSize(); | ||
1352 | update(); | ||
1347 | } | 1353 | } |
1348 | 1354 | ||
1349 | 1355 | ||