2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ */
28 /*=========================================================================
30 Module: $RCSfile: bbtkWxGUICommand.cxx,v $
32 Date: $Date: 2012/11/16 08:49:01 $
33 Version: $Revision: 1.9 $
34 =========================================================================*/
39 * \brief Short description in one line
41 * Long description which
42 * can span multiple lines
54 #ifdef _USE_WXWIDGETS_
56 #include "bbtkWxGUICommand.h"
57 #include "bbtkMessageManager.h"
58 #include "bbtkConfigurationFile.h"
59 #include "bbtkWxGUIPackageBrowser2.h"
63 //================================================================
64 BEGIN_EVENT_TABLE(WxGUICommand, wxPanel)
65 EVT_TEXT_ENTER(WxGUICommand::ID_Text_Command, WxGUICommand::OnCommandEnter)
66 EVT_BUTTON(WxGUICommand::ID_Btn_Go, WxGUICommand::OnBtnGo)
67 EVT_BUTTON(WxGUICommand::ID_Btn_Include, WxGUICommand::OnBtnInclude)
68 EVT_BUTTON(WxGUICommand::ID_Btn_Reset, WxGUICommand::OnBtnReset)
69 EVT_BUTTON(WxGUICommand::ID_Btn_Config, WxGUICommand::OnBtnConfig)
70 EVT_BUTTON(WxGUICommand::ID_Btn_GraphS, WxGUICommand::OnBtnGraphS)
71 EVT_BUTTON(WxGUICommand::ID_Btn_GraphD, WxGUICommand::OnBtnGraphD)
72 EVT_BUTTON(WxGUICommand::ID_Btn_Help, WxGUICommand::OnBtnHelp)
73 EVT_BUTTON(WxGUICommand::ID_Btn_PackageBrowser, WxGUICommand::OnBtnPackageBrowser)
75 //================================================================
78 WxGUICommand::WxGUICommand(wxWindow *parent, WxGUICommandUser* user)
82 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
94 // //| wxTAB_TRAVERSAL
97 wxButton *btnGo = new wxButton(this,ID_Btn_Go,_T("Go"));
99 wxFlexGridSizer *sizerCommand= new wxFlexGridSizer(2);
100 sizerCommand->AddGrowableCol(0);
101 sizerCommand->Add(mwxTextCommand,1,wxGROW);
102 sizerCommand->Add(btnGo);
104 sizer->Add(sizerCommand,0,wxGROW);
106 wxBoxSizer *btnsSizer = new wxBoxSizer(wxHORIZONTAL);
108 wxButton *btnInclude = new wxButton(this,ID_Btn_Include ,_T("include") );
109 wxButton *btnReset = new wxButton(this,ID_Btn_Reset ,_T("reset") );
110 wxButton *btnConfig = new wxButton(this,ID_Btn_Config ,_T("config") );
111 wxButton *btnGraphS = new wxButton(this,ID_Btn_GraphS ,_T("graph (simple)") );
112 wxButton *btnGraphD = new wxButton(this,ID_Btn_GraphD ,_T("graph (detailed)") );
113 wxButton *btnHelp = new wxButton(this,ID_Btn_Help ,_T("help") );
114 wxButton *btnPackageBrowser = new wxButton(this,ID_Btn_PackageBrowser ,_T("Start Package Browser") );
116 btnsSizer->Add( btnInclude );
117 btnsSizer->Add( btnReset );
118 btnsSizer->Add( btnConfig );
119 btnsSizer->Add( btnGraphS );
120 btnsSizer->Add( btnGraphD );
121 btnsSizer->Add( btnHelp );
122 btnsSizer->Add( btnPackageBrowser );
124 sizer->Add(btnsSizer,0,wxTOP|wxGROW, 10 );
132 WxGUICommand::~WxGUICommand()
136 void WxGUICommand::OnBtnGo(wxCommandEvent& event)
138 bbtkDebugMessage("gui",2,"WxGUICommand::OnBtnGo"<<std::endl);
139 SendCommand(wx2std(mwxTextCommand->GetValue()));
142 void WxGUICommand::OnCommandEnter(wxCommandEvent& event)
144 bbtkDebugMessage("gui",2,"WxGUICommand::OnCommandEnter"<<std::endl);
145 SendCommand(wx2std(mwxTextCommand->GetValue()));
148 void WxGUICommand::SendCommand(const std::string& command)
150 if (command.length()==0) return;
152 mwxTextCommand->SetValue(_T(""));
153 mwxTextCommand->Append(std2wx(command));
154 if (mUser) mUser->WxGUICommandEnter(command);
158 void WxGUICommand::OnBtnInclude(wxCommandEvent& event)
160 bbtkDebugMessage("gui",2,"WxGUICommand::OnBtnInclude"<<std::endl);
162 std::string default_doc_dir =
163 ConfigurationFile::GetInstance().Get_default_temp_dir();
164 std::string stdDir = default_doc_dir+"/share/bbtk/bbs";
165 wxString defaultDir(stdDir.c_str(), wxConvUTF8);
167 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
168 #if wxMAJOR_VERSION <= 2
169 wxFileDialog dialog(this, _T("Include file"),defaultDir, _T(""), _T("*.bbs"), wxOPEN );
171 wxFileDialog dialog(this, _T("Include file"),defaultDir, _T(""), _T("*.bbs"), wxFD_OPEN );
174 if (dialog.ShowModal() == wxID_OK)
176 // std::string command(_T("include "));
177 // std::string pathfilename = (const char *)(dialog.GetFilename().mb_str());
178 std::string command("include ");
179 command = command + "\"" + wx2std(dialog.GetPath()) + "\"";
180 SendCommand(command);
184 void WxGUICommand::OnBtnReset(wxCommandEvent& event)
186 bbtkDebugMessage("gui",2,"WxGUICommand::OnBtnReset"<<std::endl);
187 SendCommand("reset");
190 void WxGUICommand::OnBtnConfig(wxCommandEvent& event)
192 bbtkDebugMessage("gui",2,"WxGUICommand::OnBtnConfig"<<std::endl);
193 SendCommand("config");
196 void WxGUICommand::OnBtnGraphS(wxCommandEvent& event)
198 bbtkDebugMessage("gui",2,"WxGUICommand::OnBtnGraphS"<<std::endl);
199 SendCommand("graph");
202 void WxGUICommand::OnBtnGraphD(wxCommandEvent& event)
204 bbtkDebugMessage("gui",2,"WxGUICommand::OnBtnGraphD"<<std::endl);
205 SendCommand("graph . 1");
208 void WxGUICommand::OnBtnHelp(wxCommandEvent& event)
210 bbtkDebugMessage("gui",2,"WxGUICommand::OnBtnHelp"<<std::endl);
214 void WxGUICommand::OnBtnPackageBrowser(wxCommandEvent& event)
217 WxGUIPackageBrowser2Window *helpbrowser = new
218 WxGUIPackageBrowser2Window(this,_T("Package Browser"), wxSize(600,600) );
224 #endif // _USE_WXWIDGETS_