// Global sizer
wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
- int ctrl_style = wxLC_REPORT | wxLC_VRULES;
+ int ctrl_style = wxLC_REPORT | /*wxLC_VRULES |*/ wxLC_EDIT_LABELS;
int col_style = wxLIST_FORMAT_LEFT;
// Creating the ListCtrl for the levels > 0 (not for Root level)
// Create the columns : one for each attribute of the level
int col = 0;
-
tree::LevelDescriptor::AttributeDescriptorListType::const_iterator a;
for (a = handler->GetTree().GetAttributeDescriptorList(i).begin();
a != handler->GetTree().GetAttributeDescriptorList(i).end();
GetCtrl(l)->DeleteAllItems();
std::vector<tree::Node*>::iterator i;
+ //Adds the first item (filter)
+ GetCtrl(l)->InsertItem(0, "Filter:");
for (i=sel.begin(); i!=sel.end(); ++i)
{
GimmickDebugMessage(2,
<<(*i)->GetLabel()
<<"'"<<level
<<std::endl);
- int _id=0;
+ int _id=1;
int colorId=0;
- //Adds columns
+
+
+
+ //Adds items (other than the first) and sets their attributes
GetTreeHandler()->LoadChildren(*i,1);
tree::Node::ChildrenListType::reverse_iterator j;
for (j = (*i)->GetChildrenList().rbegin();
_id++;
long id=GetCtrl(l)->InsertItem(item);
+ //Setting first column (number of children)
std::ostringstream oss;
int n= GetTreeHandler()->GetNumberOfChildren(*j);
-
oss << n;
std::string s(oss.str());
-
-
item.SetText( crea::std2wx(s));
- // item.SetTextColour(*wxRED);
-
+
//Setting the color according to the parent
if(l==0)
{
item.SetColumn(0);
GetCtrl(l)->SetItem(item);
- // GetCtrl(l)->SetItem(id,0, crea::std2wx(s));
- // GetCtrl(l)->SetColumnWidth(0, wxLIST_AUTOSIZE );
-
+ //Setting other attributes
for (int k=1; k<GetCtrl(l)->GetColumnCount(); k++)
{
std::string val = (*j)->GetAttribute(mLevelList[l].key[k-1]);
if (val.size()==0) val = "?";
item.SetText( crea::std2wx(val));
- // item.SetTextColour(*wxBLACK);
- // item.SetBackgroundColour(*wxWHITE);
item.SetColumn(k);
- GetCtrl(l)->SetItem(item);
-
- // GetCtrl(l)->SetItem(id,k, crea::std2wx(val));
- // GetCtrl(l)->SetColumnWidth(k, wxLIST_AUTOSIZE );
-
+ GetCtrl(l)->SetItem(item);
}
}
}
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)
- {
+ // 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,
+ }
+ GimmickDebugMessage(1,
" Level "<<level+1
<<std::endl);
- if(level<mLevelList.size()-1)
+ if(event.m_itemIndex!=0)
{
- mSelected=GetSelected(level+2);
+ if(level<mLevelList.size()-1)
+ {
+ mSelected=GetSelected(level+2);
+ }
+ else
+ {
+ mLastLevelSelected=GetSelected(level+2);
+ }
+
+ if (level<mLevelList.size()-1)
+ {
+ UpdateLevel( level + 2 );
+ GetGimmickView()->ClearSelection();
+ }
+ if (level==mLevelList.size()-2) SelectLowerLevel();
+ if (level==mLevelList.size()-1) ValidateSelectedImages ();
}
else
{
- mLastLevelSelected=GetSelected(level+2);
- }
-
- if (level<mLevelList.size()-1)
- {
- UpdateLevel( level + 2 );
- GetGimmickView()->ClearSelection();
+ if(event.GetEventType()==10145)
+ {
+
+ GetCtrl(level)->SetItemText(0,crea::std2wx(""));
+ GetCtrl(level)->EditLabel(event.m_itemIndex);
+ }
+
}
- if (level==mLevelList.size()-2) SelectLowerLevel();
- if (level==mLevelList.size()-1) ValidateSelectedImages ();
}
//================================================================
wxLIST_NEXT_ALL);
if ( item == -1 )
break;
-
+ if(item!=0)
+ {
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);
+ }
}
if ( GetCtrl(level) == ctrl ) break;
}
- UpdateLevel(level+1);
-
wxBusyCursor busy;
int l = level - 1;
-
+ GetCtrl(level)->DeleteItem(0);
//Sets the data for the items to be sorted
std::string att;
unsigned int ty=0;
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]);
}
}
+
}
//Resets the selected items
std::vector<long>::iterator selectedIts;
| wxLIST_MASK_TEXT |wxLIST_MASK_IMAGE | wxLIST_MASK_DATA | wxLIST_MASK_WIDTH | wxLIST_MASK_FORMAT);
}
+ GetCtrl(level)->InsertItem(0,"Filter:");
}
}
//================================================================
+ void WxTreeView::OnBeginLabelEdit(wxListEvent& event)
+ {
+ GimmickDebugMessage(7,
+ "WxTreeView::OnBeginLabelEdit"
+ <<std::endl);
+
+ }
+ //================================================================
+ void WxTreeView::OnEndLabelEdit(wxListEvent& event)
+ {
+ GimmickDebugMessage(7,
+ "WxTreeView::OnEndLabelEdit"
+ <<std::endl);
+ wxObject* ctrl = event.GetEventObject();
+ unsigned int level = 0;
+ for (level = 0; level<mLevelList.size(); ++level)
+ {
+ if ( GetCtrl(level) == ctrl ) break;
+ }
+ std::string filter=event.m_item.m_text.c_str();
+
+ std::string att;
+
+ long it = -1;
+ UpdateLevel(level+1);
+
+ for ( ;; )
+ {
+ bool contains=false;
+ it = GetCtrl(level)->GetNextItem(it,
+ wxLIST_NEXT_ALL);
+ if ( it == -1 )
+ break;
+ if(it!=0)
+ {
+ long adr = GetCtrl(level)->GetItemData(it);
+ for (int j=1;j<GetCtrl(level)->GetColumnCount()-1&&!contains;j++)
+ {
+ tree::Node* nod = ((ItemData*)adr)->node;
+ att=(*nod).GetAttribute(mLevelList[level].key[j-1]);
+
+ if(att.find(filter)<900)
+ {
+ contains=true;
+ }
+ }
+ if(!contains)
+ {
+ GetCtrl(level)->DeleteItem(it);
+ }
+ }
+ }
+ GetGimmickView()->ClearSelection();
+ //GetCtrl(level)->DeleteAllItems();
+ }
//================================================================
void WxTreeView::ValidateSelectedImages()
{
item = GetCtrl(level)->GetNextItem(item,
wxLIST_NEXT_BELOW);
}
- if ( item == -1 )
+ if ( item == -1 )
{
break;
}
- if(GetCtrl(level)->GetItemState(item, wxLIST_STATE_SELECTED)==0)
+ if(GetCtrl(level)->GetItemState(item, wxLIST_STATE_SELECTED)==0 && item!=0)
{
adr = GetCtrl(level)->GetItemData(item);
nod = ((ItemData*)adr)->node;
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_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