minor fixups

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@28843 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2009-10-19 07:44:22 +00:00
parent f1fc5dd78a
commit c8916fd438
4 changed files with 76 additions and 47 deletions

View file

@ -1,3 +1,10 @@
2009-10-19 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSThemeTools.m: Fix last changes to compile again (variable
declarations not at startof block only work on some compilers).
* Source/NSApplication.m: Fixup to show suppressed icon when app is
deactivated.
2009-10-19 Nicolas Roard <nicolas@roard.com> 2009-10-19 Nicolas Roard <nicolas@roard.com>
* Source/GSTheme.m: * Source/GSTheme.m:
* Source/GSThemeTools.m: * Source/GSThemeTools.m:

View file

@ -868,7 +868,8 @@ typedef struct {
{ {
if ([[info objectForKey: @"NinePatch"] boolValue]) if ([[info objectForKey: @"NinePatch"] boolValue])
{ {
tiles = [[GSDrawTiles alloc] initWithNinePatchImage: image]; tiles = [[GSDrawTiles alloc]
initWithNinePatchImage: image];
[tiles setFillStyle: GSThemeFillStyleScaleAll]; [tiles setFillStyle: GSThemeFillStyleScaleAll];
} }
else else

View file

@ -127,8 +127,7 @@
// These names are role names not the actual colours // These names are role names not the actual colours
NSColor *black = [NSColor controlDarkShadowColor]; NSColor *black = [NSColor controlDarkShadowColor];
NSColor *dark = [NSColor controlShadowColor]; NSColor *dark = [NSColor controlShadowColor];
NSColor *colors[] = {dark, dark, dark, dark, NSColor *colors[] = {dark, dark, dark, dark, black,black};
black,black};
if ([[NSView focusView] isFlipped] == YES) if ([[NSView focusView] isFlipped] == YES)
{ {
@ -498,6 +497,7 @@
unsigned repetitions; unsigned repetitions;
float remainder; float remainder;
unsigned count; unsigned count;
NSPoint p;
float y; float y;
if (rect.size.width <= 0.0) if (rect.size.width <= 0.0)
@ -533,16 +533,13 @@
for (count = 0; count < repetitions; count++) for (count = 0; count < repetitions; count++)
{ {
NSPoint p = NSMakePoint (rect.origin.x + count * source.size.width, y); p = NSMakePoint (rect.origin.x + count * source.size.width, y);
[image compositeToPoint: p [image compositeToPoint: p
fromRect: source fromRect: source
operation: NSCompositeSourceOver]; operation: NSCompositeSourceOver];
} }
if (remainder > 0) if (remainder > 0)
{ {
NSPoint p;
p = NSMakePoint (rect.origin.x + repetitions * source.size.width, y); p = NSMakePoint (rect.origin.x + repetitions * source.size.width, y);
source.size.width = remainder; source.size.width = remainder;
[image compositeToPoint: p [image compositeToPoint: p
@ -860,9 +857,13 @@ withRepeatedImage: (NSImage*)image
- (NSImage*) extractImageFrom: (NSImage*) image withRect: (NSRect) rect - (NSImage*) extractImageFrom: (NSImage*) image withRect: (NSRect) rect
{ {
NSImage* img = [[NSImage alloc] initWithSize: rect.size]; NSImage *img = [[NSImage alloc] initWithSize: rect.size];
[img lockFocus]; [img lockFocus];
[image drawAtPoint: NSMakePoint(0,0) fromRect: rect operation: NSCompositeSourceOver fraction: 1.0]; [image drawAtPoint: NSMakePoint(0, 0)
fromRect: rect
operation: NSCompositeSourceOver
fraction: 1.0];
[img unlockFocus]; [img unlockFocus];
[img TIFFRepresentation]; // creates a proper NSBitmapImageRep [img TIFFRepresentation]; // creates a proper NSBitmapImageRep
return [img autorelease]; return [img autorelease];
@ -882,7 +883,8 @@ withRepeatedImage: (NSImage*)image
} }
else else
{ {
images[i] = [[self extractImageFrom: image withRect: rects[i]] retain]; images[i]
= [[self extractImageFrom: image withRect: rects[i]] retain];
} }
} }
} }
@ -1038,14 +1040,13 @@ withRepeatedImage: (NSImage*)image
NSSize bms = rects[TileBM].size; NSSize bms = rects[TileBM].size;
NSSize crs = rects[TileCR].size; NSSize crs = rects[TileCR].size;
NSSize tms = rects[TileTM].size; NSSize tms = rects[TileTM].size;
NSRect r = rects[TileCM];
NSRect inFill = NSMakeRect ( NSRect inFill = NSMakeRect (
rect.origin.x + cls.width, rect.origin.x + cls.width,
rect.origin.y + bms.height, rect.origin.y + bms.height,
rect.size.width - cls.width - crs.width, rect.size.width - cls.width - crs.width,
rect.size.height - bms.height - tms.height); rect.size.height - bms.height - tms.height);
NSRect r = rects[TileCM];
[self repeatFillRect: rect]; [self repeatFillRect: rect];
[self drawCornersRect: rect]; [self drawCornersRect: rect];
@ -1140,13 +1141,15 @@ withRepeatedImage: (NSImage*)image
- (NSRect) scaleAllStyleFillRect: (NSRect)rect - (NSRect) scaleAllStyleFillRect: (NSRect)rect
{ {
BOOL flipped = [[GSCurrentContext() focusView] isFlipped]; BOOL flipped = [[GSCurrentContext() focusView] isFlipped];
NSSize cls = rects[TileCL].size; NSSize cls = rects[TileCL].size;
NSSize bms = rects[TileBM].size; NSSize bms = rects[TileBM].size;
NSSize crs = rects[TileCR].size; NSSize crs = rects[TileCR].size;
NSSize tms = rects[TileTM].size; NSSize tms = rects[TileTM].size;
NSImage *img;
NSRect imgRect;
NSRect inFill;
NSRect inFill = NSMakeRect ( inFill = NSMakeRect (
rect.origin.x + cls.width, rect.origin.x + cls.width,
rect.origin.y + bms.height, rect.origin.y + bms.height,
rect.size.width - cls.width - crs.width, rect.size.width - cls.width - crs.width,
@ -1157,15 +1160,18 @@ withRepeatedImage: (NSImage*)image
// Draw center scaled // Draw center scaled
NSImage* img = images[TileCM]; img = images[TileCM];
NSRect imgRect = NSMakeRect(0, 0, imgRect = NSMakeRect(0, 0,
rect.size.width - cls.width - crs.width, rect.size.width - cls.width - crs.width,
rect.size.height - tms.height - bms.height); rect.size.height - tms.height - bms.height);
if (imgRect.size.width > 0 && imgRect.size.height > 0) if (imgRect.size.width > 0 && imgRect.size.height > 0)
{ {
NSPoint p;
[img setScalesWhenResized: YES]; [img setScalesWhenResized: YES];
[img setSize: imgRect.size]; [img setSize: imgRect.size];
NSPoint p = NSMakePoint(rect.origin.x + cls.width, p = NSMakePoint(rect.origin.x + cls.width,
rect.origin.y + bms.height); rect.origin.y + bms.height);
if (flipped) if (flipped)
{ {
@ -1344,6 +1350,7 @@ withRepeatedImage: (NSImage*)image
if (rect.size.width > tls.width + trs.width && tms.height > 0) if (rect.size.width > tls.width + trs.width && tms.height > 0)
{ {
float y = rect.origin.y + rect.size.height - tms.height; float y = rect.origin.y + rect.size.height - tms.height;
if (flipped) if (flipped)
{ {
y = rect.origin.y; y = rect.origin.y;
@ -1362,6 +1369,7 @@ withRepeatedImage: (NSImage*)image
if (rect.size.width > bls.width + brs.width && bms.height > 0) if (rect.size.width > bls.width + brs.width && bms.height > 0)
{ {
float y = rect.origin.y; float y = rect.origin.y;
if (flipped) if (flipped)
{ {
y = rect.origin.y + rect.size.height - bms.height; y = rect.origin.y + rect.size.height - bms.height;
@ -1407,6 +1415,9 @@ withRepeatedImage: (NSImage*)image
- (void) scaleFillRect: (NSRect)rect - (void) scaleFillRect: (NSRect)rect
{ {
BOOL flipped = [[GSCurrentContext() focusView] isFlipped]; BOOL flipped = [[GSCurrentContext() focusView] isFlipped];
NSImage *img;
NSRect imgRect;
NSPoint p;
NSSize tls = rects[TileTL].size; NSSize tls = rects[TileTL].size;
NSSize tms = rects[TileTM].size; NSSize tms = rects[TileTM].size;
@ -1419,13 +1430,14 @@ withRepeatedImage: (NSImage*)image
// Draw Top-Middle image scaled // Draw Top-Middle image scaled
NSImage* img = images[TileTM]; img = images[TileTM];
NSRect imgRect = NSMakeRect(0, 0, rect.size.width - tls.width - trs.width + 2, tms.height); imgRect = NSMakeRect(0, 0,
rect.size.width - tls.width - trs.width + 2, tms.height);
if (imgRect.size.width > 0 && imgRect.size.height > 0) if (imgRect.size.width > 0 && imgRect.size.height > 0)
{ {
[img setScalesWhenResized: YES]; [img setScalesWhenResized: YES];
[img setSize: imgRect.size]; [img setSize: imgRect.size];
NSPoint p = NSMakePoint(rect.origin.x + tls.width, p = NSMakePoint(rect.origin.x + tls.width,
rect.origin.y + rect.size.height - tms.height); rect.origin.y + rect.size.height - tms.height);
if (flipped) if (flipped)
{ {
@ -1439,12 +1451,13 @@ withRepeatedImage: (NSImage*)image
// Draw Bottom-Middle image scaled // Draw Bottom-Middle image scaled
img = images[TileBM]; img = images[TileBM];
imgRect = NSMakeRect(0, 0, rect.size.width - bls.width - brs.width + 2, bms.height); imgRect = NSMakeRect(0, 0,
rect.size.width - bls.width - brs.width + 2, bms.height);
if (imgRect.size.width > 0 && imgRect.size.height > 0) if (imgRect.size.width > 0 && imgRect.size.height > 0)
{ {
[img setScalesWhenResized: YES]; [img setScalesWhenResized: YES];
[img setSize: imgRect.size]; [img setSize: imgRect.size];
NSPoint p = NSMakePoint(rect.origin.x + bls.width, rect.origin.y); p = NSMakePoint(rect.origin.x + bls.width, rect.origin.y);
if (flipped) if (flipped)
{ {
p.y = rect.origin.y + rect.size.height; p.y = rect.origin.y + rect.size.height;
@ -1457,12 +1470,13 @@ withRepeatedImage: (NSImage*)image
// Draw Center-Left image scaled // Draw Center-Left image scaled
img = images[TileCL]; img = images[TileCL];
imgRect = NSMakeRect(0, 0, cls.width, rect.size.height - tls.height - bls.height + 2); imgRect = NSMakeRect(0, 0,
cls.width, rect.size.height - tls.height - bls.height + 2);
if (imgRect.size.width > 0 && imgRect.size.height > 0) if (imgRect.size.width > 0 && imgRect.size.height > 0)
{ {
[img setScalesWhenResized: YES]; [img setScalesWhenResized: YES];
[img setSize: imgRect.size]; [img setSize: imgRect.size];
NSPoint p = NSMakePoint(rect.origin.x, rect.origin.y + bls.height); p = NSMakePoint(rect.origin.x, rect.origin.y + bls.height);
if (flipped) if (flipped)
{ {
p.y = rect.origin.y + rect.size.height - bls.height; p.y = rect.origin.y + rect.size.height - bls.height;
@ -1475,12 +1489,14 @@ withRepeatedImage: (NSImage*)image
// Draw Center-Right image scaled // Draw Center-Right image scaled
img = images[TileCR]; img = images[TileCR];
imgRect = NSMakeRect(0, 0, crs.width + 1, rect.size.height - trs.height - brs.height + 2); imgRect = NSMakeRect(0, 0,
crs.width + 1, rect.size.height - trs.height - brs.height + 2);
if (imgRect.size.width > 0 && imgRect.size.height > 0) if (imgRect.size.width > 0 && imgRect.size.height > 0)
{ {
[img setScalesWhenResized: YES]; [img setScalesWhenResized: YES];
[img setSize: imgRect.size]; [img setSize: imgRect.size];
NSPoint p = NSMakePoint(rect.origin.x + rect.size.width - crs.width, rect.origin.y + brs.height); p = NSMakePoint(rect.origin.x + rect.size.width - crs.width,
rect.origin.y + brs.height);
if (flipped) if (flipped)
{ {
p.y = rect.origin.y + rect.size.height - brs.height; p.y = rect.origin.y + rect.size.height - brs.height;
@ -1489,7 +1505,6 @@ withRepeatedImage: (NSImage*)image
fromRect: imgRect fromRect: imgRect
operation: NSCompositeSourceOver]; operation: NSCompositeSourceOver];
} }
} }
@ -1500,6 +1515,7 @@ withRepeatedImage: (NSImage*)image
NSSize tls = rects[TileTL].size; NSSize tls = rects[TileTL].size;
NSSize trs = rects[TileTR].size; NSSize trs = rects[TileTR].size;
NSSize brs = rects[TileBR].size; NSSize brs = rects[TileBR].size;
NSRect r;
NSPoint p; NSPoint p;
p = NSMakePoint (rect.origin.x, p = NSMakePoint (rect.origin.x,
@ -1508,8 +1524,9 @@ withRepeatedImage: (NSImage*)image
{ {
p.y = rect.origin.y + tls.height; p.y = rect.origin.y + tls.height;
} }
r = NSMakeRect(0, 0, rects[TileTL].size.width, rects[TileTL].size.height);
[images[TileTL] compositeToPoint: p [images[TileTL] compositeToPoint: p
fromRect: NSMakeRect(0, 0, rects[TileTL].size.width, rects[TileTL].size.height) fromRect: r
operation: NSCompositeSourceOver]; operation: NSCompositeSourceOver];
p = NSMakePoint(rect.origin.x + rect.size.width - trs.width + 1, p = NSMakePoint(rect.origin.x + rect.size.width - trs.width + 1,
@ -1518,8 +1535,9 @@ withRepeatedImage: (NSImage*)image
{ {
p.y = rect.origin.y + tls.height; p.y = rect.origin.y + tls.height;
} }
r = NSMakeRect(0, 0, rects[TileTR].size.width, rects[TileTR].size.height);
[images[TileTR] compositeToPoint: p [images[TileTR] compositeToPoint: p
fromRect: NSMakeRect(0, 0, rects[TileTR].size.width, rects[TileTR].size.height) fromRect: r
operation: NSCompositeSourceOver]; operation: NSCompositeSourceOver];
p = NSMakePoint(rect.origin.x, rect.origin.y); p = NSMakePoint(rect.origin.x, rect.origin.y);
@ -1527,17 +1545,20 @@ withRepeatedImage: (NSImage*)image
{ {
p.y = rect.origin.y + rect.size.height; p.y = rect.origin.y + rect.size.height;
} }
r = NSMakeRect(0, 0, rects[TileBL].size.width, rects[TileBL].size.height);
[images[TileBL] compositeToPoint: p [images[TileBL] compositeToPoint: p
fromRect: NSMakeRect(0, 0, rects[TileBL].size.width, rects[TileBL].size.height) fromRect: r
operation: NSCompositeSourceOver]; operation: NSCompositeSourceOver];
p = NSMakePoint(rect.origin.x + rect.size.width - brs.width + 1, rect.origin.y); p = NSMakePoint(rect.origin.x + rect.size.width - brs.width + 1,
rect.origin.y);
if (flipped) if (flipped)
{ {
p.y = rect.origin.y + rect.size.height; p.y = rect.origin.y + rect.size.height;
} }
r = NSMakeRect(0, 0, rects[TileBR].size.width, rects[TileBR].size.height);
[images[TileBR] compositeToPoint: p [images[TileBR] compositeToPoint: p
fromRect: NSMakeRect(0, 0, rects[TileBR].size.width, rects[TileBR].size.height) fromRect: r
operation: NSCompositeSourceOver]; operation: NSCompositeSourceOver];
} }

View file

@ -579,7 +579,8 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
/* We need give input focus to some window otherwise we'll /* We need give input focus to some window otherwise we'll
never get keyboard events. FIXME: doesn't work. */ never get keyboard events. FIXME: doesn't work. */
NSWindow *menu_window= [[NSApp mainMenu] window]; NSWindow *menu_window= [[NSApp mainMenu] window];
NSDebugLLog(@"Focus", @"No key on activation - make menu key"); NSDebugLLog(@"Focus",
@"No key on activation - make menu key");
[GSServerForWindow(menu_window) setinputfocus: [GSServerForWindow(menu_window) setinputfocus:
[menu_window windowNumber]]; [menu_window windowNumber]];
} }
@ -587,7 +588,6 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
RELEASE(windows); RELEASE(windows);
} }
[NSApp unhide: self]; // or activate or do nothing. [NSApp unhide: self]; // or activate or do nothing.
} }
else else