blob: f0fc4087715035ae1d3191197f487fc65d782f60 [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
Nico Weber9d8ec5a2015-08-04 13:00:21 -070070void CPWL_EditCtrl::RePosChildWnd() {
71 m_pEdit->SetPlateRect(GetClientRect());
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)) {
Tom Sepez2f2ffec2015-07-23 14:42:09 -0700267 if (m_bMouseDown)
Lei Zhang33c03002017-08-15 11:18:19 -0700268 InvalidateRect(nullptr);
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);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700310}
311
Dan Sinclair1f403ce2017-02-21 12:56:24 -0500312void CPWL_EditCtrl::GetCaretInfo(CFX_PointF* ptHead, CFX_PointF* ptFoot) const {
Dan Sinclair6b0158f2017-07-24 09:42:55 -0400313 CPWL_EditImpl_Iterator* pIterator = m_pEdit->GetIterator();
thestig821d59e2016-05-11 12:59:22 -0700314 pIterator->SetAt(m_pEdit->GetCaret());
315 CPVT_Word word;
316 CPVT_Line line;
317 if (pIterator->GetWord(word)) {
Dan Sinclair1f403ce2017-02-21 12:56:24 -0500318 ptHead->x = word.ptWord.x + word.fWidth;
319 ptHead->y = word.ptWord.y + word.fAscent;
320 ptFoot->x = word.ptWord.x + word.fWidth;
321 ptFoot->y = word.ptWord.y + word.fDescent;
thestig821d59e2016-05-11 12:59:22 -0700322 } else if (pIterator->GetLine(line)) {
Dan Sinclair1f403ce2017-02-21 12:56:24 -0500323 ptHead->x = line.ptLine.x;
324 ptHead->y = line.ptLine.y + line.fLineAscent;
325 ptFoot->x = line.ptLine.x;
326 ptFoot->y = line.ptLine.y + line.fLineDescent;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700327 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700328}
329
tsepez4cf55152016-11-02 14:37:54 -0700330void CPWL_EditCtrl::SetCaret(bool bVisible,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500331 const CFX_PointF& ptHead,
332 const CFX_PointF& ptFoot) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700333 if (m_pEditCaret) {
334 if (!IsFocused() || m_pEdit->IsSelected())
tsepez4cf55152016-11-02 14:37:54 -0700335 bVisible = false;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700336
337 m_pEditCaret->SetCaret(bVisible, ptHead, ptFoot);
338 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700339}
340
Ryan Harrison275e2602017-09-18 14:23:18 -0400341WideString CPWL_EditCtrl::GetText() const {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700342 return m_pEdit->GetText();
343}
344
Diana Gage4d02e902017-07-20 17:20:31 -0700345void CPWL_EditCtrl::SetSelection(int32_t nStartChar, int32_t nEndChar) {
346 m_pEdit->SetSelection(nStartChar, nEndChar);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700347}
348
Diana Gage4d02e902017-07-20 17:20:31 -0700349void CPWL_EditCtrl::GetSelection(int32_t& nStartChar, int32_t& nEndChar) const {
350 m_pEdit->GetSelection(nStartChar, nEndChar);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700351}
352
Diana Gage22bf7a52017-07-21 11:33:18 -0700353void CPWL_EditCtrl::ClearSelection() {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700354 if (!IsReadOnly())
Diana Gage22bf7a52017-07-21 11:33:18 -0700355 m_pEdit->ClearSelection();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700356}
357
358void CPWL_EditCtrl::SelectAll() {
359 m_pEdit->SelectAll();
360}
361
Dan Sinclairf528eee2017-02-14 11:52:07 -0500362void CPWL_EditCtrl::SetScrollPos(const CFX_PointF& point) {
thestig732f6a02016-05-12 10:41:56 -0700363 m_pEdit->SetScrollPos(point);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700364}
365
Dan Sinclairf528eee2017-02-14 11:52:07 -0500366CFX_PointF CPWL_EditCtrl::GetScrollPos() const {
thestig732f6a02016-05-12 10:41:56 -0700367 return m_pEdit->GetScrollPos();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700368}
369
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700370void CPWL_EditCtrl::CopyText() {}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700371
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700372void CPWL_EditCtrl::PasteText() {}
373
374void CPWL_EditCtrl::CutText() {}
375
Tom Sepez62a70f92016-03-21 15:00:20 -0700376void CPWL_EditCtrl::InsertWord(uint16_t word, int32_t nCharset) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700377 if (!IsReadOnly())
378 m_pEdit->InsertWord(word, nCharset);
379}
380
381void CPWL_EditCtrl::InsertReturn() {
382 if (!IsReadOnly())
383 m_pEdit->InsertReturn();
384}
385
386void CPWL_EditCtrl::Delete() {
387 if (!IsReadOnly())
388 m_pEdit->Delete();
389}
390
391void CPWL_EditCtrl::Backspace() {
392 if (!IsReadOnly())
393 m_pEdit->Backspace();
394}
395
tsepez4cf55152016-11-02 14:37:54 -0700396bool CPWL_EditCtrl::CanUndo() const {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700397 return !IsReadOnly() && m_pEdit->CanUndo();
398}
399
tsepez4cf55152016-11-02 14:37:54 -0700400bool CPWL_EditCtrl::CanRedo() const {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700401 return !IsReadOnly() && m_pEdit->CanRedo();
402}
403
404void CPWL_EditCtrl::Redo() {
405 if (CanRedo())
406 m_pEdit->Redo();
407}
408
409void CPWL_EditCtrl::Undo() {
410 if (CanUndo())
411 m_pEdit->Undo();
412}
413
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700414int32_t CPWL_EditCtrl::GetCharSet() const {
Dan Sinclairf51a02a2017-04-19 12:46:53 -0400415 return m_nCharSet < 0 ? FX_CHARSET_Default : m_nCharSet;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700416}
417
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700418void CPWL_EditCtrl::SetReadyToInput() {
419 if (m_bMouseDown) {
420 ReleaseCapture();
tsepez4cf55152016-11-02 14:37:54 -0700421 m_bMouseDown = false;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700422 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700423}