]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/contrib/gizmos/wxCode/src/treelistctrl.cpp
Use the wxWANTS_CHARS style
[wxWidgets.git] / wxPython / contrib / gizmos / wxCode / src / treelistctrl.cpp
index 6cded83c615137ae04c201ef5328e6e5dd0cb421..0ee61d3b0be3cf3720959599d50657eca281ed97 100644 (file)
@@ -1336,7 +1336,7 @@ int wxTreeListHeaderWindow::XToCol(int x)
 
 void wxTreeListHeaderWindow::RefreshColLabel(int col)
 {
-    if ( col > GetColumnCount() )
+    if ( col >= GetColumnCount() )
         return;
     
     int x = 0;
@@ -1860,7 +1860,7 @@ bool wxTreeListMainWindow::Create (wxTreeListCtrl *parent,
     if (major < 10) style |= wxTR_ROW_LINES;
 #endif
 
-    wxScrolledWindow::Create (parent, id, pos, size, style|wxHSCROLL|wxVSCROLL, name);
+    wxScrolledWindow::Create (parent, id, pos, size, style|wxHSCROLL|wxVSCROLL|wxWANTS_CHARS, name);
 
 #if wxUSE_VALIDATORS
     SetValidator(validator);
@@ -3600,7 +3600,7 @@ void wxTreeListMainWindow::OnChar (wxKeyEvent &event) {
         default:
             if (event.GetKeyCode() >= (int)' ') {
                 if (!m_findTimer->IsRunning()) m_findStr.Clear();
-                m_findStr.Append (event.GetKeyCode());
+                m_findStr.Append ((char)event.GetKeyCode());
                 m_findTimer->Start (FIND_TIMER_TICKS, wxTIMER_ONE_SHOT);
                 wxTreeItemId prev = m_curItem? (wxTreeItemId*)m_curItem: (wxTreeItemId*)NULL;
                 while (true) {
@@ -4681,6 +4681,18 @@ int wxTreeListCtrl::GetColumnCount() const
 
 void wxTreeListCtrl::SetColumnWidth(int column, int width)
 {
+    if (width == wxLIST_AUTOSIZE_USEHEADER)
+    {
+        wxFont font = m_header_win->GetFont();
+        m_header_win->GetTextExtent(m_header_win->GetColumnText(column), &width, NULL, NULL, NULL, font.Ok()? &font: NULL);
+        //search wxTreeListHeaderWindow::OnPaint to understand this:
+        width += 2*EXTRA_WIDTH + MARGIN;
+    }
+    else if (width == wxLIST_AUTOSIZE)
+    {
+        width = m_main_win->GetBestColumnWidth(column);
+    }
+    
     m_header_win->SetColumnWidth (column, width);
     m_header_win->Refresh();
 }