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
|
|
|
|
// Id:
|
2003-03-17 05:34:04 -05:00
|
|
|
// Copyright: (c) 1998 Robert Roebling and Julian Smart
|
1999-12-04 17:34:54 -05:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 10:01:55 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef __LISTCTRLH_G__
|
|
|
|
#define __LISTCTRLH_G__
|
|
|
|
|
2002-08-31 07:29:13 -04:00
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
1998-07-03 12:36:10 -04:00
|
|
|
#pragma interface "listctrl.h"
|
1998-05-20 10:01:55 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "wx/defs.h"
|
|
|
|
#include "wx/object.h"
|
2002-07-30 12:01:35 -04:00
|
|
|
#include "wx/generic/imaglist.h"
|
|
|
|
|
1998-05-20 10:01:55 -04:00
|
|
|
#include "wx/control.h"
|
|
|
|
#include "wx/timer.h"
|
|
|
|
#include "wx/dcclient.h"
|
|
|
|
#include "wx/scrolwin.h"
|
|
|
|
#include "wx/settings.h"
|
2002-07-30 15:04:18 -04:00
|
|
|
#include "wx/listbase.h"
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1998-12-20 18:49:21 -05:00
|
|
|
#if wxUSE_DRAG_AND_DROP
|
|
|
|
class WXDLLEXPORT wxDropTarget;
|
|
|
|
#endif
|
|
|
|
|
1998-05-20 10:01:55 -04:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// classes
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
1998-12-20 18:49:21 -05:00
|
|
|
class WXDLLEXPORT wxListItem;
|
|
|
|
class WXDLLEXPORT wxListEvent;
|
2002-08-28 04:54:00 -04:00
|
|
|
|
|
|
|
#if !defined(__WXMSW__) || defined(__WIN16__) || defined(__WXUNIVERSAL__)
|
1998-12-20 18:49:21 -05:00
|
|
|
class WXDLLEXPORT wxListCtrl;
|
2002-08-28 04:54:00 -04:00
|
|
|
#define wxImageListType wxImageList
|
|
|
|
#else
|
|
|
|
#define wxImageListType wxGenericImageList
|
|
|
|
#endif
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// internal classes
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
1998-12-20 18:49:21 -05:00
|
|
|
class WXDLLEXPORT wxListHeaderData;
|
|
|
|
class WXDLLEXPORT wxListItemData;
|
|
|
|
class WXDLLEXPORT wxListLineData;
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1998-12-20 18:49:21 -05:00
|
|
|
class WXDLLEXPORT wxListHeaderWindow;
|
|
|
|
class WXDLLEXPORT wxListMainWindow;
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1998-12-20 18:49:21 -05:00
|
|
|
class WXDLLEXPORT wxListRenameTimer;
|
1999-07-25 08:59:58 -04:00
|
|
|
class WXDLLEXPORT wxListTextCtrl;
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// wxListCtrl
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2002-07-22 04:51:49 -04:00
|
|
|
class WXDLLEXPORT wxGenericListCtrl: public wxControl
|
1998-05-20 10:01:55 -04:00
|
|
|
{
|
1999-11-26 12:35:27 -05:00
|
|
|
public:
|
2002-07-22 04:51:49 -04:00
|
|
|
wxGenericListCtrl();
|
|
|
|
wxGenericListCtrl( wxWindow *parent,
|
2000-01-06 11:47:48 -05:00
|
|
|
wxWindowID id = -1,
|
|
|
|
const wxPoint &pos = wxDefaultPosition,
|
|
|
|
const wxSize &size = wxDefaultSize,
|
|
|
|
long style = wxLC_ICON,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
2002-12-04 09:11:26 -05:00
|
|
|
const wxString &name = wxT("listctrl") )
|
1998-10-24 16:25:36 -04:00
|
|
|
{
|
1999-11-26 12:35:27 -05:00
|
|
|
Create(parent, id, pos, size, style, validator, name);
|
1998-10-24 16:25:36 -04:00
|
|
|
}
|
2002-07-22 04:51:49 -04:00
|
|
|
~wxGenericListCtrl();
|
2001-06-26 17:29:16 -04:00
|
|
|
|
2000-01-06 11:47:48 -05:00
|
|
|
bool Create( wxWindow *parent,
|
|
|
|
wxWindowID id = -1,
|
|
|
|
const wxPoint &pos = wxDefaultPosition,
|
|
|
|
const wxSize &size = wxDefaultSize,
|
|
|
|
long style = wxLC_ICON,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
2002-12-04 09:11:26 -05:00
|
|
|
const wxString &name = wxT("listctrl") );
|
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
|
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);
|
|
|
|
bool SetItemImage( long item, int image, int selImage);
|
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 );
|
1998-12-07 08:28:56 -05:00
|
|
|
long GetItemData( long item ) const;
|
1998-07-04 11:17:59 -04:00
|
|
|
bool SetItemData( long item, long data );
|
1999-01-31 08:58:17 -05:00
|
|
|
bool GetItemRect( long item, 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;
|
1998-07-13 19:30:59 -04:00
|
|
|
void SetItemSpacing( int spacing, bool isSmall = FALSE );
|
1998-12-07 08:28:56 -05:00
|
|
|
int GetItemSpacing( bool isSmall ) 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;
|
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
|
|
|
|
1998-07-04 11:17:59 -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;
|
2002-08-28 04:54:00 -04:00
|
|
|
wxImageListType *GetImageList( int which ) const;
|
|
|
|
void SetImageList( wxImageListType *imageList, int which );
|
|
|
|
void AssignImageList( wxImageListType *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);
|
|
|
|
|
1999-07-25 08:59:58 -04:00
|
|
|
void EditLabel( long item ) { Edit(item); }
|
|
|
|
void Edit( long item );
|
1999-11-08 00:18:15 -05:00
|
|
|
|
1998-07-04 11:17:59 -04:00
|
|
|
bool EnsureVisible( long item );
|
1999-07-25 08:59:58 -04:00
|
|
|
long FindItem( long start, const wxString& str, bool partial = FALSE );
|
|
|
|
long FindItem( long start, long data );
|
|
|
|
long FindItem( long start, const wxPoint& pt, int direction ); // not supported in wxGLC
|
|
|
|
long HitTest( const wxPoint& point, int& flags);
|
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 );
|
|
|
|
bool SortItems( wxListCtrlCompare fn, long data );
|
|
|
|
bool Update( long item );
|
2001-06-26 17:29:16 -04:00
|
|
|
|
2001-07-05 09:08:37 -04:00
|
|
|
// returns true if it is a virtual list control
|
|
|
|
bool IsVirtual() const { return (GetWindowStyle() & wxLC_VIRTUAL) != 0; }
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
// implementation only from now on
|
|
|
|
// -------------------------------
|
|
|
|
|
2003-07-09 13:15:09 -04:00
|
|
|
void OnInternalIdle( );
|
1999-11-26 12:35:27 -05:00
|
|
|
void OnSize( wxSizeEvent &event );
|
1999-11-08 00:18:15 -05:00
|
|
|
|
1998-08-17 16:07:50 -04:00
|
|
|
// We have to hand down a few functions
|
2003-07-08 07:19:10 -04:00
|
|
|
virtual void Refresh(bool eraseBackground = TRUE,
|
|
|
|
const wxRect *rect = NULL);
|
1999-11-08 00:18:15 -05:00
|
|
|
|
2001-11-03 12:06:29 -05:00
|
|
|
virtual void Freeze();
|
|
|
|
virtual void Thaw();
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2001-11-03 12:06:29 -05:00
|
|
|
virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
|
|
|
|
|
|
|
|
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
|
|
|
|
2002-08-28 04:54:00 -04:00
|
|
|
wxImageListType *m_imageListNormal;
|
|
|
|
wxImageListType *m_imageListSmall;
|
|
|
|
wxImageListType *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;
|
1998-08-07 11:09:04 -04:00
|
|
|
|
2001-07-05 09:08:37 -04:00
|
|
|
protected:
|
|
|
|
// return the text for the given column of the given item
|
|
|
|
virtual wxString OnGetItemText(long item, long column) const;
|
|
|
|
|
|
|
|
// return the icon for the given item
|
|
|
|
virtual int OnGetItemImage(long item) 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
|
2001-07-07 09:16:34 -04:00
|
|
|
friend class WXDLLEXPORT wxListMainWindow;
|
2001-07-05 09:08:37 -04:00
|
|
|
|
1999-11-26 12:35:27 -05:00
|
|
|
private:
|
2001-07-06 17:45:11 -04:00
|
|
|
// Virtual function hiding supression
|
2002-02-16 05:59:55 -05:00
|
|
|
virtual void Update() { wxWindow::Update(); }
|
2001-07-06 17:45:11 -04:00
|
|
|
|
2001-07-06 17:18:15 -04:00
|
|
|
// create the header window
|
|
|
|
void CreateHeaderWindow();
|
|
|
|
|
2001-07-26 14:39:36 -04:00
|
|
|
// reposition the header and the main window in the report view depending
|
|
|
|
// on whether it should be shown or not
|
|
|
|
void ResizeReportView(bool showHeader);
|
|
|
|
|
1999-11-26 12:35:27 -05:00
|
|
|
DECLARE_EVENT_TABLE()
|
2002-07-22 04:51:49 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxGenericListCtrl);
|
1998-05-20 10:01:55 -04:00
|
|
|
};
|
|
|
|
|
2002-07-22 19:03:03 -04:00
|
|
|
#if !defined(__WXMSW__) || defined(__WIN16__) || defined(__WXUNIVERSAL__)
|
|
|
|
/*
|
|
|
|
* wxListCtrl has to be a real class or we have problems with
|
|
|
|
* the run-time information.
|
|
|
|
*/
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2002-07-22 19:03:03 -04:00
|
|
|
class WXDLLEXPORT wxListCtrl: public wxGenericListCtrl
|
|
|
|
{
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxListCtrl)
|
|
|
|
|
|
|
|
public:
|
|
|
|
wxListCtrl() {}
|
|
|
|
|
|
|
|
wxListCtrl(wxWindow *parent, wxWindowID id = -1,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = wxLC_ICON,
|
|
|
|
const wxValidator &validator = wxDefaultValidator,
|
2002-12-04 09:11:26 -05:00
|
|
|
const wxString &name = wxT("listctrl") )
|
2002-07-22 19:03:03 -04:00
|
|
|
: wxGenericListCtrl(parent, id, pos, size, style, validator, name)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
#endif // !__WXMSW__ || __WIN16__ || __WXUNIVERSAL__
|
2002-04-24 16:31:46 -04:00
|
|
|
|
2002-07-22 19:03:03 -04:00
|
|
|
#endif // __LISTCTRLH_G__
|