mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 09:31:19 +00:00
Popup fixes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5381 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
02d80a510c
commit
018ad81664
3 changed files with 74 additions and 82 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Fri Dec 3 14:53:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
|
* Source/NSPopUpButtonCell.m: arbitrary hacks to get window positioning
|
||||||
|
correct - NSWindow still needs some fixing.
|
||||||
|
|
||||||
Fri Dec 3 14:41:00 1999 Michael Hanni <mhanni@sprintmail.com>
|
Fri Dec 3 14:41:00 1999 Michael Hanni <mhanni@sprintmail.com>
|
||||||
|
|
||||||
* Source/NSPopUpButtonCell.m: more fixes, issues remain.
|
* Source/NSPopUpButtonCell.m: more fixes, issues remain.
|
||||||
|
|
|
@ -13,7 +13,6 @@ typedef enum {
|
||||||
{
|
{
|
||||||
NSMenu *_menu;
|
NSMenu *_menu;
|
||||||
NSMenuItem *_selectedItem;
|
NSMenuItem *_selectedItem;
|
||||||
int _selectedIndex;
|
|
||||||
struct __pbcFlags {
|
struct __pbcFlags {
|
||||||
unsigned int pullsDown: 1;
|
unsigned int pullsDown: 1;
|
||||||
unsigned int preferredEdge: 3;
|
unsigned int preferredEdge: 3;
|
||||||
|
|
|
@ -74,8 +74,6 @@
|
||||||
_menu = [[NSMenu alloc] initWithTitle: @""];
|
_menu = [[NSMenu alloc] initWithTitle: @""];
|
||||||
[_menu _setOwnedByPopUp: YES];
|
[_menu _setOwnedByPopUp: YES];
|
||||||
|
|
||||||
_selectedIndex = 0;
|
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +183,7 @@
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
index = 0;
|
index = 0;
|
||||||
if (index > [_menu numberOfItems])
|
if (index > [_menu numberOfItems])
|
||||||
index = [_menu numberOfitems];
|
index = [_menu numberOfItems];
|
||||||
|
|
||||||
[anItem setTitle: title];
|
[anItem setTitle: title];
|
||||||
[anItem setTarget: self];
|
[anItem setTarget: self];
|
||||||
|
@ -271,30 +269,25 @@
|
||||||
// Dealing with selection
|
// Dealing with selection
|
||||||
- (void) selectItem: (id <NSMenuItem>)item
|
- (void) selectItem: (id <NSMenuItem>)item
|
||||||
{
|
{
|
||||||
id selectedItem = [_menu itemAtIndex: _selectedIndex];
|
|
||||||
|
|
||||||
if (!item)
|
if (!item)
|
||||||
{
|
{
|
||||||
if (_pbcFlags.altersStateOfSelectedItem)
|
if (_pbcFlags.altersStateOfSelectedItem)
|
||||||
[selectedItem setState: NSOffState];
|
[_selectedItem setState: NSOffState];
|
||||||
|
|
||||||
_selectedIndex = -1;
|
_selectedItem = nil;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_pbcFlags.altersStateOfSelectedItem)
|
if (_pbcFlags.altersStateOfSelectedItem)
|
||||||
{
|
{
|
||||||
[selectedItem setState: NSOffState];
|
[_selectedItem setState: NSOffState];
|
||||||
}
|
}
|
||||||
_selectedIndex = [self indexOfItem: item];
|
_selectedItem = item;
|
||||||
selectedItem = [_menu itemAtIndex: _selectedIndex];
|
|
||||||
if (_pbcFlags.altersStateOfSelectedItem)
|
if (_pbcFlags.altersStateOfSelectedItem)
|
||||||
{
|
{
|
||||||
[selectedItem setState: NSOnState];
|
[_selectedItem setState: NSOnState];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[self synchronizeTitleAndSelectedItem];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) selectItemAtIndex: (int)index
|
- (void) selectItemAtIndex: (int)index
|
||||||
|
@ -340,12 +333,12 @@
|
||||||
|
|
||||||
- (id <NSMenuItem>) selectedItem
|
- (id <NSMenuItem>) selectedItem
|
||||||
{
|
{
|
||||||
return [self itemAtIndex: _selectedIndex];
|
return _selectedItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (int) indexOfSelectedItem
|
- (int) indexOfSelectedItem
|
||||||
{
|
{
|
||||||
return _selectedIndex;
|
return [_menu indexOfItem: _selectedItem];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) synchronizeTitleAndSelectedItem
|
- (void) synchronizeTitleAndSelectedItem
|
||||||
|
@ -355,14 +348,12 @@
|
||||||
|
|
||||||
if ([_menu numberOfItems] == 0)
|
if ([_menu numberOfItems] == 0)
|
||||||
{
|
{
|
||||||
_selectedIndex = -1;
|
_selectedItem = nil;
|
||||||
}
|
}
|
||||||
else if (_pbcFlags.pullsDown)
|
else if (_pbcFlags.pullsDown)
|
||||||
{
|
{
|
||||||
_selectedIndex = 0;
|
[self selectItem: [self itemAtIndex: 0]];
|
||||||
// [self selectItem: [self itemAtIndex: 0]];
|
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int index = [[_menu menuRepresentation] highlightedItemIndex];
|
int index = [[_menu menuRepresentation] highlightedItemIndex];
|
||||||
|
@ -371,7 +362,6 @@
|
||||||
index = 0;
|
index = 0;
|
||||||
[self selectItemAtIndex: index];
|
[self selectItemAtIndex: index];
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Title conveniences
|
// Title conveniences
|
||||||
|
@ -397,8 +387,8 @@
|
||||||
|
|
||||||
- (NSString *) titleOfSelectedItem
|
- (NSString *) titleOfSelectedItem
|
||||||
{
|
{
|
||||||
if (_selectedIndex >= 0)
|
if (_selectedItem != nil)
|
||||||
return [[self itemAtIndex: _selectedIndex] title];
|
return [_selectedItem title];
|
||||||
else
|
else
|
||||||
return @"";
|
return @"";
|
||||||
}
|
}
|
||||||
|
@ -427,9 +417,9 @@ NSLog(@"cF %@", NSStringFromRect(cellFrame));
|
||||||
|
|
||||||
[_aCenter postNotification: _aNotif];
|
[_aCenter postNotification: _aNotif];
|
||||||
|
|
||||||
scratchRect = [[controlView superview] convertRect: scratchRect toView: nil];
|
scratchRect.origin = NSMakePoint(0,0);
|
||||||
scratchRect.origin
|
scratchRect = [controlView convertRect: scratchRect toView: nil];
|
||||||
= [[controlView window] convertBaseToScreen: cellFrame.origin];
|
scratchRect.origin = [[controlView window] convertBaseToScreen: scratchRect.origin];
|
||||||
|
|
||||||
[[_menu menuRepresentation] _setCellSize: cellFrame.size];
|
[[_menu menuRepresentation] _setCellSize: cellFrame.size];
|
||||||
[_menu sizeToFit];
|
[_menu sizeToFit];
|
||||||
|
@ -448,13 +438,13 @@ NSLog(@"cF %@", NSStringFromRect(cellFrame));
|
||||||
{
|
{
|
||||||
winf.origin.y += ([self indexOfSelectedItem] * scratchRect.size.height);
|
winf.origin.y += ([self indexOfSelectedItem] * scratchRect.size.height);
|
||||||
}
|
}
|
||||||
|
winf.origin.y -= 22; /* HACK */
|
||||||
NSLog(@"winf %@", NSStringFromRect(winf));
|
NSLog(@"winf %@", NSStringFromRect(winf));
|
||||||
|
|
||||||
NSLog(@"here comes the popup.");
|
NSLog(@"here comes the popup.");
|
||||||
|
|
||||||
[[_menu window] setFrame: winf display: YES];
|
[[_menu window] setFrame: winf display: YES];
|
||||||
[[_menu window] orderFront: nil];
|
[[_menu window] orderFrontRegardless];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) dismissPopUp
|
- (void) dismissPopUp
|
||||||
|
@ -523,12 +513,10 @@ NSLog(@"winf %@", NSStringFromRect(winf));
|
||||||
size = [aImage size];
|
size = [aImage size];
|
||||||
position.x = cellFrame.origin.x + cellFrame.size.width - size.width - 4;
|
position.x = cellFrame.origin.x + cellFrame.size.width - size.width - 4;
|
||||||
position.y = MAX(NSMidY(cellFrame) - (size.height/2.), 0.);
|
position.y = MAX(NSMidY(cellFrame) - (size.height/2.), 0.);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Images are always drawn with their bottom-left corner at the origin
|
* Images are always drawn with their bottom-left corner at the origin
|
||||||
* so we must adjust the position to take account of a flipped view.
|
* so we must adjust the position to take account of a flipped view.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ([control_view isFlipped])
|
if ([control_view isFlipped])
|
||||||
position.y += size.height;
|
position.y += size.height;
|
||||||
[aImage compositeToPoint: position operation: NSCompositeCopy];
|
[aImage compositeToPoint: position operation: NSCompositeCopy];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue