X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=kernel%2Fsrc%2FbbtkWxGUIPackageBrowser2.cxx;h=bc5b5253bffcbc0d811f8e824bcaedc755544c4b;hb=fd7b71259d67fc2a0076f2794122d34ce2e8a540;hp=5d95e06092ef7c32c6da89eec25c141da3e2ad17;hpb=6575a389b71b1b85c79e4444885becb76ecf16e4;p=bbtk.git diff --git a/kernel/src/bbtkWxGUIPackageBrowser2.cxx b/kernel/src/bbtkWxGUIPackageBrowser2.cxx index 5d95e06..bc5b525 100644 --- a/kernel/src/bbtkWxGUIPackageBrowser2.cxx +++ b/kernel/src/bbtkWxGUIPackageBrowser2.cxx @@ -1,47 +1,53 @@ -/*========================================================================= +/* + # --------------------------------------------------------------------- + # + # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image + # pour la SantÈ) + # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton + # Previous Authors : Laurent Guigues, Jean-Pierre Roux + # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil + # + # This software is governed by the CeCILL-B license under French law and + # abiding by the rules of distribution of free software. You can use, + # modify and/ or redistribute the software under the terms of the CeCILL-B + # license as circulated by CEA, CNRS and INRIA at the following URL + # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html + # or in the file LICENSE.txt. + # + # As a counterpart to the access to the source code and rights to copy, + # modify and redistribute granted by the license, users are provided only + # with a limited warranty and the software's author, the holder of the + # economic rights, and the successive licensors have only limited + # liability. + # + # The fact that you are presently reading this means that you have had + # knowledge of the CeCILL-B license and that you accept its terms. + # ------------------------------------------------------------------------ */ + + +/*========================================================================= Program: bbtk Module: $RCSfile: bbtkWxGUIPackageBrowser2.cxx,v $ Language: C++ - Date: $Date: 2008/10/17 08:18:15 $ - Version: $Revision: 1.11 $ + Date: $Date: 2012/11/16 08:49:01 $ + Version: $Revision: 1.27 $ =========================================================================*/ -/* --------------------------------------------------------------------- - -* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale) -* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux -* -* This software is governed by the CeCILL-B license under French law and -* abiding by the rules of distribution of free software. You can use, -* modify and/ or redistribute the software under the terms of the CeCILL-B -* license as circulated by CEA, CNRS and INRIA at the following URL -* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html -* or in the file LICENSE.txt. -* -* As a counterpart to the access to the source code and rights to copy, -* modify and redistribute granted by the license, users are provided only -* with a limited warranty and the software's author, the holder of the -* economic rights, and the successive licensors have only limited -* liability. -* -* The fact that you are presently reading this means that you have had -* knowledge of the CeCILL-B license and that you accept its terms. -* ------------------------------------------------------------------------ */ /* \brief Short description in one line - * - * Long description which + * + * Long description which * can span multiple lines */ - + /** - * \file - * \brief + * \file + * \brief */ /** * \class bbtk:: - * \brief + * \brief */ @@ -58,13 +64,14 @@ //#include "wx/grid.h" //#include +#include "creaWx.h" + #define LIST_CTRL 1000 namespace bbtk { - BEGIN_EVENT_TABLE(WxGUIBlackBoxList, wxListCtrl) EVT_LIST_BEGIN_DRAG(LIST_CTRL, WxGUIBlackBoxList::OnBeginDrag) EVT_LIST_BEGIN_RDRAG(LIST_CTRL, WxGUIBlackBoxList::OnBeginRDrag) @@ -81,34 +88,34 @@ namespace bbtk EVT_LIST_KEY_DOWN(LIST_CTRL, WxGUIBlackBoxList::OnListKeyDown) EVT_LIST_ITEM_ACTIVATED(LIST_CTRL, WxGUIBlackBoxList::OnActivated) EVT_LIST_ITEM_FOCUSED(LIST_CTRL, WxGUIBlackBoxList::OnFocused) - + EVT_LIST_COL_CLICK(LIST_CTRL, WxGUIBlackBoxList::OnColClick) EVT_LIST_COL_RIGHT_CLICK(LIST_CTRL, WxGUIBlackBoxList::OnColRightClick) EVT_LIST_COL_BEGIN_DRAG(LIST_CTRL, WxGUIBlackBoxList::OnColBeginDrag) EVT_LIST_COL_DRAGGING(LIST_CTRL, WxGUIBlackBoxList::OnColDragging) EVT_LIST_COL_END_DRAG(LIST_CTRL, WxGUIBlackBoxList::OnColEndDrag) - + EVT_LIST_CACHE_HINT(LIST_CTRL, WxGUIBlackBoxList::OnCacheHint) - + #if USE_CONTEXT_MENU EVT_CONTEXT_MENU(WxGUIBlackBoxList::OnContextMenu) #endif EVT_CHAR(WxGUIBlackBoxList::OnChar) - + EVT_RIGHT_DOWN(WxGUIBlackBoxList::OnRightClick) END_EVENT_TABLE() - - int wxCALLBACK MyCompareFunction(long item1, long item2, long WXUNUSED(sortData)) + + int wxCALLBACK MyCompareFunction(long item1, long item2, long WXUNUSED(sortData)) { // inverse the order if (item1 < item2) return -1; if (item1 > item2) return 1; - + return 0; } - + // WxGUIBlackBoxList WxGUIBlackBoxList::WxGUIBlackBoxList(wxWindow *parent, const wxWindowID id, @@ -123,34 +130,34 @@ namespace bbtk EnableContextMenu(); #endif } - + void WxGUIBlackBoxList::Insert(BlackBoxDescriptor::Pointer d) { if (GetColumnCount()!=3) { - InsertColumn( 0, _("Package"), - wxLIST_FORMAT_LEFT, 60 ); - InsertColumn( 1, _("Box"), - wxLIST_FORMAT_LEFT, 200 ); - InsertColumn( 2, _("Description"), - wxLIST_FORMAT_LEFT, 500 ); + InsertColumn( 0, _("Package"), + wxLIST_FORMAT_LEFT, 90 ); + InsertColumn( 1, _("Box"), + wxLIST_FORMAT_LEFT, 150 ); + InsertColumn( 2, _("Description"), + wxLIST_FORMAT_LEFT, 500 ); } - + wxListItem kNewItem; kNewItem.SetAlign(wxLIST_FORMAT_LEFT); - + int nID = this->GetItemCount(); kNewItem.SetId(nID); kNewItem.SetMask(wxLIST_MASK_DATA); // TO DO : STORE SMART POINTER ? - kNewItem.SetData(d.get()); + kNewItem.SetData(d.get()); // BlackBoxDescriptor::Pointer* d2 = (BlackBoxDescriptor::Pointer*)kNewItem.GetData(); // std::cout << "Descr = "<InsertItem(kNewItem); this->SetItem(nID, 0, std2wx(d->GetPackage()->GetName()) ); this->SetItem(nID, 1, std2wx(d->GetTypeName()) ); this->SetItem(nID, 2, std2wx(d->GetDescription()) ); - + /* if (nID % 2) { @@ -158,16 +165,15 @@ namespace bbtk this->SetItem(kNewItem); } */ - } - - + + void WxGUIBlackBoxList::OnCacheHint(wxListEvent& event) { //wxLogMessage( wxT("OnCacheHint: cache items %ld..%ld"), // event.GetCacheFrom(), event.GetCacheTo() ); } - + void WxGUIBlackBoxList::SetColumnImage(int col, int image) { /* @@ -244,6 +250,34 @@ namespace bbtk void WxGUIBlackBoxList::OnBeginDrag(wxListEvent& event) { + std::cout<<"RaC DRAG TABLE"<GetItemText(event.GetIndex())); + wxListItem info; + info.m_itemId = event.m_itemIndex; + info.m_col = 0; + info.m_mask = wxLIST_MASK_DATA; + wxString sendtext(_T("")); + if ( GetItem(info) ) + { + // TO DO : STORE SMART PTR ? + BlackBoxDescriptor* d = (BlackBoxDescriptor*)(info.GetData()); + if (d!=0) + { + //DFGO -> To identify it is a box + sendtext += crea::std2wx("box:"); + sendtext += crea::std2wx(d->GetFullTypeName()); + } + } + else + { + wxFAIL_MSG(wxT("wxListCtrl::GetItem() failed")); + } + + wxTextDataObject tdo(sendtext); + wxDropSource tds(tdo, this); + tds.DoDragDrop(); + // const wxPoint& pt = event.m_pointDrag; //wxLogMessage( wxT("OnBeginDrag at (%d, %d), item %ld."), @@ -480,21 +514,21 @@ namespace bbtk int flags; long subitem; - // long item = + // long item = HitTest(event.GetPosition(), flags, &subitem); wxString where; switch ( flags ) { - case wxLIST_HITTEST_ABOVE: where = _T("above"); break; - case wxLIST_HITTEST_BELOW: where = _T("below"); break; - case wxLIST_HITTEST_NOWHERE: where = _T("nowhere near"); break; - case wxLIST_HITTEST_ONITEMICON: where = _T("on icon of"); break; - case wxLIST_HITTEST_ONITEMLABEL: where = _T("on label of"); break; - case wxLIST_HITTEST_ONITEMRIGHT: where = _T("right on"); break; - case wxLIST_HITTEST_TOLEFT: where = _T("to the left of"); break; - case wxLIST_HITTEST_TORIGHT: where = _T("to the right of"); break; - default: where = _T("not clear exactly where on"); break; + case wxLIST_HITTEST_ABOVE: where = _T("above"); break; + case wxLIST_HITTEST_BELOW: where = _T("below"); break; + case wxLIST_HITTEST_NOWHERE: where = _T("nowhere near"); break; + case wxLIST_HITTEST_ONITEMICON: where = _T("on icon of"); break; + case wxLIST_HITTEST_ONITEMLABEL: where = _T("on label of"); break; + case wxLIST_HITTEST_ONITEMRIGHT: where = _T("right on"); break; + case wxLIST_HITTEST_TOLEFT: where = _T("to the left of"); break; + case wxLIST_HITTEST_TORIGHT: where = _T("to the right of"); break; + default: where = _T("not clear exactly where on"); break; } //wxLogMessage(_T("Right double click %s item %ld, subitem %ld"), @@ -558,11 +592,11 @@ namespace bbtk void WxGUIBlackBoxList::ShowContextMenu(const wxPoint& pos) { wxMenu menu; - + menu.Append(wxID_ABOUT, _T("&About")); menu.AppendSeparator(); menu.Append(wxID_EXIT, _T("E&xit")); - + PopupMenu(&menu, pos.x, pos.y); } //================================================================ @@ -576,7 +610,7 @@ namespace bbtk mDescriptor() { wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL); - + // mName = new wxStaticText(this,-1,_T("")); // sizer->Add(mName,0,wxGROW); mDescription = new wxStaticText(this,-1,_T("")); @@ -586,40 +620,37 @@ namespace bbtk mCategory = new wxStaticText(this,-1,_T("")); sizer->Add(mCategory,0,wxGROW); - - wxBoxSizer *inputs = + wxBoxSizer *inputs = new wxStaticBoxSizer - ( new wxStaticBox(this, wxID_ANY, _T("Inputs")), wxVERTICAL ); + ( new wxStaticBox(this, wxID_ANY, _T("Inputs")), wxVERTICAL ); mInputList = new wxListCtrl(this, -1, wxDefaultPosition, wxDefaultSize, wxLC_REPORT //wxLC_LIST | wxSUNKEN_BORDER); - - + inputs->Add(mInputList,1,wxGROW); sizer->Add(inputs,1,wxGROW); - wxBoxSizer *outputs = + wxBoxSizer *outputs = new wxStaticBoxSizer - ( new wxStaticBox(this, wxID_ANY, _T("Outputs")), wxVERTICAL ); + ( new wxStaticBox(this, wxID_ANY, _T("Outputs")), wxVERTICAL ); mOutputList = new wxListCtrl(this, -1, wxDefaultPosition, wxDefaultSize, wxLC_REPORT //wxLC_LIST | wxSUNKEN_BORDER); - + outputs->Add(mOutputList,1,wxGROW); sizer->Add(outputs,1,wxGROW); - - + SetSizer(sizer); SetAutoLayout(true); Layout(); } //================================================================ - + //================================================================ void WxGUIBlackBoxInfo::UpdateInfo(BlackBoxDescriptor* descr) { @@ -628,44 +659,44 @@ namespace bbtk mDescription->SetLabel(std2wx(descr->GetDescription())); mAuthor->SetLabel(std2wx(descr->GetAuthor())); mCategory->SetLabel(std2wx(descr->GetCategory())); - + mInputList->ClearAll(); - mInputList->InsertColumn( 0, _("Name"), - wxLIST_FORMAT_LEFT, 80 ); - mInputList->InsertColumn( 1, _("Type"), - wxLIST_FORMAT_LEFT, 100 ); - mInputList->InsertColumn( 2, _("Nature"), - wxLIST_FORMAT_LEFT, 100 ); - mInputList->InsertColumn( 3, _("Description"), - wxLIST_FORMAT_LEFT, 500 ); + mInputList->InsertColumn( 0, _("Name"), + wxLIST_FORMAT_LEFT, 80 ); + mInputList->InsertColumn( 1, _("Type"), + wxLIST_FORMAT_LEFT, 100 ); + mInputList->InsertColumn( 2, _("Nature"), + wxLIST_FORMAT_LEFT, 100 ); + mInputList->InsertColumn( 3, _("Description"), + wxLIST_FORMAT_LEFT, 500 ); mOutputList->ClearAll(); - mOutputList->InsertColumn( 0, _("Name"), - wxLIST_FORMAT_LEFT, 80 ); - mOutputList->InsertColumn( 1, _("Type"), - wxLIST_FORMAT_LEFT, 100 ); - mOutputList->InsertColumn( 2, _("Nature"), - wxLIST_FORMAT_LEFT, 100 ); - mOutputList->InsertColumn( 3, _("Description"), - wxLIST_FORMAT_LEFT, 500 ); - + mOutputList->InsertColumn( 0, _("Name"), + wxLIST_FORMAT_LEFT, 80 ); + mOutputList->InsertColumn( 1, _("Type"), + wxLIST_FORMAT_LEFT, 100 ); + mOutputList->InsertColumn( 2, _("Nature"), + wxLIST_FORMAT_LEFT, 100 ); + mOutputList->InsertColumn( 3, _("Description"), + wxLIST_FORMAT_LEFT, 500 ); + std::vector user_defined; std::vector ubb_defined; std::vector wxbb_defined; - - const BlackBoxDescriptor::InputDescriptorMapType& imap = + + const BlackBoxDescriptor::InputDescriptorMapType& imap = descr->GetInputDescriptorMap(); BlackBoxDescriptor::InputDescriptorMapType::const_iterator in; - for ( in = imap.begin(); in != imap.end(); ++in ) + for ( in = imap.begin(); in != imap.end(); ++in ) { int iotype = 0; - if (in->second->GetCreatorTypeInfo() == + if (in->second->GetCreatorTypeInfo() == typeid(AtomicBlackBoxDescriptor)) { iotype = 1; } - else if (in->second->GetCreatorTypeInfo() == + else if (in->second->GetCreatorTypeInfo() == typeid(WxBlackBoxDescriptor)) { iotype = 2; @@ -673,58 +704,58 @@ namespace bbtk if (iotype==0) user_defined.push_back(in->second); else if (iotype==1) ubb_defined.push_back(in->second); else if (iotype==2) wxbb_defined.push_back(in->second); - + } std::vector::iterator hi; - for (hi=user_defined.begin();hi!=user_defined.end();++hi) + for (hi=user_defined.begin();hi!=user_defined.end();++hi) { InsertInputOutput(mInputList,*hi); } - for (hi=wxbb_defined.begin();hi!=wxbb_defined.end();++hi) + for (hi=wxbb_defined.begin();hi!=wxbb_defined.end();++hi) { InsertInputOutput(mInputList,*hi); } - for (hi=ubb_defined.begin();hi!=ubb_defined.end();++hi) + for (hi=ubb_defined.begin();hi!=ubb_defined.end();++hi) { InsertInputOutput(mInputList,*hi); } - + // Outputs user_defined.clear(); ubb_defined.clear(); wxbb_defined.clear(); - const BlackBoxDescriptor::OutputDescriptorMapType& omap = + const BlackBoxDescriptor::OutputDescriptorMapType& omap = descr->GetOutputDescriptorMap(); BlackBoxDescriptor::OutputDescriptorMapType::const_iterator out; - for ( out = omap.begin(); out != omap.end(); ++out ) + for ( out = omap.begin(); out != omap.end(); ++out ) { int iotype = 0; - if (out->second->GetCreatorTypeInfo() == + if (out->second->GetCreatorTypeInfo() == typeid(AtomicBlackBoxDescriptor)) { iotype = 1; } - else if (out->second->GetCreatorTypeInfo() == + else if (out->second->GetCreatorTypeInfo() == typeid(WxBlackBoxDescriptor)) { iotype = 2; } - + if (iotype==0) user_defined.push_back(out->second); else if (iotype==1) ubb_defined.push_back(out->second); else if (iotype==2) wxbb_defined.push_back(out->second); } - for (hi=user_defined.begin();hi!=user_defined.end();++hi) + for (hi=user_defined.begin();hi!=user_defined.end();++hi) { InsertInputOutput(mOutputList,*hi); } - for (hi=wxbb_defined.begin();hi!=wxbb_defined.end();++hi) + for (hi=wxbb_defined.begin();hi!=wxbb_defined.end();++hi) { InsertInputOutput(mOutputList,*hi); } - for (hi=ubb_defined.begin();hi!=ubb_defined.end();++hi) + for (hi=ubb_defined.begin();hi!=ubb_defined.end();++hi) { InsertInputOutput(mOutputList,*hi); } @@ -742,7 +773,7 @@ namespace bbtk // std::cout << nID << std::endl; kNewItem.SetId(nID); // kNewItem.SetMask(wxLIST_MASK_DATA); - // kNewItem.SetData(d); + // kNewItem.SetData(d); l->InsertItem(kNewItem); l->SetItem(nID, 0, std2wx(d->GetName()) ); l->SetItem(nID, 1, std2wx(d->GetTypeName()) ); @@ -758,7 +789,7 @@ namespace bbtk //================================================================ - enum + enum { id_f1, id_f2, @@ -773,7 +804,6 @@ namespace bbtk id_fc3 }; - //================================================================ WxGUIPackageBrowser2::WxGUIPackageBrowser2( wxWindow *parent, WxGUIPackageBrowser2User* user ) @@ -781,6 +811,7 @@ namespace bbtk mUser(user), mInterpreter() { + _actualSelected=NULL; m_mgr.SetManagedWindow(this); // wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL); @@ -792,6 +823,8 @@ namespace bbtk mBoxList->SetUser(this); mBoxList->SetBackgroundColour(*wxWHITE); + +// JGRR & CM DISABLED CLOSE BUTTON m_mgr.AddPane(mBoxList, wxAuiPaneInfo().Name(wxT("BoxList")) .Caption(wxT("Black Boxes")) @@ -799,43 +832,45 @@ namespace bbtk .MaximizeButton(true) .Center() .MinSize(wxSize(100,100)) - ); + .CloseButton(false) + ); // sizer->Add(mBoxList,5,wxGROW); mBoxInfo = new WxGUIBlackBoxInfo(this); // sizer->Add(mBoxInfo,3,wxGROW); +// JGRR & CM DISABLED CLOSE BUTTON m_mgr.AddPane(mBoxInfo, wxAuiPaneInfo().Name(wxT("Box")) .Caption(wxT("")) .MinimizeButton(true) .MaximizeButton(true) .Bottom() - .MinSize(wxSize(100,300)) - ); - + .MinSize(wxSize(100,200)) + .CloseButton(false) + ); wxPanel* filters = new wxPanel(this,-1); - wxBoxSizer *fsizer = new wxBoxSizer(wxVERTICAL ); - wxBoxSizer *fpack = + wxBoxSizer *fsizer = new wxBoxSizer(wxVERTICAL ); + wxBoxSizer *fpack = new wxStaticBoxSizer - ( new wxStaticBox(filters, wxID_ANY, _T("Package")), wxHORIZONTAL ); + ( new wxStaticBox(filters, wxID_ANY, _T("Package")), wxHORIZONTAL ); mPackageFilter = new wxTextCtrl(filters,id_f1,_T(""), wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER); fpack->Add(mPackageFilter,1,wxGROW); fsizer->Add(fpack,0,wxGROW); - wxBoxSizer *fname = + wxBoxSizer *fname = new wxStaticBoxSizer - ( new wxStaticBox(filters, wxID_ANY, _T("Name")), wxHORIZONTAL ); + ( new wxStaticBox(filters, wxID_ANY, _T("Name")), wxHORIZONTAL ); mNameFilter = new wxTextCtrl(filters,id_f2,_T(""), wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER); fname->Add(mNameFilter,1,wxGROW); fsizer->Add(fname,0,wxGROW); - wxBoxSizer *fdescr = + wxBoxSizer *fdescr = new wxStaticBoxSizer ( new wxStaticBox(filters, wxID_ANY, _T("Description")), wxHORIZONTAL ); mDescriptionFilter = new wxTextCtrl(filters,id_f3,_T(""), @@ -844,16 +879,16 @@ namespace bbtk wxTE_PROCESS_ENTER); fdescr->Add(mDescriptionFilter,1,wxGROW); fsizer->Add(fdescr,0,wxGROW); - wxBoxSizer *fcat = + wxBoxSizer *fcat = new wxStaticBoxSizer - ( new wxStaticBox(filters, wxID_ANY, _T("Category")), wxHORIZONTAL ); + ( new wxStaticBox(filters, wxID_ANY, _T("Category")), wxHORIZONTAL ); mCategoryFilter = new wxTextCtrl(filters,id_f4,_T(""), wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER); fcat->Add(mCategoryFilter,1,wxGROW); fsizer->Add(fcat,0,wxGROW); - wxBoxSizer *fintype = + wxBoxSizer *fintype = new wxStaticBoxSizer ( new wxStaticBox(filters, wxID_ANY, _T("Input type")), wxHORIZONTAL ); mInputTypeFilter = new wxTextCtrl(filters,id_f5,_T(""), @@ -862,7 +897,7 @@ namespace bbtk wxTE_PROCESS_ENTER); fintype->Add(mInputTypeFilter,1,wxGROW); fsizer->Add(fintype,0,wxGROW); - wxBoxSizer *fouttype = + wxBoxSizer *fouttype = new wxStaticBoxSizer ( new wxStaticBox(filters, wxID_ANY, _T("Output type")), wxHORIZONTAL ); mOutputTypeFilter = new wxTextCtrl(filters,id_f6,_T(""), @@ -871,18 +906,18 @@ namespace bbtk wxTE_PROCESS_ENTER); fouttype->Add(mOutputTypeFilter,1,wxGROW); fsizer->Add(fouttype,0,wxGROW); - wxBoxSizer *finnat = + wxBoxSizer *finnat = new wxStaticBoxSizer - ( new wxStaticBox(filters, wxID_ANY, _T("Input nature")),wxHORIZONTAL ); + ( new wxStaticBox(filters, wxID_ANY, _T("Input nature")),wxHORIZONTAL ); mInputNatureFilter = new wxTextCtrl(filters,id_f7,_T(""), wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER); finnat->Add(mInputNatureFilter,1,wxGROW); fsizer->Add(finnat,0,wxGROW); - wxBoxSizer *foutnat = + wxBoxSizer *foutnat = new wxStaticBoxSizer - ( new wxStaticBox(filters, wxID_ANY,_T("Output nature")),wxHORIZONTAL ); + ( new wxStaticBox(filters, wxID_ANY,_T("Output nature")),wxHORIZONTAL ); mOutputNatureFilter = new wxTextCtrl(filters,id_f8,_T(""), wxDefaultPosition, wxDefaultSize, @@ -890,7 +925,6 @@ namespace bbtk foutnat->Add(mOutputNatureFilter,1,wxGROW); fsizer->Add(foutnat,0,wxGROW); - mShowWidgetsFilter = new wxCheckBox(filters,id_fc1,_T("Show widgets")); mShowWidgetsFilter->SetValue(true); fsizer->Add(mShowWidgetsFilter,0,wxGROW); @@ -905,15 +939,16 @@ namespace bbtk filters->SetSizer(fsizer); +// JGRR & CM DISABLED CLOSE BUTTON m_mgr.AddPane(filters, wxAuiPaneInfo().Name(wxT("Filter")) .Caption(wxT("Filter")) .MinimizeButton(true) .MaximizeButton(true) - .Right() - .MinSize(wxSize(100,100)) ); - - + .Left() + .MinSize(wxSize(100,100)) + .CloseButton(false) +); // sizer->Add(fsizer,1,wxGROW); m_mgr.Update(); @@ -921,10 +956,18 @@ namespace bbtk // SetSizer(sizer); SetAutoLayout(true); Layout(); - + + } + //================================================================ + + Factory::Pointer WxGUIPackageBrowser2::GetFactory() + { + return mFactory; } + //================================================================ + //================================================================ void WxGUIPackageBrowser2::OnFilter(wxCommandEvent&) { @@ -933,16 +976,27 @@ namespace bbtk //================================================================ //================================================================ - // User callback when a box is selected in the list + // User callback when a box is selected in the list void WxGUIPackageBrowser2::WxGUIBlackBoxListUserOnSelected ( BlackBoxDescriptor* d) { + //RaC + _actualSelected=d; + mBoxInfo->UpdateInfo(d); std::string title = d->GetPackage()->GetName()+"::"+d->GetTypeName(); m_mgr.GetPane(mBoxInfo).Caption(std2wx(title)); m_mgr.Update(); } - + + //================================================================ + + //================================================================ + BlackBoxDescriptor* WxGUIPackageBrowser2::GetActualSelected() + { + return _actualSelected; + } + //================================================================ //================================================================ @@ -961,7 +1015,8 @@ namespace bbtk if (!mInterpreter) mInterpreter =bbtk::Interpreter::New(); mInterpreter->SetCommandLine(true); std::stringstream* buf = new std::stringstream; - *buf << "message max 0" << std::endl; + *buf << "exec freeze_no_error" << std::endl; + *buf << "message max 0" << std::endl; *buf << "include *" << std::endl; mInterpreter->InterpretBuffer(buf); @@ -975,36 +1030,77 @@ namespace bbtk { mFactory = F; RebuildList(); - } + } + //================================================================ //================================================================ void WxGUIPackageBrowser2::RebuildList() { mBoxList->Hide(); - mBoxList->ClearAll(); - + mBoxList->ClearAll(); + const Factory::PackageMapType& M = mFactory->GetPackageMap(); Factory::PackageMapType::const_iterator i; for (i=M.begin();i!=M.end();++i) - { - Package::Pointer P = i->second; - if (P->GetName() == "user") continue; - - Package::BlackBoxMapType::iterator j; - for (j=P->GetBlackBoxMap().begin(); - j!=P->GetBlackBoxMap().end(); - ++j) - { - // std::cout << "Insert "<second->GetTypeName()<second)) - mBoxList->Insert(j->second); - } - } + { + Package::Pointer P = i->second; + if (P->GetName() == "user") continue; + + Package::DescriptorMapType::iterator j; + for (j=P->GetDescriptorMap().begin(); + j!=P->GetDescriptorMap().end(); + ++j) + { + // std::cout << "Insert "<second->GetTypeName()<second)) + mBoxList->Insert(j->second); + }// for Descriptor + }// for package mBoxList->Show(); } //================================================================ + bool WxGUIPackageBrowser2::findnpos(const std::string &strA, const std::string &strB ) + { + if ((strB=="") || (strA=="") ) + { + return false; + } + + bool ok=false; + int i,size; + std::string strAA=strA; + std::string strBB=strB; + + + size=strAA.length(); + for (i=0;i='A')&&(strAA[i]<='Z')) + { + strAA[i]=strAA[i]+32; + } + } + + size=strBB.length(); + for (i=0;i='A')&&(strBB[i]<='Z')) + { + strBB[i]=strBB[i]+32; + } + } + + + if ( strAA.find(strBB) == std::string::npos ) + { + ok=true; + } + + return ok; + } + //================================================================ bool WxGUIPackageBrowser2::IsVisible(BlackBoxDescriptor::Pointer d) { @@ -1013,150 +1109,199 @@ namespace bbtk if ((!mShowAdaptorsFilter->IsChecked())&& ((d->GetKind()==BlackBoxDescriptor::ADAPTOR)|| (d->GetKind()==BlackBoxDescriptor::DEFAULT_ADAPTOR))) - return false; + { + return false; + } + if ((!mShowGUIsFilter->IsChecked())&& ((d->GetKind()==BlackBoxDescriptor::GUI)|| (d->GetKind()==BlackBoxDescriptor::DEFAULT_GUI))) - return false; - if (d->GetPackage()->GetName().find( wx2std(mPackageFilter->GetValue()) ) - == std::string::npos ) return false; - if (d->GetTypeName().find( wx2std(mNameFilter->GetValue()) ) - == std::string::npos ) return false; - if (d->GetDescription().find( wx2std(mDescriptionFilter->GetValue()) ) - == std::string::npos ) return false; - if (d->GetCategory().find( wx2std(mCategoryFilter->GetValue()) ) - == std::string::npos ) return false; - if (!mShowWidgetsFilter->IsChecked()) - { - bool found = false; - const BlackBoxDescriptor::OutputDescriptorMapType& imap = - d->GetOutputDescriptorMap(); - BlackBoxDescriptor::OutputDescriptorMapType::const_iterator in; - for ( in = imap.begin(); in != imap.end(); ++in ) - { - if (in->second->GetName() == "Widget" ) - { - found = true; - break; - } - } - if (found) return false; - } - if (mInputTypeFilter->GetValue().size()>0) - { - std::string s = wx2std(mInputTypeFilter->GetValue()); - bool found = false; - const BlackBoxDescriptor::InputDescriptorMapType& imap = - d->GetInputDescriptorMap(); - BlackBoxDescriptor::InputDescriptorMapType::const_iterator in; - for ( in = imap.begin(); in != imap.end(); ++in ) - { - if (in->second->GetTypeName().find(s)!=std::string::npos) - { - found = true; - break; - } - } - if (!found) return false; + { + return false; + } + +//EED if (d->GetPackage()->GetName().find( wx2std(mPackageFilter->GetValue()) ) == std::string::npos ) + if ( findnpos(d->GetPackage()->GetName(),wx2std(mPackageFilter->GetValue())) == true ) + { + return false; + } + +//EED if (d->GetTypeName().find( wx2std(mNameFilter->GetValue()) ) == std::string::npos ) + if ( findnpos(d->GetTypeName(),wx2std(mNameFilter->GetValue())) == true ) + { + return false; + } + +//EED if (d->GetDescription().find( wx2std(mDescriptionFilter->GetValue()) ) == std::string::npos ) + if ( findnpos(d->GetDescription(),wx2std(mDescriptionFilter->GetValue())) == true ) + { + return false; + } + +//EED if (d->GetCategory().find( wx2std(mCategoryFilter->GetValue()) ) == std::string::npos ) + if ( findnpos(d->GetCategory(),wx2std(mCategoryFilter->GetValue())) == true ) + { + return false; + } + + if (!mShowWidgetsFilter->IsChecked()) + { + bool found = false; + const BlackBoxDescriptor::OutputDescriptorMapType& imap = d->GetOutputDescriptorMap(); + BlackBoxDescriptor::OutputDescriptorMapType::const_iterator in; + for ( in = imap.begin(); in != imap.end(); ++in ) + { + if (in->second->GetName() == "Widget" ) + { + found = true; + break; + } + } + if (found) + { + return false; + } + } + + if (mInputTypeFilter->GetValue().size()>0) + { + std::string s = wx2std(mInputTypeFilter->GetValue()); + bool found = false; + const BlackBoxDescriptor::InputDescriptorMapType& imap = d->GetInputDescriptorMap(); + BlackBoxDescriptor::InputDescriptorMapType::const_iterator in; + for ( in = imap.begin(); in != imap.end(); ++in ) + { +//EED if (in->second->GetTypeName().find(s)!=std::string::npos) + if ( findnpos( in->second->GetTypeName() , s ) == true ) + { + found = true; + break; + } + } + if (!found) + { + return false; + } } - if (mOutputTypeFilter->GetValue().size()>0) - { - std::string s = wx2std(mOutputTypeFilter->GetValue()); - bool found = false; - const BlackBoxDescriptor::OutputDescriptorMapType& imap = - d->GetOutputDescriptorMap(); - BlackBoxDescriptor::OutputDescriptorMapType::const_iterator in; - for ( in = imap.begin(); in != imap.end(); ++in ) - { - if (in->second->GetTypeName().find(s)!=std::string::npos) - { - found = true; - break; - } - } - if (!found) return false; + + if (mOutputTypeFilter->GetValue().size()>0) + { + std::string s = wx2std(mOutputTypeFilter->GetValue()); + bool found = false; + const BlackBoxDescriptor::OutputDescriptorMapType& imap = d->GetOutputDescriptorMap(); + BlackBoxDescriptor::OutputDescriptorMapType::const_iterator in; + for ( in = imap.begin(); in != imap.end(); ++in ) + { + //EED if (in->second->GetTypeName().find(s)!=std::string::npos) + if ( findnpos( in->second->GetTypeName() , s ) == true ) + { + found = true; + break; + } + } + if (!found) + { + return false; + } } - if (mInputNatureFilter->GetValue().size()>0) - { - std::string s = wx2std(mInputNatureFilter->GetValue()); - bool found = false; - const BlackBoxDescriptor::InputDescriptorMapType& imap = - d->GetInputDescriptorMap(); - BlackBoxDescriptor::InputDescriptorMapType::const_iterator in; - for ( in = imap.begin(); in != imap.end(); ++in ) - { - if (in->second->GetNature().find(s)!=std::string::npos) - { - found = true; - break; - } - } - if (!found) return false; + + if (mInputNatureFilter->GetValue().size()>0) + { + std::string s = wx2std(mInputNatureFilter->GetValue()); + bool found = false; + const BlackBoxDescriptor::InputDescriptorMapType& imap = d->GetInputDescriptorMap(); + BlackBoxDescriptor::InputDescriptorMapType::const_iterator in; + for ( in = imap.begin(); in != imap.end(); ++in ) + { +//EED if (in->second->GetNature().find(s)!=std::string::npos) + if ( findnpos( in->second->GetNature() , s ) == true ) + { + found = true; + break; + } + } + if (!found) + { + return false; + } } - if (mOutputNatureFilter->GetValue().size()>0) - { - std::string s = wx2std(mOutputNatureFilter->GetValue()); - bool found = false; - const BlackBoxDescriptor::OutputDescriptorMapType& imap = - d->GetOutputDescriptorMap(); - BlackBoxDescriptor::OutputDescriptorMapType::const_iterator in; - for ( in = imap.begin(); in != imap.end(); ++in ) - { - if (in->second->GetNature().find(s)!=std::string::npos) - { - found = true; - break; - } - } - if (!found) return false; + + if (mOutputNatureFilter->GetValue().size()>0) + { + std::string s = wx2std(mOutputNatureFilter->GetValue()); + bool found = false; + const BlackBoxDescriptor::OutputDescriptorMapType& imap = d->GetOutputDescriptorMap(); + BlackBoxDescriptor::OutputDescriptorMapType::const_iterator in; + for ( in = imap.begin(); in != imap.end(); ++in ) + { +//EED if (in->second->GetNature().find(s)!=std::string::npos) + if ( findnpos( in->second->GetNature() , s ) == true ) + { + found = true; + break; + } + } + if (!found) + { + return false; + } } return true; + } //======================================================================== //======================================================================== BEGIN_EVENT_TABLE(WxGUIPackageBrowser2, wxPanel) - EVT_TEXT_ENTER(id_f1, WxGUIPackageBrowser2::OnFilter ) - EVT_TEXT_ENTER(id_f2, WxGUIPackageBrowser2::OnFilter ) - EVT_TEXT_ENTER(id_f3, WxGUIPackageBrowser2::OnFilter ) - EVT_TEXT_ENTER(id_f4, WxGUIPackageBrowser2::OnFilter ) - EVT_TEXT_ENTER(id_f5, WxGUIPackageBrowser2::OnFilter ) - EVT_TEXT_ENTER(id_f6, WxGUIPackageBrowser2::OnFilter ) - EVT_TEXT_ENTER(id_f7, WxGUIPackageBrowser2::OnFilter ) - EVT_TEXT_ENTER(id_f8, WxGUIPackageBrowser2::OnFilter ) - EVT_CHECKBOX( id_fc1, WxGUIPackageBrowser2::OnFilter ) - EVT_CHECKBOX( id_fc2, WxGUIPackageBrowser2::OnFilter ) - EVT_CHECKBOX( id_fc3, WxGUIPackageBrowser2::OnFilter ) +//EED EVT_TEXT_ENTER(id_f1, WxGUIPackageBrowser2::OnFilter ) +//EED EVT_TEXT_ENTER(id_f2, WxGUIPackageBrowser2::OnFilter ) +//EED EVT_TEXT_ENTER(id_f3, WxGUIPackageBrowser2::OnFilter ) +//EED EVT_TEXT_ENTER(id_f4, WxGUIPackageBrowser2::OnFilter ) +//EED EVT_TEXT_ENTER(id_f5, WxGUIPackageBrowser2::OnFilter ) +//EED EVT_TEXT_ENTER(id_f6, WxGUIPackageBrowser2::OnFilter ) +//EED EVT_TEXT_ENTER(id_f7, WxGUIPackageBrowser2::OnFilter ) +//EED EVT_TEXT_ENTER(id_f8, WxGUIPackageBrowser2::OnFilter ) + + EVT_TEXT(id_f1, WxGUIPackageBrowser2::OnFilter ) + EVT_TEXT(id_f2, WxGUIPackageBrowser2::OnFilter ) + EVT_TEXT(id_f3, WxGUIPackageBrowser2::OnFilter ) + EVT_TEXT(id_f4, WxGUIPackageBrowser2::OnFilter ) + EVT_TEXT(id_f5, WxGUIPackageBrowser2::OnFilter ) + EVT_TEXT(id_f6, WxGUIPackageBrowser2::OnFilter ) + EVT_TEXT(id_f7, WxGUIPackageBrowser2::OnFilter ) + EVT_TEXT(id_f8, WxGUIPackageBrowser2::OnFilter ) + + EVT_CHECKBOX( id_fc1, WxGUIPackageBrowser2::OnFilter ) + EVT_CHECKBOX( id_fc2, WxGUIPackageBrowser2::OnFilter ) + EVT_CHECKBOX( id_fc3, WxGUIPackageBrowser2::OnFilter ) END_EVENT_TABLE() //======================================================================== //================================================================ - WxGUIPackageBrowser2Window::WxGUIPackageBrowser2Window( wxWindow *parent, - wxString title, - wxSize size) + WxGUIPackageBrowser2Window::WxGUIPackageBrowser2Window( wxWindow *parent, + wxString title, + wxSize size) : wxFrame((wxFrame *)parent, -1, title, wxDefaultPosition, size) - { - - + { wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL); mBrowser = new WxGUIPackageBrowser2(this); mBrowser->IncludeAll(); sizer->Add(mBrowser,1,wxGROW); - + // WxGUICommand* com = new WxGUICommand(this,this); // sizer->Add(com); - + SetSizer(sizer); // Creates the parent window of all bbtk windows as a child of this // Wx::CreateTopWindow(this); - // Add the method OnWxSignal as a Wx::Signal observer + // Add the method OnWxSignal as a Wx::Signal observer //bbtkAddWxSignalObserver(WxGUIPackageBrowser2Window::OnWxSignal); - + SetAutoLayout(true); Layout(); }