]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/dataview.h
b8064ad50dc3548e54ffcc94bf20ee501a988fa7
[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 virtual void SetAsSortKey(bool sort = true);
48
49 virtual void SetResizeable( bool resizeable );
50 virtual void SetHidden( bool hidden );
51
52 virtual void SetMinWidth( int minWidth );
53 virtual void SetWidth( int width );
54
55 virtual void SetReorderable( bool reorderable );
56
57 virtual void SetFlags(int flags) { SetIndividualFlags(flags); }
58
59 // getters:
60
61 virtual wxString GetTitle() const;
62 virtual wxAlignment GetAlignment() const;
63
64 virtual bool IsSortable() const;
65 virtual bool IsSortOrderAscending() const;
66 virtual bool IsSortKey() const;
67
68 virtual bool IsResizeable() const;
69 virtual bool IsHidden() const;
70
71 virtual int GetWidth() const;
72 virtual int GetMinWidth() const;
73
74 virtual bool IsReorderable() const;
75
76 virtual int GetFlags() const { return GetFromIndividualFlags(); }
77
78 // implementation
79 GtkWidget* GetGtkHandle() { return m_column; }
80 GtkWidget* GetConstGtkHandle() const { return m_column; }
81
82 private:
83 // holds the GTK handle
84 GtkWidget *m_column;
85
86 // holds GTK handles for title/bitmap in the header
87 GtkWidget *m_image;
88 GtkWidget *m_label;
89
90 // delayed connection to mouse events
91 friend class wxDataViewCtrl;
92 void OnInternalIdle();
93 bool m_isConnected;
94
95 void Init(wxAlignment align, int flags, int width);
96 };
97
98 WX_DECLARE_LIST_WITH_DECL(wxDataViewColumn, wxDataViewColumnList,
99 class WXDLLIMPEXP_ADV);
100
101 // ---------------------------------------------------------
102 // wxDataViewCtrl
103 // ---------------------------------------------------------
104
105 class WXDLLIMPEXP_ADV wxDataViewCtrl: public wxDataViewCtrlBase
106 {
107 public:
108 wxDataViewCtrl()
109 {
110 Init();
111 }
112
113 wxDataViewCtrl( wxWindow *parent, wxWindowID id,
114 const wxPoint& pos = wxDefaultPosition,
115 const wxSize& size = wxDefaultSize, long style = 0,
116 const wxValidator& validator = wxDefaultValidator )
117 {
118 Init();
119
120 Create(parent, id, pos, size, style, validator );
121 }
122
123 bool Create(wxWindow *parent, wxWindowID id,
124 const wxPoint& pos = wxDefaultPosition,
125 const wxSize& size = wxDefaultSize, long style = 0,
126 const wxValidator& validator = wxDefaultValidator );
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 wxDataViewItem GetSelection() 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 void Expand( const wxDataViewItem & item );
162 virtual void Collapse( const wxDataViewItem & item );
163 virtual bool IsExpanded( const wxDataViewItem & item ) const;
164
165 virtual bool EnableDragSource( const wxDataFormat &format );
166 virtual bool EnableDropTarget( const wxDataFormat &format );
167
168 static wxVisualAttributes
169 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
170
171 wxWindow *GetMainWindow() { return (wxWindow*) this; }
172
173 GtkWidget *GtkGetTreeView() { return m_treeview; }
174 wxDataViewCtrlInternal* GtkGetInternal() { return m_internal; }
175
176 // Convert GTK path to our item. Returned item may be invalid if get_iter()
177 // failed.
178 wxDataViewItem GTKPathToItem(struct _GtkTreePath *path) const;
179
180 virtual void OnInternalIdle();
181
182 protected:
183 virtual void DoSetExpanderColumn();
184 virtual void DoSetIndent();
185
186 virtual void DoApplyWidgetStyle(GtkRcStyle *style);
187
188 private:
189 void Init();
190
191 friend class wxDataViewCtrlDCImpl;
192 friend class wxDataViewColumn;
193 friend class wxGtkDataViewModelNotifier;
194 friend class wxDataViewCtrlInternal;
195
196 GtkWidget *m_treeview;
197 wxDataViewModelNotifier *m_notifier;
198 wxDataViewCtrlInternal *m_internal;
199 wxDataViewColumnList m_cols;
200
201 virtual void AddChildGTK(wxWindowGTK* child);
202 void GtkEnableSelectionEvents();
203 void GtkDisableSelectionEvents();
204
205 DECLARE_DYNAMIC_CLASS(wxDataViewCtrl)
206 wxDECLARE_NO_COPY_CLASS(wxDataViewCtrl);
207 };
208
209
210 #endif // _WX_GTKDATAVIEWCTRL_H_