crop really long page titles in Go menu

This commit is contained in:
hewitt%netscape.com 2002-05-29 21:41:54 +00:00
Родитель 7a70d3095d
Коммит 1caf4a6e63
8 изменённых файлов: 136 добавлений и 20 удалений

Просмотреть файл

@ -35,7 +35,7 @@
mButtons = [[NSMutableArray alloc] init];
mDragInsertionButton = nil;
mDragInsertionPosition = BookmarksService::CHInsertNone;
[self registerForDraggedTypes:[NSArray arrayWithObjects:@"MozURLType", @"MozBookmarkType", nil]];
[self registerForDraggedTypes:[NSArray arrayWithObjects:@"MozURLType", @"MozBookmarkType", NSStringPboardType, nil]];
}
return self;
}
@ -284,6 +284,21 @@
}
}
/*src=(null)
pasteboard=CFPasteboardUnique-11c50e715b
types=(
"CorePasteboardFlavorType 0x4D5A0000",
"CorePasteboardFlavorType 0x4D5A0001",
"CorePasteboardFlavorType 0x75747874",
"NeXT plain ascii pasteboard type",
"CorePasteboardFlavorType 0x54455854",
"Apple CorePasteboard Fallback Text Script",
"CorePasteboardFlavorType 0x4D4F5A6D",
NSStringPboardType,
NSStringPboardType
)
op=Copy Link Generic Private Move Delete
*/
// NSDraggingDestination ///////////
- (unsigned int)draggingEntered:(id <NSDraggingInfo>)sender
@ -320,6 +335,9 @@
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
NSString *value = [[sender draggingPasteboard] stringForType:@"CorePasteboardFlavorType 0x4D4F5A6D"];
NSLog(@"*** DROP %s",[value cString]);
BookmarksService::CompleteBookmarkDrag([sender draggingPasteboard], BookmarksService::gToolbarRoot,
mDragInsertionButton ? [mDragInsertionButton element] : nil,
mDragInsertionPosition);

Просмотреть файл

@ -38,7 +38,9 @@ static const int kDividerTag = 4000;
// the maximum number of history entry menuitems to display
static const int kMaxItems = 15;
// the maximum number of characters in a menu title before cropping it
static const int kMaxTitleLength = 20;
static const unsigned int kMaxTitleLength = 60;
// the ellipsis string to insert into cropped strings
static const NSString *kEllipsis = @"...";
@implementation CHGoMenu
@ -132,8 +134,17 @@ static const int kMaxTitleLength = 20;
entry->GetTitle(&text);
NSString* title = [NSString stringWithCharacters: text length: nsCRT::strlen(text)];
// if the title is too long, crop it in the middle
if ([title length] > kMaxTitleLength) {
NSMutableString *croppedTitle = [NSMutableString stringWithCapacity:kMaxTitleLength+[kEllipsis length]];
int len1 = kMaxTitleLength/2;
int len2 = kMaxTitleLength - len1;
NSString *part1 = [title substringWithRange:NSMakeRange(0, len1)];
NSString *part2 = [title substringWithRange:NSMakeRange([title length]-len2, len2)];
[croppedTitle appendString:part1];
[croppedTitle appendString:kEllipsis];
[croppedTitle appendString:part2];
title = croppedTitle;
}
NSMenuItem *newItem = [self addItemWithTitle:title action:@selector(historyItemAction:) keyEquivalent:@""];

Просмотреть файл

@ -35,7 +35,7 @@
mButtons = [[NSMutableArray alloc] init];
mDragInsertionButton = nil;
mDragInsertionPosition = BookmarksService::CHInsertNone;
[self registerForDraggedTypes:[NSArray arrayWithObjects:@"MozURLType", @"MozBookmarkType", nil]];
[self registerForDraggedTypes:[NSArray arrayWithObjects:@"MozURLType", @"MozBookmarkType", NSStringPboardType, nil]];
}
return self;
}
@ -284,6 +284,21 @@
}
}
/*src=(null)
pasteboard=CFPasteboardUnique-11c50e715b
types=(
"CorePasteboardFlavorType 0x4D5A0000",
"CorePasteboardFlavorType 0x4D5A0001",
"CorePasteboardFlavorType 0x75747874",
"NeXT plain ascii pasteboard type",
"CorePasteboardFlavorType 0x54455854",
"Apple CorePasteboard Fallback Text Script",
"CorePasteboardFlavorType 0x4D4F5A6D",
NSStringPboardType,
NSStringPboardType
)
op=Copy Link Generic Private Move Delete
*/
// NSDraggingDestination ///////////
- (unsigned int)draggingEntered:(id <NSDraggingInfo>)sender
@ -320,6 +335,9 @@
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
NSString *value = [[sender draggingPasteboard] stringForType:@"CorePasteboardFlavorType 0x4D4F5A6D"];
NSLog(@"*** DROP %s",[value cString]);
BookmarksService::CompleteBookmarkDrag([sender draggingPasteboard], BookmarksService::gToolbarRoot,
mDragInsertionButton ? [mDragInsertionButton element] : nil,
mDragInsertionPosition);

Просмотреть файл

@ -38,7 +38,9 @@ static const int kDividerTag = 4000;
// the maximum number of history entry menuitems to display
static const int kMaxItems = 15;
// the maximum number of characters in a menu title before cropping it
static const int kMaxTitleLength = 20;
static const unsigned int kMaxTitleLength = 60;
// the ellipsis string to insert into cropped strings
static const NSString *kEllipsis = @"...";
@implementation CHGoMenu
@ -132,8 +134,17 @@ static const int kMaxTitleLength = 20;
entry->GetTitle(&text);
NSString* title = [NSString stringWithCharacters: text length: nsCRT::strlen(text)];
// if the title is too long, crop it in the middle
if ([title length] > kMaxTitleLength) {
NSMutableString *croppedTitle = [NSMutableString stringWithCapacity:kMaxTitleLength+[kEllipsis length]];
int len1 = kMaxTitleLength/2;
int len2 = kMaxTitleLength - len1;
NSString *part1 = [title substringWithRange:NSMakeRange(0, len1)];
NSString *part2 = [title substringWithRange:NSMakeRange([title length]-len2, len2)];
[croppedTitle appendString:part1];
[croppedTitle appendString:kEllipsis];
[croppedTitle appendString:part2];
title = croppedTitle;
}
NSMenuItem *newItem = [self addItemWithTitle:title action:@selector(historyItemAction:) keyEquivalent:@""];

Просмотреть файл

@ -35,7 +35,7 @@
mButtons = [[NSMutableArray alloc] init];
mDragInsertionButton = nil;
mDragInsertionPosition = BookmarksService::CHInsertNone;
[self registerForDraggedTypes:[NSArray arrayWithObjects:@"MozURLType", @"MozBookmarkType", nil]];
[self registerForDraggedTypes:[NSArray arrayWithObjects:@"MozURLType", @"MozBookmarkType", NSStringPboardType, nil]];
}
return self;
}
@ -284,6 +284,21 @@
}
}
/*src=(null)
pasteboard=CFPasteboardUnique-11c50e715b
types=(
"CorePasteboardFlavorType 0x4D5A0000",
"CorePasteboardFlavorType 0x4D5A0001",
"CorePasteboardFlavorType 0x75747874",
"NeXT plain ascii pasteboard type",
"CorePasteboardFlavorType 0x54455854",
"Apple CorePasteboard Fallback Text Script",
"CorePasteboardFlavorType 0x4D4F5A6D",
NSStringPboardType,
NSStringPboardType
)
op=Copy Link Generic Private Move Delete
*/
// NSDraggingDestination ///////////
- (unsigned int)draggingEntered:(id <NSDraggingInfo>)sender
@ -320,6 +335,9 @@
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
NSString *value = [[sender draggingPasteboard] stringForType:@"CorePasteboardFlavorType 0x4D4F5A6D"];
NSLog(@"*** DROP %s",[value cString]);
BookmarksService::CompleteBookmarkDrag([sender draggingPasteboard], BookmarksService::gToolbarRoot,
mDragInsertionButton ? [mDragInsertionButton element] : nil,
mDragInsertionPosition);

Просмотреть файл

@ -38,7 +38,9 @@ static const int kDividerTag = 4000;
// the maximum number of history entry menuitems to display
static const int kMaxItems = 15;
// the maximum number of characters in a menu title before cropping it
static const int kMaxTitleLength = 20;
static const unsigned int kMaxTitleLength = 60;
// the ellipsis string to insert into cropped strings
static const NSString *kEllipsis = @"...";
@implementation CHGoMenu
@ -132,8 +134,17 @@ static const int kMaxTitleLength = 20;
entry->GetTitle(&text);
NSString* title = [NSString stringWithCharacters: text length: nsCRT::strlen(text)];
// if the title is too long, crop it in the middle
if ([title length] > kMaxTitleLength) {
NSMutableString *croppedTitle = [NSMutableString stringWithCapacity:kMaxTitleLength+[kEllipsis length]];
int len1 = kMaxTitleLength/2;
int len2 = kMaxTitleLength - len1;
NSString *part1 = [title substringWithRange:NSMakeRange(0, len1)];
NSString *part2 = [title substringWithRange:NSMakeRange([title length]-len2, len2)];
[croppedTitle appendString:part1];
[croppedTitle appendString:kEllipsis];
[croppedTitle appendString:part2];
title = croppedTitle;
}
NSMenuItem *newItem = [self addItemWithTitle:title action:@selector(historyItemAction:) keyEquivalent:@""];

Просмотреть файл

@ -35,7 +35,7 @@
mButtons = [[NSMutableArray alloc] init];
mDragInsertionButton = nil;
mDragInsertionPosition = BookmarksService::CHInsertNone;
[self registerForDraggedTypes:[NSArray arrayWithObjects:@"MozURLType", @"MozBookmarkType", nil]];
[self registerForDraggedTypes:[NSArray arrayWithObjects:@"MozURLType", @"MozBookmarkType", NSStringPboardType, nil]];
}
return self;
}
@ -284,6 +284,21 @@
}
}
/*src=(null)
pasteboard=CFPasteboardUnique-11c50e715b
types=(
"CorePasteboardFlavorType 0x4D5A0000",
"CorePasteboardFlavorType 0x4D5A0001",
"CorePasteboardFlavorType 0x75747874",
"NeXT plain ascii pasteboard type",
"CorePasteboardFlavorType 0x54455854",
"Apple CorePasteboard Fallback Text Script",
"CorePasteboardFlavorType 0x4D4F5A6D",
NSStringPboardType,
NSStringPboardType
)
op=Copy Link Generic Private Move Delete
*/
// NSDraggingDestination ///////////
- (unsigned int)draggingEntered:(id <NSDraggingInfo>)sender
@ -320,6 +335,9 @@
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
NSString *value = [[sender draggingPasteboard] stringForType:@"CorePasteboardFlavorType 0x4D4F5A6D"];
NSLog(@"*** DROP %s",[value cString]);
BookmarksService::CompleteBookmarkDrag([sender draggingPasteboard], BookmarksService::gToolbarRoot,
mDragInsertionButton ? [mDragInsertionButton element] : nil,
mDragInsertionPosition);

Просмотреть файл

@ -38,7 +38,9 @@ static const int kDividerTag = 4000;
// the maximum number of history entry menuitems to display
static const int kMaxItems = 15;
// the maximum number of characters in a menu title before cropping it
static const int kMaxTitleLength = 20;
static const unsigned int kMaxTitleLength = 60;
// the ellipsis string to insert into cropped strings
static const NSString *kEllipsis = @"...";
@implementation CHGoMenu
@ -132,8 +134,17 @@ static const int kMaxTitleLength = 20;
entry->GetTitle(&text);
NSString* title = [NSString stringWithCharacters: text length: nsCRT::strlen(text)];
// if the title is too long, crop it in the middle
if ([title length] > kMaxTitleLength) {
NSMutableString *croppedTitle = [NSMutableString stringWithCapacity:kMaxTitleLength+[kEllipsis length]];
int len1 = kMaxTitleLength/2;
int len2 = kMaxTitleLength - len1;
NSString *part1 = [title substringWithRange:NSMakeRange(0, len1)];
NSString *part2 = [title substringWithRange:NSMakeRange([title length]-len2, len2)];
[croppedTitle appendString:part1];
[croppedTitle appendString:kEllipsis];
[croppedTitle appendString:part2];
title = croppedTitle;
}
NSMenuItem *newItem = [self addItemWithTitle:title action:@selector(historyItemAction:) keyEquivalent:@""];