Пример #1
0
void Table::Attach( Widget::Ptr widget, const sf::Rect<sf::Uint32>& rect, int x_options, int y_options, const sf::Vector2f& padding ) {
	assert( rect.Width > 0 );
	assert( rect.Height > 0 );

	// Store widget in a table cell object.
	priv::TableCell cell( widget, rect, x_options, y_options, padding );
	m_cells.push_back( cell );

	// Check if we need to enlarge rows/columns.
	if( rect.Left + rect.Width >= m_columns.size() ) {
		std::size_t old_size( m_columns.size() );
		m_columns.resize( rect.Left + rect.Width );

		// Set default spacings.
		for( std::size_t col_index = old_size; col_index < m_columns.size(); ++col_index ) {
			m_columns[col_index].spacing = m_general_spacings.x;
		}
	}

	if( rect.Top + rect.Height >= m_rows.size() ) {
		std::size_t old_size( m_rows.size() );
		m_rows.resize( rect.Top + rect.Height );

		// Set default spacings.
		for( std::size_t row_index = old_size; row_index < m_rows.size(); ++row_index ) {
			m_rows[row_index].spacing = m_general_spacings.y;
		}
	}

	// Add widget to container.
	Add( widget );

	// Request new size.
	RequestSize();
}
        void* realloc (void* ptr, ssize_t size)
        {
            BufferHeader* bh(0);
            ssize_t old_size(0);

            if (ptr)
            {
                bh = ptr2BH(ptr);
                assert (SEQNO_NONE == bh->seqno_g);
                old_size = bh->size;
            }

            ssize_t const diff_size(size - old_size);

            if (size > max_size_ ||
                have_free_space(diff_size) == false) return 0;

            assert (size_ + diff_size <= max_size_);

            void* tmp = ::realloc (bh, size);

            if (tmp)
            {
                allocd_.erase(bh);
                allocd_.insert(tmp);

                bh = BH_cast(tmp);
                assert (bh->size == old_size);
                bh->size  = size;

                size_ += diff_size;

                return (bh + 1);
            }

            return 0;
        }