Remove typdefs for pointer types in fx_system.h.
[pdfium.git] / fpdfsdk / src / formfiller / FFL_IFormFiller.cpp
index 686b38c..b2d80ab 100644 (file)
-// Copyright 2014 PDFium Authors. All rights reserved.\r
-// Use of this source code is governed by a BSD-style license that can be\r
-// found in the LICENSE file.\r
\r
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
-\r
-#include "../../include/formfiller/FFL_FormFiller.h"\r
-#include "../../include/formfiller/FFL_IFormFiller.h"\r
-#include "../../include/formfiller/FFL_CheckBox.h"\r
-#include "../../include/formfiller/FFL_ComboBox.h"\r
-#include "../../include/formfiller/FFL_ListBox.h"\r
-#include "../../include/formfiller/FFL_PushButton.h"\r
-#include "../../include/formfiller/FFL_RadioButton.h"\r
-#include "../../include/formfiller/FFL_TextField.h"\r
-\r
-#define FFL_MAXLISTBOXHEIGHT           140.0f\r
-\r
-// HHOOK CFFL_IFormFiller::m_hookSheet = NULL;\r
-// MSG CFFL_IFormFiller::g_Msg;\r
-\r
-/* ----------------------------- CFFL_IFormFiller ----------------------------- */\r
-\r
-CFFL_IFormFiller::CFFL_IFormFiller(CPDFDoc_Environment* pApp) : \r
-       m_pApp(pApp),\r
-       m_bNotifying(FALSE)\r
-{\r
-}\r
-\r
-CFFL_IFormFiller::~CFFL_IFormFiller()\r
-{\r
-       FX_POSITION pos = m_Maps.GetStartPosition();\r
-       while (pos)\r
-       {\r
-               CPDFSDK_Annot * pAnnot = NULL;\r
-               CFFL_FormFiller * pFormFiller = NULL;\r
-               m_Maps.GetNextAssoc(pos,pAnnot,pFormFiller);\r
-               delete pFormFiller;\r
-       }\r
-       m_Maps.RemoveAll();\r
-}\r
-\r
-FX_BOOL        CFFL_IFormFiller::Annot_HitTest(CPDFSDK_PageView* pPageView,CPDFSDK_Annot* pAnnot, CPDF_Point point)\r
-{\r
-       CPDF_Rect rc = pAnnot->GetRect();\r
-       if(rc.Contains(point.x, point.y))\r
-               return TRUE;\r
-       return FALSE;\r
-}\r
-\r
-FX_RECT CFFL_IFormFiller::GetViewBBox(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot)\r
-{\r
-       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))\r
-       {\r
-               return pFormFiller->GetViewBBox(pPageView, pAnnot);\r
-       }\r
-       else\r
-       {\r
-               ASSERT(pPageView != NULL);\r
-               ASSERT(pAnnot != NULL);\r
-\r
-               CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot();\r
-               ASSERT(pPDFAnnot != NULL);\r
-\r
-               CPDF_Rect rcAnnot;\r
-               pPDFAnnot->GetRect(rcAnnot);\r
-\r
-//             CRect rcWin;\r
-//             pPageView->DocToWindow(rcAnnot, rcWin);\r
-               CPDF_Rect rcWin = CPWL_Utils::InflateRect(rcAnnot,1);\r
-//             rcWin.InflateRect(1, 1);\r
-\r
-               return rcWin.GetOutterRect();\r
-       }\r
-}\r
-\r
-void CFFL_IFormFiller::OnDraw(CPDFSDK_PageView* pPageView, /*HDC hDC,*/ CPDFSDK_Annot* pAnnot, \r
-                                               CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,\r
-                                               /*const CRect& rcWindow,*/ FX_DWORD dwFlags)\r
-{\r
-       ASSERT(pPageView != NULL);\r
-       CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;\r
-\r
-       if (IsVisible(pWidget))\r
-       {\r
-               if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))\r
-               {\r
-                       if (pFormFiller->IsValid())\r
-                       {\r
-                               pFormFiller->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags);\r
-                               \r
-                               pAnnot->GetPDFPage();\r
-                               \r
-\r
-                               CPDFSDK_Document* pDocument = m_pApp->GetCurrentDoc();\r
-                               ASSERT(pDocument != NULL);\r
-\r
-                               if (pDocument->GetFocusAnnot() == pAnnot)\r
-                               {\r
-                                       CPDF_Rect rcFocus = pFormFiller->GetFocusBox(pPageView);\r
-                                       if (!rcFocus.IsEmpty())\r
-                                       {\r
-                                               CFX_PathData path;\r
-                                               \r
-                                               path.SetPointCount(5);\r
-                                               path.SetPoint(0, rcFocus.left,  rcFocus.top, FXPT_MOVETO);\r
-                                               path.SetPoint(1, rcFocus.left,  rcFocus.bottom, FXPT_LINETO);\r
-                                               path.SetPoint(2, rcFocus.right,  rcFocus.bottom, FXPT_LINETO);\r
-                                               path.SetPoint(3, rcFocus.right,  rcFocus.top, FXPT_LINETO);\r
-                                               path.SetPoint(4, rcFocus.left,  rcFocus.top, FXPT_LINETO);\r
-                                               \r
-                                               CFX_GraphStateData gsd;\r
-                                               gsd.SetDashCount(1);                            \r
-                                               gsd.m_DashArray[0] = 1.0f;\r
-                                               gsd.m_DashPhase = 0;    \r
-                                               \r
-                                               gsd.m_LineWidth = 1.0f;\r
-                                               pDevice->DrawPath(&path, pUser2Device, &gsd, 0, ArgbEncode(255,0,0,0), FXFILL_ALTERNATE);\r
-\r
-                                       //      ::DrawFocusRect(hDC, &rcFocus); \r
-                                       }\r
-                               }\r
-\r
-                               return;\r
-                       }\r
-               }\r
-\r
-               if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))\r
-                       pFormFiller->OnDrawDeactive(pPageView, pAnnot, pDevice, pUser2Device, dwFlags);\r
-               else\r
-                       pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);\r
-\r
-               if (!IsReadOnly(pWidget) && IsFillingAllowed(pWidget))\r
-               {\r
-                       pWidget->DrawShadow(pDevice, pPageView);\r
-               }\r
-       \r
-       }\r
-}\r
-\r
-void CFFL_IFormFiller::OnCreate(CPDFSDK_Annot* pAnnot)\r
-{\r
-       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))\r
-       {\r
-               pFormFiller->OnCreate(pAnnot);\r
-       }\r
-}\r
-\r
-void CFFL_IFormFiller::OnLoad(CPDFSDK_Annot* pAnnot)\r
-{\r
-       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))\r
-       {\r
-               pFormFiller->OnLoad(pAnnot);\r
-       }\r
-}\r
-\r
-void CFFL_IFormFiller::OnDelete(CPDFSDK_Annot* pAnnot)\r
-{\r
-       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))\r
-       {\r
-               pFormFiller->OnDelete(pAnnot);\r
-       }\r
-\r
-       UnRegisterFormFiller(pAnnot);\r
-}\r
-\r
-void CFFL_IFormFiller::OnMouseEnter(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlag)\r
-{\r
-       ASSERT(pAnnot != NULL);\r
-       ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");\r
-       \r
-       if (!m_bNotifying)\r
-       {\r
-               CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;\r
-               if (pWidget->GetAAction(CPDF_AAction::CursorEnter))\r
-               {\r
-                       m_bNotifying = TRUE;\r
-                       \r
-                       int nValueAge = pWidget->GetValueAge();\r
-\r
-                       pWidget->ClearAppModified();\r
-                       \r
-                       ASSERT(pPageView != NULL);\r
-                       \r
-                       \r
-                       \r
-                       PDFSDK_FieldAction fa;\r
-                       fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);\r
-                       fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);\r
-                       pWidget->OnAAction(CPDF_AAction::CursorEnter, fa, pPageView );\r
-                       m_bNotifying = FALSE;\r
-                       \r
-                       //if ( !IsValidAnnot(pPageView, pAnnot) ) return;\r
-                       \r
-                       if (pWidget->IsAppModified())\r
-                       {\r
-                               if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE))\r
-                               {\r
-                                       pFormFiller->ResetPDFWindow(pPageView, pWidget->GetValueAge() == nValueAge);\r
-                               }\r
-                       }\r
-               }\r
-       }\r
-       \r
-       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE))\r
-       {\r
-               pFormFiller->OnMouseEnter(pPageView, pAnnot);\r
-       }\r
-}\r
-\r
-void CFFL_IFormFiller::OnMouseExit(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlag)\r
-{\r
-       ASSERT(pAnnot != NULL);\r
-       ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");\r
-       \r
-       if (!m_bNotifying)\r
-       {\r
-               CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;\r
-               if (pWidget->GetAAction(CPDF_AAction::CursorExit))\r
-               {\r
-                       m_bNotifying = TRUE;\r
-                       pWidget->GetAppearanceAge();\r
-                       int nValueAge = pWidget->GetValueAge();\r
-                       pWidget->ClearAppModified();\r
-                       \r
-                       ASSERT(pPageView != NULL);\r
-                       \r
-                       \r
-                       \r
-                       PDFSDK_FieldAction fa;\r
-                       fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);\r
-                       fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);\r
-                       \r
-                       pWidget->OnAAction(CPDF_AAction::CursorExit, fa, pPageView);\r
-                       m_bNotifying = FALSE;\r
-                       \r
-                       //if (!IsValidAnnot(pPageView, pAnnot)) return;\r
-                       \r
-                       if (pWidget->IsAppModified())\r
-                       {\r
-                               if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE))\r
-                               {\r
-                                       pFormFiller->ResetPDFWindow(pPageView, nValueAge == pWidget->GetValueAge());\r
-                               }\r
-                       }\r
-               }\r
-       }\r
-       \r
-       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))\r
-       {\r
-               pFormFiller->OnMouseExit(pPageView, pAnnot);\r
-       }\r
-}\r
-\r
-FX_BOOL        CFFL_IFormFiller::OnLButtonDown(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)\r
-{\r
-       ASSERT(pAnnot != NULL);\r
-       ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");\r
-       \r
-       if (!m_bNotifying)\r
-       {\r
-               CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;\r
-               if (Annot_HitTest(pPageView, pAnnot, point) && pWidget->GetAAction(CPDF_AAction::ButtonDown))\r
-               {\r
-                       m_bNotifying = TRUE;\r
-                       pWidget->GetAppearanceAge();\r
-                       int nValueAge = pWidget->GetValueAge();\r
-                       pWidget->ClearAppModified();\r
-                       \r
-                       ASSERT(pPageView != NULL);\r
-                       \r
-                       \r
-                       \r
-                       PDFSDK_FieldAction fa;\r
-                       fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlags);\r
-                       fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlags);\r
-                       pWidget->OnAAction(CPDF_AAction::ButtonDown, fa, pPageView);\r
-                       m_bNotifying = FALSE;\r
-                       \r
-                       if (!IsValidAnnot(pPageView, pAnnot)) return TRUE;\r
-                       \r
-                       if (pWidget->IsAppModified())\r
-                       {\r
-                               if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE))\r
-                               {\r
-                                       pFormFiller->ResetPDFWindow(pPageView, nValueAge == pWidget->GetValueAge());\r
-                               }\r
-                       }\r
-               }\r
-       }\r
-       \r
-       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))\r
-       {\r
-               return pFormFiller->OnLButtonDown(pPageView, pAnnot, nFlags, point);\r
-       }\r
-       \r
-       return FALSE;\r
-}\r
-\r
-FX_BOOL        CFFL_IFormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)\r
-{\r
-       ASSERT(pAnnot != NULL);\r
-       ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");\r
-       \r
-       CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;\r
-       //      CReader_Page* pPage = pAnnot->GetPage();\r
-       //      ASSERT(pPage != NULL);\r
-       CPDFSDK_Document* pDocument = m_pApp->GetCurrentDoc();\r
-       ASSERT(pDocument != NULL);              \r
-       \r
-       switch (pWidget->GetFieldType())\r
-       {\r
-       case FIELDTYPE_PUSHBUTTON:\r
-       case FIELDTYPE_CHECKBOX:\r
-       case FIELDTYPE_RADIOBUTTON:\r
-               if (GetViewBBox(pPageView, pAnnot).Contains((int)point.x, (int)point.y))\r
-               {\r
-                       pDocument->SetFocusAnnot(pAnnot);\r
-               }\r
-               break;\r
-       default:\r
-               pDocument->SetFocusAnnot(pAnnot);\r
-               break;\r
-       }\r
-       \r
-       FX_BOOL bRet = FALSE;\r
-       \r
-       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))\r
-       {\r
-               bRet = pFormFiller->OnLButtonUp(pPageView, pAnnot, nFlags, point);\r
-       }\r
-\r
-       if (pDocument->GetFocusAnnot() == pAnnot)\r
-       {\r
-               FX_BOOL bExit = FALSE;\r
-               FX_BOOL bReset = FALSE;\r
-               OnButtonUp(pWidget, pPageView, bReset, bExit,nFlags);\r
-               if (bExit) return TRUE;\r
-       }\r
-       return bRet;\r
-}\r
-\r
-void CFFL_IFormFiller::OnButtonUp(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bReset, FX_BOOL& bExit,FX_UINT nFlag)\r
-{\r
-       ASSERT(pWidget != NULL);\r
-       \r
-       if (!m_bNotifying)\r
-       {\r
-               if (pWidget->GetAAction(CPDF_AAction::ButtonUp))\r
-               {\r
-                       m_bNotifying = TRUE;\r
-                       int nAge = pWidget->GetAppearanceAge();\r
-                       int nValueAge = pWidget->GetValueAge();\r
-                       \r
-                       ASSERT(pPageView != NULL);\r
-//                     CReader_DocView* pDocView = pPageView->GetDocView();\r
-//                     ASSERT(pDocView != NULL);\r
-                       \r
-                       \r
-                       \r
-                       PDFSDK_FieldAction fa;\r
-                       fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);\r
-                       fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);\r
-\r
-                       pWidget->OnAAction(CPDF_AAction::ButtonUp, fa, pPageView);\r
-                       m_bNotifying = FALSE;\r
-                       \r
-                       if (!IsValidAnnot(pPageView, pWidget))\r
-                       {\r
-                               bExit = TRUE;\r
-                               return;\r
-                       }\r
-                       \r
-                       if (nAge != pWidget->GetAppearanceAge())\r
-                       {\r
-                               if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE))\r
-                               {\r
-                                       pFormFiller->ResetPDFWindow(pPageView, nValueAge == pWidget->GetValueAge());\r
-                               }\r
-                               \r
-                               bReset = TRUE;\r
-                       }\r
-               }\r
-       }\r
-}\r
-\r
-FX_BOOL        CFFL_IFormFiller::OnLButtonDblClk(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)\r
-{\r
-       ASSERT(pAnnot != NULL);\r
-       ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");\r
-\r
-       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))\r
-       {\r
-               return pFormFiller->OnLButtonDblClk(pPageView, pAnnot, nFlags, point);\r
-       }\r
-\r
-       return FALSE;\r
-}\r
-\r
-FX_BOOL        CFFL_IFormFiller::OnMouseMove(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)\r
-{\r
-       ASSERT(pAnnot != NULL);\r
-       ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");\r
-\r
-       //change cursor\r
-       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE))\r
-       {\r
-               return pFormFiller->OnMouseMove(pPageView, pAnnot, nFlags, point);\r
-       }\r
-\r
-       return FALSE;\r
-}\r
-\r
-FX_BOOL        CFFL_IFormFiller::OnMouseWheel(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, short zDelta, const CPDF_Point& point)\r
-{\r
-       ASSERT(pAnnot != NULL);\r
-       ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");\r
-\r
-       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))\r
-       {\r
-               return pFormFiller->OnMouseWheel(pPageView, pAnnot, nFlags, zDelta, point);\r
-       }\r
-\r
-       return FALSE;\r
-}\r
-\r
-FX_BOOL        CFFL_IFormFiller::OnRButtonDown(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)\r
-{\r
-       ASSERT(pAnnot != NULL);\r
-       ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");\r
-\r
-       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))\r
-       {\r
-               return pFormFiller->OnRButtonDown(pPageView, pAnnot, nFlags, point);\r
-       }\r
-\r
-       return FALSE;\r
-}\r
-\r
-FX_BOOL        CFFL_IFormFiller::OnRButtonUp(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)\r
-{\r
-       ASSERT(pAnnot != NULL);\r
-       ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");\r
-\r
-       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))\r
-       {\r
-               return pFormFiller->OnRButtonUp(pPageView, pAnnot, nFlags, point);\r
-       }\r
-\r
-       return FALSE;\r
-}\r
-\r
-FX_BOOL        CFFL_IFormFiller::OnRButtonDblClk(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)\r
-{\r
-       ASSERT(pAnnot != NULL);\r
-       ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");\r
-\r
-       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))\r
-       {\r
-               return pFormFiller->OnRButtonDblClk(pPageView, pAnnot, nFlags, point);\r
-       }\r
-\r
-       return FALSE;\r
-}\r
-\r
-FX_BOOL        CFFL_IFormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, FX_UINT nKeyCode, FX_UINT nFlags)\r
-{\r
-       ASSERT(pAnnot != NULL);\r
-       ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");\r
-\r
-       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))\r
-       {\r
-               return pFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlags);        \r
-       }\r
-\r
-       return FALSE;\r
-}\r
-\r
-FX_BOOL        CFFL_IFormFiller::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags)\r
-{\r
-       ASSERT(pAnnot != NULL);\r
-       ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");\r
-\r
-       if (nChar == FWL_VKEY_Tab) return TRUE;\r
-\r
-       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))\r
-       {\r
-               return pFormFiller->OnChar(pAnnot, nChar, nFlags);\r
-       }\r
-\r
-       return FALSE;\r
-}\r
-\r
-void CFFL_IFormFiller::OnDeSelected(CPDFSDK_Annot* pAnnot)\r
-{\r
-       ASSERT(pAnnot != NULL);\r
-       ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");\r
-\r
-       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))\r
-       {\r
-               pFormFiller->OnDeSelected(pAnnot);\r
-       }\r
-}\r
-\r
-void CFFL_IFormFiller::OnSelected(CPDFSDK_Annot* pAnnot)\r
-{\r
-       ASSERT(pAnnot != NULL);\r
-       ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");\r
-\r
-       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))\r
-       {\r
-               pFormFiller->OnSelected(pAnnot);\r
-       }\r
-}\r
-\r
-FX_BOOL CFFL_IFormFiller::OnSetFocus(CPDFSDK_Annot* pAnnot,FX_UINT nFlag)\r
-{\r
-       if(!pAnnot) return FALSE;\r
-       ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");\r
-\r
-       if (!m_bNotifying)\r
-       {\r
-               CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;\r
-               if (pWidget->GetAAction(CPDF_AAction::GetFocus))\r
-               {\r
-                       m_bNotifying = TRUE;\r
-                       pWidget->GetAppearanceAge();\r
-                       int nValueAge = pWidget->GetValueAge();\r
-                       pWidget->ClearAppModified();\r
\r
\r
-                       CPDFSDK_PageView* pPageView = pAnnot->GetPageView();\r
-                       ASSERT(pPageView != NULL);\r
-                       \r
-                       PDFSDK_FieldAction fa;\r
-                       fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);\r
-                       fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);\r
-\r
\r
-                       CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, TRUE);\r
-                       if(!pFormFiller) return FALSE;\r
-                       pFormFiller->GetActionData(pPageView, CPDF_AAction::GetFocus, fa);\r
\r
-                       pWidget->OnAAction(CPDF_AAction::GetFocus, fa, pPageView);\r
-                       m_bNotifying = FALSE;\r
-                       \r
- //                    if (!IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, pAnnot)) return FALSE;\r
\r
-                       if (pWidget->IsAppModified())\r
-                       {\r
-                               if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE))\r
-                               {\r
-                                       pFormFiller->ResetPDFWindow(pPageView, nValueAge == pWidget->GetValueAge());\r
-                               }\r
-                       }\r
-               }\r
-       }\r
-       \r
-       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE))\r
-       {\r
-               if (pFormFiller->OnSetFocus(pAnnot, nFlag))\r
-               {\r
-                       return TRUE;\r
-               }\r
-               else\r
-                       return FALSE;\r
-       }\r
-\r
-       return TRUE;\r
-}\r
-\r
-FX_BOOL        CFFL_IFormFiller::OnKillFocus(CPDFSDK_Annot* pAnnot,FX_UINT nFlag)\r
-{\r
-       if(!pAnnot) return FALSE;\r
-       ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");\r
-\r
-       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))\r
-       {\r
-               if (pFormFiller->OnKillFocus(pAnnot, nFlag))\r
-               {\r
-                       if (!m_bNotifying)\r
-                       {\r
-                               CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;\r
-                               if (pWidget->GetAAction(CPDF_AAction::LoseFocus))\r
-                               {\r
-                                       m_bNotifying = TRUE;\r
-                                       pWidget->ClearAppModified();\r
\r
-                                       CPDFSDK_PageView* pPageView = pWidget->GetPageView();\r
-                                       ASSERT(pPageView != NULL);\r
\r
-                                       PDFSDK_FieldAction fa;\r
-                                       fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);\r
-                                       fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);\r
\r
-                                       pFormFiller->GetActionData(pPageView, CPDF_AAction::LoseFocus, fa);\r
\r
-                                       pWidget->OnAAction(CPDF_AAction::LoseFocus, fa, pPageView);\r
-                                       m_bNotifying = FALSE;\r
\r
-                               }\r
-                       }\r
-               }\r
-               else\r
-                       return FALSE;\r
-       }\r
-\r
-       return TRUE;\r
-}\r
-\r
-FX_BOOL        CFFL_IFormFiller::IsVisible(CPDFSDK_Widget* pWidget)\r
-{\r
-       return pWidget->IsVisible();\r
-}\r
-\r
-FX_BOOL        CFFL_IFormFiller::IsReadOnly(CPDFSDK_Widget* pWidget)\r
-{\r
-       ASSERT(pWidget != NULL);\r
-\r
-       int nFieldFlags = pWidget->GetFieldFlags();\r
-\r
-       return (nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY;\r
-}\r
-\r
-FX_BOOL        CFFL_IFormFiller::IsFillingAllowed(CPDFSDK_Widget* pWidget)\r
-{\r
-       ASSERT(pWidget != NULL);\r
-\r
-       if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON)\r
-               return TRUE;\r
-       else\r
-       {\r
-               CPDF_Page* pPage = pWidget->GetPDFPage();\r
-               ASSERT(pPage != NULL);\r
\r
-               CPDF_Document* pDocument = pPage->m_pDocument;\r
-               ASSERT(pDocument != NULL);\r
\r
-               FX_DWORD dwPermissions = pDocument->GetUserPermissions();\r
-               return (dwPermissions&FPDFPERM_FILL_FORM) || \r
-                               (dwPermissions&FPDFPERM_ANNOT_FORM) || \r
-                       (dwPermissions&FPDFPERM_MODIFY);\r
-       }\r
-       return TRUE;    \r
-}\r
-\r
-CFFL_FormFiller* CFFL_IFormFiller::GetFormFiller(CPDFSDK_Annot* pAnnot, FX_BOOL bRegister)\r
-{\r
-//     ASSERT(pAnnot != NULL);\r
-//     ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");\r
-\r
-       CFFL_FormFiller * pFormFiller = NULL;\r
-       m_Maps.Lookup(pAnnot, pFormFiller);\r
-\r
-       if (pFormFiller)\r
-               return pFormFiller;\r
-\r
-       if (bRegister)\r
-       {\r
-               CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;              \r
-\r
-               int nFieldType = pWidget->GetFieldType();\r
-               switch(nFieldType)\r
-               {\r
-               case FIELDTYPE_PUSHBUTTON:\r
-                       pFormFiller = new CFFL_PushButton(m_pApp, pWidget);\r
-                       break;\r
-               case FIELDTYPE_CHECKBOX:\r
-                       pFormFiller = new CFFL_CheckBox(m_pApp, pWidget);\r
-                       break;\r
-               case FIELDTYPE_RADIOBUTTON:\r
-                       pFormFiller = new CFFL_RadioButton(m_pApp, pWidget);\r
-                       break;\r
-               case FIELDTYPE_TEXTFIELD:\r
-                       pFormFiller = new CFFL_TextField(m_pApp, pWidget);\r
-                       break;\r
-               case FIELDTYPE_LISTBOX:\r
-                       pFormFiller = new CFFL_ListBox(m_pApp, pWidget);\r
-                       break;\r
-               case FIELDTYPE_COMBOBOX:\r
-                       pFormFiller = new CFFL_ComboBox(m_pApp, pWidget);\r
-                       break;\r
-               case FIELDTYPE_UNKNOWN:\r
-               default:\r
-                       pFormFiller = NULL;\r
-                       break;\r
-               }\r
-\r
-               if (pFormFiller)\r
-               {\r
-                       m_Maps.SetAt(pAnnot, pFormFiller);\r
-               }\r
-       }\r
-\r
-       return pFormFiller;\r
-}\r
-\r
-void CFFL_IFormFiller::RemoveFormFiller(CPDFSDK_Annot* pAnnot)\r
-{\r
-       if ( pAnnot != NULL )\r
-       {\r
-               UnRegisterFormFiller( pAnnot );\r
-       }\r
-}\r
-\r
-void CFFL_IFormFiller::UnRegisterFormFiller(CPDFSDK_Annot* pAnnot)\r
-{\r
-       CFFL_FormFiller * pFormFiller = NULL;\r
-\r
-       if (m_Maps.Lookup(pAnnot,pFormFiller))\r
-       {\r
-               if (pFormFiller)\r
-                       delete pFormFiller;\r
-               m_Maps.RemoveKey(pAnnot);\r
-       }\r
-}\r
-\r
-void CFFL_IFormFiller::SetFocusAnnotTab(CPDFSDK_Annot* pWidget, FX_BOOL bSameField, FX_BOOL bNext)\r
-{\r
-\r
-}\r
-\r
-void CFFL_IFormFiller::QueryWherePopup(void* pPrivateData, FX_FLOAT fPopupMin,FX_FLOAT fPopupMax, FX_INT32 & nRet, FX_FLOAT & fPopupRet)\r
-{\r
-       ASSERT(pPrivateData != NULL);\r
-\r
-       CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData;\r
-\r
-       \r
-\r
-\r
-       CPDF_Rect rcPageView(0,0,0,0);\r
-       rcPageView.right = pData->pWidget->GetPDFPage()->GetPageWidth();\r
-       rcPageView.bottom = pData->pWidget->GetPDFPage()->GetPageHeight();\r
-       rcPageView.Normalize();\r
-\r
-\r
-       ASSERT(pData->pWidget != NULL);\r
-       CPDF_Rect rcAnnot = pData->pWidget->GetRect();\r
-\r
-       FX_FLOAT fTop = 0.0f;\r
-       FX_FLOAT fBottom = 0.0f;\r
-\r
-       CPDFSDK_Widget * pWidget = (CPDFSDK_Widget*)pData->pWidget;\r
-       switch (pWidget->GetRotate() / 90)\r
-       {\r
-       default:\r
-       case 0:\r
-               fTop = rcPageView.top - rcAnnot.top;\r
-               fBottom = rcAnnot.bottom - rcPageView.bottom;\r
-               break;\r
-       case 1:\r
-               fTop = rcAnnot.left - rcPageView.left;\r
-               fBottom = rcPageView.right - rcAnnot.right;\r
-               break;\r
-       case 2:\r
-               fTop = rcAnnot.bottom - rcPageView.bottom;\r
-               fBottom = rcPageView.top - rcAnnot.top;\r
-               break;\r
-       case 3:\r
-               fTop = rcPageView.right - rcAnnot.right;\r
-               fBottom = rcAnnot.left - rcPageView.left;\r
-               break;\r
-       }\r
-\r
-       FX_FLOAT fFactHeight = 0;\r
-       FX_BOOL bBottom = TRUE;\r
-       FX_FLOAT fMaxListBoxHeight = 0;\r
-       if (fPopupMax > FFL_MAXLISTBOXHEIGHT)\r
-       {\r
-               if (fPopupMin > FFL_MAXLISTBOXHEIGHT)\r
-               {\r
-                       fMaxListBoxHeight = fPopupMin;\r
-               }\r
-               else\r
-               {\r
-                       fMaxListBoxHeight = FFL_MAXLISTBOXHEIGHT;\r
-               }\r
-       }\r
-       else\r
-               fMaxListBoxHeight = fPopupMax;\r
-\r
-       if (fBottom > fMaxListBoxHeight)\r
-       {\r
-               fFactHeight = fMaxListBoxHeight;\r
-               bBottom = TRUE;\r
-       }\r
-       else\r
-       {\r
-               if (fTop > fMaxListBoxHeight)\r
-               {\r
-                       fFactHeight = fMaxListBoxHeight;\r
-                       bBottom = FALSE;\r
-               }\r
-               else\r
-               {\r
-                       if (fTop > fBottom)\r
-                       {\r
-                               fFactHeight = fTop;\r
-                               bBottom = FALSE;\r
-                       }\r
-                       else\r
-                       {\r
-                               fFactHeight = fBottom;\r
-                               bBottom = TRUE;\r
-                       }\r
-               }\r
-       }\r
-\r
-       nRet = bBottom ? 0 : 1;\r
-       fPopupRet = fFactHeight;\r
-}\r
-\r
-void CFFL_IFormFiller::OnSetWindowRect(void* pPrivateData, const CPDF_Rect & rcWindow)\r
-{\r
-       ASSERT(pPrivateData != NULL);\r
-\r
-       CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData;\r
-\r
-       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, TRUE))\r
-       {\r
-\r
-               CPDF_Rect rcOld = pFormFiller->PWLtoFFL(pFormFiller->GetWindowRect(pData->pPageView));\r
-               CPDF_Rect rcNew = pFormFiller->PWLtoFFL(rcWindow);\r
-               pFormFiller->SetWindowRect(pData->pPageView, rcWindow);\r
-\r
-               CPDF_Rect unRect = rcOld;\r
-               unRect.Union(rcNew);\r
-               //FX_RECT rcRect = unRect.GetOutterRect();\r
-               unRect.left = (FX_FLOAT)(unRect.left - 0.5);\r
-               unRect.right = (FX_FLOAT)(unRect.right + 0.5);\r
-               unRect.top = (FX_FLOAT)(unRect.top + 0.5);\r
-               unRect.bottom = (FX_FLOAT)(unRect.bottom -0.5);\r
-               m_pApp->FFI_Invalidate(pData->pWidget->GetPDFPage(), unRect.left, unRect.top, unRect.right, unRect.bottom);\r
-       }\r
-}\r
-\r
-void CFFL_IFormFiller::OnKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, FX_INT32 nKeyCode, CFX_WideString& strChange, \r
-                                                                  const CFX_WideString& strChangeEx, FX_BOOL bKeyDown, \r
-                                                                  FX_BOOL & bRC, FX_BOOL & bExit)\r
-{\r
-       ASSERT(pPrivateData != NULL);\r
-       CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData;\r
-       ASSERT(pData->pWidget != NULL);\r
-\r
-       CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE);\r
-       ASSERT(pFormFiller != NULL);\r
-\r
-       pFormFiller->OnKeyStroke(bKeyDown);\r
-}\r
-\r
-void CFFL_IFormFiller::OnKeyStrokeCommit(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bRC, FX_BOOL& bExit, FX_DWORD nFlag)\r
-{\r
-       if (!m_bNotifying)\r
-       {\r
-               ASSERT(pWidget != NULL);\r
-               if (pWidget->GetAAction(CPDF_AAction::KeyStroke))\r
-               {\r
-                       m_bNotifying = TRUE;\r
-                       pWidget->ClearAppModified();\r
-\r
-                       ASSERT(pPageView != NULL);\r
-//                     CReader_DocView* pDocView = pPageView->GetDocView();\r
-//                     ASSERT(pDocView != NULL);\r
-                       \r
-               \r
-\r
-                       PDFSDK_FieldAction fa;\r
-                       fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);\r
-                       fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);\r
-                       fa.bWillCommit = TRUE;\r
-                       fa.nCommitKey = GetCommitKey();\r
-                       fa.bKeyDown = GetKeyDown();\r
-                       fa.bRC = TRUE;\r
-\r
-                       CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE);\r
-                       ASSERT(pFormFiller != NULL);\r
-\r
-                       pFormFiller->GetActionData(pPageView, CPDF_AAction::KeyStroke, fa);\r
-                       pFormFiller->SaveState(pPageView);\r
-\r
-                       PDFSDK_FieldAction faOld = fa;\r
-                       pWidget->OnAAction(CPDF_AAction::KeyStroke, fa, pPageView);\r
-\r
-                       bRC = fa.bRC;\r
-//                     bExit = !IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, pWidget);\r
-\r
-                       m_bNotifying = FALSE;\r
-               }\r
-       }\r
-}\r
-\r
-void CFFL_IFormFiller::OnValidate(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bRC, FX_BOOL& bExit, FX_DWORD nFlag)\r
-{\r
-       if (!m_bNotifying)\r
-       {\r
-               ASSERT(pWidget != NULL);\r
-               if (pWidget->GetAAction(CPDF_AAction::Validate))\r
-               {\r
-                       m_bNotifying = TRUE;\r
-                       pWidget->ClearAppModified();\r
-\r
-                       ASSERT(pPageView != NULL);\r
-//                     CReader_DocView* pDocView = pPageView->GetDocView();\r
-//                     ASSERT(pDocView != NULL);\r
-                       \r
-                       \r
-\r
-                       PDFSDK_FieldAction fa;\r
-                       fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);\r
-                       fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);\r
-                       fa.bKeyDown = GetKeyDown();\r
-                       fa.bRC = TRUE;\r
-\r
-                       CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE);\r
-                       ASSERT(pFormFiller != NULL);\r
-\r
-                       pFormFiller->GetActionData(pPageView, CPDF_AAction::Validate, fa);\r
-                       pFormFiller->SaveState(pPageView);\r
-\r
-                       PDFSDK_FieldAction faOld = fa;\r
-                       pWidget->OnAAction(CPDF_AAction::Validate, fa, pPageView);\r
-\r
-                       bRC = fa.bRC;\r
-//                     bExit = !IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, pWidget);\r
-\r
-                       m_bNotifying = FALSE;\r
-               }\r
-       }\r
-}\r
-\r
-void CFFL_IFormFiller::OnCalculate(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bExit, FX_DWORD nFlag)\r
-{\r
-       if (!m_bNotifying)\r
-       {\r
-               ASSERT(pWidget != NULL);\r
-               ASSERT(pPageView != NULL);\r
-//             CReader_DocView* pDocView = pPageView->GetDocView();\r
-//             ASSERT(pDocView != NULL);\r
-               CPDFSDK_Document* pDocument = pPageView->GetSDKDocument();\r
-               ASSERT(pDocument != NULL);\r
-\r
-               CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();\r
-               ASSERT(pInterForm != NULL);\r
-\r
-               pInterForm->OnCalculate(pWidget->GetFormField());\r
-\r
-//             bExit = !IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, pWidget);\r
-\r
-               m_bNotifying = FALSE;\r
-       }\r
-}\r
-\r
-void CFFL_IFormFiller::OnFormat(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bExit, FX_DWORD nFlag)\r
-{\r
-       if (!m_bNotifying)\r
-       {\r
-               ASSERT(pWidget != NULL);\r
-               ASSERT(pPageView != NULL);\r
-//             CReader_DocView* pDocView = pPageView->GetDocView();\r
-//             ASSERT(pDocView != NULL);\r
-               CPDFSDK_Document* pDocument = pPageView->GetSDKDocument();\r
-               ASSERT(pDocument != NULL);\r
-\r
-               CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();\r
-               ASSERT(pInterForm != NULL);\r
-\r
-               FX_BOOL bFormated = FALSE;\r
-               CFX_WideString sValue = pInterForm->OnFormat(pWidget->GetFormField(), GetCommitKey(), bFormated);\r
-\r
-//             bExit = !IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, pWidget);\r
-\r
-               if (bExit) return;\r
-\r
-               if (bFormated)\r
-               {\r
-                       pInterForm->ResetFieldAppearance(pWidget->GetFormField(), sValue, TRUE);\r
-                       pInterForm->UpdateField(pWidget->GetFormField());\r
-               }\r
-\r
-               m_bNotifying = FALSE;\r
-       }\r
-}\r
-\r
-// LRESULT CALLBACK CFFL_IFormFiller::FFL_WndProc(\r
-//                                                                       int code,       // hook code\r
-//                                                                       WPARAM wParam,  // virtual-key code\r
-//                                                                       LPARAM lParam   // keystroke-message information\r
-//                                                                             )\r
-// {\r
-//     if (code != HC_ACTION)\r
-//     {\r
-//             return CallNextHookEx (m_hookSheet, code, wParam, lParam);\r
-//     }\r
-// \r
-//     FXSYS_memcpy(&g_Msg, (void*)lParam, sizeof(MSG));       \r
-// \r
-//     return 0;\r
-// }\r
-\r
-// MSG CFFL_IFormFiller::GetLastMessage()\r
-// {\r
-//     return g_Msg;\r
-// }\r
-\r
-int CFFL_IFormFiller::GetCommitKey()\r
-{\r
-//     MSG msg = CFFL_IFormFiller::GetLastMessage();\r
-\r
-       int nCommitKey = 0;\r
-//     switch (msg.message)\r
-//     {\r
-//     case WM_LBUTTONDOWN:\r
-//     case WM_LBUTTONUP:\r
-//             nCommitKey = 1;\r
-//             break;\r
-//     case WM_KEYDOWN:\r
-//             switch (msg.wParam)\r
-//             {\r
-//             case VK_RETURN:\r
-//                     nCommitKey = 2;\r
-//                     break;\r
-//             case VK_TAB:\r
-//                     nCommitKey = 3;\r
-//                     break;\r
-//             }\r
-//             break;\r
-//     }\r
-\r
-       return nCommitKey;\r
-}\r
-\r
-FX_BOOL CFFL_IFormFiller::GetKeyDown()\r
-{\r
-       return TRUE;\r
-//     MSG msg = CFFL_IFormFiller::GetLastMessage();\r
-// \r
-//     return msg.message == WM_KEYDOWN || msg.message == WM_CHAR;\r
-}\r
-\r
-FX_BOOL        CFFL_IFormFiller::IsValidAnnot(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot)\r
-{\r
-\r
-       ASSERT(pPageView != NULL);\r
-       ASSERT(pAnnot != NULL);\r
-\r
-       if(pPageView)\r
-               return pPageView->IsValidAnnot(pAnnot->GetPDFAnnot());\r
-       else\r
-               return FALSE;\r
-}\r
-\r
-void CFFL_IFormFiller::BeforeUndo(CPDFSDK_Document* pDocument)\r
-{\r
-\r
-}\r
-\r
-void CFFL_IFormFiller::BeforeRedo(CPDFSDK_Document* pDocument)\r
-{\r
-       BeforeUndo(pDocument);\r
-}\r
-\r
-void CFFL_IFormFiller::AfterUndo(CPDFSDK_Document* pDocument)\r
-{\r
-}\r
-\r
-void CFFL_IFormFiller::AfterRedo(CPDFSDK_Document* pDocument)\r
-{\r
-}\r
-\r
-FX_BOOL        CFFL_IFormFiller::CanCopy(CPDFSDK_Document* pDocument)\r
-{\r
-\r
-       return FALSE;\r
-}\r
-\r
-FX_BOOL        CFFL_IFormFiller::CanCut(CPDFSDK_Document* pDocument)\r
-{\r
-\r
-       return FALSE;\r
-}\r
-\r
-FX_BOOL        CFFL_IFormFiller::CanPaste(CPDFSDK_Document* pDocument)\r
-{\r
-\r
-       return FALSE;\r
-}\r
-\r
-void CFFL_IFormFiller::DoCopy(CPDFSDK_Document* pDocument)\r
-{\r
-}\r
-\r
-void CFFL_IFormFiller::DoCut(CPDFSDK_Document* pDocument)\r
-{\r
-}\r
-\r
-void CFFL_IFormFiller::DoPaste(CPDFSDK_Document* pDocument)\r
-{\r
-\r
-}\r
-void CFFL_IFormFiller::OnBeforeKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, FX_INT32 nKeyCode,\r
-                                                                                         CFX_WideString & strChange, const CFX_WideString& strChangeEx, \r
-                                                                                         int nSelStart, int nSelEnd,\r
-                                                                               FX_BOOL bKeyDown, FX_BOOL & bRC, FX_BOOL & bExit, FX_DWORD nFlag)\r
-{\r
-       ASSERT(pPrivateData != NULL);\r
-       CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData;\r
-       ASSERT(pData->pWidget != NULL);\r
-       \r
-       CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE);\r
-       ASSERT(pFormFiller != NULL);\r
-       \r
-       if (!m_bNotifying)\r
-       {\r
-               if (pData->pWidget->GetAAction(CPDF_AAction::KeyStroke))\r
-               {\r
-                       m_bNotifying = TRUE;\r
-                       int nAge = pData->pWidget->GetAppearanceAge();\r
-                       int nValueAge = pData->pWidget->GetValueAge();\r
-\r
-                       ASSERT(pData->pPageView != NULL);\r
-                       CPDFSDK_Document* pDocument  = pData->pPageView->GetSDKDocument();\r
-                       \r
-                       PDFSDK_FieldAction fa;\r
-                       fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);\r
-                       fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);\r
-                       fa.sChange = strChange;\r
-                       fa.sChangeEx = strChangeEx;\r
-                       fa.bKeyDown = bKeyDown;\r
-                       fa.bWillCommit = FALSE;\r
-                       fa.bRC = TRUE;\r
-                       fa.nSelStart = nSelStart;\r
-                       fa.nSelEnd = nSelEnd;\r
-\r
-\r
-                       pFormFiller->GetActionData(pData->pPageView, CPDF_AAction::KeyStroke, fa);\r
-                       pFormFiller->SaveState(pData->pPageView);\r
-                       \r
-                       if (pData->pWidget->OnAAction(CPDF_AAction::KeyStroke, fa, pData->pPageView))\r
-                       {\r
-                               if (!IsValidAnnot(pData->pPageView, pData->pWidget))\r
-                               {\r
-                                       bExit = TRUE;\r
-                                       m_bNotifying = FALSE;\r
-                                       return;\r
-                               }\r
-                               \r
-                               if (nAge != pData->pWidget->GetAppearanceAge())\r
-                               {\r
-                                       CPWL_Wnd* pWnd = pFormFiller->ResetPDFWindow(pData->pPageView, nValueAge == pData->pWidget->GetValueAge());\r
-                                       pData = (CFFL_PrivateData*)pWnd->GetAttachedData();\r
-                                       bExit = TRUE;\r
-                               }\r
-                               \r
-                               if (fa.bRC)\r
-                               {\r
-                                       pFormFiller->SetActionData(pData->pPageView, CPDF_AAction::KeyStroke, fa);\r
-                                       bRC = FALSE;\r
-                               }\r
-                               else\r
-                               {\r
-                                       pFormFiller->RestoreState(pData->pPageView);\r
-                                       bRC = FALSE;\r
-                               }\r
-                               \r
-                               if (pDocument->GetFocusAnnot() != pData->pWidget)\r
-                               {\r
-                                       pFormFiller->CommitData(pData->pPageView,nFlag);\r
-                                       bExit = TRUE;\r
-                               }\r
-                       }\r
-                       else\r
-                       {                       \r
-                               if (!IsValidAnnot(pData->pPageView, pData->pWidget))\r
-                               {\r
-                                       bExit = TRUE;\r
-                                       m_bNotifying = FALSE;\r
-                                       return;\r
-                               }\r
-                       }\r
-                       \r
-                       m_bNotifying = FALSE;\r
-               }\r
-       }\r
-}\r
-\r
-void   CFFL_IFormFiller::OnAfterKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, FX_BOOL & bExit,FX_DWORD nFlag) \r
-{\r
-       ASSERT(pPrivateData != NULL);\r
-       CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData;\r
-       ASSERT(pData->pWidget != NULL);\r
-       \r
-       CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE);\r
-       ASSERT(pFormFiller != NULL);\r
-       \r
-       if (!bEditOrList)\r
-               pFormFiller->OnKeyStroke(bExit);\r
-}\r
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "../../include/formfiller/FFL_FormFiller.h"
+#include "../../include/formfiller/FFL_IFormFiller.h"
+#include "../../include/formfiller/FFL_CheckBox.h"
+#include "../../include/formfiller/FFL_ComboBox.h"
+#include "../../include/formfiller/FFL_ListBox.h"
+#include "../../include/formfiller/FFL_PushButton.h"
+#include "../../include/formfiller/FFL_RadioButton.h"
+#include "../../include/formfiller/FFL_TextField.h"
+
+#define FFL_MAXLISTBOXHEIGHT           140.0f
+
+// HHOOK CFFL_IFormFiller::m_hookSheet = NULL;
+// MSG CFFL_IFormFiller::g_Msg;
+
+/* ----------------------------- CFFL_IFormFiller ----------------------------- */
+
+CFFL_IFormFiller::CFFL_IFormFiller(CPDFDoc_Environment* pApp) : 
+       m_pApp(pApp),
+       m_bNotifying(FALSE)
+{
+}
+
+CFFL_IFormFiller::~CFFL_IFormFiller()
+{
+       FX_POSITION pos = m_Maps.GetStartPosition();
+       while (pos)
+       {
+               CPDFSDK_Annot * pAnnot = NULL;
+               CFFL_FormFiller * pFormFiller = NULL;
+               m_Maps.GetNextAssoc(pos,pAnnot,pFormFiller);
+               delete pFormFiller;
+       }
+       m_Maps.RemoveAll();
+}
+
+FX_BOOL        CFFL_IFormFiller::Annot_HitTest(CPDFSDK_PageView* pPageView,CPDFSDK_Annot* pAnnot, CPDF_Point point)
+{
+       CPDF_Rect rc = pAnnot->GetRect();
+       if(rc.Contains(point.x, point.y))
+               return TRUE;
+       return FALSE;
+}
+
+FX_RECT CFFL_IFormFiller::GetViewBBox(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot)
+{
+       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+       {
+               return pFormFiller->GetViewBBox(pPageView, pAnnot);
+       }
+       else
+       {
+               ASSERT(pPageView != NULL);
+               ASSERT(pAnnot != NULL);
+
+               CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot();
+               ASSERT(pPDFAnnot != NULL);
+
+               CPDF_Rect rcAnnot;
+               pPDFAnnot->GetRect(rcAnnot);
+
+//             CRect rcWin;
+//             pPageView->DocToWindow(rcAnnot, rcWin);
+               CPDF_Rect rcWin = CPWL_Utils::InflateRect(rcAnnot,1);
+//             rcWin.InflateRect(1, 1);
+
+               return rcWin.GetOutterRect();
+       }
+}
+
+void CFFL_IFormFiller::OnDraw(CPDFSDK_PageView* pPageView, /*HDC hDC,*/ CPDFSDK_Annot* pAnnot, 
+                                               CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
+                                               /*const CRect& rcWindow,*/ FX_DWORD dwFlags)
+{
+       ASSERT(pPageView != NULL);
+       CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+
+       if (IsVisible(pWidget))
+       {
+               if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+               {
+                       if (pFormFiller->IsValid())
+                       {
+                               pFormFiller->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags);
+                               
+                               pAnnot->GetPDFPage();
+                               
+
+                               CPDFSDK_Document* pDocument = m_pApp->GetCurrentDoc();
+                               ASSERT(pDocument != NULL);
+
+                               if (pDocument->GetFocusAnnot() == pAnnot)
+                               {
+                                       CPDF_Rect rcFocus = pFormFiller->GetFocusBox(pPageView);
+                                       if (!rcFocus.IsEmpty())
+                                       {
+                                               CFX_PathData path;
+                                               
+                                               path.SetPointCount(5);
+                                               path.SetPoint(0, rcFocus.left,  rcFocus.top, FXPT_MOVETO);
+                                               path.SetPoint(1, rcFocus.left,  rcFocus.bottom, FXPT_LINETO);
+                                               path.SetPoint(2, rcFocus.right,  rcFocus.bottom, FXPT_LINETO);
+                                               path.SetPoint(3, rcFocus.right,  rcFocus.top, FXPT_LINETO);
+                                               path.SetPoint(4, rcFocus.left,  rcFocus.top, FXPT_LINETO);
+                                               
+                                               CFX_GraphStateData gsd;
+                                               gsd.SetDashCount(1);                            
+                                               gsd.m_DashArray[0] = 1.0f;
+                                               gsd.m_DashPhase = 0;    
+                                               
+                                               gsd.m_LineWidth = 1.0f;
+                                               pDevice->DrawPath(&path, pUser2Device, &gsd, 0, ArgbEncode(255,0,0,0), FXFILL_ALTERNATE);
+
+                                       //      ::DrawFocusRect(hDC, &rcFocus); 
+                                       }
+                               }
+
+                               return;
+                       }
+               }
+
+               if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+                       pFormFiller->OnDrawDeactive(pPageView, pAnnot, pDevice, pUser2Device, dwFlags);
+               else
+                       pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
+
+               if (!IsReadOnly(pWidget) && IsFillingAllowed(pWidget))
+               {
+                       pWidget->DrawShadow(pDevice, pPageView);
+               }
+       
+       }
+}
+
+void CFFL_IFormFiller::OnCreate(CPDFSDK_Annot* pAnnot)
+{
+       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+       {
+               pFormFiller->OnCreate(pAnnot);
+       }
+}
+
+void CFFL_IFormFiller::OnLoad(CPDFSDK_Annot* pAnnot)
+{
+       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+       {
+               pFormFiller->OnLoad(pAnnot);
+       }
+}
+
+void CFFL_IFormFiller::OnDelete(CPDFSDK_Annot* pAnnot)
+{
+       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+       {
+               pFormFiller->OnDelete(pAnnot);
+       }
+
+       UnRegisterFormFiller(pAnnot);
+}
+
+void CFFL_IFormFiller::OnMouseEnter(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlag)
+{
+       ASSERT(pAnnot != NULL);
+       ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+       
+       if (!m_bNotifying)
+       {
+               CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+               if (pWidget->GetAAction(CPDF_AAction::CursorEnter))
+               {
+                       m_bNotifying = TRUE;
+                       
+                       int nValueAge = pWidget->GetValueAge();
+
+                       pWidget->ClearAppModified();
+                       
+                       ASSERT(pPageView != NULL);
+                       
+                       
+                       
+                       PDFSDK_FieldAction fa;
+                       fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
+                       fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
+                       pWidget->OnAAction(CPDF_AAction::CursorEnter, fa, pPageView );
+                       m_bNotifying = FALSE;
+                       
+                       //if ( !IsValidAnnot(pPageView, pAnnot) ) return;
+                       
+                       if (pWidget->IsAppModified())
+                       {
+                               if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE))
+                               {
+                                       pFormFiller->ResetPDFWindow(pPageView, pWidget->GetValueAge() == nValueAge);
+                               }
+                       }
+               }
+       }
+       
+       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE))
+       {
+               pFormFiller->OnMouseEnter(pPageView, pAnnot);
+       }
+}
+
+void CFFL_IFormFiller::OnMouseExit(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlag)
+{
+       ASSERT(pAnnot != NULL);
+       ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+       
+       if (!m_bNotifying)
+       {
+               CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+               if (pWidget->GetAAction(CPDF_AAction::CursorExit))
+               {
+                       m_bNotifying = TRUE;
+                       pWidget->GetAppearanceAge();
+                       int nValueAge = pWidget->GetValueAge();
+                       pWidget->ClearAppModified();
+                       
+                       ASSERT(pPageView != NULL);
+                       
+                       
+                       
+                       PDFSDK_FieldAction fa;
+                       fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
+                       fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
+                       
+                       pWidget->OnAAction(CPDF_AAction::CursorExit, fa, pPageView);
+                       m_bNotifying = FALSE;
+                       
+                       //if (!IsValidAnnot(pPageView, pAnnot)) return;
+                       
+                       if (pWidget->IsAppModified())
+                       {
+                               if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE))
+                               {
+                                       pFormFiller->ResetPDFWindow(pPageView, nValueAge == pWidget->GetValueAge());
+                               }
+                       }
+               }
+       }
+       
+       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+       {
+               pFormFiller->OnMouseExit(pPageView, pAnnot);
+       }
+}
+
+FX_BOOL        CFFL_IFormFiller::OnLButtonDown(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
+{
+       ASSERT(pAnnot != NULL);
+       ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+       
+       if (!m_bNotifying)
+       {
+               CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+               if (Annot_HitTest(pPageView, pAnnot, point) && pWidget->GetAAction(CPDF_AAction::ButtonDown))
+               {
+                       m_bNotifying = TRUE;
+                       pWidget->GetAppearanceAge();
+                       int nValueAge = pWidget->GetValueAge();
+                       pWidget->ClearAppModified();
+                       
+                       ASSERT(pPageView != NULL);
+                       
+                       
+                       
+                       PDFSDK_FieldAction fa;
+                       fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlags);
+                       fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlags);
+                       pWidget->OnAAction(CPDF_AAction::ButtonDown, fa, pPageView);
+                       m_bNotifying = FALSE;
+                       
+                       if (!IsValidAnnot(pPageView, pAnnot)) return TRUE;
+                       
+                       if (pWidget->IsAppModified())
+                       {
+                               if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE))
+                               {
+                                       pFormFiller->ResetPDFWindow(pPageView, nValueAge == pWidget->GetValueAge());
+                               }
+                       }
+               }
+       }
+       
+       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+       {
+               return pFormFiller->OnLButtonDown(pPageView, pAnnot, nFlags, point);
+       }
+       
+       return FALSE;
+}
+
+FX_BOOL        CFFL_IFormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
+{
+       ASSERT(pAnnot != NULL);
+       ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+       
+       CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+       //      CReader_Page* pPage = pAnnot->GetPage();
+       //      ASSERT(pPage != NULL);
+       CPDFSDK_Document* pDocument = m_pApp->GetCurrentDoc();
+       ASSERT(pDocument != NULL);              
+       
+       switch (pWidget->GetFieldType())
+       {
+       case FIELDTYPE_PUSHBUTTON:
+       case FIELDTYPE_CHECKBOX:
+       case FIELDTYPE_RADIOBUTTON:
+               if (GetViewBBox(pPageView, pAnnot).Contains((int)point.x, (int)point.y))
+               {
+                       pDocument->SetFocusAnnot(pAnnot);
+               }
+               break;
+       default:
+               pDocument->SetFocusAnnot(pAnnot);
+               break;
+       }
+       
+       FX_BOOL bRet = FALSE;
+       
+       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+       {
+               bRet = pFormFiller->OnLButtonUp(pPageView, pAnnot, nFlags, point);
+       }
+
+       if (pDocument->GetFocusAnnot() == pAnnot)
+       {
+               FX_BOOL bExit = FALSE;
+               FX_BOOL bReset = FALSE;
+               OnButtonUp(pWidget, pPageView, bReset, bExit,nFlags);
+               if (bExit) return TRUE;
+       }
+       return bRet;
+}
+
+void CFFL_IFormFiller::OnButtonUp(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bReset, FX_BOOL& bExit,FX_UINT nFlag)
+{
+       ASSERT(pWidget != NULL);
+       
+       if (!m_bNotifying)
+       {
+               if (pWidget->GetAAction(CPDF_AAction::ButtonUp))
+               {
+                       m_bNotifying = TRUE;
+                       int nAge = pWidget->GetAppearanceAge();
+                       int nValueAge = pWidget->GetValueAge();
+                       
+                       ASSERT(pPageView != NULL);
+//                     CReader_DocView* pDocView = pPageView->GetDocView();
+//                     ASSERT(pDocView != NULL);
+                       
+                       
+                       
+                       PDFSDK_FieldAction fa;
+                       fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
+                       fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
+
+                       pWidget->OnAAction(CPDF_AAction::ButtonUp, fa, pPageView);
+                       m_bNotifying = FALSE;
+                       
+                       if (!IsValidAnnot(pPageView, pWidget))
+                       {
+                               bExit = TRUE;
+                               return;
+                       }
+                       
+                       if (nAge != pWidget->GetAppearanceAge())
+                       {
+                               if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE))
+                               {
+                                       pFormFiller->ResetPDFWindow(pPageView, nValueAge == pWidget->GetValueAge());
+                               }
+                               
+                               bReset = TRUE;
+                       }
+               }
+       }
+}
+
+FX_BOOL        CFFL_IFormFiller::OnLButtonDblClk(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
+{
+       ASSERT(pAnnot != NULL);
+       ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+
+       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+       {
+               return pFormFiller->OnLButtonDblClk(pPageView, pAnnot, nFlags, point);
+       }
+
+       return FALSE;
+}
+
+FX_BOOL        CFFL_IFormFiller::OnMouseMove(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
+{
+       ASSERT(pAnnot != NULL);
+       ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+
+       //change cursor
+       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE))
+       {
+               return pFormFiller->OnMouseMove(pPageView, pAnnot, nFlags, point);
+       }
+
+       return FALSE;
+}
+
+FX_BOOL        CFFL_IFormFiller::OnMouseWheel(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, short zDelta, const CPDF_Point& point)
+{
+       ASSERT(pAnnot != NULL);
+       ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+
+       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+       {
+               return pFormFiller->OnMouseWheel(pPageView, pAnnot, nFlags, zDelta, point);
+       }
+
+       return FALSE;
+}
+
+FX_BOOL        CFFL_IFormFiller::OnRButtonDown(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
+{
+       ASSERT(pAnnot != NULL);
+       ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+
+       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+       {
+               return pFormFiller->OnRButtonDown(pPageView, pAnnot, nFlags, point);
+       }
+
+       return FALSE;
+}
+
+FX_BOOL        CFFL_IFormFiller::OnRButtonUp(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
+{
+       ASSERT(pAnnot != NULL);
+       ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+
+       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+       {
+               return pFormFiller->OnRButtonUp(pPageView, pAnnot, nFlags, point);
+       }
+
+       return FALSE;
+}
+
+FX_BOOL        CFFL_IFormFiller::OnRButtonDblClk(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
+{
+       ASSERT(pAnnot != NULL);
+       ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+
+       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+       {
+               return pFormFiller->OnRButtonDblClk(pPageView, pAnnot, nFlags, point);
+       }
+
+       return FALSE;
+}
+
+FX_BOOL        CFFL_IFormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, FX_UINT nKeyCode, FX_UINT nFlags)
+{
+       ASSERT(pAnnot != NULL);
+       ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+
+       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+       {
+               return pFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlags);        
+       }
+
+       return FALSE;
+}
+
+FX_BOOL        CFFL_IFormFiller::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags)
+{
+       ASSERT(pAnnot != NULL);
+       ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+
+       if (nChar == FWL_VKEY_Tab) return TRUE;
+
+       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+       {
+               return pFormFiller->OnChar(pAnnot, nChar, nFlags);
+       }
+
+       return FALSE;
+}
+
+void CFFL_IFormFiller::OnDeSelected(CPDFSDK_Annot* pAnnot)
+{
+       ASSERT(pAnnot != NULL);
+       ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+
+       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+       {
+               pFormFiller->OnDeSelected(pAnnot);
+       }
+}
+
+void CFFL_IFormFiller::OnSelected(CPDFSDK_Annot* pAnnot)
+{
+       ASSERT(pAnnot != NULL);
+       ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+
+       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+       {
+               pFormFiller->OnSelected(pAnnot);
+       }
+}
+
+FX_BOOL CFFL_IFormFiller::OnSetFocus(CPDFSDK_Annot* pAnnot,FX_UINT nFlag)
+{
+       if(!pAnnot) return FALSE;
+       ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+
+       if (!m_bNotifying)
+       {
+               CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+               if (pWidget->GetAAction(CPDF_AAction::GetFocus))
+               {
+                       m_bNotifying = TRUE;
+                       pWidget->GetAppearanceAge();
+                       int nValueAge = pWidget->GetValueAge();
+                       pWidget->ClearAppModified();
+                       CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
+                       ASSERT(pPageView != NULL);
+                       
+                       PDFSDK_FieldAction fa;
+                       fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
+                       fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
+
+                       CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, TRUE);
+                       if(!pFormFiller) return FALSE;
+                       pFormFiller->GetActionData(pPageView, CPDF_AAction::GetFocus, fa);
+                       pWidget->OnAAction(CPDF_AAction::GetFocus, fa, pPageView);
+                       m_bNotifying = FALSE;
+                       
+ //                    if (!IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, pAnnot)) return FALSE;
+                       if (pWidget->IsAppModified())
+                       {
+                               if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE))
+                               {
+                                       pFormFiller->ResetPDFWindow(pPageView, nValueAge == pWidget->GetValueAge());
+                               }
+                       }
+               }
+       }
+       
+       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE))
+       {
+               if (pFormFiller->OnSetFocus(pAnnot, nFlag))
+               {
+                       return TRUE;
+               }
+               else
+                       return FALSE;
+       }
+
+       return TRUE;
+}
+
+FX_BOOL        CFFL_IFormFiller::OnKillFocus(CPDFSDK_Annot* pAnnot,FX_UINT nFlag)
+{
+       if(!pAnnot) return FALSE;
+       ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+
+       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
+       {
+               if (pFormFiller->OnKillFocus(pAnnot, nFlag))
+               {
+                       if (!m_bNotifying)
+                       {
+                               CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+                               if (pWidget->GetAAction(CPDF_AAction::LoseFocus))
+                               {
+                                       m_bNotifying = TRUE;
+                                       pWidget->ClearAppModified();
+                                       CPDFSDK_PageView* pPageView = pWidget->GetPageView();
+                                       ASSERT(pPageView != NULL);
+                                       PDFSDK_FieldAction fa;
+                                       fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
+                                       fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
+                                       pFormFiller->GetActionData(pPageView, CPDF_AAction::LoseFocus, fa);
+                                       pWidget->OnAAction(CPDF_AAction::LoseFocus, fa, pPageView);
+                                       m_bNotifying = FALSE;
+                               }
+                       }
+               }
+               else
+                       return FALSE;
+       }
+
+       return TRUE;
+}
+
+FX_BOOL        CFFL_IFormFiller::IsVisible(CPDFSDK_Widget* pWidget)
+{
+       return pWidget->IsVisible();
+}
+
+FX_BOOL        CFFL_IFormFiller::IsReadOnly(CPDFSDK_Widget* pWidget)
+{
+       ASSERT(pWidget != NULL);
+
+       int nFieldFlags = pWidget->GetFieldFlags();
+
+       return (nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY;
+}
+
+FX_BOOL        CFFL_IFormFiller::IsFillingAllowed(CPDFSDK_Widget* pWidget)
+{
+       ASSERT(pWidget != NULL);
+
+       if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON)
+               return TRUE;
+       else
+       {
+               CPDF_Page* pPage = pWidget->GetPDFPage();
+               ASSERT(pPage != NULL);
+               CPDF_Document* pDocument = pPage->m_pDocument;
+               ASSERT(pDocument != NULL);
+               FX_DWORD dwPermissions = pDocument->GetUserPermissions();
+               return (dwPermissions&FPDFPERM_FILL_FORM) || 
+                               (dwPermissions&FPDFPERM_ANNOT_FORM) || 
+                       (dwPermissions&FPDFPERM_MODIFY);
+       }
+       return TRUE;    
+}
+
+CFFL_FormFiller* CFFL_IFormFiller::GetFormFiller(CPDFSDK_Annot* pAnnot, FX_BOOL bRegister)
+{
+//     ASSERT(pAnnot != NULL);
+//     ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
+
+       CFFL_FormFiller * pFormFiller = NULL;
+       m_Maps.Lookup(pAnnot, pFormFiller);
+
+       if (pFormFiller)
+               return pFormFiller;
+
+       if (bRegister)
+       {
+               CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;              
+
+               int nFieldType = pWidget->GetFieldType();
+               switch(nFieldType)
+               {
+               case FIELDTYPE_PUSHBUTTON:
+                       pFormFiller = new CFFL_PushButton(m_pApp, pWidget);
+                       break;
+               case FIELDTYPE_CHECKBOX:
+                       pFormFiller = new CFFL_CheckBox(m_pApp, pWidget);
+                       break;
+               case FIELDTYPE_RADIOBUTTON:
+                       pFormFiller = new CFFL_RadioButton(m_pApp, pWidget);
+                       break;
+               case FIELDTYPE_TEXTFIELD:
+                       pFormFiller = new CFFL_TextField(m_pApp, pWidget);
+                       break;
+               case FIELDTYPE_LISTBOX:
+                       pFormFiller = new CFFL_ListBox(m_pApp, pWidget);
+                       break;
+               case FIELDTYPE_COMBOBOX:
+                       pFormFiller = new CFFL_ComboBox(m_pApp, pWidget);
+                       break;
+               case FIELDTYPE_UNKNOWN:
+               default:
+                       pFormFiller = NULL;
+                       break;
+               }
+
+               if (pFormFiller)
+               {
+                       m_Maps.SetAt(pAnnot, pFormFiller);
+               }
+       }
+
+       return pFormFiller;
+}
+
+void CFFL_IFormFiller::RemoveFormFiller(CPDFSDK_Annot* pAnnot)
+{
+       if ( pAnnot != NULL )
+       {
+               UnRegisterFormFiller( pAnnot );
+       }
+}
+
+void CFFL_IFormFiller::UnRegisterFormFiller(CPDFSDK_Annot* pAnnot)
+{
+       CFFL_FormFiller * pFormFiller = NULL;
+
+       if (m_Maps.Lookup(pAnnot,pFormFiller))
+       {
+               if (pFormFiller)
+                       delete pFormFiller;
+               m_Maps.RemoveKey(pAnnot);
+       }
+}
+
+void CFFL_IFormFiller::SetFocusAnnotTab(CPDFSDK_Annot* pWidget, FX_BOOL bSameField, FX_BOOL bNext)
+{
+
+}
+
+void CFFL_IFormFiller::QueryWherePopup(void* pPrivateData, FX_FLOAT fPopupMin,FX_FLOAT fPopupMax, int32_t & nRet, FX_FLOAT & fPopupRet)
+{
+       ASSERT(pPrivateData != NULL);
+
+       CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData;
+
+       
+
+
+       CPDF_Rect rcPageView(0,0,0,0);
+       rcPageView.right = pData->pWidget->GetPDFPage()->GetPageWidth();
+       rcPageView.bottom = pData->pWidget->GetPDFPage()->GetPageHeight();
+       rcPageView.Normalize();
+
+
+       ASSERT(pData->pWidget != NULL);
+       CPDF_Rect rcAnnot = pData->pWidget->GetRect();
+
+       FX_FLOAT fTop = 0.0f;
+       FX_FLOAT fBottom = 0.0f;
+
+       CPDFSDK_Widget * pWidget = (CPDFSDK_Widget*)pData->pWidget;
+       switch (pWidget->GetRotate() / 90)
+       {
+       default:
+       case 0:
+               fTop = rcPageView.top - rcAnnot.top;
+               fBottom = rcAnnot.bottom - rcPageView.bottom;
+               break;
+       case 1:
+               fTop = rcAnnot.left - rcPageView.left;
+               fBottom = rcPageView.right - rcAnnot.right;
+               break;
+       case 2:
+               fTop = rcAnnot.bottom - rcPageView.bottom;
+               fBottom = rcPageView.top - rcAnnot.top;
+               break;
+       case 3:
+               fTop = rcPageView.right - rcAnnot.right;
+               fBottom = rcAnnot.left - rcPageView.left;
+               break;
+       }
+
+       FX_FLOAT fFactHeight = 0;
+       FX_BOOL bBottom = TRUE;
+       FX_FLOAT fMaxListBoxHeight = 0;
+       if (fPopupMax > FFL_MAXLISTBOXHEIGHT)
+       {
+               if (fPopupMin > FFL_MAXLISTBOXHEIGHT)
+               {
+                       fMaxListBoxHeight = fPopupMin;
+               }
+               else
+               {
+                       fMaxListBoxHeight = FFL_MAXLISTBOXHEIGHT;
+               }
+       }
+       else
+               fMaxListBoxHeight = fPopupMax;
+
+       if (fBottom > fMaxListBoxHeight)
+       {
+               fFactHeight = fMaxListBoxHeight;
+               bBottom = TRUE;
+       }
+       else
+       {
+               if (fTop > fMaxListBoxHeight)
+               {
+                       fFactHeight = fMaxListBoxHeight;
+                       bBottom = FALSE;
+               }
+               else
+               {
+                       if (fTop > fBottom)
+                       {
+                               fFactHeight = fTop;
+                               bBottom = FALSE;
+                       }
+                       else
+                       {
+                               fFactHeight = fBottom;
+                               bBottom = TRUE;
+                       }
+               }
+       }
+
+       nRet = bBottom ? 0 : 1;
+       fPopupRet = fFactHeight;
+}
+
+void CFFL_IFormFiller::OnSetWindowRect(void* pPrivateData, const CPDF_Rect & rcWindow)
+{
+       ASSERT(pPrivateData != NULL);
+
+       CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData;
+
+       if (CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, TRUE))
+       {
+
+               CPDF_Rect rcOld = pFormFiller->PWLtoFFL(pFormFiller->GetWindowRect(pData->pPageView));
+               CPDF_Rect rcNew = pFormFiller->PWLtoFFL(rcWindow);
+               pFormFiller->SetWindowRect(pData->pPageView, rcWindow);
+
+               CPDF_Rect unRect = rcOld;
+               unRect.Union(rcNew);
+               //FX_RECT rcRect = unRect.GetOutterRect();
+               unRect.left = (FX_FLOAT)(unRect.left - 0.5);
+               unRect.right = (FX_FLOAT)(unRect.right + 0.5);
+               unRect.top = (FX_FLOAT)(unRect.top + 0.5);
+               unRect.bottom = (FX_FLOAT)(unRect.bottom -0.5);
+               m_pApp->FFI_Invalidate(pData->pWidget->GetPDFPage(), unRect.left, unRect.top, unRect.right, unRect.bottom);
+       }
+}
+
+void CFFL_IFormFiller::OnKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, int32_t nKeyCode, CFX_WideString& strChange, 
+                                                                  const CFX_WideString& strChangeEx, FX_BOOL bKeyDown, 
+                                                                  FX_BOOL & bRC, FX_BOOL & bExit)
+{
+       ASSERT(pPrivateData != NULL);
+       CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData;
+       ASSERT(pData->pWidget != NULL);
+
+       CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE);
+       ASSERT(pFormFiller != NULL);
+
+       pFormFiller->OnKeyStroke(bKeyDown);
+}
+
+void CFFL_IFormFiller::OnKeyStrokeCommit(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bRC, FX_BOOL& bExit, FX_DWORD nFlag)
+{
+       if (!m_bNotifying)
+       {
+               ASSERT(pWidget != NULL);
+               if (pWidget->GetAAction(CPDF_AAction::KeyStroke))
+               {
+                       m_bNotifying = TRUE;
+                       pWidget->ClearAppModified();
+
+                       ASSERT(pPageView != NULL);
+//                     CReader_DocView* pDocView = pPageView->GetDocView();
+//                     ASSERT(pDocView != NULL);
+                       
+               
+
+                       PDFSDK_FieldAction fa;
+                       fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
+                       fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
+                       fa.bWillCommit = TRUE;
+                       fa.nCommitKey = GetCommitKey();
+                       fa.bKeyDown = GetKeyDown();
+                       fa.bRC = TRUE;
+
+                       CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE);
+                       ASSERT(pFormFiller != NULL);
+
+                       pFormFiller->GetActionData(pPageView, CPDF_AAction::KeyStroke, fa);
+                       pFormFiller->SaveState(pPageView);
+
+                       PDFSDK_FieldAction faOld = fa;
+                       pWidget->OnAAction(CPDF_AAction::KeyStroke, fa, pPageView);
+
+                       bRC = fa.bRC;
+//                     bExit = !IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, pWidget);
+
+                       m_bNotifying = FALSE;
+               }
+       }
+}
+
+void CFFL_IFormFiller::OnValidate(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bRC, FX_BOOL& bExit, FX_DWORD nFlag)
+{
+       if (!m_bNotifying)
+       {
+               ASSERT(pWidget != NULL);
+               if (pWidget->GetAAction(CPDF_AAction::Validate))
+               {
+                       m_bNotifying = TRUE;
+                       pWidget->ClearAppModified();
+
+                       ASSERT(pPageView != NULL);
+//                     CReader_DocView* pDocView = pPageView->GetDocView();
+//                     ASSERT(pDocView != NULL);
+                       
+                       
+
+                       PDFSDK_FieldAction fa;
+                       fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
+                       fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
+                       fa.bKeyDown = GetKeyDown();
+                       fa.bRC = TRUE;
+
+                       CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE);
+                       ASSERT(pFormFiller != NULL);
+
+                       pFormFiller->GetActionData(pPageView, CPDF_AAction::Validate, fa);
+                       pFormFiller->SaveState(pPageView);
+
+                       PDFSDK_FieldAction faOld = fa;
+                       pWidget->OnAAction(CPDF_AAction::Validate, fa, pPageView);
+
+                       bRC = fa.bRC;
+//                     bExit = !IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, pWidget);
+
+                       m_bNotifying = FALSE;
+               }
+       }
+}
+
+void CFFL_IFormFiller::OnCalculate(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bExit, FX_DWORD nFlag)
+{
+       if (!m_bNotifying)
+       {
+               ASSERT(pWidget != NULL);
+               ASSERT(pPageView != NULL);
+//             CReader_DocView* pDocView = pPageView->GetDocView();
+//             ASSERT(pDocView != NULL);
+               CPDFSDK_Document* pDocument = pPageView->GetSDKDocument();
+               ASSERT(pDocument != NULL);
+
+               CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
+               ASSERT(pInterForm != NULL);
+
+               pInterForm->OnCalculate(pWidget->GetFormField());
+
+//             bExit = !IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, pWidget);
+
+               m_bNotifying = FALSE;
+       }
+}
+
+void CFFL_IFormFiller::OnFormat(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bExit, FX_DWORD nFlag)
+{
+       if (!m_bNotifying)
+       {
+               ASSERT(pWidget != NULL);
+               ASSERT(pPageView != NULL);
+//             CReader_DocView* pDocView = pPageView->GetDocView();
+//             ASSERT(pDocView != NULL);
+               CPDFSDK_Document* pDocument = pPageView->GetSDKDocument();
+               ASSERT(pDocument != NULL);
+
+               CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();
+               ASSERT(pInterForm != NULL);
+
+               FX_BOOL bFormated = FALSE;
+               CFX_WideString sValue = pInterForm->OnFormat(pWidget->GetFormField(), GetCommitKey(), bFormated);
+
+//             bExit = !IsValidAnnot(m_pApp, pDocument, pDocView, pPageView, pWidget);
+
+               if (bExit) return;
+
+               if (bFormated)
+               {
+                       pInterForm->ResetFieldAppearance(pWidget->GetFormField(), sValue.c_str(), TRUE);
+                       pInterForm->UpdateField(pWidget->GetFormField());
+               }
+
+               m_bNotifying = FALSE;
+       }
+}
+
+// LRESULT CALLBACK CFFL_IFormFiller::FFL_WndProc(
+//                                                                       int code,       // hook code
+//                                                                       WPARAM wParam,  // virtual-key code
+//                                                                       LPARAM lParam   // keystroke-message information
+//                                                                             )
+// {
+//     if (code != HC_ACTION)
+//     {
+//             return CallNextHookEx (m_hookSheet, code, wParam, lParam);
+//     }
+// 
+//     FXSYS_memcpy(&g_Msg, (void*)lParam, sizeof(MSG));       
+// 
+//     return 0;
+// }
+
+// MSG CFFL_IFormFiller::GetLastMessage()
+// {
+//     return g_Msg;
+// }
+
+int CFFL_IFormFiller::GetCommitKey()
+{
+//     MSG msg = CFFL_IFormFiller::GetLastMessage();
+
+       int nCommitKey = 0;
+//     switch (msg.message)
+//     {
+//     case WM_LBUTTONDOWN:
+//     case WM_LBUTTONUP:
+//             nCommitKey = 1;
+//             break;
+//     case WM_KEYDOWN:
+//             switch (msg.wParam)
+//             {
+//             case VK_RETURN:
+//                     nCommitKey = 2;
+//                     break;
+//             case VK_TAB:
+//                     nCommitKey = 3;
+//                     break;
+//             }
+//             break;
+//     }
+
+       return nCommitKey;
+}
+
+FX_BOOL CFFL_IFormFiller::GetKeyDown()
+{
+       return TRUE;
+//     MSG msg = CFFL_IFormFiller::GetLastMessage();
+// 
+//     return msg.message == WM_KEYDOWN || msg.message == WM_CHAR;
+}
+
+FX_BOOL        CFFL_IFormFiller::IsValidAnnot(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot)
+{
+
+       ASSERT(pPageView != NULL);
+       ASSERT(pAnnot != NULL);
+
+       if(pPageView)
+               return pPageView->IsValidAnnot(pAnnot->GetPDFAnnot());
+       else
+               return FALSE;
+}
+
+void CFFL_IFormFiller::BeforeUndo(CPDFSDK_Document* pDocument)
+{
+
+}
+
+void CFFL_IFormFiller::BeforeRedo(CPDFSDK_Document* pDocument)
+{
+       BeforeUndo(pDocument);
+}
+
+void CFFL_IFormFiller::AfterUndo(CPDFSDK_Document* pDocument)
+{
+}
+
+void CFFL_IFormFiller::AfterRedo(CPDFSDK_Document* pDocument)
+{
+}
+
+FX_BOOL        CFFL_IFormFiller::CanCopy(CPDFSDK_Document* pDocument)
+{
+
+       return FALSE;
+}
+
+FX_BOOL        CFFL_IFormFiller::CanCut(CPDFSDK_Document* pDocument)
+{
+
+       return FALSE;
+}
+
+FX_BOOL        CFFL_IFormFiller::CanPaste(CPDFSDK_Document* pDocument)
+{
+
+       return FALSE;
+}
+
+void CFFL_IFormFiller::DoCopy(CPDFSDK_Document* pDocument)
+{
+}
+
+void CFFL_IFormFiller::DoCut(CPDFSDK_Document* pDocument)
+{
+}
+
+void CFFL_IFormFiller::DoPaste(CPDFSDK_Document* pDocument)
+{
+
+}
+void CFFL_IFormFiller::OnBeforeKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, int32_t nKeyCode,
+                                                                                         CFX_WideString & strChange, const CFX_WideString& strChangeEx, 
+                                                                                         int nSelStart, int nSelEnd,
+                                                                               FX_BOOL bKeyDown, FX_BOOL & bRC, FX_BOOL & bExit, FX_DWORD nFlag)
+{
+       ASSERT(pPrivateData != NULL);
+       CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData;
+       ASSERT(pData->pWidget != NULL);
+       
+       CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE);
+       ASSERT(pFormFiller != NULL);
+       
+       if (!m_bNotifying)
+       {
+               if (pData->pWidget->GetAAction(CPDF_AAction::KeyStroke))
+               {
+                       m_bNotifying = TRUE;
+                       int nAge = pData->pWidget->GetAppearanceAge();
+                       int nValueAge = pData->pWidget->GetValueAge();
+
+                       ASSERT(pData->pPageView != NULL);
+                       CPDFSDK_Document* pDocument  = pData->pPageView->GetSDKDocument();
+                       
+                       PDFSDK_FieldAction fa;
+                       fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
+                       fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
+                       fa.sChange = strChange;
+                       fa.sChangeEx = strChangeEx;
+                       fa.bKeyDown = bKeyDown;
+                       fa.bWillCommit = FALSE;
+                       fa.bRC = TRUE;
+                       fa.nSelStart = nSelStart;
+                       fa.nSelEnd = nSelEnd;
+
+
+                       pFormFiller->GetActionData(pData->pPageView, CPDF_AAction::KeyStroke, fa);
+                       pFormFiller->SaveState(pData->pPageView);
+                       
+                       if (pData->pWidget->OnAAction(CPDF_AAction::KeyStroke, fa, pData->pPageView))
+                       {
+                               if (!IsValidAnnot(pData->pPageView, pData->pWidget))
+                               {
+                                       bExit = TRUE;
+                                       m_bNotifying = FALSE;
+                                       return;
+                               }
+                               
+                               if (nAge != pData->pWidget->GetAppearanceAge())
+                               {
+                                       CPWL_Wnd* pWnd = pFormFiller->ResetPDFWindow(pData->pPageView, nValueAge == pData->pWidget->GetValueAge());
+                                       pData = (CFFL_PrivateData*)pWnd->GetAttachedData();
+                                       bExit = TRUE;
+                               }
+                               
+                               if (fa.bRC)
+                               {
+                                       pFormFiller->SetActionData(pData->pPageView, CPDF_AAction::KeyStroke, fa);
+                                       bRC = FALSE;
+                               }
+                               else
+                               {
+                                       pFormFiller->RestoreState(pData->pPageView);
+                                       bRC = FALSE;
+                               }
+                               
+                               if (pDocument->GetFocusAnnot() != pData->pWidget)
+                               {
+                                       pFormFiller->CommitData(pData->pPageView,nFlag);
+                                       bExit = TRUE;
+                               }
+                       }
+                       else
+                       {                       
+                               if (!IsValidAnnot(pData->pPageView, pData->pWidget))
+                               {
+                                       bExit = TRUE;
+                                       m_bNotifying = FALSE;
+                                       return;
+                               }
+                       }
+                       
+                       m_bNotifying = FALSE;
+               }
+       }
+}
+
+void   CFFL_IFormFiller::OnAfterKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, FX_BOOL & bExit,FX_DWORD nFlag) 
+{
+       ASSERT(pPrivateData != NULL);
+       CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData;
+       ASSERT(pData->pWidget != NULL);
+       
+       CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE);
+       ASSERT(pFormFiller != NULL);
+       
+       if (!bEditOrList)
+               pFormFiller->OnKeyStroke(bExit);
+}