+
+ if (level<mLevelList.size()) UpdateLevel(level+1);
+ }
+ //=====================================================================
+
+
+ //================================================================
+ void WxTreeView::OnSelectedChanged(wxListEvent& event)
+ {
+ GimmickDebugMessage(1,
+ GetTreeHandler()->GetTree().GetLabel()
+ <<" view : item selected "
+ <<std::endl);
+
+ wxListItem info;
+ info.m_itemId = event.m_itemIndex;
+ mLastSelected=event.m_itemIndex;
+
+ // retrieve the level
+ wxObject* obj = event.GetEventObject();
+ unsigned int level = 0;
+ for (level = 0; level<mLevelList.size(); ++level)
+ {
+ if ( GetCtrl(level) == obj ) break;
+ }
+ GimmickDebugMessage(1,
+ " Level "<<level+1
+ <<std::endl);
+ if (level<mLevelList.size()-1) UpdateLevel( level + 2 );
+ if (level==mLevelList.size()-1) ValidateSelectedImages ();
+
+ }
+ //================================================================
+
+//================================================================
+ void WxTreeView::OnColClick(wxListEvent& event)
+ {
+ //Obtain the column name and the level that needs to be organized
+ mColumnSelected=event.m_col;
+ GimmickDebugMessage(1,
+ " Column selected: " <<event.m_col
+ <<std::endl);
+
+ if(mColumnSelected!=0)
+ {
+ wxObject* ctrl = event.GetEventObject();
+ unsigned int level = 0;
+ for (level = 0; level<mLevelList.size(); ++level)
+ {
+ if ( GetCtrl(level) == ctrl ) break;
+ }
+ UpdateLevel(level+1);
+ wxBusyCursor busy;
+
+ int l = level - 1;
+
+ //Sets the data for the items to be sorted
+ std::string att;
+ unsigned int ty=0;
+ int n = GetCtrl(level)->GetItemCount();
+ for (int i = 0; i < n; i++)
+ {
+
+ //Gets current item data
+ long adr = GetCtrl(level)->GetItemData(i);
+ //Extracts the node and the type of attribute
+ tree::Node* nod = ((ItemData*)adr)->node;
+ if(i==0)
+ {
+ (*nod).GetAttributeDescriptor(mLevelList[level].key[mColumnSelected-1]).DecodeType(ty);
+ }
+ //Obtains the organizing attribute
+ att=(*nod).GetAttribute(mLevelList[level].key[mColumnSelected-1]);
+
+ char* d= new char [att.size()+1];
+ strcpy (d, att.c_str());
+
+ //Creates array
+ long* lp= new long[2];
+ lp[0]=adr;
+ lp[1]=(long)d;
+
+ //Sets it as the data
+ GetCtrl(level)->SetItemData(i,(long)lp);
+ }
+
+ if(mDirection)
+ {
+ if(ty==1)
+ {
+ GetCtrl(level)->SortItems(CompareFunctionInts, 0);
+ }
+ else
+ {
+ GetCtrl(level)->SortItems(CompareFunctionStrings, 0);
+ }
+
+ mDirection=false;
+ }
+ else
+ {
+ if(ty==1)
+ {
+ GetCtrl(level)->SortItems(CompareFunctionInts, 1);
+ }
+ else
+ {
+ GetCtrl(level)->SortItems(CompareFunctionStrings, 1);
+ }
+ mDirection=true;
+ }
+
+ //Resets original data
+
+ long it = -1;
+ for ( ;; )
+ {
+ it = GetCtrl(level)->GetNextItem(it,
+ wxLIST_NEXT_ALL);
+ if ( it == -1 )
+ break;
+ //Gets current item data, extracts the node and resets it
+ long item = GetCtrl(level)->GetItemData(it);
+ GetCtrl(level)->SetItemData(it,((long*)item)[0]);
+
+ }
+ }
+
+ }
+ //================================================================
+
+
+ //================================================================
+ void WxTreeView::ValidateSelectedImages()
+ {
+ GimmickDebugMessage(7,
+ "WxTreeView::ValidateSelectedImages"
+ <<std::endl);
+ std::vector<tree::Node*> sel(GetSelected(mLevelList.size()+1));
+ GetGimmickView()->OnSelectionChange(sel);
+ /*
+ //Send an event telling wether the selection is valid or not
+ wxCommandEvent event( 0, GetId() );
+ event.SetEventObject( this );
+ std::vector<tree::Node*> sel=GetSelected((mLevelList.size()+1));
+ event.SetClientData(&sel);
+ GetEventHandler()->ProcessEvent( event );
+ */
+ //
+ }
+ //================================================================
+
+
+ //================================================================
+ 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 )
+ {
+ 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::GetSelectedAsString(std::vector<std::string>&s)
+ {
+ int level=mLevelList.size();
+ std::vector<tree::Node*> sel=GetSelected(level+1);
+ std::vector<tree::Node*>::iterator i;
+
+ for (i=sel.begin(); i!=sel.end(); ++i)
+ {
+ std::string filename=(*i)->GetAttribute("FullFileName");
+ s.push_back(filename);
+ }
+ }
+ //================================================================
+ 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(LIST_CTRL, MyListCtrl::OnBeginLabelEdit)
+ EVT_LIST_END_LABEL_EDIT(LIST_CTRL, MyListCtrl::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_ITEM_SELECTED(-1, WxTreeView::OnSelectedChanged)
+
+ EVT_LIST_ITEM_DESELECTED(-1, WxTreeView::OnSelectedChanged)
+ /*
+ 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(LIST_CTRL, MyListCtrl::OnColRightClick)
+ */
+ EVT_LIST_COL_CLICK(-1, WxTreeView::OnColClick)
+ /*
+ 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