| 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 "fpdfsdk/formfiller/cffl_formfiller.h" | 7 #include "fpdfsdk/formfiller/cffl_formfiller.h" |
| 8 | 8 |
| 9 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" | 9 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" |
| 10 #include "core/fxge/include/cfx_renderdevice.h" | 10 #include "core/fxge/include/cfx_renderdevice.h" |
| 11 #include "fpdfsdk/formfiller/cba_fontmap.h" | 11 #include "fpdfsdk/formfiller/cba_fontmap.h" |
| 12 #include "fpdfsdk/include/cpdfdoc_environment.h" | 12 #include "fpdfsdk/include/cpdfdoc_environment.h" |
| 13 #include "fpdfsdk/include/cpdfsdk_document.h" | 13 #include "fpdfsdk/include/cpdfsdk_document.h" |
| 14 #include "fpdfsdk/include/cpdfsdk_pageview.h" | 14 #include "fpdfsdk/include/cpdfsdk_pageview.h" |
| 15 #include "fpdfsdk/include/cpdfsdk_widget.h" | 15 #include "fpdfsdk/include/cpdfsdk_widget.h" |
| 16 #include "fpdfsdk/include/fsdk_common.h" | 16 #include "fpdfsdk/include/fsdk_common.h" |
| 17 #include "fpdfsdk/pdfwindow/PWL_Utils.h" | 17 #include "fpdfsdk/pdfwindow/PWL_Utils.h" |
| 18 | 18 |
| 19 #define GetRed(rgb) ((uint8_t)(rgb)) | 19 #define GetRed(rgb) ((uint8_t)(rgb)) |
| 20 #define GetGreen(rgb) ((uint8_t)(((uint16_t)(rgb)) >> 8)) | 20 #define GetGreen(rgb) ((uint8_t)(((uint16_t)(rgb)) >> 8)) |
| 21 #define GetBlue(rgb) ((uint8_t)((rgb) >> 16)) | 21 #define GetBlue(rgb) ((uint8_t)((rgb) >> 16)) |
| 22 | 22 |
| 23 #define FFL_HINT_ELAPSE 800 | 23 #define FFL_HINT_ELAPSE 800 |
| 24 | 24 |
| 25 CFFL_FormFiller::CFFL_FormFiller(CPDFDoc_Environment* pApp, | 25 CFFL_FormFiller::CFFL_FormFiller(CPDFDoc_Environment* pApp, |
| 26 CPDFSDK_Annot* pAnnot) | 26 CPDFSDK_Annot* pAnnot) |
| 27 : m_pApp(pApp), m_pAnnot(pAnnot), m_bValid(FALSE), m_ptOldPos(0, 0) { | 27 : m_pApp(pApp), m_pAnnot(pAnnot), m_bValid(FALSE) { |
| 28 m_pWidget = (CPDFSDK_Widget*)pAnnot; | 28 m_pWidget = static_cast<CPDFSDK_Widget*>(pAnnot); |
| 29 } | 29 } |
| 30 | 30 |
| 31 CFFL_FormFiller::~CFFL_FormFiller() { | 31 CFFL_FormFiller::~CFFL_FormFiller() { |
| 32 DestroyWindows(); | 32 DestroyWindows(); |
| 33 } | 33 } |
| 34 | 34 |
| 35 void CFFL_FormFiller::DestroyWindows() { | 35 void CFFL_FormFiller::DestroyWindows() { |
| 36 for (const auto& it : m_Maps) { | 36 for (const auto& it : m_Maps) { |
| 37 CPWL_Wnd* pWnd = it.second; | 37 CPWL_Wnd* pWnd = it.second; |
| 38 CFFL_PrivateData* pData = (CFFL_PrivateData*)pWnd->GetAttachedData(); | 38 CFFL_PrivateData* pData = (CFFL_PrivateData*)pWnd->GetAttachedData(); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 return pWnd->OnLButtonDown(WndtoPWL(pPageView, point), nFlags); | 138 return pWnd->OnLButtonDown(WndtoPWL(pPageView, point), nFlags); |
| 139 } | 139 } |
| 140 | 140 |
| 141 return FALSE; | 141 return FALSE; |
| 142 } | 142 } |
| 143 | 143 |
| 144 FX_BOOL CFFL_FormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView, | 144 FX_BOOL CFFL_FormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView, |
| 145 CPDFSDK_Annot* pAnnot, | 145 CPDFSDK_Annot* pAnnot, |
| 146 FX_UINT nFlags, | 146 FX_UINT nFlags, |
| 147 const CFX_FloatPoint& point) { | 147 const CFX_FloatPoint& point) { |
| 148 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { | 148 CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE); |
| 149 FX_RECT rcFFL = GetViewBBox(pPageView, pAnnot); | 149 if (!pWnd) |
| 150 InvalidateRect(rcFFL.left, rcFFL.top, rcFFL.right, rcFFL.bottom); | 150 return FALSE; |
| 151 pWnd->OnLButtonUp(WndtoPWL(pPageView, point), nFlags); | |
| 152 return TRUE; | |
| 153 } | |
| 154 | 151 |
| 155 return FALSE; | 152 FX_RECT rcFFL = GetViewBBox(pPageView, pAnnot); |
| 153 InvalidateRect(rcFFL.left, rcFFL.top, rcFFL.right, rcFFL.bottom); |
| 154 pWnd->OnLButtonUp(WndtoPWL(pPageView, point), nFlags); |
| 155 return TRUE; |
| 156 } | 156 } |
| 157 | 157 |
| 158 FX_BOOL CFFL_FormFiller::OnLButtonDblClk(CPDFSDK_PageView* pPageView, | 158 FX_BOOL CFFL_FormFiller::OnLButtonDblClk(CPDFSDK_PageView* pPageView, |
| 159 CPDFSDK_Annot* pAnnot, | 159 CPDFSDK_Annot* pAnnot, |
| 160 FX_UINT nFlags, | 160 FX_UINT nFlags, |
| 161 const CFX_FloatPoint& point) { | 161 const CFX_FloatPoint& point) { |
| 162 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { | 162 CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE); |
| 163 pWnd->OnLButtonDblClk(WndtoPWL(pPageView, point), nFlags); | 163 if (!pWnd) |
| 164 return TRUE; | 164 return FALSE; |
| 165 } | |
| 166 | 165 |
| 167 return FALSE; | 166 pWnd->OnLButtonDblClk(WndtoPWL(pPageView, point), nFlags); |
| 167 return TRUE; |
| 168 } | 168 } |
| 169 | 169 |
| 170 FX_BOOL CFFL_FormFiller::OnMouseMove(CPDFSDK_PageView* pPageView, | 170 FX_BOOL CFFL_FormFiller::OnMouseMove(CPDFSDK_PageView* pPageView, |
| 171 CPDFSDK_Annot* pAnnot, | 171 CPDFSDK_Annot* pAnnot, |
| 172 FX_UINT nFlags, | 172 FX_UINT nFlags, |
| 173 const CFX_FloatPoint& point) { | 173 const CFX_FloatPoint& point) { |
| 174 if ((m_ptOldPos.x != point.x) || (m_ptOldPos.y != point.y)) { | 174 if (m_ptOldPos != point) |
| 175 m_ptOldPos = point; | 175 m_ptOldPos = point; |
| 176 } | |
| 177 | 176 |
| 178 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { | 177 CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE); |
| 179 pWnd->OnMouseMove(WndtoPWL(pPageView, point), nFlags); | 178 if (!pWnd) |
| 180 return TRUE; | 179 return FALSE; |
| 181 } | |
| 182 | 180 |
| 183 return FALSE; | 181 pWnd->OnMouseMove(WndtoPWL(pPageView, point), nFlags); |
| 182 return TRUE; |
| 184 } | 183 } |
| 185 | 184 |
| 186 FX_BOOL CFFL_FormFiller::OnMouseWheel(CPDFSDK_PageView* pPageView, | 185 FX_BOOL CFFL_FormFiller::OnMouseWheel(CPDFSDK_PageView* pPageView, |
| 187 CPDFSDK_Annot* pAnnot, | 186 CPDFSDK_Annot* pAnnot, |
| 188 FX_UINT nFlags, | 187 FX_UINT nFlags, |
| 189 short zDelta, | 188 short zDelta, |
| 190 const CFX_FloatPoint& point) { | 189 const CFX_FloatPoint& point) { |
| 191 if (!IsValid()) | 190 if (!IsValid()) |
| 192 return FALSE; | 191 return FALSE; |
| 193 | 192 |
| 194 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE)) { | 193 CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE); |
| 195 return pWnd->OnMouseWheel(zDelta, WndtoPWL(pPageView, point), nFlags); | 194 return pWnd && pWnd->OnMouseWheel(zDelta, WndtoPWL(pPageView, point), nFlags); |
| 196 } | |
| 197 | |
| 198 return FALSE; | |
| 199 } | 195 } |
| 200 | 196 |
| 201 FX_BOOL CFFL_FormFiller::OnRButtonDown(CPDFSDK_PageView* pPageView, | 197 FX_BOOL CFFL_FormFiller::OnRButtonDown(CPDFSDK_PageView* pPageView, |
| 202 CPDFSDK_Annot* pAnnot, | 198 CPDFSDK_Annot* pAnnot, |
| 203 FX_UINT nFlags, | 199 FX_UINT nFlags, |
| 204 const CFX_FloatPoint& point) { | 200 const CFX_FloatPoint& point) { |
| 205 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE)) { | 201 CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE); |
| 206 pWnd->OnRButtonDown(WndtoPWL(pPageView, point), nFlags); | 202 if (!pWnd) |
| 207 return TRUE; | 203 return FALSE; |
| 208 } | |
| 209 | 204 |
| 210 return FALSE; | 205 pWnd->OnRButtonDown(WndtoPWL(pPageView, point), nFlags); |
| 206 return TRUE; |
| 211 } | 207 } |
| 212 | 208 |
| 213 FX_BOOL CFFL_FormFiller::OnRButtonUp(CPDFSDK_PageView* pPageView, | 209 FX_BOOL CFFL_FormFiller::OnRButtonUp(CPDFSDK_PageView* pPageView, |
| 214 CPDFSDK_Annot* pAnnot, | 210 CPDFSDK_Annot* pAnnot, |
| 215 FX_UINT nFlags, | 211 FX_UINT nFlags, |
| 216 const CFX_FloatPoint& point) { | 212 const CFX_FloatPoint& point) { |
| 217 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { | 213 CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE); |
| 218 pWnd->OnRButtonUp(WndtoPWL(pPageView, point), nFlags); | 214 if (!pWnd) |
| 219 return TRUE; | 215 return FALSE; |
| 220 } | |
| 221 | 216 |
| 222 return FALSE; | 217 pWnd->OnRButtonUp(WndtoPWL(pPageView, point), nFlags); |
| 218 return TRUE; |
| 223 } | 219 } |
| 224 | 220 |
| 225 FX_BOOL CFFL_FormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, | 221 FX_BOOL CFFL_FormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, |
| 226 FX_UINT nKeyCode, | 222 FX_UINT nKeyCode, |
| 227 FX_UINT nFlags) { | 223 FX_UINT nFlags) { |
| 228 if (IsValid()) { | 224 if (IsValid()) { |
| 229 CPDFSDK_PageView* pPageView = GetCurPageView(true); | 225 CPDFSDK_PageView* pPageView = GetCurPageView(true); |
| 230 ASSERT(pPageView); | 226 ASSERT(pPageView); |
| 231 | 227 |
| 232 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { | 228 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, nullptr); | 711 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, nullptr); |
| 716 } | 712 } |
| 717 } | 713 } |
| 718 | 714 |
| 719 void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView* pPageView, | 715 void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView* pPageView, |
| 720 CPDFSDK_Annot* pAnnot, | 716 CPDFSDK_Annot* pAnnot, |
| 721 CFX_RenderDevice* pDevice, | 717 CFX_RenderDevice* pDevice, |
| 722 CFX_Matrix* pUser2Device) { | 718 CFX_Matrix* pUser2Device) { |
| 723 OnDraw(pPageView, pAnnot, pDevice, pUser2Device); | 719 OnDraw(pPageView, pAnnot, pDevice, pUser2Device); |
| 724 } | 720 } |
| OLD | NEW |