namespace creaImageIO
{
+ //=====================================================================
// CTor
WxTreeView::WxTreeView(TreeHandler* handler,
wxWindow* parent,
{
GimmickDebugMessage(5,"Creating ListCtrl for level "<<i
<<std::endl);
-
+ LevelType level;
wxListCtrl* ctrl = new wxListCtrl(this,
i,
wxDefaultPosition,
wxDefaultSize,
ctrl_style);
-
+ level.wxCtrl = ctrl;
+
// Create the columns : one for each attribute of the level
int col = 0;
tree::LevelDescriptor::AttributeDescriptorListType::const_iterator a;
ctrl->InsertColumn(col,
crea::std2wx(a->GetName()),
col_style);
+ level.key.push_back(a->GetKey());
+ // ctrl->SetColumnWidth(col, wxLIST_AUTOSIZE );
col++;
}
- mListCtrl.push_back(ctrl);
+ mLevelList.push_back(level);
sizer->Add( ctrl ,1, wxGROW ,0);
}
+ UpdateLevel(1);
+
SetSizer( sizer );
SetAutoLayout(true);
Layout();
}
+ //=====================================================================
+ //=====================================================================
/// Destructor
WxTreeView::~WxTreeView()
{
GimmickDebugMessage(1,"WxTreeView::~WxTreeView"
<<std::endl);
}
+ //=====================================================================
+ //=====================================================================
+ struct ItemData
+ {
+ tree::Node* node;
+ };
+ //=====================================================================
+
+ //=====================================================================
///
- void WxTreeView::UpdateView()
+ void WxTreeView::UpdateLevel( int level )
{
+ GimmickDebugMessage(1,
+ GetTreeHandler()->GetTree().GetLabel()
+ <<" view : updating level "<<level
+ <<std::endl);
+ int l = level - 1;
+ // the selection of upper level
+ std::vector<tree::Node*> sel;
+ if (level == 1)
+ {
+ sel.push_back(GetTreeHandler()->GetTree().GetTree());
+ }
+ else
+ {
+ int n = GetCtrl(l-1)->GetItemCount();
+ for (int i = 0; i < n; i++)
+ {
+ if ( GetCtrl(l-1)->GetItemState(i,wxLIST_STATE_SELECTED))
+ {
+ long adr = GetCtrl(l-1)->GetItemData(i);
+ tree::Node* n = ((ItemData*)adr)->node;
+ sel.push_back(n);
+ }
+ }
+ }
+
+ // to speed up inserting we hide the control temporarily
+ GetCtrl(l)->Hide();
+ GetCtrl(l)->DeleteAllItems();
+
+ std::vector<tree::Node*>::iterator i;
+ for (i=sel.begin(); i!=sel.end(); ++i)
+ {
+ GimmickDebugMessage(2,
+ "adding children of '"
+ <<(*i)->GetLabel()
+ <<"'"<<level
+ <<std::endl);
+
+ GetTreeHandler()->LoadChildren(*i,1);
+ tree::Node::ChildrenListType::reverse_iterator j;
+ for (j = (*i)->GetChildrenList().rbegin();
+ j!= (*i)->GetChildrenList().rend();
+ ++j)
+ {
+ wxListItem item;
+ item.SetMask(wxLIST_MASK_STATE |
+ wxLIST_MASK_TEXT |
+ // wxLIST_MASK_IMAGE |
+ wxLIST_MASK_DATA |
+ // wxLIST_MASK_WIDTH |
+ wxLIST_MASK_FORMAT
+ );
+
+ ItemData* data = new ItemData;
+ data->node = *j;
+ item.SetData(data);
+
+ long id = GetCtrl(l)->InsertItem(item);
+
+ for (int k=0; k<GetCtrl(l)->GetColumnCount(); k++)
+ {
+ GetCtrl(l)->SetItem
+ (id,k,
+ crea::std2wx
+ ( (*j)->GetAttribute(mLevelList[l].key[k]) ));
+ }
+
+ }
+ }
+
+ GetCtrl(l)->Show();
+ }
+ //=====================================================================
+
+
+ //================================================================
+ void WxTreeView::OnSelected(wxListEvent& event)
+ {
+ GimmickDebugMessage(1,
+ GetTreeHandler()->GetTree().GetLabel()
+ <<" view : item selected "
+ <<std::endl);
+
+
+ wxListItem info;
+ info.m_itemId = 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 );
+
}
-
+ //================================================================
+
+
+
+ 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::OnSelected)
+ /*
+ EVT_LIST_ITEM_DESELECTED(LIST_CTRL, MyListCtrl::OnDeselected)
+ 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_CLICK(LIST_CTRL, MyListCtrl::OnColClick)
+ EVT_LIST_COL_RIGHT_CLICK(LIST_CTRL, MyListCtrl::OnColRightClick)
+ 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