本文整理汇总了C++中CDrawPort::GetTextWidth2方法的典型用法代码示例。如果您正苦于以下问题:C++ CDrawPort::GetTextWidth2方法的具体用法?C++ CDrawPort::GetTextWidth2怎么用?C++ CDrawPort::GetTextWidth2使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDrawPort
的用法示例。
在下文中一共展示了CDrawPort::GetTextWidth2方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StringSplit
void StringSplit(std::vector<CTString>& vecOutput, CTString strInput, ULONG ulColumnWidth)
{
CDrawPort* pDrawPort = CUIManager::getSingleton()->GetDrawPort();
ULONG ulWidth = 0;
#if defined(G_RUSSIA)
ulWidth = UTIL_HELP()->GetNoFixedWidth(_pfdDefaultFont, strInput.str_String);
#else // defined(G_RUSSIA)
ulWidth = pDrawPort->GetTextWidth2(strInput);
#endif // defined(G_RUSSIA)
if (ulWidth <= ulColumnWidth)
{
strInput.TrimSpacesLeft();
strInput.TrimSpacesRight();
vecOutput.push_back(strInput);
return;
}
char szTemp[4];
int len = strInput.Length(), pos = 0;
ulWidth = 0;
for (int i = 0, j = 0; i < len; j = 0)
{
if (IsDBCSLeadByte(strInput[i]))
szTemp[j++] = strInput[i++];
szTemp[j++] = strInput[i++];
szTemp[j] = 0;
ULONG ulTempWidth = 0;
#if defined(G_RUSSIA)
ulTempWidth = UTIL_HELP()->GetNoFixedWidth(_pfdDefaultFont, szTemp);
#else // defined(G_RUSSIA)
ulTempWidth = pDrawPort->GetTextWidth2(szTemp);
#endif // defined(G_RUSSIA)
if (ulWidth + ulTempWidth > ulColumnWidth &&
!(j == 1 && (szTemp[0] == '.' || szTemp[0] == ',' || szTemp[0] == ' ')))
break;
pos = i;
ulWidth += ulTempWidth;
if( strInput[pos] == '\n' || strInput[pos] == '\r' )
{
pos++;
break;
}
}
CTString strLeft, strRight;
strInput.Split(pos, strLeft, strRight);
strLeft.TrimSpacesLeft();
strLeft.TrimSpacesRight();
vecOutput.push_back(strLeft);
if (strRight.Length() > 0)
StringSplit(vecOutput, strRight, ulColumnWidth);
}
示例2: updateUI
void CUIPortal::updateUI()
{
if (m_pList == NULL)
return;
m_pList->DeleteAllListItem();
int nMax = m_vectorListInfo.size();
if (nMax <= 0)
return;
CUIListItem* pTemp = m_pList->GetListItemTemplate();
if (pTemp == NULL)
return;
CUIListItem* pItem = NULL;
CUIText* pText = NULL;
CTString strTemp;
CDrawPort* pDrawPort = CUIManager::getSingleton()->GetDrawPort();
for( int i = 0; i < nMax; i++ )
{
m_pList->AddListItem(pTemp->Clone());
pItem = (CUIListItem*)m_pList->GetListItem(i);
if (pItem == NULL)
return;
{
CmdPortalMouseEvent* pCmd = new CmdPortalMouseEvent;
pCmd->setData(this, pItem, 0xF8E1B5FF);
pItem->SetCommandEnter(pCmd);
}
{
CmdPortalMouseEvent* pCmd = new CmdPortalMouseEvent;
pCmd->setData(this, pItem, 0xC0C0C0FF);
pItem->SetCommandLeave(pCmd);
}
pText = (CUIText*)pItem->findUI("txt_zone");
if (pText != NULL)
{
strTemp.PrintF("%s", CZoneInfo::getSingleton()->GetZoneName( m_vectorListInfo[i].zone ) );
ULONG nStringWidth = pDrawPort->GetTextWidth2(strTemp);
if (nStringWidth > pText->GetWidth())
{
pText->setTooltip(strTemp);
strTemp = UtilHelp::getSingleton()->GetCalcStringEllipsis(strTemp, pText->GetWidth(), CTString("..."));
}
pText->SetText(strTemp);
}
pText = (CUIText*)pItem->findUI("txt_pos");
if (pText != NULL)
{
strTemp.PrintF("%s", CZoneInfo::getSingleton()->GetExtraName( m_vectorListInfo[i].zone, m_vectorListInfo[i].extra ) );
ULONG nStringWidth = pDrawPort->GetTextWidth2(strTemp);
if (nStringWidth > pText->GetWidth())
{
pText->setTooltip(strTemp);
strTemp = UtilHelp::getSingleton()->GetCalcStringEllipsis(strTemp, pText->GetWidth(), CTString("..."));
}
pText->SetText(strTemp);
}
}
m_pList->UpdateList();
}