mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 05:20:59 +00:00
Add support for popup preferred edge.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@26023 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
80e1ea3407
commit
f76e07d9af
6 changed files with 223 additions and 164 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
2008-02-04 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Images/common_3DArrowLeft.tiff,
|
||||||
|
* Images/common_3DArrowUp.tiff: New files
|
||||||
|
* Images/GNUmakefile: Install new files.
|
||||||
|
* Source/NSMenuView.m
|
||||||
|
(-setWindowFrameForAttachingToRect:...popUpSelectedItem:):
|
||||||
|
Implement preferred edge handling.
|
||||||
|
* Source/NSPopUpButtonCell.m: Rewrote handling of preferred edge,
|
||||||
|
arrow possition and pull down flag.
|
||||||
|
|
||||||
2008-02-04 Fred Kiefer <FredKiefer@gmx.de>
|
2008-02-04 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Source/GSHorizontalTypesetter.m
|
* Source/GSHorizontalTypesetter.m
|
||||||
|
|
|
@ -34,6 +34,8 @@ imagedir = $(GNUSTEP_LIBRARY)/Images
|
||||||
|
|
||||||
IMAGE_FILES = \
|
IMAGE_FILES = \
|
||||||
GNUstep_Images_Copyright \
|
GNUstep_Images_Copyright \
|
||||||
|
common_3DArrowUp.tiff \
|
||||||
|
common_3DArrowLeft.tiff \
|
||||||
common_3DArrowDown.tiff \
|
common_3DArrowDown.tiff \
|
||||||
common_ArrowDown.tiff \
|
common_ArrowDown.tiff \
|
||||||
common_ArrowDownH.tiff \
|
common_ArrowDownH.tiff \
|
||||||
|
|
BIN
Images/common_3DArrowLeft.tiff
Normal file
BIN
Images/common_3DArrowLeft.tiff
Normal file
Binary file not shown.
BIN
Images/common_3DArrowUp.tiff
Normal file
BIN
Images/common_3DArrowUp.tiff
Normal file
Binary file not shown.
|
@ -1075,13 +1075,24 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update position, if needed, using the preferredEdge
|
||||||
|
if (edge == NSMaxYEdge)
|
||||||
|
{
|
||||||
|
screenFrame.origin.y += screenRect.size.height;
|
||||||
|
}
|
||||||
|
else if (edge == NSMaxXEdge)
|
||||||
|
{
|
||||||
|
screenFrame.origin.x += screenRect.size.width;
|
||||||
|
}
|
||||||
|
else if (edge == NSMinXEdge)
|
||||||
|
{
|
||||||
|
screenFrame.origin.x -= screenRect.size.width;
|
||||||
|
}
|
||||||
|
|
||||||
// Get the frameRect
|
// Get the frameRect
|
||||||
r = [NSWindow frameRectForContentRect: screenFrame
|
r = [NSWindow frameRectForContentRect: screenFrame
|
||||||
styleMask: [_window styleMask]];
|
styleMask: [_window styleMask]];
|
||||||
|
|
||||||
// Update position,if needed, using the preferredEdge;
|
|
||||||
// TODO
|
|
||||||
|
|
||||||
// Set the window frame
|
// Set the window frame
|
||||||
[_window setFrame: r display: NO];
|
[_window setFrame: r display: NO];
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,10 +37,11 @@
|
||||||
#include "AppKit/NSPopUpButtonCell.h"
|
#include "AppKit/NSPopUpButtonCell.h"
|
||||||
#include "AppKit/NSWindow.h"
|
#include "AppKit/NSWindow.h"
|
||||||
|
|
||||||
/* The image to use in a specific popupbutton is
|
/* The image to use in a specific popupbutton depends on type and
|
||||||
* _pbc_image[_pbcFlags.pullsDown]; that is, _pbc_image[0] if it is a
|
* preferred edge; that is, _pbc_image[0] if it is a
|
||||||
* popup menu, _pbc_image[1] if it is a pulls down list. */
|
* popup menu, _pbc_image[1] if it is a pulls down list pointing down,
|
||||||
static NSImage *_pbc_image[2];
|
* and so on. */
|
||||||
|
static NSImage *_pbc_image[5];
|
||||||
|
|
||||||
@implementation NSPopUpButtonCell
|
@implementation NSPopUpButtonCell
|
||||||
+ (void) initialize
|
+ (void) initialize
|
||||||
|
@ -50,6 +51,9 @@ static NSImage *_pbc_image[2];
|
||||||
[self setVersion: 2];
|
[self setVersion: 2];
|
||||||
ASSIGN(_pbc_image[0], [NSImage imageNamed: @"common_Nibble"]);
|
ASSIGN(_pbc_image[0], [NSImage imageNamed: @"common_Nibble"]);
|
||||||
ASSIGN(_pbc_image[1], [NSImage imageNamed: @"common_3DArrowDown"]);
|
ASSIGN(_pbc_image[1], [NSImage imageNamed: @"common_3DArrowDown"]);
|
||||||
|
ASSIGN(_pbc_image[2], [NSImage imageNamed: @"common_3DArrowRight"]);
|
||||||
|
ASSIGN(_pbc_image[3], [NSImage imageNamed: @"common_3DArrowUp"]);
|
||||||
|
ASSIGN(_pbc_image[4], [NSImage imageNamed: @"common_3DArrowLeft"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,6 +101,8 @@ static NSImage *_pbc_image[2];
|
||||||
|
|
||||||
[self setPullsDown: flag];
|
[self setPullsDown: flag];
|
||||||
_pbcFlags.usesItemFromMenu = YES;
|
_pbcFlags.usesItemFromMenu = YES;
|
||||||
|
[self setPreferredEdge: NSMinYEdge];
|
||||||
|
[self setArrowPosition: NSPopUpArrowAtCenter];
|
||||||
|
|
||||||
if ([stringValue length] > 0)
|
if ([stringValue length] > 0)
|
||||||
{
|
{
|
||||||
|
@ -178,21 +184,13 @@ static NSImage *_pbc_image[2];
|
||||||
NSMenuItem *item = _menuItem;
|
NSMenuItem *item = _menuItem;
|
||||||
|
|
||||||
[self setMenuItem: nil];
|
[self setMenuItem: nil];
|
||||||
_pbcFlags.pullsDown = flag;
|
if (flag && !_pbcFlags.pullsDown
|
||||||
[self setAltersStateOfSelectedItem: !flag];
|
&& _pbcFlags.altersStateOfSelectedItem)
|
||||||
|
{
|
||||||
|
[[self selectedItem] setState: NSOffState];
|
||||||
|
}
|
||||||
|
|
||||||
if (!flag)
|
_pbcFlags.pullsDown = flag;
|
||||||
{
|
|
||||||
// pop up
|
|
||||||
[self setArrowPosition: NSPopUpArrowAtCenter];
|
|
||||||
[self setPreferredEdge: NSMinYEdge];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// pull down
|
|
||||||
[self setArrowPosition: NSPopUpArrowAtBottom];
|
|
||||||
[self setPreferredEdge: NSMaxYEdge];
|
|
||||||
}
|
|
||||||
|
|
||||||
[self setMenuItem: item];
|
[self setMenuItem: item];
|
||||||
}
|
}
|
||||||
|
@ -522,6 +520,42 @@ static NSImage *_pbc_image[2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSImage *) _currentArrowImage
|
||||||
|
{
|
||||||
|
if (_pbcFlags.pullsDown)
|
||||||
|
{
|
||||||
|
if (_pbcFlags.arrowPosition == NSPopUpNoArrow)
|
||||||
|
{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_pbcFlags.preferredEdge == NSMinYEdge)
|
||||||
|
{
|
||||||
|
return _pbc_image[1];
|
||||||
|
}
|
||||||
|
else if (_pbcFlags.preferredEdge == NSMaxXEdge)
|
||||||
|
{
|
||||||
|
return _pbc_image[2];
|
||||||
|
}
|
||||||
|
else if (_pbcFlags.preferredEdge == NSMaxYEdge)
|
||||||
|
{
|
||||||
|
return _pbc_image[3];
|
||||||
|
}
|
||||||
|
else if (_pbcFlags.preferredEdge == NSMinXEdge)
|
||||||
|
{
|
||||||
|
return _pbc_image[4];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return _pbc_image[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return _pbc_image[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void) setImage: (NSImage *)anImage
|
- (void) setImage: (NSImage *)anImage
|
||||||
{
|
{
|
||||||
// Do nothing as the image is determined by the current item
|
// Do nothing as the image is determined by the current item
|
||||||
|
@ -534,19 +568,7 @@ static NSImage *_pbc_image[2];
|
||||||
if (_menuItem == item)
|
if (_menuItem == item)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_pbcFlags.arrowPosition == NSPopUpArrowAtBottom)
|
image = [self _currentArrowImage];
|
||||||
{
|
|
||||||
image = _pbc_image[1];
|
|
||||||
}
|
|
||||||
else if (_pbcFlags.arrowPosition == NSPopUpArrowAtCenter)
|
|
||||||
{
|
|
||||||
image = _pbc_image[0];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// No image for NSPopUpNoArrow
|
|
||||||
image = nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ([_menuItem image] == image)
|
if ([_menuItem image] == image)
|
||||||
{
|
{
|
||||||
|
@ -554,7 +576,7 @@ static NSImage *_pbc_image[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
//[super setMenuItem: item];
|
//[super setMenuItem: item];
|
||||||
ASSIGN (_menuItem, item);
|
ASSIGN(_menuItem, item);
|
||||||
|
|
||||||
if ([_menuItem image] == nil)
|
if ([_menuItem image] == nil)
|
||||||
{
|
{
|
||||||
|
@ -852,7 +874,10 @@ static NSImage *_pbc_image[2];
|
||||||
eventNumber: [theEvent eventNumber]
|
eventNumber: [theEvent eventNumber]
|
||||||
clickCount: [theEvent clickCount]
|
clickCount: [theEvent clickCount]
|
||||||
pressure: [theEvent pressure]];
|
pressure: [theEvent pressure]];
|
||||||
[NSApp sendEvent: e];
|
|
||||||
|
// Send the event directly to the popup window, as it may not be located
|
||||||
|
// at the event position.
|
||||||
|
[mr mouseDown: e];
|
||||||
|
|
||||||
// End of mouse tracking here -- dismiss popup
|
// End of mouse tracking here -- dismiss popup
|
||||||
// No synchronization needed here
|
// No synchronization needed here
|
||||||
|
@ -922,10 +947,16 @@ static NSImage *_pbc_image[2];
|
||||||
NSSize titleSize;
|
NSSize titleSize;
|
||||||
int i, count;
|
int i, count;
|
||||||
NSString *title;
|
NSString *title;
|
||||||
|
NSImage *image;
|
||||||
|
|
||||||
count = [_menu numberOfItems];
|
count = [_menu numberOfItems];
|
||||||
|
|
||||||
imageSize = [_pbc_image[_pbcFlags.pullsDown] size];
|
image = [self _currentArrowImage];
|
||||||
|
if (image)
|
||||||
|
imageSize = [image size];
|
||||||
|
else
|
||||||
|
imageSize = NSZeroSize;
|
||||||
|
|
||||||
s = NSMakeSize(0, imageSize.height);
|
s = NSMakeSize(0, imageSize.height);
|
||||||
|
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
|
@ -1019,6 +1050,9 @@ static NSImage *_pbc_image[2];
|
||||||
NSMenu *menu;
|
NSMenu *menu;
|
||||||
|
|
||||||
self = [super initWithCoder: aDecoder];
|
self = [super initWithCoder: aDecoder];
|
||||||
|
if (!self)
|
||||||
|
return nil;
|
||||||
|
|
||||||
if ([aDecoder allowsKeyedCoding])
|
if ([aDecoder allowsKeyedCoding])
|
||||||
{
|
{
|
||||||
if ([aDecoder containsValueForKey: @"NSAltersState"])
|
if ([aDecoder containsValueForKey: @"NSAltersState"])
|
||||||
|
@ -1100,6 +1134,7 @@ static NSImage *_pbc_image[2];
|
||||||
}
|
}
|
||||||
[self selectItem: selectedItem];
|
[self selectItem: selectedItem];
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue