14#ifndef COCOA_COMBOBOX_MM
15#define COCOA_COMBOBOX_MM
22- (id)initWithFrame:(NSRect)frame {
23 self = [
super initWithFrame:frame];
25 [
self setTarget:self];
26 [
self setAction:@selector(textChanged:)];
39-(NSSize) neededTextSize {
40 if ([
self numberOfItems] > 0) {
41 NSSize maxSize = NSZeroSize;
42 NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:
43 [NSColor blackColor], NSForegroundColorAttributeName,
44 [
self font], NSFontAttributeName,
46 NSArray *objectValues = [
self objectValues];
48 for (NSString *s in objectValues) {
49 NSSize titleSize = [s sizeWithAttributes:attributes];
50 if (maxSize.width < titleSize.width) maxSize.width = titleSize.width;
51 if (maxSize.height < titleSize.height) maxSize.height = titleSize.height;
59-(void) computeMinWidth {
60 NSSize size = [
self neededTextSize];