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 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
629 uint32_t dwPartStates = CFWL_PartState_Normal; | 629 uint32_t dwPartStates = CFWL_PartState_Normal; |
630 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { | 630 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { |
631 dwPartStates = CFWL_PartState_Disabled; | 631 dwPartStates = CFWL_PartState_Disabled; |
632 } else if (dwItemStyles & FWL_ITEMSTATE_LTB_Selected) { | 632 } else if (dwItemStyles & FWL_ITEMSTATE_LTB_Selected) { |
633 dwPartStates = CFWL_PartState_Selected; | 633 dwPartStates = CFWL_PartState_Selected; |
634 } | 634 } |
635 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused && | 635 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused && |
636 dwItemStyles & FWL_ITEMSTATE_LTB_Focused) { | 636 dwItemStyles & FWL_ITEMSTATE_LTB_Focused) { |
637 dwPartStates |= CFWL_PartState_Focused; | 637 dwPartStates |= CFWL_PartState_Focused; |
638 } | 638 } |
639 FWL_ListBoxItemData itemData; | |
640 itemData.pDataProvider = pData; | |
641 itemData.iIndex = Index; | |
642 { | 639 { |
643 CFWL_ThemeBackground param; | 640 CFWL_ThemeBackground param; |
644 param.m_pWidget = m_pInterface; | 641 param.m_pWidget = m_pInterface; |
645 param.m_iPart = CFWL_Part::ListItem; | 642 param.m_iPart = CFWL_Part::ListItem; |
646 param.m_dwStates = dwPartStates; | 643 param.m_dwStates = dwPartStates; |
647 param.m_pGraphics = pGraphics; | 644 param.m_pGraphics = pGraphics; |
648 param.m_matrix.Concat(*pMatrix); | 645 param.m_matrix.Concat(*pMatrix); |
649 param.m_rtPart = rtItem; | 646 param.m_rtPart = rtItem; |
650 param.m_dwData = (uint32_t)(uintptr_t)(&itemData); | |
dsinclair
2016/05/04 16:31:01
This strikes me as a bad idea given that itemData
| |
651 CFX_RectF rtFocus(rtItem); | 647 CFX_RectF rtFocus(rtItem); |
652 param.m_pData = &rtFocus; | 648 param.m_pData = &rtFocus; |
653 if (m_pVertScrollBar && !m_pHorzScrollBar && | 649 if (m_pVertScrollBar && !m_pHorzScrollBar && |
654 (dwPartStates & CFWL_PartState_Focused)) { | 650 (dwPartStates & CFWL_PartState_Focused)) { |
655 param.m_rtPart.left += 1; | 651 param.m_rtPart.left += 1; |
656 param.m_rtPart.width -= (m_fScorllBarWidth + 1); | 652 param.m_rtPart.width -= (m_fScorllBarWidth + 1); |
657 rtFocus.Deflate(0.5, 0.5, 1 + m_fScorllBarWidth, 1); | 653 rtFocus.Deflate(0.5, 0.5, 1 + m_fScorllBarWidth, 1); |
658 } | 654 } |
659 pTheme->DrawBackground(¶m); | 655 pTheme->DrawBackground(¶m); |
660 } | 656 } |
661 { | 657 { |
662 FX_BOOL bHasIcon = GetStylesEx() & FWL_STYLEEXT_LTB_Icon; | 658 FX_BOOL bHasIcon = GetStylesEx() & FWL_STYLEEXT_LTB_Icon; |
663 if (bHasIcon) { | 659 if (bHasIcon) { |
664 CFX_RectF rtDIB; | 660 CFX_RectF rtDIB; |
665 CFX_DIBitmap* pDib = pData->GetItemIcon(m_pInterface, hItem); | 661 CFX_DIBitmap* pDib = pData->GetItemIcon(m_pInterface, hItem); |
666 rtDIB.Set(rtItem.left, rtItem.top, rtItem.height, rtItem.height); | 662 rtDIB.Set(rtItem.left, rtItem.top, rtItem.height, rtItem.height); |
667 if (pDib) { | 663 if (pDib) { |
668 CFWL_ThemeBackground param; | 664 CFWL_ThemeBackground param; |
669 param.m_pWidget = m_pInterface; | 665 param.m_pWidget = m_pInterface; |
670 param.m_iPart = CFWL_Part::Icon; | 666 param.m_iPart = CFWL_Part::Icon; |
671 param.m_pGraphics = pGraphics; | 667 param.m_pGraphics = pGraphics; |
672 param.m_matrix.Concat(*pMatrix); | 668 param.m_matrix.Concat(*pMatrix); |
673 param.m_rtPart = rtDIB; | 669 param.m_rtPart = rtDIB; |
674 param.m_dwData = (uint32_t)(uintptr_t)(&itemData); | |
675 param.m_pImage = pDib; | 670 param.m_pImage = pDib; |
676 pTheme->DrawBackground(¶m); | 671 pTheme->DrawBackground(¶m); |
677 } | 672 } |
678 } | 673 } |
679 FX_BOOL bHasCheck = GetStylesEx() & FWL_STYLEEXT_LTB_Check; | 674 FX_BOOL bHasCheck = GetStylesEx() & FWL_STYLEEXT_LTB_Check; |
680 if (bHasCheck) { | 675 if (bHasCheck) { |
681 CFX_RectF rtCheck; | 676 CFX_RectF rtCheck; |
682 rtCheck.Set(rtItem.left, rtItem.top, rtItem.height, rtItem.height); | 677 rtCheck.Set(rtItem.left, rtItem.top, rtItem.height, rtItem.height); |
683 rtCheck.Deflate(2, 2, 2, 2); | 678 rtCheck.Deflate(2, 2, 2, 2); |
684 pData->SetItemCheckRect(m_pInterface, hItem, rtCheck); | 679 pData->SetItemCheckRect(m_pInterface, hItem, rtCheck); |
685 CFWL_ThemeBackground param; | 680 CFWL_ThemeBackground param; |
686 param.m_pWidget = m_pInterface; | 681 param.m_pWidget = m_pInterface; |
687 param.m_iPart = CFWL_Part::Check; | 682 param.m_iPart = CFWL_Part::Check; |
688 param.m_pGraphics = pGraphics; | 683 param.m_pGraphics = pGraphics; |
689 if (GetItemChecked(hItem)) { | 684 if (GetItemChecked(hItem)) { |
690 param.m_dwStates = CFWL_PartState_Checked; | 685 param.m_dwStates = CFWL_PartState_Checked; |
691 } else { | 686 } else { |
692 param.m_dwStates = CFWL_PartState_Normal; | 687 param.m_dwStates = CFWL_PartState_Normal; |
693 } | 688 } |
694 param.m_matrix.Concat(*pMatrix); | 689 param.m_matrix.Concat(*pMatrix); |
695 param.m_rtPart = rtCheck; | 690 param.m_rtPart = rtCheck; |
696 param.m_dwData = (uint32_t)(uintptr_t)(&itemData); | |
697 pTheme->DrawBackground(¶m); | 691 pTheme->DrawBackground(¶m); |
698 } | 692 } |
699 CFX_WideString wsText; | 693 CFX_WideString wsText; |
700 pData->GetItemText(m_pInterface, hItem, wsText); | 694 pData->GetItemText(m_pInterface, hItem, wsText); |
701 if (wsText.GetLength() <= 0) { | 695 if (wsText.GetLength() <= 0) { |
702 return; | 696 return; |
703 } | 697 } |
704 CFX_RectF rtText(rtItem); | 698 CFX_RectF rtText(rtItem); |
705 rtText.Deflate(FWL_LISTBOX_ItemTextMargin, FWL_LISTBOX_ItemTextMargin); | 699 rtText.Deflate(FWL_LISTBOX_ItemTextMargin, FWL_LISTBOX_ItemTextMargin); |
706 if (bHasIcon || bHasCheck) { | 700 if (bHasIcon || bHasCheck) { |
707 rtText.Deflate(rtItem.height, 0, 0, 0); | 701 rtText.Deflate(rtItem.height, 0, 0, 0); |
708 } | 702 } |
709 CFWL_ThemeText textParam; | 703 CFWL_ThemeText textParam; |
710 textParam.m_pWidget = m_pInterface; | 704 textParam.m_pWidget = m_pInterface; |
711 textParam.m_iPart = CFWL_Part::ListItem; | 705 textParam.m_iPart = CFWL_Part::ListItem; |
712 textParam.m_dwStates = dwPartStates; | 706 textParam.m_dwStates = dwPartStates; |
713 textParam.m_pGraphics = pGraphics; | 707 textParam.m_pGraphics = pGraphics; |
714 textParam.m_matrix.Concat(*pMatrix); | 708 textParam.m_matrix.Concat(*pMatrix); |
715 textParam.m_rtPart = rtText; | 709 textParam.m_rtPart = rtText; |
716 textParam.m_wsText = wsText; | 710 textParam.m_wsText = wsText; |
717 textParam.m_dwTTOStyles = m_dwTTOStyles; | 711 textParam.m_dwTTOStyles = m_dwTTOStyles; |
718 textParam.m_iTTOAlign = m_iTTOAligns; | 712 textParam.m_iTTOAlign = m_iTTOAligns; |
719 textParam.m_dwData = (uint32_t)(uintptr_t)(&itemData); | |
720 pTheme->DrawText(&textParam); | 713 pTheme->DrawText(&textParam); |
721 } | 714 } |
722 } | 715 } |
723 CFX_SizeF CFWL_ListBoxImp::CalcSize(FX_BOOL bAutoSize) { | 716 CFX_SizeF CFWL_ListBoxImp::CalcSize(FX_BOOL bAutoSize) { |
724 CFX_SizeF fs; | 717 CFX_SizeF fs; |
725 if (!m_pProperties->m_pThemeProvider) | 718 if (!m_pProperties->m_pThemeProvider) |
726 return fs; | 719 return fs; |
727 | 720 |
728 GetClientRect(m_rtClient); | 721 GetClientRect(m_rtClient); |
729 m_rtConent = m_rtClient; | 722 m_rtConent = m_rtClient; |
(...skipping 13 matching lines...) Expand all Loading... | |
743 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 736 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
744 if (!bAutoSize) { | 737 if (!bAutoSize) { |
745 } | 738 } |
746 int32_t iCount = pData->CountItems(m_pInterface); | 739 int32_t iCount = pData->CountItems(m_pInterface); |
747 for (int32_t i = 0; i < iCount; i++) { | 740 for (int32_t i = 0; i < iCount; i++) { |
748 FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); | 741 FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); |
749 CFWL_ThemePart itemPart; | 742 CFWL_ThemePart itemPart; |
750 itemPart.m_pWidget = m_pInterface; | 743 itemPart.m_pWidget = m_pInterface; |
751 itemPart.m_iPart = CFWL_Part::ListItem; | 744 itemPart.m_iPart = CFWL_Part::ListItem; |
752 itemPart.m_pData = m_pProperties->m_pDataProvider; | 745 itemPart.m_pData = m_pProperties->m_pDataProvider; |
753 itemPart.m_dwData = i; | |
754 CFX_RectF r; | 746 CFX_RectF r; |
755 m_pProperties->m_pThemeProvider->GetPartRect(&itemPart, r); | 747 m_pProperties->m_pThemeProvider->GetPartRect(&itemPart, r); |
756 if (!bAutoSize) { | 748 if (!bAutoSize) { |
757 CFX_RectF rtItem; | 749 CFX_RectF rtItem; |
758 rtItem.Set(m_rtClient.left, m_rtClient.top + fs.y, r.width, r.height); | 750 rtItem.Set(m_rtClient.left, m_rtClient.top + fs.y, r.width, r.height); |
759 IFWL_ListBoxDP* pData = | 751 IFWL_ListBoxDP* pData = |
760 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 752 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
761 pData->SetItemRect(m_pInterface, hItem, rtItem); | 753 pData->SetItemRect(m_pInterface, hItem, rtItem); |
762 } | 754 } |
763 fs.y += r.height; | 755 fs.y += r.height; |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1242 pScrollBar->SetTrackPos(fPos); | 1234 pScrollBar->SetTrackPos(fPos); |
1243 m_pOwner->Repaint(&m_pOwner->m_rtClient); | 1235 m_pOwner->Repaint(&m_pOwner->m_rtClient); |
1244 } | 1236 } |
1245 return TRUE; | 1237 return TRUE; |
1246 } | 1238 } |
1247 void CFWL_ListBoxImpDelegate::DispatchSelChangedEv() { | 1239 void CFWL_ListBoxImpDelegate::DispatchSelChangedEv() { |
1248 CFWL_EvtLtbSelChanged ev; | 1240 CFWL_EvtLtbSelChanged ev; |
1249 ev.m_pSrcTarget = m_pOwner->m_pInterface; | 1241 ev.m_pSrcTarget = m_pOwner->m_pInterface; |
1250 m_pOwner->DispatchEvent(&ev); | 1242 m_pOwner->DispatchEvent(&ev); |
1251 } | 1243 } |
OLD | NEW |