]> git.saurik.com Git - wxWidgets.git/blob - src/common/datavcmn.cpp
Added wxDataViewColumn
[wxWidgets.git] / src / common / datavcmn.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/datavcmn.cpp
3 // Purpose: wxDataViewCtrl base classes and common parts
4 // Author: Robert Roebling
5 // Created: 2006/02/20
6 // RCS-ID: $Id$
7 // Copyright: (c) 2006, Robert Roebling
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
13
14 #ifdef __BORLANDC__
15 #pragma hdrstop
16 #endif
17
18 #include "wx/object.h"
19 #include "wx/dataview.h"
20 #include "wx/log.h"
21 #include "wx/image.h"
22
23 // ---------------------------------------------------------
24 // wxDataViewModel
25 // ---------------------------------------------------------
26
27 IMPLEMENT_ABSTRACT_CLASS(wxDataViewModel, wxObject)
28
29 // ---------------------------------------------------------
30 // wxDataViewListModel
31 // ---------------------------------------------------------
32
33 IMPLEMENT_ABSTRACT_CLASS(wxDataViewListModel, wxDataViewModel)
34
35 wxDataViewListModel::wxDataViewListModel()
36 {
37 m_notifier = NULL;
38 }
39
40 wxDataViewListModel::~wxDataViewListModel()
41 {
42 if (m_notifier)
43 delete m_notifier;
44 }
45
46 bool wxDataViewListModel::RowAppended()
47 {
48 if (m_notifier)
49 return m_notifier->RowAppended();
50
51 return false;
52 }
53
54 bool wxDataViewListModel::RowPrepended()
55 {
56 if (m_notifier)
57 return m_notifier->RowPrepended();
58
59 return false;
60 }
61
62 bool wxDataViewListModel::RowInserted( size_t before )
63 {
64 if (m_notifier)
65 return m_notifier->RowInserted( before );
66
67 return false;
68 }
69
70 bool wxDataViewListModel::RowDeleted( size_t row )
71 {
72 if (m_notifier)
73 return m_notifier->RowDeleted( row );
74
75 return false;
76 }
77
78 bool wxDataViewListModel::RowChanged( size_t row )
79 {
80 if (m_notifier)
81 return m_notifier->RowChanged( row );
82
83 return false;
84 }
85
86 bool wxDataViewListModel::ValueChanged( size_t row, size_t col )
87 {
88 if (m_notifier)
89 return m_notifier->RowAppended();
90
91 return false;
92 }
93
94 bool wxDataViewListModel::Cleared()
95 {
96 if (m_notifier)
97 return m_notifier->Cleared();
98
99 return false;
100 }
101
102 void wxDataViewListModel::SetNotifier( wxDataViewListModelNotifier *notifier )
103 {
104 if (m_notifier)
105 delete m_notifier;
106
107 m_notifier = notifier;
108 }
109
110 wxDataViewListModelNotifier* wxDataViewListModel::GetNotifier()
111 {
112 return m_notifier;
113 }
114
115 // ---------------------------------------------------------
116 // wxDataViewColumnBase
117 // ---------------------------------------------------------
118
119 IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumnBase, wxObject)
120
121 wxDataViewColumnBase::wxDataViewColumnBase( const wxString &title, wxDataViewCtrl *ctrl,
122 wxDataViewColumnType kind, int flags)
123 {
124 m_ctrl = ctrl;
125 m_kind = kind;
126 m_flags = flags;
127 m_title = title;
128 }
129
130 void wxDataViewColumnBase::SetTitle( const wxString &title )
131 {
132 m_title = title;
133 }
134
135 wxString wxDataViewColumnBase::GetTitle()
136 {
137 return m_title;
138 }
139
140 // ---------------------------------------------------------
141 // wxDataViewCtrlBase
142 // ---------------------------------------------------------
143
144 IMPLEMENT_ABSTRACT_CLASS(wxDataViewCtrlBase, wxControl)
145
146 wxDataViewCtrlBase::wxDataViewCtrlBase()
147 {
148 m_model = NULL;
149 m_cols.DeleteContents( true );
150 }
151
152 wxDataViewCtrlBase::~wxDataViewCtrlBase()
153 {
154 if (m_model)
155 delete m_model;
156 }
157
158 bool wxDataViewCtrlBase::AssociateModel( wxDataViewListModel *model )
159 {
160 if (m_model)
161 delete m_model;
162
163 m_model = model;
164
165 return true;
166 }
167
168 wxDataViewListModel* wxDataViewCtrlBase::GetModel()
169 {
170 return m_model;
171 }
172
173 bool wxDataViewCtrlBase::AppendStringColumn( const wxString &label )
174 {
175 return AppendColumn( new wxDataViewColumn( label, (wxDataViewCtrl*) this, wxDATAVIEW_COL_TEXT ) );
176 }
177
178 bool wxDataViewCtrlBase::AppendColumn( wxDataViewColumn *col )
179 {
180 m_cols.Append( (wxObject*) col );
181 return true;
182 }
183
184 size_t wxDataViewCtrlBase::GetNumberOfColumns()
185 {
186 return m_cols.GetCount();
187 }
188
189 bool wxDataViewCtrlBase::DeleteColumn( size_t pos )
190 {
191 return false;
192 }
193
194 bool wxDataViewCtrlBase::ClearColumns()
195 {
196 return false;
197 }
198
199 wxDataViewColumn* wxDataViewCtrlBase::GetColumn( size_t pos )
200 {
201 return (wxDataViewColumn*) m_cols[ pos ];
202 }
203