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 /////////////////////////////////////////////////////////////////////////////
9 #ifndef _WX_GTKDATAVIEWCTRL_H_
10 #define _WX_GTKDATAVIEWCTRL_H_
14 class WXDLLIMPEXP_FWD_ADV wxDataViewCtrlInternal
;
18 // ---------------------------------------------------------
20 // ---------------------------------------------------------
22 class WXDLLIMPEXP_ADV wxDataViewColumn
: public wxDataViewColumnBase
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
);
37 virtual void SetTitle( const wxString
&title
);
38 virtual void SetBitmap( const wxBitmap
&bitmap
);
40 virtual void SetOwner( wxDataViewCtrl
*owner
);
42 virtual void SetAlignment( wxAlignment align
);
44 virtual void SetSortable( bool sortable
);
45 virtual void SetSortOrder( bool ascending
);
47 virtual void SetResizeable( bool resizable
);
48 virtual void SetHidden( bool hidden
);
50 virtual void SetMinWidth( int minWidth
);
51 virtual void SetWidth( int width
);
53 virtual void SetReorderable( bool reorderable
);
55 virtual void SetFlags(int flags
) { SetIndividualFlags(flags
); }
59 virtual wxString
GetTitle() const;
60 virtual wxAlignment
GetAlignment() const;
62 virtual bool IsSortable() const;
63 virtual bool IsSortOrderAscending() const;
64 virtual bool IsSortKey() const;
66 virtual bool IsResizeable() const;
67 virtual bool IsHidden() const;
69 virtual int GetWidth() const;
70 virtual int GetMinWidth() const;
72 virtual bool IsReorderable() const;
74 virtual int GetFlags() const { return GetFromIndividualFlags(); }
77 GtkWidget
* GetGtkHandle() const { return m_column
; }
80 // holds the GTK handle
83 // holds GTK handles for title/bitmap in the header
87 // delayed connection to mouse events
88 friend class wxDataViewCtrl
;
89 void OnInternalIdle();
92 void Init(wxAlignment align
, int flags
, int width
);
95 WX_DECLARE_LIST_WITH_DECL(wxDataViewColumn
, wxDataViewColumnList
,
96 class WXDLLIMPEXP_ADV
);
98 // ---------------------------------------------------------
100 // ---------------------------------------------------------
102 class WXDLLIMPEXP_ADV wxDataViewCtrl
: public wxDataViewCtrlBase
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
)
118 Create(parent
, id
, pos
, size
, style
, validator
, name
);
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
);
127 virtual ~wxDataViewCtrl();
129 virtual bool AssociateModel( wxDataViewModel
*model
);
131 virtual bool PrependColumn( wxDataViewColumn
*col
);
132 virtual bool AppendColumn( wxDataViewColumn
*col
);
133 virtual bool InsertColumn( unsigned int pos
, wxDataViewColumn
*col
);
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;
141 virtual wxDataViewColumn
*GetSortingColumn() const;
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();
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;
160 virtual bool SetRowHeight( int rowHeight
);
162 virtual void EditItem(const wxDataViewItem
& item
, const wxDataViewColumn
*column
);
164 virtual void Expand( const wxDataViewItem
& item
);
165 virtual void Collapse( const wxDataViewItem
& item
);
166 virtual bool IsExpanded( const wxDataViewItem
& item
) const;
168 virtual bool EnableDragSource( const wxDataFormat
&format
);
169 virtual bool EnableDropTarget( const wxDataFormat
&format
);
171 virtual wxDataViewColumn
*GetCurrentColumn() const;
173 static wxVisualAttributes
174 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
);
176 wxWindow
*GetMainWindow() { return (wxWindow
*) this; }
178 GtkWidget
*GtkGetTreeView() { return m_treeview
; }
179 wxDataViewCtrlInternal
* GtkGetInternal() { return m_internal
; }
181 // Convert GTK path to our item. Returned item may be invalid if get_iter()
183 wxDataViewItem
GTKPathToItem(struct _GtkTreePath
*path
) const;
185 virtual void OnInternalIdle();
187 int GTKGetUniformRowHeight() const { return m_uniformRowHeight
; }
190 virtual void DoSetExpanderColumn();
191 virtual void DoSetIndent();
193 virtual void DoApplyWidgetStyle(GtkRcStyle
*style
);
198 virtual wxDataViewItem
DoGetCurrentItem() const;
199 virtual void DoSetCurrentItem(const wxDataViewItem
& item
);
201 // Return wxDataViewColumn matching the given GtkTreeViewColumn.
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;
207 friend class wxDataViewCtrlDCImpl
;
208 friend class wxDataViewColumn
;
209 friend class wxDataViewCtrlInternal
;
211 GtkWidget
*m_treeview
;
212 wxDataViewCtrlInternal
*m_internal
;
213 wxDataViewColumnList m_cols
;
214 wxDataViewItem m_ensureVisibleDefered
;
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
;
221 virtual void AddChildGTK(wxWindowGTK
* child
);
222 void GtkEnableSelectionEvents();
223 void GtkDisableSelectionEvents();
225 DECLARE_DYNAMIC_CLASS(wxDataViewCtrl
)
226 wxDECLARE_NO_COPY_CLASS(wxDataViewCtrl
);
230 #endif // _WX_GTKDATAVIEWCTRL_H_