Ejemplo n.º 1
0
/*************************************************************************
	Handler for mouse wheel changes
*************************************************************************/
void Listbox::onMouseWheel(MouseEventArgs& e)
{
	// base class processing.
	Window::onMouseWheel(e);

    Scrollbar* vertScrollbar = getVertScrollbar();
    Scrollbar* horzScrollbar = getHorzScrollbar();

	if (vertScrollbar->isVisible() && (vertScrollbar->getDocumentSize() > vertScrollbar->getPageSize()))
	{
		vertScrollbar->setScrollPosition(vertScrollbar->getScrollPosition() + vertScrollbar->getStepSize() * -e.wheelChange);
	}
	else if (horzScrollbar->isVisible() && (horzScrollbar->getDocumentSize() > horzScrollbar->getPageSize()))
	{
		horzScrollbar->setScrollPosition(horzScrollbar->getScrollPosition() + horzScrollbar->getStepSize() * -e.wheelChange);
	}

	++e.handled;
}
/************************************************************************
    Handle mouse wheel event
************************************************************************/
void ScrolledItemListBase::onMouseWheel(MouseEventArgs& e)
{
    ItemListBase::onMouseWheel(e);

    size_t count = getItemCount();
    Scrollbar* v = getVertScrollbar();

    // dont do anything if we are no using scrollbars
    // or have'nt got any items
    if (!v->isVisible(true) || !count)
    {
        return;
    }

    float pixH = d_pane->getUnclippedOuterRect().getHeight();
    float delta = (pixH/float(count)) * -e.wheelChange;
    v->setScrollPosition(v->getScrollPosition() + delta);
    ++e.handled;
}
Ejemplo n.º 3
0
//----------------------------------------------------------------------------//
void ScrollablePane::configureScrollbars(void)
{
    // controls should all be valid by this stage
    Scrollbar* vertScrollbar = getVertScrollbar();
    Scrollbar* horzScrollbar = getHorzScrollbar();
    
    // enable required scrollbars
    vertScrollbar->setVisible(isVertScrollbarNeeded());
    horzScrollbar->setVisible(isHorzScrollbarNeeded());
    
    // Check if the addition of the horizontal scrollbar means we
    // now also need the vertical bar.
    if (horzScrollbar->isVisible())
    {
        vertScrollbar->setVisible(isVertScrollbarNeeded());
    }
    
    performChildWindowLayout();
    
    // get viewable area
    Rect viewableArea(getViewableArea());
    
    // set up vertical scroll bar values
    vertScrollbar->setDocumentSize(fabsf(d_contentRect.getHeight()));
    vertScrollbar->setPageSize(viewableArea.getHeight());
    vertScrollbar->setStepSize(ceguimax(1.0f, viewableArea.getHeight() * d_vertStep));
    vertScrollbar->setOverlapSize(ceguimax(1.0f, viewableArea.getHeight() * d_vertOverlap));
    vertScrollbar->setScrollPosition(vertScrollbar->getScrollPosition());
    
    // set up horizontal scroll bar values
    horzScrollbar->setDocumentSize(fabsf(d_contentRect.getWidth()));
    horzScrollbar->setPageSize(viewableArea.getWidth());
    horzScrollbar->setStepSize(ceguimax(1.0f, viewableArea.getWidth() * d_horzStep));
    horzScrollbar->setOverlapSize(ceguimax(1.0f, viewableArea.getWidth() * d_horzOverlap));
    horzScrollbar->setScrollPosition(horzScrollbar->getScrollPosition());
}
Ejemplo n.º 4
0
	void CPFRotatingText::renderRotatingText()
	{
		Font* font = d_window->getFont();
		// can't render text without a font :)
		if( font==NULL){
			return;
		}

		// get destination area for the text.
		Rect absarea(getTextRenderArea());
		Rect clipper(absarea);

		float textHeight = font->getFormattedLineCount(d_window->getText(), absarea, (TextFormatting)d_horzFormatting) * font->getLineSpacing();

		Scrollbar* vertScrollbar = getVertScrollbar();
		Scrollbar* horzScrollbar = getHorzScrollbar();

		// calculate X offset
		static float xOffset = horzScrollbar->getPageSize();
		if( xOffset<-(horzScrollbar->getDocumentSize()+horzScrollbar->getPageSize()) ){
			xOffset = horzScrollbar->getPageSize();
		}
		static boost::system_time previous_time = boost::get_system_time();
		boost::system_time time = boost::get_system_time();
		boost::system_time::time_duration_type time_step = (time-previous_time);
		xOffset -= (static_cast<float>(time_step.total_milliseconds())*d_textSpeed);
		previous_time = time;
		absarea.offset(Point(xOffset, 0));

		// see if we may need to adjust horizontal position
		if( horzScrollbar->isVisible() ){
			switch(d_horzFormatting)
			{
			case LeftAligned:
			case WordWrapLeftAligned:
			case Justified:
			case WordWrapJustified:
				absarea.offset(Point(-horzScrollbar->getScrollPosition(), 0));
				break;

			case Centred:
			case WordWrapCentred:
				absarea.setWidth(horzScrollbar->getDocumentSize());
				absarea.offset(Point(-horzScrollbar->getScrollPosition(), 0));
				break;

			case RightAligned:
			case WordWrapRightAligned:
				absarea.offset(Point(horzScrollbar->getScrollPosition(), 0));
				break;
			}
		}

		// adjust y positioning according to formatting option
		switch(d_vertFormatting)
		{
		case TopAligned:
			absarea.d_top -= vertScrollbar->getScrollPosition();
			break;

		case VertCentred:
			// if scroll bar is in use, act like TopAligned
			if( vertScrollbar->isVisible() ){
				absarea.d_top -= vertScrollbar->getScrollPosition();
			}
			// no scroll bar, so centre text instead.
			else{
				absarea.d_top += PixelAligned((absarea.getHeight() - textHeight) * 0.5f);
			}
			break;

		case BottomAligned:
			absarea.d_top = absarea.d_bottom - textHeight;
			absarea.d_top += vertScrollbar->getScrollPosition();
			break;
		}

		// offset the font little down so that it's centered within its own spacing
		absarea.d_top += (font->getLineSpacing() - font->getFontHeight()) * 0.5f;
		// calculate final colours
		ColourRect final_cols(d_textCols);
		final_cols.modulateAlpha(d_window->getEffectiveAlpha());
		// cache the text for rendering.
		d_window->getRenderCache().cacheText(d_window->getText(), font, (TextFormatting)d_horzFormatting, absarea, 0, final_cols, &clipper);
	}