2006-02-21 12:35:19 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/gtk/dataview.h
|
|
|
|
// Purpose: wxDataViewCtrl GTK+2 implementation header
|
|
|
|
// Author: Robert Roebling
|
|
|
|
// Copyright: (c) 1998 Robert Roebling
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2007-12-20 01:08:00 -05:00
|
|
|
#ifndef _WX_GTKDATAVIEWCTRL_H_
|
|
|
|
#define _WX_GTKDATAVIEWCTRL_H_
|
2006-02-21 12:35:19 -05:00
|
|
|
|
|
|
|
#include "wx/list.h"
|
|
|
|
|
2007-10-10 15:44:26 -04:00
|
|
|
class WXDLLIMPEXP_FWD_ADV wxDataViewCtrlInternal;
|
2006-02-21 12:35:19 -05:00
|
|
|
|
2010-08-08 07:37:37 -04:00
|
|
|
struct _GtkTreePath;
|
|
|
|
|
2008-12-07 09:19:18 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-02-21 19:19:04 -05:00
|
|
|
// wxDataViewColumn
|
2008-12-07 09:19:18 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-02-21 19:19:04 -05:00
|
|
|
|
2007-10-10 15:44:26 -04:00
|
|
|
class WXDLLIMPEXP_ADV wxDataViewColumn: public wxDataViewColumnBase
|
2006-02-21 19:19:04 -05:00
|
|
|
{
|
|
|
|
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 );
|
|
|
|
|
2007-02-23 02:57:46 -05:00
|
|
|
|
|
|
|
// setters:
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void SetTitle( const wxString &title ) wxOVERRIDE;
|
|
|
|
virtual void SetBitmap( const wxBitmap &bitmap ) wxOVERRIDE;
|
2006-10-05 15:35:23 -04:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void SetOwner( wxDataViewCtrl *owner ) wxOVERRIDE;
|
2006-11-01 10:24:48 -05:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void SetAlignment( wxAlignment align ) wxOVERRIDE;
|
2008-12-07 09:19:18 -05:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void SetSortable( bool sortable ) wxOVERRIDE;
|
|
|
|
virtual void SetSortOrder( bool ascending ) wxOVERRIDE;
|
2006-10-05 15:35:23 -04:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void SetResizeable( bool resizable ) wxOVERRIDE;
|
|
|
|
virtual void SetHidden( bool hidden ) wxOVERRIDE;
|
2007-02-23 02:57:46 -05:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void SetMinWidth( int minWidth ) wxOVERRIDE;
|
|
|
|
virtual void SetWidth( int width ) wxOVERRIDE;
|
2007-02-23 02:57:46 -05:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void SetReorderable( bool reorderable ) wxOVERRIDE;
|
2007-02-23 02:57:46 -05:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void SetFlags(int flags) wxOVERRIDE { SetIndividualFlags(flags); }
|
2008-12-03 16:53:10 -05:00
|
|
|
|
2007-02-23 02:57:46 -05:00
|
|
|
// getters:
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual wxString GetTitle() const wxOVERRIDE;
|
|
|
|
virtual wxAlignment GetAlignment() const wxOVERRIDE;
|
2007-02-23 02:57:46 -05:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool IsSortable() const wxOVERRIDE;
|
|
|
|
virtual bool IsSortOrderAscending() const wxOVERRIDE;
|
|
|
|
virtual bool IsSortKey() const wxOVERRIDE;
|
2008-12-07 09:47:55 -05:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool IsResizeable() const wxOVERRIDE;
|
|
|
|
virtual bool IsHidden() const wxOVERRIDE;
|
2007-02-17 07:32:38 -05:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual int GetWidth() const wxOVERRIDE;
|
|
|
|
virtual int GetMinWidth() const wxOVERRIDE;
|
2008-12-07 09:19:18 -05:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool IsReorderable() const wxOVERRIDE;
|
2007-02-23 02:57:46 -05:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual int GetFlags() const wxOVERRIDE { return GetFromIndividualFlags(); }
|
2008-12-03 16:53:10 -05:00
|
|
|
|
2006-02-21 19:19:04 -05:00
|
|
|
// implementation
|
2011-04-26 18:56:56 -04:00
|
|
|
GtkWidget* GetGtkHandle() const { 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;
|
2008-12-07 09:19:18 -05:00
|
|
|
|
2008-04-12 16:07:53 -04:00
|
|
|
// holds GTK handles for title/bitmap in the header
|
|
|
|
GtkWidget *m_image;
|
|
|
|
GtkWidget *m_label;
|
2008-12-07 09:19:18 -05:00
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2007-10-10 15:44:26 -04:00
|
|
|
WX_DECLARE_LIST_WITH_DECL(wxDataViewColumn, wxDataViewColumnList,
|
|
|
|
class WXDLLIMPEXP_ADV);
|
2007-08-26 06:05:16 -04:00
|
|
|
|
2008-12-07 09:19:18 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-02-21 12:35:19 -05:00
|
|
|
// wxDataViewCtrl
|
2008-12-07 09:19:18 -05:00
|
|
|
// ---------------------------------------------------------
|
2006-02-21 12:35:19 -05:00
|
|
|
|
2007-10-10 15:44:26 -04:00
|
|
|
class WXDLLIMPEXP_ADV wxDataViewCtrl: public wxDataViewCtrlBase
|
2006-02-21 12:35:19 -05:00
|
|
|
{
|
|
|
|
public:
|
2008-12-07 09:19:18 -05:00
|
|
|
wxDataViewCtrl()
|
2006-02-21 12:35:19 -05:00
|
|
|
{
|
|
|
|
Init();
|
|
|
|
}
|
2008-12-07 09:19:18 -05:00
|
|
|
|
2006-02-21 12:35:19 -05:00
|
|
|
wxDataViewCtrl( wxWindow *parent, wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize, long style = 0,
|
2010-08-08 07:37:57 -04:00
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = wxDataViewCtrlNameStr )
|
2006-02-21 12:35:19 -05:00
|
|
|
{
|
2009-10-24 17:41:30 -04:00
|
|
|
Init();
|
|
|
|
|
2010-08-08 07:37:57 -04:00
|
|
|
Create(parent, id, pos, size, style, validator, name);
|
2006-02-21 12:35:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Create(wxWindow *parent, wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize, long style = 0,
|
2010-08-08 07:37:57 -04:00
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = wxDataViewCtrlNameStr);
|
2006-02-21 12:35:19 -05:00
|
|
|
|
2009-10-24 17:41:30 -04:00
|
|
|
virtual ~wxDataViewCtrl();
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool AssociateModel( wxDataViewModel *model ) wxOVERRIDE;
|
2008-12-07 09:19:18 -05:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool PrependColumn( wxDataViewColumn *col ) wxOVERRIDE;
|
|
|
|
virtual bool AppendColumn( wxDataViewColumn *col ) wxOVERRIDE;
|
|
|
|
virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col ) wxOVERRIDE;
|
2008-12-07 09:19:18 -05:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual unsigned int GetColumnCount() const wxOVERRIDE;
|
|
|
|
virtual wxDataViewColumn* GetColumn( unsigned int pos ) const wxOVERRIDE;
|
|
|
|
virtual bool DeleteColumn( wxDataViewColumn *column ) wxOVERRIDE;
|
|
|
|
virtual bool ClearColumns() wxOVERRIDE;
|
|
|
|
virtual int GetColumnPosition( const wxDataViewColumn *column ) const wxOVERRIDE;
|
2007-07-14 09:54:14 -04:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual wxDataViewColumn *GetSortingColumn() const wxOVERRIDE;
|
2007-09-13 08:57:40 -04:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual int GetSelectedItemsCount() const wxOVERRIDE;
|
|
|
|
virtual int GetSelections( wxDataViewItemArray & sel ) const wxOVERRIDE;
|
|
|
|
virtual void SetSelections( const wxDataViewItemArray & sel ) wxOVERRIDE;
|
|
|
|
virtual void Select( const wxDataViewItem & item ) wxOVERRIDE;
|
|
|
|
virtual void Unselect( const wxDataViewItem & item ) wxOVERRIDE;
|
|
|
|
virtual bool IsSelected( const wxDataViewItem & item ) const wxOVERRIDE;
|
|
|
|
virtual void SelectAll() wxOVERRIDE;
|
|
|
|
virtual void UnselectAll() wxOVERRIDE;
|
2007-08-19 16:11:34 -04:00
|
|
|
|
2008-12-07 09:19:18 -05:00
|
|
|
virtual void EnsureVisible( const wxDataViewItem& item,
|
2014-03-29 20:02:23 -04:00
|
|
|
const wxDataViewColumn *column = NULL ) wxOVERRIDE;
|
2008-12-07 09:19:18 -05:00
|
|
|
virtual void HitTest( const wxPoint &point,
|
|
|
|
wxDataViewItem &item,
|
2014-03-29 20:02:23 -04:00
|
|
|
wxDataViewColumn *&column ) const wxOVERRIDE;
|
2008-12-07 09:19:18 -05:00
|
|
|
virtual wxRect GetItemRect( const wxDataViewItem &item,
|
2014-03-29 20:02:23 -04:00
|
|
|
const wxDataViewColumn *column = NULL ) const wxOVERRIDE;
|
2011-06-11 19:56:44 -04:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool SetRowHeight( int rowHeight ) wxOVERRIDE;
|
2011-06-11 19:56:44 -04:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void EditItem(const wxDataViewItem& item, const wxDataViewColumn *column) wxOVERRIDE;
|
2007-08-20 13:26:11 -04:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void Collapse( const wxDataViewItem & item ) wxOVERRIDE;
|
|
|
|
virtual bool IsExpanded( const wxDataViewItem & item ) const wxOVERRIDE;
|
2008-12-16 16:23:55 -05:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool EnableDragSource( const wxDataFormat &format ) wxOVERRIDE;
|
|
|
|
virtual bool EnableDropTarget( const wxDataFormat &format ) wxOVERRIDE;
|
2009-01-19 17:27:06 -05:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual wxDataViewColumn *GetCurrentColumn() const wxOVERRIDE;
|
2012-01-17 09:05:07 -05:00
|
|
|
|
2006-11-01 10:24:48 -05:00
|
|
|
static wxVisualAttributes
|
|
|
|
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
|
2008-12-07 09:19:18 -05:00
|
|
|
|
2007-04-17 08:08:10 -04:00
|
|
|
wxWindow *GetMainWindow() { return (wxWindow*) this; }
|
2008-12-07 09:19:18 -05:00
|
|
|
|
2007-07-17 18:01:47 -04:00
|
|
|
GtkWidget *GtkGetTreeView() { return m_treeview; }
|
|
|
|
wxDataViewCtrlInternal* GtkGetInternal() { return m_internal; }
|
2007-07-12 08:58:28 -04:00
|
|
|
|
2010-08-08 07:37:37 -04:00
|
|
|
// Convert GTK path to our item. Returned item may be invalid if get_iter()
|
|
|
|
// failed.
|
|
|
|
wxDataViewItem GTKPathToItem(struct _GtkTreePath *path) const;
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void OnInternalIdle() wxOVERRIDE;
|
2007-12-20 01:08:00 -05:00
|
|
|
|
2011-06-11 19:56:44 -04:00
|
|
|
int GTKGetUniformRowHeight() const { return m_uniformRowHeight; }
|
|
|
|
|
2007-07-12 08:58:28 -04:00
|
|
|
protected:
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void DoSetExpanderColumn() wxOVERRIDE;
|
|
|
|
virtual void DoSetIndent() wxOVERRIDE;
|
2007-07-12 08:58:28 -04:00
|
|
|
|
2016-03-22 16:22:36 -04:00
|
|
|
virtual void DoExpand(const wxDataViewItem& item) wxOVERRIDE;
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void DoApplyWidgetStyle(GtkRcStyle *style) wxOVERRIDE;
|
2009-09-26 12:43:30 -04:00
|
|
|
|
2006-02-25 09:07:06 -05:00
|
|
|
private:
|
2009-10-24 17:41:30 -04:00
|
|
|
void Init();
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual wxDataViewItem DoGetCurrentItem() const wxOVERRIDE;
|
|
|
|
virtual void DoSetCurrentItem(const wxDataViewItem& item) wxOVERRIDE;
|
2010-08-10 08:53:03 -04:00
|
|
|
|
2011-04-26 18:57:01 -04:00
|
|
|
// Return wxDataViewColumn matching the given GtkTreeViewColumn.
|
|
|
|
//
|
|
|
|
// If the input argument is NULL, return NULL too. Otherwise we must find
|
|
|
|
// the matching column and assert if we didn't.
|
|
|
|
wxDataViewColumn* FromGTKColumn(GtkTreeViewColumn *gtk_col) const;
|
|
|
|
|
2007-11-30 08:48:22 -05:00
|
|
|
friend class wxDataViewCtrlDCImpl;
|
2006-10-06 05:50:45 -04:00
|
|
|
friend class wxDataViewColumn;
|
2007-12-17 08:56:28 -05:00
|
|
|
friend class wxDataViewCtrlInternal;
|
2008-12-07 09:19:18 -05:00
|
|
|
|
2007-07-04 20:13:28 -04:00
|
|
|
GtkWidget *m_treeview;
|
2007-07-17 18:01:47 -04:00
|
|
|
wxDataViewCtrlInternal *m_internal;
|
2007-08-26 06:05:16 -04:00
|
|
|
wxDataViewColumnList m_cols;
|
2010-09-17 15:07:02 -04:00
|
|
|
wxDataViewItem m_ensureVisibleDefered;
|
2007-07-12 08:58:28 -04:00
|
|
|
|
2011-06-11 19:56:44 -04:00
|
|
|
// By default this is set to -1 and the height of the rows is determined by
|
|
|
|
// GetRect() methods of the renderers but this can be set to a positive
|
|
|
|
// value to force the height of all rows to the given value.
|
|
|
|
int m_uniformRowHeight;
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void AddChildGTK(wxWindowGTK* child) wxOVERRIDE;
|
2007-05-30 16:31:53 -04:00
|
|
|
void GtkEnableSelectionEvents();
|
|
|
|
void GtkDisableSelectionEvents();
|
2008-12-07 09:19:18 -05:00
|
|
|
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_DYNAMIC_CLASS(wxDataViewCtrl);
|
2009-02-08 06:45:59 -05:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxDataViewCtrl);
|
2006-02-21 12:35:19 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2007-12-20 01:08:00 -05:00
|
|
|
#endif // _WX_GTKDATAVIEWCTRL_H_
|