Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00038 #ifndef HIPPAPP_H_
00039 #define HIPPAPP_H_
00040
00041 #include <wx/wx.h>
00042 #include <wx/app.h>
00043 #include <wx/docview.h>
00044 #include <H3D/X3DSAX2Handlers.h>
00045 #include <H3D/MagneticSurface.h>
00046 #include <H3D/SFString.h>
00047 #include <wx/cmdline.h>
00048 #include <wx/intl.h>
00049 #include <wx/translation.h>
00050
00051 #include "HippFrame.h"
00052
00053 using namespace std;
00054 using namespace H3D;
00055 using H3D::AutoUpdate;
00056
00057 namespace hipp {
00058 inline string toStr(const wxString &s) {
00059 # if(wxUSE_UNICODE)
00060 char *b = new char[s.size()+1];
00061 const wchar_t *wb = s.c_str();
00062 for( unsigned int i = 0; i < s.size(); i++ ) {
00063 b[i] = (char)(wb[i]);
00064 }
00065
00066 b[s.size()] = '\0';
00067 string sb(b);
00068 delete[] b;
00069 return sb;
00070 #else
00071 return string(s.c_str());
00072 #endif
00073 }
00074
00075 H3D_API_EXCEPTION( QuitAPIException );
00076
00077 class QuitAPIField: public AutoUpdate<SFString> {
00078 virtual void update() {
00079 string s = static_cast<SFString *> (routes_in[0])->getValue();
00080 if (s[0] == 27) {
00081 throw QuitAPIException();
00082 }
00083 }
00084 };
00085
00086 const wxCmdLineEntryDesc gCmdLineDesc[] = { { wxCMD_LINE_PARAM, NULL, NULL,
00087 _("File to load"), wxCMD_LINE_VAL_STRING,
00088 wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_NONE, NULL, NULL, NULL,
00089 wxCMD_LINE_VAL_NONE, 0 } };
00090
00091
00103 class HippApp: public wxApp {
00104 public:
00105 HippApp();
00106 virtual ~HippApp();
00107
00109 virtual bool OnInit();
00111 virtual int OnExit();
00112 virtual void OnIdle(wxIdleEvent& event);
00113 virtual bool OnExceptionInMainLoop();
00114 virtual void OnInitCmdLine(wxCmdLineParser& parser) {
00115 parser.SetDesc(gCmdLineDesc);
00116 }
00117
00118 virtual bool OnCmdLineParsed(wxCmdLineParser& parser) {
00119 for (int i = 0; i < (int) parser.GetParamCount(); i++) {
00120 cmd_line_filename = parser.GetParam(i);
00121 }
00122
00123 return true;
00124 }
00125
00126 wxLocale m_locale;
00127 protected:
00128 wxString cmd_line_filename;
00129 HippFrame *frame;
00130 DECLARE_EVENT_TABLE()
00131 private:
00132 wxDocManager* m_docManager;
00133 };
00134 wxDECLARE_APP( HippApp );
00135 }
00136 #endif