Moved popup positioning to GSComboWindow, rewrote popup size code

to respect numberOfItems and to adopt the used matrix. New methods
for the cell to popup interaction.
Corrected the encoding code of NSComboBoxCell. [objectValues] now
correctly warns in the data source case. New method
[stringValueAtIndex:]. Hack in [_didClick:] to get setting of
values working.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@15320 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
FredKiefer 2002-12-23 23:21:43 +00:00
parent 0efdb2bc37
commit bbf834a4d2

View file

@ -39,29 +39,35 @@
#include <AppKit/NSGraphicsContext.h> #include <AppKit/NSGraphicsContext.h>
#include <AppKit/NSImage.h> #include <AppKit/NSImage.h>
#include <AppKit/NSMatrix.h> #include <AppKit/NSMatrix.h>
#include <AppKit/NSPanel.h>
#include <AppKit/NSScreen.h> #include <AppKit/NSScreen.h>
#include <AppKit/NSScroller.h> #include <AppKit/NSScroller.h>
#include <AppKit/NSWindow.h>
@interface GSComboWindow : NSWindow @interface GSComboWindow : NSPanel
{ {
NSBrowser *browser; NSBrowser *browser;
@private; @private;
NSArray *list;
NSComboBoxCell *_cell; NSComboBoxCell *_cell;
BOOL _stopped; BOOL _stopped;
} }
+ (GSComboWindow *)defaultPopUp; + (GSComboWindow *)defaultPopUp;
- (NSMatrix *)matrix; - (void) positionForCell:(NSComboBoxCell *)aCell
- (NSSize)popUpCellSizeForPopUp:(NSComboBoxCell *)aCell; view: (NSView *)popView;
- (void)popUpCell:(NSComboBoxCell *)aCell - (NSSize) popUpCellSizeForPopUp:(NSComboBoxCell *)aCell
popUpAt:(NSPoint)aPoint width: (float) width;
width:(float)aWidth; - (void) popUpForCell: (NSComboBoxCell *)aCell
view: (NSView *)popView;
- (void) runModalPopUp; - (void) runModalPopUp;
- (void) runLoop; - (void) runLoop;
- (void) reloadData;
- (void) noteNumberOfItemsChanged;
- (void) scrollItemAtIndexToTop: (int)index;
- (void) scrollItemAtIndexToVisible: (int)index;
- (void) selectItemAtIndex: (int)index;
- (void) deselectItemAtIndex: (int)index;
@end @end
@ -69,7 +75,7 @@
static NSNotificationCenter *nc; static NSNotificationCenter *nc;
@interface NSComboBoxCell(_Private_) @interface NSComboBoxCell(_Private_)
- (NSArray *)_dataSourceObjectValues; - (NSString *) _stringValueAtIndex: (int)index;
- (void) _didClickInRect: (NSRect)cellFrame - (void) _didClickInRect: (NSRect)cellFrame
ofView: (NSView *)controlView; ofView: (NSView *)controlView;
- (void) _didClick: (id)sender; - (void) _didClick: (id)sender;
@ -102,6 +108,10 @@ static NSNotificationCenter *nc;
styleMask: aStyle styleMask: aStyle
backing: bufferingType backing: bufferingType
defer: flag]; defer: flag];
[self setLevel: NSPopUpMenuWindowLevel];
[self setWorksWhenModal: YES];
[self setBecomesKeyOnlyIfNeeded: YES];
box = [[NSBox alloc] initWithFrame: contentRect]; box = [[NSBox alloc] initWithFrame: contentRect];
[box setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable]; [box setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
[box setBorderType: NSLineBorder]; [box setBorderType: NSLineBorder];
@ -121,59 +131,125 @@ static NSNotificationCenter *nc;
[browser setAutoresizingMask: NSViewWidthSizable | NSViewWidthSizable]; [browser setAutoresizingMask: NSViewWidthSizable | NSViewWidthSizable];
[browser setAllowsEmptySelection: NO]; [browser setAllowsEmptySelection: NO];
[browser setAllowsMultipleSelection: NO]; [browser setAllowsMultipleSelection: NO];
[browser setReusesColumns: YES];
// Create an empty matrix
[browser loadColumnZero];
[box setContentView: browser]; [box setContentView: browser];
RELEASE(browser); RELEASE(browser);
return self; return self;
} }
- (BOOL) canBecomeKeyWindow { return YES; }
- (void)dealloc - (void)dealloc
{ {
// Browser was not retained so don't release it // Browser was not retained so don't release it
[super dealloc]; [super dealloc];
} }
- (NSMatrix *) matrix { return [browser matrixInColumn:0]; }
- (NSSize) popUpCellSizeForPopUp: (NSComboBoxCell *)aCell - (NSSize) popUpCellSizeForPopUp: (NSComboBoxCell *)aCell
width: (float) width
{ {
NSMatrix *matrix = [browser matrixInColumn: 0];
NSSize size; NSSize size;
NSSize bsize = _sizeForBorderType(NSLineBorder);
float itemHeight; float itemHeight;
float cellSpacing; float cellSpacing;
int num = [aCell numberOfItems];
int max = [aCell numberOfVisibleItems];
if (num > max)
num = max;
itemHeight = [aCell itemHeight]; itemHeight = [aCell itemHeight];
cellSpacing = [aCell intercellSpacing].height;
if (itemHeight <= 0) if (itemHeight <= 0)
itemHeight = [[self matrix] cellSize].height; {
itemHeight = [matrix cellSize].height;
if (cellSpacing <= 0) }
cellSpacing = [[self matrix] intercellSpacing].height; else
{
size = NSMakeSize(2.0 + [NSScroller scrollerWidth] + 100.0, size.height = itemHeight;
2.0 + (itemHeight * [aCell numberOfVisibleItems]) + if ([aCell hasVerticalScroller])
(cellSpacing * [aCell numberOfVisibleItems])); {
size.height += 4.0; size.width = width - [NSScroller scrollerWidth] - bsize.width;
size.width += 4.0; }
else
return size; {
size.width = width - bsize.width;
}
[matrix setCellSize: size];
} }
- (void) popUpCell: (NSComboBoxCell *)aCell size = [aCell intercellSpacing];
popUpAt: (NSPoint)aPoint cellSpacing = size.height;
width: (float)aWidth if (cellSpacing <= 0)
cellSpacing = [matrix intercellSpacing].height;
else
[matrix setIntercellSpacing: size];
return NSMakeSize(width, 2.0 + bsize.height + (itemHeight + cellSpacing) * num);
}
- (void) positionForCell: (NSComboBoxCell *)aCell
view: (NSView *)popView
{ {
NSRect popRect = [popView bounds];
NSRect screenFrame;
NSRect rect; NSRect rect;
NSSize size;
NSPoint point, oldPoint;
rect.size = [self popUpCellSizeForPopUp: aCell]; size = [self popUpCellSizeForPopUp: aCell width: NSWidth(popRect)];
_cell = aCell; if (size.width == 0 || size.height == 0)
return;
rect.size.width = aWidth; screenFrame = [[[popView window] screen] frame];
rect.origin.x = aPoint.x; point = popRect.origin;
rect.origin.y = aPoint.y; if ([popView isFlipped])
point.y += NSHeight(popRect);
point = [popView convertPoint: point toView: nil];
point.y -= 1.0;
point = [[popView window] convertBaseToScreen: point];
point.y -= size.height;
if (point.y < 0)
{
// Off screen, so move it.
oldPoint = point;
point = popRect.origin;
if (![popView isFlipped])
point.y += NSHeight(popRect);
point = [popView convertPoint: point toView: nil];
point.y += 1.0;
point = [[popView window] convertBaseToScreen: point];
if (point.y > NSHeight(screenFrame))
point = oldPoint;
if (point.y + size.height > NSHeight(screenFrame))
point.y = NSHeight(screenFrame) - size.height;
}
if (point.x + size.width > NSWidth(screenFrame))
point.x = NSWidth(screenFrame) - size.width;
if (point.x < 0.0)
point.x = 0.0;
rect.size = size;
rect.origin.x = point.x;
rect.origin.y = point.y;
rect = [NSWindow frameRectForContentRect: rect
styleMask: _styleMask];
[self setFrame: rect display: NO]; [self setFrame: rect display: NO];
}
[browser loadColumnZero]; - (void) popUpForCell: (NSComboBoxCell *)aCell
view: (NSView *)popView
{
[self positionForCell: aCell
view: popView];
_cell = aCell;
[self reloadData];
// [self enableKeyEquivalentForDefaultButtonCell]; // [self enableKeyEquivalentForDefaultButtonCell];
[self runModalPopUp]; [self runModalPopUp];
@ -188,8 +264,8 @@ static NSNotificationCenter *nc;
NSException *exception = nil; NSException *exception = nil;
onWindow = [[_cell controlView] window]; onWindow = [[_cell controlView] window];
[self setLevel: [onWindow level]]; // [self setLevel: [onWindow level]];
[self orderWindow: NSWindowAbove relativeTo: [onWindow windowNumber]]; // [self orderWindow: NSWindowAbove relativeTo: [onWindow windowNumber]];
while ((event = [NSApp nextEventMatchingMask: NSAnyEventMask while ((event = [NSApp nextEventMatchingMask: NSAnyEventMask
untilDate: [NSDate dateWithTimeIntervalSinceNow: 0] untilDate: [NSDate dateWithTimeIntervalSinceNow: 0]
@ -233,6 +309,7 @@ static NSNotificationCenter *nc;
NSEvent *event; NSEvent *event;
int cnt = 0; int cnt = 0;
BOOL kDown; BOOL kDown;
NSDate *limit = [NSDate distantFuture];
CREATE_AUTORELEASE_POOL (pool); CREATE_AUTORELEASE_POOL (pool);
_stopped = NO; _stopped = NO;
@ -247,7 +324,7 @@ static NSNotificationCenter *nc;
cnt = 0; cnt = 0;
} }
event = [NSApp nextEventMatchingMask: NSAnyEventMask event = [NSApp nextEventMatchingMask: NSAnyEventMask
untilDate: [NSDate distantFuture] untilDate: limit
inMode: NSDefaultRunLoopMode inMode: NSDefaultRunLoopMode
dequeue: NO]; dequeue: NO];
if (event) if (event)
@ -258,7 +335,7 @@ static NSNotificationCenter *nc;
[event windowNumber] == [self windowNumber]) [event windowNumber] == [self windowNumber])
{ {
event = [NSApp nextEventMatchingMask: NSAnyEventMask event = [NSApp nextEventMatchingMask: NSAnyEventMask
untilDate: [NSDate distantFuture] untilDate: limit
inMode: NSDefaultRunLoopMode inMode: NSDefaultRunLoopMode
dequeue: YES]; dequeue: YES];
[NSApp sendEvent: event]; [NSApp sendEvent: event];
@ -274,7 +351,7 @@ static NSNotificationCenter *nc;
[event type] == NSCursorUpdate) [event type] == NSCursorUpdate)
{ {
event = [NSApp nextEventMatchingMask: NSAnyEventMask event = [NSApp nextEventMatchingMask: NSAnyEventMask
untilDate:[NSDate distantFuture] untilDate: limit
inMode: NSDefaultRunLoopMode inMode: NSDefaultRunLoopMode
dequeue: YES]; dequeue: YES];
[NSApp sendEvent:event]; [NSApp sendEvent:event];
@ -283,16 +360,17 @@ static NSNotificationCenter *nc;
_stopped = YES; _stopped = YES;
} }
} }
if (kDown) if (kDown)
while ((event = [NSApp nextEventMatchingMask: NSAnyEventMask while ((event = [NSApp nextEventMatchingMask: NSAnyEventMask
untilDate: [NSDate distantFuture] untilDate: limit
inMode: NSDefaultRunLoopMode inMode: NSDefaultRunLoopMode
dequeue: NO])) dequeue: NO]))
{ {
if ([event windowNumber] != [self windowNumber]) if ([event windowNumber] != [self windowNumber])
break; break;
event = [NSApp nextEventMatchingMask: NSAnyEventMask event = [NSApp nextEventMatchingMask: NSAnyEventMask
untilDate:[NSDate distantFuture] untilDate: limit
inMode: NSDefaultRunLoopMode inMode: NSDefaultRunLoopMode
dequeue: YES]; dequeue: YES];
[NSApp sendEvent: event]; [NSApp sendEvent: event];
@ -302,14 +380,52 @@ static NSNotificationCenter *nc;
RELEASE(pool); RELEASE(pool);
} }
- (BOOL) canBecomeKeyWindow { return YES; } - (void) reloadData
- (BOOL) worksWhenModal { return NO; } {
[browser loadColumnZero];
[self selectItemAtIndex: [_cell indexOfSelectedItem]];
}
- (void) noteNumberOfItemsChanged
{
// FIXME: Should only load the additional items
[self reloadData];
}
- (void) scrollItemAtIndexToTop: (int)index
{
NSMatrix *matrix = [browser matrixInColumn: 0];
NSRect rect;
rect = [matrix cellFrameAtRow: index column: 0];
[matrix scrollPoint: rect.origin];
}
- (void) scrollItemAtIndexToVisible: (int)index
{
NSMatrix *matrix = [browser matrixInColumn: 0];
[matrix scrollCellToVisibleAtRow: index column: 0];
}
- (void) selectItemAtIndex: (int)index
{
[browser selectRow: index inColumn: 0];
}
- (void) deselectItemAtIndex: (int)index
{
NSMatrix *matrix = [browser matrixInColumn: 0];
[matrix deselectSelectedCell];
}
// Target/Action of Browser // Target/Action of Browser
- (void) selectItem: (id)sender - (void) selectItem: (id)sender
{ {
if (_cell) if (_cell)
{ {
[_cell selectItemAtIndex: [sender selectedRowInColumn: 0]];
[_cell setStringValue: [[sender selectedCell] stringValue]]; [_cell setStringValue: [[sender selectedCell] stringValue]];
_stopped = YES; _stopped = YES;
} }
@ -322,7 +438,6 @@ numberOfRowsInColumn: (int)column
if (!_cell) if (!_cell)
return 0; return 0;
ASSIGN(list, [_cell objectValues]);
return [_cell numberOfItems]; return [_cell numberOfItems];
} }
@ -331,12 +446,16 @@ willDisplayCell: (id)aCell
atRow: (int)row atRow: (int)row
column: (int)column column: (int)column
{ {
[aCell setStringValue: [list objectAtIndex:row]]; if (!_cell)
return;
[aCell setStringValue: [_cell _stringValueAtIndex: row]];
[aCell setLeaf: YES]; [aCell setLeaf: YES];
} }
@end @end
@implementation NSComboBoxCell @implementation NSComboBoxCell
// //
@ -359,17 +478,15 @@ willDisplayCell: (id)aCell
// //
//_dataSource = nil; //_dataSource = nil;
//_buttonCell = nil; //_buttonCell = nil;
_popUpList = [[NSMutableArray alloc] init];
//_usesDataSource = NO; //_usesDataSource = NO;
//_completes = NO; //_completes = NO;
_popUpList = [[NSMutableArray alloc] init];
_hasVerticalScroller = YES; _hasVerticalScroller = YES;
_visibleItems = 10; _visibleItems = 10;
_intercellSpacing = NSMakeSize(3.0, 2.0); _intercellSpacing = NSMakeSize(3.0, 2.0);
_itemHeight = 16; _itemHeight = 16;
_selectedItem = -1; _selectedItem = -1;
_popRect = NSZeroRect;
//_mUpEvent = nil;
_buttonCell = [[NSButtonCell alloc] initImageCell: _buttonCell = [[NSButtonCell alloc] initImageCell:
[NSImage imageNamed: @"NSComboArrow"]]; [NSImage imageNamed: @"NSComboArrow"]];
[_buttonCell setImagePosition: NSImageOnly]; [_buttonCell setImagePosition: NSImageOnly];
@ -420,12 +537,12 @@ willDisplayCell: (id)aCell
- (void) reloadData - (void) reloadData
{ {
// TODO notify popup [_popup reloadData];
} }
- (void) noteNumberOfItemsChanged - (void) noteNumberOfItemsChanged
{ {
// TODO notify popup [_popup noteNumberOfItemsChanged];
} }
- (BOOL) usesDataSource { return _usesDataSource; } - (BOOL) usesDataSource { return _usesDataSource; }
@ -436,12 +553,12 @@ willDisplayCell: (id)aCell
- (void) scrollItemAtIndexToTop: (int)index - (void) scrollItemAtIndexToTop: (int)index
{ {
// TODO [_popup scrollItemAtIndexToTop: index];
} }
- (void) scrollItemAtIndexToVisible: (int)index - (void) scrollItemAtIndexToVisible: (int)index
{ {
// TODO [_popup scrollItemAtIndexToVisible: index];
} }
- (void) selectItemAtIndex: (int)index - (void) selectItemAtIndex: (int)index
@ -452,7 +569,9 @@ willDisplayCell: (id)aCell
if (_selectedItem != index) if (_selectedItem != index)
{ {
_selectedItem = index; _selectedItem = index;
// TODO: Notify popup
[_popup selectItemAtIndex: index];
[nc postNotificationName: NSComboBoxSelectionDidChangeNotification [nc postNotificationName: NSComboBoxSelectionDidChangeNotification
object: [self controlView] object: [self controlView]
userInfo: nil]; userInfo: nil];
@ -464,7 +583,9 @@ willDisplayCell: (id)aCell
if (_selectedItem == index) if (_selectedItem == index)
{ {
_selectedItem = -1; _selectedItem = -1;
// TODO: Notify popup
[_popup deselectItemAtIndex: index];
[nc postNotificationName: NSComboBoxSelectionDidChangeNotification [nc postNotificationName: NSComboBoxSelectionDidChangeNotification
object: [self controlView] object: [self controlView]
userInfo: nil]; userInfo: nil];
@ -622,8 +743,10 @@ willDisplayCell: (id)aCell
- (NSArray *)objectValues - (NSArray *)objectValues
{ {
if (_usesDataSource) if (_usesDataSource)
// FIXME: This should give a warning {
return [self _dataSourceObjectValues]; NSLog(@"Method Invalid: ComboBox uses dataSource");
return nil;
}
return _popUpList; return _popUpList;
} }
@ -776,11 +899,12 @@ buttonCellFrameFromRect(NSRect cellRect)
point = [controlView convertPoint: [nEvent locationInWindow] point = [controlView convertPoint: [nEvent locationInWindow]
fromView: nil]; fromView: nil];
if (NSPointInRect(point, buttonCellFrameFromRect(cellFrame))) if (NSPointInRect(point, buttonCellFrameFromRect(cellFrame)))
{
// [_buttonCell performClick: self]; // [_buttonCell performClick: self];
[self _didClickInRect: cellFrame ofView: controlView]; [self _didClickInRect: cellFrame ofView: controlView];
} }
} }
_mUpEvent = nEvent; }
return rValue; return rValue;
} }
@ -814,26 +938,30 @@ buttonCellFrameFromRect(NSRect cellRect)
[coder encodeValueOfObjCType: @encode(int) at: &_selectedItem]; [coder encodeValueOfObjCType: @encode(int) at: &_selectedItem];
if (_usesDataSource == YES) if (_usesDataSource == YES)
[coder encodeValueOfObjCType: @encode(id) at: &_dataSource]; [coder encodeConditionalObject: _dataSource];
} }
- (id) initWithCoder: (NSCoder *)coder - (id) initWithCoder: (NSCoder *)coder
{ {
BOOL dummy;
self = [super initWithCoder: coder]; self = [super initWithCoder: coder];
[coder decodeValueOfObjCType: @encode(id) at: &_buttonCell]; [coder decodeValueOfObjCType: @encode(id) at: &_buttonCell];
RETAIN(_buttonCell);
[coder decodeValueOfObjCType: @encode(id) at: &_popUpList]; [coder decodeValueOfObjCType: @encode(id) at: &_popUpList];
RETAIN(_popUpList);
[coder decodeValueOfObjCType: @encode(BOOL) at: &_usesDataSource]; [coder decodeValueOfObjCType: @encode(BOOL) at: &_usesDataSource];
[coder decodeValueOfObjCType: @encode(BOOL) at: &_hasVerticalScroller]; [coder decodeValueOfObjCType: @encode(BOOL) at: &_hasVerticalScroller];
[coder decodeValueOfObjCType: @encode(BOOL) at: &_completes]; [coder decodeValueOfObjCType: @encode(BOOL) at: &_completes];
[coder decodeValueOfObjCType: @encode(BOOL) at: &_usesDataSource]; [coder decodeValueOfObjCType: @encode(BOOL) at: &dummy];
[coder decodeValueOfObjCType: @encode(int) at: &_visibleItems]; [coder decodeValueOfObjCType: @encode(int) at: &_visibleItems];
[coder decodeValueOfObjCType: @encode(NSSize) at: &_intercellSpacing]; [coder decodeValueOfObjCType: @encode(NSSize) at: &_intercellSpacing];
[coder decodeValueOfObjCType: @encode(float) at: &_itemHeight]; [coder decodeValueOfObjCType: @encode(float) at: &_itemHeight];
[coder decodeValueOfObjCType: @encode(int) at: &_selectedItem]; [coder decodeValueOfObjCType: @encode(int) at: &_selectedItem];
if (_usesDataSource == YES) if (_usesDataSource == YES)
[coder decodeValueOfObjCType: @encode(id) at: &_dataSource]; [self setDataSource: [coder decodeObject]];
return self; return self;
} }
@ -842,44 +970,34 @@ buttonCellFrameFromRect(NSRect cellRect)
@implementation NSComboBoxCell(_Private_) @implementation NSComboBoxCell(_Private_)
- (NSArray *)_dataSourceObjectValues - (NSString *)_stringValueAtIndex: (int)index
{
if (!_usesDataSource)
{
return [[self itemObjectValueAtIndex: index] description];
}
else
{ {
NSMutableArray *array = nil;
id obj;
SEL selector;
int i,cnt;
if (!_dataSource) if (!_dataSource)
NSLog(@"No DataSource Specified");
else
{ {
cnt = [self numberOfItems]; NSLog(@"ComboBox: No DataSource Specified");
if ([[self controlView] isKindOfClass:[NSComboBox class]]) return nil;
}
if ([_dataSource respondsToSelector:
@selector(comboBox:objectValueForItemAtIndex:)])
{ {
obj = [self controlView]; return [[_dataSource comboBox: (NSComboBox *)[self controlView]
selector = @selector(comboBox:objectValueForItemAtIndex:); objectValueForItemAtIndex: index] description];
if ([_dataSource respondsToSelector:selector]) }
else if ([_dataSource respondsToSelector:
@selector(comboBoxCell:objectValueForItemAtIndex:)])
{ {
array = [NSMutableArray array]; return [[_dataSource comboBoxCell: self
for (i=0;i<cnt;i++) objectValueForItemAtIndex: index] description];
[array addObject:[_dataSource comboBox:obj
objectValueForItemAtIndex:i]];
} }
} }
else
{ return nil;
obj = self;
selector = @selector(comboBoxCell:indexOfItemWithStringValue:);
if ([_dataSource respondsToSelector:selector])
{
array = [NSMutableArray array];
for (i=0;i<cnt;i++)
[array addObject:[_dataSource comboBoxCell:obj
objectValueForItemAtIndex:i]];
}
}
}
return array;
} }
- (void) _didClickInRect: (NSRect)cellFrame - (void) _didClickInRect: (NSRect)cellFrame
@ -894,10 +1012,7 @@ buttonCellFrameFromRect(NSRect cellRect)
inView: controlView]; inView: controlView];
[cvWin flushWindow]; [cvWin flushWindow];
_popRect = cellFrame;
[self _didClick: self]; [self _didClick: self];
_popRect = NSZeroRect;
[_buttonCell highlight: NO [_buttonCell highlight: NO
withFrame: buttonCellFrameFromRect(cellFrame) withFrame: buttonCellFrameFromRect(cellFrame)
@ -907,64 +1022,28 @@ buttonCellFrameFromRect(NSRect cellRect)
- (void) _didClick: (id)sender - (void) _didClick: (id)sender
{ {
NSSize size;
NSPoint point,oldPoint;
NSRect screenFrame;
NSView *popView = [self controlView]; NSView *popView = [self controlView];
if (_cell.is_disabled) if ((_cell.is_disabled) || (popView == nil))
return; return;
size = [[self _popUp] popUpCellSizeForPopUp: self];
if (size.width == 0 || size.height == 0)
return;
screenFrame = [[[popView window] screen] frame];
point = _popRect.origin;
if ([popView isFlipped])
point.y += NSHeight(_popRect);
point = [popView convertPoint: point toView: nil];
point.y -= 1.0;
point = [[popView window] convertBaseToScreen: point];
point.y -= size.height;
if (point.y < 0)
{
// Off screen, so move it.
oldPoint = point;
point = _popRect.origin;
if (![popView isFlipped])
point.y += NSHeight(_popRect);
point = [popView convertPoint: point toView: nil];
point.y += 1.0;
point = [[popView window] convertBaseToScreen: point];
if (point.y > NSHeight(screenFrame))
point = oldPoint;
if (point.y + size.height > NSHeight(screenFrame))
point.y = NSHeight(screenFrame) - size.height;
}
if (point.x + size.width > NSWidth(screenFrame))
point.x = NSWidth(screenFrame) - size.width;
if (point.x < 0.0)
point.x = 0.0;
[nc postNotificationName: NSComboBoxWillPopUpNotification [nc postNotificationName: NSComboBoxWillPopUpNotification
object: popView object: popView
userInfo: nil]; userInfo: nil];
[[self _popUp] popUpCell: self popUpAt: point width: NSWidth(_popRect)]; // HACK Abort the editing, otherwise the selected value is overwritten by the editor
//if ([_control_view isKindOfClass: NSControl])
[(NSControl *)_control_view abortEditing];
_popup = [self _popUp];
[_popup popUpForCell: self view: popView];
_popup = nil;
[nc postNotificationName: NSComboBoxWillDismissNotification [nc postNotificationName: NSComboBoxWillDismissNotification
object: popView object: popView
userInfo: nil]; userInfo: nil];
} }
- (NSEvent *)_mouseUpEvent
{
return _mUpEvent;
}
- (GSComboWindow *)_popUp - (GSComboWindow *)_popUp
{ {
return [GSComboWindow defaultPopUp]; return [GSComboWindow defaultPopUp];