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 "xfa/fwl/core/fwl_noteimp.h" | 7 #include "xfa/fwl/core/fwl_noteimp.h" |
8 | 8 |
9 #include "core/fxcrt/include/fx_ext.h" | 9 #include "core/fxcrt/include/fx_ext.h" |
10 #include "xfa/fwl/basewidget/fwl_tooltipctrlimp.h" | 10 #include "xfa/fwl/basewidget/fwl_tooltipctrlimp.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 CFWL_MsgKey* pMsgKey = static_cast<CFWL_MsgKey*>(pMessage); | 69 CFWL_MsgKey* pMsgKey = static_cast<CFWL_MsgKey*>(pMessage); |
70 if (pMsgKey->m_dwCmd != FWL_MSGKEYCMD_KeyDown) { | 70 if (pMsgKey->m_dwCmd != FWL_MSGKEYCMD_KeyDown) { |
71 return FALSE; | 71 return FALSE; |
72 } | 72 } |
73 CFX_MapAccelerators& accel = | 73 CFX_MapAccelerators& accel = |
74 static_cast<CFWL_FormImp*>(m_pForm)->GetAccelerator(); | 74 static_cast<CFWL_FormImp*>(m_pForm)->GetAccelerator(); |
75 FX_POSITION pos = accel.GetStartPosition(); | 75 FX_POSITION pos = accel.GetStartPosition(); |
76 if (!pos) { | 76 if (!pos) { |
77 return FALSE; | 77 return FALSE; |
78 } | 78 } |
79 FX_DWORD vrKey, rValue; | 79 uint32_t vrKey, rValue; |
80 while (pos) { | 80 while (pos) { |
81 accel.GetNextAssoc(pos, vrKey, rValue); | 81 accel.GetNextAssoc(pos, vrKey, rValue); |
82 FX_DWORD dwFlags = (vrKey & 0xFF00) >> 8; | 82 uint32_t dwFlags = (vrKey & 0xFF00) >> 8; |
83 FX_DWORD m_dwKeyCode = vrKey & 0x00FF; | 83 uint32_t m_dwKeyCode = vrKey & 0x00FF; |
84 if (pMsgKey->m_dwFlags == dwFlags && pMsgKey->m_dwKeyCode == m_dwKeyCode) { | 84 if (pMsgKey->m_dwFlags == dwFlags && pMsgKey->m_dwKeyCode == m_dwKeyCode) { |
85 GenerateCommondEvent(rValue); | 85 GenerateCommondEvent(rValue); |
86 return TRUE; | 86 return TRUE; |
87 } | 87 } |
88 } | 88 } |
89 return FALSE; | 89 return FALSE; |
90 } | 90 } |
91 FWL_ERR CFWL_NoteLoop::SetMainForm(CFWL_WidgetImp* pForm) { | 91 FWL_ERR CFWL_NoteLoop::SetMainForm(CFWL_WidgetImp* pForm) { |
92 m_pForm = pForm; | 92 m_pForm = pForm; |
93 return FWL_ERR_Succeeded; | 93 return FWL_ERR_Succeeded; |
94 } | 94 } |
95 void CFWL_NoteLoop::GenerateCommondEvent(FX_DWORD dwCommand) { | 95 void CFWL_NoteLoop::GenerateCommondEvent(uint32_t dwCommand) { |
96 CFWL_EvtMenuCommand ev; | 96 CFWL_EvtMenuCommand ev; |
97 ev.m_iCommand = dwCommand; | 97 ev.m_iCommand = dwCommand; |
98 IFWL_NoteThread* pThread = m_pForm->GetOwnerThread(); | 98 IFWL_NoteThread* pThread = m_pForm->GetOwnerThread(); |
99 if (!pThread) | 99 if (!pThread) |
100 return; | 100 return; |
101 IFWL_NoteDriver* pDriver = pThread->GetNoteDriver(); | 101 IFWL_NoteDriver* pDriver = pThread->GetNoteDriver(); |
102 if (!pDriver) | 102 if (!pDriver) |
103 return; | 103 return; |
104 pDriver->SendNote(&ev); | 104 pDriver->SendNote(&ev); |
105 } | 105 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 if (pDelegate) { | 158 if (pDelegate) { |
159 pDelegate->OnProcessMessage(static_cast<CFWL_Message*>(pNote)); | 159 pDelegate->OnProcessMessage(static_cast<CFWL_Message*>(pNote)); |
160 } | 160 } |
161 } | 161 } |
162 return TRUE; | 162 return TRUE; |
163 } | 163 } |
164 | 164 |
165 #define FWL_NoteDriver_EventKey 1100 | 165 #define FWL_NoteDriver_EventKey 1100 |
166 FWL_ERR CFWL_NoteDriver::RegisterEventTarget(IFWL_Widget* pListener, | 166 FWL_ERR CFWL_NoteDriver::RegisterEventTarget(IFWL_Widget* pListener, |
167 IFWL_Widget* pEventSource, | 167 IFWL_Widget* pEventSource, |
168 FX_DWORD dwFilter) { | 168 uint32_t dwFilter) { |
169 FX_DWORD dwkey = (FX_DWORD)(uintptr_t)pListener->GetPrivateData( | 169 uint32_t dwkey = (uint32_t)(uintptr_t)pListener->GetPrivateData( |
170 (void*)(uintptr_t)FWL_NoteDriver_EventKey); | 170 (void*)(uintptr_t)FWL_NoteDriver_EventKey); |
171 if (dwkey == 0) { | 171 if (dwkey == 0) { |
172 void* random = FX_Random_MT_Start(0); | 172 void* random = FX_Random_MT_Start(0); |
173 dwkey = rand(); | 173 dwkey = rand(); |
174 FX_Random_MT_Close(random); | 174 FX_Random_MT_Close(random); |
175 pListener->SetPrivateData((void*)(uintptr_t)FWL_NoteDriver_EventKey, | 175 pListener->SetPrivateData((void*)(uintptr_t)FWL_NoteDriver_EventKey, |
176 (void*)(uintptr_t)dwkey, NULL); | 176 (void*)(uintptr_t)dwkey, NULL); |
177 } | 177 } |
178 CFWL_EventTarget* value = NULL; | 178 CFWL_EventTarget* value = NULL; |
179 if (!m_eventTargets.Lookup((void*)(uintptr_t)dwkey, (void*&)value)) { | 179 if (!m_eventTargets.Lookup((void*)(uintptr_t)dwkey, (void*&)value)) { |
180 value = new CFWL_EventTarget(this, pListener); | 180 value = new CFWL_EventTarget(this, pListener); |
181 m_eventTargets.SetAt((void*)(uintptr_t)dwkey, value); | 181 m_eventTargets.SetAt((void*)(uintptr_t)dwkey, value); |
182 } | 182 } |
183 value->SetEventSource(pEventSource, dwFilter); | 183 value->SetEventSource(pEventSource, dwFilter); |
184 return FWL_ERR_Succeeded; | 184 return FWL_ERR_Succeeded; |
185 } | 185 } |
186 FWL_ERR CFWL_NoteDriver::UnregisterEventTarget(IFWL_Widget* pListener) { | 186 FWL_ERR CFWL_NoteDriver::UnregisterEventTarget(IFWL_Widget* pListener) { |
187 FX_DWORD dwkey = (FX_DWORD)(uintptr_t)pListener->GetPrivateData( | 187 uint32_t dwkey = (uint32_t)(uintptr_t)pListener->GetPrivateData( |
188 (void*)(uintptr_t)FWL_NoteDriver_EventKey); | 188 (void*)(uintptr_t)FWL_NoteDriver_EventKey); |
189 if (dwkey == 0) { | 189 if (dwkey == 0) { |
190 return FWL_ERR_Indefinite; | 190 return FWL_ERR_Indefinite; |
191 } | 191 } |
192 CFWL_EventTarget* value = NULL; | 192 CFWL_EventTarget* value = NULL; |
193 if (m_eventTargets.Lookup((void*)(uintptr_t)dwkey, (void*&)value)) { | 193 if (m_eventTargets.Lookup((void*)(uintptr_t)dwkey, (void*&)value)) { |
194 value->FlagInvalid(); | 194 value->FlagInvalid(); |
195 } | 195 } |
196 return FWL_ERR_Succeeded; | 196 return FWL_ERR_Succeeded; |
197 } | 197 } |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 CFX_SizeF CFWL_CoreToolTipDP::GetToolTipIconSize(IFWL_Widget* pWidget) { | 840 CFX_SizeF CFWL_CoreToolTipDP::GetToolTipIconSize(IFWL_Widget* pWidget) { |
841 return CFX_SizeF(); | 841 return CFX_SizeF(); |
842 } | 842 } |
843 CFX_RectF CFWL_CoreToolTipDP::GetAnchor() { | 843 CFX_RectF CFWL_CoreToolTipDP::GetAnchor() { |
844 return m_fAnchor; | 844 return m_fAnchor; |
845 } | 845 } |
846 CFWL_EventTarget::~CFWL_EventTarget() { | 846 CFWL_EventTarget::~CFWL_EventTarget() { |
847 m_eventSources.RemoveAll(); | 847 m_eventSources.RemoveAll(); |
848 } | 848 } |
849 int32_t CFWL_EventTarget::SetEventSource(IFWL_Widget* pSource, | 849 int32_t CFWL_EventTarget::SetEventSource(IFWL_Widget* pSource, |
850 FX_DWORD dwFilter) { | 850 uint32_t dwFilter) { |
851 if (pSource) { | 851 if (pSource) { |
852 m_eventSources.SetAt(pSource, dwFilter); | 852 m_eventSources.SetAt(pSource, dwFilter); |
853 return m_eventSources.GetCount(); | 853 return m_eventSources.GetCount(); |
854 } | 854 } |
855 return 1; | 855 return 1; |
856 } | 856 } |
857 FX_BOOL CFWL_EventTarget::ProcessEvent(CFWL_Event* pEvent) { | 857 FX_BOOL CFWL_EventTarget::ProcessEvent(CFWL_Event* pEvent) { |
858 IFWL_WidgetDelegate* pDelegate = m_pListener->SetDelegate(NULL); | 858 IFWL_WidgetDelegate* pDelegate = m_pListener->SetDelegate(NULL); |
859 if (!pDelegate) | 859 if (!pDelegate) |
860 return FALSE; | 860 return FALSE; |
861 if (m_eventSources.GetCount() == 0) { | 861 if (m_eventSources.GetCount() == 0) { |
862 pDelegate->OnProcessEvent(pEvent); | 862 pDelegate->OnProcessEvent(pEvent); |
863 return TRUE; | 863 return TRUE; |
864 } | 864 } |
865 FX_POSITION pos = m_eventSources.GetStartPosition(); | 865 FX_POSITION pos = m_eventSources.GetStartPosition(); |
866 while (pos) { | 866 while (pos) { |
867 IFWL_Widget* pSource = NULL; | 867 IFWL_Widget* pSource = NULL; |
868 FX_DWORD dwFilter = 0; | 868 uint32_t dwFilter = 0; |
869 m_eventSources.GetNextAssoc(pos, (void*&)pSource, dwFilter); | 869 m_eventSources.GetNextAssoc(pos, (void*&)pSource, dwFilter); |
870 if (pSource == pEvent->m_pSrcTarget || | 870 if (pSource == pEvent->m_pSrcTarget || |
871 pEvent->GetClassID() == FWL_EVTHASH_Idle) { | 871 pEvent->GetClassID() == FWL_EVTHASH_Idle) { |
872 if (IsFilterEvent(pEvent, dwFilter)) { | 872 if (IsFilterEvent(pEvent, dwFilter)) { |
873 pDelegate->OnProcessEvent(pEvent); | 873 pDelegate->OnProcessEvent(pEvent); |
874 return TRUE; | 874 return TRUE; |
875 } | 875 } |
876 } | 876 } |
877 } | 877 } |
878 return FALSE; | 878 return FALSE; |
879 } | 879 } |
880 FX_BOOL CFWL_EventTarget::IsFilterEvent(CFWL_Event* pEvent, FX_DWORD dwFilter) { | 880 FX_BOOL CFWL_EventTarget::IsFilterEvent(CFWL_Event* pEvent, uint32_t dwFilter) { |
881 if (dwFilter == FWL_EVENT_ALL_MASK) { | 881 if (dwFilter == FWL_EVENT_ALL_MASK) { |
882 return TRUE; | 882 return TRUE; |
883 } | 883 } |
884 FX_BOOL bRet = FALSE; | 884 FX_BOOL bRet = FALSE; |
885 switch (pEvent->GetClassID()) { | 885 switch (pEvent->GetClassID()) { |
886 case FWL_EVTHASH_Mouse: { | 886 case FWL_EVTHASH_Mouse: { |
887 bRet = dwFilter & FWL_EVENT_MOUSE_MASK; | 887 bRet = dwFilter & FWL_EVENT_MOUSE_MASK; |
888 break; | 888 break; |
889 } | 889 } |
890 case FWL_EVTHASH_MouseWheel: { | 890 case FWL_EVTHASH_MouseWheel: { |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1086 return NULL; | 1086 return NULL; |
1087 return widget->GetInterface(); | 1087 return widget->GetInterface(); |
1088 } | 1088 } |
1089 FWL_ERR FWL_SetHook(IFWL_NoteDriver* driver, | 1089 FWL_ERR FWL_SetHook(IFWL_NoteDriver* driver, |
1090 FWLMessageHookCallback callback, | 1090 FWLMessageHookCallback callback, |
1091 void* info) { | 1091 void* info) { |
1092 CFWL_NoteDriver* noteDriver = static_cast<CFWL_NoteDriver*>(driver); | 1092 CFWL_NoteDriver* noteDriver = static_cast<CFWL_NoteDriver*>(driver); |
1093 noteDriver->SetHook(callback, info); | 1093 noteDriver->SetHook(callback, info); |
1094 return FWL_ERR_Succeeded; | 1094 return FWL_ERR_Succeeded; |
1095 } | 1095 } |
OLD | NEW |