* Source/GSThemeDrawing.m (-drawTableViewRect:inView:): Use

correct imp type.
        * Source/NSButtonCell.m (-setBackgroundColor:): Update the
        control view.
        * Source/NSSegmentedCell.m (-drawSegment:inFrame:withView:):
        * Draw
        image if available.
        * Source/NSPopUpButtonCell.m (-initWithCoder:): Add work around
        for NSClassSwapper cell replacement.
        Patches based on changes by Josh Freeman
        <pikopixel@twilightedge.com>


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@39006 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2015-09-20 21:16:33 +00:00
parent 1d2c5d5ebd
commit be98a77769
5 changed files with 80 additions and 14 deletions

View file

@ -1,3 +1,15 @@
2015-09-20 Fred Kiefer <FredKiefer@gmx.de>
* Source/GSThemeDrawing.m (-drawTableViewRect:inView:): Use
correct imp type.
* Source/NSButtonCell.m (-setBackgroundColor:): Update the
control view.
* Source/NSSegmentedCell.m (-drawSegment:inFrame:withView:): Draw
image if available.
* Source/NSPopUpButtonCell.m (-initWithCoder:): Add work around
for NSClassSwapper cell replacement.
Patches based on changes by Josh Freeman <pikopixel@twilightedge.com>
2015-09-19 Fred Kiefer <FredKiefer@gmx.de>
* Headers/AppKit/NSMenu.h,

View file

@ -2999,11 +2999,13 @@ typedef enum {
// NSLog(@"drawRect : %d-%d", startingRow, endingRow);
{
SEL sel = @selector(drawRow:clipRect:);
IMP imp = [tableView methodForSelector: sel];
void (*imp)(id, SEL, NSInteger, NSRect);
imp = (void (*)(id, SEL, NSInteger, NSRect))[tableView methodForSelector: sel];
for (i = startingRow; i <= endingRow; i++)
{
(*imp)(tableView, sel, i, aRect);
imp(tableView, sel, i, aRect);
}
}
}

View file

@ -931,6 +931,14 @@ typedef struct _GSButtonCellFlags
- (void) setBackgroundColor: (NSColor *)color
{
ASSIGN(_backgroundColor, color);
if (_control_view)
{
if ([_control_view isKindOfClass: [NSControl class]])
{
[(NSControl*)_control_view updateCell: self];
}
}
}
- (GSThemeControlState) themeControlState

View file

@ -1243,8 +1243,27 @@ static NSImage *_pbc_image[5];
{
/* First decode menu, menu items must be available to set the selection */
menu = [aDecoder decodeObjectForKey: @"NSMenu"];
[self setMenu: nil];
[self setMenu: menu];
if (menu)
{
NSEnumerator *menuItemEnumerator;
NSMenuItem *menuItem;
[self setMenu: nil];
[self setMenu: menu];
// FIXME: This special handling is needed bacause the NSClassSwapper
// might have replaced the cell, but the items still refere to it.
menuItemEnumerator = [[menu itemArray] objectEnumerator];
while ((menuItem = [menuItemEnumerator nextObject]) != nil)
{
if (sel_isEqual([menuItem action], @selector(_popUpItemAction:))
&& ([menuItem target] != self))
{
[menuItem setTarget: self];
}
}
}
if ([aDecoder containsValueForKey: @"NSAltersState"])
{

View file

@ -544,28 +544,28 @@
withView: (NSView *)view
{
id segment = [_items objectAtIndex: seg];
NSString *label = [segment label];
NSSize textSize = [label sizeWithAttributes: [NSDictionary dictionary]];
NSRect textFrame = frame;
CGFloat x_offset = (frame.size.width - textSize.width) / 2;
NSString *label = [self labelForSegment: seg];
NSImage *segmentImage = [self imageForSegment: seg];
GSThemeControlState state = GSThemeNormalState;
BOOL roundedLeft = NO;
BOOL roundedRight = NO;
textFrame.origin.x += x_offset;
textFrame.size.width -= x_offset;
[segment setFrame: frame];
if([segment isSelected])
if ([segment isSelected])
{
state = GSThemeSelectedState;
}
if (seg == 0)
roundedLeft = YES;
{
roundedLeft = YES;
}
if (seg == ([_items count] - 1))
roundedRight = YES;
{
roundedRight = YES;
}
[[GSTheme theme] drawSegmentedControlSegment: self
withFrame: frame
@ -574,7 +574,32 @@
state: state
roundedLeft: roundedLeft
roundedRight: roundedRight];
[self _drawText: [segment label] inFrame: textFrame];
if (label)
{
NSSize textSize = [label sizeWithAttributes: [self _nonAutoreleasedTypingAttributes]];
NSRect textFrame = frame;
CGFloat x_offset = (frame.size.width - textSize.width) / 2;
textFrame.origin.x += x_offset;
textFrame.size.width -= x_offset;
[self _drawText: label inFrame: textFrame];
}
if (segmentImage)
{
NSSize size = [segmentImage size];
NSPoint position;
NSRect destinationRect;
position.x = MAX(NSMidX(frame) - (size.width/2.), 0.);
position.y = MAX(NSMidY(frame) - (size.height/2.), 0.);
destinationRect = NSMakeRect(position.x, position.y, size.width, size.height);
[segmentImage drawInRect: destinationRect
fromRect: NSZeroRect
operation: NSCompositeSourceOver
fraction: 1.0];
}
}
- (void) drawInteriorWithFrame: (NSRect)cellFrame