2000-01-14 13:34:15 +00:00
|
|
|
|
/* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2003-05-29 05:40:28 +00:00
|
|
|
|
#include <AppKit/AppKit.h>
|
|
|
|
|
#include <InterfaceBuilder/InterfaceBuilder.h>
|
2005-03-31 03:01:36 +00:00
|
|
|
|
#include <GormCore/GormPrivate.h>
|
|
|
|
|
#include <GormCore/GormDocument.h>
|
2000-01-14 13:34:15 +00:00
|
|
|
|
|
|
|
|
|
@interface GormMenuAttributesInspector : IBInspector
|
|
|
|
|
{
|
|
|
|
|
NSTextField *titleText;
|
2003-09-28 01:58:57 +00:00
|
|
|
|
NSMatrix *menuType;
|
2003-10-28 05:25:14 +00:00
|
|
|
|
id autoenable;
|
2000-01-14 13:34:15 +00:00
|
|
|
|
}
|
2003-09-28 23:31:35 +00:00
|
|
|
|
- (void) updateMenuType: (id)sender;
|
2003-10-28 05:25:14 +00:00
|
|
|
|
- (void) updateAutoenable: (id)sender;
|
2000-01-14 13:34:15 +00:00
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation GormMenuAttributesInspector
|
|
|
|
|
|
|
|
|
|
- (void) controlTextDidEndEditing: (NSNotification*)aNotification
|
|
|
|
|
{
|
2004-06-30 05:22:25 +00:00
|
|
|
|
id<IBDocuments> doc = [(id<IB>)NSApp activeDocument];
|
2000-01-14 13:34:15 +00:00
|
|
|
|
[object setTitle: [titleText stringValue]];
|
2004-06-30 05:22:25 +00:00
|
|
|
|
[doc touch];
|
2000-01-14 13:34:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) init
|
|
|
|
|
{
|
2003-09-28 01:58:57 +00:00
|
|
|
|
if ([super init] == nil)
|
|
|
|
|
return nil;
|
2002-09-21 15:24:59 +00:00
|
|
|
|
|
2003-09-28 01:58:57 +00:00
|
|
|
|
if ([NSBundle loadNibNamed: @"GormMenuAttributesInspector" owner: self] == NO)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Could not gorm GormMenuAttributesInspector");
|
|
|
|
|
return nil;
|
2000-01-14 13:34:15 +00:00
|
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setObject: (id)anObject
|
|
|
|
|
{
|
2003-09-28 23:31:35 +00:00
|
|
|
|
GormDocument *doc = (GormDocument *)[(id<IB>)NSApp activeDocument];
|
2003-10-13 03:32:51 +00:00
|
|
|
|
|
2004-07-27 06:20:45 +00:00
|
|
|
|
ASSIGN(object, nil); // remove reference to old object...
|
2000-01-14 13:34:15 +00:00
|
|
|
|
[super setObject: anObject];
|
|
|
|
|
[titleText setStringValue: [object title]];
|
2003-10-28 05:25:14 +00:00
|
|
|
|
[autoenable setState: ([object autoenablesItems]?NSOnState:NSOffState)];
|
|
|
|
|
|
2003-09-28 23:31:35 +00:00
|
|
|
|
// set up the menu type matrix...
|
|
|
|
|
if([doc windowsMenu] == anObject)
|
|
|
|
|
{
|
|
|
|
|
[menuType selectCellAtRow: 0 column: 0];
|
|
|
|
|
}
|
|
|
|
|
else if([doc servicesMenu] == anObject)
|
|
|
|
|
{
|
|
|
|
|
[menuType selectCellAtRow: 1 column: 0];
|
|
|
|
|
}
|
|
|
|
|
else // normal menu without any special function
|
|
|
|
|
{
|
|
|
|
|
[menuType selectCellAtRow: 2 column: 0];
|
|
|
|
|
}
|
2000-01-14 13:34:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-28 23:31:35 +00:00
|
|
|
|
- (void) updateMenuType: (id)sender
|
|
|
|
|
{
|
|
|
|
|
BOOL flag;
|
|
|
|
|
GormDocument *doc = (GormDocument *)[(id<IB>)NSApp activeDocument];
|
|
|
|
|
|
|
|
|
|
// look at the values passed back in the matrix.
|
|
|
|
|
flag = ([[menuType cellAtRow: 0 column: 0] state] == NSOnState) ? YES : NO; // windows menu...
|
|
|
|
|
if(flag)
|
|
|
|
|
{
|
|
|
|
|
[doc setWindowsMenu: [self object]];
|
|
|
|
|
if([doc servicesMenu] == [self object])
|
|
|
|
|
{
|
2003-10-13 03:32:51 +00:00
|
|
|
|
[doc setServicesMenu: nil];
|
2003-09-28 23:31:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
flag = ([[menuType cellAtRow: 1 column: 0] state] == NSOnState) ? YES : NO; // services menu...
|
|
|
|
|
if(flag)
|
|
|
|
|
{
|
|
|
|
|
[doc setServicesMenu: [self object]];
|
|
|
|
|
if([doc windowsMenu] == [self object])
|
|
|
|
|
{
|
2003-10-13 03:32:51 +00:00
|
|
|
|
[doc setWindowsMenu: nil];
|
2003-09-28 23:31:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
flag = ([[menuType cellAtRow: 2 column: 0] state] == NSOnState) ? YES : NO; // normal menu...
|
|
|
|
|
if(flag)
|
|
|
|
|
{
|
|
|
|
|
[doc setWindowsMenu: nil];
|
|
|
|
|
[doc setServicesMenu: nil];
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-10-28 05:25:14 +00:00
|
|
|
|
|
|
|
|
|
- (void) updateAutoenable: (id)sender
|
|
|
|
|
{
|
|
|
|
|
BOOL flag;
|
|
|
|
|
|
|
|
|
|
// look at the values passed back in the matrix.
|
|
|
|
|
flag = ([autoenable state] == NSOnState) ? YES : NO;
|
|
|
|
|
[object setAutoenablesItems: flag];
|
|
|
|
|
}
|
2000-01-14 13:34:15 +00:00
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-05-29 05:40:28 +00:00
|
|
|
|
@implementation NSMenuItem (IBObjectAdditions)
|
2000-01-14 13:34:15 +00:00
|
|
|
|
- (NSString*) inspectorClassName
|
|
|
|
|
{
|
|
|
|
|
return @"GormMenuItemAttributesInspector";
|
|
|
|
|
}
|
2004-01-11 18:03:45 +00:00
|
|
|
|
|
2004-05-01 00:05:53 +00:00
|
|
|
|
/*
|
2004-01-11 18:03:45 +00:00
|
|
|
|
- (void)awakeFromDocument: (id <IBDocuments>)doc
|
|
|
|
|
{
|
|
|
|
|
NSMenu *menu = [self menu];
|
|
|
|
|
if(menu != nil)
|
|
|
|
|
{
|
|
|
|
|
if([menu supermenu] != nil)
|
|
|
|
|
{
|
|
|
|
|
// NSLog(@"Menu = %@",menu);
|
|
|
|
|
// [menu display];
|
|
|
|
|
[menu close];
|
|
|
|
|
[menu closeTransient];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-05-01 00:05:53 +00:00
|
|
|
|
*/
|
2000-01-14 13:34:15 +00:00
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@interface GormMenuItemAttributesInspector : IBInspector
|
|
|
|
|
{
|
|
|
|
|
NSTextField *titleText;
|
2000-02-04 12:02:17 +00:00
|
|
|
|
NSTextField *shortCut;
|
2002-09-21 15:24:59 +00:00
|
|
|
|
NSTextField *tagText;
|
2000-01-14 13:34:15 +00:00
|
|
|
|
}
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation GormMenuItemAttributesInspector
|
|
|
|
|
|
|
|
|
|
- (void) controlTextDidEndEditing: (NSNotification*)aNotification
|
|
|
|
|
{
|
2000-02-04 12:02:17 +00:00
|
|
|
|
id o = [aNotification object];
|
2004-06-30 05:22:25 +00:00
|
|
|
|
id<IBDocuments> doc = [(id<IB>)NSApp activeDocument];
|
2000-02-04 12:02:17 +00:00
|
|
|
|
|
|
|
|
|
if (o == titleText)
|
|
|
|
|
{
|
|
|
|
|
[object setTitle: [titleText stringValue]];
|
|
|
|
|
}
|
|
|
|
|
if (o == shortCut)
|
|
|
|
|
{
|
|
|
|
|
NSString *s = [[shortCut stringValue] stringByTrimmingSpaces];
|
|
|
|
|
|
|
|
|
|
[object setKeyEquivalent: s];
|
|
|
|
|
}
|
2002-09-21 15:24:59 +00:00
|
|
|
|
if (o == tagText)
|
|
|
|
|
{
|
|
|
|
|
[object setTag: [tagText intValue]];
|
|
|
|
|
}
|
2004-06-30 05:22:25 +00:00
|
|
|
|
|
|
|
|
|
[doc touch];
|
2000-02-04 12:02:17 +00:00
|
|
|
|
[[object menu] display];
|
2000-01-14 13:34:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) init
|
|
|
|
|
{
|
2003-09-28 01:58:57 +00:00
|
|
|
|
if ([super init] == nil)
|
|
|
|
|
return nil;
|
|
|
|
|
|
|
|
|
|
if ([NSBundle loadNibNamed: @"GormMenuItemAttributesInspector" owner: self] == NO)
|
2000-01-14 13:34:15 +00:00
|
|
|
|
{
|
2003-09-28 01:58:57 +00:00
|
|
|
|
NSLog(@"Could not gorm GormMenuItemAttributesInspector");
|
|
|
|
|
return nil;
|
2000-01-14 13:34:15 +00:00
|
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setObject: (id)anObject
|
|
|
|
|
{
|
|
|
|
|
[super setObject: anObject];
|
|
|
|
|
[titleText setStringValue: [object title]];
|
2000-02-04 12:02:17 +00:00
|
|
|
|
[shortCut setStringValue: [object keyEquivalent]];
|
2002-09-21 15:24:59 +00:00
|
|
|
|
[tagText setIntValue: [object tag]];
|
2000-01-14 13:34:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|