From 522c3d414e26a8a6b14407d664cee38fa3f52c07 Mon Sep 17 00:00:00 2001 From: dsinclair Date: Thu, 10 Nov 2016 14:01:19 -0800 Subject: IFWL method and param cleanup Cleaning up virtual methods, unused methods, and visibility. Review-Url: https://codereview.chromium.org/2491103002 --- xfa/fwl/core/cfwl_combobox.cpp | 5 - xfa/fwl/core/cfwl_combobox.h | 1 - xfa/fwl/core/cfwl_edit.cpp | 203 ++------------- xfa/fwl/core/cfwl_edit.h | 42 +--- xfa/fwl/core/cfwl_event.h | 1 - xfa/fwl/core/ifwl_barcode.cpp | 16 +- xfa/fwl/core/ifwl_barcode.h | 7 +- xfa/fwl/core/ifwl_combobox.cpp | 24 +- xfa/fwl/core/ifwl_combobox.h | 1 - xfa/fwl/core/ifwl_comboedit.cpp | 4 +- xfa/fwl/core/ifwl_datetimepicker.cpp | 19 +- xfa/fwl/core/ifwl_edit.cpp | 472 ++++++++--------------------------- xfa/fwl/core/ifwl_edit.h | 117 +++------ xfa/fwl/core/ifwl_form.cpp | 144 +---------- xfa/fwl/core/ifwl_form.h | 57 ++--- 15 files changed, 235 insertions(+), 878 deletions(-) (limited to 'xfa/fwl') diff --git a/xfa/fwl/core/cfwl_combobox.cpp b/xfa/fwl/core/cfwl_combobox.cpp index bd045f4e71..1a75927dda 100644 --- a/xfa/fwl/core/cfwl_combobox.cpp +++ b/xfa/fwl/core/cfwl_combobox.cpp @@ -127,11 +127,6 @@ FWL_Error CFWL_ComboBox::SetEditLimit(int32_t nLimit) { : FWL_Error::Indefinite; } -FWL_Error CFWL_ComboBox::EditDoClipboard(int32_t iCmd) { - return GetWidget() ? ToComboBox(GetWidget())->EditDoClipboard(iCmd) - : FWL_Error::Indefinite; -} - bool CFWL_ComboBox::EditRedo(const IFDE_TxtEdtDoRecord* pRecord) { return GetWidget() ? ToComboBox(GetWidget())->EditRedo(pRecord) : false; } diff --git a/xfa/fwl/core/cfwl_combobox.h b/xfa/fwl/core/cfwl_combobox.h index 84864714a5..246711983d 100644 --- a/xfa/fwl/core/cfwl_combobox.h +++ b/xfa/fwl/core/cfwl_combobox.h @@ -37,7 +37,6 @@ class CFWL_ComboBox : public CFWL_Widget, public IFWL_ComboBoxDP { int32_t GetEditSelRange(int32_t nIndex, int32_t& nStart); int32_t GetEditLimit(); FWL_Error SetEditLimit(int32_t nLimit); - FWL_Error EditDoClipboard(int32_t iCmd); bool EditRedo(const IFDE_TxtEdtDoRecord* pRecord); bool EditUndo(const IFDE_TxtEdtDoRecord* pRecord); FWL_Error SetMaxListHeight(FX_FLOAT fMaxHeight); diff --git a/xfa/fwl/core/cfwl_edit.cpp b/xfa/fwl/core/cfwl_edit.cpp index 579442b369..c7acf18f77 100644 --- a/xfa/fwl/core/cfwl_edit.cpp +++ b/xfa/fwl/core/cfwl_edit.cpp @@ -17,10 +17,6 @@ IFWL_Edit* ToEdit(IFWL_Widget* widget) { return static_cast(widget); } -const IFWL_Edit* ToEdit(const IFWL_Widget* widget) { - return static_cast(widget); -} - } // namespace CFWL_Edit::CFWL_Edit(const IFWL_App* app) : CFWL_Widget(app) {} @@ -36,202 +32,41 @@ void CFWL_Edit::Initialize() { CFWL_Widget::Initialize(); } -FWL_Error CFWL_Edit::SetText(const CFX_WideString& wsText) { - if (!GetWidget()) - return FWL_Error::Indefinite; - return ToEdit(GetWidget())->SetText(wsText); -} - -int32_t CFWL_Edit::GetTextLength() const { - if (!GetWidget()) - return 0; - return ToEdit(GetWidget())->GetTextLength(); -} - -FWL_Error CFWL_Edit::GetText(CFX_WideString& wsText, - int32_t nStart, - int32_t nCount) const { - if (!GetWidget()) - return FWL_Error::Indefinite; - return ToEdit(GetWidget())->GetText(wsText, nStart, nCount); -} - -FWL_Error CFWL_Edit::ClearText() { - if (!GetWidget()) - return FWL_Error::Indefinite; - return ToEdit(GetWidget())->ClearText(); -} - -int32_t CFWL_Edit::GetCaretPos() const { - if (!GetWidget()) - return -1; - return ToEdit(GetWidget())->GetCaretPos(); +void CFWL_Edit::SetText(const CFX_WideString& wsText) { + if (GetWidget()) + ToEdit(GetWidget())->SetText(wsText); } -int32_t CFWL_Edit::SetCaretPos(int32_t nIndex, bool bBefore) { - if (!GetWidget()) - return -1; - return ToEdit(GetWidget())->SetCaretPos(nIndex, bBefore); -} - -int32_t CFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount) { - if (!GetWidget()) - return -1; - ToEdit(GetWidget())->AddSelRange(nStart, nCount); - int32_t pos = 0; - int32_t sum = ToEdit(GetWidget())->GetTextLength(); - if (nCount == -1) { - pos = sum; - } else { - pos = nStart + nCount; - } - return ToEdit(GetWidget())->SetCaretPos(pos); +void CFWL_Edit::GetText(CFX_WideString& wsText, + int32_t nStart, + int32_t nCount) { + if (GetWidget()) + ToEdit(GetWidget())->GetText(wsText, nStart, nCount); } int32_t CFWL_Edit::CountSelRanges() { - if (!GetWidget()) - return 0; - return ToEdit(GetWidget())->CountSelRanges(); + return GetWidget() ? ToEdit(GetWidget())->CountSelRanges() : 0; } int32_t CFWL_Edit::GetSelRange(int32_t nIndex, int32_t& nStart) { - if (!GetWidget()) - return 0; - return ToEdit(GetWidget())->GetSelRange(nIndex, nStart); -} - -FWL_Error CFWL_Edit::ClearSelections() { - if (!GetWidget()) - return FWL_Error::Indefinite; - return ToEdit(GetWidget())->ClearSelections(); + return GetWidget() ? ToEdit(GetWidget())->GetSelRange(nIndex, nStart) : 0; } int32_t CFWL_Edit::GetLimit() { - if (!GetWidget()) - return -1; - return ToEdit(GetWidget())->GetLimit(); -} - -FWL_Error CFWL_Edit::SetLimit(int32_t nLimit) { - if (!GetWidget()) - return FWL_Error::Indefinite; - return ToEdit(GetWidget())->SetLimit(nLimit); -} - -FWL_Error CFWL_Edit::SetAliasChar(FX_WCHAR wAlias) { - if (!GetWidget()) - return FWL_Error::Indefinite; - return ToEdit(GetWidget())->SetAliasChar(wAlias); -} - -FWL_Error CFWL_Edit::Insert(int32_t nStart, - const FX_WCHAR* lpText, - int32_t nLen) { - if (!GetWidget()) - return FWL_Error::Indefinite; - return ToEdit(GetWidget())->Insert(nStart, lpText, nLen); -} - -FWL_Error CFWL_Edit::DeleteSelections() { - if (!GetWidget()) - return FWL_Error::Indefinite; - return ToEdit(GetWidget())->DeleteSelections(); -} - -FWL_Error CFWL_Edit::DeleteRange(int32_t nStart, int32_t nCount) { - if (!GetWidget()) - return FWL_Error::Indefinite; - return ToEdit(GetWidget())->DeleteRange(nStart, nCount); -} - -FWL_Error CFWL_Edit::Replace(int32_t nStart, - int32_t nLen, - const CFX_WideStringC& wsReplace) { - if (!GetWidget()) - return FWL_Error::Indefinite; - return ToEdit(GetWidget())->Replace(nStart, nLen, wsReplace); -} - -FWL_Error CFWL_Edit::DoClipboard(int32_t iCmd) { - if (!GetWidget()) - return FWL_Error::Indefinite; - return ToEdit(GetWidget())->DoClipboard(iCmd); + return GetWidget() ? ToEdit(GetWidget())->GetLimit() : -1; } -bool CFWL_Edit::Redo(const IFDE_TxtEdtDoRecord* pRecord) { - return GetWidget() && ToEdit(GetWidget())->Redo(pRecord); +void CFWL_Edit::SetLimit(int32_t nLimit) { + if (GetWidget()) + ToEdit(GetWidget())->SetLimit(nLimit); } -bool CFWL_Edit::Undo(const IFDE_TxtEdtDoRecord* pRecord) { - return GetWidget() && ToEdit(GetWidget())->Undo(pRecord); -} - -FWL_Error CFWL_Edit::SetTabWidth(FX_FLOAT fTabWidth, bool bEquidistant) { - if (!GetWidget()) - return FWL_Error::Indefinite; - return ToEdit(GetWidget())->SetTabWidth(fTabWidth, bEquidistant); -} - -FWL_Error CFWL_Edit::SetNumberRange(int32_t iMin, int32_t iMax) { - if (iMin > iMax) - return FWL_Error::ParameterInvalid; - return ToEdit(GetWidget())->SetNumberRange(iMin, iMax); -} - -FWL_Error CFWL_Edit::SetBackColor(uint32_t dwColor) { - if (!GetWidget()) - return FWL_Error::Indefinite; - return ToEdit(GetWidget())->SetBackgroundColor(dwColor); -} - -FWL_Error CFWL_Edit::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) { - if (!GetWidget()) - return FWL_Error::Indefinite; - return ToEdit(GetWidget())->SetFont(wsFont, fSize); -} - -bool CFWL_Edit::CanUndo() { - return ToEdit(GetWidget())->CanUndo(); -} - -bool CFWL_Edit::CanRedo() { - return ToEdit(GetWidget())->CanRedo(); -} - -bool CFWL_Edit::Undo() { - return ToEdit(GetWidget())->Undo(); -} - -bool CFWL_Edit::Redo() { - return ToEdit(GetWidget())->Undo(); -} - -bool CFWL_Edit::Copy(CFX_WideString& wsCopy) { - return ToEdit(GetWidget())->Copy(wsCopy); -} - -bool CFWL_Edit::Cut(CFX_WideString& wsCut) { - return ToEdit(GetWidget())->Cut(wsCut); -} - -bool CFWL_Edit::Paste(const CFX_WideString& wsPaste) { - return ToEdit(GetWidget())->Paste(wsPaste); -} - -bool CFWL_Edit::Delete() { - return ToEdit(GetWidget())->Delete(); +void CFWL_Edit::SetAliasChar(FX_WCHAR wAlias) { + if (GetWidget()) + ToEdit(GetWidget())->SetAliasChar(wAlias); } void CFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) { - return ToEdit(GetWidget())->SetScrollOffset(fScrollOffset); -} - -bool CFWL_Edit::GetSuggestWords(CFX_PointF pointf, - std::vector& sSuggest) { - return ToEdit(GetWidget())->GetSuggestWords(pointf, sSuggest); -} - -bool CFWL_Edit::ReplaceSpellCheckWord(CFX_PointF pointf, - const CFX_ByteStringC& bsReplace) { - return ToEdit(GetWidget())->ReplaceSpellCheckWord(pointf, bsReplace); + if (GetWidget()) + ToEdit(GetWidget())->SetScrollOffset(fScrollOffset); } diff --git a/xfa/fwl/core/cfwl_edit.h b/xfa/fwl/core/cfwl_edit.h index 2f2983b092..a3a77a7f52 100644 --- a/xfa/fwl/core/cfwl_edit.h +++ b/xfa/fwl/core/cfwl_edit.h @@ -21,48 +21,14 @@ class CFWL_Edit : public CFWL_Widget { void Initialize(); - FWL_Error SetText(const CFX_WideString& wsText); - int32_t GetTextLength() const; - FWL_Error GetText(CFX_WideString& wsText, - int32_t nStart = 0, - int32_t nCount = -1) const; - FWL_Error ClearText(); - int32_t GetCaretPos() const; - int32_t SetCaretPos(int32_t nIndex, bool bBefore = true); - int32_t AddSelRange(int32_t nStart, int32_t nCount = -1); + void SetText(const CFX_WideString& wsText); + void GetText(CFX_WideString& wsText, int32_t nStart = 0, int32_t nCount = -1); int32_t CountSelRanges(); int32_t GetSelRange(int32_t nIndex, int32_t& nStart); - FWL_Error ClearSelections(); int32_t GetLimit(); - FWL_Error SetLimit(int32_t nLimit); - FWL_Error SetAliasChar(FX_WCHAR wAlias); - FWL_Error SetFormatString(const CFX_WideString& wsFormat); - FWL_Error Insert(int32_t nStart, const FX_WCHAR* lpText, int32_t nLen); - FWL_Error DeleteSelections(); - FWL_Error DeleteRange(int32_t nStart, int32_t nCount = -1); - FWL_Error Replace(int32_t nStart, - int32_t nLen, - const CFX_WideStringC& wsReplace); - FWL_Error DoClipboard(int32_t iCmd); - bool Redo(const IFDE_TxtEdtDoRecord* pRecord); - bool Undo(const IFDE_TxtEdtDoRecord* pRecord); - FWL_Error SetTabWidth(FX_FLOAT fTabWidth, bool bEquidistant); - FWL_Error SetNumberRange(int32_t iMin, int32_t iMax); - FWL_Error SetBackColor(uint32_t dwColor); - FWL_Error SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize); - bool CanUndo(); - bool CanRedo(); - bool Undo(); - bool Redo(); - bool Copy(CFX_WideString& wsCopy); - bool Cut(CFX_WideString& wsCut); - bool Paste(const CFX_WideString& wsPaste); - bool Delete(); + void SetLimit(int32_t nLimit); + void SetAliasChar(FX_WCHAR wAlias); void SetScrollOffset(FX_FLOAT fScrollOffset); - bool GetSuggestWords(CFX_PointF pointf, - std::vector& sSuggest); - bool ReplaceSpellCheckWord(CFX_PointF pointf, - const CFX_ByteStringC& bsReplace); }; #endif // XFA_FWL_CORE_CFWL_EDIT_H_ diff --git a/xfa/fwl/core/cfwl_event.h b/xfa/fwl/core/cfwl_event.h index ba8a4d683f..0052c4e097 100644 --- a/xfa/fwl/core/cfwl_event.h +++ b/xfa/fwl/core/cfwl_event.h @@ -41,7 +41,6 @@ enum class CFWL_EventType { DrawItem, DropDown, EditChanged, - GetSuggestedWords, HoverChanged, Idle, Key, diff --git a/xfa/fwl/core/ifwl_barcode.cpp b/xfa/fwl/core/ifwl_barcode.cpp index 518ed4a599..c918b3bc8c 100644 --- a/xfa/fwl/core/ifwl_barcode.cpp +++ b/xfa/fwl/core/ifwl_barcode.cpp @@ -45,8 +45,8 @@ void IFWL_Barcode::DrawWidget(CFX_Graphics* pGraphics, return; } CFX_Matrix mt; - mt.e = m_rtClient.left; - mt.f = m_rtClient.top; + mt.e = GetRTClient().left; + mt.f = GetRTClient().top; if (pMatrix) { mt.Concat(*pMatrix); } @@ -69,8 +69,8 @@ void IFWL_Barcode::GenerateBarcodeImageCache() { if (!m_pBarcodeEngine) return; CFX_WideString wsText; - if (GetText(wsText) != FWL_Error::Succeeded) - return; + GetText(wsText); + CFWL_ThemePart part; part.m_pWidget = this; IFWL_ThemeProvider* pTheme = GetAvailableTheme(); @@ -90,8 +90,8 @@ void IFWL_Barcode::GenerateBarcodeImageCache() { if (pFontColor) { m_pBarcodeEngine->SetFontColor(*pFontColor); } - m_pBarcodeEngine->SetHeight(int32_t(m_rtClient.height)); - m_pBarcodeEngine->SetWidth(int32_t(m_rtClient.width)); + m_pBarcodeEngine->SetHeight(int32_t(GetRTClient().height)); + m_pBarcodeEngine->SetWidth(int32_t(GetRTClient().width)); uint32_t dwAttributeMask = pData->GetBarcodeAttributeMask(); if (dwAttributeMask & FWL_BCDATTRIBUTE_CHARENCODING) { m_pBarcodeEngine->SetCharEncoding(pData->GetCharEncoding()); @@ -155,10 +155,10 @@ void IFWL_Barcode::SetType(BC_TYPE type) { m_type = type; m_dwStatus = XFA_BCS_NeedUpdate; } -FWL_Error IFWL_Barcode::SetText(const CFX_WideString& wsText) { +void IFWL_Barcode::SetText(const CFX_WideString& wsText) { m_pBarcodeEngine.reset(); m_dwStatus = XFA_BCS_NeedUpdate; - return IFWL_Edit::SetText(wsText); + IFWL_Edit::SetText(wsText); } bool IFWL_Barcode::IsProtectedType() { if (!m_pBarcodeEngine) { diff --git a/xfa/fwl/core/ifwl_barcode.h b/xfa/fwl/core/ifwl_barcode.h index 28025fc8bc..1d88c32259 100644 --- a/xfa/fwl/core/ifwl_barcode.h +++ b/xfa/fwl/core/ifwl_barcode.h @@ -9,6 +9,7 @@ #include +#include "xfa/fwl/core/ifwl_dataprovider.h" #include "xfa/fwl/core/ifwl_edit.h" #include "xfa/fwl/core/ifwl_scrollbar.h" #include "xfa/fxbarcode/BC_Library.h" @@ -37,7 +38,7 @@ enum FWL_BCDAttribute { FWL_BCDATTRIBUTE_TRUNCATED = 1 << 12 }; -class IFWL_BarcodeDP : public IFWL_EditDP { +class IFWL_BarcodeDP : public IFWL_DataProvider { public: virtual BC_CHAR_ENCODING GetCharEncoding() const = 0; virtual int32_t GetModuleHeight() const = 0; @@ -66,9 +67,11 @@ class IFWL_Barcode : public IFWL_Edit { void Update() override; void DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix = nullptr) override; - FWL_Error SetText(const CFX_WideString& wsText) override; void OnProcessEvent(CFWL_Event* pEvent) override; + // IFWL_Edit + void SetText(const CFX_WideString& wsText) override; + void SetType(BC_TYPE type); bool IsProtectedType(); diff --git a/xfa/fwl/core/ifwl_combobox.cpp b/xfa/fwl/core/ifwl_combobox.cpp index b0fc9a3a98..e8534a45f2 100644 --- a/xfa/fwl/core/ifwl_combobox.cpp +++ b/xfa/fwl/core/ifwl_combobox.cpp @@ -286,8 +286,10 @@ FWL_Error IFWL_ComboBox::GetEditText(CFX_WideString& wsText, int32_t nStart, int32_t nCount) const { if (m_pEdit) { - return m_pEdit->GetText(wsText, nStart, nCount); - } else if (m_pListBox) { + m_pEdit->GetText(wsText, nStart, nCount); + return FWL_Error::Succeeded; + } + if (m_pListBox) { IFWL_ComboBoxDP* pData = static_cast(m_pProperties->m_pDataProvider); CFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel); @@ -320,13 +322,8 @@ int32_t IFWL_ComboBox::GetEditLimit() { FWL_Error IFWL_ComboBox::SetEditLimit(int32_t nLimit) { if (!m_pEdit) return FWL_Error::Indefinite; - return m_pEdit->SetLimit(nLimit); -} - -FWL_Error IFWL_ComboBox::EditDoClipboard(int32_t iCmd) { - if (!m_pEdit) - return FWL_Error::Indefinite; - return m_pEdit->DoClipboard(iCmd); + m_pEdit->SetLimit(nLimit); + return FWL_Error::Succeeded; } bool IFWL_ComboBox::EditRedo(const IFDE_TxtEdtDoRecord* pRecord) { @@ -402,15 +399,18 @@ bool IFWL_ComboBox::EditPaste(const CFX_WideString& wsPaste) { } bool IFWL_ComboBox::EditSelectAll() { - return m_pEdit->AddSelRange(0) == FWL_Error::Succeeded; + m_pEdit->AddSelRange(0); + return true; } bool IFWL_ComboBox::EditDelete() { - return m_pEdit->ClearText() == FWL_Error::Succeeded; + m_pEdit->ClearText(); + return true; } bool IFWL_ComboBox::EditDeSelect() { - return m_pEdit->ClearSelections() == FWL_Error::Succeeded; + m_pEdit->ClearSelections(); + return true; } FWL_Error IFWL_ComboBox::GetBBox(CFX_RectF& rect) { diff --git a/xfa/fwl/core/ifwl_combobox.h b/xfa/fwl/core/ifwl_combobox.h index e5065dbbc3..0b586b424f 100644 --- a/xfa/fwl/core/ifwl_combobox.h +++ b/xfa/fwl/core/ifwl_combobox.h @@ -110,7 +110,6 @@ class IFWL_ComboBox : public IFWL_Widget { int32_t GetEditSelRange(int32_t nIndex, int32_t& nStart); int32_t GetEditLimit(); FWL_Error SetEditLimit(int32_t nLimit); - FWL_Error EditDoClipboard(int32_t iCmd); bool EditRedo(const IFDE_TxtEdtDoRecord* pRecord); bool EditUndo(const IFDE_TxtEdtDoRecord* pRecord); IFWL_ListBox* GetListBoxt(); diff --git a/xfa/fwl/core/ifwl_comboedit.cpp b/xfa/fwl/core/ifwl_comboedit.cpp index a8b04fda89..2a7ac904e1 100644 --- a/xfa/fwl/core/ifwl_comboedit.cpp +++ b/xfa/fwl/core/ifwl_comboedit.cpp @@ -19,7 +19,7 @@ IFWL_ComboEdit::IFWL_ComboEdit( void IFWL_ComboEdit::ClearSelected() { ClearSelections(); - Repaint(&m_rtClient); + Repaint(&GetRTClient()); } void IFWL_ComboEdit::SetSelected() { @@ -29,7 +29,7 @@ void IFWL_ComboEdit::SetSelected() { } void IFWL_ComboEdit::EndCaret() { - m_pEdtEngine->MoveCaretPos(MC_End); + GetTxtEdtEngine()->MoveCaretPos(MC_End); } void IFWL_ComboEdit::FlagFocus(bool bSet) { diff --git a/xfa/fwl/core/ifwl_datetimepicker.cpp b/xfa/fwl/core/ifwl_datetimepicker.cpp index 31e5b65cf0..ff2dbfbc4c 100644 --- a/xfa/fwl/core/ifwl_datetimepicker.cpp +++ b/xfa/fwl/core/ifwl_datetimepicker.cpp @@ -204,19 +204,20 @@ FWL_Error IFWL_DateTimePicker::SetEditText(const CFX_WideString& wsText) { if (!m_pEdit) return FWL_Error::Indefinite; - FWL_Error iRet = m_pEdit->SetText(wsText); + m_pEdit->SetText(wsText); Repaint(&m_rtClient); CFWL_Event_DtpEditChanged ev; ev.m_wsText = wsText; DispatchEvent(&ev); - return iRet; + return FWL_Error::Succeeded; } FWL_Error IFWL_DateTimePicker::GetEditText(CFX_WideString& wsText, int32_t nStart, int32_t nCount) const { if (m_pEdit) { - return m_pEdit->GetText(wsText, nStart, nCount); + m_pEdit->GetText(wsText, nStart, nCount); + return FWL_Error::Succeeded; } return FWL_Error::Indefinite; } @@ -267,15 +268,18 @@ bool IFWL_DateTimePicker::Paste(const CFX_WideString& wsPaste) { } bool IFWL_DateTimePicker::SelectAll() { - return m_pEdit->AddSelRange(0) == FWL_Error::Succeeded; + m_pEdit->AddSelRange(0); + return true; } bool IFWL_DateTimePicker::Delete() { - return m_pEdit->ClearText() == FWL_Error::Succeeded; + m_pEdit->ClearText(); + return true; } bool IFWL_DateTimePicker::DeSelect() { - return m_pEdit->ClearSelections() == FWL_Error::Succeeded; + m_pEdit->ClearSelections(); + return true; } FWL_Error IFWL_DateTimePicker::GetBBox(CFX_RectF& rect) { @@ -294,7 +298,8 @@ FWL_Error IFWL_DateTimePicker::GetBBox(CFX_RectF& rect) { } FWL_Error IFWL_DateTimePicker::SetEditLimit(int32_t nLimit) { - return m_pEdit->SetLimit(nLimit); + m_pEdit->SetLimit(nLimit); + return FWL_Error::Succeeded; } void IFWL_DateTimePicker::ModifyEditStylesEx(uint32_t dwStylesExAdded, diff --git a/xfa/fwl/core/ifwl_edit.cpp b/xfa/fwl/core/ifwl_edit.cpp index 1679a5b16d..aa3fdcec39 100644 --- a/xfa/fwl/core/ifwl_edit.cpp +++ b/xfa/fwl/core/ifwl_edit.cpp @@ -62,14 +62,9 @@ IFWL_Edit::IFWL_Edit(const IFWL_App* app, m_bLButtonDown(false), m_nSelStart(0), m_nLimit(-1), - m_fSpaceAbove(0), - m_fSpaceBelow(0), m_fFontSize(0), m_bSetRange(false), - m_iMin(-1), m_iMax(0xFFFFFFF), - m_backColor(0), - m_updateBackColor(false), m_iCurRecord(-1), m_iMaxRecord(128) { m_rtClient.Reset(); @@ -77,8 +72,6 @@ IFWL_Edit::IFWL_Edit(const IFWL_App* app, m_rtStatic.Reset(); InitCaret(); - if (!m_pEdtEngine) - InitEngine(); } IFWL_Edit::~IFWL_Edit() { @@ -95,16 +88,15 @@ FWL_Type IFWL_Edit::GetClassID() const { void IFWL_Edit::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { if (bAutoSize) { rect.Set(0, 0, 0, 0); - if (m_pEdtEngine) { - int32_t iTextLen = m_pEdtEngine->GetTextLength(); - if (iTextLen > 0) { - CFX_WideString wsText; - m_pEdtEngine->GetText(wsText, 0); - CFX_SizeF sz = CalcTextSize( - wsText, m_pProperties->m_pThemeProvider, - !!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine)); - rect.Set(0, 0, sz.x, sz.y); - } + + int32_t iTextLen = m_EdtEngine.GetTextLength(); + if (iTextLen > 0) { + CFX_WideString wsText; + m_EdtEngine.GetText(wsText, 0); + CFX_SizeF sz = CalcTextSize( + wsText, m_pProperties->m_pThemeProvider, + !!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine)); + rect.Set(0, 0, sz.x, sz.y); } IFWL_Widget::GetWidgetRect(rect, true); } else { @@ -180,10 +172,10 @@ void IFWL_Edit::AddSpellCheckObj(CFX_Path& PathData, FX_FLOAT fEndX = 0.0f; FX_FLOAT fY = 0.0f; FX_FLOAT fStep = 0.0f; - IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); + IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0); CFX_RectFArray rectArray; CFX_RectF rectText; - const FDE_TXTEDTPARAMS* txtEdtParams = m_pEdtEngine->GetEditParams(); + const FDE_TXTEDTPARAMS* txtEdtParams = m_EdtEngine.GetEditParams(); FX_FLOAT fAsent = (FX_FLOAT)txtEdtParams->pFont->GetAscent() * txtEdtParams->fFontSize / 1000; pPage->CalcRangeRectArray(nStart, nCount, rectArray); @@ -196,69 +188,6 @@ void IFWL_Edit::AddSpellCheckObj(CFX_Path& PathData, AddSquigglyPath(&PathData, fStartX, fEndX, fY, fStep); } } -int32_t IFWL_Edit::GetWordAtPoint(CFX_PointF pointf, int32_t& nCount) { - return 0; -} -bool IFWL_Edit::GetSuggestWords(CFX_PointF pointf, - std::vector& sSuggest) { - int32_t nWordCount = 0; - int32_t nWordStart = GetWordAtPoint(pointf, nWordCount); - if (nWordCount < 1) { - return false; - } - CFX_WideString wsSpell; - GetText(wsSpell, nWordStart, nWordCount); - CFX_ByteString sLatinWord; - for (int i = 0; i < nWordCount; i++) { - if (!FX_EDIT_ISLATINWORD(wsSpell[i])) { - break; - } - sLatinWord += (FX_CHAR)wsSpell[i]; - } - if (sLatinWord.IsEmpty()) { - return false; - } - CFWL_EvtEdtCheckWord checkWordEvent; - checkWordEvent.m_pSrcTarget = this; - checkWordEvent.bsWord = sLatinWord; - checkWordEvent.bCheckWord = true; - DispatchEvent(&checkWordEvent); - if (checkWordEvent.bCheckWord) { - return false; - } - CFWL_EvtEdtGetSuggestWords suggestWordsEvent; - suggestWordsEvent.m_pSrcTarget = this; - suggestWordsEvent.bsWord = sLatinWord; - suggestWordsEvent.bsArraySuggestWords = sSuggest; - suggestWordsEvent.bSuggestWords = false; - DispatchEvent(&checkWordEvent); - return suggestWordsEvent.bSuggestWords; -} -bool IFWL_Edit::ReplaceSpellCheckWord(CFX_PointF pointf, - const CFX_ByteStringC& bsReplace) { - int32_t nWordCount = 0; - int32_t nWordStart = GetWordAtPoint(pointf, nWordCount); - if (nWordCount < 1) { - return false; - } - CFX_WideString wsSpell; - GetText(wsSpell, nWordStart, nWordCount); - for (int i = 0; i < nWordCount; i++) { - if (!FX_EDIT_ISLATINWORD(wsSpell[i])) { - nWordCount = i; - break; - } - } - int32_t nDestLen = bsReplace.GetLength(); - CFX_WideString wsDest; - FX_WCHAR* pBuffer = wsDest.GetBuffer(nDestLen); - for (int32_t i = 0; i < nDestLen; i++) { - pBuffer[i] = bsReplace[i]; - } - wsDest.ReleaseBuffer(nDestLen); - Replace(nWordStart, nWordCount, wsDest.AsStringC()); - return true; -} void IFWL_Edit::DrawSpellCheck(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { pGraphics->SaveGraphState(); @@ -329,9 +258,9 @@ void IFWL_Edit::DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { if (!m_pWidgetMgr->IsFormDisabled()) { DrawTextBk(pGraphics, pTheme, pMatrix); } - if (m_pEdtEngine) { - DrawContent(pGraphics, pTheme, pMatrix); - } + + DrawContent(pGraphics, pTheme, pMatrix); + if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) && !(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly)) { DrawSpellCheck(pGraphics, pMatrix); @@ -358,154 +287,55 @@ void IFWL_Edit::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { m_pProperties->m_pThemeProvider = pThemeProvider; } -FWL_Error IFWL_Edit::SetText(const CFX_WideString& wsText) { - m_pEdtEngine->SetText(wsText); - return FWL_Error::Succeeded; +void IFWL_Edit::SetText(const CFX_WideString& wsText) { + m_EdtEngine.SetText(wsText); } int32_t IFWL_Edit::GetTextLength() const { - if (!m_pEdtEngine) - return -1; - return m_pEdtEngine->GetTextLength(); -} - -FWL_Error IFWL_Edit::GetText(CFX_WideString& wsText, - int32_t nStart, - int32_t nCount) const { - if (!m_pEdtEngine) - return FWL_Error::Indefinite; - - m_pEdtEngine->GetText(wsText, nStart, nCount); - return FWL_Error::Succeeded; + return m_EdtEngine.GetTextLength(); } -FWL_Error IFWL_Edit::ClearText() { - if (!m_pEdtEngine) - return FWL_Error::Indefinite; - - m_pEdtEngine->ClearText(); - return FWL_Error::Succeeded; +void IFWL_Edit::GetText(CFX_WideString& wsText, + int32_t nStart, + int32_t nCount) { + m_EdtEngine.GetText(wsText, nStart, nCount); } -int32_t IFWL_Edit::GetCaretPos() const { - if (!m_pEdtEngine) - return -1; - return m_pEdtEngine->GetCaretPos(); +void IFWL_Edit::ClearText() { + m_EdtEngine.ClearText(); } -int32_t IFWL_Edit::SetCaretPos(int32_t nIndex, bool bBefore) { - if (!m_pEdtEngine) - return -1; - return m_pEdtEngine->SetCaretPos(nIndex, bBefore); -} - -FWL_Error IFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount) { - if (!m_pEdtEngine) - return FWL_Error::Indefinite; - - m_pEdtEngine->AddSelRange(nStart, nCount); - return FWL_Error::Succeeded; +void IFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount) { + m_EdtEngine.AddSelRange(nStart, nCount); } int32_t IFWL_Edit::CountSelRanges() { - if (!m_pEdtEngine) - return 0; - return m_pEdtEngine->CountSelRanges(); + return m_EdtEngine.CountSelRanges(); } int32_t IFWL_Edit::GetSelRange(int32_t nIndex, int32_t& nStart) { - if (!m_pEdtEngine) - return -1; - return m_pEdtEngine->GetSelRange(nIndex, nStart); + return m_EdtEngine.GetSelRange(nIndex, nStart); } -FWL_Error IFWL_Edit::ClearSelections() { - if (!m_pEdtEngine) - return FWL_Error::Indefinite; - - m_pEdtEngine->ClearSelection(); - return FWL_Error::Succeeded; +void IFWL_Edit::ClearSelections() { + m_EdtEngine.ClearSelection(); } int32_t IFWL_Edit::GetLimit() { return m_nLimit; } -FWL_Error IFWL_Edit::SetLimit(int32_t nLimit) { +void IFWL_Edit::SetLimit(int32_t nLimit) { m_nLimit = nLimit; - if (!m_pEdtEngine) - return FWL_Error::Indefinite; - - m_pEdtEngine->SetLimit(nLimit); - return FWL_Error::Succeeded; + m_EdtEngine.SetLimit(nLimit); } -FWL_Error IFWL_Edit::SetAliasChar(FX_WCHAR wAlias) { - if (!m_pEdtEngine) - return FWL_Error::Indefinite; - - m_pEdtEngine->SetAliasChar(wAlias); - return FWL_Error::Succeeded; -} - -FWL_Error IFWL_Edit::Insert(int32_t nStart, - const FX_WCHAR* lpText, - int32_t nLen) { - if (!m_pEdtEngine) - return FWL_Error::Indefinite; - - if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || - (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { - return FWL_Error::Indefinite; - } - m_pEdtEngine->Insert(nStart, lpText, nLen); - return FWL_Error::Succeeded; -} - -FWL_Error IFWL_Edit::DeleteSelections() { - if (!m_pEdtEngine) - return FWL_Error::Indefinite; - - int32_t iCount = m_pEdtEngine->CountSelRanges(); - if (iCount > 0) - m_pEdtEngine->Delete(-1); - return FWL_Error::Succeeded; -} - -FWL_Error IFWL_Edit::DeleteRange(int32_t nStart, int32_t nCount) { - if (!m_pEdtEngine) - return FWL_Error::Indefinite; - - m_pEdtEngine->DeleteRange(nStart, nCount); - return FWL_Error::Succeeded; -} - -FWL_Error IFWL_Edit::Replace(int32_t nStart, - int32_t nLen, - const CFX_WideStringC& wsReplace) { - if (!m_pEdtEngine) - return FWL_Error::Indefinite; - - m_pEdtEngine->Replace(nStart, nLen, CFX_WideString(wsReplace)); - return FWL_Error::Succeeded; -} - -FWL_Error IFWL_Edit::DoClipboard(int32_t iCmd) { - if (!m_pEdtEngine) - return FWL_Error::Indefinite; - - if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || - (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { - return FWL_Error::Succeeded; - } - return FWL_Error::Indefinite; +void IFWL_Edit::SetAliasChar(FX_WCHAR wAlias) { + m_EdtEngine.SetAliasChar(wAlias); } bool IFWL_Edit::Copy(CFX_WideString& wsCopy) { - if (!m_pEdtEngine) - return false; - - int32_t nCount = m_pEdtEngine->CountSelRanges(); + int32_t nCount = m_EdtEngine.CountSelRanges(); if (nCount == 0) return false; @@ -513,8 +343,8 @@ bool IFWL_Edit::Copy(CFX_WideString& wsCopy) { CFX_WideString wsTemp; int32_t nStart, nLength; for (int32_t i = 0; i < nCount; i++) { - nLength = m_pEdtEngine->GetSelRange(i, nStart); - m_pEdtEngine->GetText(wsTemp, nStart, nLength); + nLength = m_EdtEngine.GetSelRange(i, nStart); + m_EdtEngine.GetText(wsTemp, nStart, nLength); wsCopy += wsTemp; wsTemp.clear(); } @@ -522,10 +352,7 @@ bool IFWL_Edit::Copy(CFX_WideString& wsCopy) { } bool IFWL_Edit::Cut(CFX_WideString& wsCut) { - if (!m_pEdtEngine) - return false; - - int32_t nCount = m_pEdtEngine->CountSelRanges(); + int32_t nCount = m_EdtEngine.CountSelRanges(); if (nCount == 0) return false; @@ -533,22 +360,19 @@ bool IFWL_Edit::Cut(CFX_WideString& wsCut) { CFX_WideString wsTemp; int32_t nStart, nLength; for (int32_t i = 0; i < nCount; i++) { - nLength = m_pEdtEngine->GetSelRange(i, nStart); - m_pEdtEngine->GetText(wsTemp, nStart, nLength); + nLength = m_EdtEngine.GetSelRange(i, nStart); + m_EdtEngine.GetText(wsTemp, nStart, nLength); wsCut += wsTemp; wsTemp.clear(); } - m_pEdtEngine->Delete(0); + m_EdtEngine.Delete(0); return true; } bool IFWL_Edit::Paste(const CFX_WideString& wsPaste) { - if (!m_pEdtEngine) - return false; - - int32_t nCaret = m_pEdtEngine->GetCaretPos(); + int32_t nCaret = m_EdtEngine.GetCaretPos(); int32_t iError = - m_pEdtEngine->Insert(nCaret, wsPaste.c_str(), wsPaste.GetLength()); + m_EdtEngine.Insert(nCaret, wsPaste.c_str(), wsPaste.GetLength()); if (iError < 0) { ProcessInsertError(iError); return false; @@ -556,32 +380,16 @@ bool IFWL_Edit::Paste(const CFX_WideString& wsPaste) { return true; } -bool IFWL_Edit::Delete() { - if (!m_pEdtEngine) - return false; - - int32_t nCount = m_pEdtEngine->CountSelRanges(); - if (nCount < 1) - return false; - - m_pEdtEngine->Delete(0); - return true; -} - bool IFWL_Edit::Redo(const IFDE_TxtEdtDoRecord* pRecord) { - if (!m_pEdtEngine) - return false; if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoRedoUndo) return true; - return m_pEdtEngine->Redo(pRecord); + return m_EdtEngine.Redo(pRecord); } bool IFWL_Edit::Undo(const IFDE_TxtEdtDoRecord* pRecord) { - if (!m_pEdtEngine) - return false; if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoRedoUndo) return true; - return m_pEdtEngine->Undo(pRecord); + return m_EdtEngine.Undo(pRecord); } bool IFWL_Edit::Undo() { @@ -604,26 +412,8 @@ bool IFWL_Edit::CanRedo() { return m_iCurRecord < pdfium::CollectionSize(m_DoRecords) - 1; } -FWL_Error IFWL_Edit::SetTabWidth(FX_FLOAT fTabWidth, bool bEquidistant) { - if (!m_pEdtEngine) - return FWL_Error::Indefinite; - - FDE_TXTEDTPARAMS* pParams = m_pEdtEngine->GetEditParams(); - pParams->fTabWidth = fTabWidth; - pParams->bTabEquidistant = bEquidistant; - return FWL_Error::Succeeded; -} - -FWL_Error IFWL_Edit::SetOuter(IFWL_Widget* pOuter) { +void IFWL_Edit::SetOuter(IFWL_Widget* pOuter) { m_pOuter = pOuter; - return FWL_Error::Succeeded; -} - -FWL_Error IFWL_Edit::SetNumberRange(int32_t iMin, int32_t iMax) { - m_iMin = iMin; - m_iMax = iMax; - m_bSetRange = true; - return FWL_Error::Succeeded; } void IFWL_Edit::On_CaretChanged(CFDE_TxtEdtEngine* pEdit, @@ -660,7 +450,7 @@ void IFWL_Edit::On_TextChanged(CFDE_TxtEdtEngine* pEdit, if (dwStyleEx & FWL_STYLEEXT_EDT_VAlignMask) UpdateVAlignment(); - IFDE_TxtEdtPage* page = m_pEdtEngine->GetPage(0); + IFDE_TxtEdtPage* page = m_EdtEngine.GetPage(0); FX_FLOAT fContentWidth = page->GetContentsBox().width; FX_FLOAT fContentHeight = page->GetContentsBox().height; CFX_RectF rtTemp; @@ -697,7 +487,7 @@ void IFWL_Edit::On_TextChanged(CFDE_TxtEdtEngine* pEdit, if (bNeedUpdate) { UpdateEditParams(); UpdateEditLayout(); - IFDE_TxtEdtPage* page1 = m_pEdtEngine->GetPage(0); + IFDE_TxtEdtPage* page1 = m_EdtEngine.GetPage(0); fContentWidth1 = page1->GetContentsBox().width; fContentHeight1 = page1->GetContentsBox().height; } @@ -729,7 +519,7 @@ void IFWL_Edit::On_SelChanged(CFDE_TxtEdtEngine* pEdit) { bool IFWL_Edit::On_PageLoad(CFDE_TxtEdtEngine* pEdit, int32_t nPageIndex, int32_t nPurpose) { - IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(nPageIndex); + IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(nPageIndex); if (!pPage) return false; pPage->LoadPage(nullptr, nullptr); @@ -739,7 +529,7 @@ bool IFWL_Edit::On_PageLoad(CFDE_TxtEdtEngine* pEdit, bool IFWL_Edit::On_PageUnload(CFDE_TxtEdtEngine* pEdit, int32_t nPageIndex, int32_t nPurpose) { - IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(nPageIndex); + IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(nPageIndex); if (!pPage) return false; pPage->UnloadPage(nullptr); @@ -765,18 +555,6 @@ bool IFWL_Edit::On_Validate(CFDE_TxtEdtEngine* pEdit, CFX_WideString& wsText) { return event.bValidate; } -FWL_Error IFWL_Edit::SetBackgroundColor(uint32_t color) { - m_backColor = color; - m_updateBackColor = true; - return FWL_Error::Succeeded; -} - -FWL_Error IFWL_Edit::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) { - m_wsFont = wsFont; - m_fFontSize = fSize; - return FWL_Error::Succeeded; -} - void IFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) { m_fScrollOffsetY = fScrollOffset; } @@ -816,9 +594,7 @@ void IFWL_Edit::DrawTextBk(CFX_Graphics* pGraphics, void IFWL_Edit::DrawContent(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme, const CFX_Matrix* pMatrix) { - if (!m_pEdtEngine) - return; - IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); + IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0); if (!pPage) return; pGraphics->SaveGraphState(); @@ -843,7 +619,7 @@ void IFWL_Edit::DrawContent(CFX_Graphics* pGraphics, FWL_WGTSTATE_Deactivated; } } - int32_t nSelCount = m_pEdtEngine->CountSelRanges(); + int32_t nSelCount = m_EdtEngine.CountSelRanges(); if (bShowSel && nSelCount > 0) { int32_t nPageCharStart = pPage->GetCharStart(); int32_t nPageCharCount = pPage->GetCharCount(); @@ -853,7 +629,7 @@ void IFWL_Edit::DrawContent(CFX_Graphics* pGraphics, CFX_RectFArray rectArr; int32_t i = 0; for (i = 0; i < nSelCount; i++) { - nCharCount = m_pEdtEngine->GetSelRange(i, nCharStart); + nCharCount = m_EdtEngine.GetSelRange(i, nCharStart); int32_t nCharEnd = nCharStart + nCharCount - 1; if (nCharEnd < nPageCharStart || nCharStart > nPageCharEnd) { continue; @@ -917,7 +693,7 @@ void IFWL_Edit::UpdateEditEngine() { UpdateEditParams(); UpdateEditLayout(); if (m_nLimit > -1) { - m_pEdtEngine->SetLimit(m_nLimit); + m_EdtEngine.SetLimit(m_nLimit); } } void IFWL_Edit::UpdateEditParams() { @@ -1033,34 +809,34 @@ void IFWL_Edit::UpdateEditParams() { params.wLineBreakChar = L'\n'; params.nCharRotation = 0; params.pEventSink = this; - m_pEdtEngine->SetEditParams(params); + m_EdtEngine.SetEditParams(params); } void IFWL_Edit::UpdateEditLayout() { - if (m_pEdtEngine->GetTextLength() <= 0) - m_pEdtEngine->SetTextByStream(nullptr); + if (m_EdtEngine.GetTextLength() <= 0) + m_EdtEngine.SetTextByStream(nullptr); - IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); + IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0); if (pPage) pPage->UnloadPage(nullptr); - m_pEdtEngine->StartLayout(); - m_pEdtEngine->DoLayout(nullptr); - m_pEdtEngine->EndLayout(); - pPage = m_pEdtEngine->GetPage(0); + m_EdtEngine.StartLayout(); + m_EdtEngine.DoLayout(nullptr); + m_EdtEngine.EndLayout(); + pPage = m_EdtEngine.GetPage(0); if (pPage) pPage->LoadPage(nullptr, nullptr); } bool IFWL_Edit::UpdateOffset() { CFX_RectF rtCaret; - m_pEdtEngine->GetCaretRect(rtCaret); + m_EdtEngine.GetCaretRect(rtCaret); FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX; FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset; rtCaret.Offset(fOffSetX, fOffSetY); const CFX_RectF& rtEidt = m_rtEngine; if (rtEidt.Contains(rtCaret)) { - IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); + IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0); if (!pPage) return false; @@ -1105,7 +881,7 @@ bool IFWL_Edit::UpdateOffset(IFWL_ScrollBar* pScrollBar, FX_FLOAT fPosChanged) { } void IFWL_Edit::UpdateVAlignment() { - IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); + IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0); if (!pPage) return; const CFX_RectF& rtFDE = pPage->GetContentsBox(); @@ -1144,7 +920,7 @@ void IFWL_Edit::UpdateVAlignment() { } void IFWL_Edit::UpdateCaret() { CFX_RectF rtFDE; - m_pEdtEngine->GetCaretRect(rtFDE); + m_EdtEngine.GetCaretRect(rtFDE); rtFDE.Offset(m_rtEngine.left - m_fScrollOffsetX, m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset); CFX_RectF rtCaret; @@ -1189,7 +965,7 @@ IFWL_ScrollBar* IFWL_Edit::UpdateScroll() { if (!bShowHorz && !bShowVert) { return nullptr; } - IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); + IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0); if (!pPage) return nullptr; const CFX_RectF& rtFDE = pPage->GetContentsBox(); @@ -1230,7 +1006,7 @@ IFWL_ScrollBar* IFWL_Edit::UpdateScroll() { m_pVertScrollBar->GetWidgetRect(rtScroll); if (rtScroll.height < rtFDE.height) { m_pVertScrollBar->LockUpdate(); - FX_FLOAT fStep = m_pEdtEngine->GetEditParams()->fLineSpace; + FX_FLOAT fStep = m_EdtEngine.GetEditParams()->fLineSpace; FX_FLOAT fRange = rtFDE.height - m_rtEngine.height; if (fRange < fStep) { fRange = fStep; @@ -1277,9 +1053,7 @@ bool IFWL_Edit::IsShowScrollBar(bool bVert) { (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine); } bool IFWL_Edit::IsContentHeightOverflow() { - if (!m_pEdtEngine) - return false; - IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); + IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0); if (!pPage) return false; return pPage->GetContentsBox().height > m_rtEngine.height + 1.0f; @@ -1455,11 +1229,6 @@ void IFWL_Edit::InitScrollBar(bool bVert) { m_pHorzScrollBar.reset(sb); } -void IFWL_Edit::InitEngine() { - if (!m_pEdtEngine) - m_pEdtEngine.reset(new CFDE_TxtEdtEngine); -} - bool FWL_ShowCaret(IFWL_Widget* pWidget, bool bVisible, const CFX_RectF* pRtAnchor) { @@ -1510,21 +1279,18 @@ void IFWL_Edit::ShowCaret(bool bVisible, CFX_RectF* pRect) { } } bool IFWL_Edit::ValidateNumberChar(FX_WCHAR cNum) { - if (!m_pEdtEngine) { - return false; - } if (!m_bSetRange) { return true; } CFX_WideString wsOld, wsText; - m_pEdtEngine->GetText(wsText, 0); + m_EdtEngine.GetText(wsText, 0); if (wsText.IsEmpty()) { if (cNum == L'0') { return false; } return true; } - int32_t caretPos = m_pEdtEngine->GetCaretPos(); + int32_t caretPos = m_EdtEngine.GetCaretPos(); int32_t iSel = CountSelRanges(); if (iSel == 0) { if (cNum == L'0' && caretPos == 0) { @@ -1571,7 +1337,8 @@ void IFWL_Edit::ProcessInsertError(int32_t iError) { DispatchEvent(&textFullEvent); break; } - default: {} + default: + break; } } @@ -1661,10 +1428,8 @@ void IFWL_Edit::DoDeactivate(CFWL_MsgDeactivate* pMsg) { void IFWL_Edit::DoButtonDown(CFWL_MsgMouse* pMsg) { if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) SetFocus(true); - if (!m_pEdtEngine) - UpdateEditEngine(); - IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); + IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0); if (!pPage) return; CFX_PointF pt(pMsg->m_fx, pMsg->m_fy); @@ -1674,7 +1439,7 @@ void IFWL_Edit::DoButtonDown(CFWL_MsgMouse* pMsg) { if (nIndex < 0) nIndex = 0; - m_pEdtEngine->SetCaretPos(nIndex, bBefore); + m_EdtEngine.SetCaretPos(nIndex, bBefore); } void IFWL_Edit::OnFocusChanged(CFWL_Message* pMsg, bool bSet) { @@ -1682,8 +1447,6 @@ void IFWL_Edit::OnFocusChanged(CFWL_Message* pMsg, bool bSet) { bool bRepaint = !!(dwStyleEx & FWL_STYLEEXT_EDT_InnerCaret); if (bSet) { m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; - if (!m_pEdtEngine) - UpdateEditEngine(); UpdateVAlignment(); UpdateOffset(); @@ -1691,13 +1454,13 @@ void IFWL_Edit::OnFocusChanged(CFWL_Message* pMsg, bool bSet) { } else if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; ShowCaret(false); - if (m_pEdtEngine && (dwStyleEx & FWL_STYLEEXT_EDT_NoHideSel) == 0) { + if ((dwStyleEx & FWL_STYLEEXT_EDT_NoHideSel) == 0) { int32_t nSel = CountSelRanges(); if (nSel > 0) { ClearSelections(); bRepaint = true; } - SetCaretPos(0); + m_EdtEngine.SetCaretPos(0, true); UpdateOffset(); } ClearRecord(); @@ -1718,11 +1481,11 @@ void IFWL_Edit::OnLButtonDown(CFWL_MsgMouse* pMsg) { m_bLButtonDown = true; SetGrab(true); DoButtonDown(pMsg); - int32_t nIndex = m_pEdtEngine->GetCaretPos(); + int32_t nIndex = m_EdtEngine.GetCaretPos(); bool bRepaint = false; - int32_t iCount = m_pEdtEngine->CountSelRanges(); + int32_t iCount = m_EdtEngine.CountSelRanges(); if (iCount > 0) { - m_pEdtEngine->ClearSelection(); + m_EdtEngine.ClearSelection(); bRepaint = true; } @@ -1730,7 +1493,7 @@ void IFWL_Edit::OnLButtonDown(CFWL_MsgMouse* pMsg) { if (bShift && m_nSelStart != nIndex) { int32_t iStart = std::min(m_nSelStart, nIndex); int32_t iEnd = std::max(m_nSelStart, nIndex); - m_pEdtEngine->AddSelRange(iStart, iEnd - iStart); + m_EdtEngine.AddSelRange(iStart, iEnd - iStart); bRepaint = true; } else { m_nSelStart = nIndex; @@ -1745,10 +1508,7 @@ void IFWL_Edit::OnLButtonUp(CFWL_MsgMouse* pMsg) { } void IFWL_Edit::OnButtonDblClk(CFWL_MsgMouse* pMsg) { - if (!m_pEdtEngine) - return; - - IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); + IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0); if (!pPage) return; @@ -1759,18 +1519,16 @@ void IFWL_Edit::OnButtonDblClk(CFWL_MsgMouse* pMsg) { if (nIndex < 0) return; - m_pEdtEngine->AddSelRange(nIndex, nCount); - m_pEdtEngine->SetCaretPos(nIndex + nCount - 1, false); + m_EdtEngine.AddSelRange(nIndex, nCount); + m_EdtEngine.SetCaretPos(nIndex + nCount - 1, false); Repaint(&m_rtEngine); } void IFWL_Edit::OnMouseMove(CFWL_MsgMouse* pMsg) { - if (!m_pEdtEngine) - return; if (m_nSelStart == -1 || !m_bLButtonDown) return; - IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0); + IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0); if (!pPage) return; @@ -1778,23 +1536,20 @@ void IFWL_Edit::OnMouseMove(CFWL_MsgMouse* pMsg) { DeviceToEngine(pt); bool bBefore = true; int32_t nIndex = pPage->GetCharIndex(pt, bBefore); - m_pEdtEngine->SetCaretPos(nIndex, bBefore); - nIndex = m_pEdtEngine->GetCaretPos(); - m_pEdtEngine->ClearSelection(); + m_EdtEngine.SetCaretPos(nIndex, bBefore); + nIndex = m_EdtEngine.GetCaretPos(); + m_EdtEngine.ClearSelection(); if (nIndex != m_nSelStart) { - int32_t nLen = m_pEdtEngine->GetTextLength(); + int32_t nLen = m_EdtEngine.GetTextLength(); if (m_nSelStart >= nLen) m_nSelStart = nLen; - m_pEdtEngine->AddSelRange(std::min(m_nSelStart, nIndex), - FXSYS_abs(nIndex - m_nSelStart)); + m_EdtEngine.AddSelRange(std::min(m_nSelStart, nIndex), + FXSYS_abs(nIndex - m_nSelStart)); } } void IFWL_Edit::OnKeyDown(CFWL_MsgKey* pMsg) { - if (!m_pEdtEngine) - return; - FDE_TXTEDTMOVECARET MoveCaret = MC_MoveNone; bool bShift = !!(pMsg->m_dwFlags & FWL_KEYFLAG_Shift); bool bCtrl = !!(pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl); @@ -1831,11 +1586,11 @@ void IFWL_Edit::OnKeyDown(CFWL_MsgKey* pMsg) { (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { break; } - int32_t nCaret = m_pEdtEngine->GetCaretPos(); + int32_t nCaret = m_EdtEngine.GetCaretPos(); #if (_FX_OS_ == _FX_MACOSX_) - m_pEdtEngine->Delete(nCaret, true); + m_EdtEngine.Delete(nCaret, true); #else - m_pEdtEngine->Delete(nCaret); + m_EdtEngine.Delete(nCaret); #endif break; } @@ -1845,29 +1600,11 @@ void IFWL_Edit::OnKeyDown(CFWL_MsgKey* pMsg) { DispatchKeyEvent(pMsg); break; } - default: { -#if (_FX_OS_ == _FX_MACOSX_) - if (pMsg->m_dwFlags & FWL_KEYFLAG_Command) { -#else - if (pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl) { -#endif - if (dwKeyCode == 0x43 || dwKeyCode == 0x63) { - DoClipboard(1); - return; - } - if (dwKeyCode == 0x58 || dwKeyCode == 0x78) { - DoClipboard(2); - return; - } - if (dwKeyCode == 0x56 || dwKeyCode == 0x76) { - DoClipboard(3); - return; - } - } - } + default: + break; } if (MoveCaret != MC_MoveNone) - m_pEdtEngine->MoveCaretPos(MoveCaret, bShift, bCtrl); + m_EdtEngine.MoveCaretPos(MoveCaret, bShift, bCtrl); } void IFWL_Edit::OnChar(CFWL_MsgKey* pMsg) { @@ -1875,27 +1612,25 @@ void IFWL_Edit::OnChar(CFWL_MsgKey* pMsg) { (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { return; } - if (!m_pEdtEngine) - return; int32_t iError = 0; FX_WCHAR c = (FX_WCHAR)pMsg->m_dwKeyCode; - int32_t nCaret = m_pEdtEngine->GetCaretPos(); + int32_t nCaret = m_EdtEngine.GetCaretPos(); switch (c) { case FWL_VKEY_Back: - m_pEdtEngine->Delete(nCaret, true); + m_EdtEngine.Delete(nCaret, true); break; case 0x0A: break; case FWL_VKEY_Escape: break; case FWL_VKEY_Tab: { - iError = m_pEdtEngine->Insert(nCaret, L"\t", 1); + iError = m_EdtEngine.Insert(nCaret, L"\t", 1); break; } case FWL_VKEY_Return: { if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_WantReturn) { - iError = m_pEdtEngine->Insert(nCaret, L"\n", 1); + iError = m_EdtEngine.Insert(nCaret, L"\n", 1); } break; } @@ -1919,7 +1654,7 @@ void IFWL_Edit::OnChar(CFWL_MsgKey* pMsg) { { break; } - iError = m_pEdtEngine->Insert(nCaret, &c, 1); + iError = m_EdtEngine.Insert(nCaret, &c, 1); break; } } @@ -1982,9 +1717,8 @@ bool IFWL_Edit::OnScroll(IFWL_ScrollBar* pScrollBar, pScrollBar->SetPos(fPos); pScrollBar->SetTrackPos(fPos); UpdateOffset(pScrollBar, fPos - iCurPos); - if (m_pEdtEngine) { - UpdateCaret(); - } + UpdateCaret(); + CFX_RectF rect; GetWidgetRect(rect); CFX_RectF rtInvalidate; diff --git a/xfa/fwl/core/ifwl_edit.h b/xfa/fwl/core/ifwl_edit.h index d436a4f550..65c660332d 100644 --- a/xfa/fwl/core/ifwl_edit.h +++ b/xfa/fwl/core/ifwl_edit.h @@ -8,11 +8,10 @@ #define XFA_FWL_CORE_IFWL_EDIT_H_ #include -#include #include +#include "xfa/fde/cfde_txtedtengine.h" #include "xfa/fde/ifde_txtedtdorecord.h" -#include "xfa/fde/ifde_txtedtengine.h" #include "xfa/fwl/core/cfwl_event.h" #include "xfa/fwl/core/cfwl_widget.h" #include "xfa/fwl/core/ifwl_dataprovider.h" @@ -85,12 +84,6 @@ FWL_EVENT_DEF(CFWL_EvtEdtCheckWord, CFX_ByteString bsWord; bool bCheckWord;) -FWL_EVENT_DEF(CFWL_EvtEdtGetSuggestWords, - CFWL_EventType::GetSuggestedWords, - bool bSuggestWords; - CFX_ByteString bsWord; - std::vector bsArraySuggestWords;) - class IFDE_TxtEdtDoRecord; class IFWL_Edit; class CFWL_MsgActivate; @@ -99,8 +92,6 @@ class CFWL_MsgMouse; class CFWL_WidgetProperties; class IFWL_Caret; -class IFWL_EditDP : public IFWL_DataProvider {}; - class IFWL_Edit : public IFWL_Widget { public: IFWL_Edit(const IFWL_App* app, @@ -122,45 +113,30 @@ class IFWL_Edit : public IFWL_Widget { void OnDrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) override; - virtual FWL_Error SetText(const CFX_WideString& wsText); - virtual int32_t GetTextLength() const; - virtual FWL_Error GetText(CFX_WideString& wsText, - int32_t nStart = 0, - int32_t nCount = -1) const; - virtual FWL_Error ClearText(); - virtual int32_t GetCaretPos() const; - virtual int32_t SetCaretPos(int32_t nIndex, bool bBefore = true); - virtual FWL_Error AddSelRange(int32_t nStart, int32_t nCount = -1); - virtual int32_t CountSelRanges(); - virtual int32_t GetSelRange(int32_t nIndex, int32_t& nStart); - virtual FWL_Error ClearSelections(); - virtual int32_t GetLimit(); - virtual FWL_Error SetLimit(int32_t nLimit); - virtual FWL_Error SetAliasChar(FX_WCHAR wAlias); - virtual FWL_Error Insert(int32_t nStart, - const FX_WCHAR* lpText, - int32_t nLen); - virtual FWL_Error DeleteSelections(); - virtual FWL_Error DeleteRange(int32_t nStart, int32_t nCount = -1); - virtual FWL_Error Replace(int32_t nStart, - int32_t nLen, - const CFX_WideStringC& wsReplace); - virtual FWL_Error DoClipboard(int32_t iCmd); - virtual bool Copy(CFX_WideString& wsCopy); - virtual bool Cut(CFX_WideString& wsCut); - virtual bool Paste(const CFX_WideString& wsPaste); - virtual bool Delete(); - virtual bool Redo(const IFDE_TxtEdtDoRecord* pRecord); - virtual bool Undo(const IFDE_TxtEdtDoRecord* pRecord); - virtual bool Undo(); - virtual bool Redo(); - virtual bool CanUndo(); - virtual bool CanRedo(); - virtual FWL_Error SetTabWidth(FX_FLOAT fTabWidth, bool bEquidistant); - virtual FWL_Error SetOuter(IFWL_Widget* pOuter); - virtual FWL_Error SetNumberRange(int32_t iMin, int32_t iMax); - virtual FWL_Error SetBackgroundColor(uint32_t color); - virtual FWL_Error SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize); + virtual void SetText(const CFX_WideString& wsText); + + int32_t GetTextLength() const; + void GetText(CFX_WideString& wsText, int32_t nStart = 0, int32_t nCount = -1); + void ClearText(); + + void AddSelRange(int32_t nStart, int32_t nCount = -1); + int32_t CountSelRanges(); + int32_t GetSelRange(int32_t nIndex, int32_t& nStart); + void ClearSelections(); + int32_t GetLimit(); + void SetLimit(int32_t nLimit); + void SetAliasChar(FX_WCHAR wAlias); + bool Copy(CFX_WideString& wsCopy); + bool Cut(CFX_WideString& wsCut); + bool Paste(const CFX_WideString& wsPaste); + bool Redo(const IFDE_TxtEdtDoRecord* pRecord); + bool Undo(const IFDE_TxtEdtDoRecord* pRecord); + bool Undo(); + bool Redo(); + bool CanUndo(); + bool CanRedo(); + + void SetOuter(IFWL_Widget* pOuter); void On_CaretChanged(CFDE_TxtEdtEngine* pEdit, int32_t nPage, @@ -177,14 +153,13 @@ class IFWL_Edit : public IFWL_Widget { void On_AddDoRecord(CFDE_TxtEdtEngine* pEdit, IFDE_TxtEdtDoRecord* pRecord); bool On_Validate(CFDE_TxtEdtEngine* pEdit, CFX_WideString& wsText); void SetScrollOffset(FX_FLOAT fScrollOffset); - bool GetSuggestWords(CFX_PointF pointf, - std::vector& sSuggest); - bool ReplaceSpellCheckWord(CFX_PointF pointf, - const CFX_ByteStringC& bsReplace); protected: - friend class CFWL_TxtEdtEventSink; + void ShowCaret(bool bVisible, CFX_RectF* pRect = nullptr); + const CFX_RectF& GetRTClient() const { return m_rtClient; } + CFDE_TxtEdtEngine* GetTxtEdtEngine() { return &m_EdtEngine; } + private: void DrawTextBk(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme, const CFX_Matrix* pMatrix = nullptr); @@ -204,7 +179,6 @@ class IFWL_Edit : public IFWL_Widget { void DeviceToEngine(CFX_PointF& pt); void InitScrollBar(bool bVert = true); void InitEngine(); - virtual void ShowCaret(bool bVisible, CFX_RectF* pRect = nullptr); bool ValidateNumberChar(FX_WCHAR cNum); void InitCaret(); void ClearRecord(); @@ -220,7 +194,17 @@ class IFWL_Edit : public IFWL_Widget { int32_t nCount, FX_FLOAT fOffSetX, FX_FLOAT fOffSetY); - int32_t GetWordAtPoint(CFX_PointF pointf, int32_t& nCount); + void DoActivate(CFWL_MsgActivate* pMsg); + void DoDeactivate(CFWL_MsgDeactivate* pMsg); + void DoButtonDown(CFWL_MsgMouse* pMsg); + void OnFocusChanged(CFWL_Message* pMsg, bool bSet); + void OnLButtonDown(CFWL_MsgMouse* pMsg); + void OnLButtonUp(CFWL_MsgMouse* pMsg); + void OnButtonDblClk(CFWL_MsgMouse* pMsg); + void OnMouseMove(CFWL_MsgMouse* pMsg); + void OnKeyDown(CFWL_MsgKey* pMsg); + void OnChar(CFWL_MsgKey* pMsg); + bool OnScroll(IFWL_ScrollBar* pScrollBar, FWL_SCBCODE dwCode, FX_FLOAT fPos); CFX_RectF m_rtClient; CFX_RectF m_rtEngine; @@ -228,40 +212,21 @@ class IFWL_Edit : public IFWL_Widget { FX_FLOAT m_fVAlignOffset; FX_FLOAT m_fScrollOffsetX; FX_FLOAT m_fScrollOffsetY; - std::unique_ptr m_pEdtEngine; + CFDE_TxtEdtEngine m_EdtEngine; bool m_bLButtonDown; int32_t m_nSelStart; int32_t m_nLimit; - FX_FLOAT m_fSpaceAbove; - FX_FLOAT m_fSpaceBelow; FX_FLOAT m_fFontSize; - FX_ARGB m_argbSel; bool m_bSetRange; - int32_t m_iMin; int32_t m_iMax; std::unique_ptr m_pVertScrollBar; std::unique_ptr m_pHorzScrollBar; std::unique_ptr m_pCaret; CFX_WideString m_wsCache; - uint32_t m_backColor; - bool m_updateBackColor; CFX_WideString m_wsFont; std::deque> m_DoRecords; int32_t m_iCurRecord; int32_t m_iMaxRecord; - - private: - void DoActivate(CFWL_MsgActivate* pMsg); - void DoDeactivate(CFWL_MsgDeactivate* pMsg); - void DoButtonDown(CFWL_MsgMouse* pMsg); - void OnFocusChanged(CFWL_Message* pMsg, bool bSet); - void OnLButtonDown(CFWL_MsgMouse* pMsg); - void OnLButtonUp(CFWL_MsgMouse* pMsg); - void OnButtonDblClk(CFWL_MsgMouse* pMsg); - void OnMouseMove(CFWL_MsgMouse* pMsg); - void OnKeyDown(CFWL_MsgKey* pMsg); - void OnChar(CFWL_MsgKey* pMsg); - bool OnScroll(IFWL_ScrollBar* pScrollBar, FWL_SCBCODE dwCode, FX_FLOAT fPos); }; #endif // XFA_FWL_CORE_IFWL_EDIT_H_ diff --git a/xfa/fwl/core/ifwl_form.cpp b/xfa/fwl/core/ifwl_form.cpp index e256a135f9..4a8d911976 100644 --- a/xfa/fwl/core/ifwl_form.cpp +++ b/xfa/fwl/core/ifwl_form.cpp @@ -41,6 +41,9 @@ IFWL_Form::IFWL_Form(const IFWL_App* app, std::unique_ptr properties, IFWL_Widget* pOuter) : IFWL_Widget(app, std::move(properties), pOuter), +#if (_FX_OS_ == _FX_MACOSX_) + m_bMouseIn(false), +#endif m_pCloseBox(nullptr), m_pMinBox(nullptr), m_pMaxBox(nullptr), @@ -55,11 +58,9 @@ IFWL_Form::IFWL_Form(const IFWL_App* app, m_bMaximized(false), m_bSetMaximize(false), m_bCustomizeLayout(false), - m_eFormSize(FWL_FORMSIZE_Manual), m_bDoModalFlag(false), m_pBigIcon(nullptr), - m_pSmallIcon(nullptr), - m_bMouseIn(false) { + m_pSmallIcon(nullptr) { m_rtRelative.Reset(); m_rtCaption.Reset(); m_rtRestore.Reset(); @@ -319,15 +320,6 @@ void IFWL_Form::DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { #endif } -FWL_FORMSIZE IFWL_Form::GetFormSize() { - return m_eFormSize; -} - -FWL_Error IFWL_Form::SetFormSize(FWL_FORMSIZE eFormSize) { - m_eFormSize = eFormSize; - return FWL_Error::Succeeded; -} - IFWL_Widget* IFWL_Form::DoModal() { const IFWL_App* pApp = GetOwnerApp(); if (!pApp) @@ -350,37 +342,29 @@ IFWL_Widget* IFWL_Form::DoModal() { return nullptr; } -IFWL_Widget* IFWL_Form::DoModal(uint32_t& dwCommandID) { - return DoModal(); -} - -FWL_Error IFWL_Form::EndDoModal() { +void IFWL_Form::EndDoModal() { if (!m_pNoteLoop) - return FWL_Error::Indefinite; + return; m_bDoModalFlag = false; #if (_FX_OS_ == _FX_MACOSX_) m_pNoteLoop->EndModalLoop(); const IFWL_App* pApp = GetOwnerApp(); if (!pApp) - return FWL_Error::Indefinite; + return; CFWL_NoteDriver* pDriver = static_cast(pApp->GetNoteDriver()); if (!pDriver) - return FWL_Error::Indefinite; + return; pDriver->PopNoteLoop(); SetStates(FWL_WGTSTATE_Invisible, true); - return FWL_Error::Succeeded; #else SetStates(FWL_WGTSTATE_Invisible, true); - return m_pNoteLoop->EndModalLoop(); + m_pNoteLoop->EndModalLoop(); #endif } -FWL_Error IFWL_Form::SetBorderRegion(CFX_Path* pPath) { - return FWL_Error::Succeeded; -} void IFWL_Form::DrawBackground(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme) { CFWL_ThemeBackground param; @@ -392,28 +376,6 @@ void IFWL_Form::DrawBackground(CFX_Graphics* pGraphics, m_fCXBorder); pTheme->DrawBackground(¶m); } -IFWL_Widget* IFWL_Form::GetSubFocus() { - return m_pSubFocus; -} -void IFWL_Form::SetSubFocus(IFWL_Widget* pWidget) { - m_pSubFocus = pWidget; -} - -void IFWL_Form::ShowChildWidget(IFWL_Widget* pParent) { - const IFWL_App* pApp = pParent->GetOwnerApp(); - if (!pApp) - return; - - CFWL_WidgetMgr* pWidgetMgr = pApp->GetWidgetMgr(); - if (!pWidgetMgr) - return; - - IFWL_Widget* pChild = pWidgetMgr->GetFirstChildWidget(pParent); - while (pChild) { - ShowChildWidget(pChild); - pChild = pWidgetMgr->GetNextSiblingWidget(pChild); - } -} void IFWL_Form::RemoveSysButtons() { m_rtCaption.Reset(); @@ -427,17 +389,6 @@ void IFWL_Form::RemoveSysButtons() { m_pCaptionBox = nullptr; } -void IFWL_Form::CalcContentRect(CFX_RectF& rtContent) { -#ifdef FWL_UseMacSystemBorder - rtContent = m_rtRelative; -#else - GetEdgeRect(rtContent); - if (HasEdge()) { - FX_FLOAT fEdge = GetEdgeWidth(); - rtContent.Deflate(fEdge, fEdge); - } -#endif -} CFWL_SysBtn* IFWL_Form::GetSysBtnAtPoint(FX_FLOAT fx, FX_FLOAT fy) { if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy)) { return m_pCloseBox; @@ -578,14 +529,14 @@ void IFWL_Form::SetWorkAreaRect() { m_bSetMaximize = true; Repaint(&m_rtRelative); } -void IFWL_Form::SetCursor(FX_FLOAT fx, FX_FLOAT fy) {} + void IFWL_Form::Layout() { GetRelativeRect(m_rtRelative); #ifndef FWL_UseMacSystemBorder - ReSetSysBtn(); + ResetSysBtn(); #endif } -void IFWL_Form::ReSetSysBtn() { +void IFWL_Form::ResetSysBtn() { m_fCXBorder = *static_cast(GetThemeCapacity(CFWL_WidgetCapacity::CXBorder)); m_fCYBorder = @@ -676,9 +627,7 @@ void IFWL_Form::UnRegisterForm() { pDriver->UnRegisterForm(this); } -bool IFWL_Form::IsDoModal() { - return m_bDoModalFlag; -} + void IFWL_Form::SetThemeData() { m_fSmallIconSz = *static_cast(GetThemeCapacity(CFWL_WidgetCapacity::SmallIcon)); @@ -713,55 +662,6 @@ void IFWL_Form::UpdateCaption() { CFX_WideString text; pData->GetCaption(this, text); } -void IFWL_Form::DoWidthLimit(FX_FLOAT& fLeft, - FX_FLOAT& fWidth, - FX_FLOAT fCurX, - FX_FLOAT fSpace, - FX_FLOAT fLimitMin, - FX_FLOAT fLimitMax, - bool bLeft) { - FX_FLOAT fx = fCurX; - FX_FLOAT fy = 0; - TransformTo(nullptr, fx, fy); - FX_FLOAT fTemp = - bLeft ? (fWidth - fx + fLeft + fSpace) : (fx - fLeft + fSpace); - if (fTemp >= fLimitMin && fTemp <= fLimitMax) { - fWidth = fTemp; - fLeft += bLeft ? (fx - fLeft - fSpace) : 0; - } else { - if (fTemp < fLimitMin && fWidth > fLimitMin) { - fLeft += bLeft ? (fWidth - fLimitMin) : 0; - fWidth = fLimitMin; - } else if (fTemp > fLimitMax && fWidth < fLimitMax) { - fLeft -= bLeft ? (fLimitMax - fWidth) : 0; - fWidth = fLimitMax; - } - } -} -void IFWL_Form::DoHeightLimit(FX_FLOAT& fTop, - FX_FLOAT& fHeight, - FX_FLOAT fCurY, - FX_FLOAT fSpace, - FX_FLOAT fLimitMin, - FX_FLOAT fLimitMax, - bool bTop) { - FX_FLOAT fx = 0; - FX_FLOAT fy = fCurY; - TransformTo(nullptr, fx, fy); - FX_FLOAT fTemp = bTop ? (fHeight - fy + fTop + fSpace) : (fy - fTop + fSpace); - if (fTemp >= fLimitMin && fTemp <= fLimitMax) { - fHeight = fTemp; - fTop += bTop ? (fy - fTop - fSpace) : 0; - } else { - if (fTemp < fLimitMin && fHeight > fLimitMin) { - fTop += bTop ? (fHeight - fLimitMin) : 0; - fHeight = fLimitMin; - } else if (fTemp > fLimitMax && fHeight < fLimitMax) { - fTop -= bTop ? (fLimitMax - fHeight) : 0; - fHeight = fLimitMax; - } - } -} #ifdef FWL_UseMacSystemBorder void IFWL_Form::OnProcessMessage(CFWL_Message* pMessage) { @@ -832,9 +732,6 @@ void IFWL_Form::OnProcessMessage(CFWL_Message* pMessage) { case FWL_MouseCommand::Move: OnMouseMove(pMsg); break; - case FWL_MouseCommand::Hover: - OnMouseHover(pMsg); - break; case FWL_MouseCommand::Leave: OnMouseLeave(pMsg); break; @@ -897,10 +794,6 @@ void IFWL_Form::OnLButtonDown(CFWL_MsgMouse* pMsg) { Repaint(&pPressBtn->m_rtBtn); } else if (rtCap.Contains(pMsg->m_fx, pMsg->m_fy)) { m_eResizeType = FORM_RESIZETYPE_Cap; - } else if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) && - (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) && - !m_bMaximized) { - SetCursor(pMsg->m_fx, pMsg->m_fy); } m_InfoStart.m_ptStart = CFX_PointF(pMsg->m_fx, pMsg->m_fy); m_InfoStart.m_szStart = CFX_SizeF(m_pProperties->m_rtWidget.width, @@ -937,11 +830,6 @@ void IFWL_Form::OnMouseMove(CFWL_MsgMouse* pMsg) { if (m_bLButtonDown) return; - if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) && - (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) && - !m_bMaximized) { - SetCursor(pMsg->m_fx, pMsg->m_fy); - } CFX_RectF rtInvalidate; rtInvalidate.Reset(); CFWL_SysBtn* pPointBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); @@ -990,18 +878,12 @@ void IFWL_Form::OnMouseMove(CFWL_MsgMouse* pMsg) { Repaint(&rtInvalidate); } -void IFWL_Form::OnMouseHover(CFWL_MsgMouse* pMsg) { - SetCursor(pMsg->m_fx, pMsg->m_fy); -} - void IFWL_Form::OnMouseLeave(CFWL_MsgMouse* pMsg) { CFWL_SysBtn* pHover = GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover); if (pHover) { pHover->SetNormal(); Repaint(&pHover->m_rtBtn); } - if (pMsg->m_dwCmd == FWL_MouseCommand::Leave && !m_bLButtonDown) - SetCursor(pMsg->m_fx, pMsg->m_fy); } void IFWL_Form::OnLButtonDblClk(CFWL_MsgMouse* pMsg) { diff --git a/xfa/fwl/core/ifwl_form.h b/xfa/fwl/core/ifwl_form.h index 08211fe213..77acbd84d4 100644 --- a/xfa/fwl/core/ifwl_form.h +++ b/xfa/fwl/core/ifwl_form.h @@ -101,22 +101,15 @@ class IFWL_Form : public IFWL_Widget { void OnDrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) override; - FWL_FORMSIZE GetFormSize(); - FWL_Error SetFormSize(FWL_FORMSIZE eFormSize); IFWL_Widget* DoModal(); - IFWL_Widget* DoModal(uint32_t& dwCommandID); - FWL_Error EndDoModal(); - FWL_Error SetBorderRegion(CFX_Path* pPath); - void DrawBackground(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme); - IFWL_Widget* GetSubFocus(); - void SetSubFocus(IFWL_Widget* pWidget); + void EndDoModal(); - protected: - friend class CFWL_FormImpDelegate; + IFWL_Widget* GetSubFocus() const { return m_pSubFocus; } + void SetSubFocus(IFWL_Widget* pWidget) { m_pSubFocus = pWidget; } - void ShowChildWidget(IFWL_Widget* pParent); + private: + void DrawBackground(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme); void RemoveSysButtons(); - void CalcContentRect(CFX_RectF& rtContent); CFWL_SysBtn* GetSysBtnAtPoint(FX_FLOAT fx, FX_FLOAT fy); CFWL_SysBtn* GetSysBtnByState(uint32_t dwState); CFWL_SysBtn* GetSysBtnByIndex(int32_t nIndex); @@ -130,31 +123,25 @@ class IFWL_Form : public IFWL_Widget { const CFX_Matrix* pMatrix = nullptr); void GetEdgeRect(CFX_RectF& rtEdge); void SetWorkAreaRect(); - void SetCursor(FX_FLOAT fx, FX_FLOAT fy); void Layout(); - void ReSetSysBtn(); + void ResetSysBtn(); void RegisterForm(); void UnRegisterForm(); - bool IsDoModal(); void SetThemeData(); bool HasIcon(); void UpdateIcon(); void UpdateCaption(); - void DoWidthLimit(FX_FLOAT& fLeft, - FX_FLOAT& fWidth, - FX_FLOAT fCurX, - FX_FLOAT fSpace, - FX_FLOAT fLimitMin, - FX_FLOAT fLimitMax, - bool bLeft); - void DoHeightLimit(FX_FLOAT& fTop, - FX_FLOAT& fHeight, - FX_FLOAT fCurY, - FX_FLOAT fSpace, - FX_FLOAT fLimitMin, - FX_FLOAT fLimitMax, - bool bTop); + void OnLButtonDown(CFWL_MsgMouse* pMsg); + void OnLButtonUp(CFWL_MsgMouse* pMsg); + void OnMouseMove(CFWL_MsgMouse* pMsg); + void OnMouseLeave(CFWL_MsgMouse* pMsg); + void OnLButtonDblClk(CFWL_MsgMouse* pMsg); + void OnWindowMove(CFWL_MsgWindowMove* pMsg); + void OnClose(CFWL_MsgClose* pMsg); +#if (_FX_OS_ == _FX_MACOSX_) + bool m_bMouseIn; +#endif CFX_RectF m_rtRestore; CFX_RectF m_rtCaptionText; CFX_RectF m_rtRelative; @@ -176,23 +163,11 @@ class IFWL_Form : public IFWL_Widget { bool m_bMaximized; bool m_bSetMaximize; bool m_bCustomizeLayout; - FWL_FORMSIZE m_eFormSize; bool m_bDoModalFlag; FX_FLOAT m_fSmallIconSz; FX_FLOAT m_fBigIconSz; CFX_DIBitmap* m_pBigIcon; CFX_DIBitmap* m_pSmallIcon; - bool m_bMouseIn; - - private: - void OnLButtonDown(CFWL_MsgMouse* pMsg); - void OnLButtonUp(CFWL_MsgMouse* pMsg); - void OnMouseMove(CFWL_MsgMouse* pMsg); - void OnMouseHover(CFWL_MsgMouse* pMsg); - void OnMouseLeave(CFWL_MsgMouse* pMsg); - void OnLButtonDblClk(CFWL_MsgMouse* pMsg); - void OnWindowMove(CFWL_MsgWindowMove* pMsg); - void OnClose(CFWL_MsgClose* pMsg); }; #endif // XFA_FWL_CORE_IFWL_FORM_H_ -- cgit v1.2.3