1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/dataview.h
3 // Purpose: wxDataViewCtrl GTK+2 implementation header
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_GTKDATAVIEWCTRL_H_
11 #define _WX_GTKDATAVIEWCTRL_H_
15 class WXDLLIMPEXP_FWD_ADV wxDataViewCtrlInternal
;
19 // ---------------------------------------------------------
21 // ---------------------------------------------------------
23 class WXDLLIMPEXP_ADV wxDataViewColumn
: public wxDataViewColumnBase
26 wxDataViewColumn( const wxString
&title
, wxDataViewRenderer
*renderer
,
27 unsigned int model_column
, int width
= wxDVC_DEFAULT_WIDTH
,
28 wxAlignment align
= wxALIGN_CENTER
,
29 int flags
= wxDATAVIEW_COL_RESIZABLE
);
30 wxDataViewColumn( const wxBitmap
&bitmap
, wxDataViewRenderer
*renderer
,
31 unsigned int model_column
, int width
= wxDVC_DEFAULT_WIDTH
,
32 wxAlignment align
= wxALIGN_CENTER
,
33 int flags
= wxDATAVIEW_COL_RESIZABLE
);
38 virtual void SetTitle( const wxString
&title
);
39 virtual void SetBitmap( const wxBitmap
&bitmap
);
41 virtual void SetOwner( wxDataViewCtrl
*owner
);
43 virtual void SetAlignment( wxAlignment align
);
45 virtual void SetSortable( bool sortable
);
46 virtual void SetSortOrder( bool ascending
);
47 virtual void SetAsSortKey(bool sort
= true);
49 virtual void SetResizeable( bool resizable
);
50 virtual void SetHidden( bool hidden
);
52 virtual void SetMinWidth( int minWidth
);
53 virtual void SetWidth( int width
);
55 virtual void SetReorderable( bool reorderable
);
57 virtual void SetFlags(int flags
) { SetIndividualFlags(flags
); }
61 virtual wxString
GetTitle() const;
62 virtual wxAlignment
GetAlignment() const;
64 virtual bool IsSortable() const;
65 virtual bool IsSortOrderAscending() const;
66 virtual bool IsSortKey() const;
68 virtual bool IsResizeable() const;
69 virtual bool IsHidden() const;
71 virtual int GetWidth() const;
72 virtual int GetMinWidth() const;
74 virtual bool IsReorderable() const;
76 virtual int GetFlags() const { return GetFromIndividualFlags(); }
79 GtkWidget
* GetGtkHandle() { return m_column
; }
80 GtkWidget
* GetConstGtkHandle() const { return m_column
; }
83 // holds the GTK handle
86 // holds GTK handles for title/bitmap in the header
90 // delayed connection to mouse events
91 friend class wxDataViewCtrl
;
92 void OnInternalIdle();
95 void Init(wxAlignment align
, int flags
, int width
);
98 WX_DECLARE_LIST_WITH_DECL(wxDataViewColumn
, wxDataViewColumnList
,
99 class WXDLLIMPEXP_ADV
);
101 // ---------------------------------------------------------
103 // ---------------------------------------------------------
105 class WXDLLIMPEXP_ADV wxDataViewCtrl
: public wxDataViewCtrlBase
113 wxDataViewCtrl( wxWindow
*parent
, wxWindowID id
,
114 const wxPoint
& pos
= wxDefaultPosition
,
115 const wxSize
& size
= wxDefaultSize
, long style
= 0,
116 const wxValidator
& validator
= wxDefaultValidator
,
117 const wxString
& name
= wxDataViewCtrlNameStr
)
121 Create(parent
, id
, pos
, size
, style
, validator
, name
);
124 bool Create(wxWindow
*parent
, wxWindowID id
,
125 const wxPoint
& pos
= wxDefaultPosition
,
126 const wxSize
& size
= wxDefaultSize
, long style
= 0,
127 const wxValidator
& validator
= wxDefaultValidator
,
128 const wxString
& name
= wxDataViewCtrlNameStr
);
130 virtual ~wxDataViewCtrl();
132 virtual bool AssociateModel( wxDataViewModel
*model
);
134 virtual bool PrependColumn( wxDataViewColumn
*col
);
135 virtual bool AppendColumn( wxDataViewColumn
*col
);
136 virtual bool InsertColumn( unsigned int pos
, wxDataViewColumn
*col
);
138 virtual unsigned int GetColumnCount() const;
139 virtual wxDataViewColumn
* GetColumn( unsigned int pos
) const;
140 virtual bool DeleteColumn( wxDataViewColumn
*column
);
141 virtual bool ClearColumns();
142 virtual int GetColumnPosition( const wxDataViewColumn
*column
) const;
144 virtual wxDataViewColumn
*GetSortingColumn() const;
146 virtual wxDataViewItem
GetSelection() const;
147 virtual int GetSelections( wxDataViewItemArray
& sel
) const;
148 virtual void SetSelections( const wxDataViewItemArray
& sel
);
149 virtual void Select( const wxDataViewItem
& item
);
150 virtual void Unselect( const wxDataViewItem
& item
);
151 virtual bool IsSelected( const wxDataViewItem
& item
) const;
152 virtual void SelectAll();
153 virtual void UnselectAll();
155 virtual void EnsureVisible( const wxDataViewItem
& item
,
156 const wxDataViewColumn
*column
= NULL
);
157 virtual void HitTest( const wxPoint
&point
,
158 wxDataViewItem
&item
,
159 wxDataViewColumn
*&column
) const;
160 virtual wxRect
GetItemRect( const wxDataViewItem
&item
,
161 const wxDataViewColumn
*column
= NULL
) const;
163 virtual void Expand( const wxDataViewItem
& item
);
164 virtual void Collapse( const wxDataViewItem
& item
);
165 virtual bool IsExpanded( const wxDataViewItem
& item
) const;
167 virtual bool EnableDragSource( const wxDataFormat
&format
);
168 virtual bool EnableDropTarget( const wxDataFormat
&format
);
170 static wxVisualAttributes
171 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
);
173 wxWindow
*GetMainWindow() { return (wxWindow
*) this; }
175 GtkWidget
*GtkGetTreeView() { return m_treeview
; }
176 wxDataViewCtrlInternal
* GtkGetInternal() { return m_internal
; }
178 // Convert GTK path to our item. Returned item may be invalid if get_iter()
180 wxDataViewItem
GTKPathToItem(struct _GtkTreePath
*path
) const;
182 virtual void OnInternalIdle();
185 virtual void DoSetExpanderColumn();
186 virtual void DoSetIndent();
188 virtual void DoApplyWidgetStyle(GtkRcStyle
*style
);
193 virtual wxDataViewItem
DoGetCurrentItem() const;
194 virtual void DoSetCurrentItem(const wxDataViewItem
& item
);
196 friend class wxDataViewCtrlDCImpl
;
197 friend class wxDataViewColumn
;
198 friend class wxDataViewCtrlInternal
;
200 GtkWidget
*m_treeview
;
201 wxDataViewCtrlInternal
*m_internal
;
202 wxDataViewColumnList m_cols
;
203 wxDataViewItem m_ensureVisibleDefered
;
205 virtual void AddChildGTK(wxWindowGTK
* child
);
206 void GtkEnableSelectionEvents();
207 void GtkDisableSelectionEvents();
209 DECLARE_DYNAMIC_CLASS(wxDataViewCtrl
)
210 wxDECLARE_NO_COPY_CLASS(wxDataViewCtrl
);
214 #endif // _WX_GTKDATAVIEWCTRL_H_