// common part of all ctors
void Init();
+ void SendListEvent(wxEventType type, wxPoint pos);
+
DECLARE_DYNAMIC_CLASS(wxListHeaderWindow)
DECLARE_EVENT_TABLE()
};
// suspend/resume redrawing the control
void Freeze();
void Thaw();
-
+
void SetFocus();
void OnRenameTimer();
if ( item->HasImage() )
{
- m_gi->m_rectIcon.x = m_gi->m_rectAll.x + 4
- + (spacing - m_gi->m_rectIcon.width)/2;
+ m_gi->m_rectIcon.x = m_gi->m_rectAll.x + 4 +
+ (m_gi->m_rectAll.width - m_gi->m_rectIcon.width) / 2;
m_gi->m_rectIcon.y = m_gi->m_rectAll.y + 4;
}
if (m_isDragging)
{
+ SendListEvent(wxEVT_COMMAND_LIST_COL_DRAGGING,
+ event.GetPosition());
+
// we don't draw the line beyond our window, but we allow dragging it
// there
int w = 0;
m_isDragging = FALSE;
m_dirty = TRUE;
m_owner->SetColumnWidth( m_column, m_currentX - m_minX );
+ SendListEvent(wxEVT_COMMAND_LIST_COL_END_DRAG,
+ event.GetPosition());
}
else
{
m_currentX = x;
DrawCurrent();
CaptureMouse();
+ SendListEvent(wxEVT_COMMAND_LIST_COL_BEGIN_DRAG,
+ event.GetPosition());
}
else // click on a column
{
- wxWindow *parent = GetParent();
- wxListEvent le( event.LeftDown()
+ SendListEvent( event.LeftDown()
? wxEVT_COMMAND_LIST_COL_CLICK
: wxEVT_COMMAND_LIST_COL_RIGHT_CLICK,
- parent->GetId() );
- le.SetEventObject( parent );
- le.m_pointDrag = event.GetPosition();
-
- // the position should be relative to the parent window, not
- // this one for compatibility with MSW and common sense: the
- // user code doesn't know anything at all about this header
- // window, so why should it get positions relative to it?
- le.m_pointDrag.y -= GetSize().y;
-
- le.m_col = m_column;
- parent->GetEventHandler()->ProcessEvent( le );
+ event.GetPosition());
}
}
else if (event.Moving())
m_owner->SetFocus();
}
+void wxListHeaderWindow::SendListEvent(wxEventType type, wxPoint pos)
+{
+ wxWindow *parent = GetParent();
+ wxListEvent le( type, parent->GetId() );
+ le.SetEventObject( parent );
+ le.m_pointDrag = pos;
+
+ // the position should be relative to the parent window, not
+ // this one for compatibility with MSW and common sense: the
+ // user code doesn't know anything at all about this header
+ // window, so why should it get positions relative to it?
+ le.m_pointDrag.y -= GetSize().y;
+
+ le.m_col = m_column;
+ parent->GetEventHandler()->ProcessEvent( le );
+}
+
//-----------------------------------------------------------------------------
// wxListRenameTimer (internal)
//-----------------------------------------------------------------------------
(*m_accept) = TRUE;
(*m_res) = GetValue();
-
+
if ((*m_res) != m_startValue)
m_owner->OnRenameAccept();
}
if ( ld->HasImage() && GetLineIconRect(line).Inside(x, y) )
return wxLIST_HITTEST_ONITEMICON;
- if ( ld->HasText() )
+ // VS: Testing for "ld->HasText() || InReportView()" instead of
+ // "ld->HasText()" is needed to make empty lines in report view
+ // possible
+ if ( ld->HasText() || InReportView() )
{
wxRect rect = InReportView() ? GetLineRect(line)
: GetLineLabelRect(line);
if (m_dirty)
wxSafeYield();
- wxClientDC dc(this);
- PrepareDC( dc );
-
wxString s = data->GetText(0);
wxRect rectLabel = GetLineLabelRect(m_currentEdit);
- rectLabel.x = dc.LogicalToDeviceX( rectLabel.x );
- rectLabel.y = dc.LogicalToDeviceY( rectLabel.y );
+ CalcScrolledPosition(rectLabel.x, rectLabel.y, &rectLabel.x, &rectLabel.y);
wxListTextCtrl *text = new wxListTextCtrl
(
#ifdef __WXGTK__
// FIXME: wxGTK generates bad sequence of events prior to doubleclick
- // ("down, up, down, double, up" while other ports
+ // ("down, up, down, double, up" while other ports
// do "down, up, double, up"). We have to have this hack
// in place till somebody fixes wxGTK...
if ( current == m_lineBeforeLastClicked )
void wxListMainWindow::SetFocus()
{
// VS: wxListMainWindow derives from wxPanel (via wxScrolledWindow) and wxPanel
- // overrides SetFocus in such way that it does never change focus from
+ // overrides SetFocus in such way that it does never change focus from
// panel's child to the panel itself. Unfortunately, we must be able to change
- // focus to the panel from wxListTextCtrl because the text control should
+ // focus to the panel from wxListTextCtrl because the text control should
// disappear when the user clicks outside it.
wxWindow *oldFocus = FindFocus();
-
+
if ( oldFocus && oldFocus->GetParent() == this )
{
wxWindow::SetFocus();
{
ResetCurrent();
+ if ( IsSingleSel() )
+ {
+ // we must unselect the old current item as well or we
+ // might end up with more than one selected item in a
+ // single selection control
+ HighlightLine(oldCurrent, FALSE);
+ }
+
RefreshLine( oldCurrent );
}
}
int clientWidth,
clientHeight;
GetSize( &clientWidth, &clientHeight );
-
+
if ( HasFlag(wxLC_REPORT) )
{
// all lines have the same height
{
// We start with 4 for the border around all items
entireWidth = 4;
-
+
if (tries == 1)
{
// Now we have decided that the items do not fit into the
// a scrollbar at the bottom of its client area.
entireWidth += SCROLL_UNIT_X;
}
-
+
// Start at 2,2 so the text does not touch the border
int x = 2;
int y = 2;
entireWidth += maxWidth+6;
maxWidth = 0;
}
-
+
// We have reached the last item.
if ( i == count - 1 )
entireWidth += maxWidth;
-
+
if ( (tries == 0) && (entireWidth+SCROLL_UNIT_X > clientWidth) )
{
clientHeight -= 15; // We guess the scrollbar height. (FIXME)
currentlyVisibleLines = 0;
break;
}
-
+
if ( i == count - 1 )
tries = 1; // Everything fits, no second try required.
}
m_dirty = TRUE;
m_columns.DeleteNode( node );
+
+ // invalidate it as it has to be recalculated
+ m_headerWidth = 0;
}
void wxListMainWindow::DoDeleteAllItems()
{
m_columns.Append( column );
}
+
+ // invalidate it as it has to be recalculated
+ m_headerWidth = 0;
}
}
IMPLEMENT_DYNAMIC_CLASS(wxListItem, wxObject)
-wxListItem::wxListItem()
-{
- m_attr = NULL;
-
- Clear();
-}
-
-void wxListItem::Clear()
-{
- m_mask = 0;
- m_itemId = 0;
- m_col = 0;
- m_state = 0;
- m_stateMask = 0;
- m_image = -1;
- m_data = 0;
- m_format = wxLIST_FORMAT_CENTRE;
- m_width = 0;
- m_text.clear();
-
- ClearAttributes();
-}
-
-void wxListItem::ClearAttributes()
-{
- if (m_attr)
- {
- delete m_attr;
- m_attr = NULL;
- }
-}
-
// -------------------------------------------------------------------------------------
// wxListCtrl
// -------------------------------------------------------------------------------------
return m_mainWin->GetItemSpacing( isSmall );
}
+void wxListCtrl::SetItemTextColour( long item, const wxColour &col )
+{
+ wxListItem info;
+ info.m_itemId = item;
+ info.SetTextColour( col );
+ m_mainWin->SetItem( info );
+}
+
+wxColour wxListCtrl::GetItemTextColour( long item ) const
+{
+ wxListItem info;
+ info.m_itemId = item;
+ m_mainWin->GetItem( info );
+ return info.GetTextColour();
+}
+
+void wxListCtrl::SetItemBackgroundColour( long item, const wxColour &col )
+{
+ wxListItem info;
+ info.m_itemId = item;
+ info.SetBackgroundColour( col );
+ m_mainWin->SetItem( info );
+}
+
+wxColour wxListCtrl::GetItemBackgroundColour( long item ) const
+{
+ wxListItem info;
+ info.m_itemId = item;
+ m_mainWin->GetItem( info );
+ return info.GetBackgroundColour();
+}
+
int wxListCtrl::GetSelectedItemCount() const
{
return m_mainWin->GetSelectedItemCount();
// event handlers
// ----------------------------------------------------------------------------
-void wxListCtrl::OnSize(wxSizeEvent& event)
+void wxListCtrl::OnSize(wxSizeEvent& WXUNUSED(event))
{
if ( !m_mainWin )
return;
// virtual list control support
// ----------------------------------------------------------------------------
-wxString wxListCtrl::OnGetItemText(long item, long col) const
+wxString wxListCtrl::OnGetItemText(long WXUNUSED(item), long WXUNUSED(col)) const
{
// this is a pure virtual function, in fact - which is not really pure
// because the controls which are not virtual don't need to implement it
- wxFAIL_MSG( _T("not supposed to be called") );
+ wxFAIL_MSG( _T("wxListCtrl::OnGetItemText not supposed to be called") );
return wxEmptyString;
}
-int wxListCtrl::OnGetItemImage(long item) const
+int wxListCtrl::OnGetItemImage(long WXUNUSED(item)) const
{
// same as above
- wxFAIL_MSG( _T("not supposed to be called") );
+ wxFAIL_MSG( _T("wxListCtrl::OnGetItemImage not supposed to be called") );
return -1;
}
}
#endif // wxUSE_LISTCTRL
+
+// vi:sts=4:sw=4:et