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 "../../third_party/base/nonstd_unique_ptr.h" | 7 #include "../../third_party/base/nonstd_unique_ptr.h" |
8 #include "../include/fsdk_define.h" | 8 #include "../include/fsdk_define.h" |
9 #include "../include/fpdfxfa/fpdfxfa_doc.h" | 9 #include "../include/fpdfxfa/fpdfxfa_doc.h" |
10 #include "../include/fpdfxfa/fpdfxfa_util.h" | 10 #include "../include/fpdfxfa/fpdfxfa_util.h" |
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 ASSERT(m_pInterForm != NULL); | 954 ASSERT(m_pInterForm != NULL); |
955 m_pInterForm->UpdateField(pFormField); | 955 m_pInterForm->UpdateField(pFormField); |
956 } | 956 } |
957 | 957 |
958 void CPDFSDK_Widget::DrawShadow(CFX_RenderDevice* pDevice, | 958 void CPDFSDK_Widget::DrawShadow(CFX_RenderDevice* pDevice, |
959 CPDFSDK_PageView* pPageView) { | 959 CPDFSDK_PageView* pPageView) { |
960 ASSERT(m_pInterForm != NULL); | 960 ASSERT(m_pInterForm != NULL); |
961 | 961 |
962 int nFieldType = GetFieldType(); | 962 int nFieldType = GetFieldType(); |
963 if (m_pInterForm->IsNeedHighLight(nFieldType)) { | 963 if (m_pInterForm->IsNeedHighLight(nFieldType)) { |
964 // if (nFieldType != FIELDTYPE_PUSHBUTTON) | |
965 // { | |
966 CPDF_Rect rc = GetRect(); | 964 CPDF_Rect rc = GetRect(); |
967 FX_COLORREF color = m_pInterForm->GetHighlightColor(nFieldType); | 965 FX_COLORREF color = m_pInterForm->GetHighlightColor(nFieldType); |
968 uint8_t alpha = m_pInterForm->GetHighlightAlpha(); | 966 uint8_t alpha = m_pInterForm->GetHighlightAlpha(); |
969 | 967 |
970 CFX_FloatRect rcDevice; | 968 CFX_FloatRect rcDevice; |
971 ASSERT(m_pInterForm->GetDocument()); | 969 ASSERT(m_pInterForm->GetDocument()); |
972 CPDFDoc_Environment* pEnv = m_pInterForm->GetDocument()->GetEnv(); | 970 CPDFDoc_Environment* pEnv = m_pInterForm->GetDocument()->GetEnv(); |
973 if (!pEnv) | 971 if (!pEnv) |
974 return; | 972 return; |
975 CFX_AffineMatrix page2device; | 973 CFX_AffineMatrix page2device; |
976 pPageView->GetCurrentMatrix(page2device); | 974 pPageView->GetCurrentMatrix(page2device); |
977 page2device.Transform(((FX_FLOAT)rc.left), ((FX_FLOAT)rc.bottom), | 975 page2device.Transform(((FX_FLOAT)rc.left), ((FX_FLOAT)rc.bottom), |
978 rcDevice.left, rcDevice.bottom); | 976 rcDevice.left, rcDevice.bottom); |
979 // pEnv->FFI_PageToDevice(m_pPageView->GetPDFPage(), rc.left, | |
980 // rc.bottom, &rcDevice.left, &rcDevice.bottom); | |
981 // pEnv->FFI_PageToDevice(m_pPageView->GetPDFPage(), rc.right, | |
982 // rc.top, &rcDevice.right, &rcDevice.top); | |
983 page2device.Transform(((FX_FLOAT)rc.right), ((FX_FLOAT)rc.top), | 977 page2device.Transform(((FX_FLOAT)rc.right), ((FX_FLOAT)rc.top), |
984 rcDevice.right, rcDevice.top); | 978 rcDevice.right, rcDevice.top); |
985 | 979 |
986 rcDevice.Normalize(); | 980 rcDevice.Normalize(); |
987 | 981 |
988 FX_ARGB argb = ArgbEncode((int)alpha, color); | 982 FX_ARGB argb = ArgbEncode((int)alpha, color); |
989 FX_RECT rcDev((int)rcDevice.left, (int)rcDevice.top, (int)rcDevice.right, | 983 FX_RECT rcDev((int)rcDevice.left, (int)rcDevice.top, (int)rcDevice.right, |
990 (int)rcDevice.bottom); | 984 (int)rcDevice.bottom); |
991 pDevice->FillRect(&rcDev, argb); | 985 pDevice->FillRect(&rcDev, argb); |
992 /* }*/ | |
993 } | 986 } |
994 } | 987 } |
995 | 988 |
996 void CPDFSDK_Widget::ResetAppearance_PushButton() { | 989 void CPDFSDK_Widget::ResetAppearance_PushButton() { |
997 CPDF_FormControl* pControl = GetFormControl(); | 990 CPDF_FormControl* pControl = GetFormControl(); |
998 ASSERT(pControl != NULL); | 991 ASSERT(pControl != NULL); |
999 | 992 |
1000 CPDF_Rect rcWindow = GetRotatedRect(); | 993 CPDF_Rect rcWindow = GetRotatedRect(); |
1001 | 994 |
1002 int32_t nLayout = 0; | 995 int32_t nLayout = 0; |
(...skipping 1206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2209 m_pInterForm->SetFormNotify(this); | 2202 m_pInterForm->SetFormNotify(this); |
2210 | 2203 |
2211 for (int i = 0; i < 6; i++) | 2204 for (int i = 0; i < 6; i++) |
2212 m_bNeedHightlight[i] = FALSE; | 2205 m_bNeedHightlight[i] = FALSE; |
2213 m_iHighlightAlpha = 0; | 2206 m_iHighlightAlpha = 0; |
2214 } | 2207 } |
2215 | 2208 |
2216 CPDFSDK_InterForm::~CPDFSDK_InterForm() { | 2209 CPDFSDK_InterForm::~CPDFSDK_InterForm() { |
2217 delete m_pInterForm; | 2210 delete m_pInterForm; |
2218 m_pInterForm = nullptr; | 2211 m_pInterForm = nullptr; |
2219 | |
2220 m_Map.clear(); | 2212 m_Map.clear(); |
2221 m_XFAMap.RemoveAll(); | 2213 m_XFAMap.RemoveAll(); |
2222 } | 2214 } |
2223 | 2215 |
2224 FX_BOOL CPDFSDK_InterForm::HighlightWidgets() { | 2216 FX_BOOL CPDFSDK_InterForm::HighlightWidgets() { |
2225 return FALSE; | 2217 return FALSE; |
2226 } | 2218 } |
2227 | 2219 |
2228 CPDFSDK_Widget* CPDFSDK_InterForm::GetSibling(CPDFSDK_Widget* pWidget, | 2220 CPDFSDK_Widget* CPDFSDK_InterForm::GetSibling(CPDFSDK_Widget* pWidget, |
2229 FX_BOOL bNext) const { | 2221 FX_BOOL bNext) const { |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2974 if (bRC) { | 2966 if (bRC) { |
2975 OnValidate(pFormField, csValue, bRC); | 2967 OnValidate(pFormField, csValue, bRC); |
2976 return bRC ? 1 : -1; | 2968 return bRC ? 1 : -1; |
2977 } | 2969 } |
2978 return -1; | 2970 return -1; |
2979 } | 2971 } |
2980 return 0; | 2972 return 0; |
2981 } | 2973 } |
2982 | 2974 |
2983 int CPDFSDK_InterForm::AfterValueChange(const CPDF_FormField* pField) { | 2975 int CPDFSDK_InterForm::AfterValueChange(const CPDF_FormField* pField) { |
2984 ASSERT(pField != NULL); | |
2985 | |
2986 CPDF_FormField* pFormField = (CPDF_FormField*)pField; | 2976 CPDF_FormField* pFormField = (CPDF_FormField*)pField; |
2987 | |
2988 SynchronizeField(pFormField, FALSE); | 2977 SynchronizeField(pFormField, FALSE); |
2989 | 2978 |
2990 int nType = pFormField->GetFieldType(); | 2979 int nType = pFormField->GetFieldType(); |
2991 | |
2992 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) { | 2980 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) { |
2993 OnCalculate(pFormField); | 2981 OnCalculate(pFormField); |
2994 FX_BOOL bFormated = FALSE; | 2982 FX_BOOL bFormated = FALSE; |
2995 CFX_WideString sValue = OnFormat(pFormField, bFormated); | 2983 CFX_WideString sValue = OnFormat(pFormField, bFormated); |
2996 if (bFormated) | 2984 if (bFormated) |
2997 ResetFieldAppearance(pFormField, sValue.c_str(), TRUE); | 2985 ResetFieldAppearance(pFormField, sValue.c_str(), TRUE); |
2998 else | 2986 else |
2999 ResetFieldAppearance(pFormField, NULL, TRUE); | 2987 ResetFieldAppearance(pFormField, NULL, TRUE); |
3000 UpdateField(pFormField); | 2988 UpdateField(pFormField); |
3001 } | 2989 } |
3002 | |
3003 return 0; | 2990 return 0; |
3004 } | 2991 } |
3005 | 2992 |
3006 int CPDFSDK_InterForm::BeforeSelectionChange(const CPDF_FormField* pField, | 2993 int CPDFSDK_InterForm::BeforeSelectionChange(const CPDF_FormField* pField, |
3007 CFX_WideString& csValue) { | 2994 CFX_WideString& csValue) { |
3008 CPDF_FormField* pFormField = (CPDF_FormField*)pField; | 2995 CPDF_FormField* pFormField = (CPDF_FormField*)pField; |
3009 if (pFormField->GetFieldType() != FIELDTYPE_LISTBOX) | 2996 if (pFormField->GetFieldType() != FIELDTYPE_LISTBOX) |
3010 return 0; | 2997 return 0; |
3011 | 2998 |
3012 FX_BOOL bRC = TRUE; | 2999 FX_BOOL bRC = TRUE; |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3368 ASSERT(pAnnot != NULL); | 3355 ASSERT(pAnnot != NULL); |
3369 | 3356 |
3370 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); | 3357 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); |
3371 ASSERT(pPDFAnnot != NULL); | 3358 ASSERT(pPDFAnnot != NULL); |
3372 | 3359 |
3373 CPDF_Rect rcAnnot; | 3360 CPDF_Rect rcAnnot; |
3374 pPDFAnnot->GetRect(rcAnnot); | 3361 pPDFAnnot->GetRect(rcAnnot); |
3375 | 3362 |
3376 return rcAnnot; | 3363 return rcAnnot; |
3377 } | 3364 } |
OLD | NEW |