2006-01-08 16:50:02 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/dataview.h
|
|
|
|
// Purpose: wxDataViewCtrl base classes
|
|
|
|
// Author: Robert Roebling
|
|
|
|
// Modified by:
|
|
|
|
// Created: 08.01.06
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// 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 12:35:19 -05:00
|
|
|
#include "wx/control.h"
|
|
|
|
#include "wx/textctrl.h"
|
|
|
|
#include "wx/bitmap.h"
|
2006-02-21 13:12:44 -05:00
|
|
|
#include "wx/variant.h"
|
2006-02-21 12:35:19 -05:00
|
|
|
|
2006-03-20 11:37:24 -05:00
|
|
|
|
|
|
|
#if defined(__WXGTK20__)
|
|
|
|
// for testing
|
2006-03-28 03:14:50 -05:00
|
|
|
#define wxUSE_GENERICDATAVIEWCTRL 1
|
2006-03-20 11:37:24 -05:00
|
|
|
#elif defined(__WXMAC__)
|
|
|
|
#define wxUSE_GENERICDATAVIEWCTRL 1
|
|
|
|
#else
|
|
|
|
#define wxUSE_GENERICDATAVIEWCTRL 1
|
|
|
|
#endif
|
|
|
|
|
2006-01-08 16:50:02 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
2006-03-27 09:01:33 -05:00
|
|
|
// wxDataViewCtrl flags
|
2006-01-08 16:50:02 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2006-02-21 12:35:19 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxDataViewCtrl globals
|
|
|
|
// ----------------------------------------------------------------------------
|
2006-01-08 16:50:02 -05:00
|
|
|
|
2006-02-28 10:04:25 -05:00
|
|
|
class WXDLLIMPEXP_CORE wxDataViewModel;
|
|
|
|
class WXDLLIMPEXP_CORE wxDataViewListModel;
|
2006-02-21 19:19:04 -05:00
|
|
|
class WXDLLIMPEXP_CORE wxDataViewCtrl;
|
|
|
|
class WXDLLIMPEXP_CORE wxDataViewColumn;
|
2006-02-22 21:04:46 -05:00
|
|
|
class WXDLLIMPEXP_CORE wxDataViewCell;
|
2006-02-21 19:19:04 -05:00
|
|
|
|
2006-01-16 09:59:55 -05:00
|
|
|
extern WXDLLEXPORT_DATA(const wxChar) wxDataViewCtrlNameStr[];
|
2006-01-08 16:50:02 -05:00
|
|
|
|
2006-03-27 09:01:33 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-02-21 12:35:19 -05:00
|
|
|
// wxDataViewModel
|
2006-03-27 09:01:33 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-02-21 12:35:19 -05:00
|
|
|
|
|
|
|
class wxDataViewModel: public wxObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDataViewModel() { }
|
|
|
|
virtual ~wxDataViewModel() { }
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-02-21 12:35:19 -05:00
|
|
|
protected:
|
2006-02-21 14:55:58 -05:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewModel)
|
2006-02-21 12:35:19 -05:00
|
|
|
};
|
|
|
|
|
2006-03-27 09:01:33 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-02-21 12:35:19 -05:00
|
|
|
// wxDataViewListModelNotifier
|
2006-03-27 09:01:33 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-02-21 12:35:19 -05:00
|
|
|
|
2006-02-28 10:04:25 -05:00
|
|
|
|
|
|
|
class wxDataViewListModelNotifier: public wxObject
|
2006-02-21 12:35:19 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDataViewListModelNotifier() { }
|
|
|
|
virtual ~wxDataViewListModelNotifier() { }
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-02-21 12:35:19 -05:00
|
|
|
virtual bool RowAppended() = 0;
|
|
|
|
virtual bool RowPrepended() = 0;
|
|
|
|
virtual bool RowInserted( size_t before ) = 0;
|
|
|
|
virtual bool RowDeleted( size_t row ) = 0;
|
|
|
|
virtual bool RowChanged( size_t row ) = 0;
|
2006-02-27 08:09:41 -05:00
|
|
|
virtual bool ValueChanged( size_t col, size_t row ) = 0;
|
2006-03-01 05:49:06 -05:00
|
|
|
virtual bool RowsReordered( size_t *new_order ) = 0;
|
2006-02-21 12:35:19 -05:00
|
|
|
virtual bool Cleared() = 0;
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-02-28 10:04:25 -05:00
|
|
|
void SetOwner( wxDataViewListModel *owner ) { m_owner = owner; }
|
|
|
|
wxDataViewListModel *GetOwner() { return m_owner; }
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-02-28 10:04:25 -05:00
|
|
|
private:
|
|
|
|
wxDataViewListModel *m_owner;
|
2006-02-21 13:12:44 -05:00
|
|
|
};
|
2006-02-21 12:35:19 -05:00
|
|
|
|
2006-03-27 09:01:33 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-02-21 12:35:19 -05:00
|
|
|
// wxDataViewListModel
|
2006-03-27 09:01:33 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-02-21 12:35:19 -05:00
|
|
|
|
2006-02-28 10:04:25 -05:00
|
|
|
class wxDataViewViewingColumn: public wxObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDataViewViewingColumn( wxDataViewColumn *view_column, size_t model_column )
|
|
|
|
{
|
|
|
|
m_viewColumn = view_column;
|
|
|
|
m_modelColumn = model_column;
|
|
|
|
}
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-02-28 10:04:25 -05:00
|
|
|
wxDataViewColumn *m_viewColumn;
|
|
|
|
size_t m_modelColumn;
|
|
|
|
};
|
|
|
|
|
2006-02-21 12:35:19 -05:00
|
|
|
class wxDataViewListModel: public wxDataViewModel
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDataViewListModel();
|
|
|
|
virtual ~wxDataViewListModel();
|
|
|
|
|
|
|
|
virtual size_t GetNumberOfRows() = 0;
|
|
|
|
virtual size_t GetNumberOfCols() = 0;
|
2006-02-23 08:34:15 -05:00
|
|
|
// return type as reported by wxVariant
|
2006-02-21 12:35:19 -05:00
|
|
|
virtual wxString GetColType( size_t col ) = 0;
|
2006-02-23 08:34:15 -05:00
|
|
|
// get value into a wxVariant
|
2006-03-02 05:46:01 -05:00
|
|
|
virtual void GetValue( wxVariant &variant, size_t col, size_t row ) = 0;
|
2006-02-23 08:34:15 -05:00
|
|
|
// set value, call ValueChanged() afterwards!
|
|
|
|
virtual bool SetValue( wxVariant &variant, size_t col, size_t row ) = 0;
|
2006-02-21 12:35:19 -05:00
|
|
|
|
|
|
|
// delegated notifiers
|
2006-02-28 05:47:28 -05:00
|
|
|
virtual bool RowAppended();
|
|
|
|
virtual bool RowPrepended();
|
|
|
|
virtual bool RowInserted( size_t before );
|
|
|
|
virtual bool RowDeleted( size_t row );
|
|
|
|
virtual bool RowChanged( size_t row );
|
|
|
|
virtual bool ValueChanged( size_t col, size_t row );
|
2006-03-01 05:49:06 -05:00
|
|
|
virtual bool RowsReordered( size_t *new_order );
|
2006-02-28 05:47:28 -05:00
|
|
|
virtual bool Cleared();
|
2006-02-27 08:09:41 -05:00
|
|
|
|
2006-03-27 09:01:33 -05:00
|
|
|
// Used internally
|
2006-02-28 05:47:28 -05:00
|
|
|
virtual void AddViewingColumn( wxDataViewColumn *view_column, size_t model_column );
|
|
|
|
virtual void RemoveViewingColumn( wxDataViewColumn *column );
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-02-28 10:04:25 -05:00
|
|
|
virtual void AddNotifier( wxDataViewListModelNotifier *notifier );
|
|
|
|
virtual void RemoveNotifier( wxDataViewListModelNotifier *notifier );
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-02-28 10:04:25 -05:00
|
|
|
wxList m_notifiers;
|
|
|
|
wxList m_viewingColumns;
|
2006-02-21 12:35:19 -05:00
|
|
|
|
|
|
|
protected:
|
2006-02-21 14:55:58 -05:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewListModel)
|
2006-02-21 12:35:19 -05:00
|
|
|
};
|
|
|
|
|
2006-03-27 09:01:33 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-02-28 05:47:28 -05:00
|
|
|
// wxDataViewSortedListModel
|
2006-03-27 09:01:33 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-02-28 05:47:28 -05:00
|
|
|
|
|
|
|
typedef int (wxCALLBACK *wxDataViewListModelCompare)
|
|
|
|
(size_t row1, size_t row2, size_t col, wxDataViewListModel* model );
|
|
|
|
|
|
|
|
WX_DEFINE_SORTED_EXPORTED_ARRAY_SIZE_T(size_t, wxDataViewSortedIndexArray );
|
|
|
|
|
|
|
|
class wxDataViewSortedListModel: public wxDataViewListModel
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDataViewSortedListModel( wxDataViewListModel *child );
|
|
|
|
virtual ~wxDataViewSortedListModel();
|
|
|
|
|
|
|
|
virtual size_t GetNumberOfRows();
|
|
|
|
virtual size_t GetNumberOfCols();
|
|
|
|
// return type as reported by wxVariant
|
|
|
|
virtual wxString GetColType( size_t col );
|
|
|
|
// get value into a wxVariant
|
2006-03-02 05:46:01 -05:00
|
|
|
virtual void GetValue( wxVariant &variant, size_t col, size_t row );
|
2006-02-28 05:47:28 -05:00
|
|
|
// set value, call ValueChanged() afterwards!
|
|
|
|
virtual bool SetValue( wxVariant &variant, size_t col, size_t row );
|
|
|
|
|
|
|
|
// delegated notifiers
|
|
|
|
virtual bool RowAppended();
|
|
|
|
virtual bool RowPrepended();
|
|
|
|
virtual bool RowInserted( size_t before );
|
|
|
|
virtual bool RowDeleted( size_t row );
|
|
|
|
virtual bool RowChanged( size_t row );
|
|
|
|
virtual bool ValueChanged( size_t col, size_t row );
|
2006-03-01 05:49:06 -05:00
|
|
|
virtual bool RowsReordered( size_t *new_order );
|
2006-02-28 05:47:28 -05:00
|
|
|
virtual bool Cleared();
|
|
|
|
|
2006-03-01 05:49:06 -05:00
|
|
|
bool ChildValueChanged( size_t col, size_t row );
|
|
|
|
|
2006-02-28 10:04:25 -05:00
|
|
|
virtual void Resort();
|
|
|
|
|
2006-02-28 05:47:28 -05:00
|
|
|
private:
|
|
|
|
wxDataViewListModel *m_child;
|
|
|
|
wxDataViewSortedIndexArray m_array;
|
2006-03-01 05:49:06 -05:00
|
|
|
wxDataViewListModelNotifier *m_notifierOnChild;
|
2006-02-28 05:47:28 -05:00
|
|
|
|
|
|
|
protected:
|
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewSortedListModel)
|
|
|
|
};
|
|
|
|
|
2006-03-27 09:01:33 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-02-22 21:04:46 -05:00
|
|
|
// wxDataViewCellBase
|
2006-03-27 09:01:33 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-02-21 19:19:04 -05:00
|
|
|
|
2006-02-22 21:04:46 -05:00
|
|
|
enum wxDataViewCellMode
|
2006-02-21 19:19:04 -05:00
|
|
|
{
|
2006-02-22 21:04:46 -05:00
|
|
|
wxDATAVIEW_CELL_INERT,
|
|
|
|
wxDATAVIEW_CELL_ACTIVATABLE,
|
|
|
|
wxDATAVIEW_CELL_EDITABLE
|
2006-02-21 19:19:04 -05:00
|
|
|
};
|
|
|
|
|
2006-02-22 21:04:46 -05:00
|
|
|
enum wxDataViewCellRenderState
|
|
|
|
{
|
|
|
|
wxDATAVIEW_CELL_SELECTED = 1,
|
|
|
|
wxDATAVIEW_CELL_PRELIT = 2,
|
|
|
|
wxDATAVIEW_CELL_INSENSITIVE = 4,
|
|
|
|
wxDATAVIEW_CELL_FOCUSED = 8
|
|
|
|
};
|
|
|
|
|
|
|
|
class wxDataViewCellBase: public wxObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDataViewCellBase( const wxString &varianttype, wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
|
|
|
|
|
2006-03-27 09:01:33 -05:00
|
|
|
virtual bool SetValue( const wxVariant& WXUNUSED(value) ) { return true; }
|
|
|
|
virtual bool GetValue( wxVariant& WXUNUSED(value) ) { return true; }
|
|
|
|
virtual bool Validate( wxVariant& WXUNUSED(value) ) { return true; }
|
|
|
|
|
2006-03-23 06:44:57 -05:00
|
|
|
wxString GetVariantType() { return m_variantType; }
|
|
|
|
wxDataViewCellMode GetMode() { return m_mode; }
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-02-22 21:04:46 -05:00
|
|
|
void SetOwner( wxDataViewColumn *owner ) { m_owner = owner; }
|
|
|
|
wxDataViewColumn* GetOwner() { return m_owner; }
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-02-23 08:34:15 -05:00
|
|
|
protected:
|
2006-02-22 21:04:46 -05:00
|
|
|
wxDataViewCellMode m_mode;
|
|
|
|
wxString m_variantType;
|
|
|
|
wxDataViewColumn *m_owner;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCellBase)
|
|
|
|
};
|
|
|
|
|
2006-03-27 09:01:33 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-02-22 21:04:46 -05:00
|
|
|
// wxDataViewColumnBase
|
2006-03-27 09:01:33 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-02-22 21:04:46 -05:00
|
|
|
|
2006-02-21 19:19:04 -05:00
|
|
|
enum wxDataViewColumnFlags
|
|
|
|
{
|
|
|
|
wxDATAVIEW_COL_RESIZABLE = 1,
|
|
|
|
wxDATAVIEW_COL_SORTABLE = 2,
|
|
|
|
wxDATAVIEW_COL_HIDDEN = 4
|
|
|
|
};
|
|
|
|
|
2006-04-18 19:14:36 -04:00
|
|
|
enum wxDataViewColumnSizing
|
|
|
|
{
|
|
|
|
wxDATAVIEW_COL_WIDTH_FIXED,
|
|
|
|
wxDATAVIEW_COL_WIDTH_AUTO,
|
|
|
|
wxDATAVIEW_COL_WIDTH_GROW
|
|
|
|
};
|
|
|
|
|
2006-02-21 19:19:04 -05:00
|
|
|
class wxDataViewColumnBase: public wxObject
|
|
|
|
{
|
|
|
|
public:
|
2006-04-27 07:33:56 -04:00
|
|
|
wxDataViewColumnBase( const wxString &title, wxDataViewCell *cell, size_t model_column,
|
2006-04-18 19:14:36 -04:00
|
|
|
int fixed_width = 80, wxDataViewColumnSizing sizing = wxDATAVIEW_COL_WIDTH_FIXED, int flags = 0 );
|
2006-02-22 21:04:46 -05:00
|
|
|
~wxDataViewColumnBase();
|
2006-02-21 19:19:04 -05:00
|
|
|
|
|
|
|
virtual void SetTitle( const wxString &title );
|
|
|
|
virtual wxString GetTitle();
|
2006-04-27 07:33:56 -04:00
|
|
|
|
2006-02-22 21:04:46 -05:00
|
|
|
wxDataViewCell* GetCell() { return m_cell; }
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-02-22 21:04:46 -05:00
|
|
|
size_t GetModelColumn() { return m_model_column; }
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-02-22 21:04:46 -05:00
|
|
|
void SetOwner( wxDataViewCtrl *owner ) { m_owner = owner; }
|
|
|
|
wxDataViewCtrl *GetOwner() { return m_owner; }
|
2006-04-27 07:33:56 -04:00
|
|
|
|
2006-04-18 19:14:36 -04:00
|
|
|
virtual int GetWidth() = 0;
|
2006-04-27 07:33:56 -04:00
|
|
|
|
2006-04-18 19:14:36 -04:00
|
|
|
virtual void SetFixedWidth( int width ) = 0;
|
|
|
|
virtual int GetFixedWidth() = 0;
|
2006-02-21 19:19:04 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
wxDataViewCtrl *m_ctrl;
|
2006-02-22 21:04:46 -05:00
|
|
|
wxDataViewCell *m_cell;
|
|
|
|
int m_model_column;
|
2006-02-21 19:19:04 -05:00
|
|
|
int m_flags;
|
|
|
|
wxString m_title;
|
2006-02-22 21:04:46 -05:00
|
|
|
wxDataViewCtrl *m_owner;
|
2006-02-21 19:19:04 -05:00
|
|
|
|
|
|
|
protected:
|
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumnBase)
|
|
|
|
};
|
|
|
|
|
2006-03-27 09:01:33 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-02-21 12:35:19 -05:00
|
|
|
// wxDataViewCtrlBase
|
2006-03-27 09:01:33 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-02-21 12:35:19 -05:00
|
|
|
|
2006-04-19 04:31:35 -04:00
|
|
|
#define wxDV_SINGLE 0x0000 // for convenience
|
|
|
|
#define wxDV_MULTIPLE 0x0020 // can select multiple items
|
|
|
|
|
2006-02-21 12:35:19 -05:00
|
|
|
class wxDataViewCtrlBase: public wxControl
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDataViewCtrlBase();
|
|
|
|
~wxDataViewCtrlBase();
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-02-21 15:52:05 -05:00
|
|
|
virtual bool AssociateModel( wxDataViewListModel *model );
|
|
|
|
wxDataViewListModel* GetModel();
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-02-24 08:19:23 -05:00
|
|
|
virtual bool AppendTextColumn( const wxString &label, size_t model_column );
|
|
|
|
virtual bool AppendToggleColumn( const wxString &label, size_t model_column );
|
2006-02-25 08:13:05 -05:00
|
|
|
virtual bool AppendProgressColumn( const wxString &label, size_t model_column );
|
2006-02-26 10:48:42 -05:00
|
|
|
virtual bool AppendDateColumn( const wxString &label, size_t model_column );
|
2006-03-27 09:01:33 -05:00
|
|
|
virtual bool AppendColumn( wxDataViewColumn *col );
|
2006-02-21 19:19:04 -05:00
|
|
|
virtual size_t GetNumberOfColumns();
|
|
|
|
virtual bool DeleteColumn( size_t pos );
|
|
|
|
virtual bool ClearColumns();
|
|
|
|
virtual wxDataViewColumn* GetColumn( size_t pos );
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-02-21 12:35:19 -05:00
|
|
|
private:
|
2006-02-21 15:52:05 -05:00
|
|
|
wxDataViewListModel *m_model;
|
2006-02-21 19:19:04 -05:00
|
|
|
wxList m_cols;
|
2006-01-08 16:50:02 -05:00
|
|
|
|
2006-02-21 12:35:19 -05:00
|
|
|
protected:
|
2006-02-21 14:55:58 -05:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase)
|
2006-02-21 12:35:19 -05:00
|
|
|
};
|
2006-01-08 16:50:02 -05:00
|
|
|
|
2006-03-20 11:37:24 -05:00
|
|
|
#if defined(wxUSE_GENERICDATAVIEWCTRL)
|
|
|
|
#include "wx/generic/dataview.h"
|
|
|
|
#elif defined(__WXGTK20__)
|
2006-01-08 16:50:02 -05:00
|
|
|
#include "wx/gtk/dataview.h"
|
|
|
|
#elif defined(__WXMAC__)
|
2006-04-27 07:33:56 -04:00
|
|
|
// TODO
|
|
|
|
// #include "wx/mac/dataview.h"
|
2006-01-08 16:50:02 -05:00
|
|
|
#else
|
|
|
|
#include "wx/generic/dataview.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // wxUSE_DATAVIEWCTRL
|
|
|
|
|
|
|
|
#endif
|
|
|
|
// _WX_DATAVIEW_H_BASE_
|