Minor fixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5672 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 2000-01-05 17:42:47 +00:00
parent c23e5e2e11
commit 623f5da51a
2 changed files with 122 additions and 121 deletions

View file

@ -3,6 +3,7 @@ Wed Jan 5 16:27:00 2000 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/NSMenuItem.m: minor fixes and tidying. * Source/NSMenuItem.m: minor fixes and tidying.
* Source/NSMenuView.m: reverted to previous version - last change * Source/NSMenuView.m: reverted to previous version - last change
broke much more than it fixed. broke much more than it fixed.
Also tidied coding style a bit and fixed a couple of encode/decode bugs.
Mon Jan 3 18:35:00 2000 Richard Frith-Macdonald <richard@brainstorm.co.uk> Mon Jan 3 18:35:00 2000 Richard Frith-Macdonald <richard@brainstorm.co.uk>

View file

@ -46,25 +46,25 @@ static float GSMenuBarHeight = 25.0; // A wild guess.
@implementation NSMenuView @implementation NSMenuView
// /*
// Class methods. * Class methods.
// */
+ (float) menuBarHeight + (float) menuBarHeight
{ {
return GSMenuBarHeight; return GSMenuBarHeight;
} }
// /*
// NSView overrides * NSView overrides
// */
- (BOOL) acceptsFirstMouse: (NSEvent*)theEvent - (BOOL) acceptsFirstMouse: (NSEvent*)theEvent
{ {
return YES; return YES;
} }
// /*
// Init methods. * Init methods.
// */
- (id) init - (id) init
{ {
return [self initWithFrame: NSZeroRect]; return [self initWithFrame: NSZeroRect];
@ -98,14 +98,14 @@ static float GSMenuBarHeight = 25.0; // A wild guess.
return self; return self;
} }
// /*
// Getting and Setting Menu View Attributes * Getting and Setting Menu View Attributes
// */
- (void) setMenu: (NSMenu*)menu - (void) setMenu: (NSMenu*)menu
{ {
NSNotificationCenter *theCenter = [NSNotificationCenter defaultCenter]; NSNotificationCenter *theCenter = [NSNotificationCenter defaultCenter];
if (menuv_menu) if (menuv_menu != nil)
{ {
// Remove this menu view from the old menu list of observers. // Remove this menu view from the old menu list of observers.
[theCenter removeObserver: self name: nil object: menuv_menu]; [theCenter removeObserver: self name: nil object: menuv_menu];
@ -276,9 +276,9 @@ static float GSMenuBarHeight = 25.0; // A wild guess.
return menuv_horizontalEdgePad; return menuv_horizontalEdgePad;
} }
// /*
// Notification Methods * Notification Methods
// */
- (void) itemChanged: (NSNotification*)notification - (void) itemChanged: (NSNotification*)notification
{ {
int index = [[[notification userInfo] objectForKey: @"NSMenuItemIndex"] int index = [[[notification userInfo] objectForKey: @"NSMenuItemIndex"]
@ -334,9 +334,9 @@ static float GSMenuBarHeight = 25.0; // A wild guess.
[self setNeedsSizing: YES]; [self setNeedsSizing: YES];
} }
// /*
// Working with Submenus. * Working with Submenus.
// */
- (void) detachSubmenu - (void) detachSubmenu
{ {
NSMenu *attachedMenu = [menuv_menu attachedMenu]; NSMenu *attachedMenu = [menuv_menu attachedMenu];
@ -362,11 +362,12 @@ static float GSMenuBarHeight = 25.0; // A wild guess.
- (void) attachSubmenuForItemAtIndex: (int)index - (void) attachSubmenuForItemAtIndex: (int)index
{ {
// Transient menus are used for torn-off menus, which are already on the /*
// screen and for sons of transient menus. As transients disappear as * Transient menus are used for torn-off menus, which are already on the
// soon as we release the mouse the user will be able to leave submenus * screen and for sons of transient menus. As transients disappear as
// open on the screen and interact with other menus at the same time. * soon as we release the mouse the user will be able to leave submenus
* open on the screen and interact with other menus at the same time.
*/
NSMenu *attachableMenu = [[menuv_items_link objectAtIndex: index] submenu]; NSMenu *attachableMenu = [[menuv_items_link objectAtIndex: index] submenu];
if ([attachableMenu isTornOff] || [menuv_menu isFollowTransient]) if ([attachableMenu isTornOff] || [menuv_menu isFollowTransient])
@ -380,9 +381,9 @@ static float GSMenuBarHeight = 25.0; // A wild guess.
[attachableMenu display]; [attachableMenu display];
} }
// /*
// Calculating Menu Geometry * Calculating Menu Geometry
// */
- (void) update - (void) update
{ {
[menuv_menu update]; [menuv_menu update];
@ -634,9 +635,9 @@ static float GSMenuBarHeight = 25.0; // A wild guess.
display: YES]; display: YES];
} }
// /*
// Drawing. * Drawing.
// */
- (void) drawRect: (NSRect)rect - (void) drawRect: (NSRect)rect
{ {
int i; int i;
@ -669,9 +670,9 @@ static float GSMenuBarHeight = 25.0; // A wild guess.
} }
} }
// /*
// Event Handling * Event Handling
// */
- (void) performActionWithHighlightingForItemAtIndex: (int)index - (void) performActionWithHighlightingForItemAtIndex: (int)index
{ {
NSMenu *candidateMenu = menuv_menu; NSMenu *candidateMenu = menuv_menu;
@ -680,9 +681,9 @@ static float GSMenuBarHeight = 25.0; // A wild guess.
for (;;) for (;;)
{ {
if (![candidateMenu supermenu] || if (![candidateMenu supermenu]
[candidateMenu isAttached] || || [candidateMenu isAttached]
[candidateMenu isTornOff]) || [candidateMenu isTornOff])
{ {
targetMenuView = [candidateMenu menuRepresentation]; targetMenuView = [candidateMenu menuRepresentation];
@ -819,9 +820,8 @@ static float GSMenuBarHeight = 25.0; // A wild guess.
} }
// Close menus if needed. // Close menus if needed.
if (!menuv_keepAttachedMenus || if (!menuv_keepAttachedMenus || index == -1
index == -1 || || (alreadyAttachedMenu && [alreadyAttachedMenu isFollowTransient]))
(alreadyAttachedMenu && [alreadyAttachedMenu isFollowTransient]))
{ {
NSMenu *parentMenu; NSMenu *parentMenu;
NSMenu *masterMenu; NSMenu *masterMenu;
@ -884,9 +884,9 @@ static float GSMenuBarHeight = 25.0; // A wild guess.
return [menuv_menu performKeyEquivalent: theEvent]; return [menuv_menu performKeyEquivalent: theEvent];
} }
// /*
// NSCoding Protocol * NSCoding Protocol
// */
- (void) encodeWithCoder: (NSCoder*)encoder - (void) encodeWithCoder: (NSCoder*)encoder
{ {
[super encodeWithCoder: encoder]; [super encodeWithCoder: encoder];
@ -904,8 +904,8 @@ static float GSMenuBarHeight = 25.0; // A wild guess.
{ {
self = [super initWithCoder: decoder]; self = [super initWithCoder: decoder];
menuv_itemCells = [decoder decodeObject]; [decoder decodeValueOfObjCType: @encode(id) at: &menuv_itemCells];
menuv_font = [decoder decodeObject]; [decoder decodeValueOfObjCType: @encode(id) at: &menuv_font];
menuv_menu = [decoder decodeObject]; menuv_menu = [decoder decodeObject];
menuv_items_link = [decoder decodeObject]; menuv_items_link = [decoder decodeObject];
[decoder decodeValueOfObjCType: @encode(BOOL) at: &menuv_horizontal]; [decoder decodeValueOfObjCType: @encode(BOOL) at: &menuv_horizontal];