From 9870f513bc0b8cc25c5149d0d816c2cc15df16f1 Mon Sep 17 00:00:00 2001 From: michael Date: Tue, 7 Sep 1999 08:59:35 +0000 Subject: [PATCH] Lots of fixes. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4844 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 18 + Headers/gnustep/gui/NSInterfaceStyle.h | 9 +- Images/GNUmakefile | 2 +- Images/common_TabDownSelectedLeft.tiff | Bin 594 -> 584 bytes Images/common_TabDownUnSelectedJunction.tiff | Bin 758 -> 756 bytes ...n_TabDownUnSelectedToSelectedJunction.tiff | Bin 758 -> 732 bytes Source/NSAttributedString.m | 2 +- Source/NSInterfaceStyle.m | 2 + Source/NSLayoutManager.m | 110 +++-- Source/NSMenu.m | 26 +- Source/NSTabView.m | 386 ++++++++++-------- Source/NSTextView.m | 11 + 12 files changed, 352 insertions(+), 214 deletions(-) diff --git a/ChangeLog b/ChangeLog index 86b92f175..554d58d05 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +1999-09-07 Michael Hanni + + * Source/NSInterfaceStyle.m: added support for + GSWindowMakerInterfaceStyle. + * Headers/NSInterfaceStyle.h: added enum + GSWindowMakerInterfaceStyle. + * Source/NSMenu.m: implemented NSInterfaceStyle based window maker + like menus. i.e. they line up with the menu item selected. + try 'defaults write NSGlobalDomain NSMenuInterfaceStyle + GSWindowMakerInterfaceStyle' + * Source/NSTabView.m: some modifications to make tabs on the + bottom look a little better. + * Source/NSAttributedString.m: turned off fixParagraphAttributes, + was causing Text Network to crash. (Most likely my fault.) + * Source/NSLayoutManager.m: lots of code... nothing exciting. + * Images/*: somehow I triggered CVS to touch everything in here, + oops. + Tue Sep 7 6:50:00 1999 Richard Frith-Macdonald * Source/NSScrollView.m: ([-setContentView:]) prohibit illegal settings. diff --git a/Headers/gnustep/gui/NSInterfaceStyle.h b/Headers/gnustep/gui/NSInterfaceStyle.h index 5fd40a4f9..e8d021956 100644 --- a/Headers/gnustep/gui/NSInterfaceStyle.h +++ b/Headers/gnustep/gui/NSInterfaceStyle.h @@ -36,7 +36,14 @@ typedef enum { NSNoInterfaceStyle = 0, NSNextStepInterfaceStyle = 1, NSMacintoshInterfaceStyle = 2, - NSWindows95InterfaceStyle = 3 + NSWindows95InterfaceStyle = 3, + +/* + * GNUstep specific. Blame: Michael Hanni. + */ + + GSWindowMakerInterfaceStyle = 4 + } NSInterfaceStyle; extern NSString *NSInterfaceStyleDefault; diff --git a/Images/GNUmakefile b/Images/GNUmakefile index 673a71b79..995664b9b 100644 --- a/Images/GNUmakefile +++ b/Images/GNUmakefile @@ -19,7 +19,7 @@ # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free -# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. GNUSTEP_INSTALLATION_DIR = $(GNUSTEP_SYSTEM_ROOT) diff --git a/Images/common_TabDownSelectedLeft.tiff b/Images/common_TabDownSelectedLeft.tiff index ff68d375a067d3ab9763387007c2e27420d22ece..056eabe15c6e791144a23ef389586f8ac9a25569 100644 GIT binary patch delta 312 zcmV-80muH*1jqz`Nl7XI_@=p{e(S)JGgiDbniyBpG{3AvI3qZUCYE`SvS|m&KnCTL@ zvhNCjVKat{R*GugQq24S3Kp(hCqk+;=>RBDrvLz0zhLWS){&`5ntx_=Spq0swtU4_ zJ%R=HU#n-o-ib0L?N>?dF#nWB)+{unvIO~}{j+DlrE{5b6~+!7K9bVt+Ox8bpE!By zz$6Qc3{yK|RNs}e*UZh3IP-=Si~ZBYPY(bzgwOy41d-?>0nU>P0V@$p0002i0RR9F z0RjLP0000YlSctN8QcH>02%=W0096105}2w02=`X0096106>$Q0Z|B0a&Ky7V{~(q K`vEbND*`7l;CUth delta 345 zcmX@Xa*3th(^HG#1p@;E;~(}<>%+E2F@&v+W))E5u`&6;(D0SpEN9CL!=z(fs;&zH z{^$Jo%%)(V+3-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z#*af-5~&k3Iz`hJOE(*f(;!dYP9Gv)TmP9 zKZ*dy7T~I#fcF=VdA981p+{g5_N|B(K5x&ph=4+0E$Wi zP%B?80RNy17f4?yzg6p20r0O4fFwPN02q^@T{%P5ruuDv83G`ck0bzPl(FrWq=UC0Whph8vqFtN|!BPamcU&ut9glyphRange.location, -aObject->glyphRange.location, position); +// NSLog(@"key: %d aObject: %d position: %d", aKey->glyphRange.location, +//aObject->glyphRange.location, position); if (position > 0) { @@ -179,18 +179,18 @@ aObject->glyphRange.location, position); if (anKey->glyphRange.location == aObject->glyphRange.location) { // GSIArrayInsertSorted(_runs, (GSIArrayItem)anObject, aSort); - NSLog(@"=========> duplicated item."); +// NSLog(@"=========> duplicated item."); GSIArraySetItemAtIndex(_runs, (GSIArrayItem)anObject, position-1); } else { - NSLog(@"=========> not duplicated item."); +// NSLog(@"=========> not duplicated item."); GSIArrayInsertItem(_runs, (GSIArrayItem)anObject, position); } } else if (position == 0) { - NSLog(@"=========> first item (zero index)."); +// NSLog(@"=========> first item (zero index)."); GSIArrayInsertItem(_runs, (GSIArrayItem)anObject, position); // GSIArrayInsertSorted(_runs, (GSIArrayItem)anObject, aSort); // [self insertObject:anObject atIndex:position]; @@ -198,7 +198,7 @@ aObject->glyphRange.location, position); else NSLog(@"dead. VERY DEAD DEAD DEAD DEAD."); - NSLog(@"==> %d item(s)", GSIArrayCount(_runs)); +// NSLog(@"==> %d item(s)", GSIArrayCount(_runs)); } - (void)insertObject:(id)anObject @@ -536,16 +536,19 @@ textContainer(s) in containerRuns.", [containerRuns count]); { GSTextContainerLayoutInfo *aNewLine = [containerRuns objectAtIndex:i]; +/* NSLog(@"glyphRangeForTextContainer: (%d, %d)", aNewLine->glyphRange.location, aNewLine->glyphRange.length); +*/ if ([aNewLine->textContainer isEqual:aTextContainer]) { +/* NSLog(@"glyphRangeForWantedTextContainer: (%d, %d)", aNewLine->glyphRange.location, aNewLine->glyphRange.length); - +*/ return aNewLine->glyphRange; } } @@ -927,7 +930,7 @@ info->lineFragmentRect.size.height); firstPosition = [fragmentRuns indexOfObjectContainingLocation:glyphRange.location]; lastPosition = [fragmentRuns -indexOfObjectContainingLocation:(glyphRange.location+glyphRange.length-2)]; +indexOfObjectContainingLocation:(glyphRange.location+glyphRange.length-3)]; NSLog(@"glyphRange: (%d, %d) position1: %d position2: %d", glyphRange.location, glyphRange.length, firstPosition, lastPosition); @@ -936,13 +939,16 @@ glyphRange.location, glyphRange.length, firstPosition, lastPosition); { if (lastPosition == -1) { - lastPosition = [fragmentRuns count]; // FIXME + lastPosition = [fragmentRuns count] - 1; // FIXME NSLog(@"fixed lastPosition: %d", lastPosition); } - for (i = firstPosition; i < lastPosition; i++) + for (i = firstPosition; i <= lastPosition; i++) { GSLineLayoutInfo *aLine = [fragmentRuns objectAtIndex:i]; + NSRect aRect = aLine->lineFragmentRect; + aRect.size.height -= 4; + /* NSLog(@"drawRange: (%d, %d) inRect (%f, %f) (%f, %f)", aLine->glyphRange.location, @@ -952,6 +958,8 @@ aLine->lineFragmentRect.origin.y, aLine->lineFragmentRect.size.width, aLine->lineFragmentRect.size.height); */ + + NSEraseRect (aRect); [_textStorage drawRange:aLine->glyphRange inRect:aLine->lineFragmentRect]; } } @@ -1015,13 +1023,15 @@ Ghiradelli chocolate to he who puts all the pieces together :) */ { NSSize cSize = [aContainer containerSize]; float i = 0.0; - NSMutableArray *lines = [NSMutableArray new]; + NSMutableArray *lineStarts = [NSMutableArray new]; + NSMutableArray *lineEnds = [NSMutableArray new]; int indexToAdd; _GNUTextScanner *lineScanner; _GNUTextScanner *paragraphScanner; BOOL lastLineForContainerReached = NO; NSString *aString; int previousScanLocation; + int previousParagraphLocation; int endScanLocation; int startIndex; NSRect firstProposedRect; @@ -1038,9 +1048,11 @@ Ghiradelli chocolate to he who puts all the pieces together :) */ NSRange currentStringRange; NSRange trailingSpacesRange; NSRange leadingNlRange; + NSRange trailingNlRange; NSSize lSize; float lineWidth = 0.0; float ourLines = 0.0; + int beginLineIndex = 0; NSLog(@"rebuilding Layout at index: %d.\n", glyphIndex); @@ -1075,23 +1087,30 @@ Ghiradelli chocolate to he who puts all the pieces together :) */ while (![paragraphScanner isAtEnd]) { -// leadingNlRange=[paragraphScanner scanSetCharacters]; - paragraphRange = [paragraphScanner scanNonSetCharacters]; - leadingNlRange=[paragraphScanner scanSetCharacters]; + previousParagraphLocation = [paragraphScanner scanLocation]; + beginLineIndex = previousParagraphLocation; + lineWidth = 0.0; - if (leadingNlRange.length) - currentStringRange = NSUnionRange (leadingNlRange,paragraphRange); + leadingNlRange=[paragraphScanner scanSetCharacters]; + paragraphRange = [paragraphScanner scanNonSetCharacters]; + trailingNlRange=[paragraphScanner scanSetCharacters]; + +// NSLog(@"leadingNlRange: (%d, %d)", leadingNlRange.location, leadingNlRange.length); + +// if (leadingNlRange.length) +// paragraphRange = NSUnionRange (leadingNlRange,paragraphRange); +// if (trailingNlRange.length) +// paragraphRange = NSUnionRange (trailingNlRange,paragraphRange); NSLog(@"paragraphRange: (%d, %d)", paragraphRange.location, paragraphRange.length); - NSLog(@"======> begin paragraph"); - lineScanner = [_GNUTextScanner scannerWithString:[[_textStorage string] substringWithRange:paragraphRange] set:selectionWordGranularitySet invertedSet:invSelectionWordGranularitySet]; while(![lineScanner isAtEnd]) { previousScanLocation = [lineScanner scanLocation]; + // snack next word leadingSpacesRange = [lineScanner scanSetCharacters]; // leading spaces: only first time currentStringRange = [lineScanner scanNonSetCharacters]; @@ -1104,16 +1123,28 @@ Ghiradelli chocolate to he who puts all the pieces together :) */ lSize = [_textStorage sizeRange:currentStringRange]; - if (lineWidth + lSize.width < cSize.width) +// lSize = [_textStorage sizeRange: +//NSMakeRange(currentStringRange.location+paragraphRange.location+startIndex, +//currentStringRange.length)]; + + if ((lineWidth + lSize.width) < cSize.width) { if ([lineScanner isAtEnd]) { NSLog(@"we are at end before finishing a line: %d.\n", [lineScanner scanLocation]); - [lines addObject:[NSNumber numberWithInt:(int)[lineScanner scanLocation] + paragraphRange.location]]; + NSLog(@"scanLocation = %d, previousParagraphLocation = %d, beginLineIndex = %d", +[lineScanner scanLocation], +previousParagraphLocation, +beginLineIndex); + [lineStarts addObject: [NSNumber +numberWithInt:beginLineIndex]]; + [lineEnds addObject: [NSNumber +numberWithInt:(int)[lineScanner scanLocation] + previousParagraphLocation - (beginLineIndex)]]; + lineWidth = 0.0; } lineWidth += lSize.width; - NSLog(@"lineWidth: %f", lineWidth); + //NSLog(@"lineWidth: %f", lineWidth); } else { @@ -1124,13 +1155,22 @@ Ghiradelli chocolate to he who puts all the pieces together :) */ } [lineScanner setScanLocation:previousScanLocation]; - indexToAdd = previousScanLocation + paragraphRange.location; + indexToAdd = previousScanLocation + previousParagraphLocation +- (beginLineIndex); + + NSLog(@"previousScanLocation = %d, previousParagraphLocation = %d, beginLineIndex = %d indexToAdd = %d", +previousScanLocation, +previousParagraphLocation, +beginLineIndex, +indexToAdd); + ourLines += 14.0; - lineWidth = 0; + lineWidth = 0.0; - NSLog(@"indexToAdd: %d\tourLines: %f", indexToAdd, ourLines); - - [lines addObject:[NSNumber numberWithInt:indexToAdd]]; + [lineStarts addObject: [NSNumber +numberWithInt:beginLineIndex]]; + [lineEnds addObject:[NSNumber numberWithInt:indexToAdd]]; + beginLineIndex = previousScanLocation + previousParagraphLocation; } } @@ -1138,7 +1178,7 @@ Ghiradelli chocolate to he who puts all the pieces together :) */ break; } - endScanLocation = [lineScanner scanLocation] + paragraphRange.location; + endScanLocation = [paragraphScanner scanLocation]; NSLog(@"endScanLocation: %d", endScanLocation); @@ -1151,14 +1191,18 @@ Ghiradelli chocolate to he who puts all the pieces together :) */ // step 2. break the lines up and assign rects to them. - for (i=0;i<[lines count];i++) + for (i=0;i<[lineStarts count];i++) { NSRect aRect, bRect; float padding = [aContainer lineFragmentPadding]; NSRange ourRange; - NSLog(@"\t\t===> %d", [[lines objectAtIndex:i] intValue]); +// NSLog(@"\t\t===> %d", [[lines objectAtIndex:i] intValue]); + ourRange = NSMakeRange ([[lineStarts objectAtIndex: i] intValue], + [[lineEnds objectAtIndex: i] intValue]); + +/* if (i == 0) { ourRange = NSMakeRange (startIndex, @@ -1170,7 +1214,10 @@ Ghiradelli chocolate to he who puts all the pieces together :) */ [[lines objectAtIndex:i] intValue] - [[lines objectAtIndex:i-1] intValue]); } - +*/ + NSLog(@"line: %@|", [[_textStorage string] +substringWithRange:ourRange]); + firstProposedRect = NSMakeRect (0, i * 14, cSize.width, 14); // ask our textContainer to fix our lineFragment. @@ -1204,7 +1251,8 @@ intValue]); // didCompleteLayoutForTextContainer:[textContainers objectAtIndex:i] // atEnd:YES]; - [lines release]; + [lineStarts release]; + [lineEnds release]; return endScanLocation; } diff --git a/Source/NSMenu.m b/Source/NSMenu.m index 8098334ac..9faf2b799 100644 --- a/Source/NSMenu.m +++ b/Source/NSMenu.m @@ -489,14 +489,17 @@ static NSString* NSMenuLocationsKey = @"NSMenuLocations"; { NSRect frame; NSRect submenuFrame; + NSWindow *win_link; if (![self isFollowTransient]) { frame = [aWindow frame]; + win_link = aWindow; } else { frame = [bWindow frame]; + win_link = bWindow; } if (aSubmenu) @@ -506,9 +509,20 @@ static NSString* NSMenuLocationsKey = @"NSMenuLocations"; else submenuFrame = NSZeroRect; - return NSMakePoint (frame.origin.x + frame.size.width + 1, - frame.origin.y + frame.size.height - - submenuFrame.size.height); + if (NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", nil) == GSWindowMakerInterfaceStyle) + { + NSRect aRect = [menu_view rectOfItemAtIndex:[self indexOfItemWithTitle:[aSubmenu title]]]; + NSPoint subOrigin = [win_link convertBaseToScreen: NSMakePoint(aRect.origin.x, aRect.origin.y)]; + + return NSMakePoint (frame.origin.x + frame.size.width + 1, + subOrigin.y - (submenuFrame.size.height - 41)); + } + else + { + return NSMakePoint (frame.origin.x + frame.size.width + 1, + frame.origin.y + frame.size.height + - submenuFrame.size.height); + } } - (NSMenu *) supermenu @@ -837,6 +851,12 @@ NSArray* array; } } +- (void) _rightMouseDisplay +{ + // TODO: implement this method + ; +} + - (void) display { if (menu_changed) diff --git a/Source/NSTabView.m b/Source/NSTabView.m index eb905aefb..e87cfa7f1 100644 --- a/Source/NSTabView.m +++ b/Source/NSTabView.m @@ -309,204 +309,234 @@ if (tab_type == NSBottomTabsBezelBorder) { - for (i=0;i