mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-02-23 19:51:00 +00:00
* GormCore/GormConnectionInspector.m: use custom cell class for "Outlets" browser to draw dimple image on connected outlets.
This commit is contained in:
parent
00d3f7cdc7
commit
35c2b55e35
1 changed files with 63 additions and 0 deletions
|
@ -30,6 +30,59 @@
|
|||
#include "GormPrivate.h"
|
||||
#include "GormConnectionInspector.h"
|
||||
|
||||
@interface GormConnectionCell : NSBrowserCell
|
||||
{
|
||||
BOOL isOutletConnected;
|
||||
}
|
||||
@end
|
||||
@implementation GormConnectionCell : NSBrowserCell
|
||||
|
||||
- (void) setIsOutletConnected:(BOOL)yn
|
||||
{
|
||||
isOutletConnected = yn;
|
||||
}
|
||||
|
||||
- (void) drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView *)controlView
|
||||
{
|
||||
if (isOutletConnected != NO)
|
||||
{
|
||||
NSImage *dimple_image = [NSImage imageNamed: @"common_Dimple"];
|
||||
NSRect title_rect = cellFrame;
|
||||
NSRect imgRect;
|
||||
|
||||
if ([self isHighlighted] != NO)
|
||||
{
|
||||
[[self highlightColorInView: controlView] setFill];
|
||||
NSRectFill(cellFrame);
|
||||
}
|
||||
|
||||
imgRect.size = [dimple_image size];
|
||||
imgRect.origin.x = MAX(NSMaxX(title_rect) - imgRect.size.width - 4.0, 0.);
|
||||
imgRect.origin.y = MAX(NSMidY(title_rect) - (imgRect.size.height/2.), 0.);
|
||||
|
||||
title_rect.size.width -= imgRect.size.width + 8;
|
||||
[super drawInteriorWithFrame: title_rect inView: controlView];
|
||||
|
||||
if (controlView != nil)
|
||||
{
|
||||
imgRect = [controlView centerScanRect: imgRect];
|
||||
}
|
||||
|
||||
[dimple_image drawInRect: imgRect
|
||||
fromRect: NSZeroRect
|
||||
operation: NSCompositeSourceOver
|
||||
fraction: 1.0
|
||||
respectFlipped: YES
|
||||
hints: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
[super drawInteriorWithFrame: cellFrame inView: controlView];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation GormConnectionInspector
|
||||
|
||||
- (id) init
|
||||
|
@ -63,6 +116,7 @@
|
|||
|
||||
- (void) awakeFromNib
|
||||
{
|
||||
[newBrowser setCellClass: [GormConnectionCell class]];
|
||||
[newBrowser setDoubleAction: @selector(ok:)];
|
||||
}
|
||||
|
||||
|
@ -333,6 +387,7 @@ selectCellWithString: (NSString*)title
|
|||
atRow: (NSInteger)row
|
||||
column: (NSInteger)col
|
||||
{
|
||||
[aCell setRefusesFirstResponder: YES];
|
||||
if (sender == newBrowser)
|
||||
{
|
||||
NSString *name;
|
||||
|
@ -352,6 +407,14 @@ selectCellWithString: (NSString*)title
|
|||
[aCell setLeaf: YES];
|
||||
}
|
||||
[aCell setEnabled: YES];
|
||||
|
||||
// Draws dimple for connected outlets
|
||||
for (id conn in connectors) {
|
||||
if ([name isEqualToString: [conn label]]) {
|
||||
[aCell setIsOutletConnected: YES];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue