From: John L. <jr...@us...> - 2006-10-04 02:46:45
|
Update of /cvsroot/wxlua/wxLua/modules/wxluadebug/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv23774/wxLua/modules/wxluadebug/src Modified Files: staktree.cpp wxldebug.cpp Log Message: add GetEventTypeName(int) to bindings to lookup event name string use sizers in stack dialog simplify the stackdialog by unifying all treectrl item adding better comments in headers Index: wxldebug.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/src/wxldebug.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** wxldebug.cpp 13 Sep 2006 04:13:47 -0000 1.19 --- wxldebug.cpp 2 Oct 2006 21:19:24 -0000 1.20 *************** *** 241,245 **** if (tableRef == -1) { ! lua_pushvalue(L, LUA_GLOBALSINDEX); int nRef = wxlState.tinsert(-1); Add(new wxLuaDebugDataItem(wxT("Globals"), wxT(""), wxT(""), wxT(""), nRef, 0)); --- 241,245 ---- if (tableRef == -1) { ! wxlState.GetGlobals(); int nRef = wxlState.tinsert(-1); Add(new wxLuaDebugDataItem(wxT("Globals"), wxT(""), wxT(""), wxT(""), nRef, 0)); *************** *** 438,448 **** } - int wxLuaInterface::Ref() - { - int nReference = m_wxlState.tinsert(-1); - m_references.Add(nReference); - return nReference; - } - wxLuaDebugData wxLuaInterface::EnumerateStack() { --- 438,441 ---- *************** *** 469,475 **** { wxLuaDebugData debugData; ! m_wxlState.GetGlobals(); ! int nRef = Ref(); ! debugData.Add(new wxLuaDebugDataItem(wxT("Globals"), wxT(""), wxT(""), wxT(""), nRef, 0)); return debugData; } --- 462,466 ---- { wxLuaDebugData debugData; ! debugData.EnumerateTable(m_wxlState, -1, -1, m_references); // Get global table return debugData; } Index: staktree.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/src/staktree.cpp,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** staktree.cpp 8 Sep 2006 22:43:47 -0000 1.28 --- staktree.cpp 2 Oct 2006 21:19:24 -0000 1.29 *************** *** 39,47 **** BEGIN_EVENT_TABLE(wxLuaStackDialog, wxDialog) - EVT_SIZE(wxLuaStackDialog::OnSizeWindow) - EVT_COMBOBOX( ID_WXLUA_STACKDIALOG_COMBO, wxLuaStackDialog::OnSelectStack) EVT_TREE_ITEM_EXPANDING(ID_WXLUA_STACKDIALOG_STACKTREE, wxLuaStackDialog::OnItemExpanding) - EVT_BUTTON( ID_WXLUA_STACKDIALOG_DISMISS_BUTTON, wxLuaStackDialog::OnCloseDialog) END_EVENT_TABLE() --- 39,44 ---- *************** *** 69,89 **** return false; ! m_stackComboBox = new wxComboBox( this, ID_WXLUA_STACKDIALOG_COMBO, wxEmptyString, ! wxPoint(0, 0), wxDefaultSize, 0, NULL, wxCB_DROPDOWN | wxCB_READONLY); ! m_scrolledWindow = new wxSplitterScrolledWindow(this, ID_WXLUA_STACKDIALOG_SCRWIN, ! wxDefaultPosition, wxDefaultSize, wxNO_BORDER | wxCLIP_CHILDREN | wxVSCROLL); - m_dismissButton = new wxButton(this, ID_WXLUA_STACKDIALOG_DISMISS_BUTTON, - _("Cancel"), - wxDefaultPosition, wxDefaultSize, - wxBU_EXACTFIT); - m_dismissButton->SetDefault(); - m_treeSplitter = new wxThinSplitterWindow(m_scrolledWindow, ID_WXLUA_STACKDIALOG_SPLITWIN, --- 66,82 ---- return false; ! wxPanel* panel = new wxPanel(this, wxID_ANY); ! ! m_stackComboBox = new wxComboBox( panel, ID_WXLUA_STACKDIALOG_COMBO, wxEmptyString, ! wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_DROPDOWN | wxCB_READONLY); ! m_scrolledWindow = new wxSplitterScrolledWindow(panel, ID_WXLUA_STACKDIALOG_SCRWIN, ! wxDefaultPosition, wxSize(400, 350), wxNO_BORDER | wxCLIP_CHILDREN | wxVSCROLL); m_treeSplitter = new wxThinSplitterWindow(m_scrolledWindow, ID_WXLUA_STACKDIALOG_SPLITWIN, *************** *** 131,139 **** SetIcon(wxICON(LUA)); ! int nWidth, nHeight; ! GetClientSize(&nWidth, &nHeight); ! SizeWindow(nWidth, nHeight); ! if (m_luaInterface->IsDebugServer()) m_luaInterface->EnumerateStack(); else --- 124,135 ---- SetIcon(wxICON(LUA)); ! wxBoxSizer* rootSizer = new wxBoxSizer(wxVERTICAL); ! rootSizer->Add(m_stackComboBox, 0, wxEXPAND|wxBOTTOM, 4); ! rootSizer->Add(m_scrolledWindow, 1, wxEXPAND); ! rootSizer->SetMinSize(450, 400); ! panel->SetSizer(rootSizer); ! rootSizer->SetSizeHints(this); ! if (m_luaInterface->IsDebugger()) m_luaInterface->EnumerateStack(); else *************** *** 174,201 **** } - void wxLuaStackDialog::OnSizeWindow(wxSizeEvent &event) - { - wxSize size = GetClientSize(); //event.GetSize(); event size no good in > 2.5.3 at least - SizeWindow(size.x, size.y); - event.Skip(); - } - - void wxLuaStackDialog::SizeWindow(int nWidth, int nHeight) - { - int nComboWidth, nComboHeight, nButtonWidth, nButtonHeight; - m_stackComboBox->GetSize(&nComboWidth, &nComboHeight); - m_dismissButton->GetSize(&nButtonWidth, &nButtonHeight); - nComboHeight += 2; // makes it look a little better - m_stackComboBox->SetSize(0, 0, nWidth, -1); - m_scrolledWindow->SetSize(0, - nComboHeight, - nWidth, - nHeight - 15 - nComboHeight - nButtonHeight); - m_dismissButton->SetSize((nWidth / 2) - (nButtonWidth / 2), - nHeight - 5 - nButtonHeight, - nButtonWidth, - nButtonHeight); - } - void wxLuaStackDialog::OnSelectStack(wxCommandEvent &event) { --- 170,173 ---- *************** *** 209,213 **** int nEntry = (int) m_stackComboBox->GetClientData(nCurrentSel); ! if (m_luaInterface->IsDebugServer()) { m_luaInterface->EnumerateStackEntry(nEntry); --- 181,185 ---- int nEntry = (int) m_stackComboBox->GetClientData(nCurrentSel); ! if (m_luaInterface->IsDebugger()) { m_luaInterface->EnumerateStackEntry(nEntry); *************** *** 226,264 **** m_treeControl->AdjustRemoteScrollbars(); ! size_t idx, count = debugData.GetCount(); ! for (idx = 0; idx < count; ++idx) ! { ! const wxLuaDebugDataItem *item = debugData.Item(idx); ! int nOffset = (item->GetReference() != LUA_NOREF) ? 0 : 1; ! ! wxTreeItemId treeNode = m_treeControl->AppendItem(rootItem, ! item->GetName(), ! nOffset, ! nOffset, ! new wxLuaDebugDataItem(*item)); ! ! if (item->GetReference() != LUA_NOREF) ! m_treeControl->SetItemHasChildren(treeNode); ! } // If at global scope, process globals if (m_nCurrentSel == (int)m_stackComboBox->GetCount() - 1) { ! if (m_luaInterface->IsDebugServer()) m_luaInterface->EnumerateTable(-1, -1, (long)rootItem.m_pItem); else { wxLuaDebugData globalDebugData = m_luaInterface->GetGlobalData(); ! const wxLuaDebugDataItem *item = globalDebugData.Item(0); ! ! wxTreeItemId treeNode = m_treeControl->AppendItem( rootItem, ! item->GetName(), ! 0, ! 0, ! new wxLuaDebugDataItem(*item)); ! ! if (item->GetReference() != LUA_NOREF) ! m_treeControl->SetItemHasChildren(treeNode); ! GetDerivedAndTrackedItems(m_treeControl, rootItem); } --- 198,213 ---- m_treeControl->AdjustRemoteScrollbars(); ! if (debugData.GetCount() > 0u) ! FillTableEntry(rootItem, debugData); // If at global scope, process globals if (m_nCurrentSel == (int)m_stackComboBox->GetCount() - 1) { ! if (m_luaInterface->IsDebugger()) m_luaInterface->EnumerateTable(-1, -1, (long)rootItem.m_pItem); else { wxLuaDebugData globalDebugData = m_luaInterface->GetGlobalData(); ! FillTableEntry(rootItem, globalDebugData); GetDerivedAndTrackedItems(m_treeControl, rootItem); } *************** *** 317,321 **** int nIndex = pDebugDataItem->GetIndex() + 1; ! if (m_luaInterface->IsDebugServer()) { m_luaInterface->EnumerateTable(nRef, nIndex, (long)itemNode.m_pItem); --- 266,270 ---- int nIndex = pDebugDataItem->GetIndex() + 1; ! if (m_luaInterface->IsDebugger()) { m_luaInterface->EnumerateTable(nRef, nIndex, (long)itemNode.m_pItem); *************** *** 328,332 **** } } ! else if (!m_luaInterface->IsDebugServer() && m_luaInterface->GetwxLuaState().Ok() && ((pDebugDataItem->GetName() == _("Tracked List")) || --- 277,281 ---- } } ! else if (!m_luaInterface->IsDebugger() && m_luaInterface->GetwxLuaState().Ok() && ((pDebugDataItem->GetName() == _("Tracked List")) || *************** *** 346,362 **** for (it = hashMap->begin(); it != hashMap->end(); ++it) { wxObject* obj = (wxObject*)it->second; if (obj && obj->GetClassInfo() && obj->GetClassInfo()->GetClassName()) { ! wxString name(obj->GetClassInfo()->GetClassName()); ! int idx = names.Index(name); ! if (idx == wxNOT_FOUND) ! { ! names.Add(name); ! counts.Add(1); ! } ! else ! counts[idx]++; } } } --- 295,314 ---- for (it = hashMap->begin(); it != hashMap->end(); ++it) { + wxString name(wxT("Unknown Tracked Item")); + wxObject* obj = (wxObject*)it->second; if (obj && obj->GetClassInfo() && obj->GetClassInfo()->GetClassName()) + name = obj->GetClassInfo()->GetClassName(); + + //name = wxString::Format(wxT("%p "), obj) + name; + + int idx = names.Index(name); + if (idx == wxNOT_FOUND) { ! names.Add(name); ! counts.Add(1); } + else + counts[idx]++; } } *************** *** 368,372 **** wxLuaCallback *pCallback = (wxLuaCallback *) node->GetData(); wxCHECK_RET(pCallback, wxT("Invalid wxLuaCallback")); ! wxString name = wxString::Format(wxT("Evt type %d"), (int)pCallback->GetEventType()); int idx = names.Index(name); if (idx == wxNOT_FOUND) --- 320,337 ---- wxLuaCallback *pCallback = (wxLuaCallback *) node->GetData(); wxCHECK_RET(pCallback, wxT("Invalid wxLuaCallback")); ! ! wxString evtName; ! if (wxlState.GetLuaBindingList()) ! { ! wxLuaBindingList::Node *bindNode = wxlState.GetLuaBindingList()->GetFirst(); ! for (; bindNode; bindNode = bindNode->GetNext()) ! { ! wxLuaBinding* binding = bindNode->GetData(); ! evtName = binding->GetEventTypeName(pCallback->GetEventType()); ! if (!evtName.IsEmpty()) break; ! } ! } ! ! wxString name = wxString::Format(wxT("%d %s"), (int)pCallback->GetEventType(), evtName.c_str()); int idx = names.Index(name); if (idx == wxNOT_FOUND) *************** *** 445,453 **** } - void wxLuaStackDialog::OnCloseDialog(wxCommandEvent & WXUNUSED(event)) - { - EndModal(0); - } - // ---------------------------------------------------------------------------- // wxLuaStackTree --- 410,413 ---- *************** *** 459,465 **** wxLuaStackTree::wxLuaStackTree( wxWindow *parent, wxWindowID id, ! const wxPoint &pt, const wxSize &sz, long style) ! : wxRemotelyScrolledTreeCtrl(parent, id, pt, sz, style) { m_imageList = new wxImageList(16, 16, true); --- 419,425 ---- wxLuaStackTree::wxLuaStackTree( wxWindow *parent, wxWindowID id, ! const wxPoint &pos, const wxSize &sz, long style) ! : wxRemotelyScrolledTreeCtrl(parent, id, pos, sz, style) { m_imageList = new wxImageList(16, 16, true); *************** *** 494,522 **** void wxLuaStackDataWindow::DrawItem(wxDC &dc, wxTreeItemId id, const wxRect &rect) { ! if (m_treeControl) ! { ! wxLuaDebugDataItem *itemData = (wxLuaDebugDataItem *) m_treeControl->GetItemData(id); ! if (itemData != NULL) ! { ! dc.SetTextForeground(*wxBLACK); ! dc.SetBackgroundMode(wxTRANSPARENT); ! int textWidth, textHeight = 0; ! if (m_fFirst) ! dc.GetTextExtent(itemData->GetType(), &textWidth, &textHeight); ! else ! dc.GetTextExtent(itemData->GetValue(), &textWidth, &textHeight); ! int x = 5; ! int y = (rect.GetHeight() - textHeight) / 2; // try to center it, else pin to top ! y = rect.GetY() + wxMax(0, y); ! if (m_fFirst) ! dc.DrawText(itemData->GetType(), x, y); ! else ! dc.DrawText(itemData->GetValue(), x, y); ! } } } --- 454,481 ---- void wxLuaStackDataWindow::DrawItem(wxDC &dc, wxTreeItemId id, const wxRect &rect) { ! if (!m_treeControl) return; ! wxLuaDebugDataItem *itemData = (wxLuaDebugDataItem *) m_treeControl->GetItemData(id); ! if (itemData != NULL) ! { ! dc.SetTextForeground(*wxBLACK); ! dc.SetBackgroundMode(wxTRANSPARENT); ! int textWidth, textHeight = 0; ! if (m_fFirst) ! dc.GetTextExtent(itemData->GetType(), &textWidth, &textHeight); ! else ! dc.GetTextExtent(itemData->GetValue(), &textWidth, &textHeight); ! int x = 5; ! int y = (rect.GetHeight() - textHeight) / 2; // try to center it, else pin to top ! y = rect.GetY() + wxMax(0, y); ! ! if (m_fFirst) ! dc.DrawText(itemData->GetType(), x, y); ! else ! dc.DrawText(itemData->GetValue(), x, y); } } |