* Palettes/3Containers/GNUmakefile

* Palettes/3Containers/main.m
* Palettes/3Containers/GormNSBrowser.m
* Palettes/3Containers/GormNSBrowser.h
* Gorm.m
* GormDocument.m
Subclass of NSBrowser and NSTableView to be able to set the
delegate for runtime only (there is a dummy delegate for edit-time
and test-time). Those classes are encoded as NSBrowser/NSTableView
and NSTableView/NSBrowser are decoded as GormNSBrowser/GormNSTableView

* Palettes/1Windows/GNUmakefile
* Palettes/1Windows/GormNSWindow.h
* Palettes/1Windows/GormNSWindow.m
* Palettes/1Windows/main.m
* GormDocument.m
* Gorm.m
Subclass of NSWindow to be able to choose the stylemask
and to still be able to resize/close/minimize the window in the editor
regardless of the stylemask. This class is encoded as NSWindow and
NSWindow is decoded as GormNSWindow.

* GormDocument.m ([-attachObect:toParent]):
NSTableView & NSTextView objects contained in NSScrollView are now
added. Connections to and from those objects are now available.

* GormWindowEditor.m: new bestKnownSuperview function
(original patch from Stefan Urbanek <stefanurbanek@yahoo.fr>
modified to let the user select the NSScrollView or the NSTextView/
NSTableView contained within the NSScrollView).

* Palettes/3Containers/inspectors.m
* Palettes/3Containers/GormBrowserInspector.gorm
* Palettes/3Containers/GormTableViewInspector.gorm
NSTableView and NSBrowser inspectors updated (new tag field)
(patch from Stefan Urbanek <stefanurbanek@yahoo.fr>)


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@12559 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Pierre-Yves Rivaille 2002-02-18 12:37:26 +00:00
parent 132a6d6d2d
commit ef475a3451
15 changed files with 436 additions and 68 deletions

View file

@ -1,3 +1,42 @@
2002-02-18 Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
* Palettes/3Containers/GNUmakefile
* Palettes/3Containers/main.m
* Palettes/3Containers/GormNSBrowser.m
* Palettes/3Containers/GormNSBrowser.h
* Gorm.m
* GormDocument.m
Subclass of NSBrowser and NSTableView to be able to set the
delegate for runtime only (there is a dummy delegate for edit-time
and test-time). Those classes are encoded as NSBrowser/NSTableView
and NSTableView/NSBrowser are decoded as GormNSBrowser/GormNSTableView
* Palettes/1Windows/GNUmakefile
* Palettes/1Windows/GormNSWindow.h
* Palettes/1Windows/GormNSWindow.m
* Palettes/1Windows/main.m
* GormDocument.m
* Gorm.m
Subclass of NSWindow to be able to choose the stylemask
and to still be able to resize/close/minimize the window in the editor
regardless of the stylemask. This class is encoded as NSWindow and
NSWindow is decoded as GormNSWindow.
* GormDocument.m ([-attachObect:toParent]):
NSTableView & NSTextView objects contained in NSScrollView are now
added. Connections to and from those objects are now available.
* GormWindowEditor.m: new bestKnownSuperview function
(original patch from Stefan Urbanek <stefanurbanek@yahoo.fr>
modified to let the user select the NSScrollView or the NSTextView/
NSTableView contained within the NSScrollView).
* Palettes/3Containers/inspectors.m
* Palettes/3Containers/GormBrowserInspector.gorm
* Palettes/3Containers/GormTableViewInspector.gorm
NSTableView and NSBrowser inspectors updated (new tag field)
(patch from Stefan Urbanek <stefanurbanek@yahoo.fr>)
2002-01-30 Adam Fedor <fedor@gnu.org>
* Version: 0.1.0

15
Gorm.m
View file

@ -300,8 +300,8 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
/*
* Erase image from old location.
*/
r.origin.x -= 1.0;
r.origin.y += 1.0;
r.origin.y -= 1.0;
r.origin.x += 1.0;
r.size = [sourceImage size];
r.size.width += 2.0;
r.size.height += 2.0;
@ -1029,11 +1029,17 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
GormDocument *a = (GormDocument*)[self activeDocument];
NSData *d;
NSArchiver *archiver;
archiver = [[NSArchiver alloc] init];
[a beginArchiving];
d = [NSArchiver archivedDataWithRootObject: a];
[archiver encodeClassName: @"GormNSWindow"
intoClassName: @"NSWindow"];
[archiver encodeRootObject: a];
d = RETAIN([archiver archiverData]);
[a endArchiving];
RELEASE(archiver);
[nc postNotificationName: IBWillBeginTestingInterfaceNotification
object: self];
@ -1091,6 +1097,7 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
[nc postNotificationName: IBDidBeginTestingInterfaceNotification
object: self];
RELEASE(d);
return self;
}
}

View file

@ -181,6 +181,7 @@ static NSImage *classesImage = nil;
{
[self setName: nil forObject: anObject];
}
NSLog(@"%@", anObject);
/*
* Add top-level objects to objectsView and open their editors.
*/
@ -195,6 +196,28 @@ static NSImage *classesImage = nil;
[anObject setReleasedWhenClosed: NO];
}
}
/*
* if this a scrollview, it is interesting to add its contentview
* if it is a tableview or a textview
*/
if (([anObject isKindOfClass: [NSScrollView class]] == YES)
&& ([(NSScrollView *)anObject documentView] != nil))
{
if ([[anObject documentView] isKindOfClass:
[NSTableView class]] == YES)
{
[self attachObject: [anObject documentView]
toParent: aParent];
}
else if ([[anObject documentView] isKindOfClass:
[NSTextView class]] == YES)
{
[self attachObject: [anObject documentView]
toParent: aParent];
}
}
}
- (void) attachObjects: (NSArray*)anArray toParent: (id)aParent
@ -1299,6 +1322,8 @@ static NSImage *classesImage = nil;
[u decodeClassName: @"GSNibContainer" asClassName: @"GormDocument"];
[u decodeClassName: @"GSNibItem" asClassName: @"GormObjectProxy"];
[u decodeClassName: @"GSCustomView" asClassName: @"GormCustomView"];
[u decodeClassName: @"NSWindow" asClassName: @"GormNSWindow"];
[u decodeClassName: @"NSBrowser" asClassName: @"GormNSBrowser"];
c = [u decodeObject];
if (c == nil || [c isKindOfClass: [GSNibContainer class]] == NO)
@ -1564,10 +1589,11 @@ static NSImage *classesImage = nil;
unsigned style = NSTitledWindowMask | NSClosableWindowMask
| NSResizableWindowMask | NSMiniaturizableWindowMask;
aWindow = [[NSWindow alloc] initWithContentRect: NSMakeRect(0,0,600, 400)
styleMask: style
backing: NSBackingStoreRetained
defer: NO];
aWindow = [[NSWindow allocSubstitute]
initWithContentRect: NSMakeRect(0,0,600, 400)
styleMask: style
backing: NSBackingStoreRetained
defer: NO];
[aWindow setFrameTopLeftPoint:
NSMakePoint(220, frame.size.height-100)];
[aWindow setTitle: @"My Window"];
@ -1835,6 +1861,10 @@ static NSImage *classesImage = nil;
[archiver encodeClassName: @"GormObjectProxy" intoClassName: @"GSNibItem"];
[archiver encodeClassName: @"GormCustomView"
intoClassName: @"GSCustomView"];
[archiver encodeClassName: @"GormNSWindow"
intoClassName: @"NSWindow"];
[archiver encodeClassName: @"GormNSBrowser"
intoClassName: @"NSBrowser"];
[archiver encodeRootObject: self];
archiveResult = [archiverData writeToFile: documentPath atomically: YES];
//archiveResult = [NSArchiver archiveRootObject: self toFile: documentPath];

View file

@ -62,6 +62,72 @@ _constrainPointToBounds(NSPoint point, NSRect bounds)
return point;
}
@class GSTableCornerView;
static NSView *bestKnownSuperview(NSView *aView)
{
NSView *best = aView;
NSView *view = aView;
NSLog(@"Convert %@", aView);
if ([view isKindOfClass:[NSTableHeaderView class]])
{
return [view tableView];
}
else if ([view isKindOfClass:[GSTableCornerView class]])
{
if ([view enclosingScrollView] != nil)
return [view enclosingScrollView];
}
else if ([view isKindOfClass:[NSScroller class]])
{
if ([view enclosingScrollView] != nil)
{
if ([[view enclosingScrollView] documentView]
&& ([[[view enclosingScrollView] documentView]
isKindOfClass: [NSTableView class]]
|| [[[view enclosingScrollView] documentView]
isKindOfClass: [NSTextView class]])
)
return [view enclosingScrollView];
}
}
while( view )
{
if([view isKindOfClass:[NSBrowser class]]
|| [view isKindOfClass:[NSTextView class]]
|| [view isKindOfClass:[NSTableView class]])
{
best = view;
break;
}
else if([view isKindOfClass:[NSScrollView class]])
{
best = view;
}
view = [view superview];
}
if([best isKindOfClass:[NSScrollView class]])
{
view = [best contentView];
if([view isKindOfClass:[NSClipView class]])
{
view = [view documentView];
if([view isKindOfClass:[NSTextView class]]
|| [view isKindOfClass:[NSTableView class]])
{
return view;
}
}
}
return best;
}
@implementation NSWindow (GormObjectAdditions)
- (NSString*) editorClassName
{
@ -1388,6 +1454,8 @@ static BOOL done_editing;
NSPoint loc = [sender draggingLocation];
NSView *sub = [super hitTest: loc];
sub = bestKnownSuperview(sub);
if (sub == self)
{
sub = nil;
@ -1396,6 +1464,7 @@ static BOOL done_editing;
{
sub = nil;
}
// NSLog(@"DST %@",sub);
[NSApp displayConnectionBetween: [NSApp connectSource] and: sub];
return NSDragOperationLink;
}
@ -1604,6 +1673,10 @@ static BOOL done_editing;
NSPoint loc = [sender draggingLocation];
NSView *sub = [super hitTest: loc];
sub = bestKnownSuperview(sub);
// NSLog(@"DST %@",sub);
[NSApp displayConnectionBetween: [NSApp connectSource] and: sub];
[NSApp startConnecting];
}

View file

@ -25,7 +25,8 @@ include $(GNUSTEP_MAKEFILES)/common.make
PALETTE_NAME = 1Windows
1Windows_PALETTE_ICON = WindowsPalette
1Windows_OBJC_FILES = main.m
1Windows_OBJC_FILES = main.m GormNSWindow.m
1Windows_HEADER_FILES = GormNSWindow.h
1Windows_PRINCIPAL_CLASS = WindowsPalette
1Windows_RESOURCE_FILES = WindowsPalette.tiff WindowDrag.tiff \
GormWindowSizeInspector.gorm \

View file

@ -0,0 +1,33 @@
/* GormWindow.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 GormNSWindow : NSWindow
{
unsigned _gormStyleMask;
}
- (void)setStyleMask: (unsigned) newStyleMask;
- (unsigned)styleMask;
@end

View file

@ -0,0 +1,63 @@
/* GormWindow.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 <AppKit/AppKit.h>
#import "GormNSWindow.h"
@implementation GormNSWindow
- (void)encodeWithCoder: (NSCoder*) aCoder
{
unsigned oldStyleMask;
oldStyleMask = _styleMask;
_styleMask = _gormStyleMask;
[super encodeWithCoder: aCoder];
_styleMask = oldStyleMask;
}
- (id) initWithContentRect: (NSRect)contentRect
styleMask: (unsigned int)aStyle
backing: (NSBackingStoreType)bufferingType
defer: (BOOL)flag
screen: (NSScreen*)aScreen
{
_gormStyleMask = aStyle;
return [super initWithContentRect: contentRect
styleMask: NSTitledWindowMask | NSClosableWindowMask
| NSResizableWindowMask | NSMiniaturizableWindowMask
backing: bufferingType
defer: flag
screen: aScreen];
}
- (void)setStyleMask: (unsigned) newStyleMask
{
_gormStyleMask = newStyleMask;
}
- (unsigned)styleMask
{
return _gormStyleMask;
}
@end

View file

@ -24,6 +24,7 @@
#include <Foundation/Foundation.h>
#include <AppKit/AppKit.h>
#include "../../GormPrivate.h"
#include "GormNSWindow.h"
@interface GormWindowMaker : NSObject <NSCoding>
{
@ -41,10 +42,10 @@
unsigned style = NSTitledWindowMask | NSClosableWindowMask
| NSResizableWindowMask | NSMiniaturizableWindowMask;
w = [[NSWindow alloc] initWithContentRect: NSMakeRect(0, 0, 500, 300)
styleMask: style
backing: NSBackingStoreRetained
defer: NO];
w = [[GormNSWindow alloc] initWithContentRect: NSMakeRect(0, 0, 500, 300)
styleMask: style
backing: NSBackingStoreRetained
defer: NO];
[w setTitle: @"Window"];
RELEASE(self);
return w;
@ -131,11 +132,19 @@
/* ---------------------------------------------------------
NSwindow inspector
---------------------------------------------------------*/
@implementation NSWindow (GormPrivate)
+ (id) allocSubstitute
{
return [GormNSWindow alloc];
}
@end
/*
@interface NSWindow (GormPrivate)
- (void) _setStyleMask: (unsigned int)mask;
@end
@implementation NSWindow (GormPrivate)
*/
/*
@implementation GormWindow (GormPrivate)
// private method to change the Window style mask on the fly
- (void) _setStyleMask: (unsigned int)mask
{
@ -143,8 +152,8 @@ NSwindow inspector
DPSstylewindow(GSCurrentContext(), mask, [self windowNumber]);
}
@end
@implementation NSWindow (IBInspectorClassNames)
*/
@implementation GormNSWindow (IBInspectorClassNames)
- (NSString*) inspectorClassName
{
return @"GormWindowAttributesInspector";
@ -194,7 +203,7 @@ NSwindow inspector
newStyleMask &= ~[[control cellAtRow: i column: 0] tag];
}
[object _setStyleMask: newStyleMask];
[object setStyleMask: newStyleMask];
// FIXME: This doesn't refresh the window decoration. How to do that?
// (currently needs manual hide/unhide to update decorations)
[object display];

View file

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

View file

@ -0,0 +1,31 @@
/* GormNSBrowser.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 GormNSBrowser : NSBrowser
{
id _gormDelegate;
}
@end

View file

@ -0,0 +1,113 @@
/* GormNSBrowser.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 "GormNSBrowser.h"
/* ---------------------------------------------------------------
* NSBrowser Delegate
*/
@interface NSBrowserDelegate: NSObject
{
}
- (int) browser: (NSBrowser *)sender numberOfRowsInColumn: (int)column;
- (NSString *) browser: (NSBrowser *)sender titleOfColumn: (int)column;
- (void) browser: (NSBrowser *)sender willDisplayCell: (id)cell
atRow: (int)row column: (int)column;
@end
@implementation NSBrowserDelegate
- (int) browser: (NSBrowser *)sender numberOfRowsInColumn: (int)column
{
return 0;
}
- (NSString *) browser: (NSBrowser *)sender titleOfColumn: (int)column
{
return (column==0) ? @"Browser" : @"";
}
- (void) browser: (NSBrowser *)sender
willDisplayCell: (id)cell
atRow: (int)row
column: (int)column
{
NSDebugLog(@"<%@ %x>: browser %x will display %@ %x at %d,%d",[self class],self,sender,[cell class],cell,row,column);
// This code should never be called because there is no row
// in our browser. But just in case...
[cell setLeaf:YES];
[cell setStringValue: @""];
}
@end
static id _sharedDelegate = nil;
@implementation GormNSBrowser
+ (id) sharedDelegate
{
if (_sharedDelegate == nil)
{
_sharedDelegate = [[NSBrowserDelegate alloc] init];
}
return _sharedDelegate;
}
- (id) initWithFrame: (NSRect) aRect
{
self = [super initWithFrame: aRect];
[super setDelegate: [GormNSBrowser sharedDelegate]];
_gormDelegate = nil;
return self;
}
- (void)setDelegate: (id)anObject
{
_gormDelegate = anObject;
}
- (id)delegate
{
return _gormDelegate;
}
- (void)encodeWithCoder: (NSCoder*) aCoder
{
id oldDelegate;
_browserDelegate = _gormDelegate;
[super encodeWithCoder: aCoder];
_browserDelegate = _sharedDelegate;
}
- (id) initWithCoder: (NSCoder*) aCoder
{
[super setDelegate: [GormNSBrowser sharedDelegate]];
self = [super initWithCoder: aCoder];
return self;
}
@end

View file

@ -44,6 +44,7 @@
@interface GormBrowserAttributesInspector : IBInspector
{
id optionMatrix;
id tagField;
}
- (void) _getValuesFromObject: (id)anObject;
@ -74,6 +75,10 @@
flag = ([[control cellAtRow: 5 column: 0] state] == NSOnState) ? YES : NO;
[object setHasHorizontalScroller: flag];
}
else if( control == tagField )
{
[object setTag:[[tagField cellAtIndex:0] intValue]];
}
}
- (void) _getValuesFromObject: anObject
@ -97,6 +102,8 @@
[optionMatrix selectCellAtRow: 4 column: 0];
if ([anObject hasHorizontalScroller])
[optionMatrix selectCellAtRow: 5 column: 0];
[[tagField cellAtIndex:0] setIntValue:[anObject tag]];
}
- (void) dealloc
@ -155,6 +162,7 @@
id borderMatrix;
id rowsHeightForm;
id optionMatrix;
id tagField;
}
- (void) _getValuesFromObject: (id)anObject;
@ -213,6 +221,10 @@
flag = ([[control cellAtRow: 2 column: 0] state] == NSOnState) ? YES : NO;
[object setAllowsColumnReordering: flag];
}
else if( control == tagField )
{
[object setTag:[[tagField cellAtIndex:0] intValue]];
}
}
- (void) _getValuesFromObject: anObject
@ -265,6 +277,7 @@
[optionMatrix selectCellAtRow: 1 column: 0];
if ([anObject allowsColumnReordering])
[optionMatrix selectCellAtRow: 2 column: 0];
[[tagField cellAtIndex:0] setIntValue:[anObject tag]];
}
- (void) dealloc

View file

@ -24,52 +24,9 @@
#include <Foundation/Foundation.h>
#include <AppKit/AppKit.h>
#include "../../Gorm.h"
#include "GormNSBrowser.h"
@class NSBrowserDelegate;
NSBrowserDelegate * browserDelegate;
/* ---------------------------------------------------------------
* NSBrowser Delegate
*/
@interface NSBrowserDelegate: NSObject
{
}
- (int) browser: (NSBrowser *)sender numberOfRowsInColumn: (int)column;
- (NSString *) browser: (NSBrowser *)sender titleOfColumn: (int)column;
- (void) browser: (NSBrowser *)sender willDisplayCell: (id)cell
atRow: (int)row column: (int)column;
@end
@implementation NSBrowserDelegate
- (int) browser: (NSBrowser *)sender numberOfRowsInColumn: (int)column
{
return 0;
}
- (NSString *) browser: (NSBrowser *)sender titleOfColumn: (int)column
{
return (column==0) ? @"Browser" : @"";
}
- (void) browser: (NSBrowser *)sender
willDisplayCell: (id)cell
atRow: (int)row
column: (int)column
{
NSDebugLog(@"<%@ %x>: browser %x will display %@ %x at %d,%d",[self class],self,sender,[cell class],cell,row,column);
// This code should never be called because there is no row
// in our browser. But just in case...
[cell setLeaf:YES];
[cell setStringValue: @""];
}
@end
/* ---------------------------------------------------------------
* NSTableView data source
@ -105,7 +62,7 @@ NSBrowserDelegate * browserDelegate;
- (void) dealloc
{
RELEASE(browserDelegate);
// RELEASE(browserDelegate);
[super dealloc];
}
@ -131,11 +88,9 @@ NSBrowserDelegate * browserDelegate;
// NSBrowser
// 124 is the minimum width. Below that the browser doesn't display !!
v = [[NSBrowser alloc] initWithFrame: NSMakeRect(10, 38, 124, 116)];
browserDelegate = [[NSBrowserDelegate alloc] init];
[v setDelegate:browserDelegate];
v = [[GormNSBrowser alloc] initWithFrame: NSMakeRect(10, 38, 124, 116)];
// [v setDelegate:nil];
[v setHasHorizontalScroller: YES];
[v setTitled: YES];
[v loadColumnZero];