From: John L. <jr...@us...> - 2007-06-18 18:37:50
|
Update of /cvsroot/wxlua/wxLua/modules/wxluadebug/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv24653/wxLua/modules/wxluadebug/src Modified Files: wxlstack.cpp Log Message: Fix stack tree for MSW treectrl oddity of not being able to expand or collapse an item w/o children. Index: wxlstack.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/src/wxlstack.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** wxlstack.cpp 16 Jun 2007 06:39:45 -0000 1.7 --- wxlstack.cpp 18 Jun 2007 18:37:47 -0000 1.8 *************** *** 32,35 **** --- 32,44 ---- #endif + // Define our own flag to help track down where we've hacked thing to work + // equally well with the treectrl for MSW + #if defined(__WXMSW__) + #define WXLUA_STACK_MSWTREE + #endif //defined(__WXMSW__) + + #define DUMMY_TREEITEM wxT(" ") + + // ---------------------------------------------------------------------------- // wxLuaStackDialog *************** *** 188,192 **** m_treeCtrl = new wxTreeCtrl(m_splitterWin, ID_WXLUA_STACK_TREECTRL, wxDefaultPosition, wxDefaultSize, ! wxTR_HAS_BUTTONS|wxTR_SINGLE); m_treeCtrl->SetImageList(m_imageList); --- 197,201 ---- m_treeCtrl = new wxTreeCtrl(m_splitterWin, ID_WXLUA_STACK_TREECTRL, wxDefaultPosition, wxDefaultSize, ! wxTR_HAS_BUTTONS|wxTR_SINGLE|wxTR_HIDE_ROOT|wxTR_LINES_AT_ROOT); m_treeCtrl->SetImageList(m_imageList); *************** *** 367,370 **** --- 376,380 ---- m_treeCtrl->DeleteAllItems(); m_treeCtrl->AddRoot(wxT("wxLua Data"), -1, -1, NULL); + m_treeCtrl->SetItemHasChildren(m_treeCtrl->GetRootItem()); // Add the locals, fake a debug item to get it setup right *************** *** 438,441 **** --- 448,453 ---- } + m_treeCtrl->SetItemHasChildren(treeId); + size_t n, count = debugData.GetCount(); long lc_item = lc_item_; *************** *** 457,460 **** --- 469,483 ---- m_treeCtrl->SetItemHasChildren(id); stkListData->m_treeId = id; + + // add dummy item for MSW to expand properly, also it shows that + // there's nothing in this level if they try to expand it and there + // aren't any real items (see below) + m_treeCtrl->AppendItem(id, DUMMY_TREEITEM); + + // now that we've added something, remove the first dummy " " item from parent + wxTreeItemIdValue dummyCookie; + wxTreeItemId dummyId = m_treeCtrl->GetFirstChild(treeId, dummyCookie); + if (m_treeCtrl->GetItemText(dummyId) == DUMMY_TREEITEM) + m_treeCtrl->Delete(dummyId); } *************** *** 473,478 **** } ! if (treeId) m_treeCtrl->Expand(treeId); } } --- 496,508 ---- } ! // NOTE : The MSW treectrl will expand and immediately collapse a node if you call Expand() ! // from within a handler, don't do anything and it works... ! #if !defined(WXLUA_STACK_MSWTREE) ! // Cannot expand hidden root, nor can you check it ! if (treeId && ! ((treeId != m_treeCtrl->GetRootItem()) || ((m_treeCtrl->GetWindowStyle() & wxTR_HIDE_ROOT) == 0)) && ! !m_treeCtrl->IsExpanded(treeId)) m_treeCtrl->Expand(treeId); + #endif //!defined(WXLUA_STACK_MSWTREE) } } *************** *** 717,721 **** long list_item = FindListItem(stkTreeData->m_stkListData); ! if (list_item < 0) return; // oops? if (event.GetEventType() == wxEVT_COMMAND_TREE_ITEM_EXPANDED) --- 747,751 ---- long list_item = FindListItem(stkTreeData->m_stkListData); ! if (list_item < 0) return; // not an item that we can do anything with if (event.GetEventType() == wxEVT_COMMAND_TREE_ITEM_EXPANDED) *************** *** 753,759 **** --- 783,800 ---- { if (!debugItem->GetFlagBit(WXLUA_DEBUGITEM_EXPANDED)) + { ExpandItem(event.GetIndex()); + // Hack for WXLUA_STACK_MSWTREE, need children to expand + if (stkListData->m_treeId && !m_treeCtrl->IsExpanded(stkListData->m_treeId)) + m_treeCtrl->Expand(stkListData->m_treeId); + } else + { + // Hack for WXLUA_STACK_MSWTREE, need children to collapse + if (stkListData->m_treeId && m_treeCtrl->IsExpanded(stkListData->m_treeId)) + m_treeCtrl->Collapse(stkListData->m_treeId); + CollapseItem(event.GetIndex()); + } } } *************** *** 907,911 **** } ! m_treeCtrl->CollapseAndReset(stkListData->m_treeId); debugItem->SetFlagBit(WXLUA_DEBUGITEM_EXPANDED, false); m_listCtrl->SetItemImage(lc_item, IMG_TABLE); --- 948,957 ---- } ! // don't call collapse here, let MSW do it if this is called from OnTreeItem ! // else we've already collapsed it in OnListActivated ! m_treeCtrl->DeleteChildren(stkListData->m_treeId); ! // Add back our dummy item for MSW to allow it to be reexpanded ! m_treeCtrl->AppendItem(stkListData->m_treeId, DUMMY_TREEITEM); ! debugItem->SetFlagBit(WXLUA_DEBUGITEM_EXPANDED, false); m_listCtrl->SetItemImage(lc_item, IMG_TABLE); |