/[gnustep]/gnustep/dev-apps/Gorm/Palettes/0Menus/GormMenuInspectors.m
ViewVC logotype

Contents of /gnustep/dev-apps/Gorm/Palettes/0Menus/GormMenuInspectors.m

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (show annotations) (download)
Sun Sep 28 23:31:35 2003 UTC (20 years, 6 months ago) by gcasa
Branch: MAIN
CVS Tags: Gorm-0_4_0
Changes since 1.6: +52 -1 lines
Corrected Report #5205.   Menus for Windows/Services should now be designated by Gorm and correctly shown when the .gorm file loads.

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 #include "GormPrivate.h"
28 #include "GormDocument.h"
29
30 @interface GormMenuAttributesInspector : IBInspector
31 {
32 NSTextField *titleText;
33 NSMatrix *menuType;
34 }
35 - (void) updateMenuType: (id)sender;
36 @end
37
38 @implementation GormMenuAttributesInspector
39
40 - (void) controlTextDidEndEditing: (NSNotification*)aNotification
41 {
42 [object setTitle: [titleText stringValue]];
43 }
44
45 - (id) init
46 {
47 if ([super init] == nil)
48 return nil;
49
50 if ([NSBundle loadNibNamed: @"GormMenuAttributesInspector" owner: self] == NO)
51 {
52 NSLog(@"Could not gorm GormMenuAttributesInspector");
53 return nil;
54 }
55 return self;
56 }
57
58 - (void) setObject: (id)anObject
59 {
60 BOOL flag = NO;
61 GormDocument *doc = (GormDocument *)[(id<IB>)NSApp activeDocument];
62 [super setObject: anObject];
63 [titleText setStringValue: [object title]];
64
65 // set up the menu type matrix...
66 if([doc windowsMenu] == anObject)
67 {
68 [menuType selectCellAtRow: 0 column: 0];
69 }
70 else if([doc servicesMenu] == anObject)
71 {
72 [menuType selectCellAtRow: 1 column: 0];
73 }
74 else // normal menu without any special function
75 {
76 [menuType selectCellAtRow: 2 column: 0];
77 }
78 }
79
80 - (void) updateMenuType: (id)sender
81 {
82 BOOL flag;
83 GormDocument *doc = (GormDocument *)[(id<IB>)NSApp activeDocument];
84
85 // look at the values passed back in the matrix.
86 flag = ([[menuType cellAtRow: 0 column: 0] state] == NSOnState) ? YES : NO; // windows menu...
87 if(flag)
88 {
89 [doc setWindowsMenu: [self object]];
90 if([doc servicesMenu] == [self object])
91 {
92 [doc setServicesObject: nil];
93 }
94 }
95
96 flag = ([[menuType cellAtRow: 1 column: 0] state] == NSOnState) ? YES : NO; // services menu...
97 if(flag)
98 {
99 [doc setServicesMenu: [self object]];
100 if([doc windowsMenu] == [self object])
101 {
102 [doc setWindowsObject: nil];
103 }
104 }
105
106 flag = ([[menuType cellAtRow: 2 column: 0] state] == NSOnState) ? YES : NO; // normal menu...
107 if(flag)
108 {
109 [doc setWindowsMenu: nil];
110 [doc setServicesMenu: nil];
111 }
112 }
113 @end
114
115
116
117 @implementation NSMenuItem (IBObjectAdditions)
118 - (NSString*) inspectorClassName
119 {
120 return @"GormMenuItemAttributesInspector";
121 }
122 @end
123
124 @interface GormMenuItemAttributesInspector : IBInspector
125 {
126 NSTextField *titleText;
127 NSTextField *shortCut;
128 NSTextField *tagText;
129 }
130 @end
131
132 @implementation GormMenuItemAttributesInspector
133
134 - (void) controlTextDidEndEditing: (NSNotification*)aNotification
135 {
136 id o = [aNotification object];
137
138 if (o == titleText)
139 {
140 [object setTitle: [titleText stringValue]];
141 }
142 if (o == shortCut)
143 {
144 NSString *s = [[shortCut stringValue] stringByTrimmingSpaces];
145
146 [object setKeyEquivalent: s];
147 }
148 if (o == tagText)
149 {
150 [object setTag: [tagText intValue]];
151 }
152 [[object menu] display];
153 }
154
155 - (id) init
156 {
157 if ([super init] == nil)
158 return nil;
159
160 if ([NSBundle loadNibNamed: @"GormMenuItemAttributesInspector" owner: self] == NO)
161 {
162 NSLog(@"Could not gorm GormMenuItemAttributesInspector");
163 return nil;
164 }
165 return self;
166 }
167
168 - (void) setObject: (id)anObject
169 {
170 [super setObject: anObject];
171 [titleText setStringValue: [object title]];
172 [shortCut setStringValue: [object keyEquivalent]];
173 [tagText setIntValue: [object tag]];
174 }
175
176 @end

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26