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:
|
|
|
|
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
|
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__
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
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"
|
2001-07-07 18:42:35 -04:00
|
|
|
#include "wx/imaglist.h"
|
1998-05-20 10:01:55 -04:00
|
|
|
#include "wx/control.h"
|
|
|
|
#include "wx/timer.h"
|
1998-08-17 13:05:47 -04:00
|
|
|
#include "wx/textctrl.h"
|
1998-05-20 10:01:55 -04:00
|
|
|
#include "wx/dcclient.h"
|
|
|
|
#include "wx/scrolwin.h"
|
|
|
|
#include "wx/settings.h"
|
|
|
|
|
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;
|
|
|
|
class WXDLLEXPORT wxListCtrl;
|
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
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
1998-12-20 18:49:21 -05:00
|
|
|
class WXDLLEXPORT wxListCtrl: public wxControl
|
1998-05-20 10:01:55 -04:00
|
|
|
{
|
1999-11-26 12:35:27 -05:00
|
|
|
public:
|
1999-07-25 08:59:58 -04:00
|
|
|
wxListCtrl();
|
2000-01-06 11:47:48 -05:00
|
|
|
wxListCtrl( wxWindow *parent,
|
|
|
|
wxWindowID id = -1,
|
|
|
|
const wxPoint &pos = wxDefaultPosition,
|
|
|
|
const wxSize &size = wxDefaultSize,
|
|
|
|
long style = wxLC_ICON,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString &name = "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
|
|
|
}
|
1999-07-25 08:59:58 -04:00
|
|
|
~wxListCtrl();
|
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,
|
|
|
|
const wxString &name = "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;
|
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;
|
|
|
|
wxImageList *GetImageList( int which ) const;
|
|
|
|
void SetImageList( wxImageList *imageList, int which );
|
2000-09-28 18:29:26 -04:00
|
|
|
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);
|
|
|
|
|
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 );
|
|
|
|
long InsertColumn( long col, const wxString& heading, int format = wxLIST_FORMAT_LEFT,
|
|
|
|
int width = -1 );
|
|
|
|
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; }
|
|
|
|
|
1998-08-17 16:07:50 -04:00
|
|
|
void OnIdle( wxIdleEvent &event );
|
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
|
1999-11-08 00:18:15 -05:00
|
|
|
|
1999-05-09 18:17:03 -04:00
|
|
|
bool SetBackgroundColour( const wxColour &colour );
|
|
|
|
bool SetForegroundColour( const wxColour &colour );
|
|
|
|
bool SetFont( const wxFont &font );
|
1999-11-08 00:18:15 -05:00
|
|
|
|
1998-12-20 18:49:21 -05:00
|
|
|
#if wxUSE_DRAG_AND_DROP
|
2000-02-22 10:22:21 -05:00
|
|
|
void SetDropTarget( wxDropTarget *dropTarget );
|
|
|
|
wxDropTarget *GetDropTarget() const;
|
1998-12-20 18:49:21 -05:00
|
|
|
#endif
|
|
|
|
|
2000-02-22 10:22:21 -05:00
|
|
|
bool SetCursor( const wxCursor &cursor );
|
|
|
|
wxColour GetBackgroundColour() const;
|
|
|
|
wxColour GetForegroundColour() const;
|
|
|
|
bool DoPopupMenu( wxMenu *menu, int x, int y );
|
|
|
|
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
|
|
|
|
1998-08-07 11:09:04 -04:00
|
|
|
wxImageList *m_imageListNormal;
|
|
|
|
wxImageList *m_imageListSmall;
|
1998-05-20 10:01:55 -04:00
|
|
|
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;
|
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;
|
|
|
|
|
|
|
|
// it calls our OnGetXXX() functions
|
2001-07-07 10:48:50 -04:00
|
|
|
|
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
|
|
|
|
void Update(void)
|
|
|
|
{ wxWindowBase::Update(); }
|
|
|
|
|
2001-07-06 17:18:15 -04:00
|
|
|
// create the header window
|
|
|
|
void CreateHeaderWindow();
|
|
|
|
|
1999-11-26 12:35:27 -05:00
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxListCtrl);
|
1998-05-20 10:01:55 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // __LISTCTRLH_G__
|