OLD | NEW |
(Empty) | |
| 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 #ifndef CHROME_BROWSER_UI_GTK_TRANSLATE_TRANSLATE_INFOBAR_BASE_GTK_H_ |
| 6 #define CHROME_BROWSER_UI_GTK_TRANSLATE_TRANSLATE_INFOBAR_BASE_GTK_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "chrome/browser/translate/translate_infobar_view.h" |
| 10 #include "chrome/browser/gtk/infobar_gtk.h" |
| 11 #include "ui/base/animation/animation_delegate.h" |
| 12 |
| 13 class MenuGtk; |
| 14 class OptionsMenuModel; |
| 15 class TranslateInfoBarDelegate; |
| 16 |
| 17 // This class contains some of the base functionality that translate infobars |
| 18 // use. |
| 19 class TranslateInfoBarBase : public TranslateInfoBarView, |
| 20 public InfoBar, |
| 21 public ui::AnimationDelegate { |
| 22 public: |
| 23 explicit TranslateInfoBarBase(TranslateInfoBarDelegate* delegate); |
| 24 virtual ~TranslateInfoBarBase(); |
| 25 |
| 26 // Initializes the infobar widgets. Should be called after the object has been |
| 27 // created. |
| 28 virtual void Init(); |
| 29 |
| 30 // Overridden from InfoBar: |
| 31 virtual void GetTopColor(InfoBarDelegate::Type type, |
| 32 double* r, double* g, double *b); |
| 33 virtual void GetBottomColor(InfoBarDelegate::Type type, |
| 34 double* r, double* g, double *b); |
| 35 |
| 36 // Overridden from TranslateInfoBarView: |
| 37 virtual void OriginalLanguageChanged() {} |
| 38 virtual void TargetLanguageChanged() {} |
| 39 |
| 40 // Overridden from ui::AnimationDelegate: |
| 41 virtual void AnimationProgressed(const ui::Animation* animation); |
| 42 |
| 43 protected: |
| 44 // Sub-classes that want to have the options menu button showing sould |
| 45 // override and return true. |
| 46 virtual bool ShowOptionsMenuButton() const; |
| 47 |
| 48 // Creates a label with the appropriate font and color for the translate |
| 49 // infobars. |
| 50 GtkWidget* CreateLabel(const std::string& text); |
| 51 |
| 52 // Creates a combobox that displays the languages currently available. |
| 53 // |selected_language| is the language index (as used in the |
| 54 // TranslateInfoDelegate) that should be selected initially. |
| 55 // |exclude_language| is the language index of the language that should not be |
| 56 // included in the list (-1 means no language excluded). |
| 57 GtkWidget* CreateLanguageCombobox(int selected_language, |
| 58 int exclude_language); |
| 59 |
| 60 // Given an above-constructed combobox, returns the currently selected |
| 61 // language id. |
| 62 static int GetLanguageComboboxActiveId(GtkComboBox* combo); |
| 63 |
| 64 // Convenience to retrieve the TranslateInfoBarDelegate for this infobar. |
| 65 TranslateInfoBarDelegate* GetDelegate() const; |
| 66 |
| 67 private: |
| 68 // Builds a button with an arrow in it to emulate the menu-button style from |
| 69 // the windows version. |
| 70 static GtkWidget* BuildOptionsMenuButton(); |
| 71 |
| 72 // The menu displayed when the Options button is pressed. |
| 73 scoped_ptr<OptionsMenuModel> options_menu_model_; |
| 74 scoped_ptr<MenuGtk> options_menu_menu_; |
| 75 |
| 76 CHROMEGTK_CALLBACK_0(TranslateInfoBarBase, void, OnOptionsClicked); |
| 77 |
| 78 // A percentage to average the normal page action background with the error |
| 79 // background. When 0, the infobar background should be pure PAGE_ACTION_TYPE. |
| 80 // When 1, the infobar background should be pure WARNING_TYPE. |
| 81 double background_error_percent_; |
| 82 |
| 83 // Changes the color of the background from normal to error color and back. |
| 84 scoped_ptr<ui::SlideAnimation> background_color_animation_; |
| 85 |
| 86 DISALLOW_COPY_AND_ASSIGN(TranslateInfoBarBase); |
| 87 }; |
| 88 |
| 89 #endif // CHROME_BROWSER_UI_GTK_TRANSLATE_TRANSLATE_INFOBAR_BASE_GTK_H_ |
OLD | NEW |