Made working for a flipped view.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@25478 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2007-09-12 12:54:38 +00:00
parent e1cb2b75ef
commit d8f3c46725
2 changed files with 64 additions and 23 deletions

View file

@ -1,3 +1,8 @@
2007-09-12 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSToolbarItem.m (GSToolbarButtonCell-drawInteriorWithFrame:inView:):
Made working for a flipped view.
2007-09-11 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSSplitView.m (-displayRectIgnoringOpacity:inContext:):

View file

@ -392,6 +392,7 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
@end
// FIXME: Why does this class exists at all?
@implementation GSToolbarButtonCell
/* Overriden NSButtonCell method to handle cell type in a basic way which avoids
@ -413,29 +414,64 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
}
}
// Overriden NSButtonCell method
// Overriden NSButtonCell method to make sure all test is at the same height.
- (void) drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
{
NSSize titleSize = [[self attributedTitle] size];
BOOL flippedView = [controlView isFlipped];
NSCellImagePosition ipos = _cell.image_position;
// We ignore alternateAttributedTitle, it is not needed
NSSize titleSize = [[self attributedTitle] size];
if (flippedView == YES)
{
if (ipos == NSImageAbove)
{
ipos = NSImageBelow;
}
else if (ipos == NSImageBelow)
{
ipos = NSImageAbove;
}
}
/* We store the values we need to customize the drawing into titleRect and
imageRect. */
titleRect.origin.x = cellFrame.origin.x;
titleRect.origin.y = cellFrame.origin.y + InsetItemTextY;
titleRect.size.width = cellFrame.size.width;
titleRect.size.height = titleSize.height;
imageRect.origin.x = cellFrame.origin.x;
imageRect.origin.y = cellFrame.origin.y;
if ([self imagePosition] != NSImageOnly)
imageRect.origin.y += titleRect.size.height;
imageRect.size.width = cellFrame.size.width;
imageRect.size.height = cellFrame.size.height;
if ([self imagePosition] != NSImageOnly)
imageRect.size.height -= titleRect.size.height;
switch (ipos)
{
case NSNoImage:
titleRect = cellFrame;
break;
case NSImageOnly:
imageRect = cellFrame;
break;
default:
case NSImageBelow:
titleRect.origin.x = cellFrame.origin.x;
titleRect.origin.y = NSMaxY(cellFrame) - titleSize.height - InsetItemTextY;
titleRect.size.width = cellFrame.size.width;
titleRect.size.height = titleSize.height;
imageRect.origin.x = cellFrame.origin.x;
imageRect.origin.y = cellFrame.origin.y;
imageRect.size.width = cellFrame.size.width;
imageRect.size.height = cellFrame.size.height - titleRect.size.height;
break;
case NSImageAbove:
titleRect.origin.x = cellFrame.origin.x;
titleRect.origin.y = cellFrame.origin.y + InsetItemTextY;
titleRect.size.width = cellFrame.size.width;
titleRect.size.height = titleSize.height;
imageRect.origin.x = cellFrame.origin.x;
imageRect.origin.y = cellFrame.origin.y + titleRect.size.height;
imageRect.size.width = cellFrame.size.width;
imageRect.size.height = cellFrame.size.height - titleRect.size.height;
break;
}
[super drawInteriorWithFrame: cellFrame inView: controlView];
}
@ -1086,16 +1122,16 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
button = [[GSToolbarButton alloc] initWithToolbarItem: self];
cell = [button cell];
[button setTitle: @""];
[button setEnabled: NO];
[button setTitle: @""];
[button setEnabled: NO];
[button setBordered: NO];
[button setImagePosition: NSImageAbove];
[cell setBezeled: YES];
[cell setBezeled: YES];
[cell setHighlightsBy:
NSChangeGrayCellMask | NSChangeBackgroundCellMask];
NSChangeGrayCellMask | NSChangeBackgroundCellMask];
[cell setFont: [NSFont systemFontOfSize: 11]];
/* [NSFont smallSystemFontSize] or better should be
controlContentFontSize. */
/* [NSFont smallSystemFontSize] or better should be
controlContentFontSize. */
[_backView release];
_backView = button;