Re: how to create status bar?
Re: how to create status bar?
- Subject: Re: how to create status bar?
- From: Aram Greenman <email@hidden>
- Date: Sat, 28 Feb 2004 10:27:34 -0800
I think you mean how to have a bar that you can show or hide, right?
This is what I did for a window which has a status bar at the top and a
scroll view which takes up the rest of the window. Create the window
without the status bar in IB, then add a CustomView to your nib file
for the status bar.
@interface Controller : NSObject {
IBOutlet NSView *statusBar; // connect this to the CustomView
IBOutlet NSScrollView *scrollView;
}
- (IBAction)toggleStatusBar:(id)sender;
- (BOOL)statusBarVisible;
- (void)setStatusBarVisible:(BOOL)visible;
@end
@implementation
- (IBAction)toggleStatusBar:(id)sender {
[self setStatusBarVisible:![self statusBarVisible]];
}
- (BOOL)statusBarVisible {
return [statusBar superview] != nil;
}
- (void)setStatusBarVisible:(BOOL)visible {
if (visible == [self statusBarVisible])
return;
NSSize scrollViewSize = [scrollView frame].size,
statusBarSize = [statusBar frame].size;
if (visible) {
scrollViewSize.height -= statusBarSize.height;
[scrollView setFrameSize:scrollViewSize];
[statusBar setFrameSize:NSMakeSize(scrollViewSize.width,
statusBarSize.height)];
[statusBar setFrameOrigin:NSMakePoint(0,
scrollViewSize.height)];
[[[scrollView window] contentView] addSubview:statusBar];
}
else {
scrollViewSize.height += statusBarSize.height;
[scrollView setFrameSize:scrollViewSize];
[statusBar removeFromSuperview];
}
}
@end
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.