예제 #1
0
/*************************************************************************
	Perform the actual rendering for this Window.
*************************************************************************/
void Listbox::populateRenderCache()
{
    // get the derived class to render general stuff before we handle the items
    cacheListboxBaseImagery();

    //
    // Render list items
    //
    Vector3	itemPos;
    Size	itemSize;
    Rect	itemClipper, itemRect;
    float	widest = getWidestItemWidth();

    // calculate position of area we have to render into
    Rect itemsArea(getListRenderArea());

    // set up some initial positional details for items
    itemPos.d_x = itemsArea.d_left - d_horzScrollbar->getScrollPosition();
    itemPos.d_y = itemsArea.d_top - d_vertScrollbar->getScrollPosition();
    itemPos.d_z = System::getSingleton().getRenderer()->getZLayer(3) - System::getSingleton().getRenderer()->getCurrentZ();

    float alpha = getEffectiveAlpha();

    // loop through the items
    size_t itemCount = getItemCount();

    for (size_t i = 0; i < itemCount; ++i)
    {
        itemSize.d_height = d_listItems[i]->getPixelSize().d_height;

        // allow item to have full width of box if this is wider than items
        itemSize.d_width = ceguimax(itemsArea.getWidth(), widest);

        // calculate destination area for this item.
        itemRect.d_left	= itemPos.d_x;
        itemRect.d_top	= itemPos.d_y;
        itemRect.setSize(itemSize);
        itemClipper = itemRect.getIntersection(itemsArea);

        // skip this item if totally clipped
        if (itemClipper.getWidth() == 0)
        {
            itemPos.d_y += itemSize.d_height;
            continue;
        }

        // draw this item
        d_listItems[i]->draw(d_renderCache, itemRect, itemPos.d_z, alpha, &itemClipper);

        // update position ready for next item
        itemPos.d_y += itemSize.d_height;
    }

}
예제 #2
0
/*************************************************************************
    Perform the actual rendering for this Window.
*************************************************************************/
void Tree::populateGeometryBuffer()
{
    // get the derived class to render general stuff before we handle the items
    cacheTreeBaseImagery();
    
    // Render list items
    Vector2f itemPos;
    float    widest = getWidestItemWidth();
    
    // calculate position of area we have to render into
    //Rect itemsArea(getTreeRenderArea());
    //Rect itemsArea(0,0,500,500);
    
    // set up some initial positional details for items
    itemPos.d_x = d_itemArea.left() - d_horzScrollbar->getScrollPosition();
    itemPos.d_y = d_itemArea.top() - d_vertScrollbar->getScrollPosition();
    
    drawItemList(d_listItems, d_itemArea, widest, itemPos, *d_geometry,
                 getEffectiveAlpha());
}
예제 #3
0
/*************************************************************************
	display required integrated scroll bars according to current state
	of the list box and update their values.
*************************************************************************/
void Listbox::configureScrollbars(void)
{
    Scrollbar* vertScrollbar = getVertScrollbar();
    Scrollbar* horzScrollbar = getHorzScrollbar();

	float totalHeight	= getTotalItemsHeight();
	float widestItem	= getWidestItemWidth();

	//
	// First show or hide the scroll bars as needed (or requested)
	//
	// show or hide vertical scroll bar as required (or as specified by option)
	if ((totalHeight > getListRenderArea().getHeight()) || d_forceVertScroll)
	{
		vertScrollbar->show();

		// show or hide horizontal scroll bar as required (or as specified by option)
		if ((widestItem > getListRenderArea().getWidth()) || d_forceHorzScroll)
		{
			horzScrollbar->show();
		}
		else
		{
			horzScrollbar->hide();
		}

	}
	else
	{
		// show or hide horizontal scroll bar as required (or as specified by option)
		if ((widestItem > getListRenderArea().getWidth()) || d_forceHorzScroll)
		{
			horzScrollbar->show();

			// show or hide vertical scroll bar as required (or as specified by option)
			if ((totalHeight > getListRenderArea().getHeight()) || d_forceVertScroll)
			{
				vertScrollbar->show();
			}
			else
			{
				vertScrollbar->hide();
			}

		}
		else
		{
			vertScrollbar->hide();
			horzScrollbar->hide();
		}

	}

	//
	// Set up scroll bar values
	//
	Rect renderArea(getListRenderArea());

	vertScrollbar->setDocumentSize(totalHeight);
	vertScrollbar->setPageSize(renderArea.getHeight());
	vertScrollbar->setStepSize(ceguimax(1.0f, renderArea.getHeight() / 10.0f));
	vertScrollbar->setScrollPosition(vertScrollbar->getScrollPosition());

	horzScrollbar->setDocumentSize(widestItem);
	horzScrollbar->setPageSize(renderArea.getWidth());
	horzScrollbar->setStepSize(ceguimax(1.0f, renderArea.getWidth() / 10.0f));
	horzScrollbar->setScrollPosition(horzScrollbar->getScrollPosition());
}
예제 #4
0
/*************************************************************************
	display required integrated scroll bars according to current state
	of the list box and update their values.
*************************************************************************/
void Listbox::configureScrollbars(void)
{
    Scrollbar* vertScrollbar;
    Scrollbar* horzScrollbar;

    try
    {
        vertScrollbar = static_cast<Scrollbar*>(WindowManager::getSingleton().getWindow(getName() + "__auto_vscrollbar__"));
        horzScrollbar = static_cast<Scrollbar*>(WindowManager::getSingleton().getWindow(getName() + "__auto_hscrollbar__"));
    }
    catch (UnknownObjectException)
    {
        // no scrollbars?  Can't configure then!
        return;
    }

	float totalHeight	= getTotalItemsHeight();
	float widestItem	= getWidestItemWidth();

	//
	// First show or hide the scroll bars as needed (or requested)
	//
	// show or hide vertical scroll bar as required (or as specified by option)
	if ((totalHeight > getListRenderArea().getHeight()) || d_forceVertScroll)
	{
		vertScrollbar->show();

		// show or hide horizontal scroll bar as required (or as specified by option)
		if ((widestItem > getListRenderArea().getWidth()) || d_forceHorzScroll)
		{
			horzScrollbar->show();
		}
		else
		{
			horzScrollbar->hide();
		}

	}
	else
	{
		// show or hide horizontal scroll bar as required (or as specified by option)
		if ((widestItem > getListRenderArea().getWidth()) || d_forceHorzScroll)
		{
			horzScrollbar->show();

			// show or hide vertical scroll bar as required (or as specified by option)
			if ((totalHeight > getListRenderArea().getHeight()) || d_forceVertScroll)
			{
				vertScrollbar->show();
			}
			else
			{
				vertScrollbar->hide();
			}

		}
		else
		{
			vertScrollbar->hide();
			horzScrollbar->hide();
		}

	}

	//
	// Set up scroll bar values
	//
	Rect renderArea(getListRenderArea());

	vertScrollbar->setDocumentSize(totalHeight);
	vertScrollbar->setPageSize(renderArea.getHeight());
	vertScrollbar->setStepSize(ceguimax(1.0f, renderArea.getHeight() / 10.0f));
	vertScrollbar->setScrollPosition(vertScrollbar->getScrollPosition());

	horzScrollbar->setDocumentSize(widestItem);
	horzScrollbar->setPageSize(renderArea.getWidth());
	horzScrollbar->setStepSize(ceguimax(1.0f, renderArea.getWidth() / 10.0f));
	horzScrollbar->setScrollPosition(horzScrollbar->getScrollPosition());
}
예제 #5
0
/*************************************************************************
    display required integrated scroll bars according to current state
    of the tree and update their values.
*************************************************************************/
void Tree::configureScrollbars(void)
{
    Rectf renderArea(getTreeRenderArea());
    
    //This is becuase CEGUI IS GAY! and fires events before the item is initialized
    if(!d_vertScrollbar)
        d_vertScrollbar = createVertScrollbar("__auto_vscrollbar__");
    if(!d_horzScrollbar)
        d_horzScrollbar = createHorzScrollbar("__auto_hscrollbar__");
    
    float totalHeight = getTotalItemsHeight();
    float widestItem  = getWidestItemWidth() + 20;
    
    //
    // First show or hide the scroll bars as needed (or requested)
    //
    // show or hide vertical scroll bar as required (or as specified by option)
    if ((totalHeight > renderArea.getHeight()) || d_forceVertScroll)
    {
        d_vertScrollbar->show();
        renderArea.d_max.d_x -= d_vertScrollbar->getWidth().d_offset + d_vertScrollbar->getXPosition().d_offset;
        // show or hide horizontal scroll bar as required (or as specified by option)
        if ((widestItem > renderArea.getWidth()) || d_forceHorzScroll)
        {
            d_horzScrollbar->show();
            renderArea.d_max.d_y -= d_horzScrollbar->getHeight().d_offset;
        }
        else
        {
            d_horzScrollbar->hide();
            d_horzScrollbar->setScrollPosition(0);
        }
    }
    else
    {
        // show or hide horizontal scroll bar as required (or as specified by option)
        if ((widestItem > renderArea.getWidth()) || d_forceHorzScroll)
        {
            d_horzScrollbar->show();
            renderArea.d_max.d_y -= d_vertScrollbar->getHeight().d_offset;
            
            // show or hide vertical scroll bar as required (or as specified by option)
            if ((totalHeight > renderArea.getHeight()) || d_forceVertScroll)
            {
                d_vertScrollbar->show();
                //            renderArea.d_right -= d_vertScrollbar->getAbsoluteWidth();
                renderArea.d_max.d_x -= d_vertScrollbar->getWidth().d_offset;
            }
            else
            {
                d_vertScrollbar->hide();
                d_vertScrollbar->setScrollPosition(0);
            }
        }
        else
        {
            d_vertScrollbar->hide();
            d_vertScrollbar->setScrollPosition(0);
            d_horzScrollbar->hide();
            d_horzScrollbar->setScrollPosition(0);
        }
    }
    
    //
    // Set up scroll bar values
    //
    
    float itemHeight;
    if (!d_listItems.empty())
        itemHeight = d_listItems[0]->getPixelSize().d_height;
    else
        itemHeight = 10;
    
    d_vertScrollbar->setDocumentSize(totalHeight);
    d_vertScrollbar->setPageSize(renderArea.getHeight());
    d_vertScrollbar->setStepSize(ceguimax(1.0f, renderArea.getHeight() / itemHeight));
    d_vertScrollbar->setScrollPosition(d_vertScrollbar->getScrollPosition());
    
    d_horzScrollbar->setDocumentSize(widestItem + d_vertScrollbar->getWidth().d_offset);
    //   d_horzScrollbar->setDocumentSize(widestItem + d_vertScrollbar->getAbsoluteWidth());
    d_horzScrollbar->setPageSize(renderArea.getWidth());
    d_horzScrollbar->setStepSize(ceguimax(1.0f, renderArea.getWidth() / HORIZONTAL_STEP_SIZE_DIVISOR));
    d_horzScrollbar->setScrollPosition(d_horzScrollbar->getScrollPosition());
}