+wxFont wxTreeListMainWindow::GetItemFont (wxTreeListItem *item) {
+    wxTreeItemAttr *attr = item->GetAttributes();
+
+    if (attr && attr->HasFont()) {
+        return attr->GetFont();
+    }else if (item->IsBold()) {
+        return m_boldFont;
+    }else{
+        return m_normalFont;
+   }
+}
+
+int wxTreeListMainWindow::GetItemWidth (int column, wxTreeListItem *item) {
+    if (!item) return 0;
+
+    // determine item width
+    int w = 0, h = 0;
+    wxFont font = GetItemFont (item);
+    GetTextExtent (item->GetText (column), &w, &h, NULL, NULL, font.Ok()? &font: NULL);
+    w += 2*MARGIN;
+
+    // calculate width
+    int width = w + 2*MARGIN;
+    if (column == GetMainColumn()) {
+        width += MARGIN;
+        if (HasFlag(wxTR_LINES_AT_ROOT)) width += LINEATROOT;
+        if (HasButtons()) width += m_btnWidth + LINEATROOT;
+        if (item->GetCurrentImage() != NO_IMAGE) width += m_imgWidth;
+
+        // count indent level
+        int level = 0;
+        wxTreeListItem *parent = item->GetItemParent();
+        wxTreeListItem *root = (wxTreeListItem*)GetRootItem().m_pItem;
+        while (parent && (!HasFlag(wxTR_HIDE_ROOT) || (parent != root))) {
+            level++;
+            parent = parent->GetItemParent();
+        }
+        if (level) width += level * GetIndent();
+    }
+
+    return width;
+}
+
+int wxTreeListMainWindow::GetBestColumnWidth (int column, wxTreeItemId parent) {
+    int maxWidth, h;
+    GetClientSize (&maxWidth, &h);
+    int width = 0;
+
+    // get root if on item
+    if (!parent.IsOk()) parent = GetRootItem();
+
+    // add root width
+    if (!HasFlag(wxTR_HIDE_ROOT)) {
+        int w = GetItemWidth (column, (wxTreeListItem*)parent.m_pItem);
+        if (width < w) width = w;
+        if (width > maxWidth) return maxWidth;
+    }
+
+    wxTreeItemIdValue cookie = 0;
+    wxTreeItemId item = GetFirstChild (parent, cookie);
+    while (item.IsOk()) {
+        int w = GetItemWidth (column, (wxTreeListItem*)item.m_pItem);
+        if (width < w) width = w;
+        if (width > maxWidth) return maxWidth;
+
+        // check the children of this item
+        if (((wxTreeListItem*)item.m_pItem)->IsExpanded()) {
+            int w = GetBestColumnWidth (column, item);
+            if (width < w) width = w;
+            if (width > maxWidth) return maxWidth;
+        }
+
+        // next sibling
+        item = GetNextChild (parent, cookie);
+    }
+
+    return width;
+}
+