mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-04-22 14:10:44 +00:00
Add menu inspectors
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@5774 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
6dad274f1e
commit
21d066e79e
6 changed files with 206 additions and 63 deletions
|
@ -341,6 +341,11 @@ static NSImage *classesImage = nil;
|
|||
return [aPasteboard setData: obj forType: aType];
|
||||
}
|
||||
|
||||
- (void) pasteboardChangedOwner: (NSPasteboard*)sender
|
||||
{
|
||||
NSLog(@"Owner changed for %@", sender);
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||
|
@ -468,10 +473,18 @@ static NSImage *classesImage = nil;
|
|||
[link setDestination: editor];
|
||||
[connections addObject: link];
|
||||
RELEASE(link);
|
||||
if (anEditor != nil)
|
||||
if (anEditor == nil)
|
||||
{
|
||||
/*
|
||||
* This editor has a parent - so link to it.
|
||||
* By default all editors are owned by the top-level editor of
|
||||
* the document.
|
||||
*/
|
||||
anEditor = objectsView;
|
||||
}
|
||||
if (anEditor != editor)
|
||||
{
|
||||
/*
|
||||
* Link to the parent of the editor.
|
||||
*/
|
||||
link = [GormEditorToParent new];
|
||||
[link setSource: editor];
|
||||
|
@ -1010,7 +1023,7 @@ static NSImage *classesImage = nil;
|
|||
id<IBEditors> e = [self editorForObject: anObject create: YES];
|
||||
id<IBEditors> p = [self parentEditorForEditor: e];
|
||||
|
||||
if (p != nil)
|
||||
if (p != nil && p != objectsView)
|
||||
{
|
||||
[self openEditorForObject: [p editedObject]];
|
||||
}
|
||||
|
@ -1048,12 +1061,20 @@ static NSImage *classesImage = nil;
|
|||
fromPasteboard: (NSPasteboard*)aPasteboard
|
||||
parent: (id)parent
|
||||
{
|
||||
NSData *data = [aPasteboard dataForType: aType];
|
||||
NSArray *objects = [NSUnarchiver unarchiveObjectWithData: data];
|
||||
NSEnumerator *enumerator = [objects objectEnumerator];
|
||||
NSData *data;
|
||||
NSArray *objects;
|
||||
NSEnumerator *enumerator;
|
||||
NSPoint filePoint;
|
||||
NSPoint screenPoint;
|
||||
|
||||
data = [aPasteboard dataForType: aType];
|
||||
if (data == nil)
|
||||
{
|
||||
NSLog(@"Pasteboard %@ doesn't contain data of %@", aPasteboard, aType);
|
||||
return nil;
|
||||
}
|
||||
objects = [NSUnarchiver unarchiveObjectWithData: data];
|
||||
enumerator = [objects objectEnumerator];
|
||||
filePoint = [window mouseLocationOutsideOfEventStream];
|
||||
screenPoint = [window convertBaseToScreen: filePoint];
|
||||
|
||||
|
|
|
@ -1060,6 +1060,7 @@ NSRectFromPoints(NSPoint p0, NSPoint p1)
|
|||
NSEnumerator *enumerator;
|
||||
NSView *sub;
|
||||
|
||||
[self makeSelectionVisible: NO];
|
||||
/*
|
||||
* Ask the document to get the dragged views from the pasteboard and add
|
||||
* them to it's collection of known objects.
|
||||
|
@ -1082,6 +1083,9 @@ NSRectFromPoints(NSPoint p0, NSPoint p1)
|
|||
[sub setFrame: rect];
|
||||
[self addSubview: sub];
|
||||
}
|
||||
[self selectObjects: views];
|
||||
[self displayIfNeeded];
|
||||
[self makeSelectionVisible: YES];
|
||||
}
|
||||
else if (dragType == GormLinkPboardType)
|
||||
{
|
||||
|
|
|
@ -27,6 +27,7 @@ PALETTE_NAME = 0Menus
|
|||
0Menus_PALETTE_ICON = MenusPalette
|
||||
0Menus_OBJC_FILES = \
|
||||
GormMenuEditor.m \
|
||||
GormMenuInspectors.m \
|
||||
main.m
|
||||
0Menus_PRINCIPAL_CLASS = MenusPalette
|
||||
0Menus_RESOURCE_FILES = MenusPalette.tiff
|
||||
|
|
|
@ -299,8 +299,10 @@
|
|||
{
|
||||
/*
|
||||
* The mouse down wasn't over the menu items, so we just let the menu
|
||||
* handle it.
|
||||
* handle it - but make sure the menu is selected in the editor first.
|
||||
*/
|
||||
[[document parentEditorForEditor: self] selectObjects:
|
||||
[NSArray arrayWithObject: edited]];
|
||||
[hit mouseDown: theEvent];
|
||||
}
|
||||
}
|
||||
|
@ -674,7 +676,7 @@
|
|||
loc.y += 10;
|
||||
pos = [rep indexOfItemAtPoint: loc] + 1;
|
||||
|
||||
NSLog(@"Drop at index: %d (%@)", pos, NSStringFromPoint(loc));
|
||||
[self makeSelectionVisible: NO];
|
||||
/*
|
||||
* Ask the document to get the dragged views from the pasteboard and add
|
||||
* them to it's collection of known objects.
|
||||
|
@ -698,6 +700,8 @@ NSLog(@"Drop at index: %d (%@)", pos, NSStringFromPoint(loc));
|
|||
}
|
||||
[edited sizeToFit];
|
||||
[edited display];
|
||||
[self selectObjects: items];
|
||||
[self makeSelectionVisible: YES];
|
||||
}
|
||||
else if (dragType == GormLinkPboardType)
|
||||
{
|
||||
|
|
168
Palettes/0Menus/GormMenuInspectors.m
Normal file
168
Palettes/0Menus/GormMenuInspectors.m
Normal file
|
@ -0,0 +1,168 @@
|
|||
/* GormMenuInspectors.m
|
||||
*
|
||||
* Copyright (C) 2000 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Richard Frith-Macdonald <richard@brainstrom.co.uk>
|
||||
* Date: 2000
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "../../GormPrivate.h"
|
||||
|
||||
@implementation NSMenu (IBInspectorClassNames)
|
||||
- (NSString*) inspectorClassName
|
||||
{
|
||||
return @"GormMenuAttributesInspector";
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GormMenuAttributesInspector : IBInspector
|
||||
{
|
||||
NSTextField *titleText;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation GormMenuAttributesInspector
|
||||
|
||||
- (void) controlTextDidEndEditing: (NSNotification*)aNotification
|
||||
{
|
||||
[object setTitle: [titleText stringValue]];
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||
RELEASE(window);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
NSView *contents;
|
||||
NSTextField *title;
|
||||
|
||||
window = [[NSWindow alloc] initWithContentRect: NSMakeRect(0, 0, IVW, IVH)
|
||||
styleMask: NSBorderlessWindowMask
|
||||
backing: NSBackingStoreRetained
|
||||
defer: NO];
|
||||
contents = [window contentView];
|
||||
|
||||
title
|
||||
= [[NSTextField alloc] initWithFrame: NSMakeRect(10,IVH-30,70,20)];
|
||||
[title setEditable: NO];
|
||||
[title setSelectable: NO];
|
||||
[title setBezeled: NO];
|
||||
[title setAlignment: NSLeftTextAlignment];
|
||||
[title setFont: [NSFont systemFontOfSize: 14.0]];
|
||||
[title setDrawsBackground: NO];
|
||||
[title setStringValue: @"Title:"];
|
||||
[contents addSubview: title];
|
||||
RELEASE(title);
|
||||
|
||||
titleText
|
||||
= [[NSTextField alloc] initWithFrame: NSMakeRect(60,IVH-30,IVW-80,20)];
|
||||
[titleText setDelegate: self];
|
||||
[contents addSubview: titleText];
|
||||
RELEASE(titleText);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) setObject: (id)anObject
|
||||
{
|
||||
[super setObject: anObject];
|
||||
[titleText setStringValue: [object title]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@implementation NSMenuItem (IBInspectorClassNames)
|
||||
- (NSString*) inspectorClassName
|
||||
{
|
||||
return @"GormMenuItemAttributesInspector";
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GormMenuItemAttributesInspector : IBInspector
|
||||
{
|
||||
NSTextField *titleText;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation GormMenuItemAttributesInspector
|
||||
|
||||
- (void) controlTextDidEndEditing: (NSNotification*)aNotification
|
||||
{
|
||||
[object setTitle: [titleText stringValue]];
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||
RELEASE(window);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
NSView *contents;
|
||||
NSTextField *title;
|
||||
|
||||
window = [[NSWindow alloc] initWithContentRect: NSMakeRect(0, 0, IVW, IVH)
|
||||
styleMask: NSBorderlessWindowMask
|
||||
backing: NSBackingStoreRetained
|
||||
defer: NO];
|
||||
contents = [window contentView];
|
||||
|
||||
title
|
||||
= [[NSTextField alloc] initWithFrame: NSMakeRect(10,IVH-30,70,20)];
|
||||
[title setEditable: NO];
|
||||
[title setSelectable: NO];
|
||||
[title setBezeled: NO];
|
||||
[title setAlignment: NSLeftTextAlignment];
|
||||
[title setFont: [NSFont systemFontOfSize: 14.0]];
|
||||
[title setDrawsBackground: NO];
|
||||
[title setStringValue: @"Title:"];
|
||||
[contents addSubview: title];
|
||||
RELEASE(title);
|
||||
|
||||
titleText
|
||||
= [[NSTextField alloc] initWithFrame: NSMakeRect(60,IVH-30,IVW-80,20)];
|
||||
[titleText setDelegate: self];
|
||||
[contents addSubview: titleText];
|
||||
RELEASE(titleText);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) setObject: (id)anObject
|
||||
{
|
||||
[super setObject: anObject];
|
||||
[titleText setStringValue: [object title]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -510,58 +510,3 @@
|
|||
}
|
||||
@end
|
||||
|
||||
@implementation NSMenu (IBInspectorClassNames)
|
||||
- (NSString*) inspectorClassName
|
||||
{
|
||||
return @"GormMenuAttributesInspector";
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@interface GormMenuAttributesInspector : IBInspector
|
||||
{
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation GormMenuAttributesInspector
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(window);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
NSView *contents;
|
||||
NSBox *box;
|
||||
|
||||
window = [[NSWindow alloc] initWithContentRect: NSMakeRect(0, 0, 272, 360)
|
||||
styleMask: NSBorderlessWindowMask
|
||||
backing: NSBackingStoreRetained
|
||||
defer: NO];
|
||||
contents = [window contentView];
|
||||
|
||||
box = [[NSBox alloc] initWithFrame: NSMakeRect(10, 10, 210, 250)];
|
||||
[box setTitle: @"Options"];
|
||||
[box setBorderType: NSGrooveBorder];
|
||||
[contents addSubview: box];
|
||||
RELEASE(box);
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) ok: (id)sender
|
||||
{
|
||||
}
|
||||
|
||||
- (void) setObject: (id)anObject
|
||||
{
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
Loading…
Reference in a new issue