GormDocument.m

Palettes/3Containers/GNUmakefile
Palettes/3Containers/main.m
Palettes/3Containers/inspectors.m
Palettes/3Containers/GormNSTableView.m
Palettes/3Containers/GormNSTableView.h


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@13242 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Pierre-Yves Rivaille 2002-03-26 17:15:26 +00:00
parent 5f6ecd232f
commit af63d0b288
7 changed files with 229 additions and 36 deletions

View file

@ -1,3 +1,19 @@
2002-03-26 Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
* GormDocument.m ([GormDocument -init]):
Call setWidth instead of setMinWidth for non-resizable column.
Call sizeToFit on classesView.
* GormDocument.m ([GormDocument -{load, save}Document]):
Add support for GormNSTableView.
* Palettes/3Containers/GNUMakefile
* Palettes/3Containers/main.m
* Palettes/3Containers/GormNSTableView.m
* Palettes/3Containers/GormNSTableView.h
* Palettes/3Containers/inspectors.m
GormNSTableView replaces NSTableView when editing interface.
GormNSTableView features a dummy dataSource during editing and
testing.
2002-03-24 Gregory John Casamento <greg_casamento@yahoo.com>
* GormDocument.m: Minor cleanup of debug statements.

View file

@ -1187,18 +1187,20 @@ static NSImage *classesImage = nil;
tableColumn = [[NSTableColumn alloc] initWithIdentifier: @"outlets"];
[[tableColumn headerCell] setStringValue: @"O"];
[tableColumn setMinWidth: 25];
[tableColumn setWidth: 25];
[tableColumn setResizable: NO];
[classesView addTableColumn: tableColumn];
RELEASE(tableColumn);
tableColumn = [[NSTableColumn alloc] initWithIdentifier: @"actions"];
[[tableColumn headerCell] setStringValue: @"A"];
[tableColumn setMinWidth: 25];
[tableColumn setWidth: 25];
[tableColumn setResizable: NO];
[classesView addTableColumn: tableColumn];
RELEASE(tableColumn);
[classesView sizeToFit];
// expand all of the items in the classesView...
[classesView expandItem: @"NSObject"];
@ -1328,6 +1330,7 @@ static NSImage *classesImage = nil;
[u decodeClassName: @"GSCustomView" asClassName: @"GormCustomView"];
[u decodeClassName: @"NSWindow" asClassName: @"GormNSWindow"];
[u decodeClassName: @"NSBrowser" asClassName: @"GormNSBrowser"];
[u decodeClassName: @"NSTableView" asClassName: @"GormNSTableView"];
c = [u decodeObject];
if (c == nil || [c isKindOfClass: [GSNibContainer class]] == NO)
@ -1873,6 +1876,8 @@ static NSImage *classesImage = nil;
intoClassName: @"NSWindow"];
[archiver encodeClassName: @"GormNSBrowser"
intoClassName: @"NSBrowser"];
[archiver encodeClassName: @"GormNSTableView"
intoClassName: @"NSTableView"];
[archiver encodeRootObject: self];
archiveResult = [archiverData writeToFile: documentPath atomically: YES];
//archiveResult = [NSArchiver archiveRootObject: self toFile: documentPath];

View file

@ -25,8 +25,9 @@ include $(GNUSTEP_MAKEFILES)/common.make
PALETTE_NAME = 3Containers
3Containers_PALETTE_ICON = ContainersPalette
3Containers_OBJC_FILES = main.m inspectors.m GormNSBrowser.m
3Containers_HEADER_FILES = GormNSBrowser.m
3Containers_OBJC_FILES = main.m inspectors.m GormNSBrowser.m \
GormNSTableView.m
3Containers_HEADER_FILES = GormNSBrowser.h GormNSTableView.h
3Containers_PRINCIPAL_CLASS = ContainersPalette
3Containers_RESOURCE_FILES = ContainersPalette.tiff \
GormBrowserInspector.gorm \

View file

@ -0,0 +1,31 @@
/* GormNSTableView.h
Copyright (C) 2001 Free Software Foundation, Inc.
Author: Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
Date: 2001
This file is part of GNUstep.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#import <AppKit/AppKit.h>
@interface GormNSTableView : NSTableView
{
id _gormDataSource;
}
@end

View file

@ -0,0 +1,125 @@
/* GormNSTableView.m
Copyright (C) 2001 Free Software Foundation, Inc.
Author: Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
Date: 2001
This file is part of GNUstep.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#import "GormNSTableView.h"
/* ---------------------------------------------------------------
* NSTableView dataSource
*/
@interface NSTableViewDataSource: NSObject
{
}
- (int) numberOfRowsInTableView: (NSTableView *)tv;
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex;
@end
static NSString* value1[] =
{@"zero",
@"un",
@"deux",
@"trois",
@"quatre",
@"cinq",
@"six",
@"sept",
@"huit",
@"neuf"};
static NSString* value2[] =
{@"zero",
@"one",
@"two",
@"three",
@"four",
@"five",
@"six",
@"seven",
@"eight",
@"nine"};
@implementation NSTableViewDataSource
- (int) numberOfRowsInTableView: (NSTableView *)tv
{
return 10;
}
- (id)tableView:(NSTableView *)aTableView
objectValueForTableColumn:(NSTableColumn *)aTableColumn
row:(int)rowIndex
{
if ([[aTableColumn identifier] isEqualToString: @"column1"])
{
return value1[rowIndex];
}
return value2[rowIndex];
}
@end
static id _sharedDataSource = nil;
@implementation GormNSTableView
+ (id) sharedDataSource
{
if (_sharedDataSource == nil)
{
_sharedDataSource = [[NSTableViewDataSource alloc] init];
}
return _sharedDataSource;
}
- (id) initWithFrame: (NSRect) aRect
{
self = [super initWithFrame: aRect];
[super setDataSource: [GormNSTableView sharedDataSource]];
_gormDataSource = nil;
return self;
}
- (void)setDataSource: (id)anObject
{
_gormDataSource = anObject;
}
- (id)dataSource
{
return _gormDataSource;
}
- (void)encodeWithCoder: (NSCoder*) aCoder
{
_dataSource = _gormDataSource;
[super encodeWithCoder: aCoder];
_dataSource = _sharedDataSource;
}
- (id) initWithCoder: (NSCoder*) aCoder
{
self = [super initWithCoder: aCoder];
[super setDataSource: [GormNSTableView sharedDataSource]];
return self;
}
@end

View file

@ -135,6 +135,30 @@
@end
@interface GormViewSizeInspector : IBInspector
{
NSButton *top;
NSButton *bottom;
NSButton *left;
NSButton *right;
NSButton *width;
NSButton *height;
NSForm *sizeForm;
}
@end
@interface GormTableViewSizeInspector : GormViewSizeInspector
@end
@implementation GormTableViewSizeInspector
- (void) setObject: (id)anObject
{
id scrollView;
scrollView = [anObject enclosingScrollView];
[super setObject: scrollView];
}
@end
/*----------------------------------------------------------------------------
* NSTableView (possibly embedded in a Scroll view)
*/
@ -145,6 +169,11 @@
return @"GormTableViewAttributesInspector";
}
- (NSString*) sizeInspectorClassName
{
return @"GormTableViewSizeInspector";
}
@end
@interface GormTableViewAttributesInspector : IBInspector
@ -218,6 +247,8 @@
{
[object setTag:[[tagField cellAtIndex:0] intValue]];
}
[scrollView setNeedsDisplay: YES];
}
- (void) _getValuesFromObject: anObject
@ -225,7 +256,9 @@
BOOL isScrollView;
id scrollView;
scrollView = [[object superview] superview];
scrollView = //[[object superview] superview];
[object enclosingScrollView];
isScrollView = [ scrollView isKindOfClass: [NSScrollView class]];
if (anObject != object)
@ -249,7 +282,7 @@
[horizontalScrollerSwitch setEnabled: YES];
[horizontalScrollerSwitch setState:
([scrollView hasVerticalScroller]) ? NSOnState : NSOffState];
([scrollView hasHorizontalScroller]) ? NSOnState : NSOffState];
[borderMatrix setEnabled: YES];
[borderMatrix selectCellWithTag: [scrollView borderType]];

View file

@ -25,30 +25,10 @@
#include <AppKit/AppKit.h>
#include "../../Gorm.h"
#include "GormNSBrowser.h"
#include "GormNSTableView.h"
#include <math.h>
/* ---------------------------------------------------------------
* NSTableView data source
*/
@interface NSTableViewDataSource: NSObject
{
}
@end
@implementation NSTableViewDataSource
- (int)numberOfRowsInTableView:(NSTableView *)aTableView
{
return 3;
}
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
{
return [NSString stringWithFormat:@"%d",rowIndex];
}
@end
/* ---------------------------------------------------------------
* Containers Palette Display
*/
@ -113,31 +93,33 @@
//[v setAutoresizingMask: NSViewHeightSizable|NSViewWidthSizable];
contentSize = [v contentSize];
tv = [[NSTableView alloc] initWithFrame:
tv = [[GormNSTableView alloc] initWithFrame:
NSMakeRect(0,0,contentSize.width, contentSize.height)];
// [tv setDataSource: [[NSTableViewDataSource alloc] init]];
[tv setAutoresizesAllColumnsToFit: YES];
// [tv setAutoresizesAllColumnsToFit: YES];
[v setDocumentView: tv];
RELEASE(tv);
tc = [[NSTableColumn alloc] initWithIdentifier: @"table"];
tc = [[NSTableColumn alloc] initWithIdentifier: @"column1"];
[[tc headerCell] setStringValue: @" "];
[tc setWidth: contentSize.width/2];
[tc setWidth: floor(contentSize.width/2)];
[tc setMinWidth: 20];
[tc setResizable: YES];
[tc setEditable: YES];
[tv addTableColumn: tc];
RELEASE(tc);
tc = [[NSTableColumn alloc] initWithIdentifier: @"view"];
tc = [[NSTableColumn alloc] initWithIdentifier: @"column2"];
[[tc headerCell] setStringValue: @" "];
[tc setMinWidth: contentSize.width/2];
[tc setWidth: ceil(contentSize.width/2)];
[tc setMinWidth: 20];
[tc setResizable: YES];
[tc setEditable: YES];
[tv addTableColumn: tc];
RELEASE(tc);
[tv setFrame: NSMakeRect(0,0,contentSize.width, contentSize.height)];
[v setDocumentView: tv];
// [v setDocumentView: tv];
[contents addSubview: v];
RELEASE(tv);
RELEASE(v);