X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3dfb93fd8225558306cb41fd6f4b1a2516859565..e3e717ecc5add075cd53a04cf24fe27e24170944:/src/generic/listctrl.cpp?ds=inline diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index e319bca803..02741c4278 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -685,7 +685,7 @@ wxListHeaderWindow::wxListHeaderWindow( void ) m_owner = (wxListMainWindow *) NULL; m_currentCursor = (wxCursor *) NULL; m_resizeCursor = (wxCursor *) NULL; - m_isDraging = FALSE; + m_isDragging = FALSE; } wxListHeaderWindow::wxListHeaderWindow( wxWindow *win, wxWindowID id, wxListMainWindow *owner, @@ -697,7 +697,8 @@ wxListHeaderWindow::wxListHeaderWindow( wxWindow *win, wxWindowID id, wxListMain // m_currentCursor = wxSTANDARD_CURSOR; m_currentCursor = (wxCursor *) NULL; m_resizeCursor = new wxCursor( wxCURSOR_SIZEWE ); - m_isDraging = FALSE; + m_isDragging = FALSE; + SetBackgroundColour( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ) ); } wxListHeaderWindow::~wxListHeaderWindow( void ) @@ -780,7 +781,7 @@ void wxListHeaderWindow::DrawCurrent() m_owner->ClientToScreen( &x2, &y2 ); wxScreenDC dc; - dc.SetLogicalFunction( wxXOR ); + dc.SetLogicalFunction( wxINVERT ); dc.SetPen( wxPen( *wxBLACK, 2, wxSOLID ) ); dc.SetBrush( *wxTRANSPARENT_BRUSH ); @@ -796,13 +797,13 @@ void wxListHeaderWindow::OnMouse( wxMouseEvent &event ) { int x = event.GetX(); int y = event.GetY(); - if (m_isDraging) + if (m_isDragging) { DrawCurrent(); if (event.ButtonUp()) { ReleaseMouse(); - m_isDraging = FALSE; + m_isDragging = FALSE; m_owner->SetColumnWidth( m_column, m_currentX-m_minX ); } else @@ -837,7 +838,7 @@ void wxListHeaderWindow::OnMouse( wxMouseEvent &event ) if (event.LeftDown() && hit_border) { - m_isDraging = TRUE; + m_isDragging = TRUE; m_currentX = x; DrawCurrent(); CaptureMouse(); @@ -1423,6 +1424,14 @@ void wxListMainWindow::OnChar( wxKeyEvent &event ) ke.SetEventObject( parent ); if (parent->GetEventHandler()->ProcessEvent( ke )) return; + if (event.KeyCode() == WXK_TAB) + { + wxNavigationKeyEvent nevent; + nevent.SetDirection( !event.ShiftDown() ); + nevent.SetCurrentFocus( m_parent ); + if (m_parent->GetEventHandler()->ProcessEvent( nevent )) return; + } + /* no item -> nothing to do */ if (!m_current) { @@ -1686,7 +1695,44 @@ void wxListMainWindow::SetColumnWidth( int col, int width ) m_dirty = TRUE; - wxNode *node = m_columns.Nth( col ); + wxNode *node = (wxNode*) NULL; + + if (width == wxLIST_AUTOSIZE_USEHEADER) width = 80; + if (width == wxLIST_AUTOSIZE) + { + wxClientDC dc(this); + dc.SetFont( GetFont() ); + int max = 10; + node = m_lines.First(); + while (node) + { + wxListLineData *line = (wxListLineData*)node->Data(); + wxNode *n = line->m_items.Nth( col ); + if (n) + { + wxListItemData *item = (wxListItemData*)n->Data(); + int current = 0, ix = 0, iy = 0; + long lx = 0, ly = 0; + if (item->HasImage()) + { + GetImageSize( item->GetImage(), ix, iy ); + current = ix + 5; + } + if (item->HasText()) + { + wxString str; + item->GetText( str ); + dc.GetTextExtent( str, &lx, &ly ); + current += lx; + } + if (current > max) max = current; + } + node = node->Next(); + } + width = max+10; + } + + node = m_columns.Nth( col ); if (node) { wxListHeaderData *column = (wxListHeaderData*)node->Data(); @@ -1780,7 +1826,7 @@ void wxListMainWindow::SetItemState( long item, long state, long stateMask ) m_current = line; FocusLine( m_current ); RefreshLine( m_current ); - RefreshLine( oldCurrent ); + if (oldCurrent) RefreshLine( oldCurrent ); } } @@ -1798,9 +1844,9 @@ void wxListMainWindow::SetItemState( long item, long state, long stateMask ) UnfocusLine( m_current ); m_current = line; FocusLine( m_current ); - oldCurrent->Hilight( FALSE ); + if (oldCurrent) oldCurrent->Hilight( FALSE ); RefreshLine( m_current ); - RefreshLine( oldCurrent ); + if (oldCurrent) RefreshLine( oldCurrent ); } bool on = state & wxLIST_STATE_SELECTED; if (on != line->IsHilighted()) @@ -2344,7 +2390,9 @@ bool wxListCtrl::Create( wxWindow *parent, wxWindowID id, bool ret = wxControl::Create( parent, id, pos, size, s, name ); +#if wxUSE_VALIDATORS SetValidator( validator ); +#endif if (s & wxSUNKEN_BORDER) s -= wxSUNKEN_BORDER; @@ -2829,7 +2877,7 @@ bool wxListCtrl::SetBackgroundColour( const wxColour &colour ) if (m_headerWin) { - m_headerWin->SetBackgroundColour( colour ); +// m_headerWin->SetBackgroundColour( colour ); } return TRUE;