Merge XFA to PDFium master at 4dc95e7 on 10/28/2014
[pdfium.git] / fpdfsdk / include / formfiller / FFL_IFormFiller.h
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4  
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #ifndef _FFL_IFORMFILLER_H_
8 #define _FFL_IFORMFILLER_H_
9
10 #include "FormFiller.h"
11 class CFFL_FormFiller;
12 class CFFL_PrivateData;
13
14 #define CFFL_Widget2Filler              CFX_MapPtrTemplate<CPDFSDK_Annot*, CFFL_FormFiller*>
15
16 // #define IsALTpressed()                       (GetKeyState(VK_MENU) < 0)
17 // #define IsCTRLpressed()                      (GetKeyState(VK_CONTROL) < 0)
18 // #define IsSHIFTpressed()             (GetKeyState(VK_SHIFT)&0x8000)
19 // #define IsINSERTpressed()            (GetKeyState(VK_INSERT) & 0x01) 
20 // #define VK_SHIFT          0x10
21 // #define VK_CONTROL        0x11
22 // #define VK_MENU           0x12
23 // #define VK_RETURN         0x0D
24 // #define VK_SPACE          0x20
25 // #define VK_ESCAPE         0x1B
26
27
28
29 class CFFL_IFormFiller :/* public IBA_AnnotFiller, */public IPWL_Filler_Notify//, 
30 //      public IUndo_EventHandler, public IClipboard_Handler
31 {
32 public:
33         CFFL_IFormFiller(CPDFDoc_Environment* pApp);
34         virtual ~CFFL_IFormFiller();
35
36         virtual FX_BOOL                         Annot_HitTest(CPDFSDK_PageView* pPageView,CPDFSDK_Annot* pAnnot, CPDF_Point point);
37         virtual FX_RECT                         GetViewBBox(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot);
38         virtual void                            OnDraw(CPDFSDK_PageView *pPageView, /*HDC hDC,*/ CPDFSDK_Annot* pAnnot, 
39                                                                         CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
40                                                                         /*const CRect& rcWindow,*/ FX_DWORD dwFlags);
41
42
43         virtual void                            OnCreate(CPDFSDK_Annot* pAnnot);
44         virtual void                            OnLoad(CPDFSDK_Annot* pAnnot);
45         virtual void                            OnDelete(CPDFSDK_Annot* pAnnot);
46
47         virtual void                            OnMouseEnter(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlag);
48         virtual void                            OnMouseExit(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlag);
49
50         virtual FX_BOOL                         OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point);
51         virtual FX_BOOL                         OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point);
52         virtual FX_BOOL                         OnLButtonDblClk(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point);
53         virtual FX_BOOL                         OnMouseMove(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point);
54         virtual FX_BOOL                         OnMouseWheel(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, short zDelta, const CPDF_Point& point);
55         virtual FX_BOOL                         OnRButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point);
56         virtual FX_BOOL                         OnRButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point);
57         virtual FX_BOOL                         OnRButtonDblClk(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point);
58
59         virtual FX_BOOL                         OnKeyDown(CPDFSDK_Annot* pAnnot, FX_UINT nKeyCode, FX_UINT nFlags);
60         virtual FX_BOOL                         OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags);
61
62         virtual void                            OnDeSelected(CPDFSDK_Annot* pAnnot);
63         virtual void                            OnSelected(CPDFSDK_Annot* pAnnot);
64
65         virtual FX_BOOL                         OnSetFocus(CPDFSDK_Annot* pAnnot,FX_UINT nFlag);
66         virtual FX_BOOL                         OnKillFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag);
67
68 public:
69         virtual void                            QueryWherePopup(void* pPrivateData, FX_FLOAT fPopupMin,FX_FLOAT fPopupMax, FX_INT32 & nRet, FX_FLOAT & fPopupRet);
70         virtual void                            OnBeforeKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, FX_INT32 nKeyCode,
71                                                                                 CFX_WideString & strChange, const CFX_WideString& strChangeEx, 
72                                                                                 int nSelStart, int nSelEnd,
73                                                                                 FX_BOOL bKeyDown, FX_BOOL & bRC, FX_BOOL & bExit, FX_DWORD nFlag);
74         virtual void                            OnAfterKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, FX_BOOL & bExit, FX_DWORD nFlag) ;
75
76         virtual void                            OnSetWindowRect(void* pPrivateData, const CPDF_Rect & rcWindow);
77         virtual void                            OnKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, FX_INT32 nKeyCode, CFX_WideString & strChange, 
78                                                                         const CFX_WideString& strChangeEx, FX_BOOL bKeyDown, FX_BOOL & bRC, FX_BOOL & bExit);
79         virtual void                            OnPopupPreOpen(void* pPrivateData, FX_BOOL& bExit, FX_DWORD nFlag);
80         virtual void                            OnPopupPostOpen(void* pPrivateData, FX_BOOL& bExit, FX_DWORD nFlag);
81
82 public:
83         virtual void                            BeforeUndo(CPDFSDK_Document* pDocument);
84         virtual void                            BeforeRedo(CPDFSDK_Document* pDocument);
85         virtual void                            AfterUndo(CPDFSDK_Document* pDocument);
86         virtual void                            AfterRedo(CPDFSDK_Document* pDocument);
87
88 public:
89         virtual FX_BOOL                         CanCopy(CPDFSDK_Document* pDocument); 
90         virtual FX_BOOL                         CanCut(CPDFSDK_Document* pDocument); 
91         virtual FX_BOOL                         CanPaste(CPDFSDK_Document* pDocument); 
92
93         virtual void                            DoCopy(CPDFSDK_Document* pDocument); 
94         virtual void                            DoCut(CPDFSDK_Document* pDocument); 
95         virtual void                            DoPaste(CPDFSDK_Document* pDocument); 
96
97 public:
98         CFFL_FormFiller*                        GetFormFiller(CPDFSDK_Annot* pAnnot, FX_BOOL bRegister);
99         void                                            RemoveFormFiller(CPDFSDK_Annot* pAnnot);
100
101         static FX_BOOL                          IsVisible(CPDFSDK_Widget* pWidget);
102         static FX_BOOL                          IsReadOnly(CPDFSDK_Widget* pWidget);
103         static FX_BOOL                          IsFillingAllowed(CPDFSDK_Widget* pWidget);
104         static FX_BOOL                          IsValidAnnot(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot);
105
106         void                                            OnKeyStrokeCommit(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bRC, FX_BOOL& bExit, FX_DWORD nFlag);
107         void                                            OnValidate(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bRC, FX_BOOL& bExit, FX_DWORD nFlag);
108
109         void                                            OnCalculate(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bExit, FX_DWORD nFlag);
110         void                                            OnFormat(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bExit, FX_DWORD nFlag);
111         void                                            OnButtonUp(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bReset, FX_BOOL& bExit,FX_UINT nFlag);
112 //      static LRESULT CALLBACK         FFL_WndProc(
113 //                                                                        int code,       // hook code
114 //                                                                        WPARAM wParam,  // virtual-key code
115 //                                                                        LPARAM lParam   // keystroke-message information
116 //                                                                              );
117 //      static MSG                                      GetLastMessage();
118         static int                                      GetCommitKey();
119         static FX_BOOL                          GetKeyDown();
120
121         void                                            OnClick(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bReset, FX_BOOL& bExit, FX_UINT nFlag);
122         void                                            OnFull(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bReset, FX_BOOL& bExit, FX_UINT nFlag);
123         void                                            OnPreOpen(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bReset, FX_BOOL& bExit, FX_UINT nFlag);
124         void                                            OnPostOpen(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bReset, FX_BOOL& bExit, FX_UINT nFlag);
125
126 public:
127 //      static MSG                                      g_Msg;
128 //      static HHOOK                            m_hookSheet;
129
130 private:
131         void                                            UnRegisterFormFiller(CPDFSDK_Annot* pAnnot);
132         void                                            SetFocusAnnotTab(CPDFSDK_Annot* pWidget, FX_BOOL bSameField, FX_BOOL bNext);
133
134 private:
135         CPDFDoc_Environment*                            m_pApp;
136         CFFL_Widget2Filler                      m_Maps;
137         FX_BOOL                                         m_bNotifying;
138 };
139
140 class CFFL_PrivateData
141 {
142 public:
143         CPDFSDK_Widget*                 pWidget;
144         CPDFSDK_PageView*       pPageView;
145         int                                     nWidgetAge;
146         int                                     nValueAge;
147 };
148
149 #endif //_FFL_IFORMFILLER_H_
150