diff options
author | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-21 21:42:46 +0000 |
---|---|---|
committer | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-21 21:42:46 +0000 |
commit | cd1b1db449f9bd1ea6d75bf38562e3a2e72106d9 (patch) | |
tree | 09591b0d16869ccccc5e2122aec6db2a07bb115b /chrome/browser/cocoa/about_window_controller.mm | |
parent | 3dc5eac55b0c9d69a3491296c34270d819506e2d (diff) | |
download | chromium_src-cd1b1db449f9bd1ea6d75bf38562e3a2e72106d9.zip chromium_src-cd1b1db449f9bd1ea6d75bf38562e3a2e72106d9.tar.gz chromium_src-cd1b1db449f9bd1ea6d75bf38562e3a2e72106d9.tar.bz2 |
Make links in the cocoa about dialog clickable. (Try #2).
Once again, we're changing the implementation from an NSTextField to an
NSTextView. The text is no longer editable, the margins have been fixed
to not be standard cocoa margins and the font is explicitly set to
Lucida Grande.
After talking with jrg, I think the text should be selectable.
BUG=20493
BUG=20855
Review URL: http://codereview.chromium.org/216028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26737 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/about_window_controller.mm')
-rw-r--r-- | chrome/browser/cocoa/about_window_controller.mm | 54 |
1 files changed, 44 insertions, 10 deletions
diff --git a/chrome/browser/cocoa/about_window_controller.mm b/chrome/browser/cocoa/about_window_controller.mm index 2dff4ed..f6fe70d 100644 --- a/chrome/browser/cocoa/about_window_controller.mm +++ b/chrome/browser/cocoa/about_window_controller.mm @@ -10,6 +10,7 @@ #include "base/string_util.h" #include "base/sys_string_conversions.h" #import "chrome/app/keystone_glue.h" +#include "chrome/browser/browser_list.h" #import "chrome/browser/cocoa/about_window_controller.h" #import "chrome/browser/cocoa/background_tile_view.h" #include "chrome/browser/cocoa/restart_browser.h" @@ -63,9 +64,14 @@ void AttributedStringAppendHyperlink(NSMutableAttributedString* attr_str, [attr_str addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInt:NSSingleUnderlineStyle] range:range]; + [attr_str addAttribute:NSCursorAttributeName + value:[NSCursor pointingHandCursor] + range:range]; } -NSAttributedString* BuildLegalTextBlock() { +} // namespace + +NSAttributedString* BuildAboutWindowLegalTextBlock() { // Windows builds this up in a very complex way, we're just trying to model // it the best we can to get all the information in (they actually do it // but created Labels and Links that they carefully place to make it appear @@ -162,7 +168,7 @@ NSAttributedString* BuildLegalTextBlock() { NSString* about_terms = base::SysWideToNSString(w_about_terms); NSString* terms_link_text = l10n_util::GetNSString(IDS_TERMS_OF_SERVICE); - AttributedStringAppendString(legal_block, @"\n"); + AttributedStringAppendString(legal_block, @"\n\n"); sub_str = [about_terms substringToIndex:url_offsets[0]]; AttributedStringAppendString(legal_block, sub_str); AttributedStringAppendHyperlink(legal_block, terms_link_text, kTOS); @@ -170,12 +176,17 @@ NSAttributedString* BuildLegalTextBlock() { AttributedStringAppendString(legal_block, sub_str); #endif // defined(GOOGLE_CHROME_BUILD) + // We need to explicitly select Lucida Grande because once we click on + // the NSTextView, it changes to Helvetica 12 otherwise. + NSRange string_range = NSMakeRange(0, [legal_block length]); + [legal_block addAttribute:NSFontAttributeName + value:[NSFont labelFontOfSize:11] + range:string_range]; + [legal_block endEditing]; return legal_block; } -} // namespace - @implementation AboutWindowController - (id)initWithWindowNibName:(NSString*)nibName { @@ -209,8 +220,22 @@ NSAttributedString* BuildLegalTextBlock() { DCHECK(logoImage); [logoView_ setImage:logoImage]; - // Put the legal text into - [legalBlock_ setAttributedStringValue:BuildLegalTextBlock()]; + [[legalText_ textStorage] + setAttributedString:BuildAboutWindowLegalTextBlock()]; + + // Resize our text view now so that the |updateShift| below is set + // correctly. The about box has its controls manually positioned, so we need + // to calculate how much larger (or smaller) our text box is and store that + // difference in |legalShift|. We do something similar with |updateShift| + // below, which is either 0, or the amount of space to offset the window size + // because the view that contains the update button has been removed because + // this build doesn't have KeyStone. + NSRect oldLegalRect = [legalBlock_ frame]; + [legalText_ sizeToFit]; + NSRect newRect = oldLegalRect; + newRect.size.height = [legalText_ frame].size.height; + [legalBlock_ setFrame:newRect]; + CGFloat legalShift = newRect.size.height - oldLegalRect.size.height; KeystoneGlue* keystone = [self defaultKeystoneGlue]; CGFloat updateShift = 0.0; @@ -228,10 +253,6 @@ NSAttributedString* BuildLegalTextBlock() { } // Adjust the sizes/locations. - - CGFloat legalShift = - [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:legalBlock_]; - NSRect rect = [legalBlock_ frame]; rect.origin.y -= updateShift; [legalBlock_ setFrame:rect]; @@ -380,6 +401,19 @@ NSAttributedString* BuildLegalTextBlock() { } } +- (BOOL)textView:(NSTextView *)aTextView + clickedOnLink:(id)link + atIndex:(NSUInteger)charIndex { + BrowserList::GetLastActive()-> + OpenURL(GURL([link UTF8String]), GURL(), NEW_WINDOW, + PageTransition::LINK); + return YES; +} + +- (NSTextView*)legalText { + return legalText_; +} + - (NSButton*)updateButton { return updateNowButton_; } |