mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 14:31:55 +00:00
Further improvements to NSOutlineView class.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@12713 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
155a2f4124
commit
1fbdbae507
3 changed files with 55 additions and 30 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Sat Feb 23 22:07:09 2002 Gregory Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
|
* Source/NSOutlineView.m: More improvements. Expansion of
|
||||||
|
items is now partially supported.
|
||||||
|
|
||||||
Sat Feb 23 20:51:31 2002 Georg Fleischmann <georg@vhf.de>
|
Sat Feb 23 20:51:31 2002 Georg Fleischmann <georg@vhf.de>
|
||||||
|
|
||||||
* Source/NSBezierPath.m ([+bezierPath]): Return autoreleased object.
|
* Source/NSBezierPath.m ([+bezierPath]): Return autoreleased object.
|
||||||
|
|
|
@ -38,10 +38,10 @@
|
||||||
{
|
{
|
||||||
NSMutableArray *_items;
|
NSMutableArray *_items;
|
||||||
NSMutableArray *_expandedItems;
|
NSMutableArray *_expandedItems;
|
||||||
BOOL _resize;
|
BOOL _autoResizesOutlineColumn;
|
||||||
BOOL _followsCell;
|
BOOL _indentationMarkerFollowsCell;
|
||||||
BOOL _autosaveExpandedItems;
|
BOOL _autosaveExpandedItems;
|
||||||
float _indentLevel;
|
float _indentationPerLevel;
|
||||||
NSTableColumn *_outlineTableColumn;
|
NSTableColumn *_outlineTableColumn;
|
||||||
BOOL _shouldCollapse;
|
BOOL _shouldCollapse;
|
||||||
}
|
}
|
||||||
|
|
|
@ -229,12 +229,10 @@ _selectionChange (NSOutlineView *ov, id delegate, int numberOfRows,
|
||||||
{
|
{
|
||||||
[super initWithFrame: frame];
|
[super initWithFrame: frame];
|
||||||
|
|
||||||
NSLog(@"Intializing NSOutlineView");
|
_indentationMarkerFollowsCell = NO;
|
||||||
|
_autoResizesOutlineColumn = NO;
|
||||||
_resize = NO;
|
|
||||||
_followsCell = NO;
|
|
||||||
_autosaveExpandedItems = NO;
|
_autosaveExpandedItems = NO;
|
||||||
_indentLevel = 0.0;
|
_indentationPerLevel = 0.0;
|
||||||
_outlineTableColumn = nil;
|
_outlineTableColumn = nil;
|
||||||
_shouldCollapse = NO;
|
_shouldCollapse = NO;
|
||||||
_items = [NSMutableArray array];
|
_items = [NSMutableArray array];
|
||||||
|
@ -249,7 +247,7 @@ _selectionChange (NSOutlineView *ov, id delegate, int numberOfRows,
|
||||||
|
|
||||||
- (BOOL)autoResizesOutlineColumn
|
- (BOOL)autoResizesOutlineColumn
|
||||||
{
|
{
|
||||||
return _resize;
|
return _autoResizesOutlineColumn;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)autosaveExpandedItems
|
- (BOOL)autosaveExpandedItems
|
||||||
|
@ -413,6 +411,7 @@ _selectionChange (NSOutlineView *ov, id delegate, int numberOfRows,
|
||||||
const SEL shouldExpandSelector = @selector(outlineView:shouldExpandItem:);
|
const SEL shouldExpandSelector = @selector(outlineView:shouldExpandItem:);
|
||||||
BOOL canExpand = YES;
|
BOOL canExpand = YES;
|
||||||
|
|
||||||
|
NSLog(@"HELLO!!!!!!!!");
|
||||||
if([_delegate respondsToSelector: shouldExpandSelector])
|
if([_delegate respondsToSelector: shouldExpandSelector])
|
||||||
{
|
{
|
||||||
canExpand = [_delegate outlineView: self shouldExpandItem: item];
|
canExpand = [_delegate outlineView: self shouldExpandItem: item];
|
||||||
|
@ -420,7 +419,7 @@ _selectionChange (NSOutlineView *ov, id delegate, int numberOfRows,
|
||||||
|
|
||||||
if([self isExpandable: item] && ![self isItemExpanded: item] && canExpand)
|
if([self isExpandable: item] && ![self isItemExpanded: item] && canExpand)
|
||||||
{
|
{
|
||||||
NSMutableDictionary *infoDict = [NSDictionary dictionary];
|
NSMutableDictionary *infoDict = [NSMutableDictionary dictionary];
|
||||||
|
|
||||||
[infoDict setObject: item forKey: @"NSObject"];
|
[infoDict setObject: item forKey: @"NSObject"];
|
||||||
|
|
||||||
|
@ -475,12 +474,12 @@ _selectionChange (NSOutlineView *ov, id delegate, int numberOfRows,
|
||||||
|
|
||||||
- (BOOL)indentationMarkerFollowsCell
|
- (BOOL)indentationMarkerFollowsCell
|
||||||
{
|
{
|
||||||
return _followsCell;
|
return _indentationMarkerFollowsCell;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (float)indentationPerLevel
|
- (float)indentationPerLevel
|
||||||
{
|
{
|
||||||
return _indentLevel;
|
return _indentationPerLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)isExpandable: (id)item
|
- (BOOL)isExpandable: (id)item
|
||||||
|
@ -514,7 +513,7 @@ _selectionChange (NSOutlineView *ov, id delegate, int numberOfRows,
|
||||||
{
|
{
|
||||||
if(item == nil)
|
if(item == nil)
|
||||||
{
|
{
|
||||||
return -1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -547,7 +546,7 @@ _selectionChange (NSOutlineView *ov, id delegate, int numberOfRows,
|
||||||
|
|
||||||
- (void)setAutoresizesOutlineColumn: (BOOL)resize
|
- (void)setAutoresizesOutlineColumn: (BOOL)resize
|
||||||
{
|
{
|
||||||
_resize = resize;
|
_autoResizesOutlineColumn = resize;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setAutosaveExpandedItems: (BOOL)flag
|
- (void)setAutosaveExpandedItems: (BOOL)flag
|
||||||
|
@ -562,12 +561,12 @@ _selectionChange (NSOutlineView *ov, id delegate, int numberOfRows,
|
||||||
|
|
||||||
- (void)setIndentationMarkerFollowsCell: (BOOL)followsCell
|
- (void)setIndentationMarkerFollowsCell: (BOOL)followsCell
|
||||||
{
|
{
|
||||||
_followsCell = followsCell;
|
_indentationMarkerFollowsCell = followsCell;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setIndentationPerLevel: (float)newIndentLevel
|
- (void)setIndentationPerLevel: (float)newIndentLevel
|
||||||
{
|
{
|
||||||
_indentLevel = newIndentLevel;
|
_indentationPerLevel = newIndentLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setOutlineTableColumn: (NSTableColumn *)outlineTableColumn
|
- (void)setOutlineTableColumn: (NSTableColumn *)outlineTableColumn
|
||||||
|
@ -741,10 +740,10 @@ _selectionChange (NSOutlineView *ov, id delegate, int numberOfRows,
|
||||||
{
|
{
|
||||||
[super encodeWithCoder: aCoder];
|
[super encodeWithCoder: aCoder];
|
||||||
|
|
||||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_resize];
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_autoResizesOutlineColumn];
|
||||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_followsCell];
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_indentationMarkerFollowsCell];
|
||||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_autosaveExpandedItems];
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_autosaveExpandedItems];
|
||||||
[aCoder encodeValueOfObjCType: @encode(float) at: &_indentLevel];
|
[aCoder encodeValueOfObjCType: @encode(float) at: &_indentationPerLevel];
|
||||||
[aCoder encodeConditionalObject: _outlineTableColumn];
|
[aCoder encodeConditionalObject: _outlineTableColumn];
|
||||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_shouldCollapse];
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_shouldCollapse];
|
||||||
}
|
}
|
||||||
|
@ -754,10 +753,10 @@ _selectionChange (NSOutlineView *ov, id delegate, int numberOfRows,
|
||||||
// Since we only have one version....
|
// Since we only have one version....
|
||||||
self = [super initWithCoder: aDecoder];
|
self = [super initWithCoder: aDecoder];
|
||||||
|
|
||||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_resize];
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_autoResizesOutlineColumn];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_followsCell];
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_indentationMarkerFollowsCell];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_autosaveExpandedItems];
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_autosaveExpandedItems];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(float) at: &_indentLevel];
|
[aDecoder decodeValueOfObjCType: @encode(float) at: &_indentationPerLevel];
|
||||||
_outlineTableColumn = [aDecoder decodeObject];
|
_outlineTableColumn = [aDecoder decodeObject];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_shouldCollapse];
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_shouldCollapse];
|
||||||
|
|
||||||
|
@ -1291,6 +1290,11 @@ byExtendingSelection: (BOOL)flag
|
||||||
{
|
{
|
||||||
BOOL newSelection;
|
BOOL newSelection;
|
||||||
|
|
||||||
|
NSLog(@"row which was clicked %d, item %@",
|
||||||
|
_clickedRow,
|
||||||
|
[self itemAtRow: _clickedRow]);
|
||||||
|
[self expandItem: [self itemAtRow: _clickedRow]];
|
||||||
|
|
||||||
if ((modifiers & (NSShiftKeyMask | NSAlternateKeyMask))
|
if ((modifiers & (NSShiftKeyMask | NSAlternateKeyMask))
|
||||||
&& _allowsMultipleSelection)
|
&& _allowsMultipleSelection)
|
||||||
newSelection = NO;
|
newSelection = NO;
|
||||||
|
@ -1306,7 +1310,7 @@ byExtendingSelection: (BOOL)flag
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
selector = @selector (outlineView:shouldSelectRow:);
|
selector = @selector (outlineView:shouldSelectItem:);
|
||||||
if ([_delegate respondsToSelector: selector] == YES)
|
if ([_delegate respondsToSelector: selector] == YES)
|
||||||
{
|
{
|
||||||
id clickedItem = [self itemAtRow: _clickedRow];
|
id clickedItem = [self itemAtRow: _clickedRow];
|
||||||
|
@ -1628,7 +1632,6 @@ byExtendingSelection: (BOOL)flag
|
||||||
NSRect imageRect;
|
NSRect imageRect;
|
||||||
int i;
|
int i;
|
||||||
float x_pos;
|
float x_pos;
|
||||||
id item;
|
|
||||||
|
|
||||||
NSLog(@"In the drawing code...");
|
NSLog(@"In the drawing code...");
|
||||||
if (_dataSource == nil)
|
if (_dataSource == nil)
|
||||||
|
@ -1695,17 +1698,34 @@ byExtendingSelection: (BOOL)flag
|
||||||
|
|
||||||
if(tb == _outlineTableColumn)
|
if(tb == _outlineTableColumn)
|
||||||
{
|
{
|
||||||
|
NSImage *arrow = nil;
|
||||||
|
|
||||||
|
// display the correct arrow...
|
||||||
|
if([self isItemExpanded: item])
|
||||||
|
{
|
||||||
|
arrow = downArrow;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
arrow = rightArrow;
|
||||||
|
}
|
||||||
|
|
||||||
NSLog(@"outlineColumn: %@", item);
|
NSLog(@"outlineColumn: %@", item);
|
||||||
imageCell = [[NSCell alloc] initImageCell: rightArrow];
|
imageCell = [[NSCell alloc] initImageCell: arrow];
|
||||||
imageRect.origin.x = drawingRect.origin.x;
|
imageRect.origin.x = drawingRect.origin.x;
|
||||||
imageRect.origin.y = drawingRect.origin.y;
|
imageRect.origin.y = drawingRect.origin.y;
|
||||||
imageRect.size.width = [rightArrow size].width;
|
imageRect.size.width = [arrow size].width;
|
||||||
imageRect.size.height = [rightArrow size].height;
|
imageRect.size.height = [arrow size].height;
|
||||||
[imageCell drawWithFrame: imageRect inView: self];
|
|
||||||
|
// Draw the arrow if the item is expandable..
|
||||||
|
if([self isExpandable: item])
|
||||||
|
{
|
||||||
|
[imageCell drawWithFrame: imageRect inView: self];
|
||||||
|
}
|
||||||
|
|
||||||
// reformat drawing rect, so that there is no overlap
|
// reformat drawing rect, so that there is no overlap
|
||||||
drawingRect.origin.x += [rightArrow size].width + 1;
|
drawingRect.origin.x += [arrow size].width + 1;
|
||||||
drawingRect.size.width -= [rightArrow size].width + 1;
|
drawingRect.size.width -= [arrow size].width + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
[cell drawWithFrame: drawingRect inView: self];
|
[cell drawWithFrame: drawingRect inView: self];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue