apps-gorm/Palettes/2Controls/GormPopUpButtonEditor.m
Gregory John Casamento 3769a607ea Changed to use helper method.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@26097 72102866-910b-0410-8b05-ffd578937521
2008-02-19 01:31:42 +00:00

103 lines
1.9 KiB
Objective-C

#include <AppKit/AppKit.h>
#include <GormCore/GormPrivate.h>
#include <GormCore/GormControlEditor.h>
#include <GormCore/GormViewWithSubviewsEditor.h>
#define _EO ((NSPopUpButton *)_editedObject)
@class GormNSPopUpButtonCell;
Class _gormnspopupbuttonCellClass = 0;
@interface GormNSPopUpButton : NSPopUpButton
@end
@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";
}
- (NSString *) className
{
return @"NSPopUpButton";
}
@end
@interface GormNSPopUpButtonCell : NSPopUpButtonCell
{
}
@end
@interface NSPopUpButtonCell (DirtyHack)
- (id) _gormInitTextCell: (NSString *) string;
@end
@implementation NSPopUpButtonCell (DirtyHack)
- (id) _gormInitTextCell: (NSString *) string
{
return [super initTextCell: string];
}
@end
@implementation GormNSPopUpButtonCell
/* Overriden helper method */
- (void) _initMenu
{
NSMenu *menu = [[NSMenu allocSubstitute] initWithTitle: @""];
[self setMenu: menu];
RELEASE(menu);
}
- (NSString *) className
{
return @"NSPopUpButtonCell";
}
@end
@interface GormPopUpButtonEditor : GormControlEditor
{
}
@end
@implementation GormPopUpButtonEditor
- (void) mouseDown: (NSEvent *)theEvent
{
// double-clicked -> let's edit
if (([theEvent clickCount] == 2) && [parent isOpened])
{
[[_EO cell]
attachPopUpWithFrame: [_EO bounds]
inView: _editedObject];
NSDebugLog(@"attach down");
[[document openEditorForObject: [[_EO cell] menu]] activate];
}
else
{
[super mouseDown: theEvent];
}
}
@end