+//================================================================
+ void WxTreeView::OnColClick(wxListEvent& event)
+ {
+ //Obtain the column name and the level that needs to be organized
+ mColumnSelected=event.m_col;
+ GimmickMessage(1,
+ " Column " <<event.m_col
+ <<std::endl);
+
+
+ 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);
+ }
+
+ //int ty=GetAttributeDescriptor(mLevelList[level].key[mColumnSelected-1]).GetType();
+ 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;
+ }