Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: chrome/browser/cocoa/l10n_util.mm

Issue 2822026: Mac: First run bubble. (Closed)
Patch Set: '' Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/cocoa/l10n_util.h" 5 #import "chrome/browser/cocoa/l10n_util.h"
6 6
7 #include "base/string_util.h"
8 #include "base/sys_string_conversions.h"
7 #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" 9 #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h"
8 10
9 namespace cocoa_l10n_util { 11 namespace cocoa_l10n_util {
10 12
11 NSInteger CompareFrameY(id view1, id view2, void* context) { 13 NSInteger CompareFrameY(id view1, id view2, void* context) {
12 CGFloat y1 = NSMinY([view1 frame]); 14 CGFloat y1 = NSMinY([view1 frame]);
13 CGFloat y2 = NSMinY([view2 frame]); 15 CGFloat y2 = NSMinY([view2 frame]);
14 if (y1 < y2) 16 if (y1 < y2)
15 return NSOrderedAscending; 17 return NSOrderedAscending;
16 else if (y1 > y2) 18 else if (y1 > y2)
(...skipping 22 matching lines...) Expand all
39 // Decide it's a checkbox via showsStateBy and highlightsBy. 41 // Decide it's a checkbox via showsStateBy and highlightsBy.
40 if (([buttonCell showsStateBy] == NSCellState) && 42 if (([buttonCell showsStateBy] == NSCellState) &&
41 ([buttonCell highlightsBy] == NSCellState)) { 43 ([buttonCell highlightsBy] == NSCellState)) {
42 [GTMUILocalizerAndLayoutTweaker wrapButtonTitleForWidth:button]; 44 [GTMUILocalizerAndLayoutTweaker wrapButtonTitleForWidth:button];
43 return [GTMUILocalizerAndLayoutTweaker sizeToFitView:view]; 45 return [GTMUILocalizerAndLayoutTweaker sizeToFitView:view];
44 } 46 }
45 } 47 }
46 return [GTMUILocalizerAndLayoutTweaker sizeToFitView:view]; 48 return [GTMUILocalizerAndLayoutTweaker sizeToFitView:view];
47 } 49 }
48 50
51 CGFloat VerticallyReflowGroup(NSArray* views) {
52 views = [views sortedArrayUsingFunction:CompareFrameY
53 context:NULL];
54 CGFloat localVerticalShift = 0;
55 for (NSInteger index = [views count] - 1; index >= 0; --index) {
56 NSView* view = [views objectAtIndex:index];
57
58 NSSize delta = WrapOrSizeToFit(view);
59 localVerticalShift += delta.height;
60 if (localVerticalShift) {
61 NSPoint origin = [view frame].origin;
62 origin.y -= localVerticalShift;
63 [view setFrameOrigin:origin];
64 }
65 }
66 return localVerticalShift;
67 }
68
69 NSString* ReplaceNSStringPlaceholders(NSString* formatString,
70 const string16& a,
71 size_t* offset) {
72 return base::SysUTF16ToNSString(
73 ReplaceStringPlaceholders(base::SysNSStringToUTF16(formatString),
74 a,
75 offset));
76 }
77
49 } // namespace cocoa_l10n_util 78 } // namespace cocoa_l10n_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698