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/pdfwindow/PWL_IconList.h" | 7 #include "fpdfsdk/pdfwindow/PWL_IconList.h" |
8 | 8 |
9 #include "fpdfsdk/pdfwindow/PWL_Label.h" | 9 #include "fpdfsdk/pdfwindow/PWL_Label.h" |
10 #include "fpdfsdk/pdfwindow/PWL_ListCtrl.h" | 10 #include "fpdfsdk/pdfwindow/PWL_ListCtrl.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 } | 122 } |
123 | 123 |
124 void CPWL_IconList_Item::OnDisabled() { | 124 void CPWL_IconList_Item::OnDisabled() { |
125 m_pText->SetTextColor(PWL_DEFAULT_HEAVYGRAYCOLOR); | 125 m_pText->SetTextColor(PWL_DEFAULT_HEAVYGRAYCOLOR); |
126 | 126 |
127 InvalidateRect(); | 127 InvalidateRect(); |
128 } | 128 } |
129 | 129 |
130 CPWL_IconList_Content::CPWL_IconList_Content(int32_t nListCount) | 130 CPWL_IconList_Content::CPWL_IconList_Content(int32_t nListCount) |
131 : m_nSelectIndex(-1), | 131 : m_nSelectIndex(-1), |
132 m_pNotify(NULL), | |
133 m_bEnableNotify(TRUE), | |
134 m_bMouseDown(FALSE), | 132 m_bMouseDown(FALSE), |
135 m_nListCount(nListCount) {} | 133 m_nListCount(nListCount) {} |
136 | 134 |
137 CPWL_IconList_Content::~CPWL_IconList_Content() {} | 135 CPWL_IconList_Content::~CPWL_IconList_Content() {} |
138 | 136 |
139 void CPWL_IconList_Content::CreateChildWnd(const PWL_CREATEPARAM& cp) { | 137 void CPWL_IconList_Content::CreateChildWnd(const PWL_CREATEPARAM& cp) { |
140 for (int32_t i = 0; i < m_nListCount; i++) { | 138 for (int32_t i = 0; i < m_nListCount; i++) { |
141 CPWL_IconList_Item* pNewItem = new CPWL_IconList_Item(); | 139 CPWL_IconList_Item* pNewItem = new CPWL_IconList_Item(); |
142 | 140 |
143 PWL_CREATEPARAM icp = cp; | 141 PWL_CREATEPARAM icp = cp; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 InvalidateRect(); | 252 InvalidateRect(); |
255 if (CPWL_Wnd* pParent = GetParentWindow()) { | 253 if (CPWL_Wnd* pParent = GetParentWindow()) { |
256 pParent->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, | 254 pParent->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, |
257 (intptr_t)&ptScroll.y); | 255 (intptr_t)&ptScroll.y); |
258 } | 256 } |
259 } | 257 } |
260 } | 258 } |
261 } | 259 } |
262 | 260 |
263 void CPWL_IconList_Content::SetSelect(int32_t nIndex) { | 261 void CPWL_IconList_Content::SetSelect(int32_t nIndex) { |
264 if (m_nSelectIndex != nIndex) { | 262 if (m_nSelectIndex == nIndex) |
265 SelectItem(m_nSelectIndex, FALSE); | 263 return; |
266 SelectItem(nIndex, TRUE); | |
267 m_nSelectIndex = nIndex; | |
268 | 264 |
269 if (IPWL_IconList_Notify* pNotify = GetNotify()) | 265 SelectItem(m_nSelectIndex, FALSE); |
270 pNotify->OnNoteListSelChanged(nIndex); | 266 SelectItem(nIndex, TRUE); |
271 } | 267 m_nSelectIndex = nIndex; |
272 } | 268 } |
273 | 269 |
274 int32_t CPWL_IconList_Content::GetSelect() const { | 270 int32_t CPWL_IconList_Content::GetSelect() const { |
275 return m_nSelectIndex; | 271 return m_nSelectIndex; |
276 } | 272 } |
277 | 273 |
278 IPWL_IconList_Notify* CPWL_IconList_Content::GetNotify() const { | |
279 if (m_bEnableNotify) | |
280 return m_pNotify; | |
281 return NULL; | |
282 } | |
283 | |
284 void CPWL_IconList_Content::SetNotify(IPWL_IconList_Notify* pNotify) { | |
285 m_pNotify = pNotify; | |
286 } | |
287 | |
288 void CPWL_IconList_Content::EnableNotify(FX_BOOL bNotify) { | |
289 m_bEnableNotify = bNotify; | |
290 } | |
291 | |
292 void CPWL_IconList_Content::SelectItem(int32_t nItemIndex, FX_BOOL bSelect) { | 274 void CPWL_IconList_Content::SelectItem(int32_t nItemIndex, FX_BOOL bSelect) { |
293 if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex)) { | 275 if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex)) { |
294 pItem->SetSelect(bSelect); | 276 pItem->SetSelect(bSelect); |
295 pItem->InvalidateRect(); | 277 pItem->InvalidateRect(); |
296 } | 278 } |
297 } | 279 } |
298 | 280 |
299 CPWL_IconList_Item* CPWL_IconList_Content::GetListItem( | 281 CPWL_IconList_Item* CPWL_IconList_Content::GetListItem( |
300 int32_t nItemIndex) const { | 282 int32_t nItemIndex) const { |
301 if (nItemIndex >= 0 && nItemIndex < m_aChildren.GetSize()) { | 283 if (nItemIndex >= 0 && nItemIndex < m_aChildren.GetSize()) { |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 } | 408 } |
427 | 409 |
428 void CPWL_IconList::SetTopItem(int32_t nIndex) { | 410 void CPWL_IconList::SetTopItem(int32_t nIndex) { |
429 m_pListContent->ScrollToItem(nIndex); | 411 m_pListContent->ScrollToItem(nIndex); |
430 } | 412 } |
431 | 413 |
432 int32_t CPWL_IconList::GetSelect() const { | 414 int32_t CPWL_IconList::GetSelect() const { |
433 return m_pListContent->GetSelect(); | 415 return m_pListContent->GetSelect(); |
434 } | 416 } |
435 | 417 |
436 void CPWL_IconList::SetNotify(IPWL_IconList_Notify* pNotify) { | |
437 m_pListContent->SetNotify(pNotify); | |
438 } | |
439 | |
440 void CPWL_IconList::EnableNotify(FX_BOOL bNotify) { | |
441 m_pListContent->EnableNotify(bNotify); | |
442 } | |
443 | |
444 void CPWL_IconList::SetListData(int32_t nItemIndex, void* pData) { | 418 void CPWL_IconList::SetListData(int32_t nItemIndex, void* pData) { |
445 m_pListContent->SetListData(nItemIndex, pData); | 419 m_pListContent->SetListData(nItemIndex, pData); |
446 } | 420 } |
447 | 421 |
448 void CPWL_IconList::SetListIcon(int32_t nItemIndex, int32_t nIconIndex) { | 422 void CPWL_IconList::SetListIcon(int32_t nItemIndex, int32_t nIconIndex) { |
449 m_pListContent->SetListIcon(nItemIndex, nIconIndex); | 423 m_pListContent->SetListIcon(nItemIndex, nIconIndex); |
450 } | 424 } |
451 | 425 |
452 void CPWL_IconList::SetListString(int32_t nItemIndex, | 426 void CPWL_IconList::SetListString(int32_t nItemIndex, |
453 const CFX_WideString& str) { | 427 const CFX_WideString& str) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 if (CPWL_ScrollBar* pScrollBar = GetVScrollBar()) | 466 if (CPWL_ScrollBar* pScrollBar = GetVScrollBar()) |
493 pScrollBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, | 467 pScrollBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, |
494 (intptr_t)&ptNew.y); | 468 (intptr_t)&ptNew.y); |
495 | 469 |
496 return TRUE; | 470 return TRUE; |
497 } | 471 } |
498 } | 472 } |
499 | 473 |
500 return FALSE; | 474 return FALSE; |
501 } | 475 } |
OLD | NEW |