Changeset 4084


Ignore:
Timestamp:
Dec 6, 2007, 8:46:58 PM (14 years ago)
Author:
livings124
Message:

fix the toolbar customization sheet

Location:
trunk/macosx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/ButtonGroupToolbarItem.h

    r4083 r4084  
    2727@interface ButtonGroupToolbarItem : NSToolbarItem
    2828{
    29     NSArray * fLabels, * fIdentifiers;
    30    
    31     BOOL fMenuCreated;
     29    NSArray * fIdentifiers;
    3230}
    3331
    34 - (void) setLabels: (NSArray *) labels;
    3532- (void) setIdentifiers: (NSArray *) identifiers;
    3633
     34- (void) createMenu: (NSArray *) labels;
     35
    3736@end
  • trunk/macosx/ButtonGroupToolbarItem.m

    r4083 r4084  
    3333}
    3434
    35 - (void) setLabels: (NSArray *) labels
    36 {
    37     [fLabels release];
    38     fLabels = [labels retain];
    39 }
    40 
    4135- (void) setIdentifiers: (NSArray *) identifiers
    4236{
     
    5549}
    5650
     51- (void) createMenu: (NSArray *) labels
     52{
     53    NSMenuItem * menuItem = [[NSMenuItem alloc] initWithTitle: [self label] action: NULL keyEquivalent: @""];
     54    NSMenu * menu = [[NSMenu alloc] initWithTitle: [self label]];
     55    [menuItem setSubmenu: menu];
     56   
     57    [menu setAutoenablesItems: NO];
     58   
     59    NSMenuItem * addItem;
     60    int i;
     61    for (i = 0; i < [(NSSegmentedControl *)[self view] segmentCount]; i++)
     62    {
     63        addItem = [[NSMenuItem alloc] initWithTitle: [labels objectAtIndex: i] action: [self action] keyEquivalent: @""];
     64        [addItem setTarget: [self target]];
     65        [addItem setTag: i];
     66       
     67        [menu addItem: addItem];
     68        [addItem release];
     69    }
     70   
     71    [menu release];
     72    [self setMenuFormRepresentation: menuItem];
     73    [menuItem release];
     74}
     75
    5776- (NSMenuItem *) menuFormRepresentation
    5877{
    59     NSMenuItem * menuItem;
    60     if (!fMenuCreated)
    61     {
    62         fMenuCreated = YES;
    63        
    64         menuItem = [[[NSMenuItem alloc] initWithTitle: [self label] action: NULL keyEquivalent: @""] autorelease];
    65         NSMenu * menu = [[NSMenu alloc] initWithTitle: [self label]];
    66         [menuItem setSubmenu: menu];
    67        
    68         [menu setAutoenablesItems: NO];
    69        
    70         NSMenuItem * addItem;
    71         int i;
    72         for (i = 0; i < [(NSSegmentedControl *)[self view] segmentCount]; i++)
    73         {
    74             addItem = [[NSMenuItem alloc] initWithTitle: [fLabels objectAtIndex: i] action: [self action] keyEquivalent: @""];
    75             [addItem setTarget: [self target]];
    76             [addItem setTag: i];
    77            
    78             [menu addItem: addItem];
    79             [addItem release];
    80         }
    81        
    82         [menu release];
    83         [self setMenuFormRepresentation: menuItem];
    84     }
    85     else
    86         menuItem = [super menuFormRepresentation];
     78    NSMenuItem * menuItem = [super menuFormRepresentation];
    8779   
    8880    int i;
  • trunk/macosx/Controller.m

    r4083 r4084  
    27192719       
    27202720        [groupItem setIdentifiers: [NSArray arrayWithObjects: TOOLBAR_PAUSE_ALL, TOOLBAR_RESUME_ALL, nil]];
    2721         [groupItem setLabels: [NSArray arrayWithObjects: NSLocalizedString(@"Pause All", "All toolbar item -> label"),
    2722                                         NSLocalizedString(@"Resume All", "All toolbar item -> label"), nil]];
    27232721       
    27242722        [segmentedControl setImage: [NSImage imageNamed: @"PauseAll.png"] forSegment: TOOLBAR_PAUSE_TAG];
     
    27292727        [(NSSegmentedCell *)[segmentedControl cell] setToolTip: NSLocalizedString(@"Resume all transfers",
    27302728                                                        "All toolbar item -> tooltip") forSegment: TOOLBAR_RESUME_TAG];
     2729       
     2730        [groupItem createMenu: [NSArray arrayWithObjects: NSLocalizedString(@"Pause All", "All toolbar item -> label"),
     2731                                        NSLocalizedString(@"Resume All", "All toolbar item -> label"), nil]];
    27312732       
    27322733        [segmentedControl release];
     
    27542755       
    27552756        [groupItem setIdentifiers: [NSArray arrayWithObjects: TOOLBAR_PAUSE_SELECTED, TOOLBAR_RESUME_SELECTED, nil]];
    2756         [groupItem setLabels: [NSArray arrayWithObjects: NSLocalizedString(@"Pause Selected", "Selected toolbar item -> label"),
    2757                                         NSLocalizedString(@"Resume Selected", "Selected toolbar item -> label"), nil]];
    27582757       
    27592758        [segmentedControl setImage: [NSImage imageNamed: @"PauseSelected.png"] forSegment: TOOLBAR_PAUSE_TAG];
     
    27642763        [(NSSegmentedCell *)[segmentedControl cell] setToolTip: NSLocalizedString(@"Resume selected transfers",
    27652764                                                        "Selected toolbar item -> tooltip") forSegment: TOOLBAR_RESUME_TAG];
     2765       
     2766        [groupItem createMenu: [NSArray arrayWithObjects: NSLocalizedString(@"Pause Selected", "Selected toolbar item -> label"),
     2767                                        NSLocalizedString(@"Resume Selected", "Selected toolbar item -> label"), nil]];
    27662768       
    27672769        [segmentedControl release];
Note: See TracChangeset for help on using the changeset viewer.