Beispiel #1
0
int as_peek(Stack *stack, void *data) {
	ArrayStack *s = (ArrayStack*)stack;
	if (0 == as_size(stack))
		return -1;
	
	void *d = (s->_arrayPtr + ((s->_size - 1) * s->_dataItemSize));
	memcpy(data, d, s->_dataItemSize);
	
	return 0;
}
void msh::GraphicsDisplayLayout::clip_to_output(geometry::Rectangle& rect)
{
    auto output = get_output_for(rect);

    if (output.size.width > geom::Width{0} && output.size.height > geom::Height{0} &&
        rect.size.width > geom::Width{0} && rect.size.height > geom::Height{0})
    {
        auto tl_closed = rect.top_left;
        auto br_closed = rect.bottom_right() - geom::Displacement{1,1};

        geom::Rectangles rectangles;
        rectangles.add(output);

        rectangles.confine(tl_closed);
        rectangles.confine(br_closed);

        rect.top_left = tl_closed;
        rect.size = as_size(br_closed - tl_closed + geom::Displacement{1, 1});
    }
    else
    {
        rect.size = geom::Size{0,0};
    }
}