static const int EXTRA_BORDER_Y = 2;
// offset for the header window
-static const int HEADER_OFFSET_X = 1;
-static const int HEADER_OFFSET_Y = 1;
+static const int HEADER_OFFSET_X = 0;
+static const int HEADER_OFFSET_Y = 0;
// margin between rows of icons in [small] icon view
static const int MARGIN_BETWEEN_ROWS = 6;
m_owner->GetColumn( i, item );
int wCol = item.m_width;
- // the width of the rect to draw: make it smaller to fit entirely
- // inside the column rect
-#ifdef __WXMAC__
int cw = wCol;
int ch = h;
-#else
- int cw = wCol - 2;
- int ch = h - 2;
-#endif
int flags = 0;
if (!m_parent->IsEnabled())
void wxListHeaderWindow::DrawCurrent()
{
+#if 1
+ m_owner->SetColumnWidth( m_column, m_currentX - m_minX );
+#else
int x1 = m_currentX;
int y1 = 0;
m_owner->ClientToScreen( &x1, &y1 );
dc.SetPen( wxNullPen );
dc.SetBrush( wxNullBrush );
+#endif
}
void wxListHeaderWindow::OnMouse( wxMouseEvent &event )
{
const wxString value = m_text->GetValue();
- if ( value == m_startValue )
- // nothing changed, always accept
- return true;
-
+ // notice that we should always call OnRenameAccept() to generate the "end
+ // label editing" event, even if the user hasn't really changed anything
if ( !m_owner->OnRenameAccept(m_itemEdited, value) )
+ {
// vetoed by the user
return false;
+ }
- // accepted, do rename the item
- m_owner->SetItemText(m_itemEdited, value);
+ // accepted, do rename the item (unless nothing changed)
+ if ( value != m_startValue )
+ m_owner->SetItemText(m_itemEdited, value);
return true;
}
if ( !InReportView() )
return GetLine(line)->m_gi->m_rectLabel;
+ int image_x = 0;
+ wxListLineData *data = GetLine(line);
+ wxListItemDataList::compatibility_iterator node = data->m_items.GetFirst();
+ if (node)
+ {
+ wxListItemData *item = node->GetData();
+ if ( item->HasImage() )
+ {
+ int ix, iy;
+ GetImageSize( item->GetImage(), ix, iy );
+ image_x = 3 + ix + IMAGE_MARGIN_IN_REPORT_MODE;
+ }
+ }
+
wxRect rect;
rect.x = HEADER_OFFSET_X;
rect.y = GetLineY(line);
wxPen pen(GetRuleColour(), 1, wxSOLID);
wxSize clientSize = GetClientSize();
- // Don't draw the first one
- for ( size_t i = visibleFrom + 1; i <= visibleTo; i++ )
+ size_t i = visibleFrom;
+ if (i == 0) i = 1; // Don't draw the first one
+ for ( ; i <= visibleTo; i++ )
{
dc.SetPen(pen);
dc.SetBrush( *wxTRANSPARENT_BRUSH );
{
int colWidth = GetColumnWidth(col);
x += colWidth;
- dc.DrawLine(x - dev_x - 2, firstItemRect.GetY() - 1 - dev_y,
- x - dev_x - 2, lastItemRect.GetBottom() + 1 - dev_y);
+ int x_pos = x - dev_x;
+ if (col < GetColumnCount()-1) x_pos -= 2;
+ dc.DrawLine(x_pos, firstItemRect.GetY() - 1 - dev_y,
+ x_pos, lastItemRect.GetBottom() + 1 - dev_y);
}
}
}
(hitResult == wxLIST_HITTEST_ONITEMLABEL) &&
HasFlag(wxLC_EDIT_LABELS) )
{
- m_renameTimer->Start( 100, true );
+ if (InReportView())
+ {
+ wxRect label = GetLineLabelRect( current );
+ if (label.Contains( x, y ))
+ m_renameTimer->Start( 250, true );
+
+ }
+ else
+ m_renameTimer->Start( 250, true );
}
}
else // !shift
{
// all previously selected items are unselected unless ctrl is held
- if ( !event.ControlDown() )
+ // in a multiselection control
+ if ( !event.ControlDown() || IsSingleSel() )
HighlightAll(false);
ChangeCurrent(newCurrent);
// refresh the old focus to remove it
RefreshLine( oldCurrent );
- if ( !event.ControlDown() )
- {
+ // in single selection mode we must always have a selected item
+ if ( !event.ControlDown() || IsSingleSel() )
HighlightLine( m_current, true );
- }
}
RefreshLine( m_current );
case WXK_SPACE:
if ( IsSingleSel() )
{
- SendNotify( m_current, wxEVT_COMMAND_LIST_ITEM_ACTIVATED );
-
- if ( IsHighlighted(m_current) )
+ if ( event.ControlDown() )
{
- // don't unselect the item in single selection mode
- break;
+ ReverseHighlight(m_current);
+ }
+ else // normal space press
+ {
+ SendNotify( m_current, wxEVT_COMMAND_LIST_ITEM_ACTIVATED );
}
- //else: select it in ReverseHighlight() below if unselected
}
-
- ReverseHighlight(m_current);
+ else // multiple selection
+ {
+ ReverseHighlight(m_current);
+ }
break;
case WXK_RETURN:
void wxListMainWindow::SortItems( wxListCtrlCompare fn, long data )
{
+ // selections won't make sense any more after sorting the items so reset
+ // them
+ HighlightAll(false);
+ ResetCurrent();
+
list_ctrl_compare_func_2 = fn;
list_ctrl_compare_data = data;
m_lines.Sort( list_ctrl_compare_func_1 );
void wxListMainWindow::OnScroll(wxScrollWinEvent& event)
{
- // update our idea of which lines are shown when we redraw the window the
- // next time
- ResetVisibleLinesRange();
-
// FIXME
#if ( defined(__WXGTK__) || defined(__WXMAC__) ) && !defined(__WXUNIVERSAL__)
wxScrolledWindow::OnScroll(event);
HandleOnScroll( event );
#endif
+ // update our idea of which lines are shown when we redraw the window the
+ // next time
+ ResetVisibleLinesRange();
+
if ( event.GetOrientation() == wxHORIZONTAL && HasHeader() )
{
wxGenericListCtrl* lc = GetListCtrl();
if ( !wxControl::Create( parent, id, pos, size, style, validator, name ) )
return false;
+ // this window itself shouldn't get the focus, only m_mainWin should
+ SetCanFocus(false);
+
// don't create the inner window with the border
style &= ~wxBORDER_MASK;