| 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" |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 DrawBkground(pGraphics, pTheme, pMatrix); | 195 DrawBkground(pGraphics, pTheme, pMatrix); |
| 196 } | 196 } |
| 197 DrawItems(pGraphics, pTheme, pMatrix); | 197 DrawItems(pGraphics, pTheme, pMatrix); |
| 198 pGraphics->RestoreGraphState(); | 198 pGraphics->RestoreGraphState(); |
| 199 return FWL_Error::Succeeded; | 199 return FWL_Error::Succeeded; |
| 200 } | 200 } |
| 201 FWL_Error CFWL_ListBoxImp::SetThemeProvider( | 201 FWL_Error CFWL_ListBoxImp::SetThemeProvider( |
| 202 IFWL_ThemeProvider* pThemeProvider) { | 202 IFWL_ThemeProvider* pThemeProvider) { |
| 203 if (!pThemeProvider) | 203 if (!pThemeProvider) |
| 204 return FWL_Error::Indefinite; | 204 return FWL_Error::Indefinite; |
| 205 if (!pThemeProvider->IsValidWidget(m_pInterface)) { | |
| 206 m_pScrollBarTP = pThemeProvider; | |
| 207 return FWL_Error::Succeeded; | |
| 208 } | |
| 209 m_pProperties->m_pThemeProvider = pThemeProvider; | 205 m_pProperties->m_pThemeProvider = pThemeProvider; |
| 210 return FWL_Error::Succeeded; | 206 return FWL_Error::Succeeded; |
| 211 } | 207 } |
| 212 int32_t CFWL_ListBoxImp::CountSelItems() { | 208 int32_t CFWL_ListBoxImp::CountSelItems() { |
| 213 if (!m_pProperties->m_pDataProvider) | 209 if (!m_pProperties->m_pDataProvider) |
| 214 return 0; | 210 return 0; |
| 215 int32_t iRet = 0; | 211 int32_t iRet = 0; |
| 216 IFWL_ListBoxDP* pData = | 212 IFWL_ListBoxDP* pData = |
| 217 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 213 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
| 218 int32_t iCount = pData->CountItems(m_pInterface); | 214 int32_t iCount = pData->CountItems(m_pInterface); |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 pUIMargin->height); | 722 pUIMargin->height); |
| 727 } | 723 } |
| 728 } | 724 } |
| 729 FX_FLOAT fWidth = 0; | 725 FX_FLOAT fWidth = 0; |
| 730 if (m_pProperties->m_pThemeProvider->IsCustomizedLayout(m_pInterface)) { | 726 if (m_pProperties->m_pThemeProvider->IsCustomizedLayout(m_pInterface)) { |
| 731 IFWL_ListBoxDP* pData = | 727 IFWL_ListBoxDP* pData = |
| 732 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 728 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
| 733 int32_t iCount = pData->CountItems(m_pInterface); | 729 int32_t iCount = pData->CountItems(m_pInterface); |
| 734 for (int32_t i = 0; i < iCount; i++) { | 730 for (int32_t i = 0; i < iCount; i++) { |
| 735 IFWL_ListItem* pItem = pData->GetItem(m_pInterface, i); | 731 IFWL_ListItem* pItem = pData->GetItem(m_pInterface, i); |
| 736 CFWL_ThemePart itemPart; | |
| 737 itemPart.m_pWidget = m_pInterface; | |
| 738 itemPart.m_iPart = CFWL_Part::ListItem; | |
| 739 itemPart.m_pData = m_pProperties->m_pDataProvider; | |
| 740 itemPart.m_bMaximize = i > 0; | |
| 741 CFX_RectF r; | |
| 742 m_pProperties->m_pThemeProvider->GetPartRect(&itemPart, r); | |
| 743 if (!bAutoSize) { | 732 if (!bAutoSize) { |
| 744 CFX_RectF rtItem; | 733 CFX_RectF rtItem; |
| 745 rtItem.Set(m_rtClient.left, m_rtClient.top + fs.y, r.width, r.height); | 734 rtItem.Set(m_rtClient.left, m_rtClient.top + fs.y, 0, 0); |
| 746 IFWL_ListBoxDP* pBox = | 735 IFWL_ListBoxDP* pBox = |
| 747 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 736 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
| 748 pBox->SetItemRect(m_pInterface, pItem, rtItem); | 737 pBox->SetItemRect(m_pInterface, pItem, rtItem); |
| 749 } | 738 } |
| 750 fs.y += r.height; | 739 if (fs.x < 0) { |
| 751 if (fs.x < r.width) { | 740 fs.x = 0; |
| 752 fs.x = r.width; | 741 fWidth = 0; |
| 753 fWidth = r.width; | |
| 754 } | 742 } |
| 755 } | 743 } |
| 756 } else { | 744 } else { |
| 757 fWidth = GetMaxTextWidth(); | 745 fWidth = GetMaxTextWidth(); |
| 758 fWidth += 2 * kItemTextMargin; | 746 fWidth += 2 * kItemTextMargin; |
| 759 if (!bAutoSize) { | 747 if (!bAutoSize) { |
| 760 FX_FLOAT fActualWidth = | 748 FX_FLOAT fActualWidth = |
| 761 m_rtClient.width - rtUIMargin.left - rtUIMargin.width; | 749 m_rtClient.width - rtUIMargin.left - rtUIMargin.width; |
| 762 if (fWidth < fActualWidth) { | 750 if (fWidth < fActualWidth) { |
| 763 fWidth = fActualWidth; | 751 fWidth = fActualWidth; |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1226 pScrollBar->SetTrackPos(fPos); | 1214 pScrollBar->SetTrackPos(fPos); |
| 1227 m_pOwner->Repaint(&m_pOwner->m_rtClient); | 1215 m_pOwner->Repaint(&m_pOwner->m_rtClient); |
| 1228 } | 1216 } |
| 1229 return TRUE; | 1217 return TRUE; |
| 1230 } | 1218 } |
| 1231 void CFWL_ListBoxImpDelegate::DispatchSelChangedEv() { | 1219 void CFWL_ListBoxImpDelegate::DispatchSelChangedEv() { |
| 1232 CFWL_EvtLtbSelChanged ev; | 1220 CFWL_EvtLtbSelChanged ev; |
| 1233 ev.m_pSrcTarget = m_pOwner->m_pInterface; | 1221 ev.m_pSrcTarget = m_pOwner->m_pInterface; |
| 1234 m_pOwner->DispatchEvent(&ev); | 1222 m_pOwner->DispatchEvent(&ev); |
| 1235 } | 1223 } |
| OLD | NEW |