Merge branch 'object_outline'

This commit is contained in:
Gregory John Casamento 2024-12-29 10:53:21 -05:00
commit 9f208fe4bd
21 changed files with 517 additions and 42 deletions

View file

@ -1,3 +1,20 @@
2024-12-29 Gregory John Casamento <greg.casamento@gmail.com>
* GormCore/English.lproj/GormObjectOutlineView.gorm/data.classes
* GormCore/GNUmakefile
* GormCore/GormDocument.h
* GormCore/GormDocument.m
* GormCore/GormGenericEditor.h
* GormCore/GormObjectEditor.h
* GormCore/GormObjectEditor.m
* GormCore/GormObjectMainView.h
* GormCore/GormObjectMainView.m
* GormCore/GormObjectOutlineView.h
* GormCore/GormObjectOutlineView.m
* GormCore/GormObjectViewController.h
* GormCore/GormObjectViewController.m: Add support for
outline view of objects.
2024-12-25 Gregory John Casamento <greg.casamento@gmail.com>
* GormObjCHeaderParser/OCClass.m: Improve parsing

View file

@ -0,0 +1,22 @@
{
"## Comment" = "Do NOT change this file, Gorm maintains it";
FirstResponder = {
Actions = (
"iconView:",
"outlineView:"
);
Super = NSObject;
};
GormObjectViewController = {
Actions = (
"iconView:",
"outlineView:"
);
Outlets = (
displayView,
iconButton,
outlineButton
);
Super = NSViewController;
};
}

View file

@ -69,6 +69,9 @@ GormCore_HEADER_FILES = \
GormNSWindow.h \
GormObjectEditor.h \
GormObjectInspector.h \
GormObjectMainView.h \
GormObjectOutlineView.h \
GormObjectViewController.h \
GormOpenGLView.h \
GormOutlineView.h \
GormPalettesManager.h \
@ -148,6 +151,9 @@ GormCore_OBJC_FILES = \
GormNSWindow.m \
GormObjectEditor.m \
GormObjectInspector.m \
GormObjectMainView.m \
GormObjectOutlineView.m \
GormObjectViewController.m \
GormOpenGLView.m \
GormOutlineView.m \
GormPalettesManager.m \
@ -217,6 +223,7 @@ GormCore_RESOURCE_FILES = \
Images/GormWindow.tiff \
Images/browserView.tiff \
Images/outlineView.tiff \
Images/iconView.tiff \
Resources/VersionProfiles.plist \
Resources/ClassInformation.plist
@ -237,6 +244,7 @@ GormCore_LOCALIZED_RESOURCE_FILES = \
GormInspectorPanel.gorm \
GormNSSplitViewInspector.gorm \
GormObjectInspector.gorm \
GormObjectOutlineView.gorm \
GormPalettePanel.gorm \
GormPrefColors.gorm \
GormPreferences.gorm \

View file

@ -34,7 +34,7 @@
#include <GNUstepGUI/GSNibContainer.h>
@class GormClassManager, GormClassEditor, GormObjectProxy, GormFilesOwner,
GormFilePrefsManager, GormDocumentWindow;
GormFilePrefsManager, GormDocumentWindow, GormObjectViewController;
/*
* Trivial classes for connections from objects to their editors, and from
@ -99,6 +99,9 @@
NSMutableSet *topLevelObjects;
NSMutableSet *visibleWindows;
NSMutableSet *deferredWindows;
// Controllers...
GormObjectViewController *objectViewController;
}
/* Handle notifications */

View file

@ -56,6 +56,7 @@
#import "GormDocumentWindow.h"
#import "GormDocumentController.h"
#import "GormXLIFFDocument.h"
#import "GormObjectViewController.h"
@interface NSObject (GormNSCoding)
@end
@ -326,7 +327,8 @@ static NSImage *fileImage = nil;
NSMenu *mainMenu = nil;
NSEnumerator *en = nil;
id o = nil;
NSOutlineView *outlineView = [[NSOutlineView alloc] init];
// get the window and cache it...
window = (GormDocumentWindow *)[self _docWindow];
[IBResourceManager registerForAllPboardTypes:window
@ -361,6 +363,35 @@ static NSImage *fileImage = nil;
object: window];
// objects...
NSScrollView *outlineScrollView = [[NSScrollView alloc] initWithFrame: scrollRect];
NSTableColumn *tbo = AUTORELEASE([[NSTableColumn alloc] initWithIdentifier: @"objects"]);
NSTableColumn *tbc = AUTORELEASE([[NSTableColumn alloc] initWithIdentifier: @"destination"]);
NSTableColumn *tbs = AUTORELEASE([[NSTableColumn alloc] initWithIdentifier: @"source"]);
NSTableColumn *tbcl = AUTORELEASE([[NSTableColumn alloc] initWithIdentifier: @"class"]);
NSTableColumn *tbv = AUTORELEASE([[NSTableColumn alloc] initWithIdentifier: @"version"]);
// Titles
[tbo setTitle: @"Objects"];
[tbc setTitle: @"Destination"];
[tbs setTitle: @"Source"];
[tbcl setTitle: @"Class"];
[tbv setTitle: @"Version"];
// Set up the outline view...
[outlineView setDrawsGrid: NO];
[outlineView setOutlineTableColumn: tbo];
[outlineView addTableColumn: tbo];
[outlineView addTableColumn: tbcl];
[outlineView addTableColumn: tbv];
[outlineView addTableColumn: tbc];
[outlineView addTableColumn: tbs];
[outlineScrollView setHasVerticalScroller: YES];
[outlineScrollView setHasHorizontalScroller: YES];
[outlineScrollView setAutoresizingMask:
NSViewHeightSizable|NSViewWidthSizable];
[outlineScrollView setBorderType: NSBezelBorder];
// Configure the scrollview...
mainRect.origin = NSMakePoint(0,0);
scrollView = [[NSScrollView alloc] initWithFrame: scrollRect];
[scrollView setHasVerticalScroller: YES];
@ -368,6 +399,11 @@ static NSImage *fileImage = nil;
[scrollView setAutoresizingMask:
NSViewHeightSizable|NSViewWidthSizable];
[scrollView setBorderType: NSBezelBorder];
objectViewController = [[GormObjectViewController alloc] initWithNibName: @"GormObjectOutlineView"
bundle: [NSBundle bundleForClass: [self class]]];
[objectViewController setDocument: self];
NSDebugLog(@"objectViewController = %@, view = %@", objectViewController, [objectViewController view]);
objectsView = [[GormObjectEditor alloc] initWithObject: nil
inDocument: self];
@ -375,8 +411,24 @@ static NSImage *fileImage = nil;
[objectsView setAutoresizingMask:
NSViewHeightSizable|NSViewWidthSizable];
[scrollView setDocumentView: objectsView];
RELEASE(objectsView);
RELEASE(objectsView);
[objectViewController setIconView: scrollView];
RELEASE(scrollView);
[outlineScrollView setDocumentView: outlineView];
[objectViewController setOutlineView: outlineScrollView];
[outlineView setDataSource: self];
[self deactivateEditors];
[outlineView reloadData];
[self reactivateEditors];
RELEASE(outlineView);
[[objectViewController view] setAutoresizingMask:
NSViewHeightSizable|NSViewWidthSizable];
[objectViewController resetDisplayView: scrollView];
// images...
mainRect.origin = NSMakePoint(0,0);
imagesScrollView = [[NSScrollView alloc] initWithFrame: scrollRect];
@ -417,7 +469,7 @@ static NSImage *fileImage = nil;
/*
* Set the objects view as the initial view the user's see on startup.
*/
[selectionBox setContentView: scrollView];
[selectionBox setContentView: [objectViewController view]]; //scrollView];
// add to the objects view...
[objectsView addObject: filesOwner];
@ -952,7 +1004,7 @@ static NSImage *fileImage = nil;
{
case 0: // objects
{
[selectionBox setContentView: scrollView];
[selectionBox setContentView: [objectViewController view]]; //scrollView];
[toolbar setSelectedItemIdentifier: @"ObjectsItem"];
if (![[NSApp delegate] isConnecting])
[self setSelectionFromEditor: objectsView];
@ -2608,6 +2660,9 @@ static void _real_close(GormDocument *self,
*/
- (void) touch
{
[self deactivateEditors];
[[[objectViewController outlineView] documentView] reloadData];
[self reactivateEditors];
[self updateChangeCount: NSChangeDone];
}
@ -3780,24 +3835,6 @@ static void _real_close(GormDocument *self,
}
}
/*
NSLog(@"Checking connections..."); // %@", connections);
en = [connections objectEnumerator];
o = nil;
while ((o = [en nextObject]) != nil)
{
id src = [o source];
id dst = [o destination];
NSString *label = [o label];
if ([o isKindOfClass: [NSNibControlConnector class]])
{
}
else if ([o isKindOfClass: [NSNibOutletConnector class]])
{
}
}
*/
return results;
}
@ -3917,26 +3954,145 @@ willBeInsertedIntoToolbar: (BOOL)flag
child: (NSInteger)index
ofItem: (id)item
{
return nil;
id result = nil;
[self deactivateEditors];
NSDebugLog(@"index = %ld, item = %@", index, item);
if (item == nil)
{
result = [[topLevelObjects allObjects] objectAtIndex: index];
}
else if ([item isKindOfClass: [NSWindow class]])
{
result = [item contentView];
}
else if ([item isKindOfClass: [NSView class]])
{
result = [[item subviews] objectAtIndex: index];
}
else if ([item isKindOfClass: [NSMenu class]])
{
result = [item itemAtIndex: index];
}
else if ([item isKindOfClass: [NSMenuItem class]])
{
result = [item submenu];
}
NSDebugLog(@"result = %@", result);
[self reactivateEditors];
return result;
}
- (BOOL) outlineView: (NSOutlineView *)ov
isItemExpandable: (id)item
{
return NO;
BOOL f = NO;
[self deactivateEditors];
if (item == nil)
{
f = [topLevelObjects count] > 0;
}
else if ([item isKindOfClass: [NSWindow class]])
{
f = [item contentView] != nil;
}
else if ([item isKindOfClass: [NSView class]])
{
f = [[item subviews] count] > 0;
}
else if ([item isKindOfClass: [NSMenu class]])
{
f = [item numberOfItems] > 0;
}
else if ([item isKindOfClass: [NSMenuItem class]])
{
f = [item hasSubmenu];
}
[self reactivateEditors];
NSDebugLog(@"f = %d",f);
return f;
}
- (NSInteger) outlineView: (NSOutlineView *)ov
numberOfChildrenOfItem: (id)item
{
return 0;
NSInteger c = 0;
[self deactivateEditors];
if (item == nil)
{
c = [topLevelObjects count];
}
else if ([item isKindOfClass: [NSWindow class]])
{
c = 1; // We are only counting the contentView...
}
else if ([item isKindOfClass: [NSView class]])
{
c = [[item subviews] count];
}
else if ([item isKindOfClass: [NSMenu class]])
{
c = [item numberOfItems];
}
else if ([item isKindOfClass: [NSMenuItem class]])
{
c = 1; // one submenu...
}
[self reactivateEditors];
NSDebugLog(@"c = %ld", c);
return c;
}
- (id) outlineView: (NSOutlineView *)ov
objectValueForTableColumn: (NSTableColumn *)tableColumn
byItem: (id)tem
byItem: (id)item
{
return nil;
id value = nil;
NSString *className = [classManager classNameForObject: item];
NSString *name = [self nameForObject: item];
NSUInteger version = 0;
[self deactivateEditors];
if ([[tableColumn identifier] isEqualToString: @"objects"])
{
NSString *title = @"";
if ([item respondsToSelector: @selector(title)])
{
title = [item title];
value = [NSString stringWithFormat: @"%@ : %@", title, (name != nil)?name:@"*Unnamed*"];
}
else
{
value = [NSString stringWithFormat: @"%@", (name != nil)?name:@"*Unnamed*"];
}
}
else if ([[tableColumn identifier] isEqualToString: @"class"])
{
value = className;
}
else if ([[tableColumn identifier] isEqualToString: @"version"])
{
value = [NSNumber numberWithInteger: version];
}
else if ([[tableColumn identifier] isEqualToString: @"destination"])
{
NSArray *c = [self connectorsForDestination: item];
value = [NSNumber numberWithInteger: [c count]];
}
else if ([[tableColumn identifier] isEqualToString: @"source"])
{
NSArray *c = [self connectorsForSource: item];
value = [NSNumber numberWithInteger: [c count]];
}
[self reactivateEditors];
return value;
}
// Other methods...

View file

@ -31,7 +31,7 @@
#include <InterfaceBuilder/InterfaceBuilder.h>
@interface GormGenericEditor : NSMatrix <IBEditors, IBSelectionOwners>
@interface GormGenericEditor : NSMatrix <IBEditors, IBSelectionOwners>
{
NSMutableArray *objects;
id<IBDocuments> document;

View file

@ -3,8 +3,8 @@
* Copyright (C) 1999, 2003 Free Software Foundation, Inc.
*
* Author: Richard Frith-Macdonald <richard@brainstrom.co.uk>
* Author: Gregory John Casamento <greg_casamento@yahoo.com>
* Date: 1999, 2003, 2004
* Author: Gregory John Casamento <greg.casamento@gmail.com>
* Date: 1999, 2003, 2004, 2024
*
* This file is part of GNUstep.
*
@ -26,17 +26,29 @@
#ifndef INCLUDED_GormObjectEditor_h
#define INCLUDED_GormObjectEditor_h
#include "GormGenericEditor.h"
#import "GormGenericEditor.h"
@interface NSObject (GormObjectAdditions)
- (NSImage *) imageForViewer;
- (NSString *) inspectorClassName;
- (NSString *) connectInspectorClassName;
- (NSString *) sizeInspectorClassName;
- (NSString *) helpInspectorClassName;
- (NSString *) classInspectorClassName;
- (NSString *) editorClassName;
@end
@interface GormObjectEditor : GormGenericEditor
{
}
+ (void) setEditor: (id)editor forDocument: (id<IBDocuments>)aDocument;
- (void) draggedImage: (NSImage*)i endedAt: (NSPoint)p deposited: (BOOL)f;
- (void) draggedImage: (NSImage *)i endedAt: (NSPoint)p deposited: (BOOL)f;
- (NSDragOperation) draggingSourceOperationMaskForLocal: (BOOL)flag;
- (BOOL) acceptsTypeFromArray: (NSArray*)types;
- (BOOL) acceptsTypeFromArray: (NSArray *)types;
- (void) makeSelectionVisible: (BOOL)flag;
- (void) resetObject: (id)anObject;
@end
#endif

View file

@ -34,14 +34,11 @@
#import "GormClassManager.h"
#import "GormAbstractDelegate.h"
@implementation NSObject (GormObjectAdditions)
/*
* Method to return the image that should be used to display objects within
* the matrix containing the objects in a document.
*/
@interface NSObject (GormObjectAdditions)
@end
@implementation NSObject (GormObjectAdditions)
- (NSImage*) imageForViewer
{
static NSImage *image = nil;
@ -86,6 +83,7 @@
{
return @"GormObjectEditor";
}
@end
@implementation NSView (GormObjectAdditions)
@ -105,7 +103,7 @@ static NSMapTable *docMap = 0;
{
docMap = NSCreateMapTable(NSNonRetainedObjectMapKeyCallBacks,
NSNonRetainedObjectMapValueCallBacks,
2);
2);
}
}
@ -127,7 +125,6 @@ static NSMapTable *docMap = 0;
NSMapInsert(docMap, (void*)aDocument, (void*)editor);
}
- (BOOL) acceptsTypeFromArray: (NSArray*)types
{
return ([[(GormDocument *)document allManagedPboardTypes] firstObjectCommonWithArray: types] != nil);

View file

@ -0,0 +1,48 @@
/* Definition of class GormObjectMainView
Copyright (C) 2024 Free Software Foundation, Inc.
By: Gregory John Casamento
Date: 25-12-2024
This file is part of GNUstep.
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.1 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; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
#ifndef _GormObjectMainView_h_INCLUDE
#define _GormObjectMainView_h_INCLUDE
#import <AppKit/AppKit.h>
#import <GNUstepBase/GSVersionMacros.h>
#if defined(__cplusplus)
extern "C" {
#endif
GS_EXPORT_CLASS
@interface GormObjectMainView : NSView
{
IBOutlet NSBox *contentView;
}
@end
#if defined(__cplusplus)
}
#endif
#endif /* _GormObjectMainView_h_INCLUDE */

View file

@ -0,0 +1,30 @@
/* Implementation of class GormObjectMainView
Copyright (C) 2024 Free Software Foundation, Inc.
By: Gregory John Casamento
Date: 25-12-2024
This file is part of GNUstep.
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.1 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; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
#import "GormObjectMainView.h"
@implementation GormObjectMainView
@end

View file

@ -0,0 +1,45 @@
/* Definition of class GormObjectOutlineView
Copyright (C) 2024 Free Software Foundation, Inc.
By: Gregory John Casamento
Date: 25-12-2024
This file is part of GNUstep.
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.1 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; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
#ifndef _GormObjectOutlineView_h_INCLUDE
#define _GormObjectOutlineView_h_INCLUDE
#import <AppKit/NSView.h>
#import <GNUstepBase/GSVersionMacros.h>
#if defined(__cplusplus)
extern "C" {
#endif
GS_EXPORT_CLASS
@interface GormObjectOutlineView : NSView
@end
#if defined(__cplusplus)
}
#endif
#endif /* _GormObjectOutlineView_h_INCLUDE */

View file

@ -0,0 +1,30 @@
/* Implementation of class GormObjectOutlineView
Copyright (C) 2024 Free Software Foundation, Inc.
By: Gregory John Casamento
Date: 25-12-2024
This file is part of GNUstep.
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.1 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; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
#import "GormObjectOutlineView.h"
@implementation GormObjectOutlineView
@end

View file

@ -0,0 +1,38 @@
/* All rights reserved */
#ifndef GormObjectViewController_H_INCLUDE
#define GormObjectViewController_H_INCLUDE
#import <AppKit/AppKit.h>
@class GormDocument;
@interface GormObjectViewController : NSViewController
{
IBOutlet id displayView;
IBOutlet id iconButton;
IBOutlet id outlineButton;
// Document
GormDocument *_document;
id _iconView;
id _outlineView;
}
- (GormDocument *) document;
- (void) setDocument: (GormDocument *)document;
- (id) iconView;
- (void) setIconView: (id)iconView;
- (id) outlineView;
- (void) setOutlineView: (id)outlineView;
- (void) resetDisplayView: (NSView *)view;
- (IBAction) iconView: (id)sender;
- (IBAction) outlineView: (id)sender;
@end
#endif // GormObjectViewController_H_INCLUDE

View file

@ -0,0 +1,69 @@
/* All rights reserved */
#import "GormObjectViewController.h"
#import "GormDocument.h"
#import "GormObjectEditor.h"
@implementation GormObjectViewController
- (void) dealloc
{
RELEASE(_document);
RELEASE(_iconView);
RELEASE(_outlineView);
[super dealloc];
}
- (GormDocument *) document
{
return _document;
}
- (void) setDocument: (GormDocument *)document
{
ASSIGN(_document, document);
}
- (id) iconView
{
return _iconView;
}
- (void) setIconView: (id)iconView
{
ASSIGN(_iconView, iconView);
}
- (id) outlineView
{
return _outlineView;
}
- (void) setOutlineView: (id)outlineView
{
ASSIGN(_outlineView, outlineView);
}
- (IBAction) iconView: (id)sender
{
NSLog(@"Called %@", NSStringFromSelector(_cmd));
[self resetDisplayView: _iconView];
}
- (IBAction) outlineView: (id)sender
{
NSLog(@"Called %@", NSStringFromSelector(_cmd));
[_document deactivateEditors];
[[_outlineView documentView] reloadData];
[_document reactivateEditors];
[self resetDisplayView: _outlineView];
}
- (void) resetDisplayView: (NSView *)view
{
[displayView setContentView: view];
NSLog(@"displayView = %@", view);
}
@end

Binary file not shown.