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

Side by Side Diff: xfa/fwl/basewidget/fwl_editimp.cpp

Issue 1927973003: Remove IFDE_TxtEdt interfaces where possible. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 7 months 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/basewidget/fwl_editimp.h" 7 #include "xfa/fwl/basewidget/fwl_editimp.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <vector> 10 #include <vector>
11 11
12 #include "xfa/fde/fde_gedevice.h" 12 #include "xfa/fde/fde_gedevice.h"
13 #include "xfa/fde/fde_render.h" 13 #include "xfa/fde/fde_render.h"
14 #include "xfa/fee/fde_txtedtengine.h"
14 #include "xfa/fee/ifde_txtedtpage.h" 15 #include "xfa/fee/ifde_txtedtpage.h"
15 #include "xfa/fwl/basewidget/fwl_caretimp.h" 16 #include "xfa/fwl/basewidget/fwl_caretimp.h"
16 #include "xfa/fwl/basewidget/fwl_comboboximp.h" 17 #include "xfa/fwl/basewidget/fwl_comboboximp.h"
17 #include "xfa/fwl/basewidget/fwl_scrollbarimp.h" 18 #include "xfa/fwl/basewidget/fwl_scrollbarimp.h"
18 #include "xfa/fwl/basewidget/ifwl_caret.h" 19 #include "xfa/fwl/basewidget/ifwl_caret.h"
19 #include "xfa/fwl/basewidget/ifwl_datetimepicker.h" 20 #include "xfa/fwl/basewidget/ifwl_datetimepicker.h"
20 #include "xfa/fwl/core/cfwl_message.h" 21 #include "xfa/fwl/core/cfwl_message.h"
21 #include "xfa/fwl/core/cfwl_themebackground.h" 22 #include "xfa/fwl/core/cfwl_themebackground.h"
22 #include "xfa/fwl/core/cfwl_themepart.h" 23 #include "xfa/fwl/core/cfwl_themepart.h"
23 #include "xfa/fwl/core/fwl_appimp.h" 24 #include "xfa/fwl/core/fwl_appimp.h"
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 } 746 }
746 FX_BOOL CFWL_EditImp::CanUndo() { 747 FX_BOOL CFWL_EditImp::CanUndo() {
747 return m_iCurRecord >= 0; 748 return m_iCurRecord >= 0;
748 } 749 }
749 FX_BOOL CFWL_EditImp::CanRedo() { 750 FX_BOOL CFWL_EditImp::CanRedo() {
750 return m_iCurRecord < m_RecordArr.GetSize() - 1; 751 return m_iCurRecord < m_RecordArr.GetSize() - 1;
751 } 752 }
752 FWL_ERR CFWL_EditImp::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) { 753 FWL_ERR CFWL_EditImp::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) {
753 if (!m_pEdtEngine) 754 if (!m_pEdtEngine)
754 return FWL_ERR_Succeeded; 755 return FWL_ERR_Succeeded;
755 FDE_LPTXTEDTPARAMS pParams = 756 FDE_TXTEDTPARAMS* pParams = m_pEdtEngine->GetEditParams();
dsinclair 2016/04/28 14:59:39 The cast was casting away the const. I removed the
Tom Sepez 2016/04/28 16:51:09 Acknowledged.
756 (FDE_LPTXTEDTPARAMS)m_pEdtEngine->GetEditParams();
757 pParams->fTabWidth = fTabWidth; 757 pParams->fTabWidth = fTabWidth;
758 pParams->bTabEquidistant = bEquidistant; 758 pParams->bTabEquidistant = bEquidistant;
759 return FWL_ERR_Succeeded; 759 return FWL_ERR_Succeeded;
760 } 760 }
761 FWL_ERR CFWL_EditImp::SetOuter(IFWL_Widget* pOuter) { 761 FWL_ERR CFWL_EditImp::SetOuter(IFWL_Widget* pOuter) {
762 m_pOuter = pOuter; 762 m_pOuter = pOuter;
763 return FWL_ERR_Succeeded; 763 return FWL_ERR_Succeeded;
764 } 764 }
765 FWL_ERR CFWL_EditImp::SetNumberRange(int32_t iMin, int32_t iMax) { 765 FWL_ERR CFWL_EditImp::SetNumberRange(int32_t iMin, int32_t iMax) {
766 m_iMin = iMin; 766 m_iMin = iMin;
767 m_iMax = iMax; 767 m_iMax = iMax;
768 m_bSetRange = TRUE; 768 m_bSetRange = TRUE;
769 return FWL_ERR_Succeeded; 769 return FWL_ERR_Succeeded;
770 } 770 }
771 void CFWL_EditImp::On_CaretChanged(IFDE_TxtEdtEngine* pEdit, 771 void CFWL_EditImp::On_CaretChanged(CFDE_TxtEdtEngine* pEdit,
772 int32_t nPage, 772 int32_t nPage,
773 FX_BOOL bVisible) { 773 FX_BOOL bVisible) {
774 if (m_rtEngine.IsEmpty()) { 774 if (m_rtEngine.IsEmpty()) {
775 return; 775 return;
776 } 776 }
777 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { 777 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
778 return; 778 return;
779 } 779 }
780 FX_BOOL bRepaintContent = UpdateOffset(); 780 FX_BOOL bRepaintContent = UpdateOffset();
781 UpdateCaret(); 781 UpdateCaret();
782 CFX_RectF rtInvalid; 782 CFX_RectF rtInvalid;
783 rtInvalid.Set(0, 0, 0, 0); 783 rtInvalid.Set(0, 0, 0, 0);
784 FX_BOOL bRepaintScroll = FALSE; 784 FX_BOOL bRepaintScroll = FALSE;
785 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) { 785 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) {
786 IFWL_ScrollBar* pScroll = UpdateScroll(); 786 IFWL_ScrollBar* pScroll = UpdateScroll();
787 if (pScroll) { 787 if (pScroll) {
788 pScroll->GetWidgetRect(rtInvalid); 788 pScroll->GetWidgetRect(rtInvalid);
789 bRepaintScroll = TRUE; 789 bRepaintScroll = TRUE;
790 } 790 }
791 } 791 }
792 if (bRepaintContent || bRepaintScroll) { 792 if (bRepaintContent || bRepaintScroll) {
793 if (bRepaintContent) { 793 if (bRepaintContent) {
794 rtInvalid.Union(m_rtEngine); 794 rtInvalid.Union(m_rtEngine);
795 } 795 }
796 Repaint(&rtInvalid); 796 Repaint(&rtInvalid);
797 } 797 }
798 } 798 }
799 void CFWL_EditImp::On_TextChanged(IFDE_TxtEdtEngine* pEdit, 799 void CFWL_EditImp::On_TextChanged(CFDE_TxtEdtEngine* pEdit,
800 FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) { 800 FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) {
801 uint32_t dwStyleEx = m_pProperties->m_dwStyleExes; 801 uint32_t dwStyleEx = m_pProperties->m_dwStyleExes;
802 if (dwStyleEx & FWL_STYLEEXT_EDT_VAlignMask) { 802 if (dwStyleEx & FWL_STYLEEXT_EDT_VAlignMask) {
803 UpdateVAlignment(); 803 UpdateVAlignment();
804 } 804 }
805 IFDE_TxtEdtPage* page = m_pEdtEngine->GetPage(0); 805 IFDE_TxtEdtPage* page = m_pEdtEngine->GetPage(0);
806 FX_FLOAT fContentWidth = page->GetContentsBox().width; 806 FX_FLOAT fContentWidth = page->GetContentsBox().width;
807 FX_FLOAT fContentHeight = page->GetContentsBox().height; 807 FX_FLOAT fContentHeight = page->GetContentsBox().height;
808 CFX_RectF rtTemp; 808 CFX_RectF rtTemp;
809 GetClientRect(rtTemp); 809 GetClientRect(rtTemp);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 CFWL_EvtEdtTextChanged event; 854 CFWL_EvtEdtTextChanged event;
855 event.m_pSrcTarget = m_pInterface; 855 event.m_pSrcTarget = m_pInterface;
856 event.nChangeType = ChangeInfo.nChangeType; 856 event.nChangeType = ChangeInfo.nChangeType;
857 event.wsInsert = ChangeInfo.wsInsert; 857 event.wsInsert = ChangeInfo.wsInsert;
858 event.wsDelete = ChangeInfo.wsDelete; 858 event.wsDelete = ChangeInfo.wsDelete;
859 event.wsPrevText = ChangeInfo.wsPrevText; 859 event.wsPrevText = ChangeInfo.wsPrevText;
860 DispatchEvent(&event); 860 DispatchEvent(&event);
861 LayoutScrollBar(); 861 LayoutScrollBar();
862 Repaint(&rtTemp); 862 Repaint(&rtTemp);
863 } 863 }
864 void CFWL_EditImp::On_SelChanged(IFDE_TxtEdtEngine* pEdit) { 864 void CFWL_EditImp::On_SelChanged(CFDE_TxtEdtEngine* pEdit) {
865 CFX_RectF rtTemp; 865 CFX_RectF rtTemp;
866 GetClientRect(rtTemp); 866 GetClientRect(rtTemp);
867 Repaint(&rtTemp); 867 Repaint(&rtTemp);
868 } 868 }
869 FX_BOOL CFWL_EditImp::On_PageLoad(IFDE_TxtEdtEngine* pEdit, 869 FX_BOOL CFWL_EditImp::On_PageLoad(CFDE_TxtEdtEngine* pEdit,
870 int32_t nPageIndex, 870 int32_t nPageIndex,
871 int32_t nPurpose) { 871 int32_t nPurpose) {
872 IFDE_TxtEdtEngine* pEdtEngine = m_pEdtEngine; 872 CFDE_TxtEdtEngine* pEdtEngine = m_pEdtEngine;
873 IFDE_TxtEdtPage* pPage = pEdtEngine->GetPage(nPageIndex); 873 IFDE_TxtEdtPage* pPage = pEdtEngine->GetPage(nPageIndex);
874 if (!pPage) 874 if (!pPage)
875 return FALSE; 875 return FALSE;
876 pPage->LoadPage(nullptr, nullptr); 876 pPage->LoadPage(nullptr, nullptr);
877 return TRUE; 877 return TRUE;
878 } 878 }
879 FX_BOOL CFWL_EditImp::On_PageUnload(IFDE_TxtEdtEngine* pEdit, 879 FX_BOOL CFWL_EditImp::On_PageUnload(CFDE_TxtEdtEngine* pEdit,
880 int32_t nPageIndex, 880 int32_t nPageIndex,
881 int32_t nPurpose) { 881 int32_t nPurpose) {
882 IFDE_TxtEdtEngine* pEdtEngine = m_pEdtEngine; 882 CFDE_TxtEdtEngine* pEdtEngine = m_pEdtEngine;
883 IFDE_TxtEdtPage* pPage = pEdtEngine->GetPage(nPageIndex); 883 IFDE_TxtEdtPage* pPage = pEdtEngine->GetPage(nPageIndex);
884 if (!pPage) 884 if (!pPage)
885 return FALSE; 885 return FALSE;
886 pPage->UnloadPage(nullptr); 886 pPage->UnloadPage(nullptr);
887 return TRUE; 887 return TRUE;
888 } 888 }
889 889
890 void CFWL_EditImp::On_AddDoRecord(IFDE_TxtEdtEngine* pEdit, 890 void CFWL_EditImp::On_AddDoRecord(CFDE_TxtEdtEngine* pEdit,
891 const CFX_ByteStringC& bsDoRecord) { 891 const CFX_ByteStringC& bsDoRecord) {
892 AddDoRecord(bsDoRecord); 892 AddDoRecord(bsDoRecord);
893 } 893 }
894 894
895 FX_BOOL CFWL_EditImp::On_ValidateField(IFDE_TxtEdtEngine* pEdit, 895 FX_BOOL CFWL_EditImp::On_Validate(CFDE_TxtEdtEngine* pEdit,
896 int32_t nBlockIndex,
897 int32_t nFieldIndex,
898 const CFX_WideString& wsFieldText,
899 int32_t nCharIndex) {
900 return TRUE;
901 }
902 FX_BOOL CFWL_EditImp::On_ValidateBlock(IFDE_TxtEdtEngine* pEdit,
903 int32_t nBlockIndex) {
904 return TRUE;
905 }
906 FX_BOOL CFWL_EditImp::On_GetBlockFormatText(IFDE_TxtEdtEngine* pEdit,
907 int32_t nBlockIndex,
908 CFX_WideString& wsBlockText) {
909 return FALSE;
910 }
911 FX_BOOL CFWL_EditImp::On_Validate(IFDE_TxtEdtEngine* pEdit,
912 CFX_WideString& wsText) { 896 CFX_WideString& wsText) {
913 IFWL_Widget* pDst = GetOuter(); 897 IFWL_Widget* pDst = GetOuter();
914 if (!pDst) { 898 if (!pDst) {
915 pDst = m_pInterface; 899 pDst = m_pInterface;
916 } 900 }
917 CFWL_EvtEdtValidate event; 901 CFWL_EvtEdtValidate event;
918 event.pDstWidget = pDst; 902 event.pDstWidget = pDst;
919 event.m_pSrcTarget = m_pInterface; 903 event.m_pSrcTarget = m_pInterface;
920 event.wsInsert = wsText; 904 event.wsInsert = wsText;
921 event.bValidate = TRUE; 905 event.bValidate = TRUE;
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
1604 } 1588 }
1605 CFWL_WidgetImpProperties prop; 1589 CFWL_WidgetImpProperties prop;
1606 prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; 1590 prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz;
1607 prop.m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible; 1591 prop.m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible;
1608 prop.m_pParent = m_pInterface; 1592 prop.m_pParent = m_pInterface;
1609 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; 1593 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider;
1610 IFWL_ScrollBar* pScrollBar = IFWL_ScrollBar::Create(prop, m_pInterface); 1594 IFWL_ScrollBar* pScrollBar = IFWL_ScrollBar::Create(prop, m_pInterface);
1611 pScrollBar->Initialize(); 1595 pScrollBar->Initialize();
1612 (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar); 1596 (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar);
1613 } 1597 }
1598
1614 void CFWL_EditImp::InitEngine() { 1599 void CFWL_EditImp::InitEngine() {
1615 if (m_pEdtEngine) { 1600 if (m_pEdtEngine)
Tom Sepez 2016/04/28 16:51:09 nit: not sure why, but early return seems less sim
dsinclair 2016/04/28 17:35:56 Done.
1616 return; 1601 return;
1617 } 1602 m_pEdtEngine = new CFDE_TxtEdtEngine;
1618 m_pEdtEngine = IFDE_TxtEdtEngine::Create();
1619 } 1603 }
1620 1604
1621 FX_BOOL FWL_ShowCaret(IFWL_Widget* pWidget, 1605 FX_BOOL FWL_ShowCaret(IFWL_Widget* pWidget,
1622 FX_BOOL bVisible, 1606 FX_BOOL bVisible,
1623 const CFX_RectF* pRtAnchor) { 1607 const CFX_RectF* pRtAnchor) {
1624 CXFA_FFWidget* pXFAWidget = (CXFA_FFWidget*)pWidget->GetPrivateData(pWidget); 1608 CXFA_FFWidget* pXFAWidget = (CXFA_FFWidget*)pWidget->GetPrivateData(pWidget);
1625 if (!pXFAWidget) { 1609 if (!pXFAWidget) {
1626 return FALSE; 1610 return FALSE;
1627 } 1611 }
1628 IXFA_DocProvider* pDocProvider = pXFAWidget->GetDoc()->GetDocProvider(); 1612 IXFA_DocProvider* pDocProvider = pXFAWidget->GetDoc()->GetDocProvider();
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
2173 } 2157 }
2174 CFX_RectF rect; 2158 CFX_RectF rect;
2175 m_pOwner->GetWidgetRect(rect); 2159 m_pOwner->GetWidgetRect(rect);
2176 CFX_RectF rtInvalidate; 2160 CFX_RectF rtInvalidate;
2177 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); 2161 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2);
2178 m_pOwner->Repaint(&rtInvalidate); 2162 m_pOwner->Repaint(&rtInvalidate);
2179 } 2163 }
2180 return TRUE; 2164 return TRUE;
2181 } 2165 }
2182 void CFWL_EditImpDelegate::DoCursor(CFWL_MsgMouse* pMsg) {} 2166 void CFWL_EditImpDelegate::DoCursor(CFWL_MsgMouse* pMsg) {}
OLDNEW
« xfa/fee/ifde_txtedtengine.h ('K') | « xfa/fwl/basewidget/fwl_editimp.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698