]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/dataview.h
Define WXBUILDING in Xcode projects.
[wxWidgets.git] / include / wx / gtk / dataview.h
CommitLineData
239eaa41
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/gtk/dataview.h
3// Purpose: wxDataViewCtrl GTK+2 implementation header
4// Author: Robert Roebling
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
901a462f
PC
10#ifndef _WX_GTKDATAVIEWCTRL_H_
11#define _WX_GTKDATAVIEWCTRL_H_
239eaa41 12
239eaa41 13#include "wx/list.h"
239eaa41 14
d350fbec 15class WXDLLIMPEXP_FWD_ADV wxDataViewCtrlInternal;
239eaa41 16
17d98558
VZ
17struct _GtkTreePath;
18
bc0289bf 19// ---------------------------------------------------------
fa28826d 20// wxDataViewColumn
bc0289bf 21// ---------------------------------------------------------
fa28826d 22
d350fbec 23class WXDLLIMPEXP_ADV wxDataViewColumn: public wxDataViewColumnBase
fa28826d
RR
24{
25public:
87f0efe2
RR
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 );
34
9861f022
RR
35
36 // setters:
37
fa28826d 38 virtual void SetTitle( const wxString &title );
07a84e7b 39 virtual void SetBitmap( const wxBitmap &bitmap );
47cef10f 40
b94db696
RR
41 virtual void SetOwner( wxDataViewCtrl *owner );
42
47cef10f 43 virtual void SetAlignment( wxAlignment align );
bc0289bf 44
31fb32e1 45 virtual void SetSortable( bool sortable );
47cef10f
RR
46 virtual void SetSortOrder( bool ascending );
47
d13b34d3 48 virtual void SetResizeable( bool resizable );
9861f022
RR
49 virtual void SetHidden( bool hidden );
50
51 virtual void SetMinWidth( int minWidth );
52 virtual void SetWidth( int width );
53
99c75ebc 54 virtual void SetReorderable( bool reorderable );
9861f022 55
56873923
VZ
56 virtual void SetFlags(int flags) { SetIndividualFlags(flags); }
57
9861f022
RR
58 // getters:
59
60 virtual wxString GetTitle() const;
61 virtual wxAlignment GetAlignment() const;
62
87f0efe2
RR
63 virtual bool IsSortable() const;
64 virtual bool IsSortOrderAscending() const;
3cbd3136 65 virtual bool IsSortKey() const;
e2bfe673 66
9861f022
RR
67 virtual bool IsResizeable() const;
68 virtual bool IsHidden() const;
87f0efe2
RR
69
70 virtual int GetWidth() const;
9861f022 71 virtual int GetMinWidth() const;
bc0289bf 72
99c75ebc 73 virtual bool IsReorderable() const;
9861f022 74
56873923
VZ
75 virtual int GetFlags() const { return GetFromIndividualFlags(); }
76
fa28826d 77 // implementation
b3a8aa92 78 GtkWidget* GetGtkHandle() const { return m_column; }
fa28826d
RR
79
80private:
6842a71a 81 // holds the GTK handle
9861f022 82 GtkWidget *m_column;
bc0289bf 83
419a3607
RR
84 // holds GTK handles for title/bitmap in the header
85 GtkWidget *m_image;
86 GtkWidget *m_label;
bc0289bf 87
31fb32e1
RR
88 // delayed connection to mouse events
89 friend class wxDataViewCtrl;
90 void OnInternalIdle();
9861f022
RR
91 bool m_isConnected;
92
93 void Init(wxAlignment align, int flags, int width);
fa28826d
RR
94};
95
d350fbec
VS
96WX_DECLARE_LIST_WITH_DECL(wxDataViewColumn, wxDataViewColumnList,
97 class WXDLLIMPEXP_ADV);
91a6c655 98
bc0289bf 99// ---------------------------------------------------------
239eaa41 100// wxDataViewCtrl
bc0289bf 101// ---------------------------------------------------------
239eaa41 102
d350fbec 103class WXDLLIMPEXP_ADV wxDataViewCtrl: public wxDataViewCtrlBase
239eaa41
RR
104{
105public:
bc0289bf 106 wxDataViewCtrl()
239eaa41
RR
107 {
108 Init();
109 }
bc0289bf 110
239eaa41
RR
111 wxDataViewCtrl( wxWindow *parent, wxWindowID id,
112 const wxPoint& pos = wxDefaultPosition,
113 const wxSize& size = wxDefaultSize, long style = 0,
62e9285a
VZ
114 const wxValidator& validator = wxDefaultValidator,
115 const wxString& name = wxDataViewCtrlNameStr )
239eaa41 116 {
bf68a18d
VZ
117 Init();
118
62e9285a 119 Create(parent, id, pos, size, style, validator, name);
239eaa41
RR
120 }
121
239eaa41
RR
122 bool Create(wxWindow *parent, wxWindowID id,
123 const wxPoint& pos = wxDefaultPosition,
124 const wxSize& size = wxDefaultSize, long style = 0,
62e9285a
VZ
125 const wxValidator& validator = wxDefaultValidator,
126 const wxString& name = wxDataViewCtrlNameStr);
239eaa41 127
bf68a18d
VZ
128 virtual ~wxDataViewCtrl();
129
e0062c04 130 virtual bool AssociateModel( wxDataViewModel *model );
bc0289bf 131
736fe67c 132 virtual bool PrependColumn( wxDataViewColumn *col );
1a367564 133 virtual bool AppendColumn( wxDataViewColumn *col );
19723525 134 virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col );
bc0289bf 135
91a6c655
RR
136 virtual unsigned int GetColumnCount() const;
137 virtual wxDataViewColumn* GetColumn( unsigned int pos ) const;
138 virtual bool DeleteColumn( wxDataViewColumn *column );
139 virtual bool ClearColumns();
453091c2 140 virtual int GetColumnPosition( const wxDataViewColumn *column ) const;
1e08ad10 141
21f47fb9
RR
142 virtual wxDataViewColumn *GetSortingColumn() const;
143
fa93d732 144 virtual int GetSelectedItemsCount() const;
e98351ec
RR
145 virtual int GetSelections( wxDataViewItemArray & sel ) const;
146 virtual void SetSelections( const wxDataViewItemArray & sel );
147 virtual void Select( const wxDataViewItem & item );
148 virtual void Unselect( const wxDataViewItem & item );
149 virtual bool IsSelected( const wxDataViewItem & item ) const;
150 virtual void SelectAll();
151 virtual void UnselectAll();
152
bc0289bf 153 virtual void EnsureVisible( const wxDataViewItem& item,
fbda518c 154 const wxDataViewColumn *column = NULL );
bc0289bf
VZ
155 virtual void HitTest( const wxPoint &point,
156 wxDataViewItem &item,
a87b466d 157 wxDataViewColumn *&column ) const;
bc0289bf 158 virtual wxRect GetItemRect( const wxDataViewItem &item,
fbda518c 159 const wxDataViewColumn *column = NULL ) const;
0f4a54a6
VZ
160
161 virtual bool SetRowHeight( int rowHeight );
162
907f09f4 163 virtual void EditItem(const wxDataViewItem& item, const wxDataViewColumn *column);
66e09788 164
f71d3ba4
RR
165 virtual void Expand( const wxDataViewItem & item );
166 virtual void Collapse( const wxDataViewItem & item );
739a8399
RR
167 virtual bool IsExpanded( const wxDataViewItem & item ) const;
168
15cac64f 169 virtual bool EnableDragSource( const wxDataFormat &format );
8c2654ce 170 virtual bool EnableDropTarget( const wxDataFormat &format );
15cac64f 171
ee1377e1
VS
172 virtual wxDataViewColumn *GetCurrentColumn() const;
173
b94db696
RR
174 static wxVisualAttributes
175 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
bc0289bf 176
1e510b1e 177 wxWindow *GetMainWindow() { return (wxWindow*) this; }
bc0289bf 178
55fbde12
RR
179 GtkWidget *GtkGetTreeView() { return m_treeview; }
180 wxDataViewCtrlInternal* GtkGetInternal() { return m_internal; }
3b6280be 181
17d98558
VZ
182 // Convert GTK path to our item. Returned item may be invalid if get_iter()
183 // failed.
184 wxDataViewItem GTKPathToItem(struct _GtkTreePath *path) const;
185
901a462f
PC
186 virtual void OnInternalIdle();
187
0f4a54a6
VZ
188 int GTKGetUniformRowHeight() const { return m_uniformRowHeight; }
189
3b6280be
RR
190protected:
191 virtual void DoSetExpanderColumn();
192 virtual void DoSetIndent();
193
ddb44248
VZ
194 virtual void DoApplyWidgetStyle(GtkRcStyle *style);
195
1a367564 196private:
bf68a18d
VZ
197 void Init();
198
80ce465c
VZ
199 virtual wxDataViewItem DoGetCurrentItem() const;
200 virtual void DoSetCurrentItem(const wxDataViewItem& item);
201
b2fd3bea
VZ
202 // Return wxDataViewColumn matching the given GtkTreeViewColumn.
203 //
204 // If the input argument is NULL, return NULL too. Otherwise we must find
205 // the matching column and assert if we didn't.
206 wxDataViewColumn* FromGTKColumn(GtkTreeViewColumn *gtk_col) const;
207
888dde65 208 friend class wxDataViewCtrlDCImpl;
31fb32e1 209 friend class wxDataViewColumn;
33ba5a05 210 friend class wxDataViewCtrlInternal;
bc0289bf 211
e0062c04 212 GtkWidget *m_treeview;
55fbde12 213 wxDataViewCtrlInternal *m_internal;
91a6c655 214 wxDataViewColumnList m_cols;
3f53dd3a 215 wxDataViewItem m_ensureVisibleDefered;
3b6280be 216
0f4a54a6
VZ
217 // By default this is set to -1 and the height of the rows is determined by
218 // GetRect() methods of the renderers but this can be set to a positive
219 // value to force the height of all rows to the given value.
220 int m_uniformRowHeight;
221
48200154 222 virtual void AddChildGTK(wxWindowGTK* child);
b086d55f
RR
223 void GtkEnableSelectionEvents();
224 void GtkDisableSelectionEvents();
bc0289bf 225
239eaa41 226 DECLARE_DYNAMIC_CLASS(wxDataViewCtrl)
c0c133e1 227 wxDECLARE_NO_COPY_CLASS(wxDataViewCtrl);
239eaa41
RR
228};
229
230
901a462f 231#endif // _WX_GTKDATAVIEWCTRL_H_