1998-05-20 10:01:55 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
1999-12-04 17:34:54 -05:00
|
|
|
// Name: wx/generic/listctrl.h
|
1998-05-20 10:01:55 -04:00
|
|
|
// Purpose: Generic list control
|
|
|
|
// Author: Robert Roebling
|
|
|
|
// Created: 01/02/97
|
2005-01-14 08:07:44 -05:00
|
|
|
// RCS-ID: $Id$
|
2003-03-17 05:34:04 -05:00
|
|
|
// Copyright: (c) 1998 Robert Roebling and Julian Smart
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 10:01:55 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2006-10-02 13:38:30 -04:00
|
|
|
#ifndef _WX_GENERIC_LISTCTRL_H_
|
|
|
|
#define _WX_GENERIC_LISTCTRL_H_
|
|
|
|
|
2009-01-24 12:01:46 -05:00
|
|
|
#include "wx/scrolwin.h"
|
2006-02-24 18:40:01 -05:00
|
|
|
#include "wx/textctrl.h"
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2007-07-09 06:09:52 -04:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxImageList;
|
2006-10-02 13:38:30 -04:00
|
|
|
|
1998-12-20 18:49:21 -05:00
|
|
|
#if wxUSE_DRAG_AND_DROP
|
2007-07-09 06:09:52 -04:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxDropTarget;
|
1998-12-20 18:49:21 -05:00
|
|
|
#endif
|
|
|
|
|
1998-05-20 10:01:55 -04:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// internal classes
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2007-07-09 06:09:52 -04:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxListHeaderWindow;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxListMainWindow;
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// wxListCtrl
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2009-01-22 18:01:14 -05:00
|
|
|
class WXDLLIMPEXP_CORE wxGenericListCtrl: public wxControl,
|
|
|
|
public wxScrollHelper
|
1998-05-20 10:01:55 -04:00
|
|
|
{
|
1999-11-26 12:35:27 -05:00
|
|
|
public:
|
2006-09-16 21:20:08 -04:00
|
|
|
|
2009-01-22 18:01:14 -05:00
|
|
|
wxGenericListCtrl() : wxScrollHelper(this)
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
}
|
2009-01-27 07:01:54 -05:00
|
|
|
|
2002-07-22 04:51:49 -04:00
|
|
|
wxGenericListCtrl( wxWindow *parent,
|
2004-06-17 12:22:36 -04:00
|
|
|
wxWindowID winid = wxID_ANY,
|
2000-01-06 11:47:48 -05:00
|
|
|
const wxPoint &pos = wxDefaultPosition,
|
|
|
|
const wxSize &size = wxDefaultSize,
|
|
|
|
long style = wxLC_ICON,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
2009-01-27 07:01:54 -05:00
|
|
|
const wxString &name = wxListCtrlNameStr)
|
2009-01-22 18:01:14 -05:00
|
|
|
: wxScrollHelper(this)
|
2004-01-15 08:49:22 -05:00
|
|
|
{
|
|
|
|
Create(parent, winid, pos, size, style, validator, name);
|
|
|
|
}
|
2009-01-27 07:01:54 -05:00
|
|
|
|
2006-09-05 16:47:48 -04:00
|
|
|
virtual ~wxGenericListCtrl();
|
2009-01-27 07:01:54 -05:00
|
|
|
|
2009-01-22 18:01:14 -05:00
|
|
|
void Init();
|
2001-06-26 17:29:16 -04:00
|
|
|
|
2000-01-06 11:47:48 -05:00
|
|
|
bool Create( wxWindow *parent,
|
2004-06-17 12:22:36 -04:00
|
|
|
wxWindowID winid = wxID_ANY,
|
2000-01-06 11:47:48 -05:00
|
|
|
const wxPoint &pos = wxDefaultPosition,
|
|
|
|
const wxSize &size = wxDefaultSize,
|
|
|
|
long style = wxLC_ICON,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
2006-09-18 16:39:41 -04:00
|
|
|
const wxString &name = wxListCtrlNameStr);
|
1999-11-26 12:35:27 -05:00
|
|
|
|
1998-12-07 08:28:56 -05:00
|
|
|
bool GetColumn( int col, wxListItem& item ) const;
|
1998-07-04 11:17:59 -04:00
|
|
|
bool SetColumn( int col, wxListItem& item );
|
1998-12-07 08:28:56 -05:00
|
|
|
int GetColumnWidth( int col ) const;
|
1998-07-04 11:17:59 -04:00
|
|
|
bool SetColumnWidth( int col, int width);
|
1999-07-25 08:59:58 -04:00
|
|
|
int GetCountPerPage() const; // not the same in wxGLC as in Windows, I think
|
2003-09-14 11:58:41 -04:00
|
|
|
wxRect GetViewRect() const;
|
1999-11-26 12:35:27 -05:00
|
|
|
|
1998-12-07 08:28:56 -05:00
|
|
|
bool GetItem( wxListItem& info ) const;
|
1998-05-20 10:01:55 -04:00
|
|
|
bool SetItem( wxListItem& info ) ;
|
1998-07-04 11:17:59 -04:00
|
|
|
long SetItem( long index, int col, const wxString& label, int imageId = -1 );
|
1998-12-07 08:28:56 -05:00
|
|
|
int GetItemState( long item, long stateMask ) const;
|
1998-07-04 11:17:59 -04:00
|
|
|
bool SetItemState( long item, long state, long stateMask);
|
2004-09-30 18:27:45 -04:00
|
|
|
bool SetItemImage( long item, int image, int selImage = -1 );
|
2006-03-10 16:26:59 -05:00
|
|
|
bool SetItemColumnImage( long item, long column, int image );
|
1998-12-07 08:28:56 -05:00
|
|
|
wxString GetItemText( long item ) const;
|
1998-07-04 11:17:59 -04:00
|
|
|
void SetItemText( long item, const wxString& str );
|
2004-09-29 05:25:47 -04:00
|
|
|
wxUIntPtr GetItemData( long item ) const;
|
2007-05-09 21:53:21 -04:00
|
|
|
bool SetItemPtrData(long item, wxUIntPtr data);
|
|
|
|
bool SetItemData(long item, long data) { return SetItemPtrData(item, data); }
|
1999-01-31 08:58:17 -05:00
|
|
|
bool GetItemRect( long item, wxRect& rect, int code = wxLIST_RECT_BOUNDS ) const;
|
2008-06-30 14:21:33 -04:00
|
|
|
bool GetSubItemRect( long item, long subItem, wxRect& rect, int code = wxLIST_RECT_BOUNDS ) const;
|
1998-12-07 08:28:56 -05:00
|
|
|
bool GetItemPosition( long item, wxPoint& pos ) const;
|
1998-07-04 11:17:59 -04:00
|
|
|
bool SetItemPosition( long item, const wxPoint& pos ); // not supported in wxGLC
|
1999-07-25 08:59:58 -04:00
|
|
|
int GetItemCount() const;
|
|
|
|
int GetColumnCount() const;
|
2004-06-17 12:22:36 -04:00
|
|
|
void SetItemSpacing( int spacing, bool isSmall = false );
|
2003-09-14 12:06:27 -04:00
|
|
|
wxSize GetItemSpacing() const;
|
2002-04-24 16:31:46 -04:00
|
|
|
void SetItemTextColour( long item, const wxColour& col);
|
|
|
|
wxColour GetItemTextColour( long item ) const;
|
|
|
|
void SetItemBackgroundColour( long item, const wxColour &col);
|
|
|
|
wxColour GetItemBackgroundColour( long item ) const;
|
2005-07-22 18:29:20 -04:00
|
|
|
void SetItemFont( long item, const wxFont &f);
|
|
|
|
wxFont GetItemFont( long item ) const;
|
1999-07-25 08:59:58 -04:00
|
|
|
int GetSelectedItemCount() const;
|
1999-12-06 05:43:35 -05:00
|
|
|
wxColour GetTextColour() const;
|
|
|
|
void SetTextColour(const wxColour& col);
|
1999-07-25 08:59:58 -04:00
|
|
|
long GetTopItem() const;
|
1999-11-26 12:35:27 -05:00
|
|
|
|
2004-06-17 12:22:36 -04:00
|
|
|
void SetSingleStyle( long style, bool add = true ) ;
|
1999-07-25 08:59:58 -04:00
|
|
|
void SetWindowStyleFlag( long style );
|
|
|
|
void RecreateWindow() {}
|
|
|
|
long GetNextItem( long item, int geometry = wxLIST_NEXT_ALL, int state = wxLIST_STATE_DONTCARE ) const;
|
2006-09-18 00:41:09 -04:00
|
|
|
wxImageList *GetImageList( int which ) const;
|
|
|
|
void SetImageList( wxImageList *imageList, int which );
|
|
|
|
void AssignImageList( wxImageList *imageList, int which );
|
1998-07-04 11:17:59 -04:00
|
|
|
bool Arrange( int flag = wxLIST_ALIGN_DEFAULT ); // always wxLIST_ALIGN_LEFT in wxGLC
|
1999-11-08 00:18:15 -05:00
|
|
|
|
1998-12-17 09:07:46 -05:00
|
|
|
void ClearAll();
|
1998-07-04 11:17:59 -04:00
|
|
|
bool DeleteItem( long item );
|
1999-07-25 08:59:58 -04:00
|
|
|
bool DeleteAllItems();
|
|
|
|
bool DeleteAllColumns();
|
1998-07-04 11:17:59 -04:00
|
|
|
bool DeleteColumn( int col );
|
1999-11-08 00:18:15 -05:00
|
|
|
|
2001-07-05 09:08:37 -04:00
|
|
|
void SetItemCount(long count);
|
|
|
|
|
2006-02-24 10:32:29 -05:00
|
|
|
wxTextCtrl *EditLabel(long item,
|
|
|
|
wxClassInfo* textControlClass = CLASSINFO(wxTextCtrl));
|
|
|
|
wxTextCtrl* GetEditControl() const;
|
|
|
|
void Edit( long item ) { EditLabel(item); }
|
1999-11-08 00:18:15 -05:00
|
|
|
|
1998-07-04 11:17:59 -04:00
|
|
|
bool EnsureVisible( long item );
|
2004-06-17 12:22:36 -04:00
|
|
|
long FindItem( long start, const wxString& str, bool partial = false );
|
2004-09-29 05:25:47 -04:00
|
|
|
long FindItem( long start, wxUIntPtr data );
|
1999-07-25 08:59:58 -04:00
|
|
|
long FindItem( long start, const wxPoint& pt, int direction ); // not supported in wxGLC
|
2006-06-14 08:00:57 -04:00
|
|
|
long HitTest( const wxPoint& point, int& flags, long *pSubItem = NULL ) const;
|
1998-05-20 10:01:55 -04:00
|
|
|
long InsertItem(wxListItem& info);
|
1999-07-25 08:59:58 -04:00
|
|
|
long InsertItem( long index, const wxString& label );
|
|
|
|
long InsertItem( long index, int imageIndex );
|
|
|
|
long InsertItem( long index, const wxString& label, int imageIndex );
|
|
|
|
long InsertColumn( long col, wxListItem& info );
|
2003-07-08 07:19:10 -04:00
|
|
|
long InsertColumn( long col, const wxString& heading,
|
|
|
|
int format = wxLIST_FORMAT_LEFT, int width = -1 );
|
1999-07-25 08:59:58 -04:00
|
|
|
bool ScrollList( int dx, int dy );
|
2009-04-16 09:00:40 -04:00
|
|
|
bool SortItems( wxListCtrlCompare fn, wxIntPtr data );
|
2001-06-26 17:29:16 -04:00
|
|
|
|
2004-02-29 18:24:35 -05:00
|
|
|
// are we in report mode?
|
|
|
|
bool InReportView() const { return HasFlag(wxLC_REPORT); }
|
|
|
|
|
|
|
|
// are we in virtual report mode?
|
|
|
|
bool IsVirtual() const { return HasFlag(wxLC_VIRTUAL); }
|
|
|
|
|
|
|
|
// do we have a header window?
|
|
|
|
bool HasHeader() const
|
|
|
|
{ return InReportView() && !HasFlag(wxLC_NO_HEADER); }
|
2001-07-05 09:08:37 -04:00
|
|
|
|
2001-07-13 16:09:44 -04:00
|
|
|
// refresh items selectively (only useful for virtual list controls)
|
|
|
|
void RefreshItem(long item);
|
|
|
|
void RefreshItems(long itemFrom, long itemTo);
|
|
|
|
|
2006-03-30 09:04:17 -05:00
|
|
|
#if WXWIN_COMPATIBILITY_2_6
|
2003-09-14 12:06:27 -04:00
|
|
|
// obsolete, don't use
|
|
|
|
wxDEPRECATED( int GetItemSpacing( bool isSmall ) const );
|
2006-03-30 09:04:17 -05:00
|
|
|
#endif // WXWIN_COMPATIBILITY_2_6
|
2003-09-14 12:06:27 -04:00
|
|
|
|
2009-05-30 18:25:42 -04:00
|
|
|
|
|
|
|
// overridden base class virtuals
|
|
|
|
// ------------------------------
|
|
|
|
|
2004-05-06 17:01:24 -04:00
|
|
|
virtual wxVisualAttributes GetDefaultAttributes() const
|
|
|
|
{
|
|
|
|
return GetClassDefaultAttributes(GetWindowVariant());
|
|
|
|
}
|
|
|
|
|
|
|
|
static wxVisualAttributes
|
|
|
|
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
|
|
|
|
|
2009-05-30 18:25:42 -04:00
|
|
|
virtual void Update();
|
|
|
|
|
|
|
|
|
2001-07-13 16:09:44 -04:00
|
|
|
// implementation only from now on
|
|
|
|
// -------------------------------
|
|
|
|
|
2009-05-30 18:25:42 -04:00
|
|
|
// generic version extension, don't use in portable code
|
|
|
|
bool Update( long item );
|
|
|
|
|
2003-07-09 13:15:09 -04:00
|
|
|
void OnInternalIdle( );
|
1999-11-08 00:18:15 -05:00
|
|
|
|
1998-08-17 16:07:50 -04:00
|
|
|
// We have to hand down a few functions
|
2004-06-17 12:22:36 -04:00
|
|
|
virtual void Refresh(bool eraseBackground = true,
|
2003-07-08 07:19:10 -04:00
|
|
|
const wxRect *rect = NULL);
|
1999-11-08 00:18:15 -05:00
|
|
|
|
2001-11-03 12:06:29 -05:00
|
|
|
virtual bool SetBackgroundColour( const wxColour &colour );
|
|
|
|
virtual bool SetForegroundColour( const wxColour &colour );
|
|
|
|
virtual wxColour GetBackgroundColour() const;
|
|
|
|
virtual wxColour GetForegroundColour() const;
|
|
|
|
virtual bool SetFont( const wxFont &font );
|
|
|
|
virtual bool SetCursor( const wxCursor &cursor );
|
1999-11-08 00:18:15 -05:00
|
|
|
|
1998-12-20 18:49:21 -05:00
|
|
|
#if wxUSE_DRAG_AND_DROP
|
2001-11-03 12:06:29 -05:00
|
|
|
virtual void SetDropTarget( wxDropTarget *dropTarget );
|
|
|
|
virtual wxDropTarget *GetDropTarget() const;
|
1998-12-20 18:49:21 -05:00
|
|
|
#endif
|
|
|
|
|
2003-10-16 06:00:12 -04:00
|
|
|
virtual bool ShouldInheritColours() const { return false; }
|
2001-11-03 12:06:29 -05:00
|
|
|
virtual void SetFocus();
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1999-11-26 12:35:27 -05:00
|
|
|
// implementation
|
|
|
|
// --------------
|
1999-11-08 00:18:15 -05:00
|
|
|
|
2006-09-18 00:41:09 -04:00
|
|
|
wxImageList *m_imageListNormal;
|
|
|
|
wxImageList *m_imageListSmall;
|
|
|
|
wxImageList *m_imageListState; // what's that ?
|
2001-06-26 17:29:16 -04:00
|
|
|
bool m_ownsImageListNormal,
|
2000-09-28 18:29:26 -04:00
|
|
|
m_ownsImageListSmall,
|
|
|
|
m_ownsImageListState;
|
1998-05-20 10:01:55 -04:00
|
|
|
wxListHeaderWindow *m_headerWin;
|
|
|
|
wxListMainWindow *m_mainWin;
|
2003-09-11 11:38:38 -04:00
|
|
|
wxCoord m_headerHeight;
|
1998-08-07 11:09:04 -04:00
|
|
|
|
2001-07-05 09:08:37 -04:00
|
|
|
protected:
|
2006-02-08 16:47:09 -05:00
|
|
|
virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
|
|
|
|
|
2006-02-12 19:49:24 -05:00
|
|
|
// take into account the coordinates difference between the container
|
|
|
|
// window and the list control window itself here
|
|
|
|
virtual void DoClientToScreen( int *x, int *y ) const;
|
|
|
|
virtual void DoScreenToClient( int *x, int *y ) const;
|
|
|
|
|
2006-02-08 16:47:09 -05:00
|
|
|
virtual wxSize DoGetBestSize() const;
|
|
|
|
|
2001-07-05 09:08:37 -04:00
|
|
|
// return the text for the given column of the given item
|
|
|
|
virtual wxString OnGetItemText(long item, long column) const;
|
|
|
|
|
2006-01-25 18:29:02 -05:00
|
|
|
// return the icon for the given item. In report view, OnGetItemImage will
|
2006-03-30 09:04:17 -05:00
|
|
|
// only be called for the first column. See OnGetItemColumnImage for
|
2006-01-25 18:29:02 -05:00
|
|
|
// details.
|
2001-07-05 09:08:37 -04:00
|
|
|
virtual int OnGetItemImage(long item) const;
|
|
|
|
|
2006-01-25 18:29:02 -05:00
|
|
|
// return the icon for the given item and column.
|
|
|
|
virtual int OnGetItemColumnImage(long item, long column) const;
|
|
|
|
|
2001-07-11 12:22:12 -04:00
|
|
|
// return the attribute for the item (may return NULL if none)
|
|
|
|
virtual wxListItemAttr *OnGetItemAttr(long item) const;
|
|
|
|
|
2001-07-05 09:08:37 -04:00
|
|
|
// it calls our OnGetXXX() functions
|
2007-07-09 06:09:52 -04:00
|
|
|
friend class WXDLLIMPEXP_FWD_CORE wxListMainWindow;
|
2001-07-05 09:08:37 -04:00
|
|
|
|
2009-01-22 18:01:14 -05:00
|
|
|
virtual wxBorder GetDefaultBorder() const;
|
|
|
|
|
1999-11-26 12:35:27 -05:00
|
|
|
private:
|
2009-01-22 18:01:14 -05:00
|
|
|
void CreateOrDestroyHeaderWindowAsNeeded();
|
|
|
|
void OnScroll( wxScrollWinEvent& event );
|
|
|
|
void OnSize( wxSizeEvent &event );
|
|
|
|
virtual wxSize GetSizeAvailableForScrollTarget(const wxSize& size);
|
2001-07-06 17:18:15 -04:00
|
|
|
|
2009-01-22 18:01:14 -05:00
|
|
|
// we need to return a special WM_GETDLGCODE value to process just the
|
|
|
|
// arrows but let the other navigation characters through
|
2009-02-04 05:07:58 -05:00
|
|
|
#if defined(__WXMSW__) && !defined(__WXWINCE__) && !defined(__WXUNIVERSAL__)
|
|
|
|
virtual WXLRESULT
|
|
|
|
MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
|
2009-01-22 18:01:14 -05:00
|
|
|
#endif // __WXMSW__
|
2003-09-11 11:38:38 -04:00
|
|
|
|
2009-01-22 18:01:14 -05:00
|
|
|
WX_FORWARD_TO_SCROLL_HELPER()
|
2001-07-26 14:39:36 -04:00
|
|
|
|
1999-11-26 12:35:27 -05:00
|
|
|
DECLARE_EVENT_TABLE()
|
2005-02-08 07:37:49 -05:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxGenericListCtrl)
|
1998-05-20 10:01:55 -04:00
|
|
|
};
|
|
|
|
|
2008-09-02 07:52:20 -04:00
|
|
|
#if (!defined(__WXMSW__) || defined(__WXUNIVERSAL__)) && (!(defined(__WXMAC__) && wxOSX_USE_CARBON) || defined(__WXUNIVERSAL__ ))
|
2002-07-22 19:03:03 -04:00
|
|
|
/*
|
|
|
|
* wxListCtrl has to be a real class or we have problems with
|
|
|
|
* the run-time information.
|
|
|
|
*/
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxListCtrl: public wxGenericListCtrl
|
2002-07-22 19:03:03 -04:00
|
|
|
{
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxListCtrl)
|
|
|
|
|
|
|
|
public:
|
2004-01-15 08:49:22 -05:00
|
|
|
wxListCtrl() {}
|
2002-07-22 19:03:03 -04:00
|
|
|
|
2004-06-17 12:22:36 -04:00
|
|
|
wxListCtrl(wxWindow *parent, wxWindowID winid = wxID_ANY,
|
2002-07-22 19:03:03 -04:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = wxLC_ICON,
|
|
|
|
const wxValidator &validator = wxDefaultValidator,
|
2005-01-14 08:07:44 -05:00
|
|
|
const wxString &name = wxListCtrlNameStr)
|
2004-01-15 08:49:22 -05:00
|
|
|
: wxGenericListCtrl(parent, winid, pos, size, style, validator, name)
|
|
|
|
{
|
|
|
|
}
|
2009-01-27 07:01:54 -05:00
|
|
|
|
2002-07-22 19:03:03 -04:00
|
|
|
};
|
2004-03-28 08:10:14 -05:00
|
|
|
#endif // !__WXMSW__ || __WXUNIVERSAL__
|
2002-04-24 16:31:46 -04:00
|
|
|
|
2006-10-02 13:38:30 -04:00
|
|
|
#endif // _WX_GENERIC_LISTCTRL_H_
|