Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSSegmentedControl Display Bug?



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: http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: NSSegmentedControl Display Bug? (From: Ruediger Hanke <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.