mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 05:10:38 +00:00
2000-09-10 Mirko Viviani <mirko.viviani@rccr.cremona.it>
* Tools/gpbs.m ([PasteboardEntry -lostOwnership]): workaround to avoid core dump due to NSConnection bug. * Source/NSWindow.m ([NSWindow -keyDown:]): discard and do not perform key equivalent for null character events. Triggered return key for default button cell. ([NSWindow -defaultButtonCell]), ([NSWindow -setDefaultButtonCell:]), ([NSWindow -disableKeyEquivalentForDefaultButtonCell]), ([NSWindow -enableKeyEquivalentForDefaultButtonCell]): implemented. ([NSWindow -dealloc]): release _defaultButtonCell * Headers/AppKit/NSWindow.h: added ivar and flag. * Source/NSOpenPanel.m ([NSOpenPanel -controlTextDidEndEditing:]), ([NSOpenPanel -controlTextDidChange:]), ([NSOpenPanel -ok:]): implemented keyboard navigation. ([NSOpenPanel -runModalForDirectory:file:types:]): do not allow branch selection if can't choose directories. ([NSOpenPanel -_selectTextInColumn:]), ([NSOpenPanel -_selectCellName:]): new private methods. ([NSOpenPanel -filenames]): change for choose dirs. * Source/NSText.m ([NSText -keyDown:]): forwards text field illegal events to the next responder. * Source/NSBrowser.m ([NSBrowser -moveUp:]), ([NSBrowser -moveDown:]), ([NSBrowser -moveLeft:]), ([NSBrowser -moveRight:]), ([NSBrowser -keyDown:]): implemented keyboard navigation ([NSBrowser -selectedCell]), ([NSBrowser -selectedCells]), ([NSBrowser -columnOfMatrix:]), ([NSBrowser -selectedColumn]): changed return value from NSNotFound to -1 to conforms to NSMatrix ([NSBrowser -doClick:]): fix for new return values, added support for multiple and branch selection. ([NSBrowser -setLastColumn:]): mark column titles need display ([NSBrowser -_getTitleOfColumn:]): fix for multiple selection. * Source/NSCell.m ([NSCell -setState:]): bug fix: set value to NSOnState if someone try to set NSMixedState in a two state cell. ([NSCell -performClick:]): do not perform click if the cell is disabled. * Source/NSMatrix.m ([NSMatrix -_privateFrame:mode:numberOfRows:numberOfColumns:]), ([NSMatrix -deselectAllCells]), ([NSMatrix -deselectSelectedCell]), ([NSMatrix -selectAll:]): bug fix: set _selectRow and _selectColumn to -1 when no cells are selected ([NSMatrix -performKeyEquivalent:]): saves _selectedRow and _selectedColumn. ([NSMatrix -getRow:column:ofCell:]): check for null values for row and column. ([NSMatrix -selectCellAtRow:column:]): deselect the current selection only in NSRadioModeMatrix mode. ([NSMatrix -mouseDown:]): use the new code also for NSRadioModeMatrix and fix for this mode. * Source/NSSavePanel.m ([NSSavePanel -selectCellWithString:]): select text of the cell and enable okButton. ([NSSavePanel -controlTextDidChange:]): implemented. ([NSSavePanel -controlTextDidEndEditing:]): removed. ([NSSavePanel -browser:createRowsForColumn:inMatrix:]): follows symbolic links. ([NSSavePanel -_initWithoutGModel]): set browser doubleAction to performClick: of the _okButton. Set _okButton as default window button. Disable _okButton. ([NSSavePanel -browser:selectCellWithString:inColumn:]), ([NSSavePanel -selectText:]), ([NSSavePanel -keyDown:]): implemented keyboard navigation. ([NSSavePanel -runModalForDirectory:file:]): enable _okButton if filename is valid. ([NSSavePanel -_selectTextInColumn:]), ([NSSavePanel -_selectText:]), ([NSSavePanel -_selectCellName:]): new private methods. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@7468 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
c91af70d96
commit
df00948e11
10 changed files with 1186 additions and 102 deletions
|
@ -11,6 +11,8 @@
|
|||
Date: August 1998
|
||||
Author: Franck Wolff <wolff@cybercable.fr>
|
||||
Date: November 1999
|
||||
Author: Mirko Viviani <mirko.viviani@rccr.cremona.it>
|
||||
Date: September 2000
|
||||
|
||||
This file is part of the GNUstep GUI Library.
|
||||
|
||||
|
@ -46,6 +48,7 @@
|
|||
#include <AppKit/NSMatrix.h>
|
||||
#include <AppKit/NSTextFieldCell.h>
|
||||
#include <AppKit/PSOperators.h>
|
||||
#include <AppKit/NSEvent.h>
|
||||
|
||||
/* Cache */
|
||||
static float scrollerWidth; // == [NSScroller scrollerWidth]
|
||||
|
@ -314,11 +317,11 @@ static float scrollerWidth; // == [NSScroller scrollerWidth]
|
|||
#if defined NSBTRACE_selectedCell || defined NSBTRACE_all
|
||||
fprintf(stderr, "NSBrowser - (id)selectedCell\n");
|
||||
fprintf(stderr, "----------- i: %d (%d)\n",
|
||||
[self selectedColumn], NSNotFound);
|
||||
[self selectedColumn], -1);
|
||||
#endif
|
||||
|
||||
// Nothing selected
|
||||
if ((i = [self selectedColumn]) == NSNotFound)
|
||||
if ((i = [self selectedColumn]) == -1)
|
||||
return nil;
|
||||
|
||||
if (!(matrix = [self matrixInColumn: i]))
|
||||
|
@ -359,7 +362,7 @@ static float scrollerWidth; // == [NSScroller scrollerWidth]
|
|||
#endif
|
||||
|
||||
// Nothing selected
|
||||
if ((i = [self selectedColumn]) == NSNotFound)
|
||||
if ((i = [self selectedColumn]) == -1)
|
||||
return nil;
|
||||
|
||||
if (!(matrix = [self matrixInColumn: i]))
|
||||
|
@ -400,7 +403,7 @@ static float scrollerWidth; // == [NSScroller scrollerWidth]
|
|||
#endif
|
||||
|
||||
if (!(matrix = [self matrixInColumn: column]))
|
||||
return NSNotFound;
|
||||
return -1;
|
||||
|
||||
return [matrix selectedRow];
|
||||
}
|
||||
|
@ -805,7 +808,7 @@ static float scrollerWidth; // == [NSScroller scrollerWidth]
|
|||
}
|
||||
|
||||
// Not found
|
||||
return NSNotFound;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// -------------------
|
||||
|
@ -832,7 +835,7 @@ static float scrollerWidth; // == [NSScroller scrollerWidth]
|
|||
return i;
|
||||
}
|
||||
|
||||
return NSNotFound;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// -------------------
|
||||
|
@ -856,6 +859,7 @@ static float scrollerWidth; // == [NSScroller scrollerWidth]
|
|||
|
||||
_lastColumnLoaded = column;
|
||||
[self _unloadFromColumn: column + 1];
|
||||
[self _setColumnTitlesNeedDisplay];
|
||||
}
|
||||
|
||||
// -------------------
|
||||
|
@ -1925,9 +1929,12 @@ static float scrollerWidth; // == [NSScroller scrollerWidth]
|
|||
|
||||
- (void)doClick: (id)sender
|
||||
{
|
||||
int column;
|
||||
NSArray *a;
|
||||
BOOL shouldSelect = YES;
|
||||
NSArray *a;
|
||||
NSMutableArray *selectedCells;
|
||||
NSEnumerator *enumerator;
|
||||
NSBrowserCell *cell;
|
||||
BOOL shouldSelect = YES;
|
||||
int row, column, aCount, selectedCellsCount;
|
||||
|
||||
#if defined NSBTRACE_doClick || defined NSBTRACE_all
|
||||
fprintf(stderr, "NSBrowser - (void)doClick\n");
|
||||
|
@ -1938,48 +1945,103 @@ static float scrollerWidth; // == [NSScroller scrollerWidth]
|
|||
|
||||
column = [self columnOfMatrix: sender];
|
||||
// If the matrix isn't ours then just return
|
||||
if (column == NSNotFound)
|
||||
if (column == -1)
|
||||
return;
|
||||
|
||||
// Ask delegate if selection is ok
|
||||
if ([_browserDelegate respondsToSelector:
|
||||
@selector(browser:selectRow:inColumn:)])
|
||||
a = [sender selectedCells];
|
||||
aCount = [a count];
|
||||
if(aCount == 0)
|
||||
return;
|
||||
|
||||
selectedCells = [a mutableCopy];
|
||||
|
||||
enumerator = [a objectEnumerator];
|
||||
while((cell = [enumerator nextObject]))
|
||||
{
|
||||
int row = [sender selectedRow];
|
||||
shouldSelect = [_browserDelegate browser: self
|
||||
selectRow: row
|
||||
inColumn: column];
|
||||
}
|
||||
// Try the other method
|
||||
else if ([_browserDelegate respondsToSelector:
|
||||
@selector(browser:selectCellWithString:inColumn:)])
|
||||
{
|
||||
id c = [sender selectedCell];
|
||||
shouldSelect = [_browserDelegate browser: self
|
||||
selectCellWithString: [c stringValue]
|
||||
inColumn: column];
|
||||
if(_allowsBranchSelection == NO && [cell isLeaf] == NO)
|
||||
{
|
||||
[selectedCells removeObject:cell];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// If we should not select the cell
|
||||
// then deselect it and return
|
||||
if (!shouldSelect)
|
||||
if([selectedCells count] == 0)
|
||||
[selectedCells addObject:[sender selectedCell]];
|
||||
|
||||
enumerator = [a objectEnumerator];
|
||||
while((cell = [enumerator nextObject]))
|
||||
{
|
||||
if([selectedCells containsObject:cell] == YES)
|
||||
{
|
||||
// Ask delegate if selection is ok
|
||||
if ([_browserDelegate respondsToSelector:
|
||||
@selector(browser:selectRow:inColumn:)])
|
||||
{
|
||||
[sender getRow:&row column:NULL ofCell:cell];
|
||||
|
||||
shouldSelect = [_browserDelegate browser: self
|
||||
selectRow: row
|
||||
inColumn: column];
|
||||
}
|
||||
// Try the other method
|
||||
else if ([_browserDelegate
|
||||
respondsToSelector:
|
||||
@selector(browser:selectCellWithString:inColumn:)])
|
||||
{
|
||||
shouldSelect = [_browserDelegate browser: self
|
||||
selectCellWithString:
|
||||
[cell stringValue]
|
||||
inColumn: column];
|
||||
}
|
||||
|
||||
if (shouldSelect == NO)
|
||||
[selectedCells removeObject:cell];
|
||||
}
|
||||
}
|
||||
|
||||
selectedCellsCount = [selectedCells count];
|
||||
|
||||
if(selectedCellsCount == 0)
|
||||
{
|
||||
// If we should not select the cell
|
||||
// then deselect it and return
|
||||
|
||||
[sender deselectSelectedCell];
|
||||
RELEASE(selectedCells);
|
||||
return;
|
||||
}
|
||||
else if(selectedCellsCount < aCount)
|
||||
{
|
||||
[sender deselectSelectedCell];
|
||||
|
||||
a = [sender selectedCells];
|
||||
enumerator = [selectedCells objectEnumerator];
|
||||
while((cell = [enumerator nextObject]))
|
||||
{
|
||||
[sender getRow:&row column:NULL ofCell:cell];
|
||||
[sender selectCellAtRow:row column:0];
|
||||
}
|
||||
|
||||
if ([a count] > 0)
|
||||
enumerator = [a objectEnumerator];
|
||||
while((cell = [enumerator nextObject]))
|
||||
{
|
||||
if([selectedCells containsObject:cell] == NO)
|
||||
{
|
||||
[sender getRow:&row column:NULL ofCell:cell];
|
||||
[sender highlightCell:NO atRow:row column:0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedCellsCount > 0)
|
||||
{
|
||||
// Single selection
|
||||
if ([a count] == 1)
|
||||
if (selectedCellsCount == 1)
|
||||
{
|
||||
id c = [a objectAtIndex: 0];
|
||||
cell = [selectedCells objectAtIndex: 0];
|
||||
|
||||
// If the cell is a leaf
|
||||
// then unload the columns after
|
||||
if ([c isLeaf])
|
||||
if ([cell isLeaf])
|
||||
[self setLastColumn: column];
|
||||
// The cell is not a leaf so we need to load a column
|
||||
else
|
||||
|
@ -1991,15 +2053,16 @@ static float scrollerWidth; // == [NSScroller scrollerWidth]
|
|||
|
||||
// Load column
|
||||
[self _performLoadOfColumn: column + 1];
|
||||
[self _adjustMatrixOfColumn: column + 1];
|
||||
[self setLastColumn: column + 1];
|
||||
[self _adjustMatrixOfColumn: column + 1];
|
||||
|
||||
// If this column is the last visible
|
||||
// then scroll right by one column
|
||||
if (column == _lastVisibleColumn)
|
||||
[self scrollColumnsRightBy: 1];
|
||||
|
||||
}
|
||||
|
||||
[sender scrollCellToVisibleAtRow:[sender selectedRow] column:column];
|
||||
}
|
||||
// Multiple selection
|
||||
else
|
||||
|
@ -2014,6 +2077,8 @@ static float scrollerWidth; // == [NSScroller scrollerWidth]
|
|||
// Marks titles band as needing display.
|
||||
[self _setColumnTitlesNeedDisplay];
|
||||
|
||||
RELEASE(selectedCells);
|
||||
|
||||
#if defined NSBTRACE_doClick || defined NSBTRACE_all
|
||||
fprintf(stderr, "---------- (void)doClick ---------\n");
|
||||
fprintf(stderr, " fvc: %d, lvc: %d, mvc: %d, lcl: %d\n",
|
||||
|
@ -2299,7 +2364,242 @@ static float scrollerWidth; // == [NSScroller scrollerWidth]
|
|||
{
|
||||
}
|
||||
|
||||
- (void)moveUp:(id)sender
|
||||
{
|
||||
if(_acceptsArrowKeys == YES)
|
||||
{
|
||||
NSArray *cells;
|
||||
NSMatrix *matrix;
|
||||
NSBrowserCell *selectedCell;
|
||||
BOOL firstPass = YES;
|
||||
int selectedRow, oldSelectedRow, selectedColumn, numberOfRows;
|
||||
|
||||
selectedColumn = [self selectedColumn];
|
||||
if(selectedColumn == -1)
|
||||
{
|
||||
matrix = [self matrixInColumn:0];
|
||||
cells = [matrix cells];
|
||||
numberOfRows = [cells count];
|
||||
oldSelectedRow = selectedRow = numberOfRows - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
matrix = [self matrixInColumn:selectedColumn];
|
||||
cells = [matrix cells];
|
||||
numberOfRows = [cells count];
|
||||
oldSelectedRow = selectedRow = [matrix selectedRow];
|
||||
}
|
||||
|
||||
while(1)
|
||||
{
|
||||
if(selectedColumn == -1)
|
||||
{
|
||||
if(numberOfRows)
|
||||
{
|
||||
[matrix selectCellAtRow:selectedRow column:0];
|
||||
[self doClick:matrix];
|
||||
selectedColumn = 0;
|
||||
}
|
||||
else
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!selectedRow)
|
||||
{
|
||||
numberOfRows = [cells count];
|
||||
if(numberOfRows <= 1)
|
||||
return;
|
||||
|
||||
selectedRow = numberOfRows;
|
||||
firstPass = NO;
|
||||
}
|
||||
|
||||
selectedRow--;
|
||||
|
||||
[matrix deselectAllCells];
|
||||
[matrix selectCellAtRow:selectedRow column:0];
|
||||
[self doClick:matrix];
|
||||
}
|
||||
|
||||
selectedCell = [matrix selectedCell];
|
||||
|
||||
if(selectedCell ||
|
||||
(firstPass == NO && selectedRow == oldSelectedRow))
|
||||
break;
|
||||
}
|
||||
|
||||
if(_sendsActionOnArrowKeys == YES)
|
||||
[super sendAction:_action to:_target];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)moveDown:(id)sender
|
||||
{
|
||||
if(_acceptsArrowKeys)
|
||||
{
|
||||
NSArray *cells;
|
||||
NSMatrix *matrix;
|
||||
NSBrowserCell *selectedCell;
|
||||
BOOL firstPass = YES;
|
||||
int selectedRow, oldSelectedRow, selectedColumn, numberOfRows;
|
||||
|
||||
selectedColumn = [self selectedColumn];
|
||||
if(selectedColumn == -1)
|
||||
{
|
||||
matrix = [self matrixInColumn:0];
|
||||
oldSelectedRow = selectedRow = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
matrix = [self matrixInColumn:selectedColumn];
|
||||
oldSelectedRow = selectedRow = [matrix selectedRow];
|
||||
}
|
||||
|
||||
cells = [matrix cells];
|
||||
numberOfRows = [cells count];
|
||||
|
||||
while(1)
|
||||
{
|
||||
if(selectedColumn == -1)
|
||||
{
|
||||
if(numberOfRows)
|
||||
{
|
||||
[matrix selectCellAtRow:0 column:0];
|
||||
[self doClick:matrix];
|
||||
selectedColumn = 0;
|
||||
}
|
||||
else
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
selectedRow++;
|
||||
|
||||
if(selectedRow >= numberOfRows)
|
||||
{
|
||||
if(numberOfRows <= 1)
|
||||
return;
|
||||
|
||||
selectedRow = 0;
|
||||
firstPass = NO;
|
||||
}
|
||||
|
||||
[matrix deselectAllCells];
|
||||
[matrix selectCellAtRow:selectedRow column:0];
|
||||
[self doClick:matrix];
|
||||
}
|
||||
|
||||
selectedCell = [matrix selectedCell];
|
||||
|
||||
if(selectedCell ||
|
||||
(firstPass == NO && selectedRow == oldSelectedRow))
|
||||
break;
|
||||
}
|
||||
|
||||
if(_sendsActionOnArrowKeys == YES)
|
||||
[super sendAction:_action to:_target];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)moveLeft:(id)sender
|
||||
{
|
||||
if(_acceptsArrowKeys)
|
||||
{
|
||||
NSMatrix *matrix;
|
||||
NSCell *selectedCell;
|
||||
int selectedRow, selectedColumn;
|
||||
|
||||
selectedColumn = [self selectedColumn];
|
||||
if(selectedColumn >= 0)
|
||||
{
|
||||
matrix = [self matrixInColumn:selectedColumn];
|
||||
selectedCell = [matrix selectedCell];
|
||||
selectedRow = [matrix selectedRow];
|
||||
|
||||
[matrix deselectAllCells];
|
||||
|
||||
if(selectedColumn+1 <= [self lastColumn])
|
||||
[self setLastColumn:selectedColumn];
|
||||
|
||||
if(_sendsActionOnArrowKeys == YES)
|
||||
[super sendAction:_action to:_target];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)moveRight:(id)sender
|
||||
{
|
||||
if(_acceptsArrowKeys)
|
||||
{
|
||||
NSMatrix *matrix;
|
||||
BOOL selectFirstRow = NO;
|
||||
int selectedColumn;
|
||||
|
||||
selectedColumn = [self selectedColumn];
|
||||
if(selectedColumn == -1)
|
||||
{
|
||||
matrix = [self matrixInColumn:0];
|
||||
|
||||
if([[matrix cells] count])
|
||||
{
|
||||
[matrix selectCellAtRow:0 column:0];
|
||||
[self doClick:matrix];
|
||||
selectedColumn = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
matrix = [self matrixInColumn:selectedColumn];
|
||||
selectFirstRow = YES;
|
||||
}
|
||||
|
||||
if(selectFirstRow == YES)
|
||||
{
|
||||
matrix = [self matrixInColumn:[self lastColumn]];
|
||||
if([[matrix cells] count])
|
||||
{
|
||||
[matrix selectCellAtRow:0 column:0];
|
||||
[self doClick:matrix];
|
||||
}
|
||||
}
|
||||
|
||||
if(_sendsActionOnArrowKeys == YES)
|
||||
[super sendAction:_action to:_target];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) keyDown: (NSEvent *)theEvent
|
||||
{
|
||||
NSString *characters = [theEvent characters];
|
||||
unichar character = 0;
|
||||
|
||||
if ([characters length] > 0)
|
||||
{
|
||||
character = [characters characterAtIndex: 0];
|
||||
}
|
||||
|
||||
if(_acceptsArrowKeys)
|
||||
{
|
||||
switch (character)
|
||||
{
|
||||
case NSUpArrowFunctionKey:
|
||||
[self moveUp:self];
|
||||
return;
|
||||
case NSDownArrowFunctionKey:
|
||||
[self moveDown:self];
|
||||
return;
|
||||
case NSLeftArrowFunctionKey:
|
||||
[self moveLeft:self];
|
||||
return;
|
||||
case NSRightArrowFunctionKey:
|
||||
[self moveRight:self];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
[super keyDown: theEvent];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// NSCoding protocol
|
||||
|
@ -2687,7 +2987,24 @@ static float scrollerWidth; // == [NSScroller scrollerWidth]
|
|||
// Get the selected cell
|
||||
// Use its string value as the title
|
||||
// Only if it is not a leaf
|
||||
c = [self selectedCellInColumn: column - 1];
|
||||
if(_allowsMultipleSelection == NO)
|
||||
c = [self selectedCellInColumn: column - 1];
|
||||
else
|
||||
{
|
||||
NSMatrix *matrix;
|
||||
NSArray *selectedCells;
|
||||
|
||||
if (!(matrix = [self matrixInColumn: column - 1]))
|
||||
return @"";
|
||||
|
||||
selectedCells = [matrix selectedCells];
|
||||
|
||||
if([selectedCells count] == 1)
|
||||
c = [selectedCells objectAtIndex:0];
|
||||
else
|
||||
return @"";
|
||||
}
|
||||
|
||||
if ([c isLeaf])
|
||||
return @"";
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue