]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/dataview.h
remove obsolete check for GTK 2.6
[wxWidgets.git] / include / wx / gtk / dataview.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/dataview.h
3 // Purpose: wxDataViewCtrl GTK+2 implementation header
4 // Author: Robert Roebling
5 // Copyright: (c) 1998 Robert Roebling
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
8
9 #ifndef _WX_GTKDATAVIEWCTRL_H_
10 #define _WX_GTKDATAVIEWCTRL_H_
11
12 #include "wx/list.h"
13
14 class WXDLLIMPEXP_FWD_ADV wxDataViewCtrlInternal;
15
16 struct _GtkTreePath;
17
18 // ---------------------------------------------------------
19 // wxDataViewColumn
20 // ---------------------------------------------------------
21
22 class WXDLLIMPEXP_ADV wxDataViewColumn: public wxDataViewColumnBase
23 {
24 public:
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
34
35 // setters:
36
37 virtual void SetTitle( const wxString &title );
38 virtual void SetBitmap( const wxBitmap &bitmap );
39
40 virtual void SetOwner( wxDataViewCtrl *owner );
41
42 virtual void SetAlignment( wxAlignment align );
43
44 virtual void SetSortable( bool sortable );
45 virtual void SetSortOrder( bool ascending );
46
47 virtual void SetResizeable( bool resizable );
48 virtual void SetHidden( bool hidden );
49
50 virtual void SetMinWidth( int minWidth );
51 virtual void SetWidth( int width );
52
53 virtual void SetReorderable( bool reorderable );
54
55 virtual void SetFlags(int flags) { SetIndividualFlags(flags); }
56
57 // getters:
58
59 virtual wxString GetTitle() const;
60 virtual wxAlignment GetAlignment() const;
61
62 virtual bool IsSortable() const;
63 virtual bool IsSortOrderAscending() const;
64 virtual bool IsSortKey() const;
65
66 virtual bool IsResizeable() const;
67 virtual bool IsHidden() const;
68
69 virtual int GetWidth() const;
70 virtual int GetMinWidth() const;
71
72 virtual bool IsReorderable() const;
73
74 virtual int GetFlags() const { return GetFromIndividualFlags(); }
75
76 // implementation
77 GtkWidget* GetGtkHandle() const { return m_column; }
78
79 private:
80 // holds the GTK handle
81 GtkWidget *m_column;
82
83 // holds GTK handles for title/bitmap in the header
84 GtkWidget *m_image;
85 GtkWidget *m_label;
86
87 // delayed connection to mouse events
88 friend class wxDataViewCtrl;
89 void OnInternalIdle();
90 bool m_isConnected;
91
92 void Init(wxAlignment align, int flags, int width);
93 };
94
95 WX_DECLARE_LIST_WITH_DECL(wxDataViewColumn, wxDataViewColumnList,
96 class WXDLLIMPEXP_ADV);
97
98 // ---------------------------------------------------------
99 // wxDataViewCtrl
100 // ---------------------------------------------------------
101
102 class WXDLLIMPEXP_ADV wxDataViewCtrl: public wxDataViewCtrlBase
103 {
104 public:
105 wxDataViewCtrl()
106 {
107 Init();
108 }
109
110 wxDataViewCtrl( wxWindow *parent, wxWindowID id,
111 const wxPoint& pos = wxDefaultPosition,
112 const wxSize& size = wxDefaultSize, long style = 0,
113 const wxValidator& validator = wxDefaultValidator,
114 const wxString& name = wxDataViewCtrlNameStr )
115 {
116 Init();
117
118 Create(parent, id, pos, size, style, validator, name);
119 }
120
121 bool Create(wxWindow *parent, wxWindowID id,
122 const wxPoint& pos = wxDefaultPosition,
123 const wxSize& size = wxDefaultSize, long style = 0,
124 const wxValidator& validator = wxDefaultValidator,
125 const wxString& name = wxDataViewCtrlNameStr);
126
127 virtual ~wxDataViewCtrl();
128
129 virtual bool AssociateModel( wxDataViewModel *model );
130
131 virtual bool PrependColumn( wxDataViewColumn *col );
132 virtual bool AppendColumn( wxDataViewColumn *col );
133 virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col );
134
135 virtual unsigned int GetColumnCount() const;
136 virtual wxDataViewColumn* GetColumn( unsigned int pos ) const;
137 virtual bool DeleteColumn( wxDataViewColumn *column );
138 virtual bool ClearColumns();
139 virtual int GetColumnPosition( const wxDataViewColumn *column ) const;
140
141 virtual wxDataViewColumn *GetSortingColumn() const;
142
143 virtual int GetSelectedItemsCount() const;
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
152 virtual void EnsureVisible( const wxDataViewItem& item,
153 const wxDataViewColumn *column = NULL );
154 virtual void HitTest( const wxPoint &point,
155 wxDataViewItem &item,
156 wxDataViewColumn *&column ) const;
157 virtual wxRect GetItemRect( const wxDataViewItem &item,
158 const wxDataViewColumn *column = NULL ) const;
159
160 virtual bool SetRowHeight( int rowHeight );
161
162 virtual void EditItem(const wxDataViewItem& item, const wxDataViewColumn *column);
163
164 virtual void Expand( const wxDataViewItem & item );
165 virtual void Collapse( const wxDataViewItem & item );
166 virtual bool IsExpanded( const wxDataViewItem & item ) const;
167
168 virtual bool EnableDragSource( const wxDataFormat &format );
169 virtual bool EnableDropTarget( const wxDataFormat &format );
170
171 virtual wxDataViewColumn *GetCurrentColumn() const;
172
173 static wxVisualAttributes
174 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
175
176 wxWindow *GetMainWindow() { return (wxWindow*) this; }
177
178 GtkWidget *GtkGetTreeView() { return m_treeview; }
179 wxDataViewCtrlInternal* GtkGetInternal() { return m_internal; }
180
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
185 virtual void OnInternalIdle();
186
187 int GTKGetUniformRowHeight() const { return m_uniformRowHeight; }
188
189 protected:
190 virtual void DoSetExpanderColumn();
191 virtual void DoSetIndent();
192
193 virtual void DoApplyWidgetStyle(GtkRcStyle *style);
194
195 private:
196 void Init();
197
198 virtual wxDataViewItem DoGetCurrentItem() const;
199 virtual void DoSetCurrentItem(const wxDataViewItem& item);
200
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
207 friend class wxDataViewCtrlDCImpl;
208 friend class wxDataViewColumn;
209 friend class wxDataViewCtrlInternal;
210
211 GtkWidget *m_treeview;
212 wxDataViewCtrlInternal *m_internal;
213 wxDataViewColumnList m_cols;
214 wxDataViewItem m_ensureVisibleDefered;
215
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
221 virtual void AddChildGTK(wxWindowGTK* child);
222 void GtkEnableSelectionEvents();
223 void GtkDisableSelectionEvents();
224
225 DECLARE_DYNAMIC_CLASS(wxDataViewCtrl)
226 wxDECLARE_NO_COPY_CLASS(wxDataViewCtrl);
227 };
228
229
230 #endif // _WX_GTKDATAVIEWCTRL_H_