From 5e552d509110b73732398860a4086bb5e97f1824 Mon Sep 17 00:00:00 2001 From: Michael Silva Date: Sun, 18 Jul 1999 03:53:42 +0000 Subject: [PATCH] Fixes git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4603 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 22 ++ Headers/gnustep/gui/NSMenuView.h | 11 + Headers/gnustep/gui/NSPopUpButton.h | 35 +--- Source/NSMenu.m | 14 +- Source/NSMenuItemCell.m | 2 + Source/NSMenuView.m | 105 +++++++--- Source/NSPopUpButton.m | 313 ++++------------------------ Source/NSPopUpButtonCell.m | 61 +++++- Source/NSText.m | 29 +-- 9 files changed, 233 insertions(+), 359 deletions(-) diff --git a/ChangeLog b/ChangeLog index dc4d3ec6c..1e010a657 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +1999-07-17 Michael Hanni + + * Headers/gnustep/gui/NSMenuView.h: added new private interface. + * Headers/gnustep/gui/NSPopUpButton.h: removed NSPopUpButtonMatrix + and tidied some ivars. + * Source/NSMenu.m: fixed a few problems. + * Source/NSMenuItemCell.m: likewise. + * Source/NSMenuView.m: added functionality (privately) so this + class can be used to draw NSPopUpButton. Also made sizeToFit code + only size the view, not the window. + * Source/NSPopUpButton.m: removed NSPopUpButtonMatrix. Rewrote to + use NSMenuView. + * Source/NSPopUpButtonCell.m: rewrote portions to handle new + system of NSMenuView. + +1999-07-16 Michael Hanni + + * Source/NSText.m: add a patch to NSText from Daniel to do some + pasteboard related stuff. Also added a patch from Peter Rasmussen + that addressed my hackish NSClipView scrolling code. Still a hack, + but won't kill NSText if not used in conjunction with a ClipView. + 1999-07-15 Michael Hanni * Source/NSPopupButton.m: if (count) == 0, return early in drawing diff --git a/Headers/gnustep/gui/NSMenuView.h b/Headers/gnustep/gui/NSMenuView.h index 4fffa5500..f2de7c696 100644 --- a/Headers/gnustep/gui/NSMenuView.h +++ b/Headers/gnustep/gui/NSMenuView.h @@ -39,6 +39,7 @@ #include #include #include +#include @class NSFont; @@ -59,6 +60,9 @@ float menuv_keyEqWidth; BOOL menuv_needsSizing; NSSize cellSize; +@private + NSPopUpButton *menuv_popb; + id menuv_items_link; } + (float)menuBarHeight; @@ -108,4 +112,11 @@ - (BOOL)trackWithEvent:(NSEvent *)event; @end +@interface NSMenuView (Private) +- (id) initWithFrame: (NSRect)aFrame + cellSize: (NSSize)aSize; +- (void) setPopUpButton: (NSPopUpButton *)popb; +- (NSPopUpButton *) popupButton; +@end + #endif diff --git a/Headers/gnustep/gui/NSPopUpButton.h b/Headers/gnustep/gui/NSPopUpButton.h index 386ee64de..a8526e71a 100644 --- a/Headers/gnustep/gui/NSPopUpButton.h +++ b/Headers/gnustep/gui/NSPopUpButton.h @@ -7,6 +7,8 @@ Author: Scott Christley Date: 1996 + Author: Michael Hanni + Date: 1999 This file is part of the GNUstep GUI Library. @@ -41,40 +43,11 @@ @class NSMatrix; @class NSPopUpButton; -@interface NSPopUpButtonMatrix : NSControl -{ - NSMutableArray* cells; - NSSize cellSize; - NSMenu* menu; - id selectedCell; - NSRect selectedCellRect; - BOOL pull_down; - int selected_cell; - NSPopUpButton *popup_button; -} -- initWithFrame:(NSRect)rect; -- (id )insertItemWithTitle:(NSString*)aString - action:(SEL)aSelector - keyEquivalent:(NSString*)charCode - atIndex:(unsigned int)index; -- (void)removeItem:(id )anItem; -- (NSArray*)itemArray; -- (id )itemWithTitle:(NSString*)aString; -- (id )itemWithTag:(int)aTag; -- (NSRect)cellFrameAtRow:(int)index; -- (NSSize)cellSize; -- (void)setMenu:(NSMenu*)menu; -- (void)setSelectedCell:(id)aCell; -- (id)selectedCell; -- (NSRect)selectedCellRect; -- (void)setPopUpButton:(NSPopUpButton *)popb; -- (void) setIndexOfSelectedItem:(int)itemNum; -@end - @interface NSPopUpButton : NSButton { // Attributes - NSPopUpButtonMatrix *list_items; + NSMutableArray *list_items; + NSMenuView *popb_view; NSRect list_rect; int selected_item; id pub_target; diff --git a/Source/NSMenu.m b/Source/NSMenu.m index 7ef67dc31..43bd1c4ab 100644 --- a/Source/NSMenu.m +++ b/Source/NSMenu.m @@ -3,6 +3,16 @@ Copyright (C) 1999 Free Software Foundation, Inc. + Author: Michael Hanni + Date: 1999 + + A completely rewritten version of the original source by Scott Christley. + and: + Author: Ovidiu Predescu + Date: May 1997 + and: + Author: Felipe A. Rodriguez + Date: July 1998 This file is part of the GNUstep GUI Library. @@ -103,9 +113,9 @@ static NSZone *menuZone = NULL; - (void)insertItem:(id )newItem atIndex:(int)index { - if ([newItem conformsToProtocol:@protocol(NSMenuItem)]) + if ([(id)newItem conformsToProtocol:@protocol(NSMenuItem)]) { - if ([newItem isKindOfClass:[NSMenuItemCell class]]) + if ([(id)newItem isKindOfClass:[NSMenuItemCell class]]) [menu_items insertObject:newItem atIndex:index]; else { diff --git a/Source/NSMenuItemCell.m b/Source/NSMenuItemCell.m index 588e35c3a..1c76b962e 100644 --- a/Source/NSMenuItemCell.m +++ b/Source/NSMenuItemCell.m @@ -3,6 +3,8 @@ Copyright (C) 1999 Free Software Foundation, Inc. + Author: Michael Hanni + Date: 1999 This file is part of the GNUstep GUI Library. diff --git a/Source/NSMenuView.m b/Source/NSMenuView.m index b3bae3cf0..edc1f1cc4 100644 --- a/Source/NSMenuView.m +++ b/Source/NSMenuView.m @@ -3,6 +3,8 @@ Copyright (C) 1999 Free Software Foundation, Inc. + Author: Michael Hanni + Date: 1999 This file is part of the GNUstep GUI Library. @@ -30,6 +32,9 @@ static float GSMenuBarHeight = 25.0; // a guess. +// These private methods are used in NSPopUpButton. For NSPB we need to be +// able to init with a frame, but have a very custom cell size. + @implementation NSMenuView // Class methods. @@ -59,11 +64,22 @@ static float GSMenuBarHeight = 25.0; // a guess. return [super initWithFrame: aFrame]; } +- (id)initWithFrame: (NSRect)aFrame + cellSize: (NSSize)aSize +{ + [self initWithFrame:aFrame]; + + cellSize = aSize; + + return self; +} + // Our menu. - (void)setMenu: (NSMenu *)menu { ASSIGN(menuv_menu, menu); + menuv_items_link = [menuv_menu itemArray]; } - (NSMenu *)menu @@ -71,6 +87,19 @@ static float GSMenuBarHeight = 25.0; // a guess. return menuv_menu; } +// Or random items. + +- (void) setPopUpButton: (NSPopUpButton *)popb; +{ + ASSIGN(menuv_popb, popb); + menuv_items_link = [menuv_popb itemArray]; +} + +- (NSPopUpButton *)popupButton +{ + return menuv_popb; +} + - (void)setHorizontal: (BOOL)flag { menuv_horizontal = flag; @@ -110,7 +139,6 @@ static float GSMenuBarHeight = 25.0; // a guess. - (void)setHighlightedItemIndex: (int)index { - NSArray *menu_items = [menuv_menu itemArray]; id anItem; BOOL _closeASubmenu = NO; @@ -118,17 +146,21 @@ static float GSMenuBarHeight = 25.0; // a guess. if (index == -1) { if (menuv_highlightedItemIndex != -1) { - anItem = [menu_items objectAtIndex: menuv_highlightedItemIndex]; + anItem = [menuv_items_link objectAtIndex: menuv_highlightedItemIndex]; [anItem highlight: NO withFrame: [self rectOfItemAtIndex: menuv_highlightedItemIndex] inView: self]; + + if ([anItem hasSubmenu] && ![[anItem target] isTornOff]) + [[anItem target] close]; + [anItem setState: 0]; menuv_highlightedItemIndex = -1; } } else if (index >= 0) { if ( menuv_highlightedItemIndex != -1 ) { - anItem = [menu_items objectAtIndex: menuv_highlightedItemIndex]; + anItem = [menuv_items_link objectAtIndex: menuv_highlightedItemIndex]; [anItem highlight: NO withFrame: [self rectOfItemAtIndex: menuv_highlightedItemIndex] @@ -141,7 +173,7 @@ static float GSMenuBarHeight = 25.0; // a guess. } if (menuv_highlightedItemIndex != index) { - anItem = [menu_items objectAtIndex: index]; + anItem = [menuv_items_link objectAtIndex: index]; [anItem highlight: YES withFrame: [self rectOfItemAtIndex: index] @@ -149,7 +181,7 @@ static float GSMenuBarHeight = 25.0; // a guess. [anItem setState: 1]; - if ([anItem hasSubmenu]) + if ([anItem hasSubmenu] && ![[anItem target] isTornOff]) [[anItem target] display]; // set ivar to new index @@ -181,7 +213,7 @@ static float GSMenuBarHeight = 25.0; // a guess. - (NSMenuItemCell *)menuItemCellForItemAtIndex: (int)index { - return [[menuv_menu itemArray] objectAtIndex: index]; + return [menuv_items_link objectAtIndex: index]; } - (NSMenuView *)attachedMenuView @@ -260,15 +292,15 @@ static float GSMenuBarHeight = 25.0; // a guess. - (void)sizeToFit { int i; - int howMany = [[menuv_menu itemArray] count]; - int howHigh = (howMany * cellSize.height) + 21; + int howMany = [menuv_items_link count]; + int howHigh = (howMany * cellSize.height); float neededWidth = 0; - for (i=0;i<[[menuv_menu itemArray] count];i++) + for (i=0;i neededWidth) @@ -277,8 +309,13 @@ static float GSMenuBarHeight = 25.0; // a guess. cellSize.width = 7 + neededWidth + 7 + 7 + 5; - [[self window] setFrame: NSMakeRect(300,300,cellSize.width,howHigh) display: YES]; - [self setFrame: NSMakeRect(0,0,cellSize.width,howHigh-21)]; + [self setFrame: NSMakeRect(0,0,cellSize.width,howHigh)]; +} + +- (void)sizeToFitForPopUpButton +{ + int howHigh = ([menuv_items_link count] * cellSize.height); + [self setFrame: NSMakeRect(0,0,cellSize.width,howHigh)]; } - (float)stateImageOffset @@ -368,7 +405,7 @@ static float GSMenuBarHeight = 25.0; // a guess. - (void)setNeedsDisplayForItemAtIndex: (int)index { - [[[menuv_menu itemArray] objectAtIndex: index] setNeedsDisplay: YES]; + [[menuv_items_link objectAtIndex: index] setNeedsDisplay: YES]; } - (NSPoint)locationForSubmenu: (NSMenu *)aSubmenu @@ -402,18 +439,18 @@ static float GSMenuBarHeight = 25.0; // a guess. - (void)drawRect: (NSRect)rect { int i; - NSArray *menuCells = [menuv_menu itemArray]; NSRect aRect = [self frame]; + int howMany = [menuv_items_link count]; // This code currently doesn't take intercell spacing into account. I'll // need to fix that. - aRect.origin.y = cellSize.height * ([menuCells count] - 1); + aRect.origin.y = cellSize.height * (howMany - 1); aRect.size = cellSize; - for (i=0;i<[menuCells count];i++) + for (i=0;i aRect.origin.y && lastLocation.y < aRect.origin.y + aRect.size.height - && [[[menuv_menu itemArray] objectAtIndex: lastIndex] + && [[menuv_items_link objectAtIndex: lastIndex] hasSubmenu]) { weLeftMenu = YES; @@ -569,25 +606,26 @@ static float GSMenuBarHeight = 25.0; // a guess. if (!weLeftMenu && !weRightMenu && !weWereOut && menuv_highlightedItemIndex != -1) { - if (![[[menuv_menu itemArray] objectAtIndex: menuv_highlightedItemIndex] + if (![[menuv_items_link objectAtIndex: menuv_highlightedItemIndex] hasSubmenu]) { BOOL finished = NO; NSMenu *aMenu = menuv_menu; if (index >= 0 && index < theCount) - selectedCell = [[menuv_menu itemArray] objectAtIndex: index]; + selectedCell = [menuv_items_link objectAtIndex: index]; else selectedCell = nil; [self setHighlightedItemIndex: -1]; - if ([selectedCell action]) - [menuv_menu performActionForItem: - [[menuv_menu itemArray] objectAtIndex: lastIndex]]; + NSLog(@"just mouseUp'ed."); - if ([selectedCell hasSubmenu]) - [[selectedCell target] close]; + if ([selectedCell action] && ![selectedCell target]) + [menuv_menu performActionForItem: + [menuv_items_link objectAtIndex: lastIndex]]; + else + [menuv_popb performSelector:[selectedCell action] withObject:selectedCell]; while (!finished) { // "forward"cursive menu find. @@ -606,7 +644,7 @@ static float GSMenuBarHeight = 25.0; // a guess. if ([aMenu supermenu] && ![aMenu isTornOff]) { [[[aMenu supermenu] menuView] setHighlightedItemIndex: -1]; - [aMenu close]; +// [aMenu close]; aMenu = [aMenu supermenu]; } else @@ -615,6 +653,17 @@ static float GSMenuBarHeight = 25.0; // a guess. [window flushWindow]; } } + else if ([[menuv_items_link objectAtIndex: +menuv_highlightedItemIndex] + hasSubmenu] && [[[menuv_items_link objectAtIndex: +menuv_highlightedItemIndex] target] isTornOff]) + { + // This code does not work. Please ignore. FIXME, Michael. + // close transient. +// [self setHighlightedItemIndex: -1]; +// +// [[[menuv_menu supermenu] menuView] setHighlightedItemIndex: -1]; + } } else if (weRightMenu) { @@ -653,7 +702,7 @@ static float GSMenuBarHeight = 25.0; // a guess. NSLog(@"Urph.\n"); - selectedCell = [[menuv_menu itemArray] objectAtIndex: lastIndex]; + selectedCell = [menuv_items_link objectAtIndex: lastIndex]; if ([selectedCell hasSubmenu]) { [self mouseUp: diff --git a/Source/NSPopUpButton.m b/Source/NSPopUpButton.m index 5d37c7494..87e97c89d 100644 --- a/Source/NSPopUpButton.m +++ b/Source/NSPopUpButton.m @@ -34,243 +34,13 @@ #include #include #include +#include #include -@implementation NSPopUpButtonMatrix - -// Class variables -static NSFont* menuFont = nil; - -- (BOOL) acceptsFirstMouse: (NSEvent *)theEvent -{ - return YES; -} - -- (id) initWithFrame: (NSRect)rect -{ - [super initWithFrame: rect]; - cells = [NSMutableArray new]; - - selected_cell = 0; - - cellSize = NSMakeSize (rect.size.width, rect.size.height); - - return self; -} - -- (void) dealloc -{ - NSDebugLog (@"NSMenuMatrix of menu '%@' dealloc", [menu title]); - - [cells release]; - [super dealloc]; -} - -- (id) copyWithZone: (NSZone*)zone -{ - NSPopUpButtonMatrix* copy = [[isa allocWithZone: zone] initWithFrame: [self frame]]; - int i, count; - - NSDebugLog (@"copy menu matrix of menu with title '%@'", [menu title]); - for (i = 0, count = [cells count]; i < count; i++) - { - id aCell = [cells objectAtIndex: i]; - id cellCopy = [[aCell copyWithZone: zone] autorelease]; - - [copy->cells addObject: cellCopy]; - } - - copy->cellSize = cellSize; - copy->menu = menu; - if (selectedCell) - { - int index = [cells indexOfObject: selectedCell]; - - copy->selectedCell = [[cells objectAtIndex: index] retain]; - } - copy->selectedCellRect = selectedCellRect; - - return copy; -} - -- (void) _resizeMenuForCellSize -{ - int i, count; - float titleWidth; - - /* Compute the new width of the menu cells matrix */ - cellSize.width = 0; - count = [cells count]; - for (i = 0; i < count; i++) - { - titleWidth = [menuFont widthOfString: - [[cells objectAtIndex: i] stringValue]]; - cellSize.width = MAX(titleWidth + ADDITIONAL_WIDTH, cellSize.width); - } - cellSize.width = MAX([menuFont widthOfString: [menu title]] - + ADDITIONAL_WIDTH, - cellSize.width); - - /* Resize the frame to hold all the menu cells */ - [super setFrameSize: NSMakeSize (cellSize.width, - count ? (cellSize.height + INTERCELL_SPACE)*count - INTERCELL_SPACE : 0)]; -} - -- (id )insertItemWithTitle: (NSString*)aString - action: (SEL)aSelector - keyEquivalent: (NSString*)charCode - atIndex: (unsigned int)index -{ - id menuCell = [[NSPopUpButtonCell new] autorelease]; - - [menuCell setFont:[NSFont systemFontOfSize:12]]; - [menuCell setTitle: aString]; -// [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]; -} - -- (void)setPopUpButton:(NSPopUpButton *)popb -{ - ASSIGN(popup_button, popb); -} - -- (void)setPullsDown:(BOOL)pull -{ - pull_down = pull; -} - -- (BOOL)pullsDown -{ - return pull_down; -} - -- (BOOL) performKeyEquivalent: (NSEvent*)theEvent -{ - return [menu performKeyEquivalent: theEvent]; -} - -- (void) removeItem: (id )anItem -{ - int row = [cells indexOfObject: anItem]; - - if (row == -1) - return; - - [cells removeObjectAtIndex: row]; -} - -- (NSArray*) itemArray -{ - return cells; -} - -- (id ) itemWithTitle: (NSString*)aString -{ - unsigned i, count = [cells count]; - id menuCell; - - for (i = 0; i < count; i++) - { - menuCell = [cells objectAtIndex: i]; - if ([[menuCell title] isEqual: aString]) - return menuCell; - } - return nil; -} - -- (id ) itemWithTag: (int)aTag -{ - unsigned i, count = [cells count]; - id menuCell; - - for (i = 0; i < count; i++) - { - menuCell = [cells objectAtIndex: i]; - if ([menuCell tag] == aTag) - return menuCell; - } - return nil; -} - -- (NSRect) cellFrameAtRow: (int)index -{ - unsigned count = [cells count]; - NSRect rect; - - NSAssert(index >= 0 && index < count+1, @"invalid row coordinate"); - - rect.origin.x = 0; - rect.origin.y = (count - index - 1) - * (cellSize.height + INTERCELL_SPACE); - rect.size = cellSize; - - return rect; -} - -- (void)drawRect: (NSRect)rect -{ - unsigned i = 0, count = [cells count]; - int max, howMany; - NSRect aRect = [self frame]; - - // If there are no cells then just return - if (count == 0) return; - - aRect.origin.y = cellSize.height * (count - 1); - aRect.size = cellSize; - - for (i=0;i)itemAtIndex:(int)index { - return [[list_items itemArray] objectAtIndex:index]; + return [list_items objectAtIndex:index]; } - (NSArray *)itemArray { - return [list_items itemArray]; + return list_items; } - (NSString *)itemTitleAtIndex:(int)index { - return [[[list_items itemArray] objectAtIndex:index] title]; + return [[list_items objectAtIndex:index] title]; } - (NSArray *)itemTitles { - int i, count = [[list_items itemArray] count]; + int i, count = [list_items count]; NSMutableArray* titles = [NSMutableArray arrayWithCapacity:count]; for (i = 0; i < count; i++) - [titles addObject:[[[list_items itemArray] objectAtIndex:i] title]]; + [titles addObject:[[list_items objectAtIndex:i] title]]; return titles; } @@ -464,21 +243,21 @@ static NSFont* menuFont = nil; int index = [self indexOfItemWithTitle:title]; if (index != NSNotFound) - return [[list_items itemArray] objectAtIndex:index]; + return [list_items objectAtIndex:index]; return nil; } - (id )lastItem { - if ([[list_items itemArray] count]) - return [[list_items itemArray] lastObject]; + if ([list_items count]) + return [list_items lastObject]; else return nil; } - (id )selectedItem { - return [[list_items itemArray] objectAtIndex:selected_item]; + return [list_items objectAtIndex:selected_item]; } - (NSString *)titleOfSelectedItem @@ -501,7 +280,7 @@ static NSFont* menuFont = nil; - (void)selectItemAtIndex:(int)index { - if ((index >= 0) && (index < [[list_items itemArray] count])) + if ((index >= 0) && (index < [list_items count])) { selected_item = index; [self synchronizeTitleAndSelectedItem]; @@ -534,10 +313,10 @@ static NSFont* menuFont = nil; - (void)synchronizeTitleAndSelectedItem { - if (!pulls_down) - [list_items setIndexOfSelectedItem:selected_item]; - else - [list_items setIndexOfSelectedItem:0]; +// if (!pulls_down) +// [list_items setIndexOfSelectedItem:selected_item]; +// else +// [list_items setIndexOfSelectedItem:0]; } // @@ -582,13 +361,13 @@ static NSFont* menuFont = nil; { id aCell; - if ([[list_items itemArray] count] == 0) + if ([list_items count] == 0) return; if (!pulls_down) - aCell = [[list_items itemArray] objectAtIndex:selected_item]; + aCell = [list_items objectAtIndex:selected_item]; else - aCell = [[list_items itemArray] objectAtIndex:0]; + aCell = [list_items objectAtIndex:0]; [aCell drawWithFrame:rect inView:self]; } diff --git a/Source/NSPopUpButtonCell.m b/Source/NSPopUpButtonCell.m index 74885f57b..6ae458dc8 100644 --- a/Source/NSPopUpButtonCell.m +++ b/Source/NSPopUpButtonCell.m @@ -1,3 +1,29 @@ +/* + NSPopUpButtonCell.m + + Copyright (C) 1999 Free Software Foundation, Inc. + + Author: Michael Hanni + Date: 1999 + + This file is part of the GNUstep GUI Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + #include #include #include @@ -19,7 +45,7 @@ { return [super init]; } - + - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)view { @@ -36,9 +62,11 @@ arect.origin.y += 2; if (cell_highlighted) { + NSLog(@"highlighted."); [[NSColor whiteColor] set]; NSRectFill(arect); } else { + NSLog(@"unhighlighted."); [[NSColor lightGrayColor] set]; NSRectFill(arect); } @@ -60,13 +88,28 @@ rect.size.height = cellFrame.size.height; rect.origin.x = cellFrame.origin.x + cellFrame.size.width - (6 + 11); rect.origin.y = cellFrame.origin.y; - - if ([(NSPopUpButton *)view titleOfSelectedItem] == contents) - { - if ([(NSPopUpButton *)view pullsDown] == NO) - [super _drawImage:[NSImage imageNamed:@"common_Nibble"] inFrame:rect]; - else - [super _drawImage:[NSImage imageNamed:@"common_3DArrowDown"] inFrame:rect]; - } + + if ([view isKindOfClass:[NSMenuView class]]) + { + NSPopUpButton *popb = [(NSMenuView *)view popupButton]; + + if ([popb titleOfSelectedItem] == contents) + { + if ([popb pullsDown] == NO) + [super _drawImage:[NSImage imageNamed:@"common_Nibble"] inFrame:rect]; + else + [super _drawImage:[NSImage imageNamed:@"common_3DArrowDown"] inFrame:rect]; + } + } + else if ([view isKindOfClass:[NSPopUpButton class]]) + { + if ([(NSPopUpButton *)view titleOfSelectedItem] == contents) + { + if ([(NSPopUpButton *)view pullsDown] == NO) + [super _drawImage:[NSImage imageNamed:@"common_Nibble"] inFrame:rect]; + else + [super _drawImage:[NSImage imageNamed:@"common_3DArrowDown"] inFrame:rect]; + } + } } @end diff --git a/Source/NSText.m b/Source/NSText.m index db2904171..12b20d88b 100644 --- a/Source/NSText.m +++ b/Source/NSText.m @@ -456,28 +456,7 @@ static NSRange MakeRangeFromAbs(int a1,int a2) returnType: returnType]; } - -- (BOOL) readSelectionFromPasteboard: (NSPasteboard*)pb -{ - NSArray *types; - NSString *string; - NSRange range; - - types = [pb types]; - if ([types containsObject: NSStringPboardType] == NO) - { - return NO; - } - string = [pb stringForType: NSStringPboardType]; - range = [self selectedRange]; - [self deleteRange: range backspace: NO]; - [self insertText: string]; - range.length = [string length]; - [self setSelectedRange: range]; - return YES; -} - - (BOOL) writeSelectionToPasteboard: (NSPasteboard*)pb types: (NSArray*)sendTypes { @@ -538,6 +517,9 @@ static NSRange MakeRangeFromAbs(int a1,int a2) } return NO; } +- (BOOL) readSelectionFromPasteboard: (NSPasteboard*)pb +{ return [self performPasteOperation:pb]; +} // begin: dragging of colors and files --------------- -(unsigned int) draggingEntered:(id )sender @@ -1012,7 +994,10 @@ NSLog(@"did set font"); if([[lineLayoutInformation lastObject] type] == LineLayoutInfoType_Paragraph && NSMaxY(rect)<= newHeight) newHeight+=[[lineLayoutInformation lastObject] lineRect].size.height; - tRect = [(NSClipView*)[self superview] documentVisibleRect]; + if ( [[self superview] isKindOfClass: [NSClipView class]] ) + tRect = [(NSClipView*)[self superview] documentVisibleRect]; + else + tRect = [self bounds]; if (currentCursorY < tRect.size.height + tRect.origin.y - [[lineLayoutInformation lastObject] lineRect].size.height)