本文整理汇总了C++中CFX_RectF::Width方法的典型用法代码示例。如果您正苦于以下问题:C++ CFX_RectF::Width方法的具体用法?C++ CFX_RectF::Width怎么用?C++ CFX_RectF::Width使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFX_RectF
的用法示例。
在下文中一共展示了CFX_RectF::Width方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnDraw
void CFDE_TextOut::OnDraw(const CFX_RectF& rtClip) {
if (!m_pRenderDevice)
return;
int32_t iLines = m_ttoLines.GetSize();
if (iLines < 1)
return;
CFDE_Brush* pBrush = new CFDE_Brush;
pBrush->SetColor(m_TxtColor);
CFDE_Pen* pPen = nullptr;
m_pRenderDevice->SaveState();
if (rtClip.Width() > 0.0f && rtClip.Height() > 0.0f) {
m_pRenderDevice->SetClipRect(rtClip);
}
for (int32_t i = 0; i < iLines; i++) {
CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(i);
int32_t iPieces = pLine->GetSize();
for (int32_t j = 0; j < iPieces; j++) {
FDE_TTOPIECE* pPiece = pLine->GetPtrAt(j);
if (!pPiece)
continue;
int32_t iCount = GetDisplayPos(pPiece);
if (iCount > 0) {
m_pRenderDevice->DrawString(pBrush, m_pFont, m_CharPos.data(), iCount,
m_fFontSize, &m_Matrix);
}
DrawLine(pPiece, pPen);
}
}
m_pRenderDevice->RestoreState();
delete pBrush;
delete pPen;
}
示例2: OnDraw
void CFDE_TextOut::OnDraw(const CFX_RectF& rtClip) {
if (!m_pRenderDevice || m_ttoLines.empty())
return;
auto pBrush = pdfium::MakeUnique<CFDE_Brush>();
pBrush->SetColor(m_TxtColor);
m_pRenderDevice->SaveState();
if (rtClip.Width() > 0.0f && rtClip.Height() > 0.0f)
m_pRenderDevice->SetClipRect(rtClip);
auto pPen = pdfium::MakeUnique<CFDE_Pen>();
pPen->SetColor(m_TxtColor);
for (auto& line : m_ttoLines) {
int32_t iPieces = line.GetSize();
for (int32_t j = 0; j < iPieces; j++) {
FDE_TTOPIECE* pPiece = line.GetPtrAt(j);
if (!pPiece)
continue;
int32_t iCount = GetDisplayPos(pPiece);
if (iCount > 0) {
m_pRenderDevice->DrawString(pBrush.get(), m_pFont, m_CharPos.data(),
iCount, m_fFontSize, &m_Matrix);
}
DrawLine(pPiece, pPen.get());
}
}
m_pRenderDevice->RestoreState();
}
示例3: SetLineWidth
void CFDE_TextOut::SetLineWidth(CFX_RectF& rect) {
if ((m_dwStyles & FDE_TTOSTYLE_SingleLine) == 0) {
FX_FLOAT fLineWidth = 0.0f;
if (m_dwStyles & FDE_TTOSTYLE_VerticalLayout) {
if (rect.Height() < 1.0f) {
rect.height = m_fFontSize * 1000.0f;
}
fLineWidth = rect.Height();
} else {
if (rect.Width() < 1.0f) {
rect.width = m_fFontSize * 1000.0f;
}
fLineWidth = rect.Width();
}
m_pTxtBreak->SetLineWidth(fLineWidth);
}
}
示例4: CalcLogicSize
void CFDE_TextOut::CalcLogicSize(const FX_WCHAR* pwsStr,
int32_t iLength,
CFX_SizeF& size) {
CFX_RectF rtText;
rtText.Set(0.0f, 0.0f, size.x, size.y);
CalcLogicSize(pwsStr, iLength, rtText);
size.x = rtText.Width();
size.y = rtText.Height();
}
示例5: CalcSize
void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr,
int32_t iLength,
CFX_Size& size) {
CFX_RectF rtText;
rtText.Set(0.0f, 0.0f, (FX_FLOAT)size.x, (FX_FLOAT)size.y);
CalcSize(pwsStr, iLength, rtText);
size.x = (int32_t)rtText.Width();
size.y = (int32_t)rtText.Height();
}
示例6: CalcWidgetWidth
void CFWL_GridImp::CalcWidgetWidth(IFWL_Widget* pWidget,
CFWL_GridWidgetInfo* pInfo,
FX_FLOAT fColunmWidth) {
if (pInfo->m_Size[FWL_GRIDSIZE_Width].eUnit == FWL_GRIDUNIT_Fixed) {
SetWidgetActualWidth(pInfo, pInfo->m_Size[FWL_GRIDSIZE_Width].fLength);
} else {
FX_FLOAT fWidth = 0;
FX_FLOAT fLeftMargin = 0, fRightMargin = 0;
FX_BOOL bLeftMargin =
GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Left, fLeftMargin);
FX_BOOL bRightMargin =
GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Right, fRightMargin);
if (bLeftMargin && bRightMargin) {
fWidth = fColunmWidth - fLeftMargin - fRightMargin;
} else {
CFX_RectF rtAuto;
pWidget->GetWidgetRect(rtAuto, TRUE);
fWidth = rtAuto.Width();
}
SetWidgetActualWidth(pInfo, fWidth);
}
}
示例7: RetriecePieces
FX_BOOL CFDE_TextOut::RetriecePieces(uint32_t dwBreakStatus,
int32_t& iStartChar,
int32_t& iPieceWidths,
FX_BOOL bReload,
const CFX_RectF& rect) {
FX_BOOL bSingleLine = !!(m_dwStyles & FDE_TTOSTYLE_SingleLine);
FX_BOOL bLineWrap = !!(m_dwStyles & FDE_TTOSTYLE_LineWrap);
FX_BOOL bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout);
FX_FLOAT fLineStep =
(m_fLineSpace > m_fFontSize) ? m_fLineSpace : m_fFontSize;
if (bVertical) {
fLineStep = -fLineStep;
}
CFX_Char* pTC = nullptr;
FX_BOOL bNeedReload = FALSE;
FX_FLOAT fLineWidth = bVertical ? rect.Height() : rect.Width();
int32_t iLineWidth = FXSYS_round(fLineWidth * 20000.0f);
int32_t iCount = m_pTxtBreak->CountBreakPieces();
for (int32_t i = 0; i < iCount; i++) {
const CFX_TxtPiece* pPiece = m_pTxtBreak->GetBreakPiece(i);
int32_t iPieceChars = pPiece->GetLength();
int32_t iChar = iStartChar;
int32_t iWidth = 0;
int32_t j = 0;
for (; j < iPieceChars; j++) {
pTC = pPiece->GetCharPtr(j);
int32_t iCurCharWidth = pTC->m_iCharWidth > 0 ? pTC->m_iCharWidth : 0;
if (bSingleLine || !bLineWrap) {
if (iLineWidth - iPieceWidths - iWidth < iCurCharWidth) {
bNeedReload = TRUE;
break;
}
}
iWidth += iCurCharWidth;
m_CharWidths[iChar++] = iCurCharWidth;
}
if (j == 0 && !bReload) {
CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(m_iCurLine);
pLine->m_bNewReload = TRUE;
} else if (j > 0) {
CFX_RectF rtPiece;
if (bVertical) {
rtPiece.left = m_fLinePos;
rtPiece.top = rect.top + (FX_FLOAT)pPiece->m_iStartPos / 20000.0f;
rtPiece.width = fLineStep;
rtPiece.height = iWidth / 20000.0f;
} else {
rtPiece.left = rect.left + (FX_FLOAT)pPiece->m_iStartPos / 20000.0f;
rtPiece.top = m_fLinePos;
rtPiece.width = iWidth / 20000.0f;
rtPiece.height = fLineStep;
}
FDE_TTOPIECE ttoPiece;
ttoPiece.iStartChar = iStartChar;
ttoPiece.iChars = j;
ttoPiece.rtPiece = rtPiece;
ttoPiece.dwCharStyles = pPiece->m_dwCharStyles;
if (FX_IsOdd(pPiece->m_iBidiLevel)) {
ttoPiece.dwCharStyles |= FX_TXTCHARSTYLE_OddBidiLevel;
}
AppendPiece(ttoPiece, bNeedReload, (bReload && i == iCount - 1));
}
iStartChar += iPieceChars;
iPieceWidths += iWidth;
}
m_pTxtBreak->ClearBreakPieces();
FX_BOOL bRet = bSingleLine || bLineWrap || (!bLineWrap && bNeedReload) ||
dwBreakStatus == FX_TXTBREAK_ParagraphBreak;
return bRet;
}
示例8: CalcTextSize
void CFDE_TextOut::CalcTextSize(const FX_WCHAR* pwsStr,
int32_t iLength,
CFX_RectF& rect) {
ASSERT(m_pFont && m_fFontSize >= 1.0f);
SetLineWidth(rect);
m_iTotalLines = 0;
const FX_WCHAR* pStr = pwsStr;
FX_BOOL bHotKey = !!(m_dwStyles & FDE_TTOSTYLE_HotKey);
FX_BOOL bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout);
FX_FLOAT fWidth = 0.0f;
FX_FLOAT fHeight = 0.0f;
FX_FLOAT fStartPos = bVertical ? rect.bottom() : rect.right();
uint32_t dwBreakStatus = 0;
FX_WCHAR wPreChar = 0;
FX_WCHAR wch;
FX_WCHAR wBreak = 0;
while (iLength-- > 0) {
wch = *pStr++;
if (wBreak == 0 && (wch == L'\n' || wch == L'\r')) {
wBreak = wch;
m_pTxtBreak->SetParagraphBreakChar(wch);
}
if (bHotKey && wch == L'&' && wPreChar != L'&') {
wPreChar = wch;
continue;
}
dwBreakStatus = m_pTxtBreak->AppendChar(wch);
if (dwBreakStatus > FX_TXTBREAK_PieceBreak) {
RetrieveLineWidth(dwBreakStatus, fStartPos, fWidth, fHeight);
}
wPreChar = 0;
}
dwBreakStatus = m_pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak);
if (dwBreakStatus > FX_TXTBREAK_PieceBreak) {
RetrieveLineWidth(dwBreakStatus, fStartPos, fWidth, fHeight);
}
m_pTxtBreak->Reset();
FX_FLOAT fInc = rect.Height() - fHeight;
if (bVertical) {
fInc = rect.Width() - fHeight;
}
if (m_iAlignment >= FDE_TTOALIGNMENT_CenterLeft &&
m_iAlignment < FDE_TTOALIGNMENT_BottomLeft) {
fInc /= 2.0f;
} else if (m_iAlignment < FDE_TTOALIGNMENT_CenterLeft) {
fInc = 0.0f;
}
if (bVertical) {
rect.top += fStartPos;
rect.left += fInc;
rect.width = fHeight;
rect.height = std::min(fWidth, rect.Height());
} else {
rect.left += fStartPos;
rect.top += fInc;
rect.width = std::min(fWidth, rect.Width());
rect.height = fHeight;
if (m_dwStyles & FDE_TTOSTYLE_LastLineHeight) {
rect.height -= m_fLineSpace - m_fFontSize;
}
}
}