summaryrefslogtreecommitdiff
path: root/xfa/fwl
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fwl')
-rw-r--r--xfa/fwl/README.md2
-rw-r--r--xfa/fwl/cfwl_barcode.cpp7
-rw-r--r--xfa/fwl/cfwl_barcode.h5
-rw-r--r--xfa/fwl/cfwl_combobox.cpp3
-rw-r--r--xfa/fwl/cfwl_edit.cpp29
-rw-r--r--xfa/fwl/cfwl_edit.h7
-rw-r--r--xfa/fwl/cfwl_event.h2
-rw-r--r--xfa/fwl/cfwl_eventtextchanged.cpp12
-rw-r--r--xfa/fwl/cfwl_eventtextchanged.h20
-rw-r--r--xfa/fwl/cfwl_eventtextwillchange.cpp12
-rw-r--r--xfa/fwl/cfwl_eventtextwillchange.h24
11 files changed, 73 insertions, 50 deletions
diff --git a/xfa/fwl/README.md b/xfa/fwl/README.md
index 95a0f4c92a..6460ff1fae 100644
--- a/xfa/fwl/README.md
+++ b/xfa/fwl/README.md
@@ -46,7 +46,7 @@ and CXFA classes.
* CFWL_EventMouse
* CFWL_EventScroll
* CFWL_EventSelectChanged
- * CFWL_EventTextChanged
+ * CFWL_EventTextWillChange
* CFWL_EventValidate
The widgets use IFWL_ThemeProvider for rendering everything, calling
diff --git a/xfa/fwl/cfwl_barcode.cpp b/xfa/fwl/cfwl_barcode.cpp
index 74ac7dd9c2..649dea0c8e 100644
--- a/xfa/fwl/cfwl_barcode.cpp
+++ b/xfa/fwl/cfwl_barcode.cpp
@@ -67,10 +67,11 @@ void CFWL_Barcode::SetType(BC_TYPE type) {
m_dwStatus = XFA_BCS_NeedUpdate;
}
-void CFWL_Barcode::SetText(const WideString& wsText) {
+void CFWL_Barcode::SetText(const WideString& wsText,
+ CFDE_TextEditEngine::RecordOperation op) {
m_pBarcodeEngine.reset();
m_dwStatus = XFA_BCS_NeedUpdate;
- CFWL_Edit::SetText(wsText);
+ CFWL_Edit::SetText(wsText, op);
}
bool CFWL_Barcode::IsProtectedType() const {
@@ -86,7 +87,7 @@ bool CFWL_Barcode::IsProtectedType() const {
}
void CFWL_Barcode::OnProcessEvent(CFWL_Event* pEvent) {
- if (pEvent->GetType() == CFWL_Event::Type::TextChanged) {
+ if (pEvent->GetType() == CFWL_Event::Type::TextWillChange) {
m_pBarcodeEngine.reset();
m_dwStatus = XFA_BCS_NeedUpdate;
}
diff --git a/xfa/fwl/cfwl_barcode.h b/xfa/fwl/cfwl_barcode.h
index 2fc79608b3..58484dfba1 100644
--- a/xfa/fwl/cfwl_barcode.h
+++ b/xfa/fwl/cfwl_barcode.h
@@ -49,7 +49,10 @@ class CFWL_Barcode : public CFWL_Edit {
void OnProcessEvent(CFWL_Event* pEvent) override;
// CFWL_Edit
- void SetText(const WideString& wsText) override;
+ void SetText(
+ const WideString& wsText,
+ CFDE_TextEditEngine::RecordOperation op =
+ CFDE_TextEditEngine::RecordOperation::kInsertRecord) override;
void SetType(BC_TYPE type);
bool IsProtectedType() const;
diff --git a/xfa/fwl/cfwl_combobox.cpp b/xfa/fwl/cfwl_combobox.cpp
index 8980dc312c..9cd2119aaf 100644
--- a/xfa/fwl/cfwl_combobox.cpp
+++ b/xfa/fwl/cfwl_combobox.cpp
@@ -16,7 +16,6 @@
#include "xfa/fwl/cfwl_app.h"
#include "xfa/fwl/cfwl_event.h"
#include "xfa/fwl/cfwl_eventselectchanged.h"
-#include "xfa/fwl/cfwl_eventtextchanged.h"
#include "xfa/fwl/cfwl_listbox.h"
#include "xfa/fwl/cfwl_messagekey.h"
#include "xfa/fwl/cfwl_messagekillfocus.h"
@@ -505,7 +504,7 @@ void CFWL_ComboBox::OnProcessEvent(CFWL_Event* pEvent) {
pScrollEv.m_iScrollCode = pScrollEvent->m_iScrollCode;
pScrollEv.m_fPos = pScrollEvent->m_fPos;
DispatchEvent(&pScrollEv);
- } else if (type == CFWL_Event::Type::TextChanged) {
+ } else if (type == CFWL_Event::Type::TextWillChange) {
CFWL_Event pTemp(CFWL_Event::Type::EditChanged, this);
DispatchEvent(&pTemp);
}
diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp
index 7bdb818192..7c4f0e1607 100644
--- a/xfa/fwl/cfwl_edit.cpp
+++ b/xfa/fwl/cfwl_edit.cpp
@@ -19,7 +19,7 @@
#include "xfa/fwl/cfwl_app.h"
#include "xfa/fwl/cfwl_caret.h"
#include "xfa/fwl/cfwl_event.h"
-#include "xfa/fwl/cfwl_eventtextchanged.h"
+#include "xfa/fwl/cfwl_eventtextwillchange.h"
#include "xfa/fwl/cfwl_eventvalidate.h"
#include "xfa/fwl/cfwl_messagekey.h"
#include "xfa/fwl/cfwl_messagemouse.h"
@@ -171,9 +171,10 @@ void CFWL_Edit::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
m_pProperties->m_pThemeProvider = pThemeProvider;
}
-void CFWL_Edit::SetText(const WideString& wsText) {
+void CFWL_Edit::SetText(const WideString& wsText,
+ CFDE_TextEditEngine::RecordOperation op) {
m_EdtEngine.Clear();
- m_EdtEngine.Insert(0, wsText);
+ m_EdtEngine.Insert(0, wsText, op);
}
int32_t CFWL_Edit::GetTextLength() const {
@@ -297,14 +298,26 @@ void CFWL_Edit::OnCaretChanged() {
}
}
-void CFWL_Edit::OnTextChanged(const WideString& prevText) {
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VAlignMask)
- UpdateVAlignment();
+void CFWL_Edit::OnTextWillChange(CFDE_TextEditEngine::TextChange* change) {
+ CFWL_EventTextWillChange event(this);
+ event.previous_text = change->previous_text;
+ event.change_text = change->text;
+ event.selection_start = change->selection_start;
+ event.selection_end = change->selection_end;
+ event.cancelled = false;
- CFWL_EventTextChanged event(this);
- event.wsPrevText = prevText;
DispatchEvent(&event);
+ change->text = event.change_text;
+ change->selection_start = event.selection_start;
+ change->selection_end = event.selection_end;
+ change->cancelled = event.cancelled;
+}
+
+void CFWL_Edit::OnTextChanged() {
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VAlignMask)
+ UpdateVAlignment();
+
LayoutScrollBar();
RepaintRect(GetClientRect());
}
diff --git a/xfa/fwl/cfwl_edit.h b/xfa/fwl/cfwl_edit.h
index 894315de82..634ac225ad 100644
--- a/xfa/fwl/cfwl_edit.h
+++ b/xfa/fwl/cfwl_edit.h
@@ -65,7 +65,9 @@ class CFWL_Edit : public CFWL_Widget, public CFDE_TextEditEngine::Delegate {
void OnDrawWidget(CXFA_Graphics* pGraphics,
const CFX_Matrix& matrix) override;
- virtual void SetText(const WideString& wsText);
+ virtual void SetText(const WideString& wsText,
+ CFDE_TextEditEngine::RecordOperation op =
+ CFDE_TextEditEngine::RecordOperation::kInsertRecord);
int32_t GetTextLength() const;
WideString GetText() const;
@@ -93,7 +95,8 @@ class CFWL_Edit : public CFWL_Widget, public CFDE_TextEditEngine::Delegate {
// CFDE_TextEditEngine::Delegate
void NotifyTextFull() override;
void OnCaretChanged() override;
- void OnTextChanged(const WideString& prevText) override;
+ void OnTextWillChange(CFDE_TextEditEngine::TextChange* change) override;
+ void OnTextChanged() override;
void OnSelChanged() override;
bool OnValidate(const WideString& wsText) override;
void SetScrollOffset(float fScrollOffset) override;
diff --git a/xfa/fwl/cfwl_event.h b/xfa/fwl/cfwl_event.h
index 787f8c2640..8546447209 100644
--- a/xfa/fwl/cfwl_event.h
+++ b/xfa/fwl/cfwl_event.h
@@ -28,7 +28,7 @@ class CFWL_Event {
PreDropDown,
Scroll,
SelectChanged,
- TextChanged,
+ TextWillChange,
TextFull,
Validate
};
diff --git a/xfa/fwl/cfwl_eventtextchanged.cpp b/xfa/fwl/cfwl_eventtextchanged.cpp
deleted file mode 100644
index 439d99d927..0000000000
--- a/xfa/fwl/cfwl_eventtextchanged.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "xfa/fwl/cfwl_eventtextchanged.h"
-
-CFWL_EventTextChanged::CFWL_EventTextChanged(CFWL_Widget* pSrcTarget)
- : CFWL_Event(CFWL_Event::Type::TextChanged, pSrcTarget) {}
-
-CFWL_EventTextChanged::~CFWL_EventTextChanged() {}
diff --git a/xfa/fwl/cfwl_eventtextchanged.h b/xfa/fwl/cfwl_eventtextchanged.h
deleted file mode 100644
index 4494f08075..0000000000
--- a/xfa/fwl/cfwl_eventtextchanged.h
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FWL_CFWL_EVENTTEXTCHANGED_H_
-#define XFA_FWL_CFWL_EVENTTEXTCHANGED_H_
-
-#include "xfa/fwl/cfwl_event.h"
-
-class CFWL_EventTextChanged : public CFWL_Event {
- public:
- explicit CFWL_EventTextChanged(CFWL_Widget* pSrcTarget);
- ~CFWL_EventTextChanged() override;
-
- WideString wsPrevText;
-};
-
-#endif // XFA_FWL_CFWL_EVENTTEXTCHANGED_H_
diff --git a/xfa/fwl/cfwl_eventtextwillchange.cpp b/xfa/fwl/cfwl_eventtextwillchange.cpp
new file mode 100644
index 0000000000..22b1100f59
--- /dev/null
+++ b/xfa/fwl/cfwl_eventtextwillchange.cpp
@@ -0,0 +1,12 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fwl/cfwl_eventtextwillchange.h"
+
+CFWL_EventTextWillChange::CFWL_EventTextWillChange(CFWL_Widget* pSrcTarget)
+ : CFWL_Event(CFWL_Event::Type::TextWillChange, pSrcTarget) {}
+
+CFWL_EventTextWillChange::~CFWL_EventTextWillChange() = default;
diff --git a/xfa/fwl/cfwl_eventtextwillchange.h b/xfa/fwl/cfwl_eventtextwillchange.h
new file mode 100644
index 0000000000..4b2781f0d1
--- /dev/null
+++ b/xfa/fwl/cfwl_eventtextwillchange.h
@@ -0,0 +1,24 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FWL_CFWL_EVENTTEXTWILLCHANGE_H_
+#define XFA_FWL_CFWL_EVENTTEXTWILLCHANGE_H_
+
+#include "xfa/fwl/cfwl_event.h"
+
+class CFWL_EventTextWillChange : public CFWL_Event {
+ public:
+ explicit CFWL_EventTextWillChange(CFWL_Widget* pSrcTarget);
+ ~CFWL_EventTextWillChange() override;
+
+ WideString change_text;
+ WideString previous_text;
+ bool cancelled = false;
+ size_t selection_start = 0;
+ size_t selection_end = 0;
+};
+
+#endif // XFA_FWL_CFWL_EVENTTEXTWILLCHANGE_H_