LinearGradientPicker.cpp
// Insert a tick taking into account that the positions array must be sorted

Insert a tick taking into account that the positions array must be sorted
Insert a tick taking into account that the positions array must be sorted
void CLinearGradientPicker::InsertTick (COLORREF color, float fPosition)
{
	if (m_nNumColors >= MAX_TICKS)
		return;
	if (fPosition < 0.0 || fPosition > 1.0)
		return;
	if (fPosition == 0.0)
		m_nCurrentTick = 0;
	else if (fPosition == 1.0)
		m_nCurrentTick = m_nNumColors;
	for (int i = 0; i < m_nNumColors; i++)
		if (m_positions[i] > fPosition)
		{
			m_nCurrentTick = i;
			break;
		}
	for (int i = m_nNumColors - 1; i >= m_nCurrentTick; i--)
	{
		m_colors[i + 1] = m_colors[i];
		m_positions[i + 1] = m_positions[i];
	}
	m_colors[m_nCurrentTick] = Gdiplus::Color (GetRValue (color), GetGValue (color), GetBValue (color));
	m_positions[m_nCurrentTick] = fPosition;
	m_nNumColors++;
}
void CLinearGradientPicker :: InsertTick ( COLORREF color , float fPosition ) { if ( m_nNumColors >= MAX_TICKS ) return ; if ( fPosition < 0.0 || fPosition > 1.0 ) return ; if ( fPosition == 0.0 ) m_nCurrentTick = 0 ; else if ( fPosition == 1.0 ) m_nCurrentTick = m_nNumColors ; for ( int i = 0 ; i < m_nNumColors ; i ++ ) if ( m_positions [ i ] > fPosition ) { m_nCurrentTick = i ; break ; } for ( int i = m_nNumColors - 1 ; i >= m_nCurrentTick ; i -- ) { m_colors [ i + 1 ] = m_colors [ i ] ; m_positions [ i + 1 ] = m_positions [ i ] ; } m_colors [ m_nCurrentTick ] = Gdiplus :: Color ( GetRValue ( color ) , GetGValue ( color ) , GetBValue ( color ) ) ; m_positions [ m_nCurrentTick ] = fPosition ; m_nNumColors ++ ; }
Insert a tick taking into account that the positions array must be sorted
Insert a tick taking into account that the positions array must be sorted
// still place for another tick?
 // determine insertion position
 // move all ticks one to the right
 // new tick
