mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 20:50:48 +00:00
Fixed for drawing with no state image
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@12543 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
d24a925169
commit
6db01c15c7
1 changed files with 25 additions and 11 deletions
|
@ -260,9 +260,12 @@ static NSImage *arrowImageH = nil;
|
||||||
// Calculate the image part of cell frame from NSMenuView
|
// Calculate the image part of cell frame from NSMenuView
|
||||||
cellFrame.origin.x += [_menuView imageAndTitleOffset];
|
cellFrame.origin.x += [_menuView imageAndTitleOffset];
|
||||||
cellFrame.size.width = [_menuView imageAndTitleWidth];
|
cellFrame.size.width = [_menuView imageAndTitleWidth];
|
||||||
if ([_menuItem changesState])
|
/* If the state image has no width we do not add additional padding. */
|
||||||
cellFrame.origin.x += [_menuView stateImageWidth]
|
if ([_menuItem changesState] && _stateImageWidth > 0)
|
||||||
+ 2 * [_menuView horizontalEdgePadding];
|
{
|
||||||
|
cellFrame.origin.x += [_menuView stateImageWidth]
|
||||||
|
+ 2 * [_menuView horizontalEdgePadding];
|
||||||
|
}
|
||||||
|
|
||||||
switch (_cell.image_position)
|
switch (_cell.image_position)
|
||||||
{
|
{
|
||||||
|
@ -319,9 +322,12 @@ static NSImage *arrowImageH = nil;
|
||||||
// Calculate the image part of cell frame from NSMenuView
|
// Calculate the image part of cell frame from NSMenuView
|
||||||
cellFrame.origin.x += [_menuView imageAndTitleOffset];
|
cellFrame.origin.x += [_menuView imageAndTitleOffset];
|
||||||
cellFrame.size.width = [_menuView imageAndTitleWidth];
|
cellFrame.size.width = [_menuView imageAndTitleWidth];
|
||||||
if ([_menuItem changesState])
|
/* If the state image has no width we do not add additional padding. */
|
||||||
cellFrame.origin.x += [_menuView stateImageWidth]
|
if ([_menuItem changesState] && _stateImageWidth > 0)
|
||||||
+ 2 * [_menuView horizontalEdgePadding];
|
{
|
||||||
|
cellFrame.origin.x += [_menuView stateImageWidth]
|
||||||
|
+ 2 * [_menuView horizontalEdgePadding];
|
||||||
|
}
|
||||||
|
|
||||||
switch (_cell.image_position)
|
switch (_cell.image_position)
|
||||||
{
|
{
|
||||||
|
@ -452,8 +458,6 @@ static NSImage *arrowImageH = nil;
|
||||||
NSPoint position;
|
NSPoint position;
|
||||||
NSImage *imageToDisplay;
|
NSImage *imageToDisplay;
|
||||||
|
|
||||||
cellFrame = [self stateImageRectForBounds: cellFrame];
|
|
||||||
|
|
||||||
switch ([_menuItem state])
|
switch ([_menuItem state])
|
||||||
{
|
{
|
||||||
case NSOnState:
|
case NSOnState:
|
||||||
|
@ -470,7 +474,13 @@ static NSImage *arrowImageH = nil;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (imageToDisplay == nil)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
size = [imageToDisplay size];
|
size = [imageToDisplay size];
|
||||||
|
cellFrame = [self stateImageRectForBounds: cellFrame];
|
||||||
position.x = MAX(NSMidX(cellFrame) - (size.width/2.),0.);
|
position.x = MAX(NSMidX(cellFrame) - (size.width/2.),0.);
|
||||||
position.y = MAX(NSMidY(cellFrame) - (size.height/2.),0.);
|
position.y = MAX(NSMidY(cellFrame) - (size.height/2.),0.);
|
||||||
/*
|
/*
|
||||||
|
@ -478,10 +488,14 @@ static NSImage *arrowImageH = nil;
|
||||||
* 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 ([controlView isFlipped])
|
if ([controlView isFlipped])
|
||||||
position.y += size.height;
|
{
|
||||||
|
position.y += size.height;
|
||||||
|
}
|
||||||
|
|
||||||
if (nil != _backgroundColor)
|
if (nil != _backgroundColor)
|
||||||
[imageToDisplay setBackgroundColor: _backgroundColor];
|
{
|
||||||
|
[imageToDisplay setBackgroundColor: _backgroundColor];
|
||||||
|
}
|
||||||
[imageToDisplay compositeToPoint: position operation: NSCompositeSourceOver];
|
[imageToDisplay compositeToPoint: position operation: NSCompositeSourceOver];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue