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