void ScrollBar::updateScrollBarLayout(void) { if(getRangeModel() != NULL && getScrollBar() != NULL) { Vec2f Size(calculateScrollBarSize()); if(getScrollBar()->getSize() != Size) { getScrollBar()->setSize(Size); } Pnt2f Pos(calculateScrollBarPosition()); if(getScrollBar()->getPosition() != Pos) { getScrollBar()->setPosition(Pos); } } }
LRESULT ListCtrl::onKeyDown( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled ) { if (getScrollBar(SB_VERT) != NULL) { LONG nHeight = 0; LONG nTotal = getEndRow() + 1; LONG nPos = 0; for (LONG n = 0; n < nTotal; n++) { nPos += getRowHeight(n); } getScrollBar(SB_VERT)->setPos(nPos); BOOL bh; getScrollBar(SB_VERT)->onSize(0, 0, 0, bh); } return 1; }
void ScrollBar::handleScrollBarMousePressed(MouseEventDetails* const e) { if(getEnabled() && e->getButton() == MouseEventDetails::BUTTON1) { _ScrollBarInitialMousePosition = ViewportToComponent(e->getLocation(), this, e->getViewport()); _ScrollBarInitialScrollBarPosition = getScrollBar()->getPosition(); _ScrollBarDragMouseDraggedConnection = getParentWindow()->getParentDrawingSurface()->getEventProducer()->connectMouseDragged(boost::bind(&ScrollBar::handleScrollBarDragMouseDragged, this, _1)); _ScrollBarDragMouseReleasedConnection = getParentWindow()->getParentDrawingSurface()->getEventProducer()->connectMouseReleased(boost::bind(&ScrollBar::handleScrollBarDragMouseReleased, this, _1)); } }
void ScrollBar::handleScrollFieldAction(ActionEventDetails* const e) { if(getEnabled()) { UInt32 AxisIndex(0); if(getOrientation() == ScrollBar::HORIZONTAL_ORIENTATION ) AxisIndex = 0; else AxisIndex = 1; Pnt2f ComponentMousePosition(DrawingSurfaceToComponent(getParentWindow()->getParentDrawingSurface()->getMousePosition(), this)); //Is Mouse Major axis on the min or max side of the scroll bar if(ComponentMousePosition[AxisIndex] < getScrollBar()->getPosition()[AxisIndex]) { //Move the Bounded range model one block in the Min direction scrollBlock(-1); } else if(ComponentMousePosition[AxisIndex] > (getScrollBar()->getPosition()[AxisIndex] + getScrollBar()->getSize()[AxisIndex])) { //Move the Bounded range model one block in the Max direction scrollBlock(1); } } }
Int32 ScrollBar::calculateValueFromPosition(const Pnt2f Position) const { Int32 Value; UInt16 MajorAxis, MinorAxis; if(getOrientation() == ScrollBar::VERTICAL_ORIENTATION) { MajorAxis = 1; } else { MajorAxis = 0; } MinorAxis = (MajorAxis+1)%2; Value = (Position[MajorAxis] - getScrollField()->getPosition()[MajorAxis])/(getScrollField()->getSize()[MajorAxis] - getScrollBar()->getSize()[MajorAxis])*static_cast<Real32>(getMaximum() - getMinimum() - getExtent()) + getMinimum(); return Value; }
Pnt2f ScrollBar::calculateScrollBarPosition(void) const { Pnt2f Position; UInt16 MajorAxis, MinorAxis; if(getOrientation() == ScrollBar::VERTICAL_ORIENTATION) { MajorAxis = 1; } else { MajorAxis = 0; } MinorAxis = (MajorAxis+1)%2; Position[MajorAxis] = getScrollField()->getPosition()[MajorAxis] + (static_cast<Real32>(getValue() - getMinimum())/static_cast<Real32>(getMaximum() - getMinimum() - getExtent())) * (getScrollField()->getSize()[MajorAxis] - getScrollBar()->getSize()[MajorAxis]); Position[MinorAxis] = getScrollField()->getPosition()[MinorAxis]; return Position; }