//=====================================================================
const std::vector<tree::Node*>& WxTreeView::GetSelected(int level)
{
+printf("EED WxTreeView::GetSelected Start\n");
+
std::vector<tree::Node*>& sel = mLevelList[0].Selected;
// if (GetSelectedUpToDate(level))
int l = level - 1;
// the selection of upper level
+printf("EED WxTreeView::GetSelected 1\n");
if(mLevelList.size() == level -1)
- sel = mLevelList.back().Selected;
- else
- sel= mLevelList[l].Selected;
+ {
+ sel = mLevelList.back().Selected;
+ } else {
+ sel= mLevelList[l].Selected;
+ }
+printf("EED WxTreeView::GetSelected 2\n");
if (sel.size() > 0)
{
sel.clear();
}
- if (level == 1)
- {
- sel.push_back(GetTreeHandler()->GetTree().GetTree());
- }
- else if (level < mLevelList.size()+2 )
+printf("EED WxTreeView::GetSelected 3\n");
+ if (level == 1)
{
+printf("EED WxTreeView::GetSelected 4\n");
+ sel.push_back(GetTreeHandler()->GetTree().GetTree());
+ } else if (level < mLevelList.size()+2 )
+ {
+printf("EED WxTreeView::GetSelected 5\n");
long item = -1;
for ( ;; )
{
+printf("EED WxTreeView::GetSelected 5.1\n");
item = GetCtrl(l-1)->GetNextItem(item,
wxLIST_NEXT_ALL,
wxLIST_STATE_SELECTED);
+printf("EED WxTreeView::GetSelected 5.2\n");
if ( item == -1 )
+ {
+printf("EED WxTreeView::GetSelected 5.3\n");
break;
+ }
long adr = (long)GetCtrl(l-1)->GetItemData(item);
+printf("EED WxTreeView::GetSelected 5.4\n");
tree::Node* n = ((ItemData*)adr)->node;
/* FCY 18-04-2011: don't understand the real purpose of these lines,
if uncomment add last frame in first place
it = sel.insert ( it , n );
}
else
- {*/
-
+ {*/
+printf("EED WxTreeView::GetSelected 6\n");
sel.push_back(n);
//}
- }
+ } // for
/*int n = GetCtrl(l-1)->GetItemCount();
for (int i = 0; i<n; i++)
{
}
}
}*/
- }
- else
- {
+ } else {
// NOTHING
}
// return mLevelList[level-1].Selected;
+printf("EED WxTreeView::GetSelected End\n");
return sel;
}
}
if(needRefresh && mLastLevel>1)
- {
- UpdateLevel(mLastLevel-2);
- }
- else if(mLastLevel>1)
- {
- UpdateLevel(mLastLevel-1);
- }
- else
- {
- UpdateLevel(mLastLevel);
- }
- }
- }
- else
- {
+ {
+ UpdateLevel(mLastLevel-2);
+ } else if(mLastLevel>1) {
+ UpdateLevel(mLastLevel-1);
+ } else {
+ UpdateLevel(mLastLevel);
+ } // if needRefresh
+ } // if erase
+ } else {
// no need to incremente level
mLastLevel = tempLevel;
}
/// Updates a level of the view (adds or removes children, etc.)
void WxTreeView::UpdateLevel( int level )
{
- GimmickDebugMessage(1,
+printf("EED WxTreeView::UpdateLevel Start\n ");
+ GimmickDebugMessage(1,
GetTreeHandler()->GetTree().GetLabel()
<<"WxTreeView::UpdateLevel(level "
<<level
<<std::endl);
wxBusyCursor busy;
+printf("EED WxTreeView::UpdateLevel 1\n ");
RecursiveUpdateLevel(level);
+printf("EED WxTreeView::UpdateLevel 2\n ");
int i;
for (i=0; i<level-1; i++)
- {
- if (!GetSplitter(i)->IsSplit())
- GetSplitter(i)->SplitVertically( GetCtrl(i), GetSplitter(i+1),
- 100 );
- }
- if (GetSplitter(i)->IsSplit()) GetSplitter(i)->Unsplit();
+ {
+printf("EED WxTreeView::UpdateLevel 3\n ");
+ if (!GetSplitter(i)->IsSplit())
+ {
+printf("EED WxTreeView::UpdateLevel 4\n ");
+ GetSplitter(i)->SplitVertically( GetCtrl(i), GetSplitter(i+1),100 );
+ } // if
+ } // for
+printf("EED WxTreeView::UpdateLevel 5\n ");
+ if (GetSplitter(i)->IsSplit())
+ {
+printf("EED WxTreeView::UpdateLevel 6\n ");
+ GetSplitter(i)->Unsplit();
+ }
+printf("EED WxTreeView::UpdateLevel End\n ");
}
//=====================================================================
/// Recursive method called upon by UpdateLevel to refresh all windows
void WxTreeView::RecursiveUpdateLevel( int level )
{
+printf("EED WxTreeView::RecursiveUpdateLevel Start\n");
GimmickDebugMessage(1,
GetTreeHandler()->GetTree().GetLabel()
<<"WxTreeView::RecursiveUpdateLevel(level "
<<level
<<")"<<std::endl);
+printf("EED WxTreeView::RecursiveUpdateLevel 0.1\n");
const std::vector<tree::Node*>& sel(GetSelected(level));
+printf("EED WxTreeView::RecursiveUpdateLevel 0.2\n");
int l = level - 1;
+printf("EED WxTreeView::RecursiveUpdateLevel 0.3\n");
// to speed up inserting we hide the control temporarily
GetCtrl(l)->Hide();
+printf("EED WxTreeView::RecursiveUpdateLevel 0.4\n");
GetCtrl(l)->DeleteAllItems();
+printf("EED WxTreeView::RecursiveUpdateLevel 0.5\n");
std::vector<tree::Node*>::const_iterator i;
+printf("EED WxTreeView::RecursiveUpdateLevel 1\n");
for (i=sel.begin(); i!=sel.end(); ++i)
- {
+ {
+printf("EED WxTreeView::RecursiveUpdateLevel 2\n");
GimmickDebugMessage(1,
"adding children of '"
<<(*i)->GetLabel()
j!= (*i)->GetChildrenList().rend();
++j)
{
+printf("EED WxTreeView::RecursiveUpdateLevel 3\n");
GimmickDebugMessage(1,
"adding children "
<<(*j)->GetLabel()
if(k==0 && level <3)
{
val = (*j)->GetAttribute("NumberOfChildren");
- }
- else
+ } else {
val = (*j)->GetAttribute(mLevelList[l].key[k]);
+ }
+printf("EED WxTreeView::RecursiveUpdateLevel 4\n");
if(((*j)->GetAttributeDescriptor(mLevelList[l].key[k])).isDateEntry()) // Date
{
// std::cout << "["<<val<< "]" << std::endl;
val = valtmp;
}
// std::cout << "["<<val<< "]" << std::endl;
- }
- else if(((*j)->GetAttributeDescriptor(mLevelList[l].key[k])).isTimeEntry()) // Time
+ } else if(((*j)->GetAttributeDescriptor(mLevelList[l].key[k])).isTimeEntry()) // Time
{
if ((val.size()>6) &&
(val != "" || val != " "))
val = val.substr(0,2) + " : "
+ val.substr(2,2) + " : "
+ val.substr(4,2);
- }
- else
- {
+ } else {
if (val.size()==0) val = "?";
}
+printf("EED WxTreeView::RecursiveUpdateLevel 5\n");
if (val.size()==0) val = "X";
item.SetText( crea::std2wx(val));
item.SetColumn(k);
}
}
+printf("EED WxTreeView::RecursiveUpdateLevel 6\n");
SortLevel(l);
+printf("EED WxTreeView::RecursiveUpdateLevel 7\n");
GetCtrl(l)->Show();
+printf("EED WxTreeView::RecursiveUpdateLevel End\n");
}
//=====================================================================
//================================================================
void WxTreeView::OnItemSelected(wxListEvent& event)
{
-
- GimmickDebugMessage(1,
- GetTreeHandler()->GetTree().GetLabel()
- <<" WxTreeView::OnItemSelected"<<std::endl);
+printf("EED WxTreeView::OnItemSelected Start\n");
+ GimmickDebugMessage(1,GetTreeHandler()->GetTree().GetLabel()<<" WxTreeView::OnItemSelected"<<std::endl);
if (mIgnoreSelectedChanged)
- {
- GimmickDebugMessage(1,
- " mIgnoreSelectedChanged true: returning"
- <<std::endl);
- return;
- }
+ {
+ GimmickDebugMessage(1, " mIgnoreSelectedChanged true: returning"<<std::endl);
+printf("EED WxTreeView::OnItemSelected 0.1\n");
+ return;
+ }
-
+printf("EED WxTreeView::OnItemSelected 1\n");
wxListItem info;
info.m_itemId = event.m_itemIndex;
wxObject* obj = event.GetEventObject();
unsigned int level = 0;
for (level = 0; level<mLevelList.size(); ++level)
- {
- if ( GetCtrl(level) == obj ) break;
- }
+ {
+ if ( GetCtrl(level) == obj ) break;
+ }
mLastLevel=level;
- GimmickDebugMessage(1,
- " Level "<<level+1
- <<std::endl);
+ GimmickDebugMessage(1," Level "<<level+1<<std::endl);
+printf("EED WxTreeView::OnItemSelected 2 %d %d \n", level, mLevelList.size() );
// Update the children level (if selection not at last level)
if (level<mLevelList.size()-1)
- {
-
- UpdateLevel( level + 2 );
- // Reset the viewer setting the default image
- GetGimmickView()->ClearSelection();
- }
+ {
+printf("EED WxTreeView::OnItemSelected 2.0\n");
+ UpdateLevel( level + 2 );
+ // Reset the viewer setting the default image
+printf("EED WxTreeView::OnItemSelected 2.1\n");
+ GetGimmickView()->ClearSelection();
+printf("EED WxTreeView::OnItemSelected 2.2\n");
+ }
+printf("EED WxTreeView::OnItemSelected 3\n");
// Select all images if the selection is at series level
if (level==mLevelList.size()-2)
+ {
+printf("EED WxTreeView::OnItemSelected 4\n");
SelectAll(level+1);
+ }
+printf("EED WxTreeView::OnItemSelected 5\n");
// Validate selected images if the selection is at image level
if (level==(mLevelList.size()-1)) //&&mProcess)
- {
- if(event.GetEventType()==wxEVT_COMMAND_LIST_ITEM_SELECTED)
- {
+ {
+ if(event.GetEventType()==wxEVT_COMMAND_LIST_ITEM_SELECTED)
+ {
ValidateSelectedImages (true);
- }
- else
- {
+ } else {
ValidateSelectedImages (false);
- }
- }
-
+ }
+ } // if
+printf("EED WxTreeView::OnItemSelected End\n");
}
//================================================================
//================================================================
void WxTreeView::SelectAll(int level)
{
+printf("EED WxTreeView::SelectAll Start\n");
+
long item = -1;
// int level=mLevelList.size()-1;
for ( ;; )
GetCtrl(level)->SetItemState(item,wxLIST_STATE_SELECTED, wxLIST_MASK_STATE
| wxLIST_MASK_TEXT |wxLIST_MASK_IMAGE | wxLIST_MASK_DATA | wxLIST_MASK_WIDTH | wxLIST_MASK_FORMAT);
}
+printf("EED WxTreeView::SelectAll End\n");
+
}
//================================================================
//================================================================
void WxTreeView::SortLevel(int level)
- {
+ {
+printf("EED WxTreeView::SortLevel Start %d \n", level);
GimmickDebugMessage(1,
"WxTreeView::SortLevel("
<<level<<")"
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);
+ {
+ //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 );
+ } // if i
+ //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++;
+ } // if
+ }// for
- //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);
+printf("EED WxTreeView::SortLevel 1\n");
mIgnoreSelectedChanged = true;
//
if (mLevelList[level].SortAscending)
- {
-
- if(ty==1)
- {
- GetCtrl(level)->SortItems(CompareFunctionInts, 0);
- }
- else
- {
- GetCtrl(level)->SortItems(CompareFunctionStrings, 0);
- }
+ {
+printf("EED WxTreeView::SortLevel 2\n");
- }
- else
- {
- if(ty==1)
- {
- GetCtrl(level)->SortItems(CompareFunctionInts, 1);
- }
- else
- {
- GetCtrl(level)->SortItems(CompareFunctionStrings, 1);
- }
- }
+ if(ty==1)
+ {
+ GetCtrl(level)->SortItems(CompareFunctionInts, 0);
+ } else {
+ GetCtrl(level)->SortItems(CompareFunctionStrings, 0);
+ } // if ty
+ } else {
+ if(ty==1)
+ {
+ GetCtrl(level)->SortItems(CompareFunctionInts, 1);
+ } else {
+ GetCtrl(level)->SortItems(CompareFunctionStrings, 1);
+ } // if ty
+ } //mLevelList
+printf("EED WxTreeView::SortLevel 3\n");
// 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++;
- }
+ {
+ //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)
+ {
+printf("EED WxTreeView::SortLevel 4\n");
+ 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 data
+ if (GetCtrl(level)->GetItemState(i,wxLIST_STATE_SELECTED)>0)
+ {
+ after++;
+ }
- }
+ } // for
mIgnoreSelectedChanged = false;
- GimmickDebugMessage(1,
+ GimmickDebugMessage(1,
"WxTreeView::SortLevel : "
<<after<<" selected after sorting"
<<std::endl);
+printf("EED WxTreeView::SortLevel End\n");
}
//================================================================