1 // 2 // Copyright 2005 The Android Open Source Project 3 // 4 // Application class. 5 // 6 #ifndef _SIM_APPMAIN_H 7 #define _SIM_APPMAIN_H 8 9 #include "wx/help.h" 10 #include "wx/html/helpctrl.h" 11 12 #include "MainFrame.h" 13 #include "DeviceManager.h" 14 #include "Preferences.h" 15 16 #include <utils/AssetManager.h> 17 18 /* flag set from signal handler */ 19 extern bool gWantToKill; 20 21 /* 22 * Class representing the application. 23 */ 24 class MyApp : public wxApp { 25 public: 26 MyApp(void) 27 : mHelpController(NULL), mpMainFrame(NULL), mpAssetManager(NULL), 28 mResetPaths(false) // configurable; reset prefs with paths 29 {} 30 ~MyApp(void) 31 { 32 delete mpAssetManager; 33 delete mHelpController; 34 } 35 36 virtual bool OnInit(void); 37 virtual int OnExit(void); 38 39 wxHtmlHelpController* GetHelpController(void) const { 40 return mHelpController; 41 } 42 43 Preferences* GetPrefs(void) { return &mPrefs; } 44 45 /* return a pointer to the main window */ 46 wxWindow* GetMainFrame(void) { return mpMainFrame; } 47 48 /* get a pointer to our Asset Manager */ 49 android::AssetManager* GetAssetManager(void) { return mpAssetManager; } 50 51 /* change the asset dir; requires re-creating Asset Manager */ 52 void ChangeAssetDirectory(const wxString& dir); 53 54 const wxString& GetConfigFileName(void) const { return mConfigFile; } 55 56 wxString GetSimAssetPath() { return mSimAssetPath; } 57 wxString GetAndroidRoot() { return mAndroidRoot; } 58 wxString GetRuntimeExe() { return mRuntimeExe; } 59 bool GetDebuggerOption() { return mDebuggerOption; } 60 wxString GetDebuggerScript() { return mDebuggerScript; } 61 wxString GetAutoRunApp() { return mAutoRunApp; } 62 63 void Vibrate(int vibrateOn) { ((MainFrame*)mpMainFrame)->Vibrate(vibrateOn); } 64 65 private: 66 void SetDefaults(); 67 bool ParseArgs(int argc, char** argv); 68 void AbsifyPath(wxString& dir); 69 bool ProcessConfigFile(void); 70 static void FindExe(const wxString& exeName, const wxString paths[], 71 const wxString& defaultPath, wxString* pOut); 72 73 wxHtmlHelpController* mHelpController; 74 75 wxWindow* mpMainFrame; 76 77 android::AssetManager* mpAssetManager; 78 79 wxString mAndroidRoot; 80 wxString mSimAssetPath; 81 wxString mRuntimeExe; 82 83 /* command-line options */ 84 wxString mConfigFile; 85 bool mResetPaths; 86 bool mDebuggerOption; 87 wxString mDebuggerScript; 88 wxString mAutoRunApp; 89 90 Preferences mPrefs; 91 }; 92 93 #endif // _SIM_APPMAIN_H 94