1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/dataview.h
3 // Purpose: wxDataViewCtrl GTK+2 implementation header
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_GTKDATAVIEWCTRL_H_
11 #define _WX_GTKDATAVIEWCTRL_H_
15 class WXDLLIMPEXP_FWD_ADV wxDataViewCtrlInternal
;
17 // ---------------------------------------------------------
19 // ---------------------------------------------------------
21 class WXDLLIMPEXP_ADV wxDataViewColumn
: public wxDataViewColumnBase
24 wxDataViewColumn( const wxString
&title
, wxDataViewRenderer
*renderer
,
25 unsigned int model_column
, int width
= wxDVC_DEFAULT_WIDTH
,
26 wxAlignment align
= wxALIGN_CENTER
,
27 int flags
= wxDATAVIEW_COL_RESIZABLE
);
28 wxDataViewColumn( const wxBitmap
&bitmap
, wxDataViewRenderer
*renderer
,
29 unsigned int model_column
, int width
= wxDVC_DEFAULT_WIDTH
,
30 wxAlignment align
= wxALIGN_CENTER
,
31 int flags
= wxDATAVIEW_COL_RESIZABLE
);
36 virtual void SetTitle( const wxString
&title
);
37 virtual void SetBitmap( const wxBitmap
&bitmap
);
39 virtual void SetOwner( wxDataViewCtrl
*owner
);
41 virtual void SetAlignment( wxAlignment align
);
43 virtual void SetSortable( bool sortable
);
44 virtual void SetSortOrder( bool ascending
);
45 virtual void SetAsSortKey(bool sort
= true);
47 virtual void SetResizeable( bool resizeable
);
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() { return m_column
; }
78 GtkWidget
* GetConstGtkHandle() const { return m_column
; }
81 // holds the GTK handle
84 // holds GTK handles for title/bitmap in the header
88 // delayed connection to mouse events
89 friend class wxDataViewCtrl
;
90 void OnInternalIdle();
93 void Init(wxAlignment align
, int flags
, int width
);
96 WX_DECLARE_LIST_WITH_DECL(wxDataViewColumn
, wxDataViewColumnList
,
97 class WXDLLIMPEXP_ADV
);
99 // ---------------------------------------------------------
101 // ---------------------------------------------------------
103 class WXDLLIMPEXP_ADV wxDataViewCtrl
: public wxDataViewCtrlBase
111 wxDataViewCtrl( wxWindow
*parent
, wxWindowID id
,
112 const wxPoint
& pos
= wxDefaultPosition
,
113 const wxSize
& size
= wxDefaultSize
, long style
= 0,
114 const wxValidator
& validator
= wxDefaultValidator
)
118 Create(parent
, id
, pos
, size
, style
, validator
);
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
);
126 virtual ~wxDataViewCtrl();
128 virtual bool AssociateModel( wxDataViewModel
*model
);
130 virtual bool PrependColumn( wxDataViewColumn
*col
);
131 virtual bool AppendColumn( wxDataViewColumn
*col
);
132 virtual bool InsertColumn( unsigned int pos
, wxDataViewColumn
*col
);
134 virtual unsigned int GetColumnCount() const;
135 virtual wxDataViewColumn
* GetColumn( unsigned int pos
) const;
136 virtual bool DeleteColumn( wxDataViewColumn
*column
);
137 virtual bool ClearColumns();
138 virtual int GetColumnPosition( const wxDataViewColumn
*column
) const;
140 virtual wxDataViewColumn
*GetSortingColumn() const;
142 virtual wxDataViewItem
GetSelection() const;
143 virtual int GetSelections( wxDataViewItemArray
& sel
) const;
144 virtual void SetSelections( const wxDataViewItemArray
& sel
);
145 virtual void Select( const wxDataViewItem
& item
);
146 virtual void Unselect( const wxDataViewItem
& item
);
147 virtual bool IsSelected( const wxDataViewItem
& item
) const;
148 virtual void SelectAll();
149 virtual void UnselectAll();
151 virtual void EnsureVisible( const wxDataViewItem
& item
,
152 const wxDataViewColumn
*column
= NULL
);
153 virtual void HitTest( const wxPoint
&point
,
154 wxDataViewItem
&item
,
155 wxDataViewColumn
*&column
) const;
156 virtual wxRect
GetItemRect( const wxDataViewItem
&item
,
157 const wxDataViewColumn
*column
= NULL
) const;
159 virtual void Expand( const wxDataViewItem
& item
);
160 virtual void Collapse( const wxDataViewItem
& item
);
161 virtual bool IsExpanded( const wxDataViewItem
& item
) const;
163 virtual bool EnableDragSource( const wxDataFormat
&format
);
164 virtual bool EnableDropTarget( const wxDataFormat
&format
);
166 static wxVisualAttributes
167 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
);
169 wxWindow
*GetMainWindow() { return (wxWindow
*) this; }
171 GtkWidget
*GtkGetTreeView() { return m_treeview
; }
172 wxDataViewCtrlInternal
* GtkGetInternal() { return m_internal
; }
174 virtual void OnInternalIdle();
177 virtual void DoSetExpanderColumn();
178 virtual void DoSetIndent();
180 virtual void DoApplyWidgetStyle(GtkRcStyle
*style
);
185 friend class wxDataViewCtrlDCImpl
;
186 friend class wxDataViewColumn
;
187 friend class wxGtkDataViewModelNotifier
;
188 friend class wxDataViewCtrlInternal
;
190 GtkWidget
*m_treeview
;
191 wxDataViewModelNotifier
*m_notifier
;
192 wxDataViewCtrlInternal
*m_internal
;
193 wxDataViewColumnList m_cols
;
195 virtual void AddChildGTK(wxWindowGTK
* child
);
196 void GtkEnableSelectionEvents();
197 void GtkDisableSelectionEvents();
199 DECLARE_DYNAMIC_CLASS(wxDataViewCtrl
)
200 wxDECLARE_NO_COPY_CLASS(wxDataViewCtrl
);
204 #endif // _WX_GTKDATAVIEWCTRL_H_