+ void WxTreeView::OnPopupFilter(wxCommandEvent& event)
+ {
+ wxBusyCursor busy;
+ GimmickDebugMessage(7,
+ "WxTreeView::OnEndLabelEdit"
+ <<std::endl);
+ unsigned int level = 0;
+ for (level = 0; level<mLevelList.size(); ++level)
+ {
+ if ( GetCtrl(level) == senderCtrl ) break;
+ }
+ std::string filter = crea::wx2std(wxGetTextFromUser(_T("Enter the filter to apply"), _T("Filter On Column")));
+
+ std::string att;
+
+ long it = -1;
+ UpdateLevel(level+1);
+
+ std::vector<long> items;
+ bool in=false;
+ int del=0;
+ for ( ;; )
+ {
+ it = GetCtrl(level)->GetNextItem(it,
+ wxLIST_NEXT_ALL);
+ if ( it == -1 )
+ break;
+
+ long adr = GetCtrl(level)->GetItemData(it);
+ tree::Node* nod = ((ItemData*)adr)->node;
+ att=(*nod).GetAttribute(mLevelList[level].key[mColumnSelected]);
+
+
+ if(att.find(filter)>900)
+ {
+
+ if(!in)
+ {
+ in=true;
+ }
+ else
+ {
+ del+=1;
+ }
+
+ items.push_back(it-del);
+ }
+
+ }
+ std::vector<long>::iterator iter;
+ for(iter=items.begin();iter!=items.end();++iter)
+ {
+ GetCtrl(level)->DeleteItem(*iter);
+ }
+ GetGimmickView()->ClearSelection();
+ }
+ //================================================================
+
+ //================================================================
+ void WxTreeView::OnPopupSort(wxCommandEvent& event)
+ {
+ wxBusyCursor busy;
+ unsigned int level = 0;
+ for (level = 0; level<mLevelList.size(); ++level)
+ {
+ if ( GetCtrl(level) == senderCtrl ) break;
+ }
+ mLevelList[level].SortColumn = mColumnSelected;
+
+ if(event.GetId()==mAscendingID)
+ {
+ mLevelList[level].SortAscending = true;
+ }
+ else if(event.GetId()==mDescendingID)
+ {
+ mLevelList[level].SortAscending = false;
+ }
+
+ SortLevel(level);
+ }
+ //================================================================
+
+ //================================================================
+ void WxTreeView::OnLocalCopy(wxCommandEvent& event)
+ {
+ wxBusyCursor busy;
+
+ unsigned int tempLevel = mLastLevel;
+ mLastLevel+=1;
+ const std::vector<tree::Node*>& sel=GetSelected(mLastLevel+1);
+
+ if(sel.size() != 0)
+ {
+ bool copy=false;
+ std::stringstream out;
+ std::string levelName=GetTreeHandler()->GetTree().GetLevelDescriptor(mLastLevel).GetName();
+ out<<"Copy ";
+ out<<sel.size();
+ if(sel.size()>1&&levelName.at(levelName.size()-1)!='s')
+ {
+ out<<" "<<levelName;
+ out<<"s to .gimmick?";
+ }
+ else
+ {
+ out<<" "<<GetTreeHandler()->GetTree().GetLevelDescriptor(mLastLevel).GetName()<<" to .gimmick?";
+ }
+ if (wxMessageBox(crea::std2wx(out.str()),
+ _T("Remove Files"),
+ wxYES_NO,this ) == wxYES)
+ {
+ copy = true;
+ }
+ if(copy)
+ {
+ std::vector<std::string> s;
+ GetFilenamesAsString(sel,s);
+ GetGimmickView()->CopyFiles(s);
+ }
+ }
+ else
+ {
+ mLastLevel = tempLevel;
+ }
+
+
+ }
+ //================================================================
+
+ //================================================================
+ void WxTreeView::SortLevel(int level)
+ {
+ GimmickDebugMessage(1,
+ "WxTreeView::SortLevel("
+ <<level<<")"
+ <<std::endl);
+ //Obtain the column name and the level that needs to be organized
+
+ // int l = level - 1;
+ //Sets the data for the items to be sorted
+ // std::string att;
+ unsigned int ty=0;
+ int nbselected = 0;
+ int n = GetCtrl(level)->GetItemCount();
+ for (int i = 0; i < n; i++)
+ {
+
+ //Gets current item data
+ ItemData* data = (ItemData*)GetCtrl(level)->GetItemData(i);
+
+ //Extracts the node and the type of attribute
+ tree::Node* nod = data->node;
+ if(i==0)
+ {
+ (*nod).GetAttributeDescriptor
+ (mLevelList[level].key[mLevelList[level].SortColumn])
+ .DecodeType( ty );
+ }
+ //Obtains the organizing attribute
+ data->attr = & (*nod).GetAttribute
+ (mLevelList[level].key[mLevelList[level].SortColumn]);
+ //Selected ?
+ data->selected = false;
+ if (GetCtrl(level)->GetItemState(i,wxLIST_STATE_SELECTED)>0)
+ {
+ data->selected = true;
+ nbselected++;
+ }
+
+ }
+ GimmickDebugMessage(1,
+ "WxTreeView::OnSort : "
+ <<nbselected<<" selected before sorting"
+ <<std::endl);
+
+ mIgnoreSelectedChanged = true;
+ //
+ if (mLevelList[level].SortAscending)
+ {
+
+ if(ty==1)
+ {
+ GetCtrl(level)->SortItems(CompareFunctionInts, 0);
+ }
+ else
+ {
+ GetCtrl(level)->SortItems(CompareFunctionStrings, 0);
+ }
+
+ }
+ else
+ {
+ if(ty==1)
+ {
+ GetCtrl(level)->SortItems(CompareFunctionInts, 1);
+ }
+ else
+ {
+ GetCtrl(level)->SortItems(CompareFunctionStrings, 1);
+ }
+ }
+
+
+ // Reselects the unselected
+ n = GetCtrl(level)->GetItemCount();
+ int after = 0;
+ for (int i = 0; i < n; i++)
+ {
+
+ //Gets current item data
+ ItemData* data = (ItemData*)GetCtrl(level)->GetItemData(i);
+
+ // long item = -1;
+ // for ( ;; )
+ // {
+ // item = GetCtrl(level)->GetNextItem(item,wxLIST_NEXT_ALL);
+ // if ( item == -1 ) break;
+ //Gets current item data
+ // ItemData* data = (ItemData*)GetCtrl(level)->GetItemData(item);
+ // was selected ?
+
+ if (data->selected)
+ {
+ nbselected--;
+ if (nbselected==0)
+ {
+ // if it is the last one we must process the selection
+ mIgnoreSelectedChanged = false;
+ }
+ GetCtrl(level)->SetItemState(i,
+ wxLIST_STATE_SELECTED,
+ wxLIST_MASK_STATE
+ | wxLIST_MASK_TEXT
+ | wxLIST_MASK_IMAGE
+ | wxLIST_MASK_DATA
+ | wxLIST_MASK_WIDTH
+ | wxLIST_MASK_FORMAT);
+ }
+ if (GetCtrl(level)->GetItemState(i,wxLIST_STATE_SELECTED)>0)
+ {
+ after++;
+ }
+
+
+ }
+ mIgnoreSelectedChanged = false;
+ GimmickDebugMessage(1,
+ "WxTreeView::SortLevel : "
+ <<after<<" selected after sorting"
+ <<std::endl);
+
+ }
+ //================================================================
+
+
+ //================================================================
+ void WxTreeView::ValidateSelectedImages(bool isSelection)
+ {
+ GimmickDebugMessage(7,
+ "WxTreeView::ValidateSelectedImages"
+ <<std::endl);
+ const std::vector<tree::Node*>& sel(GetSelected(mLevelList.size()+1));
+ GetGimmickView()->OnSelectionChange(sel,
+ isSelection,(mLastSelected-1),
+ !mIgnoreSelectedChanged);
+
+ }
+ //================================================================
+
+
+ //================================================================
+ void WxTreeView::GetNodes(std::vector<tree::Node*>& nodes, bool direction)
+ {
+ long item = mLastSelected;
+ int level=mLevelList.size()-1;
+ //Gets current item data
+ long adr = GetCtrl(level)->GetItemData(item);
+ //Extracts the node
+ tree::Node* nod = ((ItemData*)adr)->node;
+ for ( ;; )
+ {
+ if(direction)
+ {
+ item = GetCtrl(level)->GetNextItem(item,
+ wxLIST_NEXT_ABOVE);
+ }
+ else
+ {
+ item = GetCtrl(level)->GetNextItem(item,
+ wxLIST_NEXT_BELOW);
+ }
+ if ( item == -1 || item==0 )
+ {
+ break;
+ }
+ if(GetCtrl(level)->GetItemState(item, wxLIST_STATE_SELECTED)==0 )
+ {
+
+ adr = GetCtrl(level)->GetItemData(item);
+ nod = ((ItemData*)adr)->node;
+ nodes.push_back(nod);
+ }
+ }
+
+ }
+ //================================================================
+ //=================================================
+ void WxTreeView::OnKeyDown(wxListEvent &event)
+ {
+ if(event.GetKeyCode() == WXK_DELETE)
+ {
+ wxBusyCursor busy;
+
+ RemoveSelected();
+ GetGimmickView()->ClearSelection();
+ }
+
+ }
+ //================================================================
+
+ //================================================================
+ // Should be in another place : not specific !
+ void WxTreeView::GetSelectedAsString(std::vector<std::string>&s)
+ {
+ int level=mLevelList.size();
+ const std::vector<tree::Node*>& sel=GetSelected(level+1);
+ std::vector<tree::Node*>::const_iterator i;
+
+ for (i=sel.begin(); i!=sel.end(); ++i)
+ {
+ std::string filename=(*i)->GetAttribute("FullFileName");
+ s.push_back(filename);
+ }
+ }
+
+ //================================================================
+ void WxTreeView::GetFilenamesAsString(const std::vector<tree::Node*>& nodes, std::vector<std::string>&s)
+ {
+ std::vector<tree::Node*>::const_iterator i;
+
+ for (i=nodes.begin(); i!=nodes.end(); ++i)
+ {
+ if((*i)->GetLevel()<mLevelList.size())
+ {
+ GetTreeHandler()->LoadChildren(*i,0);
+ GetFilenamesAsString((*i)->GetChildrenList(),s);
+ }
+ else
+ {
+ std::string filename=(*i)->GetAttribute("FullFileName");
+ s.push_back(filename);
+ }
+ }
+ }
+
+ //================================================================
+ void WxTreeView::SetColor(int l, int item)
+ {
+ int colorId=12;
+ GetCtrl(l)->SetItemTextColour(item, wxColourDatabase().Find
+ (crea::std2wx(mColorPalette[colorId])));
+ GetCtrl(l)->SetItemState(item,wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED, wxLIST_STATE_SELECTED); /*
+ int colorId=0;
+ //Setting the color according to the parent
+ if(l==0)
+ {
+ item.SetBackgroundColour
+ (wxColourDatabase().Find
+ (crea::std2wx(mColorPalette[colorId])));
+ mColorMap.insert
+ (NodeColorPair
+ (*j,wxColourDatabase().Find
+ (crea::std2wx(mColorPalette[colorId]))));
+ if(colorId<64)
+ {
+ colorId++;
+ }
+ else
+ {
+ colorId=0;
+ }
+ }
+ else if(l!=mLevelList.size()-1)
+ {
+ item.SetBackgroundColour(mColorMap[*i]);
+ mColorMap.insert(NodeColorPair(*j,mColorMap[*i]));
+ }
+ else
+ {
+ item.SetBackgroundColour(mColorMap[*i]);
+ }*/
+ }
+ //================================================================
+ void WxTreeView::CreateColorPalette()
+ {
+ GimmickDebugMessage(6,"WxTreeView::CreateColorPalette");
+ mColorPalette.push_back("WHITE");
+ mColorPalette.push_back("LIGHT GREY");
+ mColorPalette.push_back("AQUAMARINE");
+ mColorPalette.push_back("MEDIUM FOREST GREEN");
+ mColorPalette.push_back("INDIAN RED");
+ mColorPalette.push_back("KHAKI");
+ mColorPalette.push_back("ORANGE");
+ mColorPalette.push_back("LIGHT BLUE");
+ mColorPalette.push_back("LIGHT STEEL BLUE");
+ mColorPalette.push_back("PINK");
+ mColorPalette.push_back("PLUM");
+ mColorPalette.push_back("PURPLE");
+ mColorPalette.push_back("RED");
+ mColorPalette.push_back("SEA GREEN");
+ mColorPalette.push_back("SIENNA");
+ mColorPalette.push_back("SKY BLUE");
+ mColorPalette.push_back("SLATE BLUE");
+ mColorPalette.push_back("SPRING GREEN");
+ mColorPalette.push_back("TAN");
+ mColorPalette.push_back("THISTLE");
+ mColorPalette.push_back("TURQUOISE");
+ mColorPalette.push_back("VIOLET");
+ mColorPalette.push_back("VIOLET RED");
+ mColorPalette.push_back("WHEAT");
+ mColorPalette.push_back("YELLOW");
+ mColorPalette.push_back("YELLOW GREEN");
+ mColorPalette.push_back("BLUE");
+ mColorPalette.push_back("BLUE VIOLET");
+ mColorPalette.push_back("BROWN");
+ mColorPalette.push_back("CADET BLUE");
+ mColorPalette.push_back("CORAL");
+ mColorPalette.push_back("CORNFLOWER BLUE");
+ mColorPalette.push_back("CYAN");
+ mColorPalette.push_back("DARK GREY");
+ mColorPalette.push_back("DARK GREEN");
+ mColorPalette.push_back("DARK OLIVE GREEN");
+ mColorPalette.push_back("DARK ORCHID");
+ mColorPalette.push_back("DARK SLATE BLUE");
+ mColorPalette.push_back("DARK SLATE GREY");
+ mColorPalette.push_back("DARK TURQUOISE");
+ mColorPalette.push_back("FIREBRICK");
+ mColorPalette.push_back("FOREST GREEN");
+ mColorPalette.push_back("GOLD");
+ mColorPalette.push_back("GOLDENROD");
+ mColorPalette.push_back("GREY");
+ mColorPalette.push_back("GREEN");
+ mColorPalette.push_back("GREEN YELLOW");
+ mColorPalette.push_back("LIME GREEN");
+ mColorPalette.push_back("MAGENTA");
+ mColorPalette.push_back("MAROON");
+ mColorPalette.push_back("MEDIUM AQUAMARINE");
+ mColorPalette.push_back("MEDIUM BLUE");
+ mColorPalette.push_back("MEDIUM GOLDENROD");
+ mColorPalette.push_back("MEDIUM ORCHID");
+ mColorPalette.push_back("MEDIUM SEA GREEN");
+ mColorPalette.push_back("MEDIUM SLATE BLUE");
+ mColorPalette.push_back("MEDIUM SPRING GREEN");
+ mColorPalette.push_back("MEDIUM TURQUOISE");
+ mColorPalette.push_back("MEDIUM VIOLET RED");
+ mColorPalette.push_back("MIDNIGHT BLUE");
+ mColorPalette.push_back("NAVY");
+ mColorPalette.push_back("ORANGE RED");
+ mColorPalette.push_back("ORCHID, PALE GREEN");
+ mColorPalette.push_back("STEEL BLUE");
+ mColorPalette.push_back("BLACK");
+
+
+ }
+ //================================================================
+ BEGIN_EVENT_TABLE(WxTreeView, wxPanel)
+ /*
+ EVT_SIZE(MyFrame::OnSize)
+
+ EVT_MENU(LIST_QUIT, MyFrame::OnQuit)
+ EVT_MENU(LIST_ABOUT, MyFrame::OnAbout)
+ EVT_MENU(LIST_LIST_VIEW, MyFrame::OnListView)
+ EVT_MENU(LIST_REPORT_VIEW, MyFrame::OnReportView)
+ EVT_MENU(LIST_ICON_VIEW, MyFrame::OnIconView)
+ EVT_MENU(LIST_ICON_TEXT_VIEW, MyFrame::OnIconTextView)
+ EVT_MENU(LIST_SMALL_ICON_VIEW, MyFrame::OnSmallIconView)
+ EVT_MENU(LIST_SMALL_ICON_TEXT_VIEW, MyFrame::OnSmallIconTextView)
+ EVT_MENU(LIST_VIRTUAL_VIEW, MyFrame::OnVirtualView)
+ EVT_MENU(LIST_SMALL_VIRTUAL_VIEW, MyFrame::OnSmallVirtualView)
+
+ EVT_MENU(LIST_FOCUS_LAST, MyFrame::OnFocusLast)
+ EVT_MENU(LIST_TOGGLE_FIRST, MyFrame::OnToggleFirstSel)
+ EVT_MENU(LIST_DESELECT_ALL, MyFrame::OnDeselectAll)
+ EVT_MENU(LIST_SELECT_ALL, MyFrame::OnSelectAll)
+ EVT_MENU(LIST_DELETE, MyFrame::OnDelete)
+ EVT_MENU(LIST_ADD, MyFrame::OnAdd)
+ EVT_MENU(LIST_EDIT, MyFrame::OnEdit)
+ EVT_MENU(LIST_DELETE_ALL, MyFrame::OnDeleteAll)
+ EVT_MENU(LIST_SORT, MyFrame::OnSort)
+ EVT_MENU(LIST_SET_FG_COL, MyFrame::OnSetFgColour)
+ EVT_MENU(LIST_SET_BG_COL, MyFrame::OnSetBgColour)
+ EVT_MENU(LIST_TOGGLE_MULTI_SEL, MyFrame::OnToggleMultiSel)
+ EVT_MENU(LIST_SHOW_COL_INFO, MyFrame::OnShowColInfo)
+ EVT_MENU(LIST_SHOW_SEL_INFO, MyFrame::OnShowSelInfo)
+ EVT_MENU(LIST_FREEZE, MyFrame::OnFreeze)
+ EVT_MENU(LIST_THAW, MyFrame::OnThaw)
+ EVT_MENU(LIST_TOGGLE_LINES, MyFrame::OnToggleLines)
+ EVT_MENU(LIST_MAC_USE_GENERIC, MyFrame::OnToggleMacUseGeneric)
+
+ EVT_UPDATE_UI(LIST_SHOW_COL_INFO, MyFrame::OnUpdateShowColInfo)
+ EVT_UPDATE_UI(LIST_TOGGLE_MULTI_SEL, MyFrame::OnUpdateToggleMultiSel)
+END_EVENT_TABLE()
+
+BEGIN_EVENT_TABLE(MyListCtrl, wxListCtrl)
+ EVT_LIST_BEGIN_DRAG(LIST_CTRL, MyListCtrl::OnBeginDrag)
+ EVT_LIST_BEGIN_RDRAG(LIST_CTRL, MyListCtrl::OnBeginRDrag)
+
+ EVT_LIST_BEGIN_LABEL_EDIT(-1, WxTreeView::OnBeginLabelEdit)
+ EVT_LIST_END_LABEL_EDIT(-1, WxTreeView::OnEndLabelEdit)
+
+ EVT_LIST_DELETE_ITEM(LIST_CTRL, MyListCtrl::OnDeleteItem)
+ EVT_LIST_DELETE_ALL_ITEMS(LIST_CTRL, MyListCtrl::OnDeleteAllItems)
+#if WXWIN_COMPATIBILITY_2_4
+ EVT_LIST_GET_INFO(LIST_CTRL, MyListCtrl::OnGetInfo)
+ EVT_LIST_SET_INFO(LIST_CTRL, MyListCtrl::OnSetInfo)
+#endif
+ */
+ 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)
+ EVT_LIST_ITEM_ACTIVATED(LIST_CTRL, MyListCtrl::OnActivated)
+ EVT_LIST_ITEM_FOCUSED(LIST_CTRL, MyListCtrl::OnFocused)
+*/
+ EVT_LIST_COL_RIGHT_CLICK(-1, WxTreeView::OnColClick)
+
+ EVT_LIST_COL_CLICK(-1, WxTreeView::OnColClick)
+
+ //EVT_LEFT_DOWN(WxTreeView::OnMouseClick)
+ /*
+ EVT_LIST_COL_BEGIN_DRAG(LIST_CTRL, MyListCtrl::OnColBeginDrag)
+ EVT_LIST_COL_DRAGGING(LIST_CTRL, MyListCtrl::OnColDragging)
+ EVT_LIST_COL_END_DRAG(LIST_CTRL, MyListCtrl::OnColEndDrag)
+
+ EVT_LIST_CACHE_HINT(LIST_CTRL, MyListCtrl::OnCacheHint)
+
+#if USE_CONTEXT_MENU
+ EVT_CONTEXT_MENU(MyListCtrl::OnContextMenu)
+#endif
+ EVT_CHAR(MyListCtrl::OnChar)
+
+ EVT_RIGHT_DOWN(MyListCtrl::OnRightClick)
+ */
+END_EVENT_TABLE()
+
+} // EO namespace creaImageIO