Added aditional methods for text completion.

Corrected the handling of the cellClass so that every subclass of
NSControl, that uses a cell, has its own implementaion of
[cellClass] and [setCellClass].


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@9542 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2001-04-09 21:26:34 +00:00
parent 7630d53c8a
commit ca7d708943

View file

@ -30,201 +30,223 @@
- (NSEvent *)_mouseUpEvent; - (NSEvent *)_mouseUpEvent;
@end @end
/*
* Class variables
*/
static Class usedCellClass;
static Class comboBoxCellClass;
@implementation NSComboBox @implementation NSComboBox
+ (void)initialize + (void)initialize
{ {
if (self == [NSComboBox class]) if (self == [NSComboBox class])
[self setCellClass:[NSComboBoxCell class]]; {
[self setVersion: 1];
comboBoxCellClass = [NSComboBoxCell class];
usedCellClass = comboBoxCellClass;
}
} }
- (NSComboBoxCell *)comboCell /*
* Setting the Cell class
*/
+ (Class) cellClass
{ {
return (NSComboBoxCell *)[self cell]; return usedCellClass;
} }
+ (void) setCellClass: (Class)factoryId
{
usedCellClass = factoryId ? factoryId : comboBoxCellClass;
}
- (BOOL)hasVerticalScroller - (BOOL)hasVerticalScroller
{ {
return [[self comboCell] hasVerticalScroller]; return [_cell hasVerticalScroller];
} }
- (void)setHasVerticalScroller:(BOOL)flag - (void)setHasVerticalScroller:(BOOL)flag
{ {
[[self comboCell] setHasVerticalScroller:flag]; [_cell setHasVerticalScroller:flag];
} }
- (NSSize)intercellSpacing - (NSSize)intercellSpacing
{ {
return [[self comboCell] intercellSpacing]; return [_cell intercellSpacing];
} }
- (void)setIntercellSpacing:(NSSize)aSize - (void)setIntercellSpacing:(NSSize)aSize
{ {
[[self comboCell] setIntercellSpacing:aSize]; [_cell setIntercellSpacing:aSize];
} }
- (float)itemHeight - (float)itemHeight
{ {
return [[self comboCell] itemHeight]; return [_cell itemHeight];
} }
- (void)setItemHeight:(float)itemHeight - (void)setItemHeight:(float)itemHeight
{ {
[[self comboCell] setItemHeight:itemHeight]; [_cell setItemHeight:itemHeight];
} }
- (int)numberOfVisibleItems - (int)numberOfVisibleItems
{ {
return [[self comboCell] numberOfVisibleItems]; return [_cell numberOfVisibleItems];
} }
- (void)setNumberOfVisibleItems:(int)visibleItems - (void)setNumberOfVisibleItems:(int)visibleItems
{ {
[[self comboCell] setNumberOfVisibleItems:visibleItems]; [_cell setNumberOfVisibleItems:visibleItems];
} }
- (void)reloadData - (void)reloadData
{ {
[[self comboCell] reloadData]; [_cell reloadData];
} }
- (void)noteNumberOfItemsChanged - (void)noteNumberOfItemsChanged
{ {
[[self comboCell] noteNumberOfItemsChanged]; [_cell noteNumberOfItemsChanged];
} }
- (BOOL)usesDataSource - (BOOL)usesDataSource
{ {
return [[self comboCell] usesDataSource]; return [_cell usesDataSource];
} }
- (void)setUsesDataSource:(BOOL)flag - (void)setUsesDataSource:(BOOL)flag
{ {
[[self comboCell] setUsesDataSource:flag]; [_cell setUsesDataSource:flag];
} }
- (void)scrollItemAtIndexToTop:(int)index - (void)scrollItemAtIndexToTop:(int)index
{ {
[[self comboCell] scrollItemAtIndexToTop:index]; [_cell scrollItemAtIndexToTop:index];
} }
- (void)scrollItemAtIndexToVisible:(int)index - (void)scrollItemAtIndexToVisible:(int)index
{ {
[[self comboCell] scrollItemAtIndexToVisible:index]; [_cell scrollItemAtIndexToVisible:index];
} }
- (void)selectItemAtIndex:(int)index - (void)selectItemAtIndex:(int)index
{ {
[[self comboCell] selectItemAtIndex:index]; [_cell selectItemAtIndex:index];
} }
- (void)deselectItemAtIndex:(int)index - (void)deselectItemAtIndex:(int)index
{ {
[[self comboCell] deselectItemAtIndex:index]; [_cell deselectItemAtIndex:index];
} }
- (int)indexOfSelectedItem - (int)indexOfSelectedItem
{ {
return [[self comboCell] indexOfSelectedItem]; return [_cell indexOfSelectedItem];
} }
- (int)numberOfItems - (int)numberOfItems
{ {
return [[self comboCell] numberOfItems]; return [_cell numberOfItems];
} }
- (id)dataSource - (id)dataSource
{ {
return [[self comboCell] dataSource]; return [_cell dataSource];
} }
- (void)setDataSource:(id)aSource - (void)setDataSource:(id)aSource
{ {
[[self comboCell] setDataSource:aSource]; [_cell setDataSource:aSource];
} }
- (void)addItemWithObjectValue:(id)object - (void)addItemWithObjectValue:(id)object
{ {
[[self comboCell] addItemWithObjectValue:object]; [_cell addItemWithObjectValue:object];
} }
- (void)addItemsWithObjectValues:(NSArray *)objects - (void)addItemsWithObjectValues:(NSArray *)objects
{ {
[[self comboCell] addItemsWithObjectValues:objects]; [_cell addItemsWithObjectValues:objects];
} }
- (void)insertItemWithObjectValue:(id)object atIndex:(int)index - (void)insertItemWithObjectValue:(id)object atIndex:(int)index
{ {
[[self comboCell] insertItemWithObjectValue:object atIndex:index]; [_cell insertItemWithObjectValue:object atIndex:index];
} }
- (void)removeItemWithObjectValue:(id)object - (void)removeItemWithObjectValue:(id)object
{ {
[[self comboCell] removeItemWithObjectValue:object]; [_cell removeItemWithObjectValue:object];
} }
- (void)removeItemAtIndex:(int)index - (void)removeItemAtIndex:(int)index
{ {
[[self comboCell] removeItemAtIndex:index]; [_cell removeItemAtIndex:index];
} }
- (void)removeAllItems - (void)removeAllItems
{ {
[[self comboCell] removeAllItems]; [_cell removeAllItems];
} }
- (void)selectItemWithObjectValue:(id)object - (void)selectItemWithObjectValue:(id)object
{ {
[[self comboCell] selectItemWithObjectValue:object]; [_cell selectItemWithObjectValue:object];
} }
- (id)itemObjectValueAtIndex:(int)index - (id)itemObjectValueAtIndex:(int)index
{ {
return [[self comboCell] itemObjectValueAtIndex:index]; return [_cell itemObjectValueAtIndex:index];
} }
- (id)objectValueOfSelectedItem - (id)objectValueOfSelectedItem
{ {
return [[self comboCell] objectValueOfSelectedItem]; return [_cell objectValueOfSelectedItem];
} }
- (int)indexOfItemWithObjectValue:(id)object - (int)indexOfItemWithObjectValue:(id)object
{ {
return [[self comboCell] indexOfItemWithObjectValue:object]; return [_cell indexOfItemWithObjectValue:object];
} }
- (NSArray *)objectValues - (NSArray *)objectValues
{ {
return [[self comboCell] objectValues]; return [_cell objectValues];
}
- (void)setCompletes:(BOOL)completes
{
[_cell setCompletes: completes];
}
- (BOOL)completes
{
return [_cell completes];
} }
// Overridden // Overridden
- (void)mouseDown:(NSEvent *)theEvent - (void)mouseDown:(NSEvent *)theEvent
{ {
id aCell; NSEvent *cEvent;
NSEvent *cEvent;
aCell = [self cell]; [_cell trackMouse: theEvent inRect: [self bounds]
[aCell trackMouse:theEvent inRect:[self bounds] ofView: self untilMouseUp: YES];
ofView:self untilMouseUp:YES]; if ([_cell respondsToSelector: @selector(_mouseUpEvent)])
if ([aCell respondsToSelector: @selector(_mouseUpEvent)]) cEvent = [_cell _mouseUpEvent];
cEvent = [aCell _mouseUpEvent]; else
else cEvent = nil;
cEvent = nil; if ([_cell isSelectable])
if ([aCell isSelectable]) {
{
if (!cEvent) if (!cEvent)
cEvent = [NSApp currentEvent]; cEvent = [NSApp currentEvent];
if ([cEvent type] == NSLeftMouseUp && if ([cEvent type] == NSLeftMouseUp &&
([cEvent windowNumber] == [[self window] windowNumber])) ([cEvent windowNumber] == [[self window] windowNumber]))
[NSApp postEvent:cEvent atStart:NO]; [NSApp postEvent: cEvent atStart: NO];
[super mouseDown:theEvent]; [super mouseDown: theEvent];
} }
} }
@end @end
NSString *NSComboBoxWillPopUpNotification = @"NSComboBoxWillPopUpNotification";
NSString *NSComboBoxWillDismissNotification = @"NSComboBoxWillDismissNotification";
NSString *NSComboBoxSelectionDidChangeNotification = @"NSComboBoxSelectionDidChangeNotification";
NSString *NSComboBoxSelectionIsChangingNotification = @"NSComboBoxSelectionIsChangingNotification";