+void wxTreeCtrl::EnsureVisible(const wxTreeItemId& item)
+{
+ wxGenericTreeItem *gitem = item.m_pItem;
+
+ int item_y = gitem->GetY();
+
+ int start_x = 0;
+ int start_y = 0;
+ ViewStart( &start_x, &start_y );
+ start_y *= 10;
+
+ int client_h = 0;
+ int client_w = 0;
+ GetClientSize( &client_w, &client_h );
+
+ if (item_y < start_y+3)
+ {
+ int x = 0;
+ int y = 0;
+ m_anchor->GetSize( x, y );
+ y += 2*m_lineHeight;
+ int x_pos = GetScrollPos( wxHORIZONTAL );
+ SetScrollbars( 10, 10, x/10, y/10, x_pos, (item_y-client_h/2)/10 );
+ return;
+ }
+
+ if (item_y > start_y+client_h-16)
+ {
+ int x = 0;
+ int y = 0;
+ m_anchor->GetSize( x, y );
+ y += 2*m_lineHeight;
+ int x_pos = GetScrollPos( wxHORIZONTAL );
+ SetScrollbars( 10, 10, x/10, y/10, x_pos, (item_y-client_h/2)/10 );
+ return;
+ }
+}
+
+void wxTreeCtrl::ScrollTo(const wxTreeItemId& WXUNUSED(item))
+{
+ wxFAIL_MSG("not implemented");
+}
+
+wxTextCtrl *wxTreeCtrl::EditLabel( const wxTreeItemId& WXUNUSED(item),
+ wxClassInfo* WXUNUSED(textCtrlClass) )
+{
+ wxFAIL_MSG("not implemented");
+
+ return (wxTextCtrl*)NULL;
+}
+
+wxTextCtrl *wxTreeCtrl::GetEditControl() const
+{
+ wxFAIL_MSG("not implemented");
+
+ return (wxTextCtrl*)NULL;
+}
+
+void wxTreeCtrl::EndEditLabel(const wxTreeItemId& WXUNUSED(item), bool WXUNUSED(discardChanges))
+{
+ wxFAIL_MSG("not implemented");
+}
+
+// FIXME: tree sorting functions are not reentrant and not MT-safe!
+static wxTreeCtrl *s_treeBeingSorted = NULL;
+
+static int tree_ctrl_compare_func(wxGenericTreeItem **item1,
+ wxGenericTreeItem **item2)
+{
+ wxCHECK_MSG( s_treeBeingSorted, 0, "bug in wxTreeCtrl::SortChildren()" );
+
+ return s_treeBeingSorted->OnCompareItems(*item1, *item2);
+}
+
+int wxTreeCtrl::OnCompareItems(const wxTreeItemId& item1,
+ const wxTreeItemId& item2)
+{
+ return strcmp(GetItemText(item1), GetItemText(item2));
+}
+
+void wxTreeCtrl::SortChildren(const wxTreeItemId& itemId)
+{
+ wxCHECK_RET( itemId.IsOk(), "invalid tree item" );
+
+ wxGenericTreeItem *item = itemId.m_pItem;
+
+ wxCHECK_RET( !s_treeBeingSorted,
+ "wxTreeCtrl::SortChildren is not reentrant" );
+
+ wxArrayTreeItems& children = item->GetChildren();
+ if ( children.Count() > 1 )
+ {
+ s_treeBeingSorted = this;
+ children.Sort(tree_ctrl_compare_func);
+ s_treeBeingSorted = NULL;
+
+ m_dirty = TRUE;
+ }
+ //else: don't make the tree dirty as nothing changed
+}
+
+wxImageList *wxTreeCtrl::GetImageList() const
+{
+ return m_imageListNormal;
+}
+
+wxImageList *wxTreeCtrl::GetStateImageList() const
+{
+ return m_imageListState;
+}
+
+void wxTreeCtrl::SetImageList(wxImageList *imageList)
+{
+ m_imageListNormal = imageList;
+}
+
+void wxTreeCtrl::SetStateImageList(wxImageList *imageList)
+{
+ m_imageListState = imageList;
+}
+
+// -----------------------------------------------------------------------------
+// helpers
+// -----------------------------------------------------------------------------
+
+void wxTreeCtrl::AdjustMyScrollbars()
+{
+ if (m_anchor)
+ {
+ int x = 0;
+ int y = 0;
+ m_anchor->GetSize( x, y );
+ y += 2*m_lineHeight;
+ int x_pos = GetScrollPos( wxHORIZONTAL );
+ int y_pos = GetScrollPos( wxVERTICAL );
+ SetScrollbars( 10, 10, x/10, y/10, x_pos, y_pos );
+ }
+ else
+ {
+ SetScrollbars( 0, 0, 0, 0 );
+ }
+}
+
+void wxTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
+{
+ /* render bold items in bold */
+ wxFont fontOld;
+ wxFont fontNew;
+
+ if (item->IsBold())
+ {
+ fontOld = dc.GetFont();
+ if (fontOld.Ok())