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