]>
Commit | Line | Data |
---|---|---|
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 | 15 | class WXDLLIMPEXP_FWD_ADV wxDataViewCtrlInternal; |
239eaa41 | 16 | |
17d98558 VZ |
17 | struct _GtkTreePath; |
18 | ||
bc0289bf | 19 | // --------------------------------------------------------- |
fa28826d | 20 | // wxDataViewColumn |
bc0289bf | 21 | // --------------------------------------------------------- |
fa28826d | 22 | |
d350fbec | 23 | class WXDLLIMPEXP_ADV wxDataViewColumn: public wxDataViewColumnBase |
fa28826d RR |
24 | { |
25 | public: | |
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 | 46 | virtual void SetSortOrder( bool ascending ); |
e2bfe673 | 47 | virtual void SetAsSortKey(bool sort = true); |
47cef10f | 48 | |
d13b34d3 | 49 | virtual void SetResizeable( bool resizable ); |
9861f022 RR |
50 | virtual void SetHidden( bool hidden ); |
51 | ||
52 | virtual void SetMinWidth( int minWidth ); | |
53 | virtual void SetWidth( int width ); | |
54 | ||
99c75ebc | 55 | virtual void SetReorderable( bool reorderable ); |
9861f022 | 56 | |
56873923 VZ |
57 | virtual void SetFlags(int flags) { SetIndividualFlags(flags); } |
58 | ||
9861f022 RR |
59 | // getters: |
60 | ||
61 | virtual wxString GetTitle() const; | |
62 | virtual wxAlignment GetAlignment() const; | |
63 | ||
87f0efe2 RR |
64 | virtual bool IsSortable() const; |
65 | virtual bool IsSortOrderAscending() const; | |
3cbd3136 | 66 | virtual bool IsSortKey() const; |
e2bfe673 | 67 | |
9861f022 RR |
68 | virtual bool IsResizeable() const; |
69 | virtual bool IsHidden() const; | |
87f0efe2 RR |
70 | |
71 | virtual int GetWidth() const; | |
9861f022 | 72 | virtual int GetMinWidth() const; |
bc0289bf | 73 | |
99c75ebc | 74 | virtual bool IsReorderable() const; |
9861f022 | 75 | |
56873923 VZ |
76 | virtual int GetFlags() const { return GetFromIndividualFlags(); } |
77 | ||
fa28826d | 78 | // implementation |
b3a8aa92 | 79 | GtkWidget* GetGtkHandle() const { return m_column; } |
fa28826d RR |
80 | |
81 | private: | |
6842a71a | 82 | // holds the GTK handle |
9861f022 | 83 | GtkWidget *m_column; |
bc0289bf | 84 | |
419a3607 RR |
85 | // holds GTK handles for title/bitmap in the header |
86 | GtkWidget *m_image; | |
87 | GtkWidget *m_label; | |
bc0289bf | 88 | |
31fb32e1 RR |
89 | // delayed connection to mouse events |
90 | friend class wxDataViewCtrl; | |
91 | void OnInternalIdle(); | |
9861f022 RR |
92 | bool m_isConnected; |
93 | ||
94 | void Init(wxAlignment align, int flags, int width); | |
fa28826d RR |
95 | }; |
96 | ||
d350fbec VS |
97 | WX_DECLARE_LIST_WITH_DECL(wxDataViewColumn, wxDataViewColumnList, |
98 | class WXDLLIMPEXP_ADV); | |
91a6c655 | 99 | |
bc0289bf | 100 | // --------------------------------------------------------- |
239eaa41 | 101 | // wxDataViewCtrl |
bc0289bf | 102 | // --------------------------------------------------------- |
239eaa41 | 103 | |
d350fbec | 104 | class WXDLLIMPEXP_ADV wxDataViewCtrl: public wxDataViewCtrlBase |
239eaa41 RR |
105 | { |
106 | public: | |
bc0289bf | 107 | wxDataViewCtrl() |
239eaa41 RR |
108 | { |
109 | Init(); | |
110 | } | |
bc0289bf | 111 | |
239eaa41 RR |
112 | wxDataViewCtrl( wxWindow *parent, wxWindowID id, |
113 | const wxPoint& pos = wxDefaultPosition, | |
114 | const wxSize& size = wxDefaultSize, long style = 0, | |
62e9285a VZ |
115 | const wxValidator& validator = wxDefaultValidator, |
116 | const wxString& name = wxDataViewCtrlNameStr ) | |
239eaa41 | 117 | { |
bf68a18d VZ |
118 | Init(); |
119 | ||
62e9285a | 120 | Create(parent, id, pos, size, style, validator, name); |
239eaa41 RR |
121 | } |
122 | ||
239eaa41 RR |
123 | bool Create(wxWindow *parent, wxWindowID id, |
124 | const wxPoint& pos = wxDefaultPosition, | |
125 | const wxSize& size = wxDefaultSize, long style = 0, | |
62e9285a VZ |
126 | const wxValidator& validator = wxDefaultValidator, |
127 | const wxString& name = wxDataViewCtrlNameStr); | |
239eaa41 | 128 | |
bf68a18d VZ |
129 | virtual ~wxDataViewCtrl(); |
130 | ||
e0062c04 | 131 | virtual bool AssociateModel( wxDataViewModel *model ); |
bc0289bf | 132 | |
736fe67c | 133 | virtual bool PrependColumn( wxDataViewColumn *col ); |
1a367564 | 134 | virtual bool AppendColumn( wxDataViewColumn *col ); |
19723525 | 135 | virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col ); |
bc0289bf | 136 | |
91a6c655 RR |
137 | virtual unsigned int GetColumnCount() const; |
138 | virtual wxDataViewColumn* GetColumn( unsigned int pos ) const; | |
139 | virtual bool DeleteColumn( wxDataViewColumn *column ); | |
140 | virtual bool ClearColumns(); | |
453091c2 | 141 | virtual int GetColumnPosition( const wxDataViewColumn *column ) const; |
1e08ad10 | 142 | |
21f47fb9 RR |
143 | virtual wxDataViewColumn *GetSortingColumn() const; |
144 | ||
fa93d732 | 145 | virtual int GetSelectedItemsCount() const; |
e98351ec RR |
146 | virtual int GetSelections( wxDataViewItemArray & sel ) const; |
147 | virtual void SetSelections( const wxDataViewItemArray & sel ); | |
148 | virtual void Select( const wxDataViewItem & item ); | |
149 | virtual void Unselect( const wxDataViewItem & item ); | |
150 | virtual bool IsSelected( const wxDataViewItem & item ) const; | |
151 | virtual void SelectAll(); | |
152 | virtual void UnselectAll(); | |
153 | ||
bc0289bf | 154 | virtual void EnsureVisible( const wxDataViewItem& item, |
fbda518c | 155 | const wxDataViewColumn *column = NULL ); |
bc0289bf VZ |
156 | virtual void HitTest( const wxPoint &point, |
157 | wxDataViewItem &item, | |
a87b466d | 158 | wxDataViewColumn *&column ) const; |
bc0289bf | 159 | virtual wxRect GetItemRect( const wxDataViewItem &item, |
fbda518c | 160 | const wxDataViewColumn *column = NULL ) const; |
0f4a54a6 VZ |
161 | |
162 | virtual bool SetRowHeight( int rowHeight ); | |
163 | ||
eeea3b03 | 164 | virtual void StartEditor( const wxDataViewItem & item, unsigned int column ); |
66e09788 | 165 | |
f71d3ba4 RR |
166 | virtual void Expand( const wxDataViewItem & item ); |
167 | virtual void Collapse( const wxDataViewItem & item ); | |
739a8399 RR |
168 | virtual bool IsExpanded( const wxDataViewItem & item ) const; |
169 | ||
15cac64f | 170 | virtual bool EnableDragSource( const wxDataFormat &format ); |
8c2654ce | 171 | virtual bool EnableDropTarget( const wxDataFormat &format ); |
15cac64f | 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 |
189 | protected: |
190 | virtual void DoSetExpanderColumn(); | |
191 | virtual void DoSetIndent(); | |
192 | ||
ddb44248 VZ |
193 | virtual void DoApplyWidgetStyle(GtkRcStyle *style); |
194 | ||
1a367564 | 195 | private: |
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_ |