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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 m_iMaxRecord(128) { | 72 m_iMaxRecord(128) { |
73 m_rtClient.Reset(); | 73 m_rtClient.Reset(); |
74 m_rtEngine.Reset(); | 74 m_rtEngine.Reset(); |
75 m_rtStatic.Reset(); | 75 m_rtStatic.Reset(); |
76 } | 76 } |
77 | 77 |
78 IFWL_Edit::~IFWL_Edit() { | 78 IFWL_Edit::~IFWL_Edit() { |
79 ClearRecord(); | 79 ClearRecord(); |
80 } | 80 } |
81 | 81 |
82 FWL_Error IFWL_Edit::GetClassName(CFX_WideString& wsClass) const { | |
83 wsClass = FWL_CLASS_Edit; | |
84 return FWL_Error::Succeeded; | |
85 } | |
86 | |
87 FWL_Type IFWL_Edit::GetClassID() const { | 82 FWL_Type IFWL_Edit::GetClassID() const { |
88 return FWL_Type::Edit; | 83 return FWL_Type::Edit; |
89 } | 84 } |
90 | 85 |
91 FWL_Error IFWL_Edit::Initialize() { | 86 FWL_Error IFWL_Edit::Initialize() { |
92 if (IFWL_Widget::Initialize() != FWL_Error::Succeeded) | 87 if (IFWL_Widget::Initialize() != FWL_Error::Succeeded) |
93 return FWL_Error::Indefinite; | 88 return FWL_Error::Indefinite; |
94 if (!m_pDelegate) | 89 if (!m_pDelegate) |
95 m_pDelegate = new CFWL_EditImpDelegate(this); | 90 m_pDelegate = new CFWL_EditImpDelegate(this); |
96 | 91 |
97 InitCaret(); | 92 InitCaret(); |
98 if (!m_pEdtEngine) | 93 if (!m_pEdtEngine) |
99 InitEngine(); | 94 InitEngine(); |
100 | 95 |
101 return FWL_Error::Succeeded; | 96 return FWL_Error::Succeeded; |
102 } | 97 } |
103 | 98 |
104 FWL_Error IFWL_Edit::Finalize() { | 99 void IFWL_Edit::Finalize() { |
105 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { | 100 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) |
106 ShowCaret(FALSE); | 101 ShowCaret(FALSE); |
107 } | 102 if (m_pHorzScrollBar) |
108 if (m_pHorzScrollBar) { | |
109 m_pHorzScrollBar->Finalize(); | 103 m_pHorzScrollBar->Finalize(); |
110 } | 104 if (m_pVertScrollBar) |
111 if (m_pVertScrollBar) { | |
112 m_pVertScrollBar->Finalize(); | 105 m_pVertScrollBar->Finalize(); |
113 } | 106 |
114 delete m_pDelegate; | 107 delete m_pDelegate; |
115 m_pDelegate = nullptr; | 108 m_pDelegate = nullptr; |
116 return IFWL_Widget::Finalize(); | 109 IFWL_Widget::Finalize(); |
117 } | 110 } |
| 111 |
118 FWL_Error IFWL_Edit::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { | 112 FWL_Error IFWL_Edit::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { |
119 if (bAutoSize) { | 113 if (bAutoSize) { |
120 rect.Set(0, 0, 0, 0); | 114 rect.Set(0, 0, 0, 0); |
121 if (m_pEdtEngine) { | 115 if (m_pEdtEngine) { |
122 int32_t iTextLen = m_pEdtEngine->GetTextLength(); | 116 int32_t iTextLen = m_pEdtEngine->GetTextLength(); |
123 if (iTextLen > 0) { | 117 if (iTextLen > 0) { |
124 CFX_WideString wsText; | 118 CFX_WideString wsText; |
125 m_pEdtEngine->GetText(wsText, 0); | 119 m_pEdtEngine->GetText(wsText, 0); |
126 CFX_SizeF sz = CalcTextSize( | 120 CFX_SizeF sz = CalcTextSize( |
127 wsText, m_pProperties->m_pThemeProvider, | 121 wsText, m_pProperties->m_pThemeProvider, |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 pDst = this; | 783 pDst = this; |
790 } | 784 } |
791 CFWL_EvtEdtValidate event; | 785 CFWL_EvtEdtValidate event; |
792 event.pDstWidget = pDst; | 786 event.pDstWidget = pDst; |
793 event.m_pSrcTarget = this; | 787 event.m_pSrcTarget = this; |
794 event.wsInsert = wsText; | 788 event.wsInsert = wsText; |
795 event.bValidate = TRUE; | 789 event.bValidate = TRUE; |
796 DispatchEvent(&event); | 790 DispatchEvent(&event); |
797 return event.bValidate; | 791 return event.bValidate; |
798 } | 792 } |
| 793 |
799 FWL_Error IFWL_Edit::SetBackgroundColor(uint32_t color) { | 794 FWL_Error IFWL_Edit::SetBackgroundColor(uint32_t color) { |
800 m_backColor = color; | 795 m_backColor = color; |
801 m_updateBackColor = TRUE; | 796 m_updateBackColor = TRUE; |
802 return FWL_Error::Succeeded; | 797 return FWL_Error::Succeeded; |
803 } | 798 } |
| 799 |
804 FWL_Error IFWL_Edit::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) { | 800 FWL_Error IFWL_Edit::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) { |
805 m_wsFont = wsFont; | 801 m_wsFont = wsFont; |
806 m_fFontSize = fSize; | 802 m_fFontSize = fSize; |
807 return FWL_Error::Succeeded; | 803 return FWL_Error::Succeeded; |
808 } | 804 } |
| 805 |
809 void IFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) { | 806 void IFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) { |
810 m_fScrollOffsetY = fScrollOffset; | 807 m_fScrollOffsetY = fScrollOffset; |
811 } | 808 } |
| 809 |
812 void IFWL_Edit::DrawTextBk(CFX_Graphics* pGraphics, | 810 void IFWL_Edit::DrawTextBk(CFX_Graphics* pGraphics, |
813 IFWL_ThemeProvider* pTheme, | 811 IFWL_ThemeProvider* pTheme, |
814 const CFX_Matrix* pMatrix) { | 812 const CFX_Matrix* pMatrix) { |
815 CFWL_ThemeBackground param; | 813 CFWL_ThemeBackground param; |
816 param.m_pWidget = this; | 814 param.m_pWidget = this; |
817 param.m_iPart = CFWL_Part::Background; | 815 param.m_iPart = CFWL_Part::Background; |
818 param.m_bStaticBackground = false; | 816 param.m_bStaticBackground = false; |
819 param.m_dwStates = m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly | 817 param.m_dwStates = m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly |
820 ? CFWL_PartState_ReadOnly | 818 ? CFWL_PartState_ReadOnly |
821 : CFWL_PartState_Normal; | 819 : CFWL_PartState_Normal; |
(...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2038 } | 2036 } |
2039 CFX_RectF rect; | 2037 CFX_RectF rect; |
2040 m_pOwner->GetWidgetRect(rect); | 2038 m_pOwner->GetWidgetRect(rect); |
2041 CFX_RectF rtInvalidate; | 2039 CFX_RectF rtInvalidate; |
2042 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); | 2040 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); |
2043 m_pOwner->Repaint(&rtInvalidate); | 2041 m_pOwner->Repaint(&rtInvalidate); |
2044 } | 2042 } |
2045 return TRUE; | 2043 return TRUE; |
2046 } | 2044 } |
2047 void CFWL_EditImpDelegate::DoCursor(CFWL_MsgMouse* pMsg) {} | 2045 void CFWL_EditImpDelegate::DoCursor(CFWL_MsgMouse* pMsg) {} |
OLD | NEW |