NSSmallControlSize in programatically creating an NSPopUpButtonCell?
NSSmallControlSize in programatically creating an NSPopUpButtonCell?
- Subject: NSSmallControlSize in programatically creating an NSPopUpButtonCell?
- From: "l.m.orchard" <email@hidden>
- Date: Mon, 26 Nov 2001 12:42:30 -0500
So I've got this plugin to an app I'm building which adds a column to an
NSOutlineView owned by the main app. The cell in this column is an
NSPopUpButtonCell, containing values like 0% 10% 20% .. 100%, etc. It's
a progress indicator, giving the outline a to-do list function.
Well, everything works fine up to one point: I'm trying to set this
button cell's control size to NSSmallControlSize. So, the button itself
is small, but the menu items are large and so is the title in the button
itself. The text in the button, then, gets cut off at the bottom. I'd
just use a pop up button placed in a panel in a nib, but I can't figure
out how to load up the nib just to get at the button.
So I'm trying to make it programatically. Is there something I'm
missing? Here's the code I'm using to create and add the NSPopUpButton,
which seems rather hackish to me but works as an initial attempt:
--8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<
--
OutlineWindowController *outlineController = [document
outlineWindowController];
NSOutlineView *outlineView = [outlineController outlineView];
NSPopUpButton *button = [[NSPopUpButton alloc]
initWithFrame:NSMakeRect(0.0, 0.0, 38.0, 25.0) pullsDown:NO];
NSPopUpButtonCell *buttonCell = [button cell];
NSTableColumn *col;
[buttonCell setControlSize:NSSmallControlSize];
[buttonCell addItemsWithTitles:progressItems]; // progressItems is an
array of strings 0%..100%
col = [[NSTableColumn alloc] initWithIdentifier:PROP_PROGRESS];
[col setDataCell:buttonCell];
[col setResizable:NO];
[col setMinWidth:40.0];
[[col headerCell] setStringValue:TITLE_PROGRESS];
[outlineView addTableColumn:col];
// Main app calls back to this plugin class to provide outline view
datasource functions
// for this column
[outlineController addColumnHandler:self forIdentifier:PROP_PROGRESS];
--8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<
--
--
Leslie Michael Orchard <email@hidden>
ICQ: 492905 (home) 11082089 (work)
"...see you space cowboy..."