mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 15:11:37 +00:00
Minor updates
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@6223 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b23022dbb0
commit
42e851197f
2 changed files with 160 additions and 144 deletions
|
@ -59,7 +59,7 @@ static BOOL _gs_display_reading_progress = NO;
|
|||
// Subclasses (read NSOpenPanel) may implement this
|
||||
// to filter some extensions out of displayed files.
|
||||
@interface NSObject (_SavePanelPrivate)
|
||||
-(BOOL) _shouldShowExtension: (NSString *)extension;
|
||||
-(BOOL) _shouldShowExtension: (NSString*)extension;
|
||||
@end
|
||||
//
|
||||
|
||||
|
@ -353,7 +353,7 @@ static BOOL _gs_display_reading_progress = NO;
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void) setAccessoryView: (NSView *)aView
|
||||
- (void) setAccessoryView: (NSView*)aView
|
||||
{
|
||||
NSView *contentView;
|
||||
NSRect addedFrame, bottomFrame, topFrame;
|
||||
|
@ -446,7 +446,7 @@ static BOOL _gs_display_reading_progress = NO;
|
|||
}
|
||||
}
|
||||
|
||||
- (void) setTitle: (NSString *)title
|
||||
- (void) setTitle: (NSString*)title
|
||||
{
|
||||
[_titleField setStringValue: title];
|
||||
|
||||
|
@ -455,28 +455,28 @@ static BOOL _gs_display_reading_progress = NO;
|
|||
[_titleField sizeToFit];
|
||||
}
|
||||
|
||||
- (NSString *) title
|
||||
- (NSString*) title
|
||||
{
|
||||
return [_titleField stringValue];
|
||||
}
|
||||
|
||||
- (void) setPrompt: (NSString *)prompt
|
||||
- (void) setPrompt: (NSString*)prompt
|
||||
{
|
||||
[[_form cellAtIndex: 0] setTitle: prompt];
|
||||
[_form setNeedsDisplay: YES];
|
||||
}
|
||||
|
||||
- (NSString *) prompt
|
||||
- (NSString*) prompt
|
||||
{
|
||||
return [[_form cellAtIndex: 0] title];
|
||||
}
|
||||
|
||||
- (NSView *) accessoryView
|
||||
- (NSView*) accessoryView
|
||||
{
|
||||
return _accessoryView;
|
||||
}
|
||||
|
||||
- (void) setDirectory: (NSString *)path
|
||||
- (void) setDirectory: (NSString*)path
|
||||
{
|
||||
NSString *standardizedPath = [path stringByStandardizingPath];
|
||||
BOOL isDir;
|
||||
|
@ -491,12 +491,12 @@ static BOOL _gs_display_reading_progress = NO;
|
|||
}
|
||||
}
|
||||
|
||||
- (void) setRequiredFileType: (NSString *)fileType
|
||||
- (void) setRequiredFileType: (NSString*)fileType
|
||||
{
|
||||
ASSIGN(_requiredFileType, fileType);
|
||||
}
|
||||
|
||||
- (NSString *) requiredFileType
|
||||
- (NSString*) requiredFileType
|
||||
{
|
||||
return _requiredFileType;
|
||||
}
|
||||
|
@ -506,7 +506,7 @@ static BOOL _gs_display_reading_progress = NO;
|
|||
return _treatsFilePackagesAsDirectories;
|
||||
}
|
||||
|
||||
- (void) setTreatsFilePackagesAsDirectories:(BOOL) flag
|
||||
- (void) setTreatsFilePackagesAsDirectories: (BOOL)flag
|
||||
{
|
||||
_treatsFilePackagesAsDirectories = flag;
|
||||
}
|
||||
|
@ -520,13 +520,13 @@ static BOOL _gs_display_reading_progress = NO;
|
|||
{
|
||||
if (_directory)
|
||||
return [self runModalForDirectory: _directory
|
||||
file: @""];
|
||||
file: @""];
|
||||
else
|
||||
return [self runModalForDirectory: [_fm currentDirectoryPath]
|
||||
file: @""];
|
||||
file: @""];
|
||||
}
|
||||
|
||||
- (int) runModalForDirectory:(NSString *) path file:(NSString *) filename
|
||||
- (int) runModalForDirectory: (NSString*)path file: (NSString*)filename
|
||||
{
|
||||
if (path == nil || filename == nil)
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
|
@ -539,9 +539,11 @@ static BOOL _gs_display_reading_progress = NO;
|
|||
[[_form cellAtIndex: 0] setStringValue: filename];
|
||||
[_form setNeedsDisplay: YES];
|
||||
|
||||
// We need to take care of the possibility of
|
||||
// the panel being aborted. We return NSCancelButton
|
||||
// in that case.
|
||||
/*
|
||||
* We need to take care of the possibility of
|
||||
* the panel being aborted. We return NSCancelButton
|
||||
* in that case.
|
||||
*/
|
||||
_OKButtonPressed = NO;
|
||||
|
||||
[NSApp runModalForWindow: self];
|
||||
|
@ -552,7 +554,7 @@ static BOOL _gs_display_reading_progress = NO;
|
|||
return NSCancelButton;
|
||||
}
|
||||
|
||||
- (NSString *) directory
|
||||
- (NSString*) directory
|
||||
{
|
||||
if (_directory)
|
||||
return _directory;
|
||||
|
@ -560,7 +562,7 @@ static BOOL _gs_display_reading_progress = NO;
|
|||
return @"";
|
||||
}
|
||||
|
||||
- (NSString *) filename
|
||||
- (NSString*) filename
|
||||
{
|
||||
if (_fullFileName == nil)
|
||||
return @"";
|
||||
|
@ -626,14 +628,14 @@ static BOOL _gs_display_reading_progress = NO;
|
|||
//
|
||||
// NSCoding protocol
|
||||
//
|
||||
- (id) initWithCoder: (NSCoder *)aCoder
|
||||
- (id) initWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
// TODO
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder *)aCoder
|
||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
@ -645,25 +647,25 @@ static BOOL _gs_display_reading_progress = NO;
|
|||
@interface NSSavePanel (_BrowserDelegate)
|
||||
- (void) browser: (id)sender
|
||||
createRowsForColumn: (int)column
|
||||
inMatrix: (NSMatrix *)matrix;
|
||||
inMatrix: (NSMatrix*)matrix;
|
||||
|
||||
- (BOOL) browser: (NSBrowser *)sender
|
||||
- (BOOL) browser: (NSBrowser*)sender
|
||||
isColumnValid: (int)column;
|
||||
|
||||
- (BOOL) browser: (NSBrowser *)sender
|
||||
selectCellWithString: (NSString *)title
|
||||
- (BOOL) browser: (NSBrowser*)sender
|
||||
selectCellWithString: (NSString*)title
|
||||
inColumn: (int)column;
|
||||
|
||||
- (void) browser:(NSBrowser *)sender
|
||||
willDisplayCell:(id)cell
|
||||
atRow:(int)row
|
||||
column:(int)column;
|
||||
- (void) browser: (NSBrowser*)sender
|
||||
willDisplayCell: (id)cell
|
||||
atRow: (int)row
|
||||
column: (int)column;
|
||||
@end
|
||||
|
||||
@implementation NSSavePanel (_BrowserDelegate)
|
||||
- (void) browser: (id)sender
|
||||
createRowsForColumn: (int)column
|
||||
inMatrix: (NSMatrix *)matrix
|
||||
inMatrix: (NSMatrix*)matrix
|
||||
{
|
||||
NSString *path, *file, *pathAndFile, *extension, *h;
|
||||
NSArray *files, *hiddenFiles;
|
||||
|
@ -794,7 +796,7 @@ createRowsForColumn: (int)column
|
|||
}
|
||||
}
|
||||
|
||||
- (BOOL) browser: (NSBrowser *)sender
|
||||
- (BOOL) browser: (NSBrowser*)sender
|
||||
isColumnValid: (int)column
|
||||
{
|
||||
NSArray *cells = [[sender matrixInColumn: column] cells];
|
||||
|
@ -814,8 +816,8 @@ createRowsForColumn: (int)column
|
|||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL) browser: (NSBrowser *)sender
|
||||
selectCellWithString: (NSString *)title
|
||||
- (BOOL) browser: (NSBrowser*)sender
|
||||
selectCellWithString: (NSString*)title
|
||||
inColumn: (int)column
|
||||
{
|
||||
NSMatrix *m;
|
||||
|
@ -844,10 +846,10 @@ selectCellWithString: (NSString *)title
|
|||
return YES;
|
||||
}
|
||||
|
||||
- (void)browser:(NSBrowser *)sender
|
||||
willDisplayCell:(id)cell
|
||||
atRow:(int)row
|
||||
column:(int)column
|
||||
- (void) browser: (NSBrowser*)sender
|
||||
willDisplayCell: (id)cell
|
||||
atRow: (int)row
|
||||
column: (int)column
|
||||
{
|
||||
}
|
||||
@end
|
||||
|
@ -856,10 +858,10 @@ selectCellWithString: (NSString *)title
|
|||
// NSForm delegate methods
|
||||
//
|
||||
@interface NSSavePanel (FormDelegate)
|
||||
- (void) controlTextDidEndEditing: (NSNotification *)aNotification;
|
||||
- (void) controlTextDidEndEditing: (NSNotification*)aNotification;
|
||||
@end
|
||||
@implementation NSSavePanel (FormDelegate)
|
||||
- (void) controlTextDidEndEditing: (NSNotification *)aNotification
|
||||
- (void) controlTextDidEndEditing: (NSNotification*)aNotification
|
||||
{
|
||||
NSString *s;
|
||||
|
||||
|
|
|
@ -72,6 +72,7 @@ BOOL GSViewAcceptsDrag(NSView *v, id<NSDraggingInfo> dragInfo);
|
|||
*/
|
||||
@interface NSWindow (GNUstepPrivate)
|
||||
- (void) _handleWindowNeedsDisplay: (id)bogus;
|
||||
- (void) _lossOfKeyOrMainWindow;
|
||||
@end
|
||||
|
||||
@implementation NSWindow (GNUstepPrivate)
|
||||
|
@ -79,6 +80,88 @@ BOOL GSViewAcceptsDrag(NSView *v, id<NSDraggingInfo> dragInfo);
|
|||
{
|
||||
[self displayIfNeeded];
|
||||
}
|
||||
- (void) _lossOfKeyOrMainWindow
|
||||
{
|
||||
NSArray *windowList = GSAllWindows();
|
||||
unsigned pos = [windowList indexOfObjectIdenticalTo: self];
|
||||
unsigned c = [windowList count];
|
||||
unsigned i;
|
||||
NSWindow *w;
|
||||
|
||||
if ([self isKeyWindow])
|
||||
{
|
||||
[self resignKeyWindow];
|
||||
i = pos + 1;
|
||||
if (i == c)
|
||||
{
|
||||
i = 0;
|
||||
}
|
||||
while (i != pos)
|
||||
{
|
||||
w = [windowList objectAtIndex: i];
|
||||
if ([w isVisible] && [w canBecomeKeyWindow])
|
||||
{
|
||||
[w makeKeyWindow];
|
||||
break;
|
||||
}
|
||||
|
||||
i++;
|
||||
if (i == c)
|
||||
{
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* if we didn't find a possible key window - use the app icon or,
|
||||
* failing that, use the menu window.
|
||||
*/
|
||||
if (i == pos)
|
||||
{
|
||||
w = [NSApp iconWindow];
|
||||
if (w == nil || [w isVisible] == NO)
|
||||
{
|
||||
w = [[NSApp mainMenu] window];
|
||||
}
|
||||
if (w != nil && [w isVisible] == YES)
|
||||
{
|
||||
[GSCurrentContext() DPSsetinputfocus: [w windowNumber]];
|
||||
}
|
||||
}
|
||||
}
|
||||
if ([self isMainWindow])
|
||||
{
|
||||
NSWindow *w = [NSApp keyWindow];
|
||||
|
||||
[self resignMainWindow];
|
||||
if (w != nil && [w canBecomeMainWindow])
|
||||
{
|
||||
[w makeMainWindow];
|
||||
}
|
||||
else
|
||||
{
|
||||
i = pos + 1;
|
||||
if (i == c)
|
||||
{
|
||||
i = 0;
|
||||
}
|
||||
while (i != pos)
|
||||
{
|
||||
w = [windowList objectAtIndex: i];
|
||||
if ([w isVisible] && [w canBecomeMainWindow])
|
||||
{
|
||||
[w makeMainWindow];
|
||||
break;
|
||||
}
|
||||
|
||||
i++;
|
||||
if (i == c)
|
||||
{
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
|
@ -821,8 +904,8 @@ static NSMapTable* windowmaps = NULL;
|
|||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
|
||||
[first_responder becomeFirstResponder];
|
||||
if ((first_responder != self) &&
|
||||
[first_responder respondsToSelector: @selector(becomeKeyWindow)])
|
||||
if ((first_responder != self)
|
||||
&& [first_responder respondsToSelector: @selector(becomeKeyWindow)])
|
||||
[first_responder becomeKeyWindow];
|
||||
|
||||
_f.is_key = YES;
|
||||
|
@ -850,6 +933,10 @@ static NSMapTable* windowmaps = NULL;
|
|||
|
||||
- (BOOL) canBecomeKeyWindow
|
||||
{
|
||||
if (!_f.visible)
|
||||
return NO;
|
||||
if (_f.is_miniaturized)
|
||||
return NO;
|
||||
if ((NSResizableWindowMask | NSTitledWindowMask) & style_mask)
|
||||
return YES;
|
||||
else
|
||||
|
@ -860,7 +947,8 @@ static NSMapTable* windowmaps = NULL;
|
|||
{
|
||||
if (!_f.visible)
|
||||
return NO;
|
||||
|
||||
if (_f.is_miniaturized)
|
||||
return NO;
|
||||
if ((NSResizableWindowMask | NSTitledWindowMask) & style_mask)
|
||||
return YES;
|
||||
else
|
||||
|
@ -952,12 +1040,6 @@ static NSMapTable* windowmaps = NULL;
|
|||
{
|
||||
if (place == NSWindowOut)
|
||||
{
|
||||
NSArray *windowList = GSAllWindows();
|
||||
unsigned pos = [windowList indexOfObjectIdenticalTo: self];
|
||||
unsigned c = [windowList count];
|
||||
unsigned i;
|
||||
NSWindow *w;
|
||||
|
||||
_f.visible = NO;
|
||||
if (_rFlags.needs_display == YES)
|
||||
{
|
||||
|
@ -969,79 +1051,7 @@ static NSMapTable* windowmaps = NULL;
|
|||
target: self
|
||||
argument: nil];
|
||||
}
|
||||
if ([self isKeyWindow])
|
||||
{
|
||||
[self resignKeyWindow];
|
||||
i = pos + 1;
|
||||
if (i == c)
|
||||
{
|
||||
i = 0;
|
||||
}
|
||||
while (i != pos)
|
||||
{
|
||||
w = [windowList objectAtIndex: i];
|
||||
if ([w isVisible] && [w canBecomeKeyWindow])
|
||||
{
|
||||
[w makeKeyWindow];
|
||||
break;
|
||||
}
|
||||
|
||||
i++;
|
||||
if (i == c)
|
||||
{
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* if we didn't find a possible key window - use the app icon or,
|
||||
* failing that, use the menu window.
|
||||
*/
|
||||
if (i == pos)
|
||||
{
|
||||
w = [NSApp iconWindow];
|
||||
if (w == nil || [w isVisible] == NO)
|
||||
{
|
||||
w = [[NSApp mainMenu] window];
|
||||
}
|
||||
if (w != nil && [w isVisible] == YES)
|
||||
{
|
||||
[GSCurrentContext() DPSsetinputfocus: [w windowNumber]];
|
||||
}
|
||||
}
|
||||
}
|
||||
if ([self isMainWindow])
|
||||
{
|
||||
NSWindow *w = [NSApp keyWindow];
|
||||
|
||||
[self resignMainWindow];
|
||||
if (w != nil && [w canBecomeMainWindow])
|
||||
{
|
||||
[w makeMainWindow];
|
||||
}
|
||||
else
|
||||
{
|
||||
i = pos + 1;
|
||||
if (i == c)
|
||||
{
|
||||
i = 0;
|
||||
}
|
||||
while (i != pos)
|
||||
{
|
||||
w = [windowList objectAtIndex: i];
|
||||
if ([w isVisible] && [w canBecomeMainWindow])
|
||||
{
|
||||
[w makeMainWindow];
|
||||
break;
|
||||
}
|
||||
|
||||
i++;
|
||||
if (i == c)
|
||||
{
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
[self _lossOfKeyOrMainWindow];
|
||||
}
|
||||
DPSorderwindow(GSCurrentContext(), place, otherWin, window_num);
|
||||
if (place != NSWindowOut)
|
||||
|
@ -1094,9 +1104,9 @@ static NSMapTable* windowmaps = NULL;
|
|||
{
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
|
||||
// FIXME: This is in the documentation, but does not work
|
||||
//if ((first_responder != nil) && (first_responder != self))
|
||||
//[first_responder resignKeyWindow];
|
||||
if ((first_responder != self)
|
||||
&& [first_responder respondsToSelector: @selector(resignKeyWindow)])
|
||||
[first_responder resignKeyWindow];
|
||||
|
||||
_f.is_key = NO;
|
||||
|
||||
|
@ -1143,11 +1153,13 @@ static NSMapTable* windowmaps = NULL;
|
|||
|
||||
- (void) setLevel: (int)newLevel
|
||||
{
|
||||
NSGraphicsContext *context = GSCurrentContext();
|
||||
if (window_level != newLevel)
|
||||
{
|
||||
NSGraphicsContext *context = GSCurrentContext();
|
||||
|
||||
window_level = newLevel;
|
||||
DPSsetwindowlevel(context, window_level, window_num);
|
||||
[self orderFront: self];
|
||||
window_level = newLevel;
|
||||
DPSsetwindowlevel(context, window_level, window_num);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1703,8 +1715,14 @@ resetCursorRectsForView(NSView *theView)
|
|||
{
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
|
||||
if (_counterpart != 0)
|
||||
{
|
||||
NSWindow *mini = GSWindowWithNumber(_counterpart);
|
||||
|
||||
[mini orderOut: self];
|
||||
}
|
||||
_f.is_miniaturized = NO;
|
||||
// FIXME: Here seems to be something missing
|
||||
[self makeKeyAndOrderFront: self];
|
||||
|
||||
[nc postNotificationName: NSWindowDidDeminiaturizeNotification object: self];
|
||||
}
|
||||
|
@ -1719,13 +1737,14 @@ resetCursorRectsForView(NSView *theView)
|
|||
return _f.is_released_when_closed;
|
||||
}
|
||||
|
||||
- (void) miniaturize: sender
|
||||
- (void) miniaturize: (id)sender
|
||||
{
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
|
||||
[nc postNotificationName: NSWindowWillMiniaturizeNotification
|
||||
object: self];
|
||||
object: self];
|
||||
|
||||
_f.is_miniaturized = YES;
|
||||
/*
|
||||
* Ensure that we have a miniwindow counterpart.
|
||||
*/
|
||||
|
@ -1734,11 +1753,10 @@ resetCursorRectsForView(NSView *theView)
|
|||
NSWindow *mini;
|
||||
NSMiniWindowView *v;
|
||||
|
||||
mini = [[NSMiniWindow alloc]
|
||||
initWithContentRect: NSMakeRect(0,0,64,64)
|
||||
styleMask: NSMiniWindowMask
|
||||
backing: NSBackingStoreBuffered
|
||||
defer: NO];
|
||||
mini = [[NSMiniWindow alloc] initWithContentRect: NSMakeRect(0,0,64,64)
|
||||
styleMask: NSMiniWindowMask
|
||||
backing: NSBackingStoreBuffered
|
||||
defer: NO];
|
||||
mini->_counterpart = [self windowNumber];
|
||||
_counterpart = [mini windowNumber];
|
||||
v = [[NSMiniWindowView alloc] initWithFrame: NSMakeRect(0,0,64,64)];
|
||||
|
@ -1747,14 +1765,14 @@ resetCursorRectsForView(NSView *theView)
|
|||
[mini setContentView: v];
|
||||
RELEASE(v);
|
||||
}
|
||||
[self _lossOfKeyOrMainWindow];
|
||||
DPSminiwindow(GSCurrentContext(), window_num);
|
||||
_f.is_miniaturized = YES;
|
||||
|
||||
[nc postNotificationName: NSWindowDidMiniaturizeNotification
|
||||
object: self];
|
||||
object: self];
|
||||
}
|
||||
|
||||
- (void) performClose: sender
|
||||
- (void) performClose: (id)sender
|
||||
{
|
||||
/* self must have a close button in order to be closed */
|
||||
if (!(style_mask & NSClosableWindowMask))
|
||||
|
@ -3139,13 +3157,9 @@ resetCursorRectsForView(NSView *theView)
|
|||
aSize = [aDecoder decodeSize];
|
||||
[self setMaxSize: aSize];
|
||||
|
||||
/*
|
||||
* Set window to the correct level without displaying it.
|
||||
*/
|
||||
[aDecoder decodeValueOfObjCType: @encode(int)
|
||||
at: &anInt];
|
||||
window_level = anInt;
|
||||
DPSsetwindowlevel(GSCurrentContext(), window_level, window_num);
|
||||
[self setLevel: anInt];
|
||||
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||
[self setExcludedFromWindowsMenu: flag];
|
||||
|
|
Loading…
Reference in a new issue