1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830
|
/** <title>NSTableHeaderView</title>
Copyright (C) 1999 Free Software Foundation, Inc.
Author: Nicola Pero <n.pero@mi.flashnet.it>
Date: December 1999
First actual coding.
Author: Nicola Pero <nicola@brainstorm.co.uk>
Date: August 2000, Semptember 2000
Selection and resizing of Columns.
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#import <Foundation/NSArray.h>
#import <Foundation/NSDebug.h>
#import <Foundation/NSRunLoop.h>
#import <Foundation/NSUserDefaults.h>
#import "AppKit/NSTableHeaderCell.h"
#import "AppKit/NSTableHeaderView.h"
#import "AppKit/NSTableColumn.h"
#import "AppKit/NSTableView.h"
#import "AppKit/NSWindow.h"
#import "AppKit/NSEvent.h"
#import "AppKit/NSApplication.h"
#import "AppKit/NSColor.h"
#import "AppKit/NSCursor.h"
#import "AppKit/NSScrollView.h"
#import "AppKit/NSGraphics.h"
#import "GSGuiPrivate.h"
#import "GNUstepGUI/GSTheme.h"
/*
* Number of pixels in either direction that will be counted as a hit
* on the column border and trigger a column resize.
*/
#define mouse_sensitivity 4
@interface NSTableView (GNUstepPrivate)
- (void) _userResizedTableColumn: (int)index
width: (float)width;
- (float *) _columnOrigins;
- (void) _mouseDownInHeaderOfTableColumn: (NSTableColumn *)tc;
- (void) _clickTableColumn: (NSTableColumn *)tc;
@end
@implementation NSTableHeaderView
/*
*
* Class methods
*
*/
+ (void) initialize
{
if (self == [NSTableColumn class])
[self setVersion: 1];
}
/*
*
* Instance methods
*
*/
/*
* Initializes an instance
*/
// TODO: Remove this method, if not really needed
- (id)initWithFrame:(NSRect)frameRect
{
self = [super initWithFrame: frameRect];
if (self == nil)
return nil;
_tableView = nil;
_resizedColumn = -1;
return self;
}
- (BOOL) isFlipped
{
return YES;
}
/*
* Setting the table view
*/
- (void)setTableView: (NSTableView*)aTableView
{
// We do not RETAIN aTableView but aTableView is supposed
// to RETAIN us.
_tableView = aTableView;
}
- (NSTableView*)tableView
{
return _tableView;
}
/*
* Checking altered columns
*/
- (NSInteger) draggedColumn
{
// TODO
return -1;
}
- (CGFloat) draggedDistance
{
// TODO
return -1;
}
- (NSInteger) resizedColumn
{
return _resizedColumn;
}
/*
* Utility methods
*/
- (NSInteger) columnAtPoint: (NSPoint)aPoint
{
if (_tableView == nil)
return -1;
/* Ask to the tableview, which is caching geometry info */
aPoint = [self convertPoint: aPoint toView: _tableView];
aPoint.y = [_tableView bounds].origin.y;
return [_tableView columnAtPoint: aPoint];
}
- (NSRect)headerRectOfColumn: (NSInteger)columnIndex
{
NSRect rect;
if (_tableView == nil)
return NSZeroRect;
/* Ask to the tableview, which is caching geometry info */
rect = [_tableView rectOfColumn: columnIndex];
rect = [self convertRect: rect fromView: _tableView];
rect.origin.y = _bounds.origin.y;
rect.size.height = _bounds.size.height;
return rect;
}
/*
* Overidden Methods
*/
- (void)drawRect: (NSRect)aRect
{
[[GSTheme theme] drawTableHeaderRect: aRect
inView: self];
}
- (void) resetCursorRects
{
if ([[self tableView] allowsColumnResizing])
{
const NSRect visibleRect = [self visibleRect];
NSInteger i;
const NSInteger count = [[[self tableView] tableColumns] count];
for (i = 0; i < (count - 1) && (count > 0); i++)
{
NSRect resizeRect = [self headerRectOfColumn: i];
resizeRect.origin.x = NSMaxX(resizeRect) - mouse_sensitivity;
resizeRect.size.width = 2 * mouse_sensitivity;
resizeRect = NSIntersectionRect(resizeRect, visibleRect);
if (!NSEqualRects(NSZeroRect, resizeRect))
{
[self addCursorRect: resizeRect cursor: [NSCursor resizeLeftRightCursor]];
}
}
}
}
/**
* In -mouseDown we intercept the mouse event to handle the
* colum resize and rearrangement. Resizing or moving columns
* will do a live resize/move of the columns by default. Users can revert to
* a "ghost" resize/move indicator by doing:
* defaults write NSGlobalDomain GSUseGhostResize YES
*/
- (void) mouseDown: (NSEvent*)event
{
NSPoint location = [event locationInWindow];
NSInteger clickCount;
NSInteger columnIndex;
NSTableColumn *currentColumn;
clickCount = [event clickCount];
/*
if (clickCount > 2)
{
return;
}
*/
location = [self convertPoint: location fromView: nil];
columnIndex = [self columnAtPoint: location];
if (columnIndex == -1)
{
return;
}
currentColumn = [[_tableView tableColumns]
objectAtIndex: columnIndex];
if (clickCount == 2)
{
[_tableView _sendDoubleActionForColumn: columnIndex];
// return;
}
// if (clickCount == 1)
{
NSRect rect = [self headerRectOfColumn: columnIndex];
/* Safety check */
if (_resizedColumn != -1)
{
NSLog(@"Bug: starting resizing of column while already resizing!");
_resizedColumn = -1;
}
if ([_tableView allowsColumnResizing])
{
/* Start resizing if the mouse is down on the bounds of a column. */
if (location.x >= NSMaxX(rect) - mouse_sensitivity)
{
if (columnIndex < [_tableView numberOfColumns])
{
_resizedColumn = columnIndex;
}
else
{
NSLog(@"Bug: Trying to resize column past the end of the table.");
}
}
else if (location.x <= NSMinX(rect) + mouse_sensitivity)
{
if (columnIndex > 0)
{
_resizedColumn = columnIndex - 1;
}
}
}
/* Resizing */
if (_resizedColumn != -1)
{
CGFloat p;
NSEvent *e;
BOOL lit;
NSUInteger eventMask;
BOOL liveResize;
/* Width of the highlighted area. */
const float divWidth = 4;
/* Coordinates of visible part of table */
CGFloat minVisCoord = NSMinX([self visibleRect]);
CGFloat maxVisCoord = NSMaxX([self visibleRect]);
NSPoint unconverted = [event locationInWindow];
NSArray *columns = [_tableView tableColumns];
/* Column on the left of resizing bound */
NSTableColumn *column = [columns objectAtIndex: _resizedColumn];
const CGFloat columnMinX = NSMinX([self headerRectOfColumn: _resizedColumn]);
const CGFloat columnMinWidth = [column minWidth];
const CGFloat columnMaxWidth = [column maxWidth];
CGFloat newColumnWidth = [column width];
CGFloat newColumnMaxX;
NSRect oldHighlightRect;
NSRect highlightRect = [self visibleRect];
highlightRect.size.width = divWidth;
/* Mouse position */
/* YES if some highlighting was done and needs to be undone */
lit = NO;
eventMask = NSLeftMouseUpMask | NSLeftMouseDraggedMask | NSPeriodicMask;
liveResize = ![[NSUserDefaults standardUserDefaults] boolForKey: @"GSUseGhostResize"];
if ([column isResizable] == NO)
{
_resizedColumn = -1;
return;
}
/* Do we need to check that we already fit into this area ?
We should */
[[NSCursor resizeLeftRightCursor] push];
if (!liveResize)
{
oldHighlightRect = NSZeroRect;
[self lockFocus];
[[NSColor lightGrayColor] set];
}
[[NSRunLoop currentRunLoop] limitDateForMode: NSEventTrackingRunLoopMode];
[NSEvent startPeriodicEventsAfterDelay: 0.05 withPeriod: 0.05];
e = [NSApp nextEventMatchingMask: eventMask
untilDate: [NSDate distantFuture]
inMode: NSEventTrackingRunLoopMode
dequeue: YES];
while ([e type] != NSLeftMouseUp)
{
if ([e type] != NSPeriodic)
{
unconverted = [e locationInWindow];
}
p = [self convertPoint: unconverted fromView: nil].x;
minVisCoord = NSMinX([self visibleRect]);
maxVisCoord = NSMaxX([self visibleRect]);
/* newColumnWidth is always positive, since we always resize
the column to the left of the mouse pointer */
newColumnWidth = (p - columnMinX);
newColumnWidth = MAX(MIN(newColumnWidth, columnMaxWidth), columnMinWidth);
newColumnMaxX = columnMinX + newColumnWidth;
if (liveResize && [column width] != newColumnWidth)
{
[_tableView _userResizedTableColumn: _resizedColumn
width: newColumnWidth];
}
else if (!liveResize)
{
highlightRect.origin.x = newColumnMaxX;
/* Only draw the divider if it is not the same as the currently
drawn one, and lies within the header view area */
if (!NSEqualRects(oldHighlightRect,highlightRect) &&
highlightRect.origin.x > [self visibleRect].origin.x &&
highlightRect.origin.x + divWidth < [self visibleRect].origin.x + [self visibleRect].size.width)
{
if (lit)
{
NSHighlightRect(oldHighlightRect);
}
NSHighlightRect(highlightRect);
[_window flushWindow];
lit = YES;
oldHighlightRect = highlightRect;
}
}
/* Scroll the tableview, if needed, so the user's desired new
column edge position lies at the edge of the visible part of
the table */
if ((p > maxVisCoord && newColumnMaxX > maxVisCoord)
|| (p < minVisCoord && newColumnMaxX < minVisCoord))
{
NSRect tvRect = [_tableView visibleRect];
if (!liveResize && lit)
{
NSHighlightRect(oldHighlightRect);
lit = NO;
[_window flushWindow];
}
if (p > maxVisCoord) /* resizing to the right */
tvRect.origin.x = newColumnMaxX - tvRect.size.width;
else /* resizing to the left */
tvRect.origin.x = newColumnMaxX;
[_tableView scrollPoint: tvRect.origin];
}
e = [NSApp nextEventMatchingMask: eventMask
untilDate: [NSDate distantFuture]
inMode: NSEventTrackingRunLoopMode
dequeue: YES];
}
[NSEvent stopPeriodicEvents];
[NSCursor pop];
if (!liveResize)
{
if (lit)
{
NSHighlightRect(oldHighlightRect);
[_window flushWindow];
}
[self unlockFocus];
/* The following tiles the table. We use a private method
which avoids tiling the table twice. */
if ([column width] != newColumnWidth)
{
[_tableView _userResizedTableColumn: _resizedColumn
width: newColumnWidth];
}
}
/* Clean up */
_resizedColumn = -1;
return;
}
/* We are not resizing
Let's launch a mouseDownInHeaderOfTableColumn message
*/
{
NSRect rect = [self headerRectOfColumn: columnIndex];
[_tableView _mouseDownInHeaderOfTableColumn:
[[_tableView tableColumns]
objectAtIndex: columnIndex]];
rect.origin.y++;
rect.size.height--;
[[currentColumn headerCell] setHighlighted: YES];
[self lockFocus];
[[currentColumn headerCell]
highlight: YES
withFrame: rect
inView: self];
[self unlockFocus];
[_window flushWindow];
}
/* Dragging */
/* Wait for mouse dragged events.
If mouse is dragged, move the column.
If mouse is not dragged but released, select/deselect the column. */
if ([_tableView allowsColumnReordering])
{
NSInteger i = columnIndex;
NSInteger j = columnIndex;
CGFloat minCoord;
CGFloat maxCoord;
CGFloat minVisCoord;
CGFloat maxVisCoord;
CGFloat *_cO;
CGFloat *_cO_minus1;
NSInteger numberOfColumns = [_tableView numberOfColumns];
NSUInteger eventMask = (NSLeftMouseUpMask
| NSLeftMouseDraggedMask
| NSPeriodicMask);
NSUInteger modifiers = [event modifierFlags];
NSEvent *e;
NSDate *distantFuture = [NSDate distantFuture];
NSRect visibleRect = [self visibleRect];
NSRect tvRect;
NSRect highlightRect = NSZeroRect, oldRect = NSZeroRect;
BOOL outside = NO;
BOOL lit = NO;
BOOL liveResize = ![[NSUserDefaults standardUserDefaults] boolForKey: @"GSUseGhostResize"];
BOOL mouseDragged = NO;
CGFloat p;
NSPoint unconverted;
minVisCoord = NSMinX (visibleRect);
maxVisCoord = NSMaxX (visibleRect);
{
NSRect bounds = [self bounds];
minCoord = NSMinX(bounds);
maxCoord = NSMaxX(bounds);
}
{
float *_c = [_tableView _columnOrigins];
_cO_minus1 = malloc((numberOfColumns + 3) * sizeof(CGFloat));
_cO = _cO_minus1 + 1;
memcpy(_cO, _c, numberOfColumns * sizeof(CGFloat));
_cO[numberOfColumns] = maxCoord;
_cO[numberOfColumns + 1] = maxCoord;
_cO[-1] = minCoord;
}
highlightRect.size.height = NSHeight (visibleRect);
highlightRect.origin.y = NSMinY (visibleRect);
if (!liveResize)
{
[self lockFocus];
[[NSColor lightGrayColor] set];
}
[NSEvent startPeriodicEventsAfterDelay: 0.05
withPeriod: 0.05];
e = [NSApp nextEventMatchingMask: eventMask
untilDate: distantFuture
inMode: NSEventTrackingRunLoopMode
dequeue: YES];
while ([e type] != NSLeftMouseUp)
{
switch ([e type])
{
case NSLeftMouseDragged:
unconverted = [e locationInWindow];
p = [self convertPoint: unconverted fromView: nil].x;
if (mouseDragged == NO)
{
NSLog(@"TODO: Deselect the column");
}
mouseDragged = YES;
if (p < minVisCoord || p > maxVisCoord)
{
outside = YES;
}
else
{
outside = NO;
i = j;
if (p > (_cO[i] + _cO[i+1]) / 2)
{
while (p > (_cO[i] + _cO[i+1]) / 2)
i++;
}
else if (p < (_cO[i] + _cO[i-1]) / 2)
{
while (p < (_cO[i] + _cO[i-1]) / 2)
i--;
}
if (!liveResize)
{
if (i != columnIndex
&& i != columnIndex + 1)
{
j = i;
highlightRect.size.height = NSHeight (visibleRect);
highlightRect.origin.y = NSMinY (visibleRect);
highlightRect.size.width = 7;
if (i == numberOfColumns)
{
highlightRect.origin.x = _cO[i] - 3;
}
else if (i == 0)
{
highlightRect.origin.x = _cO[i] - 3;
}
else
{
highlightRect.origin.x = _cO[i] - 3;
}
if (!NSEqualRects(highlightRect, oldRect))
{
if (lit)
NSHighlightRect(oldRect);
NSHighlightRect(highlightRect);
[_window flushWindow];
}
else if (!lit)
{
NSHighlightRect(highlightRect);
[_window flushWindow];
}
oldRect = highlightRect;
lit = YES;
}
else
{
i = columnIndex;
highlightRect.size.height = NSHeight (visibleRect);
highlightRect.origin.y = NSMinY (visibleRect);
highlightRect.origin.x = _cO[columnIndex];
highlightRect.size.width =
_cO[columnIndex + 1] - _cO[columnIndex];
if (!NSEqualRects(highlightRect, oldRect))
{
if (lit)
NSHighlightRect(oldRect);
// NSHighlightRect(highlightRect);
[_window flushWindow];
}
else if (!lit)
{
// NSHighlightRect(highlightRect);
// [_window flushWindow];
}
// oldRect = highlightRect;
oldRect = NSZeroRect;
lit = NO; //lit = YES;
}
}
else if (liveResize)
{
if (i > columnIndex)
i--;
if (i != columnIndex)
{
[_tableView moveColumn: columnIndex
toColumn: i];
}
columnIndex = i;
}
}
break;
case NSPeriodic:
if (outside == YES)
{
if (!liveResize)
{
if (lit)
{
NSHighlightRect(oldRect);
[_window flushWindow];
lit = NO;
oldRect = NSZeroRect;
}
}
p = [self convertPoint: unconverted
fromView: nil].x;
tvRect = [_tableView visibleRect];
if (p > maxVisCoord)
{
if (p > maxCoord)
tvRect.origin.x += (p - maxVisCoord)/8;
else
tvRect.origin.x += (p - maxVisCoord)/2;
}
else if (p < minVisCoord)
{
if (p < minCoord)
tvRect.origin.x += (p - minVisCoord)/8;
else
tvRect.origin.x += (p - minVisCoord)/2;
}
else // TODO remove this condition
{
NSLog(@"not outside !");
}
[_tableView scrollPoint: tvRect.origin];
visibleRect = [self visibleRect];
minVisCoord = NSMinX (visibleRect);
maxVisCoord = NSMaxX (visibleRect);
}
break;
default:
break;
}
e = [NSApp nextEventMatchingMask: eventMask
untilDate: distantFuture
inMode: NSEventTrackingRunLoopMode
dequeue: YES];
}
if (!liveResize)
{
if (lit)
{
NSHighlightRect(highlightRect);
[_window flushWindow];
}
[self unlockFocus];
}
[NSEvent stopPeriodicEvents];
if (mouseDragged == NO)
{
[_tableView _selectColumn: columnIndex modifiers: modifiers];
[_tableView _clickTableColumn: currentColumn];
[self setNeedsDisplay: YES];;
}
else // mouseDragged == YES
{
{
NSRect rect = [self headerRectOfColumn: columnIndex];
[_tableView _mouseDownInHeaderOfTableColumn:
[[_tableView tableColumns]
objectAtIndex: columnIndex]];
rect.origin.y++;
rect.size.height--;
[[currentColumn headerCell]
setHighlighted: NO];
[self lockFocus];
[[currentColumn headerCell]
highlight: NO
withFrame: rect
inView: self];
[self unlockFocus];
[_window flushWindow];
}
if (i > columnIndex)
i--;
if (i != columnIndex)
{
[_tableView moveColumn: columnIndex
toColumn: i];
}
}
free(_cO_minus1);
return;
}
else
{
NSRect cellFrame = [self headerRectOfColumn: columnIndex];
NSApplication *theApp = [NSApplication sharedApplication];
NSUInteger modifiers = [event modifierFlags];
NSPoint location = [event locationInWindow];
NSPoint point = [self convertPoint: location fromView: nil];
if (![self mouse: point inRect: cellFrame])
{
NSLog(@"not in frame, what's happening ?");
return;
}
event = [theApp nextEventMatchingMask: NSLeftMouseUpMask
untilDate: [NSDate distantFuture]
inMode: NSEventTrackingRunLoopMode
dequeue: NO];
location = [event locationInWindow];
point = [self convertPoint: location fromView: nil];
if (![self mouse: point inRect: cellFrame])
{
NSDebugLLog(@"NSCell",
@"tableheaderview point not in cell frame\n");
{
NSRect rect = [self headerRectOfColumn: columnIndex];
[_tableView _mouseDownInHeaderOfTableColumn:
[[_tableView tableColumns]
objectAtIndex: columnIndex]];
rect.origin.y++;
rect.size.height--;
[[currentColumn headerCell]
setHighlighted: NO];
[self lockFocus];
[[currentColumn headerCell]
highlight: NO
withFrame: rect
inView: self];
[self unlockFocus];
[_window flushWindow];
}
}
else
{
[_tableView _selectColumn: columnIndex modifiers: modifiers];
[_tableView _clickTableColumn: currentColumn];
[self setNeedsDisplay: YES];
/*
if ([_tableView highlightedTableColumn] != currentColumn)
{
NSRect rect = [self headerRectOfColumn: columnIndex];
// [_tableView _mouseDownInHeaderOfTableColumn:
// [[_tableView tableColumns]
// objectAtIndex: columnIndex]];
rect.origin.y++;
rect.size.height--;
NSLog(@"highlight");
[[currentColumn headerCell] setHighlighted: NO];
[[currentColumn headerCell]
highlight: NO
withFrame: rect
inView: self];
[_window flushWindow];
}
*/
}
}
}
}
/*
* Encoding/Decoding
*/
- (void) encodeWithCoder: (NSCoder*)aCoder
{
[super encodeWithCoder: aCoder];
/* Nothing else to encode in NSTableHeaderView:
- _tableView is set by the parent NSTableView
- _resizedColumn is reset on decoding anyway
*/
}
- (id) initWithCoder: (NSCoder*)aDecoder
{
self = [super initWithCoder: aDecoder];
if (self == nil)
return nil;
// NOTE: some xib's can have unintuitive load orders where
// the above -initWithCoder: call causes the receiver's assocaited
// table view to be loaded, which calls -[self setTableView:].
// So at this point, _tableView might already have been set,
// so we must not set it to nil here.
_resizedColumn = -1;
return self;
}
@end
|