| 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/cfwl_listbox.h" | 7 #include "xfa/fwl/cfwl_listbox.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 bScroll = true; | 378 bScroll = true; |
| 379 } else if (rtItem.bottom() > m_rtConent.bottom()) { | 379 } else if (rtItem.bottom() > m_rtConent.bottom()) { |
| 380 fPosY += rtItem.bottom() - m_rtConent.bottom(); | 380 fPosY += rtItem.bottom() - m_rtConent.bottom(); |
| 381 bScroll = true; | 381 bScroll = true; |
| 382 } | 382 } |
| 383 if (!bScroll) | 383 if (!bScroll) |
| 384 return false; | 384 return false; |
| 385 | 385 |
| 386 m_pVertScrollBar->SetPos(fPosY); | 386 m_pVertScrollBar->SetPos(fPosY); |
| 387 m_pVertScrollBar->SetTrackPos(fPosY); | 387 m_pVertScrollBar->SetTrackPos(fPosY); |
| 388 Repaint(&m_rtClient); | 388 RepaintRect(m_rtClient); |
| 389 return true; | 389 return true; |
| 390 } | 390 } |
| 391 | 391 |
| 392 void CFWL_ListBox::DrawBkground(CFX_Graphics* pGraphics, | 392 void CFWL_ListBox::DrawBkground(CFX_Graphics* pGraphics, |
| 393 IFWL_ThemeProvider* pTheme, | 393 IFWL_ThemeProvider* pTheme, |
| 394 const CFX_Matrix* pMatrix) { | 394 const CFX_Matrix* pMatrix) { |
| 395 if (!pGraphics) | 395 if (!pGraphics) |
| 396 return; | 396 return; |
| 397 if (!pTheme) | 397 if (!pTheme) |
| 398 return; | 398 return; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 textParam.m_iTTOAlign = m_iTTOAligns; | 547 textParam.m_iTTOAlign = m_iTTOAligns; |
| 548 textParam.m_bMaximize = true; | 548 textParam.m_bMaximize = true; |
| 549 pTheme->DrawText(&textParam); | 549 pTheme->DrawText(&textParam); |
| 550 } | 550 } |
| 551 | 551 |
| 552 CFX_SizeF CFWL_ListBox::CalcSize(bool bAutoSize) { | 552 CFX_SizeF CFWL_ListBox::CalcSize(bool bAutoSize) { |
| 553 CFX_SizeF fs; | 553 CFX_SizeF fs; |
| 554 if (!m_pProperties->m_pThemeProvider) | 554 if (!m_pProperties->m_pThemeProvider) |
| 555 return fs; | 555 return fs; |
| 556 | 556 |
| 557 GetClientRect(m_rtClient); | 557 m_rtClient = GetClientRect(); |
| 558 m_rtConent = m_rtClient; | 558 m_rtConent = m_rtClient; |
| 559 CFX_RectF rtUIMargin; | 559 CFX_RectF rtUIMargin; |
| 560 rtUIMargin.Set(0, 0, 0, 0); | 560 rtUIMargin.Set(0, 0, 0, 0); |
| 561 if (!m_pOuter) { | 561 if (!m_pOuter) { |
| 562 CFX_RectF* pUIMargin = static_cast<CFX_RectF*>( | 562 CFX_RectF* pUIMargin = static_cast<CFX_RectF*>( |
| 563 GetThemeCapacity(CFWL_WidgetCapacity::UIMargin)); | 563 GetThemeCapacity(CFWL_WidgetCapacity::UIMargin)); |
| 564 if (pUIMargin) { | 564 if (pUIMargin) { |
| 565 m_rtConent.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width, | 565 m_rtConent.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width, |
| 566 pUIMargin->height); | 566 pUIMargin->height); |
| 567 } | 567 } |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 m_pHorzScrollBar->RemoveStates(FWL_WGTSTATE_Invisible); | 834 m_pHorzScrollBar->RemoveStates(FWL_WGTSTATE_Invisible); |
| 835 else | 835 else |
| 836 m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible); | 836 m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible); |
| 837 } | 837 } |
| 838 } | 838 } |
| 839 if (bSet) | 839 if (bSet) |
| 840 m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused); | 840 m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused); |
| 841 else | 841 else |
| 842 m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused); | 842 m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused); |
| 843 | 843 |
| 844 Repaint(&m_rtClient); | 844 RepaintRect(m_rtClient); |
| 845 } | 845 } |
| 846 | 846 |
| 847 void CFWL_ListBox::OnLButtonDown(CFWL_MessageMouse* pMsg) { | 847 void CFWL_ListBox::OnLButtonDown(CFWL_MessageMouse* pMsg) { |
| 848 m_bLButtonDown = true; | 848 m_bLButtonDown = true; |
| 849 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) | 849 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) |
| 850 SetFocus(true); | 850 SetFocus(true); |
| 851 | 851 |
| 852 CFWL_ListItem* pItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); | 852 CFWL_ListItem* pItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); |
| 853 if (!pItem) | 853 if (!pItem) |
| 854 return; | 854 return; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 876 GetItemCheckRectInternal(hSelectedItem, rtCheck); | 876 GetItemCheckRectInternal(hSelectedItem, rtCheck); |
| 877 bool bChecked = GetItemChecked(pItem); | 877 bool bChecked = GetItemChecked(pItem); |
| 878 if (rtCheck.Contains(pMsg->m_fx, pMsg->m_fy)) { | 878 if (rtCheck.Contains(pMsg->m_fx, pMsg->m_fy)) { |
| 879 SetItemChecked(pItem, !bChecked); | 879 SetItemChecked(pItem, !bChecked); |
| 880 Update(); | 880 Update(); |
| 881 } | 881 } |
| 882 } | 882 } |
| 883 SetFocusItem(pItem); | 883 SetFocusItem(pItem); |
| 884 ScrollToVisible(pItem); | 884 ScrollToVisible(pItem); |
| 885 SetGrab(true); | 885 SetGrab(true); |
| 886 Repaint(&m_rtClient); | 886 RepaintRect(m_rtClient); |
| 887 } | 887 } |
| 888 | 888 |
| 889 void CFWL_ListBox::OnLButtonUp(CFWL_MessageMouse* pMsg) { | 889 void CFWL_ListBox::OnLButtonUp(CFWL_MessageMouse* pMsg) { |
| 890 if (!m_bLButtonDown) | 890 if (!m_bLButtonDown) |
| 891 return; | 891 return; |
| 892 | 892 |
| 893 m_bLButtonDown = false; | 893 m_bLButtonDown = false; |
| 894 SetGrab(false); | 894 SetGrab(false); |
| 895 } | 895 } |
| 896 | 896 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 938 } else { | 938 } else { |
| 939 SetSelection(pItem, pItem, true); | 939 SetSelection(pItem, pItem, true); |
| 940 } | 940 } |
| 941 | 941 |
| 942 SetFocusItem(pItem); | 942 SetFocusItem(pItem); |
| 943 ScrollToVisible(pItem); | 943 ScrollToVisible(pItem); |
| 944 | 944 |
| 945 CFX_RectF rtInvalidate; | 945 CFX_RectF rtInvalidate; |
| 946 rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width, | 946 rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width, |
| 947 m_pProperties->m_rtWidget.height); | 947 m_pProperties->m_rtWidget.height); |
| 948 Repaint(&rtInvalidate); | 948 RepaintRect(rtInvalidate); |
| 949 } | 949 } |
| 950 | 950 |
| 951 bool CFWL_ListBox::OnScroll(CFWL_ScrollBar* pScrollBar, | 951 bool CFWL_ListBox::OnScroll(CFWL_ScrollBar* pScrollBar, |
| 952 CFWL_EventScroll::Code dwCode, | 952 CFWL_EventScroll::Code dwCode, |
| 953 FX_FLOAT fPos) { | 953 FX_FLOAT fPos) { |
| 954 CFX_SizeF fs; | 954 CFX_SizeF fs; |
| 955 pScrollBar->GetRange(&fs.x, &fs.y); | 955 pScrollBar->GetRange(&fs.x, &fs.y); |
| 956 FX_FLOAT iCurPos = pScrollBar->GetPos(); | 956 FX_FLOAT iCurPos = pScrollBar->GetPos(); |
| 957 FX_FLOAT fStep = pScrollBar->GetStepSize(); | 957 FX_FLOAT fStep = pScrollBar->GetStepSize(); |
| 958 switch (dwCode) { | 958 switch (dwCode) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 991 case CFWL_EventScroll::Code::Pos: | 991 case CFWL_EventScroll::Code::Pos: |
| 992 case CFWL_EventScroll::Code::TrackPos: | 992 case CFWL_EventScroll::Code::TrackPos: |
| 993 case CFWL_EventScroll::Code::None: | 993 case CFWL_EventScroll::Code::None: |
| 994 break; | 994 break; |
| 995 case CFWL_EventScroll::Code::EndScroll: | 995 case CFWL_EventScroll::Code::EndScroll: |
| 996 return false; | 996 return false; |
| 997 } | 997 } |
| 998 if (iCurPos != fPos) { | 998 if (iCurPos != fPos) { |
| 999 pScrollBar->SetPos(fPos); | 999 pScrollBar->SetPos(fPos); |
| 1000 pScrollBar->SetTrackPos(fPos); | 1000 pScrollBar->SetTrackPos(fPos); |
| 1001 Repaint(&m_rtClient); | 1001 RepaintRect(m_rtClient); |
| 1002 } | 1002 } |
| 1003 return true; | 1003 return true; |
| 1004 } | 1004 } |
| 1005 | 1005 |
| 1006 CFX_WideString CFWL_ListBox::GetItemText(CFWL_Widget* pWidget, | 1006 CFX_WideString CFWL_ListBox::GetItemText(CFWL_Widget* pWidget, |
| 1007 CFWL_ListItem* pItem) { | 1007 CFWL_ListItem* pItem) { |
| 1008 return pItem ? static_cast<CFWL_ListItem*>(pItem)->m_wsText : L""; | 1008 return pItem ? static_cast<CFWL_ListItem*>(pItem)->m_wsText : L""; |
| 1009 } | 1009 } |
| 1010 | 1010 |
| 1011 int32_t CFWL_ListBox::CountItems(const CFWL_Widget* pWidget) const { | 1011 int32_t CFWL_ListBox::CountItems(const CFWL_Widget* pWidget) const { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1121 | 1121 |
| 1122 void CFWL_ListBox::DeleteAll() { | 1122 void CFWL_ListBox::DeleteAll() { |
| 1123 m_ItemArray.clear(); | 1123 m_ItemArray.clear(); |
| 1124 } | 1124 } |
| 1125 | 1125 |
| 1126 uint32_t CFWL_ListBox::GetItemStates(CFWL_ListItem* pItem) { | 1126 uint32_t CFWL_ListBox::GetItemStates(CFWL_ListItem* pItem) { |
| 1127 if (!pItem) | 1127 if (!pItem) |
| 1128 return 0; | 1128 return 0; |
| 1129 return pItem->m_dwStates | pItem->m_dwCheckState; | 1129 return pItem->m_dwStates | pItem->m_dwCheckState; |
| 1130 } | 1130 } |
| OLD | NEW |