wxWindows 2 Change Log
----------------------
-2.3.3
+2.3.2
-----
wxBase:
- wxRegEx class added
-2.3.2
------
+All (GUI):
+
+- support for virtual list control added
2.3.1
-----
A list control presents lists in a number of formats: list view, report view,
icon view and small icon view. In any case, elements are numbered from zero.
-
-Using many of wxListCtrl is shown in the
+For all these modes, the items are stored in the control and must be added to
+it using \helpref{InsertItem}{wxlistctrlinsertitem} method.
+
+A special case of report view quite different from the other modes of the list
+control is a virtual control in which the items data (including text, images
+and attributes) is managed by the main program and is requested by the control
+itself only when needed which allows to have controls with millions of items
+without consuming much memory. To use virtual list control you must use
+\helpref{SetItemCount}{wxlistctrlsetitemcount} first and overload at least
+\helpref{OnGetItemText}{wxlistctrlongetitemtext} (and optionally
+\helpref{OnGetItemImage}{wxlistctrlongetitemimage} and
+\helpref{OnGetItemAttr}{wxlistctrlongetitemattr}) to return the information
+about the items when the control requests it.
+
+Using many of wxListCtrl features is shown in the
\helpref{corresponding sample}{samplelistctrl}.
To intercept events from a list control, use the event table macros described
Columns are computed automatically, i.e. you don't set columns as in wxLC\_REPORT. In other words,
the list wraps, unlike a wxListBox.}
\twocolitem{\windowstyle{wxLC\_REPORT}}{single or multicolumn report view, with optional header.}
+\twocolitem{\windowstyle{wxLC\_VIRTUAL}}{virtual control, may only be used with wxLC\_REPORT}
\twocolitem{\windowstyle{wxLC\_ICON}}{Large icon view, with optional labels.}
\twocolitem{\windowstyle{wxLC\_SMALL\_ICON}}{Small icon view, with optional labels.}
\twocolitem{\windowstyle{wxLC\_ALIGN\_TOP}}{Icons align to the top. Win32 default, Win32 only. }
\twocolitem{{\bf EVT\_LIST\_INSERT\_ITEM(id, func)}}{An item has been inserted.}
\twocolitem{{\bf EVT\_LIST\_COL\_CLICK(id, func)}}{A column ({\bf m\_col}) has been left-clicked.}
\twocolitem{{\bf EVT\_LIST\_ITEM\_RIGHT\_CLICK(id, func)}}{An item has been right-clicked.}
+\twocolitem{{\bf EVT\_LIST\_CACHE\_HINT(id, func)}}{Prepare cache for a virtual list control}
\end{twocollist}%
\wxheading{See also}
\end{twocollist}
}}
+\membersection{wxListCtrl::OnGetItemAttr}\label{wxlistctrlongetitemattr}
+
+\func{virtual wxString}{OnGetItemAttr}{\param{long }{item}}
+
+This function may be overloaded in the derived class for a control with
+{\tt wxLC\_VIRTUAL} style. It should return the attribute for the
+for the specified {\tt item} or {\tt NULL} to use the default appearance
+parameters.
+
+The base class version always returns {\tt NULL}.
+
+\wxheading{See also}
+
+\helpref{OnGetItemImage}{wxlistctrlongetitemimage},\\
+\helpref{OnGetItemText}{wxlistctrlongetitemtext}
+
+\membersection{wxListCtrl::OnGetItemImage}\label{wxlistctrlongetitemimage}
+
+\func{virtual wxString}{OnGetItemImage}{\param{long }{item}}
+
+This function may be overloaded in the derived class for a control with
+{\tt wxLC\_VIRTUAL} style. It should return the index of the items image in the
+controls image list or $-1$ for no image.
+
+The base class version always returns $-1$.
+
+\wxheading{See also}
+
+\helpref{OnGetItemText}{wxlistctrlongetitemtext},\\
+\helpref{OnGetItemAttr}{wxlistctrlongetitemattr}
+
+\membersection{wxListCtrl::OnGetItemText}\label{wxlistctrlongetitemtext}
+
+\func{virtual wxString}{OnGetItemText}{\param{long }{item}, \param{long }{column}}
+
+This function {\bf must} be overloaded in the derived class for a control with
+{\tt wxLC\_VIRTUAL} style. It should return the string containing the text of
+the given {\it column} for the specified {\tt item}.
+
+\wxheading{See also}
+
+\helpref{SetItemCount}{wxlistctrlsetitemcount},\\
+\helpref{OnGetItemImage}{wxlistctrlongetitemimage},\\
+\helpref{OnGetItemAttr}{wxlistctrlongetitemattr}
+
\membersection{wxListCtrl::ScrollList}\label{wxlistctrlscrolllist}
\func{bool}{ScrollList}{\param{int }{dx}, \param{int }{dy}}
\end{twocollist}}
}
+\membersection{wxListCtrl::SetItemCount}\label{wxlistctrlsetitemcount}
+
+\func{void}{SetItemCount}{\param{long }{count}}
+
+This method can only be used with virtual list controls. It is used to indicate
+to the control the number of items it contains. After calling it, the main
+program should be ready to handle calls to various item callbacks (such as
+\helpref{OnGetItemText}{wxlistctrlongetitemtext}) for all vitems in the range
+from $0$ to {\it count}.
+
\membersection{wxListCtrl::SetItemData}\label{wxlistctrlsetitemdata}
\func{bool}{SetItemData}{\param{long }{item}, \param{long }{data}}
\twocolitem{{\bf EVT\_LIST\_KEY\_DOWN(id, func)}}{A key has been pressed.}
\twocolitem{{\bf EVT\_LIST\_INSERT\_ITEM(id, func)}}{An item has been inserted.}
\twocolitem{{\bf EVT\_LIST\_COL\_CLICK(id, func)}}{A column ({\bf m\_col}) has been left-clicked.}
+\twocolitem{{\bf EVT\_LIST\_CACHE\_HINT(id, func)}}{Prepare cache for a virtual list control}
\end{twocollist}%
\wxheading{See also}
Constructor.
+\membersection{wxListEvent::GetCacheFrom}\label{wxlisteventgetcachefrom}
+
+\constfunc{long}{GetCacheFrom}{\void}
+
+For {\tt EVT\_LIST\_CACHE\_HINT} event only: return the first item which the
+list control advises us to cache.
+
+\membersection{wxListEvent::GetCacheTo}\label{wxlisteventgetcacheto}
+
+\constfunc{long}{GetCacheTo}{\void}
+
+For {\tt EVT\_LIST\_CACHE\_HINT} event only: return the last item (inclusive)
+which the list control advises us to cache.
+
\membersection{wxListEvent::GetCode}\label{wxlisteventgetcode}
\constfunc{int}{GetCode}{\void}
long GetMask() const { return m_item.m_mask; }
const wxListItem& GetItem() const { return m_item; }
+ // for wxEVT_COMMAND_LIST_CACHE_HINT only
+ long GetCacheFrom() const { return m_oldItemIndex; }
+ long GetCacheTo() const { return m_itemIndex; }
+
void CopyObject(wxObject& object_dest) const;
private:
DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, 713)
DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK, 714)
DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_ACTIVATED, 715)
+ DECLARE_EVENT_TYPE(wxEVT_COMMAND_LIST_CACHE_HINT, 716)
END_DECLARE_EVENT_TYPES()
typedef void (wxEvtHandler::*wxListEventFunction)(wxListEvent&);
#define EVT_LIST_ITEM_RIGHT_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL ),
#define EVT_LIST_ITEM_MIDDLE_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL ),
#define EVT_LIST_ITEM_ACTIVATED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL ),
+#define EVT_LIST_CACHE_HINT(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_LIST_CACHE_HINT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL ),
#endif // wxUSE_LISTCTRL
EVT_LIST_KEY_DOWN(LIST_CTRL, MyListCtrl::OnListKeyDown)
EVT_LIST_ITEM_ACTIVATED(LIST_CTRL, MyListCtrl::OnActivated)
EVT_LIST_COL_CLICK(LIST_CTRL, MyListCtrl::OnColClick)
+ EVT_LIST_CACHE_HINT(LIST_CTRL, MyListCtrl::OnCacheHint)
EVT_CHAR(MyListCtrl::OnChar)
END_EVENT_TABLE()
// MyListCtrl
+void MyListCtrl::OnCacheHint(wxListEvent& event)
+{
+ wxLogMessage( "OnCacheHint: cache items %ld..%ld",
+ event.GetCacheFrom(), event.GetCacheTo() );
+}
+
void MyListCtrl::OnColClick(wxListEvent& event)
{
wxLogMessage( "OnColumnClick at %d.", event.GetColumn() );
void OnDeselected(wxListEvent& event);
void OnListKeyDown(wxListEvent& event);
void OnActivated(wxListEvent& event);
+ void OnCacheHint(wxListEvent& event);
void OnChar(wxKeyEvent& event);
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_ACTIVATED)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_CACHE_HINT)
// ----------------------------------------------------------------------------
// constants
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_ACTIVATED)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_CACHE_HINT)
IMPLEMENT_DYNAMIC_CLASS(wxListCtrl, wxControl)
IMPLEMENT_DYNAMIC_CLASS(wxListItem, wxObject)
return TRUE;
#endif // _WIN32_IE >= 0x300
+ case LVN_ODCACHEHINT:
+ {
+ const NM_CACHEHINT *cacheHint = (NM_CACHEHINT *)lParam;
+
+ eventType = wxEVT_COMMAND_LIST_CACHE_HINT;
+ event.m_oldItemIndex = cacheHint->iFrom;
+ event.m_itemIndex = cacheHint->iTo;
+ }
+ break;
+
case LVN_GETDISPINFO:
if ( IsVirtual() )
{
return TRUE;
case LVN_ENDLABELEDIT:
- {
- *result = event.IsAllowed();
- return TRUE;
- }
+ // logic here is inversed compared to all the other messages
+ *result = event.IsAllowed();
+
+ return TRUE;
}
*result = !event.IsAllowed();