OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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/cpdfsdk_xfawidgethandler.h" | 7 #include "fpdfsdk/cpdfsdk_xfawidgethandler.h" |
8 | 8 |
9 #include "core/fpdfdoc/cpdf_interform.h" | 9 #include "core/fpdfdoc/cpdf_interform.h" |
10 #include "fpdfsdk/cpdfsdk_annot.h" | 10 #include "fpdfsdk/cpdfsdk_annot.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "xfa/fxfa/xfa_ffwidget.h" | 21 #include "xfa/fxfa/xfa_ffwidget.h" |
22 #include "xfa/fxfa/xfa_ffwidgethandler.h" | 22 #include "xfa/fxfa/xfa_ffwidgethandler.h" |
23 #include "xfa/fxgraphics/cfx_graphics.h" | 23 #include "xfa/fxgraphics/cfx_graphics.h" |
24 | 24 |
25 CPDFSDK_XFAWidgetHandler::CPDFSDK_XFAWidgetHandler( | 25 CPDFSDK_XFAWidgetHandler::CPDFSDK_XFAWidgetHandler( |
26 CPDFSDK_FormFillEnvironment* pFormFillEnv) | 26 CPDFSDK_FormFillEnvironment* pFormFillEnv) |
27 : m_pFormFillEnv(pFormFillEnv) {} | 27 : m_pFormFillEnv(pFormFillEnv) {} |
28 | 28 |
29 CPDFSDK_XFAWidgetHandler::~CPDFSDK_XFAWidgetHandler() {} | 29 CPDFSDK_XFAWidgetHandler::~CPDFSDK_XFAWidgetHandler() {} |
30 | 30 |
31 FX_BOOL CPDFSDK_XFAWidgetHandler::CanAnswer(CPDFSDK_Annot* pAnnot) { | 31 bool CPDFSDK_XFAWidgetHandler::CanAnswer(CPDFSDK_Annot* pAnnot) { |
32 return !!pAnnot->GetXFAWidget(); | 32 return !!pAnnot->GetXFAWidget(); |
33 } | 33 } |
34 | 34 |
35 CPDFSDK_Annot* CPDFSDK_XFAWidgetHandler::NewAnnot(CPDF_Annot* pAnnot, | 35 CPDFSDK_Annot* CPDFSDK_XFAWidgetHandler::NewAnnot(CPDF_Annot* pAnnot, |
36 CPDFSDK_PageView* pPage) { | 36 CPDFSDK_PageView* pPage) { |
37 return nullptr; | 37 return nullptr; |
38 } | 38 } |
39 | 39 |
40 CPDFSDK_Annot* CPDFSDK_XFAWidgetHandler::NewAnnot(CXFA_FFWidget* pAnnot, | 40 CPDFSDK_Annot* CPDFSDK_XFAWidgetHandler::NewAnnot(CXFA_FFWidget* pAnnot, |
41 CPDFSDK_PageView* pPage) { | 41 CPDFSDK_PageView* pPage) { |
(...skipping 10 matching lines...) Expand all Loading... |
52 bool bDrawAnnots) { | 52 bool bDrawAnnots) { |
53 ASSERT(pPageView); | 53 ASSERT(pPageView); |
54 ASSERT(pAnnot); | 54 ASSERT(pAnnot); |
55 | 55 |
56 CFX_Graphics gs; | 56 CFX_Graphics gs; |
57 gs.Create(pDevice); | 57 gs.Create(pDevice); |
58 | 58 |
59 CFX_Matrix mt; | 59 CFX_Matrix mt; |
60 mt = *pUser2Device; | 60 mt = *pUser2Device; |
61 | 61 |
62 FX_BOOL bIsHighlight = FALSE; | 62 bool bIsHighlight = false; |
63 if (pPageView->GetFormFillEnv()->GetFocusAnnot() != pAnnot) | 63 if (pPageView->GetFormFillEnv()->GetFocusAnnot() != pAnnot) |
64 bIsHighlight = TRUE; | 64 bIsHighlight = true; |
65 | 65 |
66 GetXFAWidgetHandler(pAnnot)->RenderWidget(pAnnot->GetXFAWidget(), &gs, &mt, | 66 GetXFAWidgetHandler(pAnnot)->RenderWidget(pAnnot->GetXFAWidget(), &gs, &mt, |
67 bIsHighlight); | 67 bIsHighlight); |
68 | 68 |
69 // to do highlight and shadow | 69 // to do highlight and shadow |
70 } | 70 } |
71 | 71 |
72 void CPDFSDK_XFAWidgetHandler::OnLoad(CPDFSDK_Annot* pAnnot) {} | 72 void CPDFSDK_XFAWidgetHandler::OnLoad(CPDFSDK_Annot* pAnnot) {} |
73 | 73 |
74 void CPDFSDK_XFAWidgetHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { | 74 void CPDFSDK_XFAWidgetHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { |
75 CPDFSDK_XFAWidget* pWidget = reinterpret_cast<CPDFSDK_XFAWidget*>(pAnnot); | 75 CPDFSDK_XFAWidget* pWidget = reinterpret_cast<CPDFSDK_XFAWidget*>(pAnnot); |
76 CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); | 76 CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); |
77 pInterForm->RemoveXFAMap(pWidget->GetXFAWidget()); | 77 pInterForm->RemoveXFAMap(pWidget->GetXFAWidget()); |
78 | 78 |
79 delete pWidget; | 79 delete pWidget; |
80 } | 80 } |
81 | 81 |
82 CFX_FloatRect CPDFSDK_XFAWidgetHandler::GetViewBBox(CPDFSDK_PageView* pPageView, | 82 CFX_FloatRect CPDFSDK_XFAWidgetHandler::GetViewBBox(CPDFSDK_PageView* pPageView, |
83 CPDFSDK_Annot* pAnnot) { | 83 CPDFSDK_Annot* pAnnot) { |
84 ASSERT(pAnnot); | 84 ASSERT(pAnnot); |
85 | 85 |
86 CFX_RectF rcBBox; | 86 CFX_RectF rcBBox; |
87 XFA_Element eType = pAnnot->GetXFAWidget()->GetDataAcc()->GetUIType(); | 87 XFA_Element eType = pAnnot->GetXFAWidget()->GetDataAcc()->GetUIType(); |
88 if (eType == XFA_Element::Signature) | 88 if (eType == XFA_Element::Signature) |
89 pAnnot->GetXFAWidget()->GetBBox(rcBBox, XFA_WidgetStatus_Visible, TRUE); | 89 pAnnot->GetXFAWidget()->GetBBox(rcBBox, XFA_WidgetStatus_Visible, true); |
90 else | 90 else |
91 pAnnot->GetXFAWidget()->GetBBox(rcBBox, XFA_WidgetStatus_None); | 91 pAnnot->GetXFAWidget()->GetBBox(rcBBox, XFA_WidgetStatus_None); |
92 | 92 |
93 CFX_FloatRect rcWidget(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width, | 93 CFX_FloatRect rcWidget(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width, |
94 rcBBox.top + rcBBox.height); | 94 rcBBox.top + rcBBox.height); |
95 rcWidget.left -= 1.0f; | 95 rcWidget.left -= 1.0f; |
96 rcWidget.right += 1.0f; | 96 rcWidget.right += 1.0f; |
97 rcWidget.bottom -= 1.0f; | 97 rcWidget.bottom -= 1.0f; |
98 rcWidget.top += 1.0f; | 98 rcWidget.top += 1.0f; |
99 | 99 |
100 return rcWidget; | 100 return rcWidget; |
101 } | 101 } |
102 | 102 |
103 FX_BOOL CPDFSDK_XFAWidgetHandler::HitTest(CPDFSDK_PageView* pPageView, | 103 bool CPDFSDK_XFAWidgetHandler::HitTest(CPDFSDK_PageView* pPageView, |
104 CPDFSDK_Annot* pAnnot, | 104 CPDFSDK_Annot* pAnnot, |
105 const CFX_FloatPoint& point) { | 105 const CFX_FloatPoint& point) { |
106 if (!pPageView || !pAnnot) | 106 if (!pPageView || !pAnnot) |
107 return FALSE; | 107 return false; |
108 | 108 |
109 CPDFSDK_FormFillEnvironment* pFormFillEnv = pPageView->GetFormFillEnv(); | 109 CPDFSDK_FormFillEnvironment* pFormFillEnv = pPageView->GetFormFillEnv(); |
110 if (!pFormFillEnv) | 110 if (!pFormFillEnv) |
111 return FALSE; | 111 return false; |
112 | 112 |
113 CPDFXFA_Context* pContext = pFormFillEnv->GetXFAContext(); | 113 CPDFXFA_Context* pContext = pFormFillEnv->GetXFAContext(); |
114 if (!pContext) | 114 if (!pContext) |
115 return FALSE; | 115 return false; |
116 | 116 |
117 CXFA_FFDocView* pDocView = pContext->GetXFADocView(); | 117 CXFA_FFDocView* pDocView = pContext->GetXFADocView(); |
118 if (!pDocView) | 118 if (!pDocView) |
119 return FALSE; | 119 return false; |
120 | 120 |
121 CXFA_FFWidgetHandler* pWidgetHandler = pDocView->GetWidgetHandler(); | 121 CXFA_FFWidgetHandler* pWidgetHandler = pDocView->GetWidgetHandler(); |
122 if (!pWidgetHandler) | 122 if (!pWidgetHandler) |
123 return FALSE; | 123 return false; |
124 | 124 |
125 FWL_WidgetHit dwHitTest = | 125 FWL_WidgetHit dwHitTest = |
126 pWidgetHandler->OnHitTest(pAnnot->GetXFAWidget(), point.x, point.y); | 126 pWidgetHandler->OnHitTest(pAnnot->GetXFAWidget(), point.x, point.y); |
127 return dwHitTest != FWL_WidgetHit::Unknown; | 127 return dwHitTest != FWL_WidgetHit::Unknown; |
128 } | 128 } |
129 | 129 |
130 void CPDFSDK_XFAWidgetHandler::OnMouseEnter(CPDFSDK_PageView* pPageView, | 130 void CPDFSDK_XFAWidgetHandler::OnMouseEnter(CPDFSDK_PageView* pPageView, |
131 CPDFSDK_Annot::ObservedPtr* pAnnot, | 131 CPDFSDK_Annot::ObservedPtr* pAnnot, |
132 uint32_t nFlag) { | 132 uint32_t nFlag) { |
133 if (!pPageView || !(*pAnnot)) | 133 if (!pPageView || !(*pAnnot)) |
134 return; | 134 return; |
135 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); | 135 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); |
136 pWidgetHandler->OnMouseEnter((*pAnnot)->GetXFAWidget()); | 136 pWidgetHandler->OnMouseEnter((*pAnnot)->GetXFAWidget()); |
137 } | 137 } |
138 | 138 |
139 void CPDFSDK_XFAWidgetHandler::OnMouseExit(CPDFSDK_PageView* pPageView, | 139 void CPDFSDK_XFAWidgetHandler::OnMouseExit(CPDFSDK_PageView* pPageView, |
140 CPDFSDK_Annot::ObservedPtr* pAnnot, | 140 CPDFSDK_Annot::ObservedPtr* pAnnot, |
141 uint32_t nFlag) { | 141 uint32_t nFlag) { |
142 if (!pPageView || !(*pAnnot)) | 142 if (!pPageView || !(*pAnnot)) |
143 return; | 143 return; |
144 | 144 |
145 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); | 145 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); |
146 pWidgetHandler->OnMouseExit((*pAnnot)->GetXFAWidget()); | 146 pWidgetHandler->OnMouseExit((*pAnnot)->GetXFAWidget()); |
147 } | 147 } |
148 | 148 |
149 FX_BOOL CPDFSDK_XFAWidgetHandler::OnLButtonDown( | 149 bool CPDFSDK_XFAWidgetHandler::OnLButtonDown(CPDFSDK_PageView* pPageView, |
150 CPDFSDK_PageView* pPageView, | 150 CPDFSDK_Annot::ObservedPtr* pAnnot, |
151 CPDFSDK_Annot::ObservedPtr* pAnnot, | 151 uint32_t nFlags, |
152 uint32_t nFlags, | 152 const CFX_FloatPoint& point) { |
153 const CFX_FloatPoint& point) { | |
154 if (!pPageView || !(*pAnnot)) | 153 if (!pPageView || !(*pAnnot)) |
155 return FALSE; | 154 return false; |
156 | 155 |
157 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); | 156 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); |
158 return pWidgetHandler->OnLButtonDown((*pAnnot)->GetXFAWidget(), | 157 return pWidgetHandler->OnLButtonDown((*pAnnot)->GetXFAWidget(), |
159 GetFWLFlags(nFlags), point.x, point.y); | 158 GetFWLFlags(nFlags), point.x, point.y); |
160 } | 159 } |
161 | 160 |
162 FX_BOOL CPDFSDK_XFAWidgetHandler::OnLButtonUp( | 161 bool CPDFSDK_XFAWidgetHandler::OnLButtonUp(CPDFSDK_PageView* pPageView, |
163 CPDFSDK_PageView* pPageView, | 162 CPDFSDK_Annot::ObservedPtr* pAnnot, |
164 CPDFSDK_Annot::ObservedPtr* pAnnot, | 163 uint32_t nFlags, |
165 uint32_t nFlags, | 164 const CFX_FloatPoint& point) { |
166 const CFX_FloatPoint& point) { | |
167 if (!pPageView || !(*pAnnot)) | 165 if (!pPageView || !(*pAnnot)) |
168 return FALSE; | 166 return false; |
169 | 167 |
170 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); | 168 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); |
171 return pWidgetHandler->OnLButtonUp((*pAnnot)->GetXFAWidget(), | 169 return pWidgetHandler->OnLButtonUp((*pAnnot)->GetXFAWidget(), |
172 GetFWLFlags(nFlags), point.x, point.y); | 170 GetFWLFlags(nFlags), point.x, point.y); |
173 } | 171 } |
174 | 172 |
175 FX_BOOL CPDFSDK_XFAWidgetHandler::OnLButtonDblClk( | 173 bool CPDFSDK_XFAWidgetHandler::OnLButtonDblClk( |
176 CPDFSDK_PageView* pPageView, | 174 CPDFSDK_PageView* pPageView, |
177 CPDFSDK_Annot::ObservedPtr* pAnnot, | 175 CPDFSDK_Annot::ObservedPtr* pAnnot, |
178 uint32_t nFlags, | 176 uint32_t nFlags, |
179 const CFX_FloatPoint& point) { | 177 const CFX_FloatPoint& point) { |
180 if (!pPageView || !(*pAnnot)) | 178 if (!pPageView || !(*pAnnot)) |
181 return FALSE; | 179 return false; |
182 | 180 |
183 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); | 181 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); |
184 return pWidgetHandler->OnLButtonDblClk((*pAnnot)->GetXFAWidget(), | 182 return pWidgetHandler->OnLButtonDblClk((*pAnnot)->GetXFAWidget(), |
185 GetFWLFlags(nFlags), point.x, point.y); | 183 GetFWLFlags(nFlags), point.x, point.y); |
186 } | 184 } |
187 | 185 |
188 FX_BOOL CPDFSDK_XFAWidgetHandler::OnMouseMove( | 186 bool CPDFSDK_XFAWidgetHandler::OnMouseMove(CPDFSDK_PageView* pPageView, |
189 CPDFSDK_PageView* pPageView, | 187 CPDFSDK_Annot::ObservedPtr* pAnnot, |
190 CPDFSDK_Annot::ObservedPtr* pAnnot, | 188 uint32_t nFlags, |
191 uint32_t nFlags, | 189 const CFX_FloatPoint& point) { |
192 const CFX_FloatPoint& point) { | |
193 if (!pPageView || !(*pAnnot)) | 190 if (!pPageView || !(*pAnnot)) |
194 return FALSE; | 191 return false; |
195 | 192 |
196 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); | 193 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); |
197 return pWidgetHandler->OnMouseMove((*pAnnot)->GetXFAWidget(), | 194 return pWidgetHandler->OnMouseMove((*pAnnot)->GetXFAWidget(), |
198 GetFWLFlags(nFlags), point.x, point.y); | 195 GetFWLFlags(nFlags), point.x, point.y); |
199 } | 196 } |
200 | 197 |
201 FX_BOOL CPDFSDK_XFAWidgetHandler::OnMouseWheel( | 198 bool CPDFSDK_XFAWidgetHandler::OnMouseWheel(CPDFSDK_PageView* pPageView, |
202 CPDFSDK_PageView* pPageView, | 199 CPDFSDK_Annot::ObservedPtr* pAnnot, |
203 CPDFSDK_Annot::ObservedPtr* pAnnot, | 200 uint32_t nFlags, |
204 uint32_t nFlags, | 201 short zDelta, |
205 short zDelta, | 202 const CFX_FloatPoint& point) { |
206 const CFX_FloatPoint& point) { | |
207 if (!pPageView || !(*pAnnot)) | 203 if (!pPageView || !(*pAnnot)) |
208 return FALSE; | 204 return false; |
209 | 205 |
210 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); | 206 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); |
211 return pWidgetHandler->OnMouseWheel( | 207 return pWidgetHandler->OnMouseWheel( |
212 (*pAnnot)->GetXFAWidget(), GetFWLFlags(nFlags), zDelta, point.x, point.y); | 208 (*pAnnot)->GetXFAWidget(), GetFWLFlags(nFlags), zDelta, point.x, point.y); |
213 } | 209 } |
214 | 210 |
215 FX_BOOL CPDFSDK_XFAWidgetHandler::OnRButtonDown( | 211 bool CPDFSDK_XFAWidgetHandler::OnRButtonDown(CPDFSDK_PageView* pPageView, |
216 CPDFSDK_PageView* pPageView, | 212 CPDFSDK_Annot::ObservedPtr* pAnnot, |
217 CPDFSDK_Annot::ObservedPtr* pAnnot, | 213 uint32_t nFlags, |
218 uint32_t nFlags, | 214 const CFX_FloatPoint& point) { |
219 const CFX_FloatPoint& point) { | |
220 if (!pPageView || !(*pAnnot)) | 215 if (!pPageView || !(*pAnnot)) |
221 return FALSE; | 216 return false; |
222 | 217 |
223 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); | 218 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); |
224 return pWidgetHandler->OnRButtonDown((*pAnnot)->GetXFAWidget(), | 219 return pWidgetHandler->OnRButtonDown((*pAnnot)->GetXFAWidget(), |
225 GetFWLFlags(nFlags), point.x, point.y); | 220 GetFWLFlags(nFlags), point.x, point.y); |
226 } | 221 } |
227 | 222 |
228 FX_BOOL CPDFSDK_XFAWidgetHandler::OnRButtonUp( | 223 bool CPDFSDK_XFAWidgetHandler::OnRButtonUp(CPDFSDK_PageView* pPageView, |
229 CPDFSDK_PageView* pPageView, | 224 CPDFSDK_Annot::ObservedPtr* pAnnot, |
230 CPDFSDK_Annot::ObservedPtr* pAnnot, | 225 uint32_t nFlags, |
231 uint32_t nFlags, | 226 const CFX_FloatPoint& point) { |
232 const CFX_FloatPoint& point) { | |
233 if (!pPageView || !(*pAnnot)) | 227 if (!pPageView || !(*pAnnot)) |
234 return FALSE; | 228 return false; |
235 | 229 |
236 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); | 230 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); |
237 return pWidgetHandler->OnRButtonUp((*pAnnot)->GetXFAWidget(), | 231 return pWidgetHandler->OnRButtonUp((*pAnnot)->GetXFAWidget(), |
238 GetFWLFlags(nFlags), point.x, point.y); | 232 GetFWLFlags(nFlags), point.x, point.y); |
239 } | 233 } |
240 | 234 |
241 FX_BOOL CPDFSDK_XFAWidgetHandler::OnRButtonDblClk( | 235 bool CPDFSDK_XFAWidgetHandler::OnRButtonDblClk( |
242 CPDFSDK_PageView* pPageView, | 236 CPDFSDK_PageView* pPageView, |
243 CPDFSDK_Annot::ObservedPtr* pAnnot, | 237 CPDFSDK_Annot::ObservedPtr* pAnnot, |
244 uint32_t nFlags, | 238 uint32_t nFlags, |
245 const CFX_FloatPoint& point) { | 239 const CFX_FloatPoint& point) { |
246 if (!pPageView || !(*pAnnot)) | 240 if (!pPageView || !(*pAnnot)) |
247 return FALSE; | 241 return false; |
248 | 242 |
249 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); | 243 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); |
250 return pWidgetHandler->OnRButtonDblClk((*pAnnot)->GetXFAWidget(), | 244 return pWidgetHandler->OnRButtonDblClk((*pAnnot)->GetXFAWidget(), |
251 GetFWLFlags(nFlags), point.x, point.y); | 245 GetFWLFlags(nFlags), point.x, point.y); |
252 } | 246 } |
253 | 247 |
254 FX_BOOL CPDFSDK_XFAWidgetHandler::OnChar(CPDFSDK_Annot* pAnnot, | 248 bool CPDFSDK_XFAWidgetHandler::OnChar(CPDFSDK_Annot* pAnnot, |
255 uint32_t nChar, | 249 uint32_t nChar, |
256 uint32_t nFlags) { | 250 uint32_t nFlags) { |
257 if (!pAnnot) | 251 if (!pAnnot) |
258 return FALSE; | 252 return false; |
259 | 253 |
260 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); | 254 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
261 return pWidgetHandler->OnChar(pAnnot->GetXFAWidget(), nChar, | 255 return pWidgetHandler->OnChar(pAnnot->GetXFAWidget(), nChar, |
262 GetFWLFlags(nFlags)); | 256 GetFWLFlags(nFlags)); |
263 } | 257 } |
264 | 258 |
265 FX_BOOL CPDFSDK_XFAWidgetHandler::OnKeyDown(CPDFSDK_Annot* pAnnot, | 259 bool CPDFSDK_XFAWidgetHandler::OnKeyDown(CPDFSDK_Annot* pAnnot, |
266 int nKeyCode, | 260 int nKeyCode, |
267 int nFlag) { | 261 int nFlag) { |
268 if (!pAnnot) | 262 if (!pAnnot) |
269 return FALSE; | 263 return false; |
270 | 264 |
271 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); | 265 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
272 return pWidgetHandler->OnKeyDown(pAnnot->GetXFAWidget(), nKeyCode, | 266 return pWidgetHandler->OnKeyDown(pAnnot->GetXFAWidget(), nKeyCode, |
273 GetFWLFlags(nFlag)); | 267 GetFWLFlags(nFlag)); |
274 } | 268 } |
275 | 269 |
276 FX_BOOL CPDFSDK_XFAWidgetHandler::OnKeyUp(CPDFSDK_Annot* pAnnot, | 270 bool CPDFSDK_XFAWidgetHandler::OnKeyUp(CPDFSDK_Annot* pAnnot, |
277 int nKeyCode, | 271 int nKeyCode, |
278 int nFlag) { | 272 int nFlag) { |
279 if (!pAnnot) | 273 if (!pAnnot) |
280 return FALSE; | 274 return false; |
281 | 275 |
282 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); | 276 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
283 return pWidgetHandler->OnKeyUp(pAnnot->GetXFAWidget(), nKeyCode, | 277 return pWidgetHandler->OnKeyUp(pAnnot->GetXFAWidget(), nKeyCode, |
284 GetFWLFlags(nFlag)); | 278 GetFWLFlags(nFlag)); |
285 } | 279 } |
286 | 280 |
287 FX_BOOL CPDFSDK_XFAWidgetHandler::OnSetFocus(CPDFSDK_Annot::ObservedPtr* pAnnot, | 281 bool CPDFSDK_XFAWidgetHandler::OnSetFocus(CPDFSDK_Annot::ObservedPtr* pAnnot, |
288 uint32_t nFlag) { | 282 uint32_t nFlag) { |
289 return TRUE; | 283 return true; |
290 } | 284 } |
291 | 285 |
292 FX_BOOL CPDFSDK_XFAWidgetHandler::OnKillFocus( | 286 bool CPDFSDK_XFAWidgetHandler::OnKillFocus(CPDFSDK_Annot::ObservedPtr* pAnnot, |
293 CPDFSDK_Annot::ObservedPtr* pAnnot, | 287 uint32_t nFlag) { |
294 uint32_t nFlag) { | 288 return true; |
295 return TRUE; | |
296 } | 289 } |
297 | 290 |
298 FX_BOOL CPDFSDK_XFAWidgetHandler::OnXFAChangedFocus( | 291 bool CPDFSDK_XFAWidgetHandler::OnXFAChangedFocus( |
299 CPDFSDK_Annot::ObservedPtr* pOldAnnot, | 292 CPDFSDK_Annot::ObservedPtr* pOldAnnot, |
300 CPDFSDK_Annot::ObservedPtr* pNewAnnot) { | 293 CPDFSDK_Annot::ObservedPtr* pNewAnnot) { |
301 CXFA_FFWidgetHandler* pWidgetHandler = nullptr; | 294 CXFA_FFWidgetHandler* pWidgetHandler = nullptr; |
302 if (*pOldAnnot) | 295 if (*pOldAnnot) |
303 pWidgetHandler = GetXFAWidgetHandler(pOldAnnot->Get()); | 296 pWidgetHandler = GetXFAWidgetHandler(pOldAnnot->Get()); |
304 else if (*pNewAnnot) | 297 else if (*pNewAnnot) |
305 pWidgetHandler = GetXFAWidgetHandler(pNewAnnot->Get()); | 298 pWidgetHandler = GetXFAWidgetHandler(pNewAnnot->Get()); |
306 | 299 |
307 if (!pWidgetHandler) | 300 if (!pWidgetHandler) |
308 return TRUE; | 301 return true; |
309 | 302 |
310 CXFA_FFWidget* hWidget = *pNewAnnot ? (*pNewAnnot)->GetXFAWidget() : nullptr; | 303 CXFA_FFWidget* hWidget = *pNewAnnot ? (*pNewAnnot)->GetXFAWidget() : nullptr; |
311 if (!hWidget) | 304 if (!hWidget) |
312 return TRUE; | 305 return true; |
313 | 306 |
314 CXFA_FFPageView* pXFAPageView = hWidget->GetPageView(); | 307 CXFA_FFPageView* pXFAPageView = hWidget->GetPageView(); |
315 if (!pXFAPageView) | 308 if (!pXFAPageView) |
316 return TRUE; | 309 return true; |
317 | 310 |
318 FX_BOOL bRet = pXFAPageView->GetDocView()->SetFocus(hWidget); | 311 bool bRet = pXFAPageView->GetDocView()->SetFocus(hWidget); |
319 if (pXFAPageView->GetDocView()->GetFocusWidget() == hWidget) | 312 if (pXFAPageView->GetDocView()->GetFocusWidget() == hWidget) |
320 bRet = TRUE; | 313 bRet = true; |
321 | 314 |
322 return bRet; | 315 return bRet; |
323 } | 316 } |
324 | 317 |
325 CXFA_FFWidgetHandler* CPDFSDK_XFAWidgetHandler::GetXFAWidgetHandler( | 318 CXFA_FFWidgetHandler* CPDFSDK_XFAWidgetHandler::GetXFAWidgetHandler( |
326 CPDFSDK_Annot* pAnnot) { | 319 CPDFSDK_Annot* pAnnot) { |
327 if (!pAnnot) | 320 if (!pAnnot) |
328 return nullptr; | 321 return nullptr; |
329 | 322 |
330 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); | 323 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); |
(...skipping 26 matching lines...) Expand all Loading... |
357 dwFWLFlag |= FWL_KEYFLAG_MButton; | 350 dwFWLFlag |= FWL_KEYFLAG_MButton; |
358 if (dwFlag & FWL_EVENTFLAG_RightButtonDown) | 351 if (dwFlag & FWL_EVENTFLAG_RightButtonDown) |
359 dwFWLFlag |= FWL_KEYFLAG_RButton; | 352 dwFWLFlag |= FWL_KEYFLAG_RButton; |
360 if (dwFlag & FWL_EVENTFLAG_ShiftKey) | 353 if (dwFlag & FWL_EVENTFLAG_ShiftKey) |
361 dwFWLFlag |= FWL_KEYFLAG_Shift; | 354 dwFWLFlag |= FWL_KEYFLAG_Shift; |
362 if (dwFlag & FWL_EVENTFLAG_AltKey) | 355 if (dwFlag & FWL_EVENTFLAG_AltKey) |
363 dwFWLFlag |= FWL_KEYFLAG_Alt; | 356 dwFWLFlag |= FWL_KEYFLAG_Alt; |
364 | 357 |
365 return dwFWLFlag; | 358 return dwFWLFlag; |
366 } | 359 } |
OLD | NEW |