2002-07-30 15:04:18 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2006-10-02 13:38:30 -04:00
|
|
|
// Name: wx/listbase.h
|
2002-07-30 15:04:18 -04:00
|
|
|
// Purpose: wxListCtrl class
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Modified by:
|
|
|
|
// Created: 04.12.99
|
2004-05-23 10:56:36 -04:00
|
|
|
// Copyright: (c) wxWidgets team
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
2002-07-30 15:04:18 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_LISTBASE_H_BASE_
|
|
|
|
#define _WX_LISTBASE_H_BASE_
|
|
|
|
|
2003-08-20 18:51:21 -04:00
|
|
|
#include "wx/colour.h"
|
2003-07-08 16:34:04 -04:00
|
|
|
#include "wx/font.h"
|
2003-08-20 18:51:21 -04:00
|
|
|
#include "wx/gdicmn.h"
|
|
|
|
#include "wx/event.h"
|
2012-01-07 11:11:10 -05:00
|
|
|
#include "wx/control.h"
|
2016-04-16 11:44:19 -04:00
|
|
|
#include "wx/itemattr.h"
|
2015-09-17 08:46:27 -04:00
|
|
|
#include "wx/systhemectrl.h"
|
2003-07-08 16:34:04 -04:00
|
|
|
|
2012-01-07 10:09:43 -05:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxImageList;
|
|
|
|
|
2002-07-30 15:04:18 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// types
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// type of compare function for wxListCtrl sort operation
|
2009-04-15 17:23:50 -04:00
|
|
|
typedef
|
2011-05-13 09:30:03 -04:00
|
|
|
int (wxCALLBACK *wxListCtrlCompare)(wxIntPtr item1, wxIntPtr item2, wxIntPtr sortData);
|
2002-07-30 15:04:18 -04:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxListCtrl constants
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// style flags
|
|
|
|
#define wxLC_VRULES 0x0001
|
|
|
|
#define wxLC_HRULES 0x0002
|
|
|
|
|
|
|
|
#define wxLC_ICON 0x0004
|
|
|
|
#define wxLC_SMALL_ICON 0x0008
|
|
|
|
#define wxLC_LIST 0x0010
|
|
|
|
#define wxLC_REPORT 0x0020
|
|
|
|
|
|
|
|
#define wxLC_ALIGN_TOP 0x0040
|
|
|
|
#define wxLC_ALIGN_LEFT 0x0080
|
|
|
|
#define wxLC_AUTOARRANGE 0x0100
|
|
|
|
#define wxLC_VIRTUAL 0x0200
|
|
|
|
#define wxLC_EDIT_LABELS 0x0400
|
|
|
|
#define wxLC_NO_HEADER 0x0800
|
|
|
|
#define wxLC_NO_SORT_HEADER 0x1000
|
|
|
|
#define wxLC_SINGLE_SEL 0x2000
|
|
|
|
#define wxLC_SORT_ASCENDING 0x4000
|
|
|
|
#define wxLC_SORT_DESCENDING 0x8000
|
|
|
|
|
|
|
|
#define wxLC_MASK_TYPE (wxLC_ICON | wxLC_SMALL_ICON | wxLC_LIST | wxLC_REPORT)
|
|
|
|
#define wxLC_MASK_ALIGN (wxLC_ALIGN_TOP | wxLC_ALIGN_LEFT)
|
|
|
|
#define wxLC_MASK_SORT (wxLC_SORT_ASCENDING | wxLC_SORT_DESCENDING)
|
|
|
|
|
|
|
|
// for compatibility only
|
|
|
|
#define wxLC_USER_TEXT wxLC_VIRTUAL
|
|
|
|
|
|
|
|
// Omitted because
|
|
|
|
// (a) too much detail
|
|
|
|
// (b) not enough style flags
|
|
|
|
// (c) not implemented anyhow in the generic version
|
|
|
|
//
|
|
|
|
// #define wxLC_NO_SCROLL
|
|
|
|
// #define wxLC_NO_LABEL_WRAP
|
|
|
|
// #define wxLC_OWNERDRAW_FIXED
|
|
|
|
// #define wxLC_SHOW_SEL_ALWAYS
|
|
|
|
|
|
|
|
// Mask flags to tell app/GUI what fields of wxListItem are valid
|
|
|
|
#define wxLIST_MASK_STATE 0x0001
|
|
|
|
#define wxLIST_MASK_TEXT 0x0002
|
|
|
|
#define wxLIST_MASK_IMAGE 0x0004
|
|
|
|
#define wxLIST_MASK_DATA 0x0008
|
|
|
|
#define wxLIST_SET_ITEM 0x0010
|
|
|
|
#define wxLIST_MASK_WIDTH 0x0020
|
|
|
|
#define wxLIST_MASK_FORMAT 0x0040
|
|
|
|
|
|
|
|
// State flags for indicating the state of an item
|
|
|
|
#define wxLIST_STATE_DONTCARE 0x0000
|
|
|
|
#define wxLIST_STATE_DROPHILITED 0x0001 // MSW only
|
|
|
|
#define wxLIST_STATE_FOCUSED 0x0002
|
|
|
|
#define wxLIST_STATE_SELECTED 0x0004
|
|
|
|
#define wxLIST_STATE_CUT 0x0008 // MSW only
|
2014-05-15 19:56:58 -04:00
|
|
|
#define wxLIST_STATE_DISABLED 0x0010 // Not used
|
|
|
|
#define wxLIST_STATE_FILTERED 0x0020 // Not used
|
|
|
|
#define wxLIST_STATE_INUSE 0x0040 // Not used
|
|
|
|
#define wxLIST_STATE_PICKED 0x0080 // Not used
|
|
|
|
#define wxLIST_STATE_SOURCE 0x0100 // Not used
|
2002-07-30 15:04:18 -04:00
|
|
|
|
|
|
|
// Hit test flags, used in HitTest
|
2017-02-28 09:11:19 -05:00
|
|
|
#define wxLIST_HITTEST_ABOVE 0x0001 // Above the control's client area.
|
|
|
|
#define wxLIST_HITTEST_BELOW 0x0002 // Below the control's client area.
|
|
|
|
#define wxLIST_HITTEST_NOWHERE 0x0004 // Inside the control's client area but not over an item.
|
|
|
|
#define wxLIST_HITTEST_ONITEMICON 0x0020 // Over an item's icon.
|
|
|
|
#define wxLIST_HITTEST_ONITEMLABEL 0x0080 // Over an item's text.
|
|
|
|
#define wxLIST_HITTEST_ONITEMRIGHT 0x0100 // Not used
|
|
|
|
#define wxLIST_HITTEST_ONITEMSTATEICON 0x0200 // Over the checkbox of an item.
|
|
|
|
#define wxLIST_HITTEST_TOLEFT 0x0400 // To the left of the control's client area.
|
|
|
|
#define wxLIST_HITTEST_TORIGHT 0x0800 // To the right of the control's client area.
|
2002-07-30 15:04:18 -04:00
|
|
|
|
|
|
|
#define wxLIST_HITTEST_ONITEM (wxLIST_HITTEST_ONITEMICON | wxLIST_HITTEST_ONITEMLABEL | wxLIST_HITTEST_ONITEMSTATEICON)
|
|
|
|
|
2006-05-28 14:10:10 -04:00
|
|
|
// GetSubItemRect constants
|
|
|
|
#define wxLIST_GETSUBITEMRECT_WHOLEITEM -1l
|
|
|
|
|
2002-07-30 15:04:18 -04:00
|
|
|
// Flags for GetNextItem (MSW only except wxLIST_NEXT_ALL)
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
wxLIST_NEXT_ABOVE, // Searches for an item above the specified item
|
|
|
|
wxLIST_NEXT_ALL, // Searches for subsequent item by index
|
|
|
|
wxLIST_NEXT_BELOW, // Searches for an item below the specified item
|
|
|
|
wxLIST_NEXT_LEFT, // Searches for an item to the left of the specified item
|
|
|
|
wxLIST_NEXT_RIGHT // Searches for an item to the right of the specified item
|
|
|
|
};
|
|
|
|
|
|
|
|
// Alignment flags for Arrange (MSW only except wxLIST_ALIGN_LEFT)
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
wxLIST_ALIGN_DEFAULT,
|
|
|
|
wxLIST_ALIGN_LEFT,
|
|
|
|
wxLIST_ALIGN_TOP,
|
|
|
|
wxLIST_ALIGN_SNAP_TO_GRID
|
|
|
|
};
|
|
|
|
|
|
|
|
// Column format (MSW only except wxLIST_FORMAT_LEFT)
|
|
|
|
enum wxListColumnFormat
|
|
|
|
{
|
|
|
|
wxLIST_FORMAT_LEFT,
|
|
|
|
wxLIST_FORMAT_RIGHT,
|
|
|
|
wxLIST_FORMAT_CENTRE,
|
|
|
|
wxLIST_FORMAT_CENTER = wxLIST_FORMAT_CENTRE
|
|
|
|
};
|
|
|
|
|
|
|
|
// Autosize values for SetColumnWidth
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
wxLIST_AUTOSIZE = -1,
|
|
|
|
wxLIST_AUTOSIZE_USEHEADER = -2 // partly supported by generic version
|
|
|
|
};
|
|
|
|
|
|
|
|
// Flag values for GetItemRect
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
wxLIST_RECT_BOUNDS,
|
|
|
|
wxLIST_RECT_ICON,
|
|
|
|
wxLIST_RECT_LABEL
|
|
|
|
};
|
|
|
|
|
|
|
|
// Flag values for FindItem (MSW only)
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
wxLIST_FIND_UP,
|
|
|
|
wxLIST_FIND_DOWN,
|
|
|
|
wxLIST_FIND_LEFT,
|
|
|
|
wxLIST_FIND_RIGHT
|
|
|
|
};
|
|
|
|
|
2016-04-16 11:44:19 -04:00
|
|
|
// For compatibility, define the old name for this class. There is no need to
|
|
|
|
// deprecate it as it doesn't cost us anything to keep this typedef, but the
|
|
|
|
// new code should prefer to use the new wxItemAttr name.
|
|
|
|
typedef wxItemAttr wxListItemAttr;
|
2002-07-30 15:04:18 -04:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxListItem: the item or column info, used to exchange data with wxListCtrl
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxListItem : public wxObject
|
2002-07-30 15:04:18 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxListItem() { Init(); m_attr = NULL; }
|
|
|
|
wxListItem(const wxListItem& item)
|
|
|
|
: wxObject(),
|
|
|
|
m_mask(item.m_mask),
|
|
|
|
m_itemId(item.m_itemId),
|
|
|
|
m_col(item.m_col),
|
|
|
|
m_state(item.m_state),
|
|
|
|
m_stateMask(item.m_stateMask),
|
|
|
|
m_text(item.m_text),
|
|
|
|
m_image(item.m_image),
|
|
|
|
m_data(item.m_data),
|
|
|
|
m_format(item.m_format),
|
|
|
|
m_width(item.m_width),
|
|
|
|
m_attr(NULL)
|
|
|
|
{
|
|
|
|
// copy list item attributes
|
2005-12-21 22:10:35 -05:00
|
|
|
if ( item.HasAttributes() )
|
2016-04-16 11:44:19 -04:00
|
|
|
m_attr = new wxItemAttr(*item.GetAttributes());
|
2002-07-30 15:04:18 -04:00
|
|
|
}
|
2008-03-25 09:45:40 -04:00
|
|
|
|
|
|
|
wxListItem& operator=(const wxListItem& item)
|
|
|
|
{
|
2008-11-12 09:36:21 -05:00
|
|
|
if ( &item != this )
|
|
|
|
{
|
|
|
|
m_mask = item.m_mask;
|
|
|
|
m_itemId = item.m_itemId;
|
|
|
|
m_col = item.m_col;
|
|
|
|
m_state = item.m_state;
|
|
|
|
m_stateMask = item.m_stateMask;
|
|
|
|
m_text = item.m_text;
|
|
|
|
m_image = item.m_image;
|
|
|
|
m_data = item.m_data;
|
|
|
|
m_format = item.m_format;
|
|
|
|
m_width = item.m_width;
|
2016-04-16 11:44:19 -04:00
|
|
|
m_attr = item.m_attr ? new wxItemAttr(*item.m_attr) : NULL;
|
2008-11-12 09:36:21 -05:00
|
|
|
}
|
2008-03-25 09:45:40 -04:00
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2002-07-30 15:04:18 -04:00
|
|
|
virtual ~wxListItem() { delete m_attr; }
|
|
|
|
|
|
|
|
// resetting
|
|
|
|
void Clear() { Init(); m_text.clear(); ClearAttributes(); }
|
|
|
|
void ClearAttributes() { if ( m_attr ) { delete m_attr; m_attr = NULL; } }
|
|
|
|
|
|
|
|
// setters
|
2003-01-02 15:59:40 -05:00
|
|
|
void SetMask(long mask)
|
|
|
|
{ m_mask = mask; }
|
|
|
|
void SetId(long id)
|
|
|
|
{ m_itemId = id; }
|
|
|
|
void SetColumn(int col)
|
|
|
|
{ m_col = col; }
|
|
|
|
void SetState(long state)
|
|
|
|
{ m_mask |= wxLIST_MASK_STATE; m_state = state; m_stateMask |= state; }
|
|
|
|
void SetStateMask(long stateMask)
|
|
|
|
{ m_stateMask = stateMask; }
|
|
|
|
void SetText(const wxString& text)
|
|
|
|
{ m_mask |= wxLIST_MASK_TEXT; m_text = text; }
|
|
|
|
void SetImage(int image)
|
|
|
|
{ m_mask |= wxLIST_MASK_IMAGE; m_image = image; }
|
|
|
|
void SetData(long data)
|
|
|
|
{ m_mask |= wxLIST_MASK_DATA; m_data = data; }
|
|
|
|
void SetData(void *data)
|
2004-09-28 17:53:19 -04:00
|
|
|
{ m_mask |= wxLIST_MASK_DATA; m_data = wxPtrToUInt(data); }
|
2003-01-02 15:59:40 -05:00
|
|
|
|
|
|
|
void SetWidth(int width)
|
|
|
|
{ m_mask |= wxLIST_MASK_WIDTH; m_width = width; }
|
|
|
|
void SetAlign(wxListColumnFormat align)
|
|
|
|
{ m_mask |= wxLIST_MASK_FORMAT; m_format = align; }
|
2002-07-30 15:04:18 -04:00
|
|
|
|
|
|
|
void SetTextColour(const wxColour& colText)
|
|
|
|
{ Attributes().SetTextColour(colText); }
|
|
|
|
void SetBackgroundColour(const wxColour& colBack)
|
|
|
|
{ Attributes().SetBackgroundColour(colBack); }
|
|
|
|
void SetFont(const wxFont& font)
|
|
|
|
{ Attributes().SetFont(font); }
|
|
|
|
|
|
|
|
// accessors
|
|
|
|
long GetMask() const { return m_mask; }
|
|
|
|
long GetId() const { return m_itemId; }
|
|
|
|
int GetColumn() const { return m_col; }
|
|
|
|
long GetState() const { return m_state & m_stateMask; }
|
|
|
|
const wxString& GetText() const { return m_text; }
|
|
|
|
int GetImage() const { return m_image; }
|
2004-09-28 17:53:19 -04:00
|
|
|
wxUIntPtr GetData() const { return m_data; }
|
2002-07-30 15:04:18 -04:00
|
|
|
|
|
|
|
int GetWidth() const { return m_width; }
|
|
|
|
wxListColumnFormat GetAlign() const { return (wxListColumnFormat)m_format; }
|
|
|
|
|
2016-04-16 11:44:19 -04:00
|
|
|
wxItemAttr *GetAttributes() const { return m_attr; }
|
2002-07-30 15:04:18 -04:00
|
|
|
bool HasAttributes() const { return m_attr != NULL; }
|
|
|
|
|
|
|
|
wxColour GetTextColour() const
|
|
|
|
{ return HasAttributes() ? m_attr->GetTextColour() : wxNullColour; }
|
|
|
|
wxColour GetBackgroundColour() const
|
|
|
|
{ return HasAttributes() ? m_attr->GetBackgroundColour()
|
|
|
|
: wxNullColour; }
|
|
|
|
wxFont GetFont() const
|
|
|
|
{ return HasAttributes() ? m_attr->GetFont() : wxNullFont; }
|
|
|
|
|
|
|
|
// this conversion is necessary to make old code using GetItem() to
|
|
|
|
// compile
|
|
|
|
operator long() const { return m_itemId; }
|
|
|
|
|
|
|
|
// these members are public for compatibility
|
|
|
|
|
|
|
|
long m_mask; // Indicates what fields are valid
|
|
|
|
long m_itemId; // The zero-based item position
|
|
|
|
int m_col; // Zero-based column, if in report mode
|
|
|
|
long m_state; // The state of the item
|
|
|
|
long m_stateMask;// Which flags of m_state are valid (uses same flags)
|
|
|
|
wxString m_text; // The label/header text
|
|
|
|
int m_image; // The zero-based index into an image list
|
2004-09-28 17:53:19 -04:00
|
|
|
wxUIntPtr m_data; // App-defined data
|
2002-07-30 15:04:18 -04:00
|
|
|
|
|
|
|
// For columns only
|
|
|
|
int m_format; // left, right, centre
|
|
|
|
int m_width; // width of column
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// creates m_attr if we don't have it yet
|
2016-04-16 11:44:19 -04:00
|
|
|
wxItemAttr& Attributes()
|
2002-07-30 15:04:18 -04:00
|
|
|
{
|
|
|
|
if ( !m_attr )
|
2016-04-16 11:44:19 -04:00
|
|
|
m_attr = new wxItemAttr;
|
2002-07-30 15:04:18 -04:00
|
|
|
|
|
|
|
return *m_attr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Init()
|
|
|
|
{
|
|
|
|
m_mask = 0;
|
2012-01-05 07:51:37 -05:00
|
|
|
m_itemId = -1;
|
2002-07-30 15:04:18 -04:00
|
|
|
m_col = 0;
|
|
|
|
m_state = 0;
|
|
|
|
m_stateMask = 0;
|
2007-06-03 18:35:40 -04:00
|
|
|
m_image = -1;
|
2002-07-30 15:04:18 -04:00
|
|
|
m_data = 0;
|
|
|
|
|
|
|
|
m_format = wxLIST_FORMAT_CENTRE;
|
|
|
|
m_width = 0;
|
|
|
|
}
|
|
|
|
|
2016-04-16 11:44:19 -04:00
|
|
|
wxItemAttr *m_attr; // optional pointer to the items style
|
2002-07-30 15:04:18 -04:00
|
|
|
|
|
|
|
private:
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_DYNAMIC_CLASS(wxListItem);
|
2002-07-30 15:04:18 -04:00
|
|
|
};
|
|
|
|
|
2012-01-07 10:09:34 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxListCtrlBase: the base class for the main control itself.
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Unlike other base classes, this class doesn't currently define the API of
|
|
|
|
// the real control class but is just used for implementation convenience. We
|
|
|
|
// should define the public class functions as pure virtual here in the future
|
|
|
|
// however.
|
2015-09-17 08:46:27 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxListCtrlBase : public wxSystemThemedControl<wxControl>
|
2012-01-07 10:09:34 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxListCtrlBase() { }
|
2012-01-07 10:09:37 -05:00
|
|
|
|
2012-01-07 10:09:43 -05:00
|
|
|
// Image list methods.
|
|
|
|
// -------------------
|
|
|
|
|
|
|
|
// Associate the given (possibly NULL to indicate that no images will be
|
|
|
|
// used) image list with the control. The ownership of the image list
|
|
|
|
// passes to the control, i.e. it will be deleted when the control itself
|
|
|
|
// is destroyed.
|
|
|
|
//
|
|
|
|
// The value of "which" must be one of wxIMAGE_LIST_{NORMAL,SMALL,STATE}.
|
|
|
|
virtual void AssignImageList(wxImageList* imageList, int which) = 0;
|
|
|
|
|
|
|
|
// Same as AssignImageList() but the control does not delete the image list
|
|
|
|
// so it can be shared among several controls.
|
|
|
|
virtual void SetImageList(wxImageList* imageList, int which) = 0;
|
|
|
|
|
|
|
|
// Return the currently used image list, may be NULL.
|
|
|
|
virtual wxImageList* GetImageList(int which) const = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// Column-related methods.
|
|
|
|
// -----------------------
|
|
|
|
|
|
|
|
// All these methods can only be used in report view mode.
|
|
|
|
|
2012-01-07 10:09:47 -05:00
|
|
|
// Appends a new column.
|
|
|
|
//
|
|
|
|
// Returns the index of the newly inserted column or -1 on error.
|
|
|
|
long AppendColumn(const wxString& heading,
|
2013-06-29 08:52:11 -04:00
|
|
|
wxListColumnFormat format = wxLIST_FORMAT_LEFT,
|
2012-01-07 10:09:47 -05:00
|
|
|
int width = -1);
|
|
|
|
|
2012-01-07 10:09:43 -05:00
|
|
|
// Add a new column to the control at the position "col".
|
|
|
|
//
|
|
|
|
// Returns the index of the newly inserted column or -1 on error.
|
|
|
|
long InsertColumn(long col, const wxListItem& info);
|
|
|
|
long InsertColumn(long col,
|
|
|
|
const wxString& heading,
|
|
|
|
int format = wxLIST_FORMAT_LEFT,
|
2012-01-07 10:09:51 -05:00
|
|
|
int width = wxLIST_AUTOSIZE);
|
2012-01-07 10:09:43 -05:00
|
|
|
|
|
|
|
// Delete the given or all columns.
|
|
|
|
virtual bool DeleteColumn(int col) = 0;
|
|
|
|
virtual bool DeleteAllColumns() = 0;
|
|
|
|
|
|
|
|
// Return the current number of columns.
|
|
|
|
virtual int GetColumnCount() const = 0;
|
|
|
|
|
|
|
|
// Get or update information about the given column. Set item mask to
|
|
|
|
// indicate the fields to retrieve or change.
|
|
|
|
//
|
|
|
|
// Returns false on error, e.g. if the column index is invalid.
|
|
|
|
virtual bool GetColumn(int col, wxListItem& item) const = 0;
|
|
|
|
virtual bool SetColumn(int col, const wxListItem& item) = 0;
|
|
|
|
|
|
|
|
// Convenient wrappers for the above methods which get or update just the
|
|
|
|
// column width.
|
|
|
|
virtual int GetColumnWidth(int col) const = 0;
|
|
|
|
virtual bool SetColumnWidth(int col, int width) = 0;
|
|
|
|
|
2012-12-21 21:33:23 -05:00
|
|
|
// return the attribute for the item (may return NULL if none)
|
2016-04-16 11:44:19 -04:00
|
|
|
virtual wxItemAttr *OnGetItemAttr(long item) const;
|
2012-01-07 10:09:43 -05:00
|
|
|
|
|
|
|
// Other miscellaneous accessors.
|
|
|
|
// ------------------------------
|
|
|
|
|
2012-01-07 10:09:37 -05:00
|
|
|
// Convenient functions for testing the list control mode:
|
|
|
|
bool InReportView() const { return HasFlag(wxLC_REPORT); }
|
|
|
|
bool IsVirtual() const { return HasFlag(wxLC_VIRTUAL); }
|
2012-01-07 10:09:43 -05:00
|
|
|
|
2012-10-07 18:42:27 -04:00
|
|
|
// Enable or disable beep when incremental match doesn't find any item.
|
|
|
|
// Only implemented in the generic version currently.
|
|
|
|
virtual void EnableBellOnNoMatch(bool WXUNUSED(on) = true) { }
|
|
|
|
|
2012-12-21 21:33:23 -05:00
|
|
|
void EnableAlternateRowColours(bool enable = true);
|
|
|
|
void SetAlternateRowColour(const wxColour& colour);
|
2015-11-15 21:10:16 -05:00
|
|
|
wxColour GetAlternateRowColour() const { return m_alternateRowColour.GetBackgroundColour(); }
|
2012-12-21 21:33:23 -05:00
|
|
|
|
2016-04-17 11:43:09 -04:00
|
|
|
// Header attributes support: only implemented in wxMSW currently.
|
|
|
|
virtual bool SetHeaderAttr(const wxItemAttr& WXUNUSED(attr)) { return false; }
|
|
|
|
|
2017-06-16 08:06:13 -04:00
|
|
|
// Checkboxes support.
|
2016-04-21 11:23:21 -04:00
|
|
|
virtual bool HasCheckBoxes() const { return false; }
|
|
|
|
virtual bool EnableCheckBoxes(bool WXUNUSED(enable) = true) { return false; }
|
2015-12-17 08:27:53 -05:00
|
|
|
virtual bool IsItemChecked(long WXUNUSED(item)) const { return false; }
|
|
|
|
virtual void CheckItem(long WXUNUSED(item), bool WXUNUSED(check)) { }
|
|
|
|
|
2012-01-07 10:09:43 -05:00
|
|
|
protected:
|
|
|
|
// Real implementations methods to which our public forwards.
|
|
|
|
virtual long DoInsertColumn(long col, const wxListItem& info) = 0;
|
|
|
|
|
|
|
|
// Overridden methods of the base class.
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual wxSize DoGetBestClientSize() const wxOVERRIDE;
|
2012-12-21 21:33:23 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
// user defined color to draw row lines, may be invalid
|
2016-04-16 11:44:19 -04:00
|
|
|
wxItemAttr m_alternateRowColour;
|
2012-01-07 10:09:34 -05:00
|
|
|
};
|
|
|
|
|
2002-07-30 15:04:18 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxListEvent - the event class for the wxListCtrl notifications
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxListEvent : public wxNotifyEvent
|
2002-07-30 15:04:18 -04:00
|
|
|
{
|
|
|
|
public:
|
2003-10-26 23:12:45 -05:00
|
|
|
wxListEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
|
|
|
|
: wxNotifyEvent(commandType, winid)
|
2009-05-24 14:04:37 -04:00
|
|
|
, m_code(-1)
|
|
|
|
, m_oldItemIndex(-1)
|
|
|
|
, m_itemIndex(-1)
|
|
|
|
, m_col(-1)
|
2002-07-30 15:04:18 -04:00
|
|
|
, m_pointDrag()
|
|
|
|
, m_item()
|
2003-10-07 04:41:54 -04:00
|
|
|
, m_editCancelled(false)
|
2002-07-30 15:04:18 -04:00
|
|
|
{ }
|
|
|
|
|
|
|
|
wxListEvent(const wxListEvent& event)
|
|
|
|
: wxNotifyEvent(event)
|
|
|
|
, m_code(event.m_code)
|
|
|
|
, m_oldItemIndex(event.m_oldItemIndex)
|
|
|
|
, m_itemIndex(event.m_itemIndex)
|
|
|
|
, m_col(event.m_col)
|
|
|
|
, m_pointDrag(event.m_pointDrag)
|
|
|
|
, m_item(event.m_item)
|
2003-10-07 04:41:54 -04:00
|
|
|
, m_editCancelled(event.m_editCancelled)
|
2002-07-30 15:04:18 -04:00
|
|
|
{ }
|
|
|
|
|
|
|
|
int GetKeyCode() const { return m_code; }
|
|
|
|
long GetIndex() const { return m_itemIndex; }
|
|
|
|
int GetColumn() const { return m_col; }
|
|
|
|
wxPoint GetPoint() const { return m_pointDrag; }
|
|
|
|
const wxString& GetLabel() const { return m_item.m_text; }
|
|
|
|
const wxString& GetText() const { return m_item.m_text; }
|
|
|
|
int GetImage() const { return m_item.m_image; }
|
2013-10-14 11:08:40 -04:00
|
|
|
wxUIntPtr GetData() const { return m_item.m_data; }
|
2002-07-30 15:04:18 -04:00
|
|
|
long GetMask() const { return m_item.m_mask; }
|
|
|
|
const wxListItem& GetItem() const { return m_item; }
|
|
|
|
|
2016-08-03 19:38:32 -04:00
|
|
|
void SetKeyCode(int code) { m_code = code; }
|
|
|
|
void SetIndex(long index) { m_itemIndex = index; }
|
|
|
|
void SetColumn(int col) { m_col = col; }
|
|
|
|
void SetPoint(const wxPoint& point) { m_pointDrag = point; }
|
|
|
|
void SetItem(const wxListItem& item) { m_item = item; }
|
|
|
|
|
2013-04-25 06:11:03 -04:00
|
|
|
// for wxEVT_LIST_CACHE_HINT only
|
2002-07-30 15:04:18 -04:00
|
|
|
long GetCacheFrom() const { return m_oldItemIndex; }
|
|
|
|
long GetCacheTo() const { return m_itemIndex; }
|
2016-08-03 19:38:32 -04:00
|
|
|
void SetCacheFrom(long cacheFrom) { m_oldItemIndex = cacheFrom; }
|
|
|
|
void SetCacheTo(long cacheTo) { m_itemIndex = cacheTo; }
|
2002-07-30 15:04:18 -04:00
|
|
|
|
2013-04-25 06:11:03 -04:00
|
|
|
// was label editing canceled? (for wxEVT_LIST_END_LABEL_EDIT only)
|
2003-10-07 04:41:54 -04:00
|
|
|
bool IsEditCancelled() const { return m_editCancelled; }
|
|
|
|
void SetEditCanceled(bool editCancelled) { m_editCancelled = editCancelled; }
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual wxEvent *Clone() const wxOVERRIDE { return new wxListEvent(*this); }
|
2002-07-30 15:04:18 -04:00
|
|
|
|
|
|
|
//protected: -- not for backwards compatibility
|
|
|
|
int m_code;
|
2013-04-25 06:11:03 -04:00
|
|
|
long m_oldItemIndex; // only for wxEVT_LIST_CACHE_HINT
|
2002-07-30 15:04:18 -04:00
|
|
|
long m_itemIndex;
|
|
|
|
int m_col;
|
|
|
|
wxPoint m_pointDrag;
|
|
|
|
|
|
|
|
wxListItem m_item;
|
|
|
|
|
2003-10-07 04:41:54 -04:00
|
|
|
protected:
|
|
|
|
bool m_editCancelled;
|
|
|
|
|
2002-07-30 15:04:18 -04:00
|
|
|
private:
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxListEvent);
|
2002-07-30 15:04:18 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxListCtrl event macros
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2013-04-25 06:11:03 -04:00
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_BEGIN_DRAG, wxListEvent );
|
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_BEGIN_RDRAG, wxListEvent );
|
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_BEGIN_LABEL_EDIT, wxListEvent );
|
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_END_LABEL_EDIT, wxListEvent );
|
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_DELETE_ITEM, wxListEvent );
|
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_DELETE_ALL_ITEMS, wxListEvent );
|
|
|
|
|
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_ITEM_SELECTED, wxListEvent );
|
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_ITEM_DESELECTED, wxListEvent );
|
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_KEY_DOWN, wxListEvent );
|
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_INSERT_ITEM, wxListEvent );
|
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_COL_CLICK, wxListEvent );
|
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_ITEM_RIGHT_CLICK, wxListEvent );
|
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_ITEM_MIDDLE_CLICK, wxListEvent );
|
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_ITEM_ACTIVATED, wxListEvent );
|
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_CACHE_HINT, wxListEvent );
|
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_COL_RIGHT_CLICK, wxListEvent );
|
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_COL_BEGIN_DRAG, wxListEvent );
|
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_COL_DRAGGING, wxListEvent );
|
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_COL_END_DRAG, wxListEvent );
|
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_ITEM_FOCUSED, wxListEvent );
|
2015-12-17 08:27:53 -05:00
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_ITEM_CHECKED, wxListEvent );
|
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LIST_ITEM_UNCHECKED, wxListEvent );
|
2002-07-30 15:04:18 -04:00
|
|
|
|
|
|
|
typedef void (wxEvtHandler::*wxListEventFunction)(wxListEvent&);
|
|
|
|
|
2005-02-14 18:53:48 -05:00
|
|
|
#define wxListEventHandler(func) \
|
2009-01-12 09:26:13 -05:00
|
|
|
wxEVENT_HANDLER_CAST(wxListEventFunction, func)
|
2005-02-14 18:53:48 -05:00
|
|
|
|
|
|
|
#define wx__DECLARE_LISTEVT(evt, id, fn) \
|
2013-04-25 06:11:03 -04:00
|
|
|
wx__DECLARE_EVT1(wxEVT_LIST_ ## evt, id, wxListEventHandler(fn))
|
2005-02-14 18:53:48 -05:00
|
|
|
|
|
|
|
#define EVT_LIST_BEGIN_DRAG(id, fn) wx__DECLARE_LISTEVT(BEGIN_DRAG, id, fn)
|
|
|
|
#define EVT_LIST_BEGIN_RDRAG(id, fn) wx__DECLARE_LISTEVT(BEGIN_RDRAG, id, fn)
|
|
|
|
#define EVT_LIST_BEGIN_LABEL_EDIT(id, fn) wx__DECLARE_LISTEVT(BEGIN_LABEL_EDIT, id, fn)
|
|
|
|
#define EVT_LIST_END_LABEL_EDIT(id, fn) wx__DECLARE_LISTEVT(END_LABEL_EDIT, id, fn)
|
|
|
|
#define EVT_LIST_DELETE_ITEM(id, fn) wx__DECLARE_LISTEVT(DELETE_ITEM, id, fn)
|
|
|
|
#define EVT_LIST_DELETE_ALL_ITEMS(id, fn) wx__DECLARE_LISTEVT(DELETE_ALL_ITEMS, id, fn)
|
|
|
|
#define EVT_LIST_KEY_DOWN(id, fn) wx__DECLARE_LISTEVT(KEY_DOWN, id, fn)
|
|
|
|
#define EVT_LIST_INSERT_ITEM(id, fn) wx__DECLARE_LISTEVT(INSERT_ITEM, id, fn)
|
|
|
|
|
|
|
|
#define EVT_LIST_COL_CLICK(id, fn) wx__DECLARE_LISTEVT(COL_CLICK, id, fn)
|
|
|
|
#define EVT_LIST_COL_RIGHT_CLICK(id, fn) wx__DECLARE_LISTEVT(COL_RIGHT_CLICK, id, fn)
|
|
|
|
#define EVT_LIST_COL_BEGIN_DRAG(id, fn) wx__DECLARE_LISTEVT(COL_BEGIN_DRAG, id, fn)
|
|
|
|
#define EVT_LIST_COL_DRAGGING(id, fn) wx__DECLARE_LISTEVT(COL_DRAGGING, id, fn)
|
|
|
|
#define EVT_LIST_COL_END_DRAG(id, fn) wx__DECLARE_LISTEVT(COL_END_DRAG, id, fn)
|
|
|
|
|
|
|
|
#define EVT_LIST_ITEM_SELECTED(id, fn) wx__DECLARE_LISTEVT(ITEM_SELECTED, id, fn)
|
|
|
|
#define EVT_LIST_ITEM_DESELECTED(id, fn) wx__DECLARE_LISTEVT(ITEM_DESELECTED, id, fn)
|
|
|
|
#define EVT_LIST_ITEM_RIGHT_CLICK(id, fn) wx__DECLARE_LISTEVT(ITEM_RIGHT_CLICK, id, fn)
|
|
|
|
#define EVT_LIST_ITEM_MIDDLE_CLICK(id, fn) wx__DECLARE_LISTEVT(ITEM_MIDDLE_CLICK, id, fn)
|
|
|
|
#define EVT_LIST_ITEM_ACTIVATED(id, fn) wx__DECLARE_LISTEVT(ITEM_ACTIVATED, id, fn)
|
|
|
|
#define EVT_LIST_ITEM_FOCUSED(id, fn) wx__DECLARE_LISTEVT(ITEM_FOCUSED, id, fn)
|
2015-12-17 08:27:53 -05:00
|
|
|
#define EVT_LIST_ITEM_CHECKED(id, fn) wx__DECLARE_LISTEVT(ITEM_CHECKED, id, fn)
|
|
|
|
#define EVT_LIST_ITEM_UNCHECKED(id, fn) wx__DECLARE_LISTEVT(ITEM_UNCHECKED, id, fn)
|
2005-02-14 18:53:48 -05:00
|
|
|
|
|
|
|
#define EVT_LIST_CACHE_HINT(id, fn) wx__DECLARE_LISTEVT(CACHE_HINT, id, fn)
|
|
|
|
|
2013-04-25 06:11:03 -04:00
|
|
|
// old wxEVT_COMMAND_* constants
|
|
|
|
#define wxEVT_COMMAND_LIST_BEGIN_DRAG wxEVT_LIST_BEGIN_DRAG
|
|
|
|
#define wxEVT_COMMAND_LIST_BEGIN_RDRAG wxEVT_LIST_BEGIN_RDRAG
|
|
|
|
#define wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT wxEVT_LIST_BEGIN_LABEL_EDIT
|
|
|
|
#define wxEVT_COMMAND_LIST_END_LABEL_EDIT wxEVT_LIST_END_LABEL_EDIT
|
|
|
|
#define wxEVT_COMMAND_LIST_DELETE_ITEM wxEVT_LIST_DELETE_ITEM
|
|
|
|
#define wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS wxEVT_LIST_DELETE_ALL_ITEMS
|
|
|
|
#define wxEVT_COMMAND_LIST_ITEM_SELECTED wxEVT_LIST_ITEM_SELECTED
|
|
|
|
#define wxEVT_COMMAND_LIST_ITEM_DESELECTED wxEVT_LIST_ITEM_DESELECTED
|
|
|
|
#define wxEVT_COMMAND_LIST_KEY_DOWN wxEVT_LIST_KEY_DOWN
|
|
|
|
#define wxEVT_COMMAND_LIST_INSERT_ITEM wxEVT_LIST_INSERT_ITEM
|
|
|
|
#define wxEVT_COMMAND_LIST_COL_CLICK wxEVT_LIST_COL_CLICK
|
|
|
|
#define wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK wxEVT_LIST_ITEM_RIGHT_CLICK
|
|
|
|
#define wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK wxEVT_LIST_ITEM_MIDDLE_CLICK
|
|
|
|
#define wxEVT_COMMAND_LIST_ITEM_ACTIVATED wxEVT_LIST_ITEM_ACTIVATED
|
|
|
|
#define wxEVT_COMMAND_LIST_CACHE_HINT wxEVT_LIST_CACHE_HINT
|
|
|
|
#define wxEVT_COMMAND_LIST_COL_RIGHT_CLICK wxEVT_LIST_COL_RIGHT_CLICK
|
|
|
|
#define wxEVT_COMMAND_LIST_COL_BEGIN_DRAG wxEVT_LIST_COL_BEGIN_DRAG
|
|
|
|
#define wxEVT_COMMAND_LIST_COL_DRAGGING wxEVT_LIST_COL_DRAGGING
|
|
|
|
#define wxEVT_COMMAND_LIST_COL_END_DRAG wxEVT_LIST_COL_END_DRAG
|
|
|
|
#define wxEVT_COMMAND_LIST_ITEM_FOCUSED wxEVT_LIST_ITEM_FOCUSED
|
|
|
|
|
2005-02-14 18:53:48 -05:00
|
|
|
|
2002-07-30 15:04:18 -04:00
|
|
|
#endif
|
|
|
|
// _WX_LISTCTRL_H_BASE_
|