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

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

Issue 2525083002: Rename IFWL classes which do not have CFWL equivalents (Closed)
Patch Set: 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
« no previous file with comments | « xfa/fwl/core/ifwl_edit.h ('k') | xfa/fwl/core/ifwl_form.h » ('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 <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_evtcheckword.h" 23 #include "xfa/fwl/core/cfwl_evtcheckword.h"
23 #include "xfa/fwl/core/cfwl_evttextchanged.h" 24 #include "xfa/fwl/core/cfwl_evttextchanged.h"
24 #include "xfa/fwl/core/cfwl_evttextfull.h" 25 #include "xfa/fwl/core/cfwl_evttextfull.h"
25 #include "xfa/fwl/core/cfwl_evtvalidate.h" 26 #include "xfa/fwl/core/cfwl_evtvalidate.h"
26 #include "xfa/fwl/core/cfwl_msgkey.h" 27 #include "xfa/fwl/core/cfwl_msgkey.h"
27 #include "xfa/fwl/core/cfwl_msgmouse.h" 28 #include "xfa/fwl/core/cfwl_msgmouse.h"
28 #include "xfa/fwl/core/cfwl_themebackground.h" 29 #include "xfa/fwl/core/cfwl_themebackground.h"
29 #include "xfa/fwl/core/cfwl_themepart.h" 30 #include "xfa/fwl/core/cfwl_themepart.h"
30 #include "xfa/fwl/core/cfwl_widgetmgr.h" 31 #include "xfa/fwl/core/cfwl_widgetmgr.h"
31 #include "xfa/fwl/core/ifwl_caret.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"
36 36
37 namespace { 37 namespace {
38 38
39 const int kEditMargin = 3; 39 const int kEditMargin = 3;
40 40
41 bool FX_EDIT_ISLATINWORD(FX_WCHAR c) { 41 bool FX_EDIT_ISLATINWORD(FX_WCHAR c) {
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 return; 428 return;
429 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) 429 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)
430 return; 430 return;
431 431
432 bool bRepaintContent = UpdateOffset(); 432 bool bRepaintContent = UpdateOffset();
433 UpdateCaret(); 433 UpdateCaret();
434 CFX_RectF rtInvalid; 434 CFX_RectF rtInvalid;
435 rtInvalid.Set(0, 0, 0, 0); 435 rtInvalid.Set(0, 0, 0, 0);
436 bool bRepaintScroll = false; 436 bool bRepaintScroll = false;
437 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) { 437 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) {
438 IFWL_ScrollBar* pScroll = UpdateScroll(); 438 CFWL_ScrollBar* pScroll = UpdateScroll();
439 if (pScroll) { 439 if (pScroll) {
440 pScroll->GetWidgetRect(rtInvalid); 440 pScroll->GetWidgetRect(rtInvalid);
441 bRepaintScroll = true; 441 bRepaintScroll = true;
442 } 442 }
443 } 443 }
444 if (bRepaintContent || bRepaintScroll) { 444 if (bRepaintContent || bRepaintScroll) {
445 if (bRepaintContent) 445 if (bRepaintContent)
446 rtInvalid.Union(m_rtEngine); 446 rtInvalid.Union(m_rtEngine);
447 Repaint(&rtInvalid); 447 Repaint(&rtInvalid);
448 } 448 }
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 offsetY = rtCaret.top - rtEidt.top; 831 offsetY = rtCaret.top - rtEidt.top;
832 if (rtCaret.bottom() > rtEidt.bottom()) 832 if (rtCaret.bottom() > rtEidt.bottom())
833 offsetY = rtCaret.bottom() - rtEidt.bottom(); 833 offsetY = rtCaret.bottom() - rtEidt.bottom();
834 m_fScrollOffsetX += offsetX; 834 m_fScrollOffsetX += offsetX;
835 m_fScrollOffsetY += offsetY; 835 m_fScrollOffsetY += offsetY;
836 if (m_fFontSize > m_rtEngine.height) 836 if (m_fFontSize > m_rtEngine.height)
837 m_fScrollOffsetY = 0; 837 m_fScrollOffsetY = 0;
838 return true; 838 return true;
839 } 839 }
840 840
841 bool IFWL_Edit::UpdateOffset(IFWL_ScrollBar* pScrollBar, FX_FLOAT fPosChanged) { 841 bool IFWL_Edit::UpdateOffset(CFWL_ScrollBar* pScrollBar, FX_FLOAT fPosChanged) {
842 if (pScrollBar == m_pHorzScrollBar.get()) 842 if (pScrollBar == m_pHorzScrollBar.get())
843 m_fScrollOffsetX += fPosChanged; 843 m_fScrollOffsetX += fPosChanged;
844 else 844 else
845 m_fScrollOffsetY += fPosChanged; 845 m_fScrollOffsetY += fPosChanged;
846 return true; 846 return true;
847 } 847 }
848 848
849 void IFWL_Edit::UpdateVAlignment() { 849 void IFWL_Edit::UpdateVAlignment() {
850 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0); 850 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0);
851 if (!pPage) 851 if (!pPage)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 FX_FLOAT right = rtCaret.right(); 899 FX_FLOAT right = rtCaret.right();
900 rtCaret.left = rtClient.right() - 1; 900 rtCaret.left = rtClient.right() - 1;
901 rtCaret.width = right - rtCaret.left; 901 rtCaret.width = right - rtCaret.left;
902 } 902 }
903 903
904 bool bShow = 904 bool bShow =
905 m_pProperties->m_dwStates & FWL_WGTSTATE_Focused && !rtCaret.IsEmpty(); 905 m_pProperties->m_dwStates & FWL_WGTSTATE_Focused && !rtCaret.IsEmpty();
906 ShowCaret(bShow, &rtCaret); 906 ShowCaret(bShow, &rtCaret);
907 } 907 }
908 908
909 IFWL_ScrollBar* IFWL_Edit::UpdateScroll() { 909 CFWL_ScrollBar* IFWL_Edit::UpdateScroll() {
910 bool bShowHorz = 910 bool bShowHorz =
911 m_pHorzScrollBar && 911 m_pHorzScrollBar &&
912 ((m_pHorzScrollBar->GetStates() & FWL_WGTSTATE_Invisible) == 0); 912 ((m_pHorzScrollBar->GetStates() & FWL_WGTSTATE_Invisible) == 0);
913 bool bShowVert = 913 bool bShowVert =
914 m_pVertScrollBar && 914 m_pVertScrollBar &&
915 ((m_pVertScrollBar->GetStates() & FWL_WGTSTATE_Invisible) == 0); 915 ((m_pVertScrollBar->GetStates() & FWL_WGTSTATE_Invisible) == 0);
916 if (!bShowHorz && !bShowVert) 916 if (!bShowHorz && !bShowVert)
917 return nullptr; 917 return nullptr;
918 918
919 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0); 919 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0);
920 if (!pPage) 920 if (!pPage)
921 return nullptr; 921 return nullptr;
922 922
923 const CFX_RectF& rtFDE = pPage->GetContentsBox(); 923 const CFX_RectF& rtFDE = pPage->GetContentsBox();
924 IFWL_ScrollBar* pRepaint = nullptr; 924 CFWL_ScrollBar* pRepaint = nullptr;
925 if (bShowHorz) { 925 if (bShowHorz) {
926 CFX_RectF rtScroll; 926 CFX_RectF rtScroll;
927 m_pHorzScrollBar->GetWidgetRect(rtScroll); 927 m_pHorzScrollBar->GetWidgetRect(rtScroll);
928 if (rtScroll.width < rtFDE.width) { 928 if (rtScroll.width < rtFDE.width) {
929 m_pHorzScrollBar->LockUpdate(); 929 m_pHorzScrollBar->LockUpdate();
930 FX_FLOAT fRange = rtFDE.width - rtScroll.width; 930 FX_FLOAT fRange = rtFDE.width - rtScroll.width;
931 m_pHorzScrollBar->SetRange(0.0f, fRange); 931 m_pHorzScrollBar->SetRange(0.0f, fRange);
932 932
933 FX_FLOAT fPos = std::min(std::max(m_fScrollOffsetX, 0.0f), fRange); 933 FX_FLOAT fPos = std::min(std::max(m_fScrollOffsetX, 0.0f), fRange);
934 m_pHorzScrollBar->SetPos(fPos); 934 m_pHorzScrollBar->SetPos(fPos);
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 void IFWL_Edit::InitScrollBar(bool bVert) { 1163 void IFWL_Edit::InitScrollBar(bool bVert) {
1164 if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) 1164 if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar))
1165 return; 1165 return;
1166 1166
1167 auto prop = pdfium::MakeUnique<CFWL_WidgetProperties>(); 1167 auto prop = pdfium::MakeUnique<CFWL_WidgetProperties>();
1168 prop->m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; 1168 prop->m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz;
1169 prop->m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible; 1169 prop->m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible;
1170 prop->m_pParent = this; 1170 prop->m_pParent = this;
1171 prop->m_pThemeProvider = m_pProperties->m_pThemeProvider; 1171 prop->m_pThemeProvider = m_pProperties->m_pThemeProvider;
1172 1172
1173 IFWL_ScrollBar* sb = new IFWL_ScrollBar(m_pOwnerApp, std::move(prop), this); 1173 CFWL_ScrollBar* sb = new CFWL_ScrollBar(m_pOwnerApp, std::move(prop), this);
1174 if (bVert) 1174 if (bVert)
1175 m_pVertScrollBar.reset(sb); 1175 m_pVertScrollBar.reset(sb);
1176 else 1176 else
1177 m_pHorzScrollBar.reset(sb); 1177 m_pHorzScrollBar.reset(sb);
1178 } 1178 }
1179 1179
1180 bool FWL_ShowCaret(IFWL_Widget* pWidget, 1180 bool FWL_ShowCaret(IFWL_Widget* pWidget,
1181 bool bVisible, 1181 bool bVisible,
1182 const CFX_RectF* pRtAnchor) { 1182 const CFX_RectF* pRtAnchor) {
1183 CXFA_FFWidget* pXFAWidget = 1183 CXFA_FFWidget* pXFAWidget =
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 } 1255 }
1256 1256
1257 if (wsText.GetInteger() <= m_iMax) 1257 if (wsText.GetInteger() <= m_iMax)
1258 return true; 1258 return true;
1259 return false; 1259 return false;
1260 } 1260 }
1261 1261
1262 void IFWL_Edit::InitCaret() { 1262 void IFWL_Edit::InitCaret() {
1263 if (!m_pCaret) { 1263 if (!m_pCaret) {
1264 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret)) { 1264 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret)) {
1265 m_pCaret.reset(new IFWL_Caret( 1265 m_pCaret.reset(new CFWL_Caret(
1266 m_pOwnerApp, pdfium::MakeUnique<CFWL_WidgetProperties>(), this)); 1266 m_pOwnerApp, pdfium::MakeUnique<CFWL_WidgetProperties>(), this));
1267 m_pCaret->SetParent(this); 1267 m_pCaret->SetParent(this);
1268 m_pCaret->SetStates(m_pProperties->m_dwStates); 1268 m_pCaret->SetStates(m_pProperties->m_dwStates);
1269 } 1269 }
1270 } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret) == 1270 } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret) ==
1271 0) { 1271 0) {
1272 m_pCaret.reset(); 1272 m_pCaret.reset();
1273 } 1273 }
1274 } 1274 }
1275 1275
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1337 void IFWL_Edit::OnProcessEvent(CFWL_Event* pEvent) { 1337 void IFWL_Edit::OnProcessEvent(CFWL_Event* pEvent) {
1338 if (!pEvent) 1338 if (!pEvent)
1339 return; 1339 return;
1340 if (pEvent->GetClassID() != CFWL_EventType::Scroll) 1340 if (pEvent->GetClassID() != CFWL_EventType::Scroll)
1341 return; 1341 return;
1342 1342
1343 IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget; 1343 IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget;
1344 if ((pSrcTarget == m_pVertScrollBar.get() && m_pVertScrollBar) || 1344 if ((pSrcTarget == m_pVertScrollBar.get() && m_pVertScrollBar) ||
1345 (pSrcTarget == m_pHorzScrollBar.get() && m_pHorzScrollBar)) { 1345 (pSrcTarget == m_pHorzScrollBar.get() && m_pHorzScrollBar)) {
1346 CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(pEvent); 1346 CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(pEvent);
1347 OnScroll(static_cast<IFWL_ScrollBar*>(pSrcTarget), 1347 OnScroll(static_cast<CFWL_ScrollBar*>(pSrcTarget),
1348 pScrollEvent->m_iScrollCode, pScrollEvent->m_fPos); 1348 pScrollEvent->m_iScrollCode, pScrollEvent->m_fPos);
1349 } 1349 }
1350 } 1350 }
1351 1351
1352 void IFWL_Edit::OnDrawWidget(CFX_Graphics* pGraphics, 1352 void IFWL_Edit::OnDrawWidget(CFX_Graphics* pGraphics,
1353 const CFX_Matrix* pMatrix) { 1353 const CFX_Matrix* pMatrix) {
1354 DrawWidget(pGraphics, pMatrix); 1354 DrawWidget(pGraphics, pMatrix);
1355 } 1355 }
1356 1356
1357 void IFWL_Edit::DoButtonDown(CFWL_MsgMouse* pMsg) { 1357 void IFWL_Edit::DoButtonDown(CFWL_MsgMouse* pMsg) {
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1586 break; 1586 break;
1587 } 1587 }
1588 iError = m_EdtEngine.Insert(nCaret, &c, 1); 1588 iError = m_EdtEngine.Insert(nCaret, &c, 1);
1589 break; 1589 break;
1590 } 1590 }
1591 } 1591 }
1592 if (iError < 0) 1592 if (iError < 0)
1593 ProcessInsertError(iError); 1593 ProcessInsertError(iError);
1594 } 1594 }
1595 1595
1596 bool IFWL_Edit::OnScroll(IFWL_ScrollBar* pScrollBar, 1596 bool IFWL_Edit::OnScroll(CFWL_ScrollBar* pScrollBar,
1597 FWL_SCBCODE dwCode, 1597 FWL_SCBCODE dwCode,
1598 FX_FLOAT fPos) { 1598 FX_FLOAT fPos) {
1599 CFX_SizeF fs; 1599 CFX_SizeF fs;
1600 pScrollBar->GetRange(&fs.x, &fs.y); 1600 pScrollBar->GetRange(&fs.x, &fs.y);
1601 FX_FLOAT iCurPos = pScrollBar->GetPos(); 1601 FX_FLOAT iCurPos = pScrollBar->GetPos();
1602 FX_FLOAT fStep = pScrollBar->GetStepSize(); 1602 FX_FLOAT fStep = pScrollBar->GetStepSize();
1603 switch (dwCode) { 1603 switch (dwCode) {
1604 case FWL_SCBCODE::Min: { 1604 case FWL_SCBCODE::Min: {
1605 fPos = fs.x; 1605 fPos = fs.x;
1606 break; 1606 break;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 UpdateOffset(pScrollBar, fPos - iCurPos); 1652 UpdateOffset(pScrollBar, fPos - iCurPos);
1653 UpdateCaret(); 1653 UpdateCaret();
1654 1654
1655 CFX_RectF rect; 1655 CFX_RectF rect;
1656 GetWidgetRect(rect); 1656 GetWidgetRect(rect);
1657 CFX_RectF rtInvalidate; 1657 CFX_RectF rtInvalidate;
1658 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); 1658 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2);
1659 Repaint(&rtInvalidate); 1659 Repaint(&rtInvalidate);
1660 return true; 1660 return true;
1661 } 1661 }
OLDNEW
« no previous file with comments | « xfa/fwl/core/ifwl_edit.h ('k') | xfa/fwl/core/ifwl_form.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698