| 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/PDFWindow.h" | 7 #include "fpdfsdk/include/pdfwindow/PWL_ListBox.h" |
| 8 |
| 8 #include "fpdfsdk/include/pdfwindow/PWL_Edit.h" | 9 #include "fpdfsdk/include/pdfwindow/PWL_Edit.h" |
| 9 #include "fpdfsdk/include/pdfwindow/PWL_EditCtrl.h" | 10 #include "fpdfsdk/include/pdfwindow/PWL_EditCtrl.h" |
| 10 #include "fpdfsdk/include/pdfwindow/PWL_ListBox.h" | |
| 11 #include "fpdfsdk/include/pdfwindow/PWL_ScrollBar.h" | 11 #include "fpdfsdk/include/pdfwindow/PWL_ScrollBar.h" |
| 12 #include "fpdfsdk/include/pdfwindow/PWL_Utils.h" | 12 #include "fpdfsdk/include/pdfwindow/PWL_Utils.h" |
| 13 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h" | 13 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h" |
| 14 #include "public/fpdf_fwlevent.h" |
| 14 | 15 |
| 15 #define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001) | 16 #define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001) |
| 16 #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) | 17 #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) |
| 17 #define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb))) | 18 #define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb))) |
| 18 #define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb)) | 19 #define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb)) |
| 19 | 20 |
| 20 /* ------------------------ CPWL_List_Notify ----------------------- */ | |
| 21 | |
| 22 CPWL_List_Notify::CPWL_List_Notify(CPWL_ListBox* pList) : m_pList(pList) { | 21 CPWL_List_Notify::CPWL_List_Notify(CPWL_ListBox* pList) : m_pList(pList) { |
| 23 ASSERT(m_pList); | 22 ASSERT(m_pList); |
| 24 } | 23 } |
| 25 | 24 |
| 26 CPWL_List_Notify::~CPWL_List_Notify() {} | 25 CPWL_List_Notify::~CPWL_List_Notify() {} |
| 27 | 26 |
| 28 void CPWL_List_Notify::IOnSetScrollInfoY(FX_FLOAT fPlateMin, | 27 void CPWL_List_Notify::IOnSetScrollInfoY(FX_FLOAT fPlateMin, |
| 29 FX_FLOAT fPlateMax, | 28 FX_FLOAT fPlateMax, |
| 30 FX_FLOAT fContentMin, | 29 FX_FLOAT fContentMin, |
| 31 FX_FLOAT fContentMax, | 30 FX_FLOAT fContentMax, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 58 } | 57 } |
| 59 | 58 |
| 60 void CPWL_List_Notify::IOnSetScrollPosY(FX_FLOAT fy) { | 59 void CPWL_List_Notify::IOnSetScrollPosY(FX_FLOAT fy) { |
| 61 m_pList->OnNotify(m_pList, PNM_SETSCROLLPOS, SBT_VSCROLL, (intptr_t)&fy); | 60 m_pList->OnNotify(m_pList, PNM_SETSCROLLPOS, SBT_VSCROLL, (intptr_t)&fy); |
| 62 } | 61 } |
| 63 | 62 |
| 64 void CPWL_List_Notify::IOnInvalidateRect(CPDF_Rect* pRect) { | 63 void CPWL_List_Notify::IOnInvalidateRect(CPDF_Rect* pRect) { |
| 65 m_pList->InvalidateRect(pRect); | 64 m_pList->InvalidateRect(pRect); |
| 66 } | 65 } |
| 67 | 66 |
| 68 /* --------------------------- CPWL_ListBox ---------------------------- */ | |
| 69 | |
| 70 CPWL_ListBox::CPWL_ListBox() | 67 CPWL_ListBox::CPWL_ListBox() |
| 71 : m_pList(NULL), | 68 : m_pList(NULL), |
| 72 m_pListNotify(NULL), | 69 m_pListNotify(NULL), |
| 73 m_bMouseDown(FALSE), | 70 m_bMouseDown(FALSE), |
| 74 m_bHoverSel(FALSE), | 71 m_bHoverSel(FALSE), |
| 75 m_pFillerNotify(NULL) { | 72 m_pFillerNotify(NULL) { |
| 76 m_pList = IFX_List::NewList(); | 73 m_pList = IFX_List::NewList(); |
| 77 } | 74 } |
| 78 | 75 |
| 79 CPWL_ListBox::~CPWL_ListBox() { | 76 CPWL_ListBox::~CPWL_ListBox() { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 CPDF_Point ptOffset(rcItem.left, (rcItem.top + rcItem.bottom) * 0.5f); | 170 CPDF_Point ptOffset(rcItem.left, (rcItem.top + rcItem.bottom) * 0.5f); |
| 174 if (IFX_Edit* pEdit = m_pList->GetItemEdit(i)) { | 171 if (IFX_Edit* pEdit = m_pList->GetItemEdit(i)) { |
| 175 CPDF_Rect rcContent = pEdit->GetContentRect(); | 172 CPDF_Rect rcContent = pEdit->GetContentRect(); |
| 176 if (rcContent.Width() > rcClient.Width()) | 173 if (rcContent.Width() > rcClient.Width()) |
| 177 rcItem.Intersect(rcList); | 174 rcItem.Intersect(rcList); |
| 178 else | 175 else |
| 179 rcItem.Intersect(rcClient); | 176 rcItem.Intersect(rcClient); |
| 180 } | 177 } |
| 181 | 178 |
| 182 if (m_pList->IsItemSelected(i)) { | 179 if (m_pList->IsItemSelected(i)) { |
| 183 // CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcItem, | |
| 184 // ArgbEncode(255,0,51,113)); | |
| 185 IFX_SystemHandler* pSysHandler = GetSystemHandler(); | 180 IFX_SystemHandler* pSysHandler = GetSystemHandler(); |
| 186 if (pSysHandler && pSysHandler->IsSelectionImplemented()) { | 181 if (pSysHandler && pSysHandler->IsSelectionImplemented()) { |
| 187 IFX_Edit::DrawEdit( | 182 IFX_Edit::DrawEdit( |
| 188 pDevice, pUser2Device, m_pList->GetItemEdit(i), | 183 pDevice, pUser2Device, m_pList->GetItemEdit(i), |
| 189 CPWL_Utils::PWLColorToFXColor(GetTextColor()), | 184 CPWL_Utils::PWLColorToFXColor(GetTextColor()), |
| 190 CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor()), rcList, | 185 CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor()), rcList, |
| 191 ptOffset, NULL, pSysHandler, m_pFormFiller); | 186 ptOffset, NULL, pSysHandler, m_pFormFiller); |
| 192 pSysHandler->OutputSelectedRect(m_pFormFiller, rcItem); | 187 pSysHandler->OutputSelectedRect(m_pFormFiller, rcItem); |
| 193 } else { | 188 } else { |
| 194 CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcItem, | 189 CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcItem, |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 if (zDelta < 0) { | 523 if (zDelta < 0) { |
| 529 m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); | 524 m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
| 530 } else { | 525 } else { |
| 531 m_pList->OnVK_UP(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); | 526 m_pList->OnVK_UP(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
| 532 } | 527 } |
| 533 | 528 |
| 534 FX_BOOL bExit = FALSE; | 529 FX_BOOL bExit = FALSE; |
| 535 OnNotifySelChanged(FALSE, bExit, nFlag); | 530 OnNotifySelChanged(FALSE, bExit, nFlag); |
| 536 return TRUE; | 531 return TRUE; |
| 537 } | 532 } |
| OLD | NEW |