Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: xfa/fwl/core/ifwl_edit.cpp

Issue 2515463002: Move the IFWL_Edit Events out of ifwl_edit.h (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fwl/core/ifwl_edit.h ('k') | xfa/fxfa/app/xfa_fftextedit.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fwl/core/ifwl_edit.h" 7 #include "xfa/fwl/core/ifwl_edit.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
11 #include <vector> 11 #include <vector>
12 12
13 #include "third_party/base/ptr_util.h" 13 #include "third_party/base/ptr_util.h"
14 #include "third_party/base/stl_util.h" 14 #include "third_party/base/stl_util.h"
15 #include "xfa/fde/cfde_txtedtengine.h" 15 #include "xfa/fde/cfde_txtedtengine.h"
16 #include "xfa/fde/fde_gedevice.h" 16 #include "xfa/fde/fde_gedevice.h"
17 #include "xfa/fde/fde_render.h" 17 #include "xfa/fde/fde_render.h"
18 #include "xfa/fde/ifde_txtedtpage.h" 18 #include "xfa/fde/ifde_txtedtpage.h"
19 #include "xfa/fgas/font/fgas_gefont.h" 19 #include "xfa/fgas/font/fgas_gefont.h"
20 #include "xfa/fwl/core/cfwl_evtcheckword.h"
21 #include "xfa/fwl/core/cfwl_evttextchanged.h"
22 #include "xfa/fwl/core/cfwl_evttextfull.h"
23 #include "xfa/fwl/core/cfwl_evtvalidate.h"
20 #include "xfa/fwl/core/cfwl_msgkey.h" 24 #include "xfa/fwl/core/cfwl_msgkey.h"
21 #include "xfa/fwl/core/cfwl_msgmouse.h" 25 #include "xfa/fwl/core/cfwl_msgmouse.h"
22 #include "xfa/fwl/core/cfwl_themebackground.h" 26 #include "xfa/fwl/core/cfwl_themebackground.h"
23 #include "xfa/fwl/core/cfwl_themepart.h" 27 #include "xfa/fwl/core/cfwl_themepart.h"
24 #include "xfa/fwl/core/cfwl_widgetmgr.h" 28 #include "xfa/fwl/core/cfwl_widgetmgr.h"
25 #include "xfa/fwl/core/ifwl_app.h" 29 #include "xfa/fwl/core/ifwl_app.h"
26 #include "xfa/fwl/core/ifwl_caret.h" 30 #include "xfa/fwl/core/ifwl_caret.h"
27 #include "xfa/fwl/core/ifwl_themeprovider.h" 31 #include "xfa/fwl/core/ifwl_themeprovider.h"
28 #include "xfa/fxfa/xfa_ffdoc.h" 32 #include "xfa/fxfa/xfa_ffdoc.h"
29 #include "xfa/fxfa/xfa_ffwidget.h" 33 #include "xfa/fxfa/xfa_ffwidget.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 } 193 }
190 } 194 }
191 195
192 void IFWL_Edit::DrawSpellCheck(CFX_Graphics* pGraphics, 196 void IFWL_Edit::DrawSpellCheck(CFX_Graphics* pGraphics,
193 const CFX_Matrix* pMatrix) { 197 const CFX_Matrix* pMatrix) {
194 pGraphics->SaveGraphState(); 198 pGraphics->SaveGraphState();
195 if (pMatrix) 199 if (pMatrix)
196 pGraphics->ConcatMatrix(const_cast<CFX_Matrix*>(pMatrix)); 200 pGraphics->ConcatMatrix(const_cast<CFX_Matrix*>(pMatrix));
197 201
198 CFX_Color crLine(0xFFFF0000); 202 CFX_Color crLine(0xFFFF0000);
199 CFWL_EvtEdtCheckWord checkWordEvent; 203 CFWL_EvtCheckWord checkWordEvent;
200 checkWordEvent.m_pSrcTarget = this; 204 checkWordEvent.m_pSrcTarget = this;
201 205
202 CFX_ByteString sLatinWord; 206 CFX_ByteString sLatinWord;
203 CFX_Path pathSpell; 207 CFX_Path pathSpell;
204 pathSpell.Create(); 208 pathSpell.Create();
205 209
206 int32_t nStart = 0; 210 int32_t nStart = 0;
207 FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX; 211 FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX;
208 FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset; 212 FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset;
209 213
210 CFX_WideString wsSpell; 214 CFX_WideString wsSpell;
211 GetText(wsSpell); 215 GetText(wsSpell);
212 int32_t nContentLen = wsSpell.GetLength(); 216 int32_t nContentLen = wsSpell.GetLength();
213 for (int i = 0; i < nContentLen; i++) { 217 for (int i = 0; i < nContentLen; i++) {
214 if (FX_EDIT_ISLATINWORD(wsSpell[i])) { 218 if (FX_EDIT_ISLATINWORD(wsSpell[i])) {
215 if (sLatinWord.IsEmpty()) 219 if (sLatinWord.IsEmpty())
216 nStart = i; 220 nStart = i;
217 sLatinWord += (FX_CHAR)wsSpell[i]; 221 sLatinWord += (FX_CHAR)wsSpell[i];
218 continue; 222 continue;
219 } 223 }
220 checkWordEvent.bsWord = sLatinWord; 224 checkWordEvent.bsWord = sLatinWord;
221 checkWordEvent.bCheckWord = true; 225 checkWordEvent.bCheckWord = true;
222 DispatchEvent(&checkWordEvent); 226 DispatchEvent(&checkWordEvent);
227
223 if (!sLatinWord.IsEmpty() && !checkWordEvent.bCheckWord) { 228 if (!sLatinWord.IsEmpty() && !checkWordEvent.bCheckWord) {
224 AddSpellCheckObj(pathSpell, nStart, sLatinWord.GetLength(), fOffSetX, 229 AddSpellCheckObj(pathSpell, nStart, sLatinWord.GetLength(), fOffSetX,
225 fOffSetY); 230 fOffSetY);
226 } 231 }
227 sLatinWord.clear(); 232 sLatinWord.clear();
228 } 233 }
229 234
230 checkWordEvent.bsWord = sLatinWord; 235 checkWordEvent.bsWord = sLatinWord;
231 checkWordEvent.bCheckWord = true; 236 checkWordEvent.bCheckWord = true;
232 DispatchEvent(&checkWordEvent); 237 DispatchEvent(&checkWordEvent);
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 } 448 }
444 449
445 void IFWL_Edit::On_TextChanged(CFDE_TxtEdtEngine* pEdit, 450 void IFWL_Edit::On_TextChanged(CFDE_TxtEdtEngine* pEdit,
446 FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) { 451 FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) {
447 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VAlignMask) 452 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VAlignMask)
448 UpdateVAlignment(); 453 UpdateVAlignment();
449 454
450 CFX_RectF rtTemp; 455 CFX_RectF rtTemp;
451 GetClientRect(rtTemp); 456 GetClientRect(rtTemp);
452 457
453 CFWL_EvtEdtTextChanged event; 458 CFWL_EvtTextChanged event;
454 event.m_pSrcTarget = this; 459 event.m_pSrcTarget = this;
455 event.nChangeType = ChangeInfo.nChangeType; 460 event.nChangeType = ChangeInfo.nChangeType;
456 event.wsInsert = ChangeInfo.wsInsert; 461 event.wsInsert = ChangeInfo.wsInsert;
457 event.wsDelete = ChangeInfo.wsDelete; 462 event.wsDelete = ChangeInfo.wsDelete;
458 event.wsPrevText = ChangeInfo.wsPrevText; 463 event.wsPrevText = ChangeInfo.wsPrevText;
459 DispatchEvent(&event); 464 DispatchEvent(&event);
460 465
461 LayoutScrollBar(); 466 LayoutScrollBar();
462 Repaint(&rtTemp); 467 Repaint(&rtTemp);
463 } 468 }
(...skipping 29 matching lines...) Expand all
493 void IFWL_Edit::On_AddDoRecord(CFDE_TxtEdtEngine* pEdit, 498 void IFWL_Edit::On_AddDoRecord(CFDE_TxtEdtEngine* pEdit,
494 IFDE_TxtEdtDoRecord* pRecord) { 499 IFDE_TxtEdtDoRecord* pRecord) {
495 AddDoRecord(pRecord); 500 AddDoRecord(pRecord);
496 } 501 }
497 502
498 bool IFWL_Edit::On_Validate(CFDE_TxtEdtEngine* pEdit, CFX_WideString& wsText) { 503 bool IFWL_Edit::On_Validate(CFDE_TxtEdtEngine* pEdit, CFX_WideString& wsText) {
499 IFWL_Widget* pDst = GetOuter(); 504 IFWL_Widget* pDst = GetOuter();
500 if (!pDst) 505 if (!pDst)
501 pDst = this; 506 pDst = this;
502 507
503 CFWL_EvtEdtValidate event; 508 CFWL_EvtValidate event;
504 event.pDstWidget = pDst; 509 event.pDstWidget = pDst;
505 event.m_pSrcTarget = this; 510 event.m_pSrcTarget = this;
506 event.wsInsert = wsText; 511 event.wsInsert = wsText;
507 event.bValidate = true; 512 event.bValidate = true;
508 DispatchEvent(&event); 513 DispatchEvent(&event);
509 return event.bValidate; 514 return event.bValidate;
510 } 515 }
511 516
512 void IFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) { 517 void IFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) {
513 m_fScrollOffsetY = fScrollOffset; 518 m_fScrollOffsetY = fScrollOffset;
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 m_pCaret.reset(); 1271 m_pCaret.reset();
1267 } 1272 }
1268 } 1273 }
1269 1274
1270 void IFWL_Edit::ClearRecord() { 1275 void IFWL_Edit::ClearRecord() {
1271 m_iCurRecord = -1; 1276 m_iCurRecord = -1;
1272 m_DoRecords.clear(); 1277 m_DoRecords.clear();
1273 } 1278 }
1274 1279
1275 void IFWL_Edit::ProcessInsertError(int32_t iError) { 1280 void IFWL_Edit::ProcessInsertError(int32_t iError) {
1276 switch (iError) { 1281 if (iError != -2)
1277 case -2: { 1282 return;
1278 CFWL_EvtEdtTextFull textFullEvent; 1283
1279 textFullEvent.m_pSrcTarget = this; 1284 CFWL_EvtTextFull textFullEvent;
1280 DispatchEvent(&textFullEvent); 1285 textFullEvent.m_pSrcTarget = this;
1281 break; 1286 DispatchEvent(&textFullEvent);
1282 }
1283 default:
1284 break;
1285 }
1286 } 1287 }
1287 1288
1288 void IFWL_Edit::OnProcessMessage(CFWL_Message* pMessage) { 1289 void IFWL_Edit::OnProcessMessage(CFWL_Message* pMessage) {
1289 if (!pMessage) 1290 if (!pMessage)
1290 return; 1291 return;
1291 1292
1292 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); 1293 CFWL_MessageType dwMsgCode = pMessage->GetClassID();
1293 switch (dwMsgCode) { 1294 switch (dwMsgCode) {
1294 case CFWL_MessageType::SetFocus: 1295 case CFWL_MessageType::SetFocus:
1295 case CFWL_MessageType::KillFocus: 1296 case CFWL_MessageType::KillFocus:
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
1650 UpdateOffset(pScrollBar, fPos - iCurPos); 1651 UpdateOffset(pScrollBar, fPos - iCurPos);
1651 UpdateCaret(); 1652 UpdateCaret();
1652 1653
1653 CFX_RectF rect; 1654 CFX_RectF rect;
1654 GetWidgetRect(rect); 1655 GetWidgetRect(rect);
1655 CFX_RectF rtInvalidate; 1656 CFX_RectF rtInvalidate;
1656 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); 1657 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2);
1657 Repaint(&rtInvalidate); 1658 Repaint(&rtInvalidate);
1658 return true; 1659 return true;
1659 } 1660 }
OLDNEW
« no previous file with comments | « xfa/fwl/core/ifwl_edit.h ('k') | xfa/fxfa/app/xfa_fftextedit.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698