Author: fredkiefer
Date: Sun Sep 20 23:16:33 2015
New Revision: 39006
URL: http://svn.gna.org/viewcvs/gnustep?rev=39006&view=rev
Log:
* 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
<[email protected]>
Modified:
libs/gui/trunk/ChangeLog
libs/gui/trunk/Source/GSThemeDrawing.m
libs/gui/trunk/Source/NSButtonCell.m
libs/gui/trunk/Source/NSPopUpButtonCell.m
libs/gui/trunk/Source/NSSegmentedCell.m
Modified: libs/gui/trunk/ChangeLog
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/ChangeLog?rev=39006&r1=39005&r2=39006&view=diff
==============================================================================
--- libs/gui/trunk/ChangeLog (original)
+++ libs/gui/trunk/ChangeLog Sun Sep 20 23:16:33 2015
@@ -1,3 +1,15 @@
+2015-09-20 Fred Kiefer <[email protected]>
+
+ * 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 <[email protected]>
+
2015-09-19 Fred Kiefer <[email protected]>
* Headers/AppKit/NSMenu.h,
Modified: libs/gui/trunk/Source/GSThemeDrawing.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/Source/GSThemeDrawing.m?rev=39006&r1=39005&r2=39006&view=diff
==============================================================================
--- libs/gui/trunk/Source/GSThemeDrawing.m (original)
+++ libs/gui/trunk/Source/GSThemeDrawing.m Sun Sep 20 23:16:33 2015
@@ -2999,11 +2999,13 @@
// 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);
}
}
}
Modified: libs/gui/trunk/Source/NSButtonCell.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/Source/NSButtonCell.m?rev=39006&r1=39005&r2=39006&view=diff
==============================================================================
--- libs/gui/trunk/Source/NSButtonCell.m (original)
+++ libs/gui/trunk/Source/NSButtonCell.m Sun Sep 20 23:16:33 2015
@@ -931,6 +931,14 @@
- (void) setBackgroundColor: (NSColor *)color
{
ASSIGN(_backgroundColor, color);
+
+ if (_control_view)
+ {
+ if ([_control_view isKindOfClass: [NSControl class]])
+ {
+ [(NSControl*)_control_view updateCell: self];
+ }
+ }
}
- (GSThemeControlState) themeControlState
Modified: libs/gui/trunk/Source/NSPopUpButtonCell.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/Source/NSPopUpButtonCell.m?rev=39006&r1=39005&r2=39006&view=diff
==============================================================================
--- libs/gui/trunk/Source/NSPopUpButtonCell.m (original)
+++ libs/gui/trunk/Source/NSPopUpButtonCell.m Sun Sep 20 23:16:33 2015
@@ -1243,8 +1243,27 @@
{
/* 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"])
{
Modified: libs/gui/trunk/Source/NSSegmentedCell.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/Source/NSSegmentedCell.m?rev=39006&r1=39005&r2=39006&view=diff
==============================================================================
--- libs/gui/trunk/Source/NSSegmentedCell.m (original)
+++ libs/gui/trunk/Source/NSSegmentedCell.m Sun Sep 20 23:16:33 2015
@@ -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
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs