| 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 "fpdfsdk/include/pdfwindow/PWL_IconList.h" | 7 #include "fpdfsdk/include/pdfwindow/PWL_IconList.h" |
| 8 | 8 |
| 9 #include "fpdfsdk/include/pdfwindow/PWL_Label.h" | 9 #include "fpdfsdk/include/pdfwindow/PWL_Label.h" |
| 10 #include "fpdfsdk/include/pdfwindow/PWL_ListCtrl.h" | 10 #include "fpdfsdk/include/pdfwindow/PWL_ListCtrl.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 CFX_ByteString CPWL_IconList_Item::GetClassName() const { | 26 CFX_ByteString CPWL_IconList_Item::GetClassName() const { |
| 27 return "CPWL_IconList_Item"; | 27 return "CPWL_IconList_Item"; |
| 28 } | 28 } |
| 29 | 29 |
| 30 FX_FLOAT CPWL_IconList_Item::GetItemHeight(FX_FLOAT fLimitWidth) { | 30 FX_FLOAT CPWL_IconList_Item::GetItemHeight(FX_FLOAT fLimitWidth) { |
| 31 return PWL_IconList_ITEM_HEIGHT; | 31 return PWL_IconList_ITEM_HEIGHT; |
| 32 } | 32 } |
| 33 | 33 |
| 34 void CPWL_IconList_Item::DrawThisAppearance(CFX_RenderDevice* pDevice, | 34 void CPWL_IconList_Item::DrawThisAppearance(CFX_RenderDevice* pDevice, |
| 35 CFX_Matrix* pUser2Device) { | 35 CFX_Matrix* pUser2Device) { |
| 36 CFX_FloatRect rcClient = GetClientRect(); | 36 CPDF_Rect rcClient = GetClientRect(); |
| 37 | 37 |
| 38 if (m_bSelected) { | 38 if (m_bSelected) { |
| 39 if (IsEnabled()) { | 39 if (IsEnabled()) { |
| 40 CPWL_Utils::DrawFillRect( | 40 CPWL_Utils::DrawFillRect( |
| 41 pDevice, pUser2Device, rcClient, | 41 pDevice, pUser2Device, rcClient, |
| 42 CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_SELBACKCOLOR, | 42 CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_SELBACKCOLOR, |
| 43 GetTransparency())); | 43 GetTransparency())); |
| 44 } else { | 44 } else { |
| 45 CPWL_Utils::DrawFillRect( | 45 CPWL_Utils::DrawFillRect( |
| 46 pDevice, pUser2Device, rcClient, | 46 pDevice, pUser2Device, rcClient, |
| 47 CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_LIGHTGRAYCOLOR, | 47 CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_LIGHTGRAYCOLOR, |
| 48 GetTransparency())); | 48 GetTransparency())); |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 | 51 |
| 52 CFX_FloatRect rcIcon = rcClient; | 52 CPDF_Rect rcIcon = rcClient; |
| 53 rcIcon.left += PWL_IconList_ITEM_ICON_LEFTMARGIN; | 53 rcIcon.left += PWL_IconList_ITEM_ICON_LEFTMARGIN; |
| 54 rcIcon.right = rcIcon.left + PWL_IconList_ITEM_WIDTH; | 54 rcIcon.right = rcIcon.left + PWL_IconList_ITEM_WIDTH; |
| 55 | 55 |
| 56 CPWL_Utils::DrawIconAppStream(pDevice, pUser2Device, m_nIconIndex, rcIcon, | 56 CPWL_Utils::DrawIconAppStream(pDevice, pUser2Device, m_nIconIndex, rcIcon, |
| 57 m_crIcon, m_pText->GetTextColor(), | 57 m_crIcon, m_pText->GetTextColor(), |
| 58 GetTransparency()); | 58 GetTransparency()); |
| 59 } | 59 } |
| 60 | 60 |
| 61 void CPWL_IconList_Item::SetSelect(FX_BOOL bSelected) { | 61 void CPWL_IconList_Item::SetSelect(FX_BOOL bSelected) { |
| 62 m_bSelected = bSelected; | 62 m_bSelected = bSelected; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 92 | 92 |
| 93 void CPWL_IconList_Item::SetText(const CFX_WideString& str) { | 93 void CPWL_IconList_Item::SetText(const CFX_WideString& str) { |
| 94 m_pText->SetText(str.c_str()); | 94 m_pText->SetText(str.c_str()); |
| 95 } | 95 } |
| 96 | 96 |
| 97 CFX_WideString CPWL_IconList_Item::GetText() const { | 97 CFX_WideString CPWL_IconList_Item::GetText() const { |
| 98 return m_pText->GetText(); | 98 return m_pText->GetText(); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void CPWL_IconList_Item::RePosChildWnd() { | 101 void CPWL_IconList_Item::RePosChildWnd() { |
| 102 CFX_FloatRect rcClient = GetClientRect(); | 102 CPDF_Rect rcClient = GetClientRect(); |
| 103 | 103 |
| 104 rcClient.left += | 104 rcClient.left += |
| 105 (PWL_IconList_ITEM_ICON_LEFTMARGIN + PWL_IconList_ITEM_WIDTH + | 105 (PWL_IconList_ITEM_ICON_LEFTMARGIN + PWL_IconList_ITEM_WIDTH + |
| 106 PWL_IconList_ITEM_ICON_LEFTMARGIN); | 106 PWL_IconList_ITEM_ICON_LEFTMARGIN); |
| 107 | 107 |
| 108 m_pText->Move(rcClient, TRUE, FALSE); | 108 m_pText->Move(rcClient, TRUE, FALSE); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void CPWL_IconList_Item::SetIconFillColor(const CPWL_Color& color) { | 111 void CPWL_IconList_Item::SetIconFillColor(const CPWL_Color& color) { |
| 112 m_crIcon = color; | 112 m_crIcon = color; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 143 PWL_CREATEPARAM icp = cp; | 143 PWL_CREATEPARAM icp = cp; |
| 144 icp.pParentWnd = this; | 144 icp.pParentWnd = this; |
| 145 icp.dwFlags = PWS_CHILD | PWS_VISIBLE | PWS_NOREFRESHCLIP; | 145 icp.dwFlags = PWS_CHILD | PWS_VISIBLE | PWS_NOREFRESHCLIP; |
| 146 pNewItem->Create(icp); | 146 pNewItem->Create(icp); |
| 147 } | 147 } |
| 148 | 148 |
| 149 SetItemSpace(PWL_IconList_ITEM_SPACE); | 149 SetItemSpace(PWL_IconList_ITEM_SPACE); |
| 150 ResetContent(0); | 150 ResetContent(0); |
| 151 | 151 |
| 152 if (CPWL_Wnd* pParent = GetParentWindow()) { | 152 if (CPWL_Wnd* pParent = GetParentWindow()) { |
| 153 CFX_FloatRect rcScroll = GetScrollArea(); | 153 CPDF_Rect rcScroll = GetScrollArea(); |
| 154 GetScrollPos(); | 154 GetScrollPos(); |
| 155 | 155 |
| 156 PWL_SCROLL_INFO sInfo; | 156 PWL_SCROLL_INFO sInfo; |
| 157 sInfo.fContentMin = rcScroll.bottom; | 157 sInfo.fContentMin = rcScroll.bottom; |
| 158 sInfo.fContentMax = rcScroll.top; | 158 sInfo.fContentMax = rcScroll.top; |
| 159 sInfo.fPlateWidth = GetClientRect().Height(); | 159 sInfo.fPlateWidth = GetClientRect().Height(); |
| 160 sInfo.fSmallStep = 13.0f; | 160 sInfo.fSmallStep = 13.0f; |
| 161 sInfo.fBigStep = sInfo.fPlateWidth; | 161 sInfo.fBigStep = sInfo.fPlateWidth; |
| 162 | 162 |
| 163 pParent->OnNotify(this, PNM_SETSCROLLINFO, SBT_VSCROLL, (intptr_t)&sInfo); | 163 pParent->OnNotify(this, PNM_SETSCROLLINFO, SBT_VSCROLL, (intptr_t)&sInfo); |
| 164 } | 164 } |
| 165 } | 165 } |
| 166 | 166 |
| 167 FX_BOOL CPWL_IconList_Content::OnLButtonDown(const CFX_FloatPoint& point, | 167 FX_BOOL CPWL_IconList_Content::OnLButtonDown(const CPDF_Point& point, |
| 168 FX_DWORD nFlag) { | 168 FX_DWORD nFlag) { |
| 169 SetFocus(); | 169 SetFocus(); |
| 170 | 170 |
| 171 SetCapture(); | 171 SetCapture(); |
| 172 m_bMouseDown = TRUE; | 172 m_bMouseDown = TRUE; |
| 173 | 173 |
| 174 int32_t nItemIndex = FindItemIndex(point); | 174 int32_t nItemIndex = FindItemIndex(point); |
| 175 SetSelect(nItemIndex); | 175 SetSelect(nItemIndex); |
| 176 ScrollToItem(nItemIndex); | 176 ScrollToItem(nItemIndex); |
| 177 | 177 |
| 178 return TRUE; | 178 return TRUE; |
| 179 } | 179 } |
| 180 | 180 |
| 181 FX_BOOL CPWL_IconList_Content::OnLButtonUp(const CFX_FloatPoint& point, | 181 FX_BOOL CPWL_IconList_Content::OnLButtonUp(const CPDF_Point& point, |
| 182 FX_DWORD nFlag) { | 182 FX_DWORD nFlag) { |
| 183 m_bMouseDown = FALSE; | 183 m_bMouseDown = FALSE; |
| 184 ReleaseCapture(); | 184 ReleaseCapture(); |
| 185 | 185 |
| 186 return TRUE; | 186 return TRUE; |
| 187 } | 187 } |
| 188 | 188 |
| 189 FX_BOOL CPWL_IconList_Content::OnMouseMove(const CFX_FloatPoint& point, | 189 FX_BOOL CPWL_IconList_Content::OnMouseMove(const CPDF_Point& point, |
| 190 FX_DWORD nFlag) { | 190 FX_DWORD nFlag) { |
| 191 if (m_bMouseDown) { | 191 if (m_bMouseDown) { |
| 192 int32_t nItemIndex = FindItemIndex(point); | 192 int32_t nItemIndex = FindItemIndex(point); |
| 193 SetSelect(nItemIndex); | 193 SetSelect(nItemIndex); |
| 194 ScrollToItem(nItemIndex); | 194 ScrollToItem(nItemIndex); |
| 195 } | 195 } |
| 196 | 196 |
| 197 return TRUE; | 197 return TRUE; |
| 198 } | 198 } |
| 199 | 199 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 211 int32_t nItemIndex = m_nSelectIndex + 1; | 211 int32_t nItemIndex = m_nSelectIndex + 1; |
| 212 SetSelect(nItemIndex); | 212 SetSelect(nItemIndex); |
| 213 ScrollToItem(nItemIndex); | 213 ScrollToItem(nItemIndex); |
| 214 } | 214 } |
| 215 return TRUE; | 215 return TRUE; |
| 216 } | 216 } |
| 217 | 217 |
| 218 return FALSE; | 218 return FALSE; |
| 219 } | 219 } |
| 220 | 220 |
| 221 int32_t CPWL_IconList_Content::FindItemIndex(const CFX_FloatPoint& point) { | 221 int32_t CPWL_IconList_Content::FindItemIndex(const CPDF_Point& point) { |
| 222 int32_t nIndex = 0; | 222 int32_t nIndex = 0; |
| 223 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { | 223 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { |
| 224 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { | 224 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { |
| 225 CFX_FloatRect rcWnd = pChild->ChildToParent(pChild->GetWindowRect()); | 225 CPDF_Rect rcWnd = pChild->ChildToParent(pChild->GetWindowRect()); |
| 226 | 226 |
| 227 if (point.y < rcWnd.top) { | 227 if (point.y < rcWnd.top) { |
| 228 nIndex = i; | 228 nIndex = i; |
| 229 } | 229 } |
| 230 } | 230 } |
| 231 } | 231 } |
| 232 | 232 |
| 233 return nIndex; | 233 return nIndex; |
| 234 } | 234 } |
| 235 | 235 |
| 236 void CPWL_IconList_Content::ScrollToItem(int32_t nItemIndex) { | 236 void CPWL_IconList_Content::ScrollToItem(int32_t nItemIndex) { |
| 237 CFX_FloatRect rcClient = GetClientRect(); | 237 CPDF_Rect rcClient = GetClientRect(); |
| 238 | 238 |
| 239 if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex)) { | 239 if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex)) { |
| 240 CFX_FloatRect rcOrigin = pItem->GetWindowRect(); | 240 CPDF_Rect rcOrigin = pItem->GetWindowRect(); |
| 241 CFX_FloatRect rcWnd = pItem->ChildToParent(rcOrigin); | 241 CPDF_Rect rcWnd = pItem->ChildToParent(rcOrigin); |
| 242 | 242 |
| 243 if (!(rcWnd.bottom > rcClient.bottom && rcWnd.top < rcClient.top)) { | 243 if (!(rcWnd.bottom > rcClient.bottom && rcWnd.top < rcClient.top)) { |
| 244 CFX_FloatPoint ptScroll = GetScrollPos(); | 244 CPDF_Point ptScroll = GetScrollPos(); |
| 245 | 245 |
| 246 if (rcWnd.top > rcClient.top) { | 246 if (rcWnd.top > rcClient.top) { |
| 247 ptScroll.y = rcOrigin.top; | 247 ptScroll.y = rcOrigin.top; |
| 248 } else if (rcWnd.bottom < rcClient.bottom) { | 248 } else if (rcWnd.bottom < rcClient.bottom) { |
| 249 ptScroll.y = rcOrigin.bottom + rcClient.Height(); | 249 ptScroll.y = rcOrigin.bottom + rcClient.Height(); |
| 250 } | 250 } |
| 251 | 251 |
| 252 SetScrollPos(ptScroll); | 252 SetScrollPos(ptScroll); |
| 253 ResetFace(); | 253 ResetFace(); |
| 254 InvalidateRect(); | 254 InvalidateRect(); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 RePosChildWnd(); | 391 RePosChildWnd(); |
| 392 } else { | 392 } else { |
| 393 } | 393 } |
| 394 } else { | 394 } else { |
| 395 if (pScrollBar->IsVisible()) { | 395 if (pScrollBar->IsVisible()) { |
| 396 pScrollBar->SetVisible(FALSE); | 396 pScrollBar->SetVisible(FALSE); |
| 397 RePosChildWnd(); | 397 RePosChildWnd(); |
| 398 } | 398 } |
| 399 | 399 |
| 400 if (m_pListContent) | 400 if (m_pListContent) |
| 401 m_pListContent->SetScrollPos(CFX_FloatPoint(0.0f, 0.0f)); | 401 m_pListContent->SetScrollPos(CPDF_Point(0.0f, 0.0f)); |
| 402 } | 402 } |
| 403 | 403 |
| 404 pScrollBar->OnNotify(pWnd, PNM_SETSCROLLINFO, wParam, lParam); | 404 pScrollBar->OnNotify(pWnd, PNM_SETSCROLLINFO, wParam, lParam); |
| 405 } | 405 } |
| 406 } | 406 } |
| 407 return; | 407 return; |
| 408 case PNM_SCROLLWINDOW: | 408 case PNM_SCROLLWINDOW: |
| 409 if (m_pListContent) { | 409 if (m_pListContent) { |
| 410 m_pListContent->SetScrollPos( | 410 m_pListContent->SetScrollPos(CPDF_Point(0.0f, *(FX_FLOAT*)lParam)); |
| 411 CFX_FloatPoint(0.0f, *(FX_FLOAT*)lParam)); | |
| 412 m_pListContent->ResetFace(); | 411 m_pListContent->ResetFace(); |
| 413 m_pListContent->InvalidateRect(NULL); | 412 m_pListContent->InvalidateRect(NULL); |
| 414 } | 413 } |
| 415 return; | 414 return; |
| 416 case PNM_SETSCROLLPOS: | 415 case PNM_SETSCROLLPOS: |
| 417 if (CPWL_ScrollBar* pScrollBar = GetVScrollBar()) | 416 if (CPWL_ScrollBar* pScrollBar = GetVScrollBar()) |
| 418 pScrollBar->OnNotify(pWnd, PNM_SETSCROLLPOS, wParam, lParam); | 417 pScrollBar->OnNotify(pWnd, PNM_SETSCROLLPOS, wParam, lParam); |
| 419 return; | 418 return; |
| 420 } | 419 } |
| 421 } | 420 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 | 455 |
| 457 CFX_WideString CPWL_IconList::GetListString(int32_t nItemIndex) const { | 456 CFX_WideString CPWL_IconList::GetListString(int32_t nItemIndex) const { |
| 458 return m_pListContent->GetListString(nItemIndex); | 457 return m_pListContent->GetListString(nItemIndex); |
| 459 } | 458 } |
| 460 | 459 |
| 461 void CPWL_IconList::SetIconFillColor(const CPWL_Color& color) { | 460 void CPWL_IconList::SetIconFillColor(const CPWL_Color& color) { |
| 462 m_pListContent->SetIconFillColor(color); | 461 m_pListContent->SetIconFillColor(color); |
| 463 } | 462 } |
| 464 | 463 |
| 465 FX_BOOL CPWL_IconList::OnMouseWheel(short zDelta, | 464 FX_BOOL CPWL_IconList::OnMouseWheel(short zDelta, |
| 466 const CFX_FloatPoint& point, | 465 const CPDF_Point& point, |
| 467 FX_DWORD nFlag) { | 466 FX_DWORD nFlag) { |
| 468 CFX_FloatPoint ptScroll = m_pListContent->GetScrollPos(); | 467 CPDF_Point ptScroll = m_pListContent->GetScrollPos(); |
| 469 CFX_FloatRect rcScroll = m_pListContent->GetScrollArea(); | 468 CPDF_Rect rcScroll = m_pListContent->GetScrollArea(); |
| 470 CFX_FloatRect rcContents = m_pListContent->GetClientRect(); | 469 CPDF_Rect rcContents = m_pListContent->GetClientRect(); |
| 471 | 470 |
| 472 if (rcScroll.top - rcScroll.bottom > rcContents.Height()) { | 471 if (rcScroll.top - rcScroll.bottom > rcContents.Height()) { |
| 473 CFX_FloatPoint ptNew = ptScroll; | 472 CPDF_Point ptNew = ptScroll; |
| 474 | 473 |
| 475 if (zDelta > 0) | 474 if (zDelta > 0) |
| 476 ptNew.y += 30; | 475 ptNew.y += 30; |
| 477 else | 476 else |
| 478 ptNew.y -= 30; | 477 ptNew.y -= 30; |
| 479 | 478 |
| 480 if (ptNew.y > rcScroll.top) | 479 if (ptNew.y > rcScroll.top) |
| 481 ptNew.y = rcScroll.top; | 480 ptNew.y = rcScroll.top; |
| 482 if (ptNew.y < rcScroll.bottom + rcContents.Height()) | 481 if (ptNew.y < rcScroll.bottom + rcContents.Height()) |
| 483 ptNew.y = rcScroll.bottom + rcContents.Height(); | 482 ptNew.y = rcScroll.bottom + rcContents.Height(); |
| 484 if (ptNew.y < rcScroll.bottom) | 483 if (ptNew.y < rcScroll.bottom) |
| 485 ptNew.y = rcScroll.bottom; | 484 ptNew.y = rcScroll.bottom; |
| 486 | 485 |
| 487 if (ptNew.y != ptScroll.y) { | 486 if (ptNew.y != ptScroll.y) { |
| 488 m_pListContent->SetScrollPos(ptNew); | 487 m_pListContent->SetScrollPos(ptNew); |
| 489 m_pListContent->ResetFace(); | 488 m_pListContent->ResetFace(); |
| 490 m_pListContent->InvalidateRect(NULL); | 489 m_pListContent->InvalidateRect(NULL); |
| 491 | 490 |
| 492 if (CPWL_ScrollBar* pScrollBar = GetVScrollBar()) | 491 if (CPWL_ScrollBar* pScrollBar = GetVScrollBar()) |
| 493 pScrollBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, | 492 pScrollBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, |
| 494 (intptr_t)&ptNew.y); | 493 (intptr_t)&ptNew.y); |
| 495 | 494 |
| 496 return TRUE; | 495 return TRUE; |
| 497 } | 496 } |
| 498 } | 497 } |
| 499 | 498 |
| 500 return FALSE; | 499 return FALSE; |
| 501 } | 500 } |
| OLD | NEW |