| 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 21 matching lines...) Expand all Loading... |
| 44 FX_FLOAT fStep) { | 45 FX_FLOAT fStep) { |
| 45 pPathData->MoveTo(fStartX, fY); | 46 pPathData->MoveTo(fStartX, fY); |
| 46 int i = 1; | 47 int i = 1; |
| 47 for (FX_FLOAT fx = fStartX + fStep; fx < fEndX; fx += fStep, ++i) { | 48 for (FX_FLOAT fx = fStartX + fStep; fx < fEndX; fx += fStep, ++i) { |
| 48 pPathData->LineTo(fx, fY + (i & 1) * fStep); | 49 pPathData->LineTo(fx, fY + (i & 1) * fStep); |
| 49 } | 50 } |
| 50 } | 51 } |
| 51 | 52 |
| 52 } // namespace | 53 } // namespace |
| 53 | 54 |
| 54 // static | |
| 55 IFWL_Edit* IFWL_Edit::Create(const CFWL_WidgetImpProperties& properties, | |
| 56 IFWL_Widget* pOuter) { | |
| 57 return new IFWL_Edit(properties, pOuter); | |
| 58 } | |
| 59 | |
| 60 IFWL_Edit::IFWL_Edit(const CFWL_WidgetImpProperties& properties, | 55 IFWL_Edit::IFWL_Edit(const CFWL_WidgetImpProperties& properties, |
| 61 IFWL_Widget* pOuter) | 56 IFWL_Widget* pOuter) |
| 62 : IFWL_Widget(properties, pOuter), | 57 : IFWL_Widget(properties, pOuter), |
| 63 m_fVAlignOffset(0.0f), | 58 m_fVAlignOffset(0.0f), |
| 64 m_fScrollOffsetX(0.0f), | 59 m_fScrollOffsetX(0.0f), |
| 65 m_fScrollOffsetY(0.0f), | 60 m_fScrollOffsetY(0.0f), |
| 66 m_bLButtonDown(FALSE), | 61 m_bLButtonDown(FALSE), |
| 67 m_nSelStart(0), | 62 m_nSelStart(0), |
| 68 m_nLimit(-1), | 63 m_nLimit(-1), |
| 69 m_fSpaceAbove(0), | 64 m_fSpaceAbove(0), |
| (...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1475 | 1470 |
| 1476 void IFWL_Edit::InitScrollBar(FX_BOOL bVert) { | 1471 void IFWL_Edit::InitScrollBar(FX_BOOL bVert) { |
| 1477 if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) { | 1472 if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) { |
| 1478 return; | 1473 return; |
| 1479 } | 1474 } |
| 1480 CFWL_WidgetImpProperties prop; | 1475 CFWL_WidgetImpProperties prop; |
| 1481 prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; | 1476 prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; |
| 1482 prop.m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible; | 1477 prop.m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible; |
| 1483 prop.m_pParent = this; | 1478 prop.m_pParent = this; |
| 1484 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; | 1479 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; |
| 1485 IFWL_ScrollBar* pScrollBar = IFWL_ScrollBar::Create(prop, this); | 1480 IFWL_ScrollBar* pScrollBar = new IFWL_ScrollBar(prop, this); |
| 1486 pScrollBar->Initialize(); | 1481 pScrollBar->Initialize(); |
| 1487 (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar); | 1482 (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar); |
| 1488 } | 1483 } |
| 1489 | 1484 |
| 1490 void IFWL_Edit::InitEngine() { | 1485 void IFWL_Edit::InitEngine() { |
| 1491 if (!m_pEdtEngine) | 1486 if (!m_pEdtEngine) |
| 1492 m_pEdtEngine.reset(new CFDE_TxtEdtEngine); | 1487 m_pEdtEngine.reset(new CFDE_TxtEdtEngine); |
| 1493 } | 1488 } |
| 1494 | 1489 |
| 1495 FX_BOOL FWL_ShowCaret(IFWL_Widget* pWidget, | 1490 FX_BOOL FWL_ShowCaret(IFWL_Widget* pWidget, |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1573 if (wsText.GetInteger() <= m_iMax) { | 1568 if (wsText.GetInteger() <= m_iMax) { |
| 1574 return TRUE; | 1569 return TRUE; |
| 1575 } | 1570 } |
| 1576 } | 1571 } |
| 1577 return FALSE; | 1572 return FALSE; |
| 1578 } | 1573 } |
| 1579 void IFWL_Edit::InitCaret() { | 1574 void IFWL_Edit::InitCaret() { |
| 1580 if (!m_pCaret) { | 1575 if (!m_pCaret) { |
| 1581 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret)) { | 1576 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret)) { |
| 1582 CFWL_WidgetImpProperties prop; | 1577 CFWL_WidgetImpProperties prop; |
| 1583 m_pCaret.reset(IFWL_Caret::Create(prop, this)); | 1578 m_pCaret = pdfium::MakeUnique<IFWL_Caret>(prop, this); |
| 1584 m_pCaret->Initialize(); | 1579 m_pCaret->Initialize(); |
| 1585 m_pCaret->SetParent(this); | 1580 m_pCaret->SetParent(this); |
| 1586 m_pCaret->SetStates(m_pProperties->m_dwStates); | 1581 m_pCaret->SetStates(m_pProperties->m_dwStates); |
| 1587 } | 1582 } |
| 1588 } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret) == | 1583 } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret) == |
| 1589 0) { | 1584 0) { |
| 1590 m_pCaret.reset(); | 1585 m_pCaret.reset(); |
| 1591 } | 1586 } |
| 1592 } | 1587 } |
| 1593 | 1588 |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2044 } | 2039 } |
| 2045 CFX_RectF rect; | 2040 CFX_RectF rect; |
| 2046 m_pOwner->GetWidgetRect(rect); | 2041 m_pOwner->GetWidgetRect(rect); |
| 2047 CFX_RectF rtInvalidate; | 2042 CFX_RectF rtInvalidate; |
| 2048 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); | 2043 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); |
| 2049 m_pOwner->Repaint(&rtInvalidate); | 2044 m_pOwner->Repaint(&rtInvalidate); |
| 2050 } | 2045 } |
| 2051 return TRUE; | 2046 return TRUE; |
| 2052 } | 2047 } |
| 2053 void CFWL_EditImpDelegate::DoCursor(CFWL_MsgMouse* pMsg) {} | 2048 void CFWL_EditImpDelegate::DoCursor(CFWL_MsgMouse* pMsg) {} |
| OLD | NEW |