2006-02-21 12:35:19 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/gtk/dataview.h
|
|
|
|
// Purpose: wxDataViewCtrl GTK+2 implementation header
|
|
|
|
// Author: Robert Roebling
|
|
|
|
// Id: $Id$
|
|
|
|
// Copyright: (c) 1998 Robert Roebling
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef __GTKDATAVIEWCTRLH__
|
|
|
|
#define __GTKDATAVIEWCTRLH__
|
|
|
|
|
|
|
|
#include "wx/defs.h"
|
|
|
|
#include "wx/object.h"
|
|
|
|
#include "wx/list.h"
|
|
|
|
#include "wx/control.h"
|
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
// classes
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_CORE wxDataViewCtrl;
|
|
|
|
|
2007-02-17 07:32:38 -05:00
|
|
|
|
2006-02-22 21:04:46 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-10-03 11:24:03 -04:00
|
|
|
// wxDataViewRenderer
|
2006-02-22 21:04:46 -05:00
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
2006-10-03 11:24:03 -04:00
|
|
|
class wxDataViewRenderer: public wxDataViewRendererBase
|
2006-02-22 21:04:46 -05:00
|
|
|
{
|
|
|
|
public:
|
2007-02-17 07:32:38 -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-02-22 21:04:46 -05:00
|
|
|
|
|
|
|
// implementation
|
2007-02-23 02:57:46 -05:00
|
|
|
GtkWidget* GetGtkHandle() { return m_renderer; }
|
|
|
|
|
|
|
|
virtual void SetMode( wxDataViewCellMode mode );
|
|
|
|
virtual wxDataViewCellMode GetMode() const;
|
|
|
|
|
|
|
|
virtual void SetAlignment( int align );
|
|
|
|
virtual int GetAlignment() const;
|
2006-02-22 21:04:46 -05:00
|
|
|
|
|
|
|
protected:
|
2007-02-23 02:57:46 -05:00
|
|
|
GtkWidget *m_renderer;
|
2006-02-22 21:04:46 -05:00
|
|
|
|
|
|
|
protected:
|
2006-10-03 11:24:03 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer)
|
2006-02-22 21:04:46 -05:00
|
|
|
};
|
2007-02-23 02:57:46 -05:00
|
|
|
|
2006-02-22 21:04:46 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-10-03 11:24:03 -04:00
|
|
|
// wxDataViewTextRenderer
|
2006-02-22 21:04:46 -05:00
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
2006-10-03 11:24:03 -04:00
|
|
|
class wxDataViewTextRenderer: public wxDataViewRenderer
|
2006-02-22 21:04:46 -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-02-22 21:04:46 -05:00
|
|
|
|
2006-02-22 22:04:15 -05:00
|
|
|
bool SetValue( const wxVariant &value );
|
2007-02-23 02:57:46 -05:00
|
|
|
bool GetValue( wxVariant &value ) const;
|
|
|
|
|
|
|
|
void SetAlignment( int align );
|
|
|
|
|
2006-02-22 21:04:46 -05:00
|
|
|
protected:
|
2006-10-03 11:24:03 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer)
|
2006-02-22 21:04:46 -05:00
|
|
|
};
|
|
|
|
|
2006-09-26 18:17:00 -04:00
|
|
|
// ---------------------------------------------------------
|
2006-10-03 11:24:03 -04:00
|
|
|
// wxDataViewBitmapRenderer
|
2006-09-26 18:17:00 -04:00
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
2006-10-03 11:24:03 -04:00
|
|
|
class wxDataViewBitmapRenderer: public wxDataViewRenderer
|
2006-09-26 18:17:00 -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-26 18:17:00 -04:00
|
|
|
|
|
|
|
bool SetValue( const wxVariant &value );
|
2007-02-23 02:57:46 -05:00
|
|
|
bool GetValue( wxVariant &value ) const;
|
2006-09-26 18:17:00 -04:00
|
|
|
|
|
|
|
protected:
|
2006-10-03 11:24:03 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer)
|
2006-09-26 18:17:00 -04:00
|
|
|
};
|
|
|
|
|
2006-02-24 08:19:23 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-10-03 11:24:03 -04:00
|
|
|
// wxDataViewToggleRenderer
|
2006-02-24 08:19:23 -05:00
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
2006-10-03 11:24:03 -04:00
|
|
|
class wxDataViewToggleRenderer: public wxDataViewRenderer
|
2006-02-24 08:19:23 -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-02-24 08:19:23 -05:00
|
|
|
|
|
|
|
bool SetValue( const wxVariant &value );
|
2007-02-23 02:57:46 -05:00
|
|
|
bool GetValue( wxVariant &value ) const;
|
2006-02-24 08:19:23 -05:00
|
|
|
|
|
|
|
protected:
|
2006-10-03 11:24:03 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer)
|
2006-02-24 08:19:23 -05:00
|
|
|
};
|
|
|
|
|
2006-02-24 13:19:55 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-10-03 11:24:03 -04:00
|
|
|
// wxDataViewCustomRenderer
|
2006-02-24 13:19:55 -05:00
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
2006-10-03 11:24:03 -04:00
|
|
|
class wxDataViewCustomRenderer: public wxDataViewRenderer
|
2006-02-24 13:19:55 -05:00
|
|
|
{
|
|
|
|
public:
|
2006-10-03 11:24:03 -04:00
|
|
|
wxDataViewCustomRenderer( const wxString &varianttype = wxT("string"),
|
|
|
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
2007-02-23 02:57:46 -05:00
|
|
|
int align = wxDVR_DEFAULT_ALIGNMENT,
|
2006-10-03 11:24:03 -04:00
|
|
|
bool no_init = false );
|
|
|
|
virtual ~wxDataViewCustomRenderer();
|
2007-02-23 02:57:46 -05:00
|
|
|
|
|
|
|
|
2006-02-24 13:19:55 -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;
|
|
|
|
|
2006-02-26 10:48:42 -05:00
|
|
|
virtual bool Activate( wxRect cell,
|
2006-10-03 07:09:06 -04:00
|
|
|
wxDataViewListModel *model, unsigned int col, unsigned int row )
|
2006-02-26 10:48:42 -05:00
|
|
|
{ return false; }
|
2007-02-23 02:57:46 -05:00
|
|
|
|
2006-02-26 10:48:42 -05:00
|
|
|
virtual bool LeftClick( wxPoint cursor, wxRect cell,
|
2006-10-03 07:09:06 -04:00
|
|
|
wxDataViewListModel *model, unsigned int col, unsigned int row )
|
2006-02-26 10:48:42 -05:00
|
|
|
{ return false; }
|
|
|
|
virtual bool RightClick( wxPoint cursor, wxRect cell,
|
2006-10-03 07:09:06 -04:00
|
|
|
wxDataViewListModel *model, unsigned int col, unsigned int row )
|
2006-02-26 10:48:42 -05:00
|
|
|
{ return false; }
|
|
|
|
virtual bool StartDrag( wxPoint cursor, wxRect cell,
|
2006-10-03 07:09:06 -04:00
|
|
|
wxDataViewListModel *model, unsigned int col, unsigned int row )
|
2006-02-26 10:48:42 -05:00
|
|
|
{ return false; }
|
2006-02-24 13:19:55 -05:00
|
|
|
|
|
|
|
// Create DC on request
|
|
|
|
virtual wxDC *GetDC();
|
|
|
|
|
2007-02-23 02:57:46 -05:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
bool Init(wxDataViewCellMode mode, int align);
|
|
|
|
|
2006-02-24 13:19:55 -05:00
|
|
|
private:
|
|
|
|
wxDC *m_dc;
|
|
|
|
|
|
|
|
protected:
|
2006-10-03 11:24:03 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer)
|
2006-02-24 13:19:55 -05:00
|
|
|
};
|
|
|
|
|
2006-02-25 08:13:05 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-10-03 11:24:03 -04:00
|
|
|
// wxDataViewProgressRenderer
|
2006-02-25 08:13:05 -05:00
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
2006-10-03 11:24:03 -04:00
|
|
|
class wxDataViewProgressRenderer: public wxDataViewCustomRenderer
|
2006-02-25 08:13:05 -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-02-25 08:13:05 -05:00
|
|
|
|
|
|
|
bool SetValue( const wxVariant &value );
|
2007-02-23 02:57:46 -05:00
|
|
|
bool GetValue( wxVariant &value ) const;
|
2006-02-25 08:13:05 -05:00
|
|
|
|
|
|
|
virtual bool Render( wxRect cell, wxDC *dc, int state );
|
2007-02-23 02:57:46 -05:00
|
|
|
virtual wxSize GetSize() const;
|
2006-02-25 08:13:05 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
wxString m_label;
|
|
|
|
int m_value;
|
|
|
|
|
|
|
|
protected:
|
2006-10-03 11:24:03 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer)
|
2006-02-25 08:13:05 -05:00
|
|
|
};
|
|
|
|
|
2006-02-26 10:48:42 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-10-03 11:24:03 -04:00
|
|
|
// wxDataViewDateRenderer
|
2006-02-26 10:48:42 -05:00
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
2006-10-03 11:24:03 -04:00
|
|
|
class wxDataViewDateRenderer: public wxDataViewCustomRenderer
|
2006-02-26 10:48:42 -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-02-26 10:48:42 -05:00
|
|
|
|
|
|
|
bool SetValue( const wxVariant &value );
|
2007-02-23 02:57:46 -05:00
|
|
|
bool GetValue( wxVariant &value ) const;
|
2006-02-26 10:48:42 -05:00
|
|
|
|
|
|
|
virtual bool Render( wxRect cell, wxDC *dc, int state );
|
2007-02-23 02:57:46 -05:00
|
|
|
virtual wxSize GetSize() const;
|
2006-02-26 10:48:42 -05:00
|
|
|
virtual bool Activate( wxRect cell,
|
2006-10-03 07:09:06 -04:00
|
|
|
wxDataViewListModel *model, unsigned int col, unsigned int row );
|
2006-02-26 10:48:42 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
wxDateTime m_date;
|
|
|
|
|
|
|
|
protected:
|
2006-10-03 11:24:03 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer)
|
2006-02-26 10:48:42 -05:00
|
|
|
};
|
|
|
|
|
2006-02-21 19:19:04 -05:00
|
|
|
// ---------------------------------------------------------
|
|
|
|
// wxDataViewColumn
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_CORE wxDataViewColumn: public wxDataViewColumnBase
|
|
|
|
{
|
|
|
|
public:
|
2007-02-17 07:32:38 -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 );
|
|
|
|
wxDataViewColumn( const wxBitmap &bitmap, wxDataViewRenderer *renderer,
|
|
|
|
unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH,
|
|
|
|
wxAlignment align = wxALIGN_CENTER,
|
|
|
|
int flags = wxDATAVIEW_COL_RESIZABLE );
|
|
|
|
|
2006-02-21 19:19:04 -05:00
|
|
|
virtual ~wxDataViewColumn();
|
|
|
|
|
2007-02-23 02:57:46 -05:00
|
|
|
|
|
|
|
// setters:
|
|
|
|
|
2006-02-21 19:19:04 -05:00
|
|
|
virtual void SetTitle( const wxString &title );
|
2006-10-05 15:06:21 -04:00
|
|
|
virtual void SetBitmap( const wxBitmap &bitmap );
|
2006-10-05 15:35:23 -04:00
|
|
|
|
2006-11-01 10:24:48 -05:00
|
|
|
virtual void SetOwner( wxDataViewCtrl *owner );
|
|
|
|
|
2006-10-05 15:35:23 -04:00
|
|
|
virtual void SetAlignment( wxAlignment align );
|
2006-10-06 05:50:45 -04:00
|
|
|
|
|
|
|
virtual void SetSortable( bool sortable );
|
2006-10-05 15:35:23 -04:00
|
|
|
virtual void SetSortOrder( bool ascending );
|
|
|
|
|
2007-02-23 02:57:46 -05:00
|
|
|
virtual void SetResizeable( bool resizeable );
|
|
|
|
virtual void SetHidden( bool hidden );
|
|
|
|
|
|
|
|
virtual void SetMinWidth( int minWidth );
|
|
|
|
virtual void SetWidth( int width );
|
|
|
|
|
|
|
|
|
|
|
|
// getters:
|
|
|
|
|
|
|
|
virtual wxString GetTitle() const;
|
|
|
|
virtual wxAlignment GetAlignment() const;
|
|
|
|
|
2007-02-17 07:32:38 -05:00
|
|
|
virtual bool IsSortable() const;
|
|
|
|
virtual bool IsSortOrderAscending() const;
|
2007-02-23 02:57:46 -05:00
|
|
|
virtual bool IsResizeable() const;
|
|
|
|
virtual bool IsHidden() const;
|
2007-02-17 07:32:38 -05:00
|
|
|
|
|
|
|
virtual int GetWidth() const;
|
2007-02-23 02:57:46 -05:00
|
|
|
virtual int GetMinWidth() const;
|
|
|
|
|
2006-02-21 19:19:04 -05:00
|
|
|
// implementation
|
2007-02-23 02:57:46 -05:00
|
|
|
GtkWidget* GetGtkHandle() { return m_column; }
|
2006-02-21 19:19:04 -05:00
|
|
|
|
|
|
|
private:
|
2006-02-22 21:04:46 -05:00
|
|
|
// holds the GTK handle
|
2007-02-23 02:57:46 -05:00
|
|
|
GtkWidget *m_column;
|
2006-10-06 05:50:45 -04:00
|
|
|
|
|
|
|
// delayed connection to mouse events
|
|
|
|
friend class wxDataViewCtrl;
|
|
|
|
void OnInternalIdle();
|
2007-02-23 02:57:46 -05:00
|
|
|
bool m_isConnected;
|
|
|
|
|
|
|
|
void Init(wxAlignment align, int flags, int width);
|
|
|
|
|
2006-02-21 19:19:04 -05:00
|
|
|
protected:
|
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumn)
|
|
|
|
};
|
|
|
|
|
2006-02-21 12:35:19 -05:00
|
|
|
// ---------------------------------------------------------
|
|
|
|
// wxDataViewCtrl
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_CORE wxDataViewCtrl: public wxDataViewCtrlBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDataViewCtrl()
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
}
|
|
|
|
|
|
|
|
wxDataViewCtrl( wxWindow *parent, wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize, long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator )
|
|
|
|
{
|
|
|
|
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 );
|
|
|
|
|
2006-02-21 15:52:05 -05:00
|
|
|
virtual bool AssociateModel( wxDataViewListModel *model );
|
2006-02-25 09:07:06 -05:00
|
|
|
virtual bool AppendColumn( wxDataViewColumn *col );
|
|
|
|
|
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-11-01 10:24:48 -05:00
|
|
|
|
|
|
|
static wxVisualAttributes
|
|
|
|
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
|
2006-10-03 07:39:08 -04:00
|
|
|
|
2006-02-25 09:07:06 -05:00
|
|
|
private:
|
|
|
|
friend class wxDataViewCtrlDC;
|
2006-10-06 05:50:45 -04:00
|
|
|
friend class wxDataViewColumn;
|
2006-02-27 09:18:24 -05:00
|
|
|
friend class wxGtkDataViewListModelNotifier;
|
2006-02-28 10:04:25 -05:00
|
|
|
GtkWidget *m_treeview;
|
|
|
|
wxDataViewListModelNotifier *m_notifier;
|
2006-02-21 12:35:19 -05:00
|
|
|
|
2006-10-06 05:50:45 -04:00
|
|
|
virtual void OnInternalIdle();
|
|
|
|
|
2006-02-21 12:35:19 -05:00
|
|
|
private:
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxDataViewCtrl)
|
|
|
|
DECLARE_NO_COPY_CLASS(wxDataViewCtrl)
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // __GTKDATAVIEWCTRLH__
|