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/cfwl_combobox.h" | 7 #include "xfa/fwl/core/cfwl_combobox.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 if (!pThemeProvider) | 245 if (!pThemeProvider) |
246 return; | 246 return; |
247 | 247 |
248 m_pProperties->m_pThemeProvider = pThemeProvider; | 248 m_pProperties->m_pThemeProvider = pThemeProvider; |
249 if (m_pListBox) | 249 if (m_pListBox) |
250 m_pListBox->SetThemeProvider(pThemeProvider); | 250 m_pListBox->SetThemeProvider(pThemeProvider); |
251 if (m_pEdit) | 251 if (m_pEdit) |
252 m_pEdit->SetThemeProvider(pThemeProvider); | 252 m_pEdit->SetThemeProvider(pThemeProvider); |
253 } | 253 } |
254 | 254 |
255 void CFWL_ComboBox::GetTextByIndex(int32_t iIndex, | 255 CFX_WideString CFWL_ComboBox::GetTextByIndex(int32_t iIndex) const { |
256 CFX_WideString& wsText) const { | |
257 CFWL_ListItem* pItem = static_cast<CFWL_ListItem*>( | 256 CFWL_ListItem* pItem = static_cast<CFWL_ListItem*>( |
258 m_pListBox->GetItem(m_pListBox.get(), iIndex)); | 257 m_pListBox->GetItem(m_pListBox.get(), iIndex)); |
259 if (pItem) | 258 return pItem ? pItem->m_wsText : L""; |
260 wsText = pItem->m_wsText; | |
261 } | 259 } |
262 | 260 |
263 void CFWL_ComboBox::SetCurSel(int32_t iSel) { | 261 void CFWL_ComboBox::SetCurSel(int32_t iSel) { |
264 int32_t iCount = m_pListBox->CountItems(nullptr); | 262 int32_t iCount = m_pListBox->CountItems(nullptr); |
265 bool bClearSel = iSel < 0 || iSel >= iCount; | 263 bool bClearSel = iSel < 0 || iSel >= iCount; |
266 if (IsDropDownStyle() && m_pEdit) { | 264 if (IsDropDownStyle() && m_pEdit) { |
267 if (bClearSel) { | 265 if (bClearSel) { |
268 m_pEdit->SetText(CFX_WideString()); | 266 m_pEdit->SetText(CFX_WideString()); |
269 } else { | 267 } else { |
270 CFWL_ListItem* hItem = m_pListBox->GetItem(this, iSel); | 268 CFWL_ListItem* hItem = m_pListBox->GetItem(this, iSel); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 return L""; | 305 return L""; |
308 | 306 |
309 CFWL_ListItem* hItem = m_pListBox->GetItem(this, m_iCurSel); | 307 CFWL_ListItem* hItem = m_pListBox->GetItem(this, m_iCurSel); |
310 return m_pListBox->GetDataProviderItemText(hItem); | 308 return m_pListBox->GetDataProviderItemText(hItem); |
311 } | 309 } |
312 | 310 |
313 void CFWL_ComboBox::OpenDropDownList(bool bActivate) { | 311 void CFWL_ComboBox::OpenDropDownList(bool bActivate) { |
314 ShowDropList(bActivate); | 312 ShowDropList(bActivate); |
315 } | 313 } |
316 | 314 |
317 void CFWL_ComboBox::GetBBox(CFX_RectF& rect) const { | 315 CFX_RectF CFWL_ComboBox::GetBBox() const { |
318 if (m_pWidgetMgr->IsFormDisabled()) { | 316 if (m_pWidgetMgr->IsFormDisabled()) |
319 DisForm_GetBBox(rect); | 317 return DisForm_GetBBox(); |
320 return; | |
321 } | |
322 | 318 |
323 rect = m_pProperties->m_rtWidget; | 319 CFX_RectF rect = m_pProperties->m_rtWidget; |
324 if (!m_pListBox || !IsDropListVisible()) | 320 if (!m_pListBox || !IsDropListVisible()) |
325 return; | 321 return rect; |
326 | 322 |
327 CFX_RectF rtList; | 323 CFX_RectF rtList; |
328 m_pListBox->GetWidgetRect(rtList, false); | 324 m_pListBox->GetWidgetRect(rtList, false); |
329 rtList.Offset(rect.left, rect.top); | 325 rtList.Offset(rect.left, rect.top); |
330 rect.Union(rtList); | 326 rect.Union(rtList); |
| 327 return rect; |
331 } | 328 } |
332 | 329 |
333 void CFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded, | 330 void CFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded, |
334 uint32_t dwStylesExRemoved) { | 331 uint32_t dwStylesExRemoved) { |
335 if (m_pEdit) | 332 if (m_pEdit) |
336 m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); | 333 m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); |
337 } | 334 } |
338 | 335 |
339 void CFWL_ComboBox::DrawStretchHandler(CFX_Graphics* pGraphics, | 336 void CFWL_ComboBox::DrawStretchHandler(CFX_Graphics* pGraphics, |
340 const CFX_Matrix* pMatrix) { | 337 const CFX_Matrix* pMatrix) { |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 if (m_pListBox && DisForm_IsDropListVisible()) { | 731 if (m_pListBox && DisForm_IsDropListVisible()) { |
735 CFX_RectF rtList; | 732 CFX_RectF rtList; |
736 m_pListBox->GetWidgetRect(rtList, false); | 733 m_pListBox->GetWidgetRect(rtList, false); |
737 CFX_Matrix mt; | 734 CFX_Matrix mt; |
738 mt.Set(1, 0, 0, 1, rtList.left, rtList.top); | 735 mt.Set(1, 0, 0, 1, rtList.left, rtList.top); |
739 mt.Concat(mtOrg); | 736 mt.Concat(mtOrg); |
740 m_pListBox->DrawWidget(pGraphics, &mt); | 737 m_pListBox->DrawWidget(pGraphics, &mt); |
741 } | 738 } |
742 } | 739 } |
743 | 740 |
744 void CFWL_ComboBox::DisForm_GetBBox(CFX_RectF& rect) const { | 741 CFX_RectF CFWL_ComboBox::DisForm_GetBBox() const { |
745 rect = m_pProperties->m_rtWidget; | 742 CFX_RectF rect = m_pProperties->m_rtWidget; |
746 if (!m_pListBox || !DisForm_IsDropListVisible()) | 743 if (!m_pListBox || !DisForm_IsDropListVisible()) |
747 return; | 744 return rect; |
748 | 745 |
749 CFX_RectF rtList; | 746 CFX_RectF rtList; |
750 m_pListBox->GetWidgetRect(rtList, false); | 747 m_pListBox->GetWidgetRect(rtList, false); |
751 rtList.Offset(rect.left, rect.top); | 748 rtList.Offset(rect.left, rect.top); |
752 rect.Union(rtList); | 749 rect.Union(rtList); |
| 750 return rect; |
753 } | 751 } |
754 | 752 |
755 void CFWL_ComboBox::DisForm_Layout() { | 753 void CFWL_ComboBox::DisForm_Layout() { |
756 GetClientRect(m_rtClient); | 754 GetClientRect(m_rtClient); |
757 m_rtContent = m_rtClient; | 755 m_rtContent = m_rtClient; |
758 FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>( | 756 FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>( |
759 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); | 757 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); |
760 if (!pFWidth) | 758 if (!pFWidth) |
761 return; | 759 return; |
762 | 760 |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 else | 1109 else |
1112 iCurSel++; | 1110 iCurSel++; |
1113 } | 1111 } |
1114 m_iCurSel = iCurSel; | 1112 m_iCurSel = iCurSel; |
1115 SyncEditText(m_iCurSel); | 1113 SyncEditText(m_iCurSel); |
1116 return; | 1114 return; |
1117 } | 1115 } |
1118 if (m_pEdit) | 1116 if (m_pEdit) |
1119 m_pEdit->GetDelegate()->OnProcessMessage(pMsg); | 1117 m_pEdit->GetDelegate()->OnProcessMessage(pMsg); |
1120 } | 1118 } |
OLD | NEW |