1 |
/* GormMenuInspectors.m |
2 |
* |
3 |
* Copyright (C) 2000 Free Software Foundation, Inc. |
4 |
* |
5 |
* Author: Richard Frith-Macdonald <richard@brainstrom.co.uk> |
6 |
* Date: 2000 |
7 |
* |
8 |
* This file is part of GNUstep. |
9 |
* |
10 |
* This program is free software; you can redistribute it and/or modify |
11 |
* it under the terms of the GNU General Public License as published by |
12 |
* the Free Software Foundation; either version 2 of the License, or |
13 |
* (at your option) any later version. |
14 |
* |
15 |
* This program is distributed in the hope that it will be useful, |
16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 |
* GNU General Public License for more details. |
19 |
* |
20 |
* You should have received a copy of the GNU General Public License |
21 |
* along with this program; if not, write to the Free Software |
22 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
23 |
*/ |
24 |
|
25 |
#include <AppKit/AppKit.h> |
26 |
#include <InterfaceBuilder/InterfaceBuilder.h> |
27 |
|
28 |
@interface GormMenuAttributesInspector : IBInspector |
29 |
{ |
30 |
NSTextField *titleText; |
31 |
NSMatrix *menuType; |
32 |
} |
33 |
@end |
34 |
|
35 |
@implementation GormMenuAttributesInspector |
36 |
|
37 |
- (void) controlTextDidEndEditing: (NSNotification*)aNotification |
38 |
{ |
39 |
[object setTitle: [titleText stringValue]]; |
40 |
} |
41 |
|
42 |
- (id) init |
43 |
{ |
44 |
if ([super init] == nil) |
45 |
return nil; |
46 |
|
47 |
if ([NSBundle loadNibNamed: @"GormMenuAttributesInspector" owner: self] == NO) |
48 |
{ |
49 |
NSLog(@"Could not gorm GormMenuAttributesInspector"); |
50 |
return nil; |
51 |
} |
52 |
return self; |
53 |
} |
54 |
|
55 |
- (void) setObject: (id)anObject |
56 |
{ |
57 |
[super setObject: anObject]; |
58 |
[titleText setStringValue: [object title]]; |
59 |
} |
60 |
|
61 |
@end |
62 |
|
63 |
|
64 |
|
65 |
@implementation NSMenuItem (IBObjectAdditions) |
66 |
- (NSString*) inspectorClassName |
67 |
{ |
68 |
return @"GormMenuItemAttributesInspector"; |
69 |
} |
70 |
@end |
71 |
|
72 |
@interface GormMenuItemAttributesInspector : IBInspector |
73 |
{ |
74 |
NSTextField *titleText; |
75 |
NSTextField *shortCut; |
76 |
NSTextField *tagText; |
77 |
} |
78 |
@end |
79 |
|
80 |
@implementation GormMenuItemAttributesInspector |
81 |
|
82 |
- (void) controlTextDidEndEditing: (NSNotification*)aNotification |
83 |
{ |
84 |
id o = [aNotification object]; |
85 |
|
86 |
if (o == titleText) |
87 |
{ |
88 |
[object setTitle: [titleText stringValue]]; |
89 |
} |
90 |
if (o == shortCut) |
91 |
{ |
92 |
NSString *s = [[shortCut stringValue] stringByTrimmingSpaces]; |
93 |
|
94 |
[object setKeyEquivalent: s]; |
95 |
} |
96 |
if (o == tagText) |
97 |
{ |
98 |
[object setTag: [tagText intValue]]; |
99 |
} |
100 |
[[object menu] display]; |
101 |
} |
102 |
|
103 |
- (id) init |
104 |
{ |
105 |
if ([super init] == nil) |
106 |
return nil; |
107 |
|
108 |
if ([NSBundle loadNibNamed: @"GormMenuItemAttributesInspector" owner: self] == NO) |
109 |
{ |
110 |
NSLog(@"Could not gorm GormMenuItemAttributesInspector"); |
111 |
return nil; |
112 |
} |
113 |
return self; |
114 |
} |
115 |
|
116 |
- (void) setObject: (id)anObject |
117 |
{ |
118 |
[super setObject: anObject]; |
119 |
[titleText setStringValue: [object title]]; |
120 |
[shortCut setStringValue: [object keyEquivalent]]; |
121 |
[tagText setIntValue: [object tag]]; |
122 |
} |
123 |
|
124 |
@end |
125 |
|