2006-01-08 21:50:02 +00: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 17:35:19 +00:00
|
|
|
#include "wx/control.h"
|
|
|
|
#include "wx/textctrl.h"
|
|
|
|
#include "wx/bitmap.h"
|
2006-02-21 18:12:44 +00:00
|
|
|
#include "wx/variant.h"
|
2006-02-21 17:35:19 +00:00
|
|
|
|
2006-01-08 21:50:02 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxDataViewCtrl flags
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2006-02-21 17:35:19 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxDataViewCtrl globals
|
|
|
|
// ----------------------------------------------------------------------------
|
2006-01-08 21:50:02 +00:00
|
|
|
|
2006-02-22 00:19:04 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxDataViewCtrl;
|
|
|
|
class WXDLLIMPEXP_CORE wxDataViewColumn;
|
2006-02-23 02:04:46 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxDataViewCell;
|
2006-02-22 00:19:04 +00:00
|
|
|
|
2006-01-16 14:59:55 +00:00
|
|
|
extern WXDLLEXPORT_DATA(const wxChar) wxDataViewCtrlNameStr[];
|
2006-01-08 21:50:02 +00:00
|
|
|
|
2006-02-21 17:35:19 +00:00
|
|
|
// ---------------------------------------------------------
|
|
|
|
// wxDataViewModel
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
class wxDataViewModel: public wxObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDataViewModel() { }
|
|
|
|
virtual ~wxDataViewModel() { }
|
|
|
|
|
|
|
|
protected:
|
2006-02-21 19:55:58 +00:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewModel)
|
2006-02-21 17:35:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
// wxDataViewListModelNotifier
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
class wxDataViewListModelNotifier
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDataViewListModelNotifier() { }
|
|
|
|
virtual ~wxDataViewListModelNotifier() { }
|
|
|
|
|
|
|
|
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 13:09:41 +00:00
|
|
|
virtual bool ValueChanged( size_t col, size_t row ) = 0;
|
2006-02-21 17:35:19 +00:00
|
|
|
virtual bool Cleared() = 0;
|
2006-02-27 13:09:41 +00:00
|
|
|
virtual bool ValueChanged( wxDataViewColumn *view_column, size_t model_column, size_t row ) = 0;
|
2006-02-21 18:12:44 +00:00
|
|
|
};
|
2006-02-21 17:35:19 +00:00
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
// wxDataViewListModel
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
class wxDataViewListModel: public wxDataViewModel
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDataViewListModel();
|
|
|
|
virtual ~wxDataViewListModel();
|
|
|
|
|
|
|
|
virtual size_t GetNumberOfRows() = 0;
|
|
|
|
virtual size_t GetNumberOfCols() = 0;
|
2006-02-23 13:34:15 +00:00
|
|
|
// return type as reported by wxVariant
|
2006-02-21 17:35:19 +00:00
|
|
|
virtual wxString GetColType( size_t col ) = 0;
|
2006-02-23 13:34:15 +00:00
|
|
|
// get value into a wxVariant
|
2006-02-21 17:35:19 +00:00
|
|
|
virtual wxVariant GetValue( size_t col, size_t row ) = 0;
|
2006-02-23 13:34:15 +00:00
|
|
|
// set value, call ValueChanged() afterwards!
|
|
|
|
virtual bool SetValue( wxVariant &variant, size_t col, size_t row ) = 0;
|
2006-02-21 17:35:19 +00:00
|
|
|
|
|
|
|
// delegated notifiers
|
|
|
|
bool RowAppended();
|
|
|
|
bool RowPrepended();
|
|
|
|
bool RowInserted( size_t before );
|
|
|
|
bool RowDeleted( size_t row );
|
|
|
|
bool RowChanged( size_t row );
|
2006-02-23 13:34:15 +00:00
|
|
|
bool ValueChanged( size_t col, size_t row );
|
2006-02-21 17:35:19 +00:00
|
|
|
bool Cleared();
|
2006-02-27 13:09:41 +00:00
|
|
|
|
|
|
|
// Used internally
|
|
|
|
void AddViewingColumn( wxDataViewColumn *view_column, size_t model_column );
|
|
|
|
void RemoveViewingColumn( wxDataViewColumn *column );
|
2006-02-21 17:35:19 +00:00
|
|
|
|
2006-02-27 13:09:41 +00:00
|
|
|
// Used internally
|
2006-02-21 17:35:19 +00:00
|
|
|
void SetNotifier( wxDataViewListModelNotifier *notifier );
|
|
|
|
wxDataViewListModelNotifier* GetNotifier();
|
|
|
|
|
|
|
|
private:
|
|
|
|
wxDataViewListModelNotifier *m_notifier;
|
2006-02-27 13:09:41 +00:00
|
|
|
wxList m_viewingColumns;
|
2006-02-21 17:35:19 +00:00
|
|
|
|
|
|
|
protected:
|
2006-02-21 19:55:58 +00:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewListModel)
|
2006-02-21 17:35:19 +00:00
|
|
|
};
|
|
|
|
|
2006-02-22 00:19:04 +00:00
|
|
|
// ---------------------------------------------------------
|
2006-02-23 02:04:46 +00:00
|
|
|
// wxDataViewCellBase
|
2006-02-22 00:19:04 +00:00
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
2006-02-23 02:04:46 +00:00
|
|
|
enum wxDataViewCellMode
|
2006-02-22 00:19:04 +00:00
|
|
|
{
|
2006-02-23 02:04:46 +00:00
|
|
|
wxDATAVIEW_CELL_INERT,
|
|
|
|
wxDATAVIEW_CELL_ACTIVATABLE,
|
|
|
|
wxDATAVIEW_CELL_EDITABLE
|
2006-02-22 00:19:04 +00:00
|
|
|
};
|
|
|
|
|
2006-02-23 02:04:46 +00: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 );
|
|
|
|
|
|
|
|
virtual bool SetValue( const wxVariant &value ) { return true; }
|
|
|
|
virtual bool GetValue( wxVariant &value ) { return true; }
|
2006-02-23 13:34:15 +00:00
|
|
|
virtual bool Validate( wxVariant &value ) { return true; }
|
2006-02-23 02:04:46 +00:00
|
|
|
|
2006-02-24 18:19:55 +00:00
|
|
|
wxString GetVariantType() { return m_variantType; }
|
2006-02-23 02:04:46 +00:00
|
|
|
|
|
|
|
void SetOwner( wxDataViewColumn *owner ) { m_owner = owner; }
|
|
|
|
wxDataViewColumn* GetOwner() { return m_owner; }
|
|
|
|
|
2006-02-23 13:34:15 +00:00
|
|
|
protected:
|
2006-02-23 02:04:46 +00:00
|
|
|
wxDataViewCellMode m_mode;
|
|
|
|
wxString m_variantType;
|
|
|
|
wxDataViewColumn *m_owner;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCellBase)
|
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
// wxDataViewColumnBase
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
2006-02-22 00:19:04 +00:00
|
|
|
enum wxDataViewColumnFlags
|
|
|
|
{
|
|
|
|
wxDATAVIEW_COL_RESIZABLE = 1,
|
|
|
|
wxDATAVIEW_COL_SORTABLE = 2,
|
|
|
|
wxDATAVIEW_COL_HIDDEN = 4
|
|
|
|
};
|
|
|
|
|
|
|
|
class wxDataViewColumnBase: public wxObject
|
|
|
|
{
|
|
|
|
public:
|
2006-02-23 02:04:46 +00:00
|
|
|
wxDataViewColumnBase( const wxString &title, wxDataViewCell *cell, size_t model_column, int flags = 0 );
|
|
|
|
~wxDataViewColumnBase();
|
2006-02-22 00:19:04 +00:00
|
|
|
|
|
|
|
virtual void SetTitle( const wxString &title );
|
|
|
|
virtual wxString GetTitle();
|
2006-02-23 02:04:46 +00:00
|
|
|
|
|
|
|
wxDataViewCell* GetCell() { return m_cell; }
|
|
|
|
|
|
|
|
size_t GetModelColumn() { return m_model_column; }
|
|
|
|
|
|
|
|
void SetOwner( wxDataViewCtrl *owner ) { m_owner = owner; }
|
|
|
|
wxDataViewCtrl *GetOwner() { return m_owner; }
|
2006-02-22 00:19:04 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
wxDataViewCtrl *m_ctrl;
|
2006-02-23 02:04:46 +00:00
|
|
|
wxDataViewCell *m_cell;
|
|
|
|
int m_model_column;
|
2006-02-22 00:19:04 +00:00
|
|
|
int m_flags;
|
|
|
|
wxString m_title;
|
2006-02-23 02:04:46 +00:00
|
|
|
wxDataViewCtrl *m_owner;
|
2006-02-22 00:19:04 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumnBase)
|
|
|
|
};
|
|
|
|
|
2006-02-21 17:35:19 +00:00
|
|
|
// ---------------------------------------------------------
|
|
|
|
// wxDataViewCtrlBase
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
class wxDataViewCtrlBase: public wxControl
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDataViewCtrlBase();
|
|
|
|
~wxDataViewCtrlBase();
|
|
|
|
|
2006-02-21 20:52:05 +00:00
|
|
|
virtual bool AssociateModel( wxDataViewListModel *model );
|
|
|
|
wxDataViewListModel* GetModel();
|
2006-02-21 17:35:19 +00:00
|
|
|
|
2006-02-24 13:19:23 +00:00
|
|
|
virtual bool AppendTextColumn( const wxString &label, size_t model_column );
|
|
|
|
virtual bool AppendToggleColumn( const wxString &label, size_t model_column );
|
2006-02-25 13:13:05 +00:00
|
|
|
virtual bool AppendProgressColumn( const wxString &label, size_t model_column );
|
2006-02-26 15:48:42 +00:00
|
|
|
virtual bool AppendDateColumn( const wxString &label, size_t model_column );
|
2006-02-22 00:19:04 +00:00
|
|
|
virtual bool AppendColumn( wxDataViewColumn *col );
|
|
|
|
virtual size_t GetNumberOfColumns();
|
|
|
|
virtual bool DeleteColumn( size_t pos );
|
|
|
|
virtual bool ClearColumns();
|
|
|
|
virtual wxDataViewColumn* GetColumn( size_t pos );
|
|
|
|
|
2006-02-21 17:35:19 +00:00
|
|
|
private:
|
2006-02-21 20:52:05 +00:00
|
|
|
wxDataViewListModel *m_model;
|
2006-02-22 00:19:04 +00:00
|
|
|
wxList m_cols;
|
2006-01-08 21:50:02 +00:00
|
|
|
|
2006-02-21 17:35:19 +00:00
|
|
|
protected:
|
2006-02-21 19:55:58 +00:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase)
|
2006-02-21 17:35:19 +00:00
|
|
|
};
|
2006-01-08 21:50:02 +00:00
|
|
|
|
|
|
|
#if defined(__WXGTK20__)
|
|
|
|
#include "wx/gtk/dataview.h"
|
|
|
|
#elif defined(__WXMAC__)
|
|
|
|
#include "wx/mac/dataview.h"
|
|
|
|
#else
|
|
|
|
#include "wx/generic/dataview.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // wxUSE_DATAVIEWCTRL
|
|
|
|
|
|
|
|
#endif
|
|
|
|
// _WX_DATAVIEW_H_BASE_
|