void ListboxImageItem::draw(RenderCache& cache,const Rect& targetRect, float zBase, float alpha, const Rect* clipper) const
{
    if (d_selected && d_selectBrush != 0)
    {
        cache.cacheImage(*d_selectBrush, targetRect, zBase, getModulateAlphaColourRect(d_selectCols, alpha), clipper);
    }

	if (d_image != NULL)
	{
		cache.cacheImage(*d_image, targetRect, zBase, ColourRect(colour(1,1,1,alpha)), clipper);
	}
}
    void ListboxWrappedTextItem::draw(RenderCache& cache,const Rect& targetRect,
        float zBase, float alpha, const Rect* clipper) const
    {
        if (d_selected && d_selectBrush != 0)
        {
            cache.cacheImage(*d_selectBrush, targetRect, zBase,
                getModulateAlphaColourRect(d_selectCols, alpha), clipper);
        }

        Font* font = const_cast<Font*>(getFont());

        if (font)
        {
            float left_offset = 0;
            if (d_draw_bullet)
            {
                left_offset = font->getTextExtent(ds_bullet);
            }

            Rect finalPos = targetRect;
            finalPos.d_top -= (font->getLineSpacing() - font->getBaseline()) * 0.5f;
            cache.cacheText(ds_bullet, font, d_textFormatting, finalPos, zBase,
                getModulateAlphaColourRect(d_textCols, alpha), clipper);
            finalPos.d_left += left_offset;
            cache.cacheText(d_itemText, font, d_textFormatting, finalPos, zBase,
                getModulateAlphaColourRect(d_textCols, alpha), clipper);
        }
    }
Exemplo n.º 3
0
void ListboxNumberItem::draw(RenderCache& cache,const Rect& targetRect, float zBase, float alpha, const Rect* clipper) const
{
    if (d_selected && d_selectBrush != 0)
    {
        cache.cacheImage(*d_selectBrush, targetRect, zBase, getModulateAlphaColourRect(d_selectCols, alpha), clipper);
    }

    const Font* font = getFont();

    if (font)
    {
        Rect finalPos(targetRect);
        finalPos.d_top -= (font->getLineSpacing() - font->getBaseline()) * 0.5f;
        cache.cacheText(d_itemText, font, LeftAligned, finalPos, zBase, getModulateAlphaColourRect(d_textCols, alpha), clipper);
    }
}
Exemplo n.º 4
0
void ListboxTextItem::draw(RenderCache& cache,const Rect& targetRect, float zBase, float alpha, const Rect* clipper) const
{
    if (d_selected && d_selectBrush != 0)
    {
        cache.cacheImage(*d_selectBrush, targetRect, zBase, getModulateAlphaColourRect(d_selectCols, alpha), clipper);
    }

    const FontBase* font = getFont();

    if (font)
    {
        Rect finalPos(targetRect);
		finalPos.d_top += PixelAligned( FontBase::LineSpace * 0.5f);
		cache.cacheText( getOwnerWindow(), d_itemText, font, d_horzFormateing, finalPos, zBase, getModulateAlphaColourRect(d_textCols, alpha), clipper);
    }
}
Exemplo n.º 5
0
void RenderableFrame::draw_impl(RenderCache& renderCache) const
{
    // TODO: This is a fairly substantial Cut, paste, and hack job.
    // TODO: There are probably a thousand ways that this should be improved!

    Rect destArea;
	Vector3 final_pos(0,0,0);
	float	org_width = d_area.getWidth(), org_height = d_area.getHeight();
	Size	final_size;
	ColourRect final_colours(d_colours);
	bool calcColoursPerImage = !(d_useColoursPerImage || d_colours.isMonochromatic());
	float leftfactor, rightfactor, topfactor, bottomfactor;

	// calculate 'adjustments' required to accommodate corner pieces.
	float	coord_adj, size_adj;

	// draw top-edge, if required
	if (d_top != NULL) {

		// calculate adjustments required if top-left corner will be rendered.
		if (d_topleft != NULL) {
			size_adj = (d_topleft->getWidth() - d_topleft->getOffsetX());
			coord_adj = d_topleft->getWidth();
		}
		else {
			coord_adj	= 0;
			size_adj	= 0;
		}

		// calculate adjustments required if top-right corner will be rendered.
		if (d_topright != NULL) {
			size_adj += (d_topright->getWidth() + d_topright->getOffsetX());
		}

		final_size.d_width	= org_width - size_adj;
		final_size.d_height	= d_top->getHeight();
		final_pos.d_x		= coord_adj;
		final_pos.d_y		= 0;

		// calculate final colours that are to be used
		if (calcColoursPerImage)
		{
			leftfactor = (final_pos.d_x + d_top->getOffsetX()) / org_width;
			rightfactor = leftfactor + final_size.d_width / org_width;
			topfactor = (final_pos.d_y + d_top->getOffsetY()) / org_height;
			bottomfactor = topfactor + final_size.d_height / org_height;

			final_colours = d_colours.getSubRectangle( leftfactor, rightfactor, topfactor, bottomfactor);
		}

        destArea.d_left = final_pos.d_x;
        destArea.d_top = final_pos.d_y;
        destArea.d_right = final_pos.d_x + final_size.d_width;
        destArea.d_bottom = final_pos.d_y + final_size.d_height;

        renderCache.cacheImage(*d_top, destArea, 0, final_colours);
	}

	// draw bottom-edge, if required
	if (d_bottom != NULL) {

		// calculate adjustments required if bottom-left corner will be rendered.
		if (d_bottomleft != NULL) {
			size_adj = (d_bottomleft->getWidth() - d_bottomleft->getOffsetX());
			coord_adj = d_bottomleft->getWidth();
		}
		else {
			coord_adj	= 0;
			size_adj	= 0;
		}

		// calculate adjustments required if bottom-right corner will be rendered.
		if (d_bottomright != NULL) {
			size_adj += (d_bottomright->getWidth() + d_bottomright->getOffsetX());
		}

		final_size.d_width	= org_width - size_adj;
		final_size.d_height	= d_bottom->getHeight();
		final_pos.d_x		= coord_adj;
		final_pos.d_y		= org_height - final_size.d_height;

		// calculate final colours that are to be used
		if (calcColoursPerImage)
		{
			leftfactor = (final_pos.d_x + d_bottom->getOffsetX()) / org_width;
			rightfactor = leftfactor + final_size.d_width / org_width;
			topfactor = (final_pos.d_y + d_bottom->getOffsetY()) / org_height;
			bottomfactor = topfactor + final_size.d_height / org_height;

			final_colours = d_colours.getSubRectangle( leftfactor, rightfactor, topfactor, bottomfactor);
		}

        destArea.d_left = final_pos.d_x;
        destArea.d_top = final_pos.d_y;
        destArea.d_right = final_pos.d_x + final_size.d_width;
        destArea.d_bottom = final_pos.d_y + final_size.d_height;

        renderCache.cacheImage(*d_bottom, destArea, 0, final_colours);
	}
	
	// draw left-edge, if required
	if (d_left != NULL) {

		// calculate adjustments required if top-left corner will be rendered.
		if (d_topleft != NULL) {
			size_adj = (d_topleft->getHeight() - d_topleft->getOffsetY());
			coord_adj = d_topleft->getHeight();
		}
		else {
			coord_adj	= 0;
			size_adj	= 0;
		}

		// calculate adjustments required if bottom-left corner will be rendered.
		if (d_bottomleft != NULL) {
			size_adj += (d_bottomleft->getHeight() + d_bottomleft->getOffsetY());
		}

		final_size.d_height	= org_height - size_adj;
		final_size.d_width	= d_left->getWidth();
		final_pos.d_y		= coord_adj;
		final_pos.d_x		= 0;

		// calculate final colours that are to be used
		if (calcColoursPerImage)
		{
			leftfactor = (final_pos.d_x + d_left->getOffsetX()) / org_width;
			rightfactor = leftfactor + final_size.d_width / org_width;
			topfactor = (final_pos.d_y + d_left->getOffsetY()) / org_height;
			bottomfactor = topfactor + final_size.d_height / org_height;

			final_colours = d_colours.getSubRectangle( leftfactor, rightfactor, topfactor, bottomfactor);
		}

        destArea.d_left = final_pos.d_x;
        destArea.d_top = final_pos.d_y;
        destArea.d_right = final_pos.d_x + final_size.d_width;
        destArea.d_bottom = final_pos.d_y + final_size.d_height;

        renderCache.cacheImage(*d_left, destArea, 0, final_colours);
	}

	// draw right-edge, if required
	if (d_right != NULL) {

		// calculate adjustments required if top-left corner will be rendered.
		if (d_topright != NULL) {
			size_adj = (d_topright->getHeight() - d_topright->getOffsetY());
			coord_adj = d_topright->getHeight();
		}
		else {
			coord_adj	= 0;
			size_adj	= 0;
		}

		// calculate adjustments required if bottom-left corner will be rendered.
		if (d_bottomright != NULL) {
			size_adj += (d_bottomright->getHeight() + d_bottomright->getOffsetY());
		}


		final_size.d_height	= org_height - size_adj;
		final_size.d_width	= d_right->getWidth();
		final_pos.d_y		= coord_adj;
		final_pos.d_x		= org_width - final_size.d_width;

		// calculate final colours that are to be used
		if (calcColoursPerImage)
		{
			leftfactor = (final_pos.d_x + d_right->getOffsetX()) / org_width;
			rightfactor = leftfactor + final_size.d_width / org_width;
			topfactor = (final_pos.d_y + d_right->getOffsetY()) / org_height;
			bottomfactor = topfactor + final_size.d_height / org_height;

			final_colours = d_colours.getSubRectangle( leftfactor, rightfactor, topfactor, bottomfactor);
		}

        destArea.d_left = final_pos.d_x;
        destArea.d_top = final_pos.d_y;
        destArea.d_right = final_pos.d_x + final_size.d_width;
        destArea.d_bottom = final_pos.d_y + final_size.d_height;

        renderCache.cacheImage(*d_right, destArea, 0, final_colours);
	}

	// draw required corner pieces...
	if (d_topleft != NULL) {

		// calculate final colours that are to be used
		if (calcColoursPerImage)
		{
			leftfactor = d_topleft->getOffsetX() / org_width;
			rightfactor = leftfactor + d_topleft->getWidth() / org_width;
			topfactor = d_topleft->getOffsetY() / org_height;
			bottomfactor = topfactor + d_topleft->getHeight() / org_height;

			final_colours = d_colours.getSubRectangle( leftfactor, rightfactor, topfactor, bottomfactor);
		}

        destArea.d_left = 0;
        destArea.d_top = 0;
        destArea.d_right = d_topleft->getWidth();
        destArea.d_bottom = d_topleft->getHeight();

        renderCache.cacheImage(*d_topleft, destArea, 0, final_colours);
	}

	if (d_topright != NULL) {
		final_pos.d_x = org_width - d_topright->getWidth();
		final_pos.d_y = 0;

		// calculate final colours that are to be used
		if (calcColoursPerImage)
		{
			leftfactor = (final_pos.d_x + d_topright->getOffsetX()) / org_width;
			rightfactor = leftfactor + d_topright->getWidth() / org_width;
			topfactor = (final_pos.d_y + d_topright->getOffsetY()) / org_height;
			bottomfactor = topfactor + d_topright->getHeight() / org_height;

			final_colours = d_colours.getSubRectangle( leftfactor, rightfactor, topfactor, bottomfactor);
		}

        destArea.d_left = final_pos.d_x;
        destArea.d_top = final_pos.d_y;
        destArea.d_right = final_pos.d_x + d_topright->getWidth();
        destArea.d_bottom = final_pos.d_y + d_topright->getHeight();

        renderCache.cacheImage(*d_topright, destArea, 0, final_colours);
	}

	if (d_bottomleft != NULL) {
		final_pos.d_x = 0;
		final_pos.d_y = org_height - d_bottomleft->getHeight();

		// calculate final colours that are to be used
		if (calcColoursPerImage)
		{
			leftfactor = (final_pos.d_x + d_bottomleft->getOffsetX()) / org_width;
			rightfactor = leftfactor + d_bottomleft->getWidth() / org_width;
			topfactor = (final_pos.d_y + d_bottomleft->getOffsetY()) / org_height;
			bottomfactor = topfactor + d_bottomleft->getHeight() / org_height;

			final_colours = d_colours.getSubRectangle( leftfactor, rightfactor, topfactor, bottomfactor);
		}

        destArea.d_left = final_pos.d_x;
        destArea.d_top = final_pos.d_y;
        destArea.d_right = final_pos.d_x + d_bottomleft->getWidth();
        destArea.d_bottom = final_pos.d_y + d_bottomleft->getHeight();

        renderCache.cacheImage(*d_bottomleft, destArea, 0, final_colours);
	}

	if (d_bottomright != NULL) {
		final_pos.d_x = org_width - d_bottomright->getWidth();
		final_pos.d_y = org_height - d_bottomright->getHeight();

		// calculate final colours that are to be used
		if (calcColoursPerImage)
		{
			leftfactor = (final_pos.d_x + d_bottomright->getOffsetX()) / org_width;
			rightfactor = leftfactor + d_bottomright->getWidth() / org_width;
			topfactor = (final_pos.d_y + d_bottomright->getOffsetY()) / org_height;
			bottomfactor = topfactor + d_bottomright->getHeight() / org_height;

			final_colours = d_colours.getSubRectangle( leftfactor, rightfactor, topfactor, bottomfactor);
		}

        destArea.d_left = final_pos.d_x;
        destArea.d_top = final_pos.d_y;
        destArea.d_right = final_pos.d_x + d_bottomright->getWidth();
        destArea.d_bottom = final_pos.d_y + d_bottomright->getHeight();

        renderCache.cacheImage(*d_bottomright, destArea, 0, final_colours);
	}
}