diff --git a/ChangeLog b/ChangeLog index d3c383b78..d05e554dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +1999-06-18 Michael Hanni + + * Images/common_Nibble.tiff: new image for NSPopUpButton. + * Source/NSPopUpButton.m: more changes. still using a subclass of + NSMenuMatrix but had to hack new methods in to make selected_item + working in the Matrix. + - drawRect: draws the correct item. + - synchronizeTitleAndSelectedItem: now informs our + NSPopUpButtonMatrix which one of its cells is "selected", i.e. on top. + * Source/NSPopUpButtonCell.m: added new file. empty class, used in + the backend currently. + 1999-06-17 Michael Hanni * Source/NSPopUpButton.m: half way implemented. Most still in diff --git a/Headers/gnustep/gui/NSPopUpButton.h b/Headers/gnustep/gui/NSPopUpButton.h index 2c9d5c8a0..f70e8a9be 100644 --- a/Headers/gnustep/gui/NSPopUpButton.h +++ b/Headers/gnustep/gui/NSPopUpButton.h @@ -42,8 +42,10 @@ @interface NSPopUpButtonMatrix : NSMenuMatrix { + int selected_cell; } - (id) initWithFrame: (NSRect)rect; +- (void) setIndexOfSelectedItem:(int)itemNum; @end @interface NSPopUpButton : NSButton diff --git a/Headers/gnustep/gui/NSPopUpButtonCell.h b/Headers/gnustep/gui/NSPopUpButtonCell.h new file mode 100644 index 000000000..6bac38d0f --- /dev/null +++ b/Headers/gnustep/gui/NSPopUpButtonCell.h @@ -0,0 +1,6 @@ +#include + +@interface NSPopUpButtonCell : NSMenuItem +{ +} +@end diff --git a/Images/GNUmakefile b/Images/GNUmakefile index 7c054bee9..0d7e0c14a 100644 --- a/Images/GNUmakefile +++ b/Images/GNUmakefile @@ -58,6 +58,7 @@ common_SwitchOff.tiff \ common_SliderHoriz.tiff \ common_SliderVert.tiff \ common_Tile.tiff \ +common_Nibble.tiff \ common_Dimple.tiff \ common_ret.tiff \ common_WMClose.tiff \ diff --git a/Images/common_Nibble.tiff b/Images/common_Nibble.tiff new file mode 100644 index 000000000..e7beca107 Binary files /dev/null and b/Images/common_Nibble.tiff differ diff --git a/Source/GNUmakefile b/Source/GNUmakefile index a453469c7..13125362a 100644 --- a/Source/GNUmakefile +++ b/Source/GNUmakefile @@ -89,6 +89,7 @@ NSPrintInfo.m \ NSPrintOperation.m \ NSPrintPanel.m \ NSPopUpButton.m \ +NSPopUpButtonCell.m \ NSResponder.m \ NSSavePanel.m \ NSScreen.m \ diff --git a/Source/NSPopUpButton.m b/Source/NSPopUpButton.m index f33318cd2..91c18126b 100644 --- a/Source/NSPopUpButton.m +++ b/Source/NSPopUpButton.m @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -38,6 +39,8 @@ - (id) initWithFrame: (NSRect)rect { [super initWithFrame: rect]; + + selected_cell = 0; cellSize = NSMakeSize (rect.size.width, rect.size.height); return self; @@ -47,26 +50,34 @@ { } -/* This is here so we can overide the use of NSMenuItem with -NSPopUpButtonCell once that cellClass is finished. - - (id )insertItemWithTitle: (NSString*)aString action: (SEL)aSelector keyEquivalent: (NSString*)charCode atIndex: (unsigned int)index { - id menuCell = [[[NSPopUpButton cellClass] new] autorelease]; + id menuCell = [[NSPopUpButtonCell new] autorelease]; + + NSLog(@"insertItem.\n"); - [menuCell setFont: menuFont]; + [menuCell setFont:[NSFont systemFontOfSize:12]]; [menuCell setTitle: aString]; - [menuCell setAction: aSelector]; - [menuCell setKeyEquivalent: charCode]; +// [menuCell setAction: aSelector]; +// [menuCell setKeyEquivalent: charCode]; [cells insertObject: menuCell atIndex: index]; return menuCell; } -*/ + +- (void) setIndexOfSelectedItem:(int)itemNum +{ + selected_cell = itemNum; +} + +- (NSString *)titleOfSelectedItem +{ + return [[cells objectAtIndex:selected_cell] title]; +} @end // @@ -107,7 +118,7 @@ NSPopUpButtonCell once that cellClass is finished. list_items = [[NSPopUpButtonMatrix alloc] initWithFrame:frameRect]; is_up = NO; pulls_down = flag; - selected_item = 0; + selected_item = 2; return self; } @@ -317,6 +328,10 @@ NSPopUpButtonCell once that cellClass is finished. - (void)synchronizeTitleAndSelectedItem { + if (!pulls_down) + [list_items setIndexOfSelectedItem:selected_item]; + else + [list_items setIndexOfSelectedItem:0]; } // @@ -363,19 +378,14 @@ NSPopUpButtonCell once that cellClass is finished. // - (void)drawRect:(NSRect)rect { - id aCell; + id aCell; - aCell = [[list_items itemArray] objectAtIndex:selected_item]; + if (!pulls_down) + aCell = [[list_items itemArray] objectAtIndex:selected_item]; + else + aCell = [[list_items itemArray] objectAtIndex:0]; - [aCell drawWithFrame:rect inView: self]; - - rect.origin.x = rect.size.width - 14; - rect.origin.y = rect.size.height/2 - 3; - - if (pulls_down == NO) - NSDrawPopupNibble(NSMakePoint(rect.origin.x, rect.origin.y)); - else - NSDrawDownArrow(NSMakePoint(rect.origin.x, rect.origin.y)); + [aCell drawWithFrame:rect inView:self]; } // diff --git a/Source/NSPopUpButtonCell.m b/Source/NSPopUpButtonCell.m new file mode 100644 index 000000000..f92b49956 --- /dev/null +++ b/Source/NSPopUpButtonCell.m @@ -0,0 +1,12 @@ +#include +#include + +@implementation NSPopUpButtonCell ++ (void) initialize +{ + if (self == [NSPopUpButtonCell class]) + [self setVersion: 1]; +} + + +@end diff --git a/Tools/Functions.m b/Tools/Functions.m index 49f5a521c..0f6d1d178 100644 --- a/Tools/Functions.m +++ b/Tools/Functions.m @@ -55,10 +55,6 @@ void NSDrawGrayBezel(NSRect aRect, NSRect clipRect) {} void NSDrawGroove(NSRect aRect, NSRect clipRect) {} -void NSDrawPopupNibble(NSPoint aPoint) -{} -void NSDrawDownArrow(NSPoint aPoint) -{} void PSlineto(float x, float y) {} void PSmoveto(float x, float y)