Initial commit.
[pdfium.git] / fpdfsdk / include / javascript / app.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 _APP_H_\r
8 #define _APP_H_\r
9 \r
10 class CJS_Runtime;\r
11 \r
12 /* ---------------------------- TimerObj ---------------------------- */\r
13 \r
14 class CJS_Timer;\r
15 \r
16 class TimerObj : public CJS_EmbedObj\r
17 {\r
18 public:\r
19         TimerObj(CJS_Object* pJSObject);\r
20         virtual ~TimerObj();\r
21         \r
22 public:\r
23         void                    SetTimer(CJS_Timer* pTimer);\r
24         CJS_Timer*              GetTimer() const;\r
25         \r
26 private:\r
27         CJS_Timer*              m_pTimer;\r
28 };\r
29 \r
30 class CJS_TimerObj : public CJS_Object\r
31 {\r
32 public:\r
33         CJS_TimerObj(JSFXObject pObject) : CJS_Object(pObject) {}\r
34         virtual ~CJS_TimerObj(){}\r
35         \r
36         DECLARE_JS_CLASS(CJS_TimerObj);\r
37 };\r
38 \r
39 \r
40 // struct APP_MENUITEM_ARRAY;\r
41 // \r
42 // struct APP_MENUITEM\r
43 // {\r
44 //      APP_MENUITEM() : oSubMenu(NULL), cName(L""), cReturn(L""), bMarked(false), bEnabled(true)\r
45 //      {\r
46 //      }\r
47 //      CFX_WideString cName;\r
48 //      CFX_WideString cReturn;\r
49 //      APP_MENUITEM_ARRAY* oSubMenu;\r
50 //      bool bMarked;\r
51 //      bool bEnabled;\r
52 // };\r
53 \r
54 // struct APP_MENUITEM_ARRAY\r
55 // {\r
56 //      APP_MENUITEM_ARRAY() : m_hMenu(NULL), pContents(NULL), nSize(0)\r
57 //      {\r
58 // \r
59 //      }\r
60 //      APP_MENUITEM * pContents;\r
61 //      HMENU m_hMenu;\r
62 //      int     nSize;\r
63 // };\r
64 \r
65 // struct APP_MENU;\r
66 // struct APP_MENU_ARRAY\r
67 // {\r
68 //      APP_MENU_ARRAY():\r
69 //     pContent(NULL)\r
70 //      {\r
71 //      }\r
72 // \r
73 //      APP_MENU* pContent;\r
74 // };\r
75 \r
76 // struct APP_MENU\r
77 // {\r
78 //      APP_MENU():bSubMenu(false), \r
79 //      SubMenuItems(NULL),\r
80 //      cwMenuItemName(L""),\r
81 //      hMenu(NULL),\r
82 //      iSize(0)\r
83 //      {\r
84 // \r
85 //      }\r
86 // \r
87 //      APP_MENU(CFX_WideString &cwName):\r
88 //      cwMenuItemName(cwName),\r
89 //      bSubMenu(false),\r
90 //      SubMenuItems(NULL),\r
91 //      hMenu(NULL),\r
92 //      iSize(0)\r
93 //      {\r
94 // \r
95 //      }\r
96 //      \r
97 //      CFX_WideString cwMenuItemName;\r
98 //      bool bSubMenu;  \r
99 //      APP_MENU_ARRAY* SubMenuItems;\r
100 //      int iSize;\r
101 //      HMENU hMenu;\r
102 // };\r
103 \r
104 class app : public CJS_EmbedObj\r
105 {\r
106 public:\r
107         app(CJS_Object * pJSObject);\r
108         virtual ~app();\r
109 \r
110 public:\r
111         FX_BOOL                                         activeDocs(OBJ_PROP_PARAMS);\r
112         FX_BOOL                                         calculate(OBJ_PROP_PARAMS);\r
113         FX_BOOL                                         formsVersion(OBJ_PROP_PARAMS);\r
114         FX_BOOL                                         fs(OBJ_PROP_PARAMS);\r
115         FX_BOOL                                         fullscreen(OBJ_PROP_PARAMS);\r
116         FX_BOOL                                         language(OBJ_PROP_PARAMS);\r
117         FX_BOOL                                         media(OBJ_PROP_PARAMS);\r
118         FX_BOOL                                         platform(OBJ_PROP_PARAMS);\r
119         FX_BOOL                                         runtimeHighlight(OBJ_PROP_PARAMS);\r
120         FX_BOOL                                         viewerType(OBJ_PROP_PARAMS);\r
121         FX_BOOL                                         viewerVariation(OBJ_PROP_PARAMS);\r
122         FX_BOOL                                         viewerVersion(OBJ_PROP_PARAMS); \r
123 \r
124 \r
125         FX_BOOL                                         alert(OBJ_METHOD_PARAMS);\r
126         FX_BOOL                                         beep(OBJ_METHOD_PARAMS);\r
127         FX_BOOL                                         browseForDoc(OBJ_METHOD_PARAMS);\r
128         FX_BOOL                                         clearInterval(OBJ_METHOD_PARAMS);\r
129         FX_BOOL                                         clearTimeOut(OBJ_METHOD_PARAMS);\r
130         FX_BOOL                                         execDialog(OBJ_METHOD_PARAMS);\r
131         FX_BOOL                                         execMenuItem(OBJ_METHOD_PARAMS);\r
132         FX_BOOL                                         findComponent(OBJ_METHOD_PARAMS);\r
133         FX_BOOL                                         goBack(OBJ_METHOD_PARAMS);\r
134         FX_BOOL                                         goForward(OBJ_METHOD_PARAMS);\r
135         FX_BOOL                                         launchURL(OBJ_METHOD_PARAMS);\r
136         FX_BOOL                                         mailMsg(OBJ_METHOD_PARAMS);\r
137         FX_BOOL                                         newFDF(OBJ_METHOD_PARAMS);\r
138         FX_BOOL                                         newDoc(OBJ_METHOD_PARAMS);\r
139         FX_BOOL                                         openDoc(OBJ_METHOD_PARAMS);\r
140         FX_BOOL                                         openFDF(OBJ_METHOD_PARAMS);\r
141         FX_BOOL                                         popUpMenuEx(OBJ_METHOD_PARAMS);\r
142         FX_BOOL                                         popUpMenu(OBJ_METHOD_PARAMS);\r
143         FX_BOOL                                         response(OBJ_METHOD_PARAMS);\r
144         FX_BOOL                                         setInterval(OBJ_METHOD_PARAMS);\r
145         FX_BOOL                                         setTimeOut(OBJ_METHOD_PARAMS);\r
146 \r
147 private:\r
148 //      FX_DWORD                                        AppGetTickCount(); \r
149         void                                            TimerProc(CJS_Timer* pTimer);\r
150         void                                            RunJsScript(CJS_Runtime * pRuntime,const CFX_WideString & wsScript);\r
151 //      void                                            ParsePopupMenuObj(APP_MENUITEM * ppMenuItem,JSObject * pObj);\r
152 //      void                                            DeleteMenuItems(APP_MENUITEM_ARRAY * pMenuItems);\r
153 //      void                                            AddMenuItem(APP_MENUITEM_ARRAY * pMenuItems, HMENU hMenu, MENUITEMINFO MenuItemInfo);\r
154 //      void                                            InitMenuItemInfo(MENUITEMINFO& MenuItemInfo);\r
155 //      void                                            DestroyPopUpMenu();\r
156 \r
157 //      void                                            ParserMenuItem(APP_MENU* pHead, const CJS_Parameters&params);\r
158 //      void                                            AddItemToMenu(APP_MENU* pHead, HMENU hMenu, MENUITEMINFO MenuItemInfo);\r
159 //      void                                            DestroyMenuItems(APP_MENU* pHead);\r
160 \r
161 public:\r
162         static CFX_WideString           SysPathToPDFPath(const CFX_WideString& sOldPath);\r
163         static CFX_WideString           PDFPathToSysPath(const CFX_WideString& sOldPath);\r
164         static CFX_WideString           RelativePathToSysPath(const CFX_WideString& sOldPath, const CFX_WideString& sFilePath);\r
165 \r
166 \r
167 private:\r
168 \r
169         bool                                            m_bCalculate;   \r
170         CJS_Runtime*                            m_pRuntime;\r
171         bool                                            m_bRuntimeHighLight;\r
172 \r
173         CFX_ArrayTemplate<CJS_Timer*>   m_aTimer;\r
174 //      APP_MENU*                                       m_pMenuHead;\r
175         \r
176 public:\r
177 //      static CReader_App* s_App;\r
178 };\r
179 \r
180 class CJS_App : public CJS_Object\r
181 {\r
182 public:\r
183         CJS_App(JSFXObject  pObject) : CJS_Object(pObject) {};\r
184         virtual ~CJS_App(void){};\r
185 \r
186         DECLARE_JS_CLASS(CJS_App);\r
187 \r
188         JS_STATIC_PROP(activeDocs, app);\r
189         JS_STATIC_PROP(calculate, app);\r
190         JS_STATIC_PROP(formsVersion, app);\r
191         JS_STATIC_PROP(fs, app);\r
192         JS_STATIC_PROP(fullscreen, app);\r
193         JS_STATIC_PROP(language, app);\r
194         JS_STATIC_PROP(media, app);\r
195         JS_STATIC_PROP(platform, app);\r
196         JS_STATIC_PROP(runtimeHighlight, app);\r
197         JS_STATIC_PROP(viewerType, app);\r
198         JS_STATIC_PROP(viewerVariation, app);\r
199         JS_STATIC_PROP(viewerVersion, app);     \r
200 \r
201         JS_STATIC_METHOD(alert, app);\r
202         JS_STATIC_METHOD(beep, app);\r
203         JS_STATIC_METHOD(browseForDoc, app);\r
204         JS_STATIC_METHOD(clearInterval, app);\r
205         JS_STATIC_METHOD(clearTimeOut, app);\r
206         JS_STATIC_METHOD(execDialog, app);\r
207         JS_STATIC_METHOD(execMenuItem, app);\r
208         JS_STATIC_METHOD(findComponent, app);\r
209         JS_STATIC_METHOD(goBack, app);\r
210         JS_STATIC_METHOD(goForward, app);\r
211         JS_STATIC_METHOD(launchURL, app);\r
212         JS_STATIC_METHOD(mailMsg, app);\r
213         JS_STATIC_METHOD(newFDF, app);\r
214         JS_STATIC_METHOD(newDoc, app);\r
215         JS_STATIC_METHOD(openDoc, app);\r
216         JS_STATIC_METHOD(openFDF, app);\r
217         JS_STATIC_METHOD(popUpMenuEx, app);\r
218         JS_STATIC_METHOD(popUpMenu, app);\r
219         JS_STATIC_METHOD(response, app);\r
220         JS_STATIC_METHOD(setInterval, app);\r
221         JS_STATIC_METHOD(setTimeOut, app);\r
222 \r
223 };\r
224 \r
225 #endif //_APP_H_\r