// headers
// ----------------------------------------------------------------------------
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
- #pragma implementation "listctrl.h"
- #pragma implementation "listctrlbase.h"
-#endif
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#pragma hdrstop
#endif
-#if wxUSE_LISTCTRL && defined(__WIN95__)
+#if wxUSE_LISTCTRL
#ifndef WX_PRECOMP
#include "wx/app.h"
#if defined(__VISUALC__) || defined(__BORLANDC__) || defined(NMLVFINDITEM)
#define HAVE_NMLVFINDITEM 1
#elif defined(__DMC__) || defined(NM_FINDITEM)
- #define HAVE_NM_FINDITEM 1
+ #define HAVE_NMLVFINDITEM 1
+ #define NMLVFINDITEM NM_FINDITEM
#endif
// ----------------------------------------------------------------------------
}
// init with conversion
- void Init(LV_ITEM_OTHER& item)
+ void Init(const LV_ITEM_OTHER& item)
{
// avoid unnecessary dynamic memory allocation, jjust make m_pItem
// point to our own m_item
// versions of _some_ messages (notably LVN_GETDISPINFOA) in MSLU build
wxSetCCUnicodeFormat(GetHwnd());
+ // We must set the default text colour to the system/theme color, otherwise
+ // GetTextColour will always return black
+ SetTextColour(GetDefaultAttributes().colFg);
+
// for comctl32.dll v 4.70+ we want to have some non default extended
// styles because it's prettier (and also because wxGTK does it like this)
if ( InReportView() && wxApp::GetComCtl32Version() >= 470 )
}
// Sets information about this column
-bool wxListCtrl::SetColumn(int col, wxListItem& item)
+bool wxListCtrl::SetColumn(int col, const wxListItem& item)
{
LV_COLUMN lvCol;
wxConvertToMSWListCol(col, item, lvCol);
data->lParam = info.m_data;
// attributes
- if (info.HasAttributes())
+ if ( info.HasAttributes() )
{
- if (data->attr)
- *data->attr = *info.GetAttributes();
+ const wxListItemAttr& attrNew = *info.GetAttributes();
+
+ // don't overwrite the already set attributes if we have them
+ if ( data->attr )
+ data->attr->AssignFrom(attrNew);
else
- data->attr = new wxListItemAttr(*info.GetAttributes());
+ data->attr = new wxListItemAttr(attrNew);
};
};
m_imageListState = imageList;
m_ownsImageListState = false;
}
- ListView_SetImageList(GetHwnd(), (HIMAGELIST) imageList ? imageList->GetHIMAGELIST() : 0, flags);
+ (void) ListView_SetImageList(GetHwnd(), (HIMAGELIST) imageList ? imageList->GetHIMAGELIST() : 0, flags);
}
void wxListCtrl::AssignImageList(wxImageList *imageList, int which)
// Inserts an item, returning the index of the new item if successful,
// -1 otherwise.
-long wxListCtrl::InsertItem(wxListItem& info)
+long wxListCtrl::InsertItem(const wxListItem& info)
{
wxASSERT_MSG( !IsVirtual(), _T("can't be used with virtual controls") );
}
// For list view mode (only), inserts a column.
-long wxListCtrl::InsertColumn(long col, wxListItem& item)
+long wxListCtrl::InsertColumn(long col, const wxListItem& item)
{
LV_COLUMN lvCol;
wxConvertToMSWListCol(col, item, lvCol);
return internalData->user_fn(d1, d2, internalData->data);
-};
+}
bool wxListCtrl::SortItems(wxListCtrlCompare fn, long data)
{
}
break;
-#if HAVE_NMLVFINDITEM || HAVE_NM_FINDITEM
+#ifdef HAVE_NMLVFINDITEM
case LVN_ODFINDITEM:
// this message is only used with the virtual list control but
// even there we don't want to always use it: in a control with
// application waiting while it performs linear search
if ( IsVirtual() && GetItemCount() <= 1000 )
{
-#if HAVE_NMLVFINDITEM
NMLVFINDITEM* pFindInfo = (NMLVFINDITEM*)lParam;
-#else
- NM_FINDITEM* pFindInfo = (NM_FINDITEM*)lParam;
-#endif
// no match by default
*result = -1;
processed = false;
}
break;
-#endif // HAVE_NMLVFINDITEM || HAVE_NM_FINDITEM
+#endif // HAVE_NMLVFINDITEM
case LVN_GETDISPINFO:
if ( IsVirtual() )
return NULL;
return (wxListItemInternalData *) it.lParam;
-};
+}
static
wxListItemInternalData *wxGetInternalData(const wxListCtrl *ctl, long itemId)
{
return wxGetInternalData(GetHwndOf(ctl), itemId);
-};
+}
static wxListItemAttr *wxGetInternalDataAttr(wxListCtrl *ctl, long itemId)
{
wxListItemInternalData *data = wxGetInternalData(ctl, itemId);
return data ? data->attr : NULL;
-};
+}
static void wxDeleteInternalData(wxListCtrl* ctl, long itemId)
{
// pszText is not const, hence the cast
lvItem.pszText = (wxChar *)info.m_text.c_str();
if ( lvItem.pszText )
- lvItem.cchTextMax = info.m_text.Length();
+ lvItem.cchTextMax = info.m_text.length();
else
lvItem.cchTextMax = 0;
}
//
// we don't use LVCFMT_COL_HAS_IMAGES because it doesn't seem to
// make any difference in my tests -- but maybe we should?
- lvCol.fmt |= LVCFMT_BITMAP_ON_RIGHT | LVCFMT_IMAGE;
+ if ( item.m_image != -1 )
+ lvCol.fmt |= LVCFMT_BITMAP_ON_RIGHT | LVCFMT_IMAGE;
lvCol.iImage = item.m_image;
}
}
#endif // wxUSE_LISTCTRL
-