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 | 7 |
8 #include "../../include/formfiller/FFL_FormFiller.h" | 8 #include "../../include/formfiller/FFL_FormFiller.h" |
9 #include "../../include/formfiller/FFL_Notify.h" | 9 #include "../../include/formfiller/FFL_Notify.h" |
10 #include "../../include/formfiller/FFL_CBA_Fontmap.h" | 10 #include "../../include/formfiller/FFL_CBA_Fontmap.h" |
11 | 11 |
12 #define GetRed(rgb)» » » ((uint8_t)(rgb)) | 12 #define GetRed(rgb) ((uint8_t)(rgb)) |
13 #define GetGreen(rgb)» » ((uint8_t)(((FX_WORD)(rgb)) >> 8)) | 13 #define GetGreen(rgb) ((uint8_t)(((FX_WORD)(rgb)) >> 8)) |
14 #define GetBlue(rgb)» » ((uint8_t)((rgb)>>16)) | 14 #define GetBlue(rgb) ((uint8_t)((rgb)>>16)) |
15 | 15 |
16 #define FFL_HINT_ELAPSE»» 800 | 16 #define FFL_HINT_ELAPSE 800 |
17 | 17 |
18 /* ------------------------- CFFL_FormFiller ------------------------- */ | 18 /* ------------------------- CFFL_FormFiller ------------------------- */ |
19 | 19 |
20 CFFL_FormFiller::CFFL_FormFiller(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnno
t) | 20 CFFL_FormFiller::CFFL_FormFiller(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnno
t) |
21 » :m_pApp(pApp), | 21 : m_pApp(pApp), |
22 » m_pAnnot(pAnnot), | 22 m_pAnnot(pAnnot), |
23 » m_bValid(FALSE), | 23 m_bValid(FALSE), |
24 » m_ptOldPos(0,0) | 24 m_ptOldPos(0,0) |
25 { | 25 { |
26 » m_pWidget = (CPDFSDK_Widget*) pAnnot; | 26 m_pWidget = (CPDFSDK_Widget*) pAnnot; |
27 } | 27 } |
28 | 28 |
29 CFFL_FormFiller::~CFFL_FormFiller() | 29 CFFL_FormFiller::~CFFL_FormFiller() |
30 { | 30 { |
31 for (auto& it : m_Maps) { | 31 for (auto& it : m_Maps) { |
32 CPWL_Wnd* pWnd = it.second; | 32 CPWL_Wnd* pWnd = it.second; |
33 CFFL_PrivateData* pData = (CFFL_PrivateData*)pWnd->GetAttachedData(); | 33 CFFL_PrivateData* pData = (CFFL_PrivateData*)pWnd->GetAttachedData(); |
34 pWnd->Destroy(); | 34 pWnd->Destroy(); |
35 delete pWnd; | 35 delete pWnd; |
36 delete pData; | 36 delete pData; |
37 } | 37 } |
38 m_Maps.clear(); | 38 m_Maps.clear(); |
39 } | 39 } |
40 | 40 |
41 void CFFL_FormFiller::SetWindowRect(CPDFSDK_PageView* pPageView, const CPDF_Rect
& rcWindow) | 41 void CFFL_FormFiller::SetWindowRect(CPDFSDK_PageView* pPageView, const CPDF_Rect
& rcWindow) |
42 { | 42 { |
43 » if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) | 43 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) |
44 » { | 44 { |
45 » » pWnd->Move(CPDF_Rect(rcWindow), TRUE, FALSE); | 45 pWnd->Move(CPDF_Rect(rcWindow), TRUE, FALSE); |
46 » } | 46 } |
47 } | 47 } |
48 | 48 |
49 CPDF_Rect CFFL_FormFiller::GetWindowRect(CPDFSDK_PageView* pPageView) | 49 CPDF_Rect CFFL_FormFiller::GetWindowRect(CPDFSDK_PageView* pPageView) |
50 { | 50 { |
51 » if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) | 51 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) |
52 » { | 52 { |
53 » » return pWnd->GetWindowRect(); | 53 return pWnd->GetWindowRect(); |
54 » } | 54 } |
55 | 55 |
56 » return CPDF_Rect(0,0,0,0); | 56 return CPDF_Rect(0,0,0,0); |
57 } | 57 } |
58 | 58 |
59 FX_RECT CFFL_FormFiller::GetViewBBox(CPDFSDK_PageView *pPageView, CPDFSDK_Annot*
pAnnot) | 59 FX_RECT CFFL_FormFiller::GetViewBBox(CPDFSDK_PageView *pPageView, CPDFSDK_Annot*
pAnnot) |
60 { | 60 { |
61 » ASSERT(pPageView != NULL); | 61 ASSERT(pPageView != NULL); |
62 » ASSERT(pAnnot != NULL); | 62 ASSERT(pAnnot != NULL); |
63 | 63 |
64 » CPDF_Rect rcAnnot = m_pWidget->GetRect(); | 64 CPDF_Rect rcAnnot = m_pWidget->GetRect(); |
65 | 65 |
66 » if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) | 66 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) |
67 » { | 67 { |
68 » » CPDF_Rect rcWindow = pWnd->GetWindowRect(); | 68 CPDF_Rect rcWindow = pWnd->GetWindowRect(); |
69 » » rcAnnot = PWLtoFFL(rcWindow); | 69 rcAnnot = PWLtoFFL(rcWindow); |
70 » } | 70 } |
71 | 71 |
72 » CPDF_Rect rcWin = rcAnnot; | 72 CPDF_Rect rcWin = rcAnnot; |
73 | 73 |
74 » CPDF_Rect rcFocus = GetFocusBox(pPageView); | 74 CPDF_Rect rcFocus = GetFocusBox(pPageView); |
75 » if (!rcFocus.IsEmpty()) | 75 if (!rcFocus.IsEmpty()) |
76 » » rcWin.Union(rcFocus); | 76 rcWin.Union(rcFocus); |
77 | 77 |
78 » CPDF_Rect rect = CPWL_Utils::InflateRect(rcWin,1); | 78 CPDF_Rect rect = CPWL_Utils::InflateRect(rcWin,1); |
79 | 79 |
80 » return rect.GetOutterRect(); | 80 return rect.GetOutterRect(); |
81 } | 81 } |
82 | 82 |
83 void CFFL_FormFiller::OnDraw(CPDFSDK_PageView *pPageView, /*HDC hDC,*/ CPDFSDK_A
nnot* pAnnot, | 83 void CFFL_FormFiller::OnDraw(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, |
84 » » » » » » CFX_RenderDevice* pDevice, CPDF_
Matrix* pUser2Device, | 84 CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Devic
e, |
85 » » » » » » /*const CRect& rcWindow,*/ FX_DW
ORD dwFlags) | 85 FX_DWORD dwFlags) |
86 { | 86 { |
87 » ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | 87 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); |
88 | 88 |
89 » if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE)) | 89 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE)) |
90 » { | 90 { |
91 » » CPDF_Matrix mt = GetCurMatrix(); | 91 CPDF_Matrix mt = GetCurMatrix(); |
92 » » mt.Concat(*pUser2Device); | 92 mt.Concat(*pUser2Device); |
93 » » pWnd->DrawAppearance(pDevice,&mt); | 93 pWnd->DrawAppearance(pDevice,&mt); |
94 » } | 94 } |
95 » else | 95 else |
96 » { | 96 { |
97 » » CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 97 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
98 » » if (CFFL_IFormFiller::IsVisible(pWidget)) | 98 if (CFFL_IFormFiller::IsVisible(pWidget)) |
99 » » » pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Anno
t::Normal, NULL); | 99 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, N
ULL); |
100 » } | 100 } |
101 } | 101 } |
102 | 102 |
103 void CFFL_FormFiller::OnDrawDeactive(CPDFSDK_PageView *pPageView, /*HDC hDC,*/ C
PDFSDK_Annot* pAnnot, | 103 void CFFL_FormFiller::OnDrawDeactive(CPDFSDK_PageView *pPageView, CPDFSDK_Annot*
pAnnot, |
104 » » » » » » CFX_RenderDevice* pDevice, CPDF_
Matrix* pUser2Device, | 104 CFX_RenderDevice* pDevice, CPDF_Matrix* pUs
er2Device, |
105 » » » » » » /*const CRect& rcWindow,*/ FX_DW
ORD dwFlags) | 105 FX_DWORD dwFlags) |
106 { | 106 { |
107 » ASSERT(pAnnot != NULL); | 107 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
108 | 108 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL); |
109 » CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | |
110 | |
111 » pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL)
; | |
112 } | 109 } |
113 | 110 |
114 | 111 |
115 void CFFL_FormFiller::OnCreate(CPDFSDK_Annot* pAnnot) | 112 void CFFL_FormFiller::OnCreate(CPDFSDK_Annot* pAnnot) |
116 { | 113 { |
117 } | 114 } |
118 | 115 |
119 void CFFL_FormFiller::OnLoad(CPDFSDK_Annot* pAnnot) | 116 void CFFL_FormFiller::OnLoad(CPDFSDK_Annot* pAnnot) |
120 { | 117 { |
121 } | 118 } |
122 | 119 |
123 void CFFL_FormFiller::OnDelete(CPDFSDK_Annot* pAnnot) | 120 void CFFL_FormFiller::OnDelete(CPDFSDK_Annot* pAnnot) |
124 { | 121 { |
125 } | 122 } |
126 | 123 |
127 void CFFL_FormFiller::OnMouseEnter(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* p
Annot) | 124 void CFFL_FormFiller::OnMouseEnter(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* p
Annot) |
128 { | 125 { |
129 } | 126 } |
130 | 127 |
131 void CFFL_FormFiller::OnMouseExit(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pA
nnot) | 128 void CFFL_FormFiller::OnMouseExit(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pA
nnot) |
132 { | 129 { |
133 » EndTimer(); | 130 EndTimer(); |
134 » ASSERT(m_pWidget != NULL); | 131 ASSERT(m_pWidget != NULL); |
135 } | 132 } |
136 | 133 |
137 FX_BOOL CFFL_FormFiller::OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Anno
t* pAnnot, FX_UINT nFlags, const CPDF_Point& point) | 134 FX_BOOL CFFL_FormFiller::OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Anno
t* pAnnot, FX_UINT nFlags, const CPDF_Point& point) |
138 { | 135 { |
139 » if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, TRUE)) | 136 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, TRUE)) |
140 » { | 137 { |
141 » » m_bValid = TRUE; | 138 m_bValid = TRUE; |
142 » » FX_RECT rect = GetViewBBox(pPageView,pAnnot); | 139 FX_RECT rect = GetViewBBox(pPageView,pAnnot); |
143 » » InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); | 140 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); |
144 | 141 |
145 » » if(!rect.Contains((int)point.x, (int)point.y)) | 142 if(!rect.Contains((int)point.x, (int)point.y)) |
146 » » » return FALSE; | 143 return FALSE; |
147 | 144 |
148 » » return pWnd->OnLButtonDown(WndtoPWL(pPageView, point),nFlags); | 145 return pWnd->OnLButtonDown(WndtoPWL(pPageView, point),nFlags); |
149 » } | 146 } |
150 | 147 |
151 » return FALSE; | 148 return FALSE; |
152 } | 149 } |
153 | 150 |
154 FX_BOOL»CFFL_FormFiller::OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot*
pAnnot, FX_UINT nFlags, const CPDF_Point& point) | 151 FX_BOOL CFFL_FormFiller::OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot*
pAnnot, FX_UINT nFlags, const CPDF_Point& point) |
155 { | 152 { |
156 » if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE)) | 153 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE)) |
157 » { | 154 { |
158 » » FX_RECT rcFFL = GetViewBBox(pPageView, pAnnot); | 155 FX_RECT rcFFL = GetViewBBox(pPageView, pAnnot); |
159 » » InvalidateRect(rcFFL.left, rcFFL.top, rcFFL.right, rcFFL.bottom)
; | 156 InvalidateRect(rcFFL.left, rcFFL.top, rcFFL.right, rcFFL.bottom); |
160 » » pWnd->OnLButtonUp(WndtoPWL(pPageView, point),nFlags); | 157 pWnd->OnLButtonUp(WndtoPWL(pPageView, point),nFlags); |
161 » » return TRUE; | 158 return TRUE; |
162 » } | 159 } |
163 | 160 |
164 » return FALSE; | 161 return FALSE; |
165 } | 162 } |
166 | 163 |
167 FX_BOOL»CFFL_FormFiller::OnLButtonDblClk(CPDFSDK_PageView *pPageView, CPDFSDK_An
not* pAnnot, FX_UINT nFlags, const CPDF_Point& point) | 164 FX_BOOL CFFL_FormFiller::OnLButtonDblClk(CPDFSDK_PageView *pPageView, CPDFSDK_An
not* pAnnot, FX_UINT nFlags, const CPDF_Point& point) |
168 { | 165 { |
169 » if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE)) | 166 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE)) |
170 » { | 167 { |
171 » » pWnd->OnLButtonDblClk(WndtoPWL(pPageView, point),nFlags); | 168 pWnd->OnLButtonDblClk(WndtoPWL(pPageView, point),nFlags); |
172 » » return TRUE; | 169 return TRUE; |
173 » } | 170 } |
174 | 171 |
175 » return FALSE; | 172 return FALSE; |
176 } | 173 } |
177 | 174 |
178 FX_BOOL CFFL_FormFiller::OnMouseMove(CPDFSDK_PageView *pPageView, CPDFSDK_Annot*
pAnnot, FX_UINT nFlags, const CPDF_Point& point) | 175 FX_BOOL CFFL_FormFiller::OnMouseMove(CPDFSDK_PageView *pPageView, CPDFSDK_Annot*
pAnnot, FX_UINT nFlags, const CPDF_Point& point) |
179 { | 176 { |
180 » if ((m_ptOldPos.x != point.x) || (m_ptOldPos.y != point.y)) | 177 if ((m_ptOldPos.x != point.x) || (m_ptOldPos.y != point.y)) |
181 » { | 178 { |
182 » » m_ptOldPos = point; | 179 m_ptOldPos = point; |
183 » } | 180 } |
184 | 181 |
185 » if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE)) | 182 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE)) |
186 » { | 183 { |
187 » » pWnd->OnMouseMove(WndtoPWL(pPageView, point),nFlags); | 184 pWnd->OnMouseMove(WndtoPWL(pPageView, point),nFlags); |
188 » » return TRUE; | 185 return TRUE; |
189 » } | 186 } |
190 | 187 |
191 » return FALSE; | 188 return FALSE; |
192 } | 189 } |
193 | 190 |
194 FX_BOOL CFFL_FormFiller::OnMouseWheel(CPDFSDK_PageView *pPageView, CPDFSDK_Annot
* pAnnot, FX_UINT nFlags, short zDelta, const CPDF_Point& point) | 191 FX_BOOL CFFL_FormFiller::OnMouseWheel(CPDFSDK_PageView *pPageView, CPDFSDK_Annot
* pAnnot, FX_UINT nFlags, short zDelta, const CPDF_Point& point) |
195 { | 192 { |
196 » if (!IsValid()) return FALSE; | 193 if (!IsValid()) return FALSE; |
197 | 194 |
198 » if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, TRUE)) | 195 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, TRUE)) |
199 » { | 196 { |
200 » » return pWnd->OnMouseWheel(zDelta, WndtoPWL(pPageView, point),nFl
ags); | 197 return pWnd->OnMouseWheel(zDelta, WndtoPWL(pPageView, point),nFlags); |
201 » } | 198 } |
202 | 199 |
203 » return FALSE; | 200 return FALSE; |
204 } | 201 } |
205 | 202 |
206 FX_BOOL CFFL_FormFiller::OnRButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Anno
t* pAnnot, FX_UINT nFlags, const CPDF_Point& point) | 203 FX_BOOL CFFL_FormFiller::OnRButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Anno
t* pAnnot, FX_UINT nFlags, const CPDF_Point& point) |
207 { | 204 { |
208 » if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, TRUE)) | 205 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, TRUE)) |
209 » { | 206 { |
210 » » pWnd->OnRButtonDown(WndtoPWL(pPageView, point),nFlags); | 207 pWnd->OnRButtonDown(WndtoPWL(pPageView, point),nFlags); |
211 » » return TRUE; | 208 return TRUE; |
212 » } | 209 } |
213 | 210 |
214 » return FALSE; | 211 return FALSE; |
215 } | 212 } |
216 | 213 |
217 FX_BOOL»CFFL_FormFiller::OnRButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot*
pAnnot, FX_UINT nFlags, const CPDF_Point& point) | 214 FX_BOOL CFFL_FormFiller::OnRButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot*
pAnnot, FX_UINT nFlags, const CPDF_Point& point) |
218 { | 215 { |
219 » if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE)) | 216 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE)) |
220 » { | 217 { |
221 » » pWnd->OnRButtonUp(WndtoPWL(pPageView, point),nFlags); | 218 pWnd->OnRButtonUp(WndtoPWL(pPageView, point),nFlags); |
222 » » return TRUE; | 219 return TRUE; |
223 » } | 220 } |
224 | 221 |
225 » return FALSE; | 222 return FALSE; |
226 } | 223 } |
227 | 224 |
228 FX_BOOL»CFFL_FormFiller::OnRButtonDblClk(CPDFSDK_PageView *pPageView, CPDFSDK_An
not* pAnnot, FX_UINT nFlags, const CPDF_Point& point) | 225 FX_BOOL CFFL_FormFiller::OnRButtonDblClk(CPDFSDK_PageView *pPageView, CPDFSDK_An
not* pAnnot, FX_UINT nFlags, const CPDF_Point& point) |
229 { | 226 { |
230 » if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE)) | 227 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE)) |
231 » { | 228 { |
232 » » pWnd->OnRButtonDblClk(WndtoPWL(pPageView, point),nFlags); | 229 pWnd->OnRButtonDblClk(WndtoPWL(pPageView, point),nFlags); |
233 » » return TRUE; | 230 return TRUE; |
234 » } | 231 } |
235 | 232 |
236 » return FALSE; | 233 return FALSE; |
237 } | 234 } |
238 | 235 |
239 FX_BOOL CFFL_FormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, FX_UINT nKeyCode, FX_U
INT nFlags) | 236 FX_BOOL CFFL_FormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, FX_UINT nKeyCode, FX_U
INT nFlags) |
240 { | 237 { |
241 » if (IsValid()) | 238 if (IsValid()) |
242 » { | 239 { |
243 » » CPDFSDK_PageView* pPageView = GetCurPageView(); | 240 CPDFSDK_PageView* pPageView = GetCurPageView(); |
244 » » ASSERT(pPageView != NULL); | 241 ASSERT(pPageView != NULL); |
245 | 242 |
246 » » if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE)) | 243 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE)) |
247 » » { | 244 { |
248 » » » return pWnd->OnKeyDown(nKeyCode,nFlags); | 245 return pWnd->OnKeyDown(nKeyCode,nFlags); |
249 » » } | 246 } |
250 » } | 247 } |
251 | 248 |
252 » return FALSE; | 249 return FALSE; |
253 } | 250 } |
254 | 251 |
255 FX_BOOL»CFFL_FormFiller::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nF
lags) | 252 FX_BOOL CFFL_FormFiller::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nF
lags) |
256 { | 253 { |
257 » if (IsValid()) | 254 if (IsValid()) |
258 » { | 255 { |
259 » » CPDFSDK_PageView* pPageView = GetCurPageView(); | 256 CPDFSDK_PageView* pPageView = GetCurPageView(); |
260 » » ASSERT(pPageView != NULL); | 257 ASSERT(pPageView != NULL); |
261 | 258 |
262 » » if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE)) | 259 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE)) |
263 » » { | 260 { |
264 » » » return pWnd->OnChar(nChar,nFlags); | 261 return pWnd->OnChar(nChar,nFlags); |
265 » » } | 262 } |
266 » } | 263 } |
267 | 264 |
268 » return FALSE; | 265 return FALSE; |
269 } | 266 } |
270 | 267 |
271 void CFFL_FormFiller::OnDeSelected(CPDFSDK_Annot* pAnnot) | 268 void CFFL_FormFiller::OnDeSelected(CPDFSDK_Annot* pAnnot) |
272 { | 269 { |
273 » ASSERT(FALSE); | 270 ASSERT(FALSE); |
274 } | 271 } |
275 | 272 |
276 void CFFL_FormFiller::OnSelected(CPDFSDK_Annot* pAnnot) | 273 void CFFL_FormFiller::OnSelected(CPDFSDK_Annot* pAnnot) |
277 { | 274 { |
278 » ASSERT(FALSE); | 275 ASSERT(FALSE); |
279 } | 276 } |
280 | 277 |
281 FX_BOOL»CFFL_FormFiller::OnSetFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) | 278 FX_BOOL CFFL_FormFiller::OnSetFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) |
282 { | 279 { |
283 » CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 280 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
284 | 281 CPDFXFA_Page* pPage = pWidget->GetPDFXFAPage(); |
285 » CPDFXFA_Page * pPage = pWidget->GetPDFXFAPage(); | 282 CPDFSDK_Document* pDoc = m_pApp->GetSDKDocument(); |
286 » CPDFSDK_Document * pDoc = m_pApp->GetCurrentDoc(); | 283 CPDFSDK_PageView* pPageView = pDoc->GetPageView(pPage); |
287 » CPDFSDK_PageView* pPageView = pDoc->GetPageView(pPage); | 284 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE)) |
288 » ASSERT(pPageView != NULL); | 285 pWnd->SetFocus(); |
289 | 286 |
290 | 287 m_bValid = TRUE; |
291 | 288 FX_RECT rcRect = GetViewBBox(pPageView,pAnnot); |
292 » CPWL_Wnd * pWnd = NULL; | 289 InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom); |
293 » if ( (pWnd = GetPDFWindow(pPageView, TRUE))) | 290 return TRUE; |
294 » { | 291 } |
295 » » pWnd->SetFocus(); | 292 |
296 » } | 293 FX_BOOL CFFL_FormFiller::OnKillFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) |
297 | 294 { |
298 » m_bValid = TRUE; | 295 if (!IsValid()) |
299 | 296 return TRUE; |
300 | 297 |
301 | 298 CPDFSDK_PageView* pPageView = GetCurPageView(); |
302 | 299 CommitData(pPageView, nFlag); |
303 » m_bValid = TRUE; | 300 |
304 » FX_RECT rcRect = GetViewBBox(pPageView,pAnnot); | 301 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) |
305 » InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom); | 302 pWnd->KillFocus(); |
306 | 303 |
307 » return TRUE; | 304 switch (m_pWidget->GetFieldType()) |
308 } | 305 { |
309 | 306 case FIELDTYPE_PUSHBUTTON: |
310 FX_BOOL»CFFL_FormFiller::OnKillFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) | 307 case FIELDTYPE_CHECKBOX: |
311 { | 308 case FIELDTYPE_RADIOBUTTON: |
312 » if (IsValid()) | 309 EscapeFiller(pPageView, TRUE); |
313 » { | 310 break; |
314 » » CPDFSDK_PageView* pPageView = GetCurPageView(); | 311 default: |
315 » » ASSERT(pPageView != NULL); | 312 EscapeFiller(pPageView, FALSE); |
316 | 313 break; |
317 » » CommitData(pPageView, nFlag); | 314 } |
318 | 315 return TRUE; |
319 » » if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) | 316 } |
320 » » { | 317 |
321 » » » pWnd->KillFocus(); | 318 FX_BOOL CFFL_FormFiller::IsValid() const |
322 » » } | 319 { |
323 | 320 return m_bValid; |
324 » » switch (m_pWidget->GetFieldType()) | 321 } |
325 » » { | 322 |
326 » » case FIELDTYPE_PUSHBUTTON: | 323 PWL_CREATEPARAM CFFL_FormFiller::GetCreateParam() |
327 » » case FIELDTYPE_CHECKBOX: | 324 { |
328 » » case FIELDTYPE_RADIOBUTTON: | 325 ASSERT(m_pApp != NULL); |
329 » » » EscapeFiller(pPageView, TRUE); | 326 |
330 » » » break; | 327 PWL_CREATEPARAM cp; |
331 » » default: | 328 cp.pParentWnd = NULL; |
332 » » » EscapeFiller(pPageView, FALSE); | 329 cp.pProvider = this; |
333 » » » break; | 330 cp.rcRectWnd = GetPDFWindowRect(); |
334 » » } | 331 |
335 » } | 332 FX_DWORD dwCreateFlags = PWS_BORDER | PWS_BACKGROUND | PWS_VISIBLE; |
336 | 333 FX_DWORD dwFieldFlag = m_pWidget->GetFieldFlags(); |
337 » return TRUE; | 334 if (dwFieldFlag & FIELDFLAG_READONLY) |
338 } | 335 { |
339 | 336 dwCreateFlags |= PWS_READONLY; |
340 FX_BOOL»CFFL_FormFiller::IsValid() const | 337 } |
341 { | 338 |
342 » return m_bValid; | 339 FX_COLORREF color; |
343 } | 340 if (m_pWidget->GetFillColor(color)) |
344 | 341 { |
345 PWL_CREATEPARAM»CFFL_FormFiller::GetCreateParam() | 342 cp.sBackgroundColor = CPWL_Color(GetRed(color), GetGreen(color), GetBlue
(color)); |
346 { | 343 } |
347 » ASSERT(m_pApp != NULL); | 344 |
348 | 345 if (m_pWidget->GetBorderColor(color)) |
349 » PWL_CREATEPARAM cp; | 346 { |
350 | 347 cp.sBorderColor = CPWL_Color(GetRed(color), GetGreen(color), GetBlue(col
or)); |
351 » cp.pParentWnd = NULL; | 348 } |
352 » cp.pProvider = this; | 349 |
353 » cp.rcRectWnd = GetPDFWindowRect(); | 350 cp.sTextColor = CPWL_Color(COLORTYPE_GRAY,0); |
354 | 351 |
355 » FX_DWORD dwCreateFlags = PWS_BORDER | PWS_BACKGROUND | PWS_VISIBLE; | 352 if (m_pWidget->GetTextColor(color)) |
356 | 353 { |
357 » ASSERT(m_pWidget != NULL); | 354 cp.sTextColor = CPWL_Color(GetRed(color), GetGreen(color), GetBlue(color
)); |
358 | 355 } |
359 | 356 |
360 » FX_DWORD dwFieldFlag = m_pWidget->GetFieldFlags(); | 357 cp.fFontSize = m_pWidget->GetFontSize(); |
361 | 358 cp.dwBorderWidth = m_pWidget->GetBorderWidth(); |
362 » if (dwFieldFlag & FIELDFLAG_READONLY) | 359 |
363 » { | 360 int nBorderStyle = m_pWidget->GetBorderStyle(); |
364 » » dwCreateFlags |= PWS_READONLY; | 361 |
365 » } | 362 switch (nBorderStyle) |
366 | 363 { |
367 » FX_COLORREF color; | 364 case BBS_SOLID: |
368 » if (m_pWidget->GetFillColor(color)) | 365 cp.nBorderStyle = PBS_SOLID; |
369 » { | 366 break; |
370 » » cp.sBackgroundColor = CPWL_Color(GetRed(color), GetGreen(color),
GetBlue(color)); | 367 case BBS_DASH: |
371 » } | 368 cp.nBorderStyle = PBS_DASH; |
372 | 369 cp.sDash = CPWL_Dash(3,3,0); |
373 » if (m_pWidget->GetBorderColor(color)) | 370 break; |
374 » { | 371 case BBS_BEVELED: |
375 » » cp.sBorderColor = CPWL_Color(GetRed(color), GetGreen(color), Get
Blue(color)); | 372 cp.nBorderStyle = PBS_BEVELED; |
376 » } | 373 cp.dwBorderWidth *= 2; |
377 | 374 break; |
378 » cp.sTextColor = CPWL_Color(COLORTYPE_GRAY,0); | 375 case BBS_INSET: |
379 | 376 cp.nBorderStyle = PBS_INSET; |
380 » if (m_pWidget->GetTextColor(color)) | 377 cp.dwBorderWidth *= 2; |
381 » { | 378 break; |
382 » » cp.sTextColor = CPWL_Color(GetRed(color), GetGreen(color), GetBl
ue(color)); | 379 case BBS_UNDERLINE: |
383 » } | 380 cp.nBorderStyle = PBS_UNDERLINED; |
384 | 381 break; |
385 » cp.fFontSize = m_pWidget->GetFontSize(); | 382 } |
386 » cp.dwBorderWidth = m_pWidget->GetBorderWidth(); | 383 |
387 | 384 if (cp.fFontSize <= 0) |
388 » int nBorderStyle = m_pWidget->GetBorderStyle(); | 385 { |
389 | 386 dwCreateFlags |= PWS_AUTOFONTSIZE; |
390 » switch (nBorderStyle) | 387 } |
391 » { | 388 |
392 » case BBS_SOLID: | 389 cp.dwFlags = dwCreateFlags; |
393 » » cp.nBorderStyle = PBS_SOLID; | 390 cp.pSystemHandler = m_pApp->GetSysHandler(); |
394 » » break; | 391 return cp; |
395 » case BBS_DASH: | |
396 » » cp.nBorderStyle = PBS_DASH; | |
397 » » cp.sDash = CPWL_Dash(3,3,0); | |
398 » » break; | |
399 » case BBS_BEVELED: | |
400 » » cp.nBorderStyle = PBS_BEVELED; | |
401 » » cp.dwBorderWidth *= 2; | |
402 » » break; | |
403 » case BBS_INSET: | |
404 » » cp.nBorderStyle = PBS_INSET; | |
405 » » cp.dwBorderWidth *= 2; | |
406 » » break; | |
407 » case BBS_UNDERLINE: | |
408 » » cp.nBorderStyle = PBS_UNDERLINED; | |
409 » » break; | |
410 » } | |
411 | |
412 » if (cp.fFontSize <= 0) | |
413 » { | |
414 » » dwCreateFlags |= PWS_AUTOFONTSIZE; | |
415 » } | |
416 | |
417 » cp.dwFlags = dwCreateFlags; | |
418 » cp.pSystemHandler = m_pApp->GetSysHandler(); | |
419 » return cp; | |
420 } | 392 } |
421 | 393 |
422 CPWL_Wnd* CFFL_FormFiller::GetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bNe
w) | 394 CPWL_Wnd* CFFL_FormFiller::GetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bNe
w) |
423 { | 395 { |
424 ASSERT(pPageView); | 396 ASSERT(pPageView); |
425 | 397 |
426 auto it = m_Maps.find(pPageView); | 398 auto it = m_Maps.find(pPageView); |
427 const bool found = it != m_Maps.end(); | 399 const bool found = it != m_Maps.end(); |
428 CPWL_Wnd* pWnd = found ? it->second : nullptr; | 400 CPWL_Wnd* pWnd = found ? it->second : nullptr; |
429 if (!bNew) | 401 if (!bNew) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 | 435 |
464 CPWL_Wnd* pWnd = it->second; | 436 CPWL_Wnd* pWnd = it->second; |
465 CFFL_PrivateData* pData = (CFFL_PrivateData*)pWnd->GetAttachedData(); | 437 CFFL_PrivateData* pData = (CFFL_PrivateData*)pWnd->GetAttachedData(); |
466 pWnd->Destroy(); | 438 pWnd->Destroy(); |
467 delete pWnd; | 439 delete pWnd; |
468 delete pData; | 440 delete pData; |
469 | 441 |
470 m_Maps.erase(it); | 442 m_Maps.erase(it); |
471 } | 443 } |
472 | 444 |
473 CPDF_Matrix» CFFL_FormFiller::GetWindowMatrix(void* pAttachedData) | 445 CPDF_Matrix CFFL_FormFiller::GetWindowMatrix(void* pAttachedData) |
474 { | 446 { |
475 » if (CFFL_PrivateData* pPrivateData = (CFFL_PrivateData*)pAttachedData) | 447 if (CFFL_PrivateData* pPrivateData = (CFFL_PrivateData*)pAttachedData) |
476 » { | 448 { |
477 » » if (pPrivateData->pPageView) | 449 if (pPrivateData->pPageView) |
478 » » { | 450 { |
479 » » » CPDF_Matrix mtPageView; | 451 CPDF_Matrix mtPageView; |
480 » » » pPrivateData->pPageView->GetCurrentMatrix(mtPageView); | 452 pPrivateData->pPageView->GetCurrentMatrix(mtPageView); |
481 » » » CPDF_Matrix mt = GetCurMatrix(); | 453 CPDF_Matrix mt = GetCurMatrix(); |
482 » » » mt.Concat(mtPageView); | 454 mt.Concat(mtPageView); |
483 | 455 |
484 » » » return mt; | 456 return mt; |
485 » » } | 457 } |
486 » } | 458 } |
487 » return CPDF_Matrix(1,0,0,1,0,0); | 459 return CPDF_Matrix(1,0,0,1,0,0); |
488 } | 460 } |
489 | 461 |
490 CPDF_Matrix» CFFL_FormFiller::GetCurMatrix() | 462 CPDF_Matrix CFFL_FormFiller::GetCurMatrix() |
491 { | 463 { |
492 » CPDF_Matrix mt; | 464 CPDF_Matrix mt; |
493 | 465 |
494 » ASSERT(m_pWidget != NULL); | 466 ASSERT(m_pWidget != NULL); |
495 | 467 |
496 » CPDF_Rect rcDA ; | 468 CPDF_Rect rcDA ; |
497 » m_pWidget->GetPDFAnnot()->GetRect(rcDA); | 469 m_pWidget->GetPDFAnnot()->GetRect(rcDA); |
498 | 470 |
499 | 471 |
500 » switch (m_pWidget->GetRotate()) | 472 switch (m_pWidget->GetRotate()) |
501 » { | 473 { |
502 » default: | 474 default: |
503 » case 0: | 475 case 0: |
504 » » mt = CPDF_Matrix(1,0,0,1,0,0); | 476 mt = CPDF_Matrix(1,0,0,1,0,0); |
505 » » break; | 477 break; |
506 » case 90: | 478 case 90: |
507 » » mt = CPDF_Matrix(0,1,-1,0,rcDA.right - rcDA.left,0); | 479 mt = CPDF_Matrix(0,1,-1,0,rcDA.right - rcDA.left,0); |
508 » » break; | 480 break; |
509 » case 180: | 481 case 180: |
510 » » mt = CPDF_Matrix(-1,0,0,-1,rcDA.right - rcDA.left,rcDA.top - rcD
A.bottom); | 482 mt = CPDF_Matrix(-1,0,0,-1,rcDA.right - rcDA.left,rcDA.top - rcDA.bottom
); |
511 » » break; | 483 break; |
512 » case 270: | 484 case 270: |
513 » » mt = CPDF_Matrix(0,-1,1,0,0,rcDA.top - rcDA.bottom); | 485 mt = CPDF_Matrix(0,-1,1,0,0,rcDA.top - rcDA.bottom); |
514 » » break; | 486 break; |
515 » } | 487 } |
516 » mt.e += rcDA.left; | 488 mt.e += rcDA.left; |
517 » mt.f += rcDA.bottom; | 489 mt.f += rcDA.bottom; |
518 | 490 |
519 » return mt; | 491 return mt; |
520 } | 492 } |
521 | 493 |
522 CFX_WideString CFFL_FormFiller::LoadPopupMenuString(int nIndex) | 494 CFX_WideString CFFL_FormFiller::LoadPopupMenuString(int nIndex) |
523 { | 495 { |
524 » ASSERT(m_pApp != NULL); | 496 ASSERT(m_pApp != NULL); |
525 | 497 |
526 » return L""; | 498 return L""; |
527 } | 499 } |
528 | 500 |
529 CPDF_Rect CFFL_FormFiller::GetPDFWindowRect() const | 501 CPDF_Rect CFFL_FormFiller::GetPDFWindowRect() const |
530 { | 502 { |
531 » ASSERT(m_pWidget != NULL); | 503 CPDF_Rect rectAnnot; |
| 504 m_pWidget->GetPDFAnnot()->GetRect(rectAnnot); |
532 | 505 |
533 » CPDF_Rect rectAnnot; | 506 FX_FLOAT fWidth = rectAnnot.right - rectAnnot.left; |
534 » m_pWidget->GetPDFAnnot()->GetRect(rectAnnot); | 507 FX_FLOAT fHeight = rectAnnot.top - rectAnnot.bottom; |
| 508 if ((m_pWidget->GetRotate() / 90) & 0x01) |
| 509 return CPDF_Rect(0, 0, fHeight, fWidth); |
535 | 510 |
536 » FX_FLOAT fWidth = rectAnnot.right - rectAnnot.left; | 511 return CPDF_Rect(0, 0, fWidth, fHeight); |
537 » FX_FLOAT fHeight = rectAnnot.top - rectAnnot.bottom; | |
538 | |
539 | |
540 » if ((m_pWidget->GetRotate() / 90) & 0x01) | |
541 » » return CPDF_Rect(0,0,fHeight,fWidth); | |
542 » else | |
543 » » return CPDF_Rect(0,0,fWidth,fHeight); | |
544 } | 512 } |
545 | 513 |
546 CPDFSDK_PageView* CFFL_FormFiller::GetCurPageView() | 514 CPDFSDK_PageView* CFFL_FormFiller::GetCurPageView() |
547 { | 515 { |
548 | 516 CPDFXFA_Page* pPage = m_pAnnot->GetPDFXFAPage(); |
549 » CPDFXFA_Page* pPage = m_pAnnot->GetPDFXFAPage(); | 517 CPDFSDK_Document* pSDKDoc = m_pApp->GetSDKDocument(); |
550 » CPDFSDK_Document* pSDKDoc = m_pApp->GetCurrentDoc(); | 518 if (!pSDKDoc) |
551 » if(pSDKDoc) | 519 return NULL; |
552 » { | 520 return pSDKDoc->GetPageView(pPage); |
553 » » return pSDKDoc->GetPageView(pPage); | |
554 » } | |
555 » return NULL; | |
556 } | 521 } |
557 | 522 |
558 CPDF_Rect CFFL_FormFiller::GetFocusBox(CPDFSDK_PageView* pPageView) | 523 CPDF_Rect CFFL_FormFiller::GetFocusBox(CPDFSDK_PageView* pPageView) |
559 { | 524 { |
560 » if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE)) | 525 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) |
561 » { | 526 { |
562 » » CPDF_Rect rcFocus = FFLtoWnd(pPageView, PWLtoFFL(pWnd->GetFocus
Rect())); | 527 CPDF_Rect rcFocus = FFLtoWnd(pPageView, PWLtoFFL(pWnd->GetFocusRect())); |
563 » » ASSERT(pPageView); | 528 CPDF_Rect rcPage = pPageView->GetPDFPage()->GetPageBBox(); |
564 » » CPDF_Rect rcPage = pPageView->GetPDFPage()->GetPageBBox(); | 529 if (rcPage.Contains(rcFocus)) |
565 » » if(rcPage.Contains(rcFocus)) | 530 return rcFocus; |
566 » » » return rcFocus; | 531 } |
567 » » else | 532 return CPDF_Rect(0,0,0,0); |
568 » » » return CPDF_Rect(0,0,0,0); | |
569 » } | |
570 » return CPDF_Rect(0,0,0,0); | |
571 } | 533 } |
572 | 534 |
573 CPDF_Rect CFFL_FormFiller::FFLtoPWL(const CPDF_Rect& rect) | 535 CPDF_Rect CFFL_FormFiller::FFLtoPWL(const CPDF_Rect& rect) |
574 { | 536 { |
575 » CPDF_Matrix mt; | 537 CPDF_Matrix mt; |
576 » mt.SetReverse(GetCurMatrix()); | 538 mt.SetReverse(GetCurMatrix()); |
577 | 539 |
578 » CPDF_Rect temp = rect; | 540 CPDF_Rect temp = rect; |
579 » mt.TransformRect(temp); | 541 mt.TransformRect(temp); |
580 | 542 |
581 » return temp; | 543 return temp; |
582 } | 544 } |
583 | 545 |
584 CPDF_Rect CFFL_FormFiller::PWLtoFFL(const CPDF_Rect& rect) | 546 CPDF_Rect CFFL_FormFiller::PWLtoFFL(const CPDF_Rect& rect) |
585 { | 547 { |
586 » CPDF_Matrix mt = GetCurMatrix(); | 548 CPDF_Matrix mt = GetCurMatrix(); |
587 | 549 |
588 » CPDF_Rect temp = rect; | 550 CPDF_Rect temp = rect; |
589 » mt.TransformRect(temp); | 551 mt.TransformRect(temp); |
590 | 552 |
591 » return temp; | 553 return temp; |
592 } | 554 } |
593 | 555 |
594 CPDF_Point CFFL_FormFiller::FFLtoPWL(const CPDF_Point& point) | 556 CPDF_Point CFFL_FormFiller::FFLtoPWL(const CPDF_Point& point) |
595 { | 557 { |
596 » CPDF_Matrix mt; | 558 CPDF_Matrix mt; |
597 » mt.SetReverse(GetCurMatrix()); | 559 mt.SetReverse(GetCurMatrix()); |
598 | 560 |
599 » CPDF_Point pt = point; | 561 CPDF_Point pt = point; |
600 » mt.Transform(pt.x,pt.y); | 562 mt.Transform(pt.x,pt.y); |
601 | 563 |
602 » return pt; | 564 return pt; |
603 } | 565 } |
604 | 566 |
605 CPDF_Point CFFL_FormFiller::PWLtoFFL(const CPDF_Point & point) | 567 CPDF_Point CFFL_FormFiller::PWLtoFFL(const CPDF_Point & point) |
606 { | 568 { |
607 » CPDF_Matrix mt = GetCurMatrix(); | 569 CPDF_Matrix mt = GetCurMatrix(); |
608 | 570 |
609 » CPDF_Point pt = point; | 571 CPDF_Point pt = point; |
610 » mt.Transform(pt.x,pt.y); | 572 mt.Transform(pt.x,pt.y); |
611 | 573 |
612 » return pt; | 574 return pt; |
613 } | 575 } |
614 | 576 |
615 CPDF_Point CFFL_FormFiller::WndtoPWL(CPDFSDK_PageView* pPageView, const CPDF_Poi
nt& pt) | 577 CPDF_Point CFFL_FormFiller::WndtoPWL(CPDFSDK_PageView* pPageView, const CPDF_Poi
nt& pt) |
616 { | 578 { |
617 // » ASSERT(pPageView != NULL); | 579 return FFLtoPWL(pt); |
618 // | |
619 // » CPDF_Point point(0.0f, 0.0f); | |
620 // » pPageView->WindowToDoc(pt.x, pt.y, point.x, point.y); | |
621 // | |
622 » return FFLtoPWL(pt); | |
623 //» return CPDF_Point(0, 0); | |
624 } | 580 } |
625 | 581 |
626 CPDF_Rect CFFL_FormFiller::FFLtoWnd(CPDFSDK_PageView* pPageView, const CPDF_Rect
& rect) | 582 CPDF_Rect CFFL_FormFiller::FFLtoWnd(CPDFSDK_PageView* pPageView, const CPDF_Rect
& rect) |
627 { | 583 { |
628 // » FX_RECT rcRet(0,0,0,0); | 584 return rect; |
629 // | |
630 // » ASSERT(pPageView != NULL); | |
631 // » pPageView->DocToWindow(rect, rcRet); | |
632 // | |
633 » return rect; | |
634 | |
635 } | |
636 | |
637 void CFFL_FormFiller::FFL_FreeData(void* pData) | |
638 { | |
639 » ASSERT(pData != NULL); | |
640 | |
641 » delete (CFFL_PrivateData*)pData; | |
642 } | 585 } |
643 | 586 |
644 FX_BOOL CFFL_FormFiller::CommitData(CPDFSDK_PageView* pPageView, FX_UINT nFlag) | 587 FX_BOOL CFFL_FormFiller::CommitData(CPDFSDK_PageView* pPageView, FX_UINT nFlag) |
645 { | 588 { |
646 » if (IsDataChanged(pPageView)) | 589 if (IsDataChanged(pPageView)) |
647 » { | 590 { |
648 » » //CFFL_IFormFiller* pIFormFiller = CFFL_Module::GetFormFiller(m_
pApp); | 591 FX_BOOL bRC = TRUE; |
649 » » CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller();//NULL
; | 592 FX_BOOL bExit = FALSE; |
650 » » ASSERT(pIFormFiller != NULL); | 593 CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller(); |
| 594 pIFormFiller->OnKeyStrokeCommit(m_pWidget, pPageView, bRC, bExit, nFlag)
; |
| 595 if (bExit) |
| 596 return TRUE; |
| 597 if (!bRC) |
| 598 { |
| 599 ResetPDFWindow(pPageView, FALSE); |
| 600 return TRUE; |
| 601 } |
651 | 602 |
652 » » FX_BOOL bRC = TRUE; | 603 pIFormFiller->OnValidate(m_pWidget, pPageView, bRC, bExit, nFlag); |
653 » » FX_BOOL bExit = FALSE; | 604 if (bExit) |
| 605 return TRUE; |
| 606 if (!bRC) |
| 607 { |
| 608 ResetPDFWindow(pPageView, FALSE); |
| 609 return TRUE; |
| 610 } |
654 | 611 |
655 » » pIFormFiller->OnKeyStrokeCommit(m_pWidget, pPageView, bRC, bExit
, nFlag); | 612 SaveData(pPageView); |
656 » » if (bExit) return TRUE; | 613 pIFormFiller->OnCalculate(m_pWidget, pPageView, bExit,nFlag); |
657 » » if (!bRC) | 614 if (bExit) |
658 » » { | 615 return TRUE; |
659 » » » ResetPDFWindow(pPageView, FALSE); | |
660 » » » return TRUE; | |
661 » » } | |
662 | 616 |
663 » » pIFormFiller->OnValidate(m_pWidget, pPageView, bRC, bExit, nFlag
); | 617 pIFormFiller->OnFormat(m_pWidget, pPageView, bExit,nFlag); |
664 » » if (bExit) return TRUE; | 618 } |
665 » » if (!bRC) | 619 return TRUE; |
666 » » { | |
667 » » » ResetPDFWindow(pPageView, FALSE); | |
668 » » » return TRUE; | |
669 » » } | |
670 | |
671 » » SaveData(pPageView); | |
672 | |
673 » » pIFormFiller->OnCalculate(m_pWidget, pPageView, bExit,nFlag); | |
674 » » if (bExit) return TRUE; | |
675 | |
676 » » pIFormFiller->OnFormat(m_pWidget, pPageView, bExit,nFlag); | |
677 » } | |
678 | |
679 » return TRUE; | |
680 } | 620 } |
681 | 621 |
682 FX_BOOL»CFFL_FormFiller::IsDataChanged(CPDFSDK_PageView* pPageView) | 622 FX_BOOL CFFL_FormFiller::IsDataChanged(CPDFSDK_PageView* pPageView) |
683 { | 623 { |
684 » return FALSE; | 624 return FALSE; |
685 } | 625 } |
686 | 626 |
687 void CFFL_FormFiller::SaveData(CPDFSDK_PageView* pPageView) | 627 void CFFL_FormFiller::SaveData(CPDFSDK_PageView* pPageView) |
688 { | 628 { |
689 } | 629 } |
690 | 630 |
691 void CFFL_FormFiller::GetKeyStrokeData(CPDFSDK_PageView* pPageView, FFL_KeyStrok
eData& data) | 631 void CFFL_FormFiller::GetKeyStrokeData(CPDFSDK_PageView* pPageView, FFL_KeyStrok
eData& data) |
692 { | 632 { |
693 } | 633 } |
694 | 634 |
695 FX_BOOL CFFL_FormFiller::IsFieldFull(CPDFSDK_PageView* pPageView) | 635 FX_BOOL CFFL_FormFiller::IsFieldFull(CPDFSDK_PageView* pPageView) |
696 { | 636 { |
697 » return FALSE; | 637 return FALSE; |
698 } | 638 } |
699 | 639 |
700 void CFFL_FormFiller::SetChangeMark() | 640 void CFFL_FormFiller::SetChangeMark() |
701 { | 641 { |
702 » m_pApp->FFI_OnChange(); | 642 m_pApp->FFI_OnChange(); |
703 } | 643 } |
704 | 644 |
705 void CFFL_FormFiller::GetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::A
ActionType type, | 645 void CFFL_FormFiller::GetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::A
ActionType type, |
706 » » » » » » » PDFSDK_FieldAction& fa) | 646 PDFSDK_FieldAction& fa) |
707 { | 647 { |
708 » fa.sValue = m_pWidget->GetValue(); | 648 fa.sValue = m_pWidget->GetValue(); |
709 } | 649 } |
710 | 650 |
711 void CFFL_FormFiller::SetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::A
ActionType type, | 651 void CFFL_FormFiller::SetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::A
ActionType type, |
712 » » » » » » » » » const PD
FSDK_FieldAction& fa) | 652 const PDFSDK_FieldAction& fa) |
713 { | 653 { |
714 } | 654 } |
715 | 655 |
716 FX_BOOL»CFFL_FormFiller::IsActionDataChanged(CPDF_AAction::AActionType type, con
st PDFSDK_FieldAction& faOld, | 656 FX_BOOL CFFL_FormFiller::IsActionDataChanged(CPDF_AAction::AActionType type, con
st PDFSDK_FieldAction& faOld, |
717 » » » » » » » » » const PD
FSDK_FieldAction& faNew) | 657 const PDFSDK_FieldAction& faNew) |
718 { | 658 { |
719 » return FALSE; | 659 return FALSE; |
720 } | 660 } |
721 | 661 |
722 void CFFL_FormFiller::SaveState(CPDFSDK_PageView* pPageView) | 662 void CFFL_FormFiller::SaveState(CPDFSDK_PageView* pPageView) |
723 { | 663 { |
724 } | 664 } |
725 | 665 |
726 void CFFL_FormFiller::RestoreState(CPDFSDK_PageView* pPageView) | 666 void CFFL_FormFiller::RestoreState(CPDFSDK_PageView* pPageView) |
727 { | 667 { |
728 } | 668 } |
729 | 669 |
730 CPWL_Wnd* CFFL_FormFiller::ResetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL
bRestoreValue) | 670 CPWL_Wnd* CFFL_FormFiller::ResetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL
bRestoreValue) |
731 { | 671 { |
732 » return GetPDFWindow(pPageView, FALSE); | 672 return GetPDFWindow(pPageView, FALSE); |
733 } | 673 } |
734 | 674 |
735 void CFFL_FormFiller::TimerProc() | 675 void CFFL_FormFiller::TimerProc() |
736 { | 676 { |
737 | 677 |
738 } | 678 } |
739 | 679 |
740 IFX_SystemHandler* CFFL_FormFiller::GetSystemHandler() const | 680 IFX_SystemHandler* CFFL_FormFiller::GetSystemHandler() const |
741 { | 681 { |
742 » return m_pApp->GetSysHandler(); | 682 return m_pApp->GetSysHandler(); |
743 //» return NULL; | |
744 } | 683 } |
745 | 684 |
746 void CFFL_FormFiller::OnKeyStroke(FX_BOOL bKeyDown) | 685 void CFFL_FormFiller::OnKeyStroke(FX_BOOL bKeyDown) |
747 { | 686 { |
748 } | 687 } |
749 | 688 |
750 void CFFL_FormFiller::EscapeFiller(CPDFSDK_PageView* pPageView, FX_BOOL bDestroy
PDFWindow) | 689 void CFFL_FormFiller::EscapeFiller(CPDFSDK_PageView* pPageView, FX_BOOL bDestroy
PDFWindow) |
751 { | 690 { |
752 » m_bValid = FALSE; | 691 m_bValid = FALSE; |
753 | 692 |
754 » FX_RECT rcRect = GetViewBBox(pPageView, m_pWidget); | 693 FX_RECT rcRect = GetViewBBox(pPageView, m_pWidget); |
755 » InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom); | 694 InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom); |
756 | 695 |
757 » if(bDestroyPDFWindow) | 696 if(bDestroyPDFWindow) |
758 » » DestroyPDFWindow(pPageView); | 697 DestroyPDFWindow(pPageView); |
759 } | 698 } |
760 | 699 |
761 FX_BOOL CFFL_FormFiller::CanCopy(CPDFSDK_Document* pDocument) | 700 FX_BOOL CFFL_FormFiller::CanCopy(CPDFSDK_Document* pDocument) |
762 { | 701 { |
763 » return FALSE; | 702 return FALSE; |
764 } | 703 } |
765 | 704 |
766 FX_BOOL CFFL_FormFiller::CanCut(CPDFSDK_Document* pDocument) | 705 FX_BOOL CFFL_FormFiller::CanCut(CPDFSDK_Document* pDocument) |
767 { | 706 { |
768 » return FALSE; | 707 return FALSE; |
769 } | 708 } |
770 | 709 |
771 FX_BOOL»CFFL_FormFiller::CanPaste(CPDFSDK_Document* pDocument) | 710 FX_BOOL CFFL_FormFiller::CanPaste(CPDFSDK_Document* pDocument) |
772 { | 711 { |
773 » return FALSE; | 712 return FALSE; |
774 } | 713 } |
775 | 714 |
776 void CFFL_FormFiller::DoCopy(CPDFSDK_Document* pDocument) | 715 void CFFL_FormFiller::DoCopy(CPDFSDK_Document* pDocument) |
777 { | 716 { |
778 } | 717 } |
779 | 718 |
780 void CFFL_FormFiller::DoCut(CPDFSDK_Document* pDocument) | 719 void CFFL_FormFiller::DoCut(CPDFSDK_Document* pDocument) |
781 { | 720 { |
782 } | 721 } |
783 | 722 |
784 void CFFL_FormFiller::DoPaste(CPDFSDK_Document* pDocument) | 723 void CFFL_FormFiller::DoPaste(CPDFSDK_Document* pDocument) |
785 { | 724 { |
786 } | 725 } |
787 | 726 |
788 void CFFL_FormFiller::InvalidateRect(double left, double top, double right, doub
le bottom) | 727 void CFFL_FormFiller::InvalidateRect(double left, double top, double right, doub
le bottom) |
789 { | 728 { |
790 » CPDFXFA_Page * pPage = m_pWidget->GetPDFXFAPage(); | 729 CPDFXFA_Page* pPage = m_pWidget->GetPDFXFAPage(); |
791 » m_pApp->FFI_Invalidate(pPage, left, top, right, bottom); | 730 m_pApp->FFI_Invalidate(pPage, left, top, right, bottom); |
792 } | 731 } |
793 | 732 |
794 /* ------------------------- CFFL_Button ------------------------- */ | 733 /* ------------------------- CFFL_Button ------------------------- */ |
795 | 734 |
796 CFFL_Button::CFFL_Button(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pWidget) : | 735 CFFL_Button::CFFL_Button(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pWidget) : |
797 » CFFL_FormFiller(pApp, pWidget), | 736 CFFL_FormFiller(pApp, pWidget), |
798 » m_bMouseIn(FALSE), | 737 m_bMouseIn(FALSE), |
799 » m_bMouseDown(FALSE) | 738 m_bMouseDown(FALSE) |
800 { | 739 { |
801 } | 740 } |
802 | 741 |
803 CFFL_Button::~CFFL_Button() | 742 CFFL_Button::~CFFL_Button() |
804 { | 743 { |
805 } | 744 } |
806 | 745 |
807 void CFFL_Button::OnMouseEnter(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnno
t) | 746 void CFFL_Button::OnMouseEnter(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnno
t) |
808 { | 747 { |
809 » m_bMouseIn = TRUE; | 748 m_bMouseIn = TRUE; |
810 » FX_RECT rect = GetViewBBox(pPageView,pAnnot); | 749 FX_RECT rect = GetViewBBox(pPageView,pAnnot); |
811 » InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); | 750 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); |
812 } | 751 } |
813 | 752 |
814 void CFFL_Button::OnMouseExit(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot
) | 753 void CFFL_Button::OnMouseExit(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot
) |
815 { | 754 { |
816 » m_bMouseIn = FALSE; | 755 m_bMouseIn = FALSE; |
817 | 756 |
818 » FX_RECT rect = GetViewBBox(pPageView,pAnnot); | 757 FX_RECT rect = GetViewBBox(pPageView,pAnnot); |
819 » InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); | 758 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); |
820 » EndTimer(); | 759 EndTimer(); |
821 » ASSERT(m_pWidget != NULL); | 760 ASSERT(m_pWidget != NULL); |
822 } | 761 } |
823 | 762 |
824 FX_BOOL CFFL_Button::OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* p
Annot, FX_UINT nFlags, const CPDF_Point& point) | 763 FX_BOOL CFFL_Button::OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* p
Annot, FX_UINT nFlags, const CPDF_Point& point) |
825 { | 764 { |
826 » CPDF_Rect rcAnnot = pAnnot->GetRect(); | 765 CPDF_Rect rcAnnot = pAnnot->GetRect(); |
827 » if(!rcAnnot.Contains(point.x, point.y)) | 766 if(!rcAnnot.Contains(point.x, point.y)) |
828 » » return FALSE; | 767 return FALSE; |
829 | 768 |
830 » m_bMouseDown = TRUE; | 769 m_bMouseDown = TRUE; |
831 » m_bValid = TRUE; | 770 m_bValid = TRUE; |
832 » FX_RECT rect = GetViewBBox(pPageView, pAnnot); | 771 FX_RECT rect = GetViewBBox(pPageView, pAnnot); |
833 » InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); | 772 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); |
834 » return TRUE; | 773 return TRUE; |
835 } | 774 } |
836 | 775 |
837 FX_BOOL»CFFL_Button::OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAn
not, FX_UINT nFlags, const CPDF_Point& point) | 776 FX_BOOL CFFL_Button::OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAn
not, FX_UINT nFlags, const CPDF_Point& point) |
838 { | 777 { |
839 » CPDF_Rect rcAnnot = pAnnot->GetRect(); | 778 CPDF_Rect rcAnnot = pAnnot->GetRect(); |
840 » if(!rcAnnot.Contains(point.x, point.y)) | 779 if(!rcAnnot.Contains(point.x, point.y)) |
841 » » return FALSE; | 780 return FALSE; |
842 | 781 |
843 » m_bMouseDown = FALSE; | 782 m_bMouseDown = FALSE; |
844 » m_pWidget->GetPDFPage(); | 783 m_pWidget->GetPDFPage(); |
845 | 784 |
846 | 785 |
847 » FX_RECT rect = GetViewBBox(pPageView, pAnnot); | 786 FX_RECT rect = GetViewBBox(pPageView, pAnnot); |
848 » InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); | 787 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); |
849 » return TRUE; | 788 return TRUE; |
850 } | 789 } |
851 | 790 |
852 FX_BOOL»CFFL_Button::OnMouseMove(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAn
not, FX_UINT nFlags, const CPDF_Point& point) | 791 FX_BOOL CFFL_Button::OnMouseMove(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAn
not, FX_UINT nFlags, const CPDF_Point& point) |
853 { | 792 { |
854 » ASSERT(m_pApp != NULL); | 793 ASSERT(m_pApp != NULL); |
855 | 794 |
856 » return TRUE; | 795 return TRUE; |
857 } | 796 } |
858 | 797 |
859 void CFFL_Button::OnDraw(CPDFSDK_PageView *pPageView, /*HDC hDC,*/ CPDFSDK_Annot
* pAnnot, | 798 void CFFL_Button::OnDraw(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, |
860 » » » » » » » CFX_RenderDevice* pDevic
e, CPDF_Matrix* pUser2Device, | 799 CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, |
861 » » » » » » » /*const CRect& rcWindow,
*/ FX_DWORD dwFlags) | 800 FX_DWORD dwFlags) |
862 { | 801 { |
863 » ASSERT(pPageView != NULL); | 802 ASSERT(pPageView != NULL); |
864 » ASSERT(pAnnot != NULL); | 803 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
| 804 CPDF_FormControl* pCtrl = pWidget->GetFormControl(); |
| 805 CPDF_FormControl::HighlightingMode eHM = pCtrl->GetHighlightingMode(); |
865 | 806 |
866 » CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 807 if (eHM == CPDF_FormControl::Push) |
867 | 808 { |
868 » CPDF_FormControl* pCtrl = pWidget->GetFormControl(); | 809 if (m_bMouseDown) |
869 » ASSERT(pCtrl != NULL); | 810 { |
870 | 811 if (pWidget->IsWidgetAppearanceValid(CPDF_Annot::Down)) |
871 » CPDF_FormControl::HighlightingMode eHM = pCtrl->GetHighlightingMode(); | 812 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Down,
NULL); |
872 | 813 else |
873 » if (eHM == CPDF_FormControl::Push) | 814 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Norma
l, NULL); |
874 » { | 815 } |
875 » » if (m_bMouseDown) | 816 else if (m_bMouseIn) |
876 » » { | 817 { |
877 » » » if (pWidget->IsWidgetAppearanceValid(CPDF_Annot::Down)) | 818 if (pWidget->IsWidgetAppearanceValid(CPDF_Annot::Rollover)) |
878 » » » » pWidget->DrawAppearance(pDevice, pUser2Device, C
PDF_Annot::Down, NULL); | 819 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Rollo
ver, NULL); |
879 » » » else | 820 else |
880 » » » » pWidget->DrawAppearance(pDevice, pUser2Device, C
PDF_Annot::Normal, NULL); | 821 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Norma
l, NULL); |
881 » » } | 822 } |
882 » » else if (m_bMouseIn) | 823 else |
883 » » { | 824 { |
884 » » » if (pWidget->IsWidgetAppearanceValid(CPDF_Annot::Rollove
r)) | 825 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, N
ULL); |
885 » » » » pWidget->DrawAppearance(pDevice, pUser2Device, C
PDF_Annot::Rollover, NULL); | 826 } |
886 » » » else | 827 } |
887 » » » » pWidget->DrawAppearance(pDevice, pUser2Device, C
PDF_Annot::Normal, NULL); | 828 else |
888 » » } | 829 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL)
; |
889 » » else | |
890 » » { | |
891 » » » pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Anno
t::Normal, NULL); | |
892 » » } | |
893 » } | |
894 » else | |
895 » » pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Norma
l, NULL); | |
896 } | 830 } |
897 | 831 |
898 | 832 |
899 void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView *pPageView, /*HDC hDC,*/ CPDFS
DK_Annot* pAnnot, | 833 void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAn
not, |
900 » » » » » » » » CFX_RenderDevic
e* pDevice, CPDF_Matrix* pUser2Device, | 834 CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2D
evice, |
901 » » » » » » » » /*const CRect&
rcWindow, */FX_DWORD dwFlags) | 835 FX_DWORD dwFlags) |
902 { | 836 { |
903 » OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); | 837 OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); |
904 } | 838 } |
OLD | NEW |