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 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 param.m_rtPart = rtCheck; | 702 param.m_rtPart = rtCheck; |
699 param.m_dwData = (uint32_t)(uintptr_t)(&itemData); | 703 param.m_dwData = (uint32_t)(uintptr_t)(&itemData); |
700 pTheme->DrawBackground(¶m); | 704 pTheme->DrawBackground(¶m); |
701 } | 705 } |
702 CFX_WideString wsText; | 706 CFX_WideString wsText; |
703 pData->GetItemText(m_pInterface, hItem, wsText); | 707 pData->GetItemText(m_pInterface, hItem, wsText); |
704 if (wsText.GetLength() <= 0) { | 708 if (wsText.GetLength() <= 0) { |
705 return; | 709 return; |
706 } | 710 } |
707 CFX_RectF rtText(rtItem); | 711 CFX_RectF rtText(rtItem); |
708 rtText.Deflate(FWL_LISTBOX_ItemTextMargin, FWL_LISTBOX_ItemTextMargin); | 712 rtText.Deflate(kItemTextMargin, kItemTextMargin); |
709 if (bHasIcon || bHasCheck) { | 713 if (bHasIcon || bHasCheck) { |
710 rtText.Deflate(rtItem.height, 0, 0, 0); | 714 rtText.Deflate(rtItem.height, 0, 0, 0); |
711 } | 715 } |
712 CFWL_ThemeText textParam; | 716 CFWL_ThemeText textParam; |
713 textParam.m_pWidget = m_pInterface; | 717 textParam.m_pWidget = m_pInterface; |
714 textParam.m_iPart = CFWL_Part::ListItem; | 718 textParam.m_iPart = CFWL_Part::ListItem; |
715 textParam.m_dwStates = dwPartStates; | 719 textParam.m_dwStates = dwPartStates; |
716 textParam.m_pGraphics = pGraphics; | 720 textParam.m_pGraphics = pGraphics; |
717 textParam.m_matrix.Concat(*pMatrix); | 721 textParam.m_matrix.Concat(*pMatrix); |
718 textParam.m_rtPart = rtText; | 722 textParam.m_rtPart = rtText; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 pData->SetItemRect(m_pInterface, hItem, rtItem); | 768 pData->SetItemRect(m_pInterface, hItem, rtItem); |
765 } | 769 } |
766 fs.y += r.height; | 770 fs.y += r.height; |
767 if (fs.x < r.width) { | 771 if (fs.x < r.width) { |
768 fs.x = r.width; | 772 fs.x = r.width; |
769 fWidth = r.width; | 773 fWidth = r.width; |
770 } | 774 } |
771 } | 775 } |
772 } else { | 776 } else { |
773 fWidth = GetMaxTextWidth(); | 777 fWidth = GetMaxTextWidth(); |
774 fWidth += 2 * FWL_LISTBOX_ItemTextMargin; | 778 fWidth += 2 * kItemTextMargin; |
775 if (!bAutoSize) { | 779 if (!bAutoSize) { |
776 FX_FLOAT fActualWidth = | 780 FX_FLOAT fActualWidth = |
777 m_rtClient.width - rtUIMargin.left - rtUIMargin.width; | 781 m_rtClient.width - rtUIMargin.left - rtUIMargin.width; |
778 if (fWidth < fActualWidth) { | 782 if (fWidth < fActualWidth) { |
779 fWidth = fActualWidth; | 783 fWidth = fActualWidth; |
780 } | 784 } |
781 } | 785 } |
782 IFWL_ListBoxDP* pData = | 786 IFWL_ListBoxDP* pData = |
783 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 787 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
784 m_fItemHeight = GetItemHeigt(); | 788 m_fItemHeight = GetItemHeigt(); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
934 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); | 938 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); |
935 if (!pfWidth) | 939 if (!pfWidth) |
936 return 0; | 940 return 0; |
937 return *pfWidth; | 941 return *pfWidth; |
938 } | 942 } |
939 FX_FLOAT CFWL_ListBoxImp::GetItemHeigt() { | 943 FX_FLOAT CFWL_ListBoxImp::GetItemHeigt() { |
940 FX_FLOAT* pfFont = | 944 FX_FLOAT* pfFont = |
941 static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::FontSize)); | 945 static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::FontSize)); |
942 if (!pfFont) | 946 if (!pfFont) |
943 return 20; | 947 return 20; |
944 return *pfFont + 2 * FWL_LISTBOX_ItemTextMargin; | 948 return *pfFont + 2 * kItemTextMargin; |
945 } | 949 } |
946 void CFWL_ListBoxImp::InitScrollBar(FX_BOOL bVert) { | 950 void CFWL_ListBoxImp::InitScrollBar(FX_BOOL bVert) { |
947 if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) { | 951 if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) { |
948 return; | 952 return; |
949 } | 953 } |
950 CFWL_WidgetImpProperties prop; | 954 CFWL_WidgetImpProperties prop; |
951 prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; | 955 prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; |
952 prop.m_dwStates = FWL_WGTSTATE_Invisible; | 956 prop.m_dwStates = FWL_WGTSTATE_Invisible; |
953 prop.m_pParent = m_pInterface; | 957 prop.m_pParent = m_pInterface; |
954 prop.m_pThemeProvider = m_pScrollBarTP; | 958 prop.m_pThemeProvider = m_pScrollBarTP; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 OnFocusChanged(pMessage, TRUE); | 1002 OnFocusChanged(pMessage, TRUE); |
999 break; | 1003 break; |
1000 } | 1004 } |
1001 case CFWL_MessageType::KillFocus: { | 1005 case CFWL_MessageType::KillFocus: { |
1002 OnFocusChanged(pMessage, FALSE); | 1006 OnFocusChanged(pMessage, FALSE); |
1003 break; | 1007 break; |
1004 } | 1008 } |
1005 case CFWL_MessageType::Mouse: { | 1009 case CFWL_MessageType::Mouse: { |
1006 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); | 1010 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); |
1007 switch (pMsg->m_dwCmd) { | 1011 switch (pMsg->m_dwCmd) { |
1008 case FWL_MSGMOUSECMD_LButtonDown: { | 1012 case FWL_MouseCommand::LeftButtonDown: { |
1009 OnLButtonDown(pMsg); | 1013 OnLButtonDown(pMsg); |
1010 break; | 1014 break; |
1011 } | 1015 } |
1012 case FWL_MSGMOUSECMD_LButtonUp: { | 1016 case FWL_MouseCommand::LeftButtonUp: { |
1013 OnLButtonUp(pMsg); | 1017 OnLButtonUp(pMsg); |
1014 break; | 1018 break; |
1015 } | 1019 } |
1016 default: | 1020 default: |
1017 break; | 1021 break; |
1018 } | 1022 } |
1019 break; | 1023 break; |
1020 } | 1024 } |
1021 case CFWL_MessageType::MouseWheel: { | 1025 case CFWL_MessageType::MouseWheel: { |
1022 OnMouseWheel(static_cast<CFWL_MsgMouseWheel*>(pMessage)); | 1026 OnMouseWheel(static_cast<CFWL_MsgMouseWheel*>(pMessage)); |
1023 break; | 1027 break; |
1024 } | 1028 } |
1025 case CFWL_MessageType::Key: { | 1029 case CFWL_MessageType::Key: { |
1026 CFWL_MsgKey* pMsg = static_cast<CFWL_MsgKey*>(pMessage); | 1030 CFWL_MsgKey* pMsg = static_cast<CFWL_MsgKey*>(pMessage); |
1027 if (pMsg->m_dwCmd == FWL_MSGKEYCMD_KeyDown) | 1031 if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown) |
1028 OnKeyDown(pMsg); | 1032 OnKeyDown(pMsg); |
1029 break; | 1033 break; |
1030 } | 1034 } |
1031 default: { | 1035 default: { |
1032 iRet = 0; | 1036 iRet = 0; |
1033 break; | 1037 break; |
1034 } | 1038 } |
1035 } | 1039 } |
1036 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); | 1040 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); |
1037 return iRet; | 1041 return iRet; |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1245 pScrollBar->SetTrackPos(fPos); | 1249 pScrollBar->SetTrackPos(fPos); |
1246 m_pOwner->Repaint(&m_pOwner->m_rtClient); | 1250 m_pOwner->Repaint(&m_pOwner->m_rtClient); |
1247 } | 1251 } |
1248 return TRUE; | 1252 return TRUE; |
1249 } | 1253 } |
1250 void CFWL_ListBoxImpDelegate::DispatchSelChangedEv() { | 1254 void CFWL_ListBoxImpDelegate::DispatchSelChangedEv() { |
1251 CFWL_EvtLtbSelChanged ev; | 1255 CFWL_EvtLtbSelChanged ev; |
1252 ev.m_pSrcTarget = m_pOwner->m_pInterface; | 1256 ev.m_pSrcTarget = m_pOwner->m_pInterface; |
1253 m_pOwner->DispatchEvent(&ev); | 1257 m_pOwner->DispatchEvent(&ev); |
1254 } | 1258 } |
OLD | NEW |