示例#1
0
CString	CCompileEditView::FindWord(CString strText,int& nStart,int nCount)
{
	if( strText.IsEmpty() || nStart > nCount )
		return "";

	CString strLeft  = strText.Left(nStart);
	CString strRight = strText.Mid(nStart);

	strLeft  = CutWord(strLeft,TRUE);
	nStart -= strLeft.GetLength();
	strRight = CutWord(strRight,FALSE);

	return strLeft+strRight;
}
示例#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);
	}

}