2006-03-20 11:37:24 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/generic/dataview.h
|
|
|
|
// Purpose: wxDataViewCtrl generic implementation header
|
|
|
|
// Author: Robert Roebling
|
2007-08-19 15:03:01 -04:00
|
|
|
// Modified By: Bo Yang
|
2006-03-20 11:37:24 -05:00
|
|
|
// 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
|
|
|
|
2007-07-09 06:09:52 -04:00
|
|
|
class WXDLLIMPEXP_FWD_ADV wxDataViewCtrl;
|
|
|
|
class WXDLLIMPEXP_FWD_ADV wxDataViewMainWindow;
|
|
|
|
class WXDLLIMPEXP_FWD_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:
|
2008-12-07 09:47:55 -05:00
|
|
|
wxDataViewRenderer( const wxString &varianttype,
|
2007-02-23 02:57:46 -05:00
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
|
|
|
int align = wxDVR_DEFAULT_ALIGNMENT );
|
2006-10-03 11:24:03 -04:00
|
|
|
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;
|
2007-02-23 02:57:46 -05:00
|
|
|
virtual wxSize GetSize() const = 0;
|
|
|
|
|
2008-04-08 07:17:54 -04:00
|
|
|
virtual void SetAlignment( int align );
|
|
|
|
virtual int GetAlignment() const;
|
2007-02-23 02:57:46 -05:00
|
|
|
|
|
|
|
virtual void SetMode( wxDataViewCellMode mode )
|
|
|
|
{ m_mode=mode; }
|
|
|
|
virtual wxDataViewCellMode GetMode() const
|
|
|
|
{ return m_mode; }
|
2006-03-27 09:01:33 -05:00
|
|
|
|
|
|
|
virtual bool Activate( wxRect WXUNUSED(cell),
|
2007-07-09 06:38:22 -04:00
|
|
|
wxDataViewModel *WXUNUSED(model),
|
2008-12-07 09:47:55 -05:00
|
|
|
const wxDataViewItem & WXUNUSED(item),
|
2007-07-09 06:38:22 -04:00
|
|
|
unsigned int WXUNUSED(col) )
|
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),
|
2007-07-09 06:38:22 -04:00
|
|
|
wxDataViewModel *WXUNUSED(model),
|
2008-12-07 09:47:55 -05:00
|
|
|
const wxDataViewItem & WXUNUSED(item),
|
2007-07-09 06:38:22 -04:00
|
|
|
unsigned int WXUNUSED(col) )
|
2006-03-27 09:01:33 -05:00
|
|
|
{ return false; }
|
|
|
|
virtual bool RightClick( wxPoint WXUNUSED(cursor),
|
|
|
|
wxRect WXUNUSED(cell),
|
2007-07-09 06:38:22 -04:00
|
|
|
wxDataViewModel *WXUNUSED(model),
|
2008-12-07 09:47:55 -05:00
|
|
|
const wxDataViewItem & WXUNUSED(item),
|
2007-07-09 06:38:22 -04:00
|
|
|
unsigned int WXUNUSED(col) )
|
2006-03-27 09:01:33 -05:00
|
|
|
{ return false; }
|
|
|
|
virtual bool StartDrag( wxPoint WXUNUSED(cursor),
|
|
|
|
wxRect WXUNUSED(cell),
|
2007-07-09 06:38:22 -04:00
|
|
|
wxDataViewModel *WXUNUSED(model),
|
2008-12-07 09:47:55 -05:00
|
|
|
const wxDataViewItem & WXUNUSED(item),
|
2007-07-09 06:38:22 -04:00
|
|
|
unsigned int WXUNUSED(col) )
|
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();
|
2008-12-07 09:47:55 -05:00
|
|
|
|
2007-11-08 17:51:58 -05:00
|
|
|
void SetHasAttr( bool set ) { m_hasAttr = set; }
|
|
|
|
void SetAttr( const wxDataViewItemAttr &attr ) { m_attr = attr; }
|
2009-03-05 19:05:05 -05:00
|
|
|
bool GetWantsAttr() const { return m_wantsAttr; }
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2008-04-08 07:17:54 -04:00
|
|
|
// implementation
|
|
|
|
int CalculateAlignment() const;
|
|
|
|
|
2006-03-22 05:01:57 -05:00
|
|
|
private:
|
2007-04-16 08:45:25 -04:00
|
|
|
wxDC *m_dc;
|
|
|
|
int m_align;
|
|
|
|
wxDataViewCellMode m_mode;
|
2008-12-07 09:47:55 -05:00
|
|
|
|
2007-11-08 17:51:58 -05:00
|
|
|
protected:
|
|
|
|
bool m_wantsAttr;
|
|
|
|
bool m_hasAttr;
|
|
|
|
wxDataViewItemAttr m_attr;
|
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"),
|
2007-02-23 02:57:46 -05:00
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
|
|
|
int align = wxDVR_DEFAULT_ALIGNMENT );
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2007-10-20 16:09:10 -04:00
|
|
|
void RenderText( const wxString &text, int xoffset, wxRect cell, wxDC *dc, int state );
|
|
|
|
|
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
|
|
|
|
2007-04-16 08:45:25 -04: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"),
|
2007-02-23 02:57:46 -05:00
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
|
|
|
int align = wxDVR_DEFAULT_ALIGNMENT );
|
2006-03-20 11:37:24 -05:00
|
|
|
|
|
|
|
bool SetValue( const wxVariant &value );
|
2007-02-23 02:57:46 -05:00
|
|
|
bool GetValue( wxVariant &value ) const;
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-03-22 05:01:57 -05:00
|
|
|
bool Render( wxRect cell, wxDC *dc, int state );
|
2007-02-23 02:57:46 -05:00
|
|
|
wxSize GetSize() const;
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2007-04-16 08:45:25 -04:00
|
|
|
// in-place editing
|
2009-03-05 19:05:05 -05:00
|
|
|
virtual bool HasEditorCtrl() const;
|
|
|
|
virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect,
|
|
|
|
const wxVariant &value );
|
2007-04-16 08:45:25 -04:00
|
|
|
virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value );
|
2008-12-07 09:47:55 -05:00
|
|
|
|
2007-11-08 17:51:58 -05:00
|
|
|
protected:
|
2007-04-16 08:45:25 -04:00
|
|
|
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
|
|
|
|
2007-11-08 17:51:58 -05:00
|
|
|
// ---------------------------------------------------------
|
|
|
|
// wxDataViewTextRendererAttr
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_ADV wxDataViewTextRendererAttr: public wxDataViewTextRenderer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDataViewTextRendererAttr( const wxString &varianttype = wxT("string"),
|
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
|
|
|
int align = wxDVR_DEFAULT_ALIGNMENT );
|
|
|
|
|
|
|
|
bool Render( wxRect cell, wxDC *dc, int state );
|
2008-12-07 09:47:55 -05:00
|
|
|
|
2007-11-08 17:51:58 -05:00
|
|
|
protected:
|
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRendererAttr)
|
|
|
|
};
|
|
|
|
|
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"),
|
2007-02-23 02:57:46 -05:00
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
|
|
|
int align = wxDVR_DEFAULT_ALIGNMENT );
|
2006-09-30 17:21:19 -04:00
|
|
|
|
|
|
|
bool SetValue( const wxVariant &value );
|
2007-02-23 02:57:46 -05:00
|
|
|
bool GetValue( wxVariant &value ) const;
|
2006-09-30 17:21:19 -04:00
|
|
|
|
|
|
|
bool Render( wxRect cell, wxDC *dc, int state );
|
2007-02-23 02:57:46 -05:00
|
|
|
wxSize GetSize() const;
|
2006-09-30 17:21:19 -04:00
|
|
|
|
|
|
|
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"),
|
2007-02-23 02:57:46 -05:00
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
|
|
|
int align = wxDVR_DEFAULT_ALIGNMENT );
|
2006-03-22 05:01:57 -05:00
|
|
|
|
|
|
|
bool SetValue( const wxVariant &value );
|
2007-02-23 02:57:46 -05:00
|
|
|
bool GetValue( wxVariant &value ) const;
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-03-22 05:01:57 -05:00
|
|
|
bool Render( wxRect cell, wxDC *dc, int state );
|
2008-12-07 09:47:55 -05:00
|
|
|
bool Activate( wxRect cell, wxDataViewModel *model, const wxDataViewItem & item,
|
2007-07-09 06:38:22 -04:00
|
|
|
unsigned int col );
|
2007-02-23 02:57:46 -05:00
|
|
|
wxSize GetSize() const;
|
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"),
|
2007-02-23 02:57:46 -05:00
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
|
|
|
int align = wxDVR_DEFAULT_ALIGNMENT );
|
2006-10-03 11:24:03 -04:00
|
|
|
virtual ~wxDataViewProgressRenderer();
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-03-20 11:37:24 -05:00
|
|
|
bool SetValue( const wxVariant &value );
|
2007-02-23 02:57:46 -05:00
|
|
|
bool GetValue( wxVariant& value ) const;
|
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 );
|
2007-02-23 02:57:46 -05:00
|
|
|
virtual wxSize GetSize() const;
|
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
|
|
|
};
|
2008-12-07 09:47:55 -05:00
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
2007-08-29 16:29:59 -04:00
|
|
|
// wxDataViewIconTextRenderer
|
2008-12-07 09:47:55 -05:00
|
|
|
// ---------------------------------------------------------
|
2007-08-29 16:29:59 -04:00
|
|
|
|
2008-03-17 17:00:06 -04:00
|
|
|
class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewCustomRenderer
|
2007-08-29 16:29:59 -04:00
|
|
|
{
|
|
|
|
public:
|
2008-12-07 09:47:55 -05:00
|
|
|
wxDataViewIconTextRenderer( const wxString &varianttype = wxT("wxDataViewIconText"),
|
2007-08-29 16:29:59 -04:00
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
|
|
|
int align = wxDVR_DEFAULT_ALIGNMENT );
|
|
|
|
virtual ~wxDataViewIconTextRenderer();
|
2008-12-07 09:47:55 -05:00
|
|
|
|
2007-08-29 16:29:59 -04:00
|
|
|
bool SetValue( const wxVariant &value );
|
|
|
|
bool GetValue( wxVariant &value ) const;
|
2008-12-07 09:47:55 -05:00
|
|
|
|
2007-08-29 16:29:59 -04:00
|
|
|
virtual bool Render( wxRect cell, wxDC *dc, int state );
|
|
|
|
virtual wxSize GetSize() const;
|
2008-12-07 09:47:55 -05:00
|
|
|
|
2009-03-06 14:07:40 -05:00
|
|
|
virtual bool HasEditorCtrl() const { return true; }
|
2009-03-05 19:05:05 -05:00
|
|
|
virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect,
|
|
|
|
const wxVariant &value );
|
2007-08-29 16:29:59 -04:00
|
|
|
virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value );
|
2008-12-07 09:47:55 -05:00
|
|
|
|
2007-08-29 16:29:59 -04:00
|
|
|
private:
|
|
|
|
wxDataViewIconText m_value;
|
2008-12-07 09:47:55 -05:00
|
|
|
|
2007-08-29 16:29:59 -04:00
|
|
|
protected:
|
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer)
|
|
|
|
};
|
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"),
|
2007-02-23 02:57:46 -05:00
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
|
|
|
|
int align = wxDVR_DEFAULT_ALIGNMENT );
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2006-03-20 11:37:24 -05:00
|
|
|
bool SetValue( const wxVariant &value );
|
2007-02-23 02:57:46 -05:00
|
|
|
bool GetValue( wxVariant& value ) const;
|
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 );
|
2007-02-23 02:57:46 -05:00
|
|
|
virtual wxSize GetSize() const;
|
2006-03-20 11:37:24 -05:00
|
|
|
virtual bool Activate( wxRect cell,
|
2009-03-05 19:05:05 -05:00
|
|
|
wxDataViewModel *model,
|
|
|
|
const wxDataViewItem& item,
|
|
|
|
unsigned int col );
|
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
|
|
|
|
2008-12-03 16:53:10 -05:00
|
|
|
class WXDLLIMPEXP_ADV wxDataViewColumn : public wxDataViewColumnBase
|
2006-03-20 11:37:24 -05:00
|
|
|
{
|
|
|
|
public:
|
2008-12-07 09:47:55 -05:00
|
|
|
wxDataViewColumn(const wxString& title,
|
|
|
|
wxDataViewRenderer *renderer,
|
|
|
|
unsigned int model_column,
|
|
|
|
int width = wxDVC_DEFAULT_WIDTH,
|
|
|
|
wxAlignment align = wxALIGN_CENTER,
|
|
|
|
int flags = wxDATAVIEW_COL_RESIZABLE)
|
|
|
|
: wxDataViewColumnBase(renderer, model_column),
|
|
|
|
m_title(title)
|
|
|
|
{
|
|
|
|
Init(width, align, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
wxDataViewColumn(const wxBitmap& bitmap,
|
|
|
|
wxDataViewRenderer *renderer,
|
|
|
|
unsigned int model_column,
|
|
|
|
int width = wxDVC_DEFAULT_WIDTH,
|
|
|
|
wxAlignment align = wxALIGN_CENTER,
|
|
|
|
int flags = wxDATAVIEW_COL_RESIZABLE)
|
|
|
|
: wxDataViewColumnBase(bitmap, renderer, model_column)
|
|
|
|
{
|
|
|
|
Init(width, align, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
// implement wxHeaderColumnBase methods
|
|
|
|
virtual void SetTitle(const wxString& title) { m_title = title; }
|
|
|
|
virtual wxString GetTitle() const { return m_title; }
|
|
|
|
|
|
|
|
virtual void SetWidth(int width) { m_width = width; }
|
|
|
|
virtual int GetWidth() const { return m_width; }
|
|
|
|
|
|
|
|
virtual void SetMinWidth(int minWidth) { m_minWidth = minWidth; }
|
|
|
|
virtual int GetMinWidth() const { return m_minWidth; }
|
|
|
|
|
|
|
|
virtual void SetAlignment(wxAlignment align) { m_align = align; }
|
|
|
|
virtual wxAlignment GetAlignment() const { return m_align; }
|
|
|
|
|
|
|
|
virtual void SetFlags(int flags) { m_flags = flags; }
|
|
|
|
virtual int GetFlags() const { return m_flags; }
|
|
|
|
|
|
|
|
virtual void SetAsSortKey(bool sort = true) { m_sort = sort; }
|
|
|
|
virtual bool IsSortKey() const { return m_sort; }
|
|
|
|
|
|
|
|
virtual void SetSortOrder(bool ascending) { m_sortAscending = ascending; }
|
|
|
|
virtual bool IsSortOrderAscending() const { return m_sortAscending; }
|
2006-03-20 11:37:24 -05:00
|
|
|
|
2008-12-03 16:53:10 -05:00
|
|
|
private:
|
2008-12-07 09:47:55 -05:00
|
|
|
// common part of all ctors
|
|
|
|
void Init(int width, wxAlignment align, int flags)
|
|
|
|
{
|
|
|
|
m_width = width == wxCOL_WIDTH_DEFAULT ? wxDVC_DEFAULT_WIDTH : width;
|
|
|
|
m_minWidth = 0;
|
|
|
|
m_align = align;
|
|
|
|
m_flags = flags;
|
|
|
|
m_sort = false;
|
|
|
|
m_sortAscending = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString m_title;
|
|
|
|
int m_width,
|
|
|
|
m_minWidth;
|
|
|
|
wxAlignment m_align;
|
|
|
|
int m_flags;
|
|
|
|
bool m_sort,
|
|
|
|
m_sortAscending;
|
|
|
|
|
2008-12-03 16:53:10 -05:00
|
|
|
friend class wxDataViewHeaderWindowBase;
|
|
|
|
friend class wxDataViewHeaderWindow;
|
|
|
|
friend class wxDataViewHeaderWindowMSW;
|
2006-03-20 11:37:24 -05:00
|
|
|
};
|
|
|
|
|
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
|
|
|
|
2007-11-01 20:05:09 -04:00
|
|
|
WX_DECLARE_LIST_WITH_DECL(wxDataViewColumn, wxDataViewColumnList,
|
|
|
|
class WXDLLIMPEXP_ADV);
|
2007-08-26 10:48:29 -04:00
|
|
|
|
2008-12-24 12:13:20 -05:00
|
|
|
class WXDLLIMPEXP_ADV wxDataViewCtrl : public wxDataViewCtrlBase,
|
|
|
|
public wxScrollHelper
|
2006-03-20 11:37:24 -05:00
|
|
|
{
|
2007-02-17 07:32:38 -05:00
|
|
|
friend class wxDataViewMainWindow;
|
|
|
|
friend class wxDataViewHeaderWindowBase;
|
|
|
|
friend class wxDataViewHeaderWindow;
|
|
|
|
friend class wxDataViewHeaderWindowMSW;
|
2007-02-23 02:57:46 -05:00
|
|
|
friend class wxDataViewColumn;
|
2007-02-17 07:32:38 -05:00
|
|
|
|
2006-03-20 11:37:24 -05:00
|
|
|
public:
|
2008-12-24 12:13:20 -05:00
|
|
|
wxDataViewCtrl() : wxScrollHelper(this)
|
2006-03-20 11:37:24 -05:00
|
|
|
{
|
|
|
|
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 )
|
2008-12-24 12:13:20 -05:00
|
|
|
: wxScrollHelper(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,
|
2009-03-05 19:05:05 -05:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize, long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator );
|
2006-03-20 11:37:24 -05:00
|
|
|
|
2007-07-09 06:38:22 -04:00
|
|
|
virtual bool AssociateModel( wxDataViewModel *model );
|
2008-12-07 09:47:55 -05:00
|
|
|
|
2006-03-20 11:37:24 -05:00
|
|
|
virtual bool AppendColumn( wxDataViewColumn *col );
|
2007-10-18 16:56:38 -04:00
|
|
|
virtual bool PrependColumn( wxDataViewColumn *col );
|
2008-05-21 04:47:21 -04:00
|
|
|
virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col );
|
2006-03-27 09:01:33 -05:00
|
|
|
|
2007-07-12 08:58:28 -04:00
|
|
|
virtual void DoSetExpanderColumn();
|
|
|
|
virtual void DoSetIndent();
|
|
|
|
|
2007-08-26 10:48:29 -04:00
|
|
|
virtual unsigned int GetColumnCount() const;
|
|
|
|
virtual wxDataViewColumn* GetColumn( unsigned int pos ) const;
|
|
|
|
virtual bool DeleteColumn( wxDataViewColumn *column );
|
|
|
|
virtual bool ClearColumns();
|
2007-09-13 09:29:19 -04:00
|
|
|
virtual int GetColumnPosition( const wxDataViewColumn *column ) const;
|
2007-08-26 10:48:29 -04:00
|
|
|
|
2007-09-13 08:57:40 -04:00
|
|
|
virtual wxDataViewColumn *GetSortingColumn() const;
|
2008-12-07 09:47:55 -05:00
|
|
|
|
2007-08-24 07:21:52 -04:00
|
|
|
virtual wxDataViewItem GetSelection() const;
|
2007-08-19 15:03:01 -04:00
|
|
|
virtual int GetSelections( wxDataViewItemArray & sel ) const;
|
|
|
|
virtual void SetSelections( const wxDataViewItemArray & sel );
|
|
|
|
virtual void Select( const wxDataViewItem & item );
|
|
|
|
virtual void Unselect( const wxDataViewItem & item );
|
|
|
|
virtual bool IsSelected( const wxDataViewItem & item ) const;
|
|
|
|
|
2007-08-20 13:26:11 -04:00
|
|
|
virtual void SelectAll();
|
|
|
|
virtual void UnselectAll();
|
|
|
|
|
|
|
|
virtual void EnsureVisible( const wxDataViewItem & item,
|
2007-08-24 07:21:52 -04:00
|
|
|
const wxDataViewColumn *column = NULL );
|
2009-03-05 19:05:05 -05:00
|
|
|
virtual void HitTest( const wxPoint & point, wxDataViewItem & item,
|
|
|
|
wxDataViewColumn* &column ) const;
|
|
|
|
virtual wxRect GetItemRect( const wxDataViewItem & item,
|
|
|
|
const wxDataViewColumn *column = NULL ) const;
|
2007-08-20 13:26:11 -04:00
|
|
|
|
2007-08-26 10:48:29 -04:00
|
|
|
virtual void Expand( const wxDataViewItem & item );
|
|
|
|
virtual void Collapse( const wxDataViewItem & item );
|
2008-12-16 16:23:55 -05:00
|
|
|
virtual bool IsExpanded( const wxDataViewItem & item ) const;
|
2008-12-07 09:47:55 -05:00
|
|
|
|
2008-10-21 15:10:25 -04:00
|
|
|
virtual void SetFocus();
|
2009-01-23 18:55:17 -05:00
|
|
|
|
|
|
|
#if wxUSE_DRAG_AND_DROP
|
2009-01-20 14:04:03 -05:00
|
|
|
virtual bool EnableDragSource( const wxDataFormat &format );
|
|
|
|
virtual bool EnableDropTarget( const wxDataFormat &format );
|
2009-01-23 18:55:17 -05:00
|
|
|
#endif // wxUSE_DRAG_AND_DROP
|
2007-08-26 10:48:29 -04:00
|
|
|
|
2009-01-22 08:33:00 -05:00
|
|
|
virtual wxBorder GetDefaultBorder() const;
|
|
|
|
|
2009-03-08 17:41:57 -04:00
|
|
|
void StartEditor( const wxDataViewItem & item, unsigned int column );
|
|
|
|
|
2007-08-20 13:26:11 -04:00
|
|
|
protected:
|
2008-12-07 09:47:55 -05:00
|
|
|
virtual int GetSelections( wxArrayInt & sel ) const;
|
2007-08-19 15:03:01 -04:00
|
|
|
virtual void SetSelections( const wxArrayInt & sel );
|
|
|
|
virtual void Select( int row );
|
|
|
|
virtual void Unselect( int row );
|
|
|
|
virtual bool IsSelected( int row ) const;
|
|
|
|
virtual void SelectRange( int from, int to );
|
|
|
|
virtual void UnselectRange( int from, int to );
|
|
|
|
|
2007-08-24 07:21:52 -04:00
|
|
|
virtual void EnsureVisible( int row, int column );
|
2007-08-19 15:03:01 -04:00
|
|
|
|
|
|
|
virtual wxDataViewItem GetItemByRow( unsigned int row ) const;
|
|
|
|
virtual int GetRowByItem( const wxDataViewItem & item ) const;
|
|
|
|
|
2008-12-08 16:13:29 -05:00
|
|
|
int GetSortingColumnIndex() const { return m_sortingColumnIdx; }
|
|
|
|
void SetSortingColumnIndex(int idx) { m_sortingColumnIdx = idx; }
|
2006-10-03 07:39:08 -04:00
|
|
|
|
2007-02-23 02:57:46 -05:00
|
|
|
public: // utility functions not part of the API
|
|
|
|
|
2007-02-17 07:32:38 -05:00
|
|
|
// returns the "best" width for the idx-th column
|
2007-02-23 02:57:46 -05:00
|
|
|
unsigned int GetBestColumnWidth(int WXUNUSED(idx)) const
|
2007-02-17 07:32:38 -05:00
|
|
|
{
|
2007-02-23 02:57:46 -05:00
|
|
|
return GetClientSize().GetWidth() / GetColumnCount();
|
2007-02-17 07:32:38 -05:00
|
|
|
}
|
|
|
|
|
2007-12-28 18:07:30 -05:00
|
|
|
// called by header window after reorder
|
|
|
|
void ColumnMoved( wxDataViewColumn* col, unsigned int new_pos );
|
|
|
|
|
2008-12-08 09:40:42 -05:00
|
|
|
// update the display after a change to an individual column
|
|
|
|
void OnColumnChange(unsigned int idx);
|
|
|
|
|
|
|
|
// update after a change to the number of columns
|
|
|
|
void OnColumnsCountChanged();
|
2007-02-17 07:32:38 -05:00
|
|
|
|
2007-04-17 08:08:10 -04:00
|
|
|
wxWindow *GetMainWindow() { return (wxWindow*) m_clientArea; }
|
2007-04-16 08:45:25 -04:00
|
|
|
|
2008-12-10 10:56:11 -05:00
|
|
|
// return the index of the given column in m_cols
|
|
|
|
int GetColumnIndex(const wxDataViewColumn *column) const;
|
|
|
|
|
|
|
|
// return the column displayed at the given position in the control
|
|
|
|
wxDataViewColumn *GetColumnAt(unsigned int pos) const;
|
|
|
|
|
2006-03-20 11:37:24 -05:00
|
|
|
private:
|
2008-01-14 06:04:57 -05:00
|
|
|
wxDataViewColumnList m_cols;
|
|
|
|
wxDataViewModelNotifier *m_notifier;
|
|
|
|
wxDataViewMainWindow *m_clientArea;
|
|
|
|
wxDataViewHeaderWindow *m_headerArea;
|
2008-12-08 16:13:29 -05:00
|
|
|
|
|
|
|
// the index of the column currently used for sorting or -1
|
|
|
|
int m_sortingColumnIdx;
|
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 );
|
2008-10-09 15:18:28 -04:00
|
|
|
virtual wxSize GetSizeAvailableForScrollTarget(const wxSize& size);
|
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)
|
2009-02-08 06:45:59 -05:00
|
|
|
wxDECLARE_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__
|