mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 10:21:00 +00:00
* 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:
parent
2650aab0d2
commit
fda2efe727
5 changed files with 80 additions and 14 deletions
12
ChangeLog
12
ChangeLog
|
@ -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>
|
2015-09-19 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Headers/AppKit/NSMenu.h,
|
* Headers/AppKit/NSMenu.h,
|
||||||
|
|
|
@ -2999,11 +2999,13 @@ typedef enum {
|
||||||
// NSLog(@"drawRect : %d-%d", startingRow, endingRow);
|
// NSLog(@"drawRect : %d-%d", startingRow, endingRow);
|
||||||
{
|
{
|
||||||
SEL sel = @selector(drawRow:clipRect:);
|
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++)
|
for (i = startingRow; i <= endingRow; i++)
|
||||||
{
|
{
|
||||||
(*imp)(tableView, sel, i, aRect);
|
imp(tableView, sel, i, aRect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -931,6 +931,14 @@ typedef struct _GSButtonCellFlags
|
||||||
- (void) setBackgroundColor: (NSColor *)color
|
- (void) setBackgroundColor: (NSColor *)color
|
||||||
{
|
{
|
||||||
ASSIGN(_backgroundColor, color);
|
ASSIGN(_backgroundColor, color);
|
||||||
|
|
||||||
|
if (_control_view)
|
||||||
|
{
|
||||||
|
if ([_control_view isKindOfClass: [NSControl class]])
|
||||||
|
{
|
||||||
|
[(NSControl*)_control_view updateCell: self];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (GSThemeControlState) themeControlState
|
- (GSThemeControlState) themeControlState
|
||||||
|
|
|
@ -1243,8 +1243,27 @@ static NSImage *_pbc_image[5];
|
||||||
{
|
{
|
||||||
/* First decode menu, menu items must be available to set the selection */
|
/* First decode menu, menu items must be available to set the selection */
|
||||||
menu = [aDecoder decodeObjectForKey: @"NSMenu"];
|
menu = [aDecoder decodeObjectForKey: @"NSMenu"];
|
||||||
[self setMenu: nil];
|
if (menu)
|
||||||
[self setMenu: 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"])
|
if ([aDecoder containsValueForKey: @"NSAltersState"])
|
||||||
{
|
{
|
||||||
|
|
|
@ -544,28 +544,28 @@
|
||||||
withView: (NSView *)view
|
withView: (NSView *)view
|
||||||
{
|
{
|
||||||
id segment = [_items objectAtIndex: seg];
|
id segment = [_items objectAtIndex: seg];
|
||||||
NSString *label = [segment label];
|
NSString *label = [self labelForSegment: seg];
|
||||||
NSSize textSize = [label sizeWithAttributes: [NSDictionary dictionary]];
|
NSImage *segmentImage = [self imageForSegment: seg];
|
||||||
NSRect textFrame = frame;
|
|
||||||
CGFloat x_offset = (frame.size.width - textSize.width) / 2;
|
|
||||||
GSThemeControlState state = GSThemeNormalState;
|
GSThemeControlState state = GSThemeNormalState;
|
||||||
BOOL roundedLeft = NO;
|
BOOL roundedLeft = NO;
|
||||||
BOOL roundedRight = NO;
|
BOOL roundedRight = NO;
|
||||||
|
|
||||||
textFrame.origin.x += x_offset;
|
|
||||||
textFrame.size.width -= x_offset;
|
|
||||||
[segment setFrame: frame];
|
[segment setFrame: frame];
|
||||||
|
|
||||||
if([segment isSelected])
|
if ([segment isSelected])
|
||||||
{
|
{
|
||||||
state = GSThemeSelectedState;
|
state = GSThemeSelectedState;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (seg == 0)
|
if (seg == 0)
|
||||||
roundedLeft = YES;
|
{
|
||||||
|
roundedLeft = YES;
|
||||||
|
}
|
||||||
|
|
||||||
if (seg == ([_items count] - 1))
|
if (seg == ([_items count] - 1))
|
||||||
roundedRight = YES;
|
{
|
||||||
|
roundedRight = YES;
|
||||||
|
}
|
||||||
|
|
||||||
[[GSTheme theme] drawSegmentedControlSegment: self
|
[[GSTheme theme] drawSegmentedControlSegment: self
|
||||||
withFrame: frame
|
withFrame: frame
|
||||||
|
@ -574,7 +574,32 @@
|
||||||
state: state
|
state: state
|
||||||
roundedLeft: roundedLeft
|
roundedLeft: roundedLeft
|
||||||
roundedRight: roundedRight];
|
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
|
- (void) drawInteriorWithFrame: (NSRect)cellFrame
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue