pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

Objective C pastebin - collaborative debugging tool View Help


Posted by nomothetis on Thu 3 Jul 03:18 (modification of post by nomothetis view diff)
report abuse | View followups from Matt | download | new post

  1. /*
  2.  * This is the implementaiton of the header file that at
  3.  * http://pastebin.com/m27607663.
  4.  */
  5.  
  6. #import "ITToolbarDelegate.h"
  7.  
  8. /*
  9.  * All item identifiers are strings; we define the identfier for the search
  10.  * toolbar item as a static string for convenience.
  11.  */
  12. static NSString *ITToolbarSearchItemIdentifier = @"intelliTrack.toolbar.searchItem";
  13.  
  14. @implementation ITToolbarDelegate
  15.  
  16. - (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar *)toolbar {
  17.     /* The toolbar parameter is ignored in this method, because this
  18.      * delegate is associated with just one toolbar. */
  19.     return [NSArray arrayWithObjects: NSToolbarPrintItemIdentifier,
  20.             NSToolbarShowFontsItemIdentifier,
  21.             NSToolbarShowColorsItemIdentifier,
  22.             NSToolbarSpaceItemIdentifier,
  23.             NSToolbarFlexibleSpaceItemIdentifier,
  24.             NSToolbarSeparatorItemIdentifier,
  25.             NSToolbarCustomizeToolbarItemIdentifier,
  26.             ITToolbarSearchItemIdentifier, nil];// nil is the last item as per API.
  27. }
  28.  
  29. - (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar *)toolbar {
  30.     /* The toolbar parameter is ignored in this method, because this
  31.      * delegate is associated with just one toolbar. */
  32.     return [NSArray arrayWithObjects:NSToolbarFlexibleSpaceItemIdentifier,
  33.             ITToolbarSearchItemIdentifier, nil];// nil is the last item as per API.
  34. }
  35.  
  36. - (NSToolbarItem *)toolbar:(NSToolbar *)toolbar
  37.      itemForItemIdentifier:(NSString *)itemIdentifier
  38.  willBeInsertedIntoToolbar:(BOOL)flag {
  39.     /*
  40.      * This method only needs to implement the logic for returning the
  41.      * item corresponding to the ITToolbarSearchItemIdentifier, because
  42.      * the other identifiers are handled by the corresponding method
  43.      * defined in NSToolbar. Note that the NSToolbar method is called
  44.      * first.
  45.      *
  46.      * This method ignores the <code>flag</code> parameter, as it does
  47.      * not affect what is returned.
  48.      */
  49.     if ([itemIdentifier isEqual: ITToolbarSearchItemIdentifier]) {
  50.         NSToolbarItem *newToolbarItem = [[NSToolbarItem alloc]
  51.                                          initWithItemIdentifier:ITToolbarSearchItemIdentifier];
  52.        
  53.         /* Set the required labeling information. In a production
  54.          * application, this would be externalized. */
  55.         [newToolbarItem setLabel:@"Search"];
  56.         [newToolbarItem setPaletteLabel:@"Search"];
  57.         [newToolbarItem setToolTip:@"Search for Packages"];
  58.        
  59.         /* Now set the view that will represent this item, along with
  60.          * its sizing information. */
  61.         [newToolbarItem setView:searchToolbarItemView];
  62.         CGFloat height = NSHeight([searchToolbarItemView frame]);
  63.         [newToolbarItem setMinSize:NSMakeSize(100, height)];
  64.         [newToolbarItem setMaxSize:NSMakeSize(200, height)];
  65.  
  66.        
  67.         /* No need for autorelease, as we are using Objective-C 2.0,
  68.          * which has garbage collection. */
  69.         return newToolbarItem;
  70.     } else {
  71.         /*
  72.          * If control gets here, there is nothing to return, because
  73.          * the passed item descriptor is not supported.
  74.          */
  75.         return nil;
  76.     }
  77. }
  78.  
  79. @end

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me so that I can delete my post