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> 2007-09-11 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSSplitView.m (-displayRectIgnoringOpacity:inContext:): * Source/NSSplitView.m (-displayRectIgnoringOpacity:inContext:):

View file

@ -392,6 +392,7 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
@end @end
// FIXME: Why does this class exists at all?
@implementation GSToolbarButtonCell @implementation GSToolbarButtonCell
/* Overriden NSButtonCell method to handle cell type in a basic way which avoids /* 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 - (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 // 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 /* We store the values we need to customize the drawing into titleRect and
imageRect. */ imageRect. */
switch (ipos)
titleRect.origin.x = cellFrame.origin.x; {
titleRect.origin.y = cellFrame.origin.y + InsetItemTextY; case NSNoImage:
titleRect.size.width = cellFrame.size.width; titleRect = cellFrame;
titleRect.size.height = titleSize.height; break;
imageRect.origin.x = cellFrame.origin.x; case NSImageOnly:
imageRect.origin.y = cellFrame.origin.y; imageRect = cellFrame;
if ([self imagePosition] != NSImageOnly) break;
imageRect.origin.y += titleRect.size.height;
imageRect.size.width = cellFrame.size.width; default:
imageRect.size.height = cellFrame.size.height; case NSImageBelow:
if ([self imagePosition] != NSImageOnly) titleRect.origin.x = cellFrame.origin.x;
imageRect.size.height -= titleRect.size.height; 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]; [super drawInteriorWithFrame: cellFrame inView: controlView];
} }
@ -1086,16 +1122,16 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
button = [[GSToolbarButton alloc] initWithToolbarItem: self]; button = [[GSToolbarButton alloc] initWithToolbarItem: self];
cell = [button cell]; cell = [button cell];
[button setTitle: @""]; [button setTitle: @""];
[button setEnabled: NO]; [button setEnabled: NO];
[button setBordered: NO]; [button setBordered: NO];
[button setImagePosition: NSImageAbove]; [button setImagePosition: NSImageAbove];
[cell setBezeled: YES]; [cell setBezeled: YES];
[cell setHighlightsBy: [cell setHighlightsBy:
NSChangeGrayCellMask | NSChangeBackgroundCellMask]; NSChangeGrayCellMask | NSChangeBackgroundCellMask];
[cell setFont: [NSFont systemFontOfSize: 11]]; [cell setFont: [NSFont systemFontOfSize: 11]];
/* [NSFont smallSystemFontSize] or better should be /* [NSFont smallSystemFontSize] or better should be
controlContentFontSize. */ controlContentFontSize. */
[_backView release]; [_backView release];
_backView = button; _backView = button;