| 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/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> |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 FWL_ERR IFWL_Edit::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) { | 148 FWL_ERR IFWL_Edit::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) { |
| 149 return static_cast<CFWL_EditImp*>(GetImpl()) | 149 return static_cast<CFWL_EditImp*>(GetImpl()) |
| 150 ->SetTabWidth(fTabWidth, bEquidistant); | 150 ->SetTabWidth(fTabWidth, bEquidistant); |
| 151 } | 151 } |
| 152 FWL_ERR IFWL_Edit::SetOuter(IFWL_Widget* pOuter) { | 152 FWL_ERR IFWL_Edit::SetOuter(IFWL_Widget* pOuter) { |
| 153 return static_cast<CFWL_EditImp*>(GetImpl())->SetOuter(pOuter); | 153 return static_cast<CFWL_EditImp*>(GetImpl())->SetOuter(pOuter); |
| 154 } | 154 } |
| 155 FWL_ERR IFWL_Edit::SetNumberRange(int32_t iMin, int32_t iMax) { | 155 FWL_ERR IFWL_Edit::SetNumberRange(int32_t iMin, int32_t iMax) { |
| 156 return static_cast<CFWL_EditImp*>(GetImpl())->SetNumberRange(iMin, iMax); | 156 return static_cast<CFWL_EditImp*>(GetImpl())->SetNumberRange(iMin, iMax); |
| 157 } | 157 } |
| 158 FWL_ERR IFWL_Edit::SetBackColor(FX_DWORD dwColor) { | 158 FWL_ERR IFWL_Edit::SetBackColor(uint32_t dwColor) { |
| 159 return static_cast<CFWL_EditImp*>(GetImpl())->SetBackgroundColor(dwColor); | 159 return static_cast<CFWL_EditImp*>(GetImpl())->SetBackgroundColor(dwColor); |
| 160 } | 160 } |
| 161 FWL_ERR IFWL_Edit::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) { | 161 FWL_ERR IFWL_Edit::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) { |
| 162 return static_cast<CFWL_EditImp*>(GetImpl())->SetFont(wsFont, fSize); | 162 return static_cast<CFWL_EditImp*>(GetImpl())->SetFont(wsFont, fSize); |
| 163 } | 163 } |
| 164 void IFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) { | 164 void IFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) { |
| 165 return static_cast<CFWL_EditImp*>(GetImpl())->SetScrollOffset(fScrollOffset); | 165 return static_cast<CFWL_EditImp*>(GetImpl())->SetScrollOffset(fScrollOffset); |
| 166 } | 166 } |
| 167 FX_BOOL IFWL_Edit::GetSuggestWords(CFX_PointF pointf, | 167 FX_BOOL IFWL_Edit::GetSuggestWords(CFX_PointF pointf, |
| 168 std::vector<CFX_ByteString>& sSuggest) { | 168 std::vector<CFX_ByteString>& sSuggest) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 if (m_pEdtEngine) { | 203 if (m_pEdtEngine) { |
| 204 m_pEdtEngine->Release(); | 204 m_pEdtEngine->Release(); |
| 205 m_pEdtEngine = NULL; | 205 m_pEdtEngine = NULL; |
| 206 } | 206 } |
| 207 ClearRecord(); | 207 ClearRecord(); |
| 208 } | 208 } |
| 209 FWL_ERR CFWL_EditImp::GetClassName(CFX_WideString& wsClass) const { | 209 FWL_ERR CFWL_EditImp::GetClassName(CFX_WideString& wsClass) const { |
| 210 wsClass = FWL_CLASS_Edit; | 210 wsClass = FWL_CLASS_Edit; |
| 211 return FWL_ERR_Succeeded; | 211 return FWL_ERR_Succeeded; |
| 212 } | 212 } |
| 213 FX_DWORD CFWL_EditImp::GetClassID() const { | 213 uint32_t CFWL_EditImp::GetClassID() const { |
| 214 return FWL_CLASSHASH_Edit; | 214 return FWL_CLASSHASH_Edit; |
| 215 } | 215 } |
| 216 FWL_ERR CFWL_EditImp::Initialize() { | 216 FWL_ERR CFWL_EditImp::Initialize() { |
| 217 if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) | 217 if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) |
| 218 return FWL_ERR_Indefinite; | 218 return FWL_ERR_Indefinite; |
| 219 if (!m_pDelegate) { | 219 if (!m_pDelegate) { |
| 220 m_pDelegate = new CFWL_EditImpDelegate(this); | 220 m_pDelegate = new CFWL_EditImpDelegate(this); |
| 221 } | 221 } |
| 222 InitCaret(); | 222 InitCaret(); |
| 223 if (!m_pEdtEngine) { | 223 if (!m_pEdtEngine) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 if (IsShowScrollBar(FALSE)) { | 266 if (IsShowScrollBar(FALSE)) { |
| 267 FX_FLOAT* pfWidth = static_cast<FX_FLOAT*>( | 267 FX_FLOAT* pfWidth = static_cast<FX_FLOAT*>( |
| 268 GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth)); | 268 GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth)); |
| 269 rect.height += *pfWidth; | 269 rect.height += *pfWidth; |
| 270 rect.height += FWL_EDIT_Margin; | 270 rect.height += FWL_EDIT_Margin; |
| 271 } | 271 } |
| 272 } | 272 } |
| 273 } | 273 } |
| 274 return FWL_ERR_Succeeded; | 274 return FWL_ERR_Succeeded; |
| 275 } | 275 } |
| 276 FWL_ERR CFWL_EditImp::SetStates(FX_DWORD dwStates, FX_BOOL bSet) { | 276 FWL_ERR CFWL_EditImp::SetStates(uint32_t dwStates, FX_BOOL bSet) { |
| 277 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible) || | 277 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible) || |
| 278 (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { | 278 (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { |
| 279 ShowCaret(FALSE); | 279 ShowCaret(FALSE); |
| 280 } | 280 } |
| 281 return CFWL_WidgetImp::SetStates(dwStates, bSet); | 281 return CFWL_WidgetImp::SetStates(dwStates, bSet); |
| 282 } | 282 } |
| 283 FWL_ERR CFWL_EditImp::SetWidgetRect(const CFX_RectF& rect) { | 283 FWL_ERR CFWL_EditImp::SetWidgetRect(const CFX_RectF& rect) { |
| 284 return CFWL_WidgetImp::SetWidgetRect(rect); | 284 return CFWL_WidgetImp::SetWidgetRect(rect); |
| 285 } | 285 } |
| 286 FWL_ERR CFWL_EditImp::Update() { | 286 FWL_ERR CFWL_EditImp::Update() { |
| 287 if (IsLocked()) { | 287 if (IsLocked()) { |
| 288 return FWL_ERR_Indefinite; | 288 return FWL_ERR_Indefinite; |
| 289 } | 289 } |
| 290 if (!m_pProperties->m_pThemeProvider) { | 290 if (!m_pProperties->m_pThemeProvider) { |
| 291 m_pProperties->m_pThemeProvider = GetAvailableTheme(); | 291 m_pProperties->m_pThemeProvider = GetAvailableTheme(); |
| 292 } | 292 } |
| 293 Layout(); | 293 Layout(); |
| 294 if (m_rtClient.IsEmpty()) { | 294 if (m_rtClient.IsEmpty()) { |
| 295 return FWL_ERR_Indefinite; | 295 return FWL_ERR_Indefinite; |
| 296 } | 296 } |
| 297 UpdateEditEngine(); | 297 UpdateEditEngine(); |
| 298 UpdateVAlignment(); | 298 UpdateVAlignment(); |
| 299 UpdateScroll(); | 299 UpdateScroll(); |
| 300 InitCaret(); | 300 InitCaret(); |
| 301 return FWL_ERR_Succeeded; | 301 return FWL_ERR_Succeeded; |
| 302 } | 302 } |
| 303 FX_DWORD CFWL_EditImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) { | 303 uint32_t CFWL_EditImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) { |
| 304 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { | 304 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { |
| 305 if (IsShowScrollBar(TRUE)) { | 305 if (IsShowScrollBar(TRUE)) { |
| 306 CFX_RectF rect; | 306 CFX_RectF rect; |
| 307 m_pVertScrollBar->GetWidgetRect(rect); | 307 m_pVertScrollBar->GetWidgetRect(rect); |
| 308 if (rect.Contains(fx, fy)) { | 308 if (rect.Contains(fx, fy)) { |
| 309 return FWL_WGTHITTEST_VScrollBar; | 309 return FWL_WGTHITTEST_VScrollBar; |
| 310 } | 310 } |
| 311 } | 311 } |
| 312 if (IsShowScrollBar(FALSE)) { | 312 if (IsShowScrollBar(FALSE)) { |
| 313 CFX_RectF rect; | 313 CFX_RectF rect; |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(IFDE_TxtEdtEngine* pEdit, |
| 800 FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) { | 800 FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) { |
| 801 FX_DWORD 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); |
| 810 FX_BOOL bHSelfAdaption = | 810 FX_BOOL bHSelfAdaption = |
| 811 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption; | 811 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 pDst = m_pInterface; | 915 pDst = m_pInterface; |
| 916 } | 916 } |
| 917 CFWL_EvtEdtValidate event; | 917 CFWL_EvtEdtValidate event; |
| 918 event.pDstWidget = pDst; | 918 event.pDstWidget = pDst; |
| 919 event.m_pSrcTarget = m_pInterface; | 919 event.m_pSrcTarget = m_pInterface; |
| 920 event.wsInsert = wsText; | 920 event.wsInsert = wsText; |
| 921 event.bValidate = TRUE; | 921 event.bValidate = TRUE; |
| 922 DispatchEvent(&event); | 922 DispatchEvent(&event); |
| 923 return event.bValidate; | 923 return event.bValidate; |
| 924 } | 924 } |
| 925 FWL_ERR CFWL_EditImp::SetBackgroundColor(FX_DWORD color) { | 925 FWL_ERR CFWL_EditImp::SetBackgroundColor(uint32_t color) { |
| 926 m_backColor = color; | 926 m_backColor = color; |
| 927 m_updateBackColor = TRUE; | 927 m_updateBackColor = TRUE; |
| 928 return FWL_ERR_Succeeded; | 928 return FWL_ERR_Succeeded; |
| 929 } | 929 } |
| 930 FWL_ERR CFWL_EditImp::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) { | 930 FWL_ERR CFWL_EditImp::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) { |
| 931 m_wsFont = wsFont; | 931 m_wsFont = wsFont; |
| 932 m_fFontSize = fSize; | 932 m_fFontSize = fSize; |
| 933 return FWL_ERR_Succeeded; | 933 return FWL_ERR_Succeeded; |
| 934 } | 934 } |
| 935 void CFWL_EditImp::SetScrollOffset(FX_FLOAT fScrollOffset) { | 935 void CFWL_EditImp::SetScrollOffset(FX_FLOAT fScrollOffset) { |
| 936 m_fScrollOffsetY = fScrollOffset; | 936 m_fScrollOffsetY = fScrollOffset; |
| 937 } | 937 } |
| 938 void CFWL_EditImp::DrawTextBk(CFX_Graphics* pGraphics, | 938 void CFWL_EditImp::DrawTextBk(CFX_Graphics* pGraphics, |
| 939 IFWL_ThemeProvider* pTheme, | 939 IFWL_ThemeProvider* pTheme, |
| 940 const CFX_Matrix* pMatrix) { | 940 const CFX_Matrix* pMatrix) { |
| 941 CFWL_ThemeBackground param; | 941 CFWL_ThemeBackground param; |
| 942 param.m_pWidget = m_pInterface; | 942 param.m_pWidget = m_pInterface; |
| 943 param.m_iPart = FWL_PART_EDT_Background; | 943 param.m_iPart = FWL_PART_EDT_Background; |
| 944 param.m_dwData = FWL_PARTDATA_EDT_Background; | 944 param.m_dwData = FWL_PARTDATA_EDT_Background; |
| 945 param.m_dwStates = m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly | 945 param.m_dwStates = m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly |
| 946 ? FWL_PARTSTATE_EDT_ReadOnly | 946 ? FWL_PARTSTATE_EDT_ReadOnly |
| 947 : FWL_PARTSTATE_EDT_Normal; | 947 : FWL_PARTSTATE_EDT_Normal; |
| 948 FX_DWORD dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled); | 948 uint32_t dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled); |
| 949 if (dwStates) { | 949 if (dwStates) { |
| 950 param.m_dwStates = FWL_PARTSTATE_EDT_Disable; | 950 param.m_dwStates = FWL_PARTSTATE_EDT_Disable; |
| 951 } | 951 } |
| 952 param.m_pGraphics = pGraphics; | 952 param.m_pGraphics = pGraphics; |
| 953 param.m_matrix = *pMatrix; | 953 param.m_matrix = *pMatrix; |
| 954 param.m_rtPart = m_rtClient; | 954 param.m_rtPart = m_rtClient; |
| 955 pTheme->DrawBackground(¶m); | 955 pTheme->DrawBackground(¶m); |
| 956 if (!IsShowScrollBar(TRUE) || !IsShowScrollBar(FALSE)) { | 956 if (!IsShowScrollBar(TRUE) || !IsShowScrollBar(FALSE)) { |
| 957 return; | 957 return; |
| 958 } | 958 } |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1159 } | 1159 } |
| 1160 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || | 1160 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || |
| 1161 (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { | 1161 (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { |
| 1162 params.dwMode |= FDE_TEXTEDITMODE_ReadOnly; | 1162 params.dwMode |= FDE_TEXTEDITMODE_ReadOnly; |
| 1163 } | 1163 } |
| 1164 FX_FLOAT* pFontSize = | 1164 FX_FLOAT* pFontSize = |
| 1165 static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_FontSize)); | 1165 static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_FontSize)); |
| 1166 if (!pFontSize) | 1166 if (!pFontSize) |
| 1167 return; | 1167 return; |
| 1168 m_fFontSize = *pFontSize; | 1168 m_fFontSize = *pFontSize; |
| 1169 FX_DWORD* pFontColor = | 1169 uint32_t* pFontColor = |
| 1170 static_cast<FX_DWORD*>(GetThemeCapacity(FWL_WGTCAPACITY_TextColor)); | 1170 static_cast<uint32_t*>(GetThemeCapacity(FWL_WGTCAPACITY_TextColor)); |
| 1171 if (!pFontColor) | 1171 if (!pFontColor) |
| 1172 return; | 1172 return; |
| 1173 params.dwFontColor = *pFontColor; | 1173 params.dwFontColor = *pFontColor; |
| 1174 FX_FLOAT* pLineHeight = | 1174 FX_FLOAT* pLineHeight = |
| 1175 static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_LineHeight)); | 1175 static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_LineHeight)); |
| 1176 if (!pLineHeight) | 1176 if (!pLineHeight) |
| 1177 return; | 1177 return; |
| 1178 params.fLineSpace = *pLineHeight; | 1178 params.fLineSpace = *pLineHeight; |
| 1179 IFX_Font* pFont = | 1179 IFX_Font* pFont = |
| 1180 static_cast<IFX_Font*>(GetThemeCapacity(FWL_WGTCAPACITY_Font)); | 1180 static_cast<IFX_Font*>(GetThemeCapacity(FWL_WGTCAPACITY_Font)); |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1731 break; | 1731 break; |
| 1732 } | 1732 } |
| 1733 default: {} | 1733 default: {} |
| 1734 } | 1734 } |
| 1735 } | 1735 } |
| 1736 CFWL_EditImpDelegate::CFWL_EditImpDelegate(CFWL_EditImp* pOwner) | 1736 CFWL_EditImpDelegate::CFWL_EditImpDelegate(CFWL_EditImp* pOwner) |
| 1737 : m_pOwner(pOwner) {} | 1737 : m_pOwner(pOwner) {} |
| 1738 int32_t CFWL_EditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { | 1738 int32_t CFWL_EditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { |
| 1739 if (!pMessage) | 1739 if (!pMessage) |
| 1740 return 0; | 1740 return 0; |
| 1741 FX_DWORD dwMsgCode = pMessage->GetClassID(); | 1741 uint32_t dwMsgCode = pMessage->GetClassID(); |
| 1742 int32_t iRet = 1; | 1742 int32_t iRet = 1; |
| 1743 switch (dwMsgCode) { | 1743 switch (dwMsgCode) { |
| 1744 case FWL_MSGHASH_Activate: { | 1744 case FWL_MSGHASH_Activate: { |
| 1745 DoActivate(static_cast<CFWL_MsgActivate*>(pMessage)); | 1745 DoActivate(static_cast<CFWL_MsgActivate*>(pMessage)); |
| 1746 break; | 1746 break; |
| 1747 } | 1747 } |
| 1748 case FWL_MSGHASH_Deactivate: { | 1748 case FWL_MSGHASH_Deactivate: { |
| 1749 DoDeactivate(static_cast<CFWL_MsgDeactivate*>(pMessage)); | 1749 DoDeactivate(static_cast<CFWL_MsgDeactivate*>(pMessage)); |
| 1750 break; | 1750 break; |
| 1751 } | 1751 } |
| 1752 case FWL_MSGHASH_SetFocus: | 1752 case FWL_MSGHASH_SetFocus: |
| 1753 case FWL_MSGHASH_KillFocus: { | 1753 case FWL_MSGHASH_KillFocus: { |
| 1754 OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); | 1754 OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); |
| 1755 break; | 1755 break; |
| 1756 } | 1756 } |
| 1757 case FWL_MSGHASH_Mouse: { | 1757 case FWL_MSGHASH_Mouse: { |
| 1758 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); | 1758 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); |
| 1759 FX_DWORD dwCmd = pMsg->m_dwCmd; | 1759 uint32_t dwCmd = pMsg->m_dwCmd; |
| 1760 switch (dwCmd) { | 1760 switch (dwCmd) { |
| 1761 case FWL_MSGMOUSECMD_LButtonDown: { | 1761 case FWL_MSGMOUSECMD_LButtonDown: { |
| 1762 OnLButtonDown(pMsg); | 1762 OnLButtonDown(pMsg); |
| 1763 break; | 1763 break; |
| 1764 } | 1764 } |
| 1765 case FWL_MSGMOUSECMD_LButtonUp: { | 1765 case FWL_MSGMOUSECMD_LButtonUp: { |
| 1766 OnLButtonUp(pMsg); | 1766 OnLButtonUp(pMsg); |
| 1767 break; | 1767 break; |
| 1768 } | 1768 } |
| 1769 case FWL_MSGMOUSECMD_LButtonDblClk: { | 1769 case FWL_MSGMOUSECMD_LButtonDblClk: { |
| 1770 OnButtonDblClk(pMsg); | 1770 OnButtonDblClk(pMsg); |
| 1771 break; | 1771 break; |
| 1772 } | 1772 } |
| 1773 case FWL_MSGMOUSECMD_MouseMove: { | 1773 case FWL_MSGMOUSECMD_MouseMove: { |
| 1774 OnMouseMove(pMsg); | 1774 OnMouseMove(pMsg); |
| 1775 break; | 1775 break; |
| 1776 } | 1776 } |
| 1777 case FWL_MSGMOUSECMD_RButtonDown: { | 1777 case FWL_MSGMOUSECMD_RButtonDown: { |
| 1778 DoButtonDown(pMsg); | 1778 DoButtonDown(pMsg); |
| 1779 break; | 1779 break; |
| 1780 } | 1780 } |
| 1781 default: {} | 1781 default: {} |
| 1782 } | 1782 } |
| 1783 break; | 1783 break; |
| 1784 } | 1784 } |
| 1785 case FWL_MSGHASH_Key: { | 1785 case FWL_MSGHASH_Key: { |
| 1786 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); | 1786 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); |
| 1787 FX_DWORD dwCmd = pKey->m_dwCmd; | 1787 uint32_t dwCmd = pKey->m_dwCmd; |
| 1788 if (dwCmd == FWL_MSGKEYCMD_KeyDown) { | 1788 if (dwCmd == FWL_MSGKEYCMD_KeyDown) { |
| 1789 OnKeyDown(pKey); | 1789 OnKeyDown(pKey); |
| 1790 } else if (dwCmd == FWL_MSGKEYCMD_Char) { | 1790 } else if (dwCmd == FWL_MSGKEYCMD_Char) { |
| 1791 OnChar(pKey); | 1791 OnChar(pKey); |
| 1792 } | 1792 } |
| 1793 break; | 1793 break; |
| 1794 } | 1794 } |
| 1795 default: { iRet = 0; } | 1795 default: { iRet = 0; } |
| 1796 } | 1796 } |
| 1797 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); | 1797 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); |
| 1798 return iRet; | 1798 return iRet; |
| 1799 } | 1799 } |
| 1800 FWL_ERR CFWL_EditImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { | 1800 FWL_ERR CFWL_EditImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { |
| 1801 if (!pEvent) | 1801 if (!pEvent) |
| 1802 return FWL_ERR_Indefinite; | 1802 return FWL_ERR_Indefinite; |
| 1803 FX_DWORD dwHashCode = pEvent->GetClassID(); | 1803 uint32_t dwHashCode = pEvent->GetClassID(); |
| 1804 if (dwHashCode != FWL_EVTHASH_Scroll) { | 1804 if (dwHashCode != FWL_EVTHASH_Scroll) { |
| 1805 return FWL_ERR_Succeeded; | 1805 return FWL_ERR_Succeeded; |
| 1806 } | 1806 } |
| 1807 IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget; | 1807 IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget; |
| 1808 if ((pSrcTarget == m_pOwner->m_pVertScrollBar.get() && | 1808 if ((pSrcTarget == m_pOwner->m_pVertScrollBar.get() && |
| 1809 m_pOwner->m_pVertScrollBar) || | 1809 m_pOwner->m_pVertScrollBar) || |
| 1810 (pSrcTarget == m_pOwner->m_pHorzScrollBar.get() && | 1810 (pSrcTarget == m_pOwner->m_pHorzScrollBar.get() && |
| 1811 m_pOwner->m_pHorzScrollBar)) { | 1811 m_pOwner->m_pHorzScrollBar)) { |
| 1812 CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(pEvent); | 1812 CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(pEvent); |
| 1813 OnScroll(static_cast<IFWL_ScrollBar*>(pSrcTarget), | 1813 OnScroll(static_cast<IFWL_ScrollBar*>(pSrcTarget), |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1840 CFX_PointF pt(pMsg->m_fx, pMsg->m_fy); | 1840 CFX_PointF pt(pMsg->m_fx, pMsg->m_fy); |
| 1841 m_pOwner->DeviceToEngine(pt); | 1841 m_pOwner->DeviceToEngine(pt); |
| 1842 FX_BOOL bBefore = TRUE; | 1842 FX_BOOL bBefore = TRUE; |
| 1843 int32_t nIndex = pPage->GetCharIndex(pt, bBefore); | 1843 int32_t nIndex = pPage->GetCharIndex(pt, bBefore); |
| 1844 if (nIndex < 0) { | 1844 if (nIndex < 0) { |
| 1845 nIndex = 0; | 1845 nIndex = 0; |
| 1846 } | 1846 } |
| 1847 m_pOwner->m_pEdtEngine->SetCaretPos(nIndex, bBefore); | 1847 m_pOwner->m_pEdtEngine->SetCaretPos(nIndex, bBefore); |
| 1848 } | 1848 } |
| 1849 void CFWL_EditImpDelegate::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) { | 1849 void CFWL_EditImpDelegate::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) { |
| 1850 FX_DWORD dwStyleEx = m_pOwner->GetStylesEx(); | 1850 uint32_t dwStyleEx = m_pOwner->GetStylesEx(); |
| 1851 FX_BOOL bRepaint = dwStyleEx & FWL_STYLEEXT_EDT_InnerCaret; | 1851 FX_BOOL bRepaint = dwStyleEx & FWL_STYLEEXT_EDT_InnerCaret; |
| 1852 if (bSet) { | 1852 if (bSet) { |
| 1853 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; | 1853 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; |
| 1854 if (!m_pOwner->m_pEdtEngine) { | 1854 if (!m_pOwner->m_pEdtEngine) { |
| 1855 m_pOwner->UpdateEditEngine(); | 1855 m_pOwner->UpdateEditEngine(); |
| 1856 } | 1856 } |
| 1857 m_pOwner->UpdateVAlignment(); | 1857 m_pOwner->UpdateVAlignment(); |
| 1858 m_pOwner->UpdateOffset(); | 1858 m_pOwner->UpdateOffset(); |
| 1859 m_pOwner->UpdateCaret(); | 1859 m_pOwner->UpdateCaret(); |
| 1860 } else if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { | 1860 } else if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1957 std::min(m_pOwner->m_nSelStart, nIndex), | 1957 std::min(m_pOwner->m_nSelStart, nIndex), |
| 1958 FXSYS_abs(nIndex - m_pOwner->m_nSelStart)); | 1958 FXSYS_abs(nIndex - m_pOwner->m_nSelStart)); |
| 1959 } | 1959 } |
| 1960 } | 1960 } |
| 1961 void CFWL_EditImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) { | 1961 void CFWL_EditImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) { |
| 1962 if (!m_pOwner->m_pEdtEngine) | 1962 if (!m_pOwner->m_pEdtEngine) |
| 1963 return; | 1963 return; |
| 1964 FDE_TXTEDTMOVECARET MoveCaret = MC_MoveNone; | 1964 FDE_TXTEDTMOVECARET MoveCaret = MC_MoveNone; |
| 1965 FX_BOOL bShift = pMsg->m_dwFlags & FWL_KEYFLAG_Shift; | 1965 FX_BOOL bShift = pMsg->m_dwFlags & FWL_KEYFLAG_Shift; |
| 1966 FX_BOOL bCtrl = pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl; | 1966 FX_BOOL bCtrl = pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl; |
| 1967 FX_DWORD dwKeyCode = pMsg->m_dwKeyCode; | 1967 uint32_t dwKeyCode = pMsg->m_dwKeyCode; |
| 1968 switch (dwKeyCode) { | 1968 switch (dwKeyCode) { |
| 1969 case FWL_VKEY_Left: { | 1969 case FWL_VKEY_Left: { |
| 1970 MoveCaret = MC_Left; | 1970 MoveCaret = MC_Left; |
| 1971 break; | 1971 break; |
| 1972 } | 1972 } |
| 1973 case FWL_VKEY_Right: { | 1973 case FWL_VKEY_Right: { |
| 1974 MoveCaret = MC_Right; | 1974 MoveCaret = MC_Right; |
| 1975 break; | 1975 break; |
| 1976 } | 1976 } |
| 1977 case FWL_VKEY_Up: { | 1977 case FWL_VKEY_Up: { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2102 } | 2102 } |
| 2103 iError = m_pOwner->m_pEdtEngine->Insert(nCaret, &c, 1); | 2103 iError = m_pOwner->m_pEdtEngine->Insert(nCaret, &c, 1); |
| 2104 break; | 2104 break; |
| 2105 } | 2105 } |
| 2106 } | 2106 } |
| 2107 if (iError < 0) { | 2107 if (iError < 0) { |
| 2108 m_pOwner->ProcessInsertError(iError); | 2108 m_pOwner->ProcessInsertError(iError); |
| 2109 } | 2109 } |
| 2110 } | 2110 } |
| 2111 FX_BOOL CFWL_EditImpDelegate::OnScroll(IFWL_ScrollBar* pScrollBar, | 2111 FX_BOOL CFWL_EditImpDelegate::OnScroll(IFWL_ScrollBar* pScrollBar, |
| 2112 FX_DWORD dwCode, | 2112 uint32_t dwCode, |
| 2113 FX_FLOAT fPos) { | 2113 FX_FLOAT fPos) { |
| 2114 CFX_SizeF fs; | 2114 CFX_SizeF fs; |
| 2115 pScrollBar->GetRange(fs.x, fs.y); | 2115 pScrollBar->GetRange(fs.x, fs.y); |
| 2116 FX_FLOAT iCurPos = pScrollBar->GetPos(); | 2116 FX_FLOAT iCurPos = pScrollBar->GetPos(); |
| 2117 FX_FLOAT fStep = pScrollBar->GetStepSize(); | 2117 FX_FLOAT fStep = pScrollBar->GetStepSize(); |
| 2118 switch (dwCode) { | 2118 switch (dwCode) { |
| 2119 case FWL_SCBCODE_Min: { | 2119 case FWL_SCBCODE_Min: { |
| 2120 fPos = fs.x; | 2120 fPos = fs.x; |
| 2121 break; | 2121 break; |
| 2122 } | 2122 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2170 } | 2170 } |
| 2171 CFX_RectF rect; | 2171 CFX_RectF rect; |
| 2172 m_pOwner->GetWidgetRect(rect); | 2172 m_pOwner->GetWidgetRect(rect); |
| 2173 CFX_RectF rtInvalidate; | 2173 CFX_RectF rtInvalidate; |
| 2174 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); | 2174 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); |
| 2175 m_pOwner->Repaint(&rtInvalidate); | 2175 m_pOwner->Repaint(&rtInvalidate); |
| 2176 } | 2176 } |
| 2177 return TRUE; | 2177 return TRUE; |
| 2178 } | 2178 } |
| 2179 void CFWL_EditImpDelegate::DoCursor(CFWL_MsgMouse* pMsg) {} | 2179 void CFWL_EditImpDelegate::DoCursor(CFWL_MsgMouse* pMsg) {} |
| OLD | NEW |