]> Creatis software - bbtk.git/commitdiff
*** empty log message ***
authorguigues <guigues>
Fri, 4 Apr 2008 08:04:05 +0000 (08:04 +0000)
committerguigues <guigues>
Fri, 4 Apr 2008 08:04:05 +0000 (08:04 +0000)
kernel/src/bbtkBlackBoxInputDescriptor.h
kernel/src/bbtkBlackBoxInputOutputDescriptor.h [new file with mode: 0644]
kernel/src/bbtkBlackBoxOutputDescriptor.h
kernel/src/bbtkWxGUIPackageBrowser2.cxx [new file with mode: 0644]
kernel/src/bbtkWxGUIPackageBrowser2.h [new file with mode: 0644]
kernel/src/bbtkWxGUITextEditor.cxx

index 19c578f91514093d6635413b51b590e5f2f8a844..9481722bf545eaffbb131924b9b4bcbdb92c474a 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkBlackBoxInputDescriptor.h,v $
   Language:  C++
-  Date:      $Date: 2008/02/06 14:14:22 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/04/04 08:04:05 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 
 /**
  *  \file 
- *  \brief Class bbtk::BlackBoxInputDescriptor : abstract descriptor of an input of a black box (stores a name, a description and type)
+ *  \brief Class bbtk::BlackBoxInputDescriptor : abstract descriptor of an input of a black box 
  */
 /**
  * \class bbtk::BlackBoxInputDescriptor
- * \brief Abstract descriptor of an input of a black box (stores a name, a description and type)
+ * \brief Abstract descriptor of an input of a black box 
  */
 
 #ifndef __bbtkBlackBoxInputDescriptor_h__
 #define __bbtkBlackBoxInputDescriptor_h__
 
-#include "bbtkSystem.h"
-#include "bbtkData.h"
-#include "bbtkRTTI.h"
+#include "bbtkBlackBoxInputOutputDescriptor.h"
 
 namespace bbtk
 {
-  class BBTK_EXPORT BlackBoxInputDescriptor
+  class BBTK_EXPORT BlackBoxInputDescriptor 
+    : public BlackBoxInputOutputDescriptor
   {
   public:
     typedef enum {
@@ -49,50 +48,21 @@ namespace bbtk
                            const std::string& description,
                            OptionType option = MANDATORY,
                            bool copy_construct = true)
-      : mCreatorTypeInfo(creator_type_info),
-       mName(name), mDescription(description), 
-       mOption(option), mCopyConstruct(copy_construct) 
+      : BlackBoxInputOutputDescriptor(creator_type_info,name,
+                                     description,copy_construct),
+       mOption(option)
     {}
-    
-    /// Returns the TypeInfo of the BlackBoxDescriptor which created this descriptor
-    TypeInfo GetCreatorTypeInfo() { return mCreatorTypeInfo; }
-    /// Returns the name of the input
-    const std::string& GetName() const { return mName; }
-    /// Returns the description of the input
-    const std::string& GetDescription() const { return mDescription; }
-    /// Returns the type of the input
-    virtual TypeInfo GetTypeInfo() const = 0;
-    /// Returns the name of the type of the input
-    virtual std::string GetTypeName() const = 0;
-    /// Returns the name of the type of the input
-    virtual std::string GetHumanTypeName() const = 0;
-    /// Returns true iff the type is a pointer to class 
-    virtual bool IsPointerType() const = 0;
     /// Returns the option of the input
     OptionType GetOption() const { return mOption; }
-    /// Returns true iff the input must be copied 
-    /// by the copy constructor of the box
-    bool GetCopyConstruct() const { return mCopyConstruct; }
     
-  private:
-    /// Default ctor is private
-    BlackBoxInputDescriptor() : mCreatorTypeInfo(typeid(void)),
-                               mName(""), mDescription(""), 
+  protected:
+    /// Default ctor is reserved to children
+    BlackBoxInputDescriptor() : BlackBoxInputOutputDescriptor(),
                                mOption(OPTIONAL) {}
 
-    /// The TypeInfo of the BlackBoxDescriptor which created this descriptor
-    TypeInfo mCreatorTypeInfo;
-    /// The name of the input
-    std::string mName;
-    /// The description of the input
-    std::string mDescription;
+  private:
     /// The option of the input 
     OptionType mOption;
-    /// Does the input has to be copied by copy constructor 
-    /// default = true. Must be set to false if it is 
-    /// initialized by the user in bbUserCopyConstructor 
-    /// (typically if it is a pointer)
-    bool mCopyConstruct;
   };
   
 }
diff --git a/kernel/src/bbtkBlackBoxInputOutputDescriptor.h b/kernel/src/bbtkBlackBoxInputOutputDescriptor.h
new file mode 100644 (file)
index 0000000..4560950
--- /dev/null
@@ -0,0 +1,93 @@
+/*=========================================================================
+                                                                                
+  Program:   bbtk
+  Module:    $RCSfile: bbtkBlackBoxInputOutputDescriptor.h,v $
+  Language:  C++
+  Date:      $Date: 2008/04/04 08:04:05 $
+  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.
+                                                                                
+=========================================================================*/
+
+/**
+ *  \file 
+ *  \brief Class bbtk::BlackBoxInputOutputDescriptor : abstract descriptor of an input or an output of a black box (has a name, a description and type)
+ */
+/**
+ * \class bbtk::BlackBoxInputOutputDescriptor
+ * \brief Abstract descriptor of an input or an output of a black box (has a name, a description and type)
+ */
+
+#ifndef __bbtkBlackBoxInputOutputDescriptor_h__
+#define __bbtkBlackBoxInputOutputDescriptor_h__
+
+#include "bbtkSystem.h"
+#include "bbtkData.h"
+#include "bbtkRTTI.h"
+
+
+namespace bbtk
+{
+  class BBTK_EXPORT BlackBoxInputOutputDescriptor
+  {
+  public:
+    /// Ctor with name and description
+    BlackBoxInputOutputDescriptor(TypeInfo creator_type_info,
+                                 const std::string& name,
+                                 const std::string& description,
+                                 bool copy_construct = true)
+      : mCreatorTypeInfo(creator_type_info),
+       mName(name), 
+       mDescription(description),
+       mCopyConstruct(copy_construct)
+    {}
+    
+    /// Returns the TypeInfo of the BlackBoxDescriptor which created this descriptor
+    TypeInfo GetCreatorTypeInfo() { return mCreatorTypeInfo; }
+    /// Returns the name of the in/output
+    const std::string& GetName() const { return mName; }
+    /// Returns the description of the in/output
+    const std::string& GetDescription() const { return mDescription; }
+    /// Returns the type of the in/output
+    virtual TypeInfo GetTypeInfo() const = 0;
+    /// Returns the name of the type of the in/output
+    virtual std::string GetTypeName() const = 0;
+    /// Returns the name of the type of the in/output
+    virtual std::string GetHumanTypeName() const = 0;
+    /// Returns true iff the type is a pointer to class 
+    virtual bool IsPointerType() const = 0;
+    /// Returns true iff the in/output must be copied 
+    /// by the copy constructor of the box
+    bool GetCopyConstruct() const { return mCopyConstruct; }
+
+  protected:
+    /// Default ctor is reserved to children
+    BlackBoxInputOutputDescriptor() : mCreatorTypeInfo(typeid(void)),
+                                     mName(""), mDescription(""),
+                                     mCopyConstruct(true)
+                               {}
+  private:
+
+    /// The TypeInfo of the BlackBoxDescriptor which created this descriptor
+    TypeInfo mCreatorTypeInfo;
+    /// The name of the input/output
+    std::string mName;
+    /// The description of the input/output
+    std::string mDescription;
+    /// Does the in/output has to be copied by copy constructor 
+    /// default = true. Must be set to false if it is 
+    /// initialized by the user in bbUserCopyConstructor 
+    /// (typically if it is a pointer)
+    bool mCopyConstruct;
+  };
+  
+}
+// namespace bbtk
+#endif
index c4196715c4153718ece6783acfdbd098bbe6fefc..cba3a638375fc7a10ab0c6a29d652bc8ea68e8e0 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkBlackBoxOutputDescriptor.h,v $
   Language:  C++
-  Date:      $Date: 2008/02/06 14:14:22 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/04/04 08:04:05 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 #ifndef __bbtkBlackBoxOutputDescriptor_h__
 #define __bbtkBlackBoxOutputDescriptor_h__
 
-
-#include "bbtkSystem.h"
-#include "bbtkData.h"
-#include "bbtkRTTI.h"
+#include "bbtkBlackBoxInputOutputDescriptor.h"
 
 namespace bbtk
 {
   
   class BBTK_EXPORT BlackBoxOutputDescriptor
+    : public BlackBoxInputOutputDescriptor
   {
   public:
     /// Ctor with name and description
@@ -44,46 +42,16 @@ namespace bbtk
                              const std::string& name,
                              const std::string& description,
                              bool copy_construct = true)
-      : mCreatorTypeInfo(creator_type_info),
-       mName(name), mDescription(description), 
-       mCopyConstruct(copy_construct) 
+      : BlackBoxInputOutputDescriptor(creator_type_info,name,
+                                     description,
+                                     copy_construct)
+    {}
+  protected:
+    /// Default ctor is reserved to children
+    BlackBoxOutputDescriptor() : 
+      BlackBoxInputOutputDescriptor()
     {}
-
-    /// Returns the TypeInfo of the BlackBoxDescriptor which created this descriptor
-    TypeInfo GetCreatorTypeInfo() { return mCreatorTypeInfo; }
-    /// Returns the name of the output
-    const std::string& GetName() const { return mName; }
-    /// Returns the description of the output
-    const std::string& GetDescription() const { return mDescription; }
-    /// Returns the type of the output
-    virtual TypeInfo GetTypeInfo() const = 0;
-    /// Returns the name of the type of the output
-    virtual std::string GetTypeName() const = 0;
-    /// Returns the name of the type of the output
-    virtual std::string GetHumanTypeName() const = 0;
-     /// Returns true iff the type is a pointer to class 
-    virtual bool IsPointerType() const = 0;
-    /// Returns true iff the input must be copied 
-    /// by the copy constructor of the box
-    bool GetCopyConstruct() const { return mCopyConstruct; }
-    
-    
-  private:
-    /// Default ctor is private
-    BlackBoxOutputDescriptor() : mCreatorTypeInfo(typeid(void)),
-                                mName(""), mDescription("") {}
-
-    /// The TypeInfo of the BlackBoxDescriptor which created this descriptor
-    TypeInfo mCreatorTypeInfo;
-    /// The name of the output
-    std::string mName;
-    /// The description of the output
-    std::string mDescription;
-     /// Does the output has to be copied by copy constructor 
-    /// default = true. Must be set to false if it is 
-    /// initialized by the user in bbUserCopyConstructor 
-    /// (typically if it is a pointer)
-    bool mCopyConstruct;
  };
   
 }
diff --git a/kernel/src/bbtkWxGUIPackageBrowser2.cxx b/kernel/src/bbtkWxGUIPackageBrowser2.cxx
new file mode 100644 (file)
index 0000000..02a11a9
--- /dev/null
@@ -0,0 +1,995 @@
+/*=========================================================================
+                                                                                
+Program:   bbtk
+Module:    $RCSfile: bbtkWxGUIPackageBrowser2.cxx,v $
+Language:  C++
+Date:      $Date: 2008/04/04 08:04:05 $
+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_
+
+#define CHECKBOXVIEW 1
+
+#include "bbtkWxGUIPackageBrowser2.h"
+//#include "ThirdParty/wx/treemultictrl/wxTreeMultiCtrl.h"
+#include "bbtkInterpreter.h"
+#include "bbtkBlackBoxInputDescriptor.h"
+#include "bbtkBlackBoxOutputDescriptor.h"
+#include "bbtkWxBlackBox.h"
+//#include "wx/grid.h"
+//#include <wx/statline.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)
+    EVT_LIST_BEGIN_LABEL_EDIT(LIST_CTRL, WxGUIBlackBoxList::OnBeginLabelEdit)
+    EVT_LIST_END_LABEL_EDIT(LIST_CTRL, WxGUIBlackBoxList::OnEndLabelEdit)
+    EVT_LIST_DELETE_ITEM(LIST_CTRL, WxGUIBlackBoxList::OnDeleteItem)
+    EVT_LIST_DELETE_ALL_ITEMS(LIST_CTRL, WxGUIBlackBoxList::OnDeleteAllItems)
+#if WXWIN_COMPATIBILITY_2_4
+    EVT_LIST_GET_INFO(LIST_CTRL, WxGUIBlackBoxList::OnGetInfo)
+    EVT_LIST_SET_INFO(LIST_CTRL, WxGUIBlackBoxList::OnSetInfo)
+#endif
+    EVT_LIST_ITEM_SELECTED(LIST_CTRL, WxGUIBlackBoxList::OnSelected)
+    EVT_LIST_ITEM_DESELECTED(LIST_CTRL, WxGUIBlackBoxList::OnDeselected)
+    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))
+  {
+    // inverse the order
+    if (item1 < item2)
+      return -1;
+    if (item1 > item2)
+      return 1;
+    
+    return 0;
+  }
+  
+  // WxGUIBlackBoxList
+  WxGUIBlackBoxList::WxGUIBlackBoxList(wxWindow *parent,
+                                const wxWindowID id,
+                                const wxPoint& pos,
+                                const wxSize& size,
+                                long style)
+    : wxListCtrl(parent, id, pos, size, style),
+      mUser(0),
+      m_attr(*wxBLUE, *wxLIGHT_GREY, wxNullFont)
+  {
+#ifdef __POCKETPC__
+    EnableContextMenu();
+#endif
+  }
+  
+  void WxGUIBlackBoxList::Insert(BlackBoxDescriptor* d)
+  {
+    if (GetColumnCount()!=3)
+      {
+       InsertColumn( 0, _("Package"), 
+                     wxLIST_FORMAT_LEFT, 40  ); 
+       InsertColumn( 1, _("Box"), 
+                     wxLIST_FORMAT_LEFT, 200 ); 
+       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);
+    kNewItem.SetData(d);  
+    //    BlackBoxDescriptor* d2 = (BlackBoxDescriptor*)kNewItem.GetData();
+    //    std::cout << "Descr = "<<d<<" = "<<d2<<std::endl;
+    this->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)
+      {
+      kNewItem.SetBackgroundColour(wxColour(192,192,192));
+      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)
+  {
+    /*
+      wxListItem item;
+      item.SetMask(wxLIST_MASK_IMAGE);
+      item.SetImage(image);
+      SetColumn(col, item);
+    */
+  }
+
+  void WxGUIBlackBoxList::OnColClick(wxListEvent& event)
+  {
+    int col = event.GetColumn();
+
+    // set or unset image
+    static bool x = false;
+    x = !x;
+    SetColumnImage(col, x ? 0 : -1);
+
+    //    wxLogMessage( wxT("OnColumnClick at %d."), col );
+  }
+
+  void WxGUIBlackBoxList::OnColRightClick(wxListEvent& event)
+  {
+    int col = event.GetColumn();
+    if ( col != -1 )
+      {
+        SetColumnImage(col, -1);
+      }
+
+    // Show popupmenu at position
+    wxMenu menu(wxT("Test"));
+    menu.Append(-1, _T("&About"));
+    PopupMenu(&menu, event.GetPoint());
+
+    //wxLogMessage( wxT("OnColumnRightClick at %d."), event.GetColumn() );
+  }
+
+  void WxGUIBlackBoxList::LogColEvent(const wxListEvent& event, const wxChar *name)
+  {
+    const int col = event.GetColumn();
+
+    /*
+      wxLogMessage(wxT("%s: column %d (width = %d or %d)."),
+      name,
+      col,
+      event.GetItem().GetWidth(),
+      GetColumnWidth(col));
+    */
+  }
+
+  void WxGUIBlackBoxList::OnColBeginDrag(wxListEvent& event)
+  {
+    LogColEvent( event, wxT("OnColBeginDrag") );
+    /*
+      if ( event.GetColumn() == 0 )
+      {
+      //wxLogMessage(_T("Resizing this column shouldn't work."));
+
+      event.Veto();
+      }
+    */
+  }
+
+  void WxGUIBlackBoxList::OnColDragging(wxListEvent& event)
+  {
+    LogColEvent( event, wxT("OnColDragging") );
+  }
+
+  void WxGUIBlackBoxList::OnColEndDrag(wxListEvent& event)
+  {
+    LogColEvent( event, wxT("OnColEndDrag") );
+  }
+
+  void WxGUIBlackBoxList::OnBeginDrag(wxListEvent& event)
+  {
+    const wxPoint& pt = event.m_pointDrag;
+
+    int flags;
+    //wxLogMessage( wxT("OnBeginDrag at (%d, %d), item %ld."),
+    //          pt.x, pt.y, HitTest(pt, flags) );
+  }
+
+  void WxGUIBlackBoxList::OnBeginRDrag(wxListEvent& event)
+  {
+    //wxLogMessage( wxT("OnBeginRDrag at %d,%d."),
+    //        event.m_pointDrag.x, event.m_pointDrag.y );
+  }
+
+  void WxGUIBlackBoxList::OnBeginLabelEdit(wxListEvent& event)
+  {
+    //wxLogMessage( wxT("OnBeginLabelEdit: %s"), event.m_item.m_text.c_str());
+  }
+
+  void WxGUIBlackBoxList::OnEndLabelEdit(wxListEvent& event)
+  {
+    //wxLogMessage( wxT("OnEndLabelEdit: %s"),
+    //        event.IsEditCancelled() ? _T("[cancelled]")
+    //                                      : event.m_item.m_text.c_str());
+  }
+
+  void WxGUIBlackBoxList::OnDeleteItem(wxListEvent& event)
+  {
+    LogEvent(event, _T("OnDeleteItem"));
+    std::cout << "cannot del"<<std::endl;
+    event.Veto();
+    //wxLogMessage( wxT("Number of items when delete event is sent: %d"), GetItemCount() );
+  }
+
+  void WxGUIBlackBoxList::OnDeleteAllItems(wxListEvent& event)
+  {
+    LogEvent(event, _T("OnDeleteAllItems"));
+    event.Veto();
+  }
+
+#if WXWIN_COMPATIBILITY_2_4
+  void WxGUIBlackBoxList::OnGetInfo(wxListEvent& event)
+  {
+    wxString msg;
+
+    msg << _T("OnGetInfo (") << event.m_item.m_itemId << _T(", ") << event.m_item.m_col << _T(")");
+    if ( event.m_item.m_mask & wxLIST_MASK_STATE )
+      msg << _T(" wxLIST_MASK_STATE");
+    if ( event.m_item.m_mask & wxLIST_MASK_TEXT )
+      msg << _T(" wxLIST_MASK_TEXT");
+    if ( event.m_item.m_mask & wxLIST_MASK_IMAGE )
+      msg << _T(" wxLIST_MASK_IMAGE");
+    if ( event.m_item.m_mask & wxLIST_MASK_DATA )
+      msg << _T(" wxLIST_MASK_DATA");
+    if ( event.m_item.m_mask & wxLIST_SET_ITEM )
+      msg << _T(" wxLIST_SET_ITEM");
+    if ( event.m_item.m_mask & wxLIST_MASK_WIDTH )
+      msg << _T(" wxLIST_MASK_WIDTH");
+    if ( event.m_item.m_mask & wxLIST_MASK_FORMAT )
+      msg << _T(" wxLIST_MASK_WIDTH");
+
+    if ( event.m_item.m_mask & wxLIST_MASK_TEXT )
+      {
+        event.m_item.m_text = _T("My callback text");
+      }
+
+    //wxLogMessage(msg);
+  }
+
+  void WxGUIBlackBoxList::OnSetInfo(wxListEvent& event)
+  {
+    LogEvent(event, _T("OnSetInfo"));
+  }
+#endif
+
+  void WxGUIBlackBoxList::OnSelected(wxListEvent& event)
+  {
+    if (mUser==0) return;
+
+    wxListItem info;
+    info.m_itemId = event.m_itemIndex;
+    info.m_col = 0;
+    info.m_mask = wxLIST_MASK_DATA;
+    if ( GetItem(info) )
+      {
+       BlackBoxDescriptor* d = (BlackBoxDescriptor*)(info.GetData());
+       if (d!=0) mUser->WxGUIBlackBoxListUserOnSelected(d);
+      }
+    else
+      {
+       wxFAIL_MSG(wxT("wxListCtrl::GetItem() failed"));
+      }
+  }
+
+  void WxGUIBlackBoxList::OnDeselected(wxListEvent& event)
+  {
+    LogEvent(event, _T("OnDeselected"));
+  }
+
+  void WxGUIBlackBoxList::OnActivated(wxListEvent& event)
+  {
+    LogEvent(event, _T("OnActivated"));
+  }
+
+  void WxGUIBlackBoxList::OnFocused(wxListEvent& event)
+  {
+    LogEvent(event, _T("OnFocused"));
+
+    event.Skip();
+  }
+
+  void WxGUIBlackBoxList::OnListKeyDown(wxListEvent& event)
+  {
+    long item;
+
+    switch ( event.GetKeyCode() )
+      {
+      case 'c': // colorize
+      case 'C':
+       {
+         wxListItem info;
+         info.m_itemId = event.GetIndex();
+         if ( info.m_itemId == -1 )
+           {
+             // no item
+             break;
+           }
+
+         GetItem(info);
+
+         wxListItemAttr *attr = info.GetAttributes();
+         if ( !attr || !attr->HasTextColour() )
+           {
+             info.SetTextColour(*wxCYAN);
+
+             SetItem(info);
+
+             RefreshItem(info.m_itemId);
+           }
+       }
+       break;
+
+      case 'n': // next
+      case 'N':
+       item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED);
+       if ( item++ == GetItemCount() - 1 )
+         {
+           item = 0;
+         }
+
+       //wxLogMessage(_T("Focusing item %ld"), item);
+
+       SetItemState(item, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
+       EnsureVisible(item);
+       break;
+
+      case 'r': // show bounding Rect
+      case 'R':
+       {
+         item = event.GetIndex();
+         wxRect r;
+         if ( !GetItemRect(item, r) )
+           {
+             //wxLogError(_T("Failed to retrieve rect of item %ld"), item);
+             break;
+           }
+
+         //wxLogMessage(_T("Bounding rect of item %ld is (%d, %d)-(%d, %d)"),
+         //   item, r.x, r.y, r.x + r.width, r.y + r.height);
+       }
+       break;
+
+      case WXK_DELETE:
+       item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
+       /*
+         while ( item != -1 )
+         {
+         DeleteItem(item);
+
+         //wxLogMessage(_T("Item %ld deleted"), item);
+
+         // -1 because the indices were shifted by DeleteItem()
+         item = GetNextItem(item - 1,
+         wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
+         }
+       */
+       break;
+
+      case WXK_INSERT:
+       if ( GetWindowStyle() & wxLC_REPORT )
+         {
+           if ( GetWindowStyle() & wxLC_VIRTUAL )
+             {
+               SetItemCount(GetItemCount() + 1);
+             }
+           else // !virtual
+             {
+               //InsertItemInReportView(event.GetIndex());
+             }
+         }
+       //else: fall through
+
+      default:
+       LogEvent(event, _T("OnListKeyDown"));
+
+       event.Skip();
+      }
+  }
+
+  void WxGUIBlackBoxList::OnChar(wxKeyEvent& event)
+  {
+    //wxLogMessage(_T("Got char event."));
+
+    switch ( event.GetKeyCode() )
+      {
+      case 'n':
+      case 'N':
+      case 'c':
+      case 'C':
+       // these are the keys we process ourselves
+       break;
+
+      default:
+       event.Skip();
+      }
+  }
+
+  void WxGUIBlackBoxList::OnRightClick(wxMouseEvent& event)
+  {
+    if ( !event.ControlDown() )
+      {
+        event.Skip();
+        return;
+      }
+
+    int flags;
+    long subitem;
+    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;
+      }
+
+    //wxLogMessage(_T("Right double click %s item %ld, subitem %ld"),
+    //             where.c_str(), item, subitem);
+  }
+
+  void WxGUIBlackBoxList::LogEvent(const wxListEvent& event, const wxChar *eventName)
+  {
+    //wxLogMessage(_T("Item %ld: %s (item text = %s, data = %ld)"),
+    //            event.GetIndex(), eventName,
+    //              event.GetText().c_str(), event.GetData());
+  }
+
+  wxString WxGUIBlackBoxList::OnGetItemText(long item, long column) const
+  {
+    /*
+      if ( GetItemCount() == WXSIZEOF(SMALL_VIRTUAL_VIEW_ITEMS) )
+      {
+      return SMALL_VIRTUAL_VIEW_ITEMS[item][column];
+      }
+      else
+      {
+    */
+    return wxString::Format(_T("Column %ld of item %ld"), column, item);
+    //  }
+  }
+
+  int WxGUIBlackBoxList::OnGetItemColumnImage(long item, long column) const
+  {
+    if (!column)
+      return 0;
+
+    if (!(item %3) && column == 1)
+      return 0;
+
+    return -1;
+  }
+
+  wxListItemAttr *WxGUIBlackBoxList::OnGetItemAttr(long item) const
+  {
+    return item % 2 ? NULL : (wxListItemAttr *)&m_attr;
+  }
+
+
+#if USE_CONTEXT_MENU
+  void WxGUIBlackBoxList::OnContextMenu(wxContextMenuEvent& event)
+  {
+    wxPoint point = event.GetPosition();
+    // If from keyboard
+    if (point.x == -1 && point.y == -1) {
+      wxSize size = GetSize();
+      point.x = size.x / 2;
+      point.y = size.y / 2;
+    } else {
+      point = ScreenToClient(point);
+    }
+    ShowContextMenu(point);
+  }
+#endif
+
+  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);
+  }
+  //================================================================
+
+
+
+  //================================================================
+  WxGUIBlackBoxInfo::WxGUIBlackBoxInfo(wxWindow* parent)
+    :
+    wxPanel(parent, -1),
+    mDescriptor(0)
+  {
+    wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
+    
+    mName = new wxStaticText(this,-1,_T(""));
+    sizer->Add(mName,0,wxGROW);
+    mDescription = new wxStaticText(this,-1,_T(""));
+    sizer->Add(mDescription,0,wxGROW);
+    mAuthor = new wxStaticText(this,-1,_T(""));
+    sizer->Add(mAuthor,0,wxGROW);
+    mCategory = new wxStaticText(this,-1,_T(""));
+    sizer->Add(mCategory,0,wxGROW);
+
+
+    wxBoxSizer *inputs = 
+      new wxStaticBoxSizer
+      ( new wxStaticBox(this, wxID_ANY, _T("Inputs")), wxVERTICAL );    
+    mInputList = new wxListCtrl(this, -1,
+                               wxDefaultPosition,
+                               wxDefaultSize,
+                               wxLC_REPORT //wxLC_LIST
+                               | wxSUNKEN_BORDER);
+    
+    
+    inputs->Add(mInputList,0,wxGROW);
+    sizer->Add(inputs,0,wxGROW);
+
+    wxBoxSizer *outputs = 
+      new wxStaticBoxSizer
+      ( new wxStaticBox(this, wxID_ANY, _T("Outputs")), wxVERTICAL );    
+    mOutputList = new wxListCtrl(this, -1,
+                                wxDefaultPosition,
+                                wxDefaultSize,
+                                wxLC_REPORT //wxLC_LIST
+                                | wxSUNKEN_BORDER);
+    
+    outputs->Add(mOutputList,0,wxGROW);
+    sizer->Add(outputs,0,wxGROW);
+    
+    
+    SetSizer(sizer);
+    SetAutoLayout(true);
+    Layout();
+  }
+  //================================================================
+
+    
+  //================================================================
+  void WxGUIBlackBoxInfo::UpdateInfo(BlackBoxDescriptor* descr)
+  {
+    std::cout << "UpdateInfo "<<descr<<std::endl;
+    mName->SetLabel(std2wx(descr->GetTypeName()));
+    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, _("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, _("Description"), 
+                              wxLIST_FORMAT_LEFT, 500  ); 
+    
+
+    std::vector<BlackBoxInputOutputDescriptor*> user_defined;
+    std::vector<BlackBoxInputOutputDescriptor*> ubb_defined;
+    std::vector<BlackBoxInputOutputDescriptor*> wxbb_defined;
+    
+    const BlackBoxDescriptor::InputDescriptorMapType& imap = 
+      descr->GetInputDescriptorMap();
+    BlackBoxDescriptor::InputDescriptorMapType::const_iterator in;
+    for ( in = imap.begin();  in != imap.end(); ++in ) 
+      {
+       int iotype = 0;
+       if (in->second->GetCreatorTypeInfo() == 
+           typeid(AtomicBlackBoxDescriptor))
+         {
+           iotype = 1;
+         }
+       else if (in->second->GetCreatorTypeInfo() == 
+                typeid(WxBlackBoxDescriptor))
+         {
+           iotype = 2;
+         }
+       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<BlackBoxInputOutputDescriptor*>::iterator hi;
+    for (hi=user_defined.begin();hi!=user_defined.end();++hi) 
+      {
+       InsertInputOutput(mInputList,*hi);
+      }
+    for (hi=wxbb_defined.begin();hi!=wxbb_defined.end();++hi) 
+      {
+       InsertInputOutput(mInputList,*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 = 
+      descr->GetOutputDescriptorMap();
+    BlackBoxDescriptor::OutputDescriptorMapType::const_iterator out;
+    for ( out = omap.begin();  out != omap.end(); ++out ) 
+      {
+       int iotype = 0;
+       if (out->second->GetCreatorTypeInfo() == 
+           typeid(AtomicBlackBoxDescriptor))
+         {
+           iotype = 1;
+         }
+       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) 
+      {
+       InsertInputOutput(mOutputList,*hi);
+      }
+    for (hi=wxbb_defined.begin();hi!=wxbb_defined.end();++hi) 
+      {
+       InsertInputOutput(mOutputList,*hi);
+      }
+    for (hi=ubb_defined.begin();hi!=ubb_defined.end();++hi) 
+      {
+       InsertInputOutput(mOutputList,*hi);
+      }
+  }
+  //================================================================
+
+
+  //================================================================
+  void WxGUIBlackBoxInfo::InsertInputOutput(wxListCtrl* l,
+                                           BlackBoxInputOutputDescriptor* d)
+  {
+    wxListItem kNewItem;
+    kNewItem.SetAlign(wxLIST_FORMAT_LEFT);
+    int nID = l->GetItemCount();
+    std::cout << nID << std::endl;
+    kNewItem.SetId(nID);
+    //    kNewItem.SetMask(wxLIST_MASK_DATA);
+    //    kNewItem.SetData(d);  
+    l->InsertItem(kNewItem);
+    l->SetItem(nID, 0, std2wx(d->GetName()) );
+    l->SetItem(nID, 1, std2wx(d->GetTypeName()) );
+    l->SetItem(nID, 2, std2wx(d->GetDescription()) );
+  }
+  //================================================================
+
+  //================================================================
+  WxGUIBlackBoxInfo::~WxGUIBlackBoxInfo()
+  {
+  }
+  //================================================================
+
+
+ enum 
+    {
+      id_f1,
+      id_f2,
+      id_f3,
+      id_f4,
+      id_f5,
+      id_f6
+
+    };
+
+
+  //================================================================
+  WxGUIPackageBrowser2::WxGUIPackageBrowser2( wxWindow *parent,
+                                             WxGUIPackageBrowser2User* user )
+    : wxPanel(parent, -1),
+      mUser(user),
+      mInterpreter(0)
+  {
+
+    wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
+    mBoxList = new WxGUIBlackBoxList(this, LIST_CTRL,
+                                    wxDefaultPosition,
+                                    wxDefaultSize,
+                                    wxLC_REPORT //wxLC_LIST
+                                    | wxSUNKEN_BORDER);
+    mBoxList->SetUser(this);
+    mBoxList->SetBackgroundColour(*wxWHITE);
+    sizer->Add(mBoxList,5,wxGROW);
+
+    mBoxInfo = new WxGUIBlackBoxInfo(this);
+    sizer->Add(mBoxInfo,3,wxGROW);
+
+    
+
+    wxBoxSizer *fsizer = new wxStaticBoxSizer
+      ( new wxStaticBox(this, wxID_ANY, _T("Filters")), wxHORIZONTAL );    
+
+    mPackageFilter = new wxTextCtrl(this,id_f1,_T(""),
+                                   wxDefaultPosition,
+                                   wxDefaultSize,
+                                   wxTE_PROCESS_ENTER);
+    fsizer->Add(mPackageFilter,1,wxGROW);
+    mNameFilter = new wxTextCtrl(this,id_f2,_T(""),
+                                   wxDefaultPosition,
+                                   wxDefaultSize,
+                                   wxTE_PROCESS_ENTER);
+    fsizer->Add(mNameFilter,1,wxGROW);
+    mDescriptionFilter = new wxTextCtrl(this,id_f3,_T(""),
+                                   wxDefaultPosition,
+                                   wxDefaultSize,
+                                   wxTE_PROCESS_ENTER);
+    fsizer->Add(mDescriptionFilter,1,wxGROW);
+    mCategoryFilter = new wxTextCtrl(this,id_f4,_T(""),
+                                   wxDefaultPosition,
+                                   wxDefaultSize,
+                                   wxTE_PROCESS_ENTER);
+    fsizer->Add(mCategoryFilter,1,wxGROW);
+    mInputTypeFilter = new wxTextCtrl(this,id_f4,_T(""),
+                                   wxDefaultPosition,
+                                   wxDefaultSize,
+                                   wxTE_PROCESS_ENTER);
+    fsizer->Add(mInputTypeFilter,1,wxGROW);
+    mOutputTypeFilter = new wxTextCtrl(this,id_f4,_T(""),
+                                   wxDefaultPosition,
+                                   wxDefaultSize,
+                                   wxTE_PROCESS_ENTER);
+    fsizer->Add(mOutputTypeFilter,1,wxGROW);
+
+    
+    sizer->Add(fsizer,1,wxGROW);
+
+    SetSizer(sizer);
+    SetAutoLayout(true);
+    Layout();
+    
+  }
+  //================================================================
+
+  //================================================================
+  void WxGUIPackageBrowser2::OnFilter(wxCommandEvent&)
+  {
+    RebuildList();
+  }
+  //================================================================
+
+  //================================================================
+  // User callback when a box is selected in the list 
+  void WxGUIPackageBrowser2::WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor* d)
+  {
+    mBoxInfo->UpdateInfo(d);
+  }
+  
+  //================================================================
+
+  //================================================================
+  WxGUIPackageBrowser2::~WxGUIPackageBrowser2()
+  {
+    std::cout << "del interpreter" << std::endl;
+    if (mInterpreter) delete mInterpreter;
+    std::cout << "ok" << std::endl;
+  }
+  //================================================================
+
+  //================================================================
+  void WxGUIPackageBrowser2::IncludeAll()
+  {
+    if (!mInterpreter) mInterpreter = new bbtk::Interpreter();
+    mInterpreter->SetCommandLine(true);
+    mInterpreter->InterpretLine("include *");
+
+    Factory* F = mInterpreter->GetExecuter()->GetFactory();
+    BuildFromFactory(F);
+  }
+  //================================================================
+
+  //================================================================
+  void WxGUIPackageBrowser2::BuildFromFactory(Factory* F)
+  {
+    mFactory = F;
+    RebuildList();
+  }  
+  //================================================================
+
+  //================================================================
+  void WxGUIPackageBrowser2::RebuildList()
+  {
+    mBoxList->Hide();
+    mBoxList->ClearAll();    
+    
+    const Factory::PackageMapType& M = mFactory->GetPackageMap();
+    Factory::PackageMapType::const_iterator i;
+    for (i=M.begin();i!=M.end();++i)
+      {
+       Package* P = i->second.mPackage;
+       if (P->GetName() == "user") continue;
+       
+       Package::BlackBoxMapType::iterator j;
+       for (j=P->GetBlackBoxMap().begin();
+            j!=P->GetBlackBoxMap().end();
+            ++j)
+         {
+           //      std::cout << "Insert "<<j->second->GetTypeName()<<std::endl;
+           if (IsVisible(j->second))
+             mBoxList->Insert(j->second);
+         }
+      }
+    mBoxList->Show();
+  }
+  //================================================================
+
+  //================================================================
+  bool WxGUIPackageBrowser2::IsVisible(BlackBoxDescriptor* d)
+  {
+    //    std::cout << "   '" << wx2std(mPackageFilter->GetValue())<<"'"<<std::endl;
+    //    std::cout << "vs '" << d->GetPackage()->GetName() << "'"<<std::endl;
+    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 (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;
+     }
+   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;
+     }
+
+
+    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 )
+    END_EVENT_TABLE()
+  //========================================================================
+
+
+
+  //================================================================
+  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 and sets the parent window of all bbtk windows
+    wxWindow* top = new wxPanel(this,-1);
+    top->Hide();
+    
+    Wx::SetTopWindow(top);
+   
+    SetAutoLayout(true);
+    Layout();
+  }
+  //================================================================
+
+  //================================================================
+  WxGUIPackageBrowser2Window::~WxGUIPackageBrowser2Window()
+  {
+  }
+  //================================================================
+
+} // namespace bbtk
+
+
+#endif //_USE_WXWIDGETS_
diff --git a/kernel/src/bbtkWxGUIPackageBrowser2.h b/kernel/src/bbtkWxGUIPackageBrowser2.h
new file mode 100644 (file)
index 0000000..27745bd
--- /dev/null
@@ -0,0 +1,238 @@
+/*=========================================================================
+                                                                                
+  Program:   bbtk
+  Module:    $RCSfile: bbtkWxGUIPackageBrowser2.h,v $
+  Language:  C++
+  Date:      $Date: 2008/04/04 08:04:05 $
+  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_
+
+       
+#ifndef __bbtkWxGUIPackageBrowser2_h__
+#define __bbtkWxGUIPackageBrowser2_h__
+
+
+#include "bbtkWx.h"
+
+#include "bbtkInterpreter.h"
+
+#include "wx/listctrl.h"
+// not all ports have support for EVT_CONTEXT_MENU yet, don't define
+// USE_CONTEXT_MENU for those which don't
+#if defined(__WXMOTIF__) || defined(__WXPM__) || defined(__WXX11__) || defined(__WXMGL__)
+    #define USE_CONTEXT_MENU 0
+#else
+    #define USE_CONTEXT_MENU 1
+#endif
+
+
+namespace bbtk
+{
+  //================================================================
+  class WxGUIPackageBrowser2;
+  //================================================================
+
+  //================================================================
+  /// Abstract class which defines the callbacks invoked by WxGUIPackageBrowser2
+  class BBTK_EXPORT WxGUIPackageBrowser2User
+  {
+  public:
+    WxGUIPackageBrowser2User() {}
+    ~WxGUIPackageBrowser2User() {}
+    /// Callback invoked when the 'run' button is pressed
+    virtual void WxGUIPackageBrowser2Run() {}
+  };
+  //================================================================
+
+  //================================================================
+  class WxGUIBlackBoxInfo : public wxPanel
+  {
+  public:
+    WxGUIBlackBoxInfo(wxWindow* parent);
+    ~WxGUIBlackBoxInfo();
+
+    void UpdateInfo(BlackBoxDescriptor* descr);
+    void InsertInputOutput(wxListCtrl* l, BlackBoxInputOutputDescriptor* i);
+  private:
+    BlackBoxDescriptor* mDescriptor;
+    wxStaticText* mName;
+    wxStaticText* mDescription;
+    wxStaticText* mAuthor;
+    wxStaticText* mCategory;
+      
+    wxListCtrl* mInputList;
+    wxListCtrl* mOutputList;
+  } ;
+  //================================================================
+  
+  //================================================================
+  class WxGUIBlackBoxListUser
+  {
+  public:
+    WxGUIBlackBoxListUser() {}
+    virtual ~WxGUIBlackBoxListUser() {}
+    
+    // User callback when a box is selected in the list 
+    virtual void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor* ) {}
+  };
+  //================================================================
+
+  //================================================================
+  class WxGUIBlackBoxList: public wxListCtrl
+  {
+  public:
+    WxGUIBlackBoxList(wxWindow *parent,
+                  const wxWindowID id,
+                  const wxPoint& pos,
+                  const wxSize& size,
+                  long style);
+
+    // Set the user of the object
+    void SetUser(WxGUIBlackBoxListUser* u) { mUser = u; }
+
+    // add one item to the listctrl in report mode
+    void Insert(BlackBoxDescriptor* d);
+    
+    // 
+    void OnColClick(wxListEvent& event);
+    void OnColRightClick(wxListEvent& event);
+    void OnColBeginDrag(wxListEvent& event);
+    void OnColDragging(wxListEvent& event);
+    void OnColEndDrag(wxListEvent& event);
+    void OnBeginDrag(wxListEvent& event);
+    void OnBeginRDrag(wxListEvent& event);
+    void OnBeginLabelEdit(wxListEvent& event);
+    void OnEndLabelEdit(wxListEvent& event);
+    void OnDeleteItem(wxListEvent& event);
+    void OnDeleteAllItems(wxListEvent& event);
+#if WXWIN_COMPATIBILITY_2_4
+    void OnGetInfo(wxListEvent& event);
+    void OnSetInfo(wxListEvent& event);
+#endif
+    void OnSelected(wxListEvent& event);
+    void OnDeselected(wxListEvent& event);
+    void OnListKeyDown(wxListEvent& event);
+    void OnActivated(wxListEvent& event);
+    void OnFocused(wxListEvent& event);
+    void OnCacheHint(wxListEvent& event);
+
+    void OnChar(wxKeyEvent& event);
+
+#if USE_CONTEXT_MENU
+    void OnContextMenu(wxContextMenuEvent& event);
+#endif
+
+    void OnRightClick(wxMouseEvent& event);
+
+private:
+    void ShowContextMenu(const wxPoint& pos);
+    //    wxLog *m_logOld;
+    void SetColumnImage(int col, int image);
+
+    void LogEvent(const wxListEvent& event, const wxChar *eventName);
+    void LogColEvent(const wxListEvent& event, const wxChar *eventName);
+
+    virtual wxString OnGetItemText(long item, long column) const;
+    virtual int OnGetItemColumnImage(long item, long column) const;
+    virtual wxListItemAttr *OnGetItemAttr(long item) const;
+    
+    WxGUIBlackBoxListUser* mUser;
+
+    wxListItemAttr m_attr;
+
+    //    DECLARE_NO_COPY_CLASS(WxGUIBlackBoxListCtrl)
+    DECLARE_EVENT_TABLE()
+};
+  //================================================================
+
+  //================================================================
+  /// A package browser panel
+  class BBTK_EXPORT WxGUIPackageBrowser2 : public wxPanel,
+                                          public WxGUIBlackBoxListUser
+  {
+  public:
+    WxGUIPackageBrowser2( wxWindow *parent, 
+                        WxGUIPackageBrowser2User* user = 0 );
+    ~WxGUIPackageBrowser2();
+
+    void IncludeAll();
+    void BuildFromFactory(Factory* f);
+    void RebuildList();
+    bool IsVisible(BlackBoxDescriptor* d);
+
+    void OnFilter(wxCommandEvent&);
+    // User callback when a box is selected in the list 
+    void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor* );
+
+  private:
+    WxGUIPackageBrowser2User* mUser;
+    Interpreter* mInterpreter;
+    Factory* mFactory;
+    WxGUIBlackBoxList* mBoxList;
+    WxGUIBlackBoxInfo* mBoxInfo;
+
+    wxTextCtrl* mPackageFilter;
+    wxTextCtrl* mNameFilter;
+    wxTextCtrl* mDescriptionFilter;
+    wxTextCtrl* mCategoryFilter;
+    wxTextCtrl* mInputTypeFilter;
+    wxTextCtrl* mOutputTypeFilter;
+
+   DECLARE_EVENT_TABLE()  
+  };
+  //================================================================
+
+  
+  //================================================================
+  /// Browser2 in a frame 
+  class BBTK_EXPORT WxGUIPackageBrowser2Window : public wxFrame
+                                             //, public WxGUICommandUser
+  {
+  public:
+    WxGUIPackageBrowser2Window( wxWindow *parent, wxString title, wxSize size);
+    ~WxGUIPackageBrowser2Window();
+    //    void Open(const std::string& filename) { mBrowser2->Open(filename); }
+    //    void WxGUICommandEnter(const std::string& s);
+
+
+  private :
+    
+    WxGUIPackageBrowser2* mBrowser;
+  };
+   //================================================================
+
+} // namespace bbtk
+
+
+#endif // __bbtkWxGUIPackageBrowser_h__
+
+#endif //_USE_WXWIDGETS_
index cec220f89f954cdf855135a6f37e355bfe68b697..b489c32c0119dad0cd5f937d7908c851356a4bfa 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxGUITextEditor.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/03/26 15:04:46 $
-  Version:   $Revision: 1.7 $
+  Date:      $Date: 2008/04/04 08:04:05 $
+  Version:   $Revision: 1.8 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -36,6 +36,7 @@
 #include "bbtkWxGUITextEditor.h"
 #include "bbtkWxBlackBox.h"
 #include "bbtkConfigurationFile.h"
+#include "bbtkUtilities.h"
 
 #include "icons/cc_new.xpm"
 #include "icons/cc_open.xpm"
@@ -329,7 +330,8 @@ namespace bbtk
        page->Load(name);
       }
     page->SetPageName(name);
-    mwxNotebook->AddPage(page,std2wx(name),true);
+    std::string fname = Utilities::get_file_name(name);
+    mwxNotebook->AddPage(page,std2wx(fname),true);
     FocusOnCurrentPage();
   }
   //================================================================