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