mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 13:10:59 +00:00
Update drawing code to handle binding, add NSString private method to helpers, remove debugging code from binding connector and outline
This commit is contained in:
parent
340b95c9fa
commit
fb2f605e18
5 changed files with 67 additions and 13 deletions
|
@ -87,4 +87,8 @@
|
|||
}
|
||||
@end
|
||||
|
||||
@interface NSString (PrivatePathExtension)
|
||||
- (NSString *) stringByRemovingFirstKeyPath;
|
||||
@end
|
||||
|
||||
#endif //_GS_BINDING_HELPER_H
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#import "AppKit/NSGraphics.h"
|
||||
#import "AppKit/NSImage.h"
|
||||
#import "AppKit/NSImageView.h"
|
||||
#import "AppKit/NSKeyValueBinding.h"
|
||||
#import "AppKit/NSMenuView.h"
|
||||
#import "AppKit/NSMenuItemCell.h"
|
||||
#import "AppKit/NSOutlineView.h"
|
||||
|
@ -70,6 +71,7 @@
|
|||
|
||||
#import "GNUstepGUI/GSToolbarView.h"
|
||||
#import "GNUstepGUI/GSTitleView.h"
|
||||
#import "GSBindingHelpers.h"
|
||||
|
||||
/* a border width of 5 gives a reasonable compromise between Cocoa metrics and looking good */
|
||||
/* 7.0 gives us the NeXT Look (which is 8 pix wide including the shadow) */
|
||||
|
@ -3284,7 +3286,7 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
|
|||
{
|
||||
endingRow = numberOfRows - 1;
|
||||
}
|
||||
// NSLog(@"drawRect : %d-%d", startingRow, endingRow);
|
||||
// NSLog(@"drawRect : %d-%d", startingRow, endingRow);
|
||||
{
|
||||
SEL sel = @selector(drawRow:clipRect:);
|
||||
void (*imp)(id, SEL, NSInteger, NSRect);
|
||||
|
@ -3408,6 +3410,7 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
|
|||
{
|
||||
const BOOL columnSelected = [tableView isColumnSelected: i];
|
||||
const BOOL cellSelected = (rowSelected || columnSelected);
|
||||
|
||||
tb = [tableColumns objectAtIndex: i];
|
||||
cell = [tb dataCellForRow: rowIndex];
|
||||
[tableView _willDisplayCell: cell
|
||||
|
@ -3531,8 +3534,12 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
|
|||
NSInteger i;
|
||||
id dataSource = [outlineView dataSource];
|
||||
NSTableColumn *outlineTableColumn = [outlineView outlineTableColumn];
|
||||
GSKeyValueBinding *theBinding = nil;
|
||||
|
||||
if (dataSource == nil)
|
||||
theBinding = [GSKeyValueBinding getBinding: NSContentBinding
|
||||
forObject: outlineView];
|
||||
|
||||
if (dataSource == nil && theBinding == nil)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -3566,9 +3573,9 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
|
|||
}
|
||||
else
|
||||
{
|
||||
[cell setObjectValue: [dataSource outlineView: outlineView
|
||||
objectValueForTableColumn: tb
|
||||
byItem: item]];
|
||||
id value = [outlineView _objectValueForTableColumn: tb
|
||||
row: rowIndex];
|
||||
[cell setObjectValue: value];
|
||||
}
|
||||
|
||||
drawingRect = [outlineView frameOfCellAtColumn: i
|
||||
|
|
|
@ -122,6 +122,40 @@
|
|||
|
||||
@end
|
||||
|
||||
@implementation NSString (PrivatePathExtension)
|
||||
|
||||
- (NSString *) stringByRemovingFirstKeyPath
|
||||
{
|
||||
NSArray *components = [self componentsSeparatedByString: @"."];
|
||||
NSString *result = @"";
|
||||
NSEnumerator *en = [components objectEnumerator];
|
||||
NSString *component = nil;
|
||||
NSUInteger i = 0;
|
||||
|
||||
if ([components count] == 1)
|
||||
{
|
||||
return self;
|
||||
}
|
||||
|
||||
while ((component = [en nextObject]) != nil)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
result = [result stringByAppendingString: component];
|
||||
if ([[components lastObject] isEqual: component] == NO)
|
||||
{
|
||||
result = [result stringByAppendingString: @"."];
|
||||
}
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
static NSRecursiveLock *bindingLock = nil;
|
||||
static NSMapTable *classTable = NULL; //available bindings
|
||||
static NSMapTable *objectTable = NULL; //bound bindings
|
||||
|
|
|
@ -158,7 +158,6 @@
|
|||
if ([aDecoder containsValueForKey: @"NSBinding"])
|
||||
{
|
||||
ASSIGN(_binding, [aDecoder decodeObjectForKey: @"NSBinding"]);
|
||||
NSLog(@"_binding = %@", _binding);
|
||||
}
|
||||
if ([aDecoder containsValueForKey: @"NSKeyPath"])
|
||||
{
|
||||
|
|
|
@ -1834,12 +1834,19 @@ Also returns the child index relative to this parent. */
|
|||
|
||||
// If we have content binding the data source is used only
|
||||
// like a delegate
|
||||
GSKeyValueBinding *theBinding = [GSKeyValueBinding getBinding: NSValueBinding
|
||||
forObject: tb];
|
||||
if (theBinding != nil)
|
||||
// GSKeyValueBinding *theBinding = [GSKeyValueBinding getBinding: NSValueBinding
|
||||
// forObject: tb];
|
||||
NSDictionary *info = [GSKeyValueBinding infoForBinding: NSValueBinding forObject: tb];
|
||||
if (info != nil)
|
||||
{
|
||||
NSLog(@"theBinding = %@", theBinding);
|
||||
result = [_items objectAtIndex: index];
|
||||
id theItem = [_items objectAtIndex: index];
|
||||
NSString *ikp = [info objectForKey: @"NSObservedKeyPath"];
|
||||
NSString *keyPath = [ikp stringByRemovingFirstKeyPath];
|
||||
|
||||
// NSLog(@"info = %@, ikp = %@, keyPath = %@", info, ikp, keyPath);
|
||||
|
||||
result = [theItem valueForKeyPath: keyPath];
|
||||
// NSLog(@"result = %@", result);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2038,7 +2045,6 @@ Also returns the child index relative to this parent. */
|
|||
{
|
||||
id anitem = [children objectAtIndex: i];
|
||||
|
||||
NSLog(@"-- anitem = %@, level = %ld", anitem, level);
|
||||
[anarray addObject: anitem];
|
||||
[self _loadDictionaryStartingWith: anitem
|
||||
atLevel: level + 1];
|
||||
|
@ -2075,7 +2081,6 @@ Also returns the child index relative to this parent. */
|
|||
id anitem = [_dataSource outlineView: self
|
||||
child: i
|
||||
ofItem: startitem];
|
||||
NSLog(@"++ anitem = %@, level = %ld", anitem, level);
|
||||
[anarray addObject: anitem];
|
||||
[self _loadDictionaryStartingWith: anitem
|
||||
atLevel: level + 1];
|
||||
|
@ -2358,4 +2363,9 @@ Also returns the child index relative to this parent. */
|
|||
[autoExpanded removeAllObjects];
|
||||
}
|
||||
|
||||
- (void) awakeFromNib
|
||||
{
|
||||
[self reloadData];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue