blob: 06b5dedbf0718c46256d320c042d23916f72445c [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_word.h"
dsinclair74a34fc2016-09-29 16:41:42 -070010#include "core/fxge/fx_font.h"
Dan Sinclairc411eb92017-07-25 09:39:30 -040011#include "fpdfsdk/pwl/cpwl_caret.h"
12#include "fpdfsdk/pwl/cpwl_edit_impl.h"
13#include "fpdfsdk/pwl/cpwl_font_map.h"
14#include "fpdfsdk/pwl/cpwl_scroll_bar.h"
15#include "fpdfsdk/pwl/cpwl_wnd.h"
Lei Zhangc2fb35f2016-01-05 16:46:58 -080016#include "public/fpdf_fwlevent.h"
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070017
Nico Weber9d8ec5a2015-08-04 13:00:21 -070018CPWL_EditCtrl::CPWL_EditCtrl()
Dan Sinclair6b0158f2017-07-24 09:42:55 -040019 : m_pEdit(new CPWL_EditImpl),
thestig1cd352e2016-06-07 17:53:06 -070020 m_pEditCaret(nullptr),
tsepez4cf55152016-11-02 14:37:54 -070021 m_bMouseDown(false),
Dan Sinclairf51a02a2017-04-19 12:46:53 -040022 m_nCharSet(FX_CHARSET_Default) {}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070023
dsinclairdbc77162016-07-13 11:34:23 -070024CPWL_EditCtrl::~CPWL_EditCtrl() {}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070025
Tom Sepezbf157302017-09-15 13:26:32 -070026void CPWL_EditCtrl::OnCreate(CreateParams* pParamsToAdjust) {
27 pParamsToAdjust->eCursorType = FXCT_VBEAM;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070028}
29
Nico Weber9d8ec5a2015-08-04 13:00:21 -070030void CPWL_EditCtrl::OnCreated() {
Tom Sepezbf157302017-09-15 13:26:32 -070031 SetFontSize(GetCreationParams().fFontSize);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070032
Nico Weber9d8ec5a2015-08-04 13:00:21 -070033 m_pEdit->SetFontMap(GetFontMap());
34 m_pEdit->SetNotify(this);
35 m_pEdit->Initialize();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070036}
37
tsepez4cf55152016-11-02 14:37:54 -070038bool CPWL_EditCtrl::IsWndHorV() {
Tom Sepez60d909e2015-12-10 15:34:55 -080039 CFX_Matrix mt = GetWindowMatrix();
Dan Sinclair1f403ce2017-02-21 12:56:24 -050040 return mt.Transform(CFX_PointF(1, 1)).y == mt.Transform(CFX_PointF(0, 1)).y;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070041}
42
Nico Weber9d8ec5a2015-08-04 13:00:21 -070043void CPWL_EditCtrl::SetCursor() {
44 if (IsValid()) {
dsinclairb9590102016-04-27 06:38:59 -070045 if (CFX_SystemHandler* pSH = GetSystemHandler()) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -070046 if (IsWndHorV())
47 pSH->SetCursor(FXCT_VBEAM);
48 else
49 pSH->SetCursor(FXCT_HBEAM);
Tom Sepez2f2ffec2015-07-23 14:42:09 -070050 }
Nico Weber9d8ec5a2015-08-04 13:00:21 -070051 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070052}
53
Ryan Harrison275e2602017-09-18 14:23:18 -040054WideString CPWL_EditCtrl::GetSelectedText() {
Diana Gagedce2d722017-06-20 11:17:11 -070055 if (m_pEdit)
Diana Gage89e65622017-07-20 18:09:31 -070056 return m_pEdit->GetSelectedText();
Diana Gagedce2d722017-06-20 11:17:11 -070057
Ryan Harrison275e2602017-09-18 14:23:18 -040058 return WideString();
Diana Gagedce2d722017-06-20 11:17:11 -070059}
60
Ryan Harrison275e2602017-09-18 14:23:18 -040061void CPWL_EditCtrl::ReplaceSelection(const WideString& text) {
Diana Gageab390972017-07-28 17:07:39 -070062 if (!m_pEdit)
63 return;
64
65 m_pEdit->ClearSelection();
66 m_pEdit->InsertText(text, FX_CHARSET_Default);
Diana Gage1c7f1422017-07-24 11:19:52 -070067}
68
Henrique Nakashima55469ae2017-10-04 11:08:45 -040069bool CPWL_EditCtrl::RePosChildWnd() {
Nico Weber9d8ec5a2015-08-04 13:00:21 -070070 m_pEdit->SetPlateRect(GetClientRect());
Henrique Nakashima55469ae2017-10-04 11:08:45 -040071 return true;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070072}
73
Dan Sinclairfb00ec22017-07-05 09:28:15 -040074void CPWL_EditCtrl::SetScrollInfo(const PWL_SCROLL_INFO& info) {
75 if (CPWL_Wnd* pChild = GetVScrollBar())
76 pChild->SetScrollInfo(info);
77}
78
Dan Sinclair7e0336e2017-07-05 09:39:50 -040079void CPWL_EditCtrl::SetScrollPosition(float pos) {
80 if (CPWL_Wnd* pChild = GetVScrollBar())
81 pChild->SetScrollPosition(pos);
82}
83
Dan Sinclair63fbd8d2017-07-05 14:10:36 -040084void CPWL_EditCtrl::ScrollWindowVertically(float pos) {
85 m_pEdit->SetScrollPos(CFX_PointF(m_pEdit->GetScrollPos().x, pos));
86}
87
Tom Sepezbf157302017-09-15 13:26:32 -070088void CPWL_EditCtrl::CreateChildWnd(const CreateParams& cp) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -070089 if (!IsReadOnly())
90 CreateEditCaret(cp);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070091}
92
Tom Sepezbf157302017-09-15 13:26:32 -070093void CPWL_EditCtrl::CreateEditCaret(const CreateParams& cp) {
thestig732f6a02016-05-12 10:41:56 -070094 if (m_pEditCaret)
95 return;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070096
thestig732f6a02016-05-12 10:41:56 -070097 m_pEditCaret = new CPWL_Caret;
98 m_pEditCaret->SetInvalidRect(GetClientRect());
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070099
Tom Sepezbf157302017-09-15 13:26:32 -0700100 CreateParams ecp = cp;
thestig732f6a02016-05-12 10:41:56 -0700101 ecp.pParentWnd = this;
102 ecp.dwFlags = PWS_CHILD | PWS_NOREFRESHCLIP;
103 ecp.dwBorderWidth = 0;
dsinclair92cb5e52016-05-16 11:38:28 -0700104 ecp.nBorderStyle = BorderStyle::SOLID;
Lei Zhangd24236a2017-06-29 18:28:58 -0700105 ecp.rcRectWnd = CFX_FloatRect();
thestig732f6a02016-05-12 10:41:56 -0700106
107 m_pEditCaret->Create(ecp);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700108}
109
Dan Sinclair05df0752017-03-14 14:43:42 -0400110void CPWL_EditCtrl::SetFontSize(float fFontSize) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700111 m_pEdit->SetFontSize(fFontSize);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700112}
113
Dan Sinclair05df0752017-03-14 14:43:42 -0400114float CPWL_EditCtrl::GetFontSize() const {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700115 return m_pEdit->GetFontSize();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700116}
117
tsepez4cf55152016-11-02 14:37:54 -0700118bool CPWL_EditCtrl::OnKeyDown(uint16_t nChar, uint32_t nFlag) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700119 if (m_bMouseDown)
tsepez4cf55152016-11-02 14:37:54 -0700120 return true;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700121
tsepez4cf55152016-11-02 14:37:54 -0700122 bool bRet = CPWL_Wnd::OnKeyDown(nChar, nFlag);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700123
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700124 // FILTER
125 switch (nChar) {
Tom Sepez2f2ffec2015-07-23 14:42:09 -0700126 default:
tsepez4cf55152016-11-02 14:37:54 -0700127 return false;
Tom Sepez2f2ffec2015-07-23 14:42:09 -0700128 case FWL_VKEY_Delete:
129 case FWL_VKEY_Up:
130 case FWL_VKEY_Down:
131 case FWL_VKEY_Left:
132 case FWL_VKEY_Right:
133 case FWL_VKEY_Home:
134 case FWL_VKEY_End:
135 case FWL_VKEY_Insert:
136 case 'C':
137 case 'V':
138 case 'X':
139 case 'A':
140 case 'Z':
141 case 'c':
142 case 'v':
143 case 'x':
144 case 'a':
145 case 'z':
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700146 break;
147 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700148
thestig594b20b2016-05-12 21:56:43 -0700149 if (nChar == FWL_VKEY_Delete && m_pEdit->IsSelected())
150 nChar = FWL_VKEY_Unknown;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700151
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700152 switch (nChar) {
153 case FWL_VKEY_Delete:
154 Delete();
tsepez4cf55152016-11-02 14:37:54 -0700155 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700156 case FWL_VKEY_Insert:
157 if (IsSHIFTpressed(nFlag))
158 PasteText();
tsepez4cf55152016-11-02 14:37:54 -0700159 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700160 case FWL_VKEY_Up:
tsepez4cf55152016-11-02 14:37:54 -0700161 m_pEdit->OnVK_UP(IsSHIFTpressed(nFlag), false);
162 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700163 case FWL_VKEY_Down:
tsepez4cf55152016-11-02 14:37:54 -0700164 m_pEdit->OnVK_DOWN(IsSHIFTpressed(nFlag), false);
165 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700166 case FWL_VKEY_Left:
tsepez4cf55152016-11-02 14:37:54 -0700167 m_pEdit->OnVK_LEFT(IsSHIFTpressed(nFlag), false);
168 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700169 case FWL_VKEY_Right:
tsepez4cf55152016-11-02 14:37:54 -0700170 m_pEdit->OnVK_RIGHT(IsSHIFTpressed(nFlag), false);
171 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700172 case FWL_VKEY_Home:
173 m_pEdit->OnVK_HOME(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
tsepez4cf55152016-11-02 14:37:54 -0700174 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700175 case FWL_VKEY_End:
176 m_pEdit->OnVK_END(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
tsepez4cf55152016-11-02 14:37:54 -0700177 return true;
Tom Sepez2f2ffec2015-07-23 14:42:09 -0700178 case FWL_VKEY_Unknown:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700179 if (!IsSHIFTpressed(nFlag))
Diana Gage22bf7a52017-07-21 11:33:18 -0700180 ClearSelection();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700181 else
182 CutText();
tsepez4cf55152016-11-02 14:37:54 -0700183 return true;
Tom Sepez2f2ffec2015-07-23 14:42:09 -0700184 default:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700185 break;
186 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700187
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700188 return bRet;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700189}
190
tsepez4cf55152016-11-02 14:37:54 -0700191bool CPWL_EditCtrl::OnChar(uint16_t nChar, uint32_t nFlag) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700192 if (m_bMouseDown)
tsepez4cf55152016-11-02 14:37:54 -0700193 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700194
195 CPWL_Wnd::OnChar(nChar, nFlag);
196
197 // FILTER
198 switch (nChar) {
199 case 0x0A:
200 case 0x1B:
tsepez4cf55152016-11-02 14:37:54 -0700201 return false;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700202 default:
203 break;
204 }
205
tsepez4cf55152016-11-02 14:37:54 -0700206 bool bCtrl = IsCTRLpressed(nFlag);
207 bool bAlt = IsALTpressed(nFlag);
208 bool bShift = IsSHIFTpressed(nFlag);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700209
Tom Sepez62a70f92016-03-21 15:00:20 -0700210 uint16_t word = nChar;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700211
212 if (bCtrl && !bAlt) {
213 switch (nChar) {
214 case 'C' - 'A' + 1:
215 CopyText();
tsepez4cf55152016-11-02 14:37:54 -0700216 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700217 case 'V' - 'A' + 1:
218 PasteText();
tsepez4cf55152016-11-02 14:37:54 -0700219 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700220 case 'X' - 'A' + 1:
221 CutText();
tsepez4cf55152016-11-02 14:37:54 -0700222 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700223 case 'A' - 'A' + 1:
224 SelectAll();
tsepez4cf55152016-11-02 14:37:54 -0700225 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700226 case 'Z' - 'A' + 1:
227 if (bShift)
228 Redo();
229 else
230 Undo();
tsepez4cf55152016-11-02 14:37:54 -0700231 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700232 default:
233 if (nChar < 32)
tsepez4cf55152016-11-02 14:37:54 -0700234 return false;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700235 }
236 }
237
238 if (IsReadOnly())
tsepez4cf55152016-11-02 14:37:54 -0700239 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700240
241 if (m_pEdit->IsSelected() && word == FWL_VKEY_Back)
242 word = FWL_VKEY_Unknown;
243
Diana Gage22bf7a52017-07-21 11:33:18 -0700244 ClearSelection();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700245
246 switch (word) {
247 case FWL_VKEY_Back:
248 Backspace();
249 break;
250 case FWL_VKEY_Return:
251 InsertReturn();
252 break;
253 case FWL_VKEY_Unknown:
254 break;
255 default:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700256 InsertWord(word, GetCharSet());
257 break;
258 }
259
tsepez4cf55152016-11-02 14:37:54 -0700260 return true;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700261}
262
Dan Sinclairf528eee2017-02-14 11:52:07 -0500263bool CPWL_EditCtrl::OnLButtonDown(const CFX_PointF& point, uint32_t nFlag) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700264 CPWL_Wnd::OnLButtonDown(point, nFlag);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700265
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700266 if (ClientHitTest(point)) {
Henrique Nakashima55469ae2017-10-04 11:08:45 -0400267 if (m_bMouseDown && !InvalidateRect(nullptr))
268 return true;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700269
tsepez4cf55152016-11-02 14:37:54 -0700270 m_bMouseDown = true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700271 SetCapture();
272
273 m_pEdit->OnMouseDown(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
274 }
275
tsepez4cf55152016-11-02 14:37:54 -0700276 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700277}
278
Dan Sinclairf528eee2017-02-14 11:52:07 -0500279bool CPWL_EditCtrl::OnLButtonUp(const CFX_PointF& point, uint32_t nFlag) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700280 CPWL_Wnd::OnLButtonUp(point, nFlag);
281
282 if (m_bMouseDown) {
283 // can receive keybord message
284 if (ClientHitTest(point) && !IsFocused())
285 SetFocus();
286
287 ReleaseCapture();
tsepez4cf55152016-11-02 14:37:54 -0700288 m_bMouseDown = false;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700289 }
290
tsepez4cf55152016-11-02 14:37:54 -0700291 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700292}
293
Dan Sinclairf528eee2017-02-14 11:52:07 -0500294bool CPWL_EditCtrl::OnMouseMove(const CFX_PointF& point, uint32_t nFlag) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700295 CPWL_Wnd::OnMouseMove(point, nFlag);
296
297 if (m_bMouseDown)
tsepez4cf55152016-11-02 14:37:54 -0700298 m_pEdit->OnMouseMove(point, false, false);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700299
tsepez4cf55152016-11-02 14:37:54 -0700300 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700301}
302
tsepez4cf55152016-11-02 14:37:54 -0700303void CPWL_EditCtrl::SetEditCaret(bool bVisible) {
Dan Sinclairf528eee2017-02-14 11:52:07 -0500304 CFX_PointF ptHead;
305 CFX_PointF ptFoot;
tsepez63f545c2016-09-13 16:08:49 -0700306 if (bVisible)
Dan Sinclair1f403ce2017-02-21 12:56:24 -0500307 GetCaretInfo(&ptHead, &ptFoot);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700308
Dan Sinclair0fdd1ae2017-07-05 16:00:48 -0400309 SetCaret(bVisible, ptHead, ptFoot);
Henrique Nakashima55469ae2017-10-04 11:08:45 -0400310 // Note, |this| may no longer be viable at this point. If more work needs to
311 // be done, check the return value of SetCaret().
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700312}
313
Dan Sinclair1f403ce2017-02-21 12:56:24 -0500314void CPWL_EditCtrl::GetCaretInfo(CFX_PointF* ptHead, CFX_PointF* ptFoot) const {
Dan Sinclair6b0158f2017-07-24 09:42:55 -0400315 CPWL_EditImpl_Iterator* pIterator = m_pEdit->GetIterator();
thestig821d59e2016-05-11 12:59:22 -0700316 pIterator->SetAt(m_pEdit->GetCaret());
317 CPVT_Word word;
318 CPVT_Line line;
319 if (pIterator->GetWord(word)) {
Dan Sinclair1f403ce2017-02-21 12:56:24 -0500320 ptHead->x = word.ptWord.x + word.fWidth;
321 ptHead->y = word.ptWord.y + word.fAscent;
322 ptFoot->x = word.ptWord.x + word.fWidth;
323 ptFoot->y = word.ptWord.y + word.fDescent;
thestig821d59e2016-05-11 12:59:22 -0700324 } else if (pIterator->GetLine(line)) {
Dan Sinclair1f403ce2017-02-21 12:56:24 -0500325 ptHead->x = line.ptLine.x;
326 ptHead->y = line.ptLine.y + line.fLineAscent;
327 ptFoot->x = line.ptLine.x;
328 ptFoot->y = line.ptLine.y + line.fLineDescent;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700329 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700330}
331
Henrique Nakashima55469ae2017-10-04 11:08:45 -0400332bool CPWL_EditCtrl::SetCaret(bool bVisible,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500333 const CFX_PointF& ptHead,
334 const CFX_PointF& ptFoot) {
Henrique Nakashima55469ae2017-10-04 11:08:45 -0400335 if (!m_pEditCaret)
336 return true;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700337
Henrique Nakashima55469ae2017-10-04 11:08:45 -0400338 if (!IsFocused() || m_pEdit->IsSelected())
339 bVisible = false;
340
341 ObservedPtr thisObserved(this);
342 m_pEditCaret->SetCaret(bVisible, ptHead, ptFoot);
343 if (!thisObserved)
344 return false;
345
346 return true;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700347}
348
Ryan Harrison275e2602017-09-18 14:23:18 -0400349WideString CPWL_EditCtrl::GetText() const {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700350 return m_pEdit->GetText();
351}
352
Diana Gage4d02e902017-07-20 17:20:31 -0700353void CPWL_EditCtrl::SetSelection(int32_t nStartChar, int32_t nEndChar) {
354 m_pEdit->SetSelection(nStartChar, nEndChar);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700355}
356
Diana Gage4d02e902017-07-20 17:20:31 -0700357void CPWL_EditCtrl::GetSelection(int32_t& nStartChar, int32_t& nEndChar) const {
358 m_pEdit->GetSelection(nStartChar, nEndChar);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700359}
360
Diana Gage22bf7a52017-07-21 11:33:18 -0700361void CPWL_EditCtrl::ClearSelection() {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700362 if (!IsReadOnly())
Diana Gage22bf7a52017-07-21 11:33:18 -0700363 m_pEdit->ClearSelection();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700364}
365
366void CPWL_EditCtrl::SelectAll() {
367 m_pEdit->SelectAll();
368}
369
Dan Sinclairf528eee2017-02-14 11:52:07 -0500370void CPWL_EditCtrl::SetScrollPos(const CFX_PointF& point) {
thestig732f6a02016-05-12 10:41:56 -0700371 m_pEdit->SetScrollPos(point);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700372}
373
Dan Sinclairf528eee2017-02-14 11:52:07 -0500374CFX_PointF CPWL_EditCtrl::GetScrollPos() const {
thestig732f6a02016-05-12 10:41:56 -0700375 return m_pEdit->GetScrollPos();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700376}
377
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700378void CPWL_EditCtrl::CopyText() {}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700379
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700380void CPWL_EditCtrl::PasteText() {}
381
382void CPWL_EditCtrl::CutText() {}
383
Tom Sepez62a70f92016-03-21 15:00:20 -0700384void CPWL_EditCtrl::InsertWord(uint16_t word, int32_t nCharset) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700385 if (!IsReadOnly())
386 m_pEdit->InsertWord(word, nCharset);
387}
388
389void CPWL_EditCtrl::InsertReturn() {
390 if (!IsReadOnly())
391 m_pEdit->InsertReturn();
392}
393
394void CPWL_EditCtrl::Delete() {
395 if (!IsReadOnly())
396 m_pEdit->Delete();
397}
398
399void CPWL_EditCtrl::Backspace() {
400 if (!IsReadOnly())
401 m_pEdit->Backspace();
402}
403
tsepez4cf55152016-11-02 14:37:54 -0700404bool CPWL_EditCtrl::CanUndo() const {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700405 return !IsReadOnly() && m_pEdit->CanUndo();
406}
407
tsepez4cf55152016-11-02 14:37:54 -0700408bool CPWL_EditCtrl::CanRedo() const {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700409 return !IsReadOnly() && m_pEdit->CanRedo();
410}
411
412void CPWL_EditCtrl::Redo() {
413 if (CanRedo())
414 m_pEdit->Redo();
415}
416
417void CPWL_EditCtrl::Undo() {
418 if (CanUndo())
419 m_pEdit->Undo();
420}
421
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700422int32_t CPWL_EditCtrl::GetCharSet() const {
Dan Sinclairf51a02a2017-04-19 12:46:53 -0400423 return m_nCharSet < 0 ? FX_CHARSET_Default : m_nCharSet;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700424}
425
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700426void CPWL_EditCtrl::SetReadyToInput() {
427 if (m_bMouseDown) {
428 ReleaseCapture();
tsepez4cf55152016-11-02 14:37:54 -0700429 m_bMouseDown = false;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700430 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700431}