void CFDE_TextOut::LoadEllipsis() { if (!m_bElliChanged) { return; } m_bElliChanged = FALSE; m_iEllipsisWidth = 0; int32_t iLength = m_wsEllipsis.GetLength(); if (iLength < 1) { return; } ExpandBuffer(iLength, 1); const FX_WCHAR* pStr = m_wsEllipsis.c_str(); uint32_t dwBreakStatus; FX_WCHAR wch; while (iLength-- > 0) { wch = *pStr++; dwBreakStatus = m_pTxtBreak->AppendChar(wch); if (dwBreakStatus > FX_TXTBREAK_PieceBreak) RetrieveEllPieces(&m_EllCharWidths); } dwBreakStatus = m_pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); if (dwBreakStatus > FX_TXTBREAK_PieceBreak) RetrieveEllPieces(&m_EllCharWidths); m_pTxtBreak->Reset(); }
void CFDE_TextOut::LoadText(const FX_WCHAR* pwsStr, int32_t iLength, const CFX_RectF& rect) { FX_WCHAR* pStr = m_wsText.GetBuffer(iLength); int32_t iTxtLength = iLength; ExpandBuffer(iTxtLength, 0); bool bHotKey = !!(m_dwStyles & FDE_TTOSTYLE_HotKey); bool bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout); bool bLineWrap = !!(m_dwStyles & FDE_TTOSTYLE_LineWrap); FX_FLOAT fLineStep = (m_fLineSpace > m_fFontSize) ? m_fLineSpace : m_fFontSize; FX_FLOAT fLineStop = bVertical ? rect.left : rect.bottom(); m_fLinePos = bVertical ? rect.right() : rect.top; if (bVertical) { fLineStep = -fLineStep; } m_hotKeys.RemoveAll(); int32_t iStartChar = 0; int32_t iChars = 0; int32_t iPieceWidths = 0; uint32_t dwBreakStatus; FX_WCHAR wch; bool bRet = false; while (iTxtLength-- > 0) { wch = *pwsStr++; if (bHotKey && wch == L'&' && *(pStr - 1) != L'&') { if (iTxtLength > 0) m_hotKeys.Add(iChars); continue; } *pStr++ = wch; iChars++; dwBreakStatus = m_pTxtBreak->AppendChar(wch); if (dwBreakStatus > FX_TXTBREAK_PieceBreak) { bool bEndofLine = RetriecePieces(dwBreakStatus, iStartChar, iPieceWidths, false, rect); if (bEndofLine && (bLineWrap || (dwBreakStatus > FX_TXTBREAK_LineBreak && !bLineWrap))) { iPieceWidths = 0; m_iCurLine++; m_fLinePos += fLineStep; } if ((bVertical && m_fLinePos + fLineStep < fLineStop) || (!bVertical && m_fLinePos + fLineStep > fLineStop)) { int32_t iCurLine = bEndofLine ? m_iCurLine - 1 : m_iCurLine; m_ttoLines[iCurLine].SetNewReload(true); bRet = true; break; } } } dwBreakStatus = m_pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak); if (dwBreakStatus > FX_TXTBREAK_PieceBreak && !bRet) { RetriecePieces(dwBreakStatus, iStartChar, iPieceWidths, false, rect); } m_pTxtBreak->ClearBreakPieces(); m_pTxtBreak->Reset(); m_wsText.ReleaseBuffer(iLength); }
int _Unpack(lua_State* L) { size_t sz = 0; void * buffer = GetBuffer(L, 1, &sz); void * output = lua_touserdata(L, lua_upvalueindex(1)); int osz = lua_tointeger(L, lua_upvalueindex(2)); int r = Zerounpack(buffer, sz, output, &osz); if (r < 0) return luaL_error(L, "Invalid unpack stream"); if (r > osz) { output = ExpandBuffer(L, osz, r); r = Zerounpack(buffer, sz, output, &r); if (r < 0) return luaL_error(L, "Invalid unpack stream"); } lua_pushlstring(L, (const char*)output, r); return 1; }
int _Pack(lua_State* L) { size_t sz = 0; void * buffer = GetBuffer(L, 1, &sz); size_t maxsz = (sz + 2047) / 2048 * 2 + sz; void * output = lua_touserdata(L, lua_upvalueindex(1)); int bytes; int osz = lua_tointeger(L, lua_upvalueindex(2)); if (osz < maxsz) output = ExpandBuffer(L, osz, maxsz); bytes = Zeropack(buffer, sz, output, maxsz); if (bytes > maxsz) return luaL_error(L, "packing error, return size = %d", bytes); lua_pushlstring(L, (const char*)output, bytes); return 1; }
int32_t CFDE_TextOut::GetDisplayPos(FDE_TTOPIECE* pPiece) { FX_TXTRUN tr = ToTextRun(pPiece); ExpandBuffer(tr.iLength, 2); return m_pTxtBreak->GetDisplayPos(&tr, m_CharPos.data()); }