diff options
Diffstat (limited to 'xfa')
29 files changed, 290 insertions, 394 deletions
diff --git a/xfa/fde/cfde_txtedtdorecord_deleterange.cpp b/xfa/fde/cfde_txtedtdorecord_deleterange.cpp index 12ab203539..d1682ddccd 100644 --- a/xfa/fde/cfde_txtedtdorecord_deleterange.cpp +++ b/xfa/fde/cfde_txtedtdorecord_deleterange.cpp @@ -36,7 +36,7 @@ bool CFDE_TxtEdtDoRecord_DeleteRange::Undo() const { FDE_TXTEDTPARAMS& Param = m_pEngine->m_Param; m_pEngine->m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Insert; m_pEngine->m_ChangeInfo.wsDelete = m_wsRange; - Param.pEventSink->On_TextChanged(m_pEngine, m_pEngine->m_ChangeInfo); + Param.pEventSink->OnTextChanged(m_pEngine->m_ChangeInfo); m_pEngine->SetCaretPos(m_nCaret, true); return true; } @@ -49,7 +49,7 @@ bool CFDE_TxtEdtDoRecord_DeleteRange::Redo() const { FDE_TXTEDTPARAMS& Param = m_pEngine->m_Param; m_pEngine->m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Insert; m_pEngine->m_ChangeInfo.wsDelete = m_wsRange; - Param.pEventSink->On_TextChanged(m_pEngine, m_pEngine->m_ChangeInfo); + Param.pEventSink->OnTextChanged(m_pEngine->m_ChangeInfo); m_pEngine->SetCaretPos(m_nIndex, true); return true; } diff --git a/xfa/fde/cfde_txtedtdorecord_insert.cpp b/xfa/fde/cfde_txtedtdorecord_insert.cpp index 3ea9269cb9..e659f020ca 100644 --- a/xfa/fde/cfde_txtedtdorecord_insert.cpp +++ b/xfa/fde/cfde_txtedtdorecord_insert.cpp @@ -31,7 +31,7 @@ bool CFDE_TxtEdtDoRecord_Insert::Undo() const { FDE_TXTEDTPARAMS& Param = m_pEngine->m_Param; m_pEngine->m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Delete; m_pEngine->m_ChangeInfo.wsDelete = m_wsInsert; - Param.pEventSink->On_TextChanged(m_pEngine, m_pEngine->m_ChangeInfo); + Param.pEventSink->OnTextChanged(m_pEngine->m_ChangeInfo); m_pEngine->SetCaretPos(m_nCaret, true); return true; } @@ -41,7 +41,7 @@ bool CFDE_TxtEdtDoRecord_Insert::Redo() const { FDE_TXTEDTPARAMS& Param = m_pEngine->m_Param; m_pEngine->m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Insert; m_pEngine->m_ChangeInfo.wsDelete = m_wsInsert; - Param.pEventSink->On_TextChanged(m_pEngine, m_pEngine->m_ChangeInfo); + Param.pEventSink->OnTextChanged(m_pEngine->m_ChangeInfo); m_pEngine->SetCaretPos(m_nCaret, false); return true; } diff --git a/xfa/fde/cfde_txtedtengine.cpp b/xfa/fde/cfde_txtedtengine.cpp index d9e321f382..6e113e1738 100644 --- a/xfa/fde/cfde_txtedtengine.cpp +++ b/xfa/fde/cfde_txtedtengine.cpp @@ -8,6 +8,7 @@ #include <algorithm> +#include "third_party/base/ptr_util.h" #include "xfa/fde/cfde_txtedtbuf.h" #include "xfa/fde/cfde_txtedtbufiter.h" #include "xfa/fde/cfde_txtedtdorecord_deleterange.h" @@ -207,7 +208,7 @@ int32_t CFDE_TxtEdtEngine::SetCaretPos(int32_t nIndex, bool bBefore) { m_fCaretPosReserve = (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical) ? m_rtCaret.top : m_rtCaret.left; - m_Param.pEventSink->On_CaretChanged(this, m_nCaretPage, 0); + m_Param.pEventSink->OnCaretChanged(); m_nAnchorPos = -1; return m_nCaret; } @@ -323,11 +324,11 @@ int32_t CFDE_TxtEdtEngine::MoveCaretPos(FDE_TXTEDTMOVECARET eMoveCaret, if (bShift && m_nAnchorPos != -1 && (m_nAnchorPos != m_nCaret)) { AddSelRange(std::min(m_nAnchorPos, m_nCaret), FXSYS_abs(m_nAnchorPos - m_nCaret)); - m_Param.pEventSink->On_SelChanged(this); - } - if (bSelChange) { - m_Param.pEventSink->On_SelChanged(this); + m_Param.pEventSink->OnSelChanged(); } + if (bSelChange) + m_Param.pEventSink->OnSelChanged(); + return m_nCaret; } @@ -406,19 +407,18 @@ int32_t CFDE_TxtEdtEngine::Insert(int32_t nStart, } if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) { CFX_WideString wsText = GetPreInsertText(m_nCaret, lpBuffer, nLength); - if (!m_Param.pEventSink->On_Validate(this, wsText)) { + if (!m_Param.pEventSink->OnValidate(wsText)) return FDE_TXTEDT_MODIFY_RET_F_Invalidate; - } } if (IsSelect()) { DeleteSelect(); } if (!(m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo)) - m_Param.pEventSink->On_AddDoRecord( - this, - new CFDE_TxtEdtDoRecord_Insert(this, m_nCaret, lpBuffer, nLength)); + m_Param.pEventSink->OnAddDoRecord( + pdfium::MakeUnique<CFDE_TxtEdtDoRecord_Insert>(this, m_nCaret, lpBuffer, + nLength)); - m_ChangeInfo.wsPrevText = GetText(0); + m_ChangeInfo.wsPrevText = GetText(0, -1); Inner_Insert(m_nCaret, lpBuffer, nLength); m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Insert; m_ChangeInfo.wsInsert = CFX_WideString(lpBuffer, nLength); @@ -431,7 +431,7 @@ int32_t CFDE_TxtEdtEngine::Insert(int32_t nStart, bBefore = false; } SetCaretPos(nStart, bBefore); - m_Param.pEventSink->On_TextChanged(this, m_ChangeInfo); + m_Param.pEventSink->OnTextChanged(m_ChangeInfo); return bPart ? FDE_TXTEDT_MODIFY_RET_S_Part : FDE_TXTEDT_MODIFY_RET_S_Normal; } @@ -467,43 +467,38 @@ int32_t CFDE_TxtEdtEngine::Delete(int32_t nStart, bool bBackspace) { } if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) { CFX_WideString wsText = GetPreDeleteText(nStart, nCount); - if (!m_Param.pEventSink->On_Validate(this, wsText)) { + if (!m_Param.pEventSink->OnValidate(wsText)) return FDE_TXTEDT_MODIFY_RET_F_Invalidate; - } } if (!(m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo)) { CFX_WideString wsRange = m_pTxtBuf->GetRange(nStart, nCount); - m_Param.pEventSink->On_AddDoRecord( - this, - new CFDE_TxtEdtDoRecord_DeleteRange(this, nStart, m_nCaret, wsRange)); + m_Param.pEventSink->OnAddDoRecord( + pdfium::MakeUnique<CFDE_TxtEdtDoRecord_DeleteRange>(this, nStart, + m_nCaret, wsRange)); } m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Delete; m_ChangeInfo.wsDelete = GetText(nStart, nCount); Inner_DeleteRange(nStart, nCount); SetCaretPos(nStart + ((!bBackspace && nStart > 0) ? -1 : 0), (bBackspace || nStart == 0)); - m_Param.pEventSink->On_TextChanged(this, m_ChangeInfo); + m_Param.pEventSink->OnTextChanged(m_ChangeInfo); return FDE_TXTEDT_MODIFY_RET_S_Normal; } int32_t CFDE_TxtEdtEngine::DeleteRange(int32_t nStart, int32_t nCount) { - if (IsLocked()) { + if (IsLocked()) return FDE_TXTEDT_MODIFY_RET_F_Locked; - } - if (nCount == -1) { + if (nCount == -1) nCount = GetTextBufLength(); - } - if (nCount == 0) { + if (nCount == 0) return FDE_TXTEDT_MODIFY_RET_S_Normal; - } if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) { CFX_WideString wsText = GetPreDeleteText(nStart, nCount); - if (!m_Param.pEventSink->On_Validate(this, wsText)) { + if (!m_Param.pEventSink->OnValidate(wsText)) return FDE_TXTEDT_MODIFY_RET_F_Invalidate; - } } DeleteRange_DoRecord(nStart, nCount); - m_Param.pEventSink->On_TextChanged(this, m_ChangeInfo); + m_Param.pEventSink->OnTextChanged(m_ChangeInfo); SetCaretPos(nStart, true); return FDE_TXTEDT_MODIFY_RET_S_Normal; } @@ -511,31 +506,28 @@ int32_t CFDE_TxtEdtEngine::DeleteRange(int32_t nStart, int32_t nCount) { int32_t CFDE_TxtEdtEngine::Replace(int32_t nStart, int32_t nLength, const CFX_WideString& wsReplace) { - if (IsLocked()) { + if (IsLocked()) return FDE_TXTEDT_MODIFY_RET_F_Locked; - } - if (nStart < 0 || (nStart + nLength > GetTextBufLength())) { + if (nStart < 0 || (nStart + nLength > GetTextBufLength())) return FDE_TXTEDT_MODIFY_RET_F_Boundary; - } if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) { CFX_WideString wsText = GetPreReplaceText( nStart, nLength, wsReplace.c_str(), wsReplace.GetLength()); - if (!m_Param.pEventSink->On_Validate(this, wsText)) { + if (!m_Param.pEventSink->OnValidate(wsText)) return FDE_TXTEDT_MODIFY_RET_F_Invalidate; - } } - if (IsSelect()) { + if (IsSelect()) ClearSelection(); - } + m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Replace; m_ChangeInfo.wsDelete = GetText(nStart, nLength); - if (nLength > 0) { + if (nLength > 0) Inner_DeleteRange(nStart, nLength); - } + int32_t nTextLength = wsReplace.GetLength(); - if (nTextLength > 0) { + if (nTextLength > 0) Inner_Insert(nStart, wsReplace.c_str(), nTextLength); - } + m_ChangeInfo.wsInsert = CFX_WideString(wsReplace.c_str(), nTextLength); nStart += nTextLength; FX_WCHAR wChar = m_pTxtBuf->GetCharByIndex(nStart - 1); @@ -545,9 +537,9 @@ int32_t CFDE_TxtEdtEngine::Replace(int32_t nStart, bBefore = false; } SetCaretPos(nStart, bBefore); - m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0); - m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0); - m_Param.pEventSink->On_TextChanged(this, m_ChangeInfo); + m_Param.pEventSink->OnPageUnload(m_nCaretPage); + m_Param.pEventSink->OnPageLoad(m_nCaretPage); + m_Param.pEventSink->OnTextChanged(m_ChangeInfo); return FDE_TXTEDT_MODIFY_RET_S_Normal; } @@ -583,7 +575,7 @@ void CFDE_TxtEdtEngine::AddSelRange(int32_t nStart, int32_t nCount) { lpSelRange->nStart = nStart; lpSelRange->nCount = nCount; m_SelRangePtrArr.Add(lpSelRange); - m_Param.pEventSink->On_SelChanged(this); + m_Param.pEventSink->OnSelChanged(); return; } FDE_TXTEDTSELRANGE* lpTemp = nullptr; @@ -593,7 +585,7 @@ void CFDE_TxtEdtEngine::AddSelRange(int32_t nStart, int32_t nCount) { lpSelRange->nStart = nStart; lpSelRange->nCount = nCount; m_SelRangePtrArr.Add(lpSelRange); - m_Param.pEventSink->On_SelChanged(this); + m_Param.pEventSink->OnSelChanged(); return; } int32_t nEnd = nStart + nCount - 1; @@ -639,15 +631,16 @@ void CFDE_TxtEdtEngine::AddSelRange(int32_t nStart, int32_t nCount) { m_SelRangePtrArr.RemoveAt(nRangeBgn); } } - m_Param.pEventSink->On_SelChanged(this); + m_Param.pEventSink->OnSelChanged(); } int32_t CFDE_TxtEdtEngine::CountSelRanges() const { return m_SelRangePtrArr.GetSize(); } -int32_t CFDE_TxtEdtEngine::GetSelRange(int32_t nIndex, int32_t& nStart) const { - nStart = m_SelRangePtrArr[nIndex]->nStart; +int32_t CFDE_TxtEdtEngine::GetSelRange(int32_t nIndex, int32_t* nStart) const { + if (nStart) + *nStart = m_SelRangePtrArr[nIndex]->nStart; return m_SelRangePtrArr[nIndex]->nCount; } @@ -657,7 +650,7 @@ void CFDE_TxtEdtEngine::ClearSelection() { delete m_SelRangePtrArr[i]; m_SelRangePtrArr.RemoveAll(); if (nCount && m_Param.pEventSink) - m_Param.pEventSink->On_SelChanged(this); + m_Param.pEventSink->OnSelChanged(); } bool CFDE_TxtEdtEngine::Redo(const IFDE_TxtEdtDoRecord* pDoRecord) { @@ -787,7 +780,7 @@ CFX_WideString CFDE_TxtEdtEngine::GetPreInsertText(int32_t nIndex, int32_t nSelLength = 0; int32_t nSelCount = CountSelRanges(); while (nSelCount--) { - nSelLength = GetSelRange(nSelCount, nSelIndex); + nSelLength = GetSelRange(nSelCount, &nSelIndex); wsText.Delete(nSelIndex, nSelLength); nIndex = nSelIndex; } @@ -813,7 +806,7 @@ CFX_WideString CFDE_TxtEdtEngine::GetPreReplaceText(int32_t nIndex, int32_t nSelLength = 0; int32_t nSelCount = CountSelRanges(); while (nSelCount--) { - nSelLength = GetSelRange(nSelCount, nSelIndex); + nSelLength = GetSelRange(nSelCount, &nSelIndex); wsText.Delete(nSelIndex, nSelLength); } wsText.Delete(nIndex, nOriginLength); @@ -830,7 +823,7 @@ void CFDE_TxtEdtEngine::Inner_Insert(int32_t nStart, ASSERT(nLength > 0); FDE_TXTEDTPARAGPOS ParagPos; TextPos2ParagPos(nStart, ParagPos); - m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0); + m_Param.pEventSink->OnPageUnload(m_nCaretPage); int32_t nParagCount = m_ParagPtrArray.GetSize(); int32_t i = 0; for (i = ParagPos.nParagIndex + 1; i < nParagCount; i++) @@ -884,7 +877,7 @@ void CFDE_TxtEdtEngine::Inner_Insert(int32_t nStart, nTotalLineCount += pParag->GetLineCount(); } m_nLineCount += nTotalLineCount - nReserveLineCount; - m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0); + m_Param.pEventSink->OnPageLoad(m_nCaretPage); UpdatePages(); } @@ -894,7 +887,7 @@ void CFDE_TxtEdtEngine::Inner_DeleteRange(int32_t nStart, int32_t nCount) { } int32_t nEnd = nStart + nCount - 1; ASSERT(nStart >= 0 && nEnd < m_pTxtBuf->GetTextLength()); - m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0); + m_Param.pEventSink->OnPageUnload(m_nCaretPage); FDE_TXTEDTPARAGPOS ParagPosBgn, ParagPosEnd; TextPos2ParagPos(nStart, ParagPosBgn); TextPos2ParagPos(nEnd, ParagPosEnd); @@ -940,7 +933,7 @@ void CFDE_TxtEdtEngine::Inner_DeleteRange(int32_t nStart, int32_t nCount) { if (m_nCaretPage >= nPageCount) { m_nCaretPage = nPageCount - 1; } - m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0); + m_Param.pEventSink->OnPageLoad(m_nCaretPage); } void CFDE_TxtEdtEngine::DeleteRange_DoRecord(int32_t nStart, @@ -954,9 +947,9 @@ void CFDE_TxtEdtEngine::DeleteRange_DoRecord(int32_t nStart, if (!(m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo)) { CFX_WideString wsRange = m_pTxtBuf->GetRange(nStart, nCount); - m_Param.pEventSink->On_AddDoRecord( - this, new CFDE_TxtEdtDoRecord_DeleteRange(this, nStart, m_nCaret, - wsRange, bSel)); + m_Param.pEventSink->OnAddDoRecord( + pdfium::MakeUnique<CFDE_TxtEdtDoRecord_DeleteRange>( + this, nStart, m_nCaret, wsRange, bSel)); } m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Delete; m_ChangeInfo.wsDelete = GetText(nStart, nCount); @@ -1235,14 +1228,14 @@ int32_t CFDE_TxtEdtEngine::MovePage2Char(int32_t nIndex) { ASSERT(nIndex <= m_pTxtBuf->GetTextLength()); if (m_nCaretPage >= 0) { IFDE_TxtEdtPage* pPage = m_PagePtrArray[m_nCaretPage]; - m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0); + m_Param.pEventSink->OnPageLoad(m_nCaretPage); int32_t nPageCharStart = pPage->GetCharStart(); int32_t nPageCharCount = pPage->GetCharCount(); if (nIndex >= nPageCharStart && nIndex < nPageCharStart + nPageCharCount) { - m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0); + m_Param.pEventSink->OnPageUnload(m_nCaretPage); return m_nCaretPage; } - m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0); + m_Param.pEventSink->OnPageUnload(m_nCaretPage); } CFDE_TxtEdtParag* pParag = nullptr; int32_t nLineCount = 0; @@ -1552,7 +1545,7 @@ void CFDE_TxtEdtEngine::UpdateCaretRect(int32_t nIndex, bool bBefore) { m_fCaretPosReserve = (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical) ? m_rtCaret.top : m_rtCaret.left; - m_Param.pEventSink->On_CaretChanged(this, m_nCaretPage, 0); + m_Param.pEventSink->OnCaretChanged(); } void CFDE_TxtEdtEngine::GetCaretRect(CFX_RectF& rtCaret, @@ -1560,7 +1553,7 @@ void CFDE_TxtEdtEngine::GetCaretRect(CFX_RectF& rtCaret, int32_t nCaret, bool bBefore) { IFDE_TxtEdtPage* pPage = m_PagePtrArray[m_nCaretPage]; - m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0); + m_Param.pEventSink->OnPageLoad(m_nCaretPage); bool bCombText = !!(m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_CombText); int32_t nIndexInpage = nCaret - pPage->GetCharStart(); if (bBefore && bCombText && nIndexInpage > 0) { @@ -1587,20 +1580,20 @@ void CFDE_TxtEdtEngine::GetCaretRect(CFX_RectF& rtCaret, rtCaret.width = 1.0f; } - m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0); + m_Param.pEventSink->OnPageUnload(m_nCaretPage); } void CFDE_TxtEdtEngine::UpdateCaretIndex(const CFX_PointF& ptCaret) { IFDE_TxtEdtPage* pPage = m_PagePtrArray[m_nCaretPage]; - m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0); + m_Param.pEventSink->OnPageLoad(m_nCaretPage); m_nCaret = pPage->GetCharIndex(ptCaret, m_bBefore); GetCaretRect(m_rtCaret, m_nCaretPage, m_nCaret, m_bBefore); if (!m_bBefore) { m_nCaret++; m_bBefore = true; } - m_Param.pEventSink->On_CaretChanged(this, m_nCaretPage); - m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0); + m_Param.pEventSink->OnCaretChanged(); + m_Param.pEventSink->OnPageUnload(m_nCaretPage); } bool CFDE_TxtEdtEngine::IsSelect() { @@ -1612,14 +1605,14 @@ void CFDE_TxtEdtEngine::DeleteSelect() { if (nCountRange > 0) { int32_t nSelStart = 0; while (nCountRange > 0) { - int32_t nSelCount = GetSelRange(--nCountRange, nSelStart); + int32_t nSelCount = GetSelRange(--nCountRange, &nSelStart); delete m_SelRangePtrArr[nCountRange]; m_SelRangePtrArr.RemoveAt(nCountRange); DeleteRange_DoRecord(nSelStart, nSelCount, true); } ClearSelection(); - m_Param.pEventSink->On_TextChanged(this, m_ChangeInfo); - m_Param.pEventSink->On_SelChanged(this); + m_Param.pEventSink->OnTextChanged(m_ChangeInfo); + m_Param.pEventSink->OnSelChanged(); SetCaretPos(nSelStart, true); return; } diff --git a/xfa/fde/cfde_txtedtengine.h b/xfa/fde/cfde_txtedtengine.h index a01f7565fc..755a820fd2 100644 --- a/xfa/fde/cfde_txtedtengine.h +++ b/xfa/fde/cfde_txtedtengine.h @@ -32,7 +32,7 @@ class CFDE_TxtEdtEngine { void SetTextByStream(const CFX_RetainPtr<IFGAS_Stream>& pStream); void SetText(const CFX_WideString& wsText); int32_t GetTextLength() const; - CFX_WideString GetText(int32_t nStart, int32_t nCount = -1) const; + CFX_WideString GetText(int32_t nStart, int32_t nCount) const; void ClearText(); int32_t GetCaretRect(CFX_RectF& rtCaret) const; @@ -55,11 +55,11 @@ class CFDE_TxtEdtEngine { void SetLimit(int32_t nLimit); void SetAliasChar(FX_WCHAR wcAlias); - void RemoveSelRange(int32_t nStart, int32_t nCount = -1); + void RemoveSelRange(int32_t nStart, int32_t nCount); - void AddSelRange(int32_t nStart, int32_t nCount = -1); + void AddSelRange(int32_t nStart, int32_t nCount); int32_t CountSelRanges() const; - int32_t GetSelRange(int32_t nIndex, int32_t& nStart) const; + int32_t GetSelRange(int32_t nIndex, int32_t* nStart) const; void ClearSelection(); bool Redo(const IFDE_TxtEdtDoRecord* pRecord); diff --git a/xfa/fwl/core/cfwl_combobox.cpp b/xfa/fwl/core/cfwl_combobox.cpp index 70f863504d..2d59b7d5ec 100644 --- a/xfa/fwl/core/cfwl_combobox.cpp +++ b/xfa/fwl/core/cfwl_combobox.cpp @@ -300,11 +300,9 @@ void CFWL_ComboBox::SetEditText(const CFX_WideString& wsText) { m_pEdit->Update(); } -CFX_WideString CFWL_ComboBox::GetEditText(int32_t nStart, - int32_t nCount) const { - if (m_pEdit) { - return m_pEdit->GetText(nStart, nCount); - } +CFX_WideString CFWL_ComboBox::GetEditText() const { + if (m_pEdit) + return m_pEdit->GetText(); if (!m_pListBox) return L""; @@ -624,7 +622,7 @@ void CFWL_ComboBox::DisForm_ShowDropList(bool bActivate) { pComboList->ChangeSelected(m_iCurSel); FX_FLOAT fItemHeight = pComboList->CalcItemHeight(); - FX_FLOAT fBorder = GetBorderSize(); + FX_FLOAT fBorder = GetBorderSize(true); FX_FLOAT fPopupMin = 0.0f; if (iItems > 3) fPopupMin = fItemHeight * 3 + fBorder * 2; diff --git a/xfa/fwl/core/cfwl_combobox.h b/xfa/fwl/core/cfwl_combobox.h index dda83486a6..812a6d0a29 100644 --- a/xfa/fwl/core/cfwl_combobox.h +++ b/xfa/fwl/core/cfwl_combobox.h @@ -77,7 +77,7 @@ class CFWL_ComboBox : public CFWL_Widget { void RemoveAll(); void SetEditText(const CFX_WideString& wsText); - CFX_WideString GetEditText(int32_t nStart = 0, int32_t nCount = -1) const; + CFX_WideString GetEditText() const; void OpenDropDownList(bool bActivate); @@ -127,6 +127,14 @@ class CFWL_ComboBox : public CFWL_Widget { void ResetEditAlignment(); void ResetListItemAlignment(); void InitProxyForm(); + void OnFocusChanged(CFWL_Message* pMsg, bool bSet); + void OnLButtonDown(CFWL_MsgMouse* pMsg); + void OnLButtonUp(CFWL_MsgMouse* pMsg); + void OnMouseMove(CFWL_MsgMouse* pMsg); + void OnMouseLeave(CFWL_MsgMouse* pMsg); + void OnKey(CFWL_MsgKey* pMsg); + void DoSubCtrlKey(CFWL_MsgKey* pMsg); + void DisForm_InitComboList(); void DisForm_InitComboEdit(); void DisForm_ShowDropList(bool bActivate); @@ -137,20 +145,12 @@ class CFWL_ComboBox : public CFWL_Widget { uint32_t dwStylesExRemoved); void DisForm_Update(); FWL_WidgetHit DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy); - void DisForm_DrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix = nullptr); + void DisForm_DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix); void DisForm_GetBBox(CFX_RectF& rect) const; void DisForm_Layout(); - void OnFocusChanged(CFWL_Message* pMsg, bool bSet = true); - void OnLButtonDown(CFWL_MsgMouse* pMsg); - void OnLButtonUp(CFWL_MsgMouse* pMsg); - void OnMouseMove(CFWL_MsgMouse* pMsg); - void OnMouseLeave(CFWL_MsgMouse* pMsg); - void OnKey(CFWL_MsgKey* pMsg); - void DoSubCtrlKey(CFWL_MsgKey* pMsg); void DisForm_OnProcessMessage(CFWL_Message* pMessage); void DisForm_OnLButtonDown(CFWL_MsgMouse* pMsg); - void DisForm_OnFocusChanged(CFWL_Message* pMsg, bool bSet = true); + void DisForm_OnFocusChanged(CFWL_Message* pMsg, bool bSet); void DisForm_OnKey(CFWL_MsgKey* pMsg); CFX_RectF m_rtClient; diff --git a/xfa/fwl/core/cfwl_datetimepicker.cpp b/xfa/fwl/core/cfwl_datetimepicker.cpp index 29aaaf0a2e..5207c9a492 100644 --- a/xfa/fwl/core/cfwl_datetimepicker.cpp +++ b/xfa/fwl/core/cfwl_datetimepicker.cpp @@ -196,9 +196,8 @@ void CFWL_DateTimePicker::SetEditText(const CFX_WideString& wsText) { DispatchEvent(&ev); } -CFX_WideString CFWL_DateTimePicker::GetEditText(int32_t nStart, - int32_t nCount) const { - return m_pEdit ? m_pEdit->GetText(nStart, nCount) : L""; +CFX_WideString CFWL_DateTimePicker::GetEditText() const { + return m_pEdit ? m_pEdit->GetText() : L""; } void CFWL_DateTimePicker::GetBBox(CFX_RectF& rect) const { diff --git a/xfa/fwl/core/cfwl_datetimepicker.h b/xfa/fwl/core/cfwl_datetimepicker.h index 985627441d..d6d47ebb2f 100644 --- a/xfa/fwl/core/cfwl_datetimepicker.h +++ b/xfa/fwl/core/cfwl_datetimepicker.h @@ -55,10 +55,10 @@ class CFWL_DateTimePicker : public CFWL_Widget { void SetCurSel(int32_t iYear, int32_t iMonth, int32_t iDay); void SetEditText(const CFX_WideString& wsText); - CFX_WideString GetEditText(int32_t nStart = 0, int32_t nCount = -1) const; + CFX_WideString GetEditText() const; int32_t CountSelRanges() const { return m_pEdit->CountSelRanges(); } - int32_t GetSelRange(int32_t nIndex, int32_t& nStart) const { + int32_t GetSelRange(int32_t nIndex, int32_t* nStart) const { return m_pEdit->GetSelRange(nIndex, nStart); } @@ -82,6 +82,11 @@ class CFWL_DateTimePicker : public CFWL_Widget { CFX_WideString& wsText); void ResetEditAlignment(); void InitProxyForm(); + void OnFocusChanged(CFWL_Message* pMsg, bool bSet); + void OnLButtonDown(CFWL_MsgMouse* pMsg); + void OnLButtonUp(CFWL_MsgMouse* pMsg); + void OnMouseMove(CFWL_MsgMouse* pMsg); + void OnMouseLeave(CFWL_MsgMouse* pMsg); bool DisForm_IsMonthCalendarVisible() const; void DisForm_ShowMonthCalendar(bool bActivate); @@ -90,14 +95,8 @@ class CFWL_DateTimePicker : public CFWL_Widget { void DisForm_Update(); void DisForm_GetWidgetRect(CFX_RectF& rect, bool bAutoSize); void DisForm_GetBBox(CFX_RectF& rect) const; - void DisForm_DrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix = nullptr); + void DisForm_DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix); void DisForm_OnFocusChanged(CFWL_Message* pMsg, bool bSet); - void OnFocusChanged(CFWL_Message* pMsg, bool bSet); - void OnLButtonDown(CFWL_MsgMouse* pMsg); - void OnLButtonUp(CFWL_MsgMouse* pMsg); - void OnMouseMove(CFWL_MsgMouse* pMsg); - void OnMouseLeave(CFWL_MsgMouse* pMsg); CFX_RectF m_rtBtn; CFX_RectF m_rtClient; diff --git a/xfa/fwl/core/cfwl_edit.cpp b/xfa/fwl/core/cfwl_edit.cpp index a2fee2a4e1..c5c69a3a94 100644 --- a/xfa/fwl/core/cfwl_edit.cpp +++ b/xfa/fwl/core/cfwl_edit.cpp @@ -113,7 +113,7 @@ void CFWL_Edit::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { int32_t iTextLen = m_EdtEngine.GetTextLength(); if (iTextLen > 0) { - CFX_WideString wsText = m_EdtEngine.GetText(0); + CFX_WideString wsText = m_EdtEngine.GetText(0, -1); CFX_SizeF sz = CalcTextSize( wsText, m_pProperties->m_pThemeProvider, !!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine)); @@ -297,23 +297,23 @@ int32_t CFWL_Edit::GetTextLength() const { return m_EdtEngine.GetTextLength(); } -CFX_WideString CFWL_Edit::GetText(int32_t nStart, int32_t nCount) const { - return m_EdtEngine.GetText(nStart, nCount); +CFX_WideString CFWL_Edit::GetText() const { + return m_EdtEngine.GetText(0, -1); } void CFWL_Edit::ClearText() { m_EdtEngine.ClearText(); } -void CFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount) { - m_EdtEngine.AddSelRange(nStart, nCount); +void CFWL_Edit::AddSelRange(int32_t nStart) { + m_EdtEngine.AddSelRange(nStart, -1); } int32_t CFWL_Edit::CountSelRanges() const { return m_EdtEngine.CountSelRanges(); } -int32_t CFWL_Edit::GetSelRange(int32_t nIndex, int32_t& nStart) const { +int32_t CFWL_Edit::GetSelRange(int32_t nIndex, int32_t* nStart) const { return m_EdtEngine.GetSelRange(nIndex, nStart); } @@ -340,13 +340,11 @@ bool CFWL_Edit::Copy(CFX_WideString& wsCopy) { return false; wsCopy.clear(); - CFX_WideString wsTemp; - int32_t nStart, nLength; + int32_t nStart; + int32_t nLength; for (int32_t i = 0; i < nCount; i++) { - nLength = m_EdtEngine.GetSelRange(i, nStart); - wsTemp = m_EdtEngine.GetText(nStart, nLength); - wsCopy += wsTemp; - wsTemp.clear(); + nLength = m_EdtEngine.GetSelRange(i, &nStart); + wsCopy += m_EdtEngine.GetText(nStart, nLength); } return true; } @@ -360,7 +358,7 @@ bool CFWL_Edit::Cut(CFX_WideString& wsCut) { CFX_WideString wsTemp; int32_t nStart, nLength; for (int32_t i = 0; i < nCount; i++) { - nLength = m_EdtEngine.GetSelRange(i, nStart); + nLength = m_EdtEngine.GetSelRange(i, &nStart); wsTemp = m_EdtEngine.GetText(nStart, nLength); wsCut += wsTemp; wsTemp.clear(); @@ -416,9 +414,7 @@ void CFWL_Edit::SetOuter(CFWL_Widget* pOuter) { m_pOuter = pOuter; } -void CFWL_Edit::On_CaretChanged(CFDE_TxtEdtEngine* pEdit, - int32_t nPage, - bool bVisible) { +void CFWL_Edit::OnCaretChanged() { if (m_rtEngine.IsEmpty()) return; if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) @@ -443,8 +439,7 @@ void CFWL_Edit::On_CaretChanged(CFDE_TxtEdtEngine* pEdit, } } -void CFWL_Edit::On_TextChanged(CFDE_TxtEdtEngine* pEdit, - FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) { +void CFWL_Edit::OnTextChanged(const FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) { if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VAlignMask) UpdateVAlignment(); @@ -459,15 +454,13 @@ void CFWL_Edit::On_TextChanged(CFDE_TxtEdtEngine* pEdit, Repaint(&rtTemp); } -void CFWL_Edit::On_SelChanged(CFDE_TxtEdtEngine* pEdit) { +void CFWL_Edit::OnSelChanged() { CFX_RectF rtTemp; GetClientRect(rtTemp); Repaint(&rtTemp); } -bool CFWL_Edit::On_PageLoad(CFDE_TxtEdtEngine* pEdit, - int32_t nPageIndex, - int32_t nPurpose) { +bool CFWL_Edit::OnPageLoad(int32_t nPageIndex) { IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(nPageIndex); if (!pPage) return false; @@ -476,9 +469,7 @@ bool CFWL_Edit::On_PageLoad(CFDE_TxtEdtEngine* pEdit, return true; } -bool CFWL_Edit::On_PageUnload(CFDE_TxtEdtEngine* pEdit, - int32_t nPageIndex, - int32_t nPurpose) { +bool CFWL_Edit::OnPageUnload(int32_t nPageIndex) { IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(nPageIndex); if (!pPage) return false; @@ -487,12 +478,11 @@ bool CFWL_Edit::On_PageUnload(CFDE_TxtEdtEngine* pEdit, return true; } -void CFWL_Edit::On_AddDoRecord(CFDE_TxtEdtEngine* pEdit, - IFDE_TxtEdtDoRecord* pRecord) { - AddDoRecord(pRecord); +void CFWL_Edit::OnAddDoRecord(std::unique_ptr<IFDE_TxtEdtDoRecord> pRecord) { + AddDoRecord(std::move(pRecord)); } -bool CFWL_Edit::On_Validate(CFDE_TxtEdtEngine* pEdit, CFX_WideString& wsText) { +bool CFWL_Edit::OnValidate(const CFX_WideString& wsText) { CFWL_Widget* pDst = GetOuter(); if (!pDst) pDst = this; @@ -583,7 +573,7 @@ void CFWL_Edit::DrawContent(CFX_Graphics* pGraphics, CFX_RectFArray rectArr; int32_t i = 0; for (i = 0; i < nSelCount; i++) { - nCharCount = m_EdtEngine.GetSelRange(i, nCharStart); + nCharCount = m_EdtEngine.GetSelRange(i, &nCharStart); int32_t nCharEnd = nCharStart + nCharCount - 1; if (nCharEnd < nPageCharStart || nCharStart > nPageCharEnd) continue; @@ -991,7 +981,7 @@ bool CFWL_Edit::IsContentHeightOverflow() { return pPage->GetContentsBox().height > m_rtEngine.height + 1.0f; } -int32_t CFWL_Edit::AddDoRecord(IFDE_TxtEdtDoRecord* pRecord) { +int32_t CFWL_Edit::AddDoRecord(std::unique_ptr<IFDE_TxtEdtDoRecord> pRecord) { int32_t nCount = pdfium::CollectionSize<int32_t>(m_DoRecords); if (m_iCurRecord == nCount - 1) { if (nCount == m_iMaxRecord) { @@ -1003,7 +993,7 @@ int32_t CFWL_Edit::AddDoRecord(IFDE_TxtEdtDoRecord* pRecord) { m_DoRecords.end()); } - m_DoRecords.push_back(std::unique_ptr<IFDE_TxtEdtDoRecord>(pRecord)); + m_DoRecords.push_back(std::move(pRecord)); m_iCurRecord = pdfium::CollectionSize<int32_t>(m_DoRecords) - 1; return m_iCurRecord; } @@ -1039,7 +1029,7 @@ void CFWL_Edit::Layout() { bool bShowVertScrollbar = IsShowScrollBar(true); bool bShowHorzScrollbar = IsShowScrollBar(false); if (bShowVertScrollbar) { - InitScrollBar(); + InitVerticalScrollBar(); CFX_RectF rtVertScr; if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { @@ -1061,7 +1051,7 @@ void CFWL_Edit::Layout() { } if (bShowHorzScrollbar) { - InitScrollBar(false); + InitHorizontalScrollBar(); CFX_RectF rtHoriScr; if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { @@ -1096,7 +1086,7 @@ void CFWL_Edit::LayoutScrollBar() { pfWidth = static_cast<FX_FLOAT*>( GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); FX_FLOAT fWidth = pfWidth ? *pfWidth : 0; - InitScrollBar(); + InitVerticalScrollBar(); CFX_RectF rtVertScr; if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { rtVertScr.Set(m_rtClient.right() + kEditMargin, m_rtClient.top, fWidth, @@ -1123,7 +1113,7 @@ void CFWL_Edit::LayoutScrollBar() { } FX_FLOAT fWidth = pfWidth ? *pfWidth : 0; - InitScrollBar(false); + InitHorizontalScrollBar(); CFX_RectF rtHoriScr; if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() + kEditMargin, @@ -1150,21 +1140,30 @@ void CFWL_Edit::DeviceToEngine(CFX_PointF& pt) { pt.y += m_fScrollOffsetY - m_rtEngine.top - m_fVAlignOffset; } -void CFWL_Edit::InitScrollBar(bool bVert) { - if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) +void CFWL_Edit::InitVerticalScrollBar() { + if (m_pVertScrollBar) return; auto prop = pdfium::MakeUnique<CFWL_WidgetProperties>(); - prop->m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; + prop->m_dwStyleExes = FWL_STYLEEXT_SCB_Vert; prop->m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible; prop->m_pParent = this; prop->m_pThemeProvider = m_pProperties->m_pThemeProvider; + m_pVertScrollBar = + pdfium::MakeUnique<CFWL_ScrollBar>(m_pOwnerApp, std::move(prop), this); +} - CFWL_ScrollBar* sb = new CFWL_ScrollBar(m_pOwnerApp, std::move(prop), this); - if (bVert) - m_pVertScrollBar.reset(sb); - else - m_pHorzScrollBar.reset(sb); +void CFWL_Edit::InitHorizontalScrollBar() { + if (m_pHorzScrollBar) + return; + + auto prop = pdfium::MakeUnique<CFWL_WidgetProperties>(); + prop->m_dwStyleExes = FWL_STYLEEXT_SCB_Horz; + prop->m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible; + prop->m_pParent = this; + prop->m_pThemeProvider = m_pProperties->m_pThemeProvider; + m_pHorzScrollBar = + pdfium::MakeUnique<CFWL_ScrollBar>(m_pOwnerApp, std::move(prop), this); } void CFWL_Edit::ShowCaret(CFX_RectF* pRect) { @@ -1232,7 +1231,7 @@ bool CFWL_Edit::ValidateNumberChar(FX_WCHAR cNum) { if (!m_bSetRange) return true; - CFX_WideString wsText = m_EdtEngine.GetText(0); + CFX_WideString wsText = m_EdtEngine.GetText(0, -1); if (wsText.IsEmpty()) { if (cNum == L'0') return false; diff --git a/xfa/fwl/core/cfwl_edit.h b/xfa/fwl/core/cfwl_edit.h index 0e5f0dcbaf..8143c7d5ed 100644 --- a/xfa/fwl/core/cfwl_edit.h +++ b/xfa/fwl/core/cfwl_edit.h @@ -79,12 +79,12 @@ class CFWL_Edit : public CFWL_Widget { virtual void SetText(const CFX_WideString& wsText); int32_t GetTextLength() const; - CFX_WideString GetText(int32_t nStart = 0, int32_t nCount = -1) const; + CFX_WideString GetText() const; void ClearText(); - void AddSelRange(int32_t nStart, int32_t nCount = -1); + void AddSelRange(int32_t nStart); int32_t CountSelRanges() const; - int32_t GetSelRange(int32_t nIndex, int32_t& nStart) const; + int32_t GetSelRange(int32_t nIndex, int32_t* nStart) const; void ClearSelections(); int32_t GetLimit() const; void SetLimit(int32_t nLimit); @@ -101,20 +101,13 @@ class CFWL_Edit : public CFWL_Widget { void SetOuter(CFWL_Widget* pOuter); - void On_CaretChanged(CFDE_TxtEdtEngine* pEdit, - int32_t nPage, - bool bVisible = true); - void On_TextChanged(CFDE_TxtEdtEngine* pEdit, - FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo); - void On_SelChanged(CFDE_TxtEdtEngine* pEdit); - bool On_PageLoad(CFDE_TxtEdtEngine* pEdit, - int32_t nPageIndex, - int32_t nPurpose); - bool On_PageUnload(CFDE_TxtEdtEngine* pEdit, - int32_t nPageIndex, - int32_t nPurpose); - void On_AddDoRecord(CFDE_TxtEdtEngine* pEdit, IFDE_TxtEdtDoRecord* pRecord); - bool On_Validate(CFDE_TxtEdtEngine* pEdit, CFX_WideString& wsText); + void OnCaretChanged(); + void OnTextChanged(const FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo); + void OnSelChanged(); + bool OnPageLoad(int32_t nPageIndex); + bool OnPageUnload(int32_t nPageIndex); + void OnAddDoRecord(std::unique_ptr<IFDE_TxtEdtDoRecord> pRecord); + bool OnValidate(const CFX_WideString& wsText); void SetScrollOffset(FX_FLOAT fScrollOffset); protected: @@ -126,10 +119,12 @@ class CFWL_Edit : public CFWL_Widget { private: void DrawTextBk(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix = nullptr); + const CFX_Matrix* pMatrix); void DrawContent(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix = nullptr); + const CFX_Matrix* pMatrix); + void DrawSpellCheck(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix); + void UpdateEditEngine(); void UpdateEditParams(); void UpdateEditLayout(); @@ -141,23 +136,22 @@ class CFWL_Edit : public CFWL_Widget { void Layout(); void LayoutScrollBar(); void DeviceToEngine(CFX_PointF& pt); - void InitScrollBar(bool bVert = true); + void InitVerticalScrollBar(); + void InitHorizontalScrollBar(); void InitEngine(); - bool ValidateNumberChar(FX_WCHAR cNum); void InitCaret(); + bool ValidateNumberChar(FX_WCHAR cNum); void ClearRecord(); bool IsShowScrollBar(bool bVert); bool IsContentHeightOverflow(); - int32_t AddDoRecord(IFDE_TxtEdtDoRecord* pRecord); + int32_t AddDoRecord(std::unique_ptr<IFDE_TxtEdtDoRecord> pRecord); void ProcessInsertError(int32_t iError); - - void DrawSpellCheck(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix = nullptr); void AddSpellCheckObj(CFX_Path& PathData, int32_t nStart, int32_t nCount, FX_FLOAT fOffSetX, FX_FLOAT fOffSetY); + void DoButtonDown(CFWL_MsgMouse* pMsg); void OnFocusChanged(CFWL_Message* pMsg, bool bSet); void OnLButtonDown(CFWL_MsgMouse* pMsg); diff --git a/xfa/fwl/core/cfwl_form.cpp b/xfa/fwl/core/cfwl_form.cpp index 1fe5e90b87..60f0de3862 100644 --- a/xfa/fwl/core/cfwl_form.cpp +++ b/xfa/fwl/core/cfwl_form.cpp @@ -385,7 +385,7 @@ int32_t CFWL_Form::GetSysBtnIndex(CFWL_SysBtn* pBtn) { void CFWL_Form::GetEdgeRect(CFX_RectF& rtEdge) { rtEdge = m_rtRelative; if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) { - FX_FLOAT fCX = GetBorderSize(); + FX_FLOAT fCX = GetBorderSize(true); FX_FLOAT fCY = GetBorderSize(false); rtEdge.Deflate(fCX, fCY, fCX, fCY); } @@ -549,7 +549,7 @@ void CFWL_Form::OnLButtonUp(CFWL_MsgMouse* pMsg) { if (m_bMaximized) { SetWidgetRect(m_rtRestore); Update(); - Repaint(); + Repaint(nullptr); } else { SetWorkAreaRect(); Update(); diff --git a/xfa/fwl/core/cfwl_listbox.cpp b/xfa/fwl/core/cfwl_listbox.cpp index 7589623e51..48f8c262f5 100644 --- a/xfa/fwl/core/cfwl_listbox.cpp +++ b/xfa/fwl/core/cfwl_listbox.cpp @@ -90,7 +90,7 @@ void CFWL_ListBox::Update() { m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine; m_fScorllBarWidth = GetScrollWidth(); - CalcSize(); + CalcSize(false); } FWL_WidgetHit CFWL_ListBox::HitTest(FX_FLOAT fx, FX_FLOAT fy) { @@ -622,7 +622,7 @@ CFX_SizeF CFWL_ListBox::CalcSize(bool bAutoSize) { CFX_SizeF szRange; if (bShowVertScr) { if (!m_pVertScrollBar) - InitScrollBar(); + InitVerticalScrollBar(); CFX_RectF rtScrollBar; rtScrollBar.Set(m_rtClient.right() - m_fScorllBarWidth, m_rtClient.top, @@ -655,7 +655,7 @@ CFX_SizeF CFWL_ListBox::CalcSize(bool bAutoSize) { } if (bShowHorzScr) { if (!m_pHorzScrollBar) - InitScrollBar(false); + InitHorizontalScrollBar(); CFX_RectF rtScrollBar; rtScrollBar.Set(m_rtClient.left, m_rtClient.bottom() - m_fScorllBarWidth, @@ -718,7 +718,7 @@ FX_FLOAT CFWL_ListBox::GetMaxTextWidth() { continue; CFX_WideString wsText = GetItemText(this, pItem); - CFX_SizeF sz = CalcTextSize(wsText, m_pProperties->m_pThemeProvider); + CFX_SizeF sz = CalcTextSize(wsText, m_pProperties->m_pThemeProvider, false); fRet = std::max(fRet, sz.x); } return fRet; @@ -740,20 +740,30 @@ FX_FLOAT CFWL_ListBox::CalcItemHeight() { return *pfFont + 2 * kItemTextMargin; } -void CFWL_ListBox::InitScrollBar(bool bVert) { - if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) +void CFWL_ListBox::InitVerticalScrollBar() { + if (m_pVertScrollBar) return; auto prop = pdfium::MakeUnique<CFWL_WidgetProperties>(); - prop->m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; + prop->m_dwStyleExes = FWL_STYLEEXT_SCB_Vert; prop->m_dwStates = FWL_WGTSTATE_Invisible; prop->m_pParent = this; prop->m_pThemeProvider = m_pScrollBarTP; - CFWL_ScrollBar* sb = new CFWL_ScrollBar(m_pOwnerApp, std::move(prop), this); - if (bVert) - m_pVertScrollBar.reset(sb); - else - m_pHorzScrollBar.reset(sb); + m_pVertScrollBar = + pdfium::MakeUnique<CFWL_ScrollBar>(m_pOwnerApp, std::move(prop), this); +} + +void CFWL_ListBox::InitHorizontalScrollBar() { + if (m_pHorzScrollBar) + return; + + auto prop = pdfium::MakeUnique<CFWL_WidgetProperties>(); + prop->m_dwStyleExes = FWL_STYLEEXT_SCB_Horz; + prop->m_dwStates = FWL_WGTSTATE_Invisible; + prop->m_pParent = this; + prop->m_pThemeProvider = m_pScrollBarTP; + m_pHorzScrollBar = + pdfium::MakeUnique<CFWL_ScrollBar>(m_pOwnerApp, std::move(prop), this); } bool CFWL_ListBox::IsShowScrollBar(bool bVert) { @@ -1093,12 +1103,11 @@ void CFWL_ListBox::SetItemCheckState(CFWL_Widget* pWidget, static_cast<CFWL_ListItem*>(pItem)->m_dwCheckState = dwCheckState; } -CFWL_ListItem* CFWL_ListBox::AddString(const CFX_WideStringC& wsAdd, - bool bSelect) { +CFWL_ListItem* CFWL_ListBox::AddString(const CFX_WideStringC& wsAdd) { auto pItem = pdfium::MakeUnique<CFWL_ListItem>(); pItem->m_dwStates = 0; pItem->m_wsText = wsAdd; - pItem->m_dwStates = bSelect ? FWL_ITEMSTATE_LTB_Selected : 0; + pItem->m_dwStates = 0; m_ItemArray.push_back(std::move(pItem)); return m_ItemArray.back().get(); } diff --git a/xfa/fwl/core/cfwl_listbox.h b/xfa/fwl/core/cfwl_listbox.h index e9e59ebc10..0cfe1f0367 100644 --- a/xfa/fwl/core/cfwl_listbox.h +++ b/xfa/fwl/core/cfwl_listbox.h @@ -84,7 +84,7 @@ class CFWL_ListBox : public CFWL_Widget { void SetItemCheckState(CFWL_Widget* pWidget, CFWL_ListItem* pItem, uint32_t dwCheckState); - CFWL_ListItem* AddString(const CFX_WideStringC& wsAdd, bool bSelect = false); + CFWL_ListItem* AddString(const CFX_WideStringC& wsAdd); bool RemoveAt(int32_t iIndex); bool DeleteString(CFWL_ListItem* pItem); void DeleteAll(); @@ -92,7 +92,7 @@ class CFWL_ListBox : public CFWL_Widget { int32_t CountSelItems(); CFWL_ListItem* GetSelItem(int32_t nIndexSel); int32_t GetSelIndex(int32_t nIndex); - void SetSelItem(CFWL_ListItem* hItem, bool bSelect = true); + void SetSelItem(CFWL_ListItem* hItem, bool bSelect); CFX_WideString GetDataProviderItemText(CFWL_ListItem* hItem); FX_FLOAT GetItemHeight() const { return m_fItemHeight; } @@ -103,7 +103,8 @@ class CFWL_ListBox : public CFWL_Widget { void SetSelection(CFWL_ListItem* hStart, CFWL_ListItem* hEnd, bool bSelected); CFWL_ListItem* GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy); bool ScrollToVisible(CFWL_ListItem* hItem); - void InitScrollBar(bool bVert = true); + void InitVerticalScrollBar(); + void InitHorizontalScrollBar(); bool IsShowScrollBar(bool bVert); CFWL_ScrollBar* GetVertScrollBar() const { return m_pVertScrollBar.get(); } const CFX_RectF& GetRTClient() const { return m_rtClient; } @@ -121,27 +122,27 @@ class CFWL_ListBox : public CFWL_Widget { bool GetItemChecked(CFWL_ListItem* hItem); void DrawBkground(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix = nullptr); + const CFX_Matrix* pMatrix); void DrawItems(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix = nullptr); + const CFX_Matrix* pMatrix); void DrawItem(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme, CFWL_ListItem* hItem, int32_t Index, const CFX_RectF& rtItem, - const CFX_Matrix* pMatrix = nullptr); + const CFX_Matrix* pMatrix); void DrawStatic(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme); - CFX_SizeF CalcSize(bool bAutoSize = false); + CFX_SizeF CalcSize(bool bAutoSize); void GetItemSize(CFX_SizeF& size, CFWL_ListItem* hItem, FX_FLOAT fWidth, FX_FLOAT fHeight, - bool bAutoSize = false); + bool bAutoSize); FX_FLOAT GetMaxTextWidth(); FX_FLOAT GetScrollWidth(); - void OnFocusChanged(CFWL_Message* pMsg, bool bSet = true); + void OnFocusChanged(CFWL_Message* pMsg, bool bSet); void OnLButtonDown(CFWL_MsgMouse* pMsg); void OnLButtonUp(CFWL_MsgMouse* pMsg); void OnMouseWheel(CFWL_MsgMouseWheel* pMsg); diff --git a/xfa/fwl/core/cfwl_message.cpp b/xfa/fwl/core/cfwl_message.cpp index b20cf0e6a1..a8d13fc740 100644 --- a/xfa/fwl/core/cfwl_message.cpp +++ b/xfa/fwl/core/cfwl_message.cpp @@ -17,7 +17,6 @@ CFWL_Message::CFWL_Message(Type type, CFWL_Widget* pDstTarget) : m_pSrcTarget(pSrcTarget), m_pDstTarget(pDstTarget), - m_dwExtend(0), m_type(type) {} CFWL_Message::~CFWL_Message() {} diff --git a/xfa/fwl/core/cfwl_message.h b/xfa/fwl/core/cfwl_message.h index a1545b1013..0c980066cc 100644 --- a/xfa/fwl/core/cfwl_message.h +++ b/xfa/fwl/core/cfwl_message.h @@ -30,7 +30,6 @@ class CFWL_Message { CFWL_Widget* m_pSrcTarget; CFWL_Widget* m_pDstTarget; - uint32_t m_dwExtend; private: Type m_type; diff --git a/xfa/fwl/core/cfwl_monthcalendar.cpp b/xfa/fwl/core/cfwl_monthcalendar.cpp index 76426cd5be..7b5c171a3a 100644 --- a/xfa/fwl/core/cfwl_monthcalendar.cpp +++ b/xfa/fwl/core/cfwl_monthcalendar.cpp @@ -166,7 +166,7 @@ void CFWL_MonthCalendar::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { return; } - CFX_SizeF fs = CalcSize(true); + CFX_SizeF fs = CalcSize(); rect.Set(0, 0, fs.x, fs.y); CFWL_Widget::GetWidgetRect(rect, true); } @@ -297,7 +297,8 @@ void CFWL_MonthCalendar::DrawCaption(CFX_Graphics* pGraphics, CFX_WideString wsCation; GetHeadText(iYear, iMonth, wsCation); textParam.m_wsText = wsCation; - m_szHead = CalcTextSize(textParam.m_wsText, m_pProperties->m_pThemeProvider); + m_szHead = + CalcTextSize(textParam.m_wsText, m_pProperties->m_pThemeProvider, false); CalcHeadSize(); textParam.m_rtPart = m_rtHeadText; textParam.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; @@ -442,7 +443,8 @@ void CFWL_MonthCalendar::DrawToday(CFX_Graphics* pGraphics, GetTodayText(m_iYear, m_iMonth, m_iDay, wsText); params.m_wsText = *wsDay + wsText; - m_szToday = CalcTextSize(params.m_wsText, m_pProperties->m_pThemeProvider); + m_szToday = + CalcTextSize(params.m_wsText, m_pProperties->m_pThemeProvider, false); CalcTodaySize(); params.m_rtPart = m_rtToday; params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; @@ -515,13 +517,9 @@ void CFWL_MonthCalendar::DrawDatesInCircle(CFX_Graphics* pGraphics, pTheme->DrawBackground(¶ms); } -CFX_SizeF CFWL_MonthCalendar::CalcSize(bool bAutoSize) { +CFX_SizeF CFWL_MonthCalendar::CalcSize() { if (!m_pProperties->m_pThemeProvider) return CFX_SizeF(); - if (!bAutoSize) { - GetClientRect(m_rtClient); - return CFX_SizeF(m_rtClient.width, m_rtClient.height); - } CFX_SizeF fs; CFWL_ThemePart params; @@ -532,7 +530,7 @@ CFX_SizeF CFWL_MonthCalendar::CalcSize(bool bAutoSize) { for (uint32_t i = 0; i < 7; ++i) { CFX_SizeF sz = CalcTextSize(*GetCapacityForDay(pTheme, params, i), - m_pProperties->m_pThemeProvider); + m_pProperties->m_pThemeProvider, false); fMaxWeekW = (fMaxWeekW >= sz.x) ? fMaxWeekW : sz.x; fMaxWeekH = (fMaxWeekH >= sz.y) ? fMaxWeekH : sz.y; } @@ -542,7 +540,7 @@ CFX_SizeF CFWL_MonthCalendar::CalcSize(bool bAutoSize) { for (int day = 10; day <= 31; day++) { CFX_WideString wsDay; wsDay.Format(L"%d", day); - CFX_SizeF sz = CalcTextSize(wsDay, m_pProperties->m_pThemeProvider); + CFX_SizeF sz = CalcTextSize(wsDay, m_pProperties->m_pThemeProvider, false); fDayMaxW = (fDayMaxW >= sz.x) ? fDayMaxW : sz.x; fDayMaxH = (fDayMaxH >= sz.y) ? fDayMaxH : sz.y; } @@ -557,7 +555,7 @@ CFX_SizeF CFWL_MonthCalendar::CalcSize(bool bAutoSize) { for (uint32_t i = 0; i < 12; ++i) { CFX_SizeF sz = CalcTextSize(*GetCapacityForMonth(pTheme, params, i), - m_pProperties->m_pThemeProvider); + m_pProperties->m_pThemeProvider, false); fMonthMaxW = (fMonthMaxW >= sz.x) ? fMonthMaxW : sz.x; fMonthMaxH = (fMonthMaxH >= sz.y) ? fMonthMaxH : sz.y; } @@ -565,7 +563,8 @@ CFX_SizeF CFWL_MonthCalendar::CalcSize(bool bAutoSize) { CFX_WideString wsYear; GetHeadText(m_iYear, m_iMonth, wsYear); - CFX_SizeF szYear = CalcTextSize(wsYear, m_pProperties->m_pThemeProvider); + CFX_SizeF szYear = + CalcTextSize(wsYear, m_pProperties->m_pThemeProvider, false); fMonthMaxH = std::max(fMonthMaxH, szYear.y); m_szHead = CFX_SizeF(fMonthMaxW + szYear.x, fMonthMaxH); fMonthMaxW = m_szHead.x + MONTHCAL_HEADER_BTN_HMARGIN * 2 + m_szCell.x * 2; @@ -576,7 +575,7 @@ CFX_SizeF CFWL_MonthCalendar::CalcSize(bool bAutoSize) { CFX_WideString* wsText = static_cast<CFX_WideString*>( pTheme->GetCapacity(¶ms, CFWL_WidgetCapacity::Today)); m_wsToday = *wsText + wsToday; - m_szToday = CalcTextSize(wsToday, m_pProperties->m_pThemeProvider); + m_szToday = CalcTextSize(wsToday, m_pProperties->m_pThemeProvider, false); m_szToday.y = (m_szToday.y >= m_szCell.y) ? m_szToday.y : m_szCell.y; fs.y = m_szCell.x + m_szCell.y * (MONTHCAL_ROWS - 2) + m_szToday.y + MONTHCAL_VMARGIN * MONTHCAL_ROWS * 2 + MONTHCAL_HEADER_BTN_VMARGIN * 4; @@ -811,34 +810,18 @@ void CFWL_MonthCalendar::ChangeToMonth(int32_t iYear, int32_t iMonth) { GetHeadText(m_iCurYear, m_iCurMonth, m_wsHead); } -void CFWL_MonthCalendar::RemoveSelDay(int32_t iDay, bool bAll) { - if (iDay == -1 && !bAll) - return; - if (bAll) { - int32_t iCount = m_arrSelDays.GetSize(); - int32_t iDatesCount = m_arrDates.GetSize(); - for (int32_t i = 0; i < iCount; i++) { - int32_t iSelDay = m_arrSelDays.GetAt(i); - if (iSelDay <= iDatesCount) { - DATEINFO* pDateInfo = m_arrDates.GetAt(iSelDay - 1); - pDateInfo->dwStates &= ~FWL_ITEMSTATE_MCD_Selected; - } - } - m_arrSelDays.RemoveAll(); - return; - } - - int32_t index = m_arrSelDays.Find(iDay); - if (index == -1) - return; - - int32_t iSelDay = m_arrSelDays.GetAt(iDay); +void CFWL_MonthCalendar::RemoveSelDay() { + int32_t iCount = m_arrSelDays.GetSize(); int32_t iDatesCount = m_arrDates.GetSize(); - if (iSelDay <= iDatesCount) { - DATEINFO* pDateInfo = m_arrDates.GetAt(iSelDay - 1); - pDateInfo->dwStates &= ~FWL_ITEMSTATE_MCD_Selected; + for (int32_t i = 0; i < iCount; i++) { + int32_t iSelDay = m_arrSelDays.GetAt(i); + if (iSelDay <= iDatesCount) { + DATEINFO* pDateInfo = m_arrDates.GetAt(iSelDay - 1); + pDateInfo->dwStates &= ~FWL_ITEMSTATE_MCD_Selected; + } } - m_arrSelDays.RemoveAt(index); + m_arrSelDays.RemoveAll(); + return; } void CFWL_MonthCalendar::AddSelDay(int32_t iDay) { @@ -849,7 +832,7 @@ void CFWL_MonthCalendar::AddSelDay(int32_t iDay) { if (m_arrSelDays.Find(iDay) != -1) return; - RemoveSelDay(-1, true); + RemoveSelDay(); if (iDay <= m_arrDates.GetSize()) { DATEINFO* pDateInfo = m_arrDates.GetAt(iDay - 1); pDateInfo->dwStates |= FWL_ITEMSTATE_MCD_Selected; diff --git a/xfa/fwl/core/cfwl_monthcalendar.h b/xfa/fwl/core/cfwl_monthcalendar.h index 1a983abdfb..15912e59c3 100644 --- a/xfa/fwl/core/cfwl_monthcalendar.h +++ b/xfa/fwl/core/cfwl_monthcalendar.h @@ -136,7 +136,7 @@ class CFWL_MonthCalendar : public CFWL_Widget { void DrawDatesInCircle(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme, const CFX_Matrix* pMatrix); - CFX_SizeF CalcSize(bool bAutoSize = false); + CFX_SizeF CalcSize(); void Layout(); void CalcHeadSize(); void CalcTodaySize(); @@ -148,7 +148,7 @@ class CFWL_MonthCalendar : public CFWL_Widget { void NextMonth(); void PrevMonth(); void ChangeToMonth(int32_t iYear, int32_t iMonth); - void RemoveSelDay(int32_t iDay, bool bAll = false); + void RemoveSelDay(); void AddSelDay(int32_t iDay); void JumpToToday(); void GetHeadText(int32_t iYear, int32_t iMonth, CFX_WideString& wsHead); diff --git a/xfa/fwl/core/cfwl_notedriver.cpp b/xfa/fwl/core/cfwl_notedriver.cpp index 00a0b3e4b7..8402b2b90c 100644 --- a/xfa/fwl/core/cfwl_notedriver.cpp +++ b/xfa/fwl/core/cfwl_notedriver.cpp @@ -84,19 +84,17 @@ CFWL_NoteLoop* CFWL_NoteDriver::PopNoteLoop() { return p; } -bool CFWL_NoteDriver::SetFocus(CFWL_Widget* pFocus, bool bNotify) { +bool CFWL_NoteDriver::SetFocus(CFWL_Widget* pFocus) { if (m_pFocus == pFocus) return true; CFWL_Widget* pPrev = m_pFocus; m_pFocus = pFocus; if (pPrev) { - CFWL_MsgKillFocus ms(pPrev, pPrev); - if (bNotify) - ms.m_dwExtend = 1; - - if (IFWL_WidgetDelegate* pDelegate = pPrev->GetDelegate()) + if (IFWL_WidgetDelegate* pDelegate = pPrev->GetDelegate()) { + CFWL_MsgKillFocus ms(pPrev, pPrev); pDelegate->OnProcessMessage(&ms); + } } if (pFocus) { CFWL_Widget* pWidget = @@ -105,11 +103,10 @@ bool CFWL_NoteDriver::SetFocus(CFWL_Widget* pFocus, bool bNotify) { if (pForm) pForm->SetSubFocus(pFocus); - CFWL_MsgSetFocus ms(nullptr, pFocus); - if (bNotify) - ms.m_dwExtend = 1; - if (IFWL_WidgetDelegate* pDelegate = pFocus->GetDelegate()) + if (IFWL_WidgetDelegate* pDelegate = pFocus->GetDelegate()) { + CFWL_MsgSetFocus ms(nullptr, pFocus); pDelegate->OnProcessMessage(&ms); + } } return true; } diff --git a/xfa/fwl/core/cfwl_notedriver.h b/xfa/fwl/core/cfwl_notedriver.h index 9fdb3427ab..47f11daec3 100644 --- a/xfa/fwl/core/cfwl_notedriver.h +++ b/xfa/fwl/core/cfwl_notedriver.h @@ -36,7 +36,7 @@ class CFWL_NoteDriver { CFWL_NoteLoop* PopNoteLoop(); CFWL_Widget* GetFocus() const { return m_pFocus; } - bool SetFocus(CFWL_Widget* pFocus, bool bNotify = false); + bool SetFocus(CFWL_Widget* pFocus); void SetGrab(CFWL_Widget* pGrab, bool bSet) { m_pGrab = bSet ? pGrab : nullptr; } diff --git a/xfa/fwl/core/cfwl_scrollbar.cpp b/xfa/fwl/core/cfwl_scrollbar.cpp index 490940491c..46068dc89c 100644 --- a/xfa/fwl/core/cfwl_scrollbar.cpp +++ b/xfa/fwl/core/cfwl_scrollbar.cpp @@ -309,46 +309,6 @@ FX_FLOAT CFWL_ScrollBar::GetTrackPointPos(FX_FLOAT fx, FX_FLOAT fy) { return std::min(std::max(fPos, m_fRangeMin), m_fRangeMax); } -void CFWL_ScrollBar::GetTrackRect(CFX_RectF& rect, bool bLower) { - bool bDisabled = !!(m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled); - if (bDisabled) { - rect = bLower ? m_rtMinTrack : m_rtMaxTrack; - return; - } - - FX_FLOAT fW = m_rtThumb.width / 2; - FX_FLOAT fH = m_rtThumb.height / 2; - bool bVert = IsVertical(); - if (bLower) { - if (bVert) { - FX_FLOAT fMinTrackHeight = m_rtMinTrack.height - fH - m_rtMinBtn.height; - fMinTrackHeight = (fMinTrackHeight >= 0.0f) ? fMinTrackHeight : 0.0f; - rect.Set(m_rtMinTrack.left, m_rtMinTrack.top + m_rtMinBtn.height, - m_rtMinTrack.width, fMinTrackHeight); - return; - } - - FX_FLOAT fMinTrackWidth = m_rtMinTrack.width - fW - m_rtMinBtn.width + 2; - fMinTrackWidth = (fMinTrackWidth >= 0.0f) ? fMinTrackWidth : 0.0f; - rect.Set(m_rtMinTrack.left + m_rtMinBtn.width - 1, m_rtMinTrack.top, - fMinTrackWidth, m_rtMinTrack.height); - return; - } - - if (bVert) { - FX_FLOAT fMaxTrackHeight = m_rtMaxTrack.height - fH - m_rtMaxBtn.height; - fMaxTrackHeight = (fMaxTrackHeight >= 0.0f) ? fMaxTrackHeight : 0.0f; - rect.Set(m_rtMaxTrack.left, m_rtMaxTrack.top + fH, m_rtMaxTrack.width, - fMaxTrackHeight); - return; - } - - FX_FLOAT fMaxTrackWidth = m_rtMaxTrack.width - fW - m_rtMaxBtn.width + 2; - fMaxTrackWidth = (fMaxTrackWidth >= 0.0f) ? fMaxTrackWidth : 0.0f; - rect.Set(m_rtMaxTrack.left + fW, m_rtMaxTrack.top, fMaxTrackWidth, - m_rtMaxTrack.height); -} - bool CFWL_ScrollBar::SendEvent() { if (m_iMinButtonState == CFWL_PartState_Pressed) { DoScroll(CFWL_EvtScroll::Code::StepBackward, m_fTrackPos); diff --git a/xfa/fwl/core/cfwl_scrollbar.h b/xfa/fwl/core/cfwl_scrollbar.h index 5e9c0b5df2..fb44af6908 100644 --- a/xfa/fwl/core/cfwl_scrollbar.h +++ b/xfa/fwl/core/cfwl_scrollbar.h @@ -69,15 +69,15 @@ class CFWL_ScrollBar : public CFWL_Widget { } void DrawTrack(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme, - bool bLower = true, - const CFX_Matrix* pMatrix = nullptr); + bool bLower, + const CFX_Matrix* pMatrix); void DrawArrowBtn(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme, - bool bMinBtn = true, - const CFX_Matrix* pMatrix = nullptr); + bool bMinBtn, + const CFX_Matrix* pMatrix); void DrawThumb(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix = nullptr); + const CFX_Matrix* pMatrix); void Layout(); void CalcButtonLen(); void CalcMinButtonRect(CFX_RectF& rect); @@ -86,7 +86,7 @@ class CFWL_ScrollBar : public CFWL_Widget { void CalcMinTrackRect(CFX_RectF& rect); void CalcMaxTrackRect(CFX_RectF& rect); FX_FLOAT GetTrackPointPos(FX_FLOAT fx, FX_FLOAT fy); - void GetTrackRect(CFX_RectF& rect, bool bLower = true); + bool SendEvent(); bool OnScroll(CFWL_EvtScroll::Code dwCode, FX_FLOAT fPos); void OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); @@ -98,7 +98,7 @@ class CFWL_ScrollBar : public CFWL_Widget { uint32_t dwFlags, FX_FLOAT fDeltaX, FX_FLOAT fDeltaY); - bool DoScroll(CFWL_EvtScroll::Code dwCode, FX_FLOAT fPos = 0.0f); + bool DoScroll(CFWL_EvtScroll::Code dwCode, FX_FLOAT fPos); void DoMouseDown(int32_t iItem, const CFX_RectF& rtItem, int32_t& iState, diff --git a/xfa/fwl/core/cfwl_spinbutton.cpp b/xfa/fwl/core/cfwl_spinbutton.cpp index e66b92e701..8780fed1a9 100644 --- a/xfa/fwl/core/cfwl_spinbutton.cpp +++ b/xfa/fwl/core/cfwl_spinbutton.cpp @@ -114,17 +114,16 @@ void CFWL_SpinButton::DrawWidget(CFX_Graphics* pGraphics, DrawDownButton(pGraphics, pTheme, pMatrix); } -void CFWL_SpinButton::EnableButton(bool bEnable, bool bUp) { - if (bUp) - m_dwUpState = bEnable ? CFWL_PartState_Normal : CFWL_PartState_Disabled; - else - m_dwDnState = bEnable ? CFWL_PartState_Normal : CFWL_PartState_Disabled; +void CFWL_SpinButton::DisableButton() { + m_dwDnState = CFWL_PartState_Disabled; +} + +bool CFWL_SpinButton::IsUpButtonEnabled() { + return m_dwUpState != CFWL_PartState_Disabled; } -bool CFWL_SpinButton::IsButtonEnabled(bool bUp) { - if (bUp) - return (m_dwUpState != CFWL_PartState_Disabled); - return (m_dwDnState != CFWL_PartState_Disabled); +bool CFWL_SpinButton::IsDownButtonEnabled() { + return m_dwDnState != CFWL_PartState_Disabled; } void CFWL_SpinButton::DrawUpButton(CFX_Graphics* pGraphics, @@ -222,9 +221,9 @@ void CFWL_SpinButton::OnLButtonDown(CFWL_MsgMouse* pMsg) { SetFocus(true); bool bUpPress = - (m_rtUpButton.Contains(pMsg->m_fx, pMsg->m_fy) && IsButtonEnabled(true)); + (m_rtUpButton.Contains(pMsg->m_fx, pMsg->m_fy) && IsUpButtonEnabled()); bool bDnPress = - (m_rtDnButton.Contains(pMsg->m_fx, pMsg->m_fy) && IsButtonEnabled(false)); + (m_rtDnButton.Contains(pMsg->m_fx, pMsg->m_fy) && IsDownButtonEnabled()); if (!bUpPress && !bDnPress) return; if (bUpPress) { @@ -256,11 +255,11 @@ void CFWL_SpinButton::OnLButtonUp(CFWL_MsgMouse* pMsg) { } bool bRepaint = false; CFX_RectF rtInvalidate; - if (m_dwUpState == CFWL_PartState_Pressed && IsButtonEnabled(true)) { + if (m_dwUpState == CFWL_PartState_Pressed && IsUpButtonEnabled()) { m_dwUpState = CFWL_PartState_Normal; bRepaint = true; rtInvalidate = m_rtUpButton; - } else if (m_dwDnState == CFWL_PartState_Pressed && IsButtonEnabled(false)) { + } else if (m_dwDnState == CFWL_PartState_Pressed && IsDownButtonEnabled()) { m_dwDnState = CFWL_PartState_Normal; bRepaint = true; rtInvalidate = m_rtDnButton; @@ -277,13 +276,13 @@ void CFWL_SpinButton::OnMouseMove(CFWL_MsgMouse* pMsg) { CFX_RectF rtInvlidate; rtInvlidate.Reset(); if (m_rtUpButton.Contains(pMsg->m_fx, pMsg->m_fy)) { - if (IsButtonEnabled(true)) { + if (IsUpButtonEnabled()) { if (m_dwUpState == CFWL_PartState_Hovered) { m_dwUpState = CFWL_PartState_Hovered; bRepaint = true; rtInvlidate = m_rtUpButton; } - if (m_dwDnState != CFWL_PartState_Normal && IsButtonEnabled(false)) { + if (m_dwDnState != CFWL_PartState_Normal && IsDownButtonEnabled()) { m_dwDnState = CFWL_PartState_Normal; if (bRepaint) rtInvlidate.Union(m_rtDnButton); @@ -293,17 +292,17 @@ void CFWL_SpinButton::OnMouseMove(CFWL_MsgMouse* pMsg) { bRepaint = true; } } - if (!IsButtonEnabled(false)) - EnableButton(false, false); + if (!IsDownButtonEnabled()) + DisableButton(); } else if (m_rtDnButton.Contains(pMsg->m_fx, pMsg->m_fy)) { - if (IsButtonEnabled(false)) { + if (IsDownButtonEnabled()) { if (m_dwDnState != CFWL_PartState_Hovered) { m_dwDnState = CFWL_PartState_Hovered; bRepaint = true; rtInvlidate = m_rtDnButton; } - if (m_dwUpState != CFWL_PartState_Normal && IsButtonEnabled(true)) { + if (m_dwUpState != CFWL_PartState_Normal && IsUpButtonEnabled()) { m_dwUpState = CFWL_PartState_Normal; if (bRepaint) rtInvlidate.Union(m_rtUpButton); @@ -336,9 +335,9 @@ void CFWL_SpinButton::OnMouseMove(CFWL_MsgMouse* pMsg) { void CFWL_SpinButton::OnMouseLeave(CFWL_MsgMouse* pMsg) { if (!pMsg) return; - if (m_dwUpState != CFWL_PartState_Normal && IsButtonEnabled(true)) + if (m_dwUpState != CFWL_PartState_Normal && IsUpButtonEnabled()) m_dwUpState = CFWL_PartState_Normal; - if (m_dwDnState != CFWL_PartState_Normal && IsButtonEnabled(false)) + if (m_dwDnState != CFWL_PartState_Normal && IsDownButtonEnabled()) m_dwDnState = CFWL_PartState_Normal; Repaint(&m_rtClient); @@ -352,8 +351,8 @@ void CFWL_SpinButton::OnKeyDown(CFWL_MsgKey* pMsg) { if (!bUp && !bDown) return; - bool bUpEnable = IsButtonEnabled(true); - bool bDownEnable = IsButtonEnabled(false); + bool bUpEnable = IsUpButtonEnabled(); + bool bDownEnable = IsDownButtonEnabled(); if (!bUpEnable && !bDownEnable) return; diff --git a/xfa/fwl/core/cfwl_spinbutton.h b/xfa/fwl/core/cfwl_spinbutton.h index 2993663a58..fd2f02e998 100644 --- a/xfa/fwl/core/cfwl_spinbutton.h +++ b/xfa/fwl/core/cfwl_spinbutton.h @@ -44,8 +44,9 @@ class CFWL_SpinButton : public CFWL_Widget { }; friend class CFWL_SpinButton::Timer; - void EnableButton(bool bEnable, bool bUp = true); - bool IsButtonEnabled(bool bUp = true); + void DisableButton(); + bool IsUpButtonEnabled(); + bool IsDownButtonEnabled(); void DrawUpButton(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme, const CFX_Matrix* pMatrix); diff --git a/xfa/fwl/core/cfwl_widget.cpp b/xfa/fwl/core/cfwl_widget.cpp index 8989563112..2dff10adc7 100644 --- a/xfa/fwl/core/cfwl_widget.cpp +++ b/xfa/fwl/core/cfwl_widget.cpp @@ -76,7 +76,7 @@ void CFWL_Widget::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { rect.Inflate(fEdge, fEdge); } if (HasBorder()) { - FX_FLOAT fBorder = GetBorderSize(); + FX_FLOAT fBorder = GetBorderSize(true); rect.Inflate(fBorder, fBorder); } } @@ -317,7 +317,7 @@ void CFWL_Widget::GetEdgeRect(CFX_RectF& rtEdge) { rtEdge = m_pProperties->m_rtWidget; rtEdge.left = rtEdge.top = 0; if (HasBorder()) { - FX_FLOAT fCX = GetBorderSize(); + FX_FLOAT fCX = GetBorderSize(true); FX_FLOAT fCY = GetBorderSize(false); rtEdge.Deflate(fCX, fCY); } @@ -399,8 +399,7 @@ CFWL_Widget* CFWL_Widget::GetRootOuter() { CFX_SizeF CFWL_Widget::CalcTextSize(const CFX_WideString& wsText, IFWL_ThemeProvider* pTheme, - bool bMultiLine, - int32_t iLineWidth) { + bool bMultiLine) { if (!pTheme) return CFX_SizeF(); @@ -411,10 +410,8 @@ CFX_SizeF CFWL_Widget::CalcTextSize(const CFX_WideString& wsText, bMultiLine ? FDE_TTOSTYLE_LineWrap : FDE_TTOSTYLE_SingleLine; calPart.m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft; CFX_RectF rect; - FX_FLOAT fWidth = bMultiLine - ? (iLineWidth > 0 ? (FX_FLOAT)iLineWidth - : FWL_WGT_CalcMultiLineDefWidth) - : FWL_WGT_CalcWidth; + FX_FLOAT fWidth = + bMultiLine ? FWL_WGT_CalcMultiLineDefWidth : FWL_WGT_CalcWidth; rect.Set(0, 0, fWidth, FWL_WGT_CalcHeight); pTheme->CalcTextRect(&calPart, rect); return CFX_SizeF(rect.width, rect.height); diff --git a/xfa/fwl/core/cfwl_widget.h b/xfa/fwl/core/cfwl_widget.h index a17c623b53..4961055954 100644 --- a/xfa/fwl/core/cfwl_widget.h +++ b/xfa/fwl/core/cfwl_widget.h @@ -67,7 +67,7 @@ class CFWL_Widget : public IFWL_WidgetDelegate { void OnProcessMessage(CFWL_Message* pMessage) override; void OnProcessEvent(CFWL_Event* pEvent) override; void OnDrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix = nullptr) override; + const CFX_Matrix* pMatrix) override; void SetWidgetRect(const CFX_RectF& rect); @@ -88,7 +88,7 @@ class CFWL_Widget : public IFWL_WidgetDelegate { } void TransformTo(CFWL_Widget* pWidget, FX_FLOAT& fx, FX_FLOAT& fy); - void GetMatrix(CFX_Matrix& matrix, bool bGlobal = false); + void GetMatrix(CFX_Matrix& matrix, bool bGlobal); IFWL_ThemeProvider* GetThemeProvider() const; void SetDelegate(IFWL_WidgetDelegate* delegate) { m_pDelegate = delegate; } @@ -107,7 +107,7 @@ class CFWL_Widget : public IFWL_WidgetDelegate { void SetLayoutItem(void* pItem) { m_pLayoutItem = pItem; } void SetFocus(bool bFocus); - void Repaint(const CFX_RectF* pRect = nullptr); + void Repaint(const CFX_RectF* pRect); protected: CFWL_Widget(const CFWL_App* app, @@ -120,15 +120,14 @@ class CFWL_Widget : public IFWL_WidgetDelegate { bool HasBorder() const; bool HasEdge() const; void GetEdgeRect(CFX_RectF& rtEdge); - FX_FLOAT GetBorderSize(bool bCX = true); + FX_FLOAT GetBorderSize(bool bCX); FX_FLOAT GetEdgeWidth(); void GetRelativeRect(CFX_RectF& rect); void* GetThemeCapacity(CFWL_WidgetCapacity dwCapacity); IFWL_ThemeProvider* GetAvailableTheme(); CFX_SizeF CalcTextSize(const CFX_WideString& wsText, IFWL_ThemeProvider* pTheme, - bool bMultiLine = false, - int32_t iLineWidth = -1); + bool bMultiLine); void CalcTextRect(const CFX_WideString& wsText, IFWL_ThemeProvider* pTheme, uint32_t dwTTOStyles, @@ -145,11 +144,11 @@ class CFWL_Widget : public IFWL_WidgetDelegate { void DrawBorder(CFX_Graphics* pGraphics, CFWL_Part iPartBorder, IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix = nullptr); + const CFX_Matrix* pMatrix); void DrawEdge(CFX_Graphics* pGraphics, CFWL_Part iPartEdge, IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix = nullptr); + const CFX_Matrix* pMatrix); const CFWL_App* const m_pOwnerApp; CFWL_WidgetMgr* const m_pWidgetMgr; @@ -183,7 +182,7 @@ class CFWL_Widget : public IFWL_WidgetDelegate { void DrawBackground(CFX_Graphics* pGraphics, CFWL_Part iPartBk, IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix = nullptr); + const CFX_Matrix* pMatrix); void NotifyDriver(); bool IsParent(CFWL_Widget* pParent); diff --git a/xfa/fwl/core/cfwl_widgetmgr.cpp b/xfa/fwl/core/cfwl_widgetmgr.cpp index fc9f150ac3..1649ee76b9 100644 --- a/xfa/fwl/core/cfwl_widgetmgr.cpp +++ b/xfa/fwl/core/cfwl_widgetmgr.cpp @@ -104,7 +104,7 @@ CFWL_Widget* CFWL_WidgetMgr::GetSystemFormWidget(CFWL_Widget* pWidget) const { return nullptr; } -void CFWL_WidgetMgr::SetWidgetIndex(CFWL_Widget* pWidget, int32_t nIndex) { +void CFWL_WidgetMgr::AppendWidget(CFWL_Widget* pWidget) { Item* pItem = GetWidgetMgrItem(pWidget); if (!pItem) return; @@ -115,8 +115,6 @@ void CFWL_WidgetMgr::SetWidgetIndex(CFWL_Widget* pWidget, int32_t nIndex) { int32_t i = 0; while (pChild) { if (pChild == pItem) { - if (i == nIndex) - return; if (pChild->pPrevious) pChild->pPrevious->pNext = pChild->pNext; if (pChild->pNext) @@ -137,40 +135,16 @@ void CFWL_WidgetMgr::SetWidgetIndex(CFWL_Widget* pWidget, int32_t nIndex) { pChild = pItem->pParent->pChild; if (pChild) { - if (nIndex < 0) { - while (pChild->pNext) - pChild = pChild->pNext; - - pChild->pNext = pItem; - pItem->pPrevious = pChild; - pItem->pNext = nullptr; - return; - } - - i = 0; - while (i < nIndex && pChild->pNext) { + while (pChild->pNext) pChild = pChild->pNext; - ++i; - } - if (!pChild->pNext) { - pChild->pNext = pItem; - pItem->pPrevious = pChild; - pItem->pNext = nullptr; - return; - } - if (pChild->pPrevious) { - pItem->pPrevious = pChild->pPrevious; - pChild->pPrevious->pNext = pItem; - } - pChild->pPrevious = pItem; - pItem->pNext = pChild; - if (pItem->pParent->pChild == pChild) - pItem->pParent->pChild = pItem; + + pChild->pNext = pItem; + pItem->pPrevious = pChild; } else { pItem->pParent->pChild = pItem; pItem->pPrevious = nullptr; - pItem->pNext = nullptr; } + pItem->pNext = nullptr; } void CFWL_WidgetMgr::RepaintWidget(CFWL_Widget* pWidget, @@ -201,9 +175,7 @@ void CFWL_WidgetMgr::RepaintWidget(CFWL_Widget* pWidget, m_pAdapter->RepaintWidget(pNative, &rect); } -void CFWL_WidgetMgr::InsertWidget(CFWL_Widget* pParent, - CFWL_Widget* pChild, - int32_t nIndex) { +void CFWL_WidgetMgr::InsertWidget(CFWL_Widget* pParent, CFWL_Widget* pChild) { Item* pParentItem = GetWidgetMgrItem(pParent); if (!pParentItem) { auto item = pdfium::MakeUnique<Item>(pParent); @@ -211,7 +183,7 @@ void CFWL_WidgetMgr::InsertWidget(CFWL_Widget* pParent, m_mapWidgetItem[pParent] = std::move(item); pParentItem->pParent = GetWidgetMgrItem(nullptr); - SetWidgetIndex(pParent, -1); + AppendWidget(pParent); } Item* pItem = GetWidgetMgrItem(pChild); @@ -229,7 +201,7 @@ void CFWL_WidgetMgr::InsertWidget(CFWL_Widget* pParent, pItem->pParent->pChild = pItem->pNext; } pItem->pParent = pParentItem; - SetWidgetIndex(pChild, nIndex); + AppendWidget(pChild); } void CFWL_WidgetMgr::RemoveWidget(CFWL_Widget* pWidget) { @@ -260,7 +232,7 @@ void CFWL_WidgetMgr::SetOwner(CFWL_Widget* pOwner, CFWL_Widget* pOwned) { m_mapWidgetItem[pOwner] = std::move(item); pParentItem->pParent = GetWidgetMgrItem(nullptr); - SetWidgetIndex(pOwner, -1); + AppendWidget(pOwner); } Item* pItem = GetWidgetMgrItem(pOwned); @@ -288,7 +260,7 @@ void CFWL_WidgetMgr::SetParent(CFWL_Widget* pParent, CFWL_Widget* pChild) { pItem->pPrevious = nullptr; } pItem->pParent = pParentItem; - SetWidgetIndex(pChild, -1); + AppendWidget(pChild); } void CFWL_WidgetMgr::SetWidgetRect_Native(CFWL_Widget* pWidget, @@ -327,7 +299,7 @@ CFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(CFWL_Widget* parent, x1 = x; y1 = y; CFX_Matrix matrixOnParent; - child->GetMatrix(matrixOnParent); + child->GetMatrix(matrixOnParent, false); CFX_Matrix m; m.SetIdentity(); m.SetReverse(matrixOnParent); diff --git a/xfa/fwl/core/cfwl_widgetmgr.h b/xfa/fwl/core/cfwl_widgetmgr.h index 70d8b7ec7c..5b72d44577 100644 --- a/xfa/fwl/core/cfwl_widgetmgr.h +++ b/xfa/fwl/core/cfwl_widgetmgr.h @@ -42,11 +42,9 @@ class CFWL_WidgetMgr : public CFWL_WidgetMgrDelegate { CFWL_Widget* GetFirstChildWidget(CFWL_Widget* pWidget) const; CFWL_Widget* GetSystemFormWidget(CFWL_Widget* pWidget) const; - void RepaintWidget(CFWL_Widget* pWidget, const CFX_RectF* pRect = nullptr); + void RepaintWidget(CFWL_Widget* pWidget, const CFX_RectF* pRect); - void InsertWidget(CFWL_Widget* pParent, - CFWL_Widget* pChild, - int32_t nIndex = -1); + void InsertWidget(CFWL_Widget* pParent, CFWL_Widget* pChild); void RemoveWidget(CFWL_Widget* pWidget); void SetOwner(CFWL_Widget* pOwner, CFWL_Widget* pOwned); void SetParent(CFWL_Widget* pParent, CFWL_Widget* pChild); @@ -99,7 +97,7 @@ class CFWL_WidgetMgr : public CFWL_WidgetMgrDelegate { CFWL_Widget* GetLastChildWidget(CFWL_Widget* pWidget) const; Item* GetWidgetMgrItem(CFWL_Widget* pWidget) const; - void SetWidgetIndex(CFWL_Widget* pWidget, int32_t nIndex); + void AppendWidget(CFWL_Widget* pWidget); int32_t CountRadioButtonGroup(CFWL_Widget* pFirst) const; CFWL_Widget* GetRadioButtonGroupHeader(CFWL_Widget* pRadioButton) const; diff --git a/xfa/fwl/core/ifwl_widgetdelegate.h b/xfa/fwl/core/ifwl_widgetdelegate.h index 7de14824c5..042679359c 100644 --- a/xfa/fwl/core/ifwl_widgetdelegate.h +++ b/xfa/fwl/core/ifwl_widgetdelegate.h @@ -21,7 +21,7 @@ class IFWL_WidgetDelegate { virtual void OnProcessMessage(CFWL_Message* pMessage) = 0; virtual void OnProcessEvent(CFWL_Event* pEvent) = 0; virtual void OnDrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix = nullptr) = 0; + const CFX_Matrix* pMatrix) = 0; }; #endif // XFA_FWL_CORE_IFWL_WIDGETDELEGATE_H_ diff --git a/xfa/fxfa/app/xfa_fftextedit.cpp b/xfa/fxfa/app/xfa_fftextedit.cpp index 89c323c23b..a678a20f6c 100644 --- a/xfa/fxfa/app/xfa_fftextedit.cpp +++ b/xfa/fxfa/app/xfa_fftextedit.cpp @@ -303,13 +303,13 @@ void CXFA_FFTextEdit::OnTextChanged(CFWL_Widget* pWidget, eParam.m_wsNewText = pDateTime->GetEditText(); int32_t iSels = pDateTime->CountSelRanges(); if (iSels) { - eParam.m_iSelEnd = pDateTime->GetSelRange(0, eParam.m_iSelStart); + eParam.m_iSelEnd = pDateTime->GetSelRange(0, &eParam.m_iSelStart); } } else { eParam.m_wsNewText = pEdit->GetText(); int32_t iSels = pEdit->CountSelRanges(); if (iSels) { - eParam.m_iSelEnd = pEdit->GetSelRange(0, eParam.m_iSelStart); + eParam.m_iSelEnd = pEdit->GetSelRange(0, &eParam.m_iSelStart); } } m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); |