/**************************************************
//
//创建并加入停靠行信息
//	参数:
//		prev:前一行信息
//
**************************************************/
LPRINGBARLINEINFO RingDockSite::AddLine(LPRINGBARLINEINFO prev)
{
	LPRINGBARLINEINFO addline = GetEmptyLine();
	if(addline)
	{
		addline->isVisible = TRUE;
		addline->m_maxSize = 0;
		addline->m_first = NULL;
		SetRectEmpty(&addline->m_SplitRc);

		if(prev == NULL)
		{
			//加到最前
			prev = m_First;
			m_First = addline;
			addline->m_nextline = prev;
			addline->m_pos = 0;
		}
		else
		{
			addline->m_nextline = prev->m_nextline;
			prev->m_nextline = addline;
			addline->m_pos = prev->m_pos + prev->m_maxSize;
			if(prev->m_SplitRc.right != 0 &&	(m_State & 1) == 0)			
				addline->m_pos += m_SplitterSize;
		}
	}
	return addline;
}
Exemple #2
0
const CUILine* CUILine::CutByLength(CGameFont* pFont, float length, BOOL cut_word)
{
	R_ASSERT(GetSize() > 0);
	// if first sub line is void then delete it

	Position pos;
	InitPos(pos);

	if (!pos.word_1.exist()) // void string
	{
		if (m_subLines[0].m_last_in_line)
		{
			m_subLines.erase(m_subLines.begin());
			return GetEmptyLine();
		}
		else
		{
			m_subLines.erase(m_subLines.begin());
			InitPos(pos);
		}
	}


	float len2w1 = GetLength_inclusiveWord_1(pos, pFont);
//.	* scale; bacause of our fonts not scaled

    if (!pos.word_2.exist())
	{
		if (cut_word && len2w1 > length)
			return CutWord(pFont, length);		
		else
			return Cut2Pos(pos);
	}

	
	float len2w2 = GetLength_inclusiveWord_2(pos, pFont);

	if (len2w1 > length)
	{
		if (cut_word)
            return CutWord(pFont, length);		
		else
            return Cut2Pos(pos);
	}
	else if (len2w1 <= length && len2w2 > length)
	{
		// cut whole first word
		return Cut2Pos(pos);  // all right :)
	}
	else // if (len2w1 > length && len2w2 > length)
	{
		while (IncPos(pos))
		{
			len2w1 = GetLength_inclusiveWord_1(pos, pFont);
			if(!pos.word_2.exist())
			{
				return Cut2Pos(pos);
			}
			len2w2 = GetLength_inclusiveWord_2(pos, pFont);
			if (len2w1 <= length && len2w2 > length)
				return Cut2Pos(pos);
		}
     
		return Cut2Pos(pos, false);
	}

}