bbPackageBrowser.cxx

Go to the documentation of this file.
00001 #ifdef _USE_WXWIDGETS_
00002 
00003 
00004 
00005 //==========================================================================
00006 // WITH WX
00007 //==========================================================================
00008 #include "bbtkInterpreter.h"
00009 #include "bbtkWxGUIHtmlBrowser.h" 
00010 #include "bbtkWxGUIPackageBrowser2.h" 
00011 
00012 #include "../../src/icons/cc_run.xpm"
00013 #include "../../src/icons/cc_exit.xpm"
00014 
00015 using namespace bbtk;
00016 
00017 class /*BBTK_EXPORT*/ WxGUIHelp : public wxFrame
00018 //                                            public InterpreterUser
00019 {
00020 public:
00021   WxGUIHelp( wxWindow *parent, wxString title, wxSize size );
00022   ~WxGUIHelp();
00023   void OnButtonRun(wxCommandEvent& WXUNUSED(event));
00024   void OnButtonQuit(wxCommandEvent& WXUNUSED(event));
00025 
00026   //  WxGUIHtmlBrowser* mWxGUIHtmlBrowser;
00027   WxGUIPackageBrowser2* mWxGUIPackageBrowser;
00028   //  wxButton* mwxButtonRun;
00029   wxButton* mwxButtonQuit;
00030 
00031 //  bool InterpreterUserHasOwnHtmlPageViewer() { return false; }
00032 //  void InterpreterUserViewHtmlPage(const std::string&) {} 
00033 
00034   DECLARE_EVENT_TABLE(); 
00035 };
00036 
00037 enum
00038   {
00039     ID_Button_Run,
00040     ID_Button_Quit
00041   };
00042 
00043 WxGUIHelp::WxGUIHelp( wxWindow *parent, wxString title, wxSize size )
00044   : wxFrame((wxFrame *)parent, -1, title, wxDefaultPosition, size)
00045 //                                         InterpreterUser()  
00046 { 
00047   wxBoxSizer *helpsizer = new wxBoxSizer(wxVERTICAL);
00048   // mWxGUIHtmlBrowser = new WxGUIHtmlBrowser(this,wxSize(200,0));
00049   //  helpsizer->Add (mWxGUIHtmlBrowser,1, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5  );
00050   mWxGUIPackageBrowser = new WxGUIPackageBrowser2(this);
00051   helpsizer->Add (mWxGUIPackageBrowser,1, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5  );
00052 
00053   wxBoxSizer *btnsizer = new wxBoxSizer(wxHORIZONTAL);
00054   /*
00055   wxBitmap bmp_run(cc_run_xpm);
00056   mwxButtonRun = new wxBitmapButton(this,ID_Button_Run,bmp_run);
00057   btnsizer->Add( mwxButtonRun, 0, wxALL, 5  );
00058   */
00059   wxBitmap bmp_quit(cc_exit_xpm);
00060   mwxButtonQuit = new wxBitmapButton(this,ID_Button_Quit,bmp_quit);
00061   btnsizer->Add( mwxButtonQuit, 0, wxALL, 5  );
00062 
00063   helpsizer->Add( btnsizer );
00064 
00065   // Creates and sets the parent window of all bbtk windows
00066   /*
00067   wxWindow* top = new wxPanel(this,-1);//,_T("top"));
00068   top->Hide();
00069   Wx::SetTopWindow(top);
00070   */
00071 
00072   SetSizer(helpsizer);
00073   SetAutoLayout(true);
00074   Layout();
00075 
00076   // mWxGUIHtmlBrowser->GoHome();
00077   mWxGUIPackageBrowser->IncludeAll();
00078 }
00079 
00080 WxGUIHelp::~WxGUIHelp() {}
00081 
00082 /*
00083 void WxGUIHelp::OnButtonRun(wxCommandEvent& WXUNUSED(event))
00084 {  
00085   //std::string filename = wx2std(mWxGUIHtmlBrowser->GetCurrentPage());
00086   std::string filename = mWxGUIHtmlBrowser->GetCurrentPage();
00087   size_t s = filename.length();
00088   
00089   Interpreter::Pointer I = Interpreter::New();
00090   I->SetThrow(true);
00091 
00092   if ((s>3) && (filename[s-1]=='s')
00093       && (filename[s-2]=='b')
00094       && (filename[s-3]=='b')
00095       && (filename[s-4]=='.'))
00096     {
00097       try 
00098         {
00099           I->InterpretFile(filename);
00100         }
00101       catch (QuitException e) 
00102         {
00103           std::cout << "QuitException caught"<<std::endl;
00104         }
00105       catch (Exception e)
00106         {
00107           wxString mess;
00108           mess += std2wx ( e.GetMessage() );
00109           wxMessageBox(mess,_T("Error"),wxOK | wxICON_ERROR);
00110         }
00111       catch (...)
00112         {         
00113           wxMessageBox(_T("Undefined error during script execution"),
00114                        _T("Error"),wxOK | wxICON_ERROR);
00115 
00116         }
00117     }
00118   else
00119     {
00120       wxMessageBox(_T("You can only execute .bbs script files (click on [source] in the field 'To use it' of a box) !"),_T("Warning"),wxOK | wxICON_ERROR);
00121     }
00122   
00123   //delete I;
00124 }
00125 */
00126 
00127 void WxGUIHelp::OnButtonQuit(wxCommandEvent& WXUNUSED(event))
00128 {
00129   Close();
00130 }
00131 
00132 //================================================================  
00133 BEGIN_EVENT_TABLE(WxGUIHelp, wxFrame)
00134 //  EVT_BUTTON(ID_Button_Run, WxGUIHelp::OnButtonRun )
00135   EVT_BUTTON(ID_Button_Quit, WxGUIHelp::OnButtonQuit )
00136 END_EVENT_TABLE()
00137 //================================================================
00138 
00139 
00140 
00141 class myApp : public wxApp
00142 {
00143 public:
00144   bool OnInit( );
00145   int  OnExit() { return true; }
00146 };
00147 
00148 IMPLEMENT_APP(myApp);
00149 
00150 
00151 bool myApp::OnInit( )
00152 {        
00153   wxApp::OnInit();
00154 #ifdef __WXGTK__
00155   //See http://www.wxwindows.org/faqgtk.htm#locale
00156   setlocale(LC_NUMERIC, "C");
00157 #endif
00158    wxInitAllImageHandlers();
00159    
00160    //  WxGUIHelp *I = new WxGUIHelp(0,_T("BBTK help browser"),wxSize(800,600));
00161    
00162    WxGUIPackageBrowser2Window*  I = 
00163      new WxGUIPackageBrowser2Window(0,_T("bbtk help"),wxSize(1000,800));
00164   SetTopWindow(I);  
00165   I->Show(true);
00166   return true;
00167 }
00168 
00169 /*
00170 #if defined(_WIN32) 
00171 
00172 //  How to have a Console and wxWidgets
00173 //  http://www.wxwidgets.org/wiki/index.php/MSVC_Setup_Guide
00174 //   In Visual C++ 6 (7 should be similar), to create an application that is both a console application 
00175 //  (cout's to the console are visible) and has a wxWidgets GUI, 
00176 //  you need to use the linker option "/subsystem:console" and the following code:
00177 int main(int argc, char* argv[])
00178 {
00179         return WinMain(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), SW_SHOWNORMAL);
00180 }
00181 #endif // defined(_WIN32) 
00182 */
00183         
00184 #else
00185 //==========================================================================
00186 // WITHOUT WX
00187 //==========================================================================
00188 int main(int argc, char* argv[])
00189 {  
00190   return 0;
00191 }
00192          
00193 // EOF
00194 #endif //#ifdef _USE_WXWIDGETS_
00195 
00196 
00197 

Generated on Wed Nov 12 11:37:08 2008 for BBTK by  doxygen 1.5.6