The R Project SVN R-packages

Rev

Rev 1334 | Rev 5705 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1334 Rev 1337
Line 61... Line 61...
61
- (NSToolbarItem *) toolbar: (NSToolbar *)toolbar itemForItemIdentifier: (NSString *) itemIdent willBeInsertedIntoToolbar:(BOOL) willBeInserted {
61
- (NSToolbarItem *) toolbar: (NSToolbar *)toolbar itemForItemIdentifier: (NSString *) itemIdent willBeInsertedIntoToolbar:(BOOL) willBeInserted {
62
    // Required delegate method:  Given an item identifier, this method returns an item 
62
    // Required delegate method:  Given an item identifier, this method returns an item 
63
    // The toolbar will use this method to obtain toolbar items that can be displayed in the customization sheet, or in the toolbar itself 
63
    // The toolbar will use this method to obtain toolbar items that can be displayed in the customization sheet, or in the toolbar itself 
64
    NSToolbarItem *toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent] autorelease];
64
    NSToolbarItem *toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent] autorelease];
65
    
65
    
66
    if ([itemIdent isEqual: RETI_Dummy1]) {
66
    if ([itemIdent isEqual: RETI_Save]) {
67
		// Set the text label to be displayed in the toolbar and customization palette 
67
		// Set the text label to be displayed in the toolbar and customization palette 
68
		[toolbarItem setLabel: NLS(@"Dummy1")];
68
		[toolbarItem setLabel: NLS(@"Save")];
69
		[toolbarItem setPaletteLabel: NLS(@"Dummy1 Label")];
69
		[toolbarItem setPaletteLabel: NLS(@"Save")];
70
		[toolbarItem setToolTip: NLS(@"Dummy1 Tip")];
70
		[toolbarItem setToolTip: NLS(@"Save current document")];
71
		[toolbarItem setImage: [NSImage imageNamed: @"SaveDocumentItemImage"]];
71
		[toolbarItem setImage: [NSImage imageNamed: @"SaveDocumentItemImage"]];
72
		[toolbarItem setTarget: self];
72
		[toolbarItem setTarget: [winCtrl document]];
73
		[toolbarItem setAction: @selector(saveDocument:)];
73
		[toolbarItem setAction: @selector(saveDocument:)];
74
	} else if ([itemIdent isEqual: RETI_Dummy2]) {
74
	} else if ([itemIdent isEqual: RETI_HelpSearch]) { /* help search filed - view item */
75
		NSView *myView = [winCtrl searchToolbarView];
75
		NSView *myView = [winCtrl searchToolbarView];
76
		// Set up the standard properties 
76
		// Set up the standard properties 
77
		[toolbarItem setLabel:@"Search"];
77
		[toolbarItem setLabel:@"Search"];
78
		[toolbarItem setPaletteLabel:@"Search"];
78
		[toolbarItem setPaletteLabel:@"Search"];
79
		[toolbarItem setToolTip:@"Search Help"];
79
		[toolbarItem setToolTip:@"Search Help"];
80
		// Use a custom view, a rounded text field,
-
 
81
		// attached to searchFieldOutlet in InterfaceBuilder as
80
		// Use a custom view, a rounded text field, attached to searchFieldOutlet in InterfaceBuilder as the custom view 
82
		// the custom view 
-
 
83
		[toolbarItem setView:myView];
81
		[toolbarItem setView:myView];
84
		[toolbarItem setMinSize:NSMakeSize(100,NSHeight([myView frame]))];
82
		[toolbarItem setMinSize:NSMakeSize(100,NSHeight([myView frame]))];
85
		[toolbarItem setMaxSize:NSMakeSize(300,NSHeight([myView frame]))];
83
		[toolbarItem setMaxSize:NSMakeSize(300,NSHeight([myView frame]))];
86
		// Create the custom menu 
84
		// Create the custom menu (alternative if icons are disabled)
87
		NSMenu *submenu=[[[NSMenu alloc] init] autorelease];
85
		NSMenu *submenu=[[[NSMenu alloc] init] autorelease];
88
		NSMenuItem *submenuItem=[[[NSMenuItem alloc] initWithTitle: @"Search Panel"
86
		NSMenuItem *submenuItem=[[[NSMenuItem alloc] initWithTitle: @"Search Panel"
89
															action: @selector(searchUsingSearchPanel:)
87
															action: @selector(searchUsingSearchPanel:)
90
													 keyEquivalent: @""] autorelease];
88
													 keyEquivalent: @""] autorelease];
91
		NSMenuItem *menuFormRep=[[[NSMenuItem alloc] init] autorelease];
89
		NSMenuItem *menuFormRep=[[[NSMenuItem alloc] init] autorelease];
92
		[submenu addItem: submenuItem];
90
		[submenu addItem: submenuItem];
93
		[submenuItem setTarget:self];
91
		[submenuItem setTarget:self];
94
		[menuFormRep setSubmenu:submenu];
92
		[menuFormRep setSubmenu:submenu];
95
		[menuFormRep setTitle:[toolbarItem label]];
93
		[menuFormRep setTitle:[toolbarItem label]];
96
		[toolbarItem setMenuFormRepresentation:menuFormRep];
94
		[toolbarItem setMenuFormRepresentation:menuFormRep];
97
	} else if ([itemIdent isEqual: RETI_FnList]) {
95
	} else if ([itemIdent isEqual: RETI_FnList]) { /* function list - view item */
98
		NSView *myView = [winCtrl fnListView];
96
		NSView *myView = [winCtrl fnListView];
99
		// Set up the standard properties 
-
 
100
		[toolbarItem setLabel:@"Functions"];
97
		[toolbarItem setLabel:@"Functions"];
101
		[toolbarItem setPaletteLabel:@"Functions"];
98
		[toolbarItem setPaletteLabel:@"Functions"];
102
		[toolbarItem setToolTip:@"List of Functions"];
99
		[toolbarItem setToolTip:@"List of Functions"];
103
		// Use a custom view, a rounded text field,
-
 
104
		// attached to searchFieldOutlet in InterfaceBuilder as
-
 
105
		// the custom view 
-
 
106
		[toolbarItem setView:myView];
100
		[toolbarItem setView:myView];
107
		[toolbarItem setMinSize:NSMakeSize(100,NSHeight([myView frame]))];
101
		[toolbarItem setMinSize:NSMakeSize(100,NSHeight([myView frame]))];
108
		[toolbarItem setMaxSize:NSMakeSize(200,NSHeight([myView frame]))];
102
		[toolbarItem setMaxSize:NSMakeSize(200,NSHeight([myView frame]))];
109
		/* NO: Create the custom menu 
-
 
110
		NSMenu *submenu=[[[NSMenu alloc] init] autorelease];
-
 
111
		NSMenuItem *submenuItem=[[[NSMenuItem alloc] initWithTitle: @"Search Panel"
-
 
112
															action: @selector(searchUsingSearchPanel:)
-
 
113
													 keyEquivalent: @""] autorelease];
-
 
114
		NSMenuItem *menuFormRep=[[[NSMenuItem alloc] init] autorelease];
-
 
115
		[submenu addItem: submenuItem];
-
 
116
		[submenuItem setTarget:self];
-
 
117
		[menuFormRep setSubmenu:submenu];
-
 
118
		[menuFormRep setTitle:[toolbarItem label]];
-
 
119
		[toolbarItem setMenuFormRepresentation:menuFormRep];
-
 
120
		*/
-
 
121
	} else {
103
	} else
122
		// itemIdent refered to a toolbar item that is not provide or supported by us or Cocoa 
-
 
123
		// Returning nil will inform the toolbar this kind of item is not supported 
-
 
124
		toolbarItem = nil;
104
		toolbarItem = nil;
125
	}
105
 
126
	return toolbarItem;
106
	return toolbarItem;
127
}
107
}
128
 
108
 
129
- (NSArray *) toolbarDefaultItemIdentifiers: (NSToolbar *) toolbar {
109
- (NSArray *) toolbarDefaultItemIdentifiers: (NSToolbar *) toolbar {
130
    // Required delegate method:  Returns the ordered list of items to be shown in the toolbar by default    
-
 
131
    // If during the toolbar's initialization, no overriding values are found in the user defaults, or if the
-
 
132
    // user chooses to revert to the default items this set will be used 
-
 
133
    return [NSArray arrayWithObjects: RET_ListDefault, nil];
110
    return [NSArray arrayWithObjects: RET_ListDefault, nil];
134
}
111
}
135
 
112
 
136
- (NSArray *) toolbarAllowedItemIdentifiers: (NSToolbar *) toolbar {
113
- (NSArray *) toolbarAllowedItemIdentifiers: (NSToolbar *) toolbar {
137
    // Required delegate method:  Returns the list of all allowed items by identifier.  By default, the toolbar 
-
 
138
    // does not assume any items are allowed, even the separator.  So, every allowed item must be explicitly listed   
-
 
139
    // The set of allowed items is used to construct the customization palette 
-
 
140
    return [NSArray arrayWithObjects: RET_ListAll, nil];
114
    return [NSArray arrayWithObjects: RET_ListAll, nil];
141
}
115
}
142
 
116
 
143
- (void) toolbarWillAddItem: (NSNotification *) notif {
117
- (void) toolbarWillAddItem: (NSNotification *) notif {
144
    // Optional delegate method:  Before an new item is added to the toolbar, this notification is posted.
118
    // Optional delegate method:  Before an new item is added to the toolbar, this notification is posted.
Line 157... Line 131...
157
    // key in the userInfo 
131
    // key in the userInfo 
158
	// NSToolbarItem *removedItem = [[notif userInfo] objectForKey: @"item"];
132
	// NSToolbarItem *removedItem = [[notif userInfo] objectForKey: @"item"];
159
}
133
}
160
 
134
 
161
- (BOOL) validateToolbarItem: (NSToolbarItem *) toolbarItem {
135
- (BOOL) validateToolbarItem: (NSToolbarItem *) toolbarItem {
162
    // Optional method:  This message is sent to us since we are the target of some toolbar item actions 
-
 
163
    // (for example:  of the save items action) 
-
 
164
	//NSString *iid = [toolbarItem itemIdentifier];
136
	NSString *iid = [toolbarItem itemIdentifier];
165
    BOOL enable = YES; // default is YES, if there are any that need to be disabled - check for them
137
    BOOL enable = YES; // default is YES, if there are any that need to be disabled - check for them
166
    
138
    
167
	//if ([iid isEqual: ... ]) {
139
	if ([iid isEqual: RETI_Save ])
168
	//enable = [RConsoleWindow isDocumentEdited];
140
		enable = [[winCtrl document] isDocumentEdited];
169
    //}
-
 
170
	
141
	
171
    return enable;
142
    return enable;
172
}
143
}
173
 
144
 
174
@end
145
@end