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