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

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

Issue 2530993002: Cleanup FWL Event and Message code. (Closed)
Patch Set: Cleanup Created 4 years 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
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/cfwl_edit.h" 7 #include "xfa/fwl/core/cfwl_edit.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
11 #include <utility> 11 #include <utility>
12 #include <vector> 12 #include <vector>
13 13
14 #include "third_party/base/ptr_util.h" 14 #include "third_party/base/ptr_util.h"
15 #include "third_party/base/stl_util.h" 15 #include "third_party/base/stl_util.h"
16 #include "xfa/fde/cfde_txtedtengine.h" 16 #include "xfa/fde/cfde_txtedtengine.h"
17 #include "xfa/fde/fde_gedevice.h" 17 #include "xfa/fde/fde_gedevice.h"
18 #include "xfa/fde/fde_render.h" 18 #include "xfa/fde/fde_render.h"
19 #include "xfa/fde/ifde_txtedtpage.h" 19 #include "xfa/fde/ifde_txtedtpage.h"
20 #include "xfa/fgas/font/cfgas_gefont.h" 20 #include "xfa/fgas/font/cfgas_gefont.h"
21 #include "xfa/fwl/core/cfwl_app.h" 21 #include "xfa/fwl/core/cfwl_app.h"
22 #include "xfa/fwl/core/cfwl_caret.h" 22 #include "xfa/fwl/core/cfwl_caret.h"
23 #include "xfa/fwl/core/cfwl_event.h"
23 #include "xfa/fwl/core/cfwl_evtcheckword.h" 24 #include "xfa/fwl/core/cfwl_evtcheckword.h"
24 #include "xfa/fwl/core/cfwl_evttextchanged.h" 25 #include "xfa/fwl/core/cfwl_evttextchanged.h"
25 #include "xfa/fwl/core/cfwl_evttextfull.h"
26 #include "xfa/fwl/core/cfwl_evtvalidate.h" 26 #include "xfa/fwl/core/cfwl_evtvalidate.h"
27 #include "xfa/fwl/core/cfwl_msgkey.h" 27 #include "xfa/fwl/core/cfwl_msgkey.h"
28 #include "xfa/fwl/core/cfwl_msgmouse.h" 28 #include "xfa/fwl/core/cfwl_msgmouse.h"
29 #include "xfa/fwl/core/cfwl_themebackground.h" 29 #include "xfa/fwl/core/cfwl_themebackground.h"
30 #include "xfa/fwl/core/cfwl_themepart.h" 30 #include "xfa/fwl/core/cfwl_themepart.h"
31 #include "xfa/fwl/core/cfwl_widgetmgr.h" 31 #include "xfa/fwl/core/cfwl_widgetmgr.h"
32 #include "xfa/fwl/core/ifwl_themeprovider.h" 32 #include "xfa/fwl/core/ifwl_themeprovider.h"
33 #include "xfa/fxfa/xfa_ffdoc.h" 33 #include "xfa/fxfa/xfa_ffdoc.h"
34 #include "xfa/fxfa/xfa_ffwidget.h" 34 #include "xfa/fxfa/xfa_ffwidget.h"
35 #include "xfa/fxgraphics/cfx_path.h" 35 #include "xfa/fxgraphics/cfx_path.h"
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 void CFWL_Edit::On_TextChanged(CFDE_TxtEdtEngine* pEdit, 447 void CFWL_Edit::On_TextChanged(CFDE_TxtEdtEngine* pEdit,
448 FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) { 448 FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) {
449 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VAlignMask) 449 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VAlignMask)
450 UpdateVAlignment(); 450 UpdateVAlignment();
451 451
452 CFX_RectF rtTemp; 452 CFX_RectF rtTemp;
453 GetClientRect(rtTemp); 453 GetClientRect(rtTemp);
454 454
455 CFWL_EvtTextChanged event; 455 CFWL_EvtTextChanged event;
456 event.m_pSrcTarget = this; 456 event.m_pSrcTarget = this;
457 event.nChangeType = ChangeInfo.nChangeType;
458 event.wsInsert = ChangeInfo.wsInsert;
459 event.wsDelete = ChangeInfo.wsDelete;
460 event.wsPrevText = ChangeInfo.wsPrevText; 457 event.wsPrevText = ChangeInfo.wsPrevText;
461 DispatchEvent(&event); 458 DispatchEvent(&event);
462 459
463 LayoutScrollBar(); 460 LayoutScrollBar();
464 Repaint(&rtTemp); 461 Repaint(&rtTemp);
465 } 462 }
466 463
467 void CFWL_Edit::On_SelChanged(CFDE_TxtEdtEngine* pEdit) { 464 void CFWL_Edit::On_SelChanged(CFDE_TxtEdtEngine* pEdit) {
468 CFX_RectF rtTemp; 465 CFX_RectF rtTemp;
469 GetClientRect(rtTemp); 466 GetClientRect(rtTemp);
(...skipping 26 matching lines...) Expand all
496 IFDE_TxtEdtDoRecord* pRecord) { 493 IFDE_TxtEdtDoRecord* pRecord) {
497 AddDoRecord(pRecord); 494 AddDoRecord(pRecord);
498 } 495 }
499 496
500 bool CFWL_Edit::On_Validate(CFDE_TxtEdtEngine* pEdit, CFX_WideString& wsText) { 497 bool CFWL_Edit::On_Validate(CFDE_TxtEdtEngine* pEdit, CFX_WideString& wsText) {
501 CFWL_Widget* pDst = GetOuter(); 498 CFWL_Widget* pDst = GetOuter();
502 if (!pDst) 499 if (!pDst)
503 pDst = this; 500 pDst = this;
504 501
505 CFWL_EvtValidate event; 502 CFWL_EvtValidate event;
506 event.pDstWidget = pDst;
507 event.m_pSrcTarget = this; 503 event.m_pSrcTarget = this;
508 event.wsInsert = wsText; 504 event.wsInsert = wsText;
509 event.bValidate = true; 505 event.bValidate = true;
510 DispatchEvent(&event); 506 DispatchEvent(&event);
511 return event.bValidate; 507 return event.bValidate;
512 } 508 }
513 509
514 void CFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) { 510 void CFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) {
515 m_fScrollOffsetY = fScrollOffset; 511 m_fScrollOffsetY = fScrollOffset;
516 } 512 }
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 1266
1271 void CFWL_Edit::ClearRecord() { 1267 void CFWL_Edit::ClearRecord() {
1272 m_iCurRecord = -1; 1268 m_iCurRecord = -1;
1273 m_DoRecords.clear(); 1269 m_DoRecords.clear();
1274 } 1270 }
1275 1271
1276 void CFWL_Edit::ProcessInsertError(int32_t iError) { 1272 void CFWL_Edit::ProcessInsertError(int32_t iError) {
1277 if (iError != -2) 1273 if (iError != -2)
1278 return; 1274 return;
1279 1275
1280 CFWL_EvtTextFull textFullEvent; 1276 CFWL_Event textFullEvent(CFWL_EventType::TextFull);
1281 textFullEvent.m_pSrcTarget = this; 1277 textFullEvent.m_pSrcTarget = this;
1282 DispatchEvent(&textFullEvent); 1278 DispatchEvent(&textFullEvent);
1283 } 1279 }
1284 1280
1285 void CFWL_Edit::OnProcessMessage(CFWL_Message* pMessage) { 1281 void CFWL_Edit::OnProcessMessage(CFWL_Message* pMessage) {
1286 if (!pMessage) 1282 if (!pMessage)
1287 return; 1283 return;
1288 1284
1289 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); 1285 CFWL_MessageType dwMsgCode = pMessage->GetClassID();
1290 switch (dwMsgCode) { 1286 switch (dwMsgCode) {
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1515 } 1511 }
1516 int32_t nCaret = m_EdtEngine.GetCaretPos(); 1512 int32_t nCaret = m_EdtEngine.GetCaretPos();
1517 #if (_FX_OS_ == _FX_MACOSX_) 1513 #if (_FX_OS_ == _FX_MACOSX_)
1518 m_EdtEngine.Delete(nCaret, true); 1514 m_EdtEngine.Delete(nCaret, true);
1519 #else 1515 #else
1520 m_EdtEngine.Delete(nCaret); 1516 m_EdtEngine.Delete(nCaret);
1521 #endif 1517 #endif
1522 break; 1518 break;
1523 } 1519 }
1524 case FWL_VKEY_F2: 1520 case FWL_VKEY_F2:
1525 break; 1521 case FWL_VKEY_Tab:
1526 case FWL_VKEY_Tab: {
1527 DispatchKeyEvent(pMsg);
1528 break;
1529 }
1530 default: 1522 default:
1531 break; 1523 break;
1532 } 1524 }
1533 if (MoveCaret != MC_MoveNone) 1525 if (MoveCaret != MC_MoveNone)
1534 m_EdtEngine.MoveCaretPos(MoveCaret, bShift, bCtrl); 1526 m_EdtEngine.MoveCaretPos(MoveCaret, bShift, bCtrl);
1535 } 1527 }
1536 1528
1537 void CFWL_Edit::OnChar(CFWL_MsgKey* pMsg) { 1529 void CFWL_Edit::OnChar(CFWL_MsgKey* pMsg) {
1538 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || 1530 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) ||
1539 (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { 1531 (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1647 UpdateOffset(pScrollBar, fPos - iCurPos); 1639 UpdateOffset(pScrollBar, fPos - iCurPos);
1648 UpdateCaret(); 1640 UpdateCaret();
1649 1641
1650 CFX_RectF rect; 1642 CFX_RectF rect;
1651 GetWidgetRect(rect); 1643 GetWidgetRect(rect);
1652 CFX_RectF rtInvalidate; 1644 CFX_RectF rtInvalidate;
1653 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); 1645 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2);
1654 Repaint(&rtInvalidate); 1646 Repaint(&rtInvalidate);
1655 return true; 1647 return true;
1656 } 1648 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698