blob: 2fe6e28c5905853ad9b7b23b4c67c2082ec4a1bc [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
Tom Sepezbf157302017-09-15 13:26:32 -070027void CPWL_EditCtrl::OnCreate(CreateParams* pParamsToAdjust) {
28 pParamsToAdjust->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() {
Tom Sepezbf157302017-09-15 13:26:32 -070032 SetFontSize(GetCreationParams().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
Ryan Harrison275e2602017-09-18 14:23:18 -040055WideString CPWL_EditCtrl::GetSelectedText() {
Diana Gagedce2d722017-06-20 11:17:11 -070056 if (m_pEdit)
Diana Gage89e65622017-07-20 18:09:31 -070057 return m_pEdit->GetSelectedText();
Diana Gagedce2d722017-06-20 11:17:11 -070058
Ryan Harrison275e2602017-09-18 14:23:18 -040059 return WideString();
Diana Gagedce2d722017-06-20 11:17:11 -070060}
61
Ryan Harrison275e2602017-09-18 14:23:18 -040062void CPWL_EditCtrl::ReplaceSelection(const WideString& text) {
Diana Gageab390972017-07-28 17:07:39 -070063 if (!m_pEdit)
64 return;
65
66 m_pEdit->ClearSelection();
67 m_pEdit->InsertText(text, FX_CHARSET_Default);
Diana Gage1c7f1422017-07-24 11:19:52 -070068}
69
Henrique Nakashima55469ae2017-10-04 11:08:45 -040070bool CPWL_EditCtrl::RePosChildWnd() {
Nico Weber9d8ec5a2015-08-04 13:00:21 -070071 m_pEdit->SetPlateRect(GetClientRect());
Henrique Nakashima55469ae2017-10-04 11:08:45 -040072 return true;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070073}
74
Dan Sinclairfb00ec22017-07-05 09:28:15 -040075void CPWL_EditCtrl::SetScrollInfo(const PWL_SCROLL_INFO& info) {
76 if (CPWL_Wnd* pChild = GetVScrollBar())
77 pChild->SetScrollInfo(info);
78}
79
Dan Sinclair7e0336e2017-07-05 09:39:50 -040080void CPWL_EditCtrl::SetScrollPosition(float pos) {
81 if (CPWL_Wnd* pChild = GetVScrollBar())
82 pChild->SetScrollPosition(pos);
83}
84
Dan Sinclair63fbd8d2017-07-05 14:10:36 -040085void CPWL_EditCtrl::ScrollWindowVertically(float pos) {
86 m_pEdit->SetScrollPos(CFX_PointF(m_pEdit->GetScrollPos().x, pos));
87}
88
Tom Sepezbf157302017-09-15 13:26:32 -070089void CPWL_EditCtrl::CreateChildWnd(const CreateParams& cp) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -070090 if (!IsReadOnly())
91 CreateEditCaret(cp);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070092}
93
Tom Sepezbf157302017-09-15 13:26:32 -070094void CPWL_EditCtrl::CreateEditCaret(const CreateParams& cp) {
thestig732f6a02016-05-12 10:41:56 -070095 if (m_pEditCaret)
96 return;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070097
thestig732f6a02016-05-12 10:41:56 -070098 m_pEditCaret = new CPWL_Caret;
99 m_pEditCaret->SetInvalidRect(GetClientRect());
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700100
Tom Sepezbf157302017-09-15 13:26:32 -0700101 CreateParams ecp = cp;
thestig732f6a02016-05-12 10:41:56 -0700102 ecp.pParentWnd = this;
103 ecp.dwFlags = PWS_CHILD | PWS_NOREFRESHCLIP;
104 ecp.dwBorderWidth = 0;
dsinclair92cb5e52016-05-16 11:38:28 -0700105 ecp.nBorderStyle = BorderStyle::SOLID;
Lei Zhangd24236a2017-06-29 18:28:58 -0700106 ecp.rcRectWnd = CFX_FloatRect();
thestig732f6a02016-05-12 10:41:56 -0700107
108 m_pEditCaret->Create(ecp);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700109}
110
Dan Sinclair05df0752017-03-14 14:43:42 -0400111void CPWL_EditCtrl::SetFontSize(float fFontSize) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700112 m_pEdit->SetFontSize(fFontSize);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700113}
114
Dan Sinclair05df0752017-03-14 14:43:42 -0400115float CPWL_EditCtrl::GetFontSize() const {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700116 return m_pEdit->GetFontSize();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700117}
118
tsepez4cf55152016-11-02 14:37:54 -0700119bool CPWL_EditCtrl::OnKeyDown(uint16_t nChar, uint32_t nFlag) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700120 if (m_bMouseDown)
tsepez4cf55152016-11-02 14:37:54 -0700121 return true;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700122
tsepez4cf55152016-11-02 14:37:54 -0700123 bool bRet = CPWL_Wnd::OnKeyDown(nChar, nFlag);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700124
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700125 // FILTER
126 switch (nChar) {
Tom Sepez2f2ffec2015-07-23 14:42:09 -0700127 default:
tsepez4cf55152016-11-02 14:37:54 -0700128 return false;
Tom Sepez2f2ffec2015-07-23 14:42:09 -0700129 case FWL_VKEY_Delete:
130 case FWL_VKEY_Up:
131 case FWL_VKEY_Down:
132 case FWL_VKEY_Left:
133 case FWL_VKEY_Right:
134 case FWL_VKEY_Home:
135 case FWL_VKEY_End:
136 case FWL_VKEY_Insert:
137 case 'C':
138 case 'V':
139 case 'X':
140 case 'A':
141 case 'Z':
142 case 'c':
143 case 'v':
144 case 'x':
145 case 'a':
146 case 'z':
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700147 break;
148 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700149
thestig594b20b2016-05-12 21:56:43 -0700150 if (nChar == FWL_VKEY_Delete && m_pEdit->IsSelected())
151 nChar = FWL_VKEY_Unknown;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700152
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700153 switch (nChar) {
154 case FWL_VKEY_Delete:
155 Delete();
tsepez4cf55152016-11-02 14:37:54 -0700156 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700157 case FWL_VKEY_Insert:
158 if (IsSHIFTpressed(nFlag))
159 PasteText();
tsepez4cf55152016-11-02 14:37:54 -0700160 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700161 case FWL_VKEY_Up:
tsepez4cf55152016-11-02 14:37:54 -0700162 m_pEdit->OnVK_UP(IsSHIFTpressed(nFlag), false);
163 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700164 case FWL_VKEY_Down:
tsepez4cf55152016-11-02 14:37:54 -0700165 m_pEdit->OnVK_DOWN(IsSHIFTpressed(nFlag), false);
166 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700167 case FWL_VKEY_Left:
tsepez4cf55152016-11-02 14:37:54 -0700168 m_pEdit->OnVK_LEFT(IsSHIFTpressed(nFlag), false);
169 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700170 case FWL_VKEY_Right:
tsepez4cf55152016-11-02 14:37:54 -0700171 m_pEdit->OnVK_RIGHT(IsSHIFTpressed(nFlag), false);
172 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700173 case FWL_VKEY_Home:
174 m_pEdit->OnVK_HOME(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
tsepez4cf55152016-11-02 14:37:54 -0700175 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700176 case FWL_VKEY_End:
177 m_pEdit->OnVK_END(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
tsepez4cf55152016-11-02 14:37:54 -0700178 return true;
Tom Sepez2f2ffec2015-07-23 14:42:09 -0700179 case FWL_VKEY_Unknown:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700180 if (!IsSHIFTpressed(nFlag))
Diana Gage22bf7a52017-07-21 11:33:18 -0700181 ClearSelection();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700182 else
183 CutText();
tsepez4cf55152016-11-02 14:37:54 -0700184 return true;
Tom Sepez2f2ffec2015-07-23 14:42:09 -0700185 default:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700186 break;
187 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700188
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700189 return bRet;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700190}
191
tsepez4cf55152016-11-02 14:37:54 -0700192bool CPWL_EditCtrl::OnChar(uint16_t nChar, uint32_t nFlag) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700193 if (m_bMouseDown)
tsepez4cf55152016-11-02 14:37:54 -0700194 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700195
196 CPWL_Wnd::OnChar(nChar, nFlag);
197
198 // FILTER
199 switch (nChar) {
200 case 0x0A:
201 case 0x1B:
tsepez4cf55152016-11-02 14:37:54 -0700202 return false;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700203 default:
204 break;
205 }
206
tsepez4cf55152016-11-02 14:37:54 -0700207 bool bCtrl = IsCTRLpressed(nFlag);
208 bool bAlt = IsALTpressed(nFlag);
209 bool bShift = IsSHIFTpressed(nFlag);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700210
Tom Sepez62a70f92016-03-21 15:00:20 -0700211 uint16_t word = nChar;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700212
213 if (bCtrl && !bAlt) {
214 switch (nChar) {
215 case 'C' - 'A' + 1:
216 CopyText();
tsepez4cf55152016-11-02 14:37:54 -0700217 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700218 case 'V' - 'A' + 1:
219 PasteText();
tsepez4cf55152016-11-02 14:37:54 -0700220 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700221 case 'X' - 'A' + 1:
222 CutText();
tsepez4cf55152016-11-02 14:37:54 -0700223 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700224 case 'A' - 'A' + 1:
225 SelectAll();
tsepez4cf55152016-11-02 14:37:54 -0700226 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700227 case 'Z' - 'A' + 1:
228 if (bShift)
229 Redo();
230 else
231 Undo();
tsepez4cf55152016-11-02 14:37:54 -0700232 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700233 default:
234 if (nChar < 32)
tsepez4cf55152016-11-02 14:37:54 -0700235 return false;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700236 }
237 }
238
239 if (IsReadOnly())
tsepez4cf55152016-11-02 14:37:54 -0700240 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700241
242 if (m_pEdit->IsSelected() && word == FWL_VKEY_Back)
243 word = FWL_VKEY_Unknown;
244
Diana Gage22bf7a52017-07-21 11:33:18 -0700245 ClearSelection();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700246
247 switch (word) {
248 case FWL_VKEY_Back:
249 Backspace();
250 break;
251 case FWL_VKEY_Return:
252 InsertReturn();
253 break;
254 case FWL_VKEY_Unknown:
255 break;
256 default:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700257 InsertWord(word, GetCharSet());
258 break;
259 }
260
tsepez4cf55152016-11-02 14:37:54 -0700261 return true;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700262}
263
Dan Sinclairf528eee2017-02-14 11:52:07 -0500264bool CPWL_EditCtrl::OnLButtonDown(const CFX_PointF& point, uint32_t nFlag) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700265 CPWL_Wnd::OnLButtonDown(point, nFlag);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700266
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700267 if (ClientHitTest(point)) {
Henrique Nakashima55469ae2017-10-04 11:08:45 -0400268 if (m_bMouseDown && !InvalidateRect(nullptr))
269 return true;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700270
tsepez4cf55152016-11-02 14:37:54 -0700271 m_bMouseDown = true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700272 SetCapture();
273
274 m_pEdit->OnMouseDown(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
275 }
276
tsepez4cf55152016-11-02 14:37:54 -0700277 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700278}
279
Dan Sinclairf528eee2017-02-14 11:52:07 -0500280bool CPWL_EditCtrl::OnLButtonUp(const CFX_PointF& point, uint32_t nFlag) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700281 CPWL_Wnd::OnLButtonUp(point, nFlag);
282
283 if (m_bMouseDown) {
284 // can receive keybord message
285 if (ClientHitTest(point) && !IsFocused())
286 SetFocus();
287
288 ReleaseCapture();
tsepez4cf55152016-11-02 14:37:54 -0700289 m_bMouseDown = false;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700290 }
291
tsepez4cf55152016-11-02 14:37:54 -0700292 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700293}
294
Dan Sinclairf528eee2017-02-14 11:52:07 -0500295bool CPWL_EditCtrl::OnMouseMove(const CFX_PointF& point, uint32_t nFlag) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700296 CPWL_Wnd::OnMouseMove(point, nFlag);
297
298 if (m_bMouseDown)
tsepez4cf55152016-11-02 14:37:54 -0700299 m_pEdit->OnMouseMove(point, false, false);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700300
tsepez4cf55152016-11-02 14:37:54 -0700301 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700302}
303
tsepez4cf55152016-11-02 14:37:54 -0700304void CPWL_EditCtrl::SetEditCaret(bool bVisible) {
Dan Sinclairf528eee2017-02-14 11:52:07 -0500305 CFX_PointF ptHead;
306 CFX_PointF ptFoot;
tsepez63f545c2016-09-13 16:08:49 -0700307 if (bVisible)
Dan Sinclair1f403ce2017-02-21 12:56:24 -0500308 GetCaretInfo(&ptHead, &ptFoot);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700309
Dan Sinclair0fdd1ae2017-07-05 16:00:48 -0400310 SetCaret(bVisible, ptHead, ptFoot);
Henrique Nakashima55469ae2017-10-04 11:08:45 -0400311 // Note, |this| may no longer be viable at this point. If more work needs to
312 // be done, check the return value of SetCaret().
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700313}
314
Dan Sinclair1f403ce2017-02-21 12:56:24 -0500315void CPWL_EditCtrl::GetCaretInfo(CFX_PointF* ptHead, CFX_PointF* ptFoot) const {
Dan Sinclair6b0158f2017-07-24 09:42:55 -0400316 CPWL_EditImpl_Iterator* pIterator = m_pEdit->GetIterator();
thestig821d59e2016-05-11 12:59:22 -0700317 pIterator->SetAt(m_pEdit->GetCaret());
318 CPVT_Word word;
319 CPVT_Line line;
320 if (pIterator->GetWord(word)) {
Dan Sinclair1f403ce2017-02-21 12:56:24 -0500321 ptHead->x = word.ptWord.x + word.fWidth;
322 ptHead->y = word.ptWord.y + word.fAscent;
323 ptFoot->x = word.ptWord.x + word.fWidth;
324 ptFoot->y = word.ptWord.y + word.fDescent;
thestig821d59e2016-05-11 12:59:22 -0700325 } else if (pIterator->GetLine(line)) {
Dan Sinclair1f403ce2017-02-21 12:56:24 -0500326 ptHead->x = line.ptLine.x;
327 ptHead->y = line.ptLine.y + line.fLineAscent;
328 ptFoot->x = line.ptLine.x;
329 ptFoot->y = line.ptLine.y + line.fLineDescent;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700330 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700331}
332
Henrique Nakashima55469ae2017-10-04 11:08:45 -0400333bool CPWL_EditCtrl::SetCaret(bool bVisible,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500334 const CFX_PointF& ptHead,
335 const CFX_PointF& ptFoot) {
Henrique Nakashima55469ae2017-10-04 11:08:45 -0400336 if (!m_pEditCaret)
337 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700338
Henrique Nakashima55469ae2017-10-04 11:08:45 -0400339 if (!IsFocused() || m_pEdit->IsSelected())
340 bVisible = false;
341
342 ObservedPtr thisObserved(this);
343 m_pEditCaret->SetCaret(bVisible, ptHead, ptFoot);
344 if (!thisObserved)
345 return false;
346
347 return true;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700348}
349
Ryan Harrison275e2602017-09-18 14:23:18 -0400350WideString CPWL_EditCtrl::GetText() const {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700351 return m_pEdit->GetText();
352}
353
Diana Gage4d02e902017-07-20 17:20:31 -0700354void CPWL_EditCtrl::SetSelection(int32_t nStartChar, int32_t nEndChar) {
355 m_pEdit->SetSelection(nStartChar, nEndChar);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700356}
357
Diana Gage4d02e902017-07-20 17:20:31 -0700358void CPWL_EditCtrl::GetSelection(int32_t& nStartChar, int32_t& nEndChar) const {
359 m_pEdit->GetSelection(nStartChar, nEndChar);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700360}
361
Diana Gage22bf7a52017-07-21 11:33:18 -0700362void CPWL_EditCtrl::ClearSelection() {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700363 if (!IsReadOnly())
Diana Gage22bf7a52017-07-21 11:33:18 -0700364 m_pEdit->ClearSelection();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700365}
366
367void CPWL_EditCtrl::SelectAll() {
368 m_pEdit->SelectAll();
369}
370
Dan Sinclairf528eee2017-02-14 11:52:07 -0500371void CPWL_EditCtrl::SetScrollPos(const CFX_PointF& point) {
thestig732f6a02016-05-12 10:41:56 -0700372 m_pEdit->SetScrollPos(point);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700373}
374
Dan Sinclairf528eee2017-02-14 11:52:07 -0500375CFX_PointF CPWL_EditCtrl::GetScrollPos() const {
thestig732f6a02016-05-12 10:41:56 -0700376 return m_pEdit->GetScrollPos();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700377}
378
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700379void CPWL_EditCtrl::CopyText() {}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700380
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700381void CPWL_EditCtrl::PasteText() {}
382
383void CPWL_EditCtrl::CutText() {}
384
Tom Sepez62a70f92016-03-21 15:00:20 -0700385void CPWL_EditCtrl::InsertWord(uint16_t word, int32_t nCharset) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700386 if (!IsReadOnly())
387 m_pEdit->InsertWord(word, nCharset);
388}
389
390void CPWL_EditCtrl::InsertReturn() {
391 if (!IsReadOnly())
392 m_pEdit->InsertReturn();
393}
394
395void CPWL_EditCtrl::Delete() {
396 if (!IsReadOnly())
397 m_pEdit->Delete();
398}
399
400void CPWL_EditCtrl::Backspace() {
401 if (!IsReadOnly())
402 m_pEdit->Backspace();
403}
404
tsepez4cf55152016-11-02 14:37:54 -0700405bool CPWL_EditCtrl::CanUndo() const {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700406 return !IsReadOnly() && m_pEdit->CanUndo();
407}
408
tsepez4cf55152016-11-02 14:37:54 -0700409bool CPWL_EditCtrl::CanRedo() const {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700410 return !IsReadOnly() && m_pEdit->CanRedo();
411}
412
413void CPWL_EditCtrl::Redo() {
414 if (CanRedo())
415 m_pEdit->Redo();
416}
417
418void CPWL_EditCtrl::Undo() {
419 if (CanUndo())
420 m_pEdit->Undo();
421}
422
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700423int32_t CPWL_EditCtrl::GetCharSet() const {
Dan Sinclairf51a02a2017-04-19 12:46:53 -0400424 return m_nCharSet < 0 ? FX_CHARSET_Default : m_nCharSet;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700425}
426
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700427void CPWL_EditCtrl::SetReadyToInput() {
428 if (m_bMouseDown) {
429 ReleaseCapture();
tsepez4cf55152016-11-02 14:37:54 -0700430 m_bMouseDown = false;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700431 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700432}