mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-02-24 20:11:20 +00:00
inspector. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@16829 72102866-910b-0410-8b05-ffd578937521
137 lines
2.6 KiB
Objective-C
137 lines
2.6 KiB
Objective-C
#include <AppKit/AppKit.h>
|
|
#include "GormPrivate.h"
|
|
#include "GormControlEditor.h"
|
|
#include "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";
|
|
}
|
|
@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
|
|
|
|
- (id) initTextCell: (NSString*) stringValue
|
|
pullsDown: (BOOL) pullDown
|
|
{
|
|
[super _gormInitTextCell: stringValue];
|
|
|
|
|
|
_pbcFlags.pullsDown = pullDown;
|
|
_pbcFlags.usesItemFromMenu = YES;
|
|
_pbcFlags.altersStateOfSelectedItem = YES;
|
|
|
|
if ([stringValue length] > 0)
|
|
{
|
|
[self addItemWithTitle: stringValue];
|
|
}
|
|
|
|
_menu = [(id)[NSMenu allocSubstitute] initWithTitle: @""];
|
|
[_menu _setOwnedByPopUp: self];
|
|
|
|
return self;
|
|
}
|
|
@end
|
|
// @interface GormPopUpNSMenu : NSMenu
|
|
// - (BOOL)canBecomeMainWindow
|
|
// {
|
|
// return YES;
|
|
// }
|
|
// - (BOOL)canBecomeKeyWindow
|
|
// {
|
|
// return YES;
|
|
// }
|
|
|
|
// - (void) sendEvent: (NSEvent*)theEvent
|
|
// {
|
|
// NSEventType type;
|
|
|
|
// type = [theEvent type];
|
|
// if (type == NSLeftMouseDown)
|
|
// {
|
|
// NSLog(@"here");
|
|
// if (_f.is_main == YES)
|
|
// {
|
|
// NSLog(@"already main %@", [NSApp mainWindow]);
|
|
// }
|
|
// [self makeMainWindow];
|
|
// [self makeKeyWindow];
|
|
// }
|
|
|
|
// [super sendEvent: theEvent];
|
|
// }
|
|
// @end
|
|
|
|
// @implementation GormPopUpNSMenu
|
|
// @end
|
|
|
|
@interface GormPopUpButtonEditor : GormControlEditor
|
|
{
|
|
}
|
|
@end
|
|
|
|
@implementation GormPopUpButtonEditor
|
|
- (void) mouseDown: (NSEvent *)theEvent
|
|
{
|
|
if (([theEvent clickCount] == 2) && [parent isOpened])
|
|
// double-clicked -> let's edit
|
|
{
|
|
[[_EO cell]
|
|
attachPopUpWithFrame: [_EO bounds]
|
|
inView: _editedObject];
|
|
NSLog(@"attach down");
|
|
[[document openEditorForObject: [[_EO cell] menu]] activate];
|
|
}
|
|
else
|
|
{
|
|
[super mouseDown: theEvent];
|
|
}
|
|
}
|
|
@end
|