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 "../../include/pdfwindow/PDFWindow.h" | 7 #include "../../include/pdfwindow/PDFWindow.h" |
8 #include "../../include/pdfwindow/PWL_Wnd.h" | 8 #include "../../include/pdfwindow/PWL_Wnd.h" |
9 #include "../../include/pdfwindow/PWL_Utils.h" | 9 #include "../../include/pdfwindow/PWL_Utils.h" |
10 #include "../../include/pdfwindow/PWL_ScrollBar.h" | 10 #include "../../include/pdfwindow/PWL_ScrollBar.h" |
11 | 11 |
12 /* -------------------------- CPWL_Timer -------------------------- */ | 12 /* -------------------------- CPWL_Timer -------------------------- */ |
13 | 13 |
14 static CFX_MapPtrTemplate<FX_INT32, CPWL_Timer*>» g_TimeMap; | 14 static CFX_MapPtrTemplate<FX_INT32, CPWL_Timer*>& GetPWLTimeMap() |
| 15 { |
| 16 // Leak the object at shutdown. |
| 17 static auto timeMap = new CFX_MapPtrTemplate<FX_INT32, CPWL_Timer*>; |
| 18 return *timeMap; |
| 19 } |
15 | 20 |
16 CPWL_Timer::CPWL_Timer(CPWL_TimerHandler* pAttached, IFX_SystemHandler* pSystemH
andler) : | 21 CPWL_Timer::CPWL_Timer(CPWL_TimerHandler* pAttached, IFX_SystemHandler* pSystemH
andler) : |
17 m_nTimerID(0), | 22 m_nTimerID(0), |
18 m_pAttached(pAttached), | 23 m_pAttached(pAttached), |
19 m_pSystemHandler(pSystemHandler) | 24 m_pSystemHandler(pSystemHandler) |
20 { | 25 { |
21 ASSERT(m_pAttached != NULL); | 26 ASSERT(m_pAttached != NULL); |
22 ASSERT(m_pSystemHandler != NULL); | 27 ASSERT(m_pSystemHandler != NULL); |
23 } | 28 } |
24 | 29 |
25 CPWL_Timer::~CPWL_Timer() | 30 CPWL_Timer::~CPWL_Timer() |
26 { | 31 { |
27 KillPWLTimer(); | 32 KillPWLTimer(); |
28 } | 33 } |
29 | 34 |
30 FX_INT32 CPWL_Timer::SetPWLTimer(FX_INT32 nElapse) | 35 FX_INT32 CPWL_Timer::SetPWLTimer(FX_INT32 nElapse) |
31 { | 36 { |
32 if (m_nTimerID != 0) KillPWLTimer(); | 37 if (m_nTimerID != 0) KillPWLTimer(); |
33 m_nTimerID = m_pSystemHandler->SetTimer(nElapse, TimerProc); | 38 m_nTimerID = m_pSystemHandler->SetTimer(nElapse, TimerProc); |
34 » g_TimeMap.SetAt(m_nTimerID, this); | 39 » GetPWLTimeMap().SetAt(m_nTimerID, this); |
35 return m_nTimerID; | 40 return m_nTimerID; |
36 } | 41 } |
37 | 42 |
38 void CPWL_Timer::KillPWLTimer() | 43 void CPWL_Timer::KillPWLTimer() |
39 { | 44 { |
40 if (m_nTimerID != 0) | 45 if (m_nTimerID != 0) |
41 { | 46 { |
42 m_pSystemHandler->KillTimer(m_nTimerID); | 47 m_pSystemHandler->KillTimer(m_nTimerID); |
43 » » g_TimeMap.RemoveKey(m_nTimerID); | 48 » » GetPWLTimeMap().RemoveKey(m_nTimerID); |
44 m_nTimerID = 0; | 49 m_nTimerID = 0; |
45 } | 50 } |
46 } | 51 } |
47 | 52 |
48 void CPWL_Timer::TimerProc(FX_INT32 idEvent) | 53 void CPWL_Timer::TimerProc(FX_INT32 idEvent) |
49 { | 54 { |
50 CPWL_Timer* pTimer = NULL; | 55 CPWL_Timer* pTimer = NULL; |
51 » if (g_TimeMap.Lookup(idEvent, pTimer)) | 56 » if (GetPWLTimeMap().Lookup(idEvent, pTimer)) |
52 { | 57 { |
53 if (pTimer) | 58 if (pTimer) |
54 { | 59 { |
55 if (pTimer->m_pAttached) | 60 if (pTimer->m_pAttached) |
56 pTimer->m_pAttached->TimerProc(); | 61 pTimer->m_pAttached->TimerProc(); |
57 } | 62 } |
58 } | 63 } |
59 } | 64 } |
60 | 65 |
61 /* -------------------------- CPWL_TimerHandler -------------------------- */ | 66 /* -------------------------- CPWL_TimerHandler -------------------------- */ |
(...skipping 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1333 FX_BOOL CPWL_Wnd::IsINSERTpressed(FX_DWORD nFlag) const | 1338 FX_BOOL CPWL_Wnd::IsINSERTpressed(FX_DWORD nFlag) const |
1334 { | 1339 { |
1335 if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) | 1340 if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) |
1336 { | 1341 { |
1337 return pSystemHandler->IsINSERTKeyDown(nFlag); | 1342 return pSystemHandler->IsINSERTKeyDown(nFlag); |
1338 } | 1343 } |
1339 | 1344 |
1340 return FALSE; | 1345 return FALSE; |
1341 } | 1346 } |
1342 | 1347 |
OLD | NEW |