// Purpose: Common defines for wxListCtrl and wxListCtrl-based classes.
// Author: Kevin Ollivier
// Created: 09/15/06
-// RCS-ID: $Id$
// Copyright: (c) Kevin Ollivier
// Licence: wxWindows licence
////////////////////////////////////////////////////////////////////////////////
const char wxListCtrlNameStr[] = "listCtrl";
// ListCtrl events
-wxDEFINE_EVENT( wxEVT_COMMAND_LIST_BEGIN_DRAG, wxListEvent );
-wxDEFINE_EVENT( wxEVT_COMMAND_LIST_BEGIN_RDRAG, wxListEvent );
-wxDEFINE_EVENT( wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT, wxListEvent );
-wxDEFINE_EVENT( wxEVT_COMMAND_LIST_END_LABEL_EDIT, wxListEvent );
-wxDEFINE_EVENT( wxEVT_COMMAND_LIST_DELETE_ITEM, wxListEvent );
-wxDEFINE_EVENT( wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS, wxListEvent );
-wxDEFINE_EVENT( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEvent );
-wxDEFINE_EVENT( wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEvent );
-wxDEFINE_EVENT( wxEVT_COMMAND_LIST_KEY_DOWN, wxListEvent );
-wxDEFINE_EVENT( wxEVT_COMMAND_LIST_INSERT_ITEM, wxListEvent );
-wxDEFINE_EVENT( wxEVT_COMMAND_LIST_COL_CLICK, wxListEvent );
-wxDEFINE_EVENT( wxEVT_COMMAND_LIST_COL_RIGHT_CLICK, wxListEvent );
-wxDEFINE_EVENT( wxEVT_COMMAND_LIST_COL_BEGIN_DRAG, wxListEvent );
-wxDEFINE_EVENT( wxEVT_COMMAND_LIST_COL_DRAGGING, wxListEvent );
-wxDEFINE_EVENT( wxEVT_COMMAND_LIST_COL_END_DRAG, wxListEvent );
-wxDEFINE_EVENT( wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, wxListEvent );
-wxDEFINE_EVENT( wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK, wxListEvent );
-wxDEFINE_EVENT( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEvent );
-wxDEFINE_EVENT( wxEVT_COMMAND_LIST_ITEM_FOCUSED, wxListEvent );
-wxDEFINE_EVENT( wxEVT_COMMAND_LIST_CACHE_HINT, wxListEvent );
+wxDEFINE_EVENT( wxEVT_LIST_BEGIN_DRAG, wxListEvent );
+wxDEFINE_EVENT( wxEVT_LIST_BEGIN_RDRAG, wxListEvent );
+wxDEFINE_EVENT( wxEVT_LIST_BEGIN_LABEL_EDIT, wxListEvent );
+wxDEFINE_EVENT( wxEVT_LIST_END_LABEL_EDIT, wxListEvent );
+wxDEFINE_EVENT( wxEVT_LIST_DELETE_ITEM, wxListEvent );
+wxDEFINE_EVENT( wxEVT_LIST_DELETE_ALL_ITEMS, wxListEvent );
+wxDEFINE_EVENT( wxEVT_LIST_ITEM_SELECTED, wxListEvent );
+wxDEFINE_EVENT( wxEVT_LIST_ITEM_DESELECTED, wxListEvent );
+wxDEFINE_EVENT( wxEVT_LIST_KEY_DOWN, wxListEvent );
+wxDEFINE_EVENT( wxEVT_LIST_INSERT_ITEM, wxListEvent );
+wxDEFINE_EVENT( wxEVT_LIST_COL_CLICK, wxListEvent );
+wxDEFINE_EVENT( wxEVT_LIST_COL_RIGHT_CLICK, wxListEvent );
+wxDEFINE_EVENT( wxEVT_LIST_COL_BEGIN_DRAG, wxListEvent );
+wxDEFINE_EVENT( wxEVT_LIST_COL_DRAGGING, wxListEvent );
+wxDEFINE_EVENT( wxEVT_LIST_COL_END_DRAG, wxListEvent );
+wxDEFINE_EVENT( wxEVT_LIST_ITEM_RIGHT_CLICK, wxListEvent );
+wxDEFINE_EVENT( wxEVT_LIST_ITEM_MIDDLE_CLICK, wxListEvent );
+wxDEFINE_EVENT( wxEVT_LIST_ITEM_ACTIVATED, wxListEvent );
+wxDEFINE_EVENT( wxEVT_LIST_ITEM_FOCUSED, wxListEvent );
+wxDEFINE_EVENT( wxEVT_LIST_CACHE_HINT, wxListEvent );
// -----------------------------------------------------------------------------
// XTI
#endif
wxBEGIN_PROPERTIES_TABLE(wxListCtrl)
-wxEVENT_PROPERTY( TextUpdated, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEvent )
+wxEVENT_PROPERTY( TextUpdated, wxEVT_TEXT, wxCommandEvent )
wxPROPERTY_FLAGS( WindowStyle, wxListCtrlStyle, long, SetWindowStyleFlag, \
GetWindowStyleFlag, wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \
long
wxListCtrlBase::AppendColumn(const wxString& heading,
- int format,
+ wxListColumnFormat format,
int width)
{
return InsertColumn(GetColumnCount(), heading, format, width);
return wxSize(totalWidth, 10*dc.GetCharHeight());
}
+void wxListCtrlBase::SetAlternateRowColour(const wxColour& colour)
+{
+ wxASSERT(HasFlag(wxLC_VIRTUAL));
+ m_alternateRowColour.SetBackgroundColour(colour);
+}
+
+void wxListCtrlBase::EnableAlternateRowColours(bool enable)
+{
+ if ( enable )
+ {
+ // This code is copied from wxDataViewMainWindow::OnPaint()
+
+ // Determine the alternate rows colour automatically from the
+ // background colour.
+ const wxColour bgColour = GetBackgroundColour();
+
+ // Depending on the background, alternate row color
+ // will be 3% more dark or 50% brighter.
+ int alpha = bgColour.GetRGB() > 0x808080 ? 97 : 150;
+ SetAlternateRowColour(bgColour.ChangeLightness(alpha));
+ }
+ else // Disable striping by setting invalid alternative colour.
+ {
+ SetAlternateRowColour(wxColour());
+ }
+}
+
+wxListItemAttr *wxListCtrlBase::OnGetItemAttr(long item) const
+{
+ return (m_alternateRowColour.GetBackgroundColour().IsOk() && (item % 2))
+ ? wxConstCast(&m_alternateRowColour, wxListItemAttr)
+ : NULL; // no attributes by default
+}
+
#endif // wxUSE_LISTCTRL