2006-01-08 21:50:02 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/dataview.h
|
|
|
|
// Purpose: wxDataViewCtrl base classes
|
|
|
|
// Author: Robert Roebling
|
2007-08-19 19:03:01 +00:00
|
|
|
// Modified by: Bo Yang
|
2006-01-08 21:50:02 +00:00
|
|
|
// Created: 08.01.06
|
|
|
|
// Copyright: (c) Robert Roebling
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_DATAVIEW_H_BASE_
|
|
|
|
#define _WX_DATAVIEW_H_BASE_
|
|
|
|
|
|
|
|
#include "wx/defs.h"
|
|
|
|
|
|
|
|
#if wxUSE_DATAVIEWCTRL
|
|
|
|
|
2006-02-21 17:35:19 +00:00
|
|
|
#include "wx/textctrl.h"
|
2008-12-03 21:53:10 +00:00
|
|
|
#include "wx/headercol.h"
|
2006-02-21 18:12:44 +00:00
|
|
|
#include "wx/variant.h"
|
2012-04-29 23:22:25 +00:00
|
|
|
#include "wx/dnd.h" // For wxDragResult declaration only.
|
2007-08-19 19:03:01 +00:00
|
|
|
#include "wx/dynarray.h"
|
2007-08-29 11:12:12 +00:00
|
|
|
#include "wx/icon.h"
|
2011-08-21 14:08:56 +00:00
|
|
|
#include "wx/itemid.h"
|
2008-04-11 10:40:58 +00:00
|
|
|
#include "wx/weakref.h"
|
2009-01-16 11:23:37 +00:00
|
|
|
#include "wx/vector.h"
|
2009-01-20 17:50:51 +00:00
|
|
|
#include "wx/dataobj.h"
|
2011-08-21 14:08:43 +00:00
|
|
|
#include "wx/withimages.h"
|
2015-09-17 12:46:27 +00:00
|
|
|
#include "wx/systhemectrl.h"
|
2009-01-20 17:50:51 +00:00
|
|
|
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxImageList;
|
2016-04-25 10:08:28 +00:00
|
|
|
class wxItemAttr;
|
2016-04-21 23:12:21 +00:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxHeaderCtrl;
|
2006-03-20 16:37:24 +00:00
|
|
|
|
2014-08-24 01:50:11 +00:00
|
|
|
#if !(defined(__WXGTK20__) || defined(__WXOSX__) ) || defined(__WXUNIVERSAL__)
|
2009-06-01 13:57:38 +00:00
|
|
|
// #if !(defined(__WXOSX__)) || defined(__WXUNIVERSAL__)
|
2008-12-03 21:53:10 +00:00
|
|
|
#define wxHAS_GENERIC_DATAVIEWCTRL
|
|
|
|
#endif
|
|
|
|
|
2009-11-10 17:40:58 +00:00
|
|
|
#ifdef wxHAS_GENERIC_DATAVIEWCTRL
|
|
|
|
// this symbol doesn't follow the convention for wxUSE_XXX symbols which
|
|
|
|
// are normally always defined as either 0 or 1, so its use is deprecated
|
|
|
|
// and it only exists for backwards compatibility, don't use it any more
|
|
|
|
// and use wxHAS_GENERIC_DATAVIEWCTRL instead
|
|
|
|
#define wxUSE_GENERICDATAVIEWCTRL
|
|
|
|
#endif
|
|
|
|
|
2006-02-21 17:35:19 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxDataViewCtrl globals
|
|
|
|
// ----------------------------------------------------------------------------
|
2006-01-08 21:50:02 +00:00
|
|
|
|
2007-07-09 10:09:52 +00:00
|
|
|
class WXDLLIMPEXP_FWD_ADV wxDataViewModel;
|
|
|
|
class WXDLLIMPEXP_FWD_ADV wxDataViewCtrl;
|
|
|
|
class WXDLLIMPEXP_FWD_ADV wxDataViewColumn;
|
|
|
|
class WXDLLIMPEXP_FWD_ADV wxDataViewRenderer;
|
|
|
|
class WXDLLIMPEXP_FWD_ADV wxDataViewModelNotifier;
|
2006-02-22 00:19:04 +00:00
|
|
|
|
2008-11-02 22:16:14 +00:00
|
|
|
extern WXDLLIMPEXP_DATA_ADV(const char) wxDataViewCtrlNameStr[];
|
2006-01-08 21:50:02 +00:00
|
|
|
|
2009-03-06 22:56:27 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxDataViewCtrl flags
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// size of a wxDataViewRenderer without contents:
|
|
|
|
#define wxDVC_DEFAULT_RENDERER_SIZE 20
|
|
|
|
|
2007-02-17 12:32:38 +00:00
|
|
|
// the default width of new (text) columns:
|
|
|
|
#define wxDVC_DEFAULT_WIDTH 80
|
|
|
|
|
|
|
|
// the default width of new toggle columns:
|
|
|
|
#define wxDVC_TOGGLE_DEFAULT_WIDTH 30
|
|
|
|
|
2007-02-23 07:57:46 +00:00
|
|
|
// the default minimal width of the columns:
|
|
|
|
#define wxDVC_DEFAULT_MINWIDTH 30
|
|
|
|
|
2008-04-08 10:39:57 +00:00
|
|
|
// The default alignment of wxDataViewRenderers is to take
|
|
|
|
// the alignment from the column it owns.
|
|
|
|
#define wxDVR_DEFAULT_ALIGNMENT -1
|
2007-02-23 07:57:46 +00:00
|
|
|
|
2007-02-17 12:32:38 +00:00
|
|
|
|
2006-03-27 14:01:33 +00:00
|
|
|
// ---------------------------------------------------------
|
2007-07-05 00:13:28 +00:00
|
|
|
// wxDataViewItem
|
2006-03-27 14:01:33 +00:00
|
|
|
// ---------------------------------------------------------
|
2006-02-21 17:35:19 +00:00
|
|
|
|
2011-08-21 14:08:56 +00:00
|
|
|
// Make it a class and not a typedef to allow forward declaring it.
|
|
|
|
class wxDataViewItem : public wxItemId<void*>
|
2006-02-21 17:35:19 +00:00
|
|
|
{
|
|
|
|
public:
|
2011-08-21 14:08:56 +00:00
|
|
|
wxDataViewItem() : wxItemId<void*>() { }
|
|
|
|
wxEXPLICIT wxDataViewItem(void* pItem) : wxItemId<void*>(pItem) { }
|
2006-02-21 18:12:44 +00:00
|
|
|
};
|
2006-02-21 17:35:19 +00:00
|
|
|
|
2007-08-22 13:14:57 +00:00
|
|
|
WX_DEFINE_ARRAY(wxDataViewItem, wxDataViewItemArray);
|
|
|
|
|
2007-07-25 18:46:01 +00:00
|
|
|
// ---------------------------------------------------------
|
|
|
|
// wxDataViewModelNotifier
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewModelNotifier
|
|
|
|
{
|
|
|
|
public:
|
2007-12-30 19:12:04 +00:00
|
|
|
wxDataViewModelNotifier() { m_owner = NULL; }
|
2007-07-25 18:46:01 +00:00
|
|
|
virtual ~wxDataViewModelNotifier() { m_owner = NULL; }
|
|
|
|
|
|
|
|
virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ) = 0;
|
|
|
|
virtual bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item ) = 0;
|
|
|
|
virtual bool ItemChanged( const wxDataViewItem &item ) = 0;
|
2007-10-01 10:54:57 +00:00
|
|
|
virtual bool ItemsAdded( const wxDataViewItem &parent, const wxDataViewItemArray &items );
|
|
|
|
virtual bool ItemsDeleted( const wxDataViewItem &parent, const wxDataViewItemArray &items );
|
|
|
|
virtual bool ItemsChanged( const wxDataViewItemArray &items );
|
2007-07-25 18:46:01 +00:00
|
|
|
virtual bool ValueChanged( const wxDataViewItem &item, unsigned int col ) = 0;
|
|
|
|
virtual bool Cleared() = 0;
|
2010-09-30 11:44:45 +00:00
|
|
|
|
2010-09-13 20:02:01 +00:00
|
|
|
// some platforms, such as GTK+, may need a two step procedure for ::Reset()
|
|
|
|
virtual bool BeforeReset() { return true; }
|
2010-09-12 20:07:28 +00:00
|
|
|
virtual bool AfterReset() { return Cleared(); }
|
2007-10-20 23:23:44 +00:00
|
|
|
|
2007-08-03 11:47:42 +00:00
|
|
|
virtual void Resort() = 0;
|
2007-07-25 18:46:01 +00:00
|
|
|
|
|
|
|
void SetOwner( wxDataViewModel *owner ) { m_owner = owner; }
|
2008-04-08 11:17:54 +00:00
|
|
|
wxDataViewModel *GetOwner() const { return m_owner; }
|
2007-07-25 18:46:01 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
wxDataViewModel *m_owner;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2007-11-08 22:51:58 +00:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxDataViewItemAttr: a structure containing the visual attributes of an item
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2016-04-21 22:58:38 +00:00
|
|
|
// TODO: Merge with wxItemAttr somehow.
|
2007-11-08 22:51:58 +00:00
|
|
|
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewItemAttr
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// ctors
|
2008-01-27 13:21:39 +00:00
|
|
|
wxDataViewItemAttr()
|
|
|
|
{
|
2007-11-08 22:51:58 +00:00
|
|
|
m_bold = false;
|
|
|
|
m_italic = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// setters
|
|
|
|
void SetColour(const wxColour& colour) { m_colour = colour; }
|
|
|
|
void SetBold( bool set ) { m_bold = set; }
|
|
|
|
void SetItalic( bool set ) { m_italic = set; }
|
2011-12-19 12:54:38 +00:00
|
|
|
void SetBackgroundColour(const wxColour& colour) { m_bgColour = colour; }
|
2008-01-27 13:21:39 +00:00
|
|
|
|
2007-11-08 22:51:58 +00:00
|
|
|
// accessors
|
2011-05-03 16:29:04 +00:00
|
|
|
bool HasColour() const { return m_colour.IsOk(); }
|
2007-11-08 22:51:58 +00:00
|
|
|
const wxColour& GetColour() const { return m_colour; }
|
2008-01-27 13:21:39 +00:00
|
|
|
|
2009-10-12 13:59:25 +00:00
|
|
|
bool HasFont() const { return m_bold || m_italic; }
|
2007-11-08 22:51:58 +00:00
|
|
|
bool GetBold() const { return m_bold; }
|
|
|
|
bool GetItalic() const { return m_italic; }
|
|
|
|
|
2011-12-19 12:54:38 +00:00
|
|
|
bool HasBackgroundColour() const { return m_bgColour.IsOk(); }
|
|
|
|
const wxColour& GetBackgroundColour() const { return m_bgColour; }
|
|
|
|
|
|
|
|
bool IsDefault() const { return !(HasColour() || HasFont() || HasBackgroundColour()); }
|
2009-11-10 17:41:58 +00:00
|
|
|
|
2010-10-30 15:57:49 +00:00
|
|
|
// Return the font based on the given one with this attribute applied to it.
|
|
|
|
wxFont GetEffectiveFont(const wxFont& font) const;
|
|
|
|
|
2007-11-08 22:51:58 +00:00
|
|
|
private:
|
|
|
|
wxColour m_colour;
|
|
|
|
bool m_bold;
|
|
|
|
bool m_italic;
|
2011-12-19 12:54:38 +00:00
|
|
|
wxColour m_bgColour;
|
2007-11-08 22:51:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-03-27 14:01:33 +00:00
|
|
|
// ---------------------------------------------------------
|
2007-07-05 00:13:28 +00:00
|
|
|
// wxDataViewModel
|
2006-03-27 14:01:33 +00:00
|
|
|
// ---------------------------------------------------------
|
2006-02-21 17:35:19 +00:00
|
|
|
|
2007-10-10 19:44:26 +00:00
|
|
|
WX_DECLARE_LIST_WITH_DECL(wxDataViewModelNotifier, wxDataViewModelNotifiers,
|
|
|
|
class WXDLLIMPEXP_ADV);
|
2007-07-25 18:46:01 +00:00
|
|
|
|
2009-06-14 14:11:07 +00:00
|
|
|
class WXDLLIMPEXP_ADV wxDataViewModel: public wxRefCounter
|
2006-02-21 17:35:19 +00:00
|
|
|
{
|
|
|
|
public:
|
2007-07-05 00:13:28 +00:00
|
|
|
wxDataViewModel();
|
2006-02-21 17:35:19 +00:00
|
|
|
|
2007-02-23 07:57:46 +00:00
|
|
|
virtual unsigned int GetColumnCount() const = 0;
|
2007-02-17 12:32:38 +00:00
|
|
|
|
2006-02-23 13:34:15 +00:00
|
|
|
// return type as reported by wxVariant
|
2007-02-23 07:57:46 +00:00
|
|
|
virtual wxString GetColumnType( unsigned int col ) const = 0;
|
2007-02-17 12:32:38 +00:00
|
|
|
|
2006-02-23 13:34:15 +00:00
|
|
|
// get value into a wxVariant
|
2007-10-20 23:23:44 +00:00
|
|
|
virtual void GetValue( wxVariant &variant,
|
2007-07-05 00:13:28 +00:00
|
|
|
const wxDataViewItem &item, unsigned int col ) const = 0;
|
2007-02-17 12:32:38 +00:00
|
|
|
|
2009-10-24 01:03:24 +00:00
|
|
|
// return true if the given item has a value to display in the given
|
|
|
|
// column: this is always true except for container items which by default
|
|
|
|
// only show their label in the first column (but see HasContainerColumns())
|
|
|
|
bool HasValue(const wxDataViewItem& item, unsigned col) const
|
|
|
|
{
|
|
|
|
return col == 0 || !IsContainer(item) || HasContainerColumns(item);
|
|
|
|
}
|
|
|
|
|
2009-10-23 23:49:16 +00:00
|
|
|
// usually ValueChanged() should be called after changing the value in the
|
|
|
|
// model to update the control, ChangeValue() does it on its own while
|
|
|
|
// SetValue() does not -- so while you will override SetValue(), you should
|
|
|
|
// be usually calling ChangeValue()
|
|
|
|
virtual bool SetValue(const wxVariant &variant,
|
|
|
|
const wxDataViewItem &item,
|
|
|
|
unsigned int col) = 0;
|
|
|
|
|
|
|
|
bool ChangeValue(const wxVariant& variant,
|
|
|
|
const wxDataViewItem& item,
|
|
|
|
unsigned int col)
|
|
|
|
{
|
|
|
|
return SetValue(variant, item, col) && ValueChanged(item, col);
|
|
|
|
}
|
2006-02-21 17:35:19 +00:00
|
|
|
|
2007-11-08 22:51:58 +00:00
|
|
|
// Get text attribute, return false of default attributes should be used
|
2009-10-24 21:42:04 +00:00
|
|
|
virtual bool GetAttr(const wxDataViewItem &WXUNUSED(item),
|
|
|
|
unsigned int WXUNUSED(col),
|
|
|
|
wxDataViewItemAttr &WXUNUSED(attr)) const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2007-11-08 22:51:58 +00:00
|
|
|
|
2010-12-19 15:02:56 +00:00
|
|
|
// Override this if you want to disable specific items
|
|
|
|
virtual bool IsEnabled(const wxDataViewItem &WXUNUSED(item),
|
|
|
|
unsigned int WXUNUSED(col)) const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-20 11:55:18 +00:00
|
|
|
// define hierarchy
|
2007-07-20 09:01:52 +00:00
|
|
|
virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const = 0;
|
|
|
|
virtual bool IsContainer( const wxDataViewItem &item ) const = 0;
|
2007-10-12 18:31:12 +00:00
|
|
|
// Is the container just a header or an item with all columns
|
2007-10-20 23:23:44 +00:00
|
|
|
virtual bool HasContainerColumns(const wxDataViewItem& WXUNUSED(item)) const
|
|
|
|
{ return false; }
|
2007-08-31 09:44:59 +00:00
|
|
|
virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const = 0;
|
2007-05-30 21:03:26 +00:00
|
|
|
|
2006-02-21 17:35:19 +00:00
|
|
|
// delegated notifiers
|
2010-07-24 15:30:03 +00:00
|
|
|
bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item );
|
|
|
|
bool ItemsAdded( const wxDataViewItem &parent, const wxDataViewItemArray &items );
|
|
|
|
bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item );
|
|
|
|
bool ItemsDeleted( const wxDataViewItem &parent, const wxDataViewItemArray &items );
|
|
|
|
bool ItemChanged( const wxDataViewItem &item );
|
|
|
|
bool ItemsChanged( const wxDataViewItemArray &items );
|
|
|
|
bool ValueChanged( const wxDataViewItem &item, unsigned int col );
|
|
|
|
bool Cleared();
|
2006-02-27 13:09:41 +00:00
|
|
|
|
2010-09-13 20:02:01 +00:00
|
|
|
// some platforms, such as GTK+, may need a two step procedure for ::Reset()
|
|
|
|
bool BeforeReset();
|
2010-09-12 20:07:28 +00:00
|
|
|
bool AfterReset();
|
|
|
|
|
|
|
|
|
|
|
|
// delegated action
|
2007-07-18 13:23:57 +00:00
|
|
|
virtual void Resort();
|
|
|
|
|
2007-07-05 00:13:28 +00:00
|
|
|
void AddNotifier( wxDataViewModelNotifier *notifier );
|
|
|
|
void RemoveNotifier( wxDataViewModelNotifier *notifier );
|
2007-10-20 23:23:44 +00:00
|
|
|
|
2007-07-18 13:23:57 +00:00
|
|
|
// default compare function
|
2007-10-20 23:23:44 +00:00
|
|
|
virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
|
2009-03-10 13:37:26 +00:00
|
|
|
unsigned int column, bool ascending ) const;
|
2007-08-31 09:55:36 +00:00
|
|
|
virtual bool HasDefaultCompare() const { return false; }
|
2008-01-27 13:21:39 +00:00
|
|
|
|
2007-11-18 23:54:57 +00:00
|
|
|
// internal
|
2010-07-29 20:54:00 +00:00
|
|
|
virtual bool IsListModel() const { return false; }
|
2008-04-07 09:27:21 +00:00
|
|
|
virtual bool IsVirtualListModel() const { return false; }
|
2007-08-20 17:26:11 +00:00
|
|
|
|
2007-02-17 12:32:38 +00:00
|
|
|
protected:
|
|
|
|
// the user should not delete this class directly: he should use DecRef() instead!
|
2007-07-05 14:59:16 +00:00
|
|
|
virtual ~wxDataViewModel() { }
|
2007-02-17 12:32:38 +00:00
|
|
|
|
2007-07-25 18:46:01 +00:00
|
|
|
wxDataViewModelNotifiers m_notifiers;
|
2007-07-18 13:23:57 +00:00
|
|
|
};
|
|
|
|
|
2009-10-24 21:41:54 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxDataViewListModel: a model of a list, i.e. flat data structure without any
|
|
|
|
// branches/containers, used as base class by wxDataViewIndexListModel and
|
|
|
|
// wxDataViewVirtualListModel
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewListModel : public wxDataViewModel
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// derived classes should override these methods instead of
|
|
|
|
// {Get,Set}Value() and GetAttr() inherited from the base class
|
|
|
|
|
|
|
|
virtual void GetValueByRow(wxVariant &variant,
|
|
|
|
unsigned row, unsigned col) const = 0;
|
|
|
|
|
|
|
|
virtual bool SetValueByRow(const wxVariant &variant,
|
|
|
|
unsigned row, unsigned col) = 0;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
GetAttrByRow(unsigned WXUNUSED(row), unsigned WXUNUSED(col),
|
2009-10-24 21:42:04 +00:00
|
|
|
wxDataViewItemAttr &WXUNUSED(attr)) const
|
2009-10-24 21:41:54 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-12-19 15:02:56 +00:00
|
|
|
virtual bool IsEnabledByRow(unsigned int WXUNUSED(row),
|
|
|
|
unsigned int WXUNUSED(col)) const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-10-24 21:41:54 +00:00
|
|
|
|
|
|
|
// helper methods provided by list models only
|
|
|
|
virtual unsigned GetRow( const wxDataViewItem &item ) const = 0;
|
|
|
|
|
2010-09-30 11:44:45 +00:00
|
|
|
// returns the number of rows
|
2010-09-13 20:12:57 +00:00
|
|
|
virtual unsigned int GetCount() const = 0;
|
2009-10-24 21:41:54 +00:00
|
|
|
|
|
|
|
// implement some base class pure virtual directly
|
|
|
|
virtual wxDataViewItem
|
2014-03-30 00:02:23 +00:00
|
|
|
GetParent( const wxDataViewItem & WXUNUSED(item) ) const wxOVERRIDE
|
2009-10-24 21:41:54 +00:00
|
|
|
{
|
|
|
|
// items never have valid parent in this model
|
|
|
|
return wxDataViewItem();
|
|
|
|
}
|
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual bool IsContainer( const wxDataViewItem &item ) const wxOVERRIDE
|
2009-10-24 21:41:54 +00:00
|
|
|
{
|
|
|
|
// only the invisible (and invalid) root item has children
|
|
|
|
return !item.IsOk();
|
|
|
|
}
|
|
|
|
|
|
|
|
// and implement some others by forwarding them to our own ones
|
|
|
|
virtual void GetValue( wxVariant &variant,
|
2014-03-30 00:02:23 +00:00
|
|
|
const wxDataViewItem &item, unsigned int col ) const wxOVERRIDE
|
2009-10-24 21:41:54 +00:00
|
|
|
{
|
|
|
|
GetValueByRow(variant, GetRow(item), col);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool SetValue( const wxVariant &variant,
|
2014-03-30 00:02:23 +00:00
|
|
|
const wxDataViewItem &item, unsigned int col ) wxOVERRIDE
|
2009-10-24 21:41:54 +00:00
|
|
|
{
|
|
|
|
return SetValueByRow( variant, GetRow(item), col );
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool GetAttr(const wxDataViewItem &item, unsigned int col,
|
2014-03-30 00:02:23 +00:00
|
|
|
wxDataViewItemAttr &attr) const wxOVERRIDE
|
2009-10-24 21:41:54 +00:00
|
|
|
{
|
|
|
|
return GetAttrByRow( GetRow(item), col, attr );
|
|
|
|
}
|
2010-07-29 20:54:00 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual bool IsEnabled(const wxDataViewItem &item, unsigned int col) const wxOVERRIDE
|
2010-12-19 15:02:56 +00:00
|
|
|
{
|
|
|
|
return IsEnabledByRow( GetRow(item), col );
|
|
|
|
}
|
|
|
|
|
2010-09-13 20:12:57 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual bool IsListModel() const wxOVERRIDE { return true; }
|
2009-10-24 21:41:54 +00:00
|
|
|
};
|
|
|
|
|
2007-07-18 13:23:57 +00:00
|
|
|
// ---------------------------------------------------------
|
2007-07-21 23:07:03 +00:00
|
|
|
// wxDataViewIndexListModel
|
2007-07-18 13:23:57 +00:00
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
2009-10-24 21:41:54 +00:00
|
|
|
class WXDLLIMPEXP_ADV wxDataViewIndexListModel: public wxDataViewListModel
|
2007-07-18 13:23:57 +00:00
|
|
|
{
|
|
|
|
public:
|
2007-07-21 23:07:03 +00:00
|
|
|
wxDataViewIndexListModel( unsigned int initial_size = 0 );
|
2008-01-27 13:21:39 +00:00
|
|
|
|
2007-07-21 23:07:03 +00:00
|
|
|
void RowPrepended();
|
|
|
|
void RowInserted( unsigned int before );
|
|
|
|
void RowAppended();
|
|
|
|
void RowDeleted( unsigned int row );
|
2007-12-17 11:28:02 +00:00
|
|
|
void RowsDeleted( const wxArrayInt &rows );
|
2007-07-21 23:07:03 +00:00
|
|
|
void RowChanged( unsigned int row );
|
|
|
|
void RowValueChanged( unsigned int row, unsigned int col );
|
2007-12-17 13:56:28 +00:00
|
|
|
void Reset( unsigned int new_size );
|
2007-10-20 23:23:44 +00:00
|
|
|
|
2007-07-21 23:07:03 +00:00
|
|
|
// convert to/from row/wxDataViewItem
|
2007-10-20 23:23:44 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual unsigned GetRow( const wxDataViewItem &item ) const wxOVERRIDE;
|
2007-07-21 23:07:03 +00:00
|
|
|
wxDataViewItem GetItem( unsigned int row ) const;
|
2007-10-20 23:23:44 +00:00
|
|
|
|
2007-07-21 23:07:03 +00:00
|
|
|
// implement base methods
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const wxOVERRIDE;
|
2007-10-20 23:23:44 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
unsigned int GetCount() const wxOVERRIDE { return m_hash.GetCount(); }
|
2008-01-27 13:21:39 +00:00
|
|
|
|
2007-07-21 23:07:03 +00:00
|
|
|
private:
|
2007-08-22 13:14:57 +00:00
|
|
|
wxDataViewItemArray m_hash;
|
2009-06-16 17:59:09 +00:00
|
|
|
unsigned int m_nextFreeID;
|
2007-11-15 15:03:48 +00:00
|
|
|
bool m_ordered;
|
2006-02-21 17:35:19 +00:00
|
|
|
};
|
|
|
|
|
2008-04-07 09:27:21 +00:00
|
|
|
// ---------------------------------------------------------
|
|
|
|
// wxDataViewVirtualListModel
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
// better than nothing
|
2008-04-07 18:52:31 +00:00
|
|
|
typedef wxDataViewIndexListModel wxDataViewVirtualListModel;
|
2008-04-07 09:27:21 +00:00
|
|
|
#else
|
|
|
|
|
2009-10-24 21:41:54 +00:00
|
|
|
class WXDLLIMPEXP_ADV wxDataViewVirtualListModel: public wxDataViewListModel
|
2008-04-07 09:27:21 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDataViewVirtualListModel( unsigned int initial_size = 0 );
|
|
|
|
|
|
|
|
void RowPrepended();
|
|
|
|
void RowInserted( unsigned int before );
|
|
|
|
void RowAppended();
|
|
|
|
void RowDeleted( unsigned int row );
|
|
|
|
void RowsDeleted( const wxArrayInt &rows );
|
|
|
|
void RowChanged( unsigned int row );
|
|
|
|
void RowValueChanged( unsigned int row, unsigned int col );
|
|
|
|
void Reset( unsigned int new_size );
|
|
|
|
|
|
|
|
// convert to/from row/wxDataViewItem
|
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual unsigned GetRow( const wxDataViewItem &item ) const wxOVERRIDE;
|
2008-04-07 09:27:21 +00:00
|
|
|
wxDataViewItem GetItem( unsigned int row ) const;
|
|
|
|
|
|
|
|
// compare based on index
|
|
|
|
|
|
|
|
virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
|
2014-03-30 00:02:23 +00:00
|
|
|
unsigned int column, bool ascending ) const wxOVERRIDE;
|
|
|
|
virtual bool HasDefaultCompare() const wxOVERRIDE;
|
2008-04-07 09:27:21 +00:00
|
|
|
|
|
|
|
// implement base methods
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const wxOVERRIDE;
|
2008-04-07 09:27:21 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
unsigned int GetCount() const wxOVERRIDE { return m_size; }
|
2009-10-31 15:58:19 +00:00
|
|
|
|
2008-04-07 09:27:21 +00:00
|
|
|
// internal
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual bool IsVirtualListModel() const wxOVERRIDE { return true; }
|
2008-04-07 09:27:21 +00:00
|
|
|
|
|
|
|
private:
|
2009-06-16 17:59:09 +00:00
|
|
|
unsigned int m_size;
|
2008-04-07 09:27:21 +00:00
|
|
|
};
|
|
|
|
#endif
|
2007-10-13 22:01:24 +00:00
|
|
|
|
2009-11-10 17:40:58 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxDataViewRenderer and related classes
|
|
|
|
// ----------------------------------------------------------------------------
|
2007-08-29 11:12:12 +00:00
|
|
|
|
2009-11-10 17:40:58 +00:00
|
|
|
#include "wx/dvrenderers.h"
|
2007-08-29 11:12:12 +00:00
|
|
|
|
2006-03-27 14:01:33 +00:00
|
|
|
// ---------------------------------------------------------
|
2006-02-23 02:04:46 +00:00
|
|
|
// wxDataViewColumnBase
|
2006-03-27 14:01:33 +00:00
|
|
|
// ---------------------------------------------------------
|
2006-02-23 02:04:46 +00:00
|
|
|
|
2008-12-03 21:53:10 +00:00
|
|
|
// for compatibility only, do not use
|
2006-02-22 00:19:04 +00:00
|
|
|
enum wxDataViewColumnFlags
|
|
|
|
{
|
2008-12-03 21:53:10 +00:00
|
|
|
wxDATAVIEW_COL_RESIZABLE = wxCOL_RESIZABLE,
|
|
|
|
wxDATAVIEW_COL_SORTABLE = wxCOL_SORTABLE,
|
|
|
|
wxDATAVIEW_COL_REORDERABLE = wxCOL_REORDERABLE,
|
|
|
|
wxDATAVIEW_COL_HIDDEN = wxCOL_HIDDEN
|
2006-02-22 00:19:04 +00:00
|
|
|
};
|
|
|
|
|
2008-12-11 13:05:48 +00:00
|
|
|
class WXDLLIMPEXP_ADV wxDataViewColumnBase : public wxSettableHeaderColumn
|
2006-02-22 00:19:04 +00:00
|
|
|
{
|
|
|
|
public:
|
2008-12-07 14:47:55 +00:00
|
|
|
// ctor for the text columns: takes ownership of renderer
|
|
|
|
wxDataViewColumnBase(wxDataViewRenderer *renderer,
|
|
|
|
unsigned int model_column)
|
|
|
|
{
|
|
|
|
Init(renderer, model_column);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ctor for the bitmap columns
|
|
|
|
wxDataViewColumnBase(const wxBitmap& bitmap,
|
|
|
|
wxDataViewRenderer *renderer,
|
|
|
|
unsigned int model_column)
|
|
|
|
: m_bitmap(bitmap)
|
|
|
|
{
|
|
|
|
Init(renderer, model_column);
|
|
|
|
}
|
|
|
|
|
2006-09-05 20:47:48 +00:00
|
|
|
virtual ~wxDataViewColumnBase();
|
2006-02-22 00:19:04 +00:00
|
|
|
|
2007-02-23 07:57:46 +00:00
|
|
|
// setters:
|
2007-10-20 23:23:44 +00:00
|
|
|
virtual void SetOwner( wxDataViewCtrl *owner )
|
2007-02-23 07:57:46 +00:00
|
|
|
{ m_owner = owner; }
|
2006-03-27 14:01:33 +00:00
|
|
|
|
2007-02-23 07:57:46 +00:00
|
|
|
// getters:
|
2009-05-08 17:07:50 +00:00
|
|
|
unsigned int GetModelColumn() const { return static_cast<unsigned int>(m_model_column); }
|
2007-11-17 21:20:27 +00:00
|
|
|
wxDataViewCtrl *GetOwner() const { return m_owner; }
|
|
|
|
wxDataViewRenderer* GetRenderer() const { return m_renderer; }
|
2007-02-23 07:57:46 +00:00
|
|
|
|
2008-12-03 21:53:10 +00:00
|
|
|
// implement some of base class pure virtuals (the rest is port-dependent
|
|
|
|
// and done differently in generic and native versions)
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual void SetBitmap( const wxBitmap& bitmap ) wxOVERRIDE { m_bitmap = bitmap; }
|
|
|
|
virtual wxBitmap GetBitmap() const wxOVERRIDE { return m_bitmap; }
|
2008-12-03 21:53:10 +00:00
|
|
|
|
2007-02-23 07:57:46 +00:00
|
|
|
protected:
|
2006-10-03 15:24:03 +00:00
|
|
|
wxDataViewRenderer *m_renderer;
|
2006-02-23 02:04:46 +00:00
|
|
|
int m_model_column;
|
2006-10-05 19:06:21 +00:00
|
|
|
wxBitmap m_bitmap;
|
2006-02-23 02:04:46 +00:00
|
|
|
wxDataViewCtrl *m_owner;
|
2006-02-22 00:19:04 +00:00
|
|
|
|
2008-12-07 14:47:55 +00:00
|
|
|
private:
|
|
|
|
// common part of all ctors
|
|
|
|
void Init(wxDataViewRenderer *renderer, unsigned int model_column);
|
2006-02-22 00:19:04 +00:00
|
|
|
};
|
|
|
|
|
2006-03-27 14:01:33 +00:00
|
|
|
// ---------------------------------------------------------
|
2006-02-21 17:35:19 +00:00
|
|
|
// wxDataViewCtrlBase
|
2006-03-27 14:01:33 +00:00
|
|
|
// ---------------------------------------------------------
|
2006-02-21 17:35:19 +00:00
|
|
|
|
2006-04-19 08:31:35 +00:00
|
|
|
#define wxDV_SINGLE 0x0000 // for convenience
|
2007-02-23 07:57:46 +00:00
|
|
|
#define wxDV_MULTIPLE 0x0001 // can select multiple items
|
|
|
|
|
|
|
|
#define wxDV_NO_HEADER 0x0002 // column titles not visible
|
|
|
|
#define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows
|
|
|
|
#define wxDV_VERT_RULES 0x0008 // light vertical rules between columns
|
2006-04-19 08:31:35 +00:00
|
|
|
|
2007-12-03 09:44:29 +00:00
|
|
|
#define wxDV_ROW_LINES 0x0010 // alternating colour in rows
|
2008-05-16 12:37:32 +00:00
|
|
|
#define wxDV_VARIABLE_LINE_HEIGHT 0x0020 // variable line height
|
2007-12-03 09:44:29 +00:00
|
|
|
|
2015-09-17 12:46:27 +00:00
|
|
|
class WXDLLIMPEXP_ADV wxDataViewCtrlBase: public wxSystemThemedControl<wxControl>
|
2006-02-21 17:35:19 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDataViewCtrlBase();
|
2006-09-05 20:47:48 +00:00
|
|
|
virtual ~wxDataViewCtrlBase();
|
2006-03-27 14:01:33 +00:00
|
|
|
|
2009-03-06 22:56:27 +00:00
|
|
|
// model
|
|
|
|
// -----
|
|
|
|
|
2007-07-05 00:13:28 +00:00
|
|
|
virtual bool AssociateModel( wxDataViewModel *model );
|
|
|
|
wxDataViewModel* GetModel();
|
2007-12-01 19:01:47 +00:00
|
|
|
const wxDataViewModel* GetModel() const;
|
2006-03-27 14:01:33 +00:00
|
|
|
|
2009-03-06 22:56:27 +00:00
|
|
|
|
|
|
|
// column management
|
|
|
|
// -----------------
|
|
|
|
|
2007-10-20 23:23:44 +00:00
|
|
|
wxDataViewColumn *PrependTextColumn( const wxString &label, unsigned int model_column,
|
2007-10-18 20:56:38 +00:00
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
2008-12-03 21:53:10 +00:00
|
|
|
wxAlignment align = wxALIGN_NOT,
|
2007-10-18 20:56:38 +00:00
|
|
|
int flags = wxDATAVIEW_COL_RESIZABLE );
|
2007-10-20 23:23:44 +00:00
|
|
|
wxDataViewColumn *PrependIconTextColumn( const wxString &label, unsigned int model_column,
|
2007-10-18 20:56:38 +00:00
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
2008-12-03 21:53:10 +00:00
|
|
|
wxAlignment align = wxALIGN_NOT,
|
2007-10-18 20:56:38 +00:00
|
|
|
int flags = wxDATAVIEW_COL_RESIZABLE );
|
|
|
|
wxDataViewColumn *PrependToggleColumn( const wxString &label, unsigned int model_column,
|
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
|
|
|
|
wxAlignment align = wxALIGN_CENTER,
|
|
|
|
int flags = wxDATAVIEW_COL_RESIZABLE );
|
2007-10-20 23:23:44 +00:00
|
|
|
wxDataViewColumn *PrependProgressColumn( const wxString &label, unsigned int model_column,
|
2007-10-18 20:56:38 +00:00
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
|
|
|
|
wxAlignment align = wxALIGN_CENTER,
|
|
|
|
int flags = wxDATAVIEW_COL_RESIZABLE );
|
|
|
|
wxDataViewColumn *PrependDateColumn( const wxString &label, unsigned int model_column,
|
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
|
2008-12-03 21:53:10 +00:00
|
|
|
wxAlignment align = wxALIGN_NOT,
|
2007-10-18 20:56:38 +00:00
|
|
|
int flags = wxDATAVIEW_COL_RESIZABLE );
|
|
|
|
wxDataViewColumn *PrependBitmapColumn( const wxString &label, unsigned int model_column,
|
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
|
|
|
wxAlignment align = wxALIGN_CENTER,
|
|
|
|
int flags = wxDATAVIEW_COL_RESIZABLE );
|
|
|
|
wxDataViewColumn *PrependTextColumn( const wxBitmap &label, unsigned int model_column,
|
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
2008-12-03 21:53:10 +00:00
|
|
|
wxAlignment align = wxALIGN_NOT,
|
2007-10-18 20:56:38 +00:00
|
|
|
int flags = wxDATAVIEW_COL_RESIZABLE );
|
|
|
|
wxDataViewColumn *PrependIconTextColumn( const wxBitmap &label, unsigned int model_column,
|
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
2008-12-03 21:53:10 +00:00
|
|
|
wxAlignment align = wxALIGN_NOT,
|
2007-10-18 20:56:38 +00:00
|
|
|
int flags = wxDATAVIEW_COL_RESIZABLE );
|
|
|
|
wxDataViewColumn *PrependToggleColumn( const wxBitmap &label, unsigned int model_column,
|
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
|
|
|
|
wxAlignment align = wxALIGN_CENTER,
|
|
|
|
int flags = wxDATAVIEW_COL_RESIZABLE );
|
|
|
|
wxDataViewColumn *PrependProgressColumn( const wxBitmap &label, unsigned int model_column,
|
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
|
|
|
|
wxAlignment align = wxALIGN_CENTER,
|
|
|
|
int flags = wxDATAVIEW_COL_RESIZABLE );
|
|
|
|
wxDataViewColumn *PrependDateColumn( const wxBitmap &label, unsigned int model_column,
|
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
|
2008-12-03 21:53:10 +00:00
|
|
|
wxAlignment align = wxALIGN_NOT,
|
2007-10-18 20:56:38 +00:00
|
|
|
int flags = wxDATAVIEW_COL_RESIZABLE );
|
|
|
|
wxDataViewColumn *PrependBitmapColumn( const wxBitmap &label, unsigned int model_column,
|
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
|
|
|
wxAlignment align = wxALIGN_CENTER,
|
|
|
|
int flags = wxDATAVIEW_COL_RESIZABLE );
|
2007-10-20 23:23:44 +00:00
|
|
|
|
|
|
|
wxDataViewColumn *AppendTextColumn( const wxString &label, unsigned int model_column,
|
2007-02-17 12:32:38 +00:00
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
2008-12-03 21:53:10 +00:00
|
|
|
wxAlignment align = wxALIGN_NOT,
|
2007-02-17 12:32:38 +00:00
|
|
|
int flags = wxDATAVIEW_COL_RESIZABLE );
|
2007-10-20 23:23:44 +00:00
|
|
|
wxDataViewColumn *AppendIconTextColumn( const wxString &label, unsigned int model_column,
|
2007-08-31 09:14:49 +00:00
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
2008-12-03 21:53:10 +00:00
|
|
|
wxAlignment align = wxALIGN_NOT,
|
2007-08-31 09:14:49 +00:00
|
|
|
int flags = wxDATAVIEW_COL_RESIZABLE );
|
2007-08-22 13:39:32 +00:00
|
|
|
wxDataViewColumn *AppendToggleColumn( const wxString &label, unsigned int model_column,
|
2007-02-17 12:32:38 +00:00
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
|
|
|
|
wxAlignment align = wxALIGN_CENTER,
|
|
|
|
int flags = wxDATAVIEW_COL_RESIZABLE );
|
2007-10-20 23:23:44 +00:00
|
|
|
wxDataViewColumn *AppendProgressColumn( const wxString &label, unsigned int model_column,
|
2007-02-17 12:32:38 +00:00
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
|
|
|
|
wxAlignment align = wxALIGN_CENTER,
|
|
|
|
int flags = wxDATAVIEW_COL_RESIZABLE );
|
2007-08-22 13:39:32 +00:00
|
|
|
wxDataViewColumn *AppendDateColumn( const wxString &label, unsigned int model_column,
|
2007-02-17 12:32:38 +00:00
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
|
2008-12-03 21:53:10 +00:00
|
|
|
wxAlignment align = wxALIGN_NOT,
|
2007-02-17 12:32:38 +00:00
|
|
|
int flags = wxDATAVIEW_COL_RESIZABLE );
|
2007-08-22 13:39:32 +00:00
|
|
|
wxDataViewColumn *AppendBitmapColumn( const wxString &label, unsigned int model_column,
|
2007-02-17 12:32:38 +00:00
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
|
|
|
wxAlignment align = wxALIGN_CENTER,
|
|
|
|
int flags = wxDATAVIEW_COL_RESIZABLE );
|
2007-08-22 13:39:32 +00:00
|
|
|
wxDataViewColumn *AppendTextColumn( const wxBitmap &label, unsigned int model_column,
|
2007-02-17 12:32:38 +00:00
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
2008-12-03 21:53:10 +00:00
|
|
|
wxAlignment align = wxALIGN_NOT,
|
2007-02-17 12:32:38 +00:00
|
|
|
int flags = wxDATAVIEW_COL_RESIZABLE );
|
2007-08-31 09:14:49 +00:00
|
|
|
wxDataViewColumn *AppendIconTextColumn( const wxBitmap &label, unsigned int model_column,
|
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
2008-12-03 21:53:10 +00:00
|
|
|
wxAlignment align = wxALIGN_NOT,
|
2007-08-31 09:14:49 +00:00
|
|
|
int flags = wxDATAVIEW_COL_RESIZABLE );
|
2007-08-22 13:39:32 +00:00
|
|
|
wxDataViewColumn *AppendToggleColumn( const wxBitmap &label, unsigned int model_column,
|
2007-02-17 12:32:38 +00:00
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
|
|
|
|
wxAlignment align = wxALIGN_CENTER,
|
|
|
|
int flags = wxDATAVIEW_COL_RESIZABLE );
|
2007-08-22 13:39:32 +00:00
|
|
|
wxDataViewColumn *AppendProgressColumn( const wxBitmap &label, unsigned int model_column,
|
2007-02-17 12:32:38 +00:00
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
|
|
|
|
wxAlignment align = wxALIGN_CENTER,
|
|
|
|
int flags = wxDATAVIEW_COL_RESIZABLE );
|
2007-08-22 13:39:32 +00:00
|
|
|
wxDataViewColumn *AppendDateColumn( const wxBitmap &label, unsigned int model_column,
|
2007-02-17 12:32:38 +00:00
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
|
2008-12-03 21:53:10 +00:00
|
|
|
wxAlignment align = wxALIGN_NOT,
|
2007-02-17 12:32:38 +00:00
|
|
|
int flags = wxDATAVIEW_COL_RESIZABLE );
|
2007-08-22 13:39:32 +00:00
|
|
|
wxDataViewColumn *AppendBitmapColumn( const wxBitmap &label, unsigned int model_column,
|
2007-02-17 12:32:38 +00:00
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
|
|
|
wxAlignment align = wxALIGN_CENTER,
|
|
|
|
int flags = wxDATAVIEW_COL_RESIZABLE );
|
2007-10-18 20:56:38 +00:00
|
|
|
|
|
|
|
virtual bool PrependColumn( wxDataViewColumn *col );
|
2008-05-21 08:47:21 +00:00
|
|
|
virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col );
|
2006-03-27 14:01:33 +00:00
|
|
|
virtual bool AppendColumn( wxDataViewColumn *col );
|
2007-02-23 07:57:46 +00:00
|
|
|
|
2007-08-26 10:05:16 +00:00
|
|
|
virtual unsigned int GetColumnCount() const = 0;
|
|
|
|
virtual wxDataViewColumn* GetColumn( unsigned int pos ) const = 0;
|
2007-09-13 13:29:19 +00:00
|
|
|
virtual int GetColumnPosition( const wxDataViewColumn *column ) const = 0;
|
2007-10-20 23:23:44 +00:00
|
|
|
|
2007-08-26 10:05:16 +00:00
|
|
|
virtual bool DeleteColumn( wxDataViewColumn *column ) = 0;
|
|
|
|
virtual bool ClearColumns() = 0;
|
2007-10-20 23:23:44 +00:00
|
|
|
|
2007-08-25 13:28:56 +00:00
|
|
|
void SetExpanderColumn( wxDataViewColumn *col )
|
2007-07-12 12:58:28 +00:00
|
|
|
{ m_expander_column = col ; DoSetExpanderColumn(); }
|
2007-10-20 23:23:44 +00:00
|
|
|
wxDataViewColumn *GetExpanderColumn() const
|
2007-07-12 12:58:28 +00:00
|
|
|
{ return m_expander_column; }
|
2007-10-20 23:23:44 +00:00
|
|
|
|
2007-09-13 12:57:40 +00:00
|
|
|
virtual wxDataViewColumn *GetSortingColumn() const = 0;
|
2014-02-05 22:12:53 +00:00
|
|
|
virtual wxVector<wxDataViewColumn *> GetSortingColumns() const
|
|
|
|
{
|
|
|
|
wxVector<wxDataViewColumn *> columns;
|
|
|
|
if ( wxDataViewColumn* col = GetSortingColumn() )
|
|
|
|
columns.push_back(col);
|
|
|
|
return columns;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This must be overridden to return true if the control does allow sorting
|
|
|
|
// by more than one column, which is not the case by default.
|
|
|
|
virtual bool AllowMultiColumnSort(bool allow)
|
|
|
|
{
|
|
|
|
// We can still return true when disabling multi-column sort.
|
|
|
|
return !allow;
|
|
|
|
}
|
|
|
|
|
2016-03-05 17:42:02 +00:00
|
|
|
// Return true if multi column sort is currently allowed.
|
|
|
|
virtual bool IsMultiColumnSortAllowed() const { return false; }
|
|
|
|
|
2014-02-05 22:12:53 +00:00
|
|
|
// This should also be overridden to actually use the specified column for
|
|
|
|
// sorting if using multiple columns is supported.
|
|
|
|
virtual void ToggleSortByColumn(int WXUNUSED(column)) { }
|
2008-11-02 22:16:14 +00:00
|
|
|
|
2009-03-06 22:56:27 +00:00
|
|
|
|
|
|
|
// items management
|
|
|
|
// ----------------
|
|
|
|
|
2007-07-12 12:58:28 +00:00
|
|
|
void SetIndent( int indent )
|
|
|
|
{ m_indent = indent ; DoSetIndent(); }
|
2007-10-20 23:23:44 +00:00
|
|
|
int GetIndent() const
|
|
|
|
{ return m_indent; }
|
2007-07-12 12:58:28 +00:00
|
|
|
|
2010-08-10 12:53:03 +00:00
|
|
|
// Current item is the one used by the keyboard navigation, it is the same
|
|
|
|
// as the (unique) selected item in single selection mode so these
|
|
|
|
// functions are mostly useful for controls with wxDV_MULTIPLE style.
|
|
|
|
wxDataViewItem GetCurrentItem() const;
|
|
|
|
void SetCurrentItem(const wxDataViewItem& item);
|
|
|
|
|
2012-01-17 14:05:07 +00:00
|
|
|
// Currently focused column of the current item or NULL if no column has focus
|
|
|
|
virtual wxDataViewColumn *GetCurrentColumn() const = 0;
|
|
|
|
|
2011-08-22 12:41:19 +00:00
|
|
|
// Selection: both GetSelection() and GetSelections() can be used for the
|
|
|
|
// controls both with and without wxDV_MULTIPLE style. For single selection
|
|
|
|
// controls GetSelections() is not very useful however. And for multi
|
|
|
|
// selection controls GetSelection() returns an invalid item if more than
|
|
|
|
// one item is selected. Use GetSelectedItemsCount() or HasSelection() to
|
|
|
|
// check if any items are selected at all.
|
|
|
|
virtual int GetSelectedItemsCount() const = 0;
|
|
|
|
bool HasSelection() const { return GetSelectedItemsCount() != 0; }
|
|
|
|
wxDataViewItem GetSelection() const;
|
2007-08-19 19:03:01 +00:00
|
|
|
virtual int GetSelections( wxDataViewItemArray & sel ) const = 0;
|
|
|
|
virtual void SetSelections( const wxDataViewItemArray & sel ) = 0;
|
|
|
|
virtual void Select( const wxDataViewItem & item ) = 0;
|
|
|
|
virtual void Unselect( const wxDataViewItem & item ) = 0;
|
|
|
|
virtual bool IsSelected( const wxDataViewItem & item ) const = 0;
|
|
|
|
|
|
|
|
virtual void SelectAll() = 0;
|
|
|
|
virtual void UnselectAll() = 0;
|
|
|
|
|
2016-03-22 20:22:36 +00:00
|
|
|
void Expand( const wxDataViewItem & item );
|
2016-03-22 20:14:10 +00:00
|
|
|
void ExpandAncestors( const wxDataViewItem & item );
|
2007-08-25 21:05:51 +00:00
|
|
|
virtual void Collapse( const wxDataViewItem & item ) = 0;
|
2008-12-16 21:23:55 +00:00
|
|
|
virtual bool IsExpanded( const wxDataViewItem & item ) const = 0;
|
2007-08-25 21:05:51 +00:00
|
|
|
|
2007-08-19 21:44:34 +00:00
|
|
|
virtual void EnsureVisible( const wxDataViewItem & item,
|
2008-12-23 14:56:07 +00:00
|
|
|
const wxDataViewColumn *column = NULL ) = 0;
|
2007-08-24 20:00:32 +00:00
|
|
|
virtual void HitTest( const wxPoint & point, wxDataViewItem &item, wxDataViewColumn* &column ) const = 0;
|
2007-08-24 11:21:52 +00:00
|
|
|
virtual wxRect GetItemRect( const wxDataViewItem & item, const wxDataViewColumn *column = NULL ) const = 0;
|
2011-06-07 22:49:56 +00:00
|
|
|
|
|
|
|
virtual bool SetRowHeight( int WXUNUSED(rowHeight) ) { return false; }
|
|
|
|
|
2012-01-17 14:05:17 +00:00
|
|
|
virtual void EditItem(const wxDataViewItem& item, const wxDataViewColumn *column) = 0;
|
|
|
|
|
|
|
|
// Use EditItem() instead
|
|
|
|
wxDEPRECATED( void StartEditor(const wxDataViewItem& item, unsigned int column) );
|
2009-01-20 17:50:51 +00:00
|
|
|
|
2009-01-28 21:36:57 +00:00
|
|
|
#if wxUSE_DRAG_AND_DROP
|
|
|
|
virtual bool EnableDragSource(const wxDataFormat& WXUNUSED(format))
|
|
|
|
{ return false; }
|
|
|
|
virtual bool EnableDropTarget(const wxDataFormat& WXUNUSED(format))
|
|
|
|
{ return false; }
|
|
|
|
#endif // wxUSE_DRAG_AND_DROP
|
2007-08-19 19:03:01 +00:00
|
|
|
|
2009-09-26 16:43:12 +00:00
|
|
|
// define control visual attributes
|
|
|
|
// --------------------------------
|
|
|
|
|
2016-04-21 22:58:38 +00:00
|
|
|
// Header attributes: only implemented in the generic version currently.
|
|
|
|
virtual bool SetHeaderAttr(const wxItemAttr& WXUNUSED(attr))
|
|
|
|
{ return false; }
|
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual wxVisualAttributes GetDefaultAttributes() const wxOVERRIDE
|
2009-09-26 16:43:12 +00:00
|
|
|
{
|
|
|
|
return GetClassDefaultAttributes(GetWindowVariant());
|
|
|
|
}
|
|
|
|
|
|
|
|
static wxVisualAttributes
|
|
|
|
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL)
|
|
|
|
{
|
|
|
|
return wxControl::GetCompositeControlsDefaultAttributes(variant);
|
|
|
|
}
|
|
|
|
|
2007-07-12 12:58:28 +00:00
|
|
|
protected:
|
|
|
|
virtual void DoSetExpanderColumn() = 0 ;
|
|
|
|
virtual void DoSetIndent() = 0;
|
|
|
|
|
2016-03-22 20:22:36 +00:00
|
|
|
// Just expand this item assuming it is already shown, i.e. its parent has
|
|
|
|
// been already expanded using ExpandAncestors().
|
|
|
|
virtual void DoExpand(const wxDataViewItem & item) = 0;
|
|
|
|
|
2006-02-21 17:35:19 +00:00
|
|
|
private:
|
2010-08-10 12:53:03 +00:00
|
|
|
// Implementation of the public Set/GetCurrentItem() methods which are only
|
|
|
|
// called in multi selection case (for single selection controls their
|
|
|
|
// implementation is trivial and is done in the base class itself).
|
|
|
|
virtual wxDataViewItem DoGetCurrentItem() const = 0;
|
|
|
|
virtual void DoSetCurrentItem(const wxDataViewItem& item) = 0;
|
|
|
|
|
2007-07-05 00:13:28 +00:00
|
|
|
wxDataViewModel *m_model;
|
2007-08-25 13:28:56 +00:00
|
|
|
wxDataViewColumn *m_expander_column;
|
2007-07-12 12:58:28 +00:00
|
|
|
int m_indent ;
|
2007-10-20 23:23:44 +00:00
|
|
|
|
2006-02-21 17:35:19 +00:00
|
|
|
protected:
|
2015-04-23 11:49:01 +00:00
|
|
|
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase);
|
2006-02-21 17:35:19 +00:00
|
|
|
};
|
2006-01-08 21:50:02 +00:00
|
|
|
|
2006-10-03 13:23:31 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxDataViewEvent - the event class for the wxDataViewCtrl notifications
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2006-10-03 21:51:05 +00:00
|
|
|
class WXDLLIMPEXP_ADV wxDataViewEvent : public wxNotifyEvent
|
2006-10-03 13:23:31 +00:00
|
|
|
{
|
|
|
|
public:
|
2016-03-18 22:33:27 +00:00
|
|
|
// Default ctor, normally shouldn't be used and mostly exists only for
|
|
|
|
// backwards compatibility.
|
|
|
|
wxDataViewEvent()
|
|
|
|
: wxNotifyEvent()
|
|
|
|
{
|
|
|
|
Init(NULL, NULL, wxDataViewItem());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Constructor for the events affecting columns (and possibly also items).
|
|
|
|
wxDataViewEvent(wxEventType evtType,
|
|
|
|
wxDataViewCtrlBase* dvc,
|
|
|
|
wxDataViewColumn* column,
|
|
|
|
const wxDataViewItem& item = wxDataViewItem())
|
|
|
|
: wxNotifyEvent(evtType, dvc->GetId())
|
|
|
|
{
|
|
|
|
Init(dvc, column, item);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Constructor for the events affecting only the items.
|
|
|
|
wxDataViewEvent(wxEventType evtType,
|
|
|
|
wxDataViewCtrlBase* dvc,
|
|
|
|
const wxDataViewItem& item)
|
|
|
|
: wxNotifyEvent(evtType, dvc->GetId())
|
|
|
|
{
|
|
|
|
Init(dvc, NULL, item);
|
|
|
|
}
|
2006-10-03 13:23:31 +00:00
|
|
|
|
|
|
|
wxDataViewEvent(const wxDataViewEvent& event)
|
|
|
|
: wxNotifyEvent(event),
|
2007-07-05 00:13:28 +00:00
|
|
|
m_item(event.m_item),
|
2006-10-03 13:23:31 +00:00
|
|
|
m_col(event.m_col),
|
|
|
|
m_model(event.m_model),
|
|
|
|
m_value(event.m_value),
|
2007-12-16 14:48:13 +00:00
|
|
|
m_column(event.m_column),
|
2011-01-27 11:53:51 +00:00
|
|
|
m_pos(event.m_pos),
|
2009-07-05 15:21:52 +00:00
|
|
|
m_cacheFrom(event.m_cacheFrom),
|
2011-07-19 22:35:53 +00:00
|
|
|
m_cacheTo(event.m_cacheTo),
|
|
|
|
m_editCancelled(event.m_editCancelled)
|
2009-02-10 00:15:37 +00:00
|
|
|
#if wxUSE_DRAG_AND_DROP
|
|
|
|
, m_dataObject(event.m_dataObject),
|
2009-01-20 13:46:21 +00:00
|
|
|
m_dataFormat(event.m_dataFormat),
|
|
|
|
m_dataBuffer(event.m_dataBuffer),
|
2012-04-29 23:22:25 +00:00
|
|
|
m_dataSize(event.m_dataSize),
|
|
|
|
m_dragFlags(event.m_dragFlags),
|
|
|
|
m_dropEffect(event.m_dropEffect)
|
2009-02-10 00:15:37 +00:00
|
|
|
#endif
|
2006-10-03 13:23:31 +00:00
|
|
|
{ }
|
|
|
|
|
2007-07-05 00:13:28 +00:00
|
|
|
wxDataViewItem GetItem() const { return m_item; }
|
2006-10-03 13:23:31 +00:00
|
|
|
int GetColumn() const { return m_col; }
|
|
|
|
wxDataViewModel* GetModel() const { return m_model; }
|
2007-02-23 07:57:46 +00:00
|
|
|
|
2006-10-03 13:23:31 +00:00
|
|
|
const wxVariant &GetValue() const { return m_value; }
|
|
|
|
void SetValue( const wxVariant &value ) { m_value = value; }
|
|
|
|
|
2013-04-25 10:11:03 +00:00
|
|
|
// for wxEVT_DATAVIEW_ITEM_EDITING_DONE only
|
2011-07-19 22:35:53 +00:00
|
|
|
bool IsEditCancelled() const { return m_editCancelled; }
|
|
|
|
void SetEditCanceled(bool editCancelled) { m_editCancelled = editCancelled; }
|
|
|
|
|
2006-10-06 09:50:45 +00:00
|
|
|
// for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only
|
2007-02-23 07:57:46 +00:00
|
|
|
wxDataViewColumn *GetDataViewColumn() const { return m_column; }
|
2008-01-27 13:21:39 +00:00
|
|
|
|
2007-12-16 14:48:13 +00:00
|
|
|
// for wxEVT_DATAVIEW_CONTEXT_MENU only
|
2008-03-17 21:00:06 +00:00
|
|
|
wxPoint GetPosition() const { return m_pos; }
|
2007-12-16 14:48:13 +00:00
|
|
|
void SetPosition( int x, int y ) { m_pos.x = x; m_pos.y = y; }
|
2006-10-06 09:50:45 +00:00
|
|
|
|
2013-04-25 10:11:03 +00:00
|
|
|
// For wxEVT_DATAVIEW_CACHE_HINT
|
2009-07-05 15:21:52 +00:00
|
|
|
int GetCacheFrom() const { return m_cacheFrom; }
|
|
|
|
int GetCacheTo() const { return m_cacheTo; }
|
|
|
|
void SetCache(int from, int to) { m_cacheFrom = from; m_cacheTo = to; }
|
|
|
|
|
|
|
|
|
2009-02-01 12:51:33 +00:00
|
|
|
#if wxUSE_DRAG_AND_DROP
|
2009-01-20 13:46:21 +00:00
|
|
|
// For drag operations
|
2009-01-20 11:58:52 +00:00
|
|
|
void SetDataObject( wxDataObject *obj ) { m_dataObject = obj; }
|
2009-01-20 13:46:21 +00:00
|
|
|
wxDataObject *GetDataObject() const { return m_dataObject; }
|
2009-01-20 17:50:51 +00:00
|
|
|
|
2009-01-20 13:46:21 +00:00
|
|
|
// For drop operations
|
|
|
|
void SetDataFormat( const wxDataFormat &format ) { m_dataFormat = format; }
|
|
|
|
wxDataFormat GetDataFormat() const { return m_dataFormat; }
|
|
|
|
void SetDataSize( size_t size ) { m_dataSize = size; }
|
|
|
|
size_t GetDataSize() const { return m_dataSize; }
|
|
|
|
void SetDataBuffer( void* buf ) { m_dataBuffer = buf;}
|
|
|
|
void *GetDataBuffer() const { return m_dataBuffer; }
|
2012-04-29 23:22:25 +00:00
|
|
|
void SetDragFlags( int flags ) { m_dragFlags = flags; }
|
|
|
|
int GetDragFlags() const { return m_dragFlags; }
|
|
|
|
void SetDropEffect( wxDragResult effect ) { m_dropEffect = effect; }
|
|
|
|
wxDragResult GetDropEffect() const { return m_dropEffect; }
|
2009-02-03 12:01:46 +00:00
|
|
|
#endif // wxUSE_DRAG_AND_DROP
|
2009-01-19 22:27:06 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual wxEvent *Clone() const wxOVERRIDE { return new wxDataViewEvent(*this); }
|
2006-10-03 13:23:31 +00:00
|
|
|
|
2016-03-18 22:33:27 +00:00
|
|
|
// These methods shouldn't be used outside of wxWidgets and wxWidgets
|
|
|
|
// itself doesn't use them any longer neither as it constructs the events
|
|
|
|
// with the appropriate ctors directly.
|
|
|
|
#if WXWIN_COMPATIBILITY_3_0
|
|
|
|
wxDEPRECATED_MSG("Pass the argument to the ctor instead")
|
|
|
|
void SetModel( wxDataViewModel *model ) { m_model = model; }
|
|
|
|
wxDEPRECATED_MSG("Pass the argument to the ctor instead")
|
|
|
|
void SetDataViewColumn( wxDataViewColumn *col ) { m_column = col; }
|
|
|
|
wxDEPRECATED_MSG("Pass the argument to the ctor instead")
|
|
|
|
void SetColumn( int col ) { m_col = col; }
|
|
|
|
wxDEPRECATED_MSG("Pass the argument to the ctor instead")
|
|
|
|
void SetItem( const wxDataViewItem &item ) { m_item = item; }
|
|
|
|
#endif // WXWIN_COMPATIBILITY_3_0
|
|
|
|
|
2006-10-03 13:23:31 +00:00
|
|
|
protected:
|
2007-07-05 00:13:28 +00:00
|
|
|
wxDataViewItem m_item;
|
2006-10-03 13:23:31 +00:00
|
|
|
int m_col;
|
|
|
|
wxDataViewModel *m_model;
|
|
|
|
wxVariant m_value;
|
2006-10-06 09:50:45 +00:00
|
|
|
wxDataViewColumn *m_column;
|
2007-12-16 14:48:13 +00:00
|
|
|
wxPoint m_pos;
|
2009-07-05 15:21:52 +00:00
|
|
|
int m_cacheFrom;
|
|
|
|
int m_cacheTo;
|
2011-07-19 22:35:53 +00:00
|
|
|
bool m_editCancelled;
|
2009-01-20 17:50:51 +00:00
|
|
|
|
2009-02-07 21:46:31 +00:00
|
|
|
#if wxUSE_DRAG_AND_DROP
|
2009-01-20 11:58:52 +00:00
|
|
|
wxDataObject *m_dataObject;
|
2009-01-20 17:50:51 +00:00
|
|
|
|
2009-01-20 13:46:21 +00:00
|
|
|
wxDataFormat m_dataFormat;
|
|
|
|
void* m_dataBuffer;
|
|
|
|
size_t m_dataSize;
|
2012-04-29 23:22:25 +00:00
|
|
|
|
|
|
|
int m_dragFlags;
|
|
|
|
wxDragResult m_dropEffect;
|
2009-02-07 21:46:31 +00:00
|
|
|
#endif // wxUSE_DRAG_AND_DROP
|
2006-10-03 13:23:31 +00:00
|
|
|
|
|
|
|
private:
|
2016-03-18 22:33:27 +00:00
|
|
|
// Common part of non-copy ctors.
|
|
|
|
void Init(wxDataViewCtrlBase* dvc,
|
|
|
|
wxDataViewColumn* column,
|
|
|
|
const wxDataViewItem& item);
|
|
|
|
|
2015-04-23 11:49:01 +00:00
|
|
|
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent);
|
2006-10-03 13:23:31 +00:00
|
|
|
};
|
|
|
|
|
2013-04-25 10:11:03 +00:00
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_SELECTION_CHANGED, wxDataViewEvent );
|
2009-02-07 18:59:25 +00:00
|
|
|
|
2013-04-25 10:11:03 +00:00
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_ACTIVATED, wxDataViewEvent );
|
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_COLLAPSED, wxDataViewEvent );
|
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_EXPANDED, wxDataViewEvent );
|
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_COLLAPSING, wxDataViewEvent );
|
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_EXPANDING, wxDataViewEvent );
|
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_START_EDITING, wxDataViewEvent );
|
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_EDITING_STARTED, wxDataViewEvent );
|
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_EDITING_DONE, wxDataViewEvent );
|
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_VALUE_CHANGED, wxDataViewEvent );
|
2009-02-07 18:59:25 +00:00
|
|
|
|
2013-04-25 10:11:03 +00:00
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_CONTEXT_MENU, wxDataViewEvent );
|
2009-02-07 18:59:25 +00:00
|
|
|
|
2013-04-25 10:11:03 +00:00
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_COLUMN_HEADER_CLICK, wxDataViewEvent );
|
2013-04-25 11:56:55 +00:00
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, wxDataViewEvent );
|
2013-04-25 10:11:03 +00:00
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_COLUMN_SORTED, wxDataViewEvent );
|
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_COLUMN_REORDERED, wxDataViewEvent );
|
2009-02-07 18:59:25 +00:00
|
|
|
|
2013-04-25 10:11:03 +00:00
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_CACHE_HINT, wxDataViewEvent );
|
2009-07-05 15:21:52 +00:00
|
|
|
|
2013-04-25 10:11:03 +00:00
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, wxDataViewEvent );
|
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE, wxDataViewEvent );
|
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_DATAVIEW_ITEM_DROP, wxDataViewEvent );
|
2009-01-19 22:27:06 +00:00
|
|
|
|
2006-10-03 13:23:31 +00:00
|
|
|
typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&);
|
|
|
|
|
|
|
|
#define wxDataViewEventHandler(func) \
|
2009-01-12 14:26:13 +00:00
|
|
|
wxEVENT_HANDLER_CAST(wxDataViewEventFunction, func)
|
2006-10-03 13:23:31 +00:00
|
|
|
|
|
|
|
#define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \
|
2013-04-25 10:11:03 +00:00
|
|
|
wx__DECLARE_EVT1(wxEVT_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn))
|
2006-10-03 13:23:31 +00:00
|
|
|
|
2007-09-14 08:59:07 +00:00
|
|
|
#define EVT_DATAVIEW_SELECTION_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(SELECTION_CHANGED, id, fn)
|
|
|
|
|
2007-07-05 00:13:28 +00:00
|
|
|
#define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn)
|
2007-08-19 20:42:17 +00:00
|
|
|
#define EVT_DATAVIEW_ITEM_COLLAPSING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSING, id, fn)
|
2007-08-19 14:16:29 +00:00
|
|
|
#define EVT_DATAVIEW_ITEM_COLLAPSED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSED, id, fn)
|
2007-08-19 20:42:17 +00:00
|
|
|
#define EVT_DATAVIEW_ITEM_EXPANDING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDING, id, fn)
|
2007-08-19 14:16:29 +00:00
|
|
|
#define EVT_DATAVIEW_ITEM_EXPANDED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDED, id, fn)
|
2009-03-09 20:48:04 +00:00
|
|
|
#define EVT_DATAVIEW_ITEM_START_EDITING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_START_EDITING, id, fn)
|
2007-08-25 19:44:04 +00:00
|
|
|
#define EVT_DATAVIEW_ITEM_EDITING_STARTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_STARTED, id, fn)
|
|
|
|
#define EVT_DATAVIEW_ITEM_EDITING_DONE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_DONE, id, fn)
|
2007-10-02 10:41:46 +00:00
|
|
|
#define EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_VALUE_CHANGED, id, fn)
|
2007-08-25 19:44:04 +00:00
|
|
|
|
2007-12-16 14:48:13 +00:00
|
|
|
#define EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_CONTEXT_MENU, id, fn)
|
|
|
|
|
2006-10-06 09:50:45 +00:00
|
|
|
#define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn)
|
2013-04-17 11:45:07 +00:00
|
|
|
#define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn)
|
2007-06-06 23:40:24 +00:00
|
|
|
#define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn)
|
2007-12-22 18:29:14 +00:00
|
|
|
#define EVT_DATAVIEW_COLUMN_REORDERED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_REORDERED, id, fn)
|
2009-07-05 15:21:52 +00:00
|
|
|
#define EVT_DATAVIEW_CACHE_HINT(id, fn) wx__DECLARE_DATAVIEWEVT(CACHE_HINT, id, fn)
|
2006-10-03 13:23:31 +00:00
|
|
|
|
2009-01-20 11:58:52 +00:00
|
|
|
#define EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_BEGIN_DRAG, id, fn)
|
2009-01-20 13:46:21 +00:00
|
|
|
#define EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP_POSSIBLE, id, fn)
|
|
|
|
#define EVT_DATAVIEW_ITEM_DROP(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP, id, fn)
|
2008-08-21 22:12:43 +00:00
|
|
|
|
2013-04-17 11:45:07 +00:00
|
|
|
// Old and not documented synonym, don't use.
|
|
|
|
#define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(id, fn)
|
|
|
|
|
2008-12-03 21:53:10 +00:00
|
|
|
#ifdef wxHAS_GENERIC_DATAVIEWCTRL
|
|
|
|
#include "wx/generic/dataview.h"
|
|
|
|
#elif defined(__WXGTK20__)
|
2006-01-08 21:50:02 +00:00
|
|
|
#include "wx/gtk/dataview.h"
|
2008-12-03 21:53:10 +00:00
|
|
|
#elif defined(__WXMAC__)
|
2008-06-11 19:17:41 +00:00
|
|
|
#include "wx/osx/dataview.h"
|
2014-08-24 01:50:11 +00:00
|
|
|
#elif defined(__WXQT__)
|
|
|
|
#include "wx/qt/dataview.h"
|
2006-01-08 21:50:02 +00:00
|
|
|
#else
|
2008-12-03 21:53:10 +00:00
|
|
|
#error "unknown native wxDataViewCtrl implementation"
|
2006-01-08 21:50:02 +00:00
|
|
|
#endif
|
|
|
|
|
2009-01-16 11:23:37 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// wxDataViewListStore
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewListStoreLine
|
|
|
|
{
|
|
|
|
public:
|
2012-11-08 17:47:16 +00:00
|
|
|
wxDataViewListStoreLine( wxUIntPtr data = 0 )
|
2009-01-16 11:23:37 +00:00
|
|
|
{
|
|
|
|
m_data = data;
|
|
|
|
}
|
|
|
|
|
2012-05-25 17:02:31 +00:00
|
|
|
void SetData( wxUIntPtr data )
|
|
|
|
{ m_data = data; }
|
|
|
|
wxUIntPtr GetData() const
|
2009-01-16 11:23:37 +00:00
|
|
|
{ return m_data; }
|
2009-01-20 17:50:51 +00:00
|
|
|
|
2009-01-16 11:23:37 +00:00
|
|
|
wxVector<wxVariant> m_values;
|
2009-01-20 17:50:51 +00:00
|
|
|
|
2009-01-16 11:23:37 +00:00
|
|
|
private:
|
2012-05-25 17:02:31 +00:00
|
|
|
wxUIntPtr m_data;
|
2009-01-16 11:23:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewListStore: public wxDataViewIndexListModel
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDataViewListStore();
|
|
|
|
~wxDataViewListStore();
|
|
|
|
|
|
|
|
void PrependColumn( const wxString &varianttype );
|
|
|
|
void InsertColumn( unsigned int pos, const wxString &varianttype );
|
|
|
|
void AppendColumn( const wxString &varianttype );
|
2009-01-20 17:50:51 +00:00
|
|
|
|
2012-11-08 17:47:16 +00:00
|
|
|
void AppendItem( const wxVector<wxVariant> &values, wxUIntPtr data = 0 );
|
|
|
|
void PrependItem( const wxVector<wxVariant> &values, wxUIntPtr data = 0 );
|
|
|
|
void InsertItem( unsigned int row, const wxVector<wxVariant> &values, wxUIntPtr data = 0 );
|
2009-03-06 00:01:11 +00:00
|
|
|
void DeleteItem( unsigned int pos );
|
2009-01-16 11:23:37 +00:00
|
|
|
void DeleteAllItems();
|
2013-11-21 13:13:11 +00:00
|
|
|
void ClearColumns();
|
2009-01-16 11:23:37 +00:00
|
|
|
|
2012-05-25 17:02:40 +00:00
|
|
|
unsigned int GetItemCount() const;
|
|
|
|
|
2012-05-25 17:02:35 +00:00
|
|
|
void SetItemData( const wxDataViewItem& item, wxUIntPtr data );
|
|
|
|
wxUIntPtr GetItemData( const wxDataViewItem& item ) const;
|
|
|
|
|
2009-01-16 11:23:37 +00:00
|
|
|
// override base virtuals
|
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual unsigned int GetColumnCount() const wxOVERRIDE;
|
2009-01-16 11:23:37 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual wxString GetColumnType( unsigned int col ) const wxOVERRIDE;
|
2009-01-16 11:23:37 +00:00
|
|
|
|
|
|
|
virtual void GetValueByRow( wxVariant &value,
|
2014-03-30 00:02:23 +00:00
|
|
|
unsigned int row, unsigned int col ) const wxOVERRIDE;
|
2009-01-16 11:23:37 +00:00
|
|
|
|
|
|
|
virtual bool SetValueByRow( const wxVariant &value,
|
2014-03-30 00:02:23 +00:00
|
|
|
unsigned int row, unsigned int col ) wxOVERRIDE;
|
2009-01-16 11:23:37 +00:00
|
|
|
|
2009-01-20 17:50:51 +00:00
|
|
|
|
2009-01-16 11:23:37 +00:00
|
|
|
public:
|
|
|
|
wxVector<wxDataViewListStoreLine*> m_data;
|
|
|
|
wxArrayString m_cols;
|
|
|
|
};
|
|
|
|
|
2009-01-16 15:04:00 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewListCtrl: public wxDataViewCtrl
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDataViewListCtrl();
|
|
|
|
wxDataViewListCtrl( wxWindow *parent, wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES,
|
|
|
|
const wxValidator& validator = wxDefaultValidator );
|
|
|
|
~wxDataViewListCtrl();
|
|
|
|
|
|
|
|
bool Create( wxWindow *parent, wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES,
|
|
|
|
const wxValidator& validator = wxDefaultValidator );
|
|
|
|
|
|
|
|
wxDataViewListStore *GetStore()
|
|
|
|
{ return (wxDataViewListStore*) GetModel(); }
|
|
|
|
const wxDataViewListStore *GetStore() const
|
|
|
|
{ return (const wxDataViewListStore*) GetModel(); }
|
|
|
|
|
2010-07-27 21:45:45 +00:00
|
|
|
int ItemToRow(const wxDataViewItem &item) const
|
2010-07-29 15:30:11 +00:00
|
|
|
{ return item.IsOk() ? (int)GetStore()->GetRow(item) : wxNOT_FOUND; }
|
2010-07-27 21:45:45 +00:00
|
|
|
wxDataViewItem RowToItem(int row) const
|
|
|
|
{ return row == wxNOT_FOUND ? wxDataViewItem() : GetStore()->GetItem(row); }
|
|
|
|
|
2010-07-27 21:45:50 +00:00
|
|
|
int GetSelectedRow() const
|
|
|
|
{ return ItemToRow(GetSelection()); }
|
|
|
|
void SelectRow(unsigned row)
|
|
|
|
{ Select(RowToItem(row)); }
|
|
|
|
void UnselectRow(unsigned row)
|
|
|
|
{ Unselect(RowToItem(row)); }
|
|
|
|
bool IsRowSelected(unsigned row) const
|
|
|
|
{ return IsSelected(RowToItem(row)); }
|
|
|
|
|
2009-01-19 14:44:47 +00:00
|
|
|
bool AppendColumn( wxDataViewColumn *column, const wxString &varianttype );
|
|
|
|
bool PrependColumn( wxDataViewColumn *column, const wxString &varianttype );
|
|
|
|
bool InsertColumn( unsigned int pos, wxDataViewColumn *column, const wxString &varianttype );
|
2009-01-20 17:50:51 +00:00
|
|
|
|
2009-01-19 14:44:47 +00:00
|
|
|
// overridden from base class
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual bool PrependColumn( wxDataViewColumn *col ) wxOVERRIDE;
|
|
|
|
virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col ) wxOVERRIDE;
|
|
|
|
virtual bool AppendColumn( wxDataViewColumn *col ) wxOVERRIDE;
|
|
|
|
virtual bool ClearColumns() wxOVERRIDE;
|
2009-01-19 14:44:47 +00:00
|
|
|
|
2009-01-28 21:36:57 +00:00
|
|
|
wxDataViewColumn *AppendTextColumn( const wxString &label,
|
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
2009-01-16 15:04:00 +00:00
|
|
|
int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE );
|
2009-01-28 21:36:57 +00:00
|
|
|
wxDataViewColumn *AppendToggleColumn( const wxString &label,
|
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
|
2009-01-16 15:04:00 +00:00
|
|
|
int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE );
|
2009-01-28 21:36:57 +00:00
|
|
|
wxDataViewColumn *AppendProgressColumn( const wxString &label,
|
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
2009-01-16 15:04:00 +00:00
|
|
|
int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE );
|
2009-01-28 21:36:57 +00:00
|
|
|
wxDataViewColumn *AppendIconTextColumn( const wxString &label,
|
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
2009-01-16 15:04:00 +00:00
|
|
|
int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE );
|
|
|
|
|
2012-11-08 17:47:16 +00:00
|
|
|
void AppendItem( const wxVector<wxVariant> &values, wxUIntPtr data = 0 )
|
2009-01-16 15:04:00 +00:00
|
|
|
{ GetStore()->AppendItem( values, data ); }
|
2012-11-08 17:47:16 +00:00
|
|
|
void PrependItem( const wxVector<wxVariant> &values, wxUIntPtr data = 0 )
|
2009-01-16 15:04:00 +00:00
|
|
|
{ GetStore()->PrependItem( values, data ); }
|
2012-11-08 17:47:16 +00:00
|
|
|
void InsertItem( unsigned int row, const wxVector<wxVariant> &values, wxUIntPtr data = 0 )
|
2009-01-16 15:04:00 +00:00
|
|
|
{ GetStore()->InsertItem( row, values, data ); }
|
|
|
|
void DeleteItem( unsigned row )
|
|
|
|
{ GetStore()->DeleteItem( row ); }
|
|
|
|
void DeleteAllItems()
|
|
|
|
{ GetStore()->DeleteAllItems(); }
|
|
|
|
|
|
|
|
void SetValue( const wxVariant &value, unsigned int row, unsigned int col )
|
2009-01-28 21:36:57 +00:00
|
|
|
{ GetStore()->SetValueByRow( value, row, col );
|
2009-01-16 15:44:12 +00:00
|
|
|
GetStore()->RowValueChanged( row, col); }
|
|
|
|
void GetValue( wxVariant &value, unsigned int row, unsigned int col )
|
|
|
|
{ GetStore()->GetValueByRow( value, row, col ); }
|
2009-01-16 15:04:00 +00:00
|
|
|
|
|
|
|
void SetTextValue( const wxString &value, unsigned int row, unsigned int col )
|
2009-01-16 15:44:12 +00:00
|
|
|
{ GetStore()->SetValueByRow( value, row, col );
|
|
|
|
GetStore()->RowValueChanged( row, col); }
|
2009-01-16 15:04:00 +00:00
|
|
|
wxString GetTextValue( unsigned int row, unsigned int col ) const
|
|
|
|
{ wxVariant value; GetStore()->GetValueByRow( value, row, col ); return value.GetString(); }
|
|
|
|
|
|
|
|
void SetToggleValue( bool value, unsigned int row, unsigned int col )
|
2009-01-16 15:44:12 +00:00
|
|
|
{ GetStore()->SetValueByRow( value, row, col );
|
|
|
|
GetStore()->RowValueChanged( row, col); }
|
2009-01-16 15:04:00 +00:00
|
|
|
bool GetToggleValue( unsigned int row, unsigned int col ) const
|
|
|
|
{ wxVariant value; GetStore()->GetValueByRow( value, row, col ); return value.GetBool(); }
|
|
|
|
|
2012-05-25 17:02:35 +00:00
|
|
|
void SetItemData( const wxDataViewItem& item, wxUIntPtr data )
|
|
|
|
{ GetStore()->SetItemData( item, data ); }
|
|
|
|
wxUIntPtr GetItemData( const wxDataViewItem& item ) const
|
|
|
|
{ return GetStore()->GetItemData( item ); }
|
|
|
|
|
2012-05-25 17:02:40 +00:00
|
|
|
int GetItemCount() const
|
|
|
|
{ return GetStore()->GetItemCount(); }
|
|
|
|
|
2009-01-16 15:04:00 +00:00
|
|
|
void OnSize( wxSizeEvent &event );
|
|
|
|
|
|
|
|
private:
|
2015-04-23 11:49:01 +00:00
|
|
|
wxDECLARE_EVENT_TABLE();
|
|
|
|
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewListCtrl);
|
2009-01-16 15:04:00 +00:00
|
|
|
};
|
2009-01-16 11:23:37 +00:00
|
|
|
|
2007-10-16 11:41:46 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// wxDataViewTreeStore
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewTreeStoreNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDataViewTreeStoreNode( wxDataViewTreeStoreNode *parent,
|
|
|
|
const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
|
|
|
|
virtual ~wxDataViewTreeStoreNode();
|
2007-10-20 23:23:44 +00:00
|
|
|
|
|
|
|
void SetText( const wxString &text )
|
2007-10-16 11:41:46 +00:00
|
|
|
{ m_text = text; }
|
|
|
|
wxString GetText() const
|
|
|
|
{ return m_text; }
|
|
|
|
void SetIcon( const wxIcon &icon )
|
|
|
|
{ m_icon = icon; }
|
|
|
|
const wxIcon &GetIcon() const
|
|
|
|
{ return m_icon; }
|
|
|
|
void SetData( wxClientData *data )
|
|
|
|
{ if (m_data) delete m_data; m_data = data; }
|
|
|
|
wxClientData *GetData() const
|
|
|
|
{ return m_data; }
|
2007-10-20 23:23:44 +00:00
|
|
|
|
2007-10-16 11:41:46 +00:00
|
|
|
wxDataViewItem GetItem() const
|
|
|
|
{ return wxDataViewItem( (void*) this ); }
|
2007-10-20 23:23:44 +00:00
|
|
|
|
2007-10-16 11:41:46 +00:00
|
|
|
virtual bool IsContainer()
|
|
|
|
{ return false; }
|
2007-10-20 23:23:44 +00:00
|
|
|
|
2007-10-16 11:41:46 +00:00
|
|
|
wxDataViewTreeStoreNode *GetParent()
|
|
|
|
{ return m_parent; }
|
2007-10-20 23:23:44 +00:00
|
|
|
|
2007-10-16 11:41:46 +00:00
|
|
|
private:
|
|
|
|
wxDataViewTreeStoreNode *m_parent;
|
|
|
|
wxString m_text;
|
|
|
|
wxIcon m_icon;
|
|
|
|
wxClientData *m_data;
|
|
|
|
};
|
|
|
|
|
|
|
|
WX_DECLARE_LIST_WITH_DECL(wxDataViewTreeStoreNode, wxDataViewTreeStoreNodeList,
|
|
|
|
class WXDLLIMPEXP_ADV);
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewTreeStoreContainerNode: public wxDataViewTreeStoreNode
|
|
|
|
{
|
|
|
|
public:
|
2007-10-20 23:23:44 +00:00
|
|
|
wxDataViewTreeStoreContainerNode( wxDataViewTreeStoreNode *parent,
|
|
|
|
const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
|
2007-10-16 11:41:46 +00:00
|
|
|
wxClientData *data = NULL );
|
|
|
|
virtual ~wxDataViewTreeStoreContainerNode();
|
|
|
|
|
2007-10-20 23:23:44 +00:00
|
|
|
const wxDataViewTreeStoreNodeList &GetChildren() const
|
2007-10-16 11:41:46 +00:00
|
|
|
{ return m_children; }
|
2007-10-20 23:23:44 +00:00
|
|
|
wxDataViewTreeStoreNodeList &GetChildren()
|
2007-10-16 11:41:46 +00:00
|
|
|
{ return m_children; }
|
|
|
|
|
|
|
|
void SetExpandedIcon( const wxIcon &icon )
|
|
|
|
{ m_iconExpanded = icon; }
|
|
|
|
const wxIcon &GetExpandedIcon() const
|
|
|
|
{ return m_iconExpanded; }
|
2007-10-20 23:23:44 +00:00
|
|
|
|
2007-12-01 19:01:47 +00:00
|
|
|
void SetExpanded( bool expanded = true )
|
|
|
|
{ m_isExpanded = expanded; }
|
|
|
|
bool IsExpanded() const
|
|
|
|
{ return m_isExpanded; }
|
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual bool IsContainer() wxOVERRIDE
|
2007-10-16 11:41:46 +00:00
|
|
|
{ return true; }
|
2007-10-20 23:23:44 +00:00
|
|
|
|
2007-10-16 11:41:46 +00:00
|
|
|
private:
|
|
|
|
wxDataViewTreeStoreNodeList m_children;
|
|
|
|
wxIcon m_iconExpanded;
|
2007-12-01 19:01:47 +00:00
|
|
|
bool m_isExpanded;
|
2007-10-16 11:41:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewTreeStore: public wxDataViewModel
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDataViewTreeStore();
|
|
|
|
~wxDataViewTreeStore();
|
|
|
|
|
2007-10-20 23:23:44 +00:00
|
|
|
wxDataViewItem AppendItem( const wxDataViewItem& parent,
|
2007-10-16 11:41:46 +00:00
|
|
|
const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
|
|
|
|
wxDataViewItem PrependItem( const wxDataViewItem& parent,
|
|
|
|
const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
|
|
|
|
wxDataViewItem InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous,
|
|
|
|
const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
|
2007-10-20 23:23:44 +00:00
|
|
|
|
|
|
|
wxDataViewItem PrependContainer( const wxDataViewItem& parent,
|
|
|
|
const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
|
2007-10-16 11:41:46 +00:00
|
|
|
wxClientData *data = NULL );
|
|
|
|
wxDataViewItem AppendContainer( const wxDataViewItem& parent,
|
2007-10-20 23:23:44 +00:00
|
|
|
const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
|
2007-10-16 11:41:46 +00:00
|
|
|
wxClientData *data = NULL );
|
|
|
|
wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous,
|
2007-10-20 23:23:44 +00:00
|
|
|
const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
|
2007-10-16 11:41:46 +00:00
|
|
|
wxClientData *data = NULL );
|
|
|
|
|
|
|
|
wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const;
|
|
|
|
int GetChildCount( const wxDataViewItem& parent ) const;
|
2010-09-30 11:44:45 +00:00
|
|
|
|
2007-10-16 11:41:46 +00:00
|
|
|
void SetItemText( const wxDataViewItem& item, const wxString &text );
|
|
|
|
wxString GetItemText( const wxDataViewItem& item ) const;
|
2007-10-20 23:23:44 +00:00
|
|
|
void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon );
|
2007-10-16 11:41:46 +00:00
|
|
|
const wxIcon &GetItemIcon( const wxDataViewItem& item ) const;
|
|
|
|
void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon );
|
|
|
|
const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const;
|
|
|
|
void SetItemData( const wxDataViewItem& item, wxClientData *data );
|
|
|
|
wxClientData *GetItemData( const wxDataViewItem& item ) const;
|
|
|
|
|
|
|
|
void DeleteItem( const wxDataViewItem& item );
|
|
|
|
void DeleteChildren( const wxDataViewItem& item );
|
|
|
|
void DeleteAllItems();
|
2007-10-20 23:23:44 +00:00
|
|
|
|
2007-10-16 11:41:46 +00:00
|
|
|
// implement base methods
|
|
|
|
|
2007-10-20 23:23:44 +00:00
|
|
|
virtual void GetValue( wxVariant &variant,
|
2014-03-30 00:02:23 +00:00
|
|
|
const wxDataViewItem &item, unsigned int col ) const wxOVERRIDE;
|
2007-10-20 23:23:44 +00:00
|
|
|
virtual bool SetValue( const wxVariant &variant,
|
2014-03-30 00:02:23 +00:00
|
|
|
const wxDataViewItem &item, unsigned int col ) wxOVERRIDE;
|
|
|
|
virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const wxOVERRIDE;
|
|
|
|
virtual bool IsContainer( const wxDataViewItem &item ) const wxOVERRIDE;
|
|
|
|
virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const wxOVERRIDE;
|
2007-10-16 11:41:46 +00:00
|
|
|
|
2007-10-20 23:23:44 +00:00
|
|
|
virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
|
2014-03-30 00:02:23 +00:00
|
|
|
unsigned int column, bool ascending ) const wxOVERRIDE;
|
2007-10-20 23:23:44 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual bool HasDefaultCompare() const wxOVERRIDE
|
2007-10-16 11:41:46 +00:00
|
|
|
{ return true; }
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual unsigned int GetColumnCount() const wxOVERRIDE
|
2011-12-29 14:42:13 +00:00
|
|
|
{ return 1; }
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual wxString GetColumnType( unsigned int WXUNUSED(col) ) const wxOVERRIDE
|
2007-11-17 21:20:27 +00:00
|
|
|
{ return wxT("wxDataViewIconText"); }
|
2007-10-20 23:23:44 +00:00
|
|
|
|
2007-10-16 11:41:46 +00:00
|
|
|
wxDataViewTreeStoreNode *FindNode( const wxDataViewItem &item ) const;
|
|
|
|
wxDataViewTreeStoreContainerNode *FindContainerNode( const wxDataViewItem &item ) const;
|
|
|
|
wxDataViewTreeStoreNode *GetRoot() const { return m_root; }
|
2007-10-20 23:23:44 +00:00
|
|
|
|
2007-10-16 11:41:46 +00:00
|
|
|
public:
|
|
|
|
wxDataViewTreeStoreNode *m_root;
|
|
|
|
};
|
|
|
|
|
2009-01-16 15:04:00 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2011-08-21 14:08:43 +00:00
|
|
|
class WXDLLIMPEXP_ADV wxDataViewTreeCtrl: public wxDataViewCtrl,
|
|
|
|
public wxWithImages
|
2007-10-16 11:41:46 +00:00
|
|
|
{
|
|
|
|
public:
|
2011-08-21 14:08:43 +00:00
|
|
|
wxDataViewTreeCtrl() { }
|
2009-10-24 21:41:44 +00:00
|
|
|
wxDataViewTreeCtrl(wxWindow *parent,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = wxDV_NO_HEADER | wxDV_ROW_LINES,
|
|
|
|
const wxValidator& validator = wxDefaultValidator)
|
|
|
|
{
|
|
|
|
Create(parent, id, pos, size, style, validator);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Create(wxWindow *parent,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = wxDV_NO_HEADER | wxDV_ROW_LINES,
|
|
|
|
const wxValidator& validator = wxDefaultValidator);
|
2007-10-16 11:41:46 +00:00
|
|
|
|
|
|
|
wxDataViewTreeStore *GetStore()
|
|
|
|
{ return (wxDataViewTreeStore*) GetModel(); }
|
2007-12-01 19:01:47 +00:00
|
|
|
const wxDataViewTreeStore *GetStore() const
|
|
|
|
{ return (const wxDataViewTreeStore*) GetModel(); }
|
2007-10-20 23:23:44 +00:00
|
|
|
|
2009-11-13 14:14:44 +00:00
|
|
|
bool IsContainer( const wxDataViewItem& item ) const
|
|
|
|
{ return GetStore()->IsContainer(item); }
|
|
|
|
|
2007-12-01 19:01:47 +00:00
|
|
|
wxDataViewItem AppendItem( const wxDataViewItem& parent,
|
2011-08-21 14:08:49 +00:00
|
|
|
const wxString &text, int icon = NO_IMAGE, wxClientData *data = NULL );
|
2007-12-01 19:01:47 +00:00
|
|
|
wxDataViewItem PrependItem( const wxDataViewItem& parent,
|
2011-08-21 14:08:49 +00:00
|
|
|
const wxString &text, int icon = NO_IMAGE, wxClientData *data = NULL );
|
2007-12-01 19:01:47 +00:00
|
|
|
wxDataViewItem InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous,
|
2011-08-21 14:08:49 +00:00
|
|
|
const wxString &text, int icon = NO_IMAGE, wxClientData *data = NULL );
|
2007-12-01 19:01:47 +00:00
|
|
|
|
|
|
|
wxDataViewItem PrependContainer( const wxDataViewItem& parent,
|
2011-08-21 14:08:49 +00:00
|
|
|
const wxString &text, int icon = NO_IMAGE, int expanded = NO_IMAGE,
|
2007-12-01 19:01:47 +00:00
|
|
|
wxClientData *data = NULL );
|
|
|
|
wxDataViewItem AppendContainer( const wxDataViewItem& parent,
|
2011-08-21 14:08:49 +00:00
|
|
|
const wxString &text, int icon = NO_IMAGE, int expanded = NO_IMAGE,
|
2007-12-01 19:01:47 +00:00
|
|
|
wxClientData *data = NULL );
|
|
|
|
wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous,
|
2011-08-21 14:08:49 +00:00
|
|
|
const wxString &text, int icon = NO_IMAGE, int expanded = NO_IMAGE,
|
2007-12-01 19:01:47 +00:00
|
|
|
wxClientData *data = NULL );
|
|
|
|
|
|
|
|
wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const
|
|
|
|
{ return GetStore()->GetNthChild(parent, pos); }
|
|
|
|
int GetChildCount( const wxDataViewItem& parent ) const
|
|
|
|
{ return GetStore()->GetChildCount(parent); }
|
|
|
|
|
2009-01-19 11:42:54 +00:00
|
|
|
void SetItemText( const wxDataViewItem& item, const wxString &text );
|
2007-12-01 19:01:47 +00:00
|
|
|
wxString GetItemText( const wxDataViewItem& item ) const
|
|
|
|
{ return GetStore()->GetItemText(item); }
|
2009-01-19 11:42:54 +00:00
|
|
|
void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon );
|
2007-12-01 19:01:47 +00:00
|
|
|
const wxIcon &GetItemIcon( const wxDataViewItem& item ) const
|
|
|
|
{ return GetStore()->GetItemIcon(item); }
|
2009-01-19 11:42:54 +00:00
|
|
|
void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon );
|
2007-12-01 19:01:47 +00:00
|
|
|
const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const
|
|
|
|
{ return GetStore()->GetItemExpandedIcon(item); }
|
|
|
|
void SetItemData( const wxDataViewItem& item, wxClientData *data )
|
|
|
|
{ GetStore()->SetItemData(item,data); }
|
|
|
|
wxClientData *GetItemData( const wxDataViewItem& item ) const
|
|
|
|
{ return GetStore()->GetItemData(item); }
|
|
|
|
|
2009-01-19 11:42:54 +00:00
|
|
|
void DeleteItem( const wxDataViewItem& item );
|
|
|
|
void DeleteChildren( const wxDataViewItem& item );
|
|
|
|
void DeleteAllItems();
|
2007-12-01 19:01:47 +00:00
|
|
|
|
|
|
|
void OnExpanded( wxDataViewEvent &event );
|
|
|
|
void OnCollapsed( wxDataViewEvent &event );
|
2007-12-03 09:44:29 +00:00
|
|
|
void OnSize( wxSizeEvent &event );
|
2007-10-20 23:23:44 +00:00
|
|
|
|
2007-12-01 19:01:47 +00:00
|
|
|
private:
|
2015-04-23 11:49:01 +00:00
|
|
|
wxDECLARE_EVENT_TABLE();
|
|
|
|
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewTreeCtrl);
|
2007-10-16 11:41:46 +00:00
|
|
|
};
|
|
|
|
|
2013-04-25 10:11:03 +00:00
|
|
|
// old wxEVT_COMMAND_* constants
|
|
|
|
#define wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED wxEVT_DATAVIEW_SELECTION_CHANGED
|
|
|
|
#define wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED wxEVT_DATAVIEW_ITEM_ACTIVATED
|
|
|
|
#define wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED wxEVT_DATAVIEW_ITEM_COLLAPSED
|
|
|
|
#define wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED wxEVT_DATAVIEW_ITEM_EXPANDED
|
|
|
|
#define wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING wxEVT_DATAVIEW_ITEM_COLLAPSING
|
|
|
|
#define wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING wxEVT_DATAVIEW_ITEM_EXPANDING
|
|
|
|
#define wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING wxEVT_DATAVIEW_ITEM_START_EDITING
|
|
|
|
#define wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED wxEVT_DATAVIEW_ITEM_EDITING_STARTED
|
|
|
|
#define wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE wxEVT_DATAVIEW_ITEM_EDITING_DONE
|
|
|
|
#define wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
|
|
|
|
#define wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU wxEVT_DATAVIEW_ITEM_CONTEXT_MENU
|
|
|
|
#define wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK wxEVT_DATAVIEW_COLUMN_HEADER_CLICK
|
2013-04-25 11:56:55 +00:00
|
|
|
#define wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK wxEVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK
|
2013-04-25 10:11:03 +00:00
|
|
|
#define wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED wxEVT_DATAVIEW_COLUMN_SORTED
|
|
|
|
#define wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED wxEVT_DATAVIEW_COLUMN_REORDERED
|
|
|
|
#define wxEVT_COMMAND_DATAVIEW_CACHE_HINT wxEVT_DATAVIEW_CACHE_HINT
|
|
|
|
#define wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG wxEVT_DATAVIEW_ITEM_BEGIN_DRAG
|
|
|
|
#define wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE
|
|
|
|
#define wxEVT_COMMAND_DATAVIEW_ITEM_DROP wxEVT_DATAVIEW_ITEM_DROP
|
|
|
|
|
2006-01-08 21:50:02 +00:00
|
|
|
#endif // wxUSE_DATAVIEWCTRL
|
|
|
|
|
|
|
|
#endif
|
|
|
|
// _WX_DATAVIEW_H_BASE_
|