| 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> |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 FX_FLOAT fStep) { | 44 FX_FLOAT fStep) { |
| 45 pPathData->MoveTo(fStartX, fY); | 45 pPathData->MoveTo(fStartX, fY); |
| 46 int i = 1; | 46 int i = 1; |
| 47 for (FX_FLOAT fx = fStartX + fStep; fx < fEndX; fx += fStep, ++i) { | 47 for (FX_FLOAT fx = fStartX + fStep; fx < fEndX; fx += fStep, ++i) { |
| 48 pPathData->LineTo(fx, fY + (i & 1) * fStep); | 48 pPathData->LineTo(fx, fY + (i & 1) * fStep); |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 | 51 |
| 52 } // namespace | 52 } // namespace |
| 53 | 53 |
| 54 IFWL_Edit::IFWL_Edit(const CFWL_WidgetImpProperties& properties, | 54 IFWL_Edit::IFWL_Edit(const IFWL_App* app, |
| 55 const CFWL_WidgetImpProperties& properties, |
| 55 IFWL_Widget* pOuter) | 56 IFWL_Widget* pOuter) |
| 56 : IFWL_Widget(properties, pOuter), | 57 : IFWL_Widget(app, properties, pOuter), |
| 57 m_fVAlignOffset(0.0f), | 58 m_fVAlignOffset(0.0f), |
| 58 m_fScrollOffsetX(0.0f), | 59 m_fScrollOffsetX(0.0f), |
| 59 m_fScrollOffsetY(0.0f), | 60 m_fScrollOffsetY(0.0f), |
| 60 m_bLButtonDown(FALSE), | 61 m_bLButtonDown(FALSE), |
| 61 m_nSelStart(0), | 62 m_nSelStart(0), |
| 62 m_nLimit(-1), | 63 m_nLimit(-1), |
| 63 m_fSpaceAbove(0), | 64 m_fSpaceAbove(0), |
| 64 m_fSpaceBelow(0), | 65 m_fSpaceBelow(0), |
| 65 m_fFontSize(0), | 66 m_fFontSize(0), |
| 66 m_bSetRange(FALSE), | 67 m_bSetRange(FALSE), |
| 67 m_iMin(-1), | 68 m_iMin(-1), |
| 68 m_iMax(0xFFFFFFF), | 69 m_iMax(0xFFFFFFF), |
| 69 m_backColor(0), | 70 m_backColor(0), |
| 70 m_updateBackColor(FALSE), | 71 m_updateBackColor(FALSE), |
| 71 m_iCurRecord(-1), | 72 m_iCurRecord(-1), |
| 72 m_iMaxRecord(128) { | 73 m_iMaxRecord(128) { |
| 73 m_rtClient.Reset(); | 74 m_rtClient.Reset(); |
| 74 m_rtEngine.Reset(); | 75 m_rtEngine.Reset(); |
| 75 m_rtStatic.Reset(); | 76 m_rtStatic.Reset(); |
| 76 } | 77 } |
| 77 | 78 |
| 78 IFWL_Edit::~IFWL_Edit() { | 79 IFWL_Edit::~IFWL_Edit() { |
| 79 ClearRecord(); | 80 ClearRecord(); |
| 80 } | 81 } |
| 81 | 82 |
| 82 FWL_Type IFWL_Edit::GetClassID() const { | 83 void IFWL_Edit::Initialize() { |
| 83 return FWL_Type::Edit; | 84 IFWL_Widget::Initialize(); |
| 84 } | |
| 85 | |
| 86 FWL_Error IFWL_Edit::Initialize() { | |
| 87 if (IFWL_Widget::Initialize() != FWL_Error::Succeeded) | |
| 88 return FWL_Error::Indefinite; | |
| 89 if (!m_pDelegate) | 85 if (!m_pDelegate) |
| 90 m_pDelegate = new CFWL_EditImpDelegate(this); | 86 m_pDelegate = new CFWL_EditImpDelegate(this); |
| 91 | 87 |
| 92 InitCaret(); | 88 InitCaret(); |
| 93 if (!m_pEdtEngine) | 89 if (!m_pEdtEngine) |
| 94 InitEngine(); | 90 InitEngine(); |
| 95 | |
| 96 return FWL_Error::Succeeded; | |
| 97 } | 91 } |
| 98 | 92 |
| 99 void IFWL_Edit::Finalize() { | 93 void IFWL_Edit::Finalize() { |
| 100 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) | 94 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) |
| 101 ShowCaret(FALSE); | 95 ShowCaret(FALSE); |
| 102 if (m_pHorzScrollBar) | 96 if (m_pHorzScrollBar) |
| 103 m_pHorzScrollBar->Finalize(); | 97 m_pHorzScrollBar->Finalize(); |
| 104 if (m_pVertScrollBar) | 98 if (m_pVertScrollBar) |
| 105 m_pVertScrollBar->Finalize(); | 99 m_pVertScrollBar->Finalize(); |
| 106 | 100 |
| 107 delete m_pDelegate; | 101 delete m_pDelegate; |
| 108 m_pDelegate = nullptr; | 102 m_pDelegate = nullptr; |
| 109 IFWL_Widget::Finalize(); | 103 IFWL_Widget::Finalize(); |
| 110 } | 104 } |
| 111 | 105 |
| 106 FWL_Type IFWL_Edit::GetClassID() const { |
| 107 return FWL_Type::Edit; |
| 108 } |
| 109 |
| 112 FWL_Error IFWL_Edit::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { | 110 FWL_Error IFWL_Edit::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { |
| 113 if (bAutoSize) { | 111 if (bAutoSize) { |
| 114 rect.Set(0, 0, 0, 0); | 112 rect.Set(0, 0, 0, 0); |
| 115 if (m_pEdtEngine) { | 113 if (m_pEdtEngine) { |
| 116 int32_t iTextLen = m_pEdtEngine->GetTextLength(); | 114 int32_t iTextLen = m_pEdtEngine->GetTextLength(); |
| 117 if (iTextLen > 0) { | 115 if (iTextLen > 0) { |
| 118 CFX_WideString wsText; | 116 CFX_WideString wsText; |
| 119 m_pEdtEngine->GetText(wsText, 0); | 117 m_pEdtEngine->GetText(wsText, 0); |
| 120 CFX_SizeF sz = CalcTextSize( | 118 CFX_SizeF sz = CalcTextSize( |
| 121 wsText, m_pProperties->m_pThemeProvider, | 119 wsText, m_pProperties->m_pThemeProvider, |
| (...skipping 1345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1467 | 1465 |
| 1468 void IFWL_Edit::InitScrollBar(FX_BOOL bVert) { | 1466 void IFWL_Edit::InitScrollBar(FX_BOOL bVert) { |
| 1469 if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) { | 1467 if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) { |
| 1470 return; | 1468 return; |
| 1471 } | 1469 } |
| 1472 CFWL_WidgetImpProperties prop; | 1470 CFWL_WidgetImpProperties prop; |
| 1473 prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; | 1471 prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; |
| 1474 prop.m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible; | 1472 prop.m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible; |
| 1475 prop.m_pParent = this; | 1473 prop.m_pParent = this; |
| 1476 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; | 1474 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; |
| 1477 IFWL_ScrollBar* pScrollBar = new IFWL_ScrollBar(prop, this); | 1475 IFWL_ScrollBar* pScrollBar = new IFWL_ScrollBar(m_pOwnerApp, prop, this); |
| 1478 pScrollBar->Initialize(); | 1476 pScrollBar->Initialize(); |
| 1479 (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar); | 1477 (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar); |
| 1480 } | 1478 } |
| 1481 | 1479 |
| 1482 void IFWL_Edit::InitEngine() { | 1480 void IFWL_Edit::InitEngine() { |
| 1483 if (!m_pEdtEngine) | 1481 if (!m_pEdtEngine) |
| 1484 m_pEdtEngine.reset(new CFDE_TxtEdtEngine); | 1482 m_pEdtEngine.reset(new CFDE_TxtEdtEngine); |
| 1485 } | 1483 } |
| 1486 | 1484 |
| 1487 FX_BOOL FWL_ShowCaret(IFWL_Widget* pWidget, | 1485 FX_BOOL FWL_ShowCaret(IFWL_Widget* pWidget, |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1565 if (wsText.GetInteger() <= m_iMax) { | 1563 if (wsText.GetInteger() <= m_iMax) { |
| 1566 return TRUE; | 1564 return TRUE; |
| 1567 } | 1565 } |
| 1568 } | 1566 } |
| 1569 return FALSE; | 1567 return FALSE; |
| 1570 } | 1568 } |
| 1571 void IFWL_Edit::InitCaret() { | 1569 void IFWL_Edit::InitCaret() { |
| 1572 if (!m_pCaret) { | 1570 if (!m_pCaret) { |
| 1573 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret)) { | 1571 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret)) { |
| 1574 CFWL_WidgetImpProperties prop; | 1572 CFWL_WidgetImpProperties prop; |
| 1575 m_pCaret.reset(new IFWL_Caret(prop, this)); | 1573 m_pCaret.reset(new IFWL_Caret(m_pOwnerApp, prop, this)); |
| 1576 m_pCaret->Initialize(); | 1574 m_pCaret->Initialize(); |
| 1577 m_pCaret->SetParent(this); | 1575 m_pCaret->SetParent(this); |
| 1578 m_pCaret->SetStates(m_pProperties->m_dwStates); | 1576 m_pCaret->SetStates(m_pProperties->m_dwStates); |
| 1579 } | 1577 } |
| 1580 } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret) == | 1578 } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret) == |
| 1581 0) { | 1579 0) { |
| 1582 m_pCaret.reset(); | 1580 m_pCaret.reset(); |
| 1583 } | 1581 } |
| 1584 } | 1582 } |
| 1585 | 1583 |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2036 } | 2034 } |
| 2037 CFX_RectF rect; | 2035 CFX_RectF rect; |
| 2038 m_pOwner->GetWidgetRect(rect); | 2036 m_pOwner->GetWidgetRect(rect); |
| 2039 CFX_RectF rtInvalidate; | 2037 CFX_RectF rtInvalidate; |
| 2040 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); | 2038 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); |
| 2041 m_pOwner->Repaint(&rtInvalidate); | 2039 m_pOwner->Repaint(&rtInvalidate); |
| 2042 } | 2040 } |
| 2043 return TRUE; | 2041 return TRUE; |
| 2044 } | 2042 } |
| 2045 void CFWL_EditImpDelegate::DoCursor(CFWL_MsgMouse* pMsg) {} | 2043 void CFWL_EditImpDelegate::DoCursor(CFWL_MsgMouse* pMsg) {} |
| OLD | NEW |