mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-04-23 06:20:47 +00:00
Adding a class editor to the outline view in Gorm. Currently this
only works for viewing. I am going to add the editing functionlity later this week. GJC git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@14068 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
669022e330
commit
4955a36d4f
9 changed files with 702 additions and 13 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2002-07-08 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* GormOutlineView.[hm] : Added. This is a NSOutlineView
|
||||
subclass handles outlets and actions for the class view.
|
||||
As of this revision, you can view the actions and outlets of
|
||||
a class, but you can't edit them.
|
||||
* GormDocument.m: Modified to use new class.
|
||||
* GormInspectorsManager.m: Removed some code which was causing
|
||||
the application to dump core on exit.
|
||||
|
||||
2002-05-04 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* GormClassEditor.m: Added blank implementation of
|
||||
|
|
|
@ -103,12 +103,15 @@ Gorm_RESOURCE_FILES = \
|
|||
Images/iconTopLeft_nib.tiff \
|
||||
Images/iconTopRight_nib.tiff \
|
||||
Images/iconTop_nib.tiff \
|
||||
Images/GormAction.tiff \
|
||||
Images/GormOutlet.tiff \
|
||||
Resources/GormViewSizeInspector.gorm
|
||||
|
||||
Gorm_HEADERS = \
|
||||
Gorm.h \
|
||||
GormPrivate.h \
|
||||
GormCustomView.h
|
||||
GormCustomView.h \
|
||||
GormOutlineView.h
|
||||
|
||||
Gorm_OBJC_FILES = \
|
||||
Gorm.m \
|
||||
|
@ -126,7 +129,8 @@ Gorm_OBJC_FILES = \
|
|||
GormWindowEditor.m \
|
||||
GormClassManager.m \
|
||||
GormInspectorsManager.m \
|
||||
GormPalettesManager.m
|
||||
GormPalettesManager.m \
|
||||
GormOutlineView.m
|
||||
|
||||
-include GNUmakefile.preamble
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "GormPrivate.h"
|
||||
#include "GormClassManager.h"
|
||||
#include "GormCustomView.h"
|
||||
#include "GormOutlineView.h"
|
||||
|
||||
NSString *IBDidOpenDocumentNotification = @"IBDidOpenDocumentNotification";
|
||||
NSString *IBWillSaveDocumentNotification = @"IBWillSaveDocumentNotification";
|
||||
|
@ -1051,6 +1052,26 @@ static NSImage *classesImage = nil;
|
|||
NSButtonCell *cell;
|
||||
NSTableColumn *tableColumn;
|
||||
unsigned style;
|
||||
NSColor *salmonColor =
|
||||
[NSColor colorWithCalibratedRed: 0.850980
|
||||
green: 0.737255
|
||||
blue: 0.576471
|
||||
alpha: 1.0 ];
|
||||
NSColor *darkSalmonColor =
|
||||
[NSColor colorWithCalibratedRed: 0.568627
|
||||
green: 0.494118
|
||||
blue: 0.384314
|
||||
alpha: 1.0 ];
|
||||
NSColor *lightGreyBlueColor =
|
||||
[NSColor colorWithCalibratedRed: 0.450980
|
||||
green: 0.450980
|
||||
blue: 0.521569
|
||||
alpha: 1.0 ];
|
||||
NSColor *darkGreyBlueColor =
|
||||
[NSColor colorWithCalibratedRed: 0.333333
|
||||
green: 0.333333
|
||||
blue: 0.384314
|
||||
alpha: 1.0 ];
|
||||
|
||||
classManager = [[GormClassManager alloc] init];
|
||||
classEditor = [[GormClassEditor alloc] initWithDocument: self];
|
||||
|
@ -1183,7 +1204,7 @@ static NSImage *classesImage = nil;
|
|||
NSViewHeightSizable|NSViewWidthSizable];
|
||||
|
||||
mainRect.origin = NSMakePoint(0,0);
|
||||
classesView = [[NSOutlineView alloc] initWithFrame: mainRect];
|
||||
classesView = [[GormOutlineView alloc] initWithFrame: mainRect];
|
||||
[classesView setMenu: [(Gorm*)NSApp classMenu]];
|
||||
[classesView setDataSource: self];
|
||||
[classesView setAutoresizesAllColumnsToFit: YES];
|
||||
|
@ -1192,12 +1213,14 @@ static NSImage *classesImage = nil;
|
|||
[classesView setIndentationMarkerFollowsCell: YES];
|
||||
[classesView setAutoresizesOutlineColumn: YES];
|
||||
[classesView setIndentationPerLevel: 10];
|
||||
[classesView setAttributeOffset: 30];
|
||||
[classesView setBackgroundColor: salmonColor ];
|
||||
[classesScrollView setDocumentView: classesView];
|
||||
RELEASE(classesView);
|
||||
|
||||
tableColumn = [[NSTableColumn alloc] initWithIdentifier: @"classes"];
|
||||
[[tableColumn headerCell] setStringValue: @"Classes"];
|
||||
[tableColumn setMinWidth: 250];
|
||||
[tableColumn setMinWidth: 200];
|
||||
[tableColumn setResizable: YES];
|
||||
[tableColumn setEditable: YES];
|
||||
[classesView addTableColumn: tableColumn];
|
||||
|
@ -1206,16 +1229,18 @@ static NSImage *classesImage = nil;
|
|||
|
||||
tableColumn = [[NSTableColumn alloc] initWithIdentifier: @"outlets"];
|
||||
[[tableColumn headerCell] setStringValue: @"O"];
|
||||
[tableColumn setWidth: 25];
|
||||
[tableColumn setWidth: 45];
|
||||
[tableColumn setResizable: NO];
|
||||
[classesView addTableColumn: tableColumn];
|
||||
[classesView setOutletColumn: tableColumn];
|
||||
RELEASE(tableColumn);
|
||||
|
||||
tableColumn = [[NSTableColumn alloc] initWithIdentifier: @"actions"];
|
||||
[[tableColumn headerCell] setStringValue: @"A"];
|
||||
[tableColumn setWidth: 25];
|
||||
[tableColumn setWidth: 45];
|
||||
[tableColumn setResizable: NO];
|
||||
[classesView addTableColumn: tableColumn];
|
||||
[classesView setActionColumn: tableColumn];
|
||||
RELEASE(tableColumn);
|
||||
|
||||
[classesView sizeToFit];
|
||||
|
@ -2134,7 +2159,7 @@ objectValueForTableColumn: (NSTableColumn *)aTableColumn
|
|||
if ([identifier isEqualToString: @"classes"])
|
||||
{
|
||||
return className;
|
||||
}
|
||||
}
|
||||
else if ([identifier isEqualToString: @"outlets"])
|
||||
{
|
||||
return [NSString stringWithFormat: @"%d",
|
||||
|
@ -2202,5 +2227,19 @@ numberOfChildrenOfItem: (id)item
|
|||
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSArray *)outlineView: (GormOutlineView *)anOutlineView
|
||||
actionsForItem: (id)item
|
||||
{
|
||||
NSArray *actions = [classManager allActionsForClassNamed: item];
|
||||
return actions;
|
||||
}
|
||||
|
||||
- (NSArray *)outlineView: (GormOutlineView *)anOutlineView
|
||||
outletsForItem: (id)item
|
||||
{
|
||||
NSArray *outlets = [classManager allOutletsForClassNamed: item];
|
||||
return outlets;
|
||||
}
|
||||
@end
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
@implementation GormEmptyInspector
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(window);
|
||||
//RELEASE(window);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@
|
|||
@implementation GormMultipleInspector
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(window);
|
||||
//RELEASE(window);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@
|
|||
@implementation GormNotApplicableInspector
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(window);
|
||||
//RELEASE(window);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
@ -267,7 +267,7 @@
|
|||
[item setKeyEquivalent: @"4"];
|
||||
[item setTag: 3];
|
||||
|
||||
[popup addItemWithTitle: @"Custom Class"];
|
||||
[popup addItemWithTitle: @"Class Edit"];
|
||||
item = [popup itemAtIndex: 4];
|
||||
[item setTarget: self];
|
||||
[item setAction: @selector(setCurrentInspector:)];
|
||||
|
@ -382,7 +382,7 @@
|
|||
}
|
||||
else if ([obj isKindOfClass: [GormClassProxy class]])
|
||||
{
|
||||
[panel setTitle: [NSString stringWithFormat: @"Custom Class Inspector:%@",
|
||||
[panel setTitle: [NSString stringWithFormat: @"Class Edit Inspector:%@",
|
||||
[obj className]]];
|
||||
}
|
||||
else
|
||||
|
|
|
@ -677,6 +677,11 @@ static NSMapTable *docMap = 0;
|
|||
{
|
||||
return @"GormViewSizeInspector";
|
||||
}
|
||||
|
||||
- (NSString*) customClassInspector
|
||||
{
|
||||
return @"GormCustomClassInspector";
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GormViewSizeInspector : IBInspector
|
||||
|
@ -903,6 +908,13 @@ NSImage *mVLine = nil;
|
|||
[anObject setPostsFrameChangedNotifications: YES];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
// Custom class inspector declaration and definition
|
||||
@interface GormCustomClassInspector : IBInspector
|
||||
{
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation GormCustomClassInspector
|
||||
@end
|
||||
|
|
68
GormOutlineView.h
Normal file
68
GormOutlineView.h
Normal file
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
GormOutlineView.h
|
||||
|
||||
The outline class.
|
||||
|
||||
Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
|
||||
Author: Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
Date: July 2002
|
||||
|
||||
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 Library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; see the file COPYING.LIB.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GNUstep_H_GormOutlineView
|
||||
#define _GNUstep_H_GormOutlineView
|
||||
|
||||
#include <AppKit/NSOutlineView.h>
|
||||
#include <Foundation/NSMapTable.h>
|
||||
|
||||
@class NSTableColumn;
|
||||
|
||||
@interface GormOutlineView : NSOutlineView
|
||||
{
|
||||
float _attributeOffset;
|
||||
BOOL _isEditing;
|
||||
id _itemBeingEdited;
|
||||
NSTableColumn *_actionColumn;
|
||||
NSTableColumn *_outletColumn;
|
||||
}
|
||||
|
||||
// Instance methods
|
||||
- (float)attributeOffset;
|
||||
- (void)setAttributeOffset: (float)offset;
|
||||
- (id) itemBeingEdited;
|
||||
- (void) setItemBeingEdited: (id)item;
|
||||
- (BOOL) isEditing;
|
||||
- (void) setIsEditing: (BOOL)flag;
|
||||
- (NSTableColumn *)actionColumn;
|
||||
- (void) setActionColumn: (NSTableColumn *)ac;
|
||||
- (NSTableColumn *)outletColumn;
|
||||
- (void) setOutletColumn: (NSTableColumn *)oc;
|
||||
@end /* interface of GormOutlineView */
|
||||
|
||||
// informal protocol to define necessary methods on
|
||||
// GormOutlineView's data source to make information
|
||||
// about the class which was selected...
|
||||
@interface NSObject (GormOutlineViewDataSource)
|
||||
- (NSArray *) outlineView: (GormOutlineView *)ov
|
||||
actionsForItem: (id)item;
|
||||
- (NSArray *) outlineView: (GormOutlineView *)ov
|
||||
outletsForItem: (id)item;
|
||||
@end
|
||||
#endif /* _GNUstep_H_GormOutlineView */
|
556
GormOutlineView.m
Normal file
556
GormOutlineView.m
Normal file
|
@ -0,0 +1,556 @@
|
|||
/** <title>GormOutlineView</title>
|
||||
|
||||
<abstract>The NSOutlineView subclass in gorm which handles outlet/action editing</abstract>
|
||||
|
||||
Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
|
||||
Author: Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
Date: July 2002
|
||||
|
||||
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 Library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; see the file COPYING.LIB.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "GormOutlineView.h"
|
||||
#include <Foundation/NSNotification.h>
|
||||
#include <Foundation/NSNull.h>
|
||||
#include <AppKit/NSTableColumn.h>
|
||||
#include <AppKit/NSCell.h>
|
||||
#include <AppKit/NSEvent.h>
|
||||
#include <AppKit/NSTextFieldCell.h>
|
||||
|
||||
static NSNotificationCenter *nc = nil;
|
||||
static const int current_version = 1;
|
||||
|
||||
// Cache the arrow images...
|
||||
static NSImage *collapsed = nil;
|
||||
static NSImage *expanded = nil;
|
||||
static NSImage *unexpandable = nil;
|
||||
static NSImage *action = nil;
|
||||
static NSImage *outlet = nil;
|
||||
|
||||
// some common colors which will be used to indicate state in the outline
|
||||
// view.
|
||||
static NSColor *salmonColor = nil;
|
||||
static NSColor *darkSalmonColor = nil;
|
||||
static NSColor *lightGreyBlueColor = nil;
|
||||
static NSColor *darkGreyBlueColor = nil;
|
||||
|
||||
// a class to hold the outlet/actions so that the
|
||||
// draw row method will know how to render them on
|
||||
// the display...
|
||||
@interface GormOutletActionHolder : NSObject
|
||||
{
|
||||
NSString *_name;
|
||||
}
|
||||
- initWithName: (NSString *)name;
|
||||
- (NSString *)getName;
|
||||
@end
|
||||
|
||||
@implementation GormOutletActionHolder
|
||||
- init
|
||||
{
|
||||
[super init];
|
||||
_name = nil;
|
||||
return self;
|
||||
}
|
||||
|
||||
- initWithName: (NSString *)name
|
||||
{
|
||||
[self init];
|
||||
ASSIGN(_name,name);
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString *)getName
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation GormOutlineView
|
||||
// Initialize the class when it is loaded
|
||||
+ (void) initialize
|
||||
{
|
||||
if (self == [GormOutlineView class])
|
||||
{
|
||||
// initialize images
|
||||
[self setVersion: current_version];
|
||||
nc = [NSNotificationCenter defaultCenter];
|
||||
collapsed = [NSImage imageNamed: @"common_outlineCollapsed.tiff"];
|
||||
expanded = [NSImage imageNamed: @"common_outlineExpanded.tiff"];
|
||||
unexpandable = [NSImage imageNamed: @"common_outlineUnexpandable.tiff"];
|
||||
action = [NSImage imageNamed: @"GormAction.tiff"];
|
||||
outlet = [NSImage imageNamed: @"GormOutlet.tiff"];
|
||||
|
||||
// initialize colors
|
||||
salmonColor =
|
||||
RETAIN([NSColor colorWithCalibratedRed: 0.850980
|
||||
green: 0.737255
|
||||
blue: 0.576471
|
||||
alpha: 1.0 ]);
|
||||
darkSalmonColor =
|
||||
RETAIN([NSColor colorWithCalibratedRed: 0.568627
|
||||
green: 0.494118
|
||||
blue: 0.384314
|
||||
alpha: 1.0 ]);
|
||||
lightGreyBlueColor =
|
||||
RETAIN([NSColor colorWithCalibratedRed: 0.450980
|
||||
green: 0.450980
|
||||
blue: 0.521569
|
||||
alpha: 1.0 ]);
|
||||
darkGreyBlueColor =
|
||||
RETAIN([NSColor colorWithCalibratedRed: 0.333333
|
||||
green: 0.333333
|
||||
blue: 0.384314
|
||||
alpha: 1.0 ]);
|
||||
}
|
||||
}
|
||||
|
||||
- init
|
||||
{
|
||||
[super init];
|
||||
_actionColumn = nil;
|
||||
_outletColumn = nil;
|
||||
_isEditing = NO;
|
||||
_attributeOffset = 0.0;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
}
|
||||
|
||||
- (void)collapseItem: (id)item collapseChildren: (BOOL)collapseChildren;
|
||||
{
|
||||
if(!_isEditing)
|
||||
{
|
||||
[super collapseItem: item
|
||||
collapseChildren: collapseChildren];
|
||||
} else
|
||||
NSLog(@"Cannot collapse while editing");
|
||||
}
|
||||
|
||||
- (void)expandItem:(id)item expandChildren:(BOOL)expandChildren
|
||||
{
|
||||
if(!_isEditing)
|
||||
{
|
||||
[super expandItem: item
|
||||
expandChildren: expandChildren];
|
||||
} else
|
||||
NSLog(@"Cannot expand while editing");
|
||||
}
|
||||
|
||||
- (BOOL)_isOutletOrActionOfItemBeingEdited: (NSString *)name
|
||||
{
|
||||
NSArray *array = nil;
|
||||
array = [_dataSource outlineView: self
|
||||
actionsForItem: _itemBeingEdited];
|
||||
if([array containsObject: name])
|
||||
return YES;
|
||||
array = [_dataSource outlineView: self
|
||||
outletsForItem: _itemBeingEdited];
|
||||
if([array containsObject: name])
|
||||
return YES;
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)_openActions: (id)item
|
||||
{
|
||||
int numchildren = 0;
|
||||
int i = 0;
|
||||
int insertionPoint = 0;
|
||||
id object = nil;
|
||||
id sitem = (item == nil)?[NSNull null]:item;
|
||||
|
||||
object = [_dataSource outlineView: self
|
||||
actionsForItem: sitem];
|
||||
numchildren = [object count];
|
||||
|
||||
_numberOfRows += numchildren;
|
||||
// open the item...
|
||||
if(item != nil)
|
||||
{
|
||||
[self setItemBeingEdited: item];
|
||||
[self setIsEditing: YES];
|
||||
}
|
||||
|
||||
insertionPoint = [_items indexOfObject: item];
|
||||
if(insertionPoint == NSNotFound)
|
||||
{
|
||||
insertionPoint = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
insertionPoint++;
|
||||
}
|
||||
|
||||
[self setNeedsDisplay: YES];
|
||||
for(i=numchildren-1; i >= 0; i--)
|
||||
{
|
||||
id child = [object objectAtIndex: i]; // Add all of the children...
|
||||
GormOutletActionHolder *holder = [[GormOutletActionHolder alloc] initWithName: child];
|
||||
[_items insertObject: holder atIndex: insertionPoint];
|
||||
}
|
||||
[self noteNumberOfRowsChanged];
|
||||
}
|
||||
|
||||
- (void)_openOutlets: (id)item
|
||||
{
|
||||
int numchildren = 0;
|
||||
int i = 0;
|
||||
int insertionPoint = 0;
|
||||
id object = nil;
|
||||
id sitem = (item == nil)?[NSNull null]:item;
|
||||
|
||||
object = [_dataSource outlineView: self
|
||||
outletsForItem: sitem];
|
||||
numchildren = [object count];
|
||||
|
||||
_numberOfRows += numchildren;
|
||||
// open the item...
|
||||
if(item != nil)
|
||||
{
|
||||
[self setItemBeingEdited: item];
|
||||
[self setIsEditing: YES];
|
||||
}
|
||||
|
||||
insertionPoint = [_items indexOfObject: item];
|
||||
if(insertionPoint == NSNotFound)
|
||||
{
|
||||
insertionPoint = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
insertionPoint++;
|
||||
}
|
||||
|
||||
[self setNeedsDisplay: YES];
|
||||
for(i=numchildren-1; i >= 0; i--)
|
||||
{
|
||||
id child = [object objectAtIndex: i]; // Add all of the children...
|
||||
GormOutletActionHolder *holder = [[GormOutletActionHolder alloc] initWithName: child];
|
||||
[_items insertObject: holder atIndex: insertionPoint];
|
||||
}
|
||||
[self noteNumberOfRowsChanged];
|
||||
}
|
||||
|
||||
- (void)drawRow: (int)rowIndex clipRect: (NSRect)aRect
|
||||
{
|
||||
int startingColumn;
|
||||
int endingColumn;
|
||||
NSTableColumn *tb;
|
||||
NSRect drawingRect;
|
||||
NSCell *cell;
|
||||
NSCell *imageCell = nil;
|
||||
NSRect imageRect;
|
||||
int i;
|
||||
float x_pos;
|
||||
static BOOL drawingEditedObject = NO;
|
||||
|
||||
if (_dataSource == nil)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Using columnAtPoint: here would make it called twice per row per drawn
|
||||
rect - so we avoid it and do it natively */
|
||||
|
||||
if(rowIndex >= _numberOfRows)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Determine starting column as fast as possible */
|
||||
x_pos = NSMinX (aRect);
|
||||
i = 0;
|
||||
while ((x_pos > _columnOrigins[i]) && (i < _numberOfColumns))
|
||||
{
|
||||
i++;
|
||||
}
|
||||
startingColumn = (i - 1);
|
||||
|
||||
if (startingColumn == -1)
|
||||
startingColumn = 0;
|
||||
|
||||
/* Determine ending column as fast as possible */
|
||||
x_pos = NSMaxX (aRect);
|
||||
// Nota Bene: we do *not* reset i
|
||||
while ((x_pos > _columnOrigins[i]) && (i < _numberOfColumns))
|
||||
{
|
||||
i++;
|
||||
}
|
||||
endingColumn = (i - 1);
|
||||
|
||||
if (endingColumn == -1)
|
||||
endingColumn = _numberOfColumns - 1;
|
||||
|
||||
/* Draw the row between startingColumn and endingColumn */
|
||||
for (i = startingColumn; i <= endingColumn; i++)
|
||||
{
|
||||
if (i != _editedColumn || rowIndex != _editedRow)
|
||||
{
|
||||
id item = [self itemAtRow: rowIndex];
|
||||
id value = nil, valueforcell = nil;
|
||||
BOOL isOutletAction = NO;
|
||||
|
||||
tb = [_tableColumns objectAtIndex: i];
|
||||
cell = [tb dataCellForRow: rowIndex];
|
||||
value = [_dataSource outlineView: self
|
||||
objectValueForTableColumn: tb
|
||||
byItem: item];
|
||||
|
||||
if([value isKindOfClass: [GormOutletActionHolder class]])
|
||||
{
|
||||
valueforcell = [value getName];
|
||||
isOutletAction = YES;
|
||||
drawingEditedObject = YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
valueforcell = value;
|
||||
isOutletAction = NO;
|
||||
}
|
||||
|
||||
if ([_delegate respondsToSelector: @selector(outlineView:willDisplayCell:forTableColumn:item:)])
|
||||
{
|
||||
[_delegate outlineView: self
|
||||
willDisplayCell: cell
|
||||
forTableColumn: tb
|
||||
item: item];
|
||||
}
|
||||
|
||||
[cell setObjectValue: valueforcell];
|
||||
drawingRect = [self frameOfCellAtColumn: i
|
||||
row: rowIndex];
|
||||
|
||||
|
||||
if(isOutletAction)
|
||||
{
|
||||
drawingRect.origin.x += _attributeOffset;
|
||||
drawingRect.size.width -= _attributeOffset;
|
||||
}
|
||||
|
||||
|
||||
/* For later...
|
||||
if(drawingEditedObject)
|
||||
{
|
||||
[self setBackgroundColor: salmonColor];
|
||||
}
|
||||
else
|
||||
if(_isEditing)
|
||||
{
|
||||
[self setBackgroundColor: darkSalmonColor];
|
||||
}
|
||||
*/
|
||||
|
||||
if(tb == _outlineTableColumn && !isOutletAction)
|
||||
{
|
||||
NSImage *image = nil;
|
||||
int level = 0;
|
||||
float indentationFactor = 0.0;
|
||||
// float originalWidth = drawingRect.size.width;
|
||||
|
||||
drawingEditedObject = NO;
|
||||
// display the correct arrow...
|
||||
if([self isItemExpanded: item])
|
||||
{
|
||||
image = expanded;
|
||||
}
|
||||
else
|
||||
{
|
||||
image = collapsed;
|
||||
}
|
||||
|
||||
if(![self isExpandable: item])
|
||||
{
|
||||
image = unexpandable;
|
||||
}
|
||||
|
||||
level = [self levelForItem: item];
|
||||
indentationFactor = _indentationPerLevel * level;
|
||||
imageCell = [[NSCell alloc] initImageCell: image];
|
||||
|
||||
if(_indentationMarkerFollowsCell)
|
||||
{
|
||||
imageRect.origin.x = drawingRect.origin.x + indentationFactor;
|
||||
imageRect.origin.y = drawingRect.origin.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
imageRect.origin.x = drawingRect.origin.x;
|
||||
imageRect.origin.y = drawingRect.origin.y;
|
||||
}
|
||||
|
||||
imageRect.size.width = [image size].width;
|
||||
imageRect.size.height = [image size].height;
|
||||
|
||||
[imageCell drawWithFrame: imageRect inView: self];
|
||||
|
||||
drawingRect.origin.x += indentationFactor + [image size].width + 5;
|
||||
drawingRect.size.width -= indentationFactor + [image size].width + 5;
|
||||
|
||||
}
|
||||
|
||||
|
||||
if((tb == _actionColumn || tb == _outletColumn) && !drawingEditedObject)
|
||||
{
|
||||
NSImage *image = (tb == _actionColumn)?action:outlet;
|
||||
|
||||
// Prepare image cell...
|
||||
imageCell = [[NSCell alloc] initImageCell: image];
|
||||
imageRect.origin.x = drawingRect.origin.x;
|
||||
imageRect.origin.y = drawingRect.origin.y;
|
||||
imageRect.size.width = [image size].width;
|
||||
imageRect.size.height = [image size].height;
|
||||
[imageCell drawWithFrame: imageRect inView: self];
|
||||
|
||||
// Adjust drawing rect of cell being displayed...
|
||||
drawingRect.origin.x += [image size].width + 5;
|
||||
drawingRect.size.width -= [image size].width + 5;
|
||||
}
|
||||
|
||||
if(((tb != _outletColumn || tb != _actionColumn) && !drawingEditedObject) ||
|
||||
(tb == _outlineTableColumn))
|
||||
{
|
||||
[cell drawWithFrame: drawingRect inView: self];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) mouseDown: (NSEvent *)theEvent
|
||||
{
|
||||
NSPoint location = [theEvent locationInWindow];
|
||||
NSTableColumn *tb;
|
||||
NSImage *image = nil;
|
||||
id _clickedItem = nil;
|
||||
BOOL isActionOrOutlet = NO;
|
||||
|
||||
location = [self convertPoint: location fromView: nil];
|
||||
_clickedRow = [self rowAtPoint: location];
|
||||
_clickedColumn = [self columnAtPoint: location];
|
||||
_clickedItem = [self itemAtRow: _clickedRow];
|
||||
isActionOrOutlet = [_clickedItem isKindOfClass: [GormOutletActionHolder class]];
|
||||
|
||||
NSLog(@"clickedItem = %@",_clickedItem);
|
||||
tb = [_tableColumns objectAtIndex: _clickedColumn];
|
||||
if(tb == _actionColumn)
|
||||
{
|
||||
NSLog(@"setting action image");
|
||||
image = action;
|
||||
}
|
||||
else if (tb == _outletColumn)
|
||||
{
|
||||
NSLog(@"setting outlet image");
|
||||
image = outlet;
|
||||
}
|
||||
|
||||
if((tb == _actionColumn || tb == _outletColumn) && !_isEditing)
|
||||
{
|
||||
int position = 0;
|
||||
position += _columnOrigins[_clickedColumn] + 5;
|
||||
|
||||
if(location.x >= position && location.x <= position + [image size].width + 5)
|
||||
{
|
||||
[self setItemBeingEdited: _clickedItem];
|
||||
[self setIsEditing: YES];
|
||||
// [self setBackgroundColor: darkSalmonColor]; // for later
|
||||
if(tb == _actionColumn)
|
||||
{
|
||||
[self _openActions: _clickedItem];
|
||||
}
|
||||
else if(tb == _outletColumn)
|
||||
{
|
||||
[self _openOutlets: _clickedItem];
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(_isEditing && !isActionOrOutlet)
|
||||
{
|
||||
//id clickedItem = [self itemAtRow: _clickedRow];
|
||||
if(_clickedItem != [self itemBeingEdited] &&
|
||||
!isActionOrOutlet)
|
||||
{
|
||||
NSLog(@"RESETTING......");
|
||||
[self setItemBeingEdited: nil];
|
||||
[self setIsEditing: NO];
|
||||
[self setBackgroundColor: salmonColor];
|
||||
[self reloadData];
|
||||
}
|
||||
}
|
||||
else if(isActionOrOutlet)
|
||||
{
|
||||
NSString *name = [_clickedItem getName];
|
||||
NSLog(@"clicked on action/outlet: %@",name);
|
||||
}
|
||||
|
||||
[super mouseDown: theEvent];
|
||||
}
|
||||
|
||||
// additional methods for subclass
|
||||
- (void) setAttributeOffset: (float)offset
|
||||
{
|
||||
_attributeOffset = offset;
|
||||
}
|
||||
|
||||
- (float) attributeOffset
|
||||
{
|
||||
return _attributeOffset;
|
||||
}
|
||||
|
||||
- (void) setItemBeingEdited: (id)item
|
||||
{
|
||||
_itemBeingEdited = item;
|
||||
}
|
||||
|
||||
- (id) itemBeingEdited
|
||||
{
|
||||
return _itemBeingEdited;
|
||||
}
|
||||
|
||||
- (void) setIsEditing: (BOOL)flag
|
||||
{
|
||||
_isEditing = flag;
|
||||
}
|
||||
|
||||
- (BOOL) isEditing
|
||||
{
|
||||
return _isEditing;
|
||||
}
|
||||
|
||||
- (void)setActionColumn: (NSTableColumn *)ac
|
||||
{
|
||||
ASSIGN(_actionColumn,ac);
|
||||
}
|
||||
|
||||
- (NSTableColumn *)actionColumn
|
||||
{
|
||||
return _actionColumn;
|
||||
}
|
||||
|
||||
- (void)setOutletColumn: (NSTableColumn *)oc
|
||||
{
|
||||
ASSIGN(_outletColumn,oc);
|
||||
}
|
||||
|
||||
- (NSTableColumn *)outletColumn
|
||||
{
|
||||
return _outletColumn;
|
||||
}
|
||||
@end /* implementation of GormOutlineView */
|
||||
|
BIN
Images/GormAction.tiff
Normal file
BIN
Images/GormAction.tiff
Normal file
Binary file not shown.
BIN
Images/GormOutlet.tiff
Normal file
BIN
Images/GormOutlet.tiff
Normal file
Binary file not shown.
Loading…
Reference in a new issue