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