* Gorm.m: added menu item for "group in scroll view".

* GNUmakefile: added GormScrollViewEditor.m
* GormScrollViewEditor.m: new file.
* GormInternalViewEditor.m: added support for NSScrollView
  contents editing.
* Palettes/3Containers/GormTableViewEditor.m: removed old support
  for NSScrollView.
* GormViewWithContentViewEditor.m: added support for keyboard
  moving & resizing of elements & support for "group in scroll view".

* Palettes/0Menus/GormMenuEditor.m: fixes when adding a menu item
  into an NSPopupButton.

* Palettes/2Controls/GormBoxInspector.gorm:
* Palettes/1Windows/GormWindowInspector.gorm:
* Palettes/1Windows/GormWindowSizeInspector.gorm:
  updated for better visual aspect.

* GormButtonEditor.m: fixed inline title editing.

* GormDocument.m: do not save the last directory if the save/openpanel
  do not return NSOKButton.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@14677 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Pierre-Yves Rivaille 2002-10-08 20:17:17 +00:00
parent 7fb3cb11ff
commit ca8fb4f95a
17 changed files with 417 additions and 51 deletions

View file

@ -1,3 +1,28 @@
2002-10-08 Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
* Gorm.m: added menu item for "group in scroll view".
* GNUmakefile: added GormScrollViewEditor.m
* GormScrollViewEditor.m: new file.
* GormInternalViewEditor.m: added support for NSScrollView
contents editing.
* Palettes/3Containers/GormTableViewEditor.m: removed old support
for NSScrollView.
* GormViewWithContentViewEditor.m: added support for keyboard
moving & resizing of elements & support for "group in scroll view".
* Palettes/0Menus/GormMenuEditor.m: fixes when adding a menu item
into an NSPopupButton.
* Palettes/2Controls/GormBoxInspector.gorm:
* Palettes/1Windows/GormWindowInspector.gorm:
* Palettes/1Windows/GormWindowSizeInspector.gorm:
updated for better visual aspect.
* GormButtonEditor.m: fixed inline title editing.
* GormDocument.m: do not save the last directory if the save/openpanel
do not return NSOKButton.
2002-10-04 Gregory John Casamento <greg_casamento@yahoo.com>
* GormInternalViewEditor.m: (dragExited:) move variable up for

View file

@ -599,7 +599,6 @@
);
Super = NSResponder;
};
NSWindowController = {
Actions = (
showWindow:

View file

@ -159,7 +159,8 @@ Gorm_OBJC_FILES = \
GormInternalViewEditor.m \
GormPalettesManager.m \
GormOutlineView.m \
GormCustomClassInspector.m
GormCustomClassInspector.m \
GormScrollViewEditor.m
-include GNUmakefile.preamble

11
Gorm.m
View file

@ -343,6 +343,14 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
return self;
}
- (id) groupSelectionInScrollView: (id)sender
{
if ([selectionOwner respondsToSelector: @selector(groupSelectionInScrollView)] == NO)
return nil;
[(id)selectionOwner groupSelectionInScrollView];
return self;
}
- (id) ungroup: (id)sender
{
NSLog(@"ungroup: selectionOwner %@", selectionOwner);
@ -721,6 +729,9 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
[aMenu addItemWithTitle: @"Group in box"
action: @selector(groupSelectionInBox:)
keyEquivalent: @""];
[aMenu addItemWithTitle: @"Group in scrollview"
action: @selector(groupSelectionInScrollView:)
keyEquivalent: @""];
[aMenu addItemWithTitle: @"Ungroup"
action: @selector(ungroup:)
keyEquivalent: @""];

View file

@ -515,7 +515,7 @@ static NSRect oldFrame;
}
[[[self window] contentView] setNeedsDisplayInRect: oldFrame];
[/*[[self window] contentView]*/[self superview] setNeedsDisplayInRect: oldFrame];
inside = NO;
}
@ -568,7 +568,7 @@ static NSRect oldFrame;
// frame.origin.y -= 2;
// frame.size.height = 2;
NSTextView *tv = [self startEditingInFrame: frame];
[[[self window] contentView] addSubview: tv];
[/*[[self window] contentView]*/[self superview] addSubview: tv];
[tv setText: [_EO stringValue]];
[tv setAlignment: [_EO alignment]];
[tv setFont: [_EO font]];

View file

@ -1594,10 +1594,10 @@ static NSImage *classesImage = nil;
result = [oPanel runModalForDirectory: pth
file: nil
types: fileTypes];
[[NSUserDefaults standardUserDefaults] setObject: [oPanel directory]
forKey:@"OpenDir"];
if (result == NSOKButton)
{
[[NSUserDefaults standardUserDefaults] setObject: [oPanel directory]
forKey:@"OpenDir"];
return [self loadDocument: [oPanel filename]];
}
return nil; /* Failed */

View file

@ -41,6 +41,8 @@
[[self superview] isKindOfClass: [NSTabView class]]
||
[[self superview] isKindOfClass: [GSWindowView class]]
||
[[self superview] isKindOfClass: [NSClipView class]]
))
{
return @"GormInternalViewEditor";
@ -100,6 +102,10 @@
{
[[superview window] setContentView: self];
}
else if ([superview isKindOfClass: [NSClipView class]])
{
[superview setDocumentView: self];
}
[self addSubview: _editedObject];
@ -200,6 +206,10 @@
[self removeSubview: _editedObject];
[[superview window] setContentView: _editedObject];
}
else if ([superview isKindOfClass: [NSClipView class]])
{
[superview setDocumentView: _editedObject];
}
[[NSNotificationCenter defaultCenter] removeObserver: self];
}

133
GormScrollViewEditor.m Normal file
View file

@ -0,0 +1,133 @@
/* GormScrollViewEditor.m
*
* Copyright (C) 2002 Free Software Foundation, Inc.
*
* Author: Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
* Date: 2002
*
* 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 "GormPrivate.h"
#import "GormBoxEditor.h"
#define _EO ((NSScrollView *)_editedObject)
@implementation NSScrollView (GormObjectAdditions)
- (NSString*) editorClassName
{
if ([self documentView]
&& [[self documentView] isKindOfClass: [NSTableView class]])
return @"GormTableViewEditor";
else
return @"GormScrollViewEditor";
}
@end
@interface GormScrollViewEditor : GormViewWithSubviewsEditor
{
GormInternalViewEditor *documentViewEditor;
}
@end
@implementation GormScrollViewEditor
- (BOOL) activate
{
if ([super activate])
{
NSView *documentView = [_EO documentView];
NSLog(@"documentView %@", documentView);
documentViewEditor = [document editorForObject: documentView
inEditor: self
create: YES];
return YES;
}
return NO;
}
- (void) deactivate
{
if (activated == YES)
{
[self deactivateSubeditors];
[super deactivate];
}
}
- (void) mouseDown: (NSEvent *) theEvent
{
BOOL onKnob = NO;
// if we are on one of our own knob, then this event should be processed
// by our parent (cause this is a resizing event)
{
if ([parent respondsToSelector: @selector(selection)] &&
[[parent selection] containsObject: _EO])
{
IBKnobPosition knob = IBNoneKnobPosition;
NSPoint mouseDownPoint =
[self convertPoint: [theEvent locationInWindow]
fromView: nil];
knob = GormKnobHitInRect([self bounds],
mouseDownPoint);
if (knob != IBNoneKnobPosition)
onKnob = YES;
}
if (onKnob == YES)
{
if (parent)
return [parent mouseDown: theEvent];
else
return [self noResponderFor: @selector(mouseDown:)];
}
}
if (opened == NO)
{
// NSLog(@"GormBoxEditor not opened");
[super mouseDown: theEvent];
return;
}
if ([[_EO hitTest: [theEvent locationInWindow]]
isDescendantOf: documentViewEditor])
{
// NSLog(@"md %@ descendant of", self);
if ([documentViewEditor isOpened] == NO)
[documentViewEditor setOpened: YES];
[documentViewEditor mouseDown: theEvent];
}
else
{
NSView *v = [_EO hitTest: [theEvent locationInWindow]];
if (v && [v isKindOfClass: [NSScroller class]])
[v mouseDown: theEvent];
}
}
@end

View file

@ -617,6 +617,117 @@
}
- (void) moveSelectionByX: (float)x
andY: (float)y
{
int i;
int count = [selection count];
for (i = 0; i < count; i++)
{
id v = [selection objectAtIndex: i];
NSRect f = [v frame];
f.origin.x += x;
f.origin.y += y;
[v setFrameOrigin: f.origin];
}
}
- (void) resizeSelectionByX: (float)x
andY: (float)y
{
int i;
int count = [selection count];
for (i = 0; i < count; i++)
{
id v = [selection objectAtIndex: i];
NSRect f = [v frame];
f.size.width += x;
f.size.height += y;
[v setFrameSize: f.size];
}
}
- (void) keyDown: (NSEvent *)theEvent
{
NSString *characters = [theEvent characters];
unichar character = 0;
float moveBy = 1.0;
if ([characters length] > 0)
{
character = [characters characterAtIndex: 0];
}
if (([theEvent modifierFlags] & NSShiftKeyMask) == NSShiftKeyMask)
{
if (([theEvent modifierFlags] & NSAlternateKeyMask) == NSAlternateKeyMask)
{
moveBy = 10.0;
}
if ([selection count] == 1)
{
switch (character)
{
case NSUpArrowFunctionKey:
[self resizeSelectionByX: 0 andY: 1*moveBy];
[self setNeedsDisplay: YES];
return;
case NSDownArrowFunctionKey:
[self resizeSelectionByX: 0 andY: -1*moveBy];
[self setNeedsDisplay: YES];
return;
case NSLeftArrowFunctionKey:
[self resizeSelectionByX: -1*moveBy andY: 0];
[self setNeedsDisplay: YES];
return;
case NSRightArrowFunctionKey:
[self resizeSelectionByX: 1*moveBy andY: 0];
[self setNeedsDisplay: YES];
return;
}
}
}
else
{
if (([theEvent modifierFlags] & NSAlternateKeyMask) == NSAlternateKeyMask)
{
moveBy = 10.0;
}
if ([selection count] > 0)
{
switch (character)
{
case NSUpArrowFunctionKey:
[self moveSelectionByX: 0 andY: 1*moveBy];
[self setNeedsDisplay: YES];
return;
case NSDownArrowFunctionKey:
[self moveSelectionByX: 0 andY: -1*moveBy];
[self setNeedsDisplay: YES];
return;
case NSLeftArrowFunctionKey:
[self moveSelectionByX: -1*moveBy andY: 0];
[self setNeedsDisplay: YES];
return;
case NSRightArrowFunctionKey:
[self moveSelectionByX: 1*moveBy andY: 0];
[self setNeedsDisplay: YES];
return;
}
}
}
[super keyDown: theEvent];
}
- (BOOL) acceptsTypeFromArray: (NSArray*)types
{
if ([super acceptsTypeFromArray: types])
@ -792,6 +903,63 @@
[self selectObjects: [NSArray arrayWithObject: editor]];
}
- (void) groupSelectionInScrollView
{
NSEnumerator *enumerator;
GormViewEditor *subview;
NSView *view;
NSScrollView *scrollView;
NSRect rect = NSZeroRect;
GormViewEditor *editor;
NSView *superview;
if ([selection count] < 1)
{
return;
}
enumerator = [selection objectEnumerator];
while ((subview = [enumerator nextObject]) != nil)
{
superview = [subview superview];
rect = NSUnionRect(rect, [subview frame]);
[subview deactivate];
}
view = [[NSView alloc] initWithFrame:
NSMakeRect(0, 0, rect.size.width, rect.size.height)];
scrollView = [[NSScrollView alloc] initWithFrame: rect];
[scrollView setHasHorizontalScroller: YES];
[scrollView setHasVerticalScroller: YES];
[document attachObject: scrollView
toParent: _editedObject];
[superview addSubview: scrollView];
[scrollView setDocumentView: view];
enumerator = [selection objectEnumerator];
while ((subview = [enumerator nextObject]) != nil)
{
NSPoint frameOrigin;
[view addSubview: [subview editedObject]];
frameOrigin = [[subview editedObject] frame].origin;
frameOrigin.x -= rect.origin.x;
frameOrigin.y -= rect.origin.y;
[[subview editedObject] setFrameOrigin: frameOrigin];
[subview close];
}
editor = [document editorForObject: scrollView
inEditor: self
create: YES];
[self selectObjects: [NSArray arrayWithObject: editor]];
}
@class GormBoxEditor;
@class GormSplitViewEditor;

View file

@ -698,7 +698,13 @@
}
else
{
if ([_menu _ownedByPopUp])
{
[item setOnStateImage: nil];
[item setMixedStateImage: nil];
}
[edited addItem: item];
}
}
[edited sizeToFit];
@ -749,7 +755,15 @@
// }
// else
// {
[edited insertItem: item atIndex: pos++];
if ([edited _ownedByPopUp])
{
NSLog(@"owned by popup");
[item setOnStateImage: nil];
[item setMixedStateImage: nil];
}
else
NSLog(@"not owned by popup");
[edited insertItem: item atIndex: pos++];
// }
}
[edited sizeToFit];

View file

@ -12,9 +12,9 @@
};
IBInspector = {
Actions = (
ok:,
revert:,
touch:
"ok:",
"revert:",
"touch:"
);
Outlets = (
window
@ -32,11 +32,11 @@
};
NSControl = {
Actions = (
takeDoubleValueFrom:,
takeFloatValueFrom:,
takeIntValueFrom:,
takeObjectValueFrom:,
takeStringValueFrom:
"takeDoubleValueFrom:",
"takeFloatValueFrom:",
"takeIntValueFrom:",
"takeObjectValueFrom:",
"takeStringValueFrom:"
);
Outlets = (
target
@ -68,19 +68,16 @@
Super = NSControl;
};
NSView = {
Outlets = (
nextKeyView
);
Super = NSResponder;
};
NSWindow = {
Outlets = (
delegate
delegate,
initialFirstResponder
);
Super = NSResponder;
};
NewClass1 = {
Actions = (
);
Outlets = (
);
Super = IBInspector;
};
}

View file

@ -11,9 +11,9 @@
};
IBInspector = {
Actions = (
ok:,
revert:,
touch:
"ok:",
"revert:",
"touch:"
);
Outlets = (
);
@ -30,11 +30,11 @@
};
NSControl = {
Actions = (
takeDoubleValueFrom:,
takeFloatValueFrom:,
takeIntValueFrom:,
takeObjectValueFrom:,
takeStringValueFrom:
"takeDoubleValueFrom:",
"takeFloatValueFrom:",
"takeIntValueFrom:",
"takeObjectValueFrom:",
"takeStringValueFrom:"
);
Outlets = (
target
@ -63,11 +63,15 @@
Super = NSControl;
};
NSView = {
Outlets = (
nextKeyView
);
Super = NSResponder;
};
NSWindow = {
Outlets = (
delegate
delegate,
initialFirstResponder
);
Super = NSResponder;
};

View file

@ -15,9 +15,9 @@
};
IBInspector = {
Actions = (
ok:,
revert:,
touch:
"ok:",
"revert:",
"touch:"
);
Outlets = (
window
@ -35,11 +35,11 @@
};
NSControl = {
Actions = (
takeDoubleValueFrom:,
takeFloatValueFrom:,
takeIntValueFrom:,
takeObjectValueFrom:,
takeStringValueFrom:
"takeDoubleValueFrom:",
"takeFloatValueFrom:",
"takeIntValueFrom:",
"takeObjectValueFrom:",
"takeStringValueFrom:"
);
Outlets = (
target
@ -68,11 +68,15 @@
Super = NSControl;
};
NSView = {
Outlets = (
nextKeyView
);
Super = NSResponder;
};
NSWindow = {
Outlets = (
delegate
delegate,
initialFirstResponder
);
Super = NSResponder;
};

View file

@ -33,16 +33,16 @@ static NSCell *_editedCell;
static NSCell *_currentHeaderCell;
static NSText *_textObject;
@implementation NSScrollView (GormObjectAdditions)
- (NSString*) editorClassName
{
if ([self documentView]
&& [[self documentView] isKindOfClass: [NSTableView class]])
return @"GormTableViewEditor";
else
return [super editorClassName];
}
@end
// @implementation NSScrollView (GormObjectAdditions)
// - (NSString*) editorClassName
// {
// if ([self documentView]
// && [[self documentView] isKindOfClass: [NSTableView class]])
// return @"GormTableViewEditor";
// else
// return [super editorClassName];
// }
// @end
@interface GormTableViewEditor (Private)
- (void) editHeader: (NSTableHeaderView*) th