Initial commit.
[pdfium.git] / fpdfsdk / include / javascript / JS_Context.h
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4  \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #ifndef _JS_CONTEXT_H_\r
8 #define _JS_CONTEXT_H_\r
9 \r
10 class CJS_EventHandler;\r
11 class CJS_Runtime;\r
12 \r
13 class CJS_Context : public IFXJS_Context\r
14 {\r
15 public:\r
16         CJS_Context(CJS_Runtime* pRuntime);\r
17         virtual ~CJS_Context();\r
18 \r
19 public:\r
20         virtual FX_BOOL                         Compile(const CFX_WideString& script, CFX_WideString& info);\r
21         virtual FX_BOOL                         RunScript(const CFX_WideString& script, CFX_WideString& info);\r
22 \r
23 public:\r
24         virtual void                            OnApp_Init();\r
25 \r
26         virtual void                            OnDoc_Open(CPDFSDK_Document* pDoc, const CFX_WideString& strTargetName);\r
27         virtual void                            OnDoc_WillPrint(CPDFSDK_Document* pDoc);\r
28         virtual void                            OnDoc_DidPrint(CPDFSDK_Document* pDoc);\r
29         virtual void                            OnDoc_WillSave(CPDFSDK_Document* pDoc);\r
30         virtual void                            OnDoc_DidSave(CPDFSDK_Document* pDoc);\r
31         virtual void                            OnDoc_WillClose(CPDFSDK_Document* pDoc);\r
32 \r
33         virtual void                            OnPage_Open(CPDFSDK_Document* pTarget);\r
34         virtual void                            OnPage_Close(CPDFSDK_Document* pTarget);\r
35         virtual void                            OnPage_InView(CPDFSDK_Document* pTarget);\r
36         virtual void                            OnPage_OutView(CPDFSDK_Document* pTarget);\r
37         \r
38         virtual void                            OnField_MouseDown(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField *pTarget);\r
39         virtual void                            OnField_MouseEnter(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField *pTarget);\r
40         virtual void                            OnField_MouseExit(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField *pTarget);\r
41         virtual void                            OnField_MouseUp(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField *pTarget);\r
42         virtual void                            OnField_Focus(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget, const CFX_WideString& Value);\r
43         virtual void                            OnField_Blur(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget, const CFX_WideString& Value);\r
44 \r
45         virtual void                            OnField_Calculate(CPDF_FormField* pSource, CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL& bRc);\r
46         virtual void                            OnField_Format(int nCommitKey, CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL bWillCommit);\r
47         virtual void                            OnField_Keystroke(int nCommitKey, CFX_WideString& strChange, const CFX_WideString& strChangeEx,\r
48                                                                         FX_BOOL bKeyDown, FX_BOOL bModifier, int &nSelEnd,int &nSelStart, FX_BOOL bShift,\r
49                                                                         CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL bWillCommit, \r
50                                                                         FX_BOOL bFieldFull, FX_BOOL &bRc);\r
51         virtual void                            OnField_Validate(CFX_WideString& strChange, const CFX_WideString& strChangeEx, FX_BOOL bKeyDown,\r
52                                                                         FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL& bRc);\r
53 \r
54         virtual void                            OnScreen_Focus(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen);\r
55         virtual void                            OnScreen_Blur(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen);\r
56         virtual void                            OnScreen_Open(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen);\r
57         virtual void                            OnScreen_Close(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen);\r
58         virtual void                            OnScreen_MouseDown(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen);\r
59         virtual void                            OnScreen_MouseUp(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen);\r
60         virtual void                            OnScreen_MouseEnter(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen);\r
61         virtual void                            OnScreen_MouseExit(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen);\r
62         virtual void                            OnScreen_InView(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen);\r
63         virtual void                            OnScreen_OutView(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen);\r
64 \r
65         virtual void                            OnBookmark_MouseUp(CPDF_Bookmark* pBookMark);\r
66         virtual void                            OnLink_MouseUp(CPDFSDK_Document* pTarget);\r
67 \r
68         virtual void                            OnMenu_Exec(CPDFSDK_Document* pTarget, const CFX_WideString& strTargetName);\r
69         virtual void                            OnBatchExec(CPDFSDK_Document* pTarget);\r
70         virtual void                            OnConsole_Exec();\r
71         virtual void                            OnExternal_Exec();\r
72 \r
73         virtual void                            EnableMessageBox(FX_BOOL bEnable) {m_bMsgBoxEnable = bEnable;}\r
74         FX_BOOL                                         IsMsgBoxEnabled() const {return m_bMsgBoxEnable;}\r
75 \r
76 public:\r
77         CPDFDoc_Environment*                    GetReaderApp();\r
78         CJS_Runtime*                            GetJSRuntime(){return m_pRuntime;}\r
79 \r
80         FX_BOOL                                         DoJob(int nMode, const CFX_WideString& script, CFX_WideString& info);\r
81 \r
82         CJS_EventHandler*                       GetEventHandler(){return m_pEventHandler;};     \r
83         CPDFSDK_Document*                       GetReaderDocument();\r
84 \r
85 private:\r
86         CJS_Runtime*                            m_pRuntime;     \r
87         CJS_EventHandler*                       m_pEventHandler;        \r
88 \r
89         FX_BOOL                                         m_bBusy;        \r
90         FX_BOOL                                         m_bMsgBoxEnable;\r
91 };\r
92 \r
93 // static CFX_WideString JSGetStringFromID(CJS_Context* pContext, UINT ID)\r
94 // {\r
95 //      ASSERT(pContext != NULL);\r
96 // \r
97 //      return JS_LoadString(pContext->GetReaderApp(), ID);\r
98 // }\r
99 \r
100 #endif //_JS_CONTEXT_H_\r
101 \r