1 /*=========================================================================
4 Module: $RCSfile: bbtkWxGUICommand.cxx,v $
6 Date: $Date: 2008/03/20 15:27:56 $
7 Version: $Revision: 1.3 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*//**
18 * \brief Short description in one line
20 * Long description which
21 * can span multiple lines
33 #ifdef _USE_WXWIDGETS_
35 #include "bbtkWxGUICommand.h"
36 #include "bbtkMessageManager.h"
37 #include "bbtkConfigurationFile.h"
41 //================================================================
42 BEGIN_EVENT_TABLE(WxGUICommand, wxPanel)
43 EVT_TEXT_ENTER(WxGUICommand::ID_Text_Command, WxGUICommand::OnCommandEnter)
44 EVT_BUTTON(WxGUICommand::ID_Btn_Go, WxGUICommand::OnBtnGo)
45 EVT_BUTTON(WxGUICommand::ID_Btn_Include, WxGUICommand::OnBtnInclude)
46 EVT_BUTTON(WxGUICommand::ID_Btn_Reset, WxGUICommand::OnBtnReset)
47 EVT_BUTTON(WxGUICommand::ID_Btn_Config, WxGUICommand::OnBtnConfig)
48 EVT_BUTTON(WxGUICommand::ID_Btn_GraphS, WxGUICommand::OnBtnGraphS)
49 EVT_BUTTON(WxGUICommand::ID_Btn_GraphD, WxGUICommand::OnBtnGraphD)
50 EVT_BUTTON(WxGUICommand::ID_Btn_Help, WxGUICommand::OnBtnHelp)
52 //================================================================
55 WxGUICommand::WxGUICommand(wxWindow *parent, WxGUICommandUser* user)
59 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
71 // //| wxTAB_TRAVERSAL
74 wxButton *btnGo = new wxButton(this,ID_Btn_Go,_T("Go"));
76 wxFlexGridSizer *sizerCommand= new wxFlexGridSizer(2);
77 sizerCommand->AddGrowableCol(0);
78 sizerCommand->Add(mwxTextCommand,1,wxGROW);
79 sizerCommand->Add(btnGo);
81 sizer->Add(sizerCommand,0,wxGROW);
83 wxBoxSizer *btnsSizer = new wxBoxSizer(wxHORIZONTAL);
85 wxButton *btnInclude = new wxButton(this,ID_Btn_Include,_T("include") );
86 wxButton *btnReset = new wxButton(this,ID_Btn_Reset,_T("reset") );
87 wxButton *btnConfig = new wxButton(this,ID_Btn_Config,_T("config") );
88 wxButton *btnGraphS = new wxButton(this,ID_Btn_GraphS,
89 _T("graph (simple)") );
90 wxButton *btnGraphD = new wxButton(this,ID_Btn_GraphD,
91 _T("graph (detailed)") );
92 wxButton *btnHelp = new wxButton(this,ID_Btn_Help,_T("help") );
94 btnsSizer->Add( btnInclude );
95 btnsSizer->Add( btnReset );
96 btnsSizer->Add( btnConfig );
97 btnsSizer->Add( btnGraphS );
98 btnsSizer->Add( btnGraphD );
99 btnsSizer->Add( btnHelp );
101 sizer->Add(btnsSizer,0,wxTOP|wxGROW, 10 );
109 WxGUICommand::~WxGUICommand()
113 void WxGUICommand::OnBtnGo(wxCommandEvent& event)
115 bbtkDebugMessage("gui",2,"WxGUICommand::OnBtnGo"<<std::endl);
116 SendCommand(wx2std(mwxTextCommand->GetValue()));
119 void WxGUICommand::OnCommandEnter(wxCommandEvent& event)
121 bbtkDebugMessage("gui",2,"WxGUICommand::OnCommandEnter"<<std::endl);
122 SendCommand(wx2std(mwxTextCommand->GetValue()));
125 void WxGUICommand::SendCommand(const std::string& command)
127 if (command.length()==0) return;
129 mwxTextCommand->SetValue(_T(""));
130 mwxTextCommand->Append(std2wx(command));
131 if (mUser) mUser->WxGUICommandEnter(command);
135 void WxGUICommand::OnBtnInclude(wxCommandEvent& event)
137 bbtkDebugMessage("gui",2,"WxGUICommand::OnBtnInclude"<<std::endl);
139 std::string default_doc_dir =
140 ConfigurationFile::GetInstance().Get_default_temp_dir();
141 std::string stdDir = default_doc_dir+"/share/bbtk/bbs";
142 wxString defaultDir(stdDir.c_str(), wxConvUTF8);
144 wxFileDialog dialog(this, _T("Include file"),defaultDir, _T(""), _T("*.bbs"), wxOPEN );
145 if (dialog.ShowModal() == wxID_OK)
147 // std::string command(_T("include "));
148 // std::string pathfilename = (const char *)(dialog.GetFilename().mb_str());
149 std::string command("include ");
150 command += wx2std(dialog.GetPath());
151 SendCommand(command);
155 void WxGUICommand::OnBtnReset(wxCommandEvent& event)
157 bbtkDebugMessage("gui",2,"WxGUICommand::OnBtnReset"<<std::endl);
158 SendCommand("reset");
161 void WxGUICommand::OnBtnConfig(wxCommandEvent& event)
163 bbtkDebugMessage("gui",2,"WxGUICommand::OnBtnConfig"<<std::endl);
164 SendCommand("config");
167 void WxGUICommand::OnBtnGraphS(wxCommandEvent& event)
169 bbtkDebugMessage("gui",2,"WxGUICommand::OnBtnGraphS"<<std::endl);
170 SendCommand("graph");
173 void WxGUICommand::OnBtnGraphD(wxCommandEvent& event)
175 bbtkDebugMessage("gui",2,"WxGUICommand::OnBtnGraphD"<<std::endl);
176 SendCommand("graph . 1");
179 void WxGUICommand::OnBtnHelp(wxCommandEvent& event)
181 bbtkDebugMessage("gui",2,"WxGUICommand::OnBtnHelp"<<std::endl);
187 #endif // _USE_WXWIDGETS_