OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_UI_COCOA_INFOBARS_TRANSLATE_INFOBAR_BASE_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_INFOBARS_TRANSLATE_INFOBAR_BASE_H_ |
6 #define CHROME_BROWSER_UI_COCOA_INFOBARS_TRANSLATE_INFOBAR_BASE_H_ | 6 #define CHROME_BROWSER_UI_COCOA_INFOBARS_TRANSLATE_INFOBAR_BASE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #import <Cocoa/Cocoa.h> | 9 #import <Cocoa/Cocoa.h> |
10 | 10 |
11 #import "base/mac/cocoa_protocols.h" | 11 #import "base/mac/cocoa_protocols.h" |
12 #import "base/memory/scoped_nsobject.h" | 12 #import "base/memory/scoped_nsobject.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "chrome/browser/translate/languages_menu_model.h" | 14 #include "chrome/browser/translate/languages_menu_model.h" |
15 #include "chrome/browser/translate/options_menu_model.h" | 15 #include "chrome/browser/translate/options_menu_model.h" |
16 #include "chrome/browser/translate/translate_infobar_delegate.h" | 16 #include "chrome/browser/translate/translate_infobar_delegate.h" |
17 #import "chrome/browser/ui/cocoa/infobars/infobar_controller.h" | 17 #import "chrome/browser/ui/cocoa/infobars/infobar_controller.h" |
18 #include "chrome/common/translate_errors.h" | 18 #include "chrome/common/translate_errors.h" |
19 | 19 |
20 #pragma mark TranslateInfoBarUtilities helper functions. | |
21 namespace TranslateInfoBarUtilities { | |
22 | |
23 // Move the |toMove| view |spacing| pixels before/after the |anchor| view. | |
24 // |after| signifies the side of |anchor| on which to place |toMove|. | |
25 void MoveControl(NSView* anchor, NSView* toMove, int spacing, bool after); | |
26 | |
27 // Vertically center |toMove| in its container. | |
28 void VerticallyCenterView(NSView *toMove); | |
29 // Check that the control |before| is ordered visually before the |after| | |
30 // control. | |
31 // Also, check that there is space between them. | |
32 bool VerifyControlOrderAndSpacing(id before, id after); | |
33 | |
34 // Creates a label control in the style we need for the translate infobar's | |
35 // labels within |bounds|. | |
36 NSTextField* CreateLabel(NSRect bounds); | |
37 | |
38 // Adds an item with the specified properties to |menu|. | |
39 void AddMenuItem(NSMenu *menu, id target, SEL selector, NSString* title, | |
40 int tag, bool enabled, bool checked); | |
41 | |
42 } // namespace | |
43 | |
44 // The base class for the three translate infobars. This class does all of the | 20 // The base class for the three translate infobars. This class does all of the |
45 // heavy UI lifting, while deferring to the subclass to tell it what views | 21 // heavy UI lifting, while deferring to the subclass to tell it what views |
46 // should be shown and where. Subclasses need to implement: | 22 // should be shown and where. Subclasses need to implement: |
47 // - (void)layout; | 23 // - (void)layout; |
48 // - (void)loadLabelText; | 24 // - (void)loadLabelText; |
49 // - (void)visibleControls; | 25 // - (void)visibleControls; |
50 // - (bool)verifyLayout; // For testing. | 26 // - (bool)verifyLayout; // For testing. |
51 @interface TranslateInfoBarControllerBase : InfoBarController<NSMenuDelegate> { | 27 @interface TranslateInfoBarControllerBase : InfoBarController<NSMenuDelegate> { |
52 @protected | 28 @protected |
53 scoped_nsobject<NSTextField> label1_; | 29 scoped_nsobject<NSTextField> label1_; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 - (NSMenu*)optionsMenu; | 129 - (NSMenu*)optionsMenu; |
154 | 130 |
155 // Returns |translateMessageButton_|, see declaration of member | 131 // Returns |translateMessageButton_|, see declaration of member |
156 // variable for a full description. | 132 // variable for a full description. |
157 - (NSButton*)translateMessageButton; | 133 - (NSButton*)translateMessageButton; |
158 | 134 |
159 @end // TranslateInfoBarControllerBase (TestingAPI) | 135 @end // TranslateInfoBarControllerBase (TestingAPI) |
160 | 136 |
161 | 137 |
162 #endif // CHROME_BROWSER_UI_COCOA_INFOBARS_TRANSLATE_INFOBAR_BASE_H_ | 138 #endif // CHROME_BROWSER_UI_COCOA_INFOBARS_TRANSLATE_INFOBAR_BASE_H_ |
OLD | NEW |