blob: 7b90579a5fd4050b28a9bc5afef40ea504013b2a [file] [log] [blame]
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001// Copyright 2014 PDFium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
Lei Zhang60f507b2015-06-13 00:41:00 -07004
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07005// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
Lei Zhang633a3b72017-06-02 15:27:22 -07007#include "fpdfsdk/pdfwindow/cpwl_edit_ctrl.h"
Lei Zhangc2fb35f2016-01-05 16:46:58 -08008
dsinclair1727aee2016-09-29 13:12:56 -07009#include "core/fpdfdoc/cpvt_section.h"
10#include "core/fpdfdoc/cpvt_word.h"
dsinclair74a34fc2016-09-29 16:41:42 -070011#include "core/fxge/fx_font.h"
dsinclair0bb385b2016-09-29 17:03:59 -070012#include "fpdfsdk/fxedit/fxet_edit.h"
Lei Zhang633a3b72017-06-02 15:27:22 -070013#include "fpdfsdk/pdfwindow/cpwl_caret.h"
14#include "fpdfsdk/pdfwindow/cpwl_font_map.h"
15#include "fpdfsdk/pdfwindow/cpwl_scroll_bar.h"
Lei Zhang633a3b72017-06-02 15:27:22 -070016#include "fpdfsdk/pdfwindow/cpwl_wnd.h"
Lei Zhangc2fb35f2016-01-05 16:46:58 -080017#include "public/fpdf_fwlevent.h"
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070018
Nico Weber9d8ec5a2015-08-04 13:00:21 -070019CPWL_EditCtrl::CPWL_EditCtrl()
dsinclaire35af1e2016-07-13 11:26:20 -070020 : m_pEdit(new CFX_Edit),
thestig1cd352e2016-06-07 17:53:06 -070021 m_pEditCaret(nullptr),
tsepez4cf55152016-11-02 14:37:54 -070022 m_bMouseDown(false),
Dan Sinclairf51a02a2017-04-19 12:46:53 -040023 m_nCharSet(FX_CHARSET_Default) {}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070024
dsinclairdbc77162016-07-13 11:34:23 -070025CPWL_EditCtrl::~CPWL_EditCtrl() {}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070026
Nico Weber9d8ec5a2015-08-04 13:00:21 -070027void CPWL_EditCtrl::OnCreate(PWL_CREATEPARAM& cp) {
28 cp.eCursorType = FXCT_VBEAM;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070029}
30
Nico Weber9d8ec5a2015-08-04 13:00:21 -070031void CPWL_EditCtrl::OnCreated() {
32 SetFontSize(GetCreationParam().fFontSize);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070033
Nico Weber9d8ec5a2015-08-04 13:00:21 -070034 m_pEdit->SetFontMap(GetFontMap());
35 m_pEdit->SetNotify(this);
36 m_pEdit->Initialize();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070037}
38
tsepez4cf55152016-11-02 14:37:54 -070039bool CPWL_EditCtrl::IsWndHorV() {
Tom Sepez60d909e2015-12-10 15:34:55 -080040 CFX_Matrix mt = GetWindowMatrix();
Dan Sinclair1f403ce2017-02-21 12:56:24 -050041 return mt.Transform(CFX_PointF(1, 1)).y == mt.Transform(CFX_PointF(0, 1)).y;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070042}
43
Nico Weber9d8ec5a2015-08-04 13:00:21 -070044void CPWL_EditCtrl::SetCursor() {
45 if (IsValid()) {
dsinclairb9590102016-04-27 06:38:59 -070046 if (CFX_SystemHandler* pSH = GetSystemHandler()) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -070047 if (IsWndHorV())
48 pSH->SetCursor(FXCT_VBEAM);
49 else
50 pSH->SetCursor(FXCT_HBEAM);
Tom Sepez2f2ffec2015-07-23 14:42:09 -070051 }
Nico Weber9d8ec5a2015-08-04 13:00:21 -070052 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070053}
54
Diana Gagedce2d722017-06-20 11:17:11 -070055CFX_WideString CPWL_EditCtrl::GetSelectedText() {
56 if (m_pEdit)
Diana Gage89e65622017-07-20 18:09:31 -070057 return m_pEdit->GetSelectedText();
Diana Gagedce2d722017-06-20 11:17:11 -070058
59 return CFX_WideString();
60}
61
Nico Weber9d8ec5a2015-08-04 13:00:21 -070062void CPWL_EditCtrl::RePosChildWnd() {
63 m_pEdit->SetPlateRect(GetClientRect());
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070064}
65
Dan Sinclairfb00ec22017-07-05 09:28:15 -040066void CPWL_EditCtrl::SetScrollInfo(const PWL_SCROLL_INFO& info) {
67 if (CPWL_Wnd* pChild = GetVScrollBar())
68 pChild->SetScrollInfo(info);
69}
70
Dan Sinclair7e0336e2017-07-05 09:39:50 -040071void CPWL_EditCtrl::SetScrollPosition(float pos) {
72 if (CPWL_Wnd* pChild = GetVScrollBar())
73 pChild->SetScrollPosition(pos);
74}
75
Dan Sinclair63fbd8d2017-07-05 14:10:36 -040076void CPWL_EditCtrl::ScrollWindowVertically(float pos) {
77 m_pEdit->SetScrollPos(CFX_PointF(m_pEdit->GetScrollPos().x, pos));
78}
79
Nico Weber9d8ec5a2015-08-04 13:00:21 -070080void CPWL_EditCtrl::CreateChildWnd(const PWL_CREATEPARAM& cp) {
81 if (!IsReadOnly())
82 CreateEditCaret(cp);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070083}
84
Nico Weber9d8ec5a2015-08-04 13:00:21 -070085void CPWL_EditCtrl::CreateEditCaret(const PWL_CREATEPARAM& cp) {
thestig732f6a02016-05-12 10:41:56 -070086 if (m_pEditCaret)
87 return;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070088
thestig732f6a02016-05-12 10:41:56 -070089 m_pEditCaret = new CPWL_Caret;
90 m_pEditCaret->SetInvalidRect(GetClientRect());
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070091
thestig732f6a02016-05-12 10:41:56 -070092 PWL_CREATEPARAM ecp = cp;
93 ecp.pParentWnd = this;
94 ecp.dwFlags = PWS_CHILD | PWS_NOREFRESHCLIP;
95 ecp.dwBorderWidth = 0;
dsinclair92cb5e52016-05-16 11:38:28 -070096 ecp.nBorderStyle = BorderStyle::SOLID;
Lei Zhangd24236a2017-06-29 18:28:58 -070097 ecp.rcRectWnd = CFX_FloatRect();
thestig732f6a02016-05-12 10:41:56 -070098
99 m_pEditCaret->Create(ecp);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700100}
101
Dan Sinclair05df0752017-03-14 14:43:42 -0400102void CPWL_EditCtrl::SetFontSize(float fFontSize) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700103 m_pEdit->SetFontSize(fFontSize);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700104}
105
Dan Sinclair05df0752017-03-14 14:43:42 -0400106float CPWL_EditCtrl::GetFontSize() const {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700107 return m_pEdit->GetFontSize();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700108}
109
tsepez4cf55152016-11-02 14:37:54 -0700110bool CPWL_EditCtrl::OnKeyDown(uint16_t nChar, uint32_t nFlag) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700111 if (m_bMouseDown)
tsepez4cf55152016-11-02 14:37:54 -0700112 return true;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700113
tsepez4cf55152016-11-02 14:37:54 -0700114 bool bRet = CPWL_Wnd::OnKeyDown(nChar, nFlag);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700115
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700116 // FILTER
117 switch (nChar) {
Tom Sepez2f2ffec2015-07-23 14:42:09 -0700118 default:
tsepez4cf55152016-11-02 14:37:54 -0700119 return false;
Tom Sepez2f2ffec2015-07-23 14:42:09 -0700120 case FWL_VKEY_Delete:
121 case FWL_VKEY_Up:
122 case FWL_VKEY_Down:
123 case FWL_VKEY_Left:
124 case FWL_VKEY_Right:
125 case FWL_VKEY_Home:
126 case FWL_VKEY_End:
127 case FWL_VKEY_Insert:
128 case 'C':
129 case 'V':
130 case 'X':
131 case 'A':
132 case 'Z':
133 case 'c':
134 case 'v':
135 case 'x':
136 case 'a':
137 case 'z':
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700138 break;
139 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700140
thestig594b20b2016-05-12 21:56:43 -0700141 if (nChar == FWL_VKEY_Delete && m_pEdit->IsSelected())
142 nChar = FWL_VKEY_Unknown;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700143
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700144 switch (nChar) {
145 case FWL_VKEY_Delete:
146 Delete();
tsepez4cf55152016-11-02 14:37:54 -0700147 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700148 case FWL_VKEY_Insert:
149 if (IsSHIFTpressed(nFlag))
150 PasteText();
tsepez4cf55152016-11-02 14:37:54 -0700151 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700152 case FWL_VKEY_Up:
tsepez4cf55152016-11-02 14:37:54 -0700153 m_pEdit->OnVK_UP(IsSHIFTpressed(nFlag), false);
154 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700155 case FWL_VKEY_Down:
tsepez4cf55152016-11-02 14:37:54 -0700156 m_pEdit->OnVK_DOWN(IsSHIFTpressed(nFlag), false);
157 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700158 case FWL_VKEY_Left:
tsepez4cf55152016-11-02 14:37:54 -0700159 m_pEdit->OnVK_LEFT(IsSHIFTpressed(nFlag), false);
160 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700161 case FWL_VKEY_Right:
tsepez4cf55152016-11-02 14:37:54 -0700162 m_pEdit->OnVK_RIGHT(IsSHIFTpressed(nFlag), false);
163 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700164 case FWL_VKEY_Home:
165 m_pEdit->OnVK_HOME(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
tsepez4cf55152016-11-02 14:37:54 -0700166 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700167 case FWL_VKEY_End:
168 m_pEdit->OnVK_END(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
tsepez4cf55152016-11-02 14:37:54 -0700169 return true;
Tom Sepez2f2ffec2015-07-23 14:42:09 -0700170 case FWL_VKEY_Unknown:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700171 if (!IsSHIFTpressed(nFlag))
Diana Gage22bf7a52017-07-21 11:33:18 -0700172 ClearSelection();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700173 else
174 CutText();
tsepez4cf55152016-11-02 14:37:54 -0700175 return true;
Tom Sepez2f2ffec2015-07-23 14:42:09 -0700176 default:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700177 break;
178 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700179
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700180 return bRet;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700181}
182
tsepez4cf55152016-11-02 14:37:54 -0700183bool CPWL_EditCtrl::OnChar(uint16_t nChar, uint32_t nFlag) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700184 if (m_bMouseDown)
tsepez4cf55152016-11-02 14:37:54 -0700185 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700186
187 CPWL_Wnd::OnChar(nChar, nFlag);
188
189 // FILTER
190 switch (nChar) {
191 case 0x0A:
192 case 0x1B:
tsepez4cf55152016-11-02 14:37:54 -0700193 return false;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700194 default:
195 break;
196 }
197
tsepez4cf55152016-11-02 14:37:54 -0700198 bool bCtrl = IsCTRLpressed(nFlag);
199 bool bAlt = IsALTpressed(nFlag);
200 bool bShift = IsSHIFTpressed(nFlag);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700201
Tom Sepez62a70f92016-03-21 15:00:20 -0700202 uint16_t word = nChar;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700203
204 if (bCtrl && !bAlt) {
205 switch (nChar) {
206 case 'C' - 'A' + 1:
207 CopyText();
tsepez4cf55152016-11-02 14:37:54 -0700208 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700209 case 'V' - 'A' + 1:
210 PasteText();
tsepez4cf55152016-11-02 14:37:54 -0700211 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700212 case 'X' - 'A' + 1:
213 CutText();
tsepez4cf55152016-11-02 14:37:54 -0700214 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700215 case 'A' - 'A' + 1:
216 SelectAll();
tsepez4cf55152016-11-02 14:37:54 -0700217 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700218 case 'Z' - 'A' + 1:
219 if (bShift)
220 Redo();
221 else
222 Undo();
tsepez4cf55152016-11-02 14:37:54 -0700223 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700224 default:
225 if (nChar < 32)
tsepez4cf55152016-11-02 14:37:54 -0700226 return false;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700227 }
228 }
229
230 if (IsReadOnly())
tsepez4cf55152016-11-02 14:37:54 -0700231 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700232
233 if (m_pEdit->IsSelected() && word == FWL_VKEY_Back)
234 word = FWL_VKEY_Unknown;
235
Diana Gage22bf7a52017-07-21 11:33:18 -0700236 ClearSelection();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700237
238 switch (word) {
239 case FWL_VKEY_Back:
240 Backspace();
241 break;
242 case FWL_VKEY_Return:
243 InsertReturn();
244 break;
245 case FWL_VKEY_Unknown:
246 break;
247 default:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700248 InsertWord(word, GetCharSet());
249 break;
250 }
251
tsepez4cf55152016-11-02 14:37:54 -0700252 return true;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700253}
254
Dan Sinclairf528eee2017-02-14 11:52:07 -0500255bool CPWL_EditCtrl::OnLButtonDown(const CFX_PointF& point, uint32_t nFlag) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700256 CPWL_Wnd::OnLButtonDown(point, nFlag);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700257
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700258 if (ClientHitTest(point)) {
Tom Sepez2f2ffec2015-07-23 14:42:09 -0700259 if (m_bMouseDown)
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700260 InvalidateRect();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700261
tsepez4cf55152016-11-02 14:37:54 -0700262 m_bMouseDown = true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700263 SetCapture();
264
265 m_pEdit->OnMouseDown(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
266 }
267
tsepez4cf55152016-11-02 14:37:54 -0700268 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700269}
270
Dan Sinclairf528eee2017-02-14 11:52:07 -0500271bool CPWL_EditCtrl::OnLButtonUp(const CFX_PointF& point, uint32_t nFlag) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700272 CPWL_Wnd::OnLButtonUp(point, nFlag);
273
274 if (m_bMouseDown) {
275 // can receive keybord message
276 if (ClientHitTest(point) && !IsFocused())
277 SetFocus();
278
279 ReleaseCapture();
tsepez4cf55152016-11-02 14:37:54 -0700280 m_bMouseDown = false;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700281 }
282
tsepez4cf55152016-11-02 14:37:54 -0700283 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700284}
285
Dan Sinclairf528eee2017-02-14 11:52:07 -0500286bool CPWL_EditCtrl::OnMouseMove(const CFX_PointF& point, uint32_t nFlag) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700287 CPWL_Wnd::OnMouseMove(point, nFlag);
288
289 if (m_bMouseDown)
tsepez4cf55152016-11-02 14:37:54 -0700290 m_pEdit->OnMouseMove(point, false, false);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700291
tsepez4cf55152016-11-02 14:37:54 -0700292 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700293}
294
tsepez4cf55152016-11-02 14:37:54 -0700295void CPWL_EditCtrl::SetEditCaret(bool bVisible) {
Dan Sinclairf528eee2017-02-14 11:52:07 -0500296 CFX_PointF ptHead;
297 CFX_PointF ptFoot;
tsepez63f545c2016-09-13 16:08:49 -0700298 if (bVisible)
Dan Sinclair1f403ce2017-02-21 12:56:24 -0500299 GetCaretInfo(&ptHead, &ptFoot);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700300
Dan Sinclair0fdd1ae2017-07-05 16:00:48 -0400301 SetCaret(bVisible, ptHead, ptFoot);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700302}
303
Dan Sinclair1f403ce2017-02-21 12:56:24 -0500304void CPWL_EditCtrl::GetCaretInfo(CFX_PointF* ptHead, CFX_PointF* ptFoot) const {
dsinclaire35af1e2016-07-13 11:26:20 -0700305 CFX_Edit_Iterator* pIterator = m_pEdit->GetIterator();
thestig821d59e2016-05-11 12:59:22 -0700306 pIterator->SetAt(m_pEdit->GetCaret());
307 CPVT_Word word;
308 CPVT_Line line;
309 if (pIterator->GetWord(word)) {
Dan Sinclair1f403ce2017-02-21 12:56:24 -0500310 ptHead->x = word.ptWord.x + word.fWidth;
311 ptHead->y = word.ptWord.y + word.fAscent;
312 ptFoot->x = word.ptWord.x + word.fWidth;
313 ptFoot->y = word.ptWord.y + word.fDescent;
thestig821d59e2016-05-11 12:59:22 -0700314 } else if (pIterator->GetLine(line)) {
Dan Sinclair1f403ce2017-02-21 12:56:24 -0500315 ptHead->x = line.ptLine.x;
316 ptHead->y = line.ptLine.y + line.fLineAscent;
317 ptFoot->x = line.ptLine.x;
318 ptFoot->y = line.ptLine.y + line.fLineDescent;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700319 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700320}
321
tsepez4cf55152016-11-02 14:37:54 -0700322void CPWL_EditCtrl::SetCaret(bool bVisible,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500323 const CFX_PointF& ptHead,
324 const CFX_PointF& ptFoot) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700325 if (m_pEditCaret) {
326 if (!IsFocused() || m_pEdit->IsSelected())
tsepez4cf55152016-11-02 14:37:54 -0700327 bVisible = false;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700328
329 m_pEditCaret->SetCaret(bVisible, ptHead, ptFoot);
330 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700331}
332
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700333CFX_WideString CPWL_EditCtrl::GetText() const {
334 return m_pEdit->GetText();
335}
336
Diana Gage4d02e902017-07-20 17:20:31 -0700337void CPWL_EditCtrl::SetSelection(int32_t nStartChar, int32_t nEndChar) {
338 m_pEdit->SetSelection(nStartChar, nEndChar);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700339}
340
Diana Gage4d02e902017-07-20 17:20:31 -0700341void CPWL_EditCtrl::GetSelection(int32_t& nStartChar, int32_t& nEndChar) const {
342 m_pEdit->GetSelection(nStartChar, nEndChar);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700343}
344
Diana Gage22bf7a52017-07-21 11:33:18 -0700345void CPWL_EditCtrl::ClearSelection() {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700346 if (!IsReadOnly())
Diana Gage22bf7a52017-07-21 11:33:18 -0700347 m_pEdit->ClearSelection();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700348}
349
350void CPWL_EditCtrl::SelectAll() {
351 m_pEdit->SelectAll();
352}
353
Dan Sinclairf528eee2017-02-14 11:52:07 -0500354void CPWL_EditCtrl::SetScrollPos(const CFX_PointF& point) {
thestig732f6a02016-05-12 10:41:56 -0700355 m_pEdit->SetScrollPos(point);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700356}
357
Dan Sinclairf528eee2017-02-14 11:52:07 -0500358CFX_PointF CPWL_EditCtrl::GetScrollPos() const {
thestig732f6a02016-05-12 10:41:56 -0700359 return m_pEdit->GetScrollPos();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700360}
361
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700362void CPWL_EditCtrl::CopyText() {}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700363
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700364void CPWL_EditCtrl::PasteText() {}
365
366void CPWL_EditCtrl::CutText() {}
367
Tom Sepez62a70f92016-03-21 15:00:20 -0700368void CPWL_EditCtrl::InsertWord(uint16_t word, int32_t nCharset) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700369 if (!IsReadOnly())
370 m_pEdit->InsertWord(word, nCharset);
371}
372
373void CPWL_EditCtrl::InsertReturn() {
374 if (!IsReadOnly())
375 m_pEdit->InsertReturn();
376}
377
378void CPWL_EditCtrl::Delete() {
379 if (!IsReadOnly())
380 m_pEdit->Delete();
381}
382
383void CPWL_EditCtrl::Backspace() {
384 if (!IsReadOnly())
385 m_pEdit->Backspace();
386}
387
tsepez4cf55152016-11-02 14:37:54 -0700388bool CPWL_EditCtrl::CanUndo() const {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700389 return !IsReadOnly() && m_pEdit->CanUndo();
390}
391
tsepez4cf55152016-11-02 14:37:54 -0700392bool CPWL_EditCtrl::CanRedo() const {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700393 return !IsReadOnly() && m_pEdit->CanRedo();
394}
395
396void CPWL_EditCtrl::Redo() {
397 if (CanRedo())
398 m_pEdit->Redo();
399}
400
401void CPWL_EditCtrl::Undo() {
402 if (CanUndo())
403 m_pEdit->Undo();
404}
405
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700406int32_t CPWL_EditCtrl::GetCharSet() const {
Dan Sinclairf51a02a2017-04-19 12:46:53 -0400407 return m_nCharSet < 0 ? FX_CHARSET_Default : m_nCharSet;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700408}
409
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700410void CPWL_EditCtrl::SetReadyToInput() {
411 if (m_bMouseDown) {
412 ReleaseCapture();
tsepez4cf55152016-11-02 14:37:54 -0700413 m_bMouseDown = false;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700414 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700415}