blob: a852cb62319142f4d90c9115eb80a539cea56224 [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
Dan Sinclairc411eb92017-07-25 09:39:30 -04007#include "fpdfsdk/pwl/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"
Dan Sinclairc411eb92017-07-25 09:39:30 -040012#include "fpdfsdk/pwl/cpwl_caret.h"
13#include "fpdfsdk/pwl/cpwl_edit_impl.h"
14#include "fpdfsdk/pwl/cpwl_font_map.h"
15#include "fpdfsdk/pwl/cpwl_scroll_bar.h"
16#include "fpdfsdk/pwl/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()
Dan Sinclair6b0158f2017-07-24 09:42:55 -040020 : m_pEdit(new CPWL_EditImpl),
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
Diana Gage1c7f1422017-07-24 11:19:52 -070062void CPWL_EditCtrl::DeleteSelectedText() {
63 if (m_pEdit)
64 m_pEdit->ClearSelection();
65}
66
Nico Weber9d8ec5a2015-08-04 13:00:21 -070067void CPWL_EditCtrl::RePosChildWnd() {
68 m_pEdit->SetPlateRect(GetClientRect());
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070069}
70
Dan Sinclairfb00ec22017-07-05 09:28:15 -040071void CPWL_EditCtrl::SetScrollInfo(const PWL_SCROLL_INFO& info) {
72 if (CPWL_Wnd* pChild = GetVScrollBar())
73 pChild->SetScrollInfo(info);
74}
75
Dan Sinclair7e0336e2017-07-05 09:39:50 -040076void CPWL_EditCtrl::SetScrollPosition(float pos) {
77 if (CPWL_Wnd* pChild = GetVScrollBar())
78 pChild->SetScrollPosition(pos);
79}
80
Dan Sinclair63fbd8d2017-07-05 14:10:36 -040081void CPWL_EditCtrl::ScrollWindowVertically(float pos) {
82 m_pEdit->SetScrollPos(CFX_PointF(m_pEdit->GetScrollPos().x, pos));
83}
84
Nico Weber9d8ec5a2015-08-04 13:00:21 -070085void CPWL_EditCtrl::CreateChildWnd(const PWL_CREATEPARAM& cp) {
86 if (!IsReadOnly())
87 CreateEditCaret(cp);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070088}
89
Nico Weber9d8ec5a2015-08-04 13:00:21 -070090void CPWL_EditCtrl::CreateEditCaret(const PWL_CREATEPARAM& cp) {
thestig732f6a02016-05-12 10:41:56 -070091 if (m_pEditCaret)
92 return;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070093
thestig732f6a02016-05-12 10:41:56 -070094 m_pEditCaret = new CPWL_Caret;
95 m_pEditCaret->SetInvalidRect(GetClientRect());
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070096
thestig732f6a02016-05-12 10:41:56 -070097 PWL_CREATEPARAM ecp = cp;
98 ecp.pParentWnd = this;
99 ecp.dwFlags = PWS_CHILD | PWS_NOREFRESHCLIP;
100 ecp.dwBorderWidth = 0;
dsinclair92cb5e52016-05-16 11:38:28 -0700101 ecp.nBorderStyle = BorderStyle::SOLID;
Lei Zhangd24236a2017-06-29 18:28:58 -0700102 ecp.rcRectWnd = CFX_FloatRect();
thestig732f6a02016-05-12 10:41:56 -0700103
104 m_pEditCaret->Create(ecp);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700105}
106
Dan Sinclair05df0752017-03-14 14:43:42 -0400107void CPWL_EditCtrl::SetFontSize(float fFontSize) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700108 m_pEdit->SetFontSize(fFontSize);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700109}
110
Dan Sinclair05df0752017-03-14 14:43:42 -0400111float CPWL_EditCtrl::GetFontSize() const {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700112 return m_pEdit->GetFontSize();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700113}
114
tsepez4cf55152016-11-02 14:37:54 -0700115bool CPWL_EditCtrl::OnKeyDown(uint16_t nChar, uint32_t nFlag) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700116 if (m_bMouseDown)
tsepez4cf55152016-11-02 14:37:54 -0700117 return true;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700118
tsepez4cf55152016-11-02 14:37:54 -0700119 bool bRet = CPWL_Wnd::OnKeyDown(nChar, nFlag);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700120
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700121 // FILTER
122 switch (nChar) {
Tom Sepez2f2ffec2015-07-23 14:42:09 -0700123 default:
tsepez4cf55152016-11-02 14:37:54 -0700124 return false;
Tom Sepez2f2ffec2015-07-23 14:42:09 -0700125 case FWL_VKEY_Delete:
126 case FWL_VKEY_Up:
127 case FWL_VKEY_Down:
128 case FWL_VKEY_Left:
129 case FWL_VKEY_Right:
130 case FWL_VKEY_Home:
131 case FWL_VKEY_End:
132 case FWL_VKEY_Insert:
133 case 'C':
134 case 'V':
135 case 'X':
136 case 'A':
137 case 'Z':
138 case 'c':
139 case 'v':
140 case 'x':
141 case 'a':
142 case 'z':
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700143 break;
144 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700145
thestig594b20b2016-05-12 21:56:43 -0700146 if (nChar == FWL_VKEY_Delete && m_pEdit->IsSelected())
147 nChar = FWL_VKEY_Unknown;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700148
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700149 switch (nChar) {
150 case FWL_VKEY_Delete:
151 Delete();
tsepez4cf55152016-11-02 14:37:54 -0700152 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700153 case FWL_VKEY_Insert:
154 if (IsSHIFTpressed(nFlag))
155 PasteText();
tsepez4cf55152016-11-02 14:37:54 -0700156 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700157 case FWL_VKEY_Up:
tsepez4cf55152016-11-02 14:37:54 -0700158 m_pEdit->OnVK_UP(IsSHIFTpressed(nFlag), false);
159 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700160 case FWL_VKEY_Down:
tsepez4cf55152016-11-02 14:37:54 -0700161 m_pEdit->OnVK_DOWN(IsSHIFTpressed(nFlag), false);
162 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700163 case FWL_VKEY_Left:
tsepez4cf55152016-11-02 14:37:54 -0700164 m_pEdit->OnVK_LEFT(IsSHIFTpressed(nFlag), false);
165 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700166 case FWL_VKEY_Right:
tsepez4cf55152016-11-02 14:37:54 -0700167 m_pEdit->OnVK_RIGHT(IsSHIFTpressed(nFlag), false);
168 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700169 case FWL_VKEY_Home:
170 m_pEdit->OnVK_HOME(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
tsepez4cf55152016-11-02 14:37:54 -0700171 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700172 case FWL_VKEY_End:
173 m_pEdit->OnVK_END(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
tsepez4cf55152016-11-02 14:37:54 -0700174 return true;
Tom Sepez2f2ffec2015-07-23 14:42:09 -0700175 case FWL_VKEY_Unknown:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700176 if (!IsSHIFTpressed(nFlag))
Diana Gage22bf7a52017-07-21 11:33:18 -0700177 ClearSelection();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700178 else
179 CutText();
tsepez4cf55152016-11-02 14:37:54 -0700180 return true;
Tom Sepez2f2ffec2015-07-23 14:42:09 -0700181 default:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700182 break;
183 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700184
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700185 return bRet;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700186}
187
tsepez4cf55152016-11-02 14:37:54 -0700188bool CPWL_EditCtrl::OnChar(uint16_t nChar, uint32_t nFlag) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700189 if (m_bMouseDown)
tsepez4cf55152016-11-02 14:37:54 -0700190 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700191
192 CPWL_Wnd::OnChar(nChar, nFlag);
193
194 // FILTER
195 switch (nChar) {
196 case 0x0A:
197 case 0x1B:
tsepez4cf55152016-11-02 14:37:54 -0700198 return false;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700199 default:
200 break;
201 }
202
tsepez4cf55152016-11-02 14:37:54 -0700203 bool bCtrl = IsCTRLpressed(nFlag);
204 bool bAlt = IsALTpressed(nFlag);
205 bool bShift = IsSHIFTpressed(nFlag);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700206
Tom Sepez62a70f92016-03-21 15:00:20 -0700207 uint16_t word = nChar;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700208
209 if (bCtrl && !bAlt) {
210 switch (nChar) {
211 case 'C' - 'A' + 1:
212 CopyText();
tsepez4cf55152016-11-02 14:37:54 -0700213 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700214 case 'V' - 'A' + 1:
215 PasteText();
tsepez4cf55152016-11-02 14:37:54 -0700216 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700217 case 'X' - 'A' + 1:
218 CutText();
tsepez4cf55152016-11-02 14:37:54 -0700219 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700220 case 'A' - 'A' + 1:
221 SelectAll();
tsepez4cf55152016-11-02 14:37:54 -0700222 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700223 case 'Z' - 'A' + 1:
224 if (bShift)
225 Redo();
226 else
227 Undo();
tsepez4cf55152016-11-02 14:37:54 -0700228 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700229 default:
230 if (nChar < 32)
tsepez4cf55152016-11-02 14:37:54 -0700231 return false;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700232 }
233 }
234
235 if (IsReadOnly())
tsepez4cf55152016-11-02 14:37:54 -0700236 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700237
238 if (m_pEdit->IsSelected() && word == FWL_VKEY_Back)
239 word = FWL_VKEY_Unknown;
240
Diana Gage22bf7a52017-07-21 11:33:18 -0700241 ClearSelection();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700242
243 switch (word) {
244 case FWL_VKEY_Back:
245 Backspace();
246 break;
247 case FWL_VKEY_Return:
248 InsertReturn();
249 break;
250 case FWL_VKEY_Unknown:
251 break;
252 default:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700253 InsertWord(word, GetCharSet());
254 break;
255 }
256
tsepez4cf55152016-11-02 14:37:54 -0700257 return true;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700258}
259
Dan Sinclairf528eee2017-02-14 11:52:07 -0500260bool CPWL_EditCtrl::OnLButtonDown(const CFX_PointF& point, uint32_t nFlag) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700261 CPWL_Wnd::OnLButtonDown(point, nFlag);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700262
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700263 if (ClientHitTest(point)) {
Tom Sepez2f2ffec2015-07-23 14:42:09 -0700264 if (m_bMouseDown)
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700265 InvalidateRect();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700266
tsepez4cf55152016-11-02 14:37:54 -0700267 m_bMouseDown = true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700268 SetCapture();
269
270 m_pEdit->OnMouseDown(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
271 }
272
tsepez4cf55152016-11-02 14:37:54 -0700273 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700274}
275
Dan Sinclairf528eee2017-02-14 11:52:07 -0500276bool CPWL_EditCtrl::OnLButtonUp(const CFX_PointF& point, uint32_t nFlag) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700277 CPWL_Wnd::OnLButtonUp(point, nFlag);
278
279 if (m_bMouseDown) {
280 // can receive keybord message
281 if (ClientHitTest(point) && !IsFocused())
282 SetFocus();
283
284 ReleaseCapture();
tsepez4cf55152016-11-02 14:37:54 -0700285 m_bMouseDown = false;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700286 }
287
tsepez4cf55152016-11-02 14:37:54 -0700288 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700289}
290
Dan Sinclairf528eee2017-02-14 11:52:07 -0500291bool CPWL_EditCtrl::OnMouseMove(const CFX_PointF& point, uint32_t nFlag) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700292 CPWL_Wnd::OnMouseMove(point, nFlag);
293
294 if (m_bMouseDown)
tsepez4cf55152016-11-02 14:37:54 -0700295 m_pEdit->OnMouseMove(point, false, false);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700296
tsepez4cf55152016-11-02 14:37:54 -0700297 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700298}
299
tsepez4cf55152016-11-02 14:37:54 -0700300void CPWL_EditCtrl::SetEditCaret(bool bVisible) {
Dan Sinclairf528eee2017-02-14 11:52:07 -0500301 CFX_PointF ptHead;
302 CFX_PointF ptFoot;
tsepez63f545c2016-09-13 16:08:49 -0700303 if (bVisible)
Dan Sinclair1f403ce2017-02-21 12:56:24 -0500304 GetCaretInfo(&ptHead, &ptFoot);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700305
Dan Sinclair0fdd1ae2017-07-05 16:00:48 -0400306 SetCaret(bVisible, ptHead, ptFoot);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700307}
308
Dan Sinclair1f403ce2017-02-21 12:56:24 -0500309void CPWL_EditCtrl::GetCaretInfo(CFX_PointF* ptHead, CFX_PointF* ptFoot) const {
Dan Sinclair6b0158f2017-07-24 09:42:55 -0400310 CPWL_EditImpl_Iterator* pIterator = m_pEdit->GetIterator();
thestig821d59e2016-05-11 12:59:22 -0700311 pIterator->SetAt(m_pEdit->GetCaret());
312 CPVT_Word word;
313 CPVT_Line line;
314 if (pIterator->GetWord(word)) {
Dan Sinclair1f403ce2017-02-21 12:56:24 -0500315 ptHead->x = word.ptWord.x + word.fWidth;
316 ptHead->y = word.ptWord.y + word.fAscent;
317 ptFoot->x = word.ptWord.x + word.fWidth;
318 ptFoot->y = word.ptWord.y + word.fDescent;
thestig821d59e2016-05-11 12:59:22 -0700319 } else if (pIterator->GetLine(line)) {
Dan Sinclair1f403ce2017-02-21 12:56:24 -0500320 ptHead->x = line.ptLine.x;
321 ptHead->y = line.ptLine.y + line.fLineAscent;
322 ptFoot->x = line.ptLine.x;
323 ptFoot->y = line.ptLine.y + line.fLineDescent;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700324 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700325}
326
tsepez4cf55152016-11-02 14:37:54 -0700327void CPWL_EditCtrl::SetCaret(bool bVisible,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500328 const CFX_PointF& ptHead,
329 const CFX_PointF& ptFoot) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700330 if (m_pEditCaret) {
331 if (!IsFocused() || m_pEdit->IsSelected())
tsepez4cf55152016-11-02 14:37:54 -0700332 bVisible = false;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700333
334 m_pEditCaret->SetCaret(bVisible, ptHead, ptFoot);
335 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700336}
337
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700338CFX_WideString CPWL_EditCtrl::GetText() const {
339 return m_pEdit->GetText();
340}
341
Diana Gage4d02e902017-07-20 17:20:31 -0700342void CPWL_EditCtrl::SetSelection(int32_t nStartChar, int32_t nEndChar) {
343 m_pEdit->SetSelection(nStartChar, nEndChar);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700344}
345
Diana Gage4d02e902017-07-20 17:20:31 -0700346void CPWL_EditCtrl::GetSelection(int32_t& nStartChar, int32_t& nEndChar) const {
347 m_pEdit->GetSelection(nStartChar, nEndChar);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700348}
349
Diana Gage22bf7a52017-07-21 11:33:18 -0700350void CPWL_EditCtrl::ClearSelection() {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700351 if (!IsReadOnly())
Diana Gage22bf7a52017-07-21 11:33:18 -0700352 m_pEdit->ClearSelection();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700353}
354
355void CPWL_EditCtrl::SelectAll() {
356 m_pEdit->SelectAll();
357}
358
Dan Sinclairf528eee2017-02-14 11:52:07 -0500359void CPWL_EditCtrl::SetScrollPos(const CFX_PointF& point) {
thestig732f6a02016-05-12 10:41:56 -0700360 m_pEdit->SetScrollPos(point);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700361}
362
Dan Sinclairf528eee2017-02-14 11:52:07 -0500363CFX_PointF CPWL_EditCtrl::GetScrollPos() const {
thestig732f6a02016-05-12 10:41:56 -0700364 return m_pEdit->GetScrollPos();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700365}
366
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700367void CPWL_EditCtrl::CopyText() {}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700368
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700369void CPWL_EditCtrl::PasteText() {}
370
371void CPWL_EditCtrl::CutText() {}
372
Tom Sepez62a70f92016-03-21 15:00:20 -0700373void CPWL_EditCtrl::InsertWord(uint16_t word, int32_t nCharset) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700374 if (!IsReadOnly())
375 m_pEdit->InsertWord(word, nCharset);
376}
377
378void CPWL_EditCtrl::InsertReturn() {
379 if (!IsReadOnly())
380 m_pEdit->InsertReturn();
381}
382
383void CPWL_EditCtrl::Delete() {
384 if (!IsReadOnly())
385 m_pEdit->Delete();
386}
387
388void CPWL_EditCtrl::Backspace() {
389 if (!IsReadOnly())
390 m_pEdit->Backspace();
391}
392
tsepez4cf55152016-11-02 14:37:54 -0700393bool CPWL_EditCtrl::CanUndo() const {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700394 return !IsReadOnly() && m_pEdit->CanUndo();
395}
396
tsepez4cf55152016-11-02 14:37:54 -0700397bool CPWL_EditCtrl::CanRedo() const {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700398 return !IsReadOnly() && m_pEdit->CanRedo();
399}
400
401void CPWL_EditCtrl::Redo() {
402 if (CanRedo())
403 m_pEdit->Redo();
404}
405
406void CPWL_EditCtrl::Undo() {
407 if (CanUndo())
408 m_pEdit->Undo();
409}
410
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700411int32_t CPWL_EditCtrl::GetCharSet() const {
Dan Sinclairf51a02a2017-04-19 12:46:53 -0400412 return m_nCharSet < 0 ? FX_CHARSET_Default : m_nCharSet;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700413}
414
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700415void CPWL_EditCtrl::SetReadyToInput() {
416 if (m_bMouseDown) {
417 ReleaseCapture();
tsepez4cf55152016-11-02 14:37:54 -0700418 m_bMouseDown = false;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700419 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700420}