| 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 <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "fpdfsdk/include/pdfwindow/PDFWindow.h" | |
| 10 #include "fpdfsdk/include/pdfwindow/PWL_ScrollBar.h" | 9 #include "fpdfsdk/include/pdfwindow/PWL_ScrollBar.h" |
| 11 #include "fpdfsdk/include/pdfwindow/PWL_Utils.h" | 10 #include "fpdfsdk/include/pdfwindow/PWL_Utils.h" |
| 12 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h" | 11 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h" |
| 13 | 12 |
| 14 /* -------------------------- CPWL_Timer -------------------------- */ | |
| 15 | |
| 16 static std::map<int32_t, CPWL_Timer*>& GetPWLTimeMap() { | 13 static std::map<int32_t, CPWL_Timer*>& GetPWLTimeMap() { |
| 17 // Leak the object at shutdown. | 14 // Leak the object at shutdown. |
| 18 static auto timeMap = new std::map<int32_t, CPWL_Timer*>; | 15 static auto timeMap = new std::map<int32_t, CPWL_Timer*>; |
| 19 return *timeMap; | 16 return *timeMap; |
| 20 } | 17 } |
| 21 | 18 |
| 22 CPWL_Timer::CPWL_Timer(CPWL_TimerHandler* pAttached, | 19 CPWL_Timer::CPWL_Timer(CPWL_TimerHandler* pAttached, |
| 23 IFX_SystemHandler* pSystemHandler) | 20 IFX_SystemHandler* pSystemHandler) |
| 24 : m_nTimerID(0), m_pAttached(pAttached), m_pSystemHandler(pSystemHandler) { | 21 : m_nTimerID(0), m_pAttached(pAttached), m_pSystemHandler(pSystemHandler) { |
| 25 ASSERT(m_pAttached); | 22 ASSERT(m_pAttached); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 51 void CPWL_Timer::TimerProc(int32_t idEvent) { | 48 void CPWL_Timer::TimerProc(int32_t idEvent) { |
| 52 auto it = GetPWLTimeMap().find(idEvent); | 49 auto it = GetPWLTimeMap().find(idEvent); |
| 53 if (it == GetPWLTimeMap().end()) | 50 if (it == GetPWLTimeMap().end()) |
| 54 return; | 51 return; |
| 55 | 52 |
| 56 CPWL_Timer* pTimer = it->second; | 53 CPWL_Timer* pTimer = it->second; |
| 57 if (pTimer->m_pAttached) | 54 if (pTimer->m_pAttached) |
| 58 pTimer->m_pAttached->TimerProc(); | 55 pTimer->m_pAttached->TimerProc(); |
| 59 } | 56 } |
| 60 | 57 |
| 61 /* -------------------------- CPWL_TimerHandler -------------------------- */ | |
| 62 | |
| 63 CPWL_TimerHandler::CPWL_TimerHandler() : m_pTimer(NULL) {} | 58 CPWL_TimerHandler::CPWL_TimerHandler() : m_pTimer(NULL) {} |
| 64 | 59 |
| 65 CPWL_TimerHandler::~CPWL_TimerHandler() { | 60 CPWL_TimerHandler::~CPWL_TimerHandler() { |
| 66 delete m_pTimer; | 61 delete m_pTimer; |
| 67 } | 62 } |
| 68 | 63 |
| 69 void CPWL_TimerHandler::BeginTimer(int32_t nElapse) { | 64 void CPWL_TimerHandler::BeginTimer(int32_t nElapse) { |
| 70 if (!m_pTimer) | 65 if (!m_pTimer) |
| 71 m_pTimer = new CPWL_Timer(this, GetSystemHandler()); | 66 m_pTimer = new CPWL_Timer(this, GetSystemHandler()); |
| 72 | 67 |
| 73 if (m_pTimer) | 68 if (m_pTimer) |
| 74 m_pTimer->SetPWLTimer(nElapse); | 69 m_pTimer->SetPWLTimer(nElapse); |
| 75 } | 70 } |
| 76 | 71 |
| 77 void CPWL_TimerHandler::EndTimer() { | 72 void CPWL_TimerHandler::EndTimer() { |
| 78 if (m_pTimer) | 73 if (m_pTimer) |
| 79 m_pTimer->KillPWLTimer(); | 74 m_pTimer->KillPWLTimer(); |
| 80 } | 75 } |
| 81 | 76 |
| 82 void CPWL_TimerHandler::TimerProc() {} | 77 void CPWL_TimerHandler::TimerProc() {} |
| 83 | 78 |
| 84 /* --------------------------- CPWL_MsgControl ---------------------------- */ | |
| 85 | |
| 86 class CPWL_MsgControl { | 79 class CPWL_MsgControl { |
| 87 friend class CPWL_Wnd; | 80 friend class CPWL_Wnd; |
| 88 | 81 |
| 89 public: | 82 public: |
| 90 CPWL_MsgControl(CPWL_Wnd* pWnd) { | 83 explicit CPWL_MsgControl(CPWL_Wnd* pWnd) { |
| 91 // PWL_TRACE("new CPWL_MsgControl\n"); | |
| 92 m_pCreatedWnd = pWnd; | 84 m_pCreatedWnd = pWnd; |
| 93 Default(); | 85 Default(); |
| 94 } | 86 } |
| 95 | 87 |
| 96 ~CPWL_MsgControl() { | 88 ~CPWL_MsgControl() { |
| 97 // PWL_TRACE("~CPWL_MsgControl\n"); | |
| 98 Default(); | 89 Default(); |
| 99 } | 90 } |
| 100 | 91 |
| 101 void Default() { | 92 void Default() { |
| 102 m_aMousePath.RemoveAll(); | 93 m_aMousePath.RemoveAll(); |
| 103 m_aKeyboardPath.RemoveAll(); | 94 m_aKeyboardPath.RemoveAll(); |
| 104 m_pMainMouseWnd = NULL; | 95 m_pMainMouseWnd = NULL; |
| 105 m_pMainKeyboardWnd = NULL; | 96 m_pMainKeyboardWnd = NULL; |
| 106 } | 97 } |
| 107 | 98 |
| 108 FX_BOOL IsWndCreated(const CPWL_Wnd* pWnd) const { | 99 FX_BOOL IsWndCreated(const CPWL_Wnd* pWnd) const { |
| 109 return m_pCreatedWnd == pWnd; | 100 return m_pCreatedWnd == pWnd; |
| 110 } | 101 } |
| 111 | 102 |
| 112 FX_BOOL IsMainCaptureMouse(const CPWL_Wnd* pWnd) const { | 103 FX_BOOL IsMainCaptureMouse(const CPWL_Wnd* pWnd) const { |
| 113 return pWnd == m_pMainMouseWnd; | 104 return pWnd == m_pMainMouseWnd; |
| 114 } | 105 } |
| 115 | 106 |
| 116 FX_BOOL IsWndCaptureMouse(const CPWL_Wnd* pWnd) const { | 107 FX_BOOL IsWndCaptureMouse(const CPWL_Wnd* pWnd) const { |
| 117 if (pWnd) | 108 if (pWnd) { |
| 118 for (int32_t i = 0, sz = m_aMousePath.GetSize(); i < sz; i++) | 109 for (int32_t i = 0, sz = m_aMousePath.GetSize(); i < sz; i++) { |
| 119 if (m_aMousePath.GetAt(i) == pWnd) | 110 if (m_aMousePath.GetAt(i) == pWnd) |
| 120 return TRUE; | 111 return TRUE; |
| 112 } |
| 113 } |
| 121 | 114 |
| 122 return FALSE; | 115 return FALSE; |
| 123 } | 116 } |
| 124 | 117 |
| 125 FX_BOOL IsMainCaptureKeyboard(const CPWL_Wnd* pWnd) const { | 118 FX_BOOL IsMainCaptureKeyboard(const CPWL_Wnd* pWnd) const { |
| 126 return pWnd == m_pMainKeyboardWnd; | 119 return pWnd == m_pMainKeyboardWnd; |
| 127 } | 120 } |
| 128 | 121 |
| 129 FX_BOOL IsWndCaptureKeyboard(const CPWL_Wnd* pWnd) const { | 122 FX_BOOL IsWndCaptureKeyboard(const CPWL_Wnd* pWnd) const { |
| 130 if (pWnd) | 123 if (pWnd) { |
| 131 for (int32_t i = 0, sz = m_aKeyboardPath.GetSize(); i < sz; i++) | 124 for (int32_t i = 0, sz = m_aKeyboardPath.GetSize(); i < sz; i++) { |
| 132 if (m_aKeyboardPath.GetAt(i) == pWnd) | 125 if (m_aKeyboardPath.GetAt(i) == pWnd) |
| 133 return TRUE; | 126 return TRUE; |
| 127 } |
| 128 } |
| 134 | 129 |
| 135 return FALSE; | 130 return FALSE; |
| 136 } | 131 } |
| 137 | 132 |
| 138 void SetFocus(CPWL_Wnd* pWnd) { | 133 void SetFocus(CPWL_Wnd* pWnd) { |
| 139 m_aKeyboardPath.RemoveAll(); | 134 m_aKeyboardPath.RemoveAll(); |
| 140 | 135 |
| 141 if (pWnd) { | 136 if (pWnd) { |
| 142 m_pMainKeyboardWnd = pWnd; | 137 m_pMainKeyboardWnd = pWnd; |
| 143 | 138 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 } | 175 } |
| 181 | 176 |
| 182 private: | 177 private: |
| 183 CFX_ArrayTemplate<CPWL_Wnd*> m_aMousePath; | 178 CFX_ArrayTemplate<CPWL_Wnd*> m_aMousePath; |
| 184 CFX_ArrayTemplate<CPWL_Wnd*> m_aKeyboardPath; | 179 CFX_ArrayTemplate<CPWL_Wnd*> m_aKeyboardPath; |
| 185 CPWL_Wnd* m_pCreatedWnd; | 180 CPWL_Wnd* m_pCreatedWnd; |
| 186 CPWL_Wnd* m_pMainMouseWnd; | 181 CPWL_Wnd* m_pMainMouseWnd; |
| 187 CPWL_Wnd* m_pMainKeyboardWnd; | 182 CPWL_Wnd* m_pMainKeyboardWnd; |
| 188 }; | 183 }; |
| 189 | 184 |
| 190 /* --------------------------- CPWL_Wnd ---------------------------- */ | |
| 191 | |
| 192 CPWL_Wnd::CPWL_Wnd() | 185 CPWL_Wnd::CPWL_Wnd() |
| 193 : m_pVScrollBar(NULL), | 186 : m_pVScrollBar(NULL), |
| 194 m_rcWindow(), | 187 m_rcWindow(), |
| 195 m_rcClip(), | 188 m_rcClip(), |
| 196 m_bCreated(FALSE), | 189 m_bCreated(FALSE), |
| 197 m_bVisible(FALSE), | 190 m_bVisible(FALSE), |
| 198 m_bNotifying(FALSE), | 191 m_bNotifying(FALSE), |
| 199 m_bEnabled(TRUE) {} | 192 m_bEnabled(TRUE) {} |
| 200 | 193 |
| 201 CPWL_Wnd::~CPWL_Wnd() { | 194 CPWL_Wnd::~CPWL_Wnd() { |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 } | 606 } |
| 614 | 607 |
| 615 int32_t CPWL_Wnd::GetBorderWidth() const { | 608 int32_t CPWL_Wnd::GetBorderWidth() const { |
| 616 if (HasFlag(PWS_BORDER)) | 609 if (HasFlag(PWS_BORDER)) |
| 617 return m_sPrivateParam.dwBorderWidth; | 610 return m_sPrivateParam.dwBorderWidth; |
| 618 | 611 |
| 619 return 0; | 612 return 0; |
| 620 } | 613 } |
| 621 | 614 |
| 622 int32_t CPWL_Wnd::GetInnerBorderWidth() const { | 615 int32_t CPWL_Wnd::GetInnerBorderWidth() const { |
| 623 /* | |
| 624 switch (GetBorderStyle()) | |
| 625 { | |
| 626 case PBS_BEVELED: | |
| 627 case PBS_INSET: | |
| 628 return GetBorderWidth() / 2; | |
| 629 } | |
| 630 */ | |
| 631 return 0; | 616 return 0; |
| 632 } | 617 } |
| 633 | 618 |
| 634 void CPWL_Wnd::SetBorderWidth(int32_t nBorderWidth) { | 619 void CPWL_Wnd::SetBorderWidth(int32_t nBorderWidth) { |
| 635 if (HasFlag(PWS_BORDER)) | 620 if (HasFlag(PWS_BORDER)) |
| 636 m_sPrivateParam.dwBorderWidth = nBorderWidth; | 621 m_sPrivateParam.dwBorderWidth = nBorderWidth; |
| 637 } | 622 } |
| 638 | 623 |
| 639 CPWL_Color CPWL_Wnd::GetBorderColor() const { | 624 CPWL_Color CPWL_Wnd::GetBorderColor() const { |
| 640 if (HasFlag(PWS_BORDER)) | 625 if (HasFlag(PWS_BORDER)) |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 895 case PBS_INSET: | 880 case PBS_INSET: |
| 896 color = CPWL_Color(COLORTYPE_GRAY, 0.75f); | 881 color = CPWL_Color(COLORTYPE_GRAY, 0.75f); |
| 897 break; | 882 break; |
| 898 case PBS_UNDERLINED: | 883 case PBS_UNDERLINED: |
| 899 break; | 884 break; |
| 900 } | 885 } |
| 901 | 886 |
| 902 return color; | 887 return color; |
| 903 } | 888 } |
| 904 | 889 |
| 905 /* ----------------------------------------------------------------- */ | |
| 906 | |
| 907 int32_t CPWL_Wnd::GetTransparency() { | 890 int32_t CPWL_Wnd::GetTransparency() { |
| 908 return m_sPrivateParam.nTransparency; | 891 return m_sPrivateParam.nTransparency; |
| 909 } | 892 } |
| 910 | 893 |
| 911 void CPWL_Wnd::SetTransparency(int32_t nTransparency) { | 894 void CPWL_Wnd::SetTransparency(int32_t nTransparency) { |
| 912 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { | 895 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { |
| 913 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { | 896 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { |
| 914 pChild->SetTransparency(nTransparency); | 897 pChild->SetTransparency(nTransparency); |
| 915 } | 898 } |
| 916 } | 899 } |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1071 return FALSE; | 1054 return FALSE; |
| 1072 } | 1055 } |
| 1073 | 1056 |
| 1074 FX_BOOL CPWL_Wnd::IsINSERTpressed(FX_DWORD nFlag) const { | 1057 FX_BOOL CPWL_Wnd::IsINSERTpressed(FX_DWORD nFlag) const { |
| 1075 if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) { | 1058 if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) { |
| 1076 return pSystemHandler->IsINSERTKeyDown(nFlag); | 1059 return pSystemHandler->IsINSERTKeyDown(nFlag); |
| 1077 } | 1060 } |
| 1078 | 1061 |
| 1079 return FALSE; | 1062 return FALSE; |
| 1080 } | 1063 } |
| OLD | NEW |