mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-02-24 12:01:16 +00:00
Improvements in menu handling.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@18875 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
fcad438bad
commit
8861f4f3c7
8 changed files with 113 additions and 16 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2004-03-23 22:01 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
|
* Palettes/0Menus/GormMenuEditor.m: Added code to recursivly
|
||||||
|
add all of the items and submenus to the document.
|
||||||
|
* Palettes/0Menus/main.m: Added code to allow user to drag a new
|
||||||
|
menu to the document.
|
||||||
|
* Palettes/0Menus/GormMenuDrag.tiff: Image for menu to drag
|
||||||
|
* Images/GormMenu.tiff: New image.
|
||||||
|
|
||||||
2004-03-21 23:15 Gregory John Casamento <greg_casamento@yahoo.com>
|
2004-03-21 23:15 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
* GormDocument.[hm]: added [GormDocument _instantiateFontManager]
|
* GormDocument.[hm]: added [GormDocument _instantiateFontManager]
|
||||||
|
|
|
@ -309,9 +309,20 @@ static NSImage *classesImage = nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add the current menu and any submenus.
|
||||||
|
*/
|
||||||
if ([anObject isKindOfClass: [NSMenu class]] == YES)
|
if ([anObject isKindOfClass: [NSMenu class]] == YES)
|
||||||
{
|
{
|
||||||
|
// NSArray *menus = findAllMenus(anObject);
|
||||||
|
// NSEnumerator *en = [menus objectEnumerator];
|
||||||
|
// id obj = nil;
|
||||||
|
|
||||||
[[self openEditorForObject: anObject] activate];
|
[[self openEditorForObject: anObject] activate];
|
||||||
|
// while((obj = [en nextObject]) != nil)
|
||||||
|
// {
|
||||||
|
// [[self openEditorForObject: obj] activate];
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -709,7 +720,6 @@ static NSImage *classesImage = nil;
|
||||||
while ((obj = [enumerator nextObject]) != nil)
|
while ((obj = [enumerator nextObject]) != nil)
|
||||||
{
|
{
|
||||||
id editor = [self editorForObject: obj create: NO];
|
id editor = [self editorForObject: obj create: NO];
|
||||||
|
|
||||||
if (editor != nil)
|
if (editor != nil)
|
||||||
{
|
{
|
||||||
[editors addObject: editor];
|
[editors addObject: editor];
|
||||||
|
|
|
@ -197,7 +197,8 @@ static NSImage *dragImage = nil;
|
||||||
event: theEvent
|
event: theEvent
|
||||||
pasteboard: pb
|
pasteboard: pb
|
||||||
source: self
|
source: self
|
||||||
slideBack: [type isEqual: IBWindowPboardType] ? NO : YES];
|
slideBack: ([type isEqual: IBWindowPboardType] ||
|
||||||
|
[type isEqual: IBMenuPboardType]) ? NO : YES];
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -33,6 +33,7 @@ PALETTE_NAME = 0Menus
|
||||||
|
|
||||||
0Menus_PRINCIPAL_CLASS = MenusPalette
|
0Menus_PRINCIPAL_CLASS = MenusPalette
|
||||||
0Menus_RESOURCE_FILES = MenusPalette.tiff \
|
0Menus_RESOURCE_FILES = MenusPalette.tiff \
|
||||||
|
GormMenuDrag.tiff \
|
||||||
GormMenuAttributesInspector.gorm \
|
GormMenuAttributesInspector.gorm \
|
||||||
GormMenuItemAttributesInspector.gorm
|
GormMenuItemAttributesInspector.gorm
|
||||||
|
|
||||||
|
|
BIN
Palettes/0Menus/GormMenuDrag.tiff
Normal file
BIN
Palettes/0Menus/GormMenuDrag.tiff
Normal file
Binary file not shown.
|
@ -631,6 +631,32 @@
|
||||||
return edited;
|
return edited;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// find all subitems for the given items...
|
||||||
|
void _attachAllSubmenus(id menu, NSArray *items, id document)
|
||||||
|
{
|
||||||
|
NSEnumerator *e = [items objectEnumerator];
|
||||||
|
id i = nil;
|
||||||
|
|
||||||
|
while((i = [e nextObject]) != nil)
|
||||||
|
{
|
||||||
|
[document attachObject: i toParent: menu];
|
||||||
|
if([i hasSubmenu])
|
||||||
|
{
|
||||||
|
id submenu = [i submenu];
|
||||||
|
NSArray *submenuItems = [submenu itemArray];
|
||||||
|
|
||||||
|
[document attachObject: submenu toParent: i];
|
||||||
|
_attachAllSubmenus(submenu, submenuItems, document);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _attachAll(NSMenu *menu, id document)
|
||||||
|
{
|
||||||
|
NSArray *items = [menu itemArray];
|
||||||
|
_attachAllSubmenus(menu, items, document);
|
||||||
|
}
|
||||||
|
|
||||||
- (id) initWithObject: (id)anObject inDocument: (id<IBDocuments>)aDocument
|
- (id) initWithObject: (id)anObject inDocument: (id<IBDocuments>)aDocument
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
@ -647,7 +673,8 @@
|
||||||
/*
|
/*
|
||||||
* Make sure that all our menu items are attached in the document.
|
* Make sure that all our menu items are attached in the document.
|
||||||
*/
|
*/
|
||||||
[document attachObjects: [edited itemArray] toParent: edited];
|
_attachAll(edited, document);
|
||||||
|
// [document attachObjects: [edited itemArray] toParent: edited];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -926,6 +953,7 @@
|
||||||
ASSIGN(subeditor, editor);
|
ASSIGN(subeditor, editor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now we must let the document (and hence the rest of the app) know
|
* Now we must let the document (and hence the rest of the app) know
|
||||||
* about our new selection. If there is nothing in it, make sure
|
* about our new selection. If there is nothing in it, make sure
|
||||||
|
|
|
@ -26,6 +26,34 @@
|
||||||
#include <InterfaceBuilder/InterfaceBuilder.h>
|
#include <InterfaceBuilder/InterfaceBuilder.h>
|
||||||
#include "GormNSMenu.h"
|
#include "GormNSMenu.h"
|
||||||
|
|
||||||
|
@interface GormMenuMaker : NSObject <NSCoding>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation GormMenuMaker
|
||||||
|
- (void) encodeWithCoder: (NSCoder *)coder
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) initWithCoder: (NSCoder *)coder
|
||||||
|
{
|
||||||
|
NSMenu *m = [[GormNSMenu alloc] init];
|
||||||
|
|
||||||
|
// build the menu..
|
||||||
|
[m setTitle: _(@"Main Menu")];
|
||||||
|
[m addItemWithTitle: _(@"Hide")
|
||||||
|
action: @selector(hide:)
|
||||||
|
keyEquivalent: @"h"];
|
||||||
|
[m addItemWithTitle: _(@"Quit")
|
||||||
|
action: @selector(terminate:)
|
||||||
|
keyEquivalent: @"q"];
|
||||||
|
RELEASE(self);
|
||||||
|
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
@interface MenusPalette: IBPalette
|
@interface MenusPalette: IBPalette
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -40,6 +68,11 @@
|
||||||
NSMenu *m;
|
NSMenu *m;
|
||||||
NSMenu *s;
|
NSMenu *s;
|
||||||
NSButton *b;
|
NSButton *b;
|
||||||
|
id menu;
|
||||||
|
id v;
|
||||||
|
NSBundle *bundle = [NSBundle bundleForClass: [self class]];
|
||||||
|
NSString *path = [bundle pathForImageResource: @"GormMenuDrag"];
|
||||||
|
NSImage *dragImage = [[NSImage alloc] initWithContentsOfFile: path];
|
||||||
|
|
||||||
window = [[NSWindow alloc] initWithContentRect: NSMakeRect(0, 0, 272, 192)
|
window = [[NSWindow alloc] initWithContentRect: NSMakeRect(0, 0, 272, 192)
|
||||||
styleMask: NSBorderlessWindowMask
|
styleMask: NSBorderlessWindowMask
|
||||||
|
@ -67,7 +100,7 @@
|
||||||
keyEquivalent: @""];
|
keyEquivalent: @""];
|
||||||
[i setSubmenu: m];
|
[i setSubmenu: m];
|
||||||
|
|
||||||
b = [[NSButton alloc] initWithFrame: NSMakeRect(30, 140, 100, 20)];
|
b = [[NSButton alloc] initWithFrame: NSMakeRect(30, 160, 100, 20)];
|
||||||
[b setImage: [NSImage imageNamed: @"common_3DArrowRight"]];
|
[b setImage: [NSImage imageNamed: @"common_3DArrowRight"]];
|
||||||
[b setAlignment: NSLeftTextAlignment];
|
[b setAlignment: NSLeftTextAlignment];
|
||||||
[b setImagePosition: NSImageRight];
|
[b setImagePosition: NSImageRight];
|
||||||
|
@ -118,7 +151,7 @@
|
||||||
keyEquivalent: @""];
|
keyEquivalent: @""];
|
||||||
[i setSubmenu: m];
|
[i setSubmenu: m];
|
||||||
|
|
||||||
b = [[NSButton alloc] initWithFrame: NSMakeRect(145, 140, 100, 20)];
|
b = [[NSButton alloc] initWithFrame: NSMakeRect(145, 160, 100, 20)];
|
||||||
[b setImage: [NSImage imageNamed: @"common_3DArrowRight"]];
|
[b setImage: [NSImage imageNamed: @"common_3DArrowRight"]];
|
||||||
[b setAlignment: NSLeftTextAlignment];
|
[b setAlignment: NSLeftTextAlignment];
|
||||||
[b setImagePosition: NSImageRight];
|
[b setImagePosition: NSImageRight];
|
||||||
|
@ -166,7 +199,7 @@
|
||||||
keyEquivalent: @""];
|
keyEquivalent: @""];
|
||||||
[i setSubmenu: m];
|
[i setSubmenu: m];
|
||||||
|
|
||||||
b = [[NSButton alloc] initWithFrame: NSMakeRect(30, 120, 100, 20)];
|
b = [[NSButton alloc] initWithFrame: NSMakeRect(30, 140, 100, 20)];
|
||||||
[b setImage: [NSImage imageNamed: @"common_3DArrowRight"]];
|
[b setImage: [NSImage imageNamed: @"common_3DArrowRight"]];
|
||||||
[b setAlignment: NSLeftTextAlignment];
|
[b setAlignment: NSLeftTextAlignment];
|
||||||
[b setImagePosition: NSImageRight];
|
[b setImagePosition: NSImageRight];
|
||||||
|
@ -208,7 +241,7 @@
|
||||||
keyEquivalent: @""];
|
keyEquivalent: @""];
|
||||||
[i setSubmenu: m];
|
[i setSubmenu: m];
|
||||||
|
|
||||||
b = [[NSButton alloc] initWithFrame: NSMakeRect(145, 120, 100, 20)];
|
b = [[NSButton alloc] initWithFrame: NSMakeRect(145, 140, 100, 20)];
|
||||||
[b setImage: [NSImage imageNamed: @"common_3DArrowRight"]];
|
[b setImage: [NSImage imageNamed: @"common_3DArrowRight"]];
|
||||||
[b setAlignment: NSLeftTextAlignment];
|
[b setAlignment: NSLeftTextAlignment];
|
||||||
[b setImagePosition: NSImageRight];
|
[b setImagePosition: NSImageRight];
|
||||||
|
@ -244,7 +277,7 @@
|
||||||
keyEquivalent: @""];
|
keyEquivalent: @""];
|
||||||
[i setSubmenu: m];
|
[i setSubmenu: m];
|
||||||
|
|
||||||
b = [[NSButton alloc] initWithFrame: NSMakeRect(30, 100, 100, 20)];
|
b = [[NSButton alloc] initWithFrame: NSMakeRect(30, 120, 100, 20)];
|
||||||
[b setImage: [NSImage imageNamed: @"common_3DArrowRight"]];
|
[b setImage: [NSImage imageNamed: @"common_3DArrowRight"]];
|
||||||
[b setAlignment: NSLeftTextAlignment];
|
[b setAlignment: NSLeftTextAlignment];
|
||||||
[b setImagePosition: NSImageRight];
|
[b setImagePosition: NSImageRight];
|
||||||
|
@ -283,7 +316,7 @@
|
||||||
keyEquivalent: @""];
|
keyEquivalent: @""];
|
||||||
[i setSubmenu: m];
|
[i setSubmenu: m];
|
||||||
|
|
||||||
b = [[NSButton alloc] initWithFrame: NSMakeRect(145, 100, 100, 20)];
|
b = [[NSButton alloc] initWithFrame: NSMakeRect(145, 120, 100, 20)];
|
||||||
[b setImage: [NSImage imageNamed: @"common_3DArrowRight"]];
|
[b setImage: [NSImage imageNamed: @"common_3DArrowRight"]];
|
||||||
[b setAlignment: NSLeftTextAlignment];
|
[b setAlignment: NSLeftTextAlignment];
|
||||||
[b setImagePosition: NSImageRight];
|
[b setImagePosition: NSImageRight];
|
||||||
|
@ -375,7 +408,7 @@
|
||||||
keyEquivalent: @""];
|
keyEquivalent: @""];
|
||||||
[i setSubmenu: m];
|
[i setSubmenu: m];
|
||||||
|
|
||||||
b = [[NSButton alloc] initWithFrame: NSMakeRect(30, 80, 100, 20)];
|
b = [[NSButton alloc] initWithFrame: NSMakeRect(30, 100, 100, 20)];
|
||||||
[b setImage: [NSImage imageNamed: @"common_3DArrowRight"]];
|
[b setImage: [NSImage imageNamed: @"common_3DArrowRight"]];
|
||||||
[b setAlignment: NSLeftTextAlignment];
|
[b setAlignment: NSLeftTextAlignment];
|
||||||
[b setImagePosition: NSImageRight];
|
[b setImagePosition: NSImageRight];
|
||||||
|
@ -396,7 +429,7 @@
|
||||||
action: @selector(orderFrontColorPanel:)
|
action: @selector(orderFrontColorPanel:)
|
||||||
keyEquivalent: @""];
|
keyEquivalent: @""];
|
||||||
|
|
||||||
b = [[NSButton alloc] initWithFrame: NSMakeRect(145, 80, 100, 20)];
|
b = [[NSButton alloc] initWithFrame: NSMakeRect(145, 100, 100, 20)];
|
||||||
[b setAlignment: NSLeftTextAlignment];
|
[b setAlignment: NSLeftTextAlignment];
|
||||||
[b setTitle: @" Colors..."];
|
[b setTitle: @" Colors..."];
|
||||||
[contents addSubview: b];
|
[contents addSubview: b];
|
||||||
|
@ -426,7 +459,7 @@
|
||||||
keyEquivalent: @""];
|
keyEquivalent: @""];
|
||||||
[i setSubmenu: m];
|
[i setSubmenu: m];
|
||||||
|
|
||||||
b = [[NSButton alloc] initWithFrame: NSMakeRect(30, 60, 100, 20)];
|
b = [[NSButton alloc] initWithFrame: NSMakeRect(30, 80, 100, 20)];
|
||||||
[b setImage: [NSImage imageNamed: @"common_3DArrowRight"]];
|
[b setImage: [NSImage imageNamed: @"common_3DArrowRight"]];
|
||||||
[b setAlignment: NSLeftTextAlignment];
|
[b setAlignment: NSLeftTextAlignment];
|
||||||
[b setImagePosition: NSImageRight];
|
[b setImagePosition: NSImageRight];
|
||||||
|
@ -447,7 +480,7 @@
|
||||||
action: NULL
|
action: NULL
|
||||||
keyEquivalent: @""];
|
keyEquivalent: @""];
|
||||||
|
|
||||||
b = [[NSButton alloc] initWithFrame: NSMakeRect(145, 60, 100, 20)];
|
b = [[NSButton alloc] initWithFrame: NSMakeRect(145, 80, 100, 20)];
|
||||||
[b setAlignment: NSLeftTextAlignment];
|
[b setAlignment: NSLeftTextAlignment];
|
||||||
[b setTitle: @" Item"];
|
[b setTitle: @" Item"];
|
||||||
[contents addSubview: b];
|
[contents addSubview: b];
|
||||||
|
@ -468,7 +501,7 @@
|
||||||
keyEquivalent: @""];
|
keyEquivalent: @""];
|
||||||
[i setSubmenu: m];
|
[i setSubmenu: m];
|
||||||
|
|
||||||
b = [[NSButton alloc] initWithFrame: NSMakeRect(30, 40, 100, 20)];
|
b = [[NSButton alloc] initWithFrame: NSMakeRect(30, 60, 100, 20)];
|
||||||
[b setImage: [NSImage imageNamed: @"common_3DArrowRight"]];
|
[b setImage: [NSImage imageNamed: @"common_3DArrowRight"]];
|
||||||
[b setAlignment: NSLeftTextAlignment];
|
[b setAlignment: NSLeftTextAlignment];
|
||||||
[b setImagePosition: NSImageRight];
|
[b setImagePosition: NSImageRight];
|
||||||
|
@ -495,7 +528,7 @@
|
||||||
keyEquivalent: @""];
|
keyEquivalent: @""];
|
||||||
[i setSubmenu: m];
|
[i setSubmenu: m];
|
||||||
|
|
||||||
b = [[NSButton alloc] initWithFrame: NSMakeRect(145, 40, 100, 20)];
|
b = [[NSButton alloc] initWithFrame: NSMakeRect(145, 60, 100, 20)];
|
||||||
[b setImage: [NSImage imageNamed: @"common_3DArrowRight"]];
|
[b setImage: [NSImage imageNamed: @"common_3DArrowRight"]];
|
||||||
[b setAlignment: NSLeftTextAlignment];
|
[b setAlignment: NSLeftTextAlignment];
|
||||||
[b setImagePosition: NSImageRight];
|
[b setImagePosition: NSImageRight];
|
||||||
|
@ -508,6 +541,21 @@
|
||||||
RELEASE(i);
|
RELEASE(i);
|
||||||
RELEASE(m);
|
RELEASE(m);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A whole new menu...
|
||||||
|
*/
|
||||||
|
menu = [GormMenuMaker new];
|
||||||
|
v = [[NSButton alloc] initWithFrame: NSMakeRect(148,6,48,48)];
|
||||||
|
[v setBordered: NO];
|
||||||
|
[v setImage: dragImage];
|
||||||
|
[v setImagePosition: NSImageOverlaps];
|
||||||
|
[v setTitle: nil];
|
||||||
|
[contents addSubview: v];
|
||||||
|
[self associateObject: menu
|
||||||
|
type: IBMenuPboardType
|
||||||
|
with: v];
|
||||||
|
RELEASE(v);
|
||||||
|
RELEASE(menu);
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue