// TBWidgetListener virtual bool OnWidgetInvokeEvent(TBWidget *widget, const TBWidgetEvent &ev) { // Skip these events for now if (ev.IsPointerEvent()) return false; // Always ignore activity in this window (or we might get endless recursion) if (TBWindow *window = widget->GetParentWindow()) if (TBSafeCast<DebugSettingsWindow>(window)) return false; TBTempBuffer buf; buf.AppendString(GetEventTypeStr(ev.type)); buf.AppendString(" ("); buf.AppendString(widget->GetClassName()); buf.AppendString(")"); buf.AppendString(" id: "); buf.AppendString(GetIDString(ev.target->GetID())); if (ev.ref_id) { buf.AppendString(", ref_id: "); buf.AppendString(GetIDString(ev.ref_id)); } if (ev.type == EVENT_TYPE_CHANGED) { TBStr extra, text; if (ev.target->GetText(text) && text.Length() > 24) sprintf(text.CStr() + 20, "..."); extra.SetFormatted(", value: %.2f (\"%s\")", ev.target->GetValueDouble(), text.CStr()); buf.AppendString(extra); } buf.AppendString("\n"); // Append the line to the output textfield TBStyleEdit *se = output->GetStyleEdit(); se->selection.SelectNothing(); se->AppendText(buf.GetData(), TB_ALL_TO_TERMINATION, true); se->ScrollIfNeeded(false, true); // Remove lines from the top if we exceed the height limit. const int height_limit = 2000; int current_height = se->GetContentHeight(); if (current_height > height_limit) { se->caret.Place(TBPoint(0, current_height - height_limit)); se->selection.SelectToCaret(se->blocks.GetFirst(), 0); se->Delete(); } return false; }
void TBHashTable::Debug() { TBTempBuffer line; line.AppendString("Hash table: "); int total_count = 0; for (uint32 i = 0; i < m_num_buckets; i++) { int count = 0; ITEM *item = m_buckets[i]; while (item) { count++; item = item->next; } TBStr tmp; tmp.SetFormatted("%d ", count); line.AppendString(tmp); total_count += count; } TBStr tmp; tmp.SetFormatted(" (total: %d of %d buckets)\n", total_count, m_num_buckets); line.AppendString(tmp); TBDebugOut(line.GetData()); }