NSColor extension problems...
NSColor extension problems...
- Subject: NSColor extension problems...
- From: Keith Blount <email@hidden>
- Date: Sat, 16 Oct 2004 11:57:06 -0700 (PDT)
Hello,
For one of my views I want the background colour to be
a darkened version of NSColor's windowBackgroundColor,
just like the background colour of NSBox etc.
Because this isn't supplied as a system colour in
NSColor's methods, I created a category of NSColor,
NSColor (Extensions), with the following method:
+ (NSColor *)darkStripesColor
{
NSImage *image = [[NSImage alloc]
initWithSize:NSMakeSize(1.0,4.0)];
[image lockFocus];
[[NSColor colorWithCalibratedRed:(228.0/255.0)
green:(228.0/255.0) blue:(228.0/255.0) alpha:1.0]
set];
[NSBezierPath fillRect:NSMakeRect(0.0,0.0,1.0,2.0)];
[[NSColor colorWithCalibratedRed:(232.0/255.0)
green:(232.0/255.0) blue:(232.0/255.0) alpha:1.0]
set];
[NSBezierPath fillRect:NSMakeRect(0.0,2.0,1.0,2.0)];
[image unlockFocus];
NSColor *color = [NSColor
colorWithPatternImage:image];
[image release];
return color;
}
This works very nicely - I can just call [NSColor
darkStripesColor] to get the colour I want. However, I
am having some drawing issues in one, and only one,
circumstance, and can't locate the problem. The
circumstance is this: darkStripesColor is set as the
background colour of a scroll view which is the bottom
view within a horizontal split view. If the top view
of the split view is a web view and I pull the
splitter all the way to the bottom to collapse the
scroll view, then resize the window by clicking on the
+ in the corner, and then drag the splitter back up
again, the background colour of the scroll view goes
crazy - lots of erratic black stripes, presumably
because darkStripesColor has not been retained
somewhere...? (Note that -
splitView:canCollapseSubview: is set to YES, so the
view should be retained.) Strangely, if the top view
is anything other than a webview, I don't get these
problems.
Can anybody see any problems with my darkStripesColor
method that might be causing this? I am currently
working around this by subclassing the scroll view and
calling [self setBackgroundColor:[NSColor
darkStripesColor]]; from its drawRect: method. I am
guessing that this is caused by NSSplitView - I have
had to write loads of workarounds just to get my
collapsable split view working as I would expect
already.
Many thanks for any ideas,
Keith
__________________________________
Do you Yahoo!?
Y! Messenger - Communicate in real time. Download now.
http://messenger.yahoo.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden