2006-02-21 17:35:19 +00: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
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2007-12-20 06:08:00 +00:00
|
|
|
#ifndef _WX_GTKDATAVIEWCTRL_H_
|
|
|
|
#define _WX_GTKDATAVIEWCTRL_H_
|
2006-02-21 17:35:19 +00:00
|
|
|
|
|
|
|
#include "wx/list.h"
|
|
|
|
|
2007-10-10 19:44:26 +00:00
|
|
|
class WXDLLIMPEXP_FWD_ADV wxDataViewCtrlInternal;
|
2006-02-21 17:35:19 +00:00
|
|
|
|
2010-08-08 11:37:37 +00:00
|
|
|
struct _GtkTreePath;
|
|
|
|
|
2008-12-07 14:19:18 +00:00
|
|
|
// ---------------------------------------------------------
|
2006-02-22 00:19:04 +00:00
|
|
|
// wxDataViewColumn
|
2008-12-07 14:19:18 +00:00
|
|
|
// ---------------------------------------------------------
|
2006-02-22 00:19:04 +00:00
|
|
|
|
2007-10-10 19:44:26 +00:00
|
|
|
class WXDLLIMPEXP_ADV wxDataViewColumn: public wxDataViewColumnBase
|
2006-02-22 00:19:04 +00:00
|
|
|
{
|
|
|
|
public:
|
2007-02-17 12:32:38 +00: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 07:57:46 +00:00
|
|
|
|
|
|
|
// setters:
|
|
|
|
|
2006-02-22 00:19:04 +00:00
|
|
|
virtual void SetTitle( const wxString &title );
|
2006-10-05 19:06:21 +00:00
|
|
|
virtual void SetBitmap( const wxBitmap &bitmap );
|
2006-10-05 19:35:23 +00:00
|
|
|
|
2006-11-01 15:24:48 +00:00
|
|
|
virtual void SetOwner( wxDataViewCtrl *owner );
|
|
|
|
|
2006-10-05 19:35:23 +00:00
|
|
|
virtual void SetAlignment( wxAlignment align );
|
2008-12-07 14:19:18 +00:00
|
|
|
|
2006-10-06 09:50:45 +00:00
|
|
|
virtual void SetSortable( bool sortable );
|
2006-10-05 19:35:23 +00:00
|
|
|
virtual void SetSortOrder( bool ascending );
|
|
|
|
|
2011-04-03 20:31:32 +00:00
|
|
|
virtual void SetResizeable( bool resizable );
|
2007-02-23 07:57:46 +00:00
|
|
|
virtual void SetHidden( bool hidden );
|
|
|
|
|
|
|
|
virtual void SetMinWidth( int minWidth );
|
|
|
|
virtual void SetWidth( int width );
|
|
|
|
|
2007-12-26 18:30:56 +00:00
|
|
|
virtual void SetReorderable( bool reorderable );
|
2007-02-23 07:57:46 +00:00
|
|
|
|
2008-12-03 21:53:10 +00:00
|
|
|
virtual void SetFlags(int flags) { SetIndividualFlags(flags); }
|
|
|
|
|
2007-02-23 07:57:46 +00:00
|
|
|
// getters:
|
|
|
|
|
|
|
|
virtual wxString GetTitle() const;
|
|
|
|
virtual wxAlignment GetAlignment() const;
|
|
|
|
|
2007-02-17 12:32:38 +00:00
|
|
|
virtual bool IsSortable() const;
|
|
|
|
virtual bool IsSortOrderAscending() const;
|
2008-12-07 16:04:48 +00:00
|
|
|
virtual bool IsSortKey() const;
|
2008-12-07 14:47:55 +00:00
|
|
|
|
2007-02-23 07:57:46 +00:00
|
|
|
virtual bool IsResizeable() const;
|
|
|
|
virtual bool IsHidden() const;
|
2007-02-17 12:32:38 +00:00
|
|
|
|
|
|
|
virtual int GetWidth() const;
|
2007-02-23 07:57:46 +00:00
|
|
|
virtual int GetMinWidth() const;
|
2008-12-07 14:19:18 +00:00
|
|
|
|
2007-12-26 18:30:56 +00:00
|
|
|
virtual bool IsReorderable() const;
|
2007-02-23 07:57:46 +00:00
|
|
|
|
2008-12-03 21:53:10 +00:00
|
|
|
virtual int GetFlags() const { return GetFromIndividualFlags(); }
|
|
|
|
|
2006-02-22 00:19:04 +00:00
|
|
|
// implementation
|
2011-04-26 22:56:56 +00:00
|
|
|
GtkWidget* GetGtkHandle() const { return m_column; }
|
2006-02-22 00:19:04 +00:00
|
|
|
|
|
|
|
private:
|
2006-02-23 02:04:46 +00:00
|
|
|
// holds the GTK handle
|
2007-02-23 07:57:46 +00:00
|
|
|
GtkWidget *m_column;
|
2008-12-07 14:19:18 +00:00
|
|
|
|
2008-04-12 20:07:53 +00:00
|
|
|
// holds GTK handles for title/bitmap in the header
|
|
|
|
GtkWidget *m_image;
|
|
|
|
GtkWidget *m_label;
|
2008-12-07 14:19:18 +00:00
|
|
|
|
2006-10-06 09:50:45 +00:00
|
|
|
// delayed connection to mouse events
|
|
|
|
friend class wxDataViewCtrl;
|
|
|
|
void OnInternalIdle();
|
2007-02-23 07:57:46 +00:00
|
|
|
bool m_isConnected;
|
|
|
|
|
|
|
|
void Init(wxAlignment align, int flags, int width);
|
2006-02-22 00:19:04 +00:00
|
|
|
};
|
|
|
|
|
2007-10-10 19:44:26 +00:00
|
|
|
WX_DECLARE_LIST_WITH_DECL(wxDataViewColumn, wxDataViewColumnList,
|
|
|
|
class WXDLLIMPEXP_ADV);
|
2007-08-26 10:05:16 +00:00
|
|
|
|
2008-12-07 14:19:18 +00:00
|
|
|
// ---------------------------------------------------------
|
2006-02-21 17:35:19 +00:00
|
|
|
// wxDataViewCtrl
|
2008-12-07 14:19:18 +00:00
|
|
|
// ---------------------------------------------------------
|
2006-02-21 17:35:19 +00:00
|
|
|
|
2007-10-10 19:44:26 +00:00
|
|
|
class WXDLLIMPEXP_ADV wxDataViewCtrl: public wxDataViewCtrlBase
|
2006-02-21 17:35:19 +00:00
|
|
|
{
|
|
|
|
public:
|
2008-12-07 14:19:18 +00:00
|
|
|
wxDataViewCtrl()
|
2006-02-21 17:35:19 +00:00
|
|
|
{
|
|
|
|
Init();
|
|
|
|
}
|
2008-12-07 14:19:18 +00:00
|
|
|
|
2006-02-21 17:35:19 +00:00
|
|
|
wxDataViewCtrl( wxWindow *parent, wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize, long style = 0,
|
2010-08-08 11:37:57 +00:00
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = wxDataViewCtrlNameStr )
|
2006-02-21 17:35:19 +00:00
|
|
|
{
|
2009-10-24 21:41:30 +00:00
|
|
|
Init();
|
|
|
|
|
2010-08-08 11:37:57 +00:00
|
|
|
Create(parent, id, pos, size, style, validator, name);
|
2006-02-21 17:35:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Create(wxWindow *parent, wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize, long style = 0,
|
2010-08-08 11:37:57 +00:00
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = wxDataViewCtrlNameStr);
|
2006-02-21 17:35:19 +00:00
|
|
|
|
2009-10-24 21:41:30 +00:00
|
|
|
virtual ~wxDataViewCtrl();
|
|
|
|
|
2007-07-05 00:13:28 +00:00
|
|
|
virtual bool AssociateModel( wxDataViewModel *model );
|
2008-12-07 14:19:18 +00:00
|
|
|
|
2007-10-18 20:56:38 +00:00
|
|
|
virtual bool PrependColumn( wxDataViewColumn *col );
|
2006-02-25 14:07:06 +00:00
|
|
|
virtual bool AppendColumn( wxDataViewColumn *col );
|
2008-05-21 08:47:21 +00:00
|
|
|
virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col );
|
2008-12-07 14:19:18 +00:00
|
|
|
|
2007-08-26 10:05:16 +00:00
|
|
|
virtual unsigned int GetColumnCount() const;
|
|
|
|
virtual wxDataViewColumn* GetColumn( unsigned int pos ) const;
|
|
|
|
virtual bool DeleteColumn( wxDataViewColumn *column );
|
|
|
|
virtual bool ClearColumns();
|
2007-09-13 13:29:19 +00:00
|
|
|
virtual int GetColumnPosition( const wxDataViewColumn *column ) const;
|
2007-07-14 13:54:14 +00:00
|
|
|
|
2007-09-13 12:57:40 +00:00
|
|
|
virtual wxDataViewColumn *GetSortingColumn() const;
|
|
|
|
|
2011-08-22 12:41:19 +00:00
|
|
|
virtual int GetSelectedItemsCount() const;
|
2007-08-19 20:11:34 +00: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;
|
|
|
|
virtual void SelectAll();
|
|
|
|
virtual void UnselectAll();
|
|
|
|
|
2008-12-07 14:19:18 +00:00
|
|
|
virtual void EnsureVisible( const wxDataViewItem& item,
|
2007-08-24 11:21:52 +00:00
|
|
|
const wxDataViewColumn *column = NULL );
|
2008-12-07 14:19:18 +00:00
|
|
|
virtual void HitTest( const wxPoint &point,
|
|
|
|
wxDataViewItem &item,
|
2007-08-24 20:00:32 +00:00
|
|
|
wxDataViewColumn *&column ) const;
|
2008-12-07 14:19:18 +00:00
|
|
|
virtual wxRect GetItemRect( const wxDataViewItem &item,
|
2007-08-24 11:21:52 +00:00
|
|
|
const wxDataViewColumn *column = NULL ) const;
|
2011-06-11 23:56:44 +00:00
|
|
|
|
|
|
|
virtual bool SetRowHeight( int rowHeight );
|
|
|
|
|
2012-01-17 14:05:17 +00:00
|
|
|
virtual void EditItem(const wxDataViewItem& item, const wxDataViewColumn *column);
|
2007-08-20 17:26:11 +00:00
|
|
|
|
2007-08-25 21:05:51 +00:00
|
|
|
virtual void Expand( const wxDataViewItem & item );
|
|
|
|
virtual void Collapse( const wxDataViewItem & item );
|
2008-12-16 21:23:55 +00:00
|
|
|
virtual bool IsExpanded( const wxDataViewItem & item ) const;
|
|
|
|
|
2009-01-19 22:27:06 +00:00
|
|
|
virtual bool EnableDragSource( const wxDataFormat &format );
|
2009-01-20 17:50:51 +00:00
|
|
|
virtual bool EnableDropTarget( const wxDataFormat &format );
|
2009-01-19 22:27:06 +00:00
|
|
|
|
2012-01-17 14:05:07 +00:00
|
|
|
virtual wxDataViewColumn *GetCurrentColumn() const;
|
|
|
|
|
2006-11-01 15:24:48 +00:00
|
|
|
static wxVisualAttributes
|
|
|
|
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
|
2008-12-07 14:19:18 +00:00
|
|
|
|
2007-04-17 12:08:10 +00:00
|
|
|
wxWindow *GetMainWindow() { return (wxWindow*) this; }
|
2008-12-07 14:19:18 +00:00
|
|
|
|
2007-07-17 22:01:47 +00:00
|
|
|
GtkWidget *GtkGetTreeView() { return m_treeview; }
|
|
|
|
wxDataViewCtrlInternal* GtkGetInternal() { return m_internal; }
|
2007-07-12 12:58:28 +00:00
|
|
|
|
2010-08-08 11:37:37 +00:00
|
|
|
// Convert GTK path to our item. Returned item may be invalid if get_iter()
|
|
|
|
// failed.
|
|
|
|
wxDataViewItem GTKPathToItem(struct _GtkTreePath *path) const;
|
|
|
|
|
2007-12-20 06:08:00 +00:00
|
|
|
virtual void OnInternalIdle();
|
|
|
|
|
2011-06-11 23:56:44 +00:00
|
|
|
int GTKGetUniformRowHeight() const { return m_uniformRowHeight; }
|
|
|
|
|
2007-07-12 12:58:28 +00:00
|
|
|
protected:
|
|
|
|
virtual void DoSetExpanderColumn();
|
|
|
|
virtual void DoSetIndent();
|
|
|
|
|
2009-09-26 16:43:30 +00:00
|
|
|
virtual void DoApplyWidgetStyle(GtkRcStyle *style);
|
|
|
|
|
2006-02-25 14:07:06 +00:00
|
|
|
private:
|
2009-10-24 21:41:30 +00:00
|
|
|
void Init();
|
|
|
|
|
2010-08-10 12:53:03 +00:00
|
|
|
virtual wxDataViewItem DoGetCurrentItem() const;
|
|
|
|
virtual void DoSetCurrentItem(const wxDataViewItem& item);
|
|
|
|
|
2011-04-26 22:57:01 +00: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 13:48:22 +00:00
|
|
|
friend class wxDataViewCtrlDCImpl;
|
2006-10-06 09:50:45 +00:00
|
|
|
friend class wxDataViewColumn;
|
2007-12-17 13:56:28 +00:00
|
|
|
friend class wxDataViewCtrlInternal;
|
2008-12-07 14:19:18 +00:00
|
|
|
|
2007-07-05 00:13:28 +00:00
|
|
|
GtkWidget *m_treeview;
|
2007-07-17 22:01:47 +00:00
|
|
|
wxDataViewCtrlInternal *m_internal;
|
2007-08-26 10:05:16 +00:00
|
|
|
wxDataViewColumnList m_cols;
|
2010-09-17 19:07:02 +00:00
|
|
|
wxDataViewItem m_ensureVisibleDefered;
|
2007-07-12 12:58:28 +00:00
|
|
|
|
2011-06-11 23:56:44 +00: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;
|
|
|
|
|
2008-08-29 15:46:48 +00:00
|
|
|
virtual void AddChildGTK(wxWindowGTK* child);
|
2007-05-30 20:31:53 +00:00
|
|
|
void GtkEnableSelectionEvents();
|
|
|
|
void GtkDisableSelectionEvents();
|
2008-12-07 14:19:18 +00:00
|
|
|
|
2006-02-21 17:35:19 +00:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxDataViewCtrl)
|
2009-02-08 11:45:59 +00:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxDataViewCtrl);
|
2006-02-21 17:35:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2007-12-20 06:08:00 +00:00
|
|
|
#endif // _WX_GTKDATAVIEWCTRL_H_
|