Re: NSSegmentedControl Display Bug?
Re: NSSegmentedControl Display Bug?
- Subject: Re: NSSegmentedControl Display Bug?
- From: Shaun Wexler <email@hidden>
- Date: Sun, 31 Jul 2005 08:13:32 -0700
On Jul 31, 2005, at 4:11 AM, Ruediger Hanke wrote:
I'm lost here ... basically I want to have a segmented control in
the regular
style in a unified title/toolbar window. Anybody knows how DevonThink
achieves this?
// "It's Not Nice To Fool Mother Nature"... but often necessary:
@interface SKWSegmentedControlWindowProxy : NSProxy
{
id realWindow;
}
- (id)initWithWindow:(id)window;
- (id)window;
- (void)setWindow:(NSWindow *)window;
- (unsigned int)styleMask;
@end
@implementation SKWSegmentedControlWindowProxy
- (id)initWithWindow:(id)window
{
[self setWindow:window];
return self;
}
- (void)dealloc
{
if (realWindow) {
[self setWindow:nil];
}
[super dealloc];
}
- (void)windowWillClose:(NSNotification *)notification
{
if (realWindow) {
[self setWindow:nil];
}
}
- (id)window
{
return realWindow;
}
- (void)setWindow:(NSWindow *)window
{
if (realWindow != window) {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
if ((realWindow = window)) {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(windowWillClose:)
name:NSWindowWillCloseNotification object:window];
}
}
- (unsigned int)styleMask
{
return ([realWindow styleMask] &~ NSTexturedBackgroundWindowMask);
}
- (NSMethodSignature *)methodSignatureForSelector:(SEL)selector
{
if (realWindow) {
return [realWindow methodSignatureForSelector:selector];
} else {
return [NSWindow instanceMethodSignatureForSelector:selector];
}
}
- (void)forwardInvocation:(NSInvocation *)invocation
{
if (realWindow) {
[invocation invokeWithTarget:realWindow];
}
}
@end
@interface SKWSegmentedControl : NSSegmentedControl
{
SKWSegmentedControlWindowProxy *windowProxy;
}
@end
@implementation SKWSegmentedControl
- (NSWindow *)window
{
if (!windowProxy) {
windowProxy = [[SKWSegmentedControlWindowProxy
allocWithZone:NULL] initWithWindow:[super window]];
}
else if (![windowProxy window]) {
return [super window];
}
return (NSWindow *)windowProxy;
}
- (void)viewWillMoveToWindow:(NSWindow *)window
{
[super viewWillMoveToWindow:window];
[windowProxy setWindow:window];
}
- (void)dealloc
{
[windowProxy setWindow:nil];
[windowProxy release];
windowProxy = nil;
[super dealloc];
}
@end
--
Shaun Wexler
MacFOH
http://www.macfoh.com
"If God dropped acid, would he see people?" - Steven Wright
_______________________________________________
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