| OLD | NEW |
| 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/stl_util.h" | 14 #include "third_party/base/stl_util.h" |
| 14 #include "xfa/fde/cfde_txtedtengine.h" | 15 #include "xfa/fde/cfde_txtedtengine.h" |
| 15 #include "xfa/fde/fde_gedevice.h" | 16 #include "xfa/fde/fde_gedevice.h" |
| 16 #include "xfa/fde/fde_render.h" | 17 #include "xfa/fde/fde_render.h" |
| 17 #include "xfa/fde/ifde_txtedtpage.h" | 18 #include "xfa/fde/ifde_txtedtpage.h" |
| 18 #include "xfa/fgas/font/fgas_gefont.h" | 19 #include "xfa/fgas/font/fgas_gefont.h" |
| 19 #include "xfa/fwl/core/cfwl_message.h" | 20 #include "xfa/fwl/core/cfwl_message.h" |
| 20 #include "xfa/fwl/core/cfwl_themebackground.h" | 21 #include "xfa/fwl/core/cfwl_themebackground.h" |
| 21 #include "xfa/fwl/core/cfwl_themepart.h" | 22 #include "xfa/fwl/core/cfwl_themepart.h" |
| 22 #include "xfa/fwl/core/cfwl_widgetmgr.h" | 23 #include "xfa/fwl/core/cfwl_widgetmgr.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 m_bSetRange(FALSE), | 68 m_bSetRange(FALSE), |
| 68 m_iMin(-1), | 69 m_iMin(-1), |
| 69 m_iMax(0xFFFFFFF), | 70 m_iMax(0xFFFFFFF), |
| 70 m_backColor(0), | 71 m_backColor(0), |
| 71 m_updateBackColor(FALSE), | 72 m_updateBackColor(FALSE), |
| 72 m_iCurRecord(-1), | 73 m_iCurRecord(-1), |
| 73 m_iMaxRecord(128) { | 74 m_iMaxRecord(128) { |
| 74 m_rtClient.Reset(); | 75 m_rtClient.Reset(); |
| 75 m_rtEngine.Reset(); | 76 m_rtEngine.Reset(); |
| 76 m_rtStatic.Reset(); | 77 m_rtStatic.Reset(); |
| 77 } | |
| 78 | 78 |
| 79 IFWL_Edit::~IFWL_Edit() { | 79 SetDelegate(pdfium::MakeUnique<CFWL_EditImpDelegate>(this)); |
| 80 ClearRecord(); | |
| 81 } | |
| 82 | |
| 83 void IFWL_Edit::Initialize() { | |
| 84 IFWL_Widget::Initialize(); | |
| 85 if (!m_pDelegate) | |
| 86 m_pDelegate = new CFWL_EditImpDelegate(this); | |
| 87 | |
| 88 InitCaret(); | 80 InitCaret(); |
| 89 if (!m_pEdtEngine) | 81 if (!m_pEdtEngine) |
| 90 InitEngine(); | 82 InitEngine(); |
| 91 } | 83 } |
| 92 | 84 |
| 93 void IFWL_Edit::Finalize() { | 85 IFWL_Edit::~IFWL_Edit() { |
| 94 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) | 86 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) |
| 95 ShowCaret(FALSE); | 87 ShowCaret(FALSE); |
| 96 if (m_pHorzScrollBar) | |
| 97 m_pHorzScrollBar->Finalize(); | |
| 98 if (m_pVertScrollBar) | |
| 99 m_pVertScrollBar->Finalize(); | |
| 100 | 88 |
| 101 delete m_pDelegate; | 89 ClearRecord(); |
| 102 m_pDelegate = nullptr; | |
| 103 IFWL_Widget::Finalize(); | |
| 104 } | 90 } |
| 105 | 91 |
| 106 FWL_Type IFWL_Edit::GetClassID() const { | 92 FWL_Type IFWL_Edit::GetClassID() const { |
| 107 return FWL_Type::Edit; | 93 return FWL_Type::Edit; |
| 108 } | 94 } |
| 109 | 95 |
| 110 FWL_Error IFWL_Edit::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { | 96 FWL_Error IFWL_Edit::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { |
| 111 if (bAutoSize) { | 97 if (bAutoSize) { |
| 112 rect.Set(0, 0, 0, 0); | 98 rect.Set(0, 0, 0, 0); |
| 113 if (m_pEdtEngine) { | 99 if (m_pEdtEngine) { |
| (...skipping 1351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1465 | 1451 |
| 1466 void IFWL_Edit::InitScrollBar(FX_BOOL bVert) { | 1452 void IFWL_Edit::InitScrollBar(FX_BOOL bVert) { |
| 1467 if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) { | 1453 if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) { |
| 1468 return; | 1454 return; |
| 1469 } | 1455 } |
| 1470 CFWL_WidgetImpProperties prop; | 1456 CFWL_WidgetImpProperties prop; |
| 1471 prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; | 1457 prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; |
| 1472 prop.m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible; | 1458 prop.m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible; |
| 1473 prop.m_pParent = this; | 1459 prop.m_pParent = this; |
| 1474 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; | 1460 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; |
| 1475 IFWL_ScrollBar* pScrollBar = new IFWL_ScrollBar(m_pOwnerApp, prop, this); | 1461 |
| 1476 pScrollBar->Initialize(); | 1462 IFWL_ScrollBar* sb = new IFWL_ScrollBar(m_pOwnerApp, prop, this); |
| 1477 (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar); | 1463 if (bVert) |
| 1464 m_pVertScrollBar.reset(sb); |
| 1465 else |
| 1466 m_pHorzScrollBar.reset(sb); |
| 1478 } | 1467 } |
| 1479 | 1468 |
| 1480 void IFWL_Edit::InitEngine() { | 1469 void IFWL_Edit::InitEngine() { |
| 1481 if (!m_pEdtEngine) | 1470 if (!m_pEdtEngine) |
| 1482 m_pEdtEngine.reset(new CFDE_TxtEdtEngine); | 1471 m_pEdtEngine.reset(new CFDE_TxtEdtEngine); |
| 1483 } | 1472 } |
| 1484 | 1473 |
| 1485 FX_BOOL FWL_ShowCaret(IFWL_Widget* pWidget, | 1474 FX_BOOL FWL_ShowCaret(IFWL_Widget* pWidget, |
| 1486 FX_BOOL bVisible, | 1475 FX_BOOL bVisible, |
| 1487 const CFX_RectF* pRtAnchor) { | 1476 const CFX_RectF* pRtAnchor) { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1564 return TRUE; | 1553 return TRUE; |
| 1565 } | 1554 } |
| 1566 } | 1555 } |
| 1567 return FALSE; | 1556 return FALSE; |
| 1568 } | 1557 } |
| 1569 void IFWL_Edit::InitCaret() { | 1558 void IFWL_Edit::InitCaret() { |
| 1570 if (!m_pCaret) { | 1559 if (!m_pCaret) { |
| 1571 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret)) { | 1560 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret)) { |
| 1572 CFWL_WidgetImpProperties prop; | 1561 CFWL_WidgetImpProperties prop; |
| 1573 m_pCaret.reset(new IFWL_Caret(m_pOwnerApp, prop, this)); | 1562 m_pCaret.reset(new IFWL_Caret(m_pOwnerApp, prop, this)); |
| 1574 m_pCaret->Initialize(); | |
| 1575 m_pCaret->SetParent(this); | 1563 m_pCaret->SetParent(this); |
| 1576 m_pCaret->SetStates(m_pProperties->m_dwStates); | 1564 m_pCaret->SetStates(m_pProperties->m_dwStates); |
| 1577 } | 1565 } |
| 1578 } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret) == | 1566 } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret) == |
| 1579 0) { | 1567 0) { |
| 1580 m_pCaret.reset(); | 1568 m_pCaret.reset(); |
| 1581 } | 1569 } |
| 1582 } | 1570 } |
| 1583 | 1571 |
| 1584 void IFWL_Edit::ClearRecord() { | 1572 void IFWL_Edit::ClearRecord() { |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2034 } | 2022 } |
| 2035 CFX_RectF rect; | 2023 CFX_RectF rect; |
| 2036 m_pOwner->GetWidgetRect(rect); | 2024 m_pOwner->GetWidgetRect(rect); |
| 2037 CFX_RectF rtInvalidate; | 2025 CFX_RectF rtInvalidate; |
| 2038 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); | 2026 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); |
| 2039 m_pOwner->Repaint(&rtInvalidate); | 2027 m_pOwner->Repaint(&rtInvalidate); |
| 2040 } | 2028 } |
| 2041 return TRUE; | 2029 return TRUE; |
| 2042 } | 2030 } |
| 2043 void CFWL_EditImpDelegate::DoCursor(CFWL_MsgMouse* pMsg) {} | 2031 void CFWL_EditImpDelegate::DoCursor(CFWL_MsgMouse* pMsg) {} |
| OLD | NEW |