]> Creatis software - creaImageIO.git/commitdiff
Added a List Item Menu
authorFrederic Cervenansky <Frederic.Cervenansky@creatis.insa-lyon.fr>
Thu, 30 Apr 2009 10:04:24 +0000 (10:04 +0000)
committerFrederic Cervenansky <Frederic.Cervenansky@creatis.insa-lyon.fr>
Thu, 30 Apr 2009 10:04:24 +0000 (10:04 +0000)
src2/creaImageIOWxTreeView.cpp
src2/creaImageIOWxTreeView.h

index 867a192275db6d2f713088267e1e911ba9e02686..0f2363227ffda5ecaa3f036c153a7045f4f05a7d 100644 (file)
@@ -209,6 +209,7 @@ namespace creaImageIO
     
 #if wxUSE_MENUS
 
+        // Column Menu
     menu =new wxMenu;
        wxMenuItem* m1=menu->Append(wxID_ANY, _T("&Sort ascending"));
        wxMenuItem* m2=menu->Append(wxID_ANY, _T("&Sort descending"));
@@ -219,6 +220,19 @@ namespace creaImageIO
        Connect( mAscendingID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnPopupSort) );
        Connect( mDescendingID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnPopupSort) );
        Connect( mFilterID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnPopupFilter) );
+
+
+
+       //ItemMenu
+       menuItem =new wxMenu;
+       wxMenuItem* m1Item=menuItem->Append(wxID_ANY, _T("&Anonymize"));
+       wxMenuItem* m2Item=menuItem->Append(wxID_ANY, _T("&Local Copy"));
+       
+       mAnonymizingID=m1Item->GetId();
+       mLocalCopyID=m2Item->GetId();
+       //Connect( mAnonymizingID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnAnonymize) );
+       //Connect( mLocalCopyID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnLocalCopy) );
+       
        
 #endif // wxUSE_MENUS
 
@@ -662,7 +676,22 @@ namespace creaImageIO
     PopupMenu(menu, clientpt);
     
   }
+
+  void WxTreeView::OnItemMenu(wxListEvent &event)
+  {
+        wxPoint clientpt;
+    clientpt.x = wxGetMousePosition().x - this->GetScreenPosition().x;
+    clientpt.y = wxGetMousePosition().y - this->GetScreenPosition().y;
+    senderCtrl = event.GetEventObject(); 
+    unsigned int level = 0;
+    for (level = 0; level<mLevelList.size(); ++level)
+      {
+               if ( GetCtrl(level) == senderCtrl ) break;
+      }
+    PopupMenu(menuItem, clientpt);
     
+  }
+  
   //================================================================
   //================================================================
 
@@ -1117,7 +1146,7 @@ BEGIN_EVENT_TABLE(MyListCtrl, wxListCtrl)
   */
     EVT_LIST_KEY_DOWN(-1, WxTreeView::OnKeyDown)
     EVT_LIST_ITEM_SELECTED(-1, WxTreeView::OnItemSelected)
-  
+       EVT_LIST_ITEM_RIGHT_CLICK(-1, WxTreeView::OnItemMenu)
     EVT_LIST_ITEM_DESELECTED(-1, WxTreeView::OnItemDeSelected)
        /*
     EVT_LIST_KEY_DOWN(LIST_CTRL, MyListCtrl::OnListKeyDown)
index c8697b6a70ec9c12cfcd419f544ca996133d6f93..c941606768f05410e18eda9417c9ef6b36595402 100644 (file)
@@ -56,6 +56,9 @@ namespace creaImageIO
       
       ///Callback on mouse click
       void OnMouseClick(wxMouseEvent& event);
+
+         // Display a menu for items
+         void OnItemMenu(wxListEvent &event);
       
       /// Actual processing of item selection/deselection 
       /// Called by OnItemSelected and OnItemDeSelected
@@ -131,12 +134,16 @@ namespace creaImageIO
       std::vector<std::string> mColorPalette;
 
       wxMenu* menu;
+         
       wxObject* senderCtrl;
       int mAscendingID;
       int mDescendingID;
       int mFilterID;
       unsigned int mLastLevel;
       
+         wxMenu* menuItem;
+         int mAnonymizingID;
+         int mLocalCopyID;
       // If set to true then OnSelectedChanged returns immediately.
       // Used to do avoid useless process during multiple selections 
       // or sorting