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