2006-03-20 11:37:24 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/generic/dataview.h
|
|
|
|
// Purpose: wxDataViewCtrl generic implementation header
|
|
|
|
// Author: Robert Roebling
|
|
|
|
// Id: $Id$
|
|
|
|
// Copyright: (c) 1998 Robert Roebling
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef __GENERICDATAVIEWCTRLH__
|
|
|
|
#define __GENERICDATAVIEWCTRLH__
|
|
|
|
|
|
|
|
#include "wx/defs.h"
|
|
|
|
#include "wx/object.h"
|
|
|
|
#include "wx/list.h"
|
|
|
|
#include "wx/control.h"
|
2006-03-20 11:41:41 -05:00
|
|
|
#include "wx/scrolwin.h"
|
2006-09-30 17:21:19 -04:00
|
|
|
#include "wx/icon.h"
|
2006-03-20 11:37:24 -05:00
|
|
|
|
2006-03-27 09:01:33 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-03-20 11:37:24 -05:00
|
|
|
// classes
|
2006-03-27 09:01:33 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-03-20 11:37:24 -05:00
|
|
|
|
2006-05-17 21:22:06 -04:00
|
|
|
class WXDLLIMPEXP_ADV wxDataViewCtrl;
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewMainWindow;
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewHeaderWindow;
|
2006-03-20 11:37:24 -05:00
|
|
|
|
2006-03-27 09:01:33 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-10-03 11:24:03 -04:00
|
|
|
// wxDataViewRenderer
|
2006-03-27 09:01:33 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-03-20 11:37:24 -05:00
|
|
|
|
2006-10-03 11:24:03 -04:00
|
|
|
class WXDLLIMPEXP_ADV wxDataViewRenderer: public wxDataViewRendererBase
|
2006-03-20 11:37:24 -05:00
|
|
|
{
|
|
|
|
public:
|
2006-10-03 11:24:03 -04:00
|
|
|
wxDataViewRenderer( const wxString &varianttype, wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
|
|
|
|
virtual ~wxDataViewRenderer();
|
2006-03-20 11:37:24 -05:00
|
|
|
|
2006-03-22 05:01:57 -05:00
|
|
|
virtual bool Render( wxRect cell, wxDC *dc, int state ) = 0;
|
|
|
|
virtual wxSize GetSize() = 0;
|
2006-03-27 09:01:33 -05:00
|
|
|
|
|
|
|
virtual bool Activate( wxRect WXUNUSED(cell),
|
|
|
|
wxDataViewListModel *WXUNUSED(model),
|
2006-10-03 07:09:06 -04:00
|
|
|
unsigned int WXUNUSED(col),
|
|
|
|
unsigned int WXUNUSED(row) )
|
2006-03-22 05:01:57 -05:00
|
|
|
{ return false; }
|
2006-03-27 09:01:33 -05:00
|
|
|
|
|
|
|
virtual bool LeftClick( wxPoint WXUNUSED(cursor),
|
|
|
|
wxRect WXUNUSED(cell),
|
|
|
|
wxDataViewListModel *WXUNUSED(model),
|
2006-10-03 07:09:06 -04:00
|
|
|
unsigned int WXUNUSED(col),
|
|
|
|
unsigned int WXUNUSED(row) )
|
2006-03-27 09:01:33 -05:00
|
|
|
{ return false; }
|
|
|
|
virtual bool RightClick( wxPoint WXUNUSED(cursor),
|
|
|
|
wxRect WXUNUSED(cell),
|
|
|
|
wxDataViewListModel *WXUNUSED(model),
|
2006-10-03 07:09:06 -04:00
|
|
|
unsigned int WXUNUSED(col),
|
|
|
|
unsigned int WXUNUSED(row) )
|
2006-03-27 09:01:33 -05:00
|
|
|
{ return false; }
|
|
|
|
virtual bool StartDrag( wxPoint WXUNUSED(cursor),
|
|
|
|
wxRect WXUNUSED(cell),
|
|
|
|
wxDataViewListModel *WXUNUSED(model),
|
2006-10-03 07:09:06 -04:00
|
|
|
unsigned int WXUNUSED(col),
|
|
|
|
unsigned int WXUNUSED(row) )
|
2006-03-27 09:01:33 -05:00
|
|
|
{ return false; }
|
|
|
|
|
2006-03-22 05:01:57 -05:00
|
|
|
// Create DC on request
|
|
|
|
virtual wxDC *GetDC();
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-03-22 05:01:57 -05:00
|
|
|
private:
|
|
|
|
wxDC *m_dc;
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-03-20 11:37:24 -05:00
|
|
|
protected:
|
2006-10-03 11:24:03 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer)
|
2006-03-20 11:37:24 -05:00
|
|
|
};
|
2006-03-27 09:01:33 -05:00
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
2006-10-03 11:24:03 -04:00
|
|
|
// wxDataViewCustomRenderer
|
2006-03-27 09:01:33 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-03-20 11:37:24 -05:00
|
|
|
|
2006-10-03 11:24:03 -04:00
|
|
|
class WXDLLIMPEXP_ADV wxDataViewCustomRenderer: public wxDataViewRenderer
|
2006-03-20 11:37:24 -05:00
|
|
|
{
|
|
|
|
public:
|
2006-10-03 11:24:03 -04:00
|
|
|
wxDataViewCustomRenderer( const wxString &varianttype = wxT("string"),
|
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-03-20 11:37:24 -05:00
|
|
|
protected:
|
2006-10-03 11:24:03 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer)
|
2006-03-20 11:37:24 -05:00
|
|
|
};
|
2006-03-27 09:01:33 -05:00
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
2006-10-03 11:24:03 -04:00
|
|
|
// wxDataViewTextRenderer
|
2006-03-27 09:01:33 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-03-20 11:37:24 -05:00
|
|
|
|
2006-10-03 11:24:03 -04:00
|
|
|
class WXDLLIMPEXP_ADV wxDataViewTextRenderer: public wxDataViewCustomRenderer
|
2006-03-20 11:37:24 -05:00
|
|
|
{
|
|
|
|
public:
|
2006-10-03 11:24:03 -04:00
|
|
|
wxDataViewTextRenderer( const wxString &varianttype = wxT("string"),
|
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
|
2006-03-20 11:37:24 -05:00
|
|
|
|
|
|
|
bool SetValue( const wxVariant &value );
|
|
|
|
bool GetValue( wxVariant &value );
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-03-22 05:01:57 -05:00
|
|
|
bool Render( wxRect cell, wxDC *dc, int state );
|
|
|
|
wxSize GetSize();
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-03-23 06:02:20 -05:00
|
|
|
private:
|
|
|
|
wxString m_text;
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-03-20 11:37:24 -05:00
|
|
|
protected:
|
2006-10-03 11:24:03 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer)
|
2006-03-20 11:37:24 -05:00
|
|
|
};
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-09-30 17:21:19 -04:00
|
|
|
// ---------------------------------------------------------
|
2006-10-03 11:24:03 -04:00
|
|
|
// wxDataViewBitmapRenderer
|
2006-09-30 17:21:19 -04:00
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
2006-10-03 11:24:03 -04:00
|
|
|
class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer: public wxDataViewCustomRenderer
|
2006-09-30 17:21:19 -04:00
|
|
|
{
|
|
|
|
public:
|
2006-10-03 11:24:03 -04:00
|
|
|
wxDataViewBitmapRenderer( const wxString &varianttype = wxT("wxBitmap"),
|
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
|
2006-09-30 17:21:19 -04:00
|
|
|
|
|
|
|
bool SetValue( const wxVariant &value );
|
|
|
|
bool GetValue( wxVariant &value );
|
|
|
|
|
|
|
|
bool Render( wxRect cell, wxDC *dc, int state );
|
|
|
|
wxSize GetSize();
|
|
|
|
|
|
|
|
private:
|
|
|
|
wxIcon m_icon;
|
|
|
|
wxBitmap m_bitmap;
|
|
|
|
|
|
|
|
protected:
|
2006-10-03 11:24:03 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer)
|
2006-09-30 17:21:19 -04:00
|
|
|
};
|
|
|
|
|
2006-03-27 09:01:33 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-10-03 11:24:03 -04:00
|
|
|
// wxDataViewToggleRenderer
|
2006-03-27 09:01:33 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-03-20 11:37:24 -05:00
|
|
|
|
2006-10-03 11:24:03 -04:00
|
|
|
class WXDLLIMPEXP_ADV wxDataViewToggleRenderer: public wxDataViewCustomRenderer
|
2006-03-20 11:37:24 -05:00
|
|
|
{
|
|
|
|
public:
|
2006-10-03 11:24:03 -04:00
|
|
|
wxDataViewToggleRenderer( const wxString &varianttype = wxT("bool"),
|
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
|
2006-03-22 05:01:57 -05:00
|
|
|
|
|
|
|
bool SetValue( const wxVariant &value );
|
|
|
|
bool GetValue( wxVariant &value );
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-03-22 05:01:57 -05:00
|
|
|
bool Render( wxRect cell, wxDC *dc, int state );
|
2006-10-03 07:09:06 -04:00
|
|
|
bool Activate( wxRect cell, wxDataViewListModel *model, unsigned int col, unsigned int row );
|
2006-03-22 05:01:57 -05:00
|
|
|
wxSize GetSize();
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-03-23 06:02:20 -05:00
|
|
|
private:
|
|
|
|
bool m_toggle;
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-03-20 11:37:24 -05:00
|
|
|
protected:
|
2006-10-03 11:24:03 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer)
|
2006-03-20 11:37:24 -05:00
|
|
|
};
|
2006-03-27 09:01:33 -05:00
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
2006-10-03 11:24:03 -04:00
|
|
|
// wxDataViewProgressRenderer
|
2006-03-27 09:01:33 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-03-20 11:37:24 -05:00
|
|
|
|
2006-10-03 11:24:03 -04:00
|
|
|
class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewCustomRenderer
|
2006-03-20 11:37:24 -05:00
|
|
|
{
|
|
|
|
public:
|
2006-10-03 11:24:03 -04:00
|
|
|
wxDataViewProgressRenderer( const wxString &label = wxEmptyString,
|
|
|
|
const wxString &varianttype = wxT("long"),
|
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
|
|
|
|
virtual ~wxDataViewProgressRenderer();
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-03-20 11:37:24 -05:00
|
|
|
bool SetValue( const wxVariant &value );
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-03-20 11:37:24 -05:00
|
|
|
virtual bool Render( wxRect cell, wxDC *dc, int state );
|
|
|
|
virtual wxSize GetSize();
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-03-20 11:37:24 -05:00
|
|
|
private:
|
|
|
|
wxString m_label;
|
|
|
|
int m_value;
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-03-20 11:37:24 -05:00
|
|
|
protected:
|
2006-10-03 11:24:03 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer)
|
2006-03-20 11:37:24 -05:00
|
|
|
};
|
2006-03-27 09:01:33 -05:00
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
2006-10-03 11:24:03 -04:00
|
|
|
// wxDataViewDateRenderer
|
2006-03-27 09:01:33 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-03-20 11:37:24 -05:00
|
|
|
|
2006-10-03 11:24:03 -04:00
|
|
|
class WXDLLIMPEXP_ADV wxDataViewDateRenderer: public wxDataViewCustomRenderer
|
2006-03-20 11:37:24 -05:00
|
|
|
{
|
|
|
|
public:
|
2006-10-03 11:24:03 -04:00
|
|
|
wxDataViewDateRenderer( const wxString &varianttype = wxT("datetime"),
|
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE );
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-03-20 11:37:24 -05:00
|
|
|
bool SetValue( const wxVariant &value );
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-03-20 11:37:24 -05:00
|
|
|
virtual bool Render( wxRect cell, wxDC *dc, int state );
|
|
|
|
virtual wxSize GetSize();
|
|
|
|
virtual bool Activate( wxRect cell,
|
2006-10-03 07:09:06 -04:00
|
|
|
wxDataViewListModel *model, unsigned int col, unsigned int row );
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-03-20 11:37:24 -05:00
|
|
|
private:
|
|
|
|
wxDateTime m_date;
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-03-20 11:37:24 -05:00
|
|
|
protected:
|
2006-10-03 11:24:03 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer)
|
2006-03-20 11:37:24 -05:00
|
|
|
};
|
2006-03-27 09:01:33 -05:00
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
2006-03-20 11:37:24 -05:00
|
|
|
// wxDataViewColumn
|
2006-03-27 09:01:33 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-03-20 11:37:24 -05:00
|
|
|
|
2006-05-17 21:22:06 -04:00
|
|
|
class WXDLLIMPEXP_ADV wxDataViewColumn: public wxDataViewColumnBase
|
2006-03-20 11:37:24 -05:00
|
|
|
{
|
|
|
|
public:
|
2006-10-03 11:24:03 -04:00
|
|
|
wxDataViewColumn( const wxString &title, wxDataViewRenderer *renderer, unsigned int model_column,
|
2006-10-01 17:09:56 -04:00
|
|
|
int width = 80, int flags = wxDATAVIEW_COL_RESIZABLE );
|
2006-10-05 15:06:21 -04:00
|
|
|
wxDataViewColumn( const wxBitmap &bitmap, wxDataViewRenderer *renderer, unsigned int model_column,
|
|
|
|
int width = 80, int flags = wxDATAVIEW_COL_RESIZABLE );
|
2006-03-20 11:37:24 -05:00
|
|
|
virtual ~wxDataViewColumn();
|
|
|
|
|
|
|
|
virtual void SetTitle( const wxString &title );
|
2006-10-05 15:35:23 -04:00
|
|
|
virtual void SetBitmap( const wxBitmap &bitmap );
|
|
|
|
|
|
|
|
virtual void SetAlignment( wxAlignment align );
|
2006-10-06 05:50:45 -04:00
|
|
|
|
|
|
|
virtual void SetSortable( bool sortable );
|
|
|
|
virtual bool GetSortable();
|
2006-10-05 15:35:23 -04:00
|
|
|
virtual void SetSortOrder( bool ascending );
|
2006-10-06 05:50:45 -04:00
|
|
|
virtual bool IsSortOrderAscending();
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-04-18 19:14:36 -04:00
|
|
|
virtual int GetWidth();
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-03-20 11:37:24 -05:00
|
|
|
private:
|
2006-04-18 19:14:36 -04:00
|
|
|
int m_width;
|
|
|
|
int m_fixedWidth;
|
2006-03-20 11:37:24 -05:00
|
|
|
|
|
|
|
protected:
|
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumn)
|
|
|
|
};
|
|
|
|
|
2006-03-27 09:01:33 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-03-20 11:37:24 -05:00
|
|
|
// wxDataViewCtrl
|
2006-03-27 09:01:33 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-03-20 11:37:24 -05:00
|
|
|
|
2006-05-17 21:22:06 -04:00
|
|
|
class WXDLLIMPEXP_ADV wxDataViewCtrl: public wxDataViewCtrlBase,
|
2006-03-20 11:37:24 -05:00
|
|
|
public wxScrollHelperNative
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDataViewCtrl() : wxScrollHelperNative(this)
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
}
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-03-20 11:37:24 -05:00
|
|
|
wxDataViewCtrl( wxWindow *parent, wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize, long style = 0,
|
2006-03-27 09:01:33 -05:00
|
|
|
const wxValidator& validator = wxDefaultValidator )
|
2006-03-21 07:30:06 -05:00
|
|
|
: wxScrollHelperNative(this)
|
2006-03-20 11:37:24 -05:00
|
|
|
{
|
|
|
|
Create(parent, id, pos, size, style, validator );
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~wxDataViewCtrl();
|
|
|
|
|
|
|
|
void Init();
|
|
|
|
|
|
|
|
bool Create(wxWindow *parent, wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize, long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator );
|
|
|
|
|
|
|
|
virtual bool AssociateModel( wxDataViewListModel *model );
|
|
|
|
virtual bool AppendColumn( wxDataViewColumn *col );
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-10-03 07:39:08 -04:00
|
|
|
virtual void SetSelection( int row ); // -1 for unselect
|
|
|
|
virtual void SetSelectionRange( unsigned int from, unsigned int to );
|
|
|
|
virtual void SetSelections( const wxArrayInt& aSelections);
|
2006-10-03 13:28:19 -04:00
|
|
|
virtual void Unselect( unsigned int row );
|
2006-10-03 07:39:08 -04:00
|
|
|
|
|
|
|
virtual bool IsSelected( unsigned int row ) const;
|
|
|
|
virtual int GetSelection() const;
|
|
|
|
virtual int GetSelections(wxArrayInt& aSelections) const;
|
|
|
|
|
2006-03-20 11:37:24 -05:00
|
|
|
private:
|
2006-03-21 07:30:06 -05:00
|
|
|
friend class wxDataViewMainWindow;
|
2006-03-22 05:01:57 -05:00
|
|
|
friend class wxDataViewHeaderWindow;
|
2006-03-20 11:37:24 -05:00
|
|
|
wxDataViewListModelNotifier *m_notifier;
|
2006-03-21 07:30:06 -05:00
|
|
|
wxDataViewMainWindow *m_clientArea;
|
|
|
|
wxDataViewHeaderWindow *m_headerArea;
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-03-20 11:37:24 -05:00
|
|
|
private:
|
2006-03-21 07:30:06 -05:00
|
|
|
void OnSize( wxSizeEvent &event );
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-03-20 11:37:24 -05:00
|
|
|
// we need to return a special WM_GETDLGCODE value to process just the
|
|
|
|
// arrows but let the other navigation characters through
|
|
|
|
#ifdef __WXMSW__
|
|
|
|
virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
|
|
|
|
#endif // __WXMSW__
|
|
|
|
|
|
|
|
WX_FORWARD_TO_SCROLL_HELPER()
|
2006-03-21 07:30:06 -05:00
|
|
|
|
2006-03-20 11:37:24 -05:00
|
|
|
private:
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxDataViewCtrl)
|
|
|
|
DECLARE_NO_COPY_CLASS(wxDataViewCtrl)
|
2006-03-21 07:30:06 -05:00
|
|
|
DECLARE_EVENT_TABLE()
|
2006-03-20 11:37:24 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // __GENERICDATAVIEWCTRLH__
|