Skip to content
Newer
Older
100644 817 lines (655 sloc) 22.9 KB
8990f6c @tolmasky Minor fixes and added licenses to files.
tolmasky authored
1 /*
2 * CPTableColumn.j
3 * AppKit
4 *
5 * Created by Francisco Tolmasky.
6 * Copyright 2009, 280 North, Inc.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
a40fbd7 Add the first draft of documentation inline.
Ross Boucher authored
22
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
23 @import <Foundation/CPDictionary.j>
24 @import <Foundation/CPObject.j>
01852d8 @paulbaumgart Fix a bunch of missing @imports.
paulbaumgart authored
25 @import <Foundation/CPIndexSet.j>
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
26 @import <Foundation/CPSortDescriptor.j>
27 @import <Foundation/CPString.j>
28
29 @import "CPTableHeaderView.j"
a97bb72 @tolmasky Initial commit.
tolmasky authored
30
31
32 CPTableColumnNoResizing = 0;
4a5e90b @Me1000 Fixed column resizing mask types.
Me1000 authored
33 CPTableColumnAutoresizingMask = 1 << 0;
34 CPTableColumnUserResizingMask = 1 << 1;
a97bb72 @tolmasky Initial commit.
tolmasky authored
35
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
36 /*!
37 @class CPTableColumn
38
39 A CPTableColumn contains a dataview to display for its column of the CPTableView.
6a94263 @stevegeek Fixing spelling mistakes
stevegeek authored
40 A CPTableColumn determines its own size constrains and resizing behavior.
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
41
6a94263 @stevegeek Fixing spelling mistakes
stevegeek authored
42 The default dataview is a CPTextField but you can set it to any view you'd like. See -setDataView: for documentation including theme states.
f075430 @Me1000 Doc fixes and more docs in the tableview.
Me1000 authored
43
44 To customize the text of the column header you can simply call setStringValue: on the headerview of a table column.
45 For example: [[myTableColumn headerView] setStringValue:"My Title"];
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
46 */
a97bb72 @tolmasky Initial commit.
tolmasky authored
47 @implementation CPTableColumn : CPObject
48 {
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
49 CPTableView _tableView;
50 CPView _headerView;
51 CPView _dataView;
52 Object _dataViewData;
53
54 float _width;
55 float _minWidth;
56 float _maxWidth;
a5e34d9 @appden Added CGGeometry to CPTableColumn since it's called from sizeToFit
appden authored
57 unsigned _resizingMask;
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
58
59 id _identifier;
60 BOOL _isEditable;
61 CPSortDescriptor _sortDescriptorPrototype;
62 BOOL _isHidden;
63 CPString _headerToolTip;
8b2350f @aljungberg Optimized table data loading when using bindings for the cell values.…
aljungberg authored
64
36a85e9 @cacaodev TableView : Column resizing. Works with column resizingMasks.
cacaodev authored
65 BOOL _disableResizingPosting @accessors(property=disableResizingPosting);
a97bb72 @tolmasky Initial commit.
tolmasky authored
66 }
67
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
68 /*!
69 @ignore
70 */
bc6f168 Added some designated initializers to AppKit.
Nicholas Small authored
71 - (id)init
72 {
73 return [self initWithIdentifier:@""];
a97bb72 @tolmasky Initial commit.
tolmasky authored
74 }
75
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
76 /*!
77 Initializes a newly created CPTableColumn with a given identifier.
78
79 */
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
80 - (id)initWithIdentifier:(id)anIdentifier
a97bb72 @tolmasky Initial commit.
tolmasky authored
81 {
82 self = [super init];
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
83
a97bb72 @tolmasky Initial commit.
tolmasky authored
84 if (self)
85 {
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
86 _dataViewData = { };
a97bb72 @tolmasky Initial commit.
tolmasky authored
87
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
88 _width = 100.0;
89 _minWidth = 10.0;
90 _maxWidth = 1000000.0;
36a85e9 @cacaodev TableView : Column resizing. Works with column resizingMasks.
cacaodev authored
91 _resizingMask = CPTableColumnAutoresizingMask | CPTableColumnUserResizingMask;
92 _disableResizingPosting = NO;
8b2350f @aljungberg Optimized table data loading when using bindings for the cell values.…
aljungberg authored
93
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
94 [self setIdentifier:anIdentifier];
22aa4d3 @Me1000 Hard coded header view resources into the CPTableView
Me1000 authored
95
86fa759 @cacaodev CPTableHeaderView.j: Gradient headers for canvas capable browsers | B…
cacaodev authored
96 var header = [[_CPTableColumnHeaderView alloc] initWithFrame:CGRectMakeZero()];
22aa4d3 @Me1000 Hard coded header view resources into the CPTableView
Me1000 authored
97 [self setHeaderView:header];
8b2350f @aljungberg Optimized table data loading when using bindings for the cell values.…
aljungberg authored
98
cffbf86 @Me1000 TableView theming
Me1000 authored
99 [self setDataView:[CPTextField new]];
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
100 }
a97bb72 @tolmasky Initial commit.
tolmasky authored
101
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
102 return self;
a97bb72 @tolmasky Initial commit.
tolmasky authored
103 }
104
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
105 /*!
106 Set the columns's parent tableview
107 */
a40fbd7 Add the first draft of documentation inline.
Ross Boucher authored
108 - (void)setTableView:(CPTableView)aTableView
a97bb72 @tolmasky Initial commit.
tolmasky authored
109 {
110 _tableView = aTableView;
111 }
112
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
113 /*!
b8f9263 @Me1000 Fixed some 3am typos in the documentation
Me1000 authored
114 Return the column's parent tableview
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
115 */
a97bb72 @tolmasky Initial commit.
tolmasky authored
116 - (CPTableView)tableView
117 {
118 return _tableView;
119 }
120
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
121 /*!
97b141b @Me1000 Fixes for uniform column resizing
Me1000 authored
122 @ignore
123 this method tries to resize a column called via the tableview via autoresizing
124 it returns the delta from the actual resize and the proposed resize
125
126 for example if the column should have been resized 50px but the maxWidth was hit only
127 after 25px then the return value would be 25px;
128
129 if no edge has been hit zero will be returned
130 */
131 - (int)_tryToResizeToWidth:(int)width
132 {
133 var min = [self minWidth],
134 max = [self maxWidth],
021f5bb @aljungberg Fixed: disappearing or fuzzy table header dividing lines at certain t…
aljungberg authored
135 newWidth = ROUND(MIN(MAX(width, min), max));
97b141b @Me1000 Fixes for uniform column resizing
Me1000 authored
136
137 [self setWidth:newWidth];
138
139 return newWidth - width;
140 }
141
142 /*!
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
143 Set the width of the column
144 Default value is: 100
145
146 If the value is greater than the maxWidth the maxWidth will be reset with the supplied width here
147 If the value is less than the minWidth the minWidth will be reset with the supplied width.
148 */
a97bb72 @tolmasky Initial commit.
tolmasky authored
149 - (void)setWidth:(float)aWidth
150 {
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
151 aWidth = +aWidth;
152
153 if (_width === aWidth)
154 return;
155
156 var newWidth = MIN(MAX(aWidth, [self minWidth]), [self maxWidth]);
157
158 if (_width === newWidth)
159 return;
160
161 var oldWidth = _width;
162
163 _width = newWidth;
164
165 var tableView = [self tableView];
166
167 if (tableView)
d1c0237 @tolmasky Fix for recursive notification postings crashing. Also fixed sizing i…
tolmasky authored
168 {
36a85e9 @cacaodev TableView : Column resizing. Works with column resizingMasks.
cacaodev authored
169 var index = [[tableView tableColumns] indexOfObjectIdenticalTo:self],
170 dirtyTableColumnRangeIndex = tableView._dirtyTableColumnRangeIndex;
8b2350f @aljungberg Optimized table data loading when using bindings for the cell values.…
aljungberg authored
171
36a85e9 @cacaodev TableView : Column resizing. Works with column resizingMasks.
cacaodev authored
172 if (dirtyTableColumnRangeIndex < 0)
173 tableView._dirtyTableColumnRangeIndex = index;
174 else
175 tableView._dirtyTableColumnRangeIndex = MIN(index, tableView._dirtyTableColumnRangeIndex);
8b2350f @aljungberg Optimized table data loading when using bindings for the cell values.…
aljungberg authored
176
36a85e9 @cacaodev TableView : Column resizing. Works with column resizingMasks.
cacaodev authored
177 var rows = tableView._exposedRows,
8b2350f @aljungberg Optimized table data loading when using bindings for the cell values.…
aljungberg authored
178 columns = [CPIndexSet indexSetWithIndexesInRange:CPMakeRange(index, [tableView._exposedColumns lastIndex] - index + 1)];
179
36a85e9 @cacaodev TableView : Column resizing. Works with column resizingMasks.
cacaodev authored
180 // FIXME: Would be faster with some sort of -setNeedsDisplayInColumns: that updates a dirtyTableColumnForDisplay cache; then marked columns would relayout their data views at display time.
181 [tableView _layoutDataViewsInRows:rows columns:columns];
d1c0237 @tolmasky Fix for recursive notification postings crashing. Also fixed sizing i…
tolmasky authored
182 [tableView tile];
8b2350f @aljungberg Optimized table data loading when using bindings for the cell values.…
aljungberg authored
183
36a85e9 @cacaodev TableView : Column resizing. Works with column resizingMasks.
cacaodev authored
184 if (!_disableResizingPosting)
185 [self _postDidResizeNotificationWithOldWidth:oldWidth];
d1c0237 @tolmasky Fix for recursive notification postings crashing. Also fixed sizing i…
tolmasky authored
186 }
a97bb72 @tolmasky Initial commit.
tolmasky authored
187 }
188
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
189 /*!
190 Returns the column's width
191 */
a97bb72 @tolmasky Initial commit.
tolmasky authored
192 - (float)width
193 {
194 return _width;
195 }
196
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
197 /*!
40b04b7 @aljungberg Merge branch 'master' of github.com:280north/cappuccino into cacaodev…
aljungberg authored
198 Sets the minimum width of the column.
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
199 Default value is 10.
200 */
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
201 - (void)setMinWidth:(float)aMinWidth
a97bb72 @tolmasky Initial commit.
tolmasky authored
202 {
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
203 aMinWidth = +aMinWidth;
204
205 if (_minWidth === aMinWidth)
206 return;
207
208 _minWidth = aMinWidth;
209
210 var width = [self width],
211 newWidth = MAX(width, [self minWidth]);
212
213 if (width !== newWidth)
214 [self setWidth:newWidth];
a97bb72 @tolmasky Initial commit.
tolmasky authored
215 }
216
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
217 /*!
218 Returns the minimum width of the column.
219 */
a97bb72 @tolmasky Initial commit.
tolmasky authored
220 - (float)minWidth
221 {
222 return _minWidth;
223 }
224
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
225 /*!
40b04b7 @aljungberg Merge branch 'master' of github.com:280north/cappuccino into cacaodev…
aljungberg authored
226 Sets the maximum width of the table column.
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
227 Default value is: 1000000
228 */
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
229 - (void)setMaxWidth:(float)aMaxWidth
a97bb72 @tolmasky Initial commit.
tolmasky authored
230 {
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
231 aMaxWidth = +aMaxWidth;
232
233 if (_maxWidth === aMaxWidth)
234 return;
235
236 _maxWidth = aMaxWidth;
237
238 var width = [self width],
95364b1 @Me1000 Tableview fixes including setMaxWidth reset on columns, added grid li…
Me1000 authored
239 newWidth = MIN(width, [self maxWidth]);
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
240
241 if (width !== newWidth)
242 [self setWidth:newWidth];
a97bb72 @tolmasky Initial commit.
tolmasky authored
243 }
244
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
245 /*!
246 Returns the maximum width of the column
247 */
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
248 - (float)maxWidth
a97bb72 @tolmasky Initial commit.
tolmasky authored
249 {
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
250 return _maxWidth;
a97bb72 @tolmasky Initial commit.
tolmasky authored
251 }
252
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
253 /*!
05e69c8 @Me1000 More documentation of the tableview, outlineview, and table columns. …
Me1000 authored
254 <pre>
40b04b7 @aljungberg Merge branch 'master' of github.com:280north/cappuccino into cacaodev…
aljungberg authored
255 Set the resizing mask of the column.
6a94263 @stevegeek Fixing spelling mistakes
stevegeek authored
256 By default the column can be resized automatically with the tableview and manually by the user
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
257
258 Possible masking values are:
259 CPTableColumnNoResizing
260 CPTableColumnAutoresizingMask
261 CPTableColumnUserResizingMask
05e69c8 @Me1000 More documentation of the tableview, outlineview, and table columns. …
Me1000 authored
262 </pre>
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
263 */
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
264 - (void)setResizingMask:(unsigned)aResizingMask
265 {
266 _resizingMask = aResizingMask;
267 }
268
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
269
270 /*!
271 Returns the resizing mask of the column
272 */
4a5e90b @Me1000 Fixed column resizing mask types.
Me1000 authored
273 - (unsigned)resizingMask
a97bb72 @tolmasky Initial commit.
tolmasky authored
274 {
275 return _resizingMask;
276 }
277
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
278 /*!
40b04b7 @aljungberg Merge branch 'master' of github.com:280north/cappuccino into cacaodev…
aljungberg authored
279 Sizes the column to fix the column header text.
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
280 */
a97bb72 @tolmasky Initial commit.
tolmasky authored
281 - (void)sizeToFit
282 {
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
283 var width = _CGRectGetWidth([_headerView frame]);
284
285 if (width < [self minWidth])
a97bb72 @tolmasky Initial commit.
tolmasky authored
286 [self setMinWidth:width];
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
287 else if (width > [self maxWidth])
a97bb72 @tolmasky Initial commit.
tolmasky authored
288 [self setMaxWidth:width]
289
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
290 if (_width !== width)
a97bb72 @tolmasky Initial commit.
tolmasky authored
291 [self setWidth:width];
292 }
293
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
294
295 /*!
296 Sets the header view for the column.
f075430 @Me1000 Doc fixes and more docs in the tableview.
Me1000 authored
297 The headerview handles the display of sort indicators, text, etc.
298
299 If you do not want a headerview for you table you should call setHeaderView: on your CPTableView instance.
300 Passing nil here will throw an exception.
301
302 In order to customize the text of the column header see - (CPView)headerView;
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
303 */
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
304 - (void)setHeaderView:(CPView)aView
a97bb72 @tolmasky Initial commit.
tolmasky authored
305 {
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
306 if (!aView)
307 [CPException raise:CPInvalidArgumentException reason:@"Attempt to set nil header view on " + [self description]];
308
309 _headerView = aView;
de920e9 Fix for updating table column header views after they are initially l…
Ross Boucher authored
310
311 var tableHeaderView = [_tableView headerView];
312
313 [tableHeaderView setNeedsLayout];
314 [tableHeaderView setNeedsDisplay:YES];
a97bb72 @tolmasky Initial commit.
tolmasky authored
315 }
316
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
317 /*!
f075430 @Me1000 Doc fixes and more docs in the tableview.
Me1000 authored
318 Returns the headerview for the column.
319
40b04b7 @aljungberg Merge branch 'master' of github.com:280north/cappuccino into cacaodev…
aljungberg authored
320 In order to change the text of the headerview for a column you should call setStringValue: on the headerview.
f075430 @Me1000 Doc fixes and more docs in the tableview.
Me1000 authored
321 For example: [[myTableColumn headerView] setStringValue:"My Column"];
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
322 */
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
323 - (CPView)headerView
a97bb72 @tolmasky Initial commit.
tolmasky authored
324 {
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
325 return _headerView;
a97bb72 @tolmasky Initial commit.
tolmasky authored
326 }
327
1eed190 Add some documentation to CPTableColum's setDataView: method.
Ross Boucher authored
328 /*!
6f724e3 @eventualbuddha Fix apostrophe typo.
eventualbuddha authored
329 This method sets the "prototype" view which will be used to create all table cells in this column.
112ad65 @aljungberg Support value transformers in CPTableColumn when using bindings.
aljungberg authored
330
331 It creates a snapshot of aView, using keyed archiving, which is then copied over and over for each
1eed190 Add some documentation to CPTableColum's setDataView: method.
Ross Boucher authored
332 individual cell that is shown. As a result, changes made after calling this method won't be reflected.
333
334 Example:
590b370 @Me1000 Style changes for table column documentation.
Me1000 authored
335 @code
1eed190 Add some documentation to CPTableColum's setDataView: method.
Ross Boucher authored
336 [tableColumn setDataView:someView]; // snapshot taken
337 [[tableColumn dataView] setSomething:x]; //won't work
590b370 @Me1000 Style changes for table column documentation.
Me1000 authored
338 @endcode
1eed190 Add some documentation to CPTableColum's setDataView: method.
Ross Boucher authored
339
340 This doesn't work because the snapshot is taken before the new property is applied. Instead, do:
590b370 @Me1000 Style changes for table column documentation.
Me1000 authored
341 @code
1eed190 Add some documentation to CPTableColum's setDataView: method.
Ross Boucher authored
342 [someView setSomething:x];
343 [tableColumn setDataView:someView];
590b370 @Me1000 Style changes for table column documentation.
Me1000 authored
344 @endcode
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
345
590b370 @Me1000 Style changes for table column documentation.
Me1000 authored
346 @note you should implement CPKeyedArchiving otherwise you might see unexpected results.
05e69c8 @Me1000 More documentation of the tableview, outlineview, and table columns. …
Me1000 authored
347 This is done by adding the following methods to your class:
590b370 @Me1000 Style changes for table column documentation.
Me1000 authored
348 @endnote
349
350 @code
05e69c8 @Me1000 More documentation of the tableview, outlineview, and table columns. …
Me1000 authored
351 - (id)initWithCoder(CPCoder)aCoder;
352 - (void)encodeWithCoder:(CPCoder)aCoder;
a7c5ca7 @Me1000 Typo in doc changes
Me1000 authored
353 @endcode
05e69c8 @Me1000 More documentation of the tableview, outlineview, and table columns. …
Me1000 authored
354
355 Example:
356 Say you have two instance variables in your object that need to be set up each time an object is create.
357 We will call these instance variables "image" and "text".
358 Your CPCoding methods will look like the following:
359
590b370 @Me1000 Style changes for table column documentation.
Me1000 authored
360 @code
05e69c8 @Me1000 More documentation of the tableview, outlineview, and table columns. …
Me1000 authored
361 - (id)initWithCoder:(CPCoder)aCoder
362 {
363 self = [super initWithCoder:aCoder];
364
365 if (self)
366 {
367 image = [aCoder decodeObjectForKey:"MyDataViewImage"];
368 text = [aCoder decodeObjectForKey:"MyDataViewText"];
369 }
370
371 return self;
372 }
373
374 - (void)encodeWithCoder:(CPCoder)aCoder
375 {
376 [super encodeWithCoder:aCoder];
377
378 [aCoder encodeObject:image forKey:"MyDataViewImage"];
379 [aCoder encodeObject:text forKey:"MyDataViewText"];
380 }
590b370 @Me1000 Style changes for table column documentation.
Me1000 authored
381 @endcode
382
383 @section Themeing
384
385 When you set a dataview and it is added to the tableview the theme state will be set to \c CPThemeStateTableDataView
386 When the dataview becomes selected the theme state will be set to \c CPThemeStateSelectedDataView.
387
388 If the dataview shows up in a group row of the tableview the theme state will be set to \c CPThemeStateGroupRow.
389
390 You should overide \c setThemeState: and \c unsetThemeState: to handle these theme state changes in your dataview.
1eed190 Add some documentation to CPTableColum's setDataView: method.
Ross Boucher authored
391 */
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
392 - (void)setDataView:(CPView)aView
393 {
394 if (_dataView)
395 _dataViewData[[_dataView UID]] = nil;
ac8ecdb @tolmasky A number of CPTableView improvements, still not built by default.
tolmasky authored
396
cffbf86 @Me1000 TableView theming
Me1000 authored
397 [aView setThemeState:CPThemeStateTableDataView];
398
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
399 _dataView = aView;
400 _dataViewData[[aView UID]] = [CPKeyedArchiver archivedDataWithRootObject:aView];
401 }
402
403 - (CPView)dataView
a97bb72 @tolmasky Initial commit.
tolmasky authored
404 {
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
405 return _dataView;
a97bb72 @tolmasky Initial commit.
tolmasky authored
406 }
407
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
408 /*
409 Returns the CPView object used by the CPTableView to draw values for the receiver.
410
411 By default, this method just calls dataView. Subclassers can override if they need to
05e69c8 @Me1000 More documentation of the tableview, outlineview, and table columns. …
Me1000 authored
412 potentially use different "cells" or dataViews for different rows. Subclasses should expect this method
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
413 to be invoked with row equal to -1 in cases where no actual row is involved but the table
414 view needs to get some generic cell info.
a40fbd7 Add the first draft of documentation inline.
Ross Boucher authored
415 */
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
416 - (id)dataViewForRow:(int)aRowIndex
a97bb72 @tolmasky Initial commit.
tolmasky authored
417 {
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
418 return [self dataView];
a97bb72 @tolmasky Initial commit.
tolmasky authored
419 }
420
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
421 /*!
422 @ignore
423 */
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
424 - (id)_newDataViewForRow:(int)aRowIndex
ac8ecdb @tolmasky A number of CPTableView improvements, still not built by default.
tolmasky authored
425 {
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
426 var dataView = [self dataViewForRow:aRowIndex],
427 dataViewUID = [dataView UID];
428
36a85e9 @cacaodev TableView : Column resizing. Works with column resizingMasks.
cacaodev authored
429 var x = [self tableView]._cachedDataViews[dataViewUID];
430 if (x && x.length)
8fdcbac @aljungberg Fix CPTableColumn width, minWidth and maxWidth encoding.
aljungberg authored
431 return x.pop();
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
432
433 // if we haven't cached an archive of the data view, do it now
434 if (!_dataViewData[dataViewUID])
435 _dataViewData[dataViewUID] = [CPKeyedArchiver archivedDataWithRootObject:dataView];
436
437 // unarchive the data view cache
438 var newDataView = [CPKeyedUnarchiver unarchiveObjectWithData:_dataViewData[dataViewUID]];
36a85e9 @cacaodev TableView : Column resizing. Works with column resizingMasks.
cacaodev authored
439 newDataView.identifier = dataViewUID;
8b2350f @aljungberg Optimized table data loading when using bindings for the cell values.…
aljungberg authored
440
edc5542 Fix for issue #748
Aparajita Fishman authored
441 // make sure only we have control over the size and placement
442 [newDataView setAutoresizingMask:CPViewNotSizable];
112ad65 @aljungberg Support value transformers in CPTableColumn when using bindings.
aljungberg authored
443
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
444 return newDataView;
ac8ecdb @tolmasky A number of CPTableView improvements, still not built by default.
tolmasky authored
445 }
446
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
447 //Setting the Identifier
448
05e69c8 @Me1000 More documentation of the tableview, outlineview, and table columns. …
Me1000 authored
449 /*!
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
450 Sets the receiver identifier to anIdentifier.
ac8ecdb @tolmasky A number of CPTableView improvements, still not built by default.
tolmasky authored
451 */
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
452 - (void)setIdentifier:(id)anIdentifier
a97bb72 @tolmasky Initial commit.
tolmasky authored
453 {
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
454 _identifier = anIdentifier;
a97bb72 @tolmasky Initial commit.
tolmasky authored
455 }
456
05e69c8 @Me1000 More documentation of the tableview, outlineview, and table columns. …
Me1000 authored
457 /*!
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
458 Returns the object used by the data source to identify the attribute corresponding to the receiver.
a40fbd7 Add the first draft of documentation inline.
Ross Boucher authored
459 */
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
460 - (id)identifier
a97bb72 @tolmasky Initial commit.
tolmasky authored
461 {
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
462 return _identifier;
ac8ecdb @tolmasky A number of CPTableView improvements, still not built by default.
tolmasky authored
463 }
464
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
465 //Controlling Editability
466
05e69c8 @Me1000 More documentation of the tableview, outlineview, and table columns. …
Me1000 authored
467 /*!
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
468 Controls whether the user can edit cells in the receiver by double-clicking them.
ac8ecdb @tolmasky A number of CPTableView improvements, still not built by default.
tolmasky authored
469 */
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
470 - (void)setEditable:(BOOL)shouldBeEditable
ac8ecdb @tolmasky A number of CPTableView improvements, still not built by default.
tolmasky authored
471 {
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
472 _isEditable = shouldBeEditable;
a97bb72 @tolmasky Initial commit.
tolmasky authored
473 }
474
05e69c8 @Me1000 More documentation of the tableview, outlineview, and table columns. …
Me1000 authored
475 /*!
8b2350f @aljungberg Optimized table data loading when using bindings for the cell values.…
aljungberg authored
476 Returns YES if the user can edit cells associated with the receiver by double-clicking the
590b370 @Me1000 Style changes for table column documentation.
Me1000 authored
477 column in the CPTableView, NO otherwise.
a40fbd7 Add the first draft of documentation inline.
Ross Boucher authored
478 */
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
479 - (BOOL)isEditable
a97bb72 @tolmasky Initial commit.
tolmasky authored
480 {
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
481 return _isEditable;
ac8ecdb @tolmasky A number of CPTableView improvements, still not built by default.
tolmasky authored
482 }
483
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
484 /*!
40b04b7 @aljungberg Merge branch 'master' of github.com:280north/cappuccino into cacaodev…
aljungberg authored
485 Sets the sort descriptor prototype for the column.
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
486 */
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
487 - (void)setSortDescriptorPrototype:(CPSortDescriptor)aSortDescriptor
ac8ecdb @tolmasky A number of CPTableView improvements, still not built by default.
tolmasky authored
488 {
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
489 _sortDescriptorPrototype = aSortDescriptor;
ac8ecdb @tolmasky A number of CPTableView improvements, still not built by default.
tolmasky authored
490 }
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
491
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
492 /*!
493 Returns the sort descriptor prototype for the column.
494 */
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
495 - (CPSortDescriptor)sortDescriptorPrototype
ac8ecdb @tolmasky A number of CPTableView improvements, still not built by default.
tolmasky authored
496 {
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
497 return _sortDescriptorPrototype;
ac8ecdb @tolmasky A number of CPTableView improvements, still not built by default.
tolmasky authored
498 }
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
499
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
500 /*!
4af0615 @aparajita CPTableColumn -setHidden documentation was backwards.
aparajita authored
501 If YES the tablecolumn will no longer be visible in the tableview.
502 If NO the tablecolumn will be visible in the tableview.
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
503 */
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
504 - (void)setHidden:(BOOL)shouldBeHidden
ac8ecdb @tolmasky A number of CPTableView improvements, still not built by default.
tolmasky authored
505 {
4ef9202 made the tableview handle hiding and showing of columns properly
Klaas Pieter Annema authored
506 shouldBeHidden = !!shouldBeHidden
4af0615 @aparajita CPTableColumn -setHidden documentation was backwards.
aparajita authored
507
4ef9202 made the tableview handle hiding and showing of columns properly
Klaas Pieter Annema authored
508 if (_isHidden === shouldBeHidden)
509 return;
112ad65 @aljungberg Support value transformers in CPTableColumn when using bindings.
aljungberg authored
510
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
511 _isHidden = shouldBeHidden;
112ad65 @aljungberg Support value transformers in CPTableColumn when using bindings.
aljungberg authored
512
4ef9202 made the tableview handle hiding and showing of columns properly
Klaas Pieter Annema authored
513 [[self headerView] setHidden:shouldBeHidden];
514 [[self tableView] _tableColumnVisibilityDidChange:self];
ac8ecdb @tolmasky A number of CPTableView improvements, still not built by default.
tolmasky authored
515 }
516
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
517 /*!
518 Returns the visibility status of the column.
519 */
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
520 - (BOOL)isHidden
ac8ecdb @tolmasky A number of CPTableView improvements, still not built by default.
tolmasky authored
521 {
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
522 return _isHidden;
523 }
00c6a89 Various CPTableView improvements and nib2cib support
Tom Robinson authored
524
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
525 //Setting Tool Tips
526
05e69c8 @Me1000 More documentation of the tableview, outlineview, and table columns. …
Me1000 authored
527 /*!
8b2350f @aljungberg Optimized table data loading when using bindings for the cell values.…
aljungberg authored
528 Sets the tooltip string that is displayed when the cursor pauses over the
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
529 header cell of the receiver.
530 */
531 - (void)setHeaderToolTip:(CPString)aToolTip
532 {
533 _headerToolTip = aToolTip;
a97bb72 @tolmasky Initial commit.
tolmasky authored
534 }
535
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
536 /*!
537 Returns the tooltip for the column header
538 */
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
539 - (CPString)headerToolTip
7b04023 @tolmasky bleh.
tolmasky authored
540 {
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
541 return _headerToolTip;
7b04023 @tolmasky bleh.
tolmasky authored
542 }
543
946cd38 @Me1000 Compelete documentation of the tableview and tablecolumns (which the …
Me1000 authored
544 /*!
545 @ignore
546 */
36a85e9 @cacaodev TableView : Column resizing. Works with column resizingMasks.
cacaodev authored
547 - (void)_postDidResizeNotificationWithOldWidth:(float)oldWidth
548 {
0c62609 made CPTableView aware of a resize in CPTableColumn
Klaas Pieter Annema authored
549 [[self tableView] _didResizeTableColumn:self];
550
36a85e9 @cacaodev TableView : Column resizing. Works with column resizingMasks.
cacaodev authored
551 [[CPNotificationCenter defaultCenter]
552 postNotificationName:CPTableViewColumnDidResizeNotification
553 object:[self tableView]
554 userInfo:[CPDictionary dictionaryWithObjects:[self, oldWidth] forKeys:[@"CPTableColumn", "CPOldWidth"]]];
555 }
556
a97bb72 @tolmasky Initial commit.
tolmasky authored
557 @end
ac8ecdb @tolmasky A number of CPTableView improvements, still not built by default.
tolmasky authored
558
235b323 @cacaodev Add CPTableColumnValueBinder. This binder subclass just reloads the t…
cacaodev authored
559 @implementation CPTableColumnValueBinder : CPBinder
560 {
561 }
562
563 - (void)setValueFor:(CPString)aBinding
564 {
565 var tableView = [_source tableView],
566 column = [[tableView tableColumns] indexOfObjectIdenticalTo:_source],
567 rowIndexes = [CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0, [tableView numberOfRows])],
568 columnIndexes = [CPIndexSet indexSetWithIndex:column];
40b04b7 @aljungberg Merge branch 'master' of github.com:280north/cappuccino into cacaodev…
aljungberg authored
569
235b323 @cacaodev Add CPTableColumnValueBinder. This binder subclass just reloads the t…
cacaodev authored
570 [tableView reloadDataForRowIndexes:rowIndexes columnIndexes:columnIndexes];
571 }
572
573 @end
574
3635d0e Bindings Checkpoint.
Ross Boucher authored
575 @implementation CPTableColumn (Bindings)
235b323 @cacaodev Add CPTableColumnValueBinder. This binder subclass just reloads the t…
cacaodev authored
576
577 + (id)_binderClassForBinding:(CPString)aBinding
578 {
579 if (aBinding == CPValueBinding)
580 return [CPTableColumnValueBinder class];
40b04b7 @aljungberg Merge branch 'master' of github.com:280north/cappuccino into cacaodev…
aljungberg authored
581
235b323 @cacaodev Add CPTableColumnValueBinder. This binder subclass just reloads the t…
cacaodev authored
582 return [super _binderClassForBinding:aBinding];
583 }
584
f075430 @Me1000 Doc fixes and more docs in the tableview.
Me1000 authored
585 /*!
6a94263 @stevegeek Fixing spelling mistakes
stevegeek authored
586 Binds the receiver to an object.
f075430 @Me1000 Doc fixes and more docs in the tableview.
Me1000 authored
587
588 @param CPString aBinding - The binding you wish to make. Typically CPValueBinding.
6a94263 @stevegeek Fixing spelling mistakes
stevegeek authored
589 @param id anObject - The object to bind the receiver to.
590 @param CPString aKeyPath - The key path you wish to bind the receiver to.
591 @param CPDictionary options - A dictionary of options for the binding. This parameter is optional, pass nil if you do not wish to use it.
f075430 @Me1000 Doc fixes and more docs in the tableview.
Me1000 authored
592 */
3635d0e Bindings Checkpoint.
Ross Boucher authored
593 - (void)bind:(CPString)aBinding toObject:(id)anObject withKeyPath:(CPString)aKeyPath options:(CPDictionary)options
594 {
595 [super bind:aBinding toObject:anObject withKeyPath:aKeyPath options:options];
596
597 if (![aBinding isEqual:@"someListOfExceptedBindings(notAcceptedBindings)"])
04d33e7 @aljungberg Allow binding a table column value to an array controller reached thr…
aljungberg authored
598 {
599 // Bind the table to the array controller this column is bound to.
600 // Note that anObject might not be the array controller. E.g. the keypath could be something like
601 // somePathTo.anArrayController.arrangedObjects.aKey. Cocoa doesn't support this but it is consistent
602 // and it makes sense.
603 var acIndex = aKeyPath.lastIndexOf("arrangedObjects."),
604 arrayController = anObject;
605
606 if (acIndex > 1)
607 {
608 var firstPart = aKeyPath.substring(0, acIndex - 1);
609 arrayController = [anObject valueForKeyPath:firstPart];
610 }
611
612 [[self tableView] _establishBindingsIfUnbound:arrayController];
613 }
3635d0e Bindings Checkpoint.
Ross Boucher authored
614 }
615
f075430 @Me1000 Doc fixes and more docs in the tableview.
Me1000 authored
616 /*!
617 @ignore
618 */
76400ec @aljungberg Make table column internal bindings support methods private.
aljungberg authored
619 - (void)_prepareDataView:(CPView)aDataView forRow:(unsigned)aRow
3635d0e Bindings Checkpoint.
Ross Boucher authored
620 {
3d5232b give objects a chance to change their binder class
Klaas Pieter Annema authored
621 var bindingsDictionary = [CPBinder allBindingsForObject:self],
3635d0e Bindings Checkpoint.
Ross Boucher authored
622 keys = [bindingsDictionary allKeys];
623
7129094 always archive the table column it's dataView when it's set
Klaas Pieter Annema authored
624 for (var i = 0, count = [keys count]; i < count; i++)
3635d0e Bindings Checkpoint.
Ross Boucher authored
625 {
626 var bindingName = keys[i],
627 bindingPath = [aDataView _replacementKeyPathForBinding:bindingName],
112ad65 @aljungberg Support value transformers in CPTableColumn when using bindings.
aljungberg authored
628 binding = [bindingsDictionary objectForKey:bindingName],
629 bindingInfo = binding._info,
3635d0e Bindings Checkpoint.
Ross Boucher authored
630 destination = [bindingInfo objectForKey:CPObservedObjectKey],
8b2350f @aljungberg Optimized table data loading when using bindings for the cell values.…
aljungberg authored
631 keyPath = [bindingInfo objectForKey:CPObservedKeyPathKey],
632 dotIndex = keyPath.lastIndexOf("."),
633 value;
634
635 if (dotIndex === CPNotFound)
636 value = [[destination valueForKeyPath:keyPath] objectAtIndex:aRow];
637 else
638 {
639 /*
640 Optimize the prototypical use case where the key path describes a value
641 in an array. Without this optimization, we call CPArray's valueForKey
642 which generates as many values as objects in the array, of which we then
643 pick one and throw away the rest.
644
645 The optimization is to get the array and access the value directly. This
646 turns the operation into a single access regardless of how long the model
647 array is.
648 */
649
650 var firstPart = keyPath.substring(0, dotIndex),
7129094 always archive the table column it's dataView when it's set
Klaas Pieter Annema authored
651 secondPart = keyPath.substring(dotIndex + 1),
8b2350f @aljungberg Optimized table data loading when using bindings for the cell values.…
aljungberg authored
652 firstValue = [destination valueForKeyPath:firstPart];
653
654 if ([firstValue isKindOfClass:CPArray])
655 value = [[firstValue objectAtIndex:aRow] valueForKeyPath:secondPart];
656 else
657 value = [[firstValue valueForKeyPath:secondPart] objectAtIndex:aRow];
658 }
659
112ad65 @aljungberg Support value transformers in CPTableColumn when using bindings.
aljungberg authored
660 value = [binding transformValue:value withOptions:[bindingInfo objectForKey:CPOptionsKey]];
3d5232b give objects a chance to change their binder class
Klaas Pieter Annema authored
661 [aDataView setValue:value forKey:@"objectValue"];
3635d0e Bindings Checkpoint.
Ross Boucher authored
662 }
663 }
664
76400ec @aljungberg Make table column internal bindings support methods private.
aljungberg authored
665 /*!
666 @ignore
667 */
668 - (void)_reverseSetDataView:(CPView)aDataView forRow:(unsigned)aRow
dae36cd @aljungberg Bindings support for inline table view cell editing.
aljungberg authored
669 {
670 var bindingsDictionary = [CPBinder allBindingsForObject:self],
671 keys = [bindingsDictionary allKeys],
672 newValue = [aDataView valueForKey:@"objectValue"];
673
674 for (var i = 0, count = [keys count]; i < count; i++)
675 {
676 var bindingName = keys[i],
677 bindingPath = [aDataView _replacementKeyPathForBinding:bindingName],
678 binding = [bindingsDictionary objectForKey:bindingName],
679 bindingInfo = binding._info,
680 destination = [bindingInfo objectForKey:CPObservedObjectKey],
681 keyPath = [bindingInfo objectForKey:CPObservedKeyPathKey],
25676b4 @aljungberg Fixed: reverse value transformations were not applied for table view …
aljungberg authored
682 options = [bindingInfo objectForKey:CPOptionsKey],
dae36cd @aljungberg Bindings support for inline table view cell editing.
aljungberg authored
683 dotIndex = keyPath.lastIndexOf(".");
684
25676b4 @aljungberg Fixed: reverse value transformations were not applied for table view …
aljungberg authored
685 newValue = [binding reverseTransformValue:newValue withOptions:options];
686
dae36cd @aljungberg Bindings support for inline table view cell editing.
aljungberg authored
687 if (dotIndex === CPNotFound)
688 [[destination valueForKeyPath:keyPath] replaceObjectAtIndex:aRow withObject:newValue];
689 else
690 {
691 var firstPart = keyPath.substring(0, dotIndex),
692 secondPart = keyPath.substring(dotIndex + 1),
693 firstValue = [destination valueForKeyPath:firstPart];
694
695 if ([firstValue isKindOfClass:CPArray])
696 [[firstValue objectAtIndex:aRow] setValue:newValue forKeyPath:secondPart];
697 else
698 [[firstValue valueForKeyPath:secondPart] replaceObjectAtIndex:aRow withObject:newValue];
699 }
700 }
701 }
702
3635d0e Bindings Checkpoint.
Ross Boucher authored
703 @end
704
00c6a89 Various CPTableView improvements and nib2cib support
Tom Robinson authored
705 var CPTableColumnIdentifierKey = @"CPTableColumnIdentifierKey",
706 CPTableColumnHeaderViewKey = @"CPTableColumnHeaderViewKey",
707 CPTableColumnDataViewKey = @"CPTableColumnDataViewKey",
708 CPTableColumnWidthKey = @"CPTableColumnWidthKey",
709 CPTableColumnMinWidthKey = @"CPTableColumnMinWidthKey",
710 CPTableColumnMaxWidthKey = @"CPTableColumnMaxWidthKey",
08b06b8 implemented CPCoding support for CPSortDescriptor and made CPTableCol…
klaaspieter authored
711 CPTableColumnResizingMaskKey = @"CPTableColumnResizingMaskKey",
f73d8a5 implemented isEditable nib2cib support for CPTableColumn
Klaas Pieter Annema authored
712 CPTableColumnIsHiddenKey = @"CPTableColumnIsHiddenKey",
e586273 Fix accidental global.
Ross Boucher authored
713 CPSortDescriptorPrototypeKey = @"CPSortDescriptorPrototypeKey",
714 CPTableColumnIsEditableKey = @"CPTableColumnIsEditableKey";
00c6a89 Various CPTableView improvements and nib2cib support
Tom Robinson authored
715
716 @implementation CPTableColumn (CPCoding)
717
f075430 @Me1000 Doc fixes and more docs in the tableview.
Me1000 authored
718 /*!
719 @ignore
720 */
00c6a89 Various CPTableView improvements and nib2cib support
Tom Robinson authored
721 - (id)initWithCoder:(CPCoder)aCoder
722 {
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
723 self = [super init];
00c6a89 Various CPTableView improvements and nib2cib support
Tom Robinson authored
724
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
725 if (self)
726 {
727 _dataViewData = { };
728
4086d37 @tolmasky Slight fixes for resizing tableviews.
tolmasky authored
729 _width = [aCoder decodeFloatForKey:CPTableColumnWidthKey];
730 _minWidth = [aCoder decodeFloatForKey:CPTableColumnMinWidthKey];
731 _maxWidth = [aCoder decodeFloatForKey:CPTableColumnMaxWidthKey];
732
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
733 [self setIdentifier:[aCoder decodeObjectForKey:CPTableColumnIdentifierKey]];
8617990 Add much better support for CPTableView to nib2cib.
Ross Boucher authored
734 [self setHeaderView:[aCoder decodeObjectForKey:CPTableColumnHeaderViewKey]];
735 [self setDataView:[aCoder decodeObjectForKey:CPTableColumnDataViewKey]];
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
736
04b331a decode CPTableColumn resizing mask as integer
Klaas Pieter Annema authored
737 _resizingMask = [aCoder decodeIntForKey:CPTableColumnResizingMaskKey];
f73d8a5 implemented isEditable nib2cib support for CPTableColumn
Klaas Pieter Annema authored
738 _isHidden = [aCoder decodeBoolForKey:CPTableColumnIsHiddenKey];
739 _isEditable = [aCoder decodeBoolForKey:CPTableColumnIsEditableKey];
112ad65 @aljungberg Support value transformers in CPTableColumn when using bindings.
aljungberg authored
740
08b06b8 implemented CPCoding support for CPSortDescriptor and made CPTableCol…
klaaspieter authored
741 _sortDescriptorPrototype = [aCoder decodeObjectForKey:CPSortDescriptorPrototypeKey];
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
742 }
00c6a89 Various CPTableView improvements and nib2cib support
Tom Robinson authored
743
744 return self;
745 }
746
f075430 @Me1000 Doc fixes and more docs in the tableview.
Me1000 authored
747 /*!
748 @ignore
749 */
00c6a89 Various CPTableView improvements and nib2cib support
Tom Robinson authored
750 - (void)encodeWithCoder:(CPCoder)aCoder
ac8ecdb @tolmasky A number of CPTableView improvements, still not built by default.
tolmasky authored
751 {
00c6a89 Various CPTableView improvements and nib2cib support
Tom Robinson authored
752 [aCoder encodeObject:_identifier forKey:CPTableColumnIdentifierKey];
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
753
8fdcbac @aljungberg Fix CPTableColumn width, minWidth and maxWidth encoding.
aljungberg authored
754 [aCoder encodeFloat:_width forKey:CPTableColumnWidthKey];
755 [aCoder encodeFloat:_minWidth forKey:CPTableColumnMinWidthKey];
756 [aCoder encodeFloat:_maxWidth forKey:CPTableColumnMaxWidthKey];
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
757
8617990 Add much better support for CPTableView to nib2cib.
Ross Boucher authored
758 [aCoder encodeObject:_headerView forKey:CPTableColumnHeaderViewKey];
759 [aCoder encodeObject:_dataView forKey:CPTableColumnDataViewKey];
4086d37 @tolmasky Slight fixes for resizing tableviews.
tolmasky authored
760
8617990 Add much better support for CPTableView to nib2cib.
Ross Boucher authored
761 [aCoder encodeObject:_resizingMask forKey:CPTableColumnResizingMaskKey];
f73d8a5 implemented isEditable nib2cib support for CPTableColumn
Klaas Pieter Annema authored
762 [aCoder encodeBool:_isHidden forKey:CPTableColumnIsHiddenKey];
763 [aCoder encodeBool:_isEditable forKey:CPTableColumnIsEditableKey];
112ad65 @aljungberg Support value transformers in CPTableColumn when using bindings.
aljungberg authored
764
08b06b8 implemented CPCoding support for CPSortDescriptor and made CPTableCol…
klaaspieter authored
765 [aCoder encodeObject:_sortDescriptorPrototype forKey:CPSortDescriptorPrototypeKey];
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
766 }
767
768 @end
769
770 @implementation CPTableColumn (NSInCompatibility)
f075430 @Me1000 Doc fixes and more docs in the tableview.
Me1000 authored
771 /*!
772 @ignore
773 */
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
774 - (void)setHeaderCell:(CPView)aView
775 {
776 [CPException raise:CPUnsupportedMethodException
6bd064f @dbrajkovic Fixed errors in the incompatibility CPException reasons. For example …
dbrajkovic authored
777 reason:@"setHeaderCell: is not supported. Use -setHeaderView:aView instead."];
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
778 }
779
f075430 @Me1000 Doc fixes and more docs in the tableview.
Me1000 authored
780 /*!
781 @ignore
782 */
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
783 - (CPView)headerCell
784 {
785 [CPException raise:CPUnsupportedMethodException
6bd064f @dbrajkovic Fixed errors in the incompatibility CPException reasons. For example …
dbrajkovic authored
786 reason:@"headCell is not supported. Use -headerView instead."];
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
787 }
788
f075430 @Me1000 Doc fixes and more docs in the tableview.
Me1000 authored
789 /*!
790 @ignore
791 */
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
792 - (void)setDataCell:(CPView)aView
793 {
794 [CPException raise:CPUnsupportedMethodException
6bd064f @dbrajkovic Fixed errors in the incompatibility CPException reasons. For example …
dbrajkovic authored
795 reason:@"setDataCell: is not supported. Use -setDataView:aView instead."];
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
796 }
797
f075430 @Me1000 Doc fixes and more docs in the tableview.
Me1000 authored
798 /*!
799 @ignore
800 */
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
801 - (CPView)dataCell
802 {
803 [CPException raise:CPUnsupportedMethodException
6bd064f @dbrajkovic Fixed errors in the incompatibility CPException reasons. For example …
dbrajkovic authored
804 reason:@"dataCell is not supported. Use -dataView instead."];
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
805 }
806
f075430 @Me1000 Doc fixes and more docs in the tableview.
Me1000 authored
807 /*!
808 @ignore
809 */
528ef43 @tolmasky Beginnings of nib2cib support for new tableview.
tolmasky authored
810 - (id)dataCellForRow:(int)row
811 {
812 [CPException raise:CPUnsupportedMethodException
813 reason:@"dataCellForRow: is not supported. Use -dataViewForRow:row instead."];
ac8ecdb @tolmasky A number of CPTableView improvements, still not built by default.
tolmasky authored
814 }
00c6a89 Various CPTableView improvements and nib2cib support
Tom Robinson authored
815
01852d8 @paulbaumgart Fix a bunch of missing @imports.
paulbaumgart authored
816 @end
Something went wrong with that request. Please try again.