mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 04:50:47 +00:00
Merge from 0.6.5
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@6040 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
6b5e33078b
commit
f34100ac45
42 changed files with 2343 additions and 1170 deletions
|
@ -195,16 +195,19 @@ Class _nspopupbuttonCellClass = 0;
|
|||
- (void) selectItem: (id <NSMenuItem>)anObject
|
||||
{
|
||||
[_cell selectItem: anObject];
|
||||
[self synchronizeTitleAndSelectedItem];
|
||||
}
|
||||
|
||||
- (void) selectItemAtIndex: (int)index
|
||||
{
|
||||
[_cell selectItemAtIndex: index];
|
||||
[self synchronizeTitleAndSelectedItem];
|
||||
}
|
||||
|
||||
- (void) selectItemWithTitle: (NSString*)title
|
||||
{
|
||||
[_cell selectItemWithTitle: title];
|
||||
[self synchronizeTitleAndSelectedItem];
|
||||
}
|
||||
|
||||
- (int) numberOfItems
|
||||
|
@ -302,7 +305,8 @@ Class _nspopupbuttonCellClass = 0;
|
|||
NSMenuView *mr = [[_cell menu] menuRepresentation];
|
||||
NSEvent *e;
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
|
||||
NSPoint p;
|
||||
|
||||
if ([self isEnabled] == NO)
|
||||
return;
|
||||
|
||||
|
@ -313,12 +317,23 @@ Class _nspopupbuttonCellClass = 0;
|
|||
[_cell attachPopUpWithFrame: _bounds
|
||||
inView: self];
|
||||
|
||||
{
|
||||
// Hack, function in NSPopUpButtonCell
|
||||
extern NSPoint
|
||||
_convertBaseToScreen_with_fix (NSRect frame, NSWindow *window,
|
||||
NSPoint point);
|
||||
|
||||
p = [[mr window]
|
||||
convertScreenToBase:
|
||||
_convertBaseToScreen_with_fix ([self convertRect:_bounds
|
||||
toView: nil], _window,
|
||||
[theEvent locationInWindow])];
|
||||
}
|
||||
|
||||
// Process events; we start menu events processing by converting
|
||||
// this event to the menu window, and sending it there.
|
||||
e = [NSEvent mouseEventWithType: [theEvent type]
|
||||
location: [[mr window] convertScreenToBase:
|
||||
[_window convertBaseToScreen:
|
||||
[theEvent locationInWindow]]]
|
||||
location: p
|
||||
modifierFlags: [theEvent modifierFlags]
|
||||
timestamp: [theEvent timestamp]
|
||||
windowNumber: [[mr window] windowNumber]
|
||||
|
@ -336,8 +351,7 @@ Class _nspopupbuttonCellClass = 0;
|
|||
|
||||
// Send action to target
|
||||
[super sendAction: [self action]
|
||||
to: [self target]];
|
||||
|
||||
to: [self target]];
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -345,30 +359,58 @@ Class _nspopupbuttonCellClass = 0;
|
|||
*/
|
||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
int i;
|
||||
BOOL f;
|
||||
id c;
|
||||
|
||||
/*
|
||||
* Don't encode all the cell information!
|
||||
*/
|
||||
c = RETAIN([self cell]);
|
||||
[super encodeWithCoder: aCoder];
|
||||
/*
|
||||
[aCoder encodeObject: list_items];
|
||||
[aCoder encodeRect: list_rect];
|
||||
[aCoder encodeValueOfObjCType: @encode(int) at: &selected_item];
|
||||
[aCoder encodeConditionalObject: pub_target];
|
||||
[aCoder encodeValueOfObjCType: @encode(SEL) at: &pub_action];
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &is_up];
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &pulls_down];
|
||||
*/
|
||||
[self setCell: c];
|
||||
RELEASE(c);
|
||||
f = [self pullsDown];
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &f];
|
||||
[aCoder encodeObject: [self itemArray]];
|
||||
i = [self indexOfSelectedItem];
|
||||
[aCoder encodeValueOfObjCType: @encode(int) at: &i];
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder*)aDecoder
|
||||
{
|
||||
NSArray *dItems;
|
||||
int dSelected;
|
||||
BOOL dPull;
|
||||
unsigned i;
|
||||
id aCell;
|
||||
|
||||
[super initWithCoder: aDecoder];
|
||||
/*
|
||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &list_items];
|
||||
list_rect = [aDecoder decodeRect];
|
||||
[aDecoder decodeValueOfObjCType: @encode(int) at: &selected_item];
|
||||
pub_target = [aDecoder decodeObject];
|
||||
[aDecoder decodeValueOfObjCType: @encode(SEL) at: &pub_action];
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &is_up];
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &pulls_down];
|
||||
*/
|
||||
/*
|
||||
* Set a newly created cell.
|
||||
*/
|
||||
aCell = [[[self class] cellClass] new];
|
||||
[self setCell: aCell];
|
||||
RELEASE(aCell);
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &dPull];
|
||||
[self setPullsDown: dPull];
|
||||
dItems = [aDecoder decodeObject];
|
||||
for (i = 0; i < [dItems count]; i++)
|
||||
{
|
||||
NSMenuItem *dItem = [dItems objectAtIndex: i];
|
||||
NSMenuItem *item;
|
||||
|
||||
[self addItemWithTitle: [dItem title]];
|
||||
item = [self itemAtIndex: i];
|
||||
[item setTarget: [dItem target]];
|
||||
[item setAction: [dItem action]];
|
||||
[item setEnabled: [dItem isEnabled]];
|
||||
[item setTag: [dItem tag]];
|
||||
[item setKeyEquivalent: [dItem keyEquivalent]];
|
||||
}
|
||||
[aDecoder decodeValueOfObjCType: @encode(int) at: &dSelected];
|
||||
[self selectItemAtIndex: dSelected];
|
||||
[self synchronizeTitleAndSelectedItem];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue