mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-25 18:30:56 +00:00
Fun fixes.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4877 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
4026532377
commit
3d2b84054e
6 changed files with 697 additions and 639 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,4 +1,12 @@
|
|||
1999-09-10 Pedro Ivo Andrade Tavares <ptavares@iname.com>
|
||||
1999-09-11 Michael Hanni <mhanni@sprintmail.com>
|
||||
|
||||
* Source/NSMenu.m: many small fixes and optimizations for quicker
|
||||
display. In addition several small fixes which should improve
|
||||
functionality as well as usablity.
|
||||
* Source/NSMenuView.m: ditto.
|
||||
* Source/NSHelpManager.m: a small bugfix to allow for compilation.
|
||||
|
||||
1999-09-11 Pedro Ivo Andrade Tavares <ptavares@iname.com>
|
||||
|
||||
* NSResponder.m ([NSResponder -helpRequested:]):
|
||||
Now the application exits context help mode regardless of whether
|
||||
|
|
|
@ -154,7 +154,8 @@
|
|||
return nil;
|
||||
}
|
||||
|
||||
// private; called during nib load. // we do not retain the window, since it should
|
||||
// private; called during nib load.
|
||||
// we do not retain the window, since it should
|
||||
// already have a retain from the nib.
|
||||
- (void)setWindow:(NSWindow *)window
|
||||
{
|
||||
|
@ -233,7 +234,8 @@
|
|||
{
|
||||
int result;
|
||||
|
||||
if (![self isDocumentEdited]) return YES;
|
||||
if (![self isDocumentEdited])
|
||||
return YES;
|
||||
|
||||
//FIXME -- localize.
|
||||
result = NSRunAlertPanel(@"Close", @"%@ has changed. Save?",
|
||||
|
@ -259,7 +261,8 @@
|
|||
|
||||
/* If it's the last window controller, pop up a warning */
|
||||
/* maybe we should count only loaded window controllers (or visible windows). */
|
||||
if ([windowController shouldCloseDocument] || [_windowControllers count] == 1)
|
||||
if ([windowController shouldCloseDocument]
|
||||
|| [_windowControllers count] == 1)
|
||||
{
|
||||
return [self canCloseDocument];
|
||||
}
|
||||
|
@ -304,7 +307,8 @@
|
|||
{
|
||||
NSData *data = [self dataRepresentationOfType:type];
|
||||
|
||||
if (data == nil) return nil;
|
||||
if (data == nil)
|
||||
return nil;
|
||||
|
||||
return [[[NSFileWrapper alloc] initRegularFileWithContents:data] autorelease];
|
||||
}
|
||||
|
@ -397,6 +401,7 @@
|
|||
}
|
||||
|
||||
[savePanel setTitle:title];
|
||||
|
||||
if ([self fileName])
|
||||
[savePanel setDirectory:[[self fileName] stringByDeletingLastPathComponent]];
|
||||
|
||||
|
@ -426,7 +431,7 @@
|
|||
}
|
||||
|
||||
|
||||
// Page layout panel (Page Setup)
|
||||
// Page layout panel (Page Setup)
|
||||
|
||||
- (int)runModalPageLayoutWithPrintInfo:(NSPrintInfo *)printInfo
|
||||
{
|
||||
|
@ -437,8 +442,8 @@
|
|||
{
|
||||
NSPrintInfo *printInfo = [self printInfo];
|
||||
|
||||
if ([self runModalPageLayoutWithPrintInfo:printInfo] &&
|
||||
[self shouldChangePrintInfo:printInfo])
|
||||
if ([self runModalPageLayoutWithPrintInfo:printInfo]
|
||||
&& [self shouldChangePrintInfo:printInfo])
|
||||
{
|
||||
[self setPrintInfo:printInfo];
|
||||
[self updateChangeCount:NSChangeDone];
|
||||
|
@ -640,14 +645,18 @@
|
|||
}
|
||||
|
||||
- (void)_changeWasDone:(NSNotification *)notification
|
||||
{ [self updateChangeCount:NSChangeDone];
|
||||
{
|
||||
[self updateChangeCount:NSChangeDone];
|
||||
}
|
||||
|
||||
- (void)_changeWasUndone:(NSNotification *)notification
|
||||
{ [self updateChangeCount:NSChangeUndone];
|
||||
{
|
||||
[self updateChangeCount:NSChangeUndone];
|
||||
}
|
||||
|
||||
- (void)_changeWasRedone:(NSNotification *)notification
|
||||
{ [self updateChangeCount:NSChangeDone];
|
||||
{
|
||||
[self updateChangeCount:NSChangeDone];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ static NSDictionary *TypeInfoForName(NSArray *types, NSString *typeName)
|
|||
for (i=0; i<count;i++)
|
||||
{
|
||||
NSDictionary *dict = [types objectAtIndex:i];
|
||||
|
||||
if ([[dict objectForKey:NSNameKey] isEqualToString:typeName])
|
||||
return dict;
|
||||
}
|
||||
|
@ -48,11 +49,14 @@ static NSDictionary *TypeInfoForName(NSArray *types, NSString *typeName)
|
|||
{
|
||||
return [self sharedDocumentController];
|
||||
}
|
||||
|
||||
+ (id)sharedDocumentController
|
||||
{
|
||||
static id instance = nil;
|
||||
|
||||
if (instance == nil) instance = [[super allocWithZone:NULL] init];
|
||||
if (instance == nil)
|
||||
instance = [[super allocWithZone:NULL] init];
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
@ -111,7 +115,9 @@ static NSDictionary *TypeInfoForName(NSArray *types, NSString *typeName)
|
|||
|
||||
- _defaultType
|
||||
{
|
||||
if ([_types count] == 0) return nil; // raise exception?
|
||||
if ([_types count] == 0)
|
||||
return nil; // raise exception?
|
||||
|
||||
return [[_types objectAtIndex:0] objectForKey:NSNameKey];
|
||||
}
|
||||
|
||||
|
@ -130,7 +136,8 @@ static NSDictionary *TypeInfoForName(NSArray *types, NSString *typeName)
|
|||
{
|
||||
NSDocument *document = [self makeUntitledDocumentOfType:type];
|
||||
|
||||
if (document == nil) return nil;
|
||||
if (document == nil)
|
||||
return nil;
|
||||
|
||||
[self _addDocument:document];
|
||||
if ([self shouldCreateUI])
|
||||
|
@ -153,6 +160,7 @@ static NSDictionary *TypeInfoForName(NSArray *types, NSString *typeName)
|
|||
|
||||
if ((document = [self makeDocumentWithContentsOfFile:fileName ofType:type]))
|
||||
[self _addDocument:document];
|
||||
|
||||
if ([self shouldCreateUI])
|
||||
[document makeWindowControllers];
|
||||
}
|
||||
|
@ -175,9 +183,12 @@ static NSDictionary *TypeInfoForName(NSArray *types, NSString *typeName)
|
|||
NSString *type = [self typeFromFileExtension:[[url path] pathExtension]];
|
||||
|
||||
document = [self makeDocumentWithContentsOfURL:url ofType:type];
|
||||
if (document == nil) return nil;
|
||||
|
||||
if (document == nil)
|
||||
return nil;
|
||||
|
||||
[self _addDocument:document];
|
||||
|
||||
if ([self shouldCreateUI])
|
||||
{
|
||||
[document makeWindowControllers];
|
||||
|
@ -368,7 +379,8 @@ static NSDictionary *TypeInfoForName(NSArray *types, NSString *typeName)
|
|||
|
||||
for (i=0; i<count; i++)
|
||||
{
|
||||
if ([[_documents objectAtIndex:i] isDocumentEdited]) return YES;
|
||||
if ([[_documents objectAtIndex:i] isDocumentEdited])
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
|
@ -387,7 +399,9 @@ static NSDictionary *TypeInfoForName(NSArray *types, NSString *typeName)
|
|||
BOOL isDir = NO;
|
||||
|
||||
if (directory &&
|
||||
[manager fileExistsAtPath:directory isDirectory:&isDir] && isDir) return directory;
|
||||
[manager fileExistsAtPath:directory isDirectory:&isDir] && isDir)
|
||||
return directory;
|
||||
|
||||
//FIXME -- need to remember last saved directory, and return that here.
|
||||
//Only return NSHomeDirectory if nothing's been saved yet.
|
||||
return NSHomeDirectory();
|
||||
|
@ -397,11 +411,17 @@ static NSDictionary *TypeInfoForName(NSArray *types, NSString *typeName)
|
|||
{
|
||||
id document;
|
||||
|
||||
if (window == nil) return nil;
|
||||
if (![[window windowController] isKindOfClass:[NSWindowController class]]) return nil;
|
||||
if (window == nil)
|
||||
return nil;
|
||||
|
||||
if (![[window windowController] isKindOfClass:[NSWindowController class]])
|
||||
return nil;
|
||||
|
||||
document = [[window windowController] document];
|
||||
if (![document isKindOfClass:[NSDocument class]]) return nil;
|
||||
|
||||
if (![document isKindOfClass:[NSDocument class]])
|
||||
return nil;
|
||||
|
||||
return document;
|
||||
}
|
||||
|
||||
|
|
|
@ -105,7 +105,6 @@ static NSString* NSMenuLocationsKey = @"NSMenuLocations";
|
|||
menu_follow_transient = NO;
|
||||
menu_is_beholdenToPopUpButton = YES;
|
||||
ASSIGN(menu_popb, popb);
|
||||
// menu_popb = popb;
|
||||
|
||||
menu_changed = YES;
|
||||
/* According to the spec, menus do autoenable by default */
|
||||
|
@ -171,8 +170,8 @@ static NSString* NSMenuLocationsKey = @"NSMenuLocations";
|
|||
defer: NO];
|
||||
|
||||
titleView = [NSMenuWindowTitleView new];
|
||||
[titleView setFrameOrigin: NSMakePoint(0, winRect.size.height-21)];
|
||||
[titleView setFrameSize: NSMakeSize (winRect.size.width, 21)];
|
||||
[titleView setFrameOrigin: NSMakePoint(0, winRect.size.height-22)];
|
||||
[titleView setFrameSize: NSMakeSize (winRect.size.width, 22)];
|
||||
[[aWindow contentView] addSubview:menu_view];
|
||||
[[aWindow contentView] addSubview:titleView];
|
||||
[titleView setMenu: self];
|
||||
|
@ -515,7 +514,7 @@ static NSString* NSMenuLocationsKey = @"NSMenuLocations";
|
|||
NSPoint subOrigin = [win_link convertBaseToScreen: NSMakePoint(aRect.origin.x, aRect.origin.y)];
|
||||
|
||||
return NSMakePoint (frame.origin.x + frame.size.width + 1,
|
||||
subOrigin.y - (submenuFrame.size.height - 41));
|
||||
subOrigin.y - (submenuFrame.size.height - 42));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -727,20 +726,17 @@ static NSString* NSMenuLocationsKey = @"NSMenuLocations";
|
|||
|
||||
if (!menu_is_beholdenToPopUpButton)
|
||||
{
|
||||
size.height += 21;
|
||||
size.height += 22;
|
||||
[aWindow setContentSize: size];
|
||||
[bWindow setContentSize: size];
|
||||
[menu_view setFrameOrigin: NSMakePoint(0, 0)];
|
||||
[titleView setFrame: NSMakeRect(0,size.height-21,size.width,21)];
|
||||
[titleView setFrame: NSMakeRect(0,size.height-22,size.width,22)];
|
||||
}
|
||||
else
|
||||
{
|
||||
[aWindow setContentSize: size];
|
||||
}
|
||||
|
||||
// FIXME, popup sets itself up.
|
||||
// [menu_view setNeedsDisplay:YES];
|
||||
|
||||
[aWindow display];
|
||||
|
||||
menu_changed = NO;
|
||||
|
@ -864,9 +860,7 @@ NSArray* array;
|
|||
|
||||
if (menu_supermenu && ![self isTornOff]) // query super menu for
|
||||
{ // position
|
||||
NSPoint location = [menu_supermenu locationForSubmenu: self];
|
||||
|
||||
[aWindow setFrameOrigin: location];
|
||||
[aWindow setFrameOrigin:[menu_supermenu locationForSubmenu: self]];
|
||||
menu_supermenu->menu_attached_menu = self;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -130,65 +130,94 @@ static float GSMenuBarHeight = 25.0; // a guess.
|
|||
|
||||
[self lockFocus];
|
||||
|
||||
if (index == -1) {
|
||||
if (menuv_highlightedItemIndex != -1) {
|
||||
if (index == -1)
|
||||
{
|
||||
if (menuv_highlightedItemIndex != -1)
|
||||
{
|
||||
NSRect aRect = [self rectOfItemAtIndex: menuv_highlightedItemIndex];
|
||||
|
||||
anItem = [menuv_items_link objectAtIndex: menuv_highlightedItemIndex];
|
||||
|
||||
[anItem highlight: NO
|
||||
withFrame: [self rectOfItemAtIndex: menuv_highlightedItemIndex]
|
||||
withFrame: aRect
|
||||
inView: self];
|
||||
|
||||
if ([anItem hasSubmenu] && ![[anItem target] isTornOff])
|
||||
[self setNeedsDisplayInRect: aRect];
|
||||
|
||||
[window flushWindow];
|
||||
|
||||
if ([anItem hasSubmenu]
|
||||
&& ![[anItem target] isTornOff])
|
||||
[[anItem target] close];
|
||||
else if ([anItem hasSubmenu] && [[anItem target] isTornOff])
|
||||
else if ([anItem hasSubmenu]
|
||||
&& [[anItem target] isTornOff])
|
||||
[[anItem target] closeTransient];
|
||||
|
||||
[anItem setState: 0];
|
||||
menuv_highlightedItemIndex = -1;
|
||||
}
|
||||
} else if (index >= 0) {
|
||||
if ( menuv_highlightedItemIndex != -1 ) {
|
||||
}
|
||||
else if (index >= 0)
|
||||
{
|
||||
if ( menuv_highlightedItemIndex != -1)
|
||||
{
|
||||
NSRect aRect = [self rectOfItemAtIndex: menuv_highlightedItemIndex];
|
||||
|
||||
anItem = [menuv_items_link objectAtIndex: menuv_highlightedItemIndex];
|
||||
|
||||
[anItem highlight: NO
|
||||
withFrame: [self rectOfItemAtIndex: menuv_highlightedItemIndex]
|
||||
withFrame: aRect
|
||||
inView: self];
|
||||
|
||||
if ([anItem hasSubmenu] && ![[anItem target] isTornOff])
|
||||
[self setNeedsDisplayInRect: aRect];
|
||||
|
||||
[window flushWindow];
|
||||
|
||||
if ([anItem hasSubmenu]
|
||||
&& ![[anItem target] isTornOff])
|
||||
[[anItem target] close];
|
||||
else if ([anItem hasSubmenu] && [[anItem target] isTornOff])
|
||||
else if ([anItem hasSubmenu]
|
||||
&& [[anItem target] isTornOff])
|
||||
[[anItem target] closeTransient];
|
||||
|
||||
[anItem setState: 0];
|
||||
}
|
||||
|
||||
if (menuv_highlightedItemIndex != index) {
|
||||
|
||||
if (index != menuv_highlightedItemIndex)
|
||||
{
|
||||
anItem = [menuv_items_link objectAtIndex: index];
|
||||
|
||||
if ([anItem isEnabled])
|
||||
{
|
||||
NSRect aRect = [self rectOfItemAtIndex: index];
|
||||
|
||||
[anItem highlight: YES
|
||||
withFrame: [self rectOfItemAtIndex: index]
|
||||
withFrame: aRect
|
||||
inView: self];
|
||||
[self setNeedsDisplayInRect: aRect];
|
||||
|
||||
[window flushWindow];
|
||||
|
||||
if ([anItem hasSubmenu]
|
||||
&& ![[anItem target] isTornOff])
|
||||
[[anItem target] display];
|
||||
else if ([anItem hasSubmenu]
|
||||
&& [[anItem target] isTornOff])
|
||||
[[anItem target] displayTransient];
|
||||
|
||||
[anItem setState: 1];
|
||||
|
||||
if ([anItem hasSubmenu] && ![[anItem target] isTornOff])
|
||||
[[anItem target] display];
|
||||
else if ([anItem hasSubmenu] && [[anItem target] isTornOff])
|
||||
[[anItem target] displayTransient];
|
||||
}
|
||||
|
||||
// set ivar to new index
|
||||
menuv_highlightedItemIndex = index;
|
||||
} else {
|
||||
}
|
||||
else if (menuv_highlightedItemIndex == index)
|
||||
{
|
||||
menuv_highlightedItemIndex = -1;
|
||||
}
|
||||
}
|
||||
|
||||
[self unlockFocus];
|
||||
[window flushWindow];
|
||||
}
|
||||
|
||||
- (int)highlightedItemIndex
|
||||
|
@ -522,16 +551,18 @@ static float GSMenuBarHeight = 25.0; // a guess.
|
|||
{ // Recursive menu close & deselect.
|
||||
if ([aMenu supermenu] && aMenu != menuv_menu)
|
||||
{
|
||||
[[[aMenu supermenu] menuView] setHighlightedItemIndex: -1];
|
||||
[[aMenu menuView] setHighlightedItemIndex: -1];
|
||||
aMenu = [aMenu supermenu];
|
||||
}
|
||||
else
|
||||
finished = YES;
|
||||
|
||||
[window flushWindow];
|
||||
// [window flushWindow];
|
||||
}
|
||||
}
|
||||
|
||||
[self setHighlightedItemIndex: index];
|
||||
|
||||
lastIndex = index;
|
||||
}
|
||||
|
||||
|
@ -726,8 +757,6 @@ cell do the following */
|
|||
}
|
||||
else
|
||||
finished = YES;
|
||||
|
||||
[window flushWindow];
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -770,7 +799,7 @@ cell do the following */
|
|||
{ // Recursive menu close & deselect.
|
||||
if ([aMenu supermenu])
|
||||
{
|
||||
[[[aMenu supermenu] menuView] setHighlightedItemIndex: -1];
|
||||
[[aMenu menuView] setHighlightedItemIndex: -1];
|
||||
aMenu = [aMenu supermenu];
|
||||
}
|
||||
else
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include <AppKit/NSCStringText.h>
|
||||
#include <AppKit/NSEvent.h>
|
||||
|
||||
|
||||
/*
|
||||
* Dummy definitions provided here to avoid errors when not linking with
|
||||
* a back end.
|
||||
|
@ -302,4 +301,3 @@ float NSLinkFrameThickness(void)
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue