summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/TEWidget.cpp
Side-by-side diff
Diffstat (limited to 'noncore/apps/opie-console/TEWidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/TEWidget.cpp52
1 files changed, 49 insertions, 3 deletions
diff --git a/noncore/apps/opie-console/TEWidget.cpp b/noncore/apps/opie-console/TEWidget.cpp
index e4415dc..bf9a313 100644
--- a/noncore/apps/opie-console/TEWidget.cpp
+++ b/noncore/apps/opie-console/TEWidget.cpp
@@ -81,26 +81,24 @@
//#include <kdebug.h>
//#include <klocale.h>
#define HERE printf("%s(%d): %s\n",__FILE__,__LINE__,__FUNCTION__)
#define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); }
#define loc(X,Y) ((Y)*columns+(X))
//FIXME: the rim should normally be 1, 0 only when running in full screen mode.
#define rimX 0 // left/right rim width
#define rimY 0 // top/bottom rim high
-#define SCRWIDTH 16 // width of the scrollbar
-
#define yMouseScroll 1
// scroll increment used when dragging selection at top/bottom of window.
/* Button XPM */
namespace {
static char * menu_xpm[] = {
"12 12 5 1",
" c None",
". c #000000",
"+ c #FFFDAD",
"@ c #FFFF00",
"# c #E5E100",
@@ -310,24 +308,28 @@ TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name)
{
#ifndef QT_NO_CLIPBOARD
cb = QApplication::clipboard();
QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
this, SLOT(onClearSelection()) );
#endif
scrollbar = new QScrollBar( this );
scrollbar->setCursor( arrowCursor );
connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
+ hscrollbar = new QScrollBar( Qt::Horizontal, this );
+ hscrollbar->setCursor( arrowCursor );
+ connect(hscrollbar, SIGNAL(valueChanged(int)), this, SLOT(hscrollChanged(int)));
+
m_cornerButton = new QPushButton( this );
m_cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) );
m_cornerButton->setMaximumSize( 14, 14 );
m_cornerButton->hide();
Config cfg("Konsole");
cfg.setGroup("ScrollBar");
switch( cfg.readNumEntry("Position",2)){
case 0:
scrollLoc = SCRNONE;
break;
case 1:
@@ -343,24 +345,25 @@ TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name)
// blinking = FALSE;
blinking = TRUE;
resizing = FALSE;
actSel = 0;
image = 0;
lines = 1;
columns = 1;
font_w = 1;
font_h = 1;
font_a = 1;
word_selection_mode = FALSE;
+ vcolumns = 0;
setMouseMarks(TRUE);
setVTFont( QFont("fixed") );
setColorTable(base_color_table); // init color table
qApp->installEventFilter( this ); //FIXME: see below
// KCursor::setAutoHideCursor( this, true );
// Init DnD ////////////////////////////////////////////////////////////////
currentSession = NULL;
// setAcceptDrops(true); // attempt
// m_drop = new QPopupMenu(this);
@@ -621,24 +624,31 @@ void TEWidget::propagateSize()
/* ------------------------------------------------------------------------- */
/* */
/* Scrollbar */
/* */
/* ------------------------------------------------------------------------- */
void TEWidget::scrollChanged(int)
{
emit changedHistoryCursor(scrollbar->value()); //expose
}
+void TEWidget::hscrollChanged(int loc)
+{
+ hposition = loc;
+ propagateSize();
+ update();
+}
+
void TEWidget::setScroll(int cursor, int slines)
{
disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
scrollbar->setRange(0,slines);
scrollbar->setSteps(1,lines);
scrollbar->setValue(cursor);
connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
}
void TEWidget::setScrollbarLocation(int loc)
{
if (scrollLoc == loc) return; // quickly
@@ -1130,52 +1140,81 @@ void TEWidget::clearImage()
image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR;
image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR;
image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION;
}
}
// Create Image ///////////////////////////////////////////////////////
void TEWidget::calcGeometry()
{
//FIXME: set rimX == rimY == 0 when running in full screen mode.
+ int showhscrollbar = 1;
+ int hwidth = 0;
+
+ if(vcolumns == 0) showhscrollbar = 0;
+ if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width();
+
scrollbar->resize(QApplication::style().scrollBarExtent().width(),
- contentsRect().height());
+ contentsRect().height() - hwidth);
+
+ if(showhscrollbar == 1)
+ {
+ hscrollbar->resize(contentsRect().width() - hwidth, hwidth);
+ hscrollbar->setRange(0, 40);
+
+ QPoint p = contentsRect().bottomLeft();
+ hscrollbar->move(QPoint(p.x(), p.y() - hwidth));
+ hscrollbar->show();
+ }
+ else hscrollbar->hide();
+
switch(scrollLoc)
{
case SCRNONE :
columns = ( contentsRect().width() - 2 * rimX ) / font_w;
+ if(vcolumns) columns = vcolumns;
blX = (contentsRect().width() - (columns*font_w) ) / 2;
brX = blX;
scrollbar->hide();
break;
case SCRLEFT :
columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
+ if(vcolumns) columns = vcolumns;
brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
blX = brX + scrollbar->width();
scrollbar->move(contentsRect().topLeft());
scrollbar->show();
break;
case SCRRIGHT:
columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
+ if(vcolumns) columns = vcolumns;
blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
+ if(showhscrollbar)
+ blX = -hposition * font_w;
brX = blX;
scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0));
scrollbar->show();
break;
}
//FIXME: support 'rounding' styles
lines = ( contentsRect().height() - 2 * rimY ) / font_h;
bY = (contentsRect().height() - (lines *font_h)) / 2;
+
+ if(showhscrollbar == 1)
+ {
+ //bY = bY - 10;
+ lines = lines - 1;
+ }
}
void TEWidget::makeImage()
//FIXME: rename 'calcGeometry?
{
calcGeometry();
image = (ca*) malloc(lines*columns*sizeof(ca));
clearImage();
}
// calculate the needed size
QSize TEWidget::calcSize(int cols, int lins) const
@@ -1292,12 +1331,19 @@ void TEWidget::drop_menu_activated(int)
dropText.replace(QRegExp(" "), "\\ "); // escape spaces
currentSession->getEmulation()->sendString(dropText.local8Bit());
currentSession->getEmulation()->sendString("\n");
// KWM::activate((Window)this->winId());
break;
}
#endif
}
QPushButton* TEWidget::cornerButton() {
return m_cornerButton;
}
+
+void TEWidget::setWrapAt(int columns)
+{
+ vcolumns = columns;
+}
+
+