mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 20:11:55 +00:00
Tidied a little
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4356 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
986380a33f
commit
145d4fba64
2 changed files with 73 additions and 66 deletions
|
@ -420,6 +420,7 @@ NSApplication *NSApp = nil;
|
||||||
|
|
||||||
- (int) runModalSession: (NSModalSession)theSession
|
- (int) runModalSession: (NSModalSession)theSession
|
||||||
{
|
{
|
||||||
|
NSAutoreleasePool *pool;
|
||||||
NSGraphicsContext *ctxt;
|
NSGraphicsContext *ctxt;
|
||||||
BOOL found = NO;
|
BOOL found = NO;
|
||||||
NSEvent *event;
|
NSEvent *event;
|
||||||
|
@ -429,8 +430,7 @@ NSApplication *NSApp = nil;
|
||||||
[NSException raise: NSInvalidArgumentException
|
[NSException raise: NSInvalidArgumentException
|
||||||
format: @"runModalSession: with wrong session"];
|
format: @"runModalSession: with wrong session"];
|
||||||
|
|
||||||
theSession->runState = NSRunContinuesResponse;
|
pool = [NSAutoreleasePool new];
|
||||||
[theSession->window display];
|
|
||||||
[theSession->window makeKeyAndOrderFront: self];
|
[theSession->window makeKeyAndOrderFront: self];
|
||||||
|
|
||||||
ctxt = GSCurrentContext();
|
ctxt = GSCurrentContext();
|
||||||
|
@ -453,12 +453,13 @@ NSApplication *NSApp = nil;
|
||||||
}
|
}
|
||||||
while (found == NO && theSession->runState == NSRunContinuesResponse);
|
while (found == NO && theSession->runState == NSRunContinuesResponse);
|
||||||
|
|
||||||
|
RELEASE(pool);
|
||||||
/*
|
/*
|
||||||
* Deal with the events in the queue.
|
* Deal with the events in the queue.
|
||||||
*/
|
*/
|
||||||
while (found == YES && theSession->runState == NSRunContinuesResponse)
|
while (found == YES && theSession->runState == NSRunContinuesResponse)
|
||||||
{
|
{
|
||||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
pool = [NSAutoreleasePool new];
|
||||||
|
|
||||||
event = DPSGetEvent(ctxt, NSAnyEventMask, nil, NSDefaultRunLoopMode);
|
event = DPSGetEvent(ctxt, NSAnyEventMask, nil, NSDefaultRunLoopMode);
|
||||||
if (event != nil && [event window] == theSession->window)
|
if (event != nil && [event window] == theSession->window)
|
||||||
|
@ -766,8 +767,8 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
|
||||||
// Set the app's icon
|
// Set the app's icon
|
||||||
- (void) setApplicationIconImage: (NSImage*)anImage
|
- (void) setApplicationIconImage: (NSImage*)anImage
|
||||||
{
|
{
|
||||||
[app_icon setName:nil];
|
[app_icon setName: nil];
|
||||||
[anImage setName:@"NSApplicationIcon"];
|
[anImage setName: @"NSApplicationIcon"];
|
||||||
ASSIGN(app_icon, anImage);
|
ASSIGN(app_icon, anImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -998,24 +999,22 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
|
||||||
windows_need_update = flag;
|
windows_need_update = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) updateWindows // send an update message
|
- (void) updateWindows
|
||||||
{ // to all visible windows
|
{
|
||||||
int i, count;
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
NSArray *window_list = [self windows];
|
||||||
NSArray *window_list = [self windows];
|
unsigned count = [window_list count];
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
windows_need_update = NO;
|
windows_need_update = NO;
|
||||||
// notify that an update is
|
|
||||||
// imminent
|
|
||||||
[nc postNotificationName: NSApplicationWillUpdateNotification object: self];
|
[nc postNotificationName: NSApplicationWillUpdateNotification object: self];
|
||||||
|
|
||||||
for (i = 0, count = [window_list count]; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
NSWindow *win = [window_list objectAtIndex: i];
|
NSWindow *win = [window_list objectAtIndex: i];
|
||||||
if ([win isVisible]) // send update only if the
|
if ([win isVisible])
|
||||||
[win update]; // window is visible
|
[win update];
|
||||||
}
|
}
|
||||||
// notify update did occur
|
|
||||||
[nc postNotificationName: NSApplicationDidUpdateNotification object: self];
|
[nc postNotificationName: NSApplicationDidUpdateNotification object: self];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -219,7 +219,7 @@
|
||||||
scroller_rect.size.height = [NSScroller scrollerWidth];
|
scroller_rect.size.height = [NSScroller scrollerWidth];
|
||||||
_horizontalScroller = [[NSScroller alloc] initWithFrame: scroller_rect];
|
_horizontalScroller = [[NSScroller alloc] initWithFrame: scroller_rect];
|
||||||
[_horizontalScroller setTarget: self];
|
[_horizontalScroller setTarget: self];
|
||||||
[_horizontalScroller setAction: @selector(scrollViaScroller:)];
|
[_horizontalScroller setAction: @selector(scrollViaScroller: )];
|
||||||
[self addSubview: _horizontalScroller];
|
[self addSubview: _horizontalScroller];
|
||||||
_acceptsArrowKeys = YES;
|
_acceptsArrowKeys = YES;
|
||||||
_sendsActionOnArrowKeys = YES;
|
_sendsActionOnArrowKeys = YES;
|
||||||
|
@ -294,21 +294,21 @@
|
||||||
BOOL flag = NO;
|
BOOL flag = NO;
|
||||||
BOOL both = NO;
|
BOOL both = NO;
|
||||||
|
|
||||||
if (![anObject respondsToSelector:
|
if (![anObject respondsToSelector:
|
||||||
@selector(browser: willDisplayCell: atRow: column:)])
|
@selector(browser: willDisplayCell: atRow: column: )])
|
||||||
[NSException raise: NSBrowserIllegalDelegateException
|
[NSException raise: NSBrowserIllegalDelegateException
|
||||||
format: @"Delegate does not respond to %s\n",
|
format: @"Delegate does not respond to %s\n",
|
||||||
"browser: willDisplayCell: atRow: column: "];
|
"browser: willDisplayCell: atRow: column: "];
|
||||||
|
|
||||||
if ([anObject respondsToSelector:
|
if ([anObject respondsToSelector:
|
||||||
@selector(browser: numberOfRowsInColumn:)])
|
@selector(browser: numberOfRowsInColumn: )])
|
||||||
{
|
{
|
||||||
_passiveDelegate = YES;
|
_passiveDelegate = YES;
|
||||||
flag = YES;
|
flag = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([anObject respondsToSelector:
|
if ([anObject respondsToSelector:
|
||||||
@selector(browser:createRowsForColumn:inMatrix:)])
|
@selector(browser: createRowsForColumn: inMatrix: )])
|
||||||
{
|
{
|
||||||
_passiveDelegate = NO;
|
_passiveDelegate = NO;
|
||||||
|
|
||||||
|
@ -610,8 +610,8 @@
|
||||||
bc = [_browserColumns objectAtIndex: column];
|
bc = [_browserColumns objectAtIndex: column];
|
||||||
|
|
||||||
// Ask the delegate for the column title
|
// Ask the delegate for the column title
|
||||||
if ([_browserDelegate respondsToSelector:
|
if ([_browserDelegate respondsToSelector:
|
||||||
@selector(browser:titleOfColumn:)])
|
@selector(browser: titleOfColumn: )])
|
||||||
[self setTitle: [_browserDelegate browser: self
|
[self setTitle: [_browserDelegate browser: self
|
||||||
titleOfColumn: column]
|
titleOfColumn: column]
|
||||||
ofColumn: column];
|
ofColumn: column];
|
||||||
|
@ -785,8 +785,8 @@
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
// xxx Should we trigger an exception?
|
// xxx Should we trigger an exception?
|
||||||
if (![_browserDelegate respondsToSelector:
|
if (![_browserDelegate respondsToSelector:
|
||||||
@selector(browser:isColumnValid:)])
|
@selector(browser: isColumnValid: )])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Loop through the visible columns
|
// Loop through the visible columns
|
||||||
|
@ -893,7 +893,7 @@
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Notify the delegate
|
// Notify the delegate
|
||||||
if ([_browserDelegate respondsToSelector: @selector(browserWillScroll:)])
|
if ([_browserDelegate respondsToSelector: @selector(browserWillScroll: )])
|
||||||
[_browserDelegate browserWillScroll: self];
|
[_browserDelegate browserWillScroll: self];
|
||||||
|
|
||||||
// Shift
|
// Shift
|
||||||
|
@ -907,7 +907,7 @@
|
||||||
[self updateScroller];
|
[self updateScroller];
|
||||||
|
|
||||||
// Notify the delegate
|
// Notify the delegate
|
||||||
if ([_browserDelegate respondsToSelector: @selector(browserDidScroll:)])
|
if ([_browserDelegate respondsToSelector: @selector(browserDidScroll: )])
|
||||||
[_browserDelegate browserDidScroll: self];
|
[_browserDelegate browserDidScroll: self];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -922,7 +922,7 @@
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Notify the delegate
|
// Notify the delegate
|
||||||
if ([_browserDelegate respondsToSelector: @selector(browserWillScroll:)])
|
if ([_browserDelegate respondsToSelector: @selector(browserWillScroll: )])
|
||||||
[_browserDelegate browserWillScroll: self];
|
[_browserDelegate browserWillScroll: self];
|
||||||
|
|
||||||
// Shift
|
// Shift
|
||||||
|
@ -936,7 +936,7 @@
|
||||||
[self updateScroller];
|
[self updateScroller];
|
||||||
|
|
||||||
// Notify the delegate
|
// Notify the delegate
|
||||||
if ([_browserDelegate respondsToSelector: @selector(browserDidScroll:)])
|
if ([_browserDelegate respondsToSelector: @selector(browserDidScroll: )])
|
||||||
[_browserDelegate browserDidScroll: self];
|
[_browserDelegate browserDidScroll: self];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1038,8 +1038,8 @@
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Ask delegate if selection is ok
|
// Ask delegate if selection is ok
|
||||||
if ([_browserDelegate respondsToSelector:
|
if ([_browserDelegate respondsToSelector:
|
||||||
@selector(browser:selectRow:inColumn:)])
|
@selector(browser: selectRow: inColumn: )])
|
||||||
{
|
{
|
||||||
int row = [sender selectedRow];
|
int row = [sender selectedRow];
|
||||||
shouldSelect = [_browserDelegate browser: self selectRow: row
|
shouldSelect = [_browserDelegate browser: self selectRow: row
|
||||||
|
@ -1048,12 +1048,12 @@
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Try the other method
|
// Try the other method
|
||||||
if ([_browserDelegate respondsToSelector:
|
if ([_browserDelegate respondsToSelector:
|
||||||
@selector(browser:selectCellWithString:inColumn:)])
|
@selector(browser: selectCellWithString: inColumn: )])
|
||||||
{
|
{
|
||||||
id c = [sender selectedCell];
|
id c = [sender selectedCell];
|
||||||
shouldSelect = [_browserDelegate browser: self
|
shouldSelect = [_browserDelegate browser: self
|
||||||
selectCellWithString:
|
selectCellWithString:
|
||||||
[c stringValue]
|
[c stringValue]
|
||||||
inColumn: column];
|
inColumn: column];
|
||||||
}
|
}
|
||||||
|
@ -1246,38 +1246,47 @@
|
||||||
|
|
||||||
- (NSString *)pathToColumn: (int)column
|
- (NSString *)pathToColumn: (int)column
|
||||||
{
|
{
|
||||||
int i;
|
NSMutableString *s = [_pathSeparator mutableCopy];
|
||||||
NSMutableString *s = [NSMutableString stringWithCString: ""];
|
unsigned i;
|
||||||
|
|
||||||
// Cannot go past the number of loaded columns
|
/*
|
||||||
|
* Cannot go past the number of loaded columns
|
||||||
|
*/
|
||||||
if (column > _lastColumnLoaded)
|
if (column > _lastColumnLoaded)
|
||||||
column = _lastColumnLoaded + 1;
|
column = _lastColumnLoaded + 1;
|
||||||
|
|
||||||
[s appendString: _pathSeparator];
|
|
||||||
for (i = 0;i < column; ++i)
|
for (i = 0;i < column; ++i)
|
||||||
{
|
{
|
||||||
id c = [self selectedCellInColumn: i];
|
id c = [self selectedCellInColumn: i];
|
||||||
|
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
[s appendString: _pathSeparator];
|
[s appendString: _pathSeparator];
|
||||||
[s appendString: [c stringValue]];
|
[s appendString: [c stringValue]];
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
return [[[NSString alloc] initWithString: s] autorelease];
|
* We actually return a mutable string, but that's ok since a mutable
|
||||||
|
* string is a string and the documentation specifically says that
|
||||||
|
* people should not depend on methods that return strings to return
|
||||||
|
* immutable strings.
|
||||||
|
*/
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)setPath: (NSString *)path
|
- (BOOL) setPath: (NSString *)path
|
||||||
{
|
{
|
||||||
NSArray *subStrings = [path componentsSeparatedByString:_pathSeparator];
|
NSArray *subStrings;
|
||||||
unsigned numberOfSubStrings, i;
|
|
||||||
NSString *aStr;
|
NSString *aStr;
|
||||||
|
unsigned numberOfSubStrings;
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
|
subStrings = [path componentsSeparatedByString: _pathSeparator];
|
||||||
[self setLastColumn: 0];
|
[self setLastColumn: 0];
|
||||||
numberOfSubStrings = [subStrings count];
|
numberOfSubStrings = [subStrings count];
|
||||||
|
|
||||||
if (numberOfSubStrings <= 2)
|
if (numberOfSubStrings == 2)
|
||||||
{
|
{
|
||||||
// select root path
|
/* select root path *.
|
||||||
if ([[subStrings objectAtIndex:1] length] == 0)
|
if ([[subStrings objectAtIndex: 1] length] == 0)
|
||||||
{
|
{
|
||||||
[self scrollColumnsLeftBy: [_browserColumns count]];
|
[self scrollColumnsLeftBy: [_browserColumns count]];
|
||||||
return YES;
|
return YES;
|
||||||
|
@ -1305,17 +1314,17 @@
|
||||||
{
|
{
|
||||||
NSString *cellString;
|
NSString *cellString;
|
||||||
|
|
||||||
selectedCell = [cellRow objectAtIndex:k];
|
selectedCell = [cellRow objectAtIndex: k];
|
||||||
cellString = [selectedCell stringValue];
|
cellString = [selectedCell stringValue];
|
||||||
|
|
||||||
if ([cellString isEqualToString:aStr])
|
if ([cellString isEqualToString: aStr])
|
||||||
{
|
{
|
||||||
int r, c;
|
int r, c;
|
||||||
|
|
||||||
k = numOfCols;
|
k = numOfCols;
|
||||||
j = numOfRows;
|
j = numOfRows;
|
||||||
if ([matrix getRow:&r column:&c ofCell:selectedCell])
|
if ([matrix getRow: &r column: &c ofCell: selectedCell])
|
||||||
[matrix selectCellAtRow:r column:c];
|
[matrix selectCellAtRow: r column: c];
|
||||||
else
|
else
|
||||||
selectedCell = nil;
|
selectedCell = nil;
|
||||||
}
|
}
|
||||||
|
@ -1539,18 +1548,17 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If it is not visible
|
NSBrowserColumn *bc = [_browserColumns objectAtIndex: i];
|
||||||
NSBrowserColumn *bc = [_browserColumns objectAtIndex: i];
|
id sc = [bc columnScrollView];
|
||||||
id sc = [bc columnScrollView];
|
|
||||||
|
|
||||||
// Remove it from its superview if it has one
|
// Remove it from its superview if it has one
|
||||||
if (sc)
|
if (sc)
|
||||||
if ([sc superview])
|
{
|
||||||
{
|
if ([sc superview])
|
||||||
NSLog(@"before: %d\n", [sc retainCount]);
|
{
|
||||||
[sc removeFromSuperview];
|
[sc removeFromSuperview];
|
||||||
NSLog(@"after: %d\n", [sc retainCount]);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1587,8 +1595,8 @@
|
||||||
if (!_allowsMultipleSelection)
|
if (!_allowsMultipleSelection)
|
||||||
[matrix setMode: NSRadioModeMatrix];
|
[matrix setMode: NSRadioModeMatrix];
|
||||||
[matrix setTarget: self];
|
[matrix setTarget: self];
|
||||||
[matrix setAction: @selector(doClick:)];
|
[matrix setAction: @selector(doClick: )];
|
||||||
[matrix setDoubleAction: @selector(doDoubleClick:)];
|
[matrix setDoubleAction: @selector(doDoubleClick: )];
|
||||||
|
|
||||||
// set new col matrix and release old
|
// set new col matrix and release old
|
||||||
[bc setColumnMatrix: matrix];
|
[bc setColumnMatrix: matrix];
|
||||||
|
@ -1622,8 +1630,8 @@
|
||||||
if (!_allowsMultipleSelection)
|
if (!_allowsMultipleSelection)
|
||||||
[matrix setMode: NSRadioModeMatrix];
|
[matrix setMode: NSRadioModeMatrix];
|
||||||
[matrix setTarget: self];
|
[matrix setTarget: self];
|
||||||
[matrix setAction: @selector(doClick:)];
|
[matrix setAction: @selector(doClick: )];
|
||||||
[matrix setDoubleAction: @selector(doDoubleClick:)];
|
[matrix setDoubleAction: @selector(doDoubleClick: )];
|
||||||
|
|
||||||
// set new col matrix and release old
|
// set new col matrix and release old
|
||||||
[bc setColumnMatrix: matrix];
|
[bc setColumnMatrix: matrix];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue