• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_FORMFILLER_H_
8 #define _FFL_FORMFILLER_H_
9 
10 #include "FFL_IFormFiller.h"
11 #include "FFL_CBA_Fontmap.h"
12 
13 class CPDFSDK_Annot;
14 class CFFL_FormFiller;
15 class CFFL_Notify;
16 class CPDFDoc_Environment;
17 class CPDFSDK_PageView;
18 class CPDFSDK_Document;
19 class CPDFSDK_Widget;
20 
21 
22 #define CFFL_PageView2PDFWindow		CFX_MapPtrTemplate<CPDFSDK_PageView*, CPWL_Wnd*>
23 
24 struct FFL_KeyStrokeData
25 {
26 	CFX_WideString		swValue;
27 	FX_BOOL				bFull;
28 	int					nSelStart;
29 	int					nSelEnd;
30 };
31 
32 
33 
34 class CFFL_FormFiller : /*public IBA_AnnotFiller,*/ public IPWL_Provider, public CPWL_TimerHandler
35 {
36 public:
37 	CFFL_FormFiller(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot);
38 	virtual ~CFFL_FormFiller();
39 
40 	virtual FX_RECT				GetViewBBox(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot);
41 	virtual void				OnDraw(CPDFSDK_PageView *pPageView, /*HDC hDC,*/ CPDFSDK_Annot* pAnnot,
42 									CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
43 									/*const CRect& rcWindow, */FX_DWORD dwFlags);
44 	virtual void				OnDrawDeactive(CPDFSDK_PageView *pPageView, /*HDC hDC,*/ CPDFSDK_Annot* pAnnot,
45 								CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
46 								/*const CRect& rcWindow, */FX_DWORD dwFlags);
47 
48 	virtual void				OnCreate(CPDFSDK_Annot* pAnnot);
49 	virtual void				OnLoad(CPDFSDK_Annot* pAnnot);
50 	virtual void				OnDelete(CPDFSDK_Annot* pAnnot);
51 
52 	virtual void				OnMouseEnter(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot);
53 	virtual void				OnMouseExit(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot);
54 
55 	virtual FX_BOOL				OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point);
56 	virtual FX_BOOL				OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point);
57 	virtual FX_BOOL				OnLButtonDblClk(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point);
58 	virtual FX_BOOL				OnMouseMove(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point);
59 	virtual FX_BOOL				OnMouseWheel(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, short zDelta, const CPDF_Point& point);
60 	virtual FX_BOOL				OnRButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point);
61 	virtual FX_BOOL				OnRButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point);
62 	virtual FX_BOOL				OnRButtonDblClk(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point);
63 
64 	virtual FX_BOOL				OnKeyDown(CPDFSDK_Annot* pAnnot, FX_UINT nKeyCode, FX_UINT nFlags);
65 	virtual FX_BOOL				OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags);
66 
67 	virtual	void				OnDeSelected(CPDFSDK_Annot* pAnnot);
68 	virtual	void				OnSelected(CPDFSDK_Annot* pAnnot);
69 
70 	virtual FX_BOOL				OnSetFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag);
71 	virtual FX_BOOL				OnKillFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag);
72 
73 	virtual FX_BOOL				CanCopy(CPDFSDK_Document* pDocument);
74 	virtual FX_BOOL				CanCut(CPDFSDK_Document* pDocument);
75 	virtual FX_BOOL				CanPaste(CPDFSDK_Document* pDocument);
76 
77 	virtual void				DoCopy(CPDFSDK_Document* pDocument);
78 	virtual void				DoCut(CPDFSDK_Document* pDocument);
79 	virtual void				DoPaste(CPDFSDK_Document* pDocument);
80 
81 public: //CPWL_TimerHandler
82 	virtual void				TimerProc();
83 	virtual IFX_SystemHandler*	GetSystemHandler() const;
84 
85 public:
86 	virtual CPDF_Matrix			GetWindowMatrix(void* pAttachedData);
87 	virtual CFX_WideString		LoadPopupMenuString(int nIndex);
88 
89  	virtual void				GetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AActionType type,
90  									PDFSDK_FieldAction& fa);
91  	virtual void				SetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AActionType type,
92  									const PDFSDK_FieldAction& fa);
93  	virtual FX_BOOL				IsActionDataChanged(CPDF_AAction::AActionType type, const PDFSDK_FieldAction& faOld,
94  									const PDFSDK_FieldAction& faNew);
95 
96 	virtual void				SaveState(CPDFSDK_PageView* pPageView);
97 	virtual void				RestoreState(CPDFSDK_PageView* pPageView);
98 
99 	virtual CPWL_Wnd* 			ResetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bRestoreValue);
100 
101 	virtual void				OnKeyStroke(FX_BOOL bKeyDown);
102 
103 	CPDF_Matrix					GetCurMatrix();
104 
105 	CPDF_Rect					FFLtoPWL(const CPDF_Rect& rect);
106 	CPDF_Rect					PWLtoFFL(const CPDF_Rect& rect);
107 	CPDF_Point					FFLtoPWL(const CPDF_Point& point);
108 	CPDF_Point					PWLtoFFL(const CPDF_Point& point);
109 
110 	CPDF_Point					WndtoPWL(CPDFSDK_PageView* pPageView, const CPDF_Point& pt);
111 	CPDF_Rect					FFLtoWnd(CPDFSDK_PageView* pPageView, const CPDF_Rect& rect);
112 
113 	void						SetWindowRect(CPDFSDK_PageView* pPageView, const CPDF_Rect& rcWindow);
114 	CPDF_Rect					GetWindowRect(CPDFSDK_PageView* pPageView);
115 
116 	static void					FFL_FreeData(void* pData);
117 
118 	FX_BOOL						CommitData(CPDFSDK_PageView* pPageView, FX_UINT nFlag);
119 	virtual FX_BOOL				IsDataChanged(CPDFSDK_PageView* pPageView);
120 	virtual void				SaveData(CPDFSDK_PageView* pPageView);
121 
122 	virtual void				GetKeyStrokeData(CPDFSDK_PageView* pPageView, FFL_KeyStrokeData& data);
123 
124 public:
125 	CPWL_Wnd*					GetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bNew);
126 	void						DestroyPDFWindow(CPDFSDK_PageView* pPageView);
127 	void						EscapeFiller(CPDFSDK_PageView* pPageView, FX_BOOL bDestroyPDFWindow);
128 
129 	virtual	PWL_CREATEPARAM		GetCreateParam();
130 	virtual CPWL_Wnd*			NewPDFWindow(const PWL_CREATEPARAM& cp, CPDFSDK_PageView* pPageView) = 0;
131 	virtual CPDF_Rect			GetFocusBox(CPDFSDK_PageView* pPageView);
132 
133 public:
134 	FX_BOOL						IsValid() const;
135 	CPDF_Rect					GetPDFWindowRect() const;
136 
137 	CPDFSDK_PageView*			GetCurPageView();
138 	void						SetChangeMark();
139 
140 	virtual void				InvalidateRect(double left, double top, double right, double bottom);
GetApp()141 	CPDFDoc_Environment*		GetApp(){return m_pApp;}
GetSDKAnnot()142 	CPDFSDK_Annot*				GetSDKAnnot() {return m_pAnnot;}
143 protected:
144 	CPDFDoc_Environment*		m_pApp;
145 	CPDFSDK_Widget*				m_pWidget;
146 	CPDFSDK_Annot*				m_pAnnot;
147 
148 	FX_BOOL						m_bValid;
149 	CFFL_PageView2PDFWindow		m_Maps;
150 	CPDF_Point					m_ptOldPos;
151 };
152 
153 class CFFL_Button : public CFFL_FormFiller
154 {
155 public:
156 	CFFL_Button(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pWidget);
157 	virtual ~CFFL_Button();
158 
159 	virtual void				OnMouseEnter(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot);
160 	virtual void				OnMouseExit(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot);
161 	virtual FX_BOOL				OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point);
162 	virtual FX_BOOL				OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point);
163 	virtual FX_BOOL				OnMouseMove(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point);
164 	virtual void				OnDraw(CPDFSDK_PageView *pPageView/*, HDC hDC*/, CPDFSDK_Annot* pAnnot,
165 								CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
166 								/*const CRect& rcWindow,*/ FX_DWORD dwFlags);
167 
168 	virtual	void				OnDrawDeactive(CPDFSDK_PageView *pPageView, /*HDC hDC,*/ CPDFSDK_Annot* pAnnot,
169 								CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
170 								/*const CRect& rcWindow, */FX_DWORD dwFlags);
171 protected:
172 	FX_BOOL						m_bMouseIn;
173 	FX_BOOL						m_bMouseDown;
174 };
175 
176 //#define CFFL_IM_BOX				CFX_ArrayTemplate<CBA_EditInput*>
177 
178 #endif
179