| OLD | NEW |
| 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 #include "chrome/browser/cocoa/translate/after_translate_infobar_controller.h" | 5 #include "chrome/browser/cocoa/translate/after_translate_infobar_controller.h" |
| 6 #include "base/sys_string_conversions.h" | 6 #include "base/sys_string_conversions.h" |
| 7 | 7 |
| 8 using TranslateInfoBarUtilities::MoveControl; | 8 using TranslateInfoBarUtilities::MoveControl; |
| 9 using TranslateInfoBarUtilities::VerifyControlOrderAndSpacing; |
| 9 | 10 |
| 10 @implementation AfterTranslateInfobarController | 11 @implementation AfterTranslateInfobarController |
| 11 | 12 |
| 12 - (void)loadLabelText { | 13 - (void)loadLabelText { |
| 13 std::vector<string16> strings; | 14 std::vector<string16> strings; |
| 14 TranslateInfoBarDelegate::GetAfterTranslateStrings( | 15 TranslateInfoBarDelegate::GetAfterTranslateStrings( |
| 15 &strings, &swappedLanugageButtons_); | 16 &strings, &swappedLanugageButtons_); |
| 16 DCHECK(strings.size() == 3U); | 17 DCHECK(strings.size() == 3U); |
| 17 NSString* string1 = base::SysUTF16ToNSString(strings[0]); | 18 NSString* string1 = base::SysUTF16ToNSString(strings[0]); |
| 18 NSString* string2 = base::SysUTF16ToNSString(strings[1]); | 19 NSString* string2 = base::SysUTF16ToNSString(strings[1]); |
| 19 NSString* string3 = base::SysUTF16ToNSString(strings[2]); | 20 NSString* string3 = base::SysUTF16ToNSString(strings[2]); |
| 20 | 21 |
| 21 [label1_ setStringValue:string1]; | 22 [label1_ setStringValue:string1]; |
| 22 [label2_ setStringValue:string2]; | 23 [label2_ setStringValue:string2]; |
| 23 [label3_ setStringValue:string3]; | 24 [label3_ setStringValue:string3]; |
| 24 } | 25 } |
| 25 | 26 |
| 26 - (void)layout { | 27 - (void)layout { |
| 27 [self removeOkCancelButtons]; | 28 [self removeOkCancelButtons]; |
| 28 [optionsPopUp_ setHidden:NO]; | 29 [optionsPopUp_ setHidden:NO]; |
| 29 NSView* firstPopup = fromLanguagePopUp_; | 30 NSView* firstPopup = fromLanguagePopUp_; |
| 30 NSView* lastPopup = toLanguagePopUp_; | 31 NSView* lastPopup = toLanguagePopUp_; |
| 31 if (swappedLanugageButtons_) { | 32 if (swappedLanugageButtons_) { |
| 32 firstPopup = toLanguagePopUp_; | 33 firstPopup = toLanguagePopUp_; |
| 33 lastPopup = fromLanguagePopUp_; | 34 lastPopup = fromLanguagePopUp_; |
| 34 } | 35 } |
| 35 NSView* lastControl = lastPopup; | 36 NSView* lastControl = lastPopup; |
| 36 | 37 |
| 37 MoveControl(label1_, firstPopup, 0, true); | 38 MoveControl(label1_, firstPopup, spaceBetweenControls_ / 2, true); |
| 38 MoveControl(firstPopup, label2_, 0, true); | 39 MoveControl(firstPopup, label2_, spaceBetweenControls_ / 2, true); |
| 39 MoveControl(label2_, lastPopup, 0, true); | 40 MoveControl(label2_, lastPopup, spaceBetweenControls_ / 2, true); |
| 40 MoveControl(lastPopup, label3_, 0, true); | 41 MoveControl(lastPopup, label3_, 0, true); |
| 41 lastControl = label3_; | 42 lastControl = label3_; |
| 42 | 43 |
| 43 MoveControl(lastControl, showOriginalButton_, spaceBetweenControls_ * 2, | 44 MoveControl(lastControl, showOriginalButton_, spaceBetweenControls_ * 2, |
| 44 true); | 45 true); |
| 45 } | 46 } |
| 46 | 47 |
| 47 - (NSArray*)visibleControls { | 48 - (NSArray*)visibleControls { |
| 48 return [NSArray arrayWithObjects:label1_.get(), fromLanguagePopUp_.get(), | 49 return [NSArray arrayWithObjects:label1_.get(), fromLanguagePopUp_.get(), |
| 49 label2_.get(), toLanguagePopUp_.get(), label3_.get(), | 50 label2_.get(), toLanguagePopUp_.get(), label3_.get(), |
| 50 showOriginalButton_.get(), nil]; | 51 showOriginalButton_.get(), nil]; |
| 51 } | 52 } |
| 52 | 53 |
| 53 - (bool)verifyLayout { | 54 - (bool)verifyLayout { |
| 54 if ([optionsPopUp_ isHidden]) | 55 if ([optionsPopUp_ isHidden]) |
| 55 return false; | 56 return false; |
| 56 return [super verifyLayout]; | 57 return [super verifyLayout]; |
| 57 } | 58 } |
| 58 | 59 |
| 59 @end | 60 @end |
| OLD | NEW |