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
|
2005-08-06 19:32:38 +00:00
|
|
|
|
* Author: Gregory John Casamento <greg_casamento@yahoo.com>
|
|
|
|
|
* Date: 2003
|
2000-01-14 13:34:15 +00:00
|
|
|
|
*
|
|
|
|
|
* 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
|
2007-11-05 23:44:36 +00:00
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2000-01-14 13:34:15 +00:00
|
|
|
|
* (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
|
2005-05-26 03:37:38 +00:00
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
|
2000-01-14 13:34:15 +00:00
|
|
|
|
*/
|
|
|
|
|
|
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
|
|
|
|
|
|
2005-07-07 12:43:21 +00:00
|
|
|
|
- (void)controlTextDidChange:(NSNotification *)aNotification
|
2000-01-14 13:34:15 +00:00
|
|
|
|
{
|
2011-11-28 03:33:49 +00:00
|
|
|
|
id<IBDocuments> doc = [(id<IB>)NSApp activeDocument];
|
|
|
|
|
|
2000-01-14 13:34:15 +00:00
|
|
|
|
[object setTitle: [titleText stringValue]];
|
2011-11-28 03:33:49 +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...
|
2005-07-21 11:41:04 +00:00
|
|
|
|
|
2003-09-28 23:31:35 +00:00
|
|
|
|
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)
|
|
|
|
|
{
|
2005-07-21 11:41:04 +00:00
|
|
|
|
if([doc windowsMenu] == [self object])
|
|
|
|
|
{
|
|
|
|
|
[doc setWindowsMenu: nil];
|
|
|
|
|
}
|
|
|
|
|
if([doc servicesMenu] == [self object])
|
|
|
|
|
{
|
|
|
|
|
[doc setServicesMenu: nil];
|
|
|
|
|
}
|
2003-09-28 23:31:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@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
|
|
|
|
|
|
2005-07-07 12:43:21 +00:00
|
|
|
|
- (void)controlTextDidChange:(NSNotification *)aNotification
|
2000-01-14 13:34:15 +00:00
|
|
|
|
{
|
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
|