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