2003-03-03 09:15:48 +00:00
|
|
|
#include <AppKit/AppKit.h>
|
2005-03-31 03:01:36 +00:00
|
|
|
#include <GormCore/GormPrivate.h>
|
|
|
|
#include <GormCore/GormControlEditor.h>
|
|
|
|
#include <GormCore/GormViewWithSubviewsEditor.h>
|
2002-09-21 15:24:59 +00:00
|
|
|
|
|
|
|
#define _EO ((NSPopUpButton *)_editedObject)
|
|
|
|
|
|
|
|
@class GormNSPopUpButtonCell;
|
|
|
|
|
|
|
|
Class _gormnspopupbuttonCellClass = 0;
|
|
|
|
@interface GormNSPopUpButton : NSPopUpButton
|
|
|
|
@end
|
2004-03-04 04:01:09 +00:00
|
|
|
|
2002-09-21 15:24:59 +00:00
|
|
|
@implementation GormNSPopUpButton
|
|
|
|
/*
|
|
|
|
* Class methods
|
|
|
|
*/
|
|
|
|
+ (void) initialize
|
|
|
|
{
|
|
|
|
if (self == [GormNSPopUpButton class])
|
|
|
|
{
|
|
|
|
// Initial version
|
|
|
|
[self setVersion: 1];
|
|
|
|
[self setCellClass: [GormNSPopUpButtonCell class]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (Class) cellClass
|
|
|
|
{
|
|
|
|
return _gormnspopupbuttonCellClass;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (void) setCellClass: (Class)classId
|
|
|
|
{
|
|
|
|
_gormnspopupbuttonCellClass = classId;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString*) editorClassName
|
|
|
|
{
|
|
|
|
return @"GormPopUpButtonEditor";
|
|
|
|
}
|
2004-03-04 04:01:09 +00:00
|
|
|
|
|
|
|
- (NSString *) className
|
|
|
|
{
|
|
|
|
return @"NSPopUpButton";
|
|
|
|
}
|
2002-09-21 15:24:59 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
@interface GormNSPopUpButtonCell : NSPopUpButtonCell
|
|
|
|
{
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
2003-01-04 00:17:43 +00:00
|
|
|
@interface NSPopUpButtonCell (DirtyHack)
|
|
|
|
- (id) _gormInitTextCell: (NSString *) string;
|
|
|
|
@end
|
|
|
|
|
2002-09-21 15:24:59 +00:00
|
|
|
@implementation NSPopUpButtonCell (DirtyHack)
|
|
|
|
- (id) _gormInitTextCell: (NSString *) string
|
|
|
|
{
|
|
|
|
return [super initTextCell: string];
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation GormNSPopUpButtonCell
|
|
|
|
|
2008-02-19 01:31:42 +00:00
|
|
|
/* Overriden helper method */
|
|
|
|
- (void) _initMenu
|
2002-09-21 15:24:59 +00:00
|
|
|
{
|
2008-02-19 01:31:42 +00:00
|
|
|
NSMenu *menu = [[NSMenu allocSubstitute] initWithTitle: @""];
|
|
|
|
[self setMenu: menu];
|
|
|
|
RELEASE(menu);
|
2002-09-21 15:24:59 +00:00
|
|
|
}
|
2004-03-04 04:01:09 +00:00
|
|
|
|
|
|
|
- (NSString *) className
|
|
|
|
{
|
|
|
|
return @"NSPopUpButtonCell";
|
|
|
|
}
|
2002-09-21 15:24:59 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
@interface GormPopUpButtonEditor : GormControlEditor
|
|
|
|
{
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation GormPopUpButtonEditor
|
|
|
|
- (void) mouseDown: (NSEvent *)theEvent
|
|
|
|
{
|
2004-02-21 18:48:48 +00:00
|
|
|
// double-clicked -> let's edit
|
2002-09-21 15:24:59 +00:00
|
|
|
if (([theEvent clickCount] == 2) && [parent isOpened])
|
|
|
|
{
|
|
|
|
[[_EO cell]
|
|
|
|
attachPopUpWithFrame: [_EO bounds]
|
|
|
|
inView: _editedObject];
|
2004-02-21 18:48:48 +00:00
|
|
|
NSDebugLog(@"attach down");
|
2002-09-21 15:24:59 +00:00
|
|
|
[[document openEditorForObject: [[_EO cell] menu]] activate];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[super mouseDown: theEvent];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@end
|