00001
00002
00003
00004
00005
00006
00007
00008
00010
00011 #ifdef __GNUG__
00012 #pragma implementation "CRAbstractTreeEvent.h"
00013 #endif
00014
00015 #include "CRAbstractTreeEvent.h"
00016
00017 #include <wx/treectrl.h>
00018
00019 namespace wxTst {
00020
00021
00022 CRAbstractTreeEvent::CRAbstractTreeEvent (wxEvent *event) :
00023 CRCapturedEvent (event)
00024 {
00025
00026 }
00027
00028
00029 CRAbstractTreeEvent::~CRAbstractTreeEvent ()
00030 {
00031 m_treeItemSiblingIdxHierarchyList.clear ();
00032 }
00033
00034
00035 void CRAbstractTreeEvent::BuildTreeItemSiblingIdxHierarchyList ()
00036 {
00037 wxTreeEvent *treeEvt = wxDynamicCast (m_event, wxTreeEvent);
00038 wxASSERT (treeEvt != NULL);
00039
00040 wxTreeCtrl *treeCtrl = wxDynamicCast (m_event->GetEventObject (), wxTreeCtrl);
00041 wxASSERT (treeCtrl != NULL);
00042
00043 wxTreeItemId cur = treeEvt->GetItem ();
00044 while ((cur.IsOk ()) && (cur != treeCtrl->GetRootItem ())) {
00045
00046 unsigned int siblingIdx = this->GetSiblingIdx (treeCtrl, cur);
00047 m_treeItemSiblingIdxHierarchyList.push_front (siblingIdx);
00048 cur = treeCtrl->GetItemParent (cur);
00049 }
00050 }
00051
00052
00053 unsigned int CRAbstractTreeEvent::GetSiblingIdx (
00054 wxTreeCtrl *treeCtrl, const wxTreeItemId &id)
00055 {
00056 unsigned int idx = 0;
00057 wxTreeItemId cur = id;
00058 while (cur.IsOk ()) {
00059
00060 cur = treeCtrl->GetPrevSibling (cur);
00061 idx++;
00062 }
00063
00064 return idx;
00065 }
00066
00067 }
00068