]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkWxGUIPackageBrowser2.cxx
Clean code
[bbtk.git] / kernel / src / bbtkWxGUIPackageBrowser2.cxx
index 21fc26d2e584a6a39bd9453a682bb83572a31f10..29b5b83819e7f79827322495b23527c5f85a77ef 100644 (file)
@@ -133,7 +133,7 @@ int wxCALLBACK MyCompareFunction(long item1, long item2, long WXUNUSED(sortData)
     EnableContextMenu();
 #endif
   }
-
+  
   void WxGUIBlackBoxList::Insert(BlackBoxDescriptor::Pointer d)
   {
     if (GetColumnCount()!=3)
@@ -170,6 +170,7 @@ int wxCALLBACK MyCompareFunction(long item1, long item2, long WXUNUSED(sortData)
     */
   }
 
+  
 
   void WxGUIBlackBoxList::OnCacheHint(wxListEvent& event)
   {
@@ -260,7 +261,7 @@ int wxCALLBACK MyCompareFunction(long item1, long item2, long WXUNUSED(sortData)
          info.m_itemId = event.m_itemIndex;
          info.m_col = 0;
          info.m_mask = wxLIST_MASK_DATA;
-         wxString sendtext(_T(""));
+      wxString sendtext(_T(""));
          if ( GetItem(info) )
          {
                  // TO DO : STORE SMART PTR ?
@@ -270,16 +271,19 @@ int wxCALLBACK MyCompareFunction(long item1, long item2, long WXUNUSED(sortData)
                      //DFGO -> To identify it is a box
                      sendtext += crea::std2wx("box:");
                      sendtext += crea::std2wx(d->GetFullTypeName());
+                     sendtext += _T("<EndEED>");
+//              printf("EED WxGUIBlackBoxList::OnBeginDrag <%s>%d  <%s>%d\n",  (const char*)sendtext.mb_str(),sendtext.Len() ,  d->GetFullTypeName().c_str() , d->GetFullTypeName().length() );
                  }
-         }
-         else
-         {
+
+      } else {
                  wxFAIL_MSG(wxT("wxListCtrl::GetItem() failed"));
          }
 
          wxTextDataObject tdo(sendtext);
+//      printf("EED WxGUIBlackBoxList::OnBeginDrag <%s>\n",(const char*) tdo.GetText().mb_str() );
+
          wxDropSource tds(tdo, this);
-         tds.DoDragDrop();
+         tds.DoDragDrop( );
 
     //    const wxPoint& pt = event.m_pointDrag;
 
@@ -609,6 +613,7 @@ int wxCALLBACK MyCompareFunction(long item1, long item2, long WXUNUSED(sortData)
   //================================================================
   WxGUIBlackBoxInfo::WxGUIBlackBoxInfo(wxWindow* parent)
     :
+//    wxPanel(parent, -1,wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE),
     wxPanel(parent, -1),
     mDescriptor()
   {
@@ -623,9 +628,7 @@ int wxCALLBACK MyCompareFunction(long item1, long item2, long WXUNUSED(sortData)
     mCategory = new wxStaticText(this,-1,_T(""));
     sizer->Add(mCategory,0,wxGROW);
 
-    wxBoxSizer *inputs =
-      new wxStaticBoxSizer
-      ( new wxStaticBox(this, wxID_ANY, _T("Inputs")), wxVERTICAL );
+    wxBoxSizer *inputs = new wxStaticBoxSizer ( new wxStaticBox(this, wxID_ANY, _T("Inputs")), wxVERTICAL );
     mInputList = new wxListCtrl(this, -1,
                                wxDefaultPosition,
                                wxDefaultSize,
@@ -635,24 +638,35 @@ int wxCALLBACK MyCompareFunction(long item1, long item2, long WXUNUSED(sortData)
     inputs->Add(mInputList,1,wxGROW);
     sizer->Add(inputs,1,wxGROW);
 
-    wxBoxSizer *outputs =
-      new wxStaticBoxSizer
-      ( new wxStaticBox(this, wxID_ANY, _T("Outputs")), wxVERTICAL );
+    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);
+                                | wxBORDER_SUNKEN);
+//                              | wxFULL_REPAINT_ON_RESIZE | wxVSCROLL);
 
     outputs->Add(mOutputList,1,wxGROW);
     sizer->Add(outputs,1,wxGROW);
 
     SetSizer(sizer);
+//     sizer->FitInside(this); 
+       Connect( this->GetId(),   wxEVT_ERASE_BACKGROUND , (wxObjectEventFunction)   (void (WxGUIBlackBoxInfo::*)(wxEvent&))    &WxGUIBlackBoxInfo::OnEraseBackGround ); 
+
+       
     SetAutoLayout(true);
     Layout();
   }
   //================================================================
 
+  
+      void WxGUIBlackBoxInfo::OnEraseBackGround( wxEvent& )
+         {
+               mInputList->ClearBackground();
+               mOutputList->ClearBackground();
+         }
+
+
 
   //================================================================
   void WxGUIBlackBoxInfo::UpdateInfo(BlackBoxDescriptor* descr)
@@ -807,6 +821,17 @@ int wxCALLBACK MyCompareFunction(long item1, long item2, long WXUNUSED(sortData)
       id_fc3
     };
 
+  //================================================================
+  void WxGUIPackageBrowser2::OnEraseBackGround( wxEvent& )
+  {
+       mBoxList->ClearBackground();
+       ClearBackground();
+       Refresh();
+//     Update();
+  }
+  //================================================================
+    
+       
   //================================================================
   WxGUIPackageBrowser2::WxGUIPackageBrowser2( wxWindow *parent,
                                              WxGUIPackageBrowser2User* user )
@@ -824,8 +849,8 @@ int wxCALLBACK MyCompareFunction(long item1, long item2, long WXUNUSED(sortData)
                                     wxLC_REPORT //wxLC_LIST
                                     | wxSUNKEN_BORDER);
     mBoxList->SetUser(this);
-    mBoxList->SetBackgroundColour(*wxWHITE);
 
+       Connect( GetId(),   wxEVT_SIZE , (wxObjectEventFunction)   (void (WxGUIPackageBrowser2::*)(wxEvent&))    &WxGUIPackageBrowser2::OnEraseBackGround ); 
 
 // JGRR & CM DISABLED CLOSE BUTTON
     m_mgr.AddPane(mBoxList,
@@ -961,8 +986,9 @@ int wxCALLBACK MyCompareFunction(long item1, long item2, long WXUNUSED(sortData)
     Layout();
 
   }
-  //================================================================
+  
 
+  //================================================================
        Factory::Pointer WxGUIPackageBrowser2::GetFactory()
   {
     return mFactory;
@@ -1040,9 +1066,9 @@ int wxCALLBACK MyCompareFunction(long item1, long item2, long WXUNUSED(sortData)
   //================================================================
   void WxGUIPackageBrowser2::RebuildList()
   {
-    mBoxList->Hide();
+//    mBoxList->Hide();
     mBoxList->ClearAll();
-
+    mBoxList->ClearBackground();
     const Factory::PackageMapType& M = mFactory->GetPackageMap();
     Factory::PackageMapType::const_iterator i;
     for (i=M.begin();i!=M.end();++i)
@@ -1073,8 +1099,8 @@ int wxCALLBACK MyCompareFunction(long item1, long item2, long WXUNUSED(sortData)
 
     bool ok=false;
     int i,size;
-    std::string strAA=strA;
-    std::string strBB=strB;
+    std::string strAA = strA;
+    std::string strBB = strB;
 
 
     size=strAA.length();
@@ -1255,6 +1281,15 @@ int wxCALLBACK MyCompareFunction(long item1, long item2, long WXUNUSED(sortData)
   }
   //========================================================================
 
+
+std::string WxGUIPackageBrowser2::GetNameFilter()
+{
+    std::string s = wx2std( mNameFilter->GetValue() );
+    return s;
+}
+
+
+
   //========================================================================
   BEGIN_EVENT_TABLE(WxGUIPackageBrowser2, wxPanel)
 //EED    EVT_TEXT_ENTER(id_f1, WxGUIPackageBrowser2::OnFilter )
@@ -1316,6 +1351,7 @@ int wxCALLBACK MyCompareFunction(long item1, long item2, long WXUNUSED(sortData)
   }
   //================================================================
 
+
 } // namespace bbtk