#include <creaImageIOWxTreeView.h>
#include <creaImageIOSystem.h>
#include <wx/splitter.h>
-int wxCALLBACK MyCompareFunction(long item1, long item2, long sortData)
+int wxCALLBACK CompareFunctionStrings(long item1, long item2, long sortData)
{
std::string s1((char*)((long*)item1)[1]);
std::string s2((char*)((long*)item2)[1]);
}
+int wxCALLBACK CompareFunctionInts(long item1, long item2, long sortData)
+{
+ int val1=atoi((char*)((long*)item1)[1]);
+ int val2=atoi((char*)((long*)item2)[1]);
+ GimmickMessage(1,
+ " Check: STRING 1: "
+ <<val1
+ <<" STRING 2: "
+ <<val2
+ <<std::endl);
+ if(sortData==1)
+ {
+ // inverse the order
+ if (val1 < val2)
+ return 1;
+ if (val1 > val2)
+ return -1;
+
+ return 0;
+ }
+ else
+ {
+ if (val1 < val2)
+ return -1;
+ if (val1 > val2)
+ return 1;
+
+ return 0;
+
+ }
+
+}
+
namespace creaImageIO
{
//=====================================================================
//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
+
+ //Gets current item data
long adr = GetCtrl(level)->GetItemData(i);
- //Extracts the node
+ //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]);
- int ty=(*nod).GetAttributeDescriptor(mLevelList[level].key[mColumnSelected-1]).GetType();
- GimmickMessage(1,"Type:"<<ty<<std::endl);
+
char* d= new char [att.size()+1];
strcpy (d, att.c_str());
//Sets it as the data
GetCtrl(level)->SetItemData(i,(long)lp);
}
-
+
+ //int ty=GetAttributeDescriptor(mLevelList[level].key[mColumnSelected-1]).GetType();
if(mDirection)
{
- GetCtrl(level)->SortItems(MyCompareFunction, 0);
+ if(ty==1)
+ {
+ GetCtrl(level)->SortItems(CompareFunctionInts, 0);
+ }
+ else
+ {
+ GetCtrl(level)->SortItems(CompareFunctionStrings, 0);
+ }
+
mDirection=false;
}
else
{
- GetCtrl(level)->SortItems(MyCompareFunction, 1);
- mDirection=true;
+ if(ty==1)
+ {
+ GetCtrl(level)->SortItems(CompareFunctionInts, 1);
+ }
+ else
+ {
+ GetCtrl(level)->SortItems(CompareFunctionStrings, 1);
+ }
+ mDirection=true;
}
//Resets original data