2017-01-02 08:07:46 +01:00
|
|
|
// File: fscrollview.cpp
|
|
|
|
// Provides: class FScrollView
|
|
|
|
|
|
|
|
#include "fscrollview.h"
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FScrollView
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// constructors and destructor
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FScrollView::FScrollView (FWidget* parent)
|
|
|
|
: FWidget(parent)
|
2017-01-26 00:31:07 +01:00
|
|
|
, scroll_geometry(1,1,1,1)
|
|
|
|
, viewport_geometry()
|
2017-01-02 08:07:46 +01:00
|
|
|
, viewport(0)
|
|
|
|
, vbar(0)
|
|
|
|
, hbar(0)
|
|
|
|
, nf_offset(0)
|
2017-01-03 05:19:44 +01:00
|
|
|
, use_own_print_area(false)
|
|
|
|
, vMode(fc::Auto)
|
|
|
|
, hMode(fc::Auto)
|
2017-01-02 08:07:46 +01:00
|
|
|
{
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FScrollView::~FScrollView() // destructor
|
|
|
|
{
|
|
|
|
delete vbar;
|
|
|
|
delete hbar;
|
|
|
|
removeArea (viewport);
|
2017-01-07 22:09:09 +01:00
|
|
|
child_print_area = viewport = 0;
|
2017-01-02 08:07:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// public methods of FScrollView
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FScrollView::setScrollWidth (int width)
|
|
|
|
{
|
2017-01-22 23:04:40 +01:00
|
|
|
if ( width < getViewportWidth() )
|
|
|
|
width = getViewportWidth();
|
2017-01-02 08:07:46 +01:00
|
|
|
|
2017-01-03 05:19:44 +01:00
|
|
|
if ( getScrollWidth() == width )
|
2017-01-02 08:07:46 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
if ( viewport )
|
|
|
|
{
|
|
|
|
FPoint no_shadow(0,0);
|
2017-01-26 00:31:07 +01:00
|
|
|
scroll_geometry.setWidth (width);
|
|
|
|
resizeArea (scroll_geometry, no_shadow, viewport);
|
2017-01-15 19:48:27 +01:00
|
|
|
setPreprocessingHandler
|
|
|
|
(
|
|
|
|
_PREPROC_HANDLER (this, &FScrollView::copy2area)
|
|
|
|
);
|
2017-01-07 22:09:09 +01:00
|
|
|
child_print_area = viewport;
|
2017-01-02 08:07:46 +01:00
|
|
|
}
|
|
|
|
|
2017-01-22 23:04:40 +01:00
|
|
|
hbar->setMaximum (width - getViewportWidth());
|
|
|
|
hbar->setPageSize (width, getViewportWidth());
|
2017-01-02 08:07:46 +01:00
|
|
|
hbar->calculateSliderValues();
|
2017-01-03 05:19:44 +01:00
|
|
|
setHorizontalScrollBarVisibility();
|
2017-01-02 08:07:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FScrollView::setScrollHeight (int height)
|
|
|
|
{
|
2017-01-22 23:04:40 +01:00
|
|
|
if ( height < getViewportHeight() )
|
|
|
|
height = getViewportHeight();
|
2017-01-02 08:07:46 +01:00
|
|
|
|
2017-01-03 05:19:44 +01:00
|
|
|
if ( getScrollHeight() == height )
|
2017-01-02 08:07:46 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
if ( viewport )
|
|
|
|
{
|
|
|
|
FPoint no_shadow(0,0);
|
2017-01-26 00:31:07 +01:00
|
|
|
scroll_geometry.setHeight (height);
|
|
|
|
resizeArea (scroll_geometry, no_shadow, viewport);
|
2017-01-15 19:48:27 +01:00
|
|
|
setPreprocessingHandler
|
|
|
|
(
|
|
|
|
_PREPROC_HANDLER (this, &FScrollView::copy2area)
|
|
|
|
);
|
2017-01-07 22:09:09 +01:00
|
|
|
child_print_area = viewport;
|
2017-01-02 08:07:46 +01:00
|
|
|
}
|
|
|
|
|
2017-01-22 23:04:40 +01:00
|
|
|
vbar->setMaximum (height - getViewportHeight());
|
|
|
|
vbar->setPageSize (height, getViewportHeight());
|
2017-01-02 08:07:46 +01:00
|
|
|
vbar->calculateSliderValues();
|
2017-01-03 05:19:44 +01:00
|
|
|
setVerticalScrollBarVisibility();
|
2017-01-02 08:07:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FScrollView::setScrollSize (int width, int height)
|
|
|
|
{
|
2017-01-22 23:04:40 +01:00
|
|
|
if ( width < getViewportWidth() )
|
|
|
|
width = getViewportWidth();
|
2017-01-02 08:07:46 +01:00
|
|
|
|
2017-01-22 23:04:40 +01:00
|
|
|
if ( height < getViewportHeight() )
|
|
|
|
height = getViewportHeight();
|
2017-01-02 08:07:46 +01:00
|
|
|
|
2017-01-03 05:19:44 +01:00
|
|
|
if ( getScrollWidth() == width && getScrollHeight() == height )
|
2017-01-02 08:07:46 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
if ( viewport )
|
|
|
|
{
|
|
|
|
FPoint no_shadow(0,0);
|
2017-01-26 00:31:07 +01:00
|
|
|
scroll_geometry.setSize (width, height);
|
|
|
|
resizeArea (scroll_geometry, no_shadow, viewport);
|
2017-01-15 19:48:27 +01:00
|
|
|
setPreprocessingHandler
|
|
|
|
(
|
|
|
|
_PREPROC_HANDLER (this, &FScrollView::copy2area)
|
|
|
|
);
|
2017-01-07 22:09:09 +01:00
|
|
|
child_print_area = viewport;
|
2017-01-02 08:07:46 +01:00
|
|
|
}
|
|
|
|
|
2017-01-22 23:04:40 +01:00
|
|
|
setTopPadding (1 - getScrollY());
|
|
|
|
setLeftPadding (1 - getScrollX());
|
|
|
|
setBottomPadding (1 - (getScrollHeight() - getViewportHeight() - getScrollY()));
|
|
|
|
setRightPadding (1 - (getScrollWidth() - getViewportWidth() - getScrollX()) + nf_offset);
|
|
|
|
|
|
|
|
hbar->setMaximum (width - getViewportWidth());
|
|
|
|
hbar->setPageSize (width, getViewportWidth());
|
2017-01-02 08:07:46 +01:00
|
|
|
hbar->calculateSliderValues();
|
2017-01-03 05:19:44 +01:00
|
|
|
setHorizontalScrollBarVisibility();
|
2017-01-02 08:07:46 +01:00
|
|
|
|
2017-01-22 23:04:40 +01:00
|
|
|
vbar->setMaximum (height - getViewportHeight());
|
|
|
|
vbar->setPageSize (height, getViewportHeight());
|
2017-01-02 08:07:46 +01:00
|
|
|
vbar->calculateSliderValues();
|
2017-01-03 05:19:44 +01:00
|
|
|
setVerticalScrollBarVisibility();
|
2017-01-02 08:07:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FScrollView::setX (int x, bool adjust)
|
|
|
|
{
|
|
|
|
FWidget::setX (x, adjust);
|
2017-01-03 05:19:44 +01:00
|
|
|
|
|
|
|
if ( ! adjust )
|
|
|
|
{
|
2017-01-26 00:31:07 +01:00
|
|
|
scroll_geometry.setX (getTermX() + getLeftPadding() - 1);
|
2017-01-03 05:19:44 +01:00
|
|
|
|
|
|
|
if ( viewport )
|
|
|
|
{
|
2017-01-26 00:31:07 +01:00
|
|
|
viewport->offset_top = scroll_geometry.getX();
|
|
|
|
viewport->offset_left = scroll_geometry.getY();
|
2017-01-03 05:19:44 +01:00
|
|
|
}
|
|
|
|
}
|
2017-01-02 08:07:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FScrollView::setY (int y, bool adjust)
|
|
|
|
{
|
|
|
|
FWidget::setY (y, adjust);
|
2017-01-03 05:19:44 +01:00
|
|
|
|
|
|
|
if ( ! adjust )
|
|
|
|
{
|
2017-01-26 00:31:07 +01:00
|
|
|
scroll_geometry.setY (getTermY() + getTopPadding() - 1);
|
2017-01-03 05:19:44 +01:00
|
|
|
|
|
|
|
if ( viewport )
|
|
|
|
{
|
2017-01-26 00:31:07 +01:00
|
|
|
viewport->offset_top = scroll_geometry.getX();
|
|
|
|
viewport->offset_left = scroll_geometry.getY();
|
2017-01-03 05:19:44 +01:00
|
|
|
}
|
|
|
|
}
|
2017-01-02 08:07:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FScrollView::setPos (int x, int y, bool adjust)
|
|
|
|
{
|
|
|
|
FWidget::setPos (x, y, adjust);
|
2017-01-26 00:31:07 +01:00
|
|
|
scroll_geometry.setPos ( getTermX() + getLeftPadding() - 1
|
2017-01-07 22:09:09 +01:00
|
|
|
, getTermY() + getTopPadding() - 1 );
|
2017-01-03 05:19:44 +01:00
|
|
|
|
|
|
|
if ( ! adjust )
|
|
|
|
{
|
|
|
|
if ( viewport )
|
|
|
|
{
|
2017-01-26 00:31:07 +01:00
|
|
|
viewport->offset_top = scroll_geometry.getX();
|
|
|
|
viewport->offset_left = scroll_geometry.getY();
|
2017-01-03 05:19:44 +01:00
|
|
|
}
|
|
|
|
}
|
2017-01-02 08:07:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FScrollView::setWidth (int w, bool adjust)
|
|
|
|
{
|
|
|
|
FWidget::setWidth (w, adjust);
|
2017-01-26 00:31:07 +01:00
|
|
|
viewport_geometry.setWidth(w);
|
2017-01-02 08:07:46 +01:00
|
|
|
calculateScrollbarPos();
|
|
|
|
|
2017-01-22 23:04:40 +01:00
|
|
|
if ( getScrollWidth() < getViewportWidth() )
|
|
|
|
setScrollWidth (getViewportWidth());
|
2017-01-02 08:07:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FScrollView::setHeight (int h, bool adjust)
|
|
|
|
{
|
|
|
|
FWidget::setHeight (h, adjust);
|
2017-01-26 00:31:07 +01:00
|
|
|
viewport_geometry.setHeight(h);
|
2017-01-02 08:07:46 +01:00
|
|
|
calculateScrollbarPos();
|
|
|
|
|
2017-01-22 23:04:40 +01:00
|
|
|
if ( getScrollHeight() < getViewportHeight() )
|
|
|
|
setScrollHeight (getViewportHeight());
|
2017-01-02 08:07:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FScrollView::setSize (int w, int h, bool adjust)
|
|
|
|
{
|
|
|
|
FWidget::setSize (w, h, adjust);
|
2017-01-26 00:31:07 +01:00
|
|
|
viewport_geometry.setSize(w, h);
|
2017-01-02 08:07:46 +01:00
|
|
|
calculateScrollbarPos();
|
|
|
|
|
2017-01-22 23:04:40 +01:00
|
|
|
if ( getScrollWidth() < getViewportWidth()
|
|
|
|
|| getScrollHeight() < getViewportHeight() )
|
|
|
|
setScrollSize (getViewportWidth(), getViewportHeight());
|
2017-01-02 08:07:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FScrollView::setGeometry (int x, int y, int w, int h, bool adjust)
|
|
|
|
{
|
|
|
|
FWidget::setGeometry (x, y, w, h, adjust);
|
2017-01-26 00:31:07 +01:00
|
|
|
scroll_geometry.setPos ( getTermX() + getLeftPadding() - 1
|
|
|
|
, getTermY() + getTopPadding() - 1 );
|
|
|
|
viewport_geometry.setSize(w, h);
|
2017-01-02 08:07:46 +01:00
|
|
|
calculateScrollbarPos();
|
|
|
|
|
2017-01-22 23:04:40 +01:00
|
|
|
if ( getScrollWidth() < getViewportWidth()
|
|
|
|
|| getScrollHeight() < getViewportHeight() )
|
2017-01-03 05:19:44 +01:00
|
|
|
{
|
2017-01-22 23:04:40 +01:00
|
|
|
setScrollSize (getViewportWidth(), getViewportHeight());
|
2017-01-03 05:19:44 +01:00
|
|
|
}
|
|
|
|
else if ( ! adjust && viewport )
|
|
|
|
{
|
2017-01-26 00:31:07 +01:00
|
|
|
viewport->offset_top = scroll_geometry.getX();
|
|
|
|
viewport->offset_left = scroll_geometry.getY();
|
2017-01-03 05:19:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-07 22:09:09 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FScrollView::setPrintPos (register int x, register int y)
|
|
|
|
{
|
|
|
|
FWidget::setPrintPos (x + getLeftPadding(), y + getTopPadding());
|
|
|
|
}
|
|
|
|
|
2017-01-03 05:19:44 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FScrollView::setHorizontalScrollBarMode (fc::scrollBarMode mode)
|
|
|
|
{
|
|
|
|
hMode = mode;
|
|
|
|
setHorizontalScrollBarVisibility();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FScrollView::setVerticalScrollBarMode (fc::scrollBarMode mode)
|
|
|
|
{
|
|
|
|
vMode = mode;
|
|
|
|
setVerticalScrollBarVisibility();
|
2017-01-02 08:07:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FScrollView::clearArea (int fillchar)
|
|
|
|
{
|
|
|
|
if ( viewport )
|
|
|
|
clearArea (viewport, fillchar);
|
|
|
|
}
|
|
|
|
|
2017-01-07 22:09:09 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FScrollView::scrollToX (int x)
|
|
|
|
{
|
2017-01-26 00:31:07 +01:00
|
|
|
scrollTo (x, viewport_geometry.getY() + 1);
|
2017-01-07 22:09:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FScrollView::scrollToY (int y)
|
|
|
|
{
|
2017-01-26 00:31:07 +01:00
|
|
|
scrollTo (viewport_geometry.getX() + 1, y);
|
2017-01-07 22:09:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FScrollView::scrollTo (int x, int y)
|
|
|
|
{
|
2017-01-26 00:31:07 +01:00
|
|
|
short& xoffset = viewport_geometry.x1_ref();
|
|
|
|
short& yoffset = viewport_geometry.y1_ref();
|
2017-01-22 23:04:40 +01:00
|
|
|
short xoffset_end = short(getScrollWidth() - getViewportWidth());
|
|
|
|
short yoffset_end = short(getScrollHeight() - getViewportHeight());
|
|
|
|
x--;
|
|
|
|
y--;
|
2017-01-07 22:09:09 +01:00
|
|
|
|
|
|
|
if ( xoffset == short(x) && yoffset == short(y) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
xoffset = short(x);
|
|
|
|
yoffset = short(y);
|
|
|
|
|
|
|
|
if ( yoffset < 0 )
|
|
|
|
yoffset = 0;
|
|
|
|
|
|
|
|
if ( yoffset > yoffset_end )
|
|
|
|
yoffset = yoffset_end;
|
|
|
|
|
|
|
|
if ( xoffset < 0 )
|
|
|
|
xoffset = 0;
|
|
|
|
|
|
|
|
if ( xoffset > xoffset_end )
|
|
|
|
xoffset = xoffset_end;
|
|
|
|
|
|
|
|
hbar->setValue (xoffset);
|
|
|
|
vbar->setValue (yoffset);
|
|
|
|
drawHBar();
|
|
|
|
drawVBar();
|
|
|
|
viewport->has_changes = true;
|
2017-01-22 23:04:40 +01:00
|
|
|
setTopPadding (1 - yoffset);
|
|
|
|
setLeftPadding (1 - xoffset);
|
|
|
|
setBottomPadding (1 - (getScrollHeight() - getViewportHeight() - yoffset));
|
|
|
|
setRightPadding (1 - (getScrollWidth() - getViewportWidth() - xoffset) + nf_offset);
|
2017-01-07 22:09:09 +01:00
|
|
|
copy2area();
|
|
|
|
updateTerminal();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FScrollView::scrollBy (int dx, int dy)
|
|
|
|
{
|
|
|
|
scrollTo (getScrollX() + dx, getScrollY() + dy);
|
|
|
|
}
|
|
|
|
|
2017-01-02 08:07:46 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FScrollView::draw()
|
|
|
|
{
|
2017-01-03 05:19:44 +01:00
|
|
|
use_own_print_area = true;
|
2017-01-02 08:07:46 +01:00
|
|
|
|
|
|
|
if ( FWidget* p = getParentWidget() )
|
|
|
|
setColor (p->getForegroundColor(), p->getBackgroundColor());
|
|
|
|
else
|
2017-01-15 19:48:27 +01:00
|
|
|
setColor();
|
2017-01-02 08:07:46 +01:00
|
|
|
|
|
|
|
if ( isNewFont() )
|
|
|
|
drawBorder (1, 1, getWidth() - 1, getHeight());
|
|
|
|
else
|
|
|
|
drawBorder();
|
|
|
|
|
2017-01-03 05:19:44 +01:00
|
|
|
use_own_print_area = false;
|
2017-01-02 08:07:46 +01:00
|
|
|
copy2area();
|
2017-01-07 22:09:09 +01:00
|
|
|
redrawVBar();
|
|
|
|
redrawHBar();
|
2017-01-02 08:07:46 +01:00
|
|
|
}
|
|
|
|
|
2017-01-03 19:02:04 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FScrollView::onKeyPress (FKeyEvent* ev)
|
|
|
|
{
|
|
|
|
int key = ev->key();
|
|
|
|
bool hasChanges = false;
|
2017-01-26 00:31:07 +01:00
|
|
|
short& xoffset = viewport_geometry.x1_ref();
|
|
|
|
short& yoffset = viewport_geometry.y1_ref();
|
2017-01-03 19:02:04 +01:00
|
|
|
short xoffset_before = xoffset;
|
|
|
|
short yoffset_before = yoffset;
|
2017-01-22 23:04:40 +01:00
|
|
|
short xoffset_end = short(getScrollWidth() - getViewportWidth());
|
|
|
|
short yoffset_end = short(getScrollHeight() - getViewportHeight());
|
2017-01-03 19:02:04 +01:00
|
|
|
|
|
|
|
switch ( key )
|
|
|
|
{
|
|
|
|
case fc::Fkey_up:
|
|
|
|
if ( yoffset > 0 )
|
|
|
|
yoffset--;
|
|
|
|
|
|
|
|
ev->accept();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case fc::Fkey_down:
|
|
|
|
if ( yoffset < yoffset_end )
|
|
|
|
yoffset++;
|
|
|
|
|
|
|
|
ev->accept();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case fc::Fkey_left:
|
|
|
|
if ( xoffset > 0 )
|
|
|
|
xoffset--;
|
|
|
|
|
|
|
|
ev->accept();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case fc::Fkey_right:
|
|
|
|
if ( xoffset < xoffset_end )
|
|
|
|
xoffset++;
|
|
|
|
|
|
|
|
ev->accept();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case fc::Fkey_ppage:
|
2017-01-22 23:04:40 +01:00
|
|
|
yoffset -= getViewportHeight();
|
2017-01-03 19:02:04 +01:00
|
|
|
|
|
|
|
if ( yoffset < 0 )
|
|
|
|
yoffset = 0;
|
|
|
|
|
|
|
|
ev->accept();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case fc::Fkey_npage:
|
2017-01-22 23:04:40 +01:00
|
|
|
yoffset += getViewportHeight();
|
2017-01-03 19:02:04 +01:00
|
|
|
|
|
|
|
if ( yoffset > yoffset_end )
|
|
|
|
yoffset = yoffset_end;
|
|
|
|
|
|
|
|
ev->accept();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case fc::Fkey_home:
|
|
|
|
yoffset = 0;
|
|
|
|
ev->accept();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case fc::Fkey_end:
|
|
|
|
yoffset = yoffset_end;
|
|
|
|
ev->accept();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ev->isAccepted() )
|
|
|
|
{
|
|
|
|
if ( isVisible() && viewport
|
|
|
|
&& (xoffset_before != xoffset || yoffset_before != yoffset) )
|
|
|
|
{
|
|
|
|
viewport->has_changes = true;
|
2017-01-22 23:04:40 +01:00
|
|
|
setTopPadding (1 - yoffset);
|
|
|
|
setLeftPadding (1 - xoffset);
|
|
|
|
setBottomPadding (1 - (getScrollHeight() - getViewportHeight() - yoffset));
|
|
|
|
setRightPadding (1 - (getScrollWidth() - getViewportWidth() - xoffset) + nf_offset);
|
2017-01-03 19:02:04 +01:00
|
|
|
copy2area();
|
|
|
|
hasChanges = true;
|
|
|
|
vbar->setValue (yoffset);
|
|
|
|
hbar->setValue (xoffset);
|
2017-01-07 22:09:09 +01:00
|
|
|
drawVBar();
|
|
|
|
drawHBar();
|
2017-01-03 19:02:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( hasChanges )
|
|
|
|
updateTerminal();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-02 08:07:46 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FScrollView::onWheel (FWheelEvent* ev)
|
|
|
|
{
|
2017-01-03 19:02:04 +01:00
|
|
|
bool hasChanges = false;
|
2017-01-26 00:31:07 +01:00
|
|
|
short& yoffset = viewport_geometry.y1_ref();
|
2017-01-03 19:02:04 +01:00
|
|
|
short yoffset_before = yoffset;
|
|
|
|
int wheel = ev->getWheel();
|
2017-01-02 08:07:46 +01:00
|
|
|
|
|
|
|
switch ( wheel )
|
|
|
|
{
|
|
|
|
case fc::WheelUp:
|
|
|
|
if ( yoffset == 0 )
|
|
|
|
break;
|
|
|
|
|
|
|
|
yoffset -= 4;
|
|
|
|
|
|
|
|
if ( yoffset < 0 )
|
|
|
|
yoffset=0;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case fc::WheelDown:
|
|
|
|
{
|
2017-01-22 23:04:40 +01:00
|
|
|
short yoffset_end = short(getScrollHeight() - getViewportHeight());
|
2017-01-02 08:07:46 +01:00
|
|
|
|
|
|
|
if ( yoffset_end < 0 )
|
|
|
|
yoffset_end = 0;
|
|
|
|
|
|
|
|
if ( yoffset == yoffset_end )
|
|
|
|
break;
|
|
|
|
|
|
|
|
yoffset += 4;
|
|
|
|
|
|
|
|
if ( yoffset > yoffset_end )
|
|
|
|
yoffset = yoffset_end;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-01-03 19:02:04 +01:00
|
|
|
if ( isVisible() && viewport && yoffset_before != yoffset )
|
2017-01-02 08:07:46 +01:00
|
|
|
{
|
2017-01-03 19:02:04 +01:00
|
|
|
viewport->has_changes = true;
|
2017-01-22 23:04:40 +01:00
|
|
|
setTopPadding (1 - yoffset);
|
|
|
|
setBottomPadding (1 - (getScrollHeight() - getViewportHeight() - yoffset));
|
2017-01-02 08:07:46 +01:00
|
|
|
copy2area();
|
2017-01-03 19:02:04 +01:00
|
|
|
hasChanges = true;
|
|
|
|
vbar->setValue (yoffset);
|
2017-01-07 22:09:09 +01:00
|
|
|
drawVBar();
|
2017-01-03 19:02:04 +01:00
|
|
|
}
|
2017-01-02 08:07:46 +01:00
|
|
|
|
2017-01-03 19:02:04 +01:00
|
|
|
if ( hasChanges )
|
|
|
|
updateTerminal();
|
2017-01-02 08:07:46 +01:00
|
|
|
}
|
|
|
|
|
2017-01-26 00:31:07 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FScrollView::onChildFocusChanged (FFocusEvent*)
|
|
|
|
{
|
|
|
|
// Scrolls the viewport so that the focused widget is visible
|
|
|
|
|
|
|
|
FRect widget_geometry;
|
|
|
|
FWidget* focus_widget = FWidget::getFocusWidget();
|
|
|
|
|
|
|
|
if ( ! focus_widget )
|
|
|
|
return;
|
|
|
|
|
|
|
|
widget_geometry = focus_widget->getGeometryWithShadow();
|
|
|
|
|
|
|
|
if ( ! viewport_geometry.contains(widget_geometry) )
|
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
int vx = viewport_geometry.getX();
|
|
|
|
int vy = viewport_geometry.getY();
|
|
|
|
int wx = widget_geometry.getX();
|
|
|
|
int wy = widget_geometry.getY();
|
|
|
|
|
|
|
|
if ( wx > vx )
|
|
|
|
x = widget_geometry.getX2() - viewport_geometry.getWidth() + 3;
|
|
|
|
else if ( wx < vx )
|
|
|
|
x = wx;
|
|
|
|
|
|
|
|
if ( wy > vy )
|
|
|
|
y = widget_geometry.getY2() - viewport_geometry.getHeight() + 3;
|
|
|
|
else if ( wy < vy )
|
|
|
|
y = wy;
|
|
|
|
|
|
|
|
scrollTo (x, y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-02 08:07:46 +01:00
|
|
|
|
|
|
|
// protected methods of FScrollView
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FVTerm::term_area* FScrollView::getPrintArea()
|
|
|
|
{
|
2017-01-07 22:09:09 +01:00
|
|
|
// returns print area or viewport
|
2017-01-02 08:07:46 +01:00
|
|
|
|
2017-01-07 22:09:09 +01:00
|
|
|
if ( use_own_print_area || ! viewport )
|
|
|
|
{
|
|
|
|
child_print_area = 0;
|
|
|
|
term_area* area = FVTerm::getPrintArea();
|
|
|
|
child_print_area = viewport;
|
|
|
|
return area;
|
|
|
|
}
|
2017-01-02 08:07:46 +01:00
|
|
|
else
|
2017-01-07 22:09:09 +01:00
|
|
|
return viewport;
|
2017-01-02 08:07:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FScrollView::adjustSize()
|
|
|
|
{
|
|
|
|
FWidget::adjustSize();
|
|
|
|
int width = getWidth();
|
|
|
|
int height = getHeight();
|
2017-01-26 00:31:07 +01:00
|
|
|
int xoffset = viewport_geometry.getX();
|
|
|
|
int yoffset = viewport_geometry.getY();
|
2017-01-02 08:07:46 +01:00
|
|
|
|
2017-01-26 00:31:07 +01:00
|
|
|
scroll_geometry.setPos ( getTermX() + getLeftPadding() - 1
|
|
|
|
, getTermY() + getTopPadding() - 1 );
|
2017-01-03 05:19:44 +01:00
|
|
|
|
|
|
|
if ( viewport )
|
|
|
|
{
|
2017-01-26 00:31:07 +01:00
|
|
|
viewport->offset_top = scroll_geometry.getX();
|
|
|
|
viewport->offset_left = scroll_geometry.getY();
|
2017-01-03 05:19:44 +01:00
|
|
|
}
|
|
|
|
|
2017-01-22 23:04:40 +01:00
|
|
|
hbar->setMaximum (getScrollWidth() - getViewportWidth());
|
|
|
|
hbar->setPageSize (getScrollWidth(), getViewportWidth());
|
2017-01-02 08:07:46 +01:00
|
|
|
hbar->setY (height);
|
|
|
|
hbar->setWidth (width - 2, false);
|
|
|
|
hbar->setValue (xoffset);
|
|
|
|
hbar->resize();
|
2017-01-03 05:19:44 +01:00
|
|
|
setHorizontalScrollBarVisibility();
|
2017-01-02 08:07:46 +01:00
|
|
|
|
2017-01-22 23:04:40 +01:00
|
|
|
vbar->setMaximum (getScrollHeight() - getViewportHeight());
|
|
|
|
vbar->setPageSize (getScrollHeight(), getViewportHeight());
|
2017-01-02 08:07:46 +01:00
|
|
|
vbar->setX (width);
|
|
|
|
vbar->setHeight (height - 2, false);
|
|
|
|
vbar->setValue (yoffset);
|
|
|
|
vbar->resize();
|
2017-01-03 05:19:44 +01:00
|
|
|
setVerticalScrollBarVisibility();
|
2017-01-02 08:07:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FScrollView::copy2area()
|
|
|
|
{
|
|
|
|
// copy viewport to area
|
|
|
|
|
|
|
|
int ax, ay, dx, dy, y_end, x_end;
|
|
|
|
char_data* vc; // viewport character
|
|
|
|
char_data* ac; // area character
|
|
|
|
|
2017-01-22 23:04:40 +01:00
|
|
|
if ( ! hasPrintArea() )
|
2017-01-02 08:07:46 +01:00
|
|
|
FVTerm::getPrintArea();
|
|
|
|
|
2017-01-22 23:04:40 +01:00
|
|
|
if ( ! (hasPrintArea() && viewport) )
|
2017-01-02 08:07:46 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
if ( ! viewport->has_changes )
|
|
|
|
return;
|
|
|
|
|
2017-01-15 19:48:27 +01:00
|
|
|
ax = getTermX() - print_area->offset_top;
|
|
|
|
ay = getTermY() - print_area->offset_left;
|
2017-01-26 00:31:07 +01:00
|
|
|
dx = viewport_geometry.getX();
|
|
|
|
dy = viewport_geometry.getY();
|
2017-01-22 23:04:40 +01:00
|
|
|
y_end = getViewportHeight();
|
|
|
|
x_end = getViewportWidth();
|
2017-01-02 08:07:46 +01:00
|
|
|
|
|
|
|
for (int y=0; y < y_end; y++) // line loop
|
|
|
|
{
|
|
|
|
int v_line_len = viewport->width;
|
|
|
|
int a_line_len = print_area->width + print_area->right_shadow;
|
|
|
|
vc = &viewport->text[(dy+y) * v_line_len + dx];
|
|
|
|
ac = &print_area->text[(ay+y) * a_line_len + ax];
|
|
|
|
std::memcpy (ac, vc, sizeof(char_data) * unsigned(x_end));
|
|
|
|
|
|
|
|
if ( short(print_area->changes[ay+y].xmin) > ax )
|
|
|
|
print_area->changes[ay+y].xmin = uInt(ax);
|
|
|
|
|
|
|
|
if ( short(print_area->changes[ay+y].xmax) < ax+x_end-1 )
|
|
|
|
print_area->changes[ay+y].xmax = uInt(ax+x_end-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
viewport->has_changes = false;
|
|
|
|
print_area->has_changes = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// private methods of FScrollView
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FScrollView::init()
|
|
|
|
{
|
2017-01-15 19:48:27 +01:00
|
|
|
setForegroundColor (wc.dialog_fg);
|
|
|
|
setBackgroundColor (wc.dialog_bg);
|
|
|
|
|
2017-01-02 08:07:46 +01:00
|
|
|
vbar = new FScrollbar(fc::vertical, this);
|
|
|
|
vbar->setMinimum(0);
|
|
|
|
vbar->setValue(0);
|
|
|
|
vbar->hide();
|
|
|
|
|
|
|
|
hbar = new FScrollbar(fc::horizontal, this);
|
|
|
|
hbar->setMinimum(0);
|
|
|
|
hbar->setValue(0);
|
|
|
|
hbar->hide();
|
|
|
|
|
|
|
|
vbar->addCallback
|
|
|
|
(
|
|
|
|
"change-value",
|
|
|
|
_METHOD_CALLBACK (this, &FScrollView::cb_VBarChange)
|
|
|
|
);
|
2017-01-15 19:48:27 +01:00
|
|
|
|
2017-01-02 08:07:46 +01:00
|
|
|
hbar->addCallback
|
|
|
|
(
|
|
|
|
"change-value",
|
|
|
|
_METHOD_CALLBACK (this, &FScrollView::cb_HBarChange)
|
|
|
|
);
|
|
|
|
|
|
|
|
nf_offset = isNewFont() ? 1 : 0;
|
2017-01-22 23:04:40 +01:00
|
|
|
setTopPadding (1 - getScrollY());
|
|
|
|
setLeftPadding (1 - getScrollX());
|
|
|
|
setBottomPadding (1 - (getScrollHeight() - getViewportHeight() - getScrollY()));
|
|
|
|
setRightPadding (1 - (getScrollWidth() - getViewportWidth() - getScrollX()) + nf_offset);
|
2017-01-02 08:07:46 +01:00
|
|
|
|
|
|
|
FPoint no_shadow(0,0);
|
2017-01-22 23:04:40 +01:00
|
|
|
int w = getViewportWidth();
|
|
|
|
int h = getViewportHeight();
|
|
|
|
|
|
|
|
if ( w < 1 )
|
|
|
|
w = 1;
|
|
|
|
|
|
|
|
if ( h < 1 )
|
|
|
|
h = 1;
|
|
|
|
|
2017-01-26 00:31:07 +01:00
|
|
|
scroll_geometry.setRect (0, 0, w, h);
|
|
|
|
createArea (scroll_geometry, no_shadow, viewport);
|
2017-01-15 19:48:27 +01:00
|
|
|
setPreprocessingHandler
|
|
|
|
(
|
|
|
|
_PREPROC_HANDLER (this, &FScrollView::copy2area)
|
|
|
|
);
|
2017-01-07 22:09:09 +01:00
|
|
|
|
|
|
|
if ( viewport )
|
|
|
|
child_print_area = viewport;
|
2017-01-02 08:07:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FScrollView::calculateScrollbarPos()
|
|
|
|
{
|
|
|
|
int width = getWidth();
|
|
|
|
int height = getHeight();
|
|
|
|
|
|
|
|
if ( isNewFont() )
|
|
|
|
{
|
|
|
|
vbar->setGeometry (width, 2, 2, height-2);
|
|
|
|
hbar->setGeometry (1, height, width-2, 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
vbar->setGeometry (width, 2, 1, height-2);
|
|
|
|
hbar->setGeometry (2, height, width-2, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
vbar->resize();
|
|
|
|
hbar->resize();
|
|
|
|
}
|
|
|
|
|
2017-01-03 05:19:44 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FScrollView::setHorizontalScrollBarVisibility()
|
|
|
|
{
|
|
|
|
switch ( hMode )
|
|
|
|
{
|
|
|
|
case fc::Auto:
|
2017-01-22 23:04:40 +01:00
|
|
|
if ( getScrollWidth() > getViewportWidth() )
|
2017-01-03 05:19:44 +01:00
|
|
|
hbar->setVisible();
|
|
|
|
else
|
|
|
|
hbar->hide();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case fc::Hidden:
|
|
|
|
hbar->hide();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case fc::Scroll:
|
|
|
|
hbar->setVisible();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FScrollView::setVerticalScrollBarVisibility()
|
|
|
|
{
|
|
|
|
switch ( vMode )
|
|
|
|
{
|
|
|
|
case fc::Auto:
|
2017-01-22 23:04:40 +01:00
|
|
|
if ( getScrollHeight() > getViewportHeight() )
|
2017-01-03 05:19:44 +01:00
|
|
|
vbar->setVisible();
|
|
|
|
else
|
|
|
|
vbar->hide();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case fc::Hidden:
|
|
|
|
vbar->hide();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case fc::Scroll:
|
|
|
|
vbar->setVisible();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-02 08:07:46 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FScrollView::cb_VBarChange (FWidget*, void*)
|
|
|
|
{
|
|
|
|
FScrollbar::sType scrollType;
|
2017-01-03 19:02:04 +01:00
|
|
|
bool hasChanges = false;
|
|
|
|
short distance = 1;
|
2017-01-26 00:31:07 +01:00
|
|
|
short& yoffset = viewport_geometry.y1_ref();
|
2017-01-03 19:02:04 +01:00
|
|
|
short yoffset_before = yoffset;
|
2017-01-22 23:04:40 +01:00
|
|
|
short yoffset_end = short(getScrollHeight() - getViewportHeight());
|
2017-01-02 08:07:46 +01:00
|
|
|
scrollType = vbar->getScrollType();
|
|
|
|
|
|
|
|
switch ( scrollType )
|
|
|
|
{
|
|
|
|
case FScrollbar::noScroll:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FScrollbar::scrollPageBackward:
|
2017-01-22 23:04:40 +01:00
|
|
|
distance = short(getViewportHeight());
|
2017-01-02 08:07:46 +01:00
|
|
|
// fall through
|
|
|
|
case FScrollbar::scrollStepBackward:
|
|
|
|
yoffset -= distance;
|
|
|
|
|
|
|
|
if ( yoffset < 0 )
|
|
|
|
yoffset = 0;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FScrollbar::scrollPageForward:
|
2017-01-22 23:04:40 +01:00
|
|
|
distance = short(getViewportHeight());
|
2017-01-02 08:07:46 +01:00
|
|
|
// fall through
|
|
|
|
case FScrollbar::scrollStepForward:
|
|
|
|
yoffset += distance;
|
|
|
|
|
|
|
|
if ( yoffset > yoffset_end )
|
|
|
|
yoffset = yoffset_end;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FScrollbar::scrollJump:
|
|
|
|
{
|
2017-01-03 19:02:04 +01:00
|
|
|
short val = short(vbar->getValue());
|
2017-01-02 08:07:46 +01:00
|
|
|
|
|
|
|
if ( yoffset == val )
|
|
|
|
break;
|
|
|
|
|
|
|
|
yoffset = val;
|
|
|
|
|
|
|
|
if ( yoffset > yoffset_end )
|
|
|
|
yoffset = yoffset_end;
|
|
|
|
|
|
|
|
if ( yoffset < 0 )
|
|
|
|
yoffset = 0;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case FScrollbar::scrollWheelUp:
|
|
|
|
if ( yoffset == 0 )
|
|
|
|
break;
|
|
|
|
|
|
|
|
yoffset -= 4;
|
|
|
|
|
|
|
|
if ( yoffset < 0 )
|
|
|
|
yoffset=0;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FScrollbar::scrollWheelDown:
|
|
|
|
if ( yoffset_end < 0 )
|
|
|
|
yoffset_end = 0;
|
|
|
|
|
|
|
|
if ( yoffset == yoffset_end )
|
|
|
|
break;
|
|
|
|
|
|
|
|
yoffset += 4;
|
|
|
|
|
|
|
|
if ( yoffset > yoffset_end )
|
|
|
|
yoffset = yoffset_end;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-01-03 19:02:04 +01:00
|
|
|
if ( isVisible() && viewport && yoffset_before != yoffset )
|
2017-01-02 08:07:46 +01:00
|
|
|
{
|
2017-01-03 19:02:04 +01:00
|
|
|
viewport->has_changes = true;
|
2017-01-22 23:04:40 +01:00
|
|
|
setTopPadding (1 - yoffset);
|
|
|
|
setBottomPadding (1 - (getScrollHeight() - getViewportHeight() - yoffset));
|
2017-01-02 08:07:46 +01:00
|
|
|
copy2area();
|
|
|
|
hasChanges = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( scrollType >= FScrollbar::scrollStepBackward
|
2017-01-03 19:02:04 +01:00
|
|
|
&& scrollType <= FScrollbar::scrollWheelDown
|
|
|
|
&& hasChanges )
|
2017-01-02 08:07:46 +01:00
|
|
|
{
|
|
|
|
vbar->setValue (yoffset);
|
2017-01-07 22:09:09 +01:00
|
|
|
drawVBar();
|
2017-01-02 08:07:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( hasChanges )
|
|
|
|
updateTerminal();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FScrollView::cb_HBarChange (FWidget*, void*)
|
|
|
|
{
|
|
|
|
FScrollbar::sType scrollType;
|
2017-01-03 19:02:04 +01:00
|
|
|
bool hasChanges = false;
|
|
|
|
short distance = 1;
|
2017-01-26 00:31:07 +01:00
|
|
|
short& xoffset = viewport_geometry.x1_ref();
|
2017-01-03 19:02:04 +01:00
|
|
|
short xoffset_before = xoffset;
|
2017-01-22 23:04:40 +01:00
|
|
|
short xoffset_end = short(getScrollWidth() - getViewportWidth());
|
2017-01-02 08:07:46 +01:00
|
|
|
scrollType = hbar->getScrollType();
|
|
|
|
|
|
|
|
switch ( scrollType )
|
|
|
|
{
|
|
|
|
case FScrollbar::noScroll:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FScrollbar::scrollPageBackward:
|
2017-01-22 23:04:40 +01:00
|
|
|
distance = short(getViewportWidth());
|
2017-01-02 08:07:46 +01:00
|
|
|
// fall through
|
|
|
|
case FScrollbar::scrollStepBackward:
|
|
|
|
xoffset -= distance;
|
|
|
|
|
|
|
|
if ( xoffset < 0 )
|
|
|
|
xoffset = 0;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FScrollbar::scrollPageForward:
|
2017-01-22 23:04:40 +01:00
|
|
|
distance = short(getViewportWidth());
|
2017-01-02 08:07:46 +01:00
|
|
|
// fall through
|
|
|
|
case FScrollbar::scrollStepForward:
|
|
|
|
xoffset += distance;
|
|
|
|
|
|
|
|
if ( xoffset > xoffset_end )
|
|
|
|
xoffset = xoffset_end;
|
|
|
|
|
|
|
|
if ( xoffset < 0 )
|
|
|
|
xoffset = 0;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FScrollbar::scrollJump:
|
|
|
|
{
|
2017-01-03 19:02:04 +01:00
|
|
|
short val = short(hbar->getValue());
|
2017-01-02 08:07:46 +01:00
|
|
|
|
|
|
|
if ( xoffset == val )
|
|
|
|
break;
|
|
|
|
|
|
|
|
xoffset = val;
|
|
|
|
|
|
|
|
if ( xoffset > xoffset_end )
|
|
|
|
xoffset = xoffset_end;
|
|
|
|
|
|
|
|
if ( xoffset < 0 )
|
|
|
|
xoffset = 0;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case FScrollbar::scrollWheelUp:
|
|
|
|
if ( xoffset == 0 )
|
|
|
|
break;
|
|
|
|
|
|
|
|
xoffset -= 4;
|
|
|
|
|
|
|
|
if ( xoffset < 0 )
|
|
|
|
xoffset=0;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FScrollbar::scrollWheelDown:
|
|
|
|
if ( xoffset == xoffset_end )
|
|
|
|
break;
|
|
|
|
|
|
|
|
xoffset += 4;
|
|
|
|
|
|
|
|
if ( xoffset > xoffset_end )
|
|
|
|
xoffset = xoffset_end;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-01-03 19:02:04 +01:00
|
|
|
if ( isVisible() && viewport && xoffset_before != xoffset )
|
2017-01-02 08:07:46 +01:00
|
|
|
{
|
2017-01-03 19:02:04 +01:00
|
|
|
viewport->has_changes = true;
|
2017-01-22 23:04:40 +01:00
|
|
|
setLeftPadding (1 - xoffset);
|
|
|
|
setRightPadding (1 - (getScrollWidth() - getViewportWidth() - xoffset) + nf_offset);
|
2017-01-02 08:07:46 +01:00
|
|
|
copy2area();
|
|
|
|
hasChanges = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( scrollType >= FScrollbar::scrollStepBackward
|
2017-01-03 19:02:04 +01:00
|
|
|
&& scrollType <= FScrollbar::scrollWheelDown
|
|
|
|
&& hasChanges )
|
2017-01-02 08:07:46 +01:00
|
|
|
{
|
|
|
|
hbar->setValue (xoffset);
|
2017-01-07 22:09:09 +01:00
|
|
|
drawHBar();
|
2017-01-02 08:07:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( hasChanges )
|
|
|
|
updateTerminal();
|
|
|
|
}
|
2017-01-07 22:09:09 +01:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FScrollView::redrawHBar()
|
|
|
|
{
|
|
|
|
child_print_area = 0;
|
|
|
|
|
|
|
|
if ( hbar->isVisible() )
|
|
|
|
hbar->redraw();
|
|
|
|
|
|
|
|
child_print_area = viewport;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FScrollView::redrawVBar()
|
|
|
|
{
|
|
|
|
child_print_area = 0;
|
|
|
|
|
|
|
|
if ( vbar->isVisible() )
|
|
|
|
vbar->redraw();
|
|
|
|
|
|
|
|
child_print_area = viewport;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FScrollView::drawHBar()
|
|
|
|
{
|
|
|
|
child_print_area = 0;
|
|
|
|
|
|
|
|
if ( hbar->isVisible() )
|
|
|
|
hbar->drawBar();
|
|
|
|
|
|
|
|
child_print_area = viewport;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FScrollView::drawVBar()
|
|
|
|
{
|
|
|
|
child_print_area = 0;
|
|
|
|
|
|
|
|
if ( vbar->isVisible() )
|
|
|
|
vbar->drawBar();
|
|
|
|
|
|
|
|
child_print_area = viewport;
|
|
|
|
}
|