--- /dev/null
+/*=========================================================================
+
+ Program: bbtk
+ Module: $RCSfile: bbtkWxGUICommand.cxx,v $
+ Language: C++
+ Date: $Date: 2008/03/20 09:51:29 $
+ Version: $Revision: 1.1 $
+
+ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+ l'Image). All rights reserved. See Doc/License.txt or
+ http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*//**
+ * \brief Short description in one line
+ *
+ * Long description which
+ * can span multiple lines
+ */
+/**
+ * \file
+ * \brief
+ */
+/**
+ * \class bbtk::
+ * \brief
+ */
+
+
+#ifdef _USE_WXWIDGETS_
+
+#include "bbtkWxGUICommand.h"
+#include "bbtkMessageManager.h"
+#include "bbtkConfigurationFile.h"
+
+namespace bbtk
+{
+ //================================================================
+ BEGIN_EVENT_TABLE(WxGUICommand, wxPanel)
+ EVT_TEXT_ENTER(WxGUICommand::ID_Text_Command, WxGUICommand::OnCommandEnter)
+ EVT_BUTTON(WxGUICommand::ID_Btn_Go, WxGUICommand::OnBtnGo)
+ EVT_BUTTON(WxGUICommand::ID_Btn_Include, WxGUICommand::OnBtnInclude)
+ EVT_BUTTON(WxGUICommand::ID_Btn_Reset, WxGUICommand::OnBtnReset)
+ EVT_BUTTON(WxGUICommand::ID_Btn_Config, WxGUICommand::OnBtnConfig)
+ EVT_BUTTON(WxGUICommand::ID_Btn_GraphS, WxGUICommand::OnBtnGraphS)
+ EVT_BUTTON(WxGUICommand::ID_Btn_GraphD, WxGUICommand::OnBtnGraphD)
+ EVT_BUTTON(WxGUICommand::ID_Btn_Help, WxGUICommand::OnBtnHelp)
+ END_EVENT_TABLE()
+ //================================================================
+
+
+ WxGUICommand::WxGUICommand(wxWindow *parent, WxGUICommandUser* user)
+ : wxPanel(parent,-1),
+ mUser(user)
+ {
+ wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
+
+ mwxTextCommand =
+ new wxComboBox(this,
+ ID_Text_Command,
+ _T(""),
+ wxDefaultPosition,
+ wxDefaultSize,
+ 0, NULL,
+ wxTE_PROCESS_ENTER
+ // | wxTE_PROCESS_TAB
+ // | wxWANTS_CHARS
+ // //| wxTAB_TRAVERSAL
+ );
+
+ wxButton *btnGo = new wxButton(this,ID_Btn_Go,_T("Go"));
+
+ wxFlexGridSizer *sizerCommand= new wxFlexGridSizer(2);
+ sizerCommand->AddGrowableCol(0);
+ sizerCommand->Add(mwxTextCommand,1,wxGROW);
+ sizerCommand->Add(btnGo);
+
+ sizer->Add(sizerCommand,0,wxLEFT | wxRIGHT | wxBOTTOM | wxGROW, 10 );
+
+ wxBoxSizer *btnsSizer = new wxBoxSizer(wxHORIZONTAL);
+
+ wxButton *btnInclude = new wxButton(this,ID_Btn_Include,_T("include") );
+ wxButton *btnReset = new wxButton(this,ID_Btn_Reset,_T("reset") );
+ wxButton *btnConfig = new wxButton(this,ID_Btn_Config,_T("config") );
+ wxButton *btnGraphS = new wxButton(this,ID_Btn_GraphS,
+ _T("graph (simple)") );
+ wxButton *btnGraphD = new wxButton(this,ID_Btn_GraphD,
+ _T("graph (detailed)") );
+ wxButton *btnHelp = new wxButton(this,ID_Btn_Help,_T("help") );
+
+ btnsSizer->Add( btnInclude );
+ btnsSizer->Add( btnReset );
+ btnsSizer->Add( btnConfig );
+ btnsSizer->Add( btnGraphS );
+ btnsSizer->Add( btnGraphD );
+ btnsSizer->Add( btnHelp );
+
+ sizer->Add(btnsSizer,0,wxLEFT | wxRIGHT | wxBOTTOM | wxGROW, 10 );
+
+ SetSizer(sizer);
+
+ SetAutoLayout(true);
+ Layout();
+ }
+
+ WxGUICommand::~WxGUICommand()
+ {
+ }
+
+ void WxGUICommand::OnBtnGo(wxCommandEvent& event)
+ {
+ bbtkDebugMessage("gui",2,"WxGUICommand::OnBtnGo"<<std::endl);
+ SendCommand(wx2std(mwxTextCommand->GetValue()));
+ }
+
+ void WxGUICommand::OnCommandEnter(wxCommandEvent& event)
+ {
+ bbtkDebugMessage("gui",2,"WxGUICommand::OnCommandEnter"<<std::endl);
+ SendCommand(wx2std(mwxTextCommand->GetValue()));
+ }
+
+ void WxGUICommand::SendCommand(const std::string& command)
+ {
+ if (command.length()==0) return;
+
+ mwxTextCommand->SetValue(_T(""));
+ mwxTextCommand->Append(command);
+ if (mUser) mUser->WxGUICommandEnter(command);
+ }
+
+
+ void WxGUICommand::OnBtnInclude(wxCommandEvent& event)
+ {
+ bbtkDebugMessage("gui",2,"WxGUICommand::OnBtnInclude"<<std::endl);
+
+ std::string default_doc_dir =
+ ConfigurationFile::GetInstance().Get_default_temp_dir();
+ std::string stdDir = default_doc_dir+"/share/bbtk/bbs";
+ wxString defaultDir(stdDir.c_str(), wxConvUTF8);
+
+ wxFileDialog dialog(this, _T("Include file"),defaultDir, _T(""), _T("*.bbs"), wxOPEN );
+ if (dialog.ShowModal() == wxID_OK)
+ {
+ // std::string command(_T("include "));
+ // std::string pathfilename = (const char *)(dialog.GetFilename().mb_str());
+ std::string command("include ");
+ command += wx2std(dialog.GetPath());
+ SendCommand(command);
+ }
+ }
+
+ void WxGUICommand::OnBtnReset(wxCommandEvent& event)
+ {
+ bbtkDebugMessage("gui",2,"WxGUICommand::OnBtnReset"<<std::endl);
+ SendCommand("reset");
+ }
+
+ void WxGUICommand::OnBtnConfig(wxCommandEvent& event)
+ {
+ bbtkDebugMessage("gui",2,"WxGUICommand::OnBtnConfig"<<std::endl);
+ SendCommand("config");
+ }
+
+ void WxGUICommand::OnBtnGraphS(wxCommandEvent& event)
+ {
+ bbtkDebugMessage("gui",2,"WxGUICommand::OnBtnGraphS"<<std::endl);
+ SendCommand("graph");
+ }
+
+ void WxGUICommand::OnBtnGraphD(wxCommandEvent& event)
+ {
+ bbtkDebugMessage("gui",2,"WxGUICommand::OnBtnGraphD"<<std::endl);
+ SendCommand("graph . 1");
+ }
+
+ void WxGUICommand::OnBtnHelp(wxCommandEvent& event)
+ {
+ bbtkDebugMessage("gui",2,"WxGUICommand::OnBtnHelp"<<std::endl);
+ SendCommand("help");
+ }
+
+} // namespace bbtk
+
+#endif // _USE_WXWIDGETS_