Re: Swapping toolbars
Re: Swapping toolbars
- Subject: Re: Swapping toolbars
- From: James Housley <email@hidden>
- Date: Mon, 25 Jul 2005 12:26:39 -0400
Mark Alldritt wrote:
Hi,
My application windows have two modes (editing and debugging). A number of
my users have asked to have two toolbars, one for when the window is in
editing mode and another for when its in debugging mode. I realize that
this is poor form from an Aqua UI Guidelines perspective, but I've received
enough requests that I want to do it.
I've tried swapping instances of NSToolbar using NSWindow's setToolbar call,
but that really messes up the window. The toolbar is drawn incorrectly, and
seems, well, broken.
Is there another way I can swap one toolbar item configuration for another?
I am not saying this is good or the best way, but this works for me.
- (void)setupToolbar
{
NSWindow *tmpWindow;
// Create a new toolbar instance, and attach it to our document window
currentToolbar = [[[NSToolbar alloc]
initWithIdentifier:FeedToolbarIdentifier] autorelease];
FeedToolbar = [[[NSToolbar alloc]
initWithIdentifier:FeedToolbarIdentifier] autorelease];
ItemToolbar = [[[NSToolbar alloc]
initWithIdentifier:ItemToolbarIdentifier] autorelease];
ImageToolbar = [[[NSToolbar alloc]
initWithIdentifier:ImageToolbarIdentifier] autorelease];
// Set up toolbar properties: Allow customization, give a default display
mode, and remember state in user defaults
[currentToolbar setAllowsUserCustomization:NO];
[currentToolbar setAutosavesConfiguration:NO];
[currentToolbar setDisplayMode:NSToolbarDisplayModeIconOnly];
[FeedToolbar setAllowsUserCustomization:NO];
[FeedToolbar setAutosavesConfiguration:NO];
[FeedToolbar setDisplayMode:NSToolbarDisplayModeIconOnly];
[ItemToolbar setAllowsUserCustomization:NO];
[ItemToolbar setAutosavesConfiguration:NO];
[ItemToolbar setDisplayMode:NSToolbarDisplayModeIconOnly];
[ImageToolbar setAllowsUserCustomization:NO];
[ImageToolbar setAutosavesConfiguration:NO];
[ImageToolbar setDisplayMode:NSToolbarDisplayModeIconOnly];
// We are the delegate
[currentToolbar setDelegate:self];
[FeedToolbar setDelegate:self];
[ItemToolbar setDelegate:self];
[ImageToolbar setDelegate:self];
// Attach the toolbar to the document window
tabsFeeds_index = 2;
tmpWindow = [[NSWindow alloc] init];
[tmpWindow setToolbar:ImageToolbar];
[ImageToolbar setVisible:YES];
ImageToolbarDictionary = [[NSDictionary alloc]
initWithDictionary:[ImageToolbar configurationDictionary]];
[tmpWindow release];
tabsFeeds_index = 1;
tmpWindow = [[NSWindow alloc] init];
[tmpWindow setToolbar:ItemToolbar];
[ItemToolbar setVisible:YES];
ItemToolbarDictionary = [[NSDictionary alloc]
initWithDictionary:[ItemToolbar configurationDictionary]];
[tmpWindow release];
tabsFeeds_index = 0;
tmpWindow = [[NSWindow alloc] init];
[tmpWindow setToolbar:FeedToolbar];
[FeedToolbar setVisible:YES];
FeedToolbarDictionary = [[NSDictionary alloc]
initWithDictionary:[FeedToolbar configurationDictionary]];
[tmpWindow release];
[currentToolbar setConfigurationFromDictionary:FeedToolbarDictionary];
[documentWindow setToolbar:currentToolbar];
[currentToolbar setVisible:YES];
}
- (void)switchToolbars:(int)tbNumber
{
if (tbNumber == 0)
{
[currentToolbar setConfigurationFromDictionary:FeedToolbarDictionary];
}
else if (tbNumber == 1)
{
[currentToolbar setConfigurationFromDictionary:ItemToolbarDictionary];
}
else if (tbNumber == 2)
{
[currentToolbar setConfigurationFromDictionary:ImageToolbarDictionary];
}
}
--
/"\ ASCII Ribbon Campaign .
\ / - NO HTML/RTF in e-mail .
X - NO Word docs in e-mail .
/ \ -----------------------------------------------------------------
email@hidden http://www.FreeBSD.org The Power to Serve
email@hidden http://www.TheHousleys.net
---------------------------------------------------------------------
Documentation is alot like sex. When it's good, it's very, very good.
And when it's bad, it's still better than nothing.
Attachment:
smime.p7s
Description: S/MIME Cryptographic Signature
_______________________________________________
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