| 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_listboximp.h" | 7 #include "xfa/fwl/basewidget/fwl_listboximp.h" |
| 8 | 8 |
| 9 #include "xfa/fde/tto/fde_textout.h" | 9 #include "xfa/fde/tto/fde_textout.h" |
| 10 #include "xfa/fwl/basewidget/fwl_comboboximp.h" | 10 #include "xfa/fwl/basewidget/fwl_comboboximp.h" |
| 11 #include "xfa/fwl/basewidget/fwl_scrollbarimp.h" | 11 #include "xfa/fwl/basewidget/fwl_scrollbarimp.h" |
| 12 #include "xfa/fwl/core/cfwl_message.h" | 12 #include "xfa/fwl/core/cfwl_message.h" |
| 13 #include "xfa/fwl/core/cfwl_themebackground.h" | 13 #include "xfa/fwl/core/cfwl_themebackground.h" |
| 14 #include "xfa/fwl/core/cfwl_themepart.h" | 14 #include "xfa/fwl/core/cfwl_themepart.h" |
| 15 #include "xfa/fwl/core/cfwl_themetext.h" | 15 #include "xfa/fwl/core/cfwl_themetext.h" |
| 16 #include "xfa/fwl/core/fwl_noteimp.h" | 16 #include "xfa/fwl/core/fwl_noteimp.h" |
| 17 #include "xfa/fwl/core/fwl_widgetimp.h" | 17 #include "xfa/fwl/core/fwl_widgetimp.h" |
| 18 #include "xfa/fwl/core/ifwl_themeprovider.h" | 18 #include "xfa/fwl/core/ifwl_themeprovider.h" |
| 19 | 19 |
| 20 #define FWL_LISTBOX_ItemTextMargin 2 | 20 namespace { |
| 21 |
| 22 const int kItemTextMargin = 2; |
| 23 |
| 24 } // namespace |
| 21 | 25 |
| 22 // static | 26 // static |
| 23 IFWL_ListBox* IFWL_ListBox::Create(const CFWL_WidgetImpProperties& properties, | 27 IFWL_ListBox* IFWL_ListBox::Create(const CFWL_WidgetImpProperties& properties, |
| 24 IFWL_Widget* pOuter) { | 28 IFWL_Widget* pOuter) { |
| 25 IFWL_ListBox* pListBox = new IFWL_ListBox; | 29 IFWL_ListBox* pListBox = new IFWL_ListBox; |
| 26 CFWL_ListBoxImp* pListBoxImpl = new CFWL_ListBoxImp(properties, pOuter); | 30 CFWL_ListBoxImp* pListBoxImpl = new CFWL_ListBoxImp(properties, pOuter); |
| 27 pListBox->SetImpl(pListBoxImpl); | 31 pListBox->SetImpl(pListBoxImpl); |
| 28 pListBoxImpl->SetInterface(pListBox); | 32 pListBoxImpl->SetInterface(pListBox); |
| 29 return pListBox; | 33 return pListBox; |
| 30 } | 34 } |
| (...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 param.m_rtPart = rtCheck; | 699 param.m_rtPart = rtCheck; |
| 696 param.m_dwData = (uint32_t)(uintptr_t)(&itemData); | 700 param.m_dwData = (uint32_t)(uintptr_t)(&itemData); |
| 697 pTheme->DrawBackground(¶m); | 701 pTheme->DrawBackground(¶m); |
| 698 } | 702 } |
| 699 CFX_WideString wsText; | 703 CFX_WideString wsText; |
| 700 pData->GetItemText(m_pInterface, hItem, wsText); | 704 pData->GetItemText(m_pInterface, hItem, wsText); |
| 701 if (wsText.GetLength() <= 0) { | 705 if (wsText.GetLength() <= 0) { |
| 702 return; | 706 return; |
| 703 } | 707 } |
| 704 CFX_RectF rtText(rtItem); | 708 CFX_RectF rtText(rtItem); |
| 705 rtText.Deflate(FWL_LISTBOX_ItemTextMargin, FWL_LISTBOX_ItemTextMargin); | 709 rtText.Deflate(kItemTextMargin, kItemTextMargin); |
| 706 if (bHasIcon || bHasCheck) { | 710 if (bHasIcon || bHasCheck) { |
| 707 rtText.Deflate(rtItem.height, 0, 0, 0); | 711 rtText.Deflate(rtItem.height, 0, 0, 0); |
| 708 } | 712 } |
| 709 CFWL_ThemeText textParam; | 713 CFWL_ThemeText textParam; |
| 710 textParam.m_pWidget = m_pInterface; | 714 textParam.m_pWidget = m_pInterface; |
| 711 textParam.m_iPart = CFWL_Part::ListItem; | 715 textParam.m_iPart = CFWL_Part::ListItem; |
| 712 textParam.m_dwStates = dwPartStates; | 716 textParam.m_dwStates = dwPartStates; |
| 713 textParam.m_pGraphics = pGraphics; | 717 textParam.m_pGraphics = pGraphics; |
| 714 textParam.m_matrix.Concat(*pMatrix); | 718 textParam.m_matrix.Concat(*pMatrix); |
| 715 textParam.m_rtPart = rtText; | 719 textParam.m_rtPart = rtText; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 pData->SetItemRect(m_pInterface, hItem, rtItem); | 765 pData->SetItemRect(m_pInterface, hItem, rtItem); |
| 762 } | 766 } |
| 763 fs.y += r.height; | 767 fs.y += r.height; |
| 764 if (fs.x < r.width) { | 768 if (fs.x < r.width) { |
| 765 fs.x = r.width; | 769 fs.x = r.width; |
| 766 fWidth = r.width; | 770 fWidth = r.width; |
| 767 } | 771 } |
| 768 } | 772 } |
| 769 } else { | 773 } else { |
| 770 fWidth = GetMaxTextWidth(); | 774 fWidth = GetMaxTextWidth(); |
| 771 fWidth += 2 * FWL_LISTBOX_ItemTextMargin; | 775 fWidth += 2 * kItemTextMargin; |
| 772 if (!bAutoSize) { | 776 if (!bAutoSize) { |
| 773 FX_FLOAT fActualWidth = | 777 FX_FLOAT fActualWidth = |
| 774 m_rtClient.width - rtUIMargin.left - rtUIMargin.width; | 778 m_rtClient.width - rtUIMargin.left - rtUIMargin.width; |
| 775 if (fWidth < fActualWidth) { | 779 if (fWidth < fActualWidth) { |
| 776 fWidth = fActualWidth; | 780 fWidth = fActualWidth; |
| 777 } | 781 } |
| 778 } | 782 } |
| 779 IFWL_ListBoxDP* pData = | 783 IFWL_ListBoxDP* pData = |
| 780 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 784 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
| 781 m_fItemHeight = GetItemHeigt(); | 785 m_fItemHeight = GetItemHeigt(); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); | 935 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); |
| 932 if (!pfWidth) | 936 if (!pfWidth) |
| 933 return 0; | 937 return 0; |
| 934 return *pfWidth; | 938 return *pfWidth; |
| 935 } | 939 } |
| 936 FX_FLOAT CFWL_ListBoxImp::GetItemHeigt() { | 940 FX_FLOAT CFWL_ListBoxImp::GetItemHeigt() { |
| 937 FX_FLOAT* pfFont = | 941 FX_FLOAT* pfFont = |
| 938 static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::FontSize)); | 942 static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::FontSize)); |
| 939 if (!pfFont) | 943 if (!pfFont) |
| 940 return 20; | 944 return 20; |
| 941 return *pfFont + 2 * FWL_LISTBOX_ItemTextMargin; | 945 return *pfFont + 2 * kItemTextMargin; |
| 942 } | 946 } |
| 943 void CFWL_ListBoxImp::InitScrollBar(FX_BOOL bVert) { | 947 void CFWL_ListBoxImp::InitScrollBar(FX_BOOL bVert) { |
| 944 if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) { | 948 if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) { |
| 945 return; | 949 return; |
| 946 } | 950 } |
| 947 CFWL_WidgetImpProperties prop; | 951 CFWL_WidgetImpProperties prop; |
| 948 prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; | 952 prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; |
| 949 prop.m_dwStates = FWL_WGTSTATE_Invisible; | 953 prop.m_dwStates = FWL_WGTSTATE_Invisible; |
| 950 prop.m_pParent = m_pInterface; | 954 prop.m_pParent = m_pInterface; |
| 951 prop.m_pThemeProvider = m_pScrollBarTP; | 955 prop.m_pThemeProvider = m_pScrollBarTP; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 995 OnFocusChanged(pMessage, TRUE); | 999 OnFocusChanged(pMessage, TRUE); |
| 996 break; | 1000 break; |
| 997 } | 1001 } |
| 998 case CFWL_MessageType::KillFocus: { | 1002 case CFWL_MessageType::KillFocus: { |
| 999 OnFocusChanged(pMessage, FALSE); | 1003 OnFocusChanged(pMessage, FALSE); |
| 1000 break; | 1004 break; |
| 1001 } | 1005 } |
| 1002 case CFWL_MessageType::Mouse: { | 1006 case CFWL_MessageType::Mouse: { |
| 1003 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); | 1007 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); |
| 1004 switch (pMsg->m_dwCmd) { | 1008 switch (pMsg->m_dwCmd) { |
| 1005 case FWL_MSGMOUSECMD_LButtonDown: { | 1009 case FWL_MouseCommand::LeftButtonDown: { |
| 1006 OnLButtonDown(pMsg); | 1010 OnLButtonDown(pMsg); |
| 1007 break; | 1011 break; |
| 1008 } | 1012 } |
| 1009 case FWL_MSGMOUSECMD_LButtonUp: { | 1013 case FWL_MouseCommand::LeftButtonUp: { |
| 1010 OnLButtonUp(pMsg); | 1014 OnLButtonUp(pMsg); |
| 1011 break; | 1015 break; |
| 1012 } | 1016 } |
| 1013 default: | 1017 default: |
| 1014 break; | 1018 break; |
| 1015 } | 1019 } |
| 1016 break; | 1020 break; |
| 1017 } | 1021 } |
| 1018 case CFWL_MessageType::MouseWheel: { | 1022 case CFWL_MessageType::MouseWheel: { |
| 1019 OnMouseWheel(static_cast<CFWL_MsgMouseWheel*>(pMessage)); | 1023 OnMouseWheel(static_cast<CFWL_MsgMouseWheel*>(pMessage)); |
| 1020 break; | 1024 break; |
| 1021 } | 1025 } |
| 1022 case CFWL_MessageType::Key: { | 1026 case CFWL_MessageType::Key: { |
| 1023 CFWL_MsgKey* pMsg = static_cast<CFWL_MsgKey*>(pMessage); | 1027 CFWL_MsgKey* pMsg = static_cast<CFWL_MsgKey*>(pMessage); |
| 1024 if (pMsg->m_dwCmd == FWL_MSGKEYCMD_KeyDown) | 1028 if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown) |
| 1025 OnKeyDown(pMsg); | 1029 OnKeyDown(pMsg); |
| 1026 break; | 1030 break; |
| 1027 } | 1031 } |
| 1028 default: { | 1032 default: { |
| 1029 iRet = 0; | 1033 iRet = 0; |
| 1030 break; | 1034 break; |
| 1031 } | 1035 } |
| 1032 } | 1036 } |
| 1033 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); | 1037 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); |
| 1034 return iRet; | 1038 return iRet; |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1242 pScrollBar->SetTrackPos(fPos); | 1246 pScrollBar->SetTrackPos(fPos); |
| 1243 m_pOwner->Repaint(&m_pOwner->m_rtClient); | 1247 m_pOwner->Repaint(&m_pOwner->m_rtClient); |
| 1244 } | 1248 } |
| 1245 return TRUE; | 1249 return TRUE; |
| 1246 } | 1250 } |
| 1247 void CFWL_ListBoxImpDelegate::DispatchSelChangedEv() { | 1251 void CFWL_ListBoxImpDelegate::DispatchSelChangedEv() { |
| 1248 CFWL_EvtLtbSelChanged ev; | 1252 CFWL_EvtLtbSelChanged ev; |
| 1249 ev.m_pSrcTarget = m_pOwner->m_pInterface; | 1253 ev.m_pSrcTarget = m_pOwner->m_pInterface; |
| 1250 m_pOwner->DispatchEvent(&ev); | 1254 m_pOwner->DispatchEvent(&ev); |
| 1251 } | 1255 } |
| OLD | NEW |