VOID Buffer<T,Allocator>::Allocate(SIZE_T N) { if (m_pData) m_Allocator.Delete(m_pData); m_pData = m_Allocator.New(AllocateSize(N)); m_Length = N; }
void Window::HandleAdd( Widget::Ptr child ) { Bin::HandleAdd( child ); if( GetChild() ) { // Reset allocation so the window will be as large as required. AllocateSize( sf::FloatRect( GetAllocation().Left, GetAllocation().Top, 1.f, 1.f ) ); RequestSize(); } }
VOID Buffer<T,Allocator>::Resize(SIZE_T N) { SIZE_T NewLength = AllocateSize(N); T* pData = m_Allocator.New(NewLength); CopyObjects(pData, m_pData, Min(m_Length, NewLength)); m_Allocator.Delete(m_pData); m_pData = pData; m_Length = NewLength; }
// // AudioCBuffer() // AudioCBuffer::AudioCBuffer(UINT32 size) { ZeroMemory( &m_sourceFormat, sizeof( WAVEFORMATEX ) ); ZeroMemory( &m_renderFormat, sizeof( WAVEFORMATEX ) ); AllocateSize(size); front = 0; back = 0; m_sourceSampleSize = 0; m_renderSampleSize = 0; }
/****************************************************************** *StringBuffer::StringBuffer() *Purpose: * Sets up a string buffer with an initial size. * initial data members *Entry: * none *Exit: * ******************************************************************/ StringBuffer::StringBuffer(size_t cbInitialAllocationSize) { m_allocator = Allocator::None; m_allocSize = AllocSize::Normal; m_PowerOfTwo = grandeSize; m_wszStringPtr = (WCHAR *)m_rgbBuffer; m_cbMemory = sizeof(m_rgbBuffer); Clear(); AllocateSize(cbInitialAllocationSize); }
// // AudioCBuffer() // AudioCBuffer::AudioCBuffer(UINT32 size, WAVEFORMATEX* pSourceWfx, WAVEFORMATEX* pRenderWfx) { AllocateSize(size); front = 0; back = 0; CopyMemory(&m_sourceFormat, pSourceWfx, sizeof( WAVEFORMATEX)); CopyMemory(&m_renderFormat, pRenderWfx, sizeof( WAVEFORMATEX)); m_sourceSampleSize = 0; m_renderSampleSize = 0; SetFormatCalculations(); }
void Window::HandleMouseMoveEvent( int x, int y ) { if( m_dragging ) { SetPosition( sf::Vector2f( static_cast<float>( x ) - m_drag_offset.x, static_cast<float>( y ) - m_drag_offset.y ) ); } else if( m_resizing ) { AllocateSize( sf::FloatRect( GetAllocation().Left, GetAllocation().Top, std::max( GetRequisition().x, static_cast<float>( x ) + m_drag_offset.x - GetAllocation().Left ), std::max( GetRequisition().y, static_cast<float>( y ) + m_drag_offset.y - GetAllocation().Top ) ) ); } }
void Widget::RequestSize() const { m_recalc_requisition = true; Container::Ptr parent = m_parent.lock(); // Notify observers. OnSizeRequest(); if( parent ) { parent->RequestSize(); } else { sf::Vector2f requisition( GetRequisition() ); sf::FloatRect allocation( GetAllocation().Left, GetAllocation().Top, std::max( GetAllocation().Width, requisition.x ), std::max( GetAllocation().Height, requisition.y ) ); AllocateSize( allocation ); } }